"use strict";function _createForOfIteratorHelper(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=_unsupportedIterableToArray(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0,o=function(){};return{s:o,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,l=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return a=e.done,e},e:function(e){l=!0,i=e},f:function(){try{a||null==r.return||r.return()}finally{if(l)throw i}}}}function _unsupportedIterableToArray(e,t){if(e){if("string"==typeof e)return _arrayLikeToArray(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?_arrayLikeToArray(e,t):void 0}}function _arrayLikeToArray(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function set_wms_mondial_relay_pickup_modal(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"wms_pickup_open_modal_mondial_relay",t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",r=document.getElementsByClassName(e);if(0!==r.length){var n,o=_createForOfIteratorHelper(r);try{for(o.s();!(n=o.n()).done;){var i=n.value;null==i.getAttribute("wms-backbone-set")&&(i.addEventListener("click",function(e){e.preventDefault(),jQuery(this).WCBackboneModal({template:0<t.length?t:this.getAttribute("wms-pickup-modal-id")}),modal=document.getElementById(0<t.length?t:this.getAttribute("wms-pickup-modal-id")),loader=modal.querySelector(".wc-backbone-modal-loader"),init_mondial_relay_map()}),i.setAttribute("wms-backbone-set",!0))}}catch(e){o.e(e)}finally{o.f()}}}function init_mondial_relay_map(){var e,t,r,n,o,i,a="75001",l=document.getElementById("billing_postcode"),u=document.getElementById("shipping_postcode");null!==l&&(a=l.value),null!==u&&(a=u.value);var c=document.getElementById("billing_country"),s=document.getElementById("shipping_country");null!==c&&c.value,null!==s&&s.value,jQuery(".wms_pickup_modal_map").MR_ParcelShopPicker({Target:"#wms_pickup_point",TargetDisplayInfoPR:"#wms_pickup_selected",Brand:"CC21X9MZ",Country:"FR",PostCode:a,Responsive:!0,NbResults:19,OnParcelShopSelected:function(a){e=a.ID,t=a.Nom,r=a.Adresse1,n=a.CP,o=a.Ville,i=a.Pays}}),jQuery("#wms_select_point").on("click",function(){if(null!=t){var a=[t,r,o+" "+n,i],l=jQuery("#wms_ajax_error"),u=jQuery("#wms_pickup_selected"),c=jQuery("#wms_nonce").val();confirm(sprintf(__("Merci de confirmer votre choix: %s","wc-multishipping"),"\n\n"+a.join("\n")))&&jQuery.ajax({url:wmsajaxurl,type:"POST",dataType:"json",data:{action:"wms_select_pickup_point",pickup_id:e,pickup_name:t,pickup_address:r,pickup_zipcode:n,pickup_city:o,pickup_country:i,wms_nonce:c},beforeSend:function(){l.hide()},success:function(e){if(!1===e.error){u.html("<div>"+a.join("</div><div>")+"</div>"),jQuery("#wms_pickup_info").innerText=JSON.stringify(a),modal.querySelector(".modal-close").click();var t,r=_createForOfIteratorHelper(jQuery(".wc-block-components-shipping-address"));try{for(r.s();!(t=r.n()).done;){var n=t.value;-1!=jQuery(n).html().indexOf("Livraison à")&&jQuery(n).html("Livraison à : "+a.join("\n"))}}catch(e){r.e(e)}finally{r.f()}jQuery("body").trigger("update_checkout")}else l.html(e.error_message),l.show()}})}else modal.querySelector(".modal-close").click()})}jQuery(function(e){e(document.body).on("updated_shipping_method",function(){set_wms_mondial_relay_pickup_modal()}).on("updated_wc_div",function(){set_wms_mondial_relay_pickup_modal()}).on("updated_checkout",function(){set_wms_mondial_relay_pickup_modal()}),set_wms_mondial_relay_pickup_modal()});