import{r as t,h as o,c as n}from"./p-083180bf.js";import{b as r,k as e,i as s,f as a,n as i}from"./p-a7fc1e02.js";import{_ as d}from"./p-d0993bb9.js";import{g as l}from"./p-9ec99ced.js";import{p as c}from"./p-8d363802.js";const u=r("sq:useRouter");function p(t,o){if(t)return c(t).exec(o)}const v=class{constructor(o){t(this,o),this.ignored=!0,i(this)}disconnectedCallback(){}render(){const{callbacks:t}=function(t){const o=d(),[n,r]=e(void 0),[i,l]=e(void 0),c=s(t.contextName);return a((()=>{const t=o.querySelectorAll("sqm-route");Array.from(t).forEach((t=>{const o=document.createElement("template");o.setAttribute("path",t.path),o.innerHTML=t.innerHTML,t.parentNode.appendChild(o),t.parentNode.removeChild(t)}))}),[]),a((()=>{var t,o;if(!i||!n)return void u("DOM not ready for navigation rendering on:",c);const r=n.querySelectorAll("template"),e=Array.from(r).find((t=>{var o,n,r;if(null===(r=p(null===(n=null===(o=t.attributes)||void 0===o?void 0:o.path)||void 0===n?void 0:n.nodeValue,c))||void 0===r?void 0:r.length)return t})),s=null===(o=null===(t=null==e?void 0:e.attributes)||void 0===t?void 0:t.path)||void 0===o?void 0:o.nodeValue;if(u({containerDatasetPage:i.dataset.page,templatePath:s,page:c}),!e)return u("No matching page found for ",c,", so render nothing"),i.innerHTML="",void(i.dataset.page=c);u("Page updated to ",c,e),p(s,i.dataset.page)?u("don't rerender"):e&&(i.innerHTML=e.innerHTML,i.dataset.page=c)}),[n,i,c]),{callbacks:{setSlot:r,setContainer:l}}}(l(this));return o(n,null,o("div",{ref:t.setSlot,style:{display:"none"}},o("slot",null)),o("div",{style:{display:"contents"},ref:t.setContainer}))}};v.style="sqm-router{display:contents}";export{v as sqm_context_router}