(()=>{const t=window.__jsDHLPolskaShippingLogo||{},o=Object.prototype.hasOwnProperty,e=(t,o)=>{if(!Array.isArray(t))return null;const e=t.find(t=>t&&t.key===o);return e?e.value:null},n=t=>{const o=(t=>{if(!t)return null;if("string"!=typeof t)return t;try{return JSON.parse(t)}catch(o){return t}})(e(t?.meta_data,"_fs_method"));return o&&"object"==typeof o?o:null},r=()=>{const o=t.logo_variants;return o&&"object"==typeof o&&!Array.isArray(o)?o:t.logo_url?{default:t.logo_url}:{}},a=()=>{const e=r(),n=(t.default_logo_variant||"").toString().trim();if(n&&o.call(e,n))return n;const a=Object.keys(e);return a.length?a[0]:""},l=t=>{const e=r(),n=(t||"").toString().trim();return n&&o.call(e,n)?n:a()},i=()=>{const i=r();if(!Object.keys(i).length)return;if(!window.wp||!window.wp.data||"function"!=typeof window.wp.data.select)return;const s=window.wp.data.select("wc/store/cart");if(!s||"function"!=typeof s.getCartData)return;const c=(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})(s.getCartData());c.length&&c.forEach(i=>{if(!(o=>{if(!o)return!1;const e=(r=t.method_ids,Array.isArray(r)?r:[]);var r;if(o.method_id&&e.includes(o.method_id))return!0;const a=n(o);return!(!a||!t.integration_id||(a.method_integration||a.integration_id||"")!==t.integration_id)})(i)||!(t=>{if(!t||!Array.isArray(t.meta_data))return!1;const o=n(t);let r=null;if(o&&(Object.prototype.hasOwnProperty.call(o,"show_logo")?r=o.show_logo:Object.prototype.hasOwnProperty.call(o,"dhl_polska_show_logo")&&(r=o.dhl_polska_show_logo)),null===r){const o=e(t.meta_data,"dhl_polska_show_logo");null!==o&&(r=o)}if(null===r){const o=e(t.meta_data,"show_logo");null!==o&&(r=o)}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)})(i))return;const s=(t=>t?.rate_id||t?.id||"")(i),c=(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})(s);if(!c)return;const u=c.querySelector("label")||c;if(u.querySelector(".dhl-polska-shipping-logo"))return;const d=(t=>{if(!t||!Array.isArray(t.meta_data))return a();const o=n(t);let r=null;if(o&&(Object.prototype.hasOwnProperty.call(o,"logo_variant")?r=o.logo_variant:Object.prototype.hasOwnProperty.call(o,"dhl_polska_logo_variant")&&(r=o.dhl_polska_logo_variant)),null===r){const o=e(t.meta_data,"dhl_polska_logo_variant");null!==o&&(r=o)}if(null===r){const o=e(t.meta_data,"logo_variant");null!==o&&(r=o)}return l(r)})(i),p=(t=>{const e=r(),n=l(t);return n&&o.call(e,n)?e[n]:""})(d);p&&u.appendChild((o=>{const e=document.createElement("span");e.classList.add("dhl-polska-shipping-logo"),e.style.display="block",e.style.marginTop="6px";const n=document.createElement("img");return n.src=o,n.alt=t.logo_alt||"",n.style.maxHeight="40px",n.style.width="auto",n.loading="lazy",e.appendChild(n),e})(p))})},s=()=>{Object.keys(r()).length&&(()=>{let t=!1;const o=()=>{t||(t=!0,window.requestAnimationFrame(()=>{t=!1,i()}))};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",s):s()})();