@webjsdev/core 0.7.2 → 0.7.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
function Tn(e,...t){return{_$webjs:"template",strings:e,values:t}}function _(e){return!!e&&typeof e=="object"&&e._$webjs==="template"}var m="w$";function xn(e,...t){let n=e[0];for(let r=1;r<e.length;r++)n+=String(t[r-1]??"")+e[r];return{_$webjsCss:!0,text:n}}function Te(e){return!!e&&typeof e=="object"&&e._$webjsCss===!0}function xe(e,t){if(!(!t||!t.length))if("adoptedStyleSheets"in e&&typeof CSSStyleSheet<"u"){let n=t.map(r=>{let s=new CSSStyleSheet;return s.replaceSync(r.text),s});e.adoptedStyleSheets=n}else{let n=e,r=document.createElement("style");r.textContent=t.map(s=>s.text).join(`
|
|
2
2
|
`),n.appendChild(r)}}function Rn(e){return!e||!e.length?"":`<style>${e.map(t=>t.text).join(`
|
|
3
|
-
`)}</style>`}function On(e){return String(e).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}function jn(e){return String(e).replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<")}var _t=Symbol.for("webjs.repeat");function Ln(e,t,n){return{[_t]:!0,items:[...e],keyFn:t,templateFn:n}}function Re(e){return!!e&&typeof e=="object"&&e[_t]===!0}function Mn(e){return{_$webjs:"unsafe-html",value:String(e??"")}}function Oe(e){return!!e&&typeof e=="object"&&e._$webjs==="unsafe-html"}function Pn(e){return{_$webjs:"live",value:e}}function je(e){return!!e&&typeof e=="object"&&e._$webjs==="live"}function Le(e){return!!e&&typeof e=="object"&&e._$webjs==="keyed"}function Me(e){return!!e&&typeof e=="object"&&e._$webjs==="guard"}function wt(e){return!!e&&typeof e=="object"&&e._$webjs==="template-content"}function Pe(e){return!!e&&typeof e=="object"&&e._$webjs==="ref"}function Ie(e){return!!e&&typeof e=="object"&&e._$webjs==="cache"}function Be(e){return!!e&&typeof e=="object"&&e._$webjs==="until"}function St(e){return!!e&&typeof e=="object"&&e._$webjs==="async-append"}function At(e){return!!e&&typeof e=="object"&&e._$webjs==="async-replace"}function Fe(e){return!!e&&typeof e=="object"&&e._$webjs==="watch"}var C=null,T=!1,V=0,H=null,Ue=0,Ct=(e,t)=>Object.is(e,t),ae=()=>{},vt=()=>!1;function Nt(e,t){e.liveConsumers||(e.liveConsumers=new Set);let n=e.liveConsumers.size===0;if(e.liveConsumers.add(t),n){if(e.producers&&e.producers.length>0)for(let r of e.producers)Nt(r,e);if(e.watched)try{e.watched.call(e.wrapper)}catch(r){console.error(r)}}}function z(e,t){if(e.liveConsumers&&(e.liveConsumers.delete(t),e.liveConsumers.size===0)){if(e.producers&&e.producers.length>0)for(let n of e.producers)z(n,e);if(e.unwatched)try{e.unwatched.call(e.wrapper)}catch(n){console.error(n)}}}function We(e){if(T)throw new Error("Signal read during notification phase");if(C===null)return;let t=C,n=t.nextProducerIndex++;n<t.producers.length&&t.producers[n]!==e&&qe(t)&&z(t.producers[n],t),t.producers[n]!==e&&(t.producers[n]=e,qe(t)&&Nt(e,t)),t.producerLastReadVersions[n]=e.version}function qe(e){return e.consumerIsAlwaysLive||e.liveConsumers&&e.liveConsumers.size>0}function kt(e){if(!e.liveConsumers||e.liveConsumers.size===0)return;let t=T;T=!0;try{for(let n of e.liveConsumers)n.dirty||In(n)}finally{T=t}}function In(e){e.dirty=!0,kt(e),e.consumerMarkedDirty.call(e.wrapper||e)}function le(e){if(!(!e.dirty&&e.lastCleanEpoch===V)){if(!e.producerMustRecompute()&&!Bn(e)){e.dirty=!1,e.lastCleanEpoch=V;return}e.producerRecomputeValue(),e.dirty=!1,e.lastCleanEpoch=V}}function Bn(e){for(let t=0;t<e.producers.length;t++){let n=e.producers[t],r=e.producerLastReadVersions[t];if(r!==n.version||(le(n),r!==n.version))return!0}return!1}function He(e){e&&(e.nextProducerIndex=0);let t=C;return C=e,t}function Ve(e,t){if(C=t,!!e){if(qe(e))for(let n=e.nextProducerIndex;n<e.producers.length;n++)z(e.producers[n],e);for(;e.producers.length>e.nextProducerIndex;)e.producers.pop(),e.producerLastReadVersions.pop()}}var ue=class{constructor(t,n){this.__value=t,this.version=0,this.lastCleanEpoch=V,this.dirty=!1,this.producers=[],this.producerLastReadVersions=[],this.liveConsumers=void 0,this.consumerAllowSignalWrites=!0,this.consumerIsAlwaysLive=!1,this.producerMustRecompute=vt,this.producerRecomputeValue=ae,this.consumerMarkedDirty=ae,this.wrapper=this,this.__isSignal=!0,this.__equal=n?.equals||Ct,this.watched=n?.[ze],this.unwatched=n?.[Ke]}get(){return We(this),this.__value}peek(){return this.__value}set(t){if(T)throw new Error("Signal write during notification phase");this.__equal.call(this,this.__value,t)||(this.__value=t,this.version++,V++,H!==null?Et(this):kt(this))}};function Et(e){let t=T;T=!0;try{if(!e.liveConsumers)return;for(let n of e.liveConsumers)n.dirty||(n.dirty=!0,n.__isWatcher?H.add(n):Et(n))}finally{T=t}}var $e=Symbol("unset"),De=Symbol("computing"),ce=Symbol("errored"),K=class{constructor(t,n){this.__fn=t,this.__value=$e,this.__error=null,this.version=0,this.lastCleanEpoch=-1,this.dirty=!0,this.producers=[],this.producerLastReadVersions=[],this.nextProducerIndex=0,this.liveConsumers=void 0,this.consumerAllowSignalWrites=!1,this.consumerIsAlwaysLive=!1,this.wrapper=this,this.__isSignal=!0,this.__isComputed=!0,this.__equal=n?.equals||Ct,this.watched=n?.[ze],this.unwatched=n?.[Ke];let r=this;this.producerMustRecompute=function(){return r.__value===$e||r.__value===De},this.producerRecomputeValue=function(){if(r.__value===De)throw new Error("Detected cycle in computations.");let s=r.__value;r.__value=De;let o=He(r),i,c=!1;try{i=r.__fn.call(r.wrapper)}catch(l){i=ce,r.__error=l,c=!0}finally{Ve(r,o)}if(!c&&(s!==$e&&s!==ce)&&r.__equal.call(r.wrapper,s,i)){r.__value=s;return}r.__value=i,r.version++},this.consumerMarkedDirty=ae}get(){if(le(this),We(this),this.__value===ce)throw this.__error;return this.__value}peek(){if(le(this),this.__value===ce)throw this.__error;return this.__value}},fe=class{constructor(t){this.__notify=t,this.version=0,this.lastCleanEpoch=V,this.dirty=!1,this.producers=[],this.producerLastReadVersions=[],this.nextProducerIndex=0,this.liveConsumers=void 0,this.consumerAllowSignalWrites=!1,this.consumerIsAlwaysLive=!0,this.producerMustRecompute=vt,this.producerRecomputeValue=ae,this.wrapper=this,this.__isWatcher=!0;let n=this;this.consumerMarkedDirty=function(){n.__fire()}}__fire(){this.__notify&&this.__notify.call(this)}watch(...t){if(t.length===0){this.dirty=!1;return}let n=He(this);try{for(let r of t)We(r),r.__isComputed&&le(r)}finally{Ve(this,n)}this.dirty=!1}unwatch(...t){for(let n=this.producers.length-1;n>=0;n--)t.includes(this.producers[n])&&(z(this.producers[n],this),this.producers.splice(n,1),this.producerLastReadVersions.splice(n,1),this.nextProducerIndex=Math.min(this.nextProducerIndex,this.producers.length))}getPending(){return this.producers.filter(t=>t.__isComputed&&t.dirty)}observe(t){let n=He(this),r;try{r=t()}finally{Ve(this,n)}return this.dirty=!1,r}dispose(){for(let t of this.producers)z(t,this);this.producers=[],this.producerLastReadVersions=[],this.__notify=null}},ze=Symbol("watched"),Ke=Symbol("unwatched");function Fn(e){let t=C;C=null;try{return e()}finally{C=t}}function Un(e){return e.producers.slice()}function $n(e){return e.liveConsumers?[...e.liveConsumers]:[]}function Dn(e){return!!e.liveConsumers&&e.liveConsumers.size>0}function qn(e){return e.producers.length>0}function Hn(){return C&&C.__isComputed?C:null}function Vn(e){Ue++,H===null&&(H=new Set);try{e()}finally{if(Ue--,Ue===0){let t=H;H=null;for(let n of t)n.__fire()}}}var G={State:ue,Computed:K,subtle:{Watcher:fe,untrack:Fn,introspectSources:Un,introspectSinks:$n,hasSinks:Dn,hasSources:qn,currentComputed:Hn,watched:ze,unwatched:Ke}};function Wn(e,t){return new ue(e,t)}function zn(e,t){return new K(e,t)}function Kn(e){return!!(e&&typeof e=="object"&&e.__isSignal===!0)}function Gn(e){let t=!1,n=!1,r=new K(e),s=new fe(()=>{t||n||(t=!0,queueMicrotask(()=>{if(t=!1,!n){try{r.get()}catch(o){console.error(o)}s.watch()}}))});s.watch(r);try{r.get()}catch(o){console.error(o)}return()=>{n||(n=!0,s.dispose())}}var Yn=`${m}s`,Jn=`${m}e`;function Tt(e){if(!e||e.nodeType!==8)return!1;let t=e.nodeValue;return t===Yn||t===Jn}function Xn(e){for(let t of e.addedNodes)if(Tt(t))return!0;for(let t of e.removedNodes)if(Tt(t))return!0;return!1}function Lt(){return typeof HTMLElement<"u"&&typeof HTMLSlotElement<"u"}var J=Lt(),P=Symbol("webjs.slot.state"),x="data-webjs-light",I="data-projection",X="actual",Mt="fallback",me=Symbol("webjs.slot.fallbackFrag"),Zn=64,Y=null,Ge=null,de=null,xt=!1;function Qn(){xt||(J=Lt(),J&&(Y=HTMLSlotElement.prototype.assignedNodes,Ge=HTMLSlotElement.prototype.assignedElements,de=Object.getOwnPropertyDescriptor(Element.prototype,"assignedSlot"),HTMLSlotElement.prototype.assignedNodes=function(t){return this.hasAttribute(x)&&!Rt(this)?Ye(this,t):Y?Y.call(this,t):[]},HTMLSlotElement.prototype.assignedElements=function(t){return this.hasAttribute(x)&&!Rt(this)?Ye(this,t).filter(n=>n.nodeType===1):Ge?Ge.call(this,t):[]},Object.defineProperty(Element.prototype,"assignedSlot",{configurable:!0,enumerable:!0,get:function(){let t=de&&de.get?de.get.call(this):null;return t||er(this)}}),xt=!0))}Qn();function Rt(e){let t=e;for(let n=0;n<128;n++){let r=t.parentNode;if(!r||r===t)return!1;if(r.host)return!0;t=r}return!1}function Ye(e,t){if(e.getAttribute(I)===Mt)return[];let n=Array.from(e.childNodes);return!t||!t.flatten?n:Je(n,new Set,0)}function Je(e,t,n){if(n>=Zn)return e.slice();let r=[];for(let s of e)if(s.nodeType===1&&s.tagName==="SLOT"){let o=s;if(t.has(o))continue;if(t.add(o),o.hasAttribute(x)){let i=Ye(o,{flatten:!1});if(i.length>0)for(let c of Je(i,t,n+1))r.push(c);else for(let c of Je(Array.from(o.childNodes),t,n+1))r.push(c)}else if(Y){let i=Y.call(o,{flatten:!0});for(let c of i)r.push(c)}else r.push(s)}else r.push(s);return r}function er(e){let t=e.parentElement;for(;t;){if(t.tagName==="SLOT"&&t.hasAttribute(x))return t.getAttribute(I)===X?t:null;t=t.parentElement}return null}function R(e){let t=e,n=t[P];return n||(n={assignedByName:new Map,pendingByName:new Map,lastSnapshot:new WeakMap,nameObservers:new WeakMap,childObserver:null,scheduled:!1,ownedSlots:new Set},t[P]=n),n}function Xe(e){return!!e[P]}function Pt(e){let t=R(e);for(;e.firstChild;){let n=e.firstChild,r=he(n);pe(t.assignedByName,r,n),e.removeChild(n)}}function It(e){let t=R(e),n=e.querySelectorAll(`slot[${x}]`);for(let r of n){let s=r;if(s.getAttribute(I)!==X)continue;let o=s.getAttribute("name")||null;if(!t.assignedByName.has(o)){let i=Array.from(s.childNodes);t.assignedByName.set(o,i),t.lastSnapshot.set(s,i.slice())}}}function he(e){if(e.nodeType!==1)return null;let n=e.getAttribute("slot");return n||null}function pe(e,t,n){let r=e.get(t);r||(r=[],e.set(t,r)),r.push(n)}function Bt(e,t,n){if(!n.length)return;let r=e.get(t);r||(r=[],e.set(t,r));for(let s of n)r.push(s)}function Ft(e){if(!J)return;let t=R(e);t.childObserver||(t.childObserver=new MutationObserver(n=>{let r=!1;for(let s of n)if(!Xn(s)){if(s.type==="childList"){for(let o of s.addedNodes)o.parentElement===e&&(pe(t.assignedByName,he(o),o),r=!0);for(let o of s.removedNodes)e.contains(o)||Ot(t,o)&&(r=!0)}else if(s.type==="attributes"&&s.attributeName==="slot"){let o=s.target;(Ot(t,o)||o.parentElement===e)&&(pe(t.assignedByName,he(o),o),r=!0)}}r&&ge(e)}),t.childObserver.observe(e,{childList:!0,attributes:!0,attributeFilter:["slot"],subtree:!0}))}function Ut(e){let t=e[P];if(t){t.childObserver&&(t.childObserver.disconnect(),t.childObserver=null);for(let n of t.ownedSlots){let r=t.nameObservers.get(n);r&&(r.disconnect(),t.nameObservers.delete(n))}}}function Ot(e,t){for(let[n,r]of e.assignedByName){let s=r.indexOf(t);if(s!==-1)return r.splice(s,1),r.length===0&&e.assignedByName.delete(n),!0}return!1}function ge(e){let t=R(e);t.scheduled||(t.scheduled=!0,queueMicrotask(()=>{t.scheduled=!1,tr(e)}))}function tr(e){if(!J)return;let t=e[P];if(!t)return;let n=Array.from(e.querySelectorAll(`slot[${x}]`)),r=new Set(n);for(let i of t.ownedSlots)r.has(i)||nr(t,i);for(let i of r)t.ownedSlots.has(i)||sr(e,i);t.ownedSlots=r;let s=new Map;for(let i of n){let c=i.getAttribute("name")||null,a=s.get(c);a||(a=[],s.set(c,a)),a.push(i)}for(let i of s.keys()){let c=t.pendingByName.get(i);if(c&&c.length){let a=t.assignedByName.get(i)||[],l=[];for(let u of c)l.push(u);for(let u of a)l.indexOf(u)===-1&&l.push(u);t.assignedByName.set(i,l),t.pendingByName.delete(i)}}let o=[];for(let[i,c]of s){let a=t.assignedByName.get(i)||[];for(let l=0;l<c.length;l++){let u=c[l];l===0&&a.length>0?rr(t,u,a)&&o.push(u):or(t,u)&&o.push(u)}}for(let i of o)ir(i)}function nr(e,t){let n=e.nameObservers.get(t);n&&(n.disconnect(),e.nameObservers.delete(t));let r=e.lastSnapshot.get(t);if(r&&r.length>0){let s=t.getAttribute("name")||null;Bt(e.pendingByName,s,r)}e.lastSnapshot.delete(t)}function rr(e,t,n){let r=t.getAttribute(I)!==X,s=e.lastSnapshot.get(t)||[];if(!r&&cr(s,n))return!1;let i=t[me];if(r&&i)for(;t.firstChild;)i.appendChild(t.firstChild);else for(;t.firstChild;)t.removeChild(t.firstChild);for(let c of n)t.appendChild(c);return t.setAttribute(I,X),e.lastSnapshot.set(t,n.slice()),!0}function or(e,t){let n=t.getAttribute(I)===X;if(t.setAttribute(I,Mt),!n)return jt(t),!1;for(e.lastSnapshot.delete(t);t.firstChild;)t.removeChild(t.firstChild);return jt(t),!0}function jt(e){let t=e[me];!t||t.childNodes.length===0||e.appendChild(t)}function sr(e,t){if(!J)return;let n=R(e);if(n.nameObservers.has(t))return;let r=new MutationObserver(()=>ge(e));r.observe(t,{attributes:!0,attributeFilter:["name"]}),n.nameObservers.set(t,r)}function $t(e,t){if(!Xe(e))return;let n=R(e),r=n.lastSnapshot.get(t);if(!r||r.length===0)return;let s=t.getAttribute("name")||null;for(let i of r)i.parentNode===t&&t.removeChild(i);Bt(n.pendingByName,s,r),n.lastSnapshot.delete(t);let o=n.nameObservers.get(t);o&&(o.disconnect(),n.nameObservers.delete(t)),n.ownedSlots.delete(t)}function ir(e){e.dispatchEvent(new Event("slotchange",{bubbles:!0,composed:!1}))}function cr(e,t){if(e===t)return!0;if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}var Dt=new WeakMap,Ze=Symbol.for("webjs.instance");function be(e,t){let n=t,r=n[Ze];if(_(e)){let s=e;if(r&&r.strings===s.strings){ee(r,s.values);return}r&&qt(r,t);let o=t.firstChild;o&&o.nodeType===8&&o.data==="webjs-hydrate"&&o.remove();let i=ur(s,t);n[Ze]=i;return}if(r&&qt(r,t),n[Ze]=null,t.replaceChildren(),!(e==null||e===!1||e===!0)){if(Array.isArray(e)){for(let s of e){let o=document.createTextNode(String(s??""));t.appendChild(o)}return}t.appendChild(document.createTextNode(String(e)))}}function Z(e){let{strings:t}=e,n=Dt.get(t);if(n)return n;let r=[],s="",o="text",i="",c=0,a="",l=0,u=null,p="",d="";for(let b=0;b<t.length;b++){let $=t[b];for(let y=0;y<$.length;y++){let f=$[y];switch(o){case"text":s+=f,f==="<"&&(o="tag-open");break;case"tag-open":s+=f,f==="!"?o="bang-1":f==="/"?(o="tag-name",p=""):/[a-zA-Z]/.test(f)?(o="tag-name",p=f.toLowerCase()):o="text";break;case"bang-1":s+=f,o=f==="-"?"bang-dash":"tag-name";break;case"bang-dash":s+=f,f==="-"?(o="comment",l=0):o="tag-name";break;case"comment":s+=f,f==="-"?l+=1:(f===">"&&l>=2&&(o="text"),l=0);break;case"tag-name":s+=f,f===">"?(o=p==="script"||p==="style"?"rawtext":"text",o==="rawtext"&&(d="")):/\s/.test(f)?o="in-tag":p+=f.toLowerCase();break;case"in-tag":s+=f,f===">"?(o=p==="script"||p==="style"?"rawtext":"text",o==="rawtext"&&(d="")):!/\s/.test(f)&&f!=="/"&&(o="attr-name",i=f,c=s.length-1);break;case"rawtext":s+=f,d=(d+f.toLowerCase()).slice(-9),(d.endsWith("<\/script>")||d.endsWith("</style>"))&&(o="text",d="",p="");break;case"attr-name":f==="="?(o="after-eq",s+=f):/\s/.test(f)?(o="in-tag",i="",s+=f):f===">"?(o="text",i="",s+=f):(i+=f,s+=f);break;case"after-eq":f==='"'||f==="'"?(o="attr-quoted",a=f,s+=f):/\s/.test(f)?(o="in-tag",i="",s+=f):f===">"?(o="text",i="",s+=f):(o="attr-unquoted",s+=f);break;case"attr-unquoted":/\s/.test(f)?(o="in-tag",i="",s+=f):(f===">"&&(o="text",i=""),s+=f);break;case"attr-quoted":s+=f,f===a&&(o="in-tag",i="");break;case"skip-attr":if(f===a){if(u){let D=u.firstPartIdx,A=[];for(let k=D;k<r.length;k++)(r[k].kind==="noop"||r[k].kind==="attr-mixed")&&A.push(k);let q=[],ke=t[A[0]],yt=ke.lastIndexOf(a);q.push(yt>=0?ke.slice(yt+1):ke);for(let k=1;k<A.length;k++)q.push(t[A[k]]);let Ee=t[A[A.length-1]+1],bt=Ee.indexOf(a);q.push(bt>=0?Ee.slice(0,bt):Ee),r[D]={kind:"attr-mixed",path:[],name:u.name,statics:q,group:A},u=null}o="in-tag",i=""}break}}if(b<t.length-1){let y=r.length;if(o==="comment"){l=0,r.push({kind:"noop",path:[]});continue}if(o==="rawtext"){d="",r.push({kind:"noop",path:[]});continue}if(o==="text")s+=`<!--${m}${y}-->`,r.push({kind:"child",path:[]});else if(o==="in-tag"){let f=`data-${m}${y}`;s+=`${f}=""`,r.push({kind:"element",path:[]})}else if(o==="after-eq"){let f=i[0],D=i.slice(1);if(f==="@"||f==="."||f==="?"){s=s.slice(0,c);let A=f==="@"?"event":f==="."?"prop":"bool",q=`data-${m}${y}`;s+=`${q}=""`,r.push({kind:A,path:[],name:D})}else{s=s.slice(0,c);let A=`data-${m}${y}`;s+=`${A}=""`,r.push({kind:"attr",path:[],name:i})}o="in-tag",i=""}else if(o==="attr-quoted"||o==="attr-unquoted"){s=s.slice(0,c);let f=`data-${m}${y}`;s+=`${f}=""`,u={name:i,firstPartIdx:y},r.push({kind:"noop",path:[]}),o="skip-attr"}else o==="skip-attr"&&r.push({kind:"noop",path:[]})}}let h=document.createElement("template");return h.innerHTML=s,ar(h.content,r),lr(h.content,r),n={templateEl:h,parts:r},Dt.set(t,n),n}function ar(e,t){let n=e.querySelectorAll("slot");for(let r of n){r.setAttribute(x,"");let s=t.length;r.setAttribute(`data-${m}${s}`,""),t.push({kind:"slot",path:[]})}}function lr(e,t){let n=[];function r(s){for(let o=0;o<s.childNodes.length;o++){let i=s.childNodes[o];if(n.push(o),i.nodeType===8){let c=i.data;if(c.startsWith(m)){let a=Number(c.slice(m.length));t[a]&&t[a].kind==="child"&&(t[a].path=n.slice())}}else if(i.nodeType===1){let c=i,a=[];for(let l of c.attributes)if(l.name.startsWith(`data-${m}`)){let u=Number(l.name.slice(`data-${m}`.length));t[u]&&t[u].kind!=="child"&&(t[u].path=n.slice()),a.push(l.name)}for(let l of a)c.removeAttribute(l);r(i)}n.pop()}}r(e)}function ur(e,t){let{templateEl:n,parts:r}=Z(e),s=n.content.cloneNode(!0),o=document.createComment(`${m}s`),i=document.createComment(`${m}e`),c=r.map(l=>Q(l,s)),a=[];for(let l=0;l<e.values.length;l++)O(c[l],e.values[l],void 0,e.values),a.push(e.values[l]);t.replaceChildren(o,...s.childNodes,i);for(let l of c)l.kind==="slot"&&O(l,void 0,void 0,[]);return{strings:e.strings,bound:c,lastValues:a,startNode:o,endNode:i}}function Q(e,t){if(e.kind==="noop")return{kind:"noop"};let n=t;for(let s of e.path)n=n.childNodes[s];if(e.kind==="child")return{kind:"child",marker:n};let r=n;if(e.kind==="event"){let s={kind:"event",el:r,name:e.name||"",handler:null,dispatcher(o){s.handler?.(o)}};return r.addEventListener(s.name,s.dispatcher),s}if(e.kind==="attr")return{kind:"attr",el:r,name:e.name||""};if(e.kind==="attr-mixed")return{kind:"attr-mixed",el:r,name:e.name||"",statics:e.statics||[],group:e.group||[]};if(e.kind==="prop")return{kind:"prop",el:r,name:e.name||""};if(e.kind==="bool")return{kind:"bool",el:r,name:e.name||""};if(e.kind==="element")return{kind:"element",el:r};if(e.kind==="slot")return{kind:"slot",slotEl:r,applied:!1};throw new Error(`unknown part kind ${e.kind}`)}function ee(e,t){for(let n=0;n<t.length;n++){let r=t[n];Object.is(r,e.lastValues[n])||(O(e.bound[n],r,e.lastValues[n],t),e.lastValues[n]=r)}}function qt(e,t){for(let n of e.bound){if(n.kind==="event"&&n.el.removeEventListener(n.name,n.dispatcher),n.kind==="element"){let r=n.lastTarget;if(r){if(typeof r=="function")try{r(void 0)}catch{}else typeof r=="object"&&(r.value=void 0);n.lastTarget=void 0,n.__lastEl=void 0}}if(n.kind==="slot"){let r=Qe(n.slotEl);r&&$t(r,n.slotEl)}}t.replaceChildren()}function O(e,t,n,r){if(je(t)){let s=t.value;if(e.kind==="prop"&&e.el[e.name]===s||e.kind==="attr"&&e.el.getAttribute(e.name)===String(s)||e.kind==="bool"&&e.el.hasAttribute(e.name)===!!s)return;t=s}switch(e.kind){case"child":hr(e,t);break;case"attr":{t==null||t===!1?e.el.removeAttribute(e.name):e.el.setAttribute(e.name,String(t));break}case"prop":e.el[e.name]=t;break;case"bool":t?e.el.setAttribute(e.name,""):e.el.removeAttribute(e.name);break;case"event":e.handler=typeof t=="function"?t:null;break;case"element":dr(e,t);break;case"attr-mixed":{let s=e,o=s.statics[0];for(let i=0;i<s.group.length;i++)o+=String((r?r[s.group[i]]:t)??""),o+=s.statics[i+1]||"";e.el.setAttribute(e.name,o);break}case"slot":{if(e.applied)break;let s=e.slotEl,o=()=>{e.applied=!0;let c=Qe(s);if(!c||fr(s))return;let a=document.createDocumentFragment();for(;s.firstChild;)a.appendChild(s.firstChild);s[me]=a,ge(c)};Qe(s)?o():queueMicrotask(o);break}case"noop":break}}function Qe(e){let t=e.parentElement;for(;t;){if(t[P])return t;t=t.parentElement}return null}function fr(e){let t=e;for(let n=0;n<128;n++){let r=t.parentNode;if(!r||r===t)return!1;if(r.host)return!0;t=r}return!1}function dr(e,t){let n=e,r=Pe(t)?t.target:void 0,s=n.__refTarget,o=r!==s;if(o&&s)if(typeof s=="function")try{s(void 0)}catch{}else typeof s=="object"&&(s.value=void 0);if(o||n.__refElement!==e.el){if(n.__refTarget=r,r)if(typeof r=="function"){if(!o&&n.__refElement!==void 0)try{r(void 0)}catch{}try{r(e.el)}catch{}}else typeof r=="object"&&(r.value=e.el);n.__refElement=e.el,e.lastTarget=r}}function hr(e,t){return yr(e,t),v(e,t)}function v(e,t){let n=e.marker;if(Oe(t)){B(e);let s=String(t.value??""),o=document.createElement("template");o.innerHTML=s;let i=[...o.content.childNodes],c=document.createDocumentFragment();for(let a of i)c.appendChild(a);n.parentNode?.insertBefore(c,n),e.child=i;return}if(Le(t)){let s=t,o=e.__keyedKey;o!==void 0&&!Object.is(o,s.key)&&B(e),e.__keyedKey=s.key,v(e,s.value);return}if(Me(t)){let s=t,o=e.__guardDeps,i=s.deps;if(o!==void 0&&(Array.isArray(o)&&Array.isArray(i)?gr(o,i):Object.is(o,i)))return;e.__guardDeps=Array.isArray(i)?i.slice():i,v(e,s.fn());return}if(wt(t)){B(e);let s=t.template;if(s&&s.content){let o=s.content.cloneNode(!0),i=[...o.childNodes];n.parentNode?.insertBefore(o,n),e.child=i}return}if(Pe(t))return;if(Ie(t))return br(e,t.value);if(Be(t))return _r(e,t.args);if(Fe(t))return wr(e,t.signal);if(St(t))return Sr(e,t);if(At(t))return Ar(e,t);if(Re(t)){if(e.child&&e.child.kind==="repeat"){mr(e,t);return}B(e);let s={kind:"repeat",map:new Map};e.child=s,pr(n,s,t);return}if(e.child){let s=e.child;if(s.kind==="repeat")Wt(s),e.child=void 0;else if(s.kind==="async-stream")Yt(s),e.child=void 0;else if("strings"in e.child){let o=e.child;if(_(t)&&o.strings===t.strings){ee(o,t.values);return}te(o.startNode,o.endNode),e.child=void 0}else{for(let o of e.child)o.parentNode&&o.parentNode.removeChild(o);e.child=void 0}}if(t==null||t===!1||t===!0)return;if(_(t)){let s=t,{templateEl:o,parts:i}=Z(s),c=o.content.cloneNode(!0),a=document.createComment(`${m}s`),l=document.createComment(`${m}e`),u=i.map(h=>Q(h,c)),p=[];for(let h=0;h<s.values.length;h++)O(u[h],s.values[h],void 0,s.values),p.push(s.values[h]);let d=[a,...c.childNodes,l];n.parentNode?.insertBefore(Ht(d),n);for(let h of u)h.kind==="slot"&&O(h,void 0,void 0,[]);e.child={strings:s.strings,bound:u,lastValues:p,startNode:a,endNode:l};return}if(Array.isArray(t)){let s=[];for(let i of t)if(_(i)){let c=i,{templateEl:a,parts:l}=Z(c),u=a.content.cloneNode(!0),p=l.map(d=>Q(d,u));for(let d=0;d<c.values.length;d++)O(p[d],c.values[d],void 0,c.values);s.push(...u.childNodes)}else i!=null&&i!==!1&&i!==!0&&s.push(document.createTextNode(String(i)));let o=Ht(s);n.parentNode?.insertBefore(o,n),e.child=s;return}let r=document.createTextNode(String(t));n.parentNode?.insertBefore(r,n),e.child=[r]}function Ht(e){let t=document.createDocumentFragment();for(let n of e)t.appendChild(n);return t}function te(e,t){if(!e.parentNode)return;let n=e;for(;n&&n!==t;){let r=n.nextSibling;n.parentNode?.removeChild(n),n=r}t.parentNode===e.parentNode&&t.parentNode?.removeChild(t)}function Vt(e){let{templateEl:t,parts:n}=Z(e),r=t.content.cloneNode(!0),s=document.createComment(`${m}s`),o=document.createComment(`${m}e`),i=n.map(l=>Q(l,r)),c=[];for(let l=0;l<e.values.length;l++)O(i[l],e.values[l],void 0,e.values),c.push(e.values[l]);let a=document.createDocumentFragment();for(a.appendChild(s);r.firstChild;)a.appendChild(r.firstChild);return a.appendChild(o),{inst:{strings:e.strings,bound:i,lastValues:c,startNode:s,endNode:o},frag:a}}function ye(e){for(let t of e.bound)if(t.kind==="event"&&t.el.removeEventListener(t.name,t.dispatcher),t.kind==="element"){let n=t.lastTarget;if(n){if(typeof n=="function")try{n(void 0)}catch{}else typeof n=="object"&&(n.value=void 0);t.lastTarget=void 0,t.__lastEl=void 0}}}function pr(e,t,n){let{items:r,keyFn:s,templateFn:o}=n,i=e.parentNode;if(!i)return;let c=document.createDocumentFragment();for(let a=0;a<r.length;a++){let l=s(r[a],a),u=o(r[a],a);if(!_(u))continue;let{inst:p,frag:d}=Vt(u);t.map.set(l,p),c.appendChild(d)}i.insertBefore(c,e)}function mr(e,t){let n=e.marker,r=n.parentNode;if(!r)return;let s=e.child,{items:o,keyFn:i,templateFn:c}=t,a=new Map;for(let l=0;l<o.length;l++){let u=i(o[l],l),p=c(o[l],l);if(!_(p))continue;let d=s.map.get(u);if(d&&d.strings===p.strings)ee(d,p.values),et(d.startNode,d.endNode,r,n),a.set(u,d),s.map.delete(u);else{d&&(ye(d),te(d.startNode,d.endNode),s.map.delete(u));let{inst:h,frag:b}=Vt(p);r.insertBefore(b,n),a.set(u,h)}}for(let l of s.map.values())ye(l),te(l.startNode,l.endNode);s.map=a}function Wt(e){for(let t of e.map.values())ye(t),te(t.startNode,t.endNode);e.map.clear()}function et(e,t,n,r){if(t.nextSibling===r&&e.parentNode===n)return;let s=document.createDocumentFragment(),o=e;for(;o;){let i=o.nextSibling;if(s.appendChild(o),o===t)break;o=i}n.insertBefore(s,r)}function gr(e,t){if(e===t)return!0;if(!e||!t||e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!Object.is(e[n],t[n]))return!1;return!0}function B(e){let t=e;if(t.__untilState&&(t.__untilState.aborted=!0,t.__untilState=void 0),t.__watchSub&&zt(t),!e.child)return;let n=e.child;if(n.kind==="repeat")Wt(n);else if(n.kind==="async-stream")Yt(n);else if("strings"in n){let r=e.child;ye(r),te(r.startNode,r.endNode)}else for(let r of e.child)r.parentNode&&r.parentNode.removeChild(r);e.child=void 0}function yr(e,t){let n=e;n.__untilState&&!Be(t)&&(n.__untilState.aborted=!0,n.__untilState=void 0),n.__guardDeps!==void 0&&!Me(t)&&(n.__guardDeps=void 0),n.__cacheMap&&!Ie(t)&&(n.__cacheMap=void 0),n.__keyedKey!==void 0&&!Le(t)&&(n.__keyedKey=void 0),n.__watchSub&&!Fe(t)&&zt(n)}function br(e,t){let n=e.marker,r=e,s=r.__cacheMap;s||(s=new Map,r.__cacheMap=s);let o=e.child;if(o&&"strings"in o){let c=o;if(_(t)&&c.strings===t.strings){ee(c,t.values);return}let a=document.createDocumentFragment();et(c.startNode,c.endNode,a,null),s.set(c.strings,{inst:c,holder:a}),e.child=void 0}if(_(t)){let c=t,a=s.get(c.strings);if(a){s.delete(c.strings),e.child&&B(e),et(a.inst.startNode,a.inst.endNode,n.parentNode,n),ee(a.inst,c.values),e.child=a.inst;return}}v(e,t)}function _r(e,t){let n=e,r=n.__untilState,s=n.__untilArgs,o=(d,h)=>!!(Object.is(d,h)||_(d)&&_(h)&&d.strings===h.strings),c=s&&s.length===t.length&&s.every((d,h)=>o(d,t[h]))&&r?r.highestResolved:1/0;r&&(r.aborted=!0),n.__untilArgs=t.slice();let a={aborted:!1,highestResolved:c};n.__untilState=a;let l=-1,u;for(let d=0;d<t.length;d++){let h=t[d];if(!h||typeof h.then!="function"){l=d,u=h;break}}l!==-1&&l<=a.highestResolved?(v(e,u),a.highestResolved=l):l===-1&&!n.__untilEverRendered&&v(e,""),n.__untilEverRendered=!0;let p=Math.min(l===-1?t.length:l,a.highestResolved);for(let d=0;d<p;d++){let h=t[d];!h||typeof h.then!="function"||Promise.resolve(h).then(b=>{a.aborted||d>=a.highestResolved||(a.highestResolved=d,v(e,b))},()=>{})}}function wr(e,t){let n=e;if(n.__watchSig===t&&n.__watchSub){let o;n.__watchSub.observe(()=>{o=t.get()}),v(e,o);return}n.__watchSub&&(n.__watchSub.dispose(),n.__watchSub=void 0),n.__watchSig=t;let r=new G.subtle.Watcher(()=>{queueMicrotask(()=>{if(n.__watchSub!==r)return;let o;r.observe(()=>{o=t.get()}),v(e,o)})});n.__watchSub=r;let s;r.observe(()=>{s=t.get()}),v(e,s)}function zt(e){e.__watchSub&&(e.__watchSub.dispose(),e.__watchSub=void 0,e.__watchSig=void 0)}function Sr(e,t){let n=e.child;if(n&&n.kind==="async-stream"&&n.mode==="append"&&n.iterable===t.iterable)return;B(e);let r=t.iterable[Symbol.asyncIterator](),s={kind:"async-stream",mode:"append",aborted:!1,iterable:t.iterable,iterator:r,nodes:[]};e.child=s,Kt(s,e,t)}function Ar(e,t){let n=e.child;if(n&&n.kind==="async-stream"&&n.mode==="replace"&&n.iterable===t.iterable)return;B(e);let r=t.iterable[Symbol.asyncIterator](),s={kind:"async-stream",mode:"replace",aborted:!1,iterable:t.iterable,iterator:r,nodes:[]};e.child=s,Kt(s,e,t)}async function Kt(e,t,n){let r=t.marker,s=0;try{for(;!e.aborted;){let o=await e.iterator.next();if(e.aborted||o.done)break;let i=n.mapper?n.mapper(o.value,s):o.value,c=Gt(i);if(e.mode==="replace"){for(let l of e.nodes)l.parentNode&&l.parentNode.removeChild(l);e.nodes=[]}let a=document.createDocumentFragment();for(let l of c)a.appendChild(l);r.parentNode?.insertBefore(a,r),e.nodes.push(...c),s++}}catch(o){typeof console<"u"&&console.error("[webjs] asyncStream error:",o)}}function Gt(e){if(e==null||e===!1||e===!0)return[];if(_(e)){let t=e,{templateEl:n,parts:r}=Z(t),s=n.content.cloneNode(!0),o=r.map(i=>Q(i,s));for(let i=0;i<t.values.length;i++)O(o[i],t.values[i],void 0,t.values);return[...s.childNodes]}if(Array.isArray(e)){let t=[];for(let n of e)t.push(...Gt(n));return t}return[document.createTextNode(String(e))]}function Yt(e){e.aborted=!0;for(let t of e.nodes)t.parentNode&&t.parentNode.removeChild(t);e.nodes=[];try{e.iterator.return?.()?.catch?.(()=>{})}catch{}}var Jt=Symbol.for("webjs:registry"),Xt=Symbol.for("webjs:classToTag"),_e=globalThis,N=_e[Jt]||(_e[Jt]=new Map),Zt=_e[Xt]||(_e[Xt]=new WeakMap),we=typeof window<"u"&&typeof customElements<"u";function tt(e,t){if(!e||typeof e!="string"||!e.includes("-"))throw new Error(`customElements.define: tag "${e}" must contain a hyphen (HTML spec)`);let n=t.lazy===!0,r=N.get(e);r?(r.cls=t,r.lazy=n):N.set(e,{cls:t,moduleUrl:null,lazy:n,tag:e}),Zt.set(t,e)}if(we){let e=customElements.define.bind(customElements);customElements.define=function(t,n,r){customElements.get(t)||e(t,n,r),tt(t,n)}}if(!we){let e=globalThis;e.customElements||(e.customElements={define(t,n){tt(t,n)},get(t){return N.get(t)?.cls},upgrade(){},whenDefined(t){let n=N.get(t);return Promise.resolve(n?.cls)}})}function nt(e,t){we?customElements.define(e,t):tt(e,t)}function Cr(e,t){if(we)return;let n=N.get(e);if(n){n.moduleUrl=t;return}N.set(e,{cls:null,moduleUrl:t,lazy:!1,tag:e})}function vr(e){return N.get(e)?.cls}function Nr(e){return N.get(e)?.moduleUrl||null}function kr(e){return N.get(e)?.lazy===!0}function Se(e){return Zt.get(e)}function Er(){return[...N.keys()]}var g="_$wj",oe="_id";async function rt(e){return JSON.stringify(await Qt(e))}function se(e){return en(JSON.parse(e))}async function Qt(e){let t=Tr();return await xr(e,t),F(e,t)}function en(e){return j(e,Lr())}function Tr(){return{refCount:new Map,idOf:new Map,emitted:new Set,nextId:0,blobBytes:new Map}}async function xr(e,t){let n=[e];for(;n.length;){let r=n.pop();if(!Pr(r))continue;let s=t.refCount.get(r)||0;if(t.refCount.set(r,s+1),!(s>0)){if(typeof Blob<"u"&&r instanceof Blob){let o=new Uint8Array(await r.arrayBuffer());t.blobBytes.set(r,o);continue}if(typeof FormData<"u"&&r instanceof FormData){for(let[,o]of r.entries())typeof o!="string"&&n.push(o);continue}if(Array.isArray(r))for(let o=0;o<r.length;o++)n.push(r[o]);else if(r instanceof Map)for(let[o,i]of r)n.push(o),n.push(i);else if(r instanceof Set)for(let o of r)n.push(o);else if(Ir(r))for(let o in r)Object.prototype.hasOwnProperty.call(r,o)&&n.push(r[o])}}for(let[r,s]of t.refCount)s>1&&t.idOf.set(r,t.nextId++)}function F(e,t){if(e===null)return null;if(e===void 0)return{[g]:"undef"};let n=typeof e;if(n==="string"||n==="boolean")return e;if(n==="number")return Number.isNaN(e)?{[g]:"NaN"}:e===1/0?{[g]:"Inf"}:e===-1/0?{[g]:"-Inf"}:Object.is(e,-0)?{[g]:"-0"}:e;if(n==="bigint")return{[g]:"BigInt",v:e.toString()};if(n==="symbol"){let o=Symbol.keyFor(e);if(o===void 0)throw new TypeError("Cannot serialize a local Symbol; only Symbol.for() registered symbols are supported.");return{[g]:"Sym",v:o}}if(n==="function")throw new TypeError("Cannot serialize a function.");let r=t.idOf.get(e);if(r!==void 0&&t.emitted.has(r))return{[g]:"Ref",v:r};r!==void 0&&t.emitted.add(r);let s;if(e instanceof Date)s={[g]:"Date",v:Number.isNaN(e.getTime())?null:e.toISOString()};else if(e instanceof Error)s={[g]:"Error",v:{name:e.name,message:e.message,stack:e.stack||null}};else if(typeof Blob<"u"&&e instanceof Blob){let o=t.blobBytes.get(e);typeof File<"u"&&e instanceof File?s={[g]:"File",v:re(o),n:e.name,t:e.type||"",m:e.lastModified}:s={[g]:"Blob",v:re(o),t:e.type||""}}else if(typeof FormData<"u"&&e instanceof FormData){let o=[];for(let[i,c]of e.entries())o.push([i,F(c,t)]);s={[g]:"FD",v:o}}else if(ArrayBuffer.isView(e)||e instanceof ArrayBuffer)s=Rr(e);else if(e instanceof Map){let o=[];for(let[i,c]of e)o.push([F(i,t),F(c,t)]);s={[g]:"Map",v:o}}else if(e instanceof Set){let o=[];for(let i of e)o.push(F(i,t));s={[g]:"Set",v:o}}else if(Array.isArray(e))s=e.map(o=>F(o,t));else{s={};for(let o in e){if(!Object.prototype.hasOwnProperty.call(e,o))continue;let i=Br(o)?"_"+o:o;s[i]=F(e[o],t)}}if(r!==void 0){if(Array.isArray(s))return{[g]:"Arr",[oe]:r,v:s};s[oe]=r}return s}function Rr(e){if(e instanceof ArrayBuffer)return{[g]:"buf",v:re(new Uint8Array(e))};if(e instanceof DataView)return{[g]:"dv",v:re(new Uint8Array(e.buffer,e.byteOffset,e.byteLength))};let t=e.constructor.name,n=Or[t];if(!n)throw new TypeError(`Unsupported typed array: ${t}`);let r=new Uint8Array(e.buffer,e.byteOffset,e.byteLength);return{[g]:n,v:re(r)}}var Or={Int8Array:"i8",Uint8Array:"u8",Uint8ClampedArray:"u8c",Int16Array:"i16",Uint16Array:"u16",Int32Array:"i32",Uint32Array:"u32",Float32Array:"f32",Float64Array:"f64",BigInt64Array:"bi64",BigUint64Array:"bu64"},jr={i8:Int8Array,u8:Uint8Array,u8c:Uint8ClampedArray,i16:Int16Array,u16:Uint16Array,i32:Int32Array,u32:Uint32Array,f32:Float32Array,f64:Float64Array,bi64:typeof BigInt64Array<"u"?BigInt64Array:null,bu64:typeof BigUint64Array<"u"?BigUint64Array:null};function Lr(){return{refs:new Map}}function j(e,t){if(e===null||typeof e!="object")return e;if(Array.isArray(e)){let o=[];for(let i=0;i<e.length;i++)o.push(j(e[i],t));return o}let n=e[g];if(typeof n=="string")return Mr(e,n,t);let r={},s=e[oe];typeof s=="number"&&t.refs.set(s,r);for(let o in e){if(!Object.prototype.hasOwnProperty.call(e,o)||o===oe)continue;let i=Fr(o)?o.slice(1):o;r[i]=j(e[o],t)}return r}function Mr(e,t,n){let r=e[oe];switch(t){case"undef":return;case"NaN":return NaN;case"Inf":return 1/0;case"-Inf":return-1/0;case"-0":return-0;case"BigInt":return BigInt(e.v);case"Sym":return Symbol.for(e.v);case"Date":return e.v==null?new Date(NaN):new Date(e.v);case"Error":{let s=new Error(e.v.message);return s.name=e.v.name,e.v.stack&&(s.stack=e.v.stack),typeof r=="number"&&n.refs.set(r,s),s}case"Map":{let s=new Map;typeof r=="number"&&n.refs.set(r,s);for(let[o,i]of e.v)s.set(j(o,n),j(i,n));return s}case"Set":{let s=new Set;typeof r=="number"&&n.refs.set(r,s);for(let o of e.v)s.add(j(o,n));return s}case"Arr":{let s=[];typeof r=="number"&&n.refs.set(r,s);for(let o of e.v)s.push(j(o,n));return s}case"Ref":{let s=n.refs.get(e.v);if(s===void 0)throw new TypeError(`Dangling reference: id=${e.v}`);return s}case"Blob":{if(typeof Blob>"u")throw new TypeError("Blob is not available in this environment.");let s=ne(e.v);return new Blob([s],{type:e.t||""})}case"File":{if(typeof File>"u")throw new TypeError("File is not available in this environment.");let s=ne(e.v);return new File([s],e.n,{type:e.t||"",lastModified:e.m})}case"FD":{if(typeof FormData>"u")throw new TypeError("FormData is not available in this environment.");let s=new FormData;for(let[o,i]of e.v){let c=j(i,n);s.append(o,c)}return s}default:{if(t==="buf"){let o=ne(e.v);return o.buffer.slice(o.byteOffset,o.byteOffset+o.byteLength)}if(t==="dv"){let o=ne(e.v);return new DataView(o.buffer.slice(o.byteOffset,o.byteOffset+o.byteLength))}let s=jr[t];if(s){let o=ne(e.v),i=o.buffer.slice(o.byteOffset,o.byteOffset+o.byteLength);return new s(i)}throw new TypeError(`Unknown serialization tag: ${t}`)}}}function Pr(e){return e!==null&&typeof e=="object"}function Ir(e){if(e===null||typeof e!="object")return!1;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}function Br(e){return/^_+\$wj$/.test(e)||/^_+id$/.test(e)}function Fr(e){return/^__+\$wj$/.test(e)||/^__+id$/.test(e)}var tn=typeof Buffer<"u"&&typeof Buffer.from=="function";function re(e){if(tn)return Buffer.from(e.buffer,e.byteOffset,e.byteLength).toString("base64");let t="";for(let n=0;n<e.length;n++)t+=String.fromCharCode(e[n]);return btoa(t)}function ne(e){if(tn){let r=Buffer.from(e,"base64");return new Uint8Array(r.buffer,r.byteOffset,r.byteLength)}let t=atob(e),n=new Uint8Array(t.length);for(let r=0;r<t.length;r++)n[r]=t.charCodeAt(r);return n}var on=typeof window<"u"&&typeof HTMLElement<"u";function Ur(e,t){return e!==t}var $r=on?HTMLElement:class{},ot=class extends $r{static shadow=!1;static hydrate=void 0;static properties={};static styles=null;static register(t){nt(t,this)}static get observedAttributes(){let t=this.properties||{};return Object.keys(t).filter(n=>!t[n].state).map(nn)}constructor(){super(),this._renderRoot=null,this._scheduled=!1,this._connected=!1,this.__controllers=new Set,this.__firstRendered=!1,this._changedProperties=new Map,this._updateResolve=null,this._updatePromise=Promise.resolve(!0),this._isUpdating=!1,this._initializeProperties()}_initializeProperties(){let n=this.constructor.properties;if(!(!n||typeof n!="object")){this.__propValues={};for(let[r,s]of Object.entries(n)){let o=typeof s=="object"?s:{type:s},i=this[r];Object.defineProperty(this,r,{configurable:!0,enumerable:!0,get:()=>this.__propValues[r],set:c=>{let a=this.__propValues[r];(o.hasChanged||Ur)(c,a)&&(this.__propValues[r]=c,o.reflect&&!o.state&&this._connected&&this._reflectAttribute(r,c,o),this.requestUpdate(r,a))}}),i!==void 0&&(this.__propValues[r]=i)}}}_reflectAttribute(t,n,r){let s=nn(t);if(!this.__reflectingAttribute){this.__reflectingAttribute=!0;try{if(r.converter&&r.converter.toAttribute){let o=r.converter.toAttribute(n,r.type);o==null?this.removeAttribute(s):this.setAttribute(s,o)}else r.type===Boolean?n?this.setAttribute(s,""):this.removeAttribute(s):n==null?this.removeAttribute(s):r.type===Object||r.type===Array?this.setAttribute(s,JSON.stringify(n)):this.setAttribute(s,String(n))}finally{this.__reflectingAttribute=!1}}}connectedCallback(){if(!on)return;if(this.__webjsPropsHydrated||(this.__webjsPropsHydrated=!0,this._hydratePropAttrs()),this.constructor.hydrate==="visible"&&typeof IntersectionObserver<"u"&&!this.__hydrationActivated){this.__hydrationActivated=!1,this.__hydrationObserver=new IntersectionObserver(n=>{for(let r of n)if(r.isIntersecting){this.__hydrationObserver.unobserve(this),this.__hydrationObserver.disconnect(),this.__hydrationObserver=null,this.__hydrationActivated=!0,this._activate();return}},{rootMargin:"200px"}),this.__hydrationObserver.observe(this);return}this._activate()}_hydratePropAttrs(){let t=[],n=this.attributes;for(let r=0;r<n.length;r++){let s=n[r].name;s.startsWith("data-webjs-prop-")&&t.push(s)}for(let r of t){let s=this.getAttribute(r);if(this.removeAttribute(r),s==null)continue;let o=rn(r.slice(16));try{this[o]=se(s)}catch(i){console.warn(`[webjs] failed to decode ${r} on <${this.tagName.toLowerCase()}>: ${i&&i.message}`)}}}_activate(){this._connected=!0;let t=this.constructor;if(t.shadow===!0){let n=!!this.shadowRoot;this.shadowRoot||this.attachShadow({mode:"open"}),this._renderRoot=this.shadowRoot;let r=t.styles,s=Array.isArray(r)?r:Te(r)?[r]:[];if(s.length){if(n){let o=this.shadowRoot.querySelector("style");o&&o.remove()}xe(this._renderRoot,s)}}else this._renderRoot=this,t.styles&&console.warn(`[webjs] <${Se(t)||this.tagName?.toLowerCase()}> has static shadow = false AND static styles. static styles only works with shadow DOM (adoptedStyleSheets). For light DOM, use global CSS or <style> in render().`),Xe(this)||(this.__isHydrating()?(R(this),It(this)):Pt(this));for(let n of this.__controllers)n.hostConnected&&n.hostConnected();this._updateResolve===null&&(this._updatePromise=new Promise(n=>{this._updateResolve=n})),this._scheduled=!0,queueMicrotask(()=>{this._scheduled=!1;try{this._performRender()}catch(n){console.error("[webjs] lifecycle hook threw during initial render:",n)}this._renderRoot===this&&Ft(this)})}__isHydrating(){let t=this.firstChild,n=t!=null&&t.nodeType===8&&t.data==="webjs-hydrate";return n&&(this.__hydratedAtActivate=!0),n}disconnectedCallback(){this._connected=!1,this.__hydrationObserver&&(this.__hydrationObserver.disconnect(),this.__hydrationObserver=null),this._renderRoot===this&&Ut(this),this.__signalWatcher&&(this.__signalWatcher.dispose(),this.__signalWatcher=void 0);for(let t of this.__controllers)t.hostDisconnected&&t.hostDisconnected()}attributeChangedCallback(t,n,r){if(this.__reflectingAttribute)return;let s=this.constructor,o=rn(t),i=s.properties&&(s.properties[o]||s.properties[t]);if(!i)return;let c;if(i.converter&&i.converter.fromAttribute)c=i.converter.fromAttribute(r,i.type);else if(i.type===Number)c=r==null?null:Number(r);else if(i.type===Boolean)c=r!=null&&r!=="false";else if(i.type===Object||i.type===Array)try{c=r==null?null:JSON.parse(r)}catch{c=r}else c=r;this[o]!==c&&(this[o]=c,this._connected&&this.requestUpdate())}requestUpdate(t,n){t!==void 0&&!this._changedProperties.has(t)&&this._changedProperties.set(t,n),this._scheduleUpdate()}_scheduleUpdate(){this._updateResolve===null&&(this._updatePromise=new Promise(t=>{this._updateResolve=t})),!this._isUpdating&&(this._scheduled||!this._connected||(this._scheduled=!0,queueMicrotask(()=>{this._scheduled=!1;try{this._performRender()}catch(t){console.error("[webjs] lifecycle hook threw during update cycle:",t)}})))}_performRender(){if(!this._renderRoot)return;let t=this._changedProperties;this._isUpdating=!0;let n=!1;try{if(this.shouldUpdate(t)){this.willUpdate(t);for(let r of this.__controllers)r.hostUpdate&&r.hostUpdate();try{this.update(t)}catch(r){console.error(`[webjs] render error in <${Se(this.constructor)||this.tagName?.toLowerCase()}>:`,r);try{let s=this.renderError(r);s!==void 0&&be(s,this._renderRoot)}catch(s){console.error("[webjs] renderError() also threw:",s)}}for(let r of this.__controllers)r.hostUpdated&&r.hostUpdated();n=!0}}catch(r){console.error("[webjs] lifecycle hook threw during update phase:",r)}finally{this._isUpdating=!1,n&&(this._changedProperties=new Map)}if(n)try{this.__firstRendered||(this.__firstRendered=!0,this.firstUpdated(t)),this.updated(t)}catch(r){console.error("[webjs] lifecycle hook threw during post-commit phase:",r)}finally{this._resolveUpdate()}else this._resolveUpdate()}_resolveUpdate(){if(this._updateResolve){let t=this._changedProperties.size===0;this._updateResolve(t),this._updateResolve=null}}shouldUpdate(t){return!0}willUpdate(t){}update(t){this.__signalWatcher||(this.__signalWatcher=new G.subtle.Watcher(()=>{this._connected&&this.requestUpdate()}));let n;this.__signalWatcher.observe(()=>{n=this.render()}),be(n,this._renderRoot)}updated(t){}firstUpdated(t){}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._updatePromise}addController(t){this.__controllers.add(t),this._connected&&t.hostConnected&&t.hostConnected()}removeController(t){this.__controllers.delete(t)}render(){return""}renderError(t){}};function nn(e){return e.replace(/([A-Z])/g,"-$1").toLowerCase()}function rn(e){return e.replace(/-([a-z])/g,(t,n)=>n.toUpperCase())}var sn=Symbol.for("webjs.notFound"),cn=Symbol.for("webjs.redirect");function Dr(){let e=new Error("webjs: notFound()");throw e.__webjs=sn,e}function qr(e,t=307){let n=new Error(`webjs: redirect(${e})`);throw n.__webjs=cn,n.url=e,n.status=t,n}function Hr(e){return!!e&&e.__webjs===sn}function Vr(e){return!!e&&e.__webjs===cn}var an=null;function Wr(){if(!an)return"";try{return an()||""}catch{return""}}var Yo=Symbol.for("webjs.suspense");function zr(e){return{_$webjsSuspense:!0,fallback:e.fallback,children:e.children}}function Kr(e){return!!e&&typeof e=="object"&&e._$webjsSuspense===!0}function Gr(e,t={}){let n=t.reconnect!==!1,r=0,s=!1,o=null,i=[];function c(){s||(o=new WebSocket(Yr(e),t.protocols),o.onopen=a=>{for(r=0;i.length&&o&&o.readyState===WebSocket.OPEN;)o.send(i.shift());t.onOpen?.(a)},o.onmessage=a=>{let l=a.data;if(typeof l=="string")try{l=JSON.parse(l)}catch{}t.onMessage?.(l,a)},o.onerror=a=>{t.onError?.(a)},o.onclose=a=>{if(t.onClose?.(a),!s&&n){let l=Math.min(1e3*2**r++,3e4);setTimeout(c,l)}})}return c(),{send(a){let l=typeof a=="string"||a instanceof ArrayBuffer||ArrayBuffer.isView(a)?a:JSON.stringify(a);o&&o.readyState===WebSocket.OPEN?o.send(l):i.push(l)},close(a,l){s=!0;try{o?.close(a,l)}catch{}},get socket(){return o},get readyState(){return o?.readyState??3}}}function Yr(e){if(/^wss?:\/\//i.test(e))return e;let t=typeof location<"u"&&location.protocol==="https:"?"wss:":"ws:",n=typeof location<"u"?location.host:"";return`${t}//${n}${e.startsWith("/")?e:"/"+e}`}var st="application/vnd.webjs+json";async function Jr(e,t={}){let n=new Headers(t.headers||{});n.has("accept")||n.set("accept",st);let r=t.body;r!=null&&typeof r=="object"&&!(r instanceof FormData)&&!(r instanceof Blob)&&!(r instanceof ArrayBuffer)&&!(r instanceof URLSearchParams)&&!(typeof ReadableStream<"u"&&r instanceof ReadableStream)&&!ArrayBuffer.isView(r)&&(r=await rt(r),n.has("content-type")||n.set("content-type",st));let s=await fetch(e,{...t,headers:n,body:r}),o=s.headers.get("content-type")||"",i=await s.text(),c=o.includes(st)?i?se(i):null:o.includes("application/json")?i?JSON.parse(i):null:i;if(!s.ok){let a=c&&c.error||`richFetch ${e} -> ${s.status}`,l=new Error(a);throw l.status=s.status,l.body=c,l}return c}var it=typeof HTMLElement<"u"?class extends HTMLElement{}:null;typeof customElements<"u"&&it&&!customElements.get("webjs-frame")&&customElements.define("webjs-frame",it);function hn(e){return typeof Document<"u"&&typeof Document.parseHTMLUnsafe=="function"?Document.parseHTMLUnsafe(e):typeof DOMParser<"u"?new DOMParser().parseFromString(e,"text/html"):null}var W=!1,L=null,S=0,ct=null;function Xr(){ct||typeof MutationObserver>"u"||typeof customElements>"u"||(ct=new MutationObserver(e=>{for(let t of e)for(let n of t.addedNodes){if(n.nodeType!==1)continue;let r=n;r.tagName?.includes("-")&&customElements.upgrade(r);for(let s of r.querySelectorAll("*"))s.tagName?.includes("-")&&customElements.upgrade(s)}}),ct.observe(document.body,{childList:!0,subtree:!0}))}var M=null,Ae=null;function pn(){W||typeof document>"u"||(W=!0,document.addEventListener("click",gn,!0),document.addEventListener("submit",bn,!0),window.addEventListener("popstate",yn),Xr(),typeof history<"u"&&"scrollRestoration"in history&&(Ae=history.scrollRestoration,history.scrollRestoration="manual"),typeof location<"u"&&(M=location.href))}function Zr(){W&&(W=!1,document.removeEventListener("click",gn,!0),document.removeEventListener("submit",bn,!0),window.removeEventListener("popstate",yn),typeof history<"u"&&Ae!==null&&(history.scrollRestoration=Ae,Ae=null),M=null)}async function Qr(e,t){let n=new URL(e,location.href);if(n.origin!==location.origin){location.href=e;return}await dt(n.href,t?.replace??!1,null)}function eo(e){if(!e){w.clear();return}let t=new URL(e,location.href);w.delete(t.pathname+t.search)}pn();var mn=/\.(?:pdf|zip|tar|gz|7z|rar|dmg|exe|msi|deb|rpm|apk|ipa|xlsx?|docx?|pptx?|csv|odt|ods|odp|rtf|epub|mobi|xml|json|rss|atom|txt|md|wasm|mp3|mp4|mov|avi|webm|ogg|flac|wav|m4a|m4v|mkv|png|jpe?g|gif|webp|avif|bmp|ico|svg|tiff?|heic)$/i;function gn(e){if(!W||e.defaultPrevented||e.button!==0||e.metaKey||e.ctrlKey||e.shiftKey||e.altKey)return;let t=oo(e);if(!t||t.hasAttribute("download")||t.hasAttribute("data-no-router")||t.target&&t.target!=="_self")return;let n=t.href;if(!n)return;let r=new URL(n);if(r.origin!==location.origin||r.pathname===location.pathname&&r.search===location.search&&r.hash||mn.test(r.pathname))return;e.preventDefault();let s=_n(t);dt(n,!1,s)}function yn(e){dt(location.href,!0,null)}function bn(e){if(!W||e.defaultPrevented)return;let t=e.target;if(!t||t.nodeType!==1||t.tagName!=="FORM"||t.hasAttribute("data-no-router"))return;let n=e.submitter??null;if(n&&n.hasAttribute("data-no-router"))return;let r=n&&n.getAttribute("formtarget")||t.getAttribute("target")||"";if(r&&r!=="_self")return;let s=to(t,n);if(s==="dialog")return;let o=no(t,n),i;try{i=new URL(o,location.href)}catch{return}if(i.origin!==location.origin||mn.test(i.pathname))return;let c=ro(t,n);e.preventDefault();let a=_n(t);ao(i.href,s,c,a)}function to(e,t){return(t&&t.getAttribute("formmethod")||e.getAttribute("method")||"get").toLowerCase()}function no(e,t){return t&&t.hasAttribute("formaction")?t.getAttribute("formaction")||"":e.getAttribute("action")||e.action||location.href}function ro(e,t){try{return new FormData(e,t||void 0)}catch{let n=new FormData(e);return t&&t.getAttribute("name")&&n.append(t.getAttribute("name"),t.getAttribute("value")||""),n}}function oo(e){for(let t of e.composedPath())if(t instanceof HTMLAnchorElement)return t;return null}function _n(e){let t=e;for(;t;){let n=t.closest("webjs-frame");if(n&&n.id)return n.id;let r=t.getRootNode();if(r&&r.host)t=r.host;else break}return null}function ve(e){let t=new Map,n=[];function r(s){if(s.nodeType===8){let o=s,i=o.data,c=/^wj:children:(.+)$/.exec(i);if(c){n.push({path:c[1],start:o});return}if(i.trim()==="/wj:children"){let a=n.pop();a&&!t.has(a.path)&&t.set(a.path,{start:a.start,end:o});return}return}if(s.hasChildNodes&&s.hasChildNodes())for(let o=s.firstChild;o;o=o.nextSibling)r(o)}return r(e),t}function so(e,t){let n=null;for(let r of e.keys())t.has(r)&&(n===null||r.length>n.length)&&(n=r);return n}var io=16,w=new Map;function wn(e){let t=Sn(e);w.has(t)&&w.delete(t);let n={html:document.documentElement.outerHTML,scrollX:typeof window<"u"&&window.scrollX||0,scrollY:typeof window<"u"&&window.scrollY||0};for(w.set(t,n);w.size>io;){let r=w.keys().next().value;w.delete(r)}}function co(e){let t=Sn(e),n=w.get(t);return n==null?null:(w.delete(t),w.set(t,n),typeof n=="string"?{html:n,scrollX:0,scrollY:0}:n)}function Sn(e){let t=new URL(e,location.href);return t.pathname+t.search}async function dt(e,t,n){L&&L.abort(),L=new AbortController;let r=L.signal,s=++S;M&&wn(M);let o=setTimeout(()=>{document.documentElement.setAttribute("data-navigating",""),o=null},150),i=null;t||(i=vn());try{if(t){let c=co(e);if(c){let a=hn(c.html);if(a){An(a,n,!0,null),typeof window<"u"&&window.scrollTo(c.scrollX,c.scrollY),lt(e,n,!1,i,"GET",null,r,s).catch(()=>{});return}}typeof window<"u"&&window.scrollTo(0,0)}await lt(e,n,!t,i,"GET",null,r,s)}finally{o&&clearTimeout(o),s===S&&(document.documentElement.removeAttribute("data-navigating"),typeof location<"u"&&(M=location.href))}}async function ao(e,t,n,r){L&&L.abort(),L=new AbortController;let s=L.signal,o=++S,i=t==="get"||t==="head",c=new URL(e,location.href);if(i){c.search="";for(let[u,p]of n)c.searchParams.append(u,typeof p=="string"?p:p.name)}M&&wn(M);let a=setTimeout(()=>{document.documentElement.setAttribute("data-navigating",""),a=null},150),l=vn();try{await lt(c.href,r,!0,l,i?"GET":t.toUpperCase(),i?null:n,s,o),!i&&o===S&&w.clear()}finally{a&&clearTimeout(a),o===S&&(document.documentElement.removeAttribute("data-navigating"),typeof location<"u"&&(M=location.href))}}function lo(){return[...ve(document.body).keys()].join(",")}async function lt(e,t,n,r,s,o,i,c){s=s||"GET";let a=typeof c=="number"?c:S,l,u=null,p=e;try{let h={"x-webjs-router":"1"},b=lo();b&&(h["x-webjs-have"]=b),t&&(h["x-webjs-frame"]=t);let $={method:s,headers:h,credentials:"same-origin"};i&&($.signal=i),o!=null&&s!=="GET"&&s!=="HEAD"&&($.body=o);let y=await fetch(e,$),f=y.headers.get("content-type")||"",D=/^text\/html\b/i.test(f);if(y.redirected&&y.url&&(p=y.url),y.status===204||y.status===205){a===S&&n&&history.pushState(null,"",p);return}if(!D){a===S&&(location.href=e);return}u=y.headers.get("x-webjs-build"),l=await y.text()}catch(h){if(h&&h.name==="AbortError"||a!==S)return;ho(r),location.href=e;return}if(a!==S)return;let d=hn(l);if(!d){location.href=e;return}if(An(d,t,!1,p,u),n&&history.pushState(null,"",p),n){let h=new URL(p);if(h.hash){let b=document.getElementById(h.hash.slice(1));b?b.scrollIntoView():window.scrollTo(0,0)}else window.scrollTo(0,0)}document.dispatchEvent(new CustomEvent("webjs:navigate",{detail:{url:p,frameId:t}}))}function ln(e){if(!e||!e.head)return"";let t=e.head.querySelectorAll('[data-webjs-track="reload"]');if(!t.length)return"";let n="";for(let r of t)n+=U(r);return n}function An(e,t,n,r,s){try{typeof sessionStorage<"u"&&(!r||t||n)&&sessionStorage.removeItem("webjs:importmap-reload")}catch{}if(r&&!t&&!n){let u=document.querySelector('script[type="importmap"]'),p=u?u.getAttribute("data-webjs-build"):null,d=!1;if(s&&p&&(d=s!==p),!d&&e.head&&e.head.children.length>0){let h=ln(document),b=ln(e);h!==b&&(d=!0)}if(d&&typeof location<"u")try{let h="webjs:importmap-reload";if(sessionStorage&&sessionStorage.getItem(h))sessionStorage.removeItem(h);else{sessionStorage&&sessionStorage.setItem(h,"1"),location.href=r;return}}catch{location.href=r;return}else if(!d)try{typeof sessionStorage<"u"&&sessionStorage.removeItem("webjs:importmap-reload")}catch{}}if(t){let u=document.querySelector(`webjs-frame#${CSS.escape(t)}`),p=e.querySelector(`webjs-frame#${CSS.escape(t)}`);if(u&&p){fn(e.head),po(u,p),ft(u),Ce(u),dn(e.body),at();return}}let o=ve(document.body),i=ve(e.body),c=so(o,i);if(c){fn(e.head),uo(o.get(c),i.get(c),e),dn(e.body),at();return}mo(e.head);let a=[...e.body.childNodes],l=()=>{document.body.replaceChildren(...a),ft(document.body),Ce(document.body),at()};document.startViewTransition?document.startViewTransition(l).finished.then(()=>Ce(document.body)).catch(()=>{}):l()}function at(){let e=document.activeElement;!e||e===document.body||e===document.documentElement||typeof e.blur=="function"&&e.blur()}function uo(e,t,n){if(!e||!t)return;let r=e.start.parentNode;if(!r)return;let s=[];for(let i=e.start.nextSibling;i&&i!==e.end;i=i.nextSibling)s.push(i);let o=[];for(let i=t.start.nextSibling;i&&i!==t.end;i=i.nextSibling)o.push(document.importNode(i,!0));fo(r,e.start,e.end,s,o);for(let i=e.start.nextSibling;i&&i!==e.end;i=i.nextSibling)i.nodeType===1&&(ft(i),Ce(i))}function fo(e,t,n,r,s){let o=new Map;for(let a of r){if(a.nodeType!==1)continue;let l=ie(a);l&&o.set(l,a)}let i=n,c=[];for(let a of s){if(a.nodeType===1){let l=ie(a);if(l&&o.has(l)){let u=o.get(l);ut(u,a),c.push(u),o.delete(l);continue}}c.push(a)}for(let a of r)if(a.parentNode===e){if(a.nodeType===1&&c.includes(a))continue;e.removeChild(a)}for(let a of c)e.insertBefore(a,i)}function ut(e,t){if(e.tagName!==t.tagName){e.replaceWith(t);return}let n=new Set;for(let r of t.attributes)n.add(r.name),!un.has(r.name)&&e.getAttribute(r.name)!==r.value&&e.setAttribute(r.name,r.value);for(let r of[...e.attributes])un.has(r.name)||n.has(r.name)||e.removeAttribute(r.name);Cn(e,t)}function Cn(e,t){let n=[...e.childNodes],r=[...t.childNodes].map(c=>document.importNode(c,!0)),s=new Map;for(let c of n){if(c.nodeType!==1)continue;let a=ie(c);a&&s.set(a,c)}let o=[];for(let c=0;c<r.length;c++){let a=r[c];if(a.nodeType===1){let l=ie(a);if(l&&s.has(l)){let p=s.get(l);ut(p,a),o.push(p),s.delete(l);continue}let u=n[c];if(u&&u.nodeType===1&&!ie(u)&&u.tagName===a.tagName){ut(u,a),o.push(u);continue}}else if(a.nodeType===3){let l=n[c];if(l&&l.nodeType===3){l.nodeValue!==a.nodeValue&&(l.nodeValue=a.nodeValue),o.push(l);continue}}else if(a.nodeType===8){let l=n[c];if(l&&l.nodeType===8){l.nodeValue!==a.nodeValue&&(l.nodeValue=a.nodeValue),o.push(l);continue}}o.push(a)}let i=new Set(o);for(let c of n)!i.has(c)&&c.parentNode===e&&e.removeChild(c);for(let c=0;c<o.length;c++){let a=o[c];(a.parentNode!==e||e.childNodes[c]!==a)&&e.insertBefore(a,e.childNodes[c]||null)}}function ie(e){let t=e.getAttribute("data-key");return t?`${e.tagName}:k:${t}`:e.id?`${e.tagName}:i:${e.id}`:null}var un=new Set(["value","checked","selected","indeterminate","disabled","open","popover"]);function vn(){let e=ve(document.body);if(e.size===0)return null;let t=null;for(let i of e.keys())(t===null||i.length>t.length)&&(t=i);if(t===null)return null;let n=document.getElementById(`wj-loading:${t}`);if(!(n instanceof HTMLTemplateElement))return null;let r=e.get(t),s=[];for(let i=r.start.nextSibling;i&&i!==r.end;i=i.nextSibling)s.push(i);let o=document.createRange();return o.setStartAfter(r.start),o.setEndBefore(r.end),o.deleteContents(),r.start.parentNode.insertBefore(n.content.cloneNode(!0),r.end),{slot:r,oldChildren:s,token:S}}function ho(e){if(!e||e.token!==S)return;let{slot:t,oldChildren:n}=e;if(t.start.parentNode!==t.end.parentNode)return;let r=document.createRange();r.setStartAfter(t.start),r.setEndBefore(t.end),r.deleteContents();for(let s of n)t.start.parentNode.insertBefore(s,t.end)}function po(e,t){Cn(e,t)}function Nn(){if(typeof document>"u")return"";let e=document.querySelector('meta[name="csp-nonce"]');return e&&e.getAttribute("content")||""}function ht(e){let t=document.createElement("script");for(let r of e.attributes)r.name!=="nonce"&&t.setAttribute(r.name,r.value);let n=Nn();return n&&t.setAttribute("nonce",n),t.textContent=e.textContent,t}function kn(e){if(!e.hasAttribute("nonce"))return e.cloneNode(!0);let t=e.cloneNode(!0),n=Nn();return n?t.setAttribute("nonce",n):t.removeAttribute("nonce"),t}function U(e){if(!e.hasAttribute("nonce"))return e.outerHTML;let t=e.cloneNode(!0);return t.removeAttribute("nonce"),t.outerHTML}function fn(e){let t=e.querySelector("title");t&&(document.title=t.textContent||"");let n=new Set;for(let r of document.head.children)n.add(U(r));for(let r of e.children)r.tagName==="SCRIPT"&&r.getAttribute("type")==="importmap"||r.tagName!=="BASE"&&r.tagName!=="TITLE"&&(n.has(U(r))||(r.tagName==="SCRIPT"?document.head.appendChild(ht(r)):document.head.appendChild(kn(r))))}function mo(e){let t=document.head,n=e.querySelector("title");n&&(document.title=n.textContent||"");let r=new Set;for(let o of t.children)o.tagName==="SCRIPT"&&o.getAttribute("type")==="importmap"||o.tagName!=="BASE"&&r.add(U(o));let s=new Set;for(let o of e.children)o.tagName==="SCRIPT"&&o.getAttribute("type")==="importmap"||o.tagName!=="BASE"&&s.add(U(o));for(let o of[...t.children])o.tagName==="SCRIPT"&&o.getAttribute("type")==="importmap"||o.tagName!=="BASE"&&o.tagName!=="TITLE"&&(s.has(U(o))||o.remove());for(let o of e.children)o.tagName==="SCRIPT"&&o.getAttribute("type")==="importmap"||o.tagName!=="BASE"&&o.tagName!=="TITLE"&&(r.has(U(o))||(o.tagName==="SCRIPT"?t.appendChild(ht(o)):t.appendChild(kn(o))))}function Ce(e){typeof customElements>"u"||En(e)}function En(e){let t=e instanceof Element?[e,...e.querySelectorAll("*")]:[...e.querySelectorAll("*")];for(let n of t)n.tagName&&n.tagName.includes("-")&&(customElements.upgrade(n),n.shadowRoot&&En(n.shadowRoot))}function dn(e){for(let t of e.querySelectorAll("template[data-webjs-resolve]"))document.body.appendChild(t.cloneNode(!0))}function ft(e){for(let t of e.querySelectorAll("script"))t.replaceWith(ht(t))}var go=Symbol.for("webjs.context");function yo(e){return{__context__:go,name:e}}var Ne=class extends Event{constructor(t,n,r=!1){super("context-request",{bubbles:!0,composed:!0}),this.context=t,this.callback=n,this.subscribe=r}},pt=class{constructor(t,{context:n,initialValue:r}){this._host=t,this._context=n,this._value=r,this._subscriptions=new Set,this._onRequest=s=>{let o=s;if(o.context===this._context)if(s.stopPropagation(),o.subscribe){let i={callback:o.callback},c=()=>{this._subscriptions.delete(i)};this._subscriptions.add(i),o.callback(this._value,c)}else o.callback(this._value)},typeof t.addController=="function"&&t.addController(this)}get value(){return this._value}setValue(t){if(!Object.is(this._value,t)){this._value=t;for(let n of this._subscriptions){let r=()=>{this._subscriptions.delete(n)};n.callback(t,r)}}}hostConnected(){this._host.addEventListener("context-request",this._onRequest)}hostDisconnected(){this._host.removeEventListener("context-request",this._onRequest),this._subscriptions.clear()}},mt=class{constructor(t,{context:n,subscribe:r=!0}){this._host=t,this._context=n,this._subscribe=r,this._value=void 0,this._unsubscribe=void 0,typeof t.addController=="function"&&t.addController(this)}get value(){return this._value}hostConnected(){this._dispatchRequest()}hostDisconnected(){this._unsubscribe&&(this._unsubscribe(),this._unsubscribe=void 0)}_dispatchRequest(){let t=new Ne(this._context,(n,r)=>{let s=this._value;this._value=n,r&&(this._unsubscribe=r),!Object.is(s,n)&&typeof this._host.requestUpdate=="function"&&this._host.requestUpdate()},this._subscribe);this._host.dispatchEvent(t)}};var E={INITIAL:0,PENDING:1,COMPLETE:2,ERROR:3},gt=class{constructor(t,{task:n,args:r,autoRun:s=!0}){this._host=t,this._taskFn=n,this._argsFn=r||(()=>[]),this._autoRun=s,this._status=E.INITIAL,this._value=void 0,this._error=void 0,this._abortController=null,this._prevArgs=null,typeof t.addController=="function"&&t.addController(this)}get status(){return this._status}get value(){return this._value}get error(){return this._error}async run(){this.abort();let t=new AbortController;this._abortController=t;let n=this._argsFn();this._prevArgs=n,this._status=E.PENDING,this._error=void 0,this._requestHostUpdate();try{let r=await this._taskFn(...n,{signal:t.signal});if(t.signal.aborted)return;this._value=r,this._status=E.COMPLETE,this._error=void 0}catch(r){if(t.signal.aborted)return;this._error=r,this._status=E.ERROR,this._value=void 0}finally{this._abortController===t&&(this._abortController=null)}this._requestHostUpdate()}abort(){this._abortController&&(this._abortController.abort(),this._abortController=null)}render(t={}){switch(this._status){case E.INITIAL:return t.initial?.();case E.PENDING:return t.pending?.();case E.COMPLETE:return t.complete?.(this._value);case E.ERROR:return t.error?.(this._error);default:return}}hostUpdate(){if(!this._autoRun)return;let t=this._argsFn();this._argsEqual(this._prevArgs,t)||this.run()}hostUpdated(){}hostConnected(){}hostDisconnected(){this.abort()}_requestHostUpdate(){typeof this._host.requestUpdate=="function"&&this._host.requestUpdate()}_argsEqual(t,n){if(t===null||t.length!==n.length)return!1;for(let r=0;r<t.length;r++)if(t[r]!==n[r])return!1;return!0}};export{mt as ContextConsumer,pt as ContextProvider,Ne as ContextRequestEvent,m as MARKER,G as Signal,zr as Suspense,gt as Task,E as TaskStatus,ot as WebComponent,it as WebjsFrame,xe as adoptStyles,Er as allTags,Vn as batch,zn as computed,Gr as connectWS,yo as createContext,Wr as cspNonce,xn as css,en as deserialize,Zr as disableClientRouter,Gn as effect,pn as enableClientRouter,jn as escapeAttr,On as escapeText,Tn as html,Te as isCSS,kr as isLazy,je as isLive,Hr as isNotFound,Vr as isRedirect,Re as isRepeat,Kn as isSignal,Kr as isSuspense,_ as isTemplate,Oe as isUnsafeHTML,Pn as live,vr as lookup,Nr as lookupModuleUrl,Qr as navigate,Dr as notFound,se as parse,Cr as primeModuleUrl,qr as redirect,nt as register,be as render,Ln as repeat,eo as revalidate,Jr as richFetch,Qt as serialize,Wn as signal,rt as stringify,Rn as stylesToString,Se as tagOf,Mn as unsafeHTML};
|
|
3
|
+
`)}</style>`}function On(e){return String(e).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}function jn(e){return String(e).replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<")}var _t=Symbol.for("webjs.repeat");function Ln(e,t,n){return{[_t]:!0,items:[...e],keyFn:t,templateFn:n}}function Re(e){return!!e&&typeof e=="object"&&e[_t]===!0}function Mn(e){return{_$webjs:"unsafe-html",value:String(e??"")}}function Oe(e){return!!e&&typeof e=="object"&&e._$webjs==="unsafe-html"}function Pn(e){return{_$webjs:"live",value:e}}function je(e){return!!e&&typeof e=="object"&&e._$webjs==="live"}function Le(e){return!!e&&typeof e=="object"&&e._$webjs==="keyed"}function Me(e){return!!e&&typeof e=="object"&&e._$webjs==="guard"}function wt(e){return!!e&&typeof e=="object"&&e._$webjs==="template-content"}function Pe(e){return!!e&&typeof e=="object"&&e._$webjs==="ref"}function Ie(e){return!!e&&typeof e=="object"&&e._$webjs==="cache"}function Be(e){return!!e&&typeof e=="object"&&e._$webjs==="until"}function St(e){return!!e&&typeof e=="object"&&e._$webjs==="async-append"}function At(e){return!!e&&typeof e=="object"&&e._$webjs==="async-replace"}function Fe(e){return!!e&&typeof e=="object"&&e._$webjs==="watch"}var C=null,T=!1,V=0,H=null,Ue=0,Ct=(e,t)=>Object.is(e,t),ae=()=>{},vt=()=>!1;function Nt(e,t){e.liveConsumers||(e.liveConsumers=new Set);let n=e.liveConsumers.size===0;if(e.liveConsumers.add(t),n){if(e.producers&&e.producers.length>0)for(let r of e.producers)Nt(r,e);if(e.watched)try{e.watched.call(e.wrapper)}catch(r){console.error(r)}}}function z(e,t){if(e.liveConsumers&&(e.liveConsumers.delete(t),e.liveConsumers.size===0)){if(e.producers&&e.producers.length>0)for(let n of e.producers)z(n,e);if(e.unwatched)try{e.unwatched.call(e.wrapper)}catch(n){console.error(n)}}}function We(e){if(T)throw new Error("Signal read during notification phase");if(C===null)return;let t=C,n=t.nextProducerIndex++;n<t.producers.length&&t.producers[n]!==e&&qe(t)&&z(t.producers[n],t),t.producers[n]!==e&&(t.producers[n]=e,qe(t)&&Nt(e,t)),t.producerLastReadVersions[n]=e.version}function qe(e){return e.consumerIsAlwaysLive||e.liveConsumers&&e.liveConsumers.size>0}function kt(e){if(!e.liveConsumers||e.liveConsumers.size===0)return;let t=T;T=!0;try{for(let n of e.liveConsumers)n.dirty||In(n)}finally{T=t}}function In(e){e.dirty=!0,kt(e),e.consumerMarkedDirty.call(e.wrapper||e)}function le(e){if(!(!e.dirty&&e.lastCleanEpoch===V)){if(!e.producerMustRecompute()&&!Bn(e)){e.dirty=!1,e.lastCleanEpoch=V;return}e.producerRecomputeValue(),e.dirty=!1,e.lastCleanEpoch=V}}function Bn(e){for(let t=0;t<e.producers.length;t++){let n=e.producers[t],r=e.producerLastReadVersions[t];if(r!==n.version||(le(n),r!==n.version))return!0}return!1}function He(e){e&&(e.nextProducerIndex=0);let t=C;return C=e,t}function Ve(e,t){if(C=t,!!e){if(qe(e))for(let n=e.nextProducerIndex;n<e.producers.length;n++)z(e.producers[n],e);for(;e.producers.length>e.nextProducerIndex;)e.producers.pop(),e.producerLastReadVersions.pop()}}var ue=class{constructor(t,n){this.__value=t,this.version=0,this.lastCleanEpoch=V,this.dirty=!1,this.producers=[],this.producerLastReadVersions=[],this.liveConsumers=void 0,this.consumerAllowSignalWrites=!0,this.consumerIsAlwaysLive=!1,this.producerMustRecompute=vt,this.producerRecomputeValue=ae,this.consumerMarkedDirty=ae,this.wrapper=this,this.__isSignal=!0,this.__equal=n?.equals||Ct,this.watched=n?.[ze],this.unwatched=n?.[Ke]}get(){return We(this),this.__value}peek(){return this.__value}set(t){if(T)throw new Error("Signal write during notification phase");this.__equal.call(this,this.__value,t)||(this.__value=t,this.version++,V++,H!==null?Et(this):kt(this))}};function Et(e){let t=T;T=!0;try{if(!e.liveConsumers)return;for(let n of e.liveConsumers)n.dirty||(n.dirty=!0,n.__isWatcher?H.add(n):Et(n))}finally{T=t}}var $e=Symbol("unset"),De=Symbol("computing"),ce=Symbol("errored"),K=class{constructor(t,n){this.__fn=t,this.__value=$e,this.__error=null,this.version=0,this.lastCleanEpoch=-1,this.dirty=!0,this.producers=[],this.producerLastReadVersions=[],this.nextProducerIndex=0,this.liveConsumers=void 0,this.consumerAllowSignalWrites=!1,this.consumerIsAlwaysLive=!1,this.wrapper=this,this.__isSignal=!0,this.__isComputed=!0,this.__equal=n?.equals||Ct,this.watched=n?.[ze],this.unwatched=n?.[Ke];let r=this;this.producerMustRecompute=function(){return r.__value===$e||r.__value===De},this.producerRecomputeValue=function(){if(r.__value===De)throw new Error("Detected cycle in computations.");let s=r.__value;r.__value=De;let o=He(r),i,c=!1;try{i=r.__fn.call(r.wrapper)}catch(l){i=ce,r.__error=l,c=!0}finally{Ve(r,o)}if(!c&&(s!==$e&&s!==ce)&&r.__equal.call(r.wrapper,s,i)){r.__value=s;return}r.__value=i,r.version++},this.consumerMarkedDirty=ae}get(){if(le(this),We(this),this.__value===ce)throw this.__error;return this.__value}peek(){if(le(this),this.__value===ce)throw this.__error;return this.__value}},fe=class{constructor(t){this.__notify=t,this.version=0,this.lastCleanEpoch=V,this.dirty=!1,this.producers=[],this.producerLastReadVersions=[],this.nextProducerIndex=0,this.liveConsumers=void 0,this.consumerAllowSignalWrites=!1,this.consumerIsAlwaysLive=!0,this.producerMustRecompute=vt,this.producerRecomputeValue=ae,this.wrapper=this,this.__isWatcher=!0;let n=this;this.consumerMarkedDirty=function(){n.__fire()}}__fire(){this.__notify&&this.__notify.call(this)}watch(...t){if(t.length===0){this.dirty=!1;return}let n=He(this);try{for(let r of t)We(r),r.__isComputed&&le(r)}finally{Ve(this,n)}this.dirty=!1}unwatch(...t){for(let n=this.producers.length-1;n>=0;n--)t.includes(this.producers[n])&&(z(this.producers[n],this),this.producers.splice(n,1),this.producerLastReadVersions.splice(n,1),this.nextProducerIndex=Math.min(this.nextProducerIndex,this.producers.length))}getPending(){return this.producers.filter(t=>t.__isComputed&&t.dirty)}observe(t){let n=He(this),r;try{r=t()}finally{Ve(this,n)}return this.dirty=!1,r}dispose(){for(let t of this.producers)z(t,this);this.producers=[],this.producerLastReadVersions=[],this.__notify=null}},ze=Symbol("watched"),Ke=Symbol("unwatched");function Fn(e){let t=C;C=null;try{return e()}finally{C=t}}function Un(e){return e.producers.slice()}function $n(e){return e.liveConsumers?[...e.liveConsumers]:[]}function Dn(e){return!!e.liveConsumers&&e.liveConsumers.size>0}function qn(e){return e.producers.length>0}function Hn(){return C&&C.__isComputed?C:null}function Vn(e){Ue++,H===null&&(H=new Set);try{e()}finally{if(Ue--,Ue===0){let t=H;H=null;for(let n of t)n.__fire()}}}var G={State:ue,Computed:K,subtle:{Watcher:fe,untrack:Fn,introspectSources:Un,introspectSinks:$n,hasSinks:Dn,hasSources:qn,currentComputed:Hn,watched:ze,unwatched:Ke}};function Wn(e,t){return new ue(e,t)}function zn(e,t){return new K(e,t)}function Kn(e){return!!(e&&typeof e=="object"&&e.__isSignal===!0)}function Gn(e){let t=!1,n=!1,r=new K(e),s=new fe(()=>{t||n||(t=!0,queueMicrotask(()=>{if(t=!1,!n){try{r.get()}catch(o){console.error(o)}s.watch()}}))});s.watch(r);try{r.get()}catch(o){console.error(o)}return()=>{n||(n=!0,s.dispose())}}var Yn=`${m}s`,Jn=`${m}e`;function Tt(e){if(!e||e.nodeType!==8)return!1;let t=e.nodeValue;return t===Yn||t===Jn}function Xn(e){for(let t of e.addedNodes)if(Tt(t))return!0;for(let t of e.removedNodes)if(Tt(t))return!0;return!1}function Lt(){return typeof HTMLElement<"u"&&typeof HTMLSlotElement<"u"}var J=Lt(),P=Symbol("webjs.slot.state"),x="data-webjs-light",I="data-projection",X="actual",Mt="fallback",me=Symbol("webjs.slot.fallbackFrag"),Zn=64,Y=null,Ge=null,de=null,xt=!1;function Qn(){xt||(J=Lt(),J&&(Y=HTMLSlotElement.prototype.assignedNodes,Ge=HTMLSlotElement.prototype.assignedElements,de=Object.getOwnPropertyDescriptor(Element.prototype,"assignedSlot"),HTMLSlotElement.prototype.assignedNodes=function(t){return this.hasAttribute(x)&&!Rt(this)?Ye(this,t):Y?Y.call(this,t):[]},HTMLSlotElement.prototype.assignedElements=function(t){return this.hasAttribute(x)&&!Rt(this)?Ye(this,t).filter(n=>n.nodeType===1):Ge?Ge.call(this,t):[]},Object.defineProperty(Element.prototype,"assignedSlot",{configurable:!0,enumerable:!0,get:function(){let t=de&&de.get?de.get.call(this):null;return t||er(this)}}),xt=!0))}Qn();function Rt(e){let t=e;for(let n=0;n<128;n++){let r=t.parentNode;if(!r||r===t)return!1;if(r.host)return!0;t=r}return!1}function Ye(e,t){if(e.getAttribute(I)===Mt)return[];let n=Array.from(e.childNodes);return!t||!t.flatten?n:Je(n,new Set,0)}function Je(e,t,n){if(n>=Zn)return e.slice();let r=[];for(let s of e)if(s.nodeType===1&&s.tagName==="SLOT"){let o=s;if(t.has(o))continue;if(t.add(o),o.hasAttribute(x)){let i=Ye(o,{flatten:!1});if(i.length>0)for(let c of Je(i,t,n+1))r.push(c);else for(let c of Je(Array.from(o.childNodes),t,n+1))r.push(c)}else if(Y){let i=Y.call(o,{flatten:!0});for(let c of i)r.push(c)}else r.push(s)}else r.push(s);return r}function er(e){let t=e.parentElement;for(;t;){if(t.tagName==="SLOT"&&t.hasAttribute(x))return t.getAttribute(I)===X?t:null;t=t.parentElement}return null}function R(e){let t=e,n=t[P];return n||(n={assignedByName:new Map,pendingByName:new Map,lastSnapshot:new WeakMap,nameObservers:new WeakMap,childObserver:null,scheduled:!1,ownedSlots:new Set},t[P]=n),n}function Xe(e){return!!e[P]}function Pt(e){let t=R(e);for(;e.firstChild;){let n=e.firstChild,r=he(n);pe(t.assignedByName,r,n),e.removeChild(n)}}function It(e){let t=R(e),n=e.querySelectorAll(`slot[${x}]`);for(let r of n){let s=r;if(s.getAttribute(I)!==X)continue;let o=s.getAttribute("name")||null;if(!t.assignedByName.has(o)){let i=Array.from(s.childNodes);t.assignedByName.set(o,i),t.lastSnapshot.set(s,i.slice())}}}function he(e){if(e.nodeType!==1)return null;let n=e.getAttribute("slot");return n||null}function pe(e,t,n){let r=e.get(t);r||(r=[],e.set(t,r)),r.push(n)}function Bt(e,t,n){if(!n.length)return;let r=e.get(t);r||(r=[],e.set(t,r));for(let s of n)r.push(s)}function Ft(e){if(!J)return;let t=R(e);t.childObserver||(t.childObserver=new MutationObserver(n=>{let r=!1;for(let s of n)if(!Xn(s)){if(s.type==="childList"){for(let o of s.addedNodes)o.parentElement===e&&(pe(t.assignedByName,he(o),o),r=!0);for(let o of s.removedNodes)e.contains(o)||Ot(t,o)&&(r=!0)}else if(s.type==="attributes"&&s.attributeName==="slot"){let o=s.target;(Ot(t,o)||o.parentElement===e)&&(pe(t.assignedByName,he(o),o),r=!0)}}r&&ge(e)}),t.childObserver.observe(e,{childList:!0,attributes:!0,attributeFilter:["slot"],subtree:!0}))}function Ut(e){let t=e[P];if(t){t.childObserver&&(t.childObserver.disconnect(),t.childObserver=null);for(let n of t.ownedSlots){let r=t.nameObservers.get(n);r&&(r.disconnect(),t.nameObservers.delete(n))}}}function Ot(e,t){for(let[n,r]of e.assignedByName){let s=r.indexOf(t);if(s!==-1)return r.splice(s,1),r.length===0&&e.assignedByName.delete(n),!0}return!1}function ge(e){let t=R(e);t.scheduled||(t.scheduled=!0,queueMicrotask(()=>{t.scheduled=!1,tr(e)}))}function tr(e){if(!J)return;let t=e[P];if(!t)return;let n=Array.from(e.querySelectorAll(`slot[${x}]`)),r=new Set(n);for(let i of t.ownedSlots)r.has(i)||nr(t,i);for(let i of r)t.ownedSlots.has(i)||sr(e,i);t.ownedSlots=r;let s=new Map;for(let i of n){let c=i.getAttribute("name")||null,a=s.get(c);a||(a=[],s.set(c,a)),a.push(i)}for(let i of s.keys()){let c=t.pendingByName.get(i);if(c&&c.length){let a=t.assignedByName.get(i)||[],l=[];for(let u of c)l.push(u);for(let u of a)l.indexOf(u)===-1&&l.push(u);t.assignedByName.set(i,l),t.pendingByName.delete(i)}}let o=[];for(let[i,c]of s){let a=t.assignedByName.get(i)||[];for(let l=0;l<c.length;l++){let u=c[l];l===0&&a.length>0?rr(t,u,a)&&o.push(u):or(t,u)&&o.push(u)}}for(let i of o)ir(i)}function nr(e,t){let n=e.nameObservers.get(t);n&&(n.disconnect(),e.nameObservers.delete(t));let r=e.lastSnapshot.get(t);if(r&&r.length>0){let s=t.getAttribute("name")||null;Bt(e.pendingByName,s,r)}e.lastSnapshot.delete(t)}function rr(e,t,n){let r=t.getAttribute(I)!==X,s=e.lastSnapshot.get(t)||[];if(!r&&cr(s,n))return!1;let i=t[me];if(r&&i)for(;t.firstChild;)i.appendChild(t.firstChild);else for(;t.firstChild;)t.removeChild(t.firstChild);for(let c of n)t.appendChild(c);return t.setAttribute(I,X),e.lastSnapshot.set(t,n.slice()),!0}function or(e,t){let n=t.getAttribute(I)===X;if(t.setAttribute(I,Mt),!n)return jt(t),!1;for(e.lastSnapshot.delete(t);t.firstChild;)t.removeChild(t.firstChild);return jt(t),!0}function jt(e){let t=e[me];!t||t.childNodes.length===0||e.appendChild(t)}function sr(e,t){if(!J)return;let n=R(e);if(n.nameObservers.has(t))return;let r=new MutationObserver(()=>ge(e));r.observe(t,{attributes:!0,attributeFilter:["name"]}),n.nameObservers.set(t,r)}function $t(e,t){if(!Xe(e))return;let n=R(e),r=n.lastSnapshot.get(t);if(!r||r.length===0)return;let s=t.getAttribute("name")||null;for(let i of r)i.parentNode===t&&t.removeChild(i);Bt(n.pendingByName,s,r),n.lastSnapshot.delete(t);let o=n.nameObservers.get(t);o&&(o.disconnect(),n.nameObservers.delete(t)),n.ownedSlots.delete(t)}function ir(e){e.dispatchEvent(new Event("slotchange",{bubbles:!0,composed:!1}))}function cr(e,t){if(e===t)return!0;if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}var Dt=new WeakMap,Ze=Symbol.for("webjs.instance");function be(e,t){let n=t,r=n[Ze];if(_(e)){let s=e;if(r&&r.strings===s.strings){ee(r,s.values);return}r&&qt(r,t);let o=t.firstChild;o&&o.nodeType===8&&o.data==="webjs-hydrate"&&o.remove();let i=ur(s,t);n[Ze]=i;return}if(r&&qt(r,t),n[Ze]=null,t.replaceChildren(),!(e==null||e===!1||e===!0)){if(Array.isArray(e)){for(let s of e){let o=document.createTextNode(String(s??""));t.appendChild(o)}return}t.appendChild(document.createTextNode(String(e)))}}function Z(e){let{strings:t}=e,n=Dt.get(t);if(n)return n;let r=[],s="",o="text",i="",c=0,a="",l=0,u=null,p="",d="";for(let b=0;b<t.length;b++){let $=t[b];for(let y=0;y<$.length;y++){let f=$[y];switch(o){case"text":s+=f,f==="<"&&(o="tag-open");break;case"tag-open":s+=f,f==="!"?o="bang-1":f==="/"?(o="tag-name",p=""):/[a-zA-Z]/.test(f)?(o="tag-name",p=f.toLowerCase()):o="text";break;case"bang-1":s+=f,o=f==="-"?"bang-dash":"tag-name";break;case"bang-dash":s+=f,f==="-"?(o="comment",l=0):o="tag-name";break;case"comment":s+=f,f==="-"?l+=1:(f===">"&&l>=2&&(o="text"),l=0);break;case"tag-name":s+=f,f===">"?(o=p==="script"||p==="style"?"rawtext":"text",o==="rawtext"&&(d="")):/\s/.test(f)?o="in-tag":p+=f.toLowerCase();break;case"in-tag":s+=f,f===">"?(o=p==="script"||p==="style"?"rawtext":"text",o==="rawtext"&&(d="")):!/\s/.test(f)&&f!=="/"&&(o="attr-name",i=f,c=s.length-1);break;case"rawtext":s+=f,d=(d+f.toLowerCase()).slice(-9),(d.endsWith("<\/script>")||d.endsWith("</style>"))&&(o="text",d="",p="");break;case"attr-name":f==="="?(o="after-eq",s+=f):/\s/.test(f)?(o="in-tag",i="",s+=f):f===">"?(o="text",i="",s+=f):(i+=f,s+=f);break;case"after-eq":f==='"'||f==="'"?(o="attr-quoted",a=f,s+=f):/\s/.test(f)?(o="in-tag",i="",s+=f):f===">"?(o="text",i="",s+=f):(o="attr-unquoted",s+=f);break;case"attr-unquoted":/\s/.test(f)?(o="in-tag",i="",s+=f):(f===">"&&(o="text",i=""),s+=f);break;case"attr-quoted":s+=f,f===a&&(o="in-tag",i="");break;case"skip-attr":if(f===a){if(u){let D=u.firstPartIdx,A=[];for(let k=D;k<r.length;k++)(r[k].kind==="noop"||r[k].kind==="attr-mixed")&&A.push(k);let q=[],ke=t[A[0]],yt=ke.lastIndexOf(a);q.push(yt>=0?ke.slice(yt+1):ke);for(let k=1;k<A.length;k++)q.push(t[A[k]]);let Ee=t[A[A.length-1]+1],bt=Ee.indexOf(a);q.push(bt>=0?Ee.slice(0,bt):Ee),r[D]={kind:"attr-mixed",path:[],name:u.name,statics:q,group:A},u=null}o="in-tag",i=""}break}}if(b<t.length-1){let y=r.length;if(o==="comment"){l=0,r.push({kind:"noop",path:[]});continue}if(o==="rawtext"){d="",r.push({kind:"noop",path:[]});continue}if(o==="text")s+=`<!--${m}${y}-->`,r.push({kind:"child",path:[]});else if(o==="in-tag"){let f=`data-${m}${y}`;s+=`${f}=""`,r.push({kind:"element",path:[]})}else if(o==="after-eq"){let f=i[0],D=i.slice(1);if(f==="@"||f==="."||f==="?"){s=s.slice(0,c);let A=f==="@"?"event":f==="."?"prop":"bool",q=`data-${m}${y}`;s+=`${q}=""`,r.push({kind:A,path:[],name:D})}else{s=s.slice(0,c);let A=`data-${m}${y}`;s+=`${A}=""`,r.push({kind:"attr",path:[],name:i})}o="in-tag",i=""}else if(o==="attr-quoted"||o==="attr-unquoted"){s=s.slice(0,c);let f=`data-${m}${y}`;s+=`${f}=""`,u={name:i,firstPartIdx:y},r.push({kind:"noop",path:[]}),o="skip-attr"}else o==="skip-attr"&&r.push({kind:"noop",path:[]})}}let h=document.createElement("template");return h.innerHTML=s,ar(h.content,r),lr(h.content,r),n={templateEl:h,parts:r},Dt.set(t,n),n}function ar(e,t){let n=e.querySelectorAll("slot");for(let r of n){r.setAttribute(x,"");let s=t.length;r.setAttribute(`data-${m}${s}`,""),t.push({kind:"slot",path:[]})}}function lr(e,t){let n=[];function r(s){for(let o=0;o<s.childNodes.length;o++){let i=s.childNodes[o];if(n.push(o),i.nodeType===8){let c=i.data;if(c.startsWith(m)){let a=Number(c.slice(m.length));t[a]&&t[a].kind==="child"&&(t[a].path=n.slice())}}else if(i.nodeType===1){let c=i,a=[];for(let l of c.attributes)if(l.name.startsWith(`data-${m}`)){let u=Number(l.name.slice(`data-${m}`.length));t[u]&&t[u].kind!=="child"&&(t[u].path=n.slice()),a.push(l.name)}for(let l of a)c.removeAttribute(l);r(i)}n.pop()}}r(e)}function ur(e,t){let{templateEl:n,parts:r}=Z(e),s=n.content.cloneNode(!0),o=document.createComment(`${m}s`),i=document.createComment(`${m}e`),c=r.map(l=>Q(l,s)),a=[];for(let l=0;l<e.values.length;l++)O(c[l],e.values[l],void 0,e.values),a.push(e.values[l]);t.replaceChildren(o,...s.childNodes,i);for(let l of c)l.kind==="slot"&&O(l,void 0,void 0,[]);return{strings:e.strings,bound:c,lastValues:a,startNode:o,endNode:i}}function Q(e,t){if(e.kind==="noop")return{kind:"noop"};let n=t;for(let s of e.path)n=n.childNodes[s];if(e.kind==="child")return{kind:"child",marker:n};let r=n;if(e.kind==="event"){let s={kind:"event",el:r,name:e.name||"",handler:null,dispatcher(o){s.handler?.(o)}};return r.addEventListener(s.name,s.dispatcher),s}if(e.kind==="attr")return{kind:"attr",el:r,name:e.name||""};if(e.kind==="attr-mixed")return{kind:"attr-mixed",el:r,name:e.name||"",statics:e.statics||[],group:e.group||[]};if(e.kind==="prop")return{kind:"prop",el:r,name:e.name||""};if(e.kind==="bool")return{kind:"bool",el:r,name:e.name||""};if(e.kind==="element")return{kind:"element",el:r};if(e.kind==="slot")return{kind:"slot",slotEl:r,applied:!1};throw new Error(`unknown part kind ${e.kind}`)}function ee(e,t){for(let n=0;n<t.length;n++){let r=t[n];Object.is(r,e.lastValues[n])||(O(e.bound[n],r,e.lastValues[n],t),e.lastValues[n]=r)}}function qt(e,t){for(let n of e.bound){if(n.kind==="event"&&n.el.removeEventListener(n.name,n.dispatcher),n.kind==="element"){let r=n.lastTarget;if(r){if(typeof r=="function")try{r(void 0)}catch{}else typeof r=="object"&&(r.value=void 0);n.lastTarget=void 0,n.__lastEl=void 0}}if(n.kind==="slot"){let r=Qe(n.slotEl);r&&$t(r,n.slotEl)}}t.replaceChildren()}function O(e,t,n,r){if(je(t)){let s=t.value;if(e.kind==="prop"&&e.el[e.name]===s||e.kind==="attr"&&e.el.getAttribute(e.name)===String(s)||e.kind==="bool"&&e.el.hasAttribute(e.name)===!!s)return;t=s}switch(e.kind){case"child":hr(e,t);break;case"attr":{t==null||t===!1?e.el.removeAttribute(e.name):e.el.setAttribute(e.name,String(t));break}case"prop":e.el[e.name]=t;break;case"bool":t?e.el.setAttribute(e.name,""):e.el.removeAttribute(e.name);break;case"event":e.handler=typeof t=="function"?t:null;break;case"element":dr(e,t);break;case"attr-mixed":{let s=e,o=s.statics[0];for(let i=0;i<s.group.length;i++)o+=String((r?r[s.group[i]]:t)??""),o+=s.statics[i+1]||"";e.el.setAttribute(e.name,o);break}case"slot":{if(e.applied)break;let s=e.slotEl,o=()=>{e.applied=!0;let c=Qe(s);if(!c||fr(s))return;let a=document.createDocumentFragment();for(;s.firstChild;)a.appendChild(s.firstChild);s[me]=a,ge(c)};Qe(s)?o():queueMicrotask(o);break}case"noop":break}}function Qe(e){let t=e.parentElement;for(;t;){if(t[P])return t;t=t.parentElement}return null}function fr(e){let t=e;for(let n=0;n<128;n++){let r=t.parentNode;if(!r||r===t)return!1;if(r.host)return!0;t=r}return!1}function dr(e,t){let n=e,r=Pe(t)?t.target:void 0,s=n.__refTarget,o=r!==s;if(o&&s)if(typeof s=="function")try{s(void 0)}catch{}else typeof s=="object"&&(s.value=void 0);if(o||n.__refElement!==e.el){if(n.__refTarget=r,r)if(typeof r=="function"){if(!o&&n.__refElement!==void 0)try{r(void 0)}catch{}try{r(e.el)}catch{}}else typeof r=="object"&&(r.value=e.el);n.__refElement=e.el,e.lastTarget=r}}function hr(e,t){return yr(e,t),v(e,t)}function v(e,t){let n=e.marker;if(Oe(t)){B(e);let s=String(t.value??""),o=document.createElement("template");o.innerHTML=s;let i=[...o.content.childNodes],c=document.createDocumentFragment();for(let a of i)c.appendChild(a);n.parentNode?.insertBefore(c,n),e.child=i;return}if(Le(t)){let s=t,o=e.__keyedKey;o!==void 0&&!Object.is(o,s.key)&&B(e),e.__keyedKey=s.key,v(e,s.value);return}if(Me(t)){let s=t,o=e.__guardDeps,i=s.deps;if(o!==void 0&&(Array.isArray(o)&&Array.isArray(i)?gr(o,i):Object.is(o,i)))return;e.__guardDeps=Array.isArray(i)?i.slice():i,v(e,s.fn());return}if(wt(t)){B(e);let s=t.template;if(s&&s.content){let o=s.content.cloneNode(!0),i=[...o.childNodes];n.parentNode?.insertBefore(o,n),e.child=i}return}if(Pe(t))return;if(Ie(t))return br(e,t.value);if(Be(t))return _r(e,t.args);if(Fe(t))return wr(e,t.signal);if(St(t))return Sr(e,t);if(At(t))return Ar(e,t);if(Re(t)){if(e.child&&e.child.kind==="repeat"){mr(e,t);return}B(e);let s={kind:"repeat",map:new Map};e.child=s,pr(n,s,t);return}if(e.child){let s=e.child;if(s.kind==="repeat")Wt(s),e.child=void 0;else if(s.kind==="async-stream")Yt(s),e.child=void 0;else if("strings"in e.child){let o=e.child;if(_(t)&&o.strings===t.strings){ee(o,t.values);return}te(o.startNode,o.endNode),e.child=void 0}else{for(let o of e.child)o.parentNode&&o.parentNode.removeChild(o);e.child=void 0}}if(t==null||t===!1||t===!0)return;if(_(t)){let s=t,{templateEl:o,parts:i}=Z(s),c=o.content.cloneNode(!0),a=document.createComment(`${m}s`),l=document.createComment(`${m}e`),u=i.map(h=>Q(h,c)),p=[];for(let h=0;h<s.values.length;h++)O(u[h],s.values[h],void 0,s.values),p.push(s.values[h]);let d=[a,...c.childNodes,l];n.parentNode?.insertBefore(Ht(d),n);for(let h of u)h.kind==="slot"&&O(h,void 0,void 0,[]);e.child={strings:s.strings,bound:u,lastValues:p,startNode:a,endNode:l};return}if(Array.isArray(t)){let s=[];for(let i of t)if(_(i)){let c=i,{templateEl:a,parts:l}=Z(c),u=a.content.cloneNode(!0),p=l.map(d=>Q(d,u));for(let d=0;d<c.values.length;d++)O(p[d],c.values[d],void 0,c.values);s.push(...u.childNodes)}else i!=null&&i!==!1&&i!==!0&&s.push(document.createTextNode(String(i)));let o=Ht(s);n.parentNode?.insertBefore(o,n),e.child=s;return}let r=document.createTextNode(String(t));n.parentNode?.insertBefore(r,n),e.child=[r]}function Ht(e){let t=document.createDocumentFragment();for(let n of e)t.appendChild(n);return t}function te(e,t){if(!e.parentNode)return;let n=e;for(;n&&n!==t;){let r=n.nextSibling;n.parentNode?.removeChild(n),n=r}t.parentNode===e.parentNode&&t.parentNode?.removeChild(t)}function Vt(e){let{templateEl:t,parts:n}=Z(e),r=t.content.cloneNode(!0),s=document.createComment(`${m}s`),o=document.createComment(`${m}e`),i=n.map(l=>Q(l,r)),c=[];for(let l=0;l<e.values.length;l++)O(i[l],e.values[l],void 0,e.values),c.push(e.values[l]);let a=document.createDocumentFragment();for(a.appendChild(s);r.firstChild;)a.appendChild(r.firstChild);return a.appendChild(o),{inst:{strings:e.strings,bound:i,lastValues:c,startNode:s,endNode:o},frag:a}}function ye(e){for(let t of e.bound)if(t.kind==="event"&&t.el.removeEventListener(t.name,t.dispatcher),t.kind==="element"){let n=t.lastTarget;if(n){if(typeof n=="function")try{n(void 0)}catch{}else typeof n=="object"&&(n.value=void 0);t.lastTarget=void 0,t.__lastEl=void 0}}}function pr(e,t,n){let{items:r,keyFn:s,templateFn:o}=n,i=e.parentNode;if(!i)return;let c=document.createDocumentFragment();for(let a=0;a<r.length;a++){let l=s(r[a],a),u=o(r[a],a);if(!_(u))continue;let{inst:p,frag:d}=Vt(u);t.map.set(l,p),c.appendChild(d)}i.insertBefore(c,e)}function mr(e,t){let n=e.marker,r=n.parentNode;if(!r)return;let s=e.child,{items:o,keyFn:i,templateFn:c}=t,a=new Map;for(let l=0;l<o.length;l++){let u=i(o[l],l),p=c(o[l],l);if(!_(p))continue;let d=s.map.get(u);if(d&&d.strings===p.strings)ee(d,p.values),et(d.startNode,d.endNode,r,n),a.set(u,d),s.map.delete(u);else{d&&(ye(d),te(d.startNode,d.endNode),s.map.delete(u));let{inst:h,frag:b}=Vt(p);r.insertBefore(b,n),a.set(u,h)}}for(let l of s.map.values())ye(l),te(l.startNode,l.endNode);s.map=a}function Wt(e){for(let t of e.map.values())ye(t),te(t.startNode,t.endNode);e.map.clear()}function et(e,t,n,r){if(t.nextSibling===r&&e.parentNode===n)return;let s=document.createDocumentFragment(),o=e;for(;o;){let i=o.nextSibling;if(s.appendChild(o),o===t)break;o=i}n.insertBefore(s,r)}function gr(e,t){if(e===t)return!0;if(!e||!t||e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!Object.is(e[n],t[n]))return!1;return!0}function B(e){let t=e;if(t.__untilState&&(t.__untilState.aborted=!0,t.__untilState=void 0),t.__watchSub&&zt(t),!e.child)return;let n=e.child;if(n.kind==="repeat")Wt(n);else if(n.kind==="async-stream")Yt(n);else if("strings"in n){let r=e.child;ye(r),te(r.startNode,r.endNode)}else for(let r of e.child)r.parentNode&&r.parentNode.removeChild(r);e.child=void 0}function yr(e,t){let n=e;n.__untilState&&!Be(t)&&(n.__untilState.aborted=!0,n.__untilState=void 0),n.__guardDeps!==void 0&&!Me(t)&&(n.__guardDeps=void 0),n.__cacheMap&&!Ie(t)&&(n.__cacheMap=void 0),n.__keyedKey!==void 0&&!Le(t)&&(n.__keyedKey=void 0),n.__watchSub&&!Fe(t)&&zt(n)}function br(e,t){let n=e.marker,r=e,s=r.__cacheMap;s||(s=new Map,r.__cacheMap=s);let o=e.child;if(o&&"strings"in o){let c=o;if(_(t)&&c.strings===t.strings){ee(c,t.values);return}let a=document.createDocumentFragment();et(c.startNode,c.endNode,a,null),s.set(c.strings,{inst:c,holder:a}),e.child=void 0}if(_(t)){let c=t,a=s.get(c.strings);if(a){s.delete(c.strings),e.child&&B(e),et(a.inst.startNode,a.inst.endNode,n.parentNode,n),ee(a.inst,c.values),e.child=a.inst;return}}v(e,t)}function _r(e,t){let n=e,r=n.__untilState,s=n.__untilArgs,o=(d,h)=>!!(Object.is(d,h)||_(d)&&_(h)&&d.strings===h.strings),c=s&&s.length===t.length&&s.every((d,h)=>o(d,t[h]))&&r?r.highestResolved:1/0;r&&(r.aborted=!0),n.__untilArgs=t.slice();let a={aborted:!1,highestResolved:c};n.__untilState=a;let l=-1,u;for(let d=0;d<t.length;d++){let h=t[d];if(!h||typeof h.then!="function"){l=d,u=h;break}}l!==-1&&l<=a.highestResolved?(v(e,u),a.highestResolved=l):l===-1&&!n.__untilEverRendered&&v(e,""),n.__untilEverRendered=!0;let p=Math.min(l===-1?t.length:l,a.highestResolved);for(let d=0;d<p;d++){let h=t[d];!h||typeof h.then!="function"||Promise.resolve(h).then(b=>{a.aborted||d>=a.highestResolved||(a.highestResolved=d,v(e,b))},()=>{})}}function wr(e,t){let n=e;if(n.__watchSig===t&&n.__watchSub){let o;n.__watchSub.observe(()=>{o=t.get()}),v(e,o);return}n.__watchSub&&(n.__watchSub.dispose(),n.__watchSub=void 0),n.__watchSig=t;let r=new G.subtle.Watcher(()=>{queueMicrotask(()=>{if(n.__watchSub!==r)return;let o;r.observe(()=>{o=t.get()}),v(e,o)})});n.__watchSub=r;let s;r.observe(()=>{s=t.get()}),v(e,s)}function zt(e){e.__watchSub&&(e.__watchSub.dispose(),e.__watchSub=void 0,e.__watchSig=void 0)}function Sr(e,t){let n=e.child;if(n&&n.kind==="async-stream"&&n.mode==="append"&&n.iterable===t.iterable)return;B(e);let r=t.iterable[Symbol.asyncIterator](),s={kind:"async-stream",mode:"append",aborted:!1,iterable:t.iterable,iterator:r,nodes:[]};e.child=s,Kt(s,e,t)}function Ar(e,t){let n=e.child;if(n&&n.kind==="async-stream"&&n.mode==="replace"&&n.iterable===t.iterable)return;B(e);let r=t.iterable[Symbol.asyncIterator](),s={kind:"async-stream",mode:"replace",aborted:!1,iterable:t.iterable,iterator:r,nodes:[]};e.child=s,Kt(s,e,t)}async function Kt(e,t,n){let r=t.marker,s=0;try{for(;!e.aborted;){let o=await e.iterator.next();if(e.aborted||o.done)break;let i=n.mapper?n.mapper(o.value,s):o.value,c=Gt(i);if(e.mode==="replace"){for(let l of e.nodes)l.parentNode&&l.parentNode.removeChild(l);e.nodes=[]}let a=document.createDocumentFragment();for(let l of c)a.appendChild(l);r.parentNode?.insertBefore(a,r),e.nodes.push(...c),s++}}catch(o){typeof console<"u"&&console.error("[webjs] asyncStream error:",o)}}function Gt(e){if(e==null||e===!1||e===!0)return[];if(_(e)){let t=e,{templateEl:n,parts:r}=Z(t),s=n.content.cloneNode(!0),o=r.map(i=>Q(i,s));for(let i=0;i<t.values.length;i++)O(o[i],t.values[i],void 0,t.values);return[...s.childNodes]}if(Array.isArray(e)){let t=[];for(let n of e)t.push(...Gt(n));return t}return[document.createTextNode(String(e))]}function Yt(e){e.aborted=!0;for(let t of e.nodes)t.parentNode&&t.parentNode.removeChild(t);e.nodes=[];try{e.iterator.return?.()?.catch?.(()=>{})}catch{}}var Jt=Symbol.for("webjs:registry"),Xt=Symbol.for("webjs:classToTag"),_e=globalThis,N=_e[Jt]||(_e[Jt]=new Map),Zt=_e[Xt]||(_e[Xt]=new WeakMap),we=typeof window<"u"&&typeof customElements<"u";function tt(e,t){if(!e||typeof e!="string"||!e.includes("-"))throw new Error(`customElements.define: tag "${e}" must contain a hyphen (HTML spec)`);let n=t.lazy===!0,r=N.get(e);r?(r.cls=t,r.lazy=n):N.set(e,{cls:t,moduleUrl:null,lazy:n,tag:e}),Zt.set(t,e)}if(we){let e=customElements.define.bind(customElements);customElements.define=function(t,n,r){customElements.get(t)||e(t,n,r),tt(t,n)}}if(!we){let e=globalThis;e.customElements||(e.customElements={define(t,n){tt(t,n)},get(t){return N.get(t)?.cls},upgrade(){},whenDefined(t){let n=N.get(t);return Promise.resolve(n?.cls)}})}function nt(e,t){we?customElements.define(e,t):tt(e,t)}function Cr(e,t){if(we)return;let n=N.get(e);if(n){n.moduleUrl=t;return}N.set(e,{cls:null,moduleUrl:t,lazy:!1,tag:e})}function vr(e){return N.get(e)?.cls}function Nr(e){return N.get(e)?.moduleUrl||null}function kr(e){return N.get(e)?.lazy===!0}function Se(e){return Zt.get(e)}function Er(){return[...N.keys()]}var g="_$wj",oe="_id";async function rt(e){return JSON.stringify(await Qt(e))}function se(e){return en(JSON.parse(e))}async function Qt(e){let t=Tr();return await xr(e,t),F(e,t)}function en(e){return j(e,Lr())}function Tr(){return{refCount:new Map,idOf:new Map,emitted:new Set,nextId:0,blobBytes:new Map}}async function xr(e,t){let n=[e];for(;n.length;){let r=n.pop();if(!Pr(r))continue;let s=t.refCount.get(r)||0;if(t.refCount.set(r,s+1),!(s>0)){if(typeof Blob<"u"&&r instanceof Blob){let o=new Uint8Array(await r.arrayBuffer());t.blobBytes.set(r,o);continue}if(typeof FormData<"u"&&r instanceof FormData){for(let[,o]of r.entries())typeof o!="string"&&n.push(o);continue}if(Array.isArray(r))for(let o=0;o<r.length;o++)n.push(r[o]);else if(r instanceof Map)for(let[o,i]of r)n.push(o),n.push(i);else if(r instanceof Set)for(let o of r)n.push(o);else if(Ir(r))for(let o in r)Object.prototype.hasOwnProperty.call(r,o)&&n.push(r[o])}}for(let[r,s]of t.refCount)s>1&&t.idOf.set(r,t.nextId++)}function F(e,t){if(e===null)return null;if(e===void 0)return{[g]:"undef"};let n=typeof e;if(n==="string"||n==="boolean")return e;if(n==="number")return Number.isNaN(e)?{[g]:"NaN"}:e===1/0?{[g]:"Inf"}:e===-1/0?{[g]:"-Inf"}:Object.is(e,-0)?{[g]:"-0"}:e;if(n==="bigint")return{[g]:"BigInt",v:e.toString()};if(n==="symbol"){let o=Symbol.keyFor(e);if(o===void 0)throw new TypeError("Cannot serialize a local Symbol; only Symbol.for() registered symbols are supported.");return{[g]:"Sym",v:o}}if(n==="function")throw new TypeError("Cannot serialize a function.");let r=t.idOf.get(e);if(r!==void 0&&t.emitted.has(r))return{[g]:"Ref",v:r};r!==void 0&&t.emitted.add(r);let s;if(e instanceof Date)s={[g]:"Date",v:Number.isNaN(e.getTime())?null:e.toISOString()};else if(e instanceof Error)s={[g]:"Error",v:{name:e.name,message:e.message,stack:e.stack||null}};else if(typeof Blob<"u"&&e instanceof Blob){let o=t.blobBytes.get(e);typeof File<"u"&&e instanceof File?s={[g]:"File",v:re(o),n:e.name,t:e.type||"",m:e.lastModified}:s={[g]:"Blob",v:re(o),t:e.type||""}}else if(typeof FormData<"u"&&e instanceof FormData){let o=[];for(let[i,c]of e.entries())o.push([i,F(c,t)]);s={[g]:"FD",v:o}}else if(ArrayBuffer.isView(e)||e instanceof ArrayBuffer)s=Rr(e);else if(e instanceof Map){let o=[];for(let[i,c]of e)o.push([F(i,t),F(c,t)]);s={[g]:"Map",v:o}}else if(e instanceof Set){let o=[];for(let i of e)o.push(F(i,t));s={[g]:"Set",v:o}}else if(Array.isArray(e))s=e.map(o=>F(o,t));else{s={};for(let o in e){if(!Object.prototype.hasOwnProperty.call(e,o))continue;let i=Br(o)?"_"+o:o;s[i]=F(e[o],t)}}if(r!==void 0){if(Array.isArray(s))return{[g]:"Arr",[oe]:r,v:s};s[oe]=r}return s}function Rr(e){if(e instanceof ArrayBuffer)return{[g]:"buf",v:re(new Uint8Array(e))};if(e instanceof DataView)return{[g]:"dv",v:re(new Uint8Array(e.buffer,e.byteOffset,e.byteLength))};let t=e.constructor.name,n=Or[t];if(!n)throw new TypeError(`Unsupported typed array: ${t}`);let r=new Uint8Array(e.buffer,e.byteOffset,e.byteLength);return{[g]:n,v:re(r)}}var Or={Int8Array:"i8",Uint8Array:"u8",Uint8ClampedArray:"u8c",Int16Array:"i16",Uint16Array:"u16",Int32Array:"i32",Uint32Array:"u32",Float32Array:"f32",Float64Array:"f64",BigInt64Array:"bi64",BigUint64Array:"bu64"},jr={i8:Int8Array,u8:Uint8Array,u8c:Uint8ClampedArray,i16:Int16Array,u16:Uint16Array,i32:Int32Array,u32:Uint32Array,f32:Float32Array,f64:Float64Array,bi64:typeof BigInt64Array<"u"?BigInt64Array:null,bu64:typeof BigUint64Array<"u"?BigUint64Array:null};function Lr(){return{refs:new Map}}function j(e,t){if(e===null||typeof e!="object")return e;if(Array.isArray(e)){let o=[];for(let i=0;i<e.length;i++)o.push(j(e[i],t));return o}let n=e[g];if(typeof n=="string")return Mr(e,n,t);let r={},s=e[oe];typeof s=="number"&&t.refs.set(s,r);for(let o in e){if(!Object.prototype.hasOwnProperty.call(e,o)||o===oe)continue;let i=Fr(o)?o.slice(1):o;r[i]=j(e[o],t)}return r}function Mr(e,t,n){let r=e[oe];switch(t){case"undef":return;case"NaN":return NaN;case"Inf":return 1/0;case"-Inf":return-1/0;case"-0":return-0;case"BigInt":return BigInt(e.v);case"Sym":return Symbol.for(e.v);case"Date":return e.v==null?new Date(NaN):new Date(e.v);case"Error":{let s=new Error(e.v.message);return s.name=e.v.name,e.v.stack&&(s.stack=e.v.stack),typeof r=="number"&&n.refs.set(r,s),s}case"Map":{let s=new Map;typeof r=="number"&&n.refs.set(r,s);for(let[o,i]of e.v)s.set(j(o,n),j(i,n));return s}case"Set":{let s=new Set;typeof r=="number"&&n.refs.set(r,s);for(let o of e.v)s.add(j(o,n));return s}case"Arr":{let s=[];typeof r=="number"&&n.refs.set(r,s);for(let o of e.v)s.push(j(o,n));return s}case"Ref":{let s=n.refs.get(e.v);if(s===void 0)throw new TypeError(`Dangling reference: id=${e.v}`);return s}case"Blob":{if(typeof Blob>"u")throw new TypeError("Blob is not available in this environment.");let s=ne(e.v);return new Blob([s],{type:e.t||""})}case"File":{if(typeof File>"u")throw new TypeError("File is not available in this environment.");let s=ne(e.v);return new File([s],e.n,{type:e.t||"",lastModified:e.m})}case"FD":{if(typeof FormData>"u")throw new TypeError("FormData is not available in this environment.");let s=new FormData;for(let[o,i]of e.v){let c=j(i,n);s.append(o,c)}return s}default:{if(t==="buf"){let o=ne(e.v);return o.buffer.slice(o.byteOffset,o.byteOffset+o.byteLength)}if(t==="dv"){let o=ne(e.v);return new DataView(o.buffer.slice(o.byteOffset,o.byteOffset+o.byteLength))}let s=jr[t];if(s){let o=ne(e.v),i=o.buffer.slice(o.byteOffset,o.byteOffset+o.byteLength);return new s(i)}throw new TypeError(`Unknown serialization tag: ${t}`)}}}function Pr(e){return e!==null&&typeof e=="object"}function Ir(e){if(e===null||typeof e!="object")return!1;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}function Br(e){return/^_+\$wj$/.test(e)||/^_+id$/.test(e)}function Fr(e){return/^__+\$wj$/.test(e)||/^__+id$/.test(e)}var tn=typeof Buffer<"u"&&typeof Buffer.from=="function";function re(e){if(tn)return Buffer.from(e.buffer,e.byteOffset,e.byteLength).toString("base64");let t="";for(let n=0;n<e.length;n++)t+=String.fromCharCode(e[n]);return btoa(t)}function ne(e){if(tn){let r=Buffer.from(e,"base64");return new Uint8Array(r.buffer,r.byteOffset,r.byteLength)}let t=atob(e),n=new Uint8Array(t.length);for(let r=0;r<t.length;r++)n[r]=t.charCodeAt(r);return n}var on=typeof window<"u"&&typeof HTMLElement<"u";function Ur(e,t){return e!==t}var $r=on?HTMLElement:class{},ot=class extends $r{static shadow=!1;static hydrate=void 0;static properties={};static styles=null;static register(t){nt(t,this)}static get observedAttributes(){let t=this.properties||{};return Object.keys(t).filter(n=>!t[n].state).map(nn)}constructor(){super(),this._renderRoot=null,this._scheduled=!1,this._connected=!1,this.__controllers=new Set,this.__firstRendered=!1,this._changedProperties=new Map,this._updateResolve=null,this._updatePromise=Promise.resolve(!0),this._isUpdating=!1,this._initializeProperties()}_initializeProperties(){let n=this.constructor.properties;if(!(!n||typeof n!="object")){this.__propValues={};for(let[r,s]of Object.entries(n)){let o=typeof s=="object"?s:{type:s},i=this[r];Object.defineProperty(this,r,{configurable:!0,enumerable:!0,get:()=>this.__propValues[r],set:c=>{let a=this.__propValues[r];(o.hasChanged||Ur)(c,a)&&(this.__propValues[r]=c,o.reflect&&!o.state&&this._connected&&this._reflectAttribute(r,c,o),this.requestUpdate(r,a))}}),i!==void 0&&(this.__propValues[r]=i)}}}_reflectAttribute(t,n,r){let s=nn(t);if(!this.__reflectingAttribute){this.__reflectingAttribute=!0;try{if(r.converter&&r.converter.toAttribute){let o=r.converter.toAttribute(n,r.type);o==null?this.removeAttribute(s):this.setAttribute(s,o)}else r.type===Boolean?n?this.setAttribute(s,""):this.removeAttribute(s):n==null?this.removeAttribute(s):r.type===Object||r.type===Array?this.setAttribute(s,JSON.stringify(n)):this.setAttribute(s,String(n))}finally{this.__reflectingAttribute=!1}}}connectedCallback(){if(!on)return;if(this.__webjsPropsHydrated||(this.__webjsPropsHydrated=!0,this._hydratePropAttrs()),this.constructor.hydrate==="visible"&&typeof IntersectionObserver<"u"&&!this.__hydrationActivated){this.__hydrationActivated=!1,this.__hydrationObserver=new IntersectionObserver(n=>{for(let r of n)if(r.isIntersecting){this.__hydrationObserver.unobserve(this),this.__hydrationObserver.disconnect(),this.__hydrationObserver=null,this.__hydrationActivated=!0,this._activate();return}},{rootMargin:"200px"}),this.__hydrationObserver.observe(this);return}this._activate()}_hydratePropAttrs(){let t=[],n=this.attributes;for(let r=0;r<n.length;r++){let s=n[r].name;s.startsWith("data-webjs-prop-")&&t.push(s)}for(let r of t){let s=this.getAttribute(r);if(this.removeAttribute(r),s==null)continue;let o=rn(r.slice(16));try{this[o]=se(s)}catch(i){console.warn(`[webjs] failed to decode ${r} on <${this.tagName.toLowerCase()}>: ${i&&i.message}`)}}}_activate(){this._connected=!0;let t=this.constructor;if(t.shadow===!0){let n=!!this.shadowRoot;this.shadowRoot||this.attachShadow({mode:"open"}),this._renderRoot=this.shadowRoot;let r=t.styles,s=Array.isArray(r)?r:Te(r)?[r]:[];if(s.length){if(n){let o=this.shadowRoot.querySelector("style");o&&o.remove()}xe(this._renderRoot,s)}}else this._renderRoot=this,t.styles&&console.warn(`[webjs] <${Se(t)||this.tagName?.toLowerCase()}> has static shadow = false AND static styles. static styles only works with shadow DOM (adoptedStyleSheets). For light DOM, use global CSS or <style> in render().`),Xe(this)||(this.__isHydrating()?(R(this),It(this)):Pt(this));for(let n of this.__controllers)n.hostConnected&&n.hostConnected();this._updateResolve===null&&(this._updatePromise=new Promise(n=>{this._updateResolve=n})),this._scheduled=!0,queueMicrotask(()=>{this._scheduled=!1;try{this._performRender()}catch(n){console.error("[webjs] lifecycle hook threw during initial render:",n)}this._renderRoot===this&&Ft(this)})}__isHydrating(){let t=this.firstChild,n=t!=null&&t.nodeType===8&&t.data==="webjs-hydrate";return n&&(this.__hydratedAtActivate=!0),n}disconnectedCallback(){this._connected=!1,this.__hydrationObserver&&(this.__hydrationObserver.disconnect(),this.__hydrationObserver=null),this._renderRoot===this&&Ut(this),this.__signalWatcher&&(this.__signalWatcher.dispose(),this.__signalWatcher=void 0);for(let t of this.__controllers)t.hostDisconnected&&t.hostDisconnected()}attributeChangedCallback(t,n,r){if(this.__reflectingAttribute)return;let s=this.constructor,o=rn(t),i=s.properties&&(s.properties[o]||s.properties[t]);if(!i)return;let c;if(i.converter&&i.converter.fromAttribute)c=i.converter.fromAttribute(r,i.type);else if(i.type===Number)c=r==null?null:Number(r);else if(i.type===Boolean)c=r!=null&&r!=="false";else if(i.type===Object||i.type===Array)try{c=r==null?null:JSON.parse(r)}catch{c=r}else c=r;this[o]!==c&&(this[o]=c,this._connected&&this.requestUpdate())}requestUpdate(t,n){t!==void 0&&!this._changedProperties.has(t)&&this._changedProperties.set(t,n),this._scheduleUpdate()}_scheduleUpdate(){this._updateResolve===null&&(this._updatePromise=new Promise(t=>{this._updateResolve=t})),!this._isUpdating&&(this._scheduled||!this._connected||(this._scheduled=!0,queueMicrotask(()=>{this._scheduled=!1;try{this._performRender()}catch(t){console.error("[webjs] lifecycle hook threw during update cycle:",t)}})))}_performRender(){if(!this._renderRoot)return;let t=this._changedProperties;this._isUpdating=!0;let n=!1;try{if(this.shouldUpdate(t)){this.willUpdate(t);for(let r of this.__controllers)r.hostUpdate&&r.hostUpdate();try{this.update(t)}catch(r){console.error(`[webjs] render error in <${Se(this.constructor)||this.tagName?.toLowerCase()}>:`,r);try{let s=this.renderError(r);s!==void 0&&be(s,this._renderRoot)}catch(s){console.error("[webjs] renderError() also threw:",s)}}for(let r of this.__controllers)r.hostUpdated&&r.hostUpdated();n=!0}}catch(r){console.error("[webjs] lifecycle hook threw during update phase:",r)}finally{this._isUpdating=!1,n&&(this._changedProperties=new Map)}if(n)try{this.__firstRendered||(this.__firstRendered=!0,this.firstUpdated(t)),this.updated(t)}catch(r){console.error("[webjs] lifecycle hook threw during post-commit phase:",r)}finally{this._resolveUpdate()}else this._resolveUpdate()}_resolveUpdate(){if(this._updateResolve){let t=this._changedProperties.size===0;this._updateResolve(t),this._updateResolve=null}}shouldUpdate(t){return!0}willUpdate(t){}update(t){this.__signalWatcher||(this.__signalWatcher=new G.subtle.Watcher(()=>{this._connected&&this.requestUpdate()}));let n;this.__signalWatcher.observe(()=>{n=this.render()}),be(n,this._renderRoot)}updated(t){}firstUpdated(t){}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._updatePromise}addController(t){this.__controllers.add(t),this._connected&&t.hostConnected&&t.hostConnected()}removeController(t){this.__controllers.delete(t)}render(){return""}renderError(t){}};function nn(e){return e.replace(/([A-Z])/g,"-$1").toLowerCase()}function rn(e){return e.replace(/-([a-z])/g,(t,n)=>n.toUpperCase())}var sn=Symbol.for("webjs.notFound"),cn=Symbol.for("webjs.redirect");function Dr(){let e=new Error("webjs: notFound()");throw e.__webjs=sn,e}function qr(e,t=307){let n=new Error(`webjs: redirect(${e})`);throw n.__webjs=cn,n.url=e,n.status=t,n}function Hr(e){return!!e&&e.__webjs===sn}function Vr(e){return!!e&&e.__webjs===cn}var an=null;function Wr(){if(!an)return"";try{return an()||""}catch{return""}}var Yo=Symbol.for("webjs.suspense");function zr(e){return{_$webjsSuspense:!0,fallback:e.fallback,children:e.children}}function Kr(e){return!!e&&typeof e=="object"&&e._$webjsSuspense===!0}function Gr(e,t={}){let n=t.reconnect!==!1,r=0,s=!1,o=null,i=[];function c(){s||(o=new WebSocket(Yr(e),t.protocols),o.onopen=a=>{for(r=0;i.length&&o&&o.readyState===WebSocket.OPEN;)o.send(i.shift());t.onOpen?.(a)},o.onmessage=a=>{let l=a.data;if(typeof l=="string")try{l=JSON.parse(l)}catch{}t.onMessage?.(l,a)},o.onerror=a=>{t.onError?.(a)},o.onclose=a=>{if(t.onClose?.(a),!s&&n){let l=Math.min(1e3*2**r++,3e4);setTimeout(c,l)}})}return c(),{send(a){let l=typeof a=="string"||a instanceof ArrayBuffer||ArrayBuffer.isView(a)?a:JSON.stringify(a);o&&o.readyState===WebSocket.OPEN?o.send(l):i.push(l)},close(a,l){s=!0;try{o?.close(a,l)}catch{}},get socket(){return o},get readyState(){return o?.readyState??3}}}function Yr(e){if(/^wss?:\/\//i.test(e))return e;let t=typeof location<"u"&&location.protocol==="https:"?"wss:":"ws:",n=typeof location<"u"?location.host:"";return`${t}//${n}${e.startsWith("/")?e:"/"+e}`}var st="application/vnd.webjs+json";async function Jr(e,t={}){let n=new Headers(t.headers||{});n.has("accept")||n.set("accept",st);let r=t.body;r!=null&&typeof r=="object"&&!(r instanceof FormData)&&!(r instanceof Blob)&&!(r instanceof ArrayBuffer)&&!(r instanceof URLSearchParams)&&!(typeof ReadableStream<"u"&&r instanceof ReadableStream)&&!ArrayBuffer.isView(r)&&(r=await rt(r),n.has("content-type")||n.set("content-type",st));let s=await fetch(e,{...t,headers:n,body:r}),o=s.headers.get("content-type")||"",i=await s.text(),c=o.includes(st)?i?se(i):null:o.includes("application/json")?i?JSON.parse(i):null:i;if(!s.ok){let a=c&&c.error||`richFetch ${e} -> ${s.status}`,l=new Error(a);throw l.status=s.status,l.body=c,l}return c}var it=typeof HTMLElement<"u"?class extends HTMLElement{}:null;typeof customElements<"u"&&it&&!customElements.get("webjs-frame")&&customElements.define("webjs-frame",it);function hn(e){return typeof Document<"u"&&typeof Document.parseHTMLUnsafe=="function"?Document.parseHTMLUnsafe(e):typeof DOMParser<"u"?new DOMParser().parseFromString(e,"text/html"):null}var W=!1,L=null,S=0,ct=null;function Xr(){ct||typeof MutationObserver>"u"||typeof customElements>"u"||(ct=new MutationObserver(e=>{for(let t of e)for(let n of t.addedNodes){if(n.nodeType!==1)continue;let r=n;r.tagName?.includes("-")&&customElements.upgrade(r);for(let s of r.querySelectorAll("*"))s.tagName?.includes("-")&&customElements.upgrade(s)}}),ct.observe(document.body,{childList:!0,subtree:!0}))}var M=null,Ae=null;function pn(){W||typeof document>"u"||(W=!0,document.addEventListener("click",gn,!1),document.addEventListener("submit",bn,!1),window.addEventListener("popstate",yn),Xr(),typeof history<"u"&&"scrollRestoration"in history&&(Ae=history.scrollRestoration,history.scrollRestoration="manual"),typeof location<"u"&&(M=location.href))}function Zr(){W&&(W=!1,document.removeEventListener("click",gn,!1),document.removeEventListener("submit",bn,!1),window.removeEventListener("popstate",yn),typeof history<"u"&&Ae!==null&&(history.scrollRestoration=Ae,Ae=null),M=null)}async function Qr(e,t){let n=new URL(e,location.href);if(n.origin!==location.origin){location.href=e;return}await dt(n.href,t?.replace??!1,null)}function eo(e){if(!e){w.clear();return}let t=new URL(e,location.href);w.delete(t.pathname+t.search)}pn();var mn=/\.(?:pdf|zip|tar|gz|7z|rar|dmg|exe|msi|deb|rpm|apk|ipa|xlsx?|docx?|pptx?|csv|odt|ods|odp|rtf|epub|mobi|xml|json|rss|atom|txt|md|wasm|mp3|mp4|mov|avi|webm|ogg|flac|wav|m4a|m4v|mkv|png|jpe?g|gif|webp|avif|bmp|ico|svg|tiff?|heic)$/i;function gn(e){if(!W||e.defaultPrevented||e.button!==0||e.metaKey||e.ctrlKey||e.shiftKey||e.altKey)return;let t=oo(e);if(!t||t.hasAttribute("download")||t.hasAttribute("data-no-router")||t.target&&t.target!=="_self")return;let n=t.href;if(!n)return;let r=new URL(n);if(r.origin!==location.origin||r.pathname===location.pathname&&r.search===location.search&&r.hash||mn.test(r.pathname))return;e.preventDefault();let s=_n(t);dt(n,!1,s)}function yn(e){dt(location.href,!0,null)}function bn(e){if(!W||e.defaultPrevented)return;let t=e.target;if(!t||t.nodeType!==1||t.tagName!=="FORM"||t.hasAttribute("data-no-router"))return;let n=e.submitter??null;if(n&&n.hasAttribute("data-no-router"))return;let r=n&&n.getAttribute("formtarget")||t.getAttribute("target")||"";if(r&&r!=="_self")return;let s=to(t,n);if(s==="dialog")return;let o=no(t,n),i;try{i=new URL(o,location.href)}catch{return}if(i.origin!==location.origin||mn.test(i.pathname))return;let c=ro(t,n);e.preventDefault();let a=_n(t);ao(i.href,s,c,a)}function to(e,t){return(t&&t.getAttribute("formmethod")||e.getAttribute("method")||"get").toLowerCase()}function no(e,t){return t&&t.hasAttribute("formaction")?t.getAttribute("formaction")||"":e.getAttribute("action")||e.action||location.href}function ro(e,t){try{return new FormData(e,t||void 0)}catch{let n=new FormData(e);return t&&t.getAttribute("name")&&n.append(t.getAttribute("name"),t.getAttribute("value")||""),n}}function oo(e){for(let t of e.composedPath())if(t instanceof HTMLAnchorElement)return t;return null}function _n(e){let t=e;for(;t;){let n=t.closest("webjs-frame");if(n&&n.id)return n.id;let r=t.getRootNode();if(r&&r.host)t=r.host;else break}return null}function ve(e){let t=new Map,n=[];function r(s){if(s.nodeType===8){let o=s,i=o.data,c=/^wj:children:(.+)$/.exec(i);if(c){n.push({path:c[1],start:o});return}if(i.trim()==="/wj:children"){let a=n.pop();a&&!t.has(a.path)&&t.set(a.path,{start:a.start,end:o});return}return}if(s.hasChildNodes&&s.hasChildNodes())for(let o=s.firstChild;o;o=o.nextSibling)r(o)}return r(e),t}function so(e,t){let n=null;for(let r of e.keys())t.has(r)&&(n===null||r.length>n.length)&&(n=r);return n}var io=16,w=new Map;function wn(e){let t=Sn(e);w.has(t)&&w.delete(t);let n={html:document.documentElement.outerHTML,scrollX:typeof window<"u"&&window.scrollX||0,scrollY:typeof window<"u"&&window.scrollY||0};for(w.set(t,n);w.size>io;){let r=w.keys().next().value;w.delete(r)}}function co(e){let t=Sn(e),n=w.get(t);return n==null?null:(w.delete(t),w.set(t,n),typeof n=="string"?{html:n,scrollX:0,scrollY:0}:n)}function Sn(e){let t=new URL(e,location.href);return t.pathname+t.search}async function dt(e,t,n){L&&L.abort(),L=new AbortController;let r=L.signal,s=++S;M&&wn(M);let o=setTimeout(()=>{document.documentElement.setAttribute("data-navigating",""),o=null},150),i=null;t||(i=vn());try{if(t){let c=co(e);if(c){let a=hn(c.html);if(a){An(a,n,!0,null),typeof window<"u"&&window.scrollTo(c.scrollX,c.scrollY),lt(e,n,!1,i,"GET",null,r,s).catch(()=>{});return}}typeof window<"u"&&window.scrollTo(0,0)}await lt(e,n,!t,i,"GET",null,r,s)}finally{o&&clearTimeout(o),s===S&&(document.documentElement.removeAttribute("data-navigating"),typeof location<"u"&&(M=location.href))}}async function ao(e,t,n,r){L&&L.abort(),L=new AbortController;let s=L.signal,o=++S,i=t==="get"||t==="head",c=new URL(e,location.href);if(i){c.search="";for(let[u,p]of n)c.searchParams.append(u,typeof p=="string"?p:p.name)}M&&wn(M);let a=setTimeout(()=>{document.documentElement.setAttribute("data-navigating",""),a=null},150),l=vn();try{await lt(c.href,r,!0,l,i?"GET":t.toUpperCase(),i?null:n,s,o),!i&&o===S&&w.clear()}finally{a&&clearTimeout(a),o===S&&(document.documentElement.removeAttribute("data-navigating"),typeof location<"u"&&(M=location.href))}}function lo(){return[...ve(document.body).keys()].join(",")}async function lt(e,t,n,r,s,o,i,c){s=s||"GET";let a=typeof c=="number"?c:S,l,u=null,p=e;try{let h={"x-webjs-router":"1"},b=lo();b&&(h["x-webjs-have"]=b),t&&(h["x-webjs-frame"]=t);let $={method:s,headers:h,credentials:"same-origin"};i&&($.signal=i),o!=null&&s!=="GET"&&s!=="HEAD"&&($.body=o);let y=await fetch(e,$),f=y.headers.get("content-type")||"",D=/^text\/html\b/i.test(f);if(y.redirected&&y.url&&(p=y.url),y.status===204||y.status===205){a===S&&n&&history.pushState(null,"",p);return}if(!D){a===S&&(location.href=e);return}u=y.headers.get("x-webjs-build"),l=await y.text()}catch(h){if(h&&h.name==="AbortError"||a!==S)return;ho(r),location.href=e;return}if(a!==S)return;let d=hn(l);if(!d){location.href=e;return}if(An(d,t,!1,p,u),n&&history.pushState(null,"",p),n){let h=new URL(p);if(h.hash){let b=document.getElementById(h.hash.slice(1));b?b.scrollIntoView():window.scrollTo(0,0)}else window.scrollTo(0,0)}document.dispatchEvent(new CustomEvent("webjs:navigate",{detail:{url:p,frameId:t}}))}function ln(e){if(!e||!e.head)return"";let t=e.head.querySelectorAll('[data-webjs-track="reload"]');if(!t.length)return"";let n="";for(let r of t)n+=U(r);return n}function An(e,t,n,r,s){try{typeof sessionStorage<"u"&&(!r||t||n)&&sessionStorage.removeItem("webjs:importmap-reload")}catch{}if(r&&!t&&!n){let u=document.querySelector('script[type="importmap"]'),p=u?u.getAttribute("data-webjs-build"):null,d=!1;if(s&&p&&(d=s!==p),!d&&e.head&&e.head.children.length>0){let h=ln(document),b=ln(e);h!==b&&(d=!0)}if(d&&typeof location<"u")try{let h="webjs:importmap-reload";if(sessionStorage&&sessionStorage.getItem(h))sessionStorage.removeItem(h);else{sessionStorage&&sessionStorage.setItem(h,"1"),location.href=r;return}}catch{location.href=r;return}else if(!d)try{typeof sessionStorage<"u"&&sessionStorage.removeItem("webjs:importmap-reload")}catch{}}if(t){let u=document.querySelector(`webjs-frame#${CSS.escape(t)}`),p=e.querySelector(`webjs-frame#${CSS.escape(t)}`);if(u&&p){fn(e.head),po(u,p),ft(u),Ce(u),dn(e.body),at();return}}let o=ve(document.body),i=ve(e.body),c=so(o,i);if(c){fn(e.head),uo(o.get(c),i.get(c),e),dn(e.body),at();return}mo(e.head);let a=[...e.body.childNodes],l=()=>{document.body.replaceChildren(...a),ft(document.body),Ce(document.body),at()};document.startViewTransition?document.startViewTransition(l).finished.then(()=>Ce(document.body)).catch(()=>{}):l()}function at(){let e=document.activeElement;!e||e===document.body||e===document.documentElement||typeof e.blur=="function"&&e.blur()}function uo(e,t,n){if(!e||!t)return;let r=e.start.parentNode;if(!r)return;let s=[];for(let i=e.start.nextSibling;i&&i!==e.end;i=i.nextSibling)s.push(i);let o=[];for(let i=t.start.nextSibling;i&&i!==t.end;i=i.nextSibling)o.push(document.importNode(i,!0));fo(r,e.start,e.end,s,o);for(let i=e.start.nextSibling;i&&i!==e.end;i=i.nextSibling)i.nodeType===1&&(ft(i),Ce(i))}function fo(e,t,n,r,s){let o=new Map;for(let a of r){if(a.nodeType!==1)continue;let l=ie(a);l&&o.set(l,a)}let i=n,c=[];for(let a of s){if(a.nodeType===1){let l=ie(a);if(l&&o.has(l)){let u=o.get(l);ut(u,a),c.push(u),o.delete(l);continue}}c.push(a)}for(let a of r)if(a.parentNode===e){if(a.nodeType===1&&c.includes(a))continue;e.removeChild(a)}for(let a of c)e.insertBefore(a,i)}function ut(e,t){if(e.tagName!==t.tagName){e.replaceWith(t);return}let n=new Set;for(let r of t.attributes)n.add(r.name),!un.has(r.name)&&e.getAttribute(r.name)!==r.value&&e.setAttribute(r.name,r.value);for(let r of[...e.attributes])un.has(r.name)||n.has(r.name)||e.removeAttribute(r.name);Cn(e,t)}function Cn(e,t){let n=[...e.childNodes],r=[...t.childNodes].map(c=>document.importNode(c,!0)),s=new Map;for(let c of n){if(c.nodeType!==1)continue;let a=ie(c);a&&s.set(a,c)}let o=[];for(let c=0;c<r.length;c++){let a=r[c];if(a.nodeType===1){let l=ie(a);if(l&&s.has(l)){let p=s.get(l);ut(p,a),o.push(p),s.delete(l);continue}let u=n[c];if(u&&u.nodeType===1&&!ie(u)&&u.tagName===a.tagName){ut(u,a),o.push(u);continue}}else if(a.nodeType===3){let l=n[c];if(l&&l.nodeType===3){l.nodeValue!==a.nodeValue&&(l.nodeValue=a.nodeValue),o.push(l);continue}}else if(a.nodeType===8){let l=n[c];if(l&&l.nodeType===8){l.nodeValue!==a.nodeValue&&(l.nodeValue=a.nodeValue),o.push(l);continue}}o.push(a)}let i=new Set(o);for(let c of n)!i.has(c)&&c.parentNode===e&&e.removeChild(c);for(let c=0;c<o.length;c++){let a=o[c];(a.parentNode!==e||e.childNodes[c]!==a)&&e.insertBefore(a,e.childNodes[c]||null)}}function ie(e){let t=e.getAttribute("data-key");return t?`${e.tagName}:k:${t}`:e.id?`${e.tagName}:i:${e.id}`:null}var un=new Set(["value","checked","selected","indeterminate","disabled","open","popover"]);function vn(){let e=ve(document.body);if(e.size===0)return null;let t=null;for(let i of e.keys())(t===null||i.length>t.length)&&(t=i);if(t===null)return null;let n=document.getElementById(`wj-loading:${t}`);if(!(n instanceof HTMLTemplateElement))return null;let r=e.get(t),s=[];for(let i=r.start.nextSibling;i&&i!==r.end;i=i.nextSibling)s.push(i);let o=document.createRange();return o.setStartAfter(r.start),o.setEndBefore(r.end),o.deleteContents(),r.start.parentNode.insertBefore(n.content.cloneNode(!0),r.end),{slot:r,oldChildren:s,token:S}}function ho(e){if(!e||e.token!==S)return;let{slot:t,oldChildren:n}=e;if(t.start.parentNode!==t.end.parentNode)return;let r=document.createRange();r.setStartAfter(t.start),r.setEndBefore(t.end),r.deleteContents();for(let s of n)t.start.parentNode.insertBefore(s,t.end)}function po(e,t){Cn(e,t)}function Nn(){if(typeof document>"u")return"";let e=document.querySelector('meta[name="csp-nonce"]');return e&&e.getAttribute("content")||""}function ht(e){let t=document.createElement("script");for(let r of e.attributes)r.name!=="nonce"&&t.setAttribute(r.name,r.value);let n=Nn();return n&&t.setAttribute("nonce",n),t.textContent=e.textContent,t}function kn(e){if(!e.hasAttribute("nonce"))return e.cloneNode(!0);let t=e.cloneNode(!0),n=Nn();return n?t.setAttribute("nonce",n):t.removeAttribute("nonce"),t}function U(e){if(!e.hasAttribute("nonce"))return e.outerHTML;let t=e.cloneNode(!0);return t.removeAttribute("nonce"),t.outerHTML}function fn(e){let t=e.querySelector("title");t&&(document.title=t.textContent||"");let n=new Set;for(let r of document.head.children)n.add(U(r));for(let r of e.children)r.tagName==="SCRIPT"&&r.getAttribute("type")==="importmap"||r.tagName!=="BASE"&&r.tagName!=="TITLE"&&(n.has(U(r))||(r.tagName==="SCRIPT"?document.head.appendChild(ht(r)):document.head.appendChild(kn(r))))}function mo(e){let t=document.head,n=e.querySelector("title");n&&(document.title=n.textContent||"");let r=new Set;for(let o of t.children)o.tagName==="SCRIPT"&&o.getAttribute("type")==="importmap"||o.tagName!=="BASE"&&r.add(U(o));let s=new Set;for(let o of e.children)o.tagName==="SCRIPT"&&o.getAttribute("type")==="importmap"||o.tagName!=="BASE"&&s.add(U(o));for(let o of[...t.children])o.tagName==="SCRIPT"&&o.getAttribute("type")==="importmap"||o.tagName!=="BASE"&&o.tagName!=="TITLE"&&(s.has(U(o))||o.remove());for(let o of e.children)o.tagName==="SCRIPT"&&o.getAttribute("type")==="importmap"||o.tagName!=="BASE"&&o.tagName!=="TITLE"&&(r.has(U(o))||(o.tagName==="SCRIPT"?t.appendChild(ht(o)):t.appendChild(kn(o))))}function Ce(e){typeof customElements>"u"||En(e)}function En(e){let t=e instanceof Element?[e,...e.querySelectorAll("*")]:[...e.querySelectorAll("*")];for(let n of t)n.tagName&&n.tagName.includes("-")&&(customElements.upgrade(n),n.shadowRoot&&En(n.shadowRoot))}function dn(e){for(let t of e.querySelectorAll("template[data-webjs-resolve]"))document.body.appendChild(t.cloneNode(!0))}function ft(e){for(let t of e.querySelectorAll("script"))t.replaceWith(ht(t))}var go=Symbol.for("webjs.context");function yo(e){return{__context__:go,name:e}}var Ne=class extends Event{constructor(t,n,r=!1){super("context-request",{bubbles:!0,composed:!0}),this.context=t,this.callback=n,this.subscribe=r}},pt=class{constructor(t,{context:n,initialValue:r}){this._host=t,this._context=n,this._value=r,this._subscriptions=new Set,this._onRequest=s=>{let o=s;if(o.context===this._context)if(s.stopPropagation(),o.subscribe){let i={callback:o.callback},c=()=>{this._subscriptions.delete(i)};this._subscriptions.add(i),o.callback(this._value,c)}else o.callback(this._value)},typeof t.addController=="function"&&t.addController(this)}get value(){return this._value}setValue(t){if(!Object.is(this._value,t)){this._value=t;for(let n of this._subscriptions){let r=()=>{this._subscriptions.delete(n)};n.callback(t,r)}}}hostConnected(){this._host.addEventListener("context-request",this._onRequest)}hostDisconnected(){this._host.removeEventListener("context-request",this._onRequest),this._subscriptions.clear()}},mt=class{constructor(t,{context:n,subscribe:r=!0}){this._host=t,this._context=n,this._subscribe=r,this._value=void 0,this._unsubscribe=void 0,typeof t.addController=="function"&&t.addController(this)}get value(){return this._value}hostConnected(){this._dispatchRequest()}hostDisconnected(){this._unsubscribe&&(this._unsubscribe(),this._unsubscribe=void 0)}_dispatchRequest(){let t=new Ne(this._context,(n,r)=>{let s=this._value;this._value=n,r&&(this._unsubscribe=r),!Object.is(s,n)&&typeof this._host.requestUpdate=="function"&&this._host.requestUpdate()},this._subscribe);this._host.dispatchEvent(t)}};var E={INITIAL:0,PENDING:1,COMPLETE:2,ERROR:3},gt=class{constructor(t,{task:n,args:r,autoRun:s=!0}){this._host=t,this._taskFn=n,this._argsFn=r||(()=>[]),this._autoRun=s,this._status=E.INITIAL,this._value=void 0,this._error=void 0,this._abortController=null,this._prevArgs=null,typeof t.addController=="function"&&t.addController(this)}get status(){return this._status}get value(){return this._value}get error(){return this._error}async run(){this.abort();let t=new AbortController;this._abortController=t;let n=this._argsFn();this._prevArgs=n,this._status=E.PENDING,this._error=void 0,this._requestHostUpdate();try{let r=await this._taskFn(...n,{signal:t.signal});if(t.signal.aborted)return;this._value=r,this._status=E.COMPLETE,this._error=void 0}catch(r){if(t.signal.aborted)return;this._error=r,this._status=E.ERROR,this._value=void 0}finally{this._abortController===t&&(this._abortController=null)}this._requestHostUpdate()}abort(){this._abortController&&(this._abortController.abort(),this._abortController=null)}render(t={}){switch(this._status){case E.INITIAL:return t.initial?.();case E.PENDING:return t.pending?.();case E.COMPLETE:return t.complete?.(this._value);case E.ERROR:return t.error?.(this._error);default:return}}hostUpdate(){if(!this._autoRun)return;let t=this._argsFn();this._argsEqual(this._prevArgs,t)||this.run()}hostUpdated(){}hostConnected(){}hostDisconnected(){this.abort()}_requestHostUpdate(){typeof this._host.requestUpdate=="function"&&this._host.requestUpdate()}_argsEqual(t,n){if(t===null||t.length!==n.length)return!1;for(let r=0;r<t.length;r++)if(t[r]!==n[r])return!1;return!0}};export{mt as ContextConsumer,pt as ContextProvider,Ne as ContextRequestEvent,m as MARKER,G as Signal,zr as Suspense,gt as Task,E as TaskStatus,ot as WebComponent,it as WebjsFrame,xe as adoptStyles,Er as allTags,Vn as batch,zn as computed,Gr as connectWS,yo as createContext,Wr as cspNonce,xn as css,en as deserialize,Zr as disableClientRouter,Gn as effect,pn as enableClientRouter,jn as escapeAttr,On as escapeText,Tn as html,Te as isCSS,kr as isLazy,je as isLive,Hr as isNotFound,Vr as isRedirect,Re as isRepeat,Kn as isSignal,Kr as isSuspense,_ as isTemplate,Oe as isUnsafeHTML,Pn as live,vr as lookup,Nr as lookupModuleUrl,Qr as navigate,Dr as notFound,se as parse,Cr as primeModuleUrl,qr as redirect,nt as register,be as render,Ln as repeat,eo as revalidate,Jr as richFetch,Qt as serialize,Wn as signal,rt as stringify,Rn as stylesToString,Se as tagOf,Mn as unsafeHTML};
|
|
4
4
|
//# sourceMappingURL=webjs-core-browser.js.map
|