function fetchWithTimeout(e,t={},n=5e3){const o=new AbortController,r=o.signal,c=setTimeout(()=>o.abort(),n);return fetch(e,{...t,signal:r}).then(e=>(clearTimeout(c),e)).catch(e=>{if(clearTimeout(c),"AbortError"===e.name)throw new Error("Request timed out");throw e})}function cmsNest(){const e=[];document.querySelectorAll("[data-cms-nest^='item']").forEach(t=>{const n=t.querySelector("[data-cms-nest='link']");if(!n)return void console.warn("CMS Nest: Link not found",t);const o=n.getAttribute("href");if(!o)return void console.warn("CMS Nest: Href attribute not found",n);try{const r=new URL(o,window.location.origin);if(r.hostname!==window.location.hostname)return void console.warn("CMS Nest: URL is not on the same domain",r);const c=fetchWithTimeout(o,{},5e3).then(e=>e.text()).then(n=>{const o=new DOMParser().parseFromString(n,"text/html");let c=1;for(;;){const n=t.querySelector(`[data-cms-nest='dropzone-${c}']`);if(!n)break;const s=o.querySelector(`[data-cms-nest='target-${c}']`);s?(n.innerHTML="",n.appendChild(s)):console.warn(`CMS Nest: Target-${c} not found in fetched content`,r),c++}}).catch(e=>{console.error("CMS Nest: Error fetching the link or request timed out:",e)});e.push(c)}catch(e){console.error("CMS Nest: Invalid URL",o,e)}}),Promise.all(e).then(()=>{const e=new CustomEvent("cmsNestComplete");window.dispatchEvent(e)}).catch(e=>{console.error("CMS Nest: One or more fetch requests failed",e)})}document.addEventListener("DOMContentLoaded",()=>cmsNest());