(()=>{"use strict";const e=function(e){const t=[];class n extends HTMLElement{connectedCallback(){this.post_id&&this.block_id&&(void 0===t[this.delayed]&&(t[this.delayed]={parsing:!1,elements:[]}),t[this.delayed].elements.push(this))}get post_id(){return this.getAttribute("post-id")}get block_id(){return this.getAttribute("block-id")}get delayed(){let e=this.getAttribute("delayed");return e?Number(e):0}get lifetime(){let e=this.getAttribute("lifetime");return e?Number(e):0}}async function o(){const{getBlocks:e}=PersonalizeWP,{nodeScriptReplace:n}=PersonalizeWP.utils;Object.keys(t).forEach(function(i){if(t[i].parsing)return;t[i].parsing=!0;const s=t[i].elements;let c=[];for(let e of s){const{post_id:t,block_id:n}=e;c.push({...t&&{post_id:t},...n&&{block_id:n}})}c.length?e(c,"v1/blocks").then(e=>{if(!Array.isArray(e))throw"No blocks to parse";const c=[];e.forEach(function(e){const t=s.shift();e?c.push([t,e]):t.remove()}),c.length&&setTimeout(function(){c.forEach(function(e){const t=e[0].parentNode;let o=document.createElement("div");if(o.innerHTML=e[1],o=n(o),e[0].lifetime){const t=1e3*e[0].lifetime,n=o.childNodes;for(const e of n)setTimeout(function(){e.remove()},t)}e[0].replaceWith(...o.childNodes);const i=new CustomEvent("PWP:parsePlaceholder",{bubbles:!0,cancelable:!0,detail:{container:t}});t.dispatchEvent(i)}),document.dispatchEvent(new CustomEvent("DOMContentLoaded"));const e=new CustomEvent("PWP:parsedPlaceholders",{bubbles:!0,cancelable:!0});document.dispatchEvent(e),o()},1e3*i),t[i].parsing=!1}).catch(e=>{console.log(e)}):t[i].parsing=!1})}return window.customElements.define("wp-dxp",n),e.ready=function(){o()},e.readyInit=function(){window.PersonalizeWP&&PersonalizeWP.module("wp-dxp",this)},e}({});var t;t=e,"loading"===document.readyState?document.addEventListener("DOMContentLoaded",()=>{t.readyInit()},{once:!0}):t.readyInit()})();