jQuery((function(o){function t(t){o(t).block({message:null,overlayCSS:{background:"#fff",opacity:.6}})}_dropp.location_selected;var n=!1;function e(t,e,r){if("undefined"==typeof chooseDroppLocation)return o(".dropp-error").show().text(_dropp.i18n.error_loading),void o(".dropp-location__button").hide();n||(n=!0,chooseDroppLocation().then((function(n){if(n){if(!n.id)return o(".dropp-error").show().text(_dropp.i18n.error_loading),void o(".dropp-location__button").hide();e.text(n.name).show(),o.post(_dropp.ajaxurl,{action:"dropp_set_location",instance_id:t,location_id:n.id,location_name:n.name,location_address:n.address,location_pricetype:n.pricetype},r)}})).finally((function(){return n=!1})))}var r=void 0;function c(){return r||(externalJsAdded=!0,(r=document.createElement("script")).src=_dropp.dropplocationsurl,r.dataset.storeId=_dropp.storeid,setTimeout((function(){return document.body.appendChild(r)}),10),r)}function i(t){e(t,o(".dropp-location__name"),(function(){window.location.reload()}))}function p(t,n){if(!t.length)return o();var e=t.next();return e.length&&e.hasClass("dropp-location")||(e=o(_dropp.location_picker),t.after(e),e.find(".button").on("click",(function(o){o.preventDefault(),i(n)})),e[0].addEventListener("dropp-choose",(function(o){o.preventDefault(),i(n)}))),e}function d(){for(var o=function(){if(!window.wc||!window.wp)return[];var o=wc.wcBlocksData.CART_STORE_KEY;return wp.data.select(o).getShippingRates()}(),t=[],n=0;n<o.length;n++){var e=o[n].shipping_rates;t=t.concat(e)}return t}function a(){var t=d(),n=t.filter((function(o){return o.selected})),e=n.filter((function(o){return"dropp_is"===o.method_id||"dropp_is_oca"===o.method_id}));if(e.length)for(var r=0;r<e.length;r++){var c=e[r],i=void 0;if(!(i=1===t.length?o(".wc-block-components-shipping-rates-control .wc-block-components-radio-control__label-group"):o('[value="'+c.rate_id+'"]').closest(".wc-block-components-radio-control__option")).length)return;p(i,c.instance_id).show()}}function l(t){if(o(".dropp-location").hide(),t.shippingRateId){var n=t.shippingRateId.split(":");"dropp_is"!==n[0]&&"dropp_is_oca"!==n[0]||a()}}function s(t){t.preventDefault();var n=o("form.checkout"),r=o(this).closest(".dropp-location");e(r.data("instance_id"),r.find(".dropp-location__name"),(function(){return n.trigger("update_checkout")}))}function u(){o(".dropp-location").show(),o(".dropp-error").hide(),o("#shipping_method").unblock()}if(document.querySelector(".wp-block-woocommerce-checkout")){if(!window.wp||!wp.hooks)return;c(),wp.hooks.addAction("woocommerce_blocks-checkout-set-selected-shipping-rate","dropp-for-woocommerce",l),wp.hooks.addAction("experimental__woocommerce_blocks-checkout-set-selected-shipping-rate","dropp-for-woocommerce",l);var _=setInterval((function(){var t=o(".wc-block-components-shipping-rates-control");t.length&&t.find(".wc-block-components-radio-control__option, .wc-block-components-radio-control__label-group").length&&(clearInterval(_),a())}),50)}else{var f=!1;t("#shipping_method"),c().onload=function(){u(),f=!0},o(document).on("updated_checkout",(function(){return f?u():t("#shipping_method")})),o(document).on("click",".dropp-location__button",s),document.addEventListener("dropp-choose",(function(t){s.call(o(t.target).closest(".dropp-location")[0],t)}))}}));