(()=>{const t=window.__jsDHLPolskaShippingLogo||{},o=(t,o)=>{if(!Array.isArray(t))return null;const e=t.find(t=>t&&t.key===o);return e?e.value:null},e=t=>{const e=(t=>{if(!t)return null;if("string"!=typeof t)return t;try{return JSON.parse(t)}catch(o){return t}})(o(t?.meta_data,"_fs_method"));return e&&"object"==typeof e?e:null},n=()=>{if(!t.logo_url)return;if(!window.wp||!window.wp.data||"function"!=typeof window.wp.data.select)return;const n=window.wp.data.select("wc/store/cart");if(!n||"function"!=typeof n.getCartData)return;const r=(t=>{if(!t||!Array.isArray(t.shippingRates))return[];const o=[];return t.shippingRates.forEach(t=>{var e;(null!==(e=t?.shipping_rates)&&void 0!==e?e:[]).forEach(t=>o.push(t))}),o})(n.getCartData());r.length&&r.forEach(n=>{if(!(o=>{if(!o)return!1;const n=(r=t.method_ids,Array.isArray(r)?r:[]);var r;if(o.method_id&&n.includes(o.method_id))return!0;const a=e(o);return!(!a||!t.integration_id||(a.method_integration||a.integration_id||"")!==t.integration_id)})(n)||!(t=>{if(!t||!Array.isArray(t.meta_data))return!1;const n=e(t);let r=null;if(n&&(Object.prototype.hasOwnProperty.call(n,"show_logo")?r=n.show_logo:Object.prototype.hasOwnProperty.call(n,"dhl_polska_show_logo")&&(r=n.dhl_polska_show_logo)),null===r){const e=o(t.meta_data,"dhl_polska_show_logo");null!==e&&(r=e)}if(null===r){const e=o(t.meta_data,"show_logo");null!==e&&(r=e)}return null!==r&&(t=>{if("boolean"==typeof t)return t;if("number"==typeof t)return 1===t;const o=(t||"").toString().trim().toLowerCase();return["yes","true","1","t"].includes(o)})(r)})(n))return;const r=(t=>t?.rate_id||t?.id||"")(n),a=(t=>{if(!t)return null;const o=`.wc-block-components-radio-control__option input[value="${e=t,window.CSS&&"function"==typeof window.CSS.escape?window.CSS.escape(e):e.replace(/["\\]/g,"\\$&")}"]`;var e;const n=document.querySelector(o);return n?n.closest(".wc-block-components-radio-control__option"):null})(r);if(!a)return;const i=a.querySelector("label")||a;i.querySelector(".dhl-polska-shipping-logo")||i.appendChild((()=>{const o=document.createElement("span");o.classList.add("dhl-polska-shipping-logo"),o.style.display="block",o.style.marginTop="6px";const e=document.createElement("img");return e.src=t.logo_url,e.alt=t.logo_alt||"",e.style.maxWidth="120px",e.style.height="auto",e.loading="lazy",o.appendChild(e),o})())})},r=()=>{t.logo_url&&(()=>{let t=!1;const o=()=>{t||(t=!0,window.requestAnimationFrame(()=>{t=!1,n()}))};window.wp&&window.wp.data&&"function"==typeof window.wp.data.subscribe&&window.wp.data.subscribe(o),new MutationObserver(o).observe(document.body,{childList:!0,subtree:!0}),o()})()};"loading"===document.readyState?document.addEventListener("DOMContentLoaded",r):r()})();