!function(){var e,t;window.shiptastic=window.shiptastic||{},window.shiptastic.admin=window.shiptastic.admin||{},e=jQuery,(t=window.shiptastic.admin).dhl_post_label={params:{},init:function(){var a=t.dhl_post_label;a.params=wc_shiptastic_dhl_admin_deutsche_post_label_params,e(document.body).on("wc_shiptastic_admin_shipment_modal_after_load_success",a.onLoadLabelModal)},onLoadLabelModal:function(a,i,d){var c=t.dhl_post_label;if(d.$modal.off("change.stc-dp-fields"),d.$modal.on("change.stc-dp-fields","#wc-stc-shipment-label-admin-fields-deutsche_post #product_id",{adminShipmentModal:d},c.onChangeProduct),d.$modal.on("change.stc-dp-fields","#wc-stc-shipment-label-admin-fields-deutsche_post #product_id, #wc-stc-shipment-label-admin-fields-deutsche_post #wc-stc-shipment-label-wrapper-additional-services :input",{adminShipmentModal:d},c.onRefreshPreview),d.$modal.find("#wc-stc-shipment-label-admin-fields-deutsche_post").length>0){var s=new e.Event("change");s.data={adminShipmentModal:d},c.onRefreshPreview(s)}},getSelectedAdditionalServices:function(){return e("#wc-stc-shipment-label-wrapper-additional-services :input:checked").map((function(){return e(this).attr("name").replace("service_","")})).get()},onChangeProduct:function(t){e("#wc-stc-shipment-label-wrapper-additional-services :input:checked").prop("checked",!1)},onRefreshPreview:function(e){var a=t.dhl_post_label,i=e.data.adminShipmentModal,d={};d.security=a.params.refresh_label_preview_nonce,d.product_id=a.getProductId(),d.selected_services=a.getSelectedAdditionalServices(),d.action="woocommerce_stc_dhl_refresh_deutsche_post_label_preview",i.doAjax(d,a.onPreviewSuccess)},onPreviewSuccess:function(a){var i=t.dhl_post_label,d=e(".wc-stc-dhl-im-product-data .col-preview"),c=e(".wc-stc-dhl-im-product-data").find(".image-preview");a.preview_url?(d.block({message:null,overlayCSS:{background:"#fff",opacity:.6}}),c.find(".stamp-preview").length<=0&&c.append('<img class="stamp-preview" style="display: none;" />'),i.replaceProductData(a.preview_data),c.find(".stamp-preview").prop("src",a.preview_url).on("load",(function(){d.unblock(),e(this).show()}))):(c.html(""),i.replaceProductData({}))},getProductId:function(){return e("#wc-stc-shipment-label-admin-fields-deutsche_post #product_id").val()},replaceProductData:function(a){t.dhl_post_label;var i=e(".wc-stc-shipment-create-label").find(".wc-stc-dhl-im-product-data");i.find(".data-placeholder").html(""),i.find(".data-placeholder").each((function(){var t=e(this).data("replace");a.hasOwnProperty(t)?(e(this).html(a[t]),e(this).show()):e(this).hide()}))}},e(document).ready((function(){shiptastic.admin.dhl_post_label.init()})),((window.wcShiptastic=window.wcShiptastic||{}).static=window.wcShiptastic.static||{})["admin-deutsche-post-label"]={}}();