/* esm.sh - @jsr/mastrojs__reactive@0.4.0 */
var u=Symbol(0);var A=!1,z=!1,h=null,d=null,c=null,l=0,y=[],R={},ft=()=>{},g=0,U=1,w=2,E=3;function at(){A=!0,queueMicrotask(ut)}function ut(){if(!y.length){A=!1;return}z=!0;for(let t=0;t<y.length;t++)y[t].$st!==g&&ht(y[t]);y=[],A=!1,z=!1}function ht(t){let e=[t];for(;t=t[u];)t.$e&&t.$st!==g&&e.push(t);for(let r=e.length-1;r>=0;r--)M(e[r])}function L(t){let e=Z();return K(e,t.length?t.bind(null,p.bind(e)):t,null)}function F(t){if(!t||!h)return t||ft;let e=h;return e.$d?Array.isArray(e.$d)?e.$d.push(t):e.$d=[e.$d,t]:e.$d=t,function(){e.$st!==E&&(t.call(null),S(e.$d)?e.$d=null:Array.isArray(e.$d)&&e.$d.splice(e.$d.indexOf(t),1))}}function p(t=!0){if(this.$st!==E){if(this.$h)if(Array.isArray(this.$h))for(let e=this.$h.length-1;e>=0;e--)p.call(this.$h[e]);else p.call(this.$h);if(t){let e=this[u];e&&(Array.isArray(e.$h)?e.$h.splice(e.$h.indexOf(this),1):e.$h=null),pt(this)}}}function pt(t){t.$st=E,t.$d&&J(t),t.$s&&P(t,0),t[u]=null,t.$s=null,t.$o=null,t.$h=null,t.$cx=R,t.$eh=null}function J(t){try{if(Array.isArray(t.$d))for(let e=t.$d.length-1;e>=0;e--){let r=t.$d[e];r.call(r)}else t.$d.call(t.$d);t.$d=null}catch(e){Y(t,e)}}function K(t,e,r){let s=h,i=d;h=t,d=r;try{return e.call(t)}finally{h=s,d=i}}function Y(t,e){if(!t||!t.$eh)throw e;let r=0,s=t.$eh.length,i=e;for(r=0;r<s;r++)try{t.$eh[r](i);break}catch(n){i=n}if(r===s)throw i}function C(){return this.$st===E?this.$v:(d&&!this.$e&&(!c&&d.$s&&d.$s[l]==this?l++:c?c.push(this):c=[this]),this.$c&&M(this),this.$v)}function W(t){let e=S(t)?t(this.$v):t;if(this.$ch(this.$v,e)&&(this.$v=e,this.$o))for(let r=0;r<this.$o.length;r++)X(this.$o[r],w);return this.$v}var k=function(){this[u]=null,this.$h=null,h&&h.append(this)},$=k.prototype;$.$cx=R;$.$eh=null;$.$c=null;$.$d=null;$.append=function(t){t[u]=this,this.$h?Array.isArray(this.$h)?this.$h.push(t):this.$h=[this.$h,t]:this.$h=t,t.$cx=t.$cx===R?this.$cx:{...this.$cx,...t.$cx},this.$eh&&(t.$eh=t.$eh?[...t.$eh,...this.$eh]:this.$eh)};$.dispose=function(){p.call(this)};function Z(){return new k}var G=function(e,r,s){k.call(this),this.$st=r?w:g,this.$i=!1,this.$e=!1,this.$s=null,this.$o=null,this.$v=e,r&&(this.$c=r),s&&s.dirty&&(this.$ch=s.dirty)},H=G.prototype;Object.setPrototypeOf(H,$);H.$ch=Q;H.call=C;function x(t,e,r){return new G(t,e,r)}function Q(t,e){return t!==e}function S(t){return typeof t=="function"}function M(t){if(t.$st===U)for(let e=0;e<t.$s.length&&(M(t.$s[e]),t.$st!==w);e++);t.$st===w?N(t):t.$st=g}function $t(t){t.$h&&p.call(t,!1),t.$d&&J(t),t.$eh=t[u]?t[u].$eh:null}function N(t){let e=c,r=l;c=null,l=0;try{$t(t);let s=K(t,t.$c,t);B(t),!t.$e&&t.$i?W.call(t,s):(t.$v=s,t.$i=!0)}catch(s){B(t),Y(t,s)}finally{c=e,l=r,t.$st=g}}function B(t){if(c){if(t.$s&&P(t,l),t.$s&&l>0){t.$s.length=l+c.length;for(let r=0;r<c.length;r++)t.$s[l+r]=c[r]}else t.$s=c;let e;for(let r=l;r<t.$s.length;r++)e=t.$s[r],e.$o?e.$o.push(t):e.$o=[t]}else t.$s&&l<t.$s.length&&(P(t,l),t.$s.length=l)}function X(t,e){if(!(t.$st>=e)&&(t.$e&&t.$st===g&&(y.push(t),A||at()),t.$st=e,t.$o))for(let r=0;r<t.$o.length;r++)X(t.$o[r],U)}function P(t,e){let r,s;for(let i=e;i<t.$s.length;i++)r=t.$s[i],r.$o&&(s=r.$o.indexOf(t),r.$o[s]=r.$o[r.$o.length-1],r.$o.pop())}function D(t,e){let r=x(t,null,e),s=C.bind(r);return s[u]=!0,s.set=W.bind(r),s}function I(t,e){let r=x(e?.initial,t,e),s=C.bind(r);return s[u]=!0,s}function q(t,e){let r=x(null,function(){let i=t();return S(i)&&F(i),null},void 0);return r.$e=!0,N(r),p.bind(r,!0)}var V=typeof document=="object"?void 0:await import("/node/fs/promises.mjs"),yt=typeof document=="object"?document.fs:void 0,O=typeof document=="object"?"/":(await import("/node/path.mjs")).sep;var tt=async t=>{if(t=t.startsWith("/")?t.slice(1):t,V){let e=await import("/node/process.mjs"),r=[];for await(let s of V.glob(t,{withFileTypes:!0}))if(s.isFile()&&!s.isSymbolicLink()&&!s.name.endsWith(O+".DS_Store")){let n=(s.parentPath+O+s.name).slice(e.cwd().length);r.push(n)}return r}else return yt.findFiles(t)};var dt=(t,...e)=>{let r=[],s=!1;for(let i=0;i<t.length;i++){let n=t[i];r.push(j(n)),s=(s?1:0)+et(n,"<")-et(n,">")===1;let o=e[i];Array.isArray(o)?r.push(...o):s&&bt(r.at(-1))?r.push(j('"'),o,j('"')):r.push(o)}return r},j=t=>new String(t);async function*b(t){if(t=await t,Array.isArray(t))for(let e=0;e<t.length;e++)yield*b(t[e]);else if(St(t))for await(let e of t)yield*b(e);else yield rt(t)}var T=async t=>typeof t!="object"||t instanceof String?rt(t):(await Array.fromAsync(b(t))).join(""),rt=t=>typeof t=="string"?xt(t):t==null?"":t.toString(),gt=t=>t.replaceAll("&","&amp;").replaceAll("<","&lt;").replaceAll(">","&gt;"),xt=t=>gt(t).replaceAll("'","&#39;").replaceAll('"',"&quot;"),St=t=>t&&typeof t[Symbol.asyncIterator]=="function",bt=t=>typeof t=="object"&&typeof t?.endsWith=="function"&&t.endsWith("="),et=(t,e)=>t.split(e).length-1;globalThis.URLPattern||await import("https://esm.sh/urlpattern-polyfill@10.1.3?bundle");var Tt=/^\[([a-zA-Z0-9\.]+)\]/,st=[],vt=typeof document=="object"?"js":"{ts,js}";for(let t of await tt(`routes/**/*.server.${vt}`)){let e=t.split(O).slice(2),r=e.map((s,i)=>{let n=s.match(Tt)?.[1];if(n)return n.startsWith("...")?`:${n.slice(3)}(.*)?`:`:${n}`;let o=e[i-1];return s==="index.server.ts"||s==="index.server.js"||o&&(s===`(${o}).server.ts`||s===`(${o}).server.js`)?"":s.endsWith(".server.ts")||s.endsWith(".server.js")?s.slice(0,-10):s});st.unshift({filePath:t,segments:r})}var it=st.map(t=>{let e={filePath:t.filePath,pattern:new URLPattern({pathname:"/"+t.segments.join("/")})};return Object.freeze(e),e});Object.freeze(it);var nt=t=>{let e=t.split("="),[r,s]=e.length===2?[e[0].trim(),e[1].trim()]:["innerHTML",t.trim()],[i,n]=r.split(".");if(!i)return{error:"Found invalid data-bind value",args:[]};let[o,f]=s.split("("),a=_(f);return{prop:i,subprop:n,fieldOrMethod:o,args:a}},_=t=>t?(t.endsWith(")")&&(t=t.slice(0,-1)),t.split(",").map(e=>e.trim()).map(e=>{if(e.startsWith("'")&&e.endsWith("'"))return e.slice(1,-1);if(e==="true")return!0;if(e==="false")return!1;{let r=parseFloat(e);return isNaN(r)?e:r}})):[];var le=I,At=q,ce=D;typeof HTMLElement!="function"&&(globalThis.HTMLElement=class{});var ot=class extends HTMLElement{#t;#e=["click","change","input","submit"];async connectedCallback(){if(!this.#t){this.#e.forEach(e=>(this.shadowRoot||this).addEventListener(e,r=>{let{target:s}=r,i=s&&s instanceof HTMLElement?s.dataset["on"+e]:void 0;if(i){r.stopPropagation();let[n,o]=i.split("("),f=_(o);typeof this[n]=="function"?this[n](...f,r):console.warn(`${this.nodeName.toLowerCase()}#${n.toString()} is not a function`)}})),typeof this.initialHtml=="function"&&!this.innerHTML.trim()&&((this.shadowRoot||this).innerHTML=await T(this.initialHtml()));for(let e of this.attributes)e.name.startsWith("data-")||(this[e.name]=()=>e.value);setTimeout(()=>{L(e=>{this.#t=e;let r=s=>{for(let i of s.querySelectorAll("[data-bind]"))if(i instanceof HTMLElement&&!wt(s,i))for(let n of i.dataset.bind?.split(";")||[]){let{error:o,prop:f,subprop:a,fieldOrMethod:v,args:lt}=nt(n);o?console.warn(o,i):typeof this[v]!="function"?console.warn(`${this.nodeName.toLowerCase()}#${v} is not a signal or method`,i):At(()=>{let m=this[v](...lt);f==="class"&&a?i.classList[m?"add":"remove"](a):f==="props"&&a?i[a]=this[v]:f==="attributes"&&a?m===null?i.removeAttribute(a):i.setAttribute(a,m):a?i[f][a]=m:f==="innerHTML"?T(m).then(ct=>{i[f]=ct,r(i)}):i[f]=m})}};r(this.shadowRoot||this)})})}}disconnectedCallback(){this.#t?.()}},wt=(t,e)=>{let r=e.parentElement;for(;r&&r!==t;){if(r.nodeName.includes("-"))return!0;r=r.parentElement}};export{ot as ReactiveElement,le as computed,At as effect,dt as html,b as renderToStream,T as renderToString,ce as signal,j as unsafeInnerHtml};
//# sourceMappingURL=mastrojs__reactive.bundle.mjs.map