@stacksjs/stx 0.2.888 → 0.2.890
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.
- package/dist/{chunk-c0g30cjs.js → chunk-05x1rd86.js} +2 -2
- package/dist/{chunk-6qq3wy3m.js → chunk-062qfv99.js} +2 -2
- package/dist/{chunk-s29hp1qw.js → chunk-0jdz31q1.js} +3 -3
- package/dist/{chunk-1kc0jyhj.js → chunk-0jkj8thz.js} +1 -1
- package/dist/chunk-0k437z3q.js +2 -0
- package/dist/chunk-0q0nbq50.js +2 -0
- package/dist/{chunk-5ysv0499.js → chunk-0wp23n1d.js} +1 -1
- package/dist/{chunk-9f31gs4m.js → chunk-115bb91s.js} +2 -2
- package/dist/chunk-12cjs6vs.js +2 -0
- package/dist/chunk-1a7a8cjs.js +2 -0
- package/dist/{chunk-wpa3r3b9.js → chunk-1bft48gk.js} +2 -2
- package/dist/{chunk-9tecekzq.js → chunk-1jtsr42q.js} +18 -18
- package/dist/{chunk-vazk5qbh.js → chunk-1knk403z.js} +2 -2
- package/dist/chunk-1p4q6t48.js +2 -0
- package/dist/chunk-1ph2yhfn.js +3 -0
- package/dist/{chunk-c1b0fy70.js → chunk-1t15z230.js} +5 -5
- package/dist/{chunk-2assyczz.js → chunk-1w0bqqh5.js} +2 -2
- package/dist/chunk-1z6pqvmf.js +2 -0
- package/dist/chunk-2nqmw4dv.js +2 -0
- package/dist/{chunk-e9tjxnhn.js → chunk-2xnbdqy4.js} +5 -5
- package/dist/chunk-35j7gaj5.js +2 -0
- package/dist/chunk-3b3mkgpj.js +3 -0
- package/dist/{chunk-7mcs59pr.js → chunk-3bsz7zj3.js} +2 -2
- package/dist/{chunk-w624s5jf.js → chunk-3qk8vf9m.js} +3 -3
- package/dist/chunk-3yvmaphj.js +2 -0
- package/dist/{chunk-mk6thhwf.js → chunk-40k0r6z9.js} +2 -2
- package/dist/{chunk-6t04tqvh.js → chunk-41z7f41b.js} +2 -2
- package/dist/chunk-44teqn0b.js +2 -0
- package/dist/{chunk-372xh1g1.js → chunk-49xwf7dk.js} +6 -6
- package/dist/chunk-4akw3bym.js +2 -0
- package/dist/chunk-4d85str1.js +2 -0
- package/dist/{chunk-whsdyf4t.js → chunk-4eescf3s.js} +7 -7
- package/dist/chunk-4xbtxeak.js +2 -0
- package/dist/chunk-53kcqdjj.js +2 -0
- package/dist/{chunk-1xpq83mc.js → chunk-67j2m620.js} +4 -4
- package/dist/chunk-690518hw.js +2 -0
- package/dist/chunk-6s3jwysv.js +2 -0
- package/dist/{chunk-znnvq1jp.js → chunk-6svc4kb8.js} +65 -65
- package/dist/chunk-732gb689.js +2 -0
- package/dist/{chunk-ah6nc29h.js → chunk-80ky40mm.js} +2 -2
- package/dist/chunk-80xzjxah.js +2 -0
- package/dist/chunk-850tye3c.js +2 -0
- package/dist/{chunk-b8528fra.js → chunk-8ccgty8s.js} +4 -4
- package/dist/{chunk-btsgt6w3.js → chunk-8f8qgjjr.js} +2 -2
- package/dist/{chunk-ry6w43p6.js → chunk-8hwfdwgn.js} +6 -6
- package/dist/chunk-9344rq4r.js +38 -0
- package/dist/chunk-94j4p584.js +2 -0
- package/dist/{chunk-y76znqmh.js → chunk-97snfzsy.js} +54 -54
- package/dist/chunk-9a9cec4x.js +2 -0
- package/dist/chunk-9afkttvz.js +2 -0
- package/dist/{chunk-0hj5apb9.js → chunk-9rjgq8k4.js} +1 -1
- package/dist/chunk-a0aqs5a8.js +3 -0
- package/dist/{chunk-9qrgdekg.js → chunk-a3zrwky3.js} +16 -16
- package/dist/{chunk-care745q.js → chunk-a7bqrjm5.js} +2 -2
- package/dist/{chunk-pm4kn9h2.js → chunk-adsqckg4.js} +10 -10
- package/dist/chunk-ah8az9vv.js +2 -0
- package/dist/{chunk-605g9qhp.js → chunk-aj5tsksz.js} +9 -9
- package/dist/chunk-amb7e0fp.js +2 -0
- package/dist/chunk-arr79m90.js +2 -0
- package/dist/{chunk-55kwxxm5.js → chunk-b0hj8eg2.js} +2 -2
- package/dist/{chunk-r57jz09p.js → chunk-bgfs3mbg.js} +5 -5
- package/dist/chunk-bm0mzk3b.js +2 -0
- package/dist/{chunk-ymqm898x.js → chunk-bvqgq18r.js} +2 -2
- package/dist/{chunk-wbxmn5gk.js → chunk-bw2m1e7g.js} +5 -5
- package/dist/{chunk-wm287dz2.js → chunk-c25q87ys.js} +3 -3
- package/dist/{chunk-98mj0es1.js → chunk-ch9028z3.js} +1 -1
- package/dist/{chunk-sbwvvjkc.js → chunk-cmg9x1ka.js} +3 -3
- package/dist/{chunk-11fxbd71.js → chunk-cphc60zw.js} +2 -2
- package/dist/{chunk-dj9ztcth.js → chunk-dvjv4c3a.js} +1 -1
- package/dist/{chunk-v8e2c2r1.js → chunk-e16ef18k.js} +2 -2
- package/dist/chunk-e28czxw3.js +2 -0
- package/dist/chunk-e8szp5wa.js +2 -0
- package/dist/chunk-eq86wzhr.js +1314 -0
- package/dist/chunk-essd43ad.js +2 -0
- package/dist/chunk-f60k8j9m.js +2 -0
- package/dist/chunk-fsk3rk2x.js +2 -0
- package/dist/{chunk-fce8wj3t.js → chunk-g3vce7ka.js} +2 -2
- package/dist/{chunk-em6fqvjy.js → chunk-g5nfqzfh.js} +2 -2
- package/dist/chunk-gfea8a9y.js +2 -0
- package/dist/chunk-hda7t8g6.js +2 -0
- package/dist/chunk-hk241gt2.js +2 -0
- package/dist/{chunk-c3ca056p.js → chunk-htx5yezj.js} +2 -2
- package/dist/{chunk-b0jekg4c.js → chunk-hxws025y.js} +3 -3
- package/dist/chunk-hyyh7qxw.js +25 -0
- package/dist/chunk-j6fs31va.js +2 -0
- package/dist/chunk-j9kejcrx.js +2 -0
- package/dist/chunk-j9vfv53x.js +20 -0
- package/dist/chunk-jhbz5w30.js +2 -0
- package/dist/chunk-jvnsz2x9.js +2 -0
- package/dist/chunk-k4x680e3.js +2 -0
- package/dist/chunk-k8bk685s.js +2 -0
- package/dist/chunk-kexqmwx8.js +2 -0
- package/dist/chunk-kfdmm240.js +2 -0
- package/dist/{chunk-fepezvdq.js → chunk-kg7vby72.js} +8 -8
- package/dist/{chunk-wf8pdjq5.js → chunk-khm56bfm.js} +1 -1
- package/dist/{chunk-303vzq80.js → chunk-kk2p2tgv.js} +3 -3
- package/dist/chunk-kpjq135z.js +2 -0
- package/dist/chunk-kqsm7gf1.js +2 -0
- package/dist/{chunk-j51wss7s.js → chunk-kr2400c3.js} +4 -4
- package/dist/{chunk-r8xper92.js → chunk-ksmn19qw.js} +2 -2
- package/dist/{chunk-7hm1tpw0.js → chunk-mhrnjaka.js} +6 -6
- package/dist/chunk-mtfymhy1.js +2 -0
- package/dist/{chunk-52mhrbps.js → chunk-n6q1d66k.js} +1 -1
- package/dist/chunk-neg6ckjg.js +12 -0
- package/dist/{chunk-wscry63p.js → chunk-nhv81gp2.js} +2 -2
- package/dist/{chunk-c73c0wf9.js → chunk-nq60tjkz.js} +2 -2
- package/dist/{chunk-v47xc2fr.js → chunk-nzpb263k.js} +9 -9
- package/dist/{chunk-p33npqjt.js → chunk-p0bjbtdx.js} +33 -33
- package/dist/{chunk-gdtj5rfa.js → chunk-p3hbsrk9.js} +6 -6
- package/dist/chunk-p82fzxdg.js +2 -0
- package/dist/{chunk-0d7ypcjb.js → chunk-pjj54ddk.js} +3 -3
- package/dist/{chunk-qsnpqa8q.js → chunk-pnmafbv5.js} +1 -1
- package/dist/{chunk-vgsasnwm.js → chunk-pvm48tse.js} +3 -3
- package/dist/{chunk-zek9t5za.js → chunk-pwpge9bj.js} +2 -2
- package/dist/{chunk-6zq3eh7d.js → chunk-q0y8gv18.js} +2 -2
- package/dist/{chunk-7s3j8pqq.js → chunk-qnf7w4xw.js} +3 -3
- package/dist/chunk-qsv84cwm.js +2 -0
- package/dist/{chunk-xavx271y.js → chunk-r5ecgcx2.js} +5 -5
- package/dist/chunk-r7m60q1m.js +2 -0
- package/dist/chunk-r98pye4h.js +2 -0
- package/dist/{chunk-zf29ahhd.js → chunk-rb2zbdqd.js} +4 -4
- package/dist/{chunk-vjfp8n6p.js → chunk-rd663v1m.js} +3 -3
- package/dist/{chunk-4nnmrp7w.js → chunk-rf0smj4c.js} +2 -2
- package/dist/{chunk-0dq9svfb.js → chunk-sh7a0g09.js} +3 -3
- package/dist/chunk-snkbn5y8.js +2 -0
- package/dist/chunk-sztr4d5g.js +2 -0
- package/dist/{chunk-4c9p434g.js → chunk-t0ttxayz.js} +2 -2
- package/dist/{chunk-5ymf5c8m.js → chunk-t3zmfh8w.js} +7 -7
- package/dist/chunk-t4gcsbna.js +2 -0
- package/dist/chunk-tbh7r1wh.js +2 -0
- package/dist/chunk-tspqdt8e.js +2 -0
- package/dist/{chunk-6fsnnj5v.js → chunk-v1mwwben.js} +6 -6
- package/dist/chunk-v3jyb8k6.js +2 -0
- package/dist/chunk-v6gkjg5f.js +3 -0
- package/dist/chunk-v90nz5xm.js +54 -0
- package/dist/{chunk-7nhgpjjw.js → chunk-vf4ejngv.js} +6 -6
- package/dist/chunk-vfcbz0an.js +3 -0
- package/dist/{chunk-hxhmhw23.js → chunk-vk2jy6mn.js} +3 -3
- package/dist/{chunk-e1qcfesw.js → chunk-vkfw9k1n.js} +8 -8
- package/dist/{chunk-mm1eg2pg.js → chunk-vxbvrbqs.js} +10 -10
- package/dist/chunk-wedwczed.js +2 -0
- package/dist/chunk-wg6fmren.js +4 -0
- package/dist/{chunk-s7wp7a2x.js → chunk-whcrca58.js} +31 -31
- package/dist/chunk-wmvvrsn0.js +2 -0
- package/dist/chunk-wnrh62by.js +2 -0
- package/dist/{chunk-q3bkxg2n.js → chunk-wy6vjz1e.js} +21 -21
- package/dist/{chunk-mbm3ma63.js → chunk-x5bn2svk.js} +2 -2
- package/dist/chunk-x6565mhk.js +2 -0
- package/dist/{chunk-brzjass3.js → chunk-xc5esqcb.js} +2 -2
- package/dist/{chunk-e2ws79vt.js → chunk-xeyq6d0t.js} +8 -8
- package/dist/{chunk-xw291tn7.js → chunk-xmg6bmh6.js} +27 -22
- package/dist/{chunk-3fbgpv1d.js → chunk-xvncq3m5.js} +2 -2
- package/dist/chunk-xwgdcc7w.js +2 -0
- package/dist/chunk-xwrjre34.js +2 -0
- package/dist/{chunk-1wkp3pks.js → chunk-xy8smv5e.js} +2 -2
- package/dist/{chunk-y8p59h6c.js → chunk-y1d3j2j7.js} +4 -4
- package/dist/{chunk-zje94z0k.js → chunk-yesh4dfe.js} +61 -61
- package/dist/chunk-ymc1wgb3.js +2 -0
- package/dist/{chunk-xy4j8t7w.js → chunk-ytjn0gq2.js} +2 -2
- package/dist/chunk-z4tdnfxd.js +2 -0
- package/dist/{chunk-w1q86c89.js → chunk-zf68afyh.js} +3 -3
- package/dist/{chunk-6c1vm6bs.js → chunk-zkwkhesc.js} +2 -2
- package/dist/{chunk-2rmqmajd.js → chunk-zpqjsnz9.js} +3 -3
- package/dist/{chunk-vgr7gd8k.js → chunk-zwqkbk2m.js} +2 -2
- package/dist/chunk-zxjdfgdx.js +3 -0
- package/dist/cli.js +29 -29
- package/dist/component-contract.d.ts +1 -0
- package/dist/component-contract.js +6 -4
- package/dist/component-library.d.ts +2 -1
- package/dist/component-library.js +218 -348
- package/dist/composition-api.d.ts +7 -1
- package/dist/craft-entry.js +2 -2
- package/dist/craft.js +2 -2
- package/dist/directive-arguments.js +39 -6
- package/dist/emits-declaration.d.ts +9 -0
- package/dist/emits-declaration.js +64 -0
- package/dist/parser/tokenizer.d.ts +2 -1
- package/dist/parser/tokenizer.js +7 -5
- package/dist/props-declaration.d.ts +66 -0
- package/dist/props-declaration.js +379 -0
- package/dist/pwa.js +3 -3
- package/dist/ssg.js +28 -28
- package/dist/utils.js +20 -109
- package/package.json +5 -5
- package/dist/chunk-000mwmfq.js +0 -1203
- package/dist/chunk-043d0en0.js +0 -2
- package/dist/chunk-0w66z6eq.js +0 -2
- package/dist/chunk-13wd9gf0.js +0 -3
- package/dist/chunk-1znqedae.js +0 -2
- package/dist/chunk-2drzzjcm.js +0 -2
- package/dist/chunk-3c7nt5qp.js +0 -2
- package/dist/chunk-3ed2erm6.js +0 -12
- package/dist/chunk-3zyzhcd9.js +0 -2
- package/dist/chunk-44rb9fk0.js +0 -2
- package/dist/chunk-472j3bhp.js +0 -2
- package/dist/chunk-4acce1m8.js +0 -2
- package/dist/chunk-4kasmp98.js +0 -2
- package/dist/chunk-53kkjn23.js +0 -2
- package/dist/chunk-5gwvy612.js +0 -2
- package/dist/chunk-61vbqrde.js +0 -2
- package/dist/chunk-6fpzwryt.js +0 -2
- package/dist/chunk-7195598h.js +0 -2
- package/dist/chunk-7zvf79vb.js +0 -2
- package/dist/chunk-88a735jw.js +0 -2
- package/dist/chunk-8v7yjq3b.js +0 -2
- package/dist/chunk-94mpe1ny.js +0 -3
- package/dist/chunk-97kgrevs.js +0 -4
- package/dist/chunk-a8c9j9cj.js +0 -2
- package/dist/chunk-acw851e8.js +0 -2
- package/dist/chunk-andfvr3g.js +0 -2
- package/dist/chunk-aqxh80vh.js +0 -2
- package/dist/chunk-ay5zkfdg.js +0 -2
- package/dist/chunk-b4gptdtc.js +0 -2
- package/dist/chunk-baaw9w7y.js +0 -2
- package/dist/chunk-bw2p9h2g.js +0 -2
- package/dist/chunk-ce0vv7kz.js +0 -2
- package/dist/chunk-d1yj29g2.js +0 -2
- package/dist/chunk-dbhmbef1.js +0 -20
- package/dist/chunk-dfsykk1r.js +0 -2
- package/dist/chunk-e9p596bp.js +0 -2
- package/dist/chunk-edysherg.js +0 -25
- package/dist/chunk-ftecsa8e.js +0 -2
- package/dist/chunk-ge2h5v46.js +0 -2
- package/dist/chunk-gqvnz8a7.js +0 -2
- package/dist/chunk-j41gp8p3.js +0 -2
- package/dist/chunk-jxvccj30.js +0 -2
- package/dist/chunk-k5bbre7d.js +0 -2
- package/dist/chunk-kd47vgs8.js +0 -2
- package/dist/chunk-keqjafdz.js +0 -2
- package/dist/chunk-kvxdyg7e.js +0 -3
- package/dist/chunk-kz3mejc4.js +0 -2
- package/dist/chunk-ngkh0t5b.js +0 -2
- package/dist/chunk-nx9895m6.js +0 -2
- package/dist/chunk-nxgtt1t1.js +0 -2
- package/dist/chunk-nyw2ztar.js +0 -2
- package/dist/chunk-p5q27adr.js +0 -2
- package/dist/chunk-p6hcrg3r.js +0 -3
- package/dist/chunk-pa2vt2ej.js +0 -2
- package/dist/chunk-pczb7xav.js +0 -2
- package/dist/chunk-ps37r6hj.js +0 -2
- package/dist/chunk-pvbhk17r.js +0 -2
- package/dist/chunk-q252qvsy.js +0 -2
- package/dist/chunk-q5b0vpmm.js +0 -2
- package/dist/chunk-qg1kw5yf.js +0 -2
- package/dist/chunk-qjy5yq25.js +0 -54
- package/dist/chunk-r561zt9v.js +0 -38
- package/dist/chunk-sbr85vda.js +0 -2
- package/dist/chunk-tkab24xr.js +0 -2
- package/dist/chunk-vn59yrjh.js +0 -2
- package/dist/chunk-w50yggy3.js +0 -3
- package/dist/chunk-w5zzwe2f.js +0 -2
- package/dist/chunk-wa9q1gyv.js +0 -2
- package/dist/chunk-wbmx0rge.js +0 -2
- package/dist/chunk-wpgxhrd7.js +0 -2
- package/dist/chunk-x3azrbpr.js +0 -2
- package/dist/chunk-x50hk1hq.js +0 -2
- package/dist/chunk-xbkbvfcg.js +0 -2
- package/dist/chunk-z55rpt3s.js +0 -3
- package/dist/chunk-zwde52kw.js +0 -2
- package/dist/chunk-zxff7kq9.js +0 -2
|
@@ -0,0 +1,1314 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{Ze,Mn,uo,Ki,z}from"./chunk-41z7f41b.js";import{Nn}from"./chunk-g3vce7ka.js";import{Jr,C,Bl,xt,ta,Fl}from"./chunk-cphc60zw.js";import{D}from"./chunk-vk2jy6mn.js";import{T,R}from"./chunk-0jdz31q1.js";import{Xr,bo,Fn,Dl,Le}from"./chunk-3b3mkgpj.js";import{po,d,m,zr,p,te,K,be,_,bt,ho,De,et,yo}from"./chunk-xmg6bmh6.js";import{w}from"./chunk-v6gkjg5f.js";import{ne}from"./chunk-a0aqs5a8.js";import{t,h}from"./chunk-neg6ckjg.js";import{c}from"./chunk-hxws025y.js";import Ct from"path";import un from"process";import{AsyncLocalStorage as nc}from"async_hooks";var ni=new nc;function Rn(e){return e.__stx_server_data??={pending:new Map,values:new Map}}function si(e,n){return ni.run(Rn(e),n)}async function ri(e,n){let r=ni.getStore();if(!r)throw Error("useServerData must run inside a <script server> render");if(typeof e!=="string"||!e.trim())throw TypeError("useServerData requires a non-empty string key");let i=r.pending.get(e);if(i)return i;let a=Promise.resolve().then(n).then((l)=>{let u=JSON.stringify(l,(v,S)=>{if(S===void 0||typeof S==="function"||typeof S==="symbol"||typeof S==="bigint"||typeof S==="number"&&!Number.isFinite(S))throw TypeError(`useServerData(${JSON.stringify(e)}) requires JSON-serializable data`);if(S&&typeof S==="object"&&!Array.isArray(S)&&Object.getPrototypeOf(S)!==Object.prototype&&Object.getPrototypeOf(S)!==null)throw TypeError(`useServerData(${JSON.stringify(e)}) requires JSON-serializable data`);return S}),f=JSON.parse(u);return r.values.set(e,f),f}).catch((l)=>{throw r.pending.delete(e),l});return r.pending.set(e,a),a}function Br(e){let n=e.__stx_server_data;if(!n?.values.size)return"";return`<script data-stx-scoped data-stx-server-data type="application/json">${JSON.stringify(Object.fromEntries(n.values)).replace(/</g,"\\u003c").replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}</script>`}function X(e,n=!1){let r=t(e),i=[],a=new Set,l=0,u=0,f=r.length,v=()=>{if(l!==0)return;let S=r.slice(u).match(/^(const|let|var)\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*(?:[!:;,\n]|=(?!=)|$)/);if(S){if(n&&S[1]==="const")return;let V=S[2];if(!a.has(V))i.push(V),a.add(V);return}let I=r.slice(u).match(/^(?:const|let|var)\s+\{([^}]+)\}\s*=/);if(I){if(n&&r.slice(u).startsWith("const"))return;I[1].split(",").forEach((V)=>{let W=V.trim();if(!W)return;let Z=W.indexOf(":"),G=(Z>=0?W.slice(Z+1).trim():W).split(/[\s=]/)[0];if(G&&!a.has(G))i.push(G),a.add(G)});return}let j=r.slice(u).match(/^(?:const|let|var)\s+\[([^\]]+)\]\s*=/);if(j){if(n&&r.slice(u).startsWith("const"))return;j[1].split(",").forEach((V)=>{let W=V.trim().replace(/^\.\.\./,"");if(!W)return;let Z=W.split(/[\s=]/)[0];if(Z&&!a.has(Z))i.push(Z),a.add(Z)});return}if(n)return;let L=r.slice(u).match(/^function\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*\(/);if(L){let V=L[1];if(!a.has(V))i.push(V),a.add(V);return}let M=r.slice(u).match(/^async\s+function\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*\(/);if(M){let V=M[1];if(!a.has(V))i.push(V),a.add(V)}};while(u<f){if(r[u]==="{"){l++,u++;continue}if(r[u]==="}"){l--,u++;continue}if(l===0&&/[a-z]/i.test(r[u])&&(u===0||/\s|[;{}()]/.test(r[u-1])))v();u++}return i.join(", ")}function Gs(e){return`{ enumerable: true, configurable: true, get() { return ${e} }, set(__stxValue_${e}) { ${e} = __stxValue_${e} } }`}function sc(e,n=X(e).split(",").map((r)=>r.trim()).filter(Boolean)){let r=new Set(X(e,!0).split(",").map((i)=>i.trim()));return n.map((i)=>r.has(i)?`get ${i}() { return ${i} }, set ${i}(__stxValue_${i}) { ${i} = __stxValue_${i} }`:i).join(", ")}function Xs(e,n){let r=`{ ${sc(e,n)} }`;return X(e).split(",").some((i)=>i.trim()==="__stxLiveBindings")?`Object.defineProperties(${r}, Object.getOwnPropertyDescriptors(__stxLiveBindings))`:r}import sn from"fs";import Fe from"path";function J(e){return e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").replace(/([A-Z]+)([A-Z][a-z])/g,"$1-$2").toLowerCase()}var ii=new Map;function Ir(e,n=!0){let r=ii.get(e);if(n&&r)return r;let i=new Map,a=[Fe.join(e,"src"),Fe.join(e,"dist"),e];function l(u,f){if(f>6)return;let v;try{v=sn.readdirSync(u,{withFileTypes:!0})}catch{return}for(let S of v){let I=Fe.join(u,S.name);if(S.isDirectory()){if(S.name==="node_modules"||S.name.startsWith("."))continue;l(I,f+1)}else if(S.isFile()&&S.name.endsWith(".stx")){let j=S.name.slice(0,-4);if(!i.has(j))i.set(j,I);let L=j.toLowerCase();if(!i.has(L))i.set(L,I);let M=J(j);if(!i.has(M))i.set(M,I)}}}for(let u of a)if(l(u,0),i.size>0)break;if(n)ii.set(e,i);return i}function Js(e,n){if(e.startsWith(".")||e.startsWith("/"))return null;let r=n;while(!0){let i=Fe.join(r,"node_modules",e);try{if(sn.statSync(i).isDirectory())return i}catch{}let a=Fe.dirname(r);if(a===r)return null;r=a}}function Ys(e,n,r={}){return[Fe.resolve(Fe.dirname(n),`${e}.stx`),Fe.resolve(Fe.dirname(n),e),Fe.resolve(r.componentsDir||"components",`${e}.stx`),Fe.resolve(r.componentsDir||"components",e),e.endsWith(".stx")?e:`${e}.stx`]}function oi(e){let n=e.endsWith(".stx")?e.slice(0,-4):e,r=n.split("-").map((a)=>a.charAt(0).toUpperCase()+a.slice(1)).join(""),i=J(n);return[n,r,i]}function Ti(e,n){let[r,i,a]=oi(e);for(let l of[r,r.toLowerCase(),i,a]){let u=n?.__importedComponents?.get(l);if(u!==void 0)return u}}function $i(e,n){let r=n?Fe.resolve(n):void 0,i=Fe.dirname(Fe.resolve(e));for(;;){if(sn.existsSync(Fe.join(i,"package.json")))return r&&i===r?void 0:i;let a=Fe.dirname(i);if(a===i)return;i=a}}var rc=["src/ui","src/components","components","dist"];function rs(e,n){let r=Fe.resolve(e);if(!n&&!r.split(Fe.sep).includes("node_modules"))return[];let i=$i(r,n);if(!i)return[];let a=[];try{let f=JSON.parse(sn.readFileSync(Fe.join(i,"package.json"),"utf8")).stx?.components;if(Array.isArray(f))a=f.filter((v)=>typeof v==="string")}catch{}let l=a.length?a:rc;return[Fe.dirname(Fe.resolve(e)),...l.map((u)=>Fe.resolve(i,u))]}function*Ri(e,n,r={},i){let a=oi(e);if(a[0].startsWith("./")||a[0].startsWith("../")){yield Fe.resolve(Fe.dirname(n),`${a[0]}.stx`);return}let l=[...new Set(a.map((v)=>`${v}.stx`))],u=r.projectRoot||process.cwd(),f=[...rs(n,r.projectRoot),...i?.__originalFilePath?[Fe.join(Fe.dirname(i.__originalFilePath),"components")]:[],...r.componentsDir?[r.componentsDir]:[],Fe.join(Fe.dirname(n),"components"),Fe.resolve(u,"src/components"),Fe.resolve(u,"components"),...import.meta.dir?[Fe.resolve(import.meta.dir,"components")]:[]];for(let v of new Set(f)){for(let S of l)yield Fe.join(v,S);try{for(let S of sn.readdirSync(v,{withFileTypes:!0}))if(S.isDirectory())for(let I of l)yield Fe.join(v,S.name,I)}catch{}}}function ai(e,n,r={},i){let a=Ti(e,i);if(a!==void 0)return a;for(let l of Ri(e,n,r,i))try{if(sn.statSync(l,{throwIfNoEntry:!1})?.isFile())return l}catch{}return null}function Zs(e,n=[],r={}){let i=new Set([...e].map((S)=>S.replace(/[-_]/g,"").toLowerCase()));if(!i.has("src")&&!i.has("source")||!i.has("alt")&&!i.has("decorative"))return!1;let a=new Map(Object.entries(r).map(([S,I])=>[S.replace(/[-_]/g,"").toLowerCase(),I])),l=a.get("alt"),u=a.get("decorative"),f=typeof l==="string"&&!!l.trim(),v=typeof u==="string"?!["false","0","off","no"].includes(u.trim().toLowerCase()):Boolean(u);if(!f&&!v)return!1;if(["defaultsource","provider","format","densities","quality","preload","modifiers","preset"].some((S)=>i.has(S)))return!1;if([...n].some((S)=>!["load","error"].includes(S.replace(/^@/,"").split(".")[0].toLowerCase())))return!1;if(i.has("resizemode")&&(i.has("fit")||i.has("objectfit")))return!1;if(i.has("src")&&i.has("source"))return!1;return["fit","objectfit","resizemode","position","objectposition","rounded","aspectratio","zoomonhover","sources","webpsrc","webpsrcset"].some((S)=>i.has(S))}import Is from"fs";import ge from"path";import Bt from"path";import _n from"fs";var ic=new Set(["touchstart","touchmove","wheel","mousewheel"]);function Us(e,n){if(n.passive)return!0;if(n.prevent||n.nonpassive)return!1;return ic.has(e.toLowerCase())}var ci=new Set(["click","dblclick","mousedown","mouseup","mousemove","mouseenter","mouseleave","mouseover","mouseout","contextmenu","wheel","keydown","keyup","keypress","submit","reset","change","input","focus","blur","focusin","focusout","select","invalid","touchstart","touchend","touchmove","touchcancel","drag","dragstart","dragend","dragenter","dragleave","dragover","drop","scroll","resize","load","error","abort","animationstart","animationend","animationiteration","transitionstart","transitionend","transitionrun","transitioncancel","mounted","unmounted"]),li={enter:"Enter",tab:"Tab",delete:"Delete",backspace:"Backspace",esc:"Escape",escape:"Escape",space:" ",up:"ArrowUp",down:"ArrowDown",left:"ArrowLeft",right:"ArrowRight",home:"Home",end:"End",pageup:"PageUp",pagedown:"PageDown"},oc=new Set(["ctrl","alt","shift","meta"]),fi={left:0,middle:1,right:2};function ui(e){let n={prevent:!1,stop:!1,once:!1,capture:!1,self:!1,passive:!1,nonpassive:!1,keys:[],systemKeys:[],mouse:null,debounce:null,throttle:null};for(let r of e){let i=r.toLowerCase();if(i==="prevent")n.prevent=!0;else if(i==="stop")n.stop=!0;else if(i==="once")n.once=!0;else if(i==="capture")n.capture=!0;else if(i==="self")n.self=!0;else if(i==="passive")n.passive=!0;else if(i==="nonpassive")n.nonpassive=!0;else if(oc.has(i))n.systemKeys.push(i);else if(i in fi)n.mouse=i;else if(i in li||/^[a-z]$/.test(i))n.keys.push(li[i]||i.toUpperCase());else if(i.startsWith("debounce")){let a=i.match(/debounce(?:\.(\d+))?/);n.debounce=a?.[1]?Number.parseInt(a[1],10):300}else if(i.startsWith("throttle")){let a=i.match(/throttle(?:\.(\d+))?/);n.throttle=a?.[1]?Number.parseInt(a[1],10):300}}return n}function di(e,n=""){let r=[],i=0,a=/<([a-z][a-z0-9-]*)\s+([^>]*@[a-z][^>]*)>/gi,l;while((l=a.exec(e))!==null){let[u,f,v]=l,S=l.index,I=S+u.length,j=`__stx_evt_${n}${i++}`,L=[],M=/@([a-z][a-z0-9.]*)\s*=\s*"([^"]*)"/gi,V;while((V=M.exec(v))!==null){let[,Z,q]=V,G=Z.split("."),U=G[0];if(!ci.has(U))continue;L.push({attribute:`@${Z}`,event:U,handler:q,modifiers:ui(G.slice(1)),elementId:j})}let W=/@([a-z][a-z0-9.]*)\s*=\s*'([^']*)'/gi;while((V=W.exec(v))!==null){let[,Z,q]=V,G=Z.split("."),U=G[0];if(!ci.has(U))continue;L.push({attribute:`@${Z}`,event:U,handler:q,modifiers:ui(G.slice(1)),elementId:j})}if(L.length>0)r.push({originalTag:u,elementId:j,events:L,startIndex:S,endIndex:I})}return r}function ac(e){let n=[],{modifiers:r}=e;if(r.self)n.push("if ($event.target !== $el) return");for(let i of r.systemKeys)n.push(`if (!$event.${i}Key) return`);if(r.keys.length>0){let i=r.keys.map((a)=>`$event.key === '${a}'`).join(" || ");n.push(`if (!(${i})) return`)}if(r.mouse!==null){let i=fi[r.mouse];n.push(`if ($event.button !== ${i}) return`)}if(r.prevent)n.push("$event.preventDefault()");if(r.stop)n.push("$event.stopPropagation()");return n.join("; ")}function cc(e,n){let r=e;if(n.debounce!==null)r=`__stx_debounce(() => { ${r} }, ${n.debounce})`;else if(n.throttle!==null)r=`__stx_throttle(() => { ${r} }, ${n.throttle})`;return r}function Hs(e){let n=e.trim();if(!/^[A-Za-z_$][A-Za-z0-9_$]*$/.test(n))return e;return`if (typeof ${n} === 'function' && !${n}._isSignal) ${n}($event);`}function lc(e){let{modifiers:n}=e,r=e.elementId.replace(/\\/g,"\\\\").replace(/'/g,"\\'"),i=ac(e),a=cc(Hs(e.handler),n),l=[];if(n.once)l.push("once: true");if(n.capture)l.push("capture: true");if(Us(e.event,n))l.push("passive: true");let u=l.length>0?`, { ${l.join(", ")} }`:"",f=a.replace(/\\/g,"\\\\").replace(/'/g,"\\'").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/\t/g,"\\t");if(e.event==="mounted")return`
|
|
3
|
+
(function() {
|
|
4
|
+
var $el = document.getElementById('${r}');
|
|
5
|
+
if (!$el) return;
|
|
6
|
+
// Run mounted handler immediately (DOM is ready)
|
|
7
|
+
var scope = $el.closest('[data-stx-scope]');
|
|
8
|
+
if (scope && scope.__stx_execute) {
|
|
9
|
+
scope.__stx_execute('${f}', null, $el);
|
|
10
|
+
}
|
|
11
|
+
else {
|
|
12
|
+
__stx_runHandler('${f}', null, $el);
|
|
13
|
+
}
|
|
14
|
+
})();`;if(e.event==="unmounted")return`
|
|
15
|
+
(function() {
|
|
16
|
+
var $el = document.getElementById('${r}');
|
|
17
|
+
if (!$el) return;
|
|
18
|
+
// Set up MutationObserver to detect removal
|
|
19
|
+
var observer = new MutationObserver(function(mutations) {
|
|
20
|
+
for (var m of mutations) {
|
|
21
|
+
for (var node of m.removedNodes) {
|
|
22
|
+
if (node === $el || (node.contains && node.contains($el))) {
|
|
23
|
+
observer.disconnect();
|
|
24
|
+
var scope = $el.closest('[data-stx-scope]');
|
|
25
|
+
if (scope && scope.__stx_execute) {
|
|
26
|
+
scope.__stx_execute('${f}', null, $el);
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
__stx_runHandler('${f}', null, $el);
|
|
30
|
+
}
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
observer.observe(document.body, { childList: true, subtree: true });
|
|
37
|
+
// Store observer for cleanup
|
|
38
|
+
$el.__stx_unmount_observer = observer;
|
|
39
|
+
})();`;return`
|
|
40
|
+
(function() {
|
|
41
|
+
var $el = document.getElementById('${r}');
|
|
42
|
+
if (!$el) return;
|
|
43
|
+
// eslint-disable-next-line pickier/no-unused-vars
|
|
44
|
+
$el.addEventListener('${e.event}', function($event) {
|
|
45
|
+
${i?i+";":""}
|
|
46
|
+
// Find the closest reactive scope and execute within its context
|
|
47
|
+
var scope = $el.closest('[data-stx-scope]');
|
|
48
|
+
if (scope && scope.__stx_execute) {
|
|
49
|
+
scope.__stx_execute('${f}', $event, $el);
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
// Fallback for non-reactive context (entity-safe; decoded + run in memory)
|
|
53
|
+
__stx_runHandler('${f}', $event, $el);
|
|
54
|
+
}
|
|
55
|
+
}${u});
|
|
56
|
+
})();`}function Ai(e){if(e.length===0)return"";return`
|
|
57
|
+
<script data-stx-events>
|
|
58
|
+
(function() {
|
|
59
|
+
'use strict';
|
|
60
|
+
|
|
61
|
+
// Utility functions
|
|
62
|
+
function __stx_debounce(fn, delay) {
|
|
63
|
+
var timeout;
|
|
64
|
+
return function() {
|
|
65
|
+
var args = arguments;
|
|
66
|
+
var ctx = this;
|
|
67
|
+
clearTimeout(timeout);
|
|
68
|
+
timeout = setTimeout(function() { fn.apply(ctx, args); }, delay);
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
function __stx_throttle(fn, delay) {
|
|
73
|
+
var last = 0;
|
|
74
|
+
return function() {
|
|
75
|
+
var now = Date.now();
|
|
76
|
+
if (now - last >= delay) {
|
|
77
|
+
last = now;
|
|
78
|
+
fn.apply(this, arguments);
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// Non-reactive fallback runner. The handler is embedded HTML-entity-encoded
|
|
84
|
+
// so the surrounding script element can never contain raw markup, including
|
|
85
|
+
// its own closing tag; we decode it to JS only in memory here, then run it
|
|
86
|
+
// with $event/$el in scope.
|
|
87
|
+
//
|
|
88
|
+
// This comment must not spell that closing tag out. It used to, as an
|
|
89
|
+
// example, and a browser ends the script element at the FIRST one it sees \u2014
|
|
90
|
+
// so everything below this line, __stx_runHandler included, was emitted as
|
|
91
|
+
// page text and no listener was ever bound. The comment about escaping was
|
|
92
|
+
// the thing that needed escaping.
|
|
93
|
+
function __stx_runHandler(h, $event, $el) {
|
|
94
|
+
var code = h
|
|
95
|
+
.replace(/</g, '<')
|
|
96
|
+
.replace(/>/g, '>')
|
|
97
|
+
.replace(/"/g, '"')
|
|
98
|
+
.replace(/'/g, "'")
|
|
99
|
+
.replace(/'/g, "'")
|
|
100
|
+
.replace(/&/g, '&');
|
|
101
|
+
try {
|
|
102
|
+
// eslint-disable-next-line no-new-func
|
|
103
|
+
(new Function('$event', '$el', code)).call($el, $event, $el);
|
|
104
|
+
}
|
|
105
|
+
catch (e) {
|
|
106
|
+
if (typeof console !== 'undefined') console.error('[stx] event handler error:', e);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
// Event listeners
|
|
111
|
+
${e.map(lc).join(`
|
|
112
|
+
`)}
|
|
113
|
+
})();
|
|
114
|
+
</script>`}function uc(e,n=""){let r=di(e,n);if(r.length===0)return{template:e,bindings:[]};let i=e,a=[];for(let l=r.length-1;l>=0;l--){let u=r[l],f=u.originalTag;if(!f.includes(" id="))f=f.replace(/^<([a-z][a-z0-9-]*)/,`<$1 id="${u.elementId}"`);else{let v=f.match(/id=["']([^"']+)["']/);if(v)for(let S of u.events)S.elementId=v[1]}for(let v of u.events){let S=v.attribute.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),I=new RegExp(`\\s*${S}\\s*=\\s*"[^"]*"`,"g"),j=new RegExp(`\\s*${S}\\s*=\\s*'[^']*'`,"g");f=f.replace(I,""),f=f.replace(j,"")}i=i.slice(0,u.startIndex)+f+i.slice(u.endIndex),a.push(...u.events)}return{template:i,bindings:a}}function pi(e){let n=e.$uid;return typeof n==="string"&&n?`${n}_`:""}function tl(e,n,r){if(Fl(e))return e;if(n.__stx_sfc_mode){if(/x-data\s*=\s*["']/.test(e))return e;let{template:f,bindings:v}=uc(e,pi(n)),S=n.__stx_event_bindings||[];return n.__stx_event_bindings=[...S,...v],f}let i=di(e,pi(n));if(i.length===0)return e;let a=e;for(let f=i.length-1;f>=0;f--){let v=i[f],S=v.originalTag;if(!S.includes(" id="))S=S.replace(/^<([a-z][a-z0-9-]*)/,`<$1 id="${v.elementId}"`);else{let I=S.match(/id=["']([^"']+)["']/);if(I)for(let j of v.events)j.elementId=I[1]}for(let I of v.events){let j=I.attribute.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),L=new RegExp(`\\s*${j}\\s*=\\s*"[^"]*"`,"g"),M=new RegExp(`\\s*${j}\\s*=\\s*'[^']*'`,"g");S=S.replace(L,""),S=S.replace(M,"")}a=a.slice(0,v.startIndex)+S+a.slice(v.endIndex)}let l=Ai(i.flatMap((f)=>f.events)),u=c(a);if(u!==-1)a=a.slice(0,u)+l+`
|
|
115
|
+
`+a.slice(u);else a+=l;return a}function gi(e,n){let r=new Set;for(let i of e.split(",")){let a=i.trim().replace(/^\.\.\./,"").trim();if(!a)continue;if(n){let l=a.lastIndexOf(":");if(l!==-1)a=a.slice(l+1).trim()}if(a=a.split("=")[0].trim(),/^[A-Za-z_$][\w$]*$/.test(a))r.add(a)}return r}function Vt(e,n){let r=t(e),{depths:i,balanced:a}=h(r),l=(f)=>!a||i[f]===0,u=new RegExp(`(?:^|[^\\w$.])((?:const|let|var|function|class)\\s+${n}\\b)`,"g");for(let f of r.matchAll(u)){let v=(f.index??0)+f[0].length-f[1].length;if(l(v))return!0}for(let f of r.matchAll(/(?:const|let|var)\s*\{([^}]*)\}/g))if(l(f.index??0)&&gi(f[1],!0).has(n))return!0;for(let f of r.matchAll(/(?:const|let|var)\s*\[([^\]]*)\]/g))if(l(f.index??0)&&gi(f[1],!1).has(n))return!0;return!1}var Ue="0.2.890";var mi=Symbol.for(`stx.lazy-module-promises.${Ue}`);function fc(){let e=globalThis;return e[mi]??=new Map,e[mi]}function o(e,n){let r=fc(),i=`${import.meta.url}\x00${e}`,a=r.get(i);if(a)return a;let l=n();return r.set(i,l),l.catch(()=>{if(r.get(i)===l)r.delete(i)}),l}var dc=/<\/(script)/gi;function me(e){if(!e||e.indexOf("</")===-1)return e;return e.replace(dc,"<\\/$1")}import hi from"fs";var xi=[];function k(e){let n=new T(e);return xi.push(n),n}function nl(){for(let e of xi)e.clear()}function E(e,...n){return`${n.map((r)=>String(r??"")).join("\x00")}\x00${e.length}\x00${Bun.hash(e)}`}function Or(e){let n=[];for(let r of new Set(e))try{n.push({path:r,mtimeMs:hi.statSync(r).mtimeMs})}catch{}return n}function Qs(e){for(let n of e)try{if(hi.statSync(n.path).mtimeMs!==n.mtimeMs)return!1}catch{return!1}return!0}var Ie=["browserQuery","BrowserQueryBuilder","BrowserQueryError","browserAuth","configureBrowser","getBrowserConfig","createBrowserDb","createBrowserModel","isBrowser","debounce","throttle","retry","sleep","wait","delay","waitUntil","waitWhile","lazy","clamp","rand","readableSize","useActiveElement","useIntervalFn","useObjectUrl"];var gc=/^[ \t]*import\s+['"]([^'"]+?\.css)(\?[^'"]*)?['"]\s*;?\s*$/gm;function mc(e){if(e.startsWith(".")||e.startsWith("/"))return null;if(e.startsWith("@")){let r=e.match(/^(@[^/]+\/[^/]+)(\/.*)?$/);if(!r)return null;return{pkg:r[1],subpath:r[2]||""}}let n=e.match(/^([^/]+)(\/.*)?$/);if(!n)return null;return{pkg:n[1],subpath:n[2]||""}}function hc(e,n){let r=n;while(!0){let i=Bt.join(r,"node_modules",e,"package.json");if(_n.existsSync(i))return Bt.dirname(i);let a=Bt.dirname(r);if(a===r)return null;r=a}}function xc(e,n){if(!e||typeof e!=="object")return null;let r=(a)=>{if(typeof a==="string")return a;if(a&&typeof a==="object"){if(typeof a.import==="string")return a.import;if(typeof a.default==="string")return a.default;if(typeof a.import==="object")return r(a.import);if(typeof a.default==="object")return r(a.default)}return null};if(Object.prototype.hasOwnProperty.call(e,n))return r(e[n]);let i=null;for(let a of Object.keys(e)){let l=a.indexOf("*");if(l===-1)continue;let u=a.slice(0,l),f=a.slice(l+1);if(!n.startsWith(u)||!n.endsWith(f))continue;if(n.length<u.length+f.length)continue;if(!i||u.length>i.prefix.length)i={pattern:a,prefix:u,suffix:f}}if(i){let a=n.slice(i.prefix.length,n.length-i.suffix.length),l=r(e[i.pattern]);if(l)return l.replace("*",a)}return null}function bc(e,n){let r=mc(e);if(!r||!r.subpath)return null;let i=hc(r.pkg,n);if(!i)return null;let a;try{a=JSON.parse(_n.readFileSync(Bt.join(i,"package.json"),"utf8"))}catch{return null}let l=`.${r.subpath}`,u=xc(a.exports,l);if(!u)return null;let f=Bt.resolve(i,u);return _n.existsSync(f)?f:null}function Fi(e,n){let r=n.filePath?Bt.dirname(n.filePath):n.projectRoot||process.cwd(),i=n.projectRoot||process.cwd(),a=new Set,l=[],u=[];return{code:e.replace(gc,(v,S)=>{let I;try{if(S.startsWith("./")||S.startsWith("../")||S.startsWith("/")){if(I=S.startsWith("/")?S:Bt.resolve(r,S),!_n.existsSync(I))throw Error(`file not found: ${I}`)}else{let j=null;try{j=Bun.resolveSync(S,i)}catch{j=bc(S,i)}if(!j)throw Error(`could not resolve ${S} (Bun.resolveSync + exports fallback both failed)`);I=j}}catch(j){return console.warn(`[stx:vendor-css] could not resolve ${JSON.stringify(S)} (from ${n.filePath||"<unknown>"}): ${j?.message||j}`),u.push(S),""}if(a.has(I))return"";a.add(I);try{let j=_n.readFileSync(I,"utf8");l.push({source:S,resolvedPath:I,contents:j})}catch(j){console.warn(`[stx:vendor-css] could not read ${I}: ${j?.message||j}`),u.push(S)}return""}),styles:l,unresolved:u}}function yc(e){return e.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}function zi(e){if(e.length===0)return"";return`${e.map((n)=>`<style data-stx-vendor="${yc(n.source)}" data-stx-layer="vendor">
|
|
116
|
+
@layer vendor {
|
|
117
|
+
${n.contents}
|
|
118
|
+
}
|
|
119
|
+
</style>`).join(`
|
|
120
|
+
`)}
|
|
121
|
+
`}var Dg=C,bi=k(256);function Xt(e){let n=E(e),r=bi.get(n);if(!r)r=_c(e),bi.set(n,r);return{code:r.code,imports:[...r.imports],models:[...r.models]}}function _c(e){let n=t(e),r=new Set;for(let f of e.matchAll(/^\s*import\s+(?:type\s+)?\{([^}]*)\}\s+from\s+['"][^'"]+['"]\s*;?\s*$/gm))for(let v of f[1].split(",")){let S=v.trim().split(/\s+as\s+/).pop()?.replace(/^type\s+/,"").trim();if(S)r.add(S)}let i=bo(n),a=Ie.filter((f)=>{if(r.has(f)||i.has(f))return!1;return Lg(n,f,!0)}),l=vi(n).filter((f)=>!r.has(f)&&!i.has(f));if(a.length===0&&l.length===0)return{code:e,imports:a,models:l};return{code:`${[a.length>0?`import { ${a.join(", ")} } from '@stacksjs/browser'`:"",l.length>0?"import '@stacksjs/browser'":"",l.length>0?`const { ${l.join(", ")} } = window.StacksBrowser || {}`:""].filter(Boolean).join(`
|
|
122
|
+
`)}
|
|
123
|
+
${e}`,imports:a,models:l}}var wc=new Set(["Promise","Object","Array","Map","Set","Date","Error","JSON","Math","Number","String","RegExp","Symbol","WeakMap","WeakSet","Proxy","Reflect","Intl","URL","URLSearchParams","FormData","Headers","Request","Response","AbortController","EventTarget","Element","Document","Node","Window","Console","Storage","Navigator","Blob","File","FileReader","HTMLElement","SVGElement","Event","CustomEvent","DOMParser","XMLSerializer","WebSocket","Worker","SharedWorker","IntersectionObserver","MutationObserver","ResizeObserver","PerformanceObserver","Notification","Bun","Buffer","Process","Modal","Intl"]);function vi(e,n=Xr(e)){let r=new Set,i=bo(e),a=/(?<![\w$.])([A-Z][a-zA-Z0-9]*)\s*\.\s*(all|find|first|get|where|orderBy|orderByDesc|limit|select|pluck|create|update|delete)\s*\(/g;for(let l of n.code.matchAll(a)){let u=l[1];if(wc.has(u)||i.has(u)||u.length<3)continue;if(n.shadows(u,l.index??0))continue;r.add(u)}return Array.from(r)}function vc(e){return bo(e)}var yi=k(128);function vl(e){let n=E(e),r=yi.get(n);if(!r)r=Sc(e),yi.set(n,r);return{code:r.code,stxImports:[...r.stxImports],browserImports:[...r.browserImports]}}function Sc(e){let n=new Set,r=new Set,i=e;i=i.replace(/^[ \t]*import\s+type\s+\{[^}]*\}\s+from\s+['"][^'"]+['"][ \t]*;?[ \t]*$/gm,"// [type import stripped]");let a=new Set,l=/^[ \t]*import\s+(?:type\s+)?{\s*([^}]+)\s*}\s+from\s+['"](@stacksjs\/browser|@stacksjs\/stx|stx)['"][ \t]*;?[ \t]*$/gm,u;while((u=l.exec(e))!==null){let M=u[1],V=u[2];if(u[0].includes("import type"))continue;let W=[];for(let q of M.split(",")){let G=q.trim();if(!G||G.startsWith("type "))continue;let U=G.match(/^([A-Za-z_$][\w$]*)(?:\s+as\s+([A-Za-z_$][\w$]*))?$/);if(!U)continue;let H=U[1],re=U[2]||H;if(a.add(H),a.add(re),V==="stx"||V==="@stacksjs/stx")n.add(H);else r.add(H);if(re!==H)W.push(`${re} = ${H}`)}let Z=W.length>0?`var ${W.join(", ")}; /* [auto-import processed] */`:"// [auto-import processed]";i=i.replace(u[0],Z)}let f=vc(i),v=Xr(i);for(let M of Dg){if(a.has(M)||f.has(M))continue;if(Ks(v,M,!0))n.add(M)}let S=t(i),I=Xr(S),j=new Set;for(let M of i.matchAll(/^\s*import\s+(?:type\s+)?\{([^}]*)\}\s+from\s+['"][^'"]+['"]\s*;?\s*$/gm))for(let V of M[1].split(",")){let W=V.trim().replace(/^type\s+/,"").split(/\s+as\s+/);for(let Z of W){let q=Z.trim();if(q)j.add(q)}}for(let M of Ie){if(a.has(M)||f.has(M)||j.has(M))continue;if(Ks(I,M))r.add(M)}let L=vi(S,I);for(let M of L)if(!a.has(M)&&!f.has(M))r.add(M);return{code:i,stxImports:Array.from(n),browserImports:Array.from(r)}}function Lg(e,n,r=!1){return Ks(Xr(e),n,r)}function Ks(e,n,r=!1){let i=e.code,a=new RegExp(`\\b${n.replace(/[$]/g,"\\$")}\\b`,"g");for(let l of i.matchAll(a)){let u=l.index??0;if(e.shadows(n,u))continue;let f=u+n.length,v=u-1;while(v>=0&&/\s/.test(i[v]))v--;if(i[v]==="."&&i.slice(Math.max(0,v-2),v+1)!=="...")continue;let S=f;while(S<i.length&&/\s/.test(i[S]))S++;if(i[S]===":"&&i[S+1]!==":"&&(i[v]==="{"||i[v]===","))continue;if(r&&!/^\s*(?:<[^>]*>)?\s*\(/.test(i.slice(f)))continue;if($c(i,f))continue;return!0}return!1}function $c(e,n){let r=n;while(r<e.length&&(e[r]===" "||e[r]==="\t"))r++;if(e[r]!=="(")return!1;let i=0;for(;r<e.length;r++){let a=e[r];if(a==="(")i++;else if(a===")"){if(i--,i===0)break}}if(i!==0)return!1;r++;while(r<e.length&&(e[r]===" "||e[r]==="\t"))r++;return e[r]==="{"}function xl(e,n){let r=[];if(e.length>0)r.push(` var { ${e.join(", ")} } = window.stx || window;`);if(n.length>0)r.push(` var { ${n.join(", ")} } = window.StacksBrowser || {};`);if(r.length>0)return` // STX: auto-imported from stx and @stacksjs/browser
|
|
124
|
+
${r.join(`
|
|
125
|
+
`)}
|
|
126
|
+
${Ec(e,n)}`;return""}function Ty(e,n=[]){let{browserImports:r}=vl(e),i=new Set(n);return xl([],r.filter((a)=>!i.has(a)))}function Ec(e,n){let r=[...e.map((i)=>`['${i}', typeof ${i}, 'stx']`),...n.map((i)=>`['${i}', typeof ${i}, '@stacksjs/browser']`)];if(r.length===0)return"";return` // STX: report auto-imports the client runtime did not provide
|
|
127
|
+
[${r.join(", ")}].forEach(function (e) {
|
|
128
|
+
if (e[1] !== 'undefined') return;
|
|
129
|
+
console.error(
|
|
130
|
+
'[stx] "' + e[0] + '" is used in this client script and auto-imported from ' + e[2] + ', '
|
|
131
|
+
+ 'but the client runtime does not provide it. Either it is not exported to the browser, '
|
|
132
|
+
+ 'or it should be imported from a relative path so the bundler includes it.'
|
|
133
|
+
);
|
|
134
|
+
});
|
|
135
|
+
`}function Ke(e){let n=e.__stxClientPayload;if(n&&typeof n==="object"){let i={};for(let a in n){let l=n[a];if(typeof l==="function")continue;i[a]=l}return i.__stxDeclaredPayload=!0,i}let r={};for(let i in e){if(i.startsWith("__")||i.startsWith("$"))continue;let a=e[i];if(typeof a==="function")continue;r[i]=a}return r}var kc=/token|secret|passw|apikey|api_key|privatekey|private_key|credential|webhook|bearer|jwt|signature/i,_i=new Set;function Cc(e,n){let r=kc.test(e),i=n.length>32768;if(!r&&!i)return;if(_i.has(e))return;if(_i.add(e),r)console.warn(`[stx] server\u2192client bridge is publishing "${e}" into the page body. If it holds a credential, rename it with a "__" prefix (never bridged) and pass only what the template needs. See stacksjs/stx#1831.`);if(i)console.warn(`[stx] server\u2192client bridge is publishing ${(n.length/1024).toFixed(1)}KB under "${e}". Every byte ships in the HTML on each request; prefix the binding with "__" and project just the fields the client reads.`)}function An(e,n){if(!n)return"";let r=Le(e,new Set(Object.keys(n))),i=n.__stxDeclaredPayload===!0,a=[],l=Object.entries(n).sort(([u],[f])=>u<f?-1:u>f?1:0);for(let[u,f]of l){if(!/^[A-Za-z_$][\w$]*$/.test(u))continue;if(u.startsWith("__")||u.startsWith("$"))continue;if(!i&&!r.has(u))continue;if(Vt(e,u)){if(i)console.warn(`[stx] defineClientPayload declares "${u}", but this client block also declares "${u}" at the top level, so the server value is not published (emitting it would be a duplicate binding). Rename the local, or drop "${u}" from defineClientPayload.`);continue}let v;try{v=JSON.stringify(f)}catch{continue}if(v===void 0)continue;Cc(u,v),a.push(` var ${u} = ${v.replace(/</g,"\\u003c")};`)}if(a.length===0)return"";return` // stx: server -> client data bridge (seeded from server scope)
|
|
136
|
+
${a.join(`
|
|
137
|
+
`)}
|
|
138
|
+
`}var Rc={left:0,middle:1,right:2};function Tc(e){let n=[];if(e.self)n.push("if ($event.target !== $el) return");for(let r of e.systemKeys)n.push(`if (!$event.${r}Key) return`);if(e.keys.length>0){let r=e.keys.map((i)=>`$event.key === '${i}'`).join(" || ");n.push(`if (!(${r})) return`)}if(e.mouse!==null){let r=Rc[e.mouse];n.push(`if ($event.button !== ${r}) return`)}if(e.prevent)n.push("$event.preventDefault()");if(e.stop)n.push("$event.stopPropagation()");return n.join("; ")}function Ac(e,n){let{elementId:r,event:i,modifiers:a}=e,l=Hs(e.handler),u=Tc(a),f=[];if(a.once)f.push("once: true");if(a.capture)f.push("capture: true");if(Us(i,a))f.push("passive: true");let v=f.length>0?`, { ${f.join(", ")} }`:"",S="";if(u)S+=`${u}; `;let I=l.replace(/\\/g,"\\\\").replace(/'/g,"\\'"),j=`var $emit = function(name, detail) {
|
|
139
|
+
$el.dispatchEvent(new CustomEvent(name, { detail: detail, bubbles: true, cancelable: true }))
|
|
140
|
+
};`;function L(M){if(/\$emit\s*\(/.test(M))return`${j}
|
|
141
|
+
${M}`;return`var scope = $el.closest('[data-stx-scope]');
|
|
142
|
+
if (scope && scope.__stx_execute) {
|
|
143
|
+
scope.__stx_execute('${I}', $event, $el);
|
|
144
|
+
}
|
|
145
|
+
else {
|
|
146
|
+
${M}
|
|
147
|
+
}`}if(a.debounce!==null)return` ;(function() {
|
|
148
|
+
// eslint-disable-next-line pickier/no-unused-vars
|
|
149
|
+
var $el = document.getElementById('${r}')
|
|
150
|
+
if (!$el) return
|
|
151
|
+
var __timer
|
|
152
|
+
$el.addEventListener('${i}', function($event) {
|
|
153
|
+
${u?u+"; ":""}clearTimeout(__timer)
|
|
154
|
+
__timer = setTimeout(function() { ${L(l)} }, ${a.debounce})
|
|
155
|
+
}${v})
|
|
156
|
+
})()`;if(a.throttle!==null)return` ;(function() {
|
|
157
|
+
// eslint-disable-next-line pickier/no-unused-vars
|
|
158
|
+
var $el = document.getElementById('${r}')
|
|
159
|
+
if (!$el) return
|
|
160
|
+
var __last = 0
|
|
161
|
+
$el.addEventListener('${i}', function($event) {
|
|
162
|
+
${u?u+"; ":""}var __now = Date.now()
|
|
163
|
+
if (__now - __last >= ${a.throttle}) {
|
|
164
|
+
__last = __now
|
|
165
|
+
${L(l)}
|
|
166
|
+
}
|
|
167
|
+
}${v})
|
|
168
|
+
})()`;if(/\$emit\s*\(/.test(l))return` var $el = document.getElementById('${r}')
|
|
169
|
+
if ($el) $el.addEventListener('${i}', function($event) {
|
|
170
|
+
${S}${j}
|
|
171
|
+
${l}
|
|
172
|
+
}${v})`;return` var $el = document.getElementById('${r}')
|
|
173
|
+
if ($el) $el.addEventListener('${i}', function($event) {
|
|
174
|
+
${S}var scope = $el.closest('[data-stx-scope]');
|
|
175
|
+
if (scope && scope.__stx_execute) {
|
|
176
|
+
scope.__stx_execute('${I}', $event, $el);
|
|
177
|
+
}
|
|
178
|
+
else {
|
|
179
|
+
${l}
|
|
180
|
+
}
|
|
181
|
+
}${v})`}function Ic(e){if(e.length===0)return"";return`
|
|
182
|
+
// STX: auto-generated event bindings
|
|
183
|
+
${e.map((r,i)=>Ac(r,i)).join(`
|
|
184
|
+
`)}`}function wi(e){let n=[],r=new Set,i=e.replace(/^\s*import\s+.*$/gm,""),a=0,l=i.length,u=0;while(u<l){let f=i[u];if(f==="'"||f==='"'||f==="`"){let v=f;if(u++,v==="`"){let S=0;while(u<l){if(i[u]==="\\"){u+=2;continue}if(i[u]==="`"&&S===0){u++;break}if(i[u]==="$"&&i[u+1]==="{"){S++,u+=2;continue}if(i[u]==="}"&&S>0){S--,u++;continue}u++}}else while(u<l){if(i[u]==="\\"){u+=2;continue}if(i[u]===v){u++;break}u++}continue}if(f==="/"&&i[u+1]==="/"){while(u<l&&i[u]!==`
|
|
185
|
+
`)u++;continue}if(f==="/"&&i[u+1]==="*"){u+=2;while(u<l-1&&!(i[u]==="*"&&i[u+1]==="/"))u++;u+=2;continue}if(f==="{"){a++,u++;continue}if(f==="}"){a--,u++;continue}if(a===0){let v=i.slice(u),S=v.match(/^(?:const|let|var)\s+([a-zA-Z_$]\w*)\s*(?::[^=]*)?=/);if(S){let L=S[1];if(!L.startsWith("_")&&!r.has(L))n.push(L),r.add(L);u+=S[0].length;continue}let I=v.match(/^(?:const|let|var)\s+\{([^}]+)\}\s*=/);if(I){I[1].split(",").forEach((L)=>{let M=L.trim(),V=M.indexOf(":"),W=V>=0?M.slice(V+1).trim().split(/[\s=]/)[0]:M.split(/[\s=]/)[0];if(W&&!W.startsWith("_")&&!r.has(W))n.push(W),r.add(W)}),u+=I[0].length;continue}let j=v.match(/^(?:async\s+)?function\s+([a-zA-Z_$]\w*)/);if(j){let L=j[1];if(!L.startsWith("_")&&!r.has(L))n.push(L),r.add(L);u+=j[0].length;continue}}u++}return n}var Oc=new Set(["if","else","true","false","null","undefined","typeof","instanceof","in","of","new","this","return","void","delete","throw","switch","case","break","continue","for","while","do","try","catch","finally","const","let","var","function","class","import","export","default","async","await","yield","with","debugger","console","window","document","Math","JSON","Date","Array","Object","String","Number","Boolean","Symbol","Map","Set","Promise","Error","parseInt","parseFloat","isNaN","isFinite","encodeURIComponent","decodeURIComponent","setTimeout","setInterval","clearTimeout","clearInterval","fetch","alert","confirm","prompt","event"]);function jc(e){let n=new Set,r=/[a-zA-Z_$][a-zA-Z0-9_$]*/g;function i(L){let M;while((M=r.exec(L))!==null){let V=M[0];if(!Oc.has(V))n.add(V)}}let a=/\{\{([\s\S]*?)\}\}/g,l;while((l=a.exec(e))!==null)i(l[1]);let u=/:[a-z][\w.-]*\s*=\s*"([^"]*)"/gi;while((l=u.exec(e))!==null)i(l[1]);let f=/:[a-z][\w.-]*\s*=\s*'([^']*)'/gi;while((l=f.exec(e))!==null)i(l[1]);let v=/@[a-z]+(?:\.[a-z]+)*\s*=\s*"([^"]*)"/gi;while((l=v.exec(e))!==null)i(l[1]);let S=/@[a-z]+(?:\.[a-z]+)*\s*=\s*'([^']*)'/gi;while((l=S.exec(e))!==null)i(l[1]);let I=/@model\s*=\s*["']([^"']*)["']/gi;while((l=I.exec(e))!==null)i(l[1]);let j=/@for\s*=\s*["'][^"']*\bin\s+([^"']+)["']/gi;while((l=j.exec(e))!==null)i(l[1]);return n}async function Ge(e,n={}){let r=e,i="",a=!1,l=[],u=Fi(r,{filePath:n.filePath,projectRoot:n.projectRoot});r=u.code;let f=zi(u.styles),v=Xt(r);r=v.code,l=[...v.imports,...v.models];let{hasUserImports:S,bundleClientScript:I}=await o("stx/client-script-bundler",()=>import("./chunk-sztr4d5g.js"));if(S(r))r=await I(r,n.filePath||"",{projectRoot:n.projectRoot,minify:n.production}),a=!0;if(n.autoImports!==!1){let U=vl(r);r=U.code,i=xl(U.stxImports,U.browserImports.filter((H)=>!l.includes(H)))}if(i=`${An(r,n.serverData)}${i}`,r=D(r),!a&&Xe(n.attrs||""))r=Je(r);let j=Ic(n.eventBindings||[]),L=(n.attrs||"").trim(),M=/\btype\s*=\s*["']module["']/i.test(L),V=n.instanceId?` data-stx-instance="${n.instanceId}"`:"";if(M){let U=L.replace(/\btype\s*=\s*["']module["']/i,"").trim(),H=`type="module" data-stx-scoped${V}${U?` ${U}`:""}`;return`${f}<script ${H}>
|
|
186
|
+
${me(`${i}${r}
|
|
187
|
+
${j}`)}
|
|
188
|
+
</script>`}let W=ta(e),Z=/function __stx_setup_/.test(r),q=/\bstx\.mount\s*\(|\bstx\.mountEl\s*\(/.test(e);function G(U){let H=U.length>0?`
|
|
189
|
+
return ${Xs(r,U)};`:"",re=JSON.stringify(`[stx] client block failed${n.filePath?` (${n.filePath})`:""}; this block will not hydrate`);return`${f}<script data-stx-scoped data-stx-run="always"${V}>
|
|
190
|
+
window.stx.mount(function() {
|
|
191
|
+
'use strict';
|
|
192
|
+
try {
|
|
193
|
+
${me(`${i}${r}
|
|
194
|
+
${j}${H}`)}
|
|
195
|
+
} catch (error) {
|
|
196
|
+
console.error(${re}, error);
|
|
197
|
+
return {};
|
|
198
|
+
}
|
|
199
|
+
})</script>`}if(!q&&!Z){if(W)return G(wi(e));if(n.templateContent){let U=wi(e);if(U.length>0){let H=jc(n.templateContent);if(U.some((ce)=>H.has(ce)))return G(U)}}}return`${f}<script data-stx-scoped data-stx-run="always"${V}>
|
|
200
|
+
;(function() {
|
|
201
|
+
'use strict';
|
|
202
|
+
try {
|
|
203
|
+
${me(`${i}${r}
|
|
204
|
+
${j}`)}
|
|
205
|
+
} catch (error) {
|
|
206
|
+
console.error(${JSON.stringify(`[stx] client block failed${n.filePath?` (${n.filePath})`:""}; this block will not hydrate`)}, error);
|
|
207
|
+
}
|
|
208
|
+
})()</script>`}import{createHash as Wc}from"crypto";var qs=/\s*/y,er=/\x00STX_HTML_COMMENT_\d+\x00/y;function Ut(e){let n=0;while(n<e.length){if(qs.lastIndex=n,qs.exec(e),n=qs.lastIndex,e.startsWith("<!--",n)){let r=e.indexOf("-->",n+4);if(r===-1)return n;n=r+3;continue}if(er.lastIndex=n,er.test(e)){n=er.lastIndex;continue}return n}return n}var tr=/<(\/?)([a-zA-Z][a-zA-Z0-9-]*)\b/y,Pc=new Map(["textarea","title","xmp","iframe","noembed","noframes"].map((e)=>[e,new RegExp(`</${e}\\s*>`,"ig")]));function Oe(e){let n=[],r=0;while(r<e.length){let i=e.indexOf("<",r);if(i===-1)break;if(e.startsWith("<!--",i)){let L=e.indexOf("-->",i+4);if(L===-1)break;r=L+3;continue}tr.lastIndex=i;let a=tr.exec(e);if(!a){r=i+1;continue}let l=tr.lastIndex,u=l,f=null;for(;u<e.length;u++){let L=e[u];if(f){if(L===f)f=null}else if(L==='"'||L==="'")f=L;else if(L===">")break}if(u===e.length)break;let v=a[1]==="/",S=e[u-1]==="/";n.push({start:i,end:u+1,name:a[2],attributes:e.slice(l,S?u-1:u),closing:v,selfClosing:S}),r=u+1;let I=a[2].toLowerCase();if(!v&&I==="plaintext")break;let j=Pc.get(I);if(!v&&(I==="script"||I==="style"||j)){let L=j??(I==="script"?as:cs);L.lastIndex=r;let M=L.exec(e);if(!M)break;r=M.index}}return n}var is=/<script\b[^>]*>/iy,as=/<\/script\s*>/ig,os=/<style\b[^>]*>/iy,cs=/<\/style\s*>/ig;function Si(e,n,r,i){r.lastIndex=n;let a=r.exec(e);if(!a||a.index!==n)return-1;i.lastIndex=r.lastIndex;let l=i.exec(e);if(!l)return-1;return l.index+l[0].length}function Q(e,n){return Si(e,n,is,as)}function Cn(e,n){return Si(e,n,os,cs)}function qe(e,n){if(!e.startsWith("<!--",n))return-1;let r=e.indexOf("-->",n+4);if(r===-1)return-1;return r+3}function Ei(e,n){if(e.startsWith("<!--",n)){let a=qe(e,n);return a===-1?e.length:a}if(is.lastIndex=n,is.exec(e)?.index===n){as.lastIndex=is.lastIndex;let a=as.exec(e);return a?a.index+a[0].length:e.length}if(os.lastIndex=n,os.exec(e)?.index===n){cs.lastIndex=os.lastIndex;let a=cs.exec(e);return a?a.index+a[0].length:e.length}return-1}function x(e,n){let r=[],i=0,a=e.length,l=!1,u=null;while(i<a){let f=e[i];if(l){if(u){if(f===u)u=null}else if(f==='"'||f==="'")u=f;else if(f===">")l=!1;i++;continue}if(f!=="<"){let j=e.indexOf("<",i+1);if(j===-1)break;i=j;continue}let v=n(e,i);if(v>i){r.push({start:i,end:v,token:e.slice(i,v)}),i=v;continue}let S=Ei(e,i);if(S>i){i=S;continue}let I=e.charCodeAt(i+1);if(I>=65&&I<=90||I>=97&&I<=122)l=!0;i++}return r}function ki(e){let n=0,r=0,i=0,a=!1,l=null;while(i<e.length){if(a){let j=e[i];if(l){if(j===l)l=null}else if(j==='"'||j==="'")l=j;else if(j===">")a=!1;i++;continue}let u=e.indexOf("<",i),f=u===-1?e.length:u;while(i<f){let j=e[i++];if(j==="{")n++;else if(j==="}")r++;if(n>=2&&r>=2)return!0}if(u===-1)break;let v=Ei(e,u);if(v>u){i=v;continue}let S=e.charCodeAt(u+1),I=S===47?e.charCodeAt(u+2):S;if(I>=65&&I<=90||I>=97&&I<=122)a=!0;i=u+1}return!1}function rl(e,n){while(e.size>=n){let r=e.keys().next();if(r.done)return;e.delete(r.value)}}var Mc=1024,Dc=16777216,rn=new Map,nr=0;function Nc(e,n){rn.set(e,n),nr+=e.length+n.output.length;for(let[r,i]of rn){if(nr<=Dc)break;rn.delete(r),nr-=r.length+i.output.length}}function ke(e,n,r,i){let a=i!==void 0&&e.length>=Mc,l=a?`${i}\x00${e}`:"";if(a){let I=rn.get(l);if(I)return rn.delete(l),rn.set(l,I),{output:I.output,tokens:I.tokens.slice()}}let u=x(e,n);if(u.length===0)return{output:e,tokens:[]};let f=u.map((I)=>I.token),v="",S=0;for(let I=0;I<u.length;I++){let j=u[I];v+=e.slice(S,j.start),v+=r(j.token,I),S=j.end}if(v+=e.slice(S),a)return Nc(l,{output:v,tokens:f}),{output:v,tokens:f.slice()};return{output:v,tokens:f}}var Lc=1024,zc=16777216,on=new Map,sr=0;function Bc(e,n){on.set(e,n),sr+=e.length+n.output.length;for(let[r,i]of on){if(sr<=zc)break;on.delete(r),sr-=r.length+i.output.length}}function rr(e,n,r){return{output:n,scripts:r,restore:(i)=>i===n?e:Nr(i,r)}}function se(e){let n=e.length>=Lc;if(n){let a=on.get(e);if(a)return on.delete(e),on.set(e,a),rr(e,a.output,a.scripts.slice())}let{output:r,tokens:i}=ke(e,Q,(a,l)=>`\x00STX_SCRIPT_${l}\x00`);if(n)return Bc(e,{output:r,scripts:i}),rr(e,r,i.slice());return rr(e,r,i)}function Nr(e,n){if(n.length===0)return e;return e.replace(/\x00STX_SCRIPT_(\d+)\x00/g,(r,i)=>n[+i]??"")}function ee(e){let n=Oe(e),r=[];for(let i=0;i<n.length;i++){let a=n[i],l=n[i+1];if(a.name.toLowerCase()!=="script"||a.closing||l?.name.toLowerCase()!=="script"||!l.closing)continue;r.push({start:a.start,end:l.end,bodyStart:a.end,bodyEnd:l.start,attrs:a.attributes})}return r}var ls="__stx_component_client_factories";function us(e){let n=e[ls];return n instanceof Map?n:null}function hl(e){e[ls]=new Map}function ir(e,n){let r=us(e);if(!r)return null;let i=Wc("sha256").update(n).digest("hex").slice(0,16),a=r.get(i);if(a)a.instances++;else r.set(i,{body:n,instances:1});return i}function yl(e,n){let r=us(n);if(!r?.size)return e;let i=new Map;for(let[I,j]of r)if(j.instances===1)i.set(I,j.body);let a=[];if(i.size>0){let I=[...i.keys()].map((M)=>JSON.stringify(M).replace(/[$()*+.?[\\\]^{|}]/g,"\\$&")).join("|"),j=new RegExp(`window\\.__stxComponentFactories\\[(${I})\\]\\(("[^"]+")\\);`,"g"),L=j.exec(e);while(L!==null){let M=i.get(JSON.parse(L[1]));if(M!==void 0)a.push({start:L.index,end:L.index+L[0].length,replacement:me(`(${M})(${L[2]});`)});L=j.exec(e)}}let l=[...r].filter(([,I])=>I.instances>1);if(l.length===0)return Ci(e,a);let u=l.map(([I,j])=>` try { factories[${JSON.stringify(I)}] = factories[${JSON.stringify(I)}] || ${j.body}; }
|
|
209
|
+
catch (e) { console.error('[stx] component factory ' + ${JSON.stringify(I)} + ' failed to register; instances of it will not hydrate.', e); }`).join(`
|
|
210
|
+
`),f=`<script data-stx-scoped data-stx-run="always" data-stx-component-factories>
|
|
211
|
+
(function() {
|
|
212
|
+
const factories = window.__stxComponentFactories = window.__stxComponentFactories || {};
|
|
213
|
+
${me(u)}
|
|
214
|
+
})();
|
|
215
|
+
</script>`,v,S=/<(?:template\b|script\b(?=[^>]*\bdata-stx-scoped\b))/iy;return x(e,(I,j)=>{if(v===void 0){if(S.lastIndex=j,S.test(I))v=j}return-1}),a.push({start:v??0,end:v??0,replacement:`${f}
|
|
216
|
+
`}),Ci(e,a)}function Ci(e,n){if(n.length===0)return e;n.sort((l,u)=>l.start-u.start||l.end-u.end);let r=Array(n.length*2+1),i=0,a=0;for(let l of n)r[a++]=e.slice(i,l.start),r[a++]=l.replacement,i=l.end;return r[a]=e.slice(i),r.join("")}function qi(e){let n=us(e),r=new Map;if(n)for(let[i,a]of n)r.set(i,a.instances);return r}function Zi(e,n){let r=us(e);if(!r)return[];let i=[];for(let[a,l]of r){let u=l.instances-(n.get(a)??0);if(u>0)i.push({body:l.body,count:u})}return i}function Ji(e,n){for(let{body:r,count:i}of n)for(let a=0;a<i;a++)ir(e,r)}function Pe(e,n,r=2){let i=0,a=null;for(let l=n+r;l<e.length;l++){let u=e[l];if(a){if(u==="\\"){l++;continue}if(u===a)a=null;continue}if(u==='"'||u==="'"||u==="`"){a=u;continue}if(u==="{"){i++;continue}if(u==="}"){if(i>0){i--;continue}let f=0;while(e[l+f]==="}")f++;if(f>=r)return l}}return-1}import xo from"fs";var Xi=0,or=new Map;function Cl(){Xi=0,or.clear()}function ps(e,n){let r=Xi++,i=`<!--__STX_${e.toUpperCase()}_${r}__-->`;return or.set(i,{type:e,expression:n}),i}function El(){let e={};for(let[n,r]of or)e[n]={type:r.type,expression:r.expression};return e}function Tl(e,n){let r=e;for(let[i,a]of n)r=r.split(i).join(a);return r}function Vi(e){return e.includes("<!--__STX_")}var Fc=/@(?=[a-zA-Z_]\w*\s*\(|end[a-zA-Z]*\b|else(?:if)?\b|empty\b|case\b|default\b|break\b|continue\b|fallback\b)/g;function Vc(e){return Array.from({length:e},()=>"{").join("⁠")}function Gi(e){return e.replace(/\{{2,}/g,(n)=>Vc(n.length)).replace(/\{(?=!)/g,"{⁠").replace(Fc,"@")}function Dr(e,n,r=!1){let{openTag:i,tail:a}=r?Uc(e,n):Hc(e).at(n);return qc(a,i,r)}function Uc(e,n){let r="",i=0;for(let u=0;u<n;u++){if(!e.startsWith("{{",u))continue;let f=Pe(e,u);if(f<0||f+2>n)break;r+=e.slice(i,u)+"x",u=f+1,i=f+2}r+=e.slice(i,n);let a=-1,l=null;for(let u=0;u<r.length;u++){let f=r[u];if(l){if(f===l)l=null;continue}if(f==='"'||f==="'"){l=f;continue}if(f===">"){a=-1;continue}if(f==="<")a=u}return{openTag:a,tail:a>=0?r.slice(a+1):r}}var fs=null;function Hc(e){if(fs&&fs.source===e)return fs.scanner;let n=Kc(e);return fs={source:e,scanner:n},n}function Kc(e){let n=0,r=-1,i=null,a=-1,l=(f,v)=>{let S=e[f];if(v.quote){if(S===v.quote)v.quote=null;return}if(v.openTag>=0){if(S==='"'||S==="'"){v.quote=S;return}if(S===">"){v.openTag=-1;return}}if(S==="<")v.openTag=f},u=(f,v)=>{if(v.openTag>=0||!e.startsWith("<!--",f))return-1;let S=e.indexOf("-->",f+4);return S<0?e.length:S+3};return{at(f){if(f<n)n=0,r=-1,i=null,a=-1;let v={openTag:r,quote:i},S=!1;while(n<f){if(a<0&&e.startsWith("{{",n)){let W=Pe(e,n);if(W<0)a=n;else if(W+2<=f){n=W+2;continue}else break}let V=u(n,v);if(V>=0){if(V>f){S=!0;break}n=V;continue}l(n,v),n++}if(r=v.openTag,i=v.quote,S)return{openTag:-1,tail:""};let I=a>=0?a:n,j={openTag:r,quote:i};for(let V=n;V<f;V++){let W=u(V,j);if(W>=0){if(W>f)return{openTag:-1,tail:""};V=W-1;continue}l(V,j)}if(j.openTag<0)return{openTag:-1,tail:""};let L="",M=j.openTag+1;for(let V=M;V<Math.min(f,I);V++){if(!e.startsWith("{{",V))continue;let W=Pe(e,V);L+=e.slice(M,V)+"x",V=W+1,M=W+2}return L+=e.slice(M,f),{openTag:j.openTag,tail:L}}}}function qc(e,n,r){if(n<0&&!r)return null;if(n>=0&&/^\s*[!/?]/.test(e))return/^\s*\/?\s*$/.test(e)?{kind:"tag-name"}:null;if(n>=0&&/^\s*$/.test(e))return{kind:"tag-name"};let i=0;if(n>=0)while(i<e.length&&!/\s/.test(e[i]))i++;while(i<e.length){while(/\s/.test(e[i]??"")&&i<e.length)i++;let a=i;while(i<e.length&&!/[\s=/>]/.test(e[i]))i++;let l=e.slice(a,i);if(!l)break;while(i<e.length&&/\s/.test(e[i]))i++;if(e[i]!=="=")continue;i++;while(i<e.length&&/\s/.test(e[i]))i++;let u=e[i];if(u==='"'||u==="'"){let f=++i,v=e.indexOf(u,i);if(v===-1)return{kind:"attribute",name:l,quote:u,valuePrefix:e.slice(f)};i=v+1}else{let f=i;while(i<e.length&&!/\s/.test(e[i]))i++;if(i===e.length)return{kind:"attribute",name:l,quote:null,valuePrefix:e.slice(f)}}}return{kind:"tag"}}class he extends Error{attribute;near;constructor(e,n){super(`Unsafe interpolation in ${e}: ${n}`);this.name="UnsafeInterpolationContextError",this.attribute=e}locate(e,n){if(this.near===void 0)this.near=e.slice(Math.max(0,n-160),n).replace(/\s+/g," ").trim(),this.message+=` (after: ${JSON.stringify(this.near)})`;return this}}var Yi="unsafe:";var Zc=/^(?:javascript|vbscript|livescript|mocha|view-source):/,Jc=/^data:(?:text\/html|text\/xml|application\/xhtml\+xml|application\/xml|image\/svg\+xml)/,Xc=/^data:(?:text\/html|application\/xhtml\+xml)/,Gc=new RegExp("[\\u0000-\\u0020\\u00A0\\u1680\\u2000-\\u200F\\u2028\\u2029\\u202F\\u205F\\u3000\\uFEFF]+","g");function Yc(e){return e.replace(Gc,"").toLowerCase()}function ar(e){let n=e.toLowerCase();if(new RegExp("^(?:href|xlink:href|action|formaction|ping|cite|manifest|data|to)$").test(n))return"navigable";if(new RegExp("^(?:src|srcset|poster|background)$").test(n))return"fetched";return null}function ds(e,n="navigable"){let r=Yc(e);if(Zc.test(r))return!0;return n==="navigable"?Jc.test(r):Xc.test(r)}function Mr(e,n="navigable"){return ds(e,n)?"unsafe:"+e:e}function Qc(e){let n=e.match(/(?:^|[\s"'`/])([A-Za-z][\w:-]*)\s*=\s*(["'])([^"']*)$/);if(!n)return null;if(n[3].trim()!=="")return null;return ar(n[1])}function Qi(e,n,r=256){if(n<=r)return e.slice(0,n);let i=e.slice(n-r,n),a=i.search(/[\s"'`/]/);return a===-1?"":i.slice(a)}function fo(e,n,r=n){let i=Qc(e);return i&&ds(n,i)?"unsafe:"+r:r}function Wt(e){let n=e.indexOf(" as ");if(n!==-1){let l=e.slice(0,n).trim(),u=e.slice(n+4).trim();return l&&u?{arrayExpr:l,itemVar:u}:null}let r=/^\s*(.+?)\s+in\s+([\s\S]+)$/.exec(e);if(!r)return null;let i=r[1].trim().replace(/^\(([\s\S]*)\)$/,"$1").trim(),a=r[2].trim();return i&&a?{arrayExpr:a,itemVar:i}:null}function gs(e){let n=[],r=0,i="",a=0;for(let l=0;l<e.length;l++){let u=e[l];if(i){if(u==="\\")l++;else if(u===i)i="";continue}if(u==="'"||u==='"'||u==="`")i=u;else if(u==="("||u==="["||u==="{")r++;else if(u===")"||u==="]"||u==="}")r--;else if(u===","&&r===0)n.push(e.slice(a,l)),a=l+1}return n.push(e.slice(a)),n}function go(e,n){let r=0;for(let i=0;i<e.length;i++){let a=e[i];if(a==="("||a==="["||a==="{")r++;else if(a===")"||a==="]"||a==="}")r--;else if(a===n&&r===0)return i}return-1}function mo(e){let n=0;for(let r=0;r<e.length;r++){let i=e[r];if(i==="("||i==="["||i==="{")n++;else if((i===")"||i==="]"||i==="}")&&--n===0)return r}return-1}function Ft(e,n){let r=e.trim().replace(/^\.\.\./,"").trim(),i=go(r,"=");if(i!==-1&&r[i+1]!==">")r=r.slice(0,i).trim();if(!r)return;if(r.startsWith("{")&&r.endsWith("}")){for(let a of gs(r.slice(1,-1))){let l=a.trim();if(!l)continue;if(l.startsWith("...")){Ft(l,n);continue}let u=go(l,":");Ft(u===-1?l:l.slice(u+1),n)}return}if(r.startsWith("[")&&r.endsWith("]")){for(let a of gs(r.slice(1,-1)))Ft(a,n);return}if(/^[A-Z_$][\w$]*$/i.test(r))n.push(r)}function oe(e){let n=e.trim(),r=[],i=0;for(let l=0;l<n.length;l++){let u=n[l];if(u==="("||u==="["||u==="{")i++;else if(u===")"||u==="]"||u==="}")i--;else if(i===0&&/\s/.test(u)){if(!/^\s+(?:in|of)\s/.exec(n.slice(l)))continue;let v=n.slice(0,l).trim();if(v.startsWith("(")&&mo(v)===v.length-1)v=v.slice(1,-1);for(let S of gs(v))Ft(S,r);if(r.length>0)return r;break}}let a=/^[\s\S]+?\s+as\s+([\s\S]+)$/.exec(n);if(a){let l=a[1].trim();if(l.startsWith("(")&&mo(l)===l.length-1)l=l.slice(1,-1);let u=/^([\w$]+)\s*=>\s*([\s\S]+)$/.exec(l);if(u)Ft(u[2],r),Ft(u[1],r);else for(let f of gs(l))Ft(f,r)}return r}function F(e,n){let r=n instanceof Set?n:new Set(n);if(r.size===0)return!1;let u=e.replace(/'(?:[^'\\]|\\.)*'|"(?:[^"\\]|\\.)*"/g," ").replace(/`(?:[^`\\$]|\\.|\$(?!\{))*`/g," ").replace(/\??\.\s*[a-zA-Z_$][\w$]*/g," ").replace(/([{,]\s*)[a-zA-Z_$][\w$]*(\s*:(?!:))/g,"$1$2");for(let f of u.match(/[a-zA-Z_$][\w$]*/g)||[])if(r.has(f))return!0;return!1}var ms="__stx_client_loop_names";function mt(e){let n=e?.[ms];return Array.isArray(n)?n:[]}function hs(e){if(!e.includes("#")&&!e.includes("v-slot:")&&!e.includes("data-stx-slot-binding"))return[];let n=[],r=[],i=/<!--[\s\S]*?-->|<script\b(?:"[^"]*"|'[^']*'|[^'">])*>[\s\S]*?<\/script\s*>|<style\b(?:"[^"]*"|'[^']*'|[^'">])*>[\s\S]*?<\/style\s*>|<\/?[a-z][\w:-]*\b(?:"[^"]*"|'[^']*'|[^'">])*>/gi;for(let a of e.matchAll(i)){let l=a[0];if(/^<\/template\s*>$/i.test(l)){let u=r.pop();if(u)u.end=a.index}else if(/^<template\b/i.test(l)&&!/\/\s*>$/.test(l)){let f=[...l.slice(9).matchAll(/([^\s=/>]+)(?:\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s>]+)))?/g)].find((I)=>/^(?:#[\w-]+|v-slot:[\w-]+|data-stx-slot-binding)$/i.test(I[1])),v=(f?.[2]??f?.[3])?.trim();if(v&&f?.[1]==="data-stx-slot-binding")try{v=decodeURIComponent(v)}catch{v=void 0}let S=v?{start:a.index+l.length,end:e.length,binding:v}:void 0;if(r.push(S),S)n.push(S)}}return n}var vn={},_o=new Map;function el(e){let n=_o.get(e);if(!n){let r=e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");n=new RegExp(`:${r}(?!\\w)`,"g"),_o.set(e,n)}return n.lastIndex=0,n}var lo={uppercase:(e,n)=>e!==void 0&&e!==null?String(e).toUpperCase():"",lowercase:(e,n)=>e!==void 0&&e!==null?String(e).toLowerCase():"",capitalize:(e,n)=>{if(e===void 0||e===null)return"";let r=String(e);return r.charAt(0).toUpperCase()+r.slice(1)},number:(e,n,r=0)=>{if(e===void 0||e===null)return"";try{let i=Number(e);return Number.isNaN(i)?"":i.toFixed(Number.parseInt(String(r),10))}catch{return""}},fmt:(e,n,r="en-US")=>{if(e===void 0||e===null)return"";try{let i=Number(e);if(Number.isNaN(i))return String(e);return i.toLocaleString(r)}catch{return String(e)}},join:(e,n,r=",")=>{if(!Array.isArray(e))return"";return e.join(String(r))},escape:(e,n)=>{if(e===void 0||e===null)return"";return Y(String(e))},translate:(e,n,r={})=>{if(!n||!n.__translations)return e;let i=n.__translations,a=n.__i18nConfig?.fallbackToKey??!0,l=String(e).split("."),u=i;for(let v of l){if(u===void 0||u===null)break;u=u[v]}if(u===void 0||u===null)return a?e:"";let f=String(u);return Object.entries(r).forEach(([v,S])=>{f=f.replace(el(v),()=>String(S))}),f},t:(e,n,r={})=>lo.translate(e,n,r),truncate:(e,n,r=50,i="...")=>{if(e===void 0||e===null)return"";let a=String(e);if(a.length<=r)return a;if(r<=i.length)return i.substring(0,r);return a.substring(0,r-i.length)+i},date:(e,n,r="short",i="en-US")=>{if(e===void 0||e===null)return"";try{let a=e instanceof Date?e:new Date(e);if(Number.isNaN(a.getTime()))return String(e);let l={short:{dateStyle:"short"},medium:{dateStyle:"medium"},long:{dateStyle:"long"},full:{dateStyle:"full"},time:{timeStyle:"short"},datetime:{dateStyle:"short",timeStyle:"short"},iso:{}};if(r==="iso")return a.toISOString();return new Intl.DateTimeFormat(i,l[r]||l.short).format(a)}catch{return String(e)}},currency:(e,n,r="USD",i="en-US")=>{if(e===void 0||e===null)return"";try{let a=Number(e);if(Number.isNaN(a))return String(e);return new Intl.NumberFormat(i,{style:"currency",currency:r}).format(a)}catch{return String(e)}},pluralize:(e,n,r,i)=>{let a=Number(e);if(Number.isNaN(a))return r;let l=i||`${r}s`;return a===1?r:l},first:(e,n)=>{if(e===void 0||e===null)return"";if(Array.isArray(e))return e.length===0?"":e[0];return String(e).charAt(0)},last:(e,n)=>{if(e===void 0||e===null)return"";if(Array.isArray(e))return e.length===0?"":e[e.length-1];let r=String(e);return r.charAt(r.length-1)},length:(e,n)=>{if(e===void 0||e===null)return 0;if(Array.isArray(e)||typeof e==="string")return e.length;if(e instanceof Map||e instanceof Set)return e.size;if(typeof e==="object")return Object.keys(e).length;return 0},json:(e,n,r=!1)=>{if(e===void 0)return"undefined";if(e===null)return"null";try{return r?JSON.stringify(e,null,2):JSON.stringify(e)}catch{return String(e)}},default:(e,n,r="")=>e===void 0||e===null||e===""?r:e,reverse:(e,n)=>{if(e===void 0||e===null)return"";if(Array.isArray(e))return[...e].reverse();return String(e).split("").reverse().join("")},slice:(e,n,r=0,i)=>{if(e===void 0||e===null)return"";if(Array.isArray(e)||typeof e==="string")return e.slice(r,i);return e},replace:(e,n,r,i="")=>{if(e===void 0||e===null)return"";let a=r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return String(e).replace(new RegExp(a,"g"),()=>i)},stripTags:(e,n)=>{if(e===void 0||e===null)return"";return String(e).replace(/<[^>]*>/g,"")},urlencode:(e,n)=>{if(e===void 0||e===null)return"";return encodeURIComponent(String(e))},abs:(e,n)=>{let r=Number(e);return Number.isNaN(r)?0:Math.abs(r)},round:(e,n,r=0)=>{let i=Number(e);if(Number.isNaN(i))return 0;let a=10**r;return Math.round(i*a)/a}};function qg(e,n){if(e in lo)console.warn(`Filter "${e}" already exists as a built-in filter. Custom filter will take precedence.`);vn[e]=n}function Ry(e){for(let[n,r]of Object.entries(e))qg(n,r)}function Kg(){return{...lo,...vn}}function Ay(){for(let e of Object.keys(vn))delete vn[e]}function ko(e){let n=e.next();while(!n.done)n=e.next();return n.value}function*Co(e,n,r,i){let a="{".repeat(r);if(!e.includes(a))return e;let l="",u=0,f=0,v=i===Number.POSITIVE_INFINITY?0:performance.now();for(;;){let S=e.indexOf(a,u);if(S===-1)break;let I=Pe(e,S,r);if(I===-1)break;if(l+=e.slice(u,S)+n(e.slice(S,I+r),e.slice(S+r,I),S),u=I+r,++f>=64){f=0;let j=performance.now();if(j-v>=i)v=j,yield}}return u===0?e:l+e.slice(u)}function In(e,n,r=2){return ko(Co(e,n,r,Number.POSITIVE_INFINITY))}function $l(e,n,r){let i=r[0];if(i!=="'"&&i!=='"'&&i!=="`")return!1;let a=Dr(e,n);if(!a||a.kind!=="attribute"||a.quote===i)return!1;if(!/^(?::|@|x-|v-)/.test(a.name))return!1;let l=0;for(let u=0;u<a.valuePrefix.length;u++)if(a.valuePrefix[u]==="\\")u++;else if(a.valuePrefix[u]===i)l++;return l%2===1}function g(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function Y(e){return Gi(g(e))}function Rl(e){return e.replace(/ /g," ").replace(/\t/g,"	").replace(/\n/g," ").replace(/\r/g," ").replace(/\f/g,"").replace(/=/g,"=").replace(/`/g,"`")}function Al(e){return e.replace(/\/\*[\s\S]*?\*\//g,"").replace(/\\([\dA-Fa-f]{1,6})\s?/g,(n,r)=>String.fromCodePoint(Number.parseInt(r,16))).replace(/\\([^\r\n])/g,"$1").replace(/[\u0000-\u0020]+/g,"").toLowerCase()}function Il(e,n){let r=Al(e);if(/@import|expression\(|behavior:|-moz-binding|(?:image-set|cross-fade)\(/.test(r))throw new he(n,"network-capable or executable CSS is not allowed in an escaped interpolation");let i=/url\(([^)]*)\)/g,a;while((a=i.exec(r))!==null){let l=a[1].replace(/^["']|["']$/g,""),u=l.startsWith("/")&&!l.startsWith("//")||l.startsWith("./")||l.startsWith("../")||l.startsWith("#"),f=/^data:image\/(?:avif|bmp|gif|jpeg|jpg|png|webp);base64,[a-z\d+/=]+$/i.test(l);if(!u&&!f)throw new he(n,"CSS URLs must be local paths or base64 raster images")}}function ae(e,n,r,i=!1,a=0){try{return Ol(e,n,r,i,a)}catch(l){if(l instanceof he)l.locate(e,n);throw l}}function Ol(e,n,r,i,a){let l=Dr(e,n,i),u=Y(r);if(!l)return u;if(l.kind==="tag-name"){if(!/^[A-Za-z][A-Za-z0-9:-]*$/.test(r))throw new he("tag name","dynamic tag names may contain only letters, digits, colons, and hyphens");return r}if(l.kind==="tag"){let S=e.slice(n+a).trimStart(),I=r.trim();if(!S.startsWith("=")&&(I===""||I.split(/\s+/).every((j)=>/^(?!on)[A-Za-z_:][\w:.-]*$/.test(j))))return I;throw new he("tag structure","only standalone boolean attributes may be interpolated into tag structure")}let f=l.name.toLowerCase();if(/^on[a-z]/.test(f))throw new he(l.name,"native event-handler attributes execute JavaScript; use an @event binding instead");if(f==="srcdoc")u=Y(u);if(f==="style")Il(r,l.name);if(l.quote===null)u=Rl(u);let v=ar(f);if(v&&l.valuePrefix.trim()===""&&ds(r,v))return Yi+u;return fo(Qi(e,n),r,u)}function On(e,n){let r=` ${e}="`;return ae(r,r.length,n,!0)}function Ro(e){return e.flatMap((n)=>{let r=n.match(/^<script\b([^>]*)>([\s\S]*?)<\/script\s*>$/i);return!r||/\bserver\b|\bsrc\s*=/.test(r[1])?[]:[r[2]]})}function Ne(e,n){let{scripts:r}=se(e);for(let i of Ro(r)){if(/\b(state|derived|effect|ref|reactive|computed|watch|watchEffect|useModel)\s*(?:<[^>]*>)?\s*\(/.test(i)||kl.test(i))return!0;if(Jr(i,n))return!0}if(/@(if|for|show)\s*=\s*["'][^"']*\(\s*\)/.test(e))return!0;if(/@for\s*=\s*["'][^"']*\s+(?:in|of)\s+[^"']*\(\s*\)/.test(e))return!0;if(/(?:^|[\s"'])(?::|x-)(?:for|if|else-if|else|show|text|html|model|bind)\b/.test(e))return!0;return!1}function Gg(e){let n=[],r=/<([a-zA-Z][\w-]*)\b[^>]*?\s(?::for|x-for|@for)\s*=\s*(["'])([\s\S]*?)\2[^>]*>/g;for(let i=r.exec(e);i;i=r.exec(e)){let a=i[1].toLowerCase(),l=new Set(oe(i[3]));if(l.size===0)continue;let u=i.index+i[0].length;if(i[0].endsWith("/>")){n.push({start:i.index,end:u,names:l});continue}let f=new RegExp(`<(/?)${a}\\b[^>]*?(/?)>`,"gi");f.lastIndex=u;let v=1,S=e.length;for(let I=f.exec(e);I;I=f.exec(e)){if(I[2]==="/")continue;if(v+=I[1]==="/"?-1:1,v===0){S=I.index+I[0].length;break}}n.push({start:i.index,end:S,names:l})}return n}function wo(e,n,r){let i=t(r);for(let a of e){if(n<a.start||n>=a.end)continue;for(let l of a.names)if(new RegExp(`(?<![.#\\w$])${l.replace(/\$/g,"\\$")}(?![\\w$])`).test(i))return!0}return!1}function vo(e,n){let r=["parseInt","parseFloat","String","Number","Boolean","Array","Object","JSON","Math","Date","URL","URLSearchParams","Intl","encodeURIComponent","decodeURIComponent","encodeURI","decodeURI","true","false","null","undefined","NaN","Infinity","isNaN","isFinite","window","document","console","new","typeof","instanceof","in","void"],i=e.replace(/'[^']*'/g,"").replace(/"[^"]*"/g,""),a="",l=!1,u=0;for(let S=0;S<i.length;S++){let I=i[S];if(!l&&I==="`"){l=!0,u=0;continue}if(l){if(I==="`"&&u===0){l=!1;continue}if(I==="$"&&i[S+1]==="{"){u++,S++,a+=" ";continue}if(I==="}"&&u>0){u--;continue}if(u>0){a+=I;continue}continue}a+=I}i=a;let f=/(?<![a-zA-Z0-9_$])([a-zA-Z_$][a-zA-Z0-9_$]*)/g,v;while((v=f.exec(i))!==null){let S=v[1];if(!i.substring(0,v.index).trimEnd().endsWith(".")){if(!r.includes(S)&&!(S in n))return!1}}return!0}function jl(e,n){let r=t(e);for(let i of r.matchAll(/(?<![.\w$])([A-Z_$][\w$]*)\s*\(/gi))if(typeof n[i[1]]==="function")return!0;return!1}function Pl(e,n){let r=n.__stx_serverDeclared;if(!r||r.size===0)return!1;let i=t(e);for(let a of r)if(new RegExp(`(?<![.#\\w$])${a}(?![\\w$])`).test(i))return!0;return!1}var So=new Set;function $o(e){return/^[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*)*$/.test(e.trim())}function Ml(e,n,r){let i=r[0];if(i!=="'"&&i!=='"'&&i!=="`")return!1;let a=0;for(let l=e.lastIndexOf(`
|
|
217
|
+
`,n-1)+1;l<n;l++)if(e[l]==="\\")l++;else if(e[l]===i)a++;return a%2===1}function Eo(e,n){let r=`${n??"<unknown>"}\x00${e}`;if(process.env.STX_DEBUG||!So.has(r))So.add(r),console.warn(`[stx] {{ ${e} }} in a <script> in ${n??"<unknown>"} has no server value, so it was emitted as undefined. A mustache left in JavaScript is a SyntaxError that takes the whole script down, so give the value a default in <script server>.`);return"undefined"}function Ui(e,n,r){let i=e;return i=i.replace(/\{!!([\s\S]*?)!!\}/g,(a,l)=>{try{let u=N(l,n);if(u===void 0)return $o(l)?Eo(l.trim(),r):a;return u===null?"":String(u)}catch{return a}}),i=In(i,(a,l,u)=>{let f=l.trim();if(Ml(i,u,l))return a;if(/^__[A-Z_]+__$/.test(f))return a;try{let v=N(l,n);if(v===void 0)return $o(f)?Eo(f,r):a;return JSON.stringify(v).replace(/</g,"\\u003c").replace(/@/g,"\\u0040").replace(/\{{2,}/g,(S)=>"\\u007b".repeat(S.length)).replace(/\{(?=!)/g,"\\u007b")}catch{return a}}),i}function Xg(e,n){if(!e.includes("{"))return e;let r=e;return r=r.replace(/\{!!([\s\S]*?)!!\}/g,(i,a)=>{try{let l=N(a,n);if(l===void 0)return i;return l===null?"":String(l)}catch{return i}}),r=In(r,(i,a,l)=>{let u=a.trim();if(/^__[A-Z_]+__$/.test(u))return i;try{let f=N(a,n);if(f===void 0)return i;if(f===null)return"";let v=String(f);return ae(r,l,v,!0,i.length)}catch(f){if(f instanceof he)throw f;return i}}),r}function Py(e,n,r={}){let{output:i,scripts:a}=se(e),l=a.map((u)=>{let f=u.match(/^<script\b((?:[^>\"']|\"[^\"]*\"|'[^']*')*)>/i),v=u.search(/<\/script\s*>$/i);if(!f||v===-1)return u;let S=f[1],I=u.slice(f[0].length,v);if(/\bdata-raw\b/.test(S))return u;if(r.skipServer&&/\bserver\b/.test(S))return u;let L=`<script${Xg(S,n)}>`;if(/\bsrc\s*=/.test(S)||/\btype\s*=\s*["']application\/json["']/.test(S))return L+I+u.slice(v);return L+Ui(I,n)+u.slice(v)});return Nr(i,l)}function*To(e,n,r,i){let a=e,l=(W,Z)=>{let q=Cn(W,Z);if(q===-1)return-1;return/\{\{[\s\S]*?\}\}|\{!![\s\S]*?!!\}/.test(W.slice(Z,q))?-1:q},u=(W,Z,q,G)=>{let U=q.length,{output:H,tokens:re}=ke(W,Z,(ce,le)=>G(U+le));return q.push(...re),H},f=[];a=u(a,l,f,(W)=>`<!--__STX_STYLE_${W}__-->`);let v=[];a=u(a,Q,v,(W)=>`<!--__STX_SCRIPT_EXPR_${W}__-->`);let S=n?.__stx_signals_gate===!0||Ne(e),I=new Set([...Array.isArray(n?.__stx_client_signal_names)?n.__stx_client_signal_names:[],...Hi(Ro(v))]),j=new Set(Array.isArray(n?.__stx_preserved_client_expressions)?n.__stx_preserved_client_expressions:[]);a=In(a,(W,Z,q)=>{if(F(Z,I))return W;try{let G=N(Z,n,!1,(U)=>cr(U,W,r,e));return G!==void 0&&G!==null?String(G):""}catch(G){let U=G instanceof Error?G.message:String(G);return b("Expression",`Error evaluating: {{{ ${Z.trim()}}}}: ${U}`,r,e,q,W)}},3),a=a.replace(/\{!!([\s\S]*?)!!\}/g,(W,Z,q)=>{if(F(Z,I))return W;try{let G=N(Z,n,!1,(U)=>cr(U,W,r,e));if(G===void 0&&n.__stx_buildMode==="compile")return ps("raw",Z.trim());return G!==void 0&&G!==null?String(G):""}catch(G){if(n.__stx_buildMode==="compile")return ps("raw",Z.trim());let U=G instanceof Error?G.message:String(G);return b("Expression",`Error evaluating: {!! ${Z.trim()} !!}: ${U}`,r,e,q,W)}}),a=u(a,Q,v,(W)=>`<!--__STX_SCRIPT_EXPR_${W}__-->`),a=u(a,l,f,(W)=>`<!--__STX_STYLE_${W}__-->`);let L=S?Gg(a):[],M=hs(a).map((W)=>({...W,names:new Set(oe(`${W.binding} in __slot`))})),V=new Set(mt(n));if(a=yield*Co(a,(W,Z,q)=>{let G=Z.trim();if($l(a,q,Z))return W;if(wo(M,q,G))return W;if(F(G,V))return W;if(L.length>0&&wo(L,q,G))return W;if(j.has(G))return W;let U=["parseInt","parseFloat","String","Number","Boolean","Array","Object","JSON","Math","Date","encodeURIComponent","decodeURIComponent","encodeURI","decodeURI","true","false","null","undefined"],H=/^([a-zA-Z_$][a-zA-Z0-9_$]*)/,ce=G.match(H)?.[1],le=ce&&((ce in n)||U.includes(ce)),fe=/^([a-zA-Z_$][a-zA-Z0-9_$]*)\s*\(/,we=G.match(fe),Ee=we&&!U.includes(we[1])&&!(we[1]in n);if(/^__[A-Z_]+__$/.test(G))return"";if(F(G,I))return W;if(n.__stx_native_screen===!0&&jl(G,n))return W;let Re;try{let ve=N(Z,n,!1,(Be)=>{Re=Be});if(S&&!vo(G,n))return W;if(Re)cr(Re,W,r,e);if(n.__stx_buildMode==="compile"&&!S&&(ve===void 0||Pl(G,n)))return ps("expr",G);if(ve===void 0||ve===null)return"";let Qe=String(ve);return ae(a,q,Qe,!1,W.length)}catch(ve){if(ve instanceof he)throw ve;if(S&&!vo(G,n))return W;if(Ee)return W;let Qe=ve instanceof Error?ve.message:String(ve);return b("Expression",`Error evaluating: {{ ${G} }}: ${Qe}`,r,e,q,W)}},2,i),v.length>0)a=a.replace(/<!--__STX_SCRIPT_EXPR_(\d+)__-->/g,(W,Z)=>v[Number(Z)]??W);if(f.length>0)a=a.replace(/<!--__STX_STYLE_(\d+)__-->/g,(W,Z)=>f[Number(Z)]??W);return a}function P(e,n,r){return ko(To(e,n,r,Number.POSITIVE_INFINITY))}var Nl=100;async function Wi(e,n,r,i=Nl){let a=To(e,n,r,i),l=a.next();while(!l.done)await R(),l=a.next();return l.value}function Jg(e,n,r){if(!n.trim())return e;let i=e,a=n.trim();while(a.length>0){let l=a.match(/^(\w+)/);if(!l)break;let u=l[1];a=a.substring(u.length).trim();let f=vn[u]||lo[u];if(!f)throw Error(`Filter not found: ${u}. Available filters: ${Object.keys(Kg()).join(", ")}`);let v=[];if(a.startsWith(":")){let S=a.match(/^:([^|\s]+)/);if(S){let I=S[1].trim();try{let j=Number(I);v=[Number.isNaN(j)?I:j]}catch{v=[I]}a=a.substring(S[0].length).trim()}}else if(a.startsWith("(")){let S=1,I=1;while(S>0&&I<a.length){if(a[I]==="(")S++;if(a[I]===")")S--;I++}if(S===0){let j=a.substring(1,I-1).trim();if(j)try{if(j.startsWith("{")&&j.endsWith("}"))v=[N(`(${j})`,r,!0)];else{let L=[],M="",V=null,W=0,Z=0,q=0,G=!1;for(let U=0;U<j.length;U++){let H=j[U];if(G){M+=H,G=!1;continue}if(H==="\\"){M+=H,G=!0;continue}if(V){if(M+=H,H===V)V=null;continue}if(H==='"'||H==="'"||H==="`"){V=H,M+=H;continue}if(H==="(")W++;else if(H===")")W--;else if(H==="[")Z++;else if(H==="]")Z--;else if(H==="{")q++;else if(H==="}")q--;if(H===","&&W===0&&Z===0&&q===0){L.push(M),M="";continue}M+=H}if(M)L.push(M);v=L.map((U)=>{let H=U.trim();return N(H,r,!0)})}}catch{v=[j]}a=a.substring(I).trim()}}try{i=f(i,r,...v)}catch(S){let I=S instanceof Error?S.message:String(S);throw Error(`Error applying filter '${u}': ${I}`)}if(a.startsWith("|"))a=a.substring(1).trim();else break}return i}function Ll(e){let n=!1,r="",i=0,a=0,l=0,u=!1;for(let f=0;f<e.length;f++){let v=e[f],S=e[f+1];if(n&&u){u=!1;continue}if(n&&v==="\\"){u=!0;continue}if(u=!1,(v==='"'||v==="'"||v==="`")&&!u){if(!n)n=!0,r=v;else if(v===r)n=!1,r="";continue}if(n&&r==="`"&&v==="$"&&S==="{"){let I=1;f+=2;while(f<e.length&&I>0){if(e[f]==="{")I++;else if(e[f]==="}")I--;if(I>0)f++}continue}if(n)continue;if(v==="(")i++;else if(v===")")i--;else if(v==="[")a++;else if(v==="]")a--;else if(v==="{")l++;else if(v==="}")l--;if(v==="|"&&i===0&&a===0&&l===0){if(S==="|"){f++;continue}if(S==="="){f++;continue}return f}}return-1}var wn=new Set,zl=1000;function Iy(){wn.clear()}function cr(e,n,r,i){if(!ne())return;let a=`${r}\x00${e.expression}`;if(wn.has(a))return;if(wn.size>=zl)wn.clear();wn.add(a);let l=r,u=i;try{if(r&&xo.existsSync(r))u=xo.readFileSync(r,"utf8")}catch{}let f=u.indexOf(n);if(f>=0)l=`${r}:${u.slice(0,f).split(`
|
|
218
|
+
`).length}`;console.warn(`${l}: stx warning: ${n} rendered as an empty string. The safe evaluator rejected \`${e.expression}\` (${e.rule}). Compute the value in <script server> and interpolate the variable instead.`)}function N(e,n,r=!1,i){try{let a=e.trim(),l=Ll(a);if(l>0){let f=a.substring(0,l).trim(),v=a.substring(l+1).trim(),S=N(f,n,!0,i);return Jg(S,v,n)}let u=po(a);if(u!==null){i?.({expression:a,rule:u});return}try{let f=Object.keys(n),v=Object.values(n);return p(a,f)(...v)}catch{return d(a,n)}}catch(a){if(a instanceof ReferenceError){let l=/(\b\w+)\s+is not defined/.exec(a.message);if(l){let u=l[1],f=Wl(u,Object.keys(n));if(f&&f!==u)a.message=`${a.message} \u2014 did you mean '${f}'?`}}if(!r)console.error(`Error evaluating expression: ${e}`,a);throw a}}function Wl(e,n){let r=null;for(let a of n){if(a===e)continue;let l=Vl(e,a);if(r===null||l<r.dist)r={key:a,dist:l}}if(!r)return null;let i=Math.max(e.length,r.key.length);if(r.dist<=2||r.dist/i<=0.35)return r.key;return null}function Vl(e,n){if(e===n)return 0;if(e.length===0)return n.length;if(n.length===0)return e.length;let[r,i]=e.length<n.length?[e,n]:[n,e],a=Array(r.length+1),l=Array(r.length+1);for(let u=0;u<=r.length;u++)a[u]=u;for(let u=1;u<=i.length;u++){l[0]=u;for(let f=1;f<=r.length;f++){let v=r[f-1]===i[u-1]?0:1;l[f]=Math.min(l[f-1]+1,a[f]+1,a[f-1]+v)}for(let f=0;f<=r.length;f++)a[f]=l[f]}return a[r.length]}function Oy(e){if(!e)return"";return e.replace(/</g,"<").replace(/>/g,">").replace(/"/g,'"').replace(/'/g,"'").replace(/'/g,"'").replace(/&/g,"&")}import Ul from"process";function A(e="STX_PUBLIC_"){let n={},r={};for(let[i,a]of Object.entries(Ul.env)){if(!i.startsWith(e)||a===void 0)continue;n[`import.meta.env.${i}`]=JSON.stringify(a),r[i]=a}return n["import.meta.env"]=JSON.stringify(r),n}function Ao(e,n=""){let r=`${e}${n}`,i=0;for(let a=0;a<r.length;a++){let l=r.charCodeAt(a);i=(i<<5)-i+l,i=i&i}return`stx-${Math.abs(i).toString(36)}`}function Io(e,n,r={}){let{prefix:i="",preserveHost:a=!0,scopeKeyframes:l=!0,scopeCustomProperties:u=!1}=r;if(!e.trim())return"";let f=lr(e),v=[],S=new Map;if(l)for(let I of f){let j=I.selector.match(/@keyframes\s+([a-z_-][a-z0-9_-]*)/i);if(j){let L=j[1],M=`${n}_${L}`;S.set(L,M)}}for(let I of f){let j=Oo(I,n,i,a,S,u);v.push(j)}return v.join(`
|
|
219
|
+
|
|
220
|
+
`)}function lr(e){let n=[],r=e.replace(/\/\*[\s\S]*?\*\//g,""),i=0,a="",l=!1,u="";for(let f=0;f<r.length;f++){let v=r[f];if(v==="@"&&i===0)l=!0;if(v==="{")i++;else if(v==="}"){if(i--,i===0){if(l){u+=v;let S=u.match(/@([a-z-]+)\s*([^{]*)\{([\s\S]*)\}/i);if(S){let[,I,j,L]=S;if(I==="keyframes")n.push({selector:`@keyframes ${j.trim()}`,declarations:L.trim()});else if(I==="media"||I==="supports"||I==="container"){let M=lr(L);n.push({selector:`@${I} ${j.trim()}`,declarations:M.map((V)=>`${V.selector} { ${V.declarations} }`).join(`
|
|
221
|
+
`)})}else n.push({selector:`@${I} ${j.trim()}`,declarations:L.trim()})}u="",l=!1}else if(a.trim()){a+=v;let S=a.match(/([^{]+)\{([^}]*)\}/);if(S)n.push({selector:S[1].trim(),declarations:S[2].trim()});a=""}continue}}if(l)u+=v;else a+=v}return n}function Oo(e,n,r,i,a,l){let{selector:u,declarations:f}=e;if(u.startsWith("@")){if(u.startsWith("@keyframes")){let I=u.replace("@keyframes ","").trim();return`@keyframes ${a.get(I)||I} { ${f} }`}if(u.startsWith("@media")||u.startsWith("@supports")||u.startsWith("@container")){let j=lr(`x { ${f} }`.replace(/x \{ /,"").replace(/ \}$/,"")).map((L)=>Oo(L,n,r,i,a,l)).join(`
|
|
222
|
+
`);return`${u} {
|
|
223
|
+
${j}
|
|
224
|
+
}`}return`${u} { ${f} }`}let v=Hl(u,n,r,i),S=f;for(let[I,j]of a)S=S.replace(new RegExp(`\\b${I}\\b`,"g"),j);if(l)S=S.replace(/--([a-z-]+)/gi,`--${n}-$1`);return`${v} { ${S} }`}function Hl(e,n,r,i){let a=e.split(",").map((u)=>u.trim()),l=[];for(let u of a){if(u.startsWith(":host")){if(i)l.push(u);else{let S=u.replace(/:host(\([^)]*\))?/,`.${n}$1`);l.push(S)}continue}if(u.includes("::slotted")){l.push(u);continue}if(u===":root"){l.push(`:root .${n}`);continue}let f=r?`${r} .${n}`:`.${n}`;l.push(`${f} ${u}`);let v=Kl(u,n);if(v)l.push(r?`${r} ${v}`:v)}return l.join(", ")}function Kl(e,n){let r=0,i=e.length;for(let v=0;v<e.length;v++){let S=e[v];if(S==="["||S==="(")r++;else if(S==="]"||S===")")r--;else if(r===0&&(S===" "||S===">"||S==="+"||S==="~")){i=v;break}}let a=e.slice(0,i),l=e.slice(i);if(!a)return"";let u=a.length,f=0;for(let v=0;v<a.length;v++){let S=a[v];if(S==="["||S==="(")f++;else if(S==="]"||S===")")f--;else if(r===0&&f===0&&S===":"){u=v;break}}return`${a.slice(0,u)}.${n}${a.slice(u)}${l}`}var Mo=String.raw`(?<![\w-])scoped(?![\w-])`,ur=/<style\s+([^>]*)>/gi,jo=/<style\s+([^>]*)>([\s\S]*?)<\/style>/gi,Do=new RegExp(Mo,"i"),ql=new RegExp(Mo,"gi"),pr=/<style\b[^>]*\bdata-stx-scoped(?:=(?:"[^"]*"|'[^']*'|[^\s>]+))?[^>]*>[\s\S]*?<\/style>\s*/gi;function Zl(e){ur.lastIndex=0;let n=ur.exec(e);while(n!==null){if(Do.test(n[1]))return!0;n=ur.exec(e)}return!1}function Li(e){let n=new Set,r=[];pr.lastIndex=0;let i=pr.exec(e);while(i!==null){let a=i[0].trim();if(n.has(a))r.push({start:i.index,end:i.index+i[0].length});else n.add(a);i=pr.exec(e)}return r}function Tn(e){let n=Li(e);if(n.length===0)return e;let r=Array(n.length+1),i=0;for(let a=0;a<n.length;a++){let l=n[a];r[a]=e.slice(i,l.start),i=l.end}return r[n.length]=e.slice(i),r.join("")}function so(e,n){if(!Zl(e))return{html:e,hasScoped:!1};let r=Ao(n),i=`data-v-${r}`,a=e,l=!1;if(jo.lastIndex=0,a=a.replace(jo,(u,f,v)=>{if(!Do.test(f))return u;l=!0;let S=Jl(v,i),I=f.replace(ql,"").trim(),j=I?` ${I}`:"";return`<style data-stx-scoped="${r}"${j}>${S}</style>`}),!l)return{html:e,hasScoped:!1};return a=Gl(a,i),{html:a,hasScoped:!0}}function Jl(e,n){return Io(e,"__SCOPE_PLACEHOLDER__",{preserveHost:!1}).replace(/\.(__SCOPE_PLACEHOLDER__) /g,`[${n}] `).replace(/\.(__SCOPE_PLACEHOLDER__)/g,`[${n}]`)}var Xl=(e)=>`\x00stx-scope-mask-${e}\x00`,Po=/\u0000stx-scope-mask-(\d+)\u0000/g;function Gl(e,n){let r=ke(e,(a,l)=>{let u=Q(a,l);return u>l?u:Cn(a,l)},(a,l)=>Xl(l)),i=Yl(r.output,n);return Po.lastIndex=0,i.replace(Po,(a,l)=>r.tokens[Number(l)])}function Yl(e,n){let r=new Set(["script","style","template","html","head","body","meta","link","title","base","!doctype","!DOCTYPE"]);return e.replace(/<([a-zA-Z][a-zA-Z0-9-]*)(\s[^>]*)?\/?>/g,(i,a,l)=>{if(r.has(a.toLowerCase()))return i;if(i.includes(n))return i;if(a.toLowerCase()==="style"||a.toLowerCase()==="script")return i;if(l)return i.replace(`<${a}${l}`,`<${a} ${n}${l}`);if(i.endsWith("/>"))return`<${a} ${n} />`;return`<${a} ${n}>`})}var Sn=/<\/?template\b[^>]*>/gi,Ql=/(?:^|\s)(?:id\s*=|(?:x-|[@:])(?:for|if|else(?:-if)?)(?=\s|=|$)|#[\w-]+(?:\s*=|\s|$)|v-slot(?::[\w-]+)?(?=\s|=|$)|slot\s*=)/i;function eu(e){let n=e.replace(/^<template\b/i,"").replace(/>$/,"");return Ql.test(n)}function B(e){Sn.lastIndex=0;let n;while((n=Sn.exec(e))!==null){if(n[0].startsWith("</")||eu(n[0]))continue;let r=n.index,i=Sn.lastIndex,a=1,l;while((l=Sn.exec(e))!==null)if(l[0].startsWith("</")){if(a--,a===0){let u=l.index;return{start:r,openEnd:i,closeStart:u,end:Sn.lastIndex,content:e.slice(i,u)}}}else a++;return null}return null}var tu=0,nu=0;function xs(e,n){let r=/(?:^|\s)([^\s=/>]+)(?:\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s>]+)))?/g;for(let i of e.matchAll(r))if(i[1].toLowerCase()===n.toLowerCase())return i[2]??i[3]??i[4]??null;return null}function Lo(e){let n=[],r=/<([a-z][a-z0-9-]*)\b((?:"[^"]*"|'[^']*'|[^>"'])*)>/iy;return x(e,(i,a)=>{r.lastIndex=a;let l=r.exec(i);if(!l||!xs(l[2],"x-data"))return-1;return n.push({fullMatch:l[0],tagName:l[1],attributes:l[2],startIndex:a,endIndex:r.lastIndex}),r.lastIndex}),n}function su(e){let n=[];for(let{fullMatch:r,tagName:i,attributes:a,startIndex:l}of Lo(e)){let u=xs(a,"x-data");if(!u)continue;let f=`__stx_scope_${tu++}`,v=xs(a,"x-init"),S=ru(e,i,l+r.length),I=e.slice(l,S.endIndex),j=iu(I);n.push({id:f,selector:`[data-stx-scope="${f}"]`,stateExpr:u,initExpr:v,bindings:[],refs:j})}return n}function ru(e,n,r){let i=1,a=r,l=new RegExp(`<${n}(?:\\s|>)`,"gi"),u=new RegExp(`</${n}>`,"gi"),f=new RegExp(`<${n}[^>]*/\\s*>`,"gi");while(i>0&&a<e.length){l.lastIndex=a,u.lastIndex=a,f.lastIndex=a;let v=l.exec(e),S=u.exec(e),I=f.exec(e);if(I&&I.index<(v?.index??1/0)){a=I.index+I[0].length;continue}if(!S)return{endIndex:e.length};if(v&&v.index<S.index)i++,a=v.index+v[0].length;else{if(i--,i===0)return{endIndex:S.index+S[0].length};a=S.index+S[0].length}}return{endIndex:e.length}}function iu(e){let n=new Map,r=e.replace(/x-data\s*=\s*"[^"]*"/gi,'x-data="__stripped__"').replace(/x-data\s*=\s*'[^']*'/gi,"x-data='__stripped__'"),i=/<[a-z][a-z0-9-]*\s+([^>]*x-ref\s*=\s*["']([^"']*)["'][^>]*)>/gi,a;while((a=i.exec(r))!==null){let[,l,u]=a,f=ou(l);n.set(u,f)}return n}function ou(e){let n=e.match(/\bid\s*=\s*["']([^"']*)["']/);if(n)return n[1];return`__stx_el_${nu++}`}function au(){return`
|
|
225
|
+
// STX Reactive Runtime - x-cloak and transition CSS
|
|
226
|
+
(function() {
|
|
227
|
+
var style = document.createElement('style');
|
|
228
|
+
style.textContent = [
|
|
229
|
+
'[x-cloak] { display: none !important; }',
|
|
230
|
+
// Default transition classes
|
|
231
|
+
'.stx-enter { opacity: 0; transform: scale(0.95); }',
|
|
232
|
+
'.stx-enter-start { opacity: 0; transform: scale(0.95); }',
|
|
233
|
+
'.stx-enter-active { transition: opacity 150ms ease-out, transform 150ms ease-out; }',
|
|
234
|
+
'.stx-enter-to { opacity: 1; transform: scale(1); }',
|
|
235
|
+
'.stx-leave { opacity: 1; transform: scale(1); }',
|
|
236
|
+
'.stx-leave-start { opacity: 1; transform: scale(1); }',
|
|
237
|
+
'.stx-leave-active { transition: opacity 100ms ease-in, transform 100ms ease-in; }',
|
|
238
|
+
'.stx-leave-to { opacity: 0; transform: scale(0.95); }'
|
|
239
|
+
].join('\\n');
|
|
240
|
+
document.head.appendChild(style);
|
|
241
|
+
})();
|
|
242
|
+
|
|
243
|
+
// STX Reactive Runtime
|
|
244
|
+
/* eslint-disable pickier/no-unused-vars, no-console, prefer-const */
|
|
245
|
+
window.__stx_reactive = (function() {
|
|
246
|
+
'use strict';
|
|
247
|
+
|
|
248
|
+
// Deep reactive proxy that triggers onChange for any mutation
|
|
249
|
+
function reactive(obj, onChange) {
|
|
250
|
+
if (!obj || typeof obj !== 'object') return obj;
|
|
251
|
+
return new Proxy(obj, {
|
|
252
|
+
get(target, prop) {
|
|
253
|
+
const value = target[prop];
|
|
254
|
+
if (value && typeof value === 'object' && !Array.isArray(value) && !(value instanceof Promise)) {
|
|
255
|
+
return reactive(value, onChange);
|
|
256
|
+
}
|
|
257
|
+
return value;
|
|
258
|
+
},
|
|
259
|
+
set(target, prop, value) {
|
|
260
|
+
target[prop] = value;
|
|
261
|
+
onChange(prop, value);
|
|
262
|
+
return true;
|
|
263
|
+
}
|
|
264
|
+
});
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
// Initialize an x-data scope: parse state, run init(), register into window.stx._scopes,
|
|
268
|
+
// then let the signals runtime handle all directive processing (x-for, x-text, :bind, etc.)
|
|
269
|
+
function initScope(scopeEl, initialState, bindings, refs, initExpr, deferInit) {
|
|
270
|
+
// Parse initial state (may contain methods including async init())
|
|
271
|
+
var state;
|
|
272
|
+
try {
|
|
273
|
+
state = new Function('return (' + initialState + ')')();
|
|
274
|
+
} catch (e) {
|
|
275
|
+
console.error('[stx-reactive] Invalid x-data:', initialState, e);
|
|
276
|
+
return;
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
// Build $refs object
|
|
280
|
+
var $refs = {};
|
|
281
|
+
for (var name in refs) {
|
|
282
|
+
if (Object.prototype.hasOwnProperty.call(refs, name)) {
|
|
283
|
+
(function(refName, refId) {
|
|
284
|
+
Object.defineProperty($refs, refName, {
|
|
285
|
+
get: function() { return document.getElementById(refId); }
|
|
286
|
+
});
|
|
287
|
+
})(name, refs[name]);
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
// Extract init method from state if present (Alpine.js convention)
|
|
292
|
+
var initMethod = state.init;
|
|
293
|
+
if (typeof initMethod === 'function') {
|
|
294
|
+
delete state.init;
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
// Make state reactive \u2014 mutations trigger re-render via signals
|
|
298
|
+
var scopeId = scopeEl.getAttribute('data-stx-scope');
|
|
299
|
+
var stx = window.stx;
|
|
300
|
+
|
|
301
|
+
// Create signals for each state property so the signals runtime can track dependencies
|
|
302
|
+
var signalState = {};
|
|
303
|
+
var rawState = {};
|
|
304
|
+
var derivedState = {};
|
|
305
|
+
var accessors = {};
|
|
306
|
+
// A getter must NOT be read here. Reading one calls it, and the old loop did
|
|
307
|
+
// exactly that: the returned value is not a function, so it was wrapped as a
|
|
308
|
+
// plain state() -- a snapshot of the answer at construction time, frozen
|
|
309
|
+
// forever while plain properties beside it updated (#2053). A getter is a
|
|
310
|
+
// derived value, so it is registered as one below, once ctxProxy exists for
|
|
311
|
+
// it to read through.
|
|
312
|
+
var ownDescriptors = Object.getOwnPropertyDescriptors ? Object.getOwnPropertyDescriptors(state) : {};
|
|
313
|
+
for (var key in state) {
|
|
314
|
+
if (Object.prototype.hasOwnProperty.call(state, key)) {
|
|
315
|
+
var descriptor = ownDescriptors[key];
|
|
316
|
+
if (descriptor && typeof descriptor.get === 'function') {
|
|
317
|
+
accessors[key] = descriptor;
|
|
318
|
+
continue;
|
|
319
|
+
}
|
|
320
|
+
if (typeof state[key] === 'function') {
|
|
321
|
+
// Methods \u2014 bind to a proxy so 'this.prop = val' triggers signal updates
|
|
322
|
+
signalState[key] = state[key];
|
|
323
|
+
} else {
|
|
324
|
+
// Data properties \u2014 wrap in signals for reactivity
|
|
325
|
+
signalState[key] = stx.state(state[key]);
|
|
326
|
+
rawState[key] = true;
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
// Create a proxy context that auto-unwraps signals and writes back through them.
|
|
332
|
+
// Methods get 'this' bound to this proxy so this.foo = bar triggers reactivity.
|
|
333
|
+
var ctx = {};
|
|
334
|
+
var ctxProxy = new Proxy(ctx, {
|
|
335
|
+
get: function(target, prop) {
|
|
336
|
+
if (prop === '$refs') return $refs;
|
|
337
|
+
if (prop === '$el') return scopeEl;
|
|
338
|
+
if (prop === '$nextTick') return function(fn) { requestAnimationFrame(fn); };
|
|
339
|
+
if (prop === Symbol.unscopables) return undefined;
|
|
340
|
+
if (!(prop in signalState)) {
|
|
341
|
+
var owner = stx._scopeForBinding(scopeEl, prop);
|
|
342
|
+
return owner ? owner[prop] : undefined;
|
|
343
|
+
}
|
|
344
|
+
var s = signalState[prop];
|
|
345
|
+
if (!s) return undefined;
|
|
346
|
+
if (rawState[prop] && s && typeof s === 'function' && typeof s.value !== 'undefined') {
|
|
347
|
+
return s.value; // unwrap signal
|
|
348
|
+
}
|
|
349
|
+
if (typeof s === 'function' && !rawState[prop]) {
|
|
350
|
+
return s.bind(ctxProxy); // bind methods to proxy
|
|
351
|
+
}
|
|
352
|
+
return s;
|
|
353
|
+
},
|
|
354
|
+
set: function(target, prop, value) {
|
|
355
|
+
var accessor = derivedState[prop];
|
|
356
|
+
if (accessor) {
|
|
357
|
+
// A getter/setter pair writes through its setter. A getter alone has
|
|
358
|
+
// nowhere to put the value: a derived has no .value setter, so the
|
|
359
|
+
// assignment would be a silent no-op, which is the same class of
|
|
360
|
+
// failure as the stale read this replaces.
|
|
361
|
+
if (typeof accessor.set === 'function') {
|
|
362
|
+
accessor.set.call(ctxProxy, value);
|
|
363
|
+
return true;
|
|
364
|
+
}
|
|
365
|
+
console.warn('[stx-reactive] cannot assign to ' + String(prop) + ': it is a getter in x-data, so its value comes from what it reads. Give it a setter, or make it a plain property.');
|
|
366
|
+
return true;
|
|
367
|
+
}
|
|
368
|
+
var s = signalState[prop];
|
|
369
|
+
if (rawState[prop] && s && typeof s === 'function') {
|
|
370
|
+
s.value = value; // write through signal \u2014 triggers effects
|
|
371
|
+
} else {
|
|
372
|
+
signalState[prop] = value;
|
|
373
|
+
}
|
|
374
|
+
return true;
|
|
375
|
+
},
|
|
376
|
+
has: function(target, prop) {
|
|
377
|
+
return prop in signalState || prop === '$refs' || prop === '$el' || prop === '$nextTick' || !!stx._scopeForBinding(scopeEl, prop);
|
|
378
|
+
},
|
|
379
|
+
ownKeys: function() {
|
|
380
|
+
return Object.keys(signalState).concat(['$refs', '$el', '$nextTick']);
|
|
381
|
+
},
|
|
382
|
+
getOwnPropertyDescriptor: function(target, prop) {
|
|
383
|
+
if (prop in signalState || prop === '$refs' || prop === '$el' || prop === '$nextTick') {
|
|
384
|
+
return { configurable: true, enumerable: true, writable: true, value: ctxProxy[prop] };
|
|
385
|
+
}
|
|
386
|
+
return undefined;
|
|
387
|
+
}
|
|
388
|
+
});
|
|
389
|
+
|
|
390
|
+
// Now that ctxProxy exists, a getter becomes a derived that reads through it,
|
|
391
|
+
// so it tracks whatever it touches and recomputes when that changes. derived()
|
|
392
|
+
// is lazy, so nothing is evaluated until a binding actually reads it.
|
|
393
|
+
//
|
|
394
|
+
// Marked rawState as well: that is what makes the proxy unwrap it and what
|
|
395
|
+
// exposes the signal itself to the runtime below, which is where dependency
|
|
396
|
+
// tracking comes from. A getter needs both, exactly like a data property.
|
|
397
|
+
for (var accessorKey in accessors) {
|
|
398
|
+
if (Object.prototype.hasOwnProperty.call(accessors, accessorKey)) {
|
|
399
|
+
(function(name, descriptor) {
|
|
400
|
+
signalState[name] = stx.derived(function() {
|
|
401
|
+
return descriptor.get.call(ctxProxy);
|
|
402
|
+
});
|
|
403
|
+
rawState[name] = true;
|
|
404
|
+
derivedState[name] = descriptor;
|
|
405
|
+
})(accessorKey, accessors[accessorKey]);
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
// Build scope vars for the signals runtime \u2014 it reads these for expression evaluation.
|
|
410
|
+
// We need to provide getter/setter descriptors so signals track properly.
|
|
411
|
+
var scopeVars = {};
|
|
412
|
+
for (var k in signalState) {
|
|
413
|
+
if (Object.prototype.hasOwnProperty.call(signalState, k)) {
|
|
414
|
+
if (rawState[k]) {
|
|
415
|
+
// Data: expose the signal directly so expressions trigger dependency tracking
|
|
416
|
+
scopeVars[k] = signalState[k];
|
|
417
|
+
} else {
|
|
418
|
+
// Method: bind to ctxProxy so 'this' works
|
|
419
|
+
scopeVars[k] = (typeof signalState[k] === 'function') ? signalState[k].bind(ctxProxy) : signalState[k];
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
scopeVars.$refs = $refs;
|
|
424
|
+
scopeVars.$el = scopeEl;
|
|
425
|
+
scopeVars.$nextTick = function(fn) { requestAnimationFrame(fn); };
|
|
426
|
+
|
|
427
|
+
// Register scope \u2014 merge with any existing vars from partial signal scripts
|
|
428
|
+
if (!stx._scopes) stx._scopes = {};
|
|
429
|
+
var registered = stx._scopes[scopeId] = Object.assign(stx._scopes[scopeId] || {}, scopeVars);
|
|
430
|
+
registered.__el = scopeEl;
|
|
431
|
+
|
|
432
|
+
// Store on element for findElementScope
|
|
433
|
+
scopeEl.__stx_scope = scopeVars;
|
|
434
|
+
|
|
435
|
+
// Run init() if present (supports async)
|
|
436
|
+
function runInit() {
|
|
437
|
+
var maybePromise;
|
|
438
|
+
if (initMethod) {
|
|
439
|
+
maybePromise = initMethod.call(ctxProxy);
|
|
440
|
+
}
|
|
441
|
+
if (initExpr) {
|
|
442
|
+
try {
|
|
443
|
+
var fn = new Function('with(this){' + initExpr + ';}');
|
|
444
|
+
var result = fn.call(ctxProxy);
|
|
445
|
+
if (result && typeof result.then === 'function') maybePromise = result;
|
|
446
|
+
} catch (e) {
|
|
447
|
+
console.warn('[stx-reactive] init expression error:', e);
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
// If init is async, signal updates will trigger effects automatically
|
|
451
|
+
// when init() resolves and sets this.prop = value (writes through signal)
|
|
452
|
+
if (maybePromise && typeof maybePromise.then === 'function') {
|
|
453
|
+
maybePromise.catch(function(e) {
|
|
454
|
+
console.error('[stx-reactive] async init() error:', e);
|
|
455
|
+
});
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
// A component's helper setup follows its markup. Its own mount queue
|
|
460
|
+
// starts the initializer after all component factories have registered.
|
|
461
|
+
// Standalone x-data retains synchronous initialization.
|
|
462
|
+
if (deferInit) {
|
|
463
|
+
registered.__mountCallbacks = registered.__mountCallbacks || [];
|
|
464
|
+
registered.__mountCallbacks.push(runInit);
|
|
465
|
+
} else {
|
|
466
|
+
runInit();
|
|
467
|
+
}
|
|
468
|
+
var destroyExpr = scopeEl.getAttribute('data-stx-xdestroy') || scopeEl.getAttribute('x-destroy');
|
|
469
|
+
if (destroyExpr) {
|
|
470
|
+
registered.__destroyCallbacks = registered.__destroyCallbacks || [];
|
|
471
|
+
var teardown = function() { scopeEl.__stx_execute(destroyExpr); };
|
|
472
|
+
registered.__destroyCallbacks.push(teardown);
|
|
473
|
+
registered.__destroyHooks = registered.__destroyHooks || [];
|
|
474
|
+
registered.__destroyHooks.push(teardown);
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
// Expose for debugging
|
|
478
|
+
scopeEl.__stx_state = ctxProxy;
|
|
479
|
+
scopeEl.__stx_execute = function(stmt, $event, $el) {
|
|
480
|
+
try {
|
|
481
|
+
// Run the statement with the reactive proxy as the lexical scope.
|
|
482
|
+
// Wrapping in a with-block on the proxy makes bare reads/writes go
|
|
483
|
+
// through it (so foo = bar triggers signal.set()) instead of treating
|
|
484
|
+
// each state key as a local function parameter \u2014 bare assignments
|
|
485
|
+
// would otherwise just rebind the local and never reach the signal.
|
|
486
|
+
var fn = new Function('$event', '$el', 'with(this){' + stmt + ';}');
|
|
487
|
+
fn.call(ctxProxy, $event, $el);
|
|
488
|
+
} catch (e) {
|
|
489
|
+
console.warn('[stx-reactive] execute error:', e);
|
|
490
|
+
}
|
|
491
|
+
};
|
|
492
|
+
}
|
|
493
|
+
|
|
494
|
+
return { initScope: initScope, reactive: reactive };
|
|
495
|
+
})();
|
|
496
|
+
`}function No(e,n){let r=e.replace(/\{!!([\s\S]*?)!!\}/g,(f,v)=>{try{let S=N(v,n,!0);if(S===void 0)return f;return String(S)}catch{return f}}),i="",a=0,l=null;while(a<r.length){let f=r[a];if(l&&f==="\\"){i+=f+(r[a+1]??""),a+=2;continue}if(f==="{"&&r[a+1]==="{"){let v=r.indexOf("}}",a+2);if(v!==-1){let S=r.slice(a,v+2);i+=u(r.slice(a+2,v),S,l),a=v+2;continue}}if(l){if(f===l)l=null}else if(f==="'"||f==='"'||f==="`")l=f;i+=f,a++}return i;function u(f,v,S){let I;try{I=N(f,n,!0)}catch{return v}if(I===void 0)return v;if(S){let j=String(I).replace(/\\/g,"\\\\").replace(new RegExp(S==="`"?"`":S,"g"),`\\${S}`).replace(/\r/g,"\\r").replace(/\n/g,"\\n");return S==="`"?j.replace(/\$\{/g,"\\${"):j}if(typeof I==="string"){let j=I.trim();if(j.startsWith("{")&&j.endsWith("}")||j.startsWith("[")&&j.endsWith("]"))try{return JSON.parse(j),j}catch{}}return JSON.stringify(I)}}function cu(e,n,r){if(e.length===0)return"";let i=e.map((a)=>{let l=JSON.stringify(Object.fromEntries(a.refs)),u=No(a.stateExpr,n),f=a.initExpr?No(a.initExpr,n):null,v=JSON.stringify(u),S=f?JSON.stringify(f):"null";return`
|
|
497
|
+
(function() {
|
|
498
|
+
var scopeEl = document.querySelector('${a.selector}');
|
|
499
|
+
if (!scopeEl) return;
|
|
500
|
+
var refs = ${l};
|
|
501
|
+
window.__stx_reactive.initScope(scopeEl, ${v}, [], refs, ${S}${r?", true":""});
|
|
502
|
+
})();`}).join(`
|
|
503
|
+
`);return`
|
|
504
|
+
<script data-stx-scoped data-stx-reactive data-stx-run="always">
|
|
505
|
+
${au()}
|
|
506
|
+
${i}
|
|
507
|
+
</script>`}function pl(e,n,r,i=!1){if(!fr(e))return e;let a=su(e);if(a.length===0)return e;let l=lu(e,a),u=cu(a,n,i),f=c(l);if(f!==-1)l=l.slice(0,f)+u+`
|
|
508
|
+
`+l.slice(f);else l+=u;return l}function lu(e,n){let r=[],i=0;for(let[l,u]of Lo(e).entries()){let f=n[l];if(!f)break;r.push(e.slice(i,u.startIndex));let v=xs(u.attributes,"data-stx-scope");if(v)f.id=v,f.selector=`[data-stx-scope="${f.id}"]`,r.push(u.fullMatch);else r.push(`<${u.tagName} data-stx-scope="${f.id}"${u.attributes}>`);i=u.endIndex}r.push(e.slice(i));let a=r.join("");return a=a.replace(/\s*x-data\s*=\s*"([^"]*)"/g,' data-stx-xdata="$1"'),a=a.replace(/\s*x-data\s*=\s*'([^']*)'/g," data-stx-xdata='$1'"),a=a.replace(/\s*x-init\s*=\s*"([^"]*)"/g,' data-stx-xinit="$1"'),a=a.replace(/\s*x-init\s*=\s*'([^']*)'/g," data-stx-xinit='$1'"),a=a.replace(/\s*x-destroy\s*=\s*"([^"]*)"/g,' data-stx-xdestroy="$1"'),a=a.replace(/\s*x-destroy\s*=\s*'([^']*)'/g," data-stx-xdestroy='$1'"),a}function fr(e){return/x-data\s*=\s*["']/.test(e)}function io(e,n){let r=e,i=/@json\s*\(/g,a;while((a=i.exec(r))!==null){let l=a.index,u=l+a[0].length-1,f=1,v=u+1,S=null,I=!1;while(v<r.length&&f>0){let U=r[v];if(I){I=!1,v++;continue}if(U==="\\"&&S){I=!0,v++;continue}if(S){if(U===S)S=null;v++;continue}if(U==='"'||U==="'"||U==="`"){S=U,v++;continue}if(U==="(")f++;else if(U===")"){if(f--,f===0)break}v++}if(f!==0)break;let j=r.substring(u+1,v).trim(),L=r.substring(l,v+1),M=-1,V=0,W=null,Z=!1;for(let U=0;U<j.length;U++){let H=j[U];if(Z){Z=!1;continue}if(H==="\\"&&W){Z=!0;continue}if(W){if(H===W)W=null;continue}if(H==='"'||H==="'"||H==="`"){W=H;continue}if(H==="("||H==="["||H==="{")V++;else if(H===")"||H==="]"||H==="}")V--;if(H===","&&V===0){M=U;break}}let q=M>=0?j.substring(0,M).trim():j,G=M>=0?j.substring(M+1).trim():void 0;try{let U=q.trim(),H;if(m(U))H=p(U,Object.keys(n))(...Object.values(n));else H=void 0;let re;if(G==="true")re=JSON.stringify(H,null,2);else re=JSON.stringify(H);let ce=re.replace(/</g,"\\u003c").replace(/>/g,"\\u003e").replace(/&/g,"\\u0026").replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029");r=r.substring(0,l)+ce+r.substring(v+1),i.lastIndex=l+ce.length}catch(U){K.log(U instanceof Error?U:Error(String(U)),{directive:"@json"},"error"),i.lastIndex=l+L.length}}return r}function ao(e){return e.replace(/@once\s*([\s\S]*?)@endonce/g,"$1")}function fl(e){let n=e,r=/@memo\s*\(/g,i,a=[];while((i=r.exec(n))!==null){let l=i.index,u=l+i[0].length,f=1,v=u;while(v<n.length&&f>0){if(n[v]==="(")f++;else if(n[v]===")")f--;v++}if(f!==0)continue;let S=n.slice(u,v-1).trim(),I=v,j=n.slice(I),L=j.indexOf("@endmemo");if(L===-1)continue;let M=j.slice(0,L),V=I+L+8,W=Ut(M),Z=M.slice(W),q=M.match(/(\s*)$/),G=q?q[0].length:0,U=Z.slice(0,Z.length-G),H=U.match(/^<([a-zA-Z][a-zA-Z0-9-]*)(\s[^>]*?)?(\/?)>/),re;if(H){let[ce,le,fe="",we]=H,Ee=`<${le}${fe} data-stx-memo="${S}"${we}>`;re=M.slice(0,W)+Ee+U.slice(ce.length)+M.slice(W+U.length)}else re=`${M.slice(0,W)}<div data-stx-memo="${S}">${U}</div>${M.slice(W+U.length)}`;a.push({start:l,end:V,replacement:re}),r.lastIndex=V}for(let l=a.length-1;l>=0;l--){let u=a[l];n=n.slice(0,u.start)+u.replacement+n.slice(u.end)}return n.replace(/@memo="([^"]*)"/g,'data-stx-memo="$1"')}function ji(e){let n=e.replace(/@ref="([^"]+)"/g,'data-stx-ref="$1"');return n=n.replace(/(<[a-zA-Z][a-zA-Z0-9-]*\b[^>]*?)\sref="([^"]+)"/g,'$1 data-stx-ref="$2"'),n}function Fo(e,n){let r=/<\/?([a-zA-Z][\w-]*)\b(?:"[^"]*"|'[^']*'|[^'">])*>/y,i=x(e,(f,v)=>{r.lastIndex=v;let S=r.exec(f);if(!S||/^(?:script|style)$/i.test(S[1]))return-1;return r.lastIndex}),a=[],l=0,u=[];for(let{start:f,end:v,token:S}of i){let I=/^<\/?([\w-]+)/.exec(S)[1].toLowerCase();if(S.startsWith("</")){while(a.length&&a.pop()!==I);continue}if(!a.length&&!/\sdata-stx-slot-owner\s*=/.test(S))u.push(e.slice(l,f),S.replace(/\s*\/?>$/,(j)=>` data-stx-slot-owner="${n}"${j}`)),l=v;if(!dr.has(I)&&!/\/>$/.test(S))a.push(I)}return u.push(e.slice(l)),u.join("")}function Vo(e,n){if(!/\bref\s*=/.test(e))return e;let r=/<\/?([a-zA-Z][\w-]*)\b(?:"[^"]*"|'[^']*'|[^'">])*>/y,i=x(e,(v,S)=>{r.lastIndex=S;let I=r.exec(v);if(!I||/^(?:script|style)$/i.test(I[1]))return-1;return r.lastIndex}),a=[],l=0,u=0,f=[];for(let{start:v,end:S,token:I}of i){let j=/^<\/?([\w-]+)/.exec(I)[1].toLowerCase();if(I.startsWith("</")){let W;while(W=a.pop()){if(W.scoped)l--;if(W.name===j)break}continue}let L=/\sdata-stx-scope\s*=/.test(I),M=/\sdata-stx-ref-caller\s*=\s*(["'])(.*?)\1/.exec(I),V=a.find((W)=>W.scoped)?.scopeId;if(M&&V&&M[2]===V)f.push(e.slice(u,v),I.replace(M[0],` data-stx-ref-caller="${n}"`)),u=S;else if(!l&&!L&&/\s(?:ref|@ref|:ref|x-ref|data-stx-ref)\s*=/.test(I)&&!/\sdata-stx-ref-caller\s*=/.test(I))f.push(e.slice(u,v),I.replace(/\s*\/?>$/,(W)=>` data-stx-ref-caller="${n}"${W}`)),u=S;if(!dr.has(j)&&!/\/>$/.test(I)){let W=/\sdata-stx-scope\s*=\s*(?:"([^"]*)"|'([^']*)')/.exec(I);if(a.push({name:j,scoped:L,scopeId:W?.[1]??W?.[2]}),L)l++}}return f.push(e.slice(u)),f.join("")}var dr=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),Uo=/(?:^|\s)x-no-cloak(?:=|\s|\/|>|$)/,zo=/<\/?\s*([a-z][\w-]*)/iy,uu=/\s/;function pu(e,n){let r=n-1;while(r>=0&&uu.test(e[r]))r--;return r>=0&&e[r]==="/"}function fu(e,n){let r=!1,i=!1;for(let a=n;a<e.length;a++){let l=e[a];if(r){if(l==="'")r=!1}else if(i){if(l==='"')i=!1}else if(l==="'")r=!0;else if(l==='"')i=!0;else if(l===">")return a}return-1}function du(e,n){if(e.indexOf("{",n)===-1||e.indexOf("}",n)===-1)return!1;let r=0,i=n,a=!1,l=!1,u=!1;while(i<e.length){let f=e.indexOf("<",i),v=f===-1?e.length:f;if(v>i){if(r===0)while(i<v){let j=e.indexOf(l?"}":"{",i);if(j===-1||j>=v){if(l)u=!1;else a=!1;break}if(j>i)if(l)u=!1;else a=!1;if(l){if(u)return!0;u=!0}else if(a)l=!0,u=!1;else a=!0;i=j+1}i=v;continue}if(e.startsWith("<!--",i)){let j=e.indexOf("-->",i);i=j===-1?e.length:j+3;continue}let S=fu(e,i);if(S===-1)break;zo.lastIndex=i;let I=zo.exec(e)?.[1]?.toLowerCase()??"";if(e[i+1]==="/"){if(r===0)break;r--}else if(!pu(e,S)&&!dr.has(I))r++;i=S+1}return!1}var Bo=k(256);function gl(e){if(e.length<1024)return Wo(e);let n=E(e),r=Bo.get(n);if(r!==void 0)return r;let i=Wo(e);return Bo.set(n,i),i}function Wo(e){if(e.length>=32768&&!ki(e))return e;let r=new RegExp(`<(${"div|span|p|h[1-6]|td|th|li|a|button|label|section|article|header|footer|main|nav|aside|dd|dt|figcaption|summary|caption|blockquote|pre|code|em|strong|small|sub|sup|time|mark|abbr|cite|q|s|u|b|i"})\\b`,"gi"),i="",a=0,l;while((l=r.exec(e))!==null){let u=l.index,f=u+l[0].length,v=!1,S=!1,I=-1;while(f<e.length){let L=e[f];if(v){if(L==="'")v=!1}else if(S){if(L==='"')S=!1}else if(L==="'")v=!0;else if(L==='"')S=!0;else if(L===">"){I=f;break}f++}if(I===-1)continue;let j=e.slice(u,I+1);if(Uo.test(j))continue;if(j.includes("x-cloak"))continue;if(du(e,I+1))i+=e.slice(a,I)+" x-cloak>",a=I+1}return i+=e.slice(a),i}var gu=/(?:^|\s)(?::else-if|:if|:else|:show|x-else-if|x-if|x-else|x-show|@if|@show)(?:=|\s|\/|>|$)/,mu=/<\/script>/gi,hu=/<\/style>/gi;function ml(e){let n=/<[a-z][\w-]*/gi,r="",i=0,a;while((a=n.exec(e))!==null){let l=a.index,u=a[0].slice(1).toLowerCase();if(u==="script"||u==="style"){let V=u==="script"?mu:hu;V.lastIndex=l;let W=V.exec(e);if(W!==null)n.lastIndex=W.index+W[0].length;continue}let f=l+a[0].length,v=!1,S=!1,I=-1;while(f<e.length){let V=e[f];if(v){if(V==="'")v=!1}else if(S){if(V==='"')S=!1}else if(V==="'")v=!0;else if(V==='"')S=!0;else if(V===">"){I=f;break}f++}if(I===-1)continue;let j=e.slice(l+a[0].length,I);if(Uo.test(j))continue;if(/(?:^|\s)x-cloak(?:=|\s|\/|>|$)/.test(j))continue;if(!gu.test(j))continue;let L=e[I-1]==="/",M=L?I-1:I;r+=`${e.slice(i,M)} x-cloak${L?" ":""}`,i=M}return r+=e.slice(i),r}function O(e){let n=new Map;for(let r of e.matchAll(/([^\s=/>]+)(?:\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s>]+)))?/g))n.set(r[1].toLowerCase(),r[2]??r[3]??r[4]??!0);return n}function $t(e){let n=e.get("type");return typeof n!=="string"||!n.trim()||/^(?:module|(?:text|application)\/(?:javascript|typescript|ecmascript))$/i.test(n.trim())}import ha from"path";import gr from"fs";import jn from"path";function Ho(e,n,r,i){let a=0;for(let l=n;l<e.length;l++)if(e[l]===r)a++;else if(e[l]===i&&!(i===">"&&e[l-1]==="=")){if(--a===0)return l}return-1}function xu(e){let n=t(e),r=0,i=0,a=[];for(let l=0;l<n.length;l++)if("([{".includes(n[l]))r++;else if(")]}".includes(n[l]))r--;else if(n[l]===","&&r===0)a.push(e.slice(i,l).trim()),i=l+1;return a.push(e.slice(i).trim()),a}function kn(e,n,r=!1){let i=t(e),a=new RegExp(`\\b(?:${n.map((u)=>u.replace(/[$]/g,"\\$&")).join("|")})\\s*(?=[<(])`,"g"),l=r?h(i).depths:void 0;for(let u of i.matchAll(a)){if(l&&l[u.index]!==0)continue;let f=u.index+u[0].length,v="";if(i[f]==="<"){let I=Ho(i,f,"<",">");if(I<0)continue;v=e.slice(f+1,I),f=I+1;while(/\s/.test(i[f]||"")&&f<i.length)f++}if(i[f]!=="(")continue;let S=Ho(i,f,"(",")");if(S>=0)return{type:v,args:xu(e.slice(f+1,S)),start:u.index,end:S+1}}return null}var bs=`
|
|
509
|
+
type __StxCtor<T> = T extends StringConstructor ? string : T extends NumberConstructor ? number : T extends BooleanConstructor ? boolean : T extends ArrayConstructor ? unknown[] : T extends ObjectConstructor ? object : T extends readonly unknown[] ? __StxCtor<T[number]> : T extends abstract new (...args: any[]) => infer V ? V : unknown;
|
|
510
|
+
type __StxWiden<T> = T extends string ? string : T extends number ? number : T extends boolean ? boolean : T;
|
|
511
|
+
type __StxOption<T> = T extends { type: infer C } ? __StxCtor<C> : T extends { default: infer D } ? D extends (...args: any[]) => infer V ? V : __StxWiden<D> : __StxCtor<T>;
|
|
512
|
+
type __StxRequired<O> = { [K in keyof O]-?: O[K] extends { required: true } ? K : never }[keyof O];
|
|
513
|
+
type __StxDefaulted<O> = { [K in keyof O]-?: O[K] extends { default: unknown } ? K : never }[keyof O];
|
|
514
|
+
type __StxOptions<O> = { [K in Exclude<__StxRequired<O>, __StxDefaulted<O>>]: __StxOption<O[K]> } & { [K in Exclude<keyof O, Exclude<__StxRequired<O>, __StxDefaulted<O>>>]?: __StxOption<O[K]> };
|
|
515
|
+
type __StxDefaults<P, K> = Omit<P, Extract<keyof P, K>> & Partial<Pick<P, Extract<keyof P, K>>>;
|
|
516
|
+
`;function ys(e,n){let r=[],i={defineProps:["defineProps"],defineEmits:["defineEmits"],withDefaults:["withDefaults"]},a=t(e),l=e.replace(/\bimport\s+(?:type\s+)?(\{[^}]*\}|\*\s+as\s+[\w$]+|[\w$]+)\s+from\s*(['"])([^'"]+)\2\s*;?/g,(L,M,V,W,Z)=>{if(a.slice(Z,Z+6)!=="import")return L;if(W.endsWith(".stx"))return"";let q=`${n}Import${r.length}`;if(r.push(`import * as ${q} from ${JSON.stringify(W)};`),M.startsWith("*"))return`import ${M.replace(/^\*\s+as\s+/,"")} = ${q};`;if(!M.startsWith("{"))return`import ${M} = ${q}.default;`;return M.slice(1,-1).split(",").map((G)=>{let[U,H=U]=G.trim().replace(/^type\s+/,"").split(/\s+as\s+/);if(!U)return"";if(/^(?:stx|@stacksjs\/stx)(?:\/|$)/.test(W)&&U in i)i[U].push(H);return`import ${H} = ${q}.${U};`}).join(`
|
|
517
|
+
`)}),u=kn(e,i.defineProps),f=kn(e,i.defineEmits),v=kn(e,i.withDefaults);if(!u&&!f)return{declarations:"",props:null,events:null};let S=[],I=null,j=null;if(u){S.push(`const __options = (${u.args[0]||"{}"}) as const;`),S.push(`const __defaults = (${v?.args[1]||"{}"});`);let L=u.type||"__StxOptions<typeof __options>";S.push(`export type __StxProps = __StxDefaults<${L}, keyof typeof __defaults | __StxDefaulted<typeof __options>>;`),I=`${n}.__StxProps`}if(f)S.push(`const __events = (${f.args[0]||"[]"}) as const;`),S.push(`export type __StxEvents = ${f.type||"Record<(typeof __events)[number], any[]>"};`),j=`${n}.__StxEvents`;return{declarations:`${r.join(`
|
|
518
|
+
`)}
|
|
519
|
+
namespace ${n} {
|
|
520
|
+
${l}
|
|
521
|
+
${S.join(`
|
|
522
|
+
`)}
|
|
523
|
+
}`,props:I,events:j}}var Lr=new Set(["a","abbr","address","area","article","aside","audio","b","base","bdi","bdo","blockquote","body","br","button","canvas","caption","cite","code","col","colgroup","component","data","datalist","dd","del","details","dfn","dialog","div","dl","dt","em","embed","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","iframe","img","input","ins","kbd","label","legend","li","link","main","map","mark","menu","meta","meter","nav","noscript","object","ol","optgroup","option","output","p","param","picture","pre","progress","q","rp","rt","ruby","s","samp","script","section","select","slot","small","source","span","strong","style","sub","summary","sup","svg","table","tbody","td","template","textarea","tfoot","th","thead","time","title","tr","track","u","ul","var","video","wbr","path","circle","rect","line","polygon","polyline","ellipse","text","tspan","textPath","g","defs","use","symbol","image","clipPath","mask","pattern","marker","linearGradient","radialGradient","stop","filter","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDropShadow","feFlood","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","feSpecularLighting","feTile","feTurbulence","foreignObject","animate","animateMotion","animateTransform","set","mpath","desc","metadata","switch","view"]);function jr(e){if(e.includes("-")||e==="component")return!1;if(/^[A-Z]/.test(e))return!/[a-z]/.test(e)&&[...Lr].some((n)=>n.toLowerCase()===e.toLowerCase());return Lr.has(e)||/[A-Z]/.test(e)}function*bu(e){let n=/<([A-Za-z][\w.-]*)(?=[\s/>])/g,r;while(r=n.exec(e)){let i=n.lastIndex,a=[];while(i<e.length){while(/\s/.test(e[i]||""))i++;if(e[i]===">"||e.slice(i,i+2)==="/>"){i+=e[i]===">"?1:2;break}let l=/^[^\s=/>]+/.exec(e.slice(i))?.[0];if(!l){i++;continue}let u=i;i+=l.length;while(/\s/.test(e[i]||""))i++;if(e[i]!=="="){a.push({name:l,value:!0,offset:u,braced:!1});continue}i++;while(/\s/.test(e[i]||""))i++;let f=e[i],v=f==="{",S=f==='"'||f==="'";if(S||v)i++;let I=i;if(v){let j=t(e.slice(i)),L=1,M=0;for(;M<j.length;M++){if(j[M]==="{")L++;if(j[M]==="}"&&--L===0)break}i+=M}else if(S)while(i<e.length&&e[i]!==f)i++;else while(i<e.length&&!/[\s/>]/.test(e[i]))i++;if(a.push({name:l,value:e.slice(I,i),offset:I,braced:v}),S||v)i++}n.lastIndex=i,yield{name:r[1],offset:r.index,attributes:a}}}function Ko(e,n,r){let i=[],a=[bs,"type __StxAssignedValue<T> = T extends { readonly _isSignal: true } | { readonly _isDerived: true } ? T extends () => infer V ? V : T : T;","type __StxProp<P, K> = K extends keyof P ? P[K] : unknown;",'type __StxStaticProp<P, K> = __StxProp<P, K> extends infer T ? boolean extends T ? T | "true" | "false" : T : never;','type __StxEvent<E, K> = K extends keyof E ? E[K] extends readonly unknown[] ? number extends E[K]["length"] ? E[K][0] : Exclude<E[K]["length"], 0 | 1> extends never ? E[K][0] : E[K] : E[K] : any;'],l=new Map,u=new Map,f=new Map,v=r.scriptCode(e,r.filePath),S=t(v);for(let V of v.matchAll(/\bimport\s+(\{[^}]+\}|[\w$]+)\s+from\s*['"]([^'"]+)['"]/g)){if(S.slice(V.index,V.index+6)!=="import")continue;let W=V[2],Z=jn.isAbsolute(W)||W.startsWith(".")?jn.resolve(jn.dirname(r.filePath),W):Js(W,jn.dirname(r.filePath));if(!Z)continue;let q=Z.endsWith(".stx")?Z:gr.existsSync(`${Z}.stx`)?`${Z}.stx`:void 0,G=q?null:Ir(Z,!1),U=V[1].startsWith("{")?V[1].slice(1,-1).split(","):[V[1]];for(let H of U){let[re,ce=re]=H.trim().split(/\s+as\s+/),le=q||G?.get(re)||G?.get(re.toLowerCase());if(le)f.set(ce,le),f.set(ce.toLowerCase(),le),f.set(ce.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),le)}}for(let V of n.matchAll(/@import\s*\(([^)]+)\)/g))for(let W of V[1].matchAll(/['"]([^'"]+)['"]/g)){let Z=Ys(W[1],r.filePath,r).find((q)=>gr.statSync(q,{throwIfNoEntry:!1})?.isFile());if(Z)f.set(jn.basename(W[1]).replace(/\.stx$/,""),Z)}let I={__importedComponents:f},j=new Map,L=(V,W,Z)=>{let q=e.slice(0,V);return{code:W,offset:V,attribute:Z,anchor:!0,kind:"directive",line:q.split(`
|
|
524
|
+
`).length,column:V-q.lastIndexOf(`
|
|
525
|
+
`)}},M=(V,W,Z)=>i.push({expression:V,statement:{text:W+V.code+Z,prefixLength:W.length}});for(let V of bu(n)){if(jr(V.name)||V.name==="component")continue;let W=ai(V.name,r.filePath,r,I);if(!W)continue;let Z=j.get(W);if(!Z){let G;try{G=r.readComponent?r.readComponent(W):gr.readFileSync(W,"utf8")}catch{continue}if(G===void 0)continue;u.set(W,G),Z=ys(r.scriptCode(G,W),`__StxComponent${j.size}`),j.set(W,Z),a.push(Z.declarations)}let q=[];for(let G of V.attributes){let{name:U,offset:H}=G,re=G.value===!0?"true":G.value;if(U.startsWith("@")||U.startsWith("v-on:")){if(Z.events&&G.value!==!0)l.set(H,`__StxEvent<${Z.events}, ${JSON.stringify(U.replace(/^@|^v-on:/,"").split(".")[0])}>`);continue}let ce=/^v-model(?::([\w-]+))?(?:\.[\w-]+)*$/.exec(U);if(U.startsWith("v-")&&!U.startsWith("v-bind:")&&!ce)continue;if(/^(?:x-|:)(?:if|for|show|key|else)(?:$|[.:-])/.test(U))continue;let le=(ce?ce[1]||"modelValue":U.replace(/^:|^v-bind:/,"")).replace(/-([a-z])/g,(Re,ve)=>ve.toUpperCase());if(q.push(le),!Z.props)continue;let fe=U.startsWith(":")||U.startsWith("v-bind:")||!!ce||G.braced,we=fe?re:G.value!==!0?JSON.stringify(re):"true",Ee=!fe&&G.value!==!0&&(re==="true"||re==="false");M(L(H,we,U),";void ((",`) satisfies ${Ee?"__StxStaticProp":"__StxProp"}<${Z.props}, ${JSON.stringify(le)}>);`)}if(Z.props){let G=[...new Set(q)].map((H)=>`${JSON.stringify(H)}: undefined as any`).join(", "),U=L(V.offset,`<${V.name}>`);i.push({expression:U,statement:{text:`;void ({ ${G} } satisfies ${Z.props} & Record<string, unknown>);`,prefixLength:0}})}}return{declarations:j.size?a.join(`
|
|
526
|
+
`):"",checks:i,events:l,dependencies:u}}import ia from"fs";import _t from"path";var ht=["module","exports","require","props","$props","$bool","$num","defineProps","withDefaults","defineClientPayload","useServerData","useRuntimeConfig","useServerRuntimeConfig","state","derived","effect","batch","onMount","onDestroy","definePageMeta","useRoute","useRouter","useHead","useSeoMeta","setResponseStatus","setResponseHeader","notFound","ref","reactive","computed","watch","onMounted","onUnmounted","nextTick","defineEmits","defineExpose","defineSlots","provide","inject","useColorMode","useDark","useMediaQuery","useScrollLock","usePreferredDark","usePreferredLight","usePreferredReducedMotion","usePreferredContrast","window","document","console","confirm","alert","fetch","params"];function yu(e){let n=new be(e,"javascript").tokenize(),r=e;for(let i of n.reverse())if(i.type==="COMMENT")r=r.slice(0,i.start)+i.value.replace(/[^\r\n]/g," ")+r.slice(i.end);return r}function yt(e,n,r,i){if(e[n]!==r)return-1;let a=0,l=null;for(let u=n;u<e.length;u++){let f=e[u];if(l){if(f==="\\"){u++;continue}if(f===l)l=null;continue}if(f==="'"||f==='"'||f==="`"){l=f;continue}if(f===r)a++;else if(f===i){if(i===">"&&e[u-1]==="=")continue;if(a--,a===0)return u+1}}return-1}function pt(e,n,r){let i=r?"([{<":"([{",a=r?")]}>":")]}",l=[],u=0,f=null,v="";for(let S=0;S<e.length;S++){let I=e[S];if(f){if(v+=I,I==="\\"){v+=e[++S]??"";continue}if(I===f)f=null;continue}if(I==="'"||I==='"'||I==="`"){f=I,v+=I;continue}if(i.includes(I))u++;else if(a.includes(I)&&!(r&&I===">"&&e[S-1]==="="))u--;if(u===0&&n.includes(I)){l.push(v),v="";continue}v+=I}return l.push(v),l.map((S)=>S.trim()).filter(Boolean)}function _u(e){let n=0,r=null;for(let i=0;i<e.length;i++){let a=e[i];if(r){if(a==="\\"){i++;continue}if(a===r)r=null;continue}if(a==="'"||a==='"'||a==="`"){r=a;continue}if("([{".includes(a))n++;else if(")]}".includes(a))n--;if(n!==0||a!=="=")continue;let l=e[i-1];if(e[i+1]==="="||l==="="||l==="!"||l==="<"||l===">")continue;return i}return-1}function qo(e){switch(e.trim()){case"String":return"string";case"Number":return"number";case"Boolean":return"boolean";case"Array":return"unknown[]";case"Object":return"Record<string, unknown>";default:return}}function an(e){let n=yu(e);for(let r of new Set(Fn(n).map((i)=>i.start))){let i=wu(n,r);if(i)return{...i,text:e.slice(r,r+i.text.length)}}return null}function wu(e,n){let r=Object.create(null),i=Object.create(null),a=[],l=Object.create(null),u=Object.create(null),f=n+(/^(?:const|let|var)\s+/.exec(e.slice(n))?.[0].length??0),v=()=>{while(f<e.length&&/\s/.test(e[f]))f++},S;if(e[f]==="{"){let q=yt(e,f,"{","}");if(q===-1)return null;S=e.slice(f,q),f=q}else{let q=/^[A-Za-z_$][\w$]*/.exec(e.slice(f));if(!q)return null;S=q[0],f+=q[0].length}if(v(),e[f]!=="=")return null;f++,v();let I=/^withDefaults\s*\(\s*/.exec(e.slice(f)),j=Boolean(I);if(I)f+=I[0].length;let L=/^defineProps\b/.exec(e.slice(f));if(!L)return null;f+=L[0].length;let M="";if(v(),e[f]==="<"){let q=yt(e,f,"<",">");if(q===-1)return null;M=e.slice(f+1,q-1).trim(),f=q}if(v(),e[f]!=="(")return null;let V=yt(e,f,"(",")");if(V===-1)return null;let W=e.slice(f+1,V-1).trim();if(f=V,j){if(v(),e[f]===",")f++,v();if(e[f]==="{"){let q=yt(e,f,"{","}");if(q===-1)return null;for(let[G,U]of _s(e.slice(f,q)))i[G]=U;f=q}if(v(),e[f]===",")f++,v();if(e[f]===")")f++}if(e[f]===";")f++;let Z=/^[A-Za-z_$][\w$]*$/.test(M)?M:void 0;if(M.startsWith("{"))for(let q of pt(M.replace(/^\{/,"").replace(/\}$/,""),",;",!0)){let G=/^(?:readonly\s+)?([A-Za-z_$][\w$]*)\s*\??\s*:\s*([\s\S]+)$/.exec(q);if(G)r[G[1]]=G[2].trim()}if(W.startsWith("{"))for(let[q,G]of _s(W)){if(a.push(q),!G.startsWith("{")){let U=qo(G);if(U)r[q]=U;continue}for(let[U,H]of _s(G))if(U==="default")i[q]=H;else if(U==="type"){let re=qo(H);if(re)r[q]=re}}else if(W.startsWith("["))for(let q of pt(W.slice(1,-1),",",!1))a.push(q.replace(/^['"`]/,"").replace(/['"`]$/,""));if(S.startsWith("{")){a.length=0;for(let q of pt(S.replace(/^\{/,"").replace(/\}$/,""),",",!1)){let G=_u(q),U=G===-1?q:q.slice(0,G),H=U.split(":")[0].trim().replace(/^\.\.\./,"");if(!H)continue;a.push(H),l[H]=U.trim();let re=U.split(":").at(-1).trim();if(/^[A-Za-z_$][\w$]*$/.test(re))u[H]=re;if(G!==-1)i[H]=q.slice(G+1).trim()}}else if(a.length===0)a.push(...Object.keys(r));return{text:e.slice(n,f),propNames:a,propBindings:l,localBindings:u,defaults:i,declared:r,typeName:Z,identifier:S.startsWith("{")?void 0:S}}function _s(e){let n=e.trim().replace(/^\{/,"").replace(/\}$/,""),r=[],i=0;while(i<n.length){let a=/\s*([A-Za-z_$][\w$]*)\s*:/y;a.lastIndex=i;let l=a.exec(n);if(!l)break;i=a.lastIndex;let u=0,f="",v=i;while(i<n.length){let I=n[i];if(f){if(I==="\\")i++;else if(I===f)f=""}else if(I==="'"||I==='"'||I==="`")f=I;else if(I==="{"||I==="["||I==="(")u++;else if(I==="}"||I==="]"||I===")")u--;else if(I===","&&u===0)break;i++}let S=n.slice(v,i).trim();if(S)r.push([l[1],S]);i++}return r}function mr(e){let n=/^(?:(?:0|[1-9](?:_?\d)*)(?:\.(?:\d(?:_?\d)*)?)?|\.\d(?:_?\d)*)(?:[eE][+-]?\d(?:_?\d)*)?$/,r=/^(?:0[xX][\da-fA-F](?:_?[\da-fA-F])*|0[bB][01](?:_?[01])*|0[oO][0-7](?:_?[0-7])*)$/;if(!n.test(e)&&!r.test(e))throw Error("Invalid prop number");return Number(e.replaceAll("_",""))}function ws(e){let n=new be(e,"javascript").tokenize().filter((a)=>!["COMMENT","WHITESPACE","EOF"].includes(a.type)),r=0;function i(a){if(a>64)throw Error("Prop literal too deep");let l=n[r++];if(!l)throw Error("Missing prop literal");if(l.type==="STRING"||l.type==="TEMPLATE_STRING"){let I=bt(l.value);if(I===null)throw Error("Dynamic prop string");return I}if(l.type==="NUMBER")return mr(l.value);if(l.value==="-"||l.value==="+"){let I=n[r++];if(I?.type!=="NUMBER")throw Error("Dynamic prop number");return(l.value==="-"?-1:1)*mr(I.value)}if(l.value==="true")return!0;if(l.value==="false")return!1;if(l.value==="null")return null;if(l.value==="undefined")return;if(l.value!=="["&&l.value!=="{")throw Error("Dynamic prop default");let u=l.value==="[",f=u?"]":"}",v=[],S=[];while(n[r]?.value!==f){if(u)S.push(i(a+1));else{let I=n[r++];if(!I||!["STRING","IDENTIFIER","NUMBER"].includes(I.type))throw Error("Dynamic prop key");let j=I.type==="STRING"?bt(I.value):I.type==="NUMBER"?String(mr(I.value)):I.value;if(j===null||n[r++]?.value!==":")throw Error("Dynamic prop key");v.push([j,i(a+1)])}if(n[r]?.value!==",")break;r++}if(n[r++]?.value!==f)throw Error("Unclosed prop literal");return u?S:Object.fromEntries(v)}try{let a=i(0);return r===n.length?a:void 0}catch{return}}function vs(e,n){let r=t(e),i=h(r).depths,a=/\b(interface|type)\s+([A-Za-z_$][\w$]*)\b/g;for(let l of r.matchAll(a)){if(l[2]!==n||i[l.index]!==0)continue;let u=l.index+l[0].length,f=r.indexOf("{",u);if(l[1]==="interface"&&f>=0){let v=yt(r,f,"{","}");if(v>=0)return e.slice(f,v)}if(l[1]==="type"){let v=r.indexOf("=",u);if(v<0)continue;let S=e.slice(v+1).trimStart();if(S[0]==="{"){let I=yt(S,0,"{","}");if(I>=0)return S.slice(0,I)}}}}function Ss(e){let n=e.trim();return/^[A-Za-z_$][\w$]*$/.test(n)?n:bt(n)??void 0}function Zo(e){let n=pt(e.trim().slice(1,-1),",",!0);if(n.length!==1)return e.trim();let r=n[0];if(r.startsWith("..."))return e.trim();let i=/^(?:[A-Za-z_$][\w$]*)(\?)?\s*:\s*([\s\S]+)$/.exec(r),a=i?!!i[1]:r.endsWith("?"),l=i?i[2]:a?r.slice(0,-1).trim():r;return a?`(${l}) | undefined | []`:l}function Dn(e){let n=kn(e,["defineEmits"],!0);if(!n)return null;let r=Object.create(null),i=/^[A-Za-z_$][\w$]*$/.test(n.type.trim())?n.type.trim():void 0,a=i?vs(e,i):n.type.trim();if(a?.startsWith("{"))for(let l of pt(a.slice(1,-1),`;,
|
|
527
|
+
`,!0)){if(l.startsWith("(")){let j=yt(l,0,"(",")");if(j<0)continue;let L=pt(l.slice(1,j-1),",",!0),M=L.shift()||"",V=M.indexOf(":");if(V<0)continue;for(let W of pt(M.slice(V+1),"|",!0)){let Z=Ss(W);if(Z!==void 0)r[Z]={detailType:Zo(`[${L.join(", ")}]`)}}continue}let u=new be(l,"javascript").tokenize().filter((j)=>!["WHITESPACE","COMMENT","EOF"].includes(j.type)),f=u[0],v=u.findIndex((j)=>j.value===":");if(!f||v<0)continue;let S=Ss(f.value),I=l.slice(u[v].end).trim();if(S!==void 0)r[S]={detailType:I.startsWith("[")?Zo(I):I}}else{let l=n.args[0]?.trim()||"";if(l.startsWith("["))for(let u of pt(l.slice(1,-1),",",!1)){let f=Ss(u);if(f!==void 0)r[f]={detailType:"unknown"}}else if(l.startsWith("{"))for(let u of pt(l.slice(1,-1),",",!1)){let f=new be(u,"javascript").tokenize().find((S)=>!["WHITESPACE","COMMENT"].includes(S.type)),v=f&&Ss(f.value);if(v!==void 0)r[v]={detailType:"unknown"}}}return{...n,text:e.slice(n.start,n.end),typeName:i,events:r}}import{mkdir as Jo,readFile as vu,readdir as Su,realpath as $u,stat as Xo,writeFile as Eu}from"fs/promises";import st from"path";import{builtinModules as ku}from"module";function na(e){if(e==="connectedCallback")return`method "${e}" is reserved; define "onConnect" instead, which the element calls once it is connected, rendered and bound`;if(e==="disconnectedCallback")return`method "${e}" is reserved; define "onDisconnect" instead, which the element calls as it leaves the DOM, before it releases its own listeners`;return`method "${e}" is reserved`}var sa=new Set(["constructor","connectedCallback","disconnectedCallback","attributeChangedCallback","adoptedCallback"]),Cu=new Set(ku);function Ru(e){return e.replace(/\.stx$/i,"").split(/[^a-z0-9]+/i).filter(Boolean).map((n)=>n.charAt(0).toUpperCase()+n.slice(1)).join("")}function xr(e){return e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").replace(/[^a-z0-9]+/gi,"-").replace(/^-+|-+$/g,"").toLowerCase()}function Tu(e){return/^[a-z][.0-9_a-z-]*-[.0-9_a-z-]*$/.test(e)&&!e.startsWith("xml")&&!/[A-Z]/.test(e)}function Au(e){if(e===!0)return"open";if(e==="open"||e==="closed")return e;return!1}async function Iu(e){let n=[];async function r(i){let a=await Su(i,{withFileTypes:!0});a.sort((l,u)=>l.name.localeCompare(u.name));for(let l of a){let u=st.join(i,l.name);if(l.isDirectory()){if(!l.name.startsWith(".")&&l.name!=="node_modules")await r(u)}else if(l.isFile()&&l.name.endsWith(".stx")&&!/\.(?:test|spec)\.stx$/i.test(l.name))n.push(u)}}return await r(e),n}function Ht(e){return e.replace(/<!--[\s\S]*?-->|\{\{--[\s\S]*?--\}\}/g,(n)=>n.replace(/[^\n]/g," "))}function br(e){for(let n of ee(Ht(e))){let r=O(n.attrs);if(!r.has("component")&&!r.has("stx:component"))continue;return{code:e.slice(n.bodyStart,n.bodyEnd),start:n.bodyStart,open:n.start}}}function yr(e,n){let r=br(e);if(!r)return{};let i=r.code.trim();if(!i)return{};try{let a=JSON.parse(i);if(!a||typeof a!=="object"||Array.isArray(a))throw Error("expected a JSON object");return a}catch(a){throw Error(`${n}: <script component> must contain JSON metadata (${a.message})`)}}function $s(e,n){let r=t(e),i=new Set(Fn(e).map((v)=>v.start)),a=/(?:export\s+)?(?:async\s+)?function\s+([A-Za-z_$][\w$]*)/g,l=[],u=n?void 0:new Bun.Transpiler({loader:"ts"}),f;while(f=a.exec(r)){if(!i.has(f.index+f[0].indexOf("function")))continue;let v=a.lastIndex;while(/\s/.test(r[v]||""))v++;let S=v;if(r[v]==="<")v=yt(r,v,"<",">");if(v<0)continue;let I=e.slice(S,v).trim();while(/\s/.test(r[v]||""))v++;if(r[v]!=="(")continue;let j=v,L=yt(r,v,"(",")");if(L<0)continue;for(v=L;v<e.length;v++){let M=r[v];if(M!=="{"&&M!==";")continue;let V=e.slice(f.index,v).trim();if(n){if(!n(V,M,f[1]))continue}else{let Z;try{Z=u.transformSync(V+(M==="{"?"{}":";"))}catch{continue}if(M==="{"&&!Z.includes(`function ${f[1]}(`))continue;if(M===";"&&Z.trim())continue}let W=M==="{"?yt(r,v,"{","}"):v+1;if(W<0)break;l.push({name:f[1],header:V,generic:I,parameterOffset:j+1,parameters:e.slice(j+1,L-1),returns:e.slice(L,v).trim().replace(/^:\s*/,""),async:/\basync\s+function/.test(f[0]),...M==="{"?{source:e.slice(f.index,W)}:{}}),a.lastIndex=W;break}}return l}function Ou(e){let n=pt(e.parameters,",",!0).flatMap((r,i)=>{let a=t(r),l=0,u=-1;for(let W=0;W<a.length;W++){let Z=a[W];if("([{<".includes(Z))l++;else if(")]}>".includes(Z)&&!(Z===">"&&a[W-1]==="="))l--;if(Z==="="&&l===0&&a[W+1]!==">"){u=W;break}}let f=(u<0?r:r.slice(0,u)).trim(),v=pt(f,":",!0),S=v.shift().trim();if(S==="this")return[];let I=/^[A-Za-z_$]|^\.\.\./.test(S)?S:`argument${i}`,j=u<0?"":r.slice(u+1).trim(),L=j==="true"||j==="false"?"boolean":/^-?\d+(?:\.\d+)?$/.test(j)?"number":/^['"`]/.test(j)?"string":I.startsWith("...")?"unknown[]":"unknown",M=v.join(":").trim()||L,V=u>=0&&!I.endsWith("?")&&!I.startsWith("...")?"?":"";return[`${I}${V}: ${M}`]}).join(", ");return`${e.name}${e.generic}(${n}): ${e.returns||(e.async?"Promise<unknown>":"unknown")}`}function ju(e,n){let r={},i={},a=[],l=[],u=ee(Ht(e)).map((W)=>({code:e.slice(W.bodyStart,W.bodyEnd),attributes:O(W.attrs)})).filter(({attributes:W})=>!["src","server","component","stx:component"].some((Z)=>W.has(Z))&&$t(W)),f=u.map((W)=>W.code).join(`
|
|
528
|
+
`),v=an(f),S=Dn(f);for(let W of u){let{code:Z}=W;try{new Bun.Transpiler({loader:"ts"}).transformSync(Z)}catch(le){throw Error(`${n}: failed to transpile <script client> (${le.message})`)}let q=$s(Z),G=new Set(q.filter((le)=>!le.source).map((le)=>le.name));for(let le of q){if(sa.has(le.name))throw Error(`${n}: client ${na(le.name)}`);if(le.source)r[le.name]=`${le.name}(...args) { return this._callScopeMethod(${JSON.stringify(le.name)}, args); }`;if(!le.source||!G.has(le.name))(i[le.name]??=[]).push(Ou(le))}for(let le of Z.matchAll(/^\s*import\s+(?:type\s+)?([\s\S]*?)\s+from\s*(['"])([^'"]+)\2\s*;?/gm))l.push({binding:le[1].trim(),module:le[3]});let U=t(Z),H=h(U).depths,re=/(?:export\s+)?(interface|type)\s+[A-Za-z_$][\w$]*/g,ce;while(ce=re.exec(U)){if(H[ce.index]!==0)continue;let le=re.lastIndex,fe=0;for(;le<U.length;le++){let Be=U[le];if(Be==="{"){let it=yt(U,le,"{","}");if(it<0)break;if(le=it-1,ce[1]==="interface"&&fe===0){le++;break}continue}if("([<".includes(Be))fe++;else if(")]>".includes(Be)&&!(Be===">"&&U[le-1]==="="))fe--;if(ce[1]==="type"&&fe===0&&(Be===";"||Be===`
|
|
529
|
+
`)){if(Be===`
|
|
530
|
+
`&&/^[\s]*[|&]/.test(U.slice(le+1)))continue;try{new Bun.Transpiler({loader:"ts"}).transformSync(Z.slice(ce.index,le));break}catch{}}}let we=Z.slice(ce.index,le),Ee=ce.index,Re=/(?:interface|type)\s+([A-Za-z_$][\w$]*)/.exec(ce[0])?.[1],ve=u.map((Be)=>{let it=Be===W?Z.slice(0,Ee)+Z.slice(le):Be.code;return t(it.replace(an(Be.code)?.text??"\x00","").replace(Dn(Be.code)?.text??"\x00",""))}).join(`
|
|
531
|
+
`);if(!((v?.typeName===Re||S?.typeName===Re)&&!/^export\s/.test(we)&&Re&&!new RegExp(`\\b${Re}\\b`).test(ve)))a.push(we.replace(/^export\s+/,"").trim());re.lastIndex=le+1}}let I=Object.values(i).flat().join(`
|
|
532
|
+
`)+`
|
|
533
|
+
`+a.join(`
|
|
534
|
+
`)+`
|
|
535
|
+
`+Object.values(S?.events||{}).map((W)=>W.detailType).join(`
|
|
536
|
+
`),j=new be(I,"javascript").tokenize().filter((W)=>!["WHITESPACE","COMMENT"].includes(W.type)),L=new Set(j.filter((W,Z)=>{if(j[Z-1]?.value===".")return!1;let q=j[Z+1]?.value;return q!==":"&&!(q==="?"&&j[Z+2]?.value===":")}).map((W)=>W.value)),M=l.filter((W)=>(W.binding.match(/[A-Za-z_$][\w$]*/g)||[]).filter((Z)=>!["type","as"].includes(Z)).some((Z)=>L.has(Z)));for(let W of M)if(W.module.startsWith(".")||st.isAbsolute(W.module))throw Error(`${n}: public method types import ${JSON.stringify(W.module)} outside the generated package; declare these types in the component or import them from a published dependency`);let V=[...new Set(M.map((W)=>`import type ${W.binding.replace(/\btype\s+/g,"")} from ${JSON.stringify(W.module)}`))];return{methods:r,declarations:i,types:a.join(`
|
|
537
|
+
|
|
538
|
+
`),typeImports:V.join(`
|
|
539
|
+
`)}}function Pu(e){let n=e.match(/<template\b(?![^>]*\bshadowrootmode\b)[^>]*>([\s\S]*?)<\/template>/i);return(n?n[1]:e).replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,"").replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,"").trim()}function Go(e){return[...e.matchAll(/<style\b[^>]*>([\s\S]*?)<\/style>/gi)].map((n)=>n[1].replace(/\r\n?/g,`
|
|
540
|
+
`).replaceAll("\x00","\uFFFD").trim()).filter(Boolean).join(`
|
|
541
|
+
|
|
542
|
+
`)}function Mu(e){if(!e)return null;let n=e.replace(/\s*\|\s*(?:undefined|null)\b/g,"").trim();if(/^string$/.test(n))return"string";if(/^number$/.test(n))return"number";if(/^boolean$/.test(n))return"boolean";if(/^(?:'[^']*'|"[^"]*")(?:\s*\|\s*(?:'[^']*'|"[^"]*"))*$/.test(n))return"string";return"object"}function Du(e){if(e===void 0)return"object";if(e==="true"||e==="false")return"boolean";if(/^-?\d+(?:\.\d+)?$/.test(e))return"number";if(/^['"`]/.test(e))return"string";return"object"}function Ln(e,n){if(e[n]!=="(")return null;let r=0,i="";for(let a=n;a<e.length;a++){let l=e[a];if(i!==""){if(l==="\\")a++;else if(l===i)i="";continue}if(l==="'"||l==='"'||l==="`"){i=l;continue}if(l==="(")r++;else if(l===")"){if(r--,r===0)return{expression:e.slice(n+1,a),end:a+1}}}return null}function _r(e){let n=/^([\s\S]+?)\s+as\s+(?:([A-Za-z_$][\w$]*)\s*=>\s*)?([A-Za-z_$][\w$]*)$/.exec(e.trim());return n?{iterable:n[1],key:n[2],value:n[3]}:void 0}function Nu(e,n){let r=[],i=0,a=e.replace(/\{\{--[\s\S]*?--\}\}/g,""),l=/@(if|elseif|else|endif|foreach|endforeach)\s*/g,u,f=(v)=>{if(v==="")return;let S=0,I=/\{!!\s*([\s\S]*?)\s*!!\}|\{\{\s*([\s\S]*?)\s*\}\}|(data-stx-on-[\w:-]+=")(\d+)(")/g,j;while(j=I.exec(v)){if(j.index>S)r.push(`out += ${JSON.stringify(v.slice(S,j.index))};`);r.push(j[3]!==void 0?`out += ${JSON.stringify(j[3])} + (this._handlers.push(${n[Number(j[4])]}) - 1) + ${JSON.stringify(j[5])};`:j[1]!==void 0?`out += __raw(${j[1]});`:`out += __escape(${j[2]});`),S=j.index+j[0].length}if(S<v.length)r.push(`out += ${JSON.stringify(v.slice(S))};`)};while(u=l.exec(a)){f(a.slice(i,u.index)),i=u.index+u[0].length;let S=u[1]==="if"||u[1]==="elseif"||u[1]==="foreach"?Ln(a,i):null;if(S)i=S.end,l.lastIndex=S.end;let I=S?.expression;switch(u[1]){case"if":r.push(`if (${I}) {`);break;case"elseif":r.push(`} else if (${I}) {`);break;case"else":r.push("} else {");break;case"endif":case"endforeach":r.push("}");break;case"foreach":{let j=_r(I||"");if(!j){r.push(`out += ${JSON.stringify(u[0]+(S?`(${I})`:""))};`);break}let{iterable:L,key:M,value:V}=j;r.push(M?`for (const [${M}, ${V}] of __entries(${L})) {`:`for (const ${V} of __values(${L})) {`);break}}}return f(a.slice(i)),r.join(`
|
|
543
|
+
`)}function ra(e){let n=t(e),r=h(n).depths,i=[],a=[];for(let u of n.matchAll(/\bimport\b/g)){let f=u.index;if(r[f]!==0)continue;let v=new be(e.slice(f)).tokenize().filter((V)=>!["COMMENT","WHITESPACE"].includes(V.type));if(v[1]?.value==="("||v[1]?.value===".")continue;let S=v[1]?.type==="STRING"?1:-1,I=0;for(let V=1;S===-1&&V<v.length;V++){let W=v[V];if(W.value===";"||W.type==="EOF")break;if(W.value==="{")I++;else if(W.value==="}")I--;else if(I===0&&W.value==="from"&&v[V+1]?.type==="STRING")S=V+1}if(S===-1)continue;let j=v[S],L=S;if(v[L+1]?.value==="with"&&v[L+2]?.value==="{"){L+=2;let V=1;while(V&&v[L+1]?.type!=="EOF")if(L++,v[L]?.value==="{")V++;else if(v[L]?.value==="}")V--}if(v[L+1]?.value===";")L++;let M=f+v[L].end;if(a.push({start:f,end:M}),!["stx","@stacksjs/stx"].includes(j.value.slice(1,-1)))i.push(e.slice(f,M))}let l=e;for(let u of a.reverse())l=l.slice(0,u.start)+l.slice(u.end);return{imports:i,body:l}}function Lu(e){let r=ee(Ht(e)).filter((q)=>{let G=O(q.attrs);return $t(G)&&!["component","stx:component","server","src"].some((U)=>G.has(U))});if(!r.length)return{imports:[],body:"",propNames:[],propBindings:{},defaults:{},declared:{},apis:[]};let i=r.map((q)=>e.slice(q.bodyStart,q.bodyEnd)).join(`
|
|
544
|
+
`),a=[],l=[],u=Object.create(null),f=Object.create(null),v=Object.create(null),S=ra(i);a.push(...S.imports),i=S.body;let I=an(i);if(I)l.push(...I.propNames),Object.assign(u,I.propBindings),Object.assign(f,I.defaults),Object.assign(v,I.declared),i=i.replace(I.text,I.identifier?`const ${I.identifier} = this._props();`:"");if(I?.typeName){let q=vs(i,I.typeName);if(q)for(let G of pt(q.slice(1,-1),`;,
|
|
545
|
+
`,!0)){let U=/^(?:readonly\s+)?([A-Za-z_$][\w$]*)\??\s*:\s*([\s\S]+)$/.exec(G);if(!U)continue;if(v[U[1]]=U[2].trim(),!l.includes(U[1]))l.push(U[1])}}let j=Dn(i);if(j)i=i.replace(j.text,"this._emitScope.bind(this)");let L=t(i),M=h(L).depths;for(let q of[...L.matchAll(/\bexport\s+(?=(?:interface|type|const|let|var|async|function)\b)/g)].reverse())if(M[q.index]===0)i=i.slice(0,q.index)+" ".repeat(q[0].length)+i.slice(q.index+q[0].length);let V=new Set(Fn(i).map((q)=>q.name)),W=t(i),Z=["state","derived","effect","batch","onMount","onDestroy"].filter((q)=>!V.has(q)&&new RegExp(`\\b${q}\\s*(?:<|\\()`).test(W));return{imports:a,body:i.trim(),propNames:l,propBindings:u,defaults:f,declared:v,apis:Z}}function zu(e){let n=new Set,r=[];return{template:e.replace(/\s@([a-z][\w:-]*)(\.[\w.-]+)?\s*=\s*(["'])([\s\S]*?)\3/gi,(a,l,u,f,v)=>{let S=l.toLowerCase();n.add(S);let I=(u||"").split(".").filter(Boolean).join(" "),j=r.length;return r.push(/^[A-Za-z_$][\w$]*$/.test(v.trim())?`($event) => (typeof ${v} === 'function' ? ${v} : this[${JSON.stringify(v.trim())}]).call(this, $event)`:`($event) => { ${v} }`),` data-stx-on-${S}="${j}"${I?` data-stx-mod-${S}="${I}"`:""}`}),eventTypes:[...n].sort(),handlers:r}}function Bu(e){let n=[];return{template:e.replace(/\s:([a-z][\w:-]*)\s*=\s*(["'])([\w$.]+)\2/gi,(i,a,l,u)=>{let f=n.length;return n.push({id:f,name:a,expression:u}),` data-stx-bind-${f}=""`}),bindings:n}}function Wu(e){let n=new Set;for(let r of e.matchAll(/<slot\b([^>]*)>/gi))n.add(r[1].match(/\bname\s*=\s*["']([^"']+)["']/i)?.[1]||"");return[...n].map((r)=>({name:r}))}function Fu(e){return[...new Set([...e.matchAll(/(--[a-z0-9_-]+)\s*:/gi)].map((n)=>n[1]))].sort().map((n)=>({name:n}))}function Yo(e,n){if(!n||!new Set(["string","number","boolean","object","array"]).has(n.type))throw Error(`Property "${e}" must declare one of: string, number, boolean, object, array`);return{...n,reflect:n.reflect??n.attribute!==!1}}async function Vu(e,n,r){let i=st.isAbsolute(n.file)?n.file:st.resolve(e,n.file),a=await vu(i,"utf8"),l=yr(a,i),u=st.basename(i,".stx"),f=n.name||l.name||Ru(u),v=`${xr(r.prefix||"stx")}-${xr(u)}`,S=n.tag||l.tag||v;if(!f||!/^[A-Za-z_$][\w$]*$/.test(f))throw Error(`${i}: invalid component class name "${f}"`);if(!Tu(S))throw Error(`${i}: invalid custom-element tag "${S}"; tags must be lowercase and contain a hyphen`);let I=n.properties||l.properties||l.props||{},j=Object.fromEntries(Object.entries(I).map(([U,H])=>[U,Yo(U,H)])),L=zu(Pu(a)),M=Bu(L.template),V=Lu(a);for(let U of ee(Ht(a))){let H=O(U.attrs);if(!H.has("client")||["server","component","stx:component","src"].some((re)=>H.has(re))||!$t(H))continue;V.imports.push(...ra(a.slice(U.bodyStart,U.bodyEnd)).imports)}V.imports=[...new Set(V.imports)];let W=Nu(M.template,L.handlers);for(let U of V.propNames){if(j[U])continue;let H=V.defaults[U];j[U]=Yo(U,{type:Mu(V.declared[U])??Du(H),...H===void 0?{}:{default:ws(H)}})}let Z=l.methods||{},q=n.methods||{},G=ju(a,i);return{file:st.relative(e,i),sourcePath:i,name:f,tag:S,description:n.description||l.description||"",template:M.template,styles:Go(a),shadowMode:Au(n.shadowDOM??l.shadowDOM??r.shadowDOM),progressive:n.progressive??l.progressive??r.progressive??!0,properties:j,events:{...Dn(ee(Ht(a)).filter((U)=>{let H=O(U.attrs);return $t(H)&&!["server","component","stx:component","src"].some((re)=>H.has(re))}).map((U)=>a.slice(U.bodyStart,U.bodyEnd)).join(`
|
|
546
|
+
`))?.events||{},...n.events||l.events||{}},methods:{...Z,...q,...G.methods},methodDeclarations:G.declarations,declarationTypes:G.types,declarationImports:G.typeImports,eventTypes:L.eventTypes,handlers:L.handlers,scopeMethods:Object.keys(G.methods),bindings:M.bindings,slots:Wu(M.template),cssProperties:Fu(Go(a)),scope:V,render:W}}function Uu(e=!1){let n=JSON.stringify("\\{!!\\s*([\\w$.]+)\\s*!!\\}"),r=JSON.stringify("\\{\\{\\s*([\\w$.]+)\\s*\\}\\}");return`${e?`import { state as nativeState, derived as nativeDerived, effect as nativeEffect, batch as nativeBatch } from './signals.js';
|
|
547
|
+
`:""}const HTMLElementBase = globalThis.HTMLElement || class {};
|
|
548
|
+
|
|
549
|
+
const escapeHTML = (value) => String(value ?? '')
|
|
550
|
+
.replaceAll('&', '&').replaceAll('<', '<').replaceAll('>', '>')
|
|
551
|
+
.replaceAll('"', '"').replaceAll("'", ''');
|
|
552
|
+
|
|
553
|
+
const valueAt = (host, path) => {
|
|
554
|
+
const parts = path.trim().split('.');
|
|
555
|
+
if (parts[0] === 'this') parts.shift();
|
|
556
|
+
if (!parts.length) return host;
|
|
557
|
+
const first = parts.shift();
|
|
558
|
+
// Render bindings read declared props, including attributes whose names
|
|
559
|
+
// also belong to the native DOM API. The public element keeps that API.
|
|
560
|
+
let value = host._values && Object.prototype.hasOwnProperty.call(host._values, first)
|
|
561
|
+
? host._values[first]
|
|
562
|
+
: host[first];
|
|
563
|
+
for (const part of parts) value = value?.[part];
|
|
564
|
+
return typeof value === 'function' ? value.call(host) : value;
|
|
565
|
+
};
|
|
566
|
+
|
|
567
|
+
const deserialize = (value, type, fallback) => {
|
|
568
|
+
if (value === null) return type === 'boolean' ? false : fallback;
|
|
569
|
+
if (type === 'boolean') return value !== 'false' && value !== '0';
|
|
570
|
+
if (type === 'number') return Number(value);
|
|
571
|
+
if (type === 'object' || type === 'array') {
|
|
572
|
+
try { return JSON.parse(value); }
|
|
573
|
+
catch { return fallback; }
|
|
574
|
+
}
|
|
575
|
+
return value;
|
|
576
|
+
};
|
|
577
|
+
|
|
578
|
+
const serialize = (value, type) => {
|
|
579
|
+
if (value == null || value === false) return null;
|
|
580
|
+
if (type === 'boolean') return '';
|
|
581
|
+
if (type === 'object' || type === 'array') return JSON.stringify(value);
|
|
582
|
+
return String(value);
|
|
583
|
+
};
|
|
584
|
+
|
|
585
|
+
const cloneDefault = (value, type) => {
|
|
586
|
+
if (value == null || (type !== 'object' && type !== 'array')) return value;
|
|
587
|
+
if (typeof structuredClone === 'function') return structuredClone(value);
|
|
588
|
+
return JSON.parse(JSON.stringify(value));
|
|
589
|
+
};
|
|
590
|
+
|
|
591
|
+
const defaultFor = property => cloneDefault(
|
|
592
|
+
property.default ?? ({ string: '', number: 0, boolean: false, object: {}, array: [] })[property.type],
|
|
593
|
+
property.type,
|
|
594
|
+
);
|
|
595
|
+
|
|
596
|
+
export class StxElement extends HTMLElementBase {
|
|
597
|
+
static definition = {};
|
|
598
|
+
static get observedAttributes() { return this.definition.observedAttributes || []; }
|
|
599
|
+
|
|
600
|
+
constructor() {
|
|
601
|
+
super();
|
|
602
|
+
this._values = Object.create(null);
|
|
603
|
+
this._reflecting = false;
|
|
604
|
+
this._connected = false;
|
|
605
|
+
this._hasConnected = false;
|
|
606
|
+
this._initializing = false;
|
|
607
|
+
this._updatePending = false;
|
|
608
|
+
this._listeners = new Map();
|
|
609
|
+
this._scopeStates = [];
|
|
610
|
+
this._scopeDerived = [];
|
|
611
|
+
this._scopeEffects = [];
|
|
612
|
+
this._scopeSubscriptions = [];
|
|
613
|
+
this._scopeMounts = [];
|
|
614
|
+
this._scopeDestroys = [];
|
|
615
|
+
this._scopeConnectionDestroys = [];
|
|
616
|
+
this._scopeMountCleanups = [];
|
|
617
|
+
const definition = this.constructor.definition;
|
|
618
|
+
for (const [name, property] of Object.entries(definition.properties || {})) {
|
|
619
|
+
this._values[name] = defaultFor(property);
|
|
620
|
+
}
|
|
621
|
+
if (definition.shadowMode && this.attachShadow && !this.shadowRoot) {
|
|
622
|
+
this._closedRoot = this.attachShadow({ mode: definition.shadowMode });
|
|
623
|
+
}
|
|
624
|
+
}
|
|
625
|
+
|
|
626
|
+
get updateComplete() { return this._updateComplete || Promise.resolve(); }
|
|
627
|
+
get renderRoot() { return this._closedRoot || this.shadowRoot || this; }
|
|
628
|
+
|
|
629
|
+
connectedCallback() {
|
|
630
|
+
if (this._connected) return;
|
|
631
|
+
this._connected = true;
|
|
632
|
+
this._initializing = true;
|
|
633
|
+
const definition = this.constructor.definition;
|
|
634
|
+
for (const [name, property] of Object.entries(definition.properties || {})) {
|
|
635
|
+
const attribute = property.attribute === false ? null : (property.attribute || name.replace(/[A-Z]/g, letter => '-' + letter.toLowerCase()));
|
|
636
|
+
if (attribute && this.hasAttribute?.(attribute)) this._values[name] = deserialize(this.getAttribute(attribute), property.type, defaultFor(property));
|
|
637
|
+
}
|
|
638
|
+
// Properties assigned before customElements.define() become own properties.
|
|
639
|
+
// Upgrade them after attributes so imperative state wins, matching the
|
|
640
|
+
// platform's property-first custom-element initialization convention.
|
|
641
|
+
for (const name of Object.keys(definition.properties || {})) this._upgradeProperty(name);
|
|
642
|
+
this._initializing = false;
|
|
643
|
+
const root = this.renderRoot;
|
|
644
|
+
const hasMarkup = [...(root.childNodes || [])].some(node => node.nodeType !== 3 || node.textContent.trim());
|
|
645
|
+
const firstConnection = !this._hasConnected;
|
|
646
|
+
if (!(firstConnection && definition.progressive && hasMarkup)) this._render();
|
|
647
|
+
else {
|
|
648
|
+
if (typeof this.render === 'function') this.render(RENDER_HELPERS);
|
|
649
|
+
this._upgradeDeclarativeEvents();
|
|
650
|
+
}
|
|
651
|
+
this._bindEvents();
|
|
652
|
+
if (firstConnection) {
|
|
653
|
+
this._hasConnected = true;
|
|
654
|
+
this.setAttribute?.('hydrated', '');
|
|
655
|
+
this.dispatchEvent?.(new CustomEvent('stx:hydrated', { bubbles: true, composed: true }));
|
|
656
|
+
}
|
|
657
|
+
// Called last, so a component that acquires something sees its own rendered
|
|
658
|
+
// markup and its events already bound. Reported rather than rethrown: a
|
|
659
|
+
// component that fails to set up must not take the element down with it.
|
|
660
|
+
this._runScopeMounts();
|
|
661
|
+
try { this.onConnect?.(); }
|
|
662
|
+
catch (error) { console.error('[stx] onConnect failed', error); }
|
|
663
|
+
}
|
|
664
|
+
|
|
665
|
+
disconnectedCallback() {
|
|
666
|
+
this._connected = false;
|
|
667
|
+
// Called before the framework releases anything, so the element is still
|
|
668
|
+
// intact for a component that needs to read it on the way out, and inside
|
|
669
|
+
// try/finally so a throwing hook cannot leak the framework's own listeners.
|
|
670
|
+
try { this.onDisconnect?.(); }
|
|
671
|
+
catch (error) { console.error('[stx] onDisconnect failed', error); }
|
|
672
|
+
finally {
|
|
673
|
+
this._disposeScopeEffects();
|
|
674
|
+
for (const dispose of this._scopeSubscriptions.splice(0)) {
|
|
675
|
+
try { dispose?.(); } catch (error) { console.error('[stx] scope subscription cleanup failed', error); }
|
|
676
|
+
}
|
|
677
|
+
for (const cleanup of [...this._scopeDestroys.splice(0), ...this._scopeConnectionDestroys.splice(0), ...this._scopeMountCleanups.splice(0)]) {
|
|
678
|
+
try { cleanup(); } catch (error) { console.error('[stx] scope cleanup failed', error); }
|
|
679
|
+
}
|
|
680
|
+
for (const [event, listener] of this._listeners) this.renderRoot.removeEventListener(event, listener);
|
|
681
|
+
this._listeners.clear();
|
|
682
|
+
}
|
|
683
|
+
}
|
|
684
|
+
|
|
685
|
+
attributeChangedCallback(attribute, oldValue, newValue) {
|
|
686
|
+
if (oldValue === newValue || this._reflecting) return;
|
|
687
|
+
const definition = this.constructor.definition;
|
|
688
|
+
const name = definition.attributeToProperty?.[attribute];
|
|
689
|
+
if (!name) return;
|
|
690
|
+
const property = definition.properties[name];
|
|
691
|
+
const value = deserialize(newValue, property.type, defaultFor(property));
|
|
692
|
+
if (!Object.is(this._values[name], value)) {
|
|
693
|
+
this._values[name] = value;
|
|
694
|
+
this.requestUpdate();
|
|
695
|
+
}
|
|
696
|
+
}
|
|
697
|
+
|
|
698
|
+
/**
|
|
699
|
+
* The props a compiled render reads.
|
|
700
|
+
*
|
|
701
|
+
* Its own method rather than _values directly, so a component that sets a
|
|
702
|
+
* property before upgrade still sees it, and so the generated code has one
|
|
703
|
+
* name to depend on rather than a private field's shape.
|
|
704
|
+
*/
|
|
705
|
+
_props() {
|
|
706
|
+
return this._values;
|
|
707
|
+
}
|
|
708
|
+
|
|
709
|
+
requestUpdate() {
|
|
710
|
+
if (!this._connected || this._initializing || this._updatePending) return this.updateComplete;
|
|
711
|
+
this._updatePending = true;
|
|
712
|
+
this._updateComplete = new Promise((resolve) => {
|
|
713
|
+
queueMicrotask(() => {
|
|
714
|
+
this._updatePending = false;
|
|
715
|
+
if (this._connected) this._render();
|
|
716
|
+
resolve();
|
|
717
|
+
});
|
|
718
|
+
});
|
|
719
|
+
return this._updateComplete;
|
|
720
|
+
}
|
|
721
|
+
|
|
722
|
+
emit(name, detail, options = {}) {
|
|
723
|
+
return this.dispatchEvent(new CustomEvent(name, {
|
|
724
|
+
detail, bubbles: true, composed: true, ...options,
|
|
725
|
+
}));
|
|
726
|
+
}
|
|
727
|
+
|
|
728
|
+
_disposeScopeEffects() {
|
|
729
|
+
for (const dispose of this._scopeEffects.splice(0)) {
|
|
730
|
+
try { dispose(); } catch (error) { console.error('[stx] effect cleanup failed', error); }
|
|
731
|
+
}
|
|
732
|
+
}
|
|
733
|
+
|
|
734
|
+
_runScopeMounts() {
|
|
735
|
+
for (const mount of this._scopeMounts) {
|
|
736
|
+
try { const cleanup = mount(); if (typeof cleanup === 'function') this._scopeMountCleanups.push(cleanup); }
|
|
737
|
+
catch (error) { console.error('[stx] onMount failed', error); }
|
|
738
|
+
}
|
|
739
|
+
}
|
|
740
|
+
|
|
741
|
+
${e?` _beginScope() {
|
|
742
|
+
this._disposeScopeEffects();
|
|
743
|
+
this._scopeMounts = [];
|
|
744
|
+
this._scopeDestroys = [];
|
|
745
|
+
let stateIndex = 0, derivedIndex = 0;
|
|
746
|
+
let rendering = true;
|
|
747
|
+
return {
|
|
748
|
+
finish: () => { rendering = false; },
|
|
749
|
+
state: (initial) => {
|
|
750
|
+
const index = stateIndex++;
|
|
751
|
+
const value = this._scopeStates[index] ||= nativeState(initial);
|
|
752
|
+
if (this._connected && !this._scopeSubscriptions[index]) this._scopeSubscriptions[index] = value.subscribe(() => this.requestUpdate());
|
|
753
|
+
return value;
|
|
754
|
+
},
|
|
755
|
+
derived: (compute, options) => {
|
|
756
|
+
const index = derivedIndex++;
|
|
757
|
+
let entry = this._scopeDerived[index];
|
|
758
|
+
if (!entry) {
|
|
759
|
+
entry = { compute, revision: nativeState(0) };
|
|
760
|
+
entry.value = nativeDerived(() => { entry.revision(); return entry.compute(); }, options);
|
|
761
|
+
this._scopeDerived[index] = entry;
|
|
762
|
+
} else {
|
|
763
|
+
entry.compute = compute;
|
|
764
|
+
entry.revision.update(value => value + 1);
|
|
765
|
+
}
|
|
766
|
+
return entry.value;
|
|
767
|
+
},
|
|
768
|
+
effect: (callback, options) => {
|
|
769
|
+
const dispose = nativeEffect(callback, options);
|
|
770
|
+
this._scopeEffects.push(dispose);
|
|
771
|
+
return dispose;
|
|
772
|
+
},
|
|
773
|
+
batch: nativeBatch,
|
|
774
|
+
onMount: callback => this._scopeMounts.push(callback),
|
|
775
|
+
onDestroy: callback => (rendering ? this._scopeDestroys : this._scopeConnectionDestroys).push(callback),
|
|
776
|
+
};
|
|
777
|
+
}
|
|
778
|
+
|
|
779
|
+
`:""} _emitScope(name, ...args) {
|
|
780
|
+
return this.emit(name, args.length === 1 ? args[0] : args, { cancelable: true });
|
|
781
|
+
}
|
|
782
|
+
|
|
783
|
+
_callScopeMethod(name, args) {
|
|
784
|
+
if (!this._scopeMethods || this._updatePending) this.render(RENDER_HELPERS);
|
|
785
|
+
return this._scopeMethods[name].apply(this, args);
|
|
786
|
+
}
|
|
787
|
+
|
|
788
|
+
_upgradeProperty(name) {
|
|
789
|
+
if (!Object.prototype.hasOwnProperty.call(this, name)) return;
|
|
790
|
+
const value = this[name];
|
|
791
|
+
delete this[name];
|
|
792
|
+
this[name] = value;
|
|
793
|
+
}
|
|
794
|
+
|
|
795
|
+
_upgradeDeclarativeEvents() {
|
|
796
|
+
for (const element of this.renderRoot.querySelectorAll?.('*') || []) {
|
|
797
|
+
const names = element.getAttributeNames?.() || [...(element.attributes || [])].filter(Boolean).map(attribute => attribute.name);
|
|
798
|
+
for (const attributeName of names) {
|
|
799
|
+
if (!attributeName?.startsWith('@')) continue;
|
|
800
|
+
const [event, ...modifiers] = attributeName.slice(1).split('.');
|
|
801
|
+
element.setAttribute('data-stx-on-' + event, element.getAttribute(attributeName));
|
|
802
|
+
if (modifiers.length) element.setAttribute('data-stx-mod-' + event, modifiers.join(' '));
|
|
803
|
+
element.removeAttribute(attributeName);
|
|
804
|
+
}
|
|
805
|
+
}
|
|
806
|
+
}
|
|
807
|
+
|
|
808
|
+
_bindEvents() {
|
|
809
|
+
for (const event of this.constructor.definition.eventTypes || []) {
|
|
810
|
+
if (this._listeners.has(event)) continue;
|
|
811
|
+
const listener = ($event) => {
|
|
812
|
+
const selector = '[data-stx-on-' + event + ']';
|
|
813
|
+
const target = $event.target?.closest?.(selector);
|
|
814
|
+
if (!target || !this.renderRoot.contains(target)) return;
|
|
815
|
+
const modifiers = (target.getAttribute('data-stx-mod-' + event) || '').split(' ');
|
|
816
|
+
if (modifiers.includes('self') && target !== $event.target) return;
|
|
817
|
+
if (modifiers.includes('prevent')) $event.preventDefault();
|
|
818
|
+
if (modifiers.includes('stop')) $event.stopPropagation();
|
|
819
|
+
const method = target.getAttribute('data-stx-on-' + event);
|
|
820
|
+
if (this._handlers?.[method]) this._handlers[method]($event);
|
|
821
|
+
else if (typeof this[method] === 'function') this[method]($event);
|
|
822
|
+
};
|
|
823
|
+
this.renderRoot.addEventListener(event, listener);
|
|
824
|
+
this._listeners.set(event, listener);
|
|
825
|
+
}
|
|
826
|
+
}
|
|
827
|
+
|
|
828
|
+
_render() {
|
|
829
|
+
const definition = this.constructor.definition;
|
|
830
|
+
const root = this.renderRoot;
|
|
831
|
+
const active = root.activeElement || (root.contains?.(globalThis.document?.activeElement) ? globalThis.document.activeElement : null);
|
|
832
|
+
const focusAttribute = active?.getAttribute?.('data-key') ? 'data-key' : active?.id ? 'id' : 'name';
|
|
833
|
+
const focusKey = active?.getAttribute?.(focusAttribute);
|
|
834
|
+
const focusValue = focusAttribute === 'name' && active?.type === 'radio' ? active.value : null;
|
|
835
|
+
const selectionStart = active?.selectionStart, selectionEnd = active?.selectionEnd;
|
|
836
|
+
const selection = Number.isInteger(selectionStart) && Number.isInteger(selectionEnd)
|
|
837
|
+
? [selectionStart, selectionEnd, active.selectionDirection] : null;
|
|
838
|
+
// A compiled component renders itself: the control flow and the derived
|
|
839
|
+
// values were turned into JavaScript at build time, so there is nothing to
|
|
840
|
+
// interpret here and nothing that needs an eval the page's CSP forbids.
|
|
841
|
+
// The string template remains for components that carry no logic.
|
|
842
|
+
let html = typeof this.render === 'function'
|
|
843
|
+
? this.render(RENDER_HELPERS)
|
|
844
|
+
: definition.template
|
|
845
|
+
.replace(new RegExp(${n}, 'g'), (_match, expression) => String(valueAt(this, expression) ?? ''))
|
|
846
|
+
.replace(new RegExp(${r}, 'g'), (_match, expression) => escapeHTML(valueAt(this, expression)));
|
|
847
|
+
if (definition.shadowMode && definition.styles) html = '<style>' + definition.styles + '</style>' + html;
|
|
848
|
+
root.innerHTML = html;
|
|
849
|
+
this._applyBindings();
|
|
850
|
+
this._bindEvents();
|
|
851
|
+
if (focusKey) {
|
|
852
|
+
const escaped = globalThis.CSS?.escape ? globalThis.CSS.escape(focusKey) : focusKey.replace(/["\\\\]/g, '\\$&');
|
|
853
|
+
const selector = '[' + focusAttribute + '="' + escaped + '"]';
|
|
854
|
+
// Name-only radio groups share a name, but their chosen member must stay focused.
|
|
855
|
+
const next = focusValue === null ? root.querySelector(selector)
|
|
856
|
+
: [...root.querySelectorAll(selector)].find(element => element.type === 'radio' && element.value === focusValue);
|
|
857
|
+
next?.focus?.();
|
|
858
|
+
// Several input types expose this method but reject text selection. A
|
|
859
|
+
// rerender can also change a text input into one of those types.
|
|
860
|
+
if (selection && Number.isInteger(next?.selectionStart) && Number.isInteger(next?.selectionEnd) && typeof next?.setSelectionRange === 'function')
|
|
861
|
+
next.setSelectionRange(selection[0], selection[1], selection[2] || 'none');
|
|
862
|
+
}
|
|
863
|
+
this.dispatchEvent?.(new CustomEvent('stx:updated', { bubbles: false }));
|
|
864
|
+
}
|
|
865
|
+
|
|
866
|
+
_applyBindings() {
|
|
867
|
+
for (const binding of this.constructor.definition.bindings || []) {
|
|
868
|
+
const element = this.renderRoot.querySelector('[data-stx-bind-' + binding.id + ']');
|
|
869
|
+
if (!element) continue;
|
|
870
|
+
const value = valueAt(this, binding.expression);
|
|
871
|
+
if (binding.name === 'class') element.className = value || '';
|
|
872
|
+
else if (binding.name === 'style' && typeof value === 'object') {
|
|
873
|
+
Object.assign(element.style, value);
|
|
874
|
+
}
|
|
875
|
+
else if (typeof value === 'boolean') {
|
|
876
|
+
element.toggleAttribute(binding.name, value);
|
|
877
|
+
if (binding.name in element) element[binding.name] = value;
|
|
878
|
+
}
|
|
879
|
+
else if (value == null || value === false) element.removeAttribute(binding.name);
|
|
880
|
+
else element.setAttribute(binding.name, String(value));
|
|
881
|
+
}
|
|
882
|
+
}
|
|
883
|
+
}
|
|
884
|
+
|
|
885
|
+
/**
|
|
886
|
+
* What a compiled render is handed.
|
|
887
|
+
*
|
|
888
|
+
* Passed in rather than closed over so the generated code names no globals, and
|
|
889
|
+
* a component module stays readable on its own: __escape is visibly a
|
|
890
|
+
* parameter, not something the bundler happened to leave in scope.
|
|
891
|
+
*/
|
|
892
|
+
const RENDER_HELPERS = {
|
|
893
|
+
escape: escapeHTML,
|
|
894
|
+
// The raw form is the author declaring the value is markup. Null becomes an
|
|
895
|
+
// empty string rather than the word "null", which is the only sensible
|
|
896
|
+
// reading of a missing fragment.
|
|
897
|
+
raw: (value) => String(value ?? ''),
|
|
898
|
+
// A loop over something absent runs zero times. Throwing here would fail a
|
|
899
|
+
// whole page over one empty list, which is never what the author meant.
|
|
900
|
+
values: (value) => value == null ? [] : (value[Symbol.iterator] ? value : Object.values(value)),
|
|
901
|
+
entries: (value) => value == null ? [] : (Array.isArray(value) ? value.entries() : Object.entries(value)),
|
|
902
|
+
};
|
|
903
|
+
|
|
904
|
+
export function defineComponent(Component, definition) {
|
|
905
|
+
const properties = definition.properties || {};
|
|
906
|
+
const attributeToProperty = {};
|
|
907
|
+
const observedAttributes = [];
|
|
908
|
+
for (const [name, property] of Object.entries(properties)) {
|
|
909
|
+
const attribute = property.attribute === false ? null : (property.attribute || name.replace(/[A-Z]/g, letter => '-' + letter.toLowerCase()));
|
|
910
|
+
if (attribute) {
|
|
911
|
+
attributeToProperty[attribute] = name;
|
|
912
|
+
observedAttributes.push(attribute);
|
|
913
|
+
}
|
|
914
|
+
// A style prop is an attribute value, not a replacement for the browser's
|
|
915
|
+
// CSSStyleDeclaration. Native event handler accessors must survive too.
|
|
916
|
+
if (name in HTMLElementBase.prototype) {
|
|
917
|
+
if (!attribute) throw new TypeError('STX prop "' + name + '" overlaps the native DOM API and needs an attribute binding');
|
|
918
|
+
continue;
|
|
919
|
+
}
|
|
920
|
+
Object.defineProperty(Component.prototype, name, {
|
|
921
|
+
configurable: true,
|
|
922
|
+
enumerable: true,
|
|
923
|
+
get() { return this._values[name]; },
|
|
924
|
+
set(value) {
|
|
925
|
+
const oldValue = this._values[name];
|
|
926
|
+
if (Object.is(oldValue, value)) return;
|
|
927
|
+
this._values[name] = value;
|
|
928
|
+
if (property.reflect && attribute && !this._reflecting) {
|
|
929
|
+
const serialized = serialize(value, property.type);
|
|
930
|
+
this._reflecting = true;
|
|
931
|
+
if (serialized === null) this.removeAttribute(attribute);
|
|
932
|
+
else this.setAttribute(attribute, serialized);
|
|
933
|
+
this._reflecting = false;
|
|
934
|
+
}
|
|
935
|
+
this.requestUpdate();
|
|
936
|
+
this.dispatchEvent?.(new CustomEvent(name + '-changed', {
|
|
937
|
+
detail: { value, oldValue }, bubbles: true, composed: true,
|
|
938
|
+
}));
|
|
939
|
+
},
|
|
940
|
+
});
|
|
941
|
+
}
|
|
942
|
+
Component.definition = { ...definition, attributeToProperty, observedAttributes };
|
|
943
|
+
const registry = globalThis.customElements || globalThis.window?.customElements;
|
|
944
|
+
if (registry && !registry.get(definition.tag)) {
|
|
945
|
+
registry.define(definition.tag, Component);
|
|
946
|
+
}
|
|
947
|
+
return Component;
|
|
948
|
+
}
|
|
949
|
+
`}function hr(e,n="./runtime.js"){let r=JSON.stringify({tag:e.tag,template:e.template,styles:e.styles,shadowMode:e.shadowMode,progressive:e.progressive,properties:e.properties,eventTypes:e.eventTypes,bindings:e.bindings},null,2),i=Object.entries(e.methods).map(([I,j])=>{if(sa.has(I))throw Error(`${e.sourcePath}: ${na(I)}`);if(/^(?:async\s+)?[A-Za-z_$][\w$]*\s*\(/.test(j.trim()))return` ${j.trim()}`;return` ${I}($event) {
|
|
950
|
+
${j}
|
|
951
|
+
}`}).join(`
|
|
952
|
+
|
|
953
|
+
`),a=e.scope,l=new Set(new be([a.body,...a.imports,...Object.keys(e.properties),...Object.values(a.propBindings)].join(`
|
|
954
|
+
`)).tokenize().map((I)=>I.value)),u="__stxScope";while(l.has(u))u+="$";let f=[...new Set([...Object.keys(e.properties),...a.propNames])].map((I)=>{let j=a.propBindings[I]||I;return a.defaults[I]===void 0?j:`${j} = ${a.defaults[I]}`}).join(", "),v=(I)=>I.split(`
|
|
955
|
+
`).map((j)=>j.trim()===""?j:` ${j}`).join(`
|
|
956
|
+
`),S="";if(e.render.trim()!==""||a.body!==""||f!==""){let I=[a.apis.length?`const ${u} = this._beginScope();
|
|
957
|
+
const { ${a.apis.join(", ")} } = ${u};`:"",f?`const { ${f} } = this._props();`:"",a.body,e.scopeMethods.length?`this._scopeMethods = { ${e.scopeMethods.join(", ")} };`:"",e.handlers.length?"this._handlers = [];":"","let out = '';",e.render,a.apis.length?`${u}.finish();`:"","return out;"].filter(Boolean).join(`
|
|
958
|
+
`),j;try{let L=new Bun.Transpiler({loader:"ts"}).transformSync(`export function __render(__helpers) {
|
|
959
|
+
${I}
|
|
960
|
+
}`),M=L.indexOf("{"),V=L.lastIndexOf("}");j=L.slice(M+1,V).trim()}catch(L){throw Error(`${e.sourcePath}: failed to compile render (${L.message})`)}S=`
|
|
961
|
+
render(__helpers) {
|
|
962
|
+
const { escape: __escape, raw: __raw, values: __values, entries: __entries } = __helpers;
|
|
963
|
+
${v(j.trim())}
|
|
964
|
+
}
|
|
965
|
+
`}return`import { StxElement, defineComponent } from ${n==="./runtime.js"?"'./runtime.js'":JSON.stringify(n)};
|
|
966
|
+
${a.imports.length?`${a.imports.join(`
|
|
967
|
+
`)}
|
|
968
|
+
`:""}
|
|
969
|
+
/** ${e.description||`${e.name} web component generated from ${e.file}.`} */
|
|
970
|
+
export class ${e.name} extends StxElement {
|
|
971
|
+
${i}${S}
|
|
972
|
+
}
|
|
973
|
+
|
|
974
|
+
defineComponent(${e.name}, ${r});
|
|
975
|
+
export default ${e.name};
|
|
976
|
+
`}function cn(e){if(!e||typeof e!=="object")return"unknown";switch(e.type){case"boolean":return"boolean";case"number":return"number";case"array":return"unknown[]";case"object":return"Record<string, unknown>";default:return"string"}}function Hu(e){let n=[e.declarationTypes,e.declarationImports,e.name,...Object.values(e.methodDeclarations).flat(),...Object.values(e.events).map((L)=>L.detailType)].join(`
|
|
977
|
+
`),r=new Set(new be(n).tokenize().map((L)=>L.value)),i=(L)=>{let M=L;while(r.has(M))M+="$";return r.add(M),M},a=i("__StxSupport"),l=i("__Methods"),u=i("__Details"),f=!!e.declarationTypes,v=Object.entries(e.properties).map(([L,M])=>` ${L}${M.required?"":"?"}: ${cn(M)}`).join(`
|
|
978
|
+
`),S=Object.entries(e.events).map(([L,M])=>` ${JSON.stringify(L)}: CustomEvent<${f?`${a}.${u}[${JSON.stringify(L)}]`:M.detailType||"unknown"}>`).join(`
|
|
979
|
+
`),I=Object.keys(e.methods).flatMap((L)=>e.methodDeclarations[L]||[`${L}($event?: Event): unknown`]).map((L)=>` ${L}`).join(`
|
|
980
|
+
`),j=f?`declare namespace ${a} {
|
|
981
|
+
${e.declarationTypes}
|
|
982
|
+
export interface ${l} {
|
|
983
|
+
${I}
|
|
984
|
+
}
|
|
985
|
+
export interface ${u} {
|
|
986
|
+
${Object.entries(e.events).map(([L,M])=>` ${JSON.stringify(L)}: ${M.detailType||"unknown"}`).join(`
|
|
987
|
+
`)}
|
|
988
|
+
}
|
|
989
|
+
}
|
|
990
|
+
|
|
991
|
+
`:"";return`${e.declarationImports?e.declarationImports+`
|
|
992
|
+
|
|
993
|
+
`:""}${j}export interface ${e.name}Props {
|
|
994
|
+
${v}
|
|
995
|
+
}
|
|
996
|
+
|
|
997
|
+
export interface ${e.name}EventMap {
|
|
998
|
+
${S}
|
|
999
|
+
}
|
|
1000
|
+
|
|
1001
|
+
export interface ${e.name} extends Required<Pick<${e.name}Props, Exclude<keyof ${e.name}Props, keyof HTMLElement>>>${f?`, ${a}.${l}`:""} {}
|
|
1002
|
+
|
|
1003
|
+
export declare class ${e.name} extends HTMLElement {
|
|
1004
|
+
${f?"":I}
|
|
1005
|
+
addEventListener<K extends keyof ${e.name}EventMap>(type: K, listener: (this: ${e.name}, event: ${e.name}EventMap[K]) => unknown, options?: boolean | AddEventListenerOptions): void
|
|
1006
|
+
addEventListener<K extends keyof HTMLElementEventMap>(type: K, listener: (this: HTMLElement, event: HTMLElementEventMap[K]) => unknown, options?: boolean | AddEventListenerOptions): void
|
|
1007
|
+
addEventListener(type: string, listener: EventListenerOrEventListenerObject | null, options?: boolean | AddEventListenerOptions): void
|
|
1008
|
+
removeEventListener<K extends keyof ${e.name}EventMap>(type: K, listener: (this: ${e.name}, event: ${e.name}EventMap[K]) => unknown, options?: boolean | EventListenerOptions): void
|
|
1009
|
+
removeEventListener<K extends keyof HTMLElementEventMap>(type: K, listener: (this: HTMLElement, event: HTMLElementEventMap[K]) => unknown, options?: boolean | EventListenerOptions): void
|
|
1010
|
+
removeEventListener(type: string, listener: EventListenerOrEventListenerObject | null, options?: boolean | EventListenerOptions): void
|
|
1011
|
+
readonly updateComplete: Promise<void>
|
|
1012
|
+
requestUpdate(): Promise<void>
|
|
1013
|
+
emit<T = unknown>(name: string, detail?: T, options?: CustomEventInit<T>): boolean
|
|
1014
|
+
}
|
|
1015
|
+
|
|
1016
|
+
declare global {
|
|
1017
|
+
interface HTMLElementTagNameMap {
|
|
1018
|
+
${JSON.stringify(e.tag)}: ${e.name}
|
|
1019
|
+
}
|
|
1020
|
+
}
|
|
1021
|
+
|
|
1022
|
+
export default ${e.name}
|
|
1023
|
+
`}function Ku(e){return`declare global {
|
|
1024
|
+
namespace JSX {
|
|
1025
|
+
interface IntrinsicElements {
|
|
1026
|
+
${e.map((r)=>{let i=Object.entries(r.properties).map(([l,u])=>` ${JSON.stringify(l)}?: ${cn(u)}`).join(`
|
|
1027
|
+
`),a=Object.keys(r.events).map((l)=>` ${`on${l.split(/[-:]/).map((f)=>f.charAt(0).toUpperCase()+f.slice(1)).join("")}`}?: (event: import('./${r.tag}.js').${r.name}EventMap[${JSON.stringify(l)}]) => void`).join(`
|
|
1028
|
+
`);return` ${JSON.stringify(r.tag)}: {
|
|
1029
|
+
${i}
|
|
1030
|
+
${a}
|
|
1031
|
+
children?: unknown
|
|
1032
|
+
slot?: string
|
|
1033
|
+
class?: string
|
|
1034
|
+
className?: string
|
|
1035
|
+
}`}).join(`
|
|
1036
|
+
`)}
|
|
1037
|
+
}
|
|
1038
|
+
}
|
|
1039
|
+
}
|
|
1040
|
+
|
|
1041
|
+
export {}
|
|
1042
|
+
`}function qu(e){return{schemaVersion:"1.0.0",modules:e.map((n)=>({kind:"javascript-module",path:`./${n.tag}.js`,declarations:[{kind:"class",name:n.name,description:n.description||void 0,customElement:!0,tagName:n.tag,members:Object.entries(n.properties).map(([r,i])=>({kind:"field",name:r,description:i.description,type:{text:cn(i)},default:i.default===void 0?void 0:JSON.stringify(i.default),attribute:i.attribute===!1?void 0:i.attribute||xr(r),reflects:i.reflect})),events:Object.entries(n.events).map(([r,i])=>({name:r,description:i.description,type:{text:`CustomEvent<${i.detailType||"unknown"}>`}})),slots:n.slots,cssProperties:n.cssProperties}],exports:[{kind:"js",name:n.name,declaration:{name:n.name,module:`./${n.tag}.js`}}]}))}}function Qo(e){if(!e.styles)return"";let n=e.styles.replace(/:host\b/g,":scope");if(/\@scope\s*\(/.test(n))return n;return`@scope (${e.tag}) {
|
|
1043
|
+
${n}
|
|
1044
|
+
}`}function ea(e){return e.replace(/\/\*[\s\S]*?\*\//g,"").replace(/\s+/g," ").replace(/\s*([{}:;,])\s*/g,"$1").replace(/;}/g,"}").trim()}function Zu(e){let n=JSON.stringify("\\{!!\\s*([\\w$.]+)\\s*!!\\}"),r=JSON.stringify("\\{\\{\\s*([\\w$.]+)\\s*\\}\\}"),i=JSON.stringify('<slot(?:\\s+name=["\\\']([^"\\\']+)["\\\'])?\\s*\\/?>(?:<\\/slot>)?'),a=Object.fromEntries(e.map((u)=>[u.tag,{template:u.template,styles:u.styles,shadowMode:u.shadowMode,properties:u.properties}])),l=e.map((u)=>`export const render${u.name} = (props = {}, slots = {}) => renderComponent('${u.tag}', props, slots);`).join(`
|
|
1045
|
+
`);return`const definitions = ${JSON.stringify(a,null,2)};
|
|
1046
|
+
const escapeHTML = (value) => String(value ?? '')
|
|
1047
|
+
.replaceAll('&', '&').replaceAll('<', '<').replaceAll('>', '>')
|
|
1048
|
+
.replaceAll('"', '"').replaceAll("'", ''');
|
|
1049
|
+
const valueAt = (values, path) => path.trim().split('.').reduce((value, part) => value?.[part], values);
|
|
1050
|
+
|
|
1051
|
+
export function renderComponent(tag, props = {}, slots = {}) {
|
|
1052
|
+
const definition = definitions[tag];
|
|
1053
|
+
if (!definition) throw new Error('Unknown STX component: ' + tag);
|
|
1054
|
+
const values = Object.fromEntries(Object.entries(definition.properties).map(([name, property]) => [name, property.default]));
|
|
1055
|
+
Object.assign(values, props);
|
|
1056
|
+
let template = definition.template
|
|
1057
|
+
.replace(new RegExp(${n}, 'g'), (_match, expression) => String(valueAt(values, expression) ?? ''))
|
|
1058
|
+
.replace(new RegExp(${r}, 'g'), (_match, expression) => escapeHTML(valueAt(values, expression)))
|
|
1059
|
+
.replace(new RegExp(${i}, 'gi'), (_match, name) => String(slots[name || 'default'] ?? ''));
|
|
1060
|
+
const attributes = Object.entries(definition.properties).flatMap(([name, property]) => {
|
|
1061
|
+
if (property.attribute === false || !(name in props)) return [];
|
|
1062
|
+
const attribute = property.attribute || name.replace(/[A-Z]/g, letter => '-' + letter.toLowerCase());
|
|
1063
|
+
const value = props[name];
|
|
1064
|
+
if (value == null || value === false) return [];
|
|
1065
|
+
if (value === true) return [attribute];
|
|
1066
|
+
const serialized = typeof value === 'object' ? JSON.stringify(value) : value;
|
|
1067
|
+
return [attribute + '=\\"' + escapeHTML(serialized) + '\\"'];
|
|
1068
|
+
}).join(' ');
|
|
1069
|
+
if (definition.shadowMode) {
|
|
1070
|
+
template = '<template shadowrootmode="' + definition.shadowMode + '">' +
|
|
1071
|
+
(definition.styles ? '<style>' + definition.styles + '</style>' : '') + template + '</template>' +
|
|
1072
|
+
String(slots.default ?? '');
|
|
1073
|
+
}
|
|
1074
|
+
return '<' + tag + (attributes ? ' ' + attributes : '') + '>' + template + '</' + tag + '>';
|
|
1075
|
+
}
|
|
1076
|
+
|
|
1077
|
+
${l}
|
|
1078
|
+
`}async function sl(e){let n=st.resolve(e.inputDir),r=st.resolve(e.outputDir);if(!(await Xo(n).catch(()=>null))?.isDirectory())throw Error(`Component-library input directory does not exist: ${n}`);let a=e.components?.length?e.components:(await Iu(n)).map((U)=>({file:U}));if(!a.length)throw Error(`No .stx components found in ${n}`);let l=await Promise.all(a.map((U)=>Vu(n,U,e)));l.sort((U,H)=>U.tag.localeCompare(H.tag));let u=l.filter((U,H)=>l.findIndex((re)=>re.tag===U.tag)!==H);if(u.length)throw Error(`Duplicate custom-element tag: ${u[0].tag}`);let f=l.filter((U,H)=>l.findIndex((re)=>re.name===U.name)!==H);if(f.length)throw Error(`Duplicate component class name: ${f[0].name}`);await Jo(r,{recursive:!0});let v=[],S=async(U,H)=>{let re=st.join(r,U);if(await Jo(st.dirname(re),{recursive:!0}),await Eu(re,typeof H==="string"&&!H.endsWith(`
|
|
1079
|
+
`)?`${H}
|
|
1080
|
+
`:H),!v.includes(re))v.push(re);return re},I=l.some((U)=>U.scope.apis.length),j=import.meta.url.endsWith(".ts")?".ts":".js",L=new URL(`./signals-api${j}`,import.meta.url).pathname;if(I)await S("signals.js",`export * from ${JSON.stringify(L)};`);await S("runtime.js",Uu(I));for(let U of l){if(await S(`${U.tag}.js`,hr(U)),e.declarations!==!1)await S(`${U.tag}.d.ts`,Hu(U));if(e.css!==!1&&U.styles){let H=U.shadowMode?U.styles:Qo(U);await S(`${U.tag}.css`,e.minify?ea(H):H)}}let M=new Bun.Transpiler({loader:"ts"});if(I||l.some((U)=>U.scope.imports.length||M.scanImports(hr(U)).some((H)=>H.kind==="dynamic-import"))){let U=l.map((fe)=>st.join(r,`${fe.tag}.js`)),H=new Map(await Promise.all(U.map(async(fe,we)=>[await $u(fe),l[we]])));for(let[fe,we]of U.entries())H.set(we,l[fe]);let re=new Map(l.map((fe)=>[st.join(st.dirname(fe.sourcePath),`.stx-library-${fe.tag}.ts`),fe])),ce=st.join(r,"runtime.js");if(U.push(ce),I)U.push(st.join(r,"signals.js"));let le=await Bun.build({entrypoints:U,outdir:r,root:r,target:"browser",format:"esm",splitting:!0,naming:{entry:"[name].js",chunk:"chunks/[name]-[hash].js"},minify:!1,loader:{".js":"ts"},plugins:[{name:"stx-element-runtime",setup(fe){fe.onResolve({filter:/.*/},(we)=>{if(we.path==="bun"||we.path.startsWith("bun:")||we.path.startsWith("node:")||Cu.has(we.path))throw Error(`Server-only import ${JSON.stringify(we.path)} is not available in a browser component (${we.importer})`);let Ee=H.get(we.path);if(!we.importer&&Ee)return{path:st.join(st.dirname(Ee.sourcePath),`.stx-library-${Ee.tag}.ts`)};if(we.path===ce&&re.has(we.importer))return{path:ce};if(/^(?:@stacksjs\/stx|stx)\/signals-api(?:\.[jt]s)?$/.test(we.path))return{path:L}}),fe.onLoad({filter:/\.ts$/},(we)=>{let Ee=re.get(we.path);if(Ee)return{contents:hr(Ee,ce),loader:"ts"}})}}]}).catch((fe)=>{let we=(fe instanceof AggregateError?fe.errors:[fe]).map(String).join(`
|
|
1081
|
+
`);throw Error(`Failed to bundle browser component imports
|
|
1082
|
+
${we}`)});if(!le.success)throw Error(`Failed to bundle component imports
|
|
1083
|
+
${le.logs.map(String).join(`
|
|
1084
|
+
`)}`);for(let fe of le.outputs)await S(st.relative(r,fe.path),new Uint8Array(await fe.arrayBuffer()))}let V=l.map((U)=>`export { ${U.name}, default as ${U.name}Element } from './${U.tag}.js';`).join(`
|
|
1085
|
+
`);if(await S("index.js",V),await S("ssr.js",Zu(l)),e.declarations!==!1)await S("index.d.ts",l.map((U)=>`export * from './${U.tag}.js'`).join(`
|
|
1086
|
+
`)),await S("custom-elements.d.ts",Ku(l)),await S("ssr.d.ts",`${l.map((U)=>`export declare const render${U.name}: (props?: ${U.name}Props, slots?: Record<string, string>) => string`).join(`
|
|
1087
|
+
`)}
|
|
1088
|
+
export declare function renderComponent(tag: string, props?: Record<string, unknown>, slots?: Record<string, string>): string
|
|
1089
|
+
${l.map((U)=>`import type { ${U.name}Props } from './${U.tag}.js'`).join(`
|
|
1090
|
+
`)}`);let W;if(e.manifest!==!1)W=await S("custom-elements.json",JSON.stringify(qu(l),null,2));let Z;if(e.css!==!1){let U=l.filter((H)=>!H.shadowMode&&H.styles).map(Qo).join(`
|
|
1091
|
+
|
|
1092
|
+
`);if(U)Z=await S("bundle.css",e.minify?ea(U):U)}let q;if(e.bundle!==!1){q=st.join(r,"bundle.js");let U;try{U=await Bun.build({entrypoints:[st.join(r,"index.js")],outdir:r,naming:"bundle.js",target:"browser",format:"esm",minify:e.minify??!0,sourcemap:e.sourcemap||"none"})}catch(H){let re=H instanceof AggregateError?H.errors:[H],ce=re.map((le)=>String(le).trim()).filter(Boolean).join(`
|
|
1093
|
+
`);throw AggregateError(re,`Failed to bundle component library${ce?`
|
|
1094
|
+
${ce}`:""}`)}if(!U.success){let H=U.logs.map((re)=>String(re).trim()).filter(Boolean).join(`
|
|
1095
|
+
`);throw AggregateError(U.logs,`Failed to bundle component library${H?`
|
|
1096
|
+
${H}`:""}`)}if(v.push(q),e.sourcemap==="external")v.push(`${q}.map`)}let G=await Promise.all(v.map(async(U)=>(await Xo(U)).size));return{components:l.map((U)=>({name:U.name,tag:U.tag,source:U.sourcePath,module:st.join(r,`${U.tag}.js`),styles:U.styles,shadowMode:U.shadowMode})),files:v,manifest:W,bundle:q,cssBundle:Z,totalBytes:G.reduce((U,H)=>U+H,0)}}var Ju=new Set(ht);function qt(e){let n=Zt(e),r=n.find((j)=>j.name==="InheritedContext");if(!r)return;let i=/^(?:interface\s+InheritedContext|type\s+InheritedContext\s*=)\s*\{/.test(t(r.text).trim()),a=t(e),l=h(a).depths,u=[...a.matchAll(/\b(?:interface|type)\s+InheritedContext\b/g)].find((j)=>l[j.index]===0)?.index??0,f=r.text.slice(r.text.indexOf("{")+1,r.text.lastIndexOf("}")),v=t(f),S=h(v).depths,I=[...v.matchAll(/(?:^|[;,\n])\s*(?:readonly\s+)?([A-Za-z_$][\w$]*)\??\s*:/g)].filter((j)=>S[j.index]===0).map((j)=>j[1]);return{keys:i?I:[],types:n.map((j)=>j.text).join(`
|
|
1097
|
+
`),offset:Math.max(0,u),...!i?{unsupported:"InheritedContext requires a local non-generic object interface or object type alias with named properties"}:{}}}function Xu(e){let n=[],r=t(e);for(let i of e.matchAll(/\bimport\s+(type\s+)?([\w$*{}\s,]+?)\s+from\s*(['"])([^'"]+)\3/g)){if(i[1]||r.slice(i.index,i.index+6)!=="import")continue;let a=i[2].trim(),l=["stx","@stacksjs/stx"].includes(i[4]);if(/^[A-Za-z_$][\w$]*$/.test(a)){n.push(a);continue}if(!a.startsWith("{")||!a.endsWith("}"))continue;for(let u of a.slice(1,-1).split(",")){if(/^\s*type\s+/.test(u))continue;let[f,v=f]=u.trim().split(/\s+as\s+/);if(v&&!(l&&Ju.has(f)))n.push(v)}}return n}function eo(e){let n=qt(e);if(!n||n.unsupported)return"";let r=new Set(ye(e));return n.keys.filter((i)=>!r.has(i)).map((i)=>`declare const ${i}: InheritedContext[${JSON.stringify(i)}];`).join(`
|
|
1098
|
+
`)}function oa(e,n){let r=[bs],i=[],a=new Map,l=_t.resolve(n.filePath),u=l.split(_t.sep).lastIndexOf("views"),f=u>=0?l.split(_t.sep).slice(0,u).join(_t.sep):_t.dirname(l),v=_t.resolve(n.partialsDir||_t.join(f,"partials")),S=_t.resolve(n.layoutsDir||_t.join(f,"views/layouts"));if([v,S].some((Z)=>l===Z||l.startsWith(Z+_t.sep)))return{declarations:"",checks:i,dependencies:a};let I=(Z)=>n.readTemplate?.(Z)??(ia.existsSync(Z)?ia.readFileSync(Z,"utf8"):void 0),j=0,L=!1,M=[];function V(Z,q){let G=e.slice(0,Z).split(`
|
|
1099
|
+
`).length,U=Z-e.lastIndexOf(`
|
|
1100
|
+
`,Z-1),H={code:e.slice(Z,e.indexOf(`
|
|
1101
|
+
`,Z)<0?e.length:e.indexOf(`
|
|
1102
|
+
`,Z)),line:G,column:U,kind:"directive",offset:Z,anchor:!0};i.push({expression:H,statement:{text:`;${q}`,prefixLength:1}})}function W(Z,q,G,U,H,re){let ce=`__StxInherited${j++}`;while((e+Z+[...a.values()].join("")).includes(ce))ce+="_";let le=_e(Z).filter((je)=>je.kind==="server").map((je)=>je.code).join(`
|
|
1103
|
+
`),fe=`${ce}ParentValue`,we=`${ce}ParentType`;r.push(`type ${we} = ${G};`);let Ee=wr(Es(le,_t.dirname(q)),ce);r.push(...Ee.imports);let Re=qt(le);if(Re&&H!==void 0){L=!0;let je=Ee.imports.length?Ee.aliases.join(`
|
|
1104
|
+
`):"",Ae=ys(`${je}
|
|
1105
|
+
${Re.types}
|
|
1106
|
+
const __contract = defineProps<InheritedContext>();`,`${ce}Contract`);r.push(Ae.declarations),r.push(`declare const ${ce}Input: ${we};`),V(H,Re.unsupported?`({})[${JSON.stringify(Re.unsupported)}];`:`${ce}Input satisfies ${Ae.props};`)}let ve=[...new Set([...ye(le),...Xu(le)])],Qe=[...new Set([...U,...Re?.keys||[]])].filter((je)=>!ve.includes(je)),Be=Re?`${we} & ${ce}Contract.__StxProps`:we,it=En(Ee.body).replace(/^[ \t]*export[ \t]+(?=(?:const|let|var|function|async|class|interface|type)\b)/gm,""),rt=[],wt=ln(Z),ft=/@(include|extends|layout)\s*\(/g,ot;while(ot=ft.exec(wt)){let je=Ln(wt,ft.lastIndex-1);if(!je)continue;ft.lastIndex=je.end;let Ae=/^\s*(['"])(.*?)\1\s*(?:,\s*([\s\S]*))?$/.exec(je.expression);if(!Ae){M.push({offset:H??ot.index,message:`Inherited context cannot be checked across dynamic @${ot[1]}`});continue}let dt=Ae[2],nt=ot[1];if(nt!=="include"&&Ae[3])M.push({offset:H??ot.index,message:`Inherited context cannot be checked for unsupported @${nt} data arguments`});let pn=nt==="include"?v:S,Pt=_t.resolve(dt.startsWith(".")?_t.dirname(q):pn,dt.endsWith(".stx")?dt:dt+".stx");if(I(Pt)===void 0){M.push({offset:H??ot.index,message:`Inherited context target cannot be resolved: ${dt}`});continue}rt.push({name:`edge${rt.length}`,target:Pt,kind:nt,args:nt==="include"?Ae[3]||"{}":"{}",offset:H??ot.index})}let Nt=`{ ...${fe}${ve.length?", "+ve.join(", "):""} }`;r.push(`namespace ${ce} {
|
|
1107
|
+
${Ee.aliases.join(`
|
|
1108
|
+
`)}
|
|
1109
|
+
export async function read(${fe}: ${H===void 0?"{}":Be}) {
|
|
1110
|
+
${Qe.length?`const { ${Qe.join(", ")} } = ${fe};`:""}
|
|
1111
|
+
${it}
|
|
1112
|
+
return { context: ${Nt}${rt.map((je)=>`, ${je.name}: { ...${Nt}, ...(${je.args}) }`).join("")} };
|
|
1113
|
+
}
|
|
1114
|
+
}`);for(let je of rt){if(re.includes(je.target)||re.length>=32){M.push({offset:je.offset,message:"Inherited context cannot be checked across a cyclic or overly deep template graph"});continue}let Ae=I(je.target);a.set(je.target,Ae),W(Ae,je.target,`Awaited<ReturnType<typeof ${ce}.read>>[${JSON.stringify(je.name)}]`,[...new Set([...U,...ve])],je.offset,[...re,je.target])}return ce}if(W(e,l,"{}",[],void 0,[l]),L||n.contractsKnown)for(let Z of M)V(Z.offset,`({})[${JSON.stringify(Z.message)}];`);return{declarations:L?r.join(`
|
|
1115
|
+
`):"",checks:i,dependencies:a}}function to(e,n){let r=Ht(e),i=br(e);if(!i)return;let a;try{a=yr(e,"component")}catch(H){let re=i.open,ce=H instanceof Error?H.message:"Invalid component metadata";return{declarations:"",checks:[{text:`({})[${JSON.stringify(ce)}];`,line:e.slice(0,re).split(`
|
|
1116
|
+
`).length,column:re-e.lastIndexOf(`
|
|
1117
|
+
`,re-1),origin:"component"}],project:(le)=>({code:le,columns:new Map})}}let l=ee(r).filter((H)=>{let re=O(H.attrs);return $t(re)&&re.has("client")&&!re.has("server")&&!re.has("component")&&!re.has("stx:component")&&!re.has("src")}),u=l.map((H)=>e.slice(H.bodyStart,H.bodyEnd)).join(`
|
|
1118
|
+
`),f=$s(u,n),v=Zt(u).some((H)=>H.name==="ComponentState")||ks(u).includes("ComponentState"),S=Object.entries(a.properties||a.props||{}).map(([H,re])=>`${JSON.stringify(H)}: ${cn(re)}`).join("; "),I=[...new Set(f.map((H)=>H.name))],j=[`interface __StxMetadataProperties { ${S} }`,"type __StxNativeProperties = Omit<__StxMetadataProperties, keyof HTMLElement> & Pick<HTMLElement, Extract<keyof __StxMetadataProperties, keyof HTMLElement>>;","type __StxAny<T> = 0 extends (1 & T) ? true : false;","type __StxAnyFields<T> = { [K in keyof T]-?: __StxAny<T[K]> extends true ? K : never }[keyof T];","type __StxSpecific<T> = __StxAny<T> extends true ? false : T extends object ? string extends keyof T ? false : number extends keyof T ? false : symbol extends keyof T ? false : __StxAnyFields<T> extends never ? true : false : false;",v?"type __StxState = __StxSpecific<ComponentState> extends true ? ComponentState : {};":"type __StxState = {};",v?'declare function __stxSpecificState(value: __StxSpecific<ComponentState> extends true ? true : "ComponentState requires named explicit fields without any or index signatures"): void;':"",v?"declare const __stxStateProperties: Pick<ComponentState, Extract<keyof ComponentState, keyof __StxInstanceProperties>>;":"",v?'declare function __stxStateMethods(value: Extract<keyof ComponentState, __StxMethodNames | "emit" | "requestUpdate" | "updateComplete" | "renderRoot"> extends never ? true : "ComponentState cannot redeclare component methods"): void;':"",`type __StxMethodNames = ${I.map((H)=>JSON.stringify(H)).join(" | ")||"never"};`,"type __StxInstanceProperties = Omit<HTMLElement, __StxMethodNames | keyof __StxNativeProperties> & __StxNativeProperties;",'type __StxPrivateKeys<T> = Exclude<keyof T, keyof HTMLElement | keyof __StxNativeProperties | __StxMethodNames | "emit" | "updateComplete" | "requestUpdate" | "renderRoot">;',v?'declare function __stxOptionalPrivate(value: { [K in __StxPrivateKeys<ComponentState>]-?: {} extends Pick<ComponentState, K> ? never : K }[__StxPrivateKeys<ComponentState>] extends never ? true : "Private ComponentState fields must be optional until initialized"): void;':"","type __StxRefinedProperties = { [K in keyof __StxNativeProperties]: K extends keyof __StxState ? __StxAny<__StxState[K]> extends true ? __StxNativeProperties[K] : __StxState[K] extends __StxNativeProperties[K] ? __StxState[K] : __StxNativeProperties[K] : __StxNativeProperties[K] };","type __StxNativeComponent = Omit<HTMLElement, keyof __StxNativeProperties | __StxMethodNames> & __StxRefinedProperties & Partial<Pick<__StxState, __StxPrivateKeys<__StxState>>> & {","readonly updateComplete: Promise<void>; requestUpdate(): Promise<void>; readonly renderRoot: HTMLElement | ShadowRoot;","emit<T = unknown>(name: string, detail?: T, options?: CustomEventInit<T>): boolean;",...I.map((H)=>`${JSON.stringify(H)}: typeof ${H};`),"}"].filter(Boolean).join(`
|
|
1119
|
+
`),L=-1;for(let H of l){let re=H.bodyStart,ce=e.slice(re,H.bodyEnd),le=t(ce),fe=h(le).depths,we=[...le.matchAll(/\b(?:interface|type)\s+ComponentState\b/g)].find((Ee)=>fe[Ee.index]===0)??(ks(ce).includes("ComponentState")?/\bComponentState\b/.exec(le):void 0);if(we){L=re+we.index;break}}let M=v&&L>=0?[{origin:"client",text:"__stxSpecificState(true); __stxStateMethods(true); __stxOptionalPrivate(true); __stxStateProperties satisfies Pick<__StxInstanceProperties, Extract<keyof ComponentState, keyof __StxInstanceProperties>>;",line:e.slice(0,L).split(`
|
|
1120
|
+
`).length,column:L-e.lastIndexOf(`
|
|
1121
|
+
`,L-1)}]:[],{start:V,code:W}=i,Z=t(W),q=h(Z).depths,G=new Map,U=!1;for(let H of W.matchAll(/"(?:\\.|[^"\\])*"\s*:/g)){let re=JSON.parse(H[0].slice(0,H[0].lastIndexOf(":")).trim());if(q[H.index]===1&&["properties","props"].includes(re)){U=!0;continue}if(U&&q[H.index]===1)U=!1;if(U&&q[H.index]===2&&!G.has(re))G.set(re,V+H.index)}for(let[H,re]of Object.entries(a.properties||a.props||{})){let ce=G.get(H)??V,le=e.slice(0,ce).split(`
|
|
1122
|
+
`).length,fe=ce-e.lastIndexOf(`
|
|
1123
|
+
`,ce-1);if(!re||typeof re!=="object"||!["string","number","boolean","object","array"].includes(re.type))M.push({text:`({})[${JSON.stringify(`Property ${H} must declare string, number, boolean, object or array`)}];`,line:le,column:fe,origin:"component"});if(re&&re.default!==void 0)M.push({text:`const __stxDefault${M.length}: ${cn(re)} = ${JSON.stringify(re.default)};`,line:le,column:fe,origin:"component"})}return{declarations:j,checks:M,project(H){let re=new Map,ce=[],le=0;for(let fe of $s(H,n)){if(/^\s*this\s*:/.test(fe.parameters))continue;let we=fe.parameterOffset,Ee=`this: __StxNativeComponent${fe.parameters.trim()?", ":""}`;ce.push(H.slice(le,we),Ee);let Re=H.slice(0,we).split(`
|
|
1124
|
+
`).length,ve=we-H.lastIndexOf(`
|
|
1125
|
+
`,we-1),Qe=re.get(Re)||[],Be=Qe.at(-1),it=ve+(Be?Be.generatedEnd-Be.sourceEnd:0);Qe.push({sourceStart:ve,sourceEnd:ve,generatedStart:it,generatedEnd:it+Ee.length}),re.set(Re,Qe),le=we}return ce.push(H.slice(le)),{code:ce.join(""),columns:re}}}}function aa(e){let n=[],r=[],i=/@foreach\s*\(|@endforeach\b/g,a;while(a=i.exec(e)){if(a[0].startsWith("@endforeach")){let v=r.pop();if(v)v.end=a.index,n.push(v);continue}let l=Ln(e,i.lastIndex-1);if(!l)continue;let u=_r(l.expression),f=l.end;if(u)r.push({start:f,end:e.length,iterable:u.iterable,binding:u.key?`${u.value}, ${u.key}`:u.value});i.lastIndex=f}return n.sort((l,u)=>l.start-u.start)}function Gu(e){let n=(r)=>r.replace(/[^\n]/g," ");return e.replace(/<!--[\s\S]*?-->/g,n).replace(/\{\{--[\s\S]*?--\}\}/g,n)}function _e(e){let n=[],r=Gu(e);for(let i of ee(r)){let a=i.attrs.trim(),l=O(a),{bodyStart:u,bodyEnd:f}=i,v=e.slice(u,f);if(l.has("src")||l.has("component")||l.has("stx:component"))continue;if(!$t(l))continue;let S=l.has("server")?"server":l.has("client")?"client":"plain",I=zn(e,u);n.push({kind:S,code:v,startLine:I,startColumn:Bn(e,u),offset:u,attrs:a})}return n}function zn(e,n){let r=1;for(let i=0;i<n&&i<e.length;i++)if(e.charCodeAt(i)===10)r++;return r}function Bn(e,n){let r=e.lastIndexOf(`
|
|
1126
|
+
`,n-1)+1;return n-r+1}function ln(e){let n=e.split(""),r=(a,l)=>{for(let u=a;u<l&&u<n.length;u++)if(n[u]!==`
|
|
1127
|
+
`)n[u]=" "},i=[/<script(?:\s[^>]*)?>[\s\S]*?<\/script>/gi,/<style(?:\s[^>]*)?>[\s\S]*?<\/style>/gi,/<!--[\s\S]*?-->/g,/\{\{--[\s\S]*?--\}\}/g,/@verbatim\b[\s\S]*?@endverbatim\b/g];for(let a of i){a.lastIndex=0;let l;while((l=a.exec(e))!==null)r(l.index,l.index+l[0].length)}return n.join("")}function xa(e){let n=0,r="";for(let i=0;i<e.length;i++){let a=e[i];if(r){if(a==="\\"){i++;continue}if(a===r)r="";continue}if(a==='"'||a==="'"||a==="`"){r=a;continue}if(a==="("||a==="["||a==="{"){n++;continue}if(a===")"||a==="]"||a==="}"){n--;continue}if(a==="|"&&n===0){if(e[i+1]==="|"){i++;continue}if(e[i-1]==="|")continue;return e.slice(0,i)}}return e}var ba=new Set([":for","x-for","v-for"]),Cs=/(?:^|\s)((?::|x-|v-|@)[\w.:-]+)\s*=\s*(["'])([\s\S]*?)\2/g,Sr="__stx_interpolated",ca="__StxElement",ya="__StxTemplateValue",Yu=`type ${ya}<T> = T extends { readonly _isSignal: true } | { readonly _isDerived: true } ? (T extends () => infer V ? T & V : T) : T`;function la(e){return e.replace(/\{\{[\s\S]*?\}\}/g,Sr).replace(/\{!![\s\S]*?!!\}/g,Sr)}function Qu(e,n,r){let i=0;for(let a=n;a<e.length;a++){let l=e[a];if(l==="{"){i++;continue}if(l!=="}"&&l!=="!")continue;if(e.startsWith(r,a)&&i===0)return a;if(l==="}"&&i>0)i--}return-1}function Pi(e,n,r="0"){let i=`__stxScript${r}`;while((e+n).includes(i))i+="_";let a=new Map,l=[],u=[],f=t(e),v=ka(e),S=[],I=0;for(let W=0;W<f.length;W++){let Z=f.startsWith("{{",W);if(!Z&&!f.startsWith("{!!",W))continue;let q=Z?2:3,G=Z?"}}":"!!}",U=Qu(f,W+q,G);if(U<0)continue;let H=W,re=e.slice(H,U+G.length),ce=re.slice(q,-G.length);W=U+G.length-1;let le=u.length,fe=Er(v,H),we=Er(v,H+(Z?2:3));u.push({code:xa(ce),...we});let Ee=`${i}_${le}`,Re=re.split(`
|
|
1128
|
+
`),ve=Re[0].length;Re[0]=Ee+" ".repeat(Math.max(0,ve-Ee.length));for(let rt=1;rt<Re.length;rt++)Re[rt]=Re[rt].replace(/[^\r]/g," ");let Qe=a.get(fe.line)??[],Be=Qe.at(-1),it=fe.column+(Be?Be.generatedEnd-Be.sourceEnd:0);Qe.push({sourceStart:fe.column,sourceEnd:fe.column+ve,generatedStart:it,generatedEnd:it+Re[0].length}),a.set(fe.line,Qe),S.push(e.slice(I,H),Re.join(`
|
|
1129
|
+
`)),I=H+re.length}S.push(e.slice(I));let j=S.join("");if(!u.length)return{code:j,columns:a,declarations:l};let{imports:L,aliases:M,body:V}=wr(n,i);for(let W of L)l.push({text:W});l.push({text:`namespace ${i}Scope {
|
|
1130
|
+
${M.join(`
|
|
1131
|
+
`)}
|
|
1132
|
+
export async function read() {
|
|
1133
|
+
${En(V).replace(/^[ \t]*export[ \t]+(?=(?:const|let|var|function|async|class|interface|type)\b)/gm,"")}
|
|
1134
|
+
return {`});for(let[W,Z]of u.entries())l.push({text:`value${W}: (`}),l.push({text:Z.code,origin:{line:Z.line,column:Z.column}}),l.push({text:"),"});l.push({text:`}
|
|
1135
|
+
}
|
|
1136
|
+
}`});for(let W=0;W<u.length;W++)l.push({text:`declare var ${i}_${W}: Awaited<ReturnType<typeof ${i}Scope.read>>['value${W}']`});return{code:j,columns:a,declarations:l}}function wr(e,n){let r=[],{imports:i,body:a}=wa(e),l=[],u=0;for(let f of i.split(/\n(?=import\b)/)){if(!f.trim())continue;let v=/^import\s+(?:type\s+)?([\s\S]+?)\s+from\s*(['"][^'"]+['"])/.exec(f);if(!v){r.push(f);continue}let S=`${n}Module${u++}`;r.push(`import * as ${S} from ${v[2]}`);let I=v[1],j=/\{([\s\S]*?)\}/.exec(I);for(let W of j?.[1].split(",")??[]){let[Z,q=Z]=W.trim().replace(/^type\s+/,"").split(/\s+as\s+/);if(Z==="default")l.push(`const ${q} = ${S}.default; type ${q} = import(${v[2]}).default`);else if(Z)l.push(`import ${q} = ${S}.${Z}`)}let L=I.replace(/\{[\s\S]*?\}/,""),M=/\*\s+as\s+(\w+)/.exec(L);if(M)l.push(`import ${M[1]} = ${S}`);let V=/^\s*([\w$]+)/.exec(L)?.[1];if(V)l.push(`const ${V} = ${S}.default; type ${V} = import(${v[2]}).default`)}return{imports:r,aliases:l,body:a}}function vr(e,n){let r=0;for(let i of e){if(n<i.generatedStart)break;if(n<i.generatedEnd)return i.sourceStart+Math.min(n-i.generatedStart,i.sourceEnd-i.sourceStart);r=i.sourceEnd-i.generatedEnd}return n+r}var ep=["foreach","endforeach","forelse","endforelse","for","endfor","while","endwhile","empty","if","elseif","else","endif","unless","endunless","isset","endisset","switch","case","default","endswitch","auth","endauth","guest","endguest","env","endenv","once","endonce","break","continue"],tp=new RegExp(String.raw`^[ \t]*@(?:${ep.join("|")})\b[ \t]*(\([^\n)]*\))?[ \t]*$`,"gm");function En(e){return e.replace(tp,(n)=>n.replace(/[^\n]/g," "))}var ua=new Set(["x-cloak","x-ref","x-transition","x-teleport","v-slot","x-hydrate",":key","x-tooltip","x-tooltip-position"]);function no(e){let n=ln(e),r=[],i=/(@?)\{\{([\s\S]*?)\}\}|(@?)\{!!([\s\S]*?)!!\}/g,a;while((a=i.exec(n))!==null){if(a[1]||a[3])continue;let f=a[2]??a[4]??"",v=a[2]!==void 0?2:3,S=xa(f);if(!S.trim())continue;let I=a.index+v+(S.length-S.trimStart().length);r.push({code:S.trim(),line:zn(n,I),column:Bn(n,I),offset:I,kind:"interpolation"})}let l=/@(if|elseif|else\s+if|unless)\b\s*\(/g;while((a=l.exec(n))!==null){let u=a.index+a[0].length-1,f=0,v=u;for(;v<n.length;v++){let L=n[v];if(L==="(")f++;else if(L===")"){if(f--,f===0)break}}if(f!==0)continue;let S=n.slice(u+1,v),I=S.trim();if(l.lastIndex=v+1,!I)continue;let j=u+1+(S.length-S.trimStart().length);r.push({code:I,line:zn(n,j),column:Bn(n,j),offset:a.index,kind:"condition"})}Cs.lastIndex=0;while((a=Cs.exec(n))!==null){let u=a[1],f=a[3]??"",v=u.replace(/\..*$/,"").replace(/^([^:].*?):.*$/,"$1");if(ua.has(v)||ua.has(u))continue;if(!f.trim())continue;let S=a.index+a[0].indexOf(a[2],a[0].indexOf(u)+u.length)+1;if(ba.has(v)){let j=f.match(/\s+(?:in|of)\s+/);if(!j||j.index===void 0)continue;let L=f.slice(j.index+j[0].length),M=j.index+j[0].length+(L.length-L.trimStart().length);r.push({code:la(L.trim()),line:zn(n,S+M),column:Bn(n,S+M),offset:S+M,kind:"directive",attribute:v});continue}let I=f.length-f.trimStart().length;r.push({code:la(f.trim()),line:zn(n,S+I),column:Bn(n,S+I),offset:S+I,kind:"directive",attribute:v})}return r.sort((u,f)=>u.line-f.line||u.column-f.column),r}var np=2000;function sp(e,n){let r=0,i=Math.min(e.length,n+np);for(let a=n;a<i;a++){let l=e[a];if(l==="(")r++;else if(l===")"){if(r--,r===0)return e.slice(n+1,a)}}return null}function rp(e){let n=new Map,r=(f,v)=>{let S=f.split(/[,[\]{}()\s]+/).filter(Boolean);for(let I of S){let j=I.replace(/^\.\.\./,"").trim();if(!/^\$?[A-Z_$][\w$]*$/i.test(j))continue;let L=S.length===1?v:void 0,M=n.get(j);if(!M)n.set(j,{name:j,iterable:L});else if(M.iterable!==L)M.iterable=void 0}},i=/^\$?[A-Z_$][\w$]*$/i,a=(f)=>{let v=f.trim();return i.test(v)?v:void 0};for(let f of e.matchAll(/@for(?:each|else)\s*\(/g)){let v=sp(e,f.index+f[0].length-1);if(v===null)continue;let S=Wt(v);if(!S)continue;r(S.itemVar.replace(/=>/g," "),a(S.arrayExpr))}for(let f of e.matchAll(/@for\s*\(\s*(?:(?:let|const|var)\s+)?([\w$]+|\[[^\]]*\]|\{[^}]*\})\s+(of|in)\s+([^)]*)/g))r(f[1],f[2]==="of"?a(f[3]):void 0);for(let f of e.matchAll(/@for\s*\(\s*(?:let|const|var)\s+([\w$]+)\s*[=;]/g))r(f[1]);let l=ln(e);Cs.lastIndex=0;let u;while((u=Cs.exec(l))!==null){let f=u[1].replace(/\..*$/,"");if(!ba.has(f))continue;let v=u[3].match(/\s+(?:in|of)\s+/);if(!v||v.index===void 0)continue;r(u[3].slice(0,v.index),a(u[3].slice(v.index+v[0].length)))}for(let f of e.matchAll(/@(?:php|js|ts)\b([\s\S]*?)@end(?:php|js|ts)\b/g))for(let v of f[1].matchAll(/\b(?:const|let|var|function|class)\s+([\w$]+)/g))r(v[1]);return[...n.values()].sort((f,v)=>f.name.localeCompare(v.name))}function ye(e){return Dl(e)}var $r=["params","query","cookies","host","ip","setResponseStatus","setResponseHeader","notFound","request","url","definePageMeta","defineClientPayload","defineStore","props","$props"],ip={$bool:"declare function $bool(value: unknown, fallback?: boolean): boolean",$num:"declare function $num(value: unknown, fallback?: number): number",$uid:"declare var $uid: string",$native:"declare var $native: boolean"};function ol(e=new Set){return[...$r.filter((n)=>!e.has(n)).map((n)=>`declare var ${n}: any`),...Object.entries(ip).filter(([n])=>!e.has(n)).map(([,n])=>n)].join(`
|
|
1137
|
+
`)}function il(e){return new Set([...e.matchAll(/^declare (?:function|const|let|var)\s+([A-Za-z_$][\w$]*)/gm)].map((n)=>n[1]))}function _a(e){let n=/\bdefineClientPayload\s*\(\s*\{([\s\S]*?)\}\s*\)/g,r,i=!1,a=new Set,l=t(e);while((r=n.exec(l))!==null){i=!0;for(let u of op(r[1])){let f=u.split(":")[0].trim();if(/^[A-Za-z_$][\w$]*$/.test(f))a.add(f)}}return i?[...a]:null}function op(e){let n=[],r=0,i="";for(let a of e){if(a===","&&r===0){n.push(i),i="";continue}if(a==="("||a==="["||a==="{")r++;else if(a===")"||a==="]"||a==="}")r--;i+=a}return n.push(i),n.filter((a)=>a.trim().length>0)}function wa(e){let n=/^[ \t]*import\b[\s\S]*?(?:from\s*['"][^'"]*['"]|['"][^'"]*['"])[ \t]*;?[ \t]*$/gm,r=[],i=e.replace(n,(a)=>(r.push(a.trim()),a.split(`
|
|
1138
|
+
`).map(()=>"").join(`
|
|
1139
|
+
`)));return{imports:r.join(`
|
|
1140
|
+
`),body:i}}function Zt(e){let n=t(e),r=Array(n.length),i=0;for(let f=0;f<n.length;f++){let v=n[f];if(v==="}"||v===")"||v==="]")i=Math.max(0,i-1);if(r[f]=i,v==="{"||v==="("||v==="[")i++}let a=[],l=/^[ \t]*(?:export[ \t]+)?(interface|type)[ \t]+([A-Za-z_$][\w$]*)/gm,u;while((u=l.exec(n))!==null){if(r[u.index]!==0)continue;let f=u[1],v=u[2],S;if(f==="interface"){let I=n.indexOf("{",u.index);if(I===-1)continue;let j=0;S=-1;for(let L=I;L<n.length;L++)if(n[L]==="{")j++;else if(n[L]==="}"&&--j===0){S=L+1;break}if(S===-1)continue}else{let I=0;S=n.length;for(let j=n.indexOf("=",u.index)+1;j<n.length;j++){let L=n[j];if(L==="{"||L==="["||L==="("||L==="<")I++;else if(L==="}"||L==="]"||L===")"||L===">")I--;else if(I<=0&&(L===";"||L===`
|
|
1141
|
+
`&&!/[=|&,<([{]\s*$/.test(n.slice(Math.max(0,j-40),j)))){S=L===";"?j+1:j;break}}}a.push({name:v,text:e.slice(u.index,S).replace(/^[ \t]*export[ \t]+/,"")}),l.lastIndex=S}return a}function ap(e){let n=t(e),r=[],i=/^[ \t]*(?:export[ \t]+)?(?:const|let|var)[ \t]+/gm,a,l=0,u=0;while((a=i.exec(n))!==null){for(;u<a.index;u++){let S=n[u];if(S==="{"||S==="("||S==="[")l++;else if(S==="}"||S===")"||S==="]")l=Math.max(0,l-1)}if(l!==0)continue;let f=0,v=n.length;for(let S=a.index+a[0].length;S<n.length;S++){let I=n[S];if(I==="{"||I==="("||I==="[")f++;else if(I==="}"||I===")"||I==="]")f--;else if(f<=0&&(I===";"||I===`
|
|
1142
|
+
`)){v=I===";"?S+1:S;break}}if(/\bdefineProps\s*(?:<|\()/.test(n.slice(a.index,v)))r.push(e.slice(a.index,v).replace(/^[ \t]*export[ \t]+/,"").trim())}return r}function Ii(e){let n=e.filter((a)=>a.kind==="server").map((a)=>a.code).join(`
|
|
1143
|
+
`);if(/\bdefineProps\s*(?:<|\()/.test(t(n)))return n;let r=va(n),i=e.filter((a)=>a.kind!=="server").flatMap((a)=>{let l=ap(a.code);if(!l.length)return[];return[...Zt(a.code).filter((u)=>!r.has(u.name)).map((u)=>u.text),...l]});return[n,...i].filter(Boolean).join(`
|
|
1144
|
+
`)}function va(e){return new Set(Zt(e).map((n)=>n.name))}function al(e,n=""){let r=_a(e),i=va(n),a=Zt(e).filter((S)=>!i.has(S.name)).map((S)=>S.text);if(!r){let S=ye(e).filter((I)=>!Vt(n,I));if(S.length===0&&a.length===0)return"";return["",`// ${up}`,...a,...S.map((I)=>`declare var ${I}: any`)].join(`
|
|
1145
|
+
`)}if(r.length===0)return a.length>0?["",`// ${fa}`,...a].join(`
|
|
1146
|
+
`):"";let{imports:l,body:u}=wa(e),f=u.replace(/^[ \t]*export[ \t]+(?=(?:const|let|var|function|async|class)\b)/gm,""),v=["",`// ${fa}`];if(l)v.push(l);return v.push(...a),v.push(`async function ${da}() {`,f,` return { ${r.join(", ")} }`,"}",`type ${ga} = Awaited<ReturnType<typeof ${da}>>`,...r.map((S)=>`declare var ${S}: ${ga}[${JSON.stringify(S)}]`)),v.join(`
|
|
1147
|
+
`)}function Oi(e){let n=t(e),r=n.split(""),i=[],a=0,l=0;for(let f=0;f<r.length;f++){let v=r[f];if(v===`
|
|
1148
|
+
`)l=f+1;if(v==="{"||v==="("||v==="["){if(a===0&&v!=="("&&cp.test(n.slice(l,f))){let S=Sa(n,f);if(S!==-1)i.push(...$a(n.slice(f,S+1)))}a++;continue}if(v==="}"||v===")"||v==="]"){a=Math.max(0,a-1);continue}if(a>0&&v!==`
|
|
1149
|
+
`)r[f]=" "}let u=ye(r.join(""));return i.length===0?u:[...new Set([...u,...i])].sort()}var cp=/^\s*(?:export\s+)?(?:const|let|var)\s*$/;function Sa(e,n){let r=0;for(let i=n;i<e.length;i++){let a=e[i];if(a==="{"||a==="("||a==="[")r++;else if(a==="}"||a===")"||a==="]")r--;if(r===0)return i}return-1}function lp(e){let n=[],r=0,i=0;for(let a=0;a<e.length;a++){let l=e[a];if(l==="{"||l==="("||l==="[")r++;else if(l==="}"||l===")"||l==="]")r--;else if(l===","&&r===0)n.push(e.slice(i,a)),i=a+1}return n.push(e.slice(i)),n}function pa(e){let n=0;for(let r=0;r<e.length;r++){let i=e[r];if(i==="{"||i==="("||i==="[")n++;else if(i==="}"||i===")"||i==="]")n--;else if(n===0&&(i===":"||i==="="))return{index:r,char:i}}return null}function $a(e){let n=[],r=(a)=>{let l=a.trim().replace(/^\.\.\./,"").trim();if(l.startsWith("{")||l.startsWith("[")){let f=Sa(l,0);if(f!==-1)n.push(...$a(l.slice(0,f+1)));return}let u=pa(l);if(u)l=l.slice(0,u.index).trim();if(/^[A-Z_$][\w$]*$/i.test(l))n.push(l)},i=e.slice(1,-1);for(let a of lp(i)){if(!a.trim())continue;if(e[0]==="["){r(a);continue}let l=pa(a);r(l?.char===":"?a.slice(l.index+1):a)}return n}function cl(e,n){if(_a(e)!==null)return[];let r=Oi(e),i=Le(n,new Set(r)),a=new Set(C);return r.filter((l)=>{if(a.has(l))return!1;if(Vt(n,l))return!1;return i.has(l)})}var fa="stx: types for the declared client payload (#1868)",up="stx: untyped bridge names \u2014 declare a defineClientPayload to check these (#1868)",da="__stxServerScope",ga="__StxClientPayload";var ma=["$env","$user","$slot","$slots","$attrs","$props","$page","$route","$loop","loop","$errors","$csrf","$native","props","slot"];var pp=/^\s*[A-Z_$][\w$]*\s*=[^=]/i;function fp(e){let n=new Map,r=/!|===|!==|==|!=|&&|\|\||<|>|\btypeof\b|\binstanceof\b|\bin\b/;for(let i of e){let a=t(i),{depths:l,balanced:u}=h(a);if(!u)continue;let f=/^([ \t]*(?:export[ \t]+)?const[ \t]+)([A-Za-z_$][\w$]*)[ \t]*(?::[^=\n]+)?=[ \t]*([^\n]+)$/gm;for(let v of a.matchAll(f)){let S=v.index??0;if(l[S+v[1].length]!==0)continue;let I=v[2],j=S+v[0].length-v[3].length,L=i.slice(j,S+v[0].length).trim().replace(/;$/,"").trim(),M=v[3],V=r.test(M)&&!/\bawait\b|=>|\bfunction\b|[{}]/.test(M)&&!/[,+\-*/%&|?:=]$/.test(L)&&h(M).balanced;n.set(I,n.has(I)||!V?null:L)}}return new Map([...n].filter((i)=>i[1]!==null))}function Ea(e,n,r=0,i=new Set){if(n.size===0||r>=5)return e;let a=t(e),l="",u=0;for(let f of a.matchAll(/[A-Za-z_$][\w$]*/g)){let v=f.index??0,S=f[0],I=n.get(S);if(!I||i.has(S))continue;let j=a.slice(0,v).trimEnd(),L=a.slice(v+S.length).trimStart();if(j.endsWith(".")||/^:(?!:)/.test(L)&&/[{,]$/.test(j))continue;if(v>0&&/[\w$]/.test(a[v-1]))continue;l+=`${e.slice(u,v)}(${Ea(I,n,r+1,new Set([...i,S]))})`,u=v+S.length}return l+e.slice(u)}function dp(e,n){let r=/@(if|unless|elseif|else|endif|endunless)\b\s*(\()?/g,i=[],a;while((a=r.exec(e))!==null){if(a.index>n)break;let l=a[1];if(a.index===n){if(l==="elseif"){let f=i[i.length-1];if(f?.current)f.seen.push(f.current);if(f)f.current=null}break}if(l==="endif"||l==="endunless"){i.pop();continue}let u="";if(a[2]==="("){let f=0,v=a.index+a[0].length-1,S=v+1;for(;v<e.length;v++){let I=e[v];if(I==="(")f++;else if(I===")"){if(f--,f===0)break}}u=e.slice(S,v).trim(),r.lastIndex=v+1}if(l==="if")i.push({seen:[],current:u});else if(l==="unless")i.push({seen:[],current:`!(${u})`});else if(l==="elseif"||l==="else"){let f=i[i.length-1];if(!f)continue;if(f.current)f.seen.push(f.current);f.current=l==="elseif"?u:null}}return i.flatMap((l)=>[...l.seen.map((u)=>`!(${u})`),...l.current?[l.current]:[]]).filter(Boolean)}function gp(e){let n=e.code.trim();if(!n)return null;if(e.attribute?.startsWith("@")){if(pp.test(n))return null;let i=";(($event: any): void => { ";return{text:`${i}${n} });`,prefixLength:i.length}}let r=";void ((";return{text:`${r}${n}));`,prefixLength:r.length}}var mp=/(\bfrom\s*|\bimport\s*\(\s*|\bimport\s+)(['"])(\.{1,2}\/[^'"\n]*)\2/g;function Es(e,n){return ro(e,n).code}function ro(e,n){let r=new Map;if(!n)return{code:e,columns:r};let i=ka(e),a=[],l=0;for(let u of e.matchAll(mp)){let f=u.index,[v,S,I,j]=u,L=ha.resolve(n,j).replace(/\\/g,"/"),M=`${S}${I}${L}${I}`;if(a.push(e.slice(l,f),M),l=f+v.length,v.includes(`
|
|
1150
|
+
`))continue;let V=Er(i,f),W=r.get(V.line)??[],Z=W.at(-1),q=V.column+(Z?Z.generatedEnd-Z.sourceEnd:0);W.push({sourceStart:V.column,sourceEnd:V.column+v.length,generatedStart:q,generatedEnd:q+M.length}),r.set(V.line,W)}return a.push(e.slice(l)),{code:a.join(""),columns:r}}function hp(e,n,r){let i=vr(e.importColumns?.get(n)??[],r);return vr(e.scriptColumns?.get(n)??[],vr(e.componentColumns?.get(n)??[],i))}function Ni(e){return" ".repeat(Math.max(0,(e.startColumn??1)-1))}function ks(e){let n=new Set,r=t(e);for(let i of r.matchAll(/\bimport\s+(?:type\s+)?([\w$*{}\s,]+?)\s+from\b/g)){let a=i[1],l=/\{([^}]*)\}/.exec(a);for(let S of l?.[1].split(",")??[]){let I=S.trim().replace(/^type\s+/,"").split(/\s+as\s+/).pop()?.trim();if(I&&/^[A-Z_$][\w$]*$/i.test(I))n.add(I)}let u=a.replace(/\{[^}]*\}/,""),f=/\*\s*as\s+([A-Z_$][\w$]*)/i.exec(u);if(f)n.add(f[1]);let v=/^\s*([A-Z_$][\w$]*)/i.exec(u);if(v&&v[1]!=="type")n.add(v[1])}return[...n].sort()}function Mi(e,n={}){let r=_e(e),i=n.scriptKinds?r.filter((H)=>n.scriptKinds.includes(H.kind)):r,a=to(e,n.componentMethodValidator),l=n.filePath&&n.templateExpressions!==!1?oa(e,{filePath:n.filePath,partialsDir:n.partialsDir,layoutsDir:n.layoutsDir,contractsKnown:n.inheritedContractsKnown,readTemplate:n.readComponent}):void 0,u=new Map,f=e.split(`
|
|
1151
|
+
`),v=Array.from({length:f.length},()=>""),S=new Map,I=new Map,j=new Map,L=[],M=Ii(r),V=n.filePath&&n.templateExpressions!==!1?Ko(e,ln(e),{filePath:n.filePath,componentsDir:n.componentsDir,projectRoot:n.projectRoot,readComponent:n.readComponent,scriptCode:(H,re)=>_e(H).map((ce)=>Es(ce.code,ha.dirname(re))).join(`
|
|
1152
|
+
`)}):void 0,W=new Set,Z=[];for(let[H,re]of i.entries()){let ce=Pi(Ni(re)+re.code,M,String(H));for(let[Re,ve]of ce.columns)I.set(re.startLine+Re-1,ve);for(let Re of ce.declarations)L.push({text:Es(Re.text,n.originDir??""),origin:Re.origin?{...Re.origin,line:Re.origin.line+re.startLine-1}:void 0});let le=re.kind==="client"&&a?a.project(ce.code):void 0;for(let[Re,ve]of le?.columns??[])u.set(re.startLine+Re-1,ve);let fe=En(le?.code??ce.code),we=ro(fe,n.originDir??"");for(let[Re,ve]of we.columns)j.set(re.startLine+Re-1,ve);let Ee=we.code.split(`
|
|
1153
|
+
`);Ee.forEach((Re,ve)=>{let Qe=re.startLine-1+ve;if(Qe<v.length)v[Qe]=Re,W.add(Qe)}),Z.push(re.startLine-1+Ee.length-1)}for(let H of Z){let re=v[H]?.trim()===""?H:H+1;if(re<v.length&&v[re].trim()===""&&(re===H||!W.has(re)))v[re]=";"}let q=(H,re)=>{for(let[ce,le]of H.split(`
|
|
1154
|
+
`).entries())if(v.push(le),re)S.set(v.length,ce===0?re:{...re,line:re.line+ce,column:1,prefixLength:0})},G=eo(i.filter((H)=>H.kind==="server").map((H)=>H.code).join(`
|
|
1155
|
+
`));if(G)q(G);for(let H of i.filter((re)=>re.kind==="server")){let re=qt(H.code);if(!re?.unsupported)continue;let ce=H.code.slice(0,re.offset),le=H.startLine+ce.split(`
|
|
1156
|
+
`).length-1,fe=re.offset-H.code.lastIndexOf(`
|
|
1157
|
+
`,re.offset-1)+(le===H.startLine?(H.startColumn??1)-1:0);q(`;({})[${JSON.stringify(re.unsupported)}];`,{line:le,column:fe,anchor:!0})}if(l?.declarations)q(l.declarations);for(let H of L)q(H.text,H.origin);if(a){if(q(a.declarations),n.nativeChecks!==!1)for(let H of a.checks)q(H.text,{line:H.line,column:H.column,diagnosticOrigin:H.origin,anchor:!0})}if(n.globals!==!1){q("");let H=new Set([...i.flatMap((fe)=>ye(fe.code)),...i.flatMap((fe)=>ks(fe.code))]),re=(fe)=>{if(!H.has(fe)&&!n.declaredGlobals?.includes(fe))q(`declare var ${fe}: any`)};if(n.runtimeGlobals!==!1){if(!H.has("window"))q("declare var window: any");for(let fe of C)re(fe)}let ce=[...new Set([...$r,...Ie,...ma])].filter((fe)=>!n.declaredGlobals?.includes(fe)&&(n.runtimeGlobals!==!1||!C.includes(fe)));if(n.contextScope==="global"){q("declare global {");for(let fe of ce)q(` var ${fe}: any`);q("}")}else{for(let fe of $r)re(fe);for(let fe of Ie)re(fe);for(let fe of ma)re(fe)}q(`declare var ${Sr}: any`);let le=new Set(i.flatMap((fe)=>ye(fe.code)));q(`type ${ca}<T> = T extends readonly (infer E)[] ? E : T extends Iterable<infer E2> ? E2 : any`);for(let fe of a?[]:rp(e)){if(le.has(fe.name))continue;let we=fe.iterable&&le.has(fe.iterable)?`${ca}<typeof ${fe.iterable}>`:"any";q(`declare var ${fe.name}: ${we}`)}}if(n.templateExpressions!==!1){if(V?.declarations)for(let re of V.declarations.split(`
|
|
1158
|
+
`))q(re);let H=no(e).map((re)=>{let ce=V?.events.get(re.offset??-1);if(ce){re.anchor=!0;let le=re.code.trim(),fe=/^([\w$]+)\s*=\s*([^=][\s\S]*)$/.exec(le),we=fe?`void ((${fe[2]}) satisfies __StxAssignedValue<typeof ${fe[1]}>)`:/^[\w$]+(?:\.[\w$]+)*$/.test(le)?`${le} satisfies (($event: ${ce}) => unknown)`:le,Ee=`;(($event: ${ce}): void => { `;return{expression:re,statement:{text:`${Ee}${we} });`,prefixLength:Ee.length}}}return{expression:re,statement:gp(re)}}).filter((re)=>re.statement!==null);if(H.push(...V?.checks||[],...l?.checks||[]),H.length>0){let re=ln(e),ce=hs(re),le=a?aa(re):[];if(a)q("type __StxNativeValue<T> = T extends readonly (infer E)[] ? E : T extends object ? T[keyof T] : never; declare function __stxEach<T>(items: T, callback: (item: __StxNativeValue<T>, key: string) => void): void;");let fe=fp(i.map((ve)=>ve.code)),Ee=[...new Set(i.flatMap((ve)=>ye(ve.code)))].filter((ve)=>/^[A-Z_$][\w$]*$/i.test(ve)),Re=0;if(a)q("function __stxNativeTemplate(this: __StxNativeComponent) {");if(Ee.length>0){q(Yu);for(let ve of Ee)q(`function __StxRead_${ve}() { return ${ve} }`),q(`type __StxT_${ve} = ${ya}<ReturnType<typeof __StxRead_${ve}>>`);q(`;((${Ee.map((ve)=>`${ve}: __StxT_${ve}`).join(", ")}) => {`),Re=1}for(let{expression:ve,statement:Qe}of H){let Be=" ".repeat(Re),it=ve.offset===void 0?[]:ce.filter((nt)=>ve.offset>=nt.start&&ve.offset<nt.end),rt=ve.offset===void 0?[]:le.filter((nt)=>ve.offset>=nt.start&&ve.offset<nt.end),wt=rt.map((nt)=>`;__stxEach(${nt.iterable}, (${nt.binding}) => { `).join(""),ft=" });".repeat(rt.length),ot=wt+it.map((nt)=>`;((${nt.binding.replace(/[\r\n]/g," ")}: any) => { `).join(""),Nt=" });".repeat(it.length)+ft,je=ve.offset===void 0?[]:dp(re,ve.offset),Ae=je.length>0?`${je.map((nt)=>`if (${Ea(nt,fe)}) `).join("")}{ `:"",dt=je.length>0?" }":"";q(Be+ot+Ae+Qe.text+dt+Nt,{line:ve.line,column:ve.column,expression:ve,prefixLength:Qe.prefixLength+Be.length+ot.length+Ae.length,guardPrefixLength:Be.length+ot.length+Ae.length})}if(Re>0)q("});");if(a)q("}")}}let U=!1;if(n.reference&&v[0]!==void 0&&v[0].trim()==="")v[0]=`/// <reference path=${JSON.stringify(n.reference.replace(/\\/g,"/"))} />`,U=!0;return q("export {}"),{text:v.join(`
|
|
1159
|
+
`),lineMap:S,sourceLineCount:f.length,componentDependencies:new Map([...V?.dependencies??[],...l?.dependencies??[]]),referenced:U,scriptColumns:I,importColumns:j,componentColumns:u}}function ka(e){let n=[0];for(let r=0;r<e.length;r++)if(e.charCodeAt(r)===10)n.push(r+1);return n}function Er(e,n){let r=0,i=e.length-1;while(r<i){let a=Math.ceil((r+i)/2);if(e[a]<=n)r=a;else i=a-1}return{line:r+1,column:n-e[r]+1}}function ll(e,n){if(!e.expression)return!1;return e.inGuard===!0||n===2774}function Di(e,n,r){let i=e.lineMap.get(n);if(!i)return n<=e.sourceLineCount?{line:n,column:hp(e,n,r)}:null;let a=i.anchor||i.expression?.anchor||i.diagnosticOrigin==="component"?0:Math.max(0,r-1-(i.prefixLength??0));return{line:i.line,column:i.column+a,expression:i.expression,diagnosticOrigin:i.diagnosticOrigin,inGuard:r<=(i.guardPrefixLength??0)}}var kr=k(256),xp=[{pattern:/document\.getElementById\s*\(/g,message:"document.getElementById() is prohibited",suggestion:'Use useRef("name") instead'},{pattern:/document\.querySelector\s*\(/g,message:"document.querySelector() is prohibited",suggestion:'Use useRef("name") instead'},{pattern:/document\.querySelectorAll\s*\(/g,message:"document.querySelectorAll() is prohibited",suggestion:'Use useRef("name") and access children instead'},{pattern:/document\.getElementsBy\w+\s*\(/g,message:"document.getElementsBy*() is prohibited",suggestion:'Use useRef("name") instead'},{pattern:/document\.createElement\s*\(/g,message:"document.createElement() is prohibited",suggestion:"Use template directives or component composition instead"},{pattern:/document\.activeElement(?![A-Za-z])/g,message:"document.activeElement is prohibited",suggestion:"Use useRef() to track focused elements"},{pattern:/document\.title\s*=/g,message:"document.title assignment is prohibited",suggestion:"Use useTitle() from composables"},{pattern:/document\.cookie(?![A-Za-z])/g,message:"document.cookie is prohibited",suggestion:"Use useCookie() from composables"},{pattern:/document\.addEventListener\s*\(/g,message:"document.addEventListener() is prohibited",suggestion:"Use useEventListener() or template @event directives"},{pattern:/window\.location(?![A-Za-z])/g,message:"window.location is prohibited",suggestion:"Use navigate() or useRoute()"},{pattern:/window\.history(?![A-Za-z])/g,message:"window.history is prohibited",suggestion:"Use navigate(), goBack(), goForward()"},{pattern:/window\.addEventListener\s*\(/g,message:"window.addEventListener() is prohibited",suggestion:"Use useEventListener() or @click directives"},{pattern:/(?:\bwindow\.)?localStorage(?![A-Za-z])/g,message:"window.localStorage is prohibited",suggestion:"Use useLocalStorage() from composables \u2014 or, where this must run before first paint and the runtime does not exist yet, the colorMode config for a light/dark theme, or @appearanceBootstrap when there is a second appearance axis"},{pattern:/window\.sessionStorage(?![A-Za-z])/g,message:"window.sessionStorage is prohibited",suggestion:"Use useSessionStorage() from composables"},{pattern:/window\.scrollTo\s*\(/g,message:"window.scrollTo() is prohibited",suggestion:"Use useScroll().scrollTo() from composables"},{pattern:/window\.alert\s*\(/g,message:"window.alert() is prohibited",suggestion:"Use stx modal/dialog APIs instead"},{pattern:/window\.confirm\s*\(/g,message:"window.confirm() is prohibited",suggestion:"Use stx modal/dialog APIs instead"},{pattern:/window\.prompt\s*\(/g,message:"window.prompt() is prohibited",suggestion:"Use stx modal/dialog APIs instead"},{pattern:/(?<!\w)setTimeout\s*\(/g,message:"setTimeout() is prohibited",suggestion:"Use useTimeout() or useDebounce() from composables"},{pattern:/(?<!\w)setInterval\s*\(/g,message:"setInterval() is prohibited",suggestion:"Use useInterval() from composables"},{pattern:/(?<!\w)clearTimeout\s*\(/g,message:"clearTimeout() is prohibited",suggestion:"Use useTimeout().stop() or useDebounce().cancel()"},{pattern:/(?<!\w)clearInterval\s*\(/g,message:"clearInterval() is prohibited",suggestion:"Use useInterval().pause()"},{pattern:/(?<!\w)location\.href\s*=/g,message:"location.href assignment is prohibited",suggestion:"Use navigate() instead"},{pattern:/(?<!\w)location\.assign\s*\(/g,message:"location.assign() is prohibited",suggestion:"Use navigate() instead"},{pattern:/(?<!\w)location\.replace\s*\(/g,message:"location.replace() is prohibited",suggestion:"Use navigate() instead"}],Ca=/(?:\/\/|\/\*|\{\{--)\s*stx-strict-ignore(-next-line)?([^\n*}]*)/g;function bp(e){let n=Array.from(e,(a)=>a===`
|
|
1160
|
+
`?`
|
|
1161
|
+
`:" "),r=0,i="";while(r<e.length){let a=e[r],l=e[r+1];if(i){if(a==="\\"){r+=2;continue}if(a===i)i="";r++;continue}if(a==='"'||a==="'"||a==="`"){i=a,r++;continue}if(a==="/"&&l==="/"){while(r<e.length&&e[r]!==`
|
|
1162
|
+
`)n[r]=e[r],r++;continue}if(a==="/"&&l==="*"){let u=e.indexOf("*/",r+2),f=u===-1?e.length:u+2;for(;r<f;r++)n[r]=e[r];continue}if(a==="{"&&l==="{"&&e.slice(r,r+4)==="{{--"){let u=e.indexOf("--}}",r+4),f=u===-1?e.length:u+4;for(;r<f;r++)n[r]=e[r];continue}r++}return n.join("")}function yp(e){let n=new Map,r=bp(e).split(`
|
|
1163
|
+
`),i=e.split(`
|
|
1164
|
+
`);return r.forEach((a,l)=>{Ca.lastIndex=0;for(let u of a.matchAll(Ca)){let f=u[1]==="-next-line",v=(i[l]??"").slice(0,u.index).trim(),S=f||v===""?l+2:l+1,j=(u[2]??"").split("--")[0].split(/[\s,]+/).filter(Boolean),L=j.filter((V)=>/\w/.test(V));if(j.length>0&&L.length===0)continue;let M=n.get(S);if(M&&M.size===0)continue;if(L.length===0){n.set(S,new Set);continue}if(M)L.forEach((V)=>M.add(V));else n.set(S,new Set(L))}}),n}function _p(e,n,r){let i=e.get(n);if(!i)return!1;if(i.size===0)return!0;return[...i].some((a)=>r.includes(a))}function We(e,n,r,i){let a=typeof r==="boolean"?{enabled:r,failOnViolation:r}:r??{enabled:!1};if(!a.enabled)return;let l=E(e,n,i,JSON.stringify(a)),u=kr.get(l);if(u!==void 0){if(u&&a.failOnViolation)throw new te(u,i??n);return}let f=a.allowPatterns??[],v=yp(e),S=[],I=t(e.replace(/\{\{--[\s\S]*?--\}\}/g,(V)=>V.replace(/[^\n]/g," ")));for(let{pattern:V,message:W,suggestion:Z}of xp){if(f.some((G)=>/\w/.test(G)&&W.includes(G)))continue;V.lastIndex=0;let q=I.match(V);if(q&&q.length>0){let G=I.split(`
|
|
1165
|
+
`),U=e.split(`
|
|
1166
|
+
`),H=[];if(G.forEach((fe,we)=>{if(V.lastIndex=0,V.test(fe)&&!_p(v,we+1,W))H.push(we+1)}),H.length===0&&G.some((fe)=>(V.lastIndex=0,V.test(fe))))continue;let re=H.length>0?` (script line${H.length>1?"s":""} ${H.join(", ")})`:"",ce=H.slice(0,3).map((fe)=>` ${fe} | ${(U[fe-1]??"").trim().slice(0,100)}`).join(`
|
|
1167
|
+
`),le=ce?`
|
|
1168
|
+
${ce}`:"";S.push(` \u2717 ${W}${re}
|
|
1169
|
+
\u2192 ${Z}${le}`)}}if(S.length===0){kr.set(l,"");return}let j=(V)=>{let W=`${process.cwd()}/`;return V.startsWith(W)?V.slice(W.length):V},M=`[STX] DOM API violation in ${i&&i!==n?`${j(i)} (composed into ${j(n)})`:j(n)}:
|
|
1170
|
+
${S.join(`
|
|
1171
|
+
`)}
|
|
1172
|
+
Tip: prefer useRef(), navigate(), and composables for component code`;if(kr.set(l,M),console.warn(M),a.failOnViolation)throw new te(M,i??n)}var wp=[{open:"@if",close:"@endif",name:"if"},{open:"@unless",close:"@endunless",name:"unless"},{open:"@foreach",close:"@endforeach",name:"foreach"},{open:"@for",close:"@endfor",name:"for"},{open:"@while",close:"@endwhile",name:"while"},{open:"@forelse",close:"@endforelse",name:"forelse"},{open:"@switch",close:"@endswitch",name:"switch"},{open:"@isset",close:"@endisset",name:"isset"},{open:"@empty",close:"@endempty",name:"empty"},{open:"@auth",close:"@endauth",name:"auth"},{open:"@guest",close:"@endguest",name:"guest"},{open:"@can",close:"@endcan",name:"can"},{open:"@cannot",close:"@endcannot",name:"cannot"},{open:"@section",close:"@endsection",name:"section",altClose:"@show"},{open:"@push",close:"@endpush",name:"push"},{open:"@prepend",close:"@endprepend",name:"prepend"},{open:"@once",close:"@endonce",name:"once"},{open:"@markdown",close:"@endmarkdown",name:"markdown"},{open:"@component",close:"@endcomponent",name:"component"}],vp=[{pattern:/@if\s*[^(]/,message:"@if directive missing parentheses",suggestion:"Use @if(condition)"},{pattern:/@foreach\s*[^(]/,message:"@foreach directive missing parentheses",suggestion:"Use @foreach(items as item)"},{pattern:/@foreach\([^)]*\)\s*[^@\n<]/,message:"@foreach may have content on same line",suggestion:"Put content on new line after @foreach()"},{pattern:/@include\s*[^(]/,message:"@include directive missing parentheses",suggestion:"Use @include('partial-name')"},{pattern:/@extends\s*[^(]/,message:"@extends directive missing parentheses",suggestion:"Use @extends('layout-name') or @layout('layout-name')"},{pattern:/@layout\s*[^(]/,message:"@layout directive missing parentheses",suggestion:"Use @layout('layout-name')"}],Sp=[{pattern:/\{\{\s*constructor\s*\}\}/,message:"Attempting to access constructor property"},{pattern:/\{\{\s*__proto__\s*\}\}/,message:"Attempting to access __proto__ property"},{pattern:/\{\{\s*eval\s*\(/,message:"Attempting to use eval in expression"}];function jg(e){let n=[],r=[];return $p(e,n),Ep(e,n,r),kp(e,r),Cp(e,n),{valid:n.length===0,errors:n,warnings:r}}function $p(e,n){let r=(e.match(/\{\{/g)||[]).length,i=(e.match(/\}\}/g)||[]).length;if(r!==i)n.push({type:"expression",message:`Unclosed expression brackets: found ${r} opening '{{' and ${i} closing '}}'`,suggestion:"Ensure every {{ has a matching }}"})}function Ep(e,n,r){for(let i of wp){let a=new RegExp(`${i.open}(?:\\s|\\()`,"g"),l=new RegExp(i.close,"g"),u=(e.match(a)||[]).length,f=(e.match(l)||[]).length;if(i.altClose){let v=new RegExp(i.altClose,"g");f+=(e.match(v)||[]).length}if(u>f)n.push({type:"directive",message:`Unclosed @${i.name} directive: found ${u} opening and ${f} closing`,suggestion:`Add ${u-f} missing ${i.close} tag(s)`});else if(f>u)r.push({type:"directive",message:`Extra ${i.close} found: ${f-u} more closing than opening`,suggestion:`Check for orphaned ${i.close} tags`})}}function kp(e,n){for(let r of vp)if(r.pattern.test(e))n.push({type:"syntax",message:r.message,suggestion:r.suggestion})}function Cp(e,n){for(let r of Sp)if(r.pattern.test(e))n.push({type:"expression",message:`Security warning: ${r.message}`,suggestion:"Remove dangerous code from template expressions"})}function Bg(e,n){let r=e.slice(0,n).split(`
|
|
1173
|
+
`);return{line:r.length,column:r[r.length-1].length+1}}function Fg(e,n,r){let i=[];switch(e){case"if":case"elseif":case"unless":if(r.length===0)i.push({type:"syntax",message:`@${e} requires a condition`,suggestion:`Use @${e}(condition)`});break;case"foreach":if(r.length===0||!r[0].includes(" as "))i.push({type:"syntax",message:'@foreach requires "items as item" syntax',suggestion:"Use @foreach(items as item) or @foreach(items as key => value)"});break;case"for":if(r.length===0)i.push({type:"syntax",message:"@for requires loop parameters",suggestion:"Use @for(let i = 0; i < 10; i++)"});break;case"switch":if(r.length===0)i.push({type:"syntax",message:"@switch requires an expression",suggestion:"Use @switch(expression)"});break;case"case":if(r.length===0)i.push({type:"syntax",message:"@case requires a value",suggestion:"Use @case(value)"});break;case"include":case"extends":case"component":if(r.length===0)i.push({type:"syntax",message:`@${e} requires a path`,suggestion:`Use @${e}('path/to/template')`});break}return i}function zg(e){return/@[a-z]+/i.test(e)||/\{\{/.test(e)}function Hg(e){let n=e.matchAll(/@([a-z]+)/gi),r=new Set;for(let i of n){let a=i[1].toLowerCase();if(!a.startsWith("end"))r.add(a)}return Array.from(r)}function Ra(e,n,r){let i=/^<script\b([^>]*)>/i.exec(e);if(!i||!/(?:^|\s)src\s*=/i.test(i[1]??""))return null;return P(i[0],n,r)+e.slice(i[0].length)}var Wn=new T(500),Tr=new Map;function Ta(e){try{let n=Is.statSync(e);return`${n.size}:${n.mtimeMs}`}catch{return""}}var Ts=new T(1000),Ar=new Map,Pr=new T(2000),Wr=new T(500),La=33554432,Vr=La;function Rp(e){let n=e.componentRenderCacheBytes;if(typeof n!=="number"||n<0||n===Vr)return;Vr=n,As.setMaxBytes(n)}var As=new T(2000,{maxBytes:La,sizeOf:(e)=>e.output.length});function Tp(e){let n=new WeakSet;try{let r=(i)=>{if(i===void 0)return{__stxType:"undefined"};if(typeof i==="bigint")return{__stxType:"bigint",value:i.toString()};if(typeof i==="function"||typeof i==="symbol")throw TypeError("Non-serializable component input");if(i===null||typeof i!=="object")return i;if(n.has(i))throw TypeError("Circular component input");n.add(i);try{if(i instanceof Date)return{__stxType:"date",value:i.toISOString()};if(Array.isArray(i))return i.map(r);let a=Object.getPrototypeOf(i);if(a!==Object.prototype&&a!==null)throw TypeError("Non-plain component input");let l={};for(let u of Object.keys(i).sort())l[u]=r(i[u]);return l}finally{n.delete(i)}};return JSON.stringify(r(e))}catch{return null}}function Ap(e){let n={};for(let[r,i]of Object.entries(e))if(!r.startsWith("__")||r==="__stxServeContext")n[r]=i;return n}function Cr(e){return e.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}function co(e){let n=process.cwd(),r=`${n}\x00${e}`,i=Aa.get(r);if(i===void 0)i=Bun.hash(za(e,n).split(ge.sep).join("/")).toString(36).slice(0,6),Aa.set(r,i);return i}var Aa=new Map;function za(e,n){if(!ge.isAbsolute(e))return e;let r=(i)=>{try{return Is.realpathSync(i)}catch{return i}};return ge.relative(r(n),r(e))}function Vg(e){return/\bjs\b/.test(e)||/\blang\s*=\s*["']?(js|javascript)["']?/i.test(e)}function Xe(e){return!Vg(e)}var Rs=new Map;function ie(e){let n;try{n=JSON.stringify(e)}catch{return new Bun.Transpiler(e)}let r=Rs.get(n);if(r)return r;if(Rs.size>=16)Rs.clear();let i=new Bun.Transpiler(e);return Rs.set(n,i),i}var Ia=new WeakMap,Ip=256;function Je(e){try{let n=ie({loader:"ts",target:"browser",define:A()}),r=Ia.get(n);if(!r)r=new Map,Ia.set(n,r);let i=r.get(e);if(i!==void 0)return i;let a=e.replace(/^\s*import\s+\w+\s+from\s+['"][^'"]*\.stx['"]\s*;?\s*$/gm,"");a=a.replace(/^\s*import\s+['"][^'"]*\.stx['"]\s*;?\s*$/gm,"");let l=[];a=a.replace(/\{!![\s\S]*?!!\}/g,(f)=>{let v=l.length;return l.push(f),`"__STX_EXPR_${v}__"`}),a=a.replace(/\{\{\{[\s\S]*?\}\}\}/g,(f)=>{let v=l.length;return l.push(f),`"__STX_EXPR_${v}__"`}),a=a.replace(/\{\{[\s\S]*?\}\}/g,(f)=>{let v=l.length;return l.push(f),`"__STX_EXPR_${v}__"`});let u=n.transformSync(a);for(let f=0;f<l.length;f++)u=u.replace(`"__STX_EXPR_${f}__"`,l[f]),u=u.replace(`'__STX_EXPR_${f}__'`,l[f]);if(r.size>=Ip){let f=r.keys().next();if(!f.done)r.delete(f.value)}return r.set(e,u),u}catch(n){if(process.env.STX_DEBUG_TS)console.warn("[STX] TypeScript transpilation error:",n);return e}}function Op(e){let n=[],r=new Set,i=0,a=0,l=e.length,u=(M)=>{a++;while(a<l){if(e[a]==="\\"){a+=2;continue}if(e[a]===M){a++;return}a++}},f=()=>{a++;while(a<l){if(e[a]==="\\"){a+=2;continue}if(e[a]==="`"){a++;return}if(e[a]==="$"&&e[a+1]==="{"){a+=2;let M=1;while(a<l&&M>0)if(e[a]==="{")M++,a++;else if(e[a]==="}")M--,a++;else if(e[a]==="'"||e[a]==='"')u(e[a]);else if(e[a]==="`")f();else a++;continue}a++}},v=()=>{if(e[a]==="/"&&e[a+1]==="/"){while(a<l&&e[a]!==`
|
|
1174
|
+
`)a++;return!0}if(e[a]==="/"&&e[a+1]==="*"){a+=2;while(a<l-1&&!(e[a]==="*"&&e[a+1]==="/"))a++;return a+=2,!0}return!1},S=new Set(["return","typeof","instanceof","in","of","new","delete","void","throw","case","do","else","yield","await"]),I=()=>{let M=a-1;while(M>=0&&/\s/.test(e[M]))M--;if(M<0)return!0;let V=e[M];if("(,=:[!&|?{};+-*%<>~^".includes(V))return!0;if(!/[\w$]/.test(V))return!1;let W=M;while(W>0&&/[\w$]/.test(e[W-1]))W--;return S.has(e.slice(W,M+1))},j=()=>{a++;let M=!1;while(a<l&&e[a]!==`
|
|
1175
|
+
`){let V=e[a];if(V==="\\"){a+=2;continue}if(V==="[")M=!0;else if(V==="]")M=!1;else if(V==="/"&&!M){a++;while(a<l&&/[a-z]/i.test(e[a]))a++;return}a++}},L=()=>{if(i!==0)return;let M=e.slice(a).match(/^(const|let|var)\s*\{([^}]+)\}\s*=/);if(M){let q=M[2].split(",").map((G)=>{let U=G.trim().split(":");return U[U.length-1].trim()});for(let G of q)if(G&&/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(G)&&!r.has(G))n.push(G),r.add(G);return}let V=e.slice(a).match(/^(const|let|var)\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*=/);if(V){let q=V[2];if(!r.has(q))n.push(q),r.add(q);return}let W=e.slice(a).match(/^function\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*\(/);if(W){let q=W[1];if(!r.has(q))n.push(q),r.add(q);return}let Z=e.slice(a).match(/^async\s+function\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*\(/);if(Z){let q=Z[1];if(!r.has(q))n.push(q),r.add(q)}};while(a<l){if(v())continue;if(e[a]==="'"||e[a]==='"'){u(e[a]);continue}if(e[a]==="`"){f();continue}if(e[a]==="/"&&I()){j();continue}if(e[a]==="{"){i++,a++;continue}if(e[a]==="}"){i--,a++;continue}if(i===0&&/[a-z]/i.test(e[a])&&(a===0||/\s|[;{}()]/.test(e[a-1])))L();a++}return n}function jp(e,n,r){for(let i of ee(e)){let a=O(i.attrs);if(["server","src","component","stx:component"].some((f)=>a.has(f))||!$t(a))continue;let l=an(e.slice(i.bodyStart,i.bodyEnd));if(!l)continue;let u=Object.assign(Object.create(null),r);for(let[f,v]of Object.entries(l.defaults))if(u[f]===void 0)u[f]=ws(v);for(let f of new Set([...l.propNames,...Object.keys(l.defaults)])){let v=l.localBindings[f]??(l.propBindings[f]?void 0:f);if(v)Object.defineProperty(n,v,{value:u[f],writable:!0,enumerable:!0,configurable:!0})}if(l.identifier)Object.defineProperty(n,l.identifier,{value:u,writable:!0,enumerable:!0,configurable:!0})}}var Pp=new Set(["tr","td","th","thead","tbody","tfoot","caption","colgroup","col","option","optgroup","li","dt","dd","span"]);function Ug(e,n){let r=Ut(e),i=e.slice(r).match(/^<([a-zA-Z][a-zA-Z0-9-]*)/);if(!i)return null;let a=i[1].toLowerCase();if(!Pp.has(a))return null;let l=new RegExp(`<\\/?${a}(?=[\\s/>])(?:[^>"']|"[^"]*"|'[^']*')*>`,"iy"),u=x(e,(I,j)=>(l.lastIndex=j,l.exec(I)?.index===j?l.lastIndex:-1));if(a==="span"&&/\sdata-stx-scope\s*=/.test(u[0]?.token||""))return null;let f=0,v=!1;for(let I of u){if(f+=I.token.startsWith("</")?-1:1,f<0)return null;if(f===0){if(e.slice(I.end).trim())return null;v=!0;break}}if(!v)return null;let S=r+i[0].length;return e.slice(0,S)+n+e.slice(S)}function Ba(e,n){if(!e)return!1;return[...n.additionalComponentsDirs??[],...n.fallbackComponentsDir?[n.fallbackComponentsDir]:[]].some((i)=>{let a=ge.relative(ge.resolve(i),ge.resolve(e));return!a.startsWith("..")&&!ge.isAbsolute(a)})}async function Fr(e,n,r,i,a){let l=e.endsWith(".stx")?e.slice(0,-4):e,u=(ce)=>ce.split("-").map((le)=>le.charAt(0).toUpperCase()+le.slice(1)).join(""),f=r.__importedComponents;if(f){for(let ce of[l,l.toLowerCase(),u(l),J(l)])if(f.has(ce))return!0}let v=[...new Set([`${l}.stx`,`${u(l)}.stx`,`${J(l)}.stx`])],S=typeof a.root==="string"?ge.resolve(a.root):void 0,I=S??ge.dirname(i),j=[],L=(ce)=>{if(ce&&!j.includes(ce))j.push(ce)};for(let ce of rs(i,S))L(ce);let M=r.__originalFilePath;if(M)L(ge.join(ge.dirname(M),"components"));if(Ba(n,a))L(a._rootComponentsDir);L(n),L(a._rootComponentsDir),L(ge.join(ge.dirname(i),"components")),L(a.componentsDir);for(let ce of a.additionalComponentsDirs??[])L(ce);let V=a._targetComponentFallbackNames?.some((ce)=>ce.toLowerCase()===l.toLowerCase());if(!V)for(let ce of a._targetComponentDirs??[])L(ce);if(S)L(ge.resolve(S,"resources/views/components")),L(ge.resolve(S,"resources/components")),L(ge.resolve(S,"src/components")),L(ge.resolve(S,"components"));for(let ce of a._layerComponentDirs??[])L(ce);let W=a._pluginComponentDirs;if(Array.isArray(W))for(let ce of W)L(typeof ce==="string"?ce:null);if(L(a.fallbackComponentsDir),V)for(let ce of a._targetComponentDirs??[])L(ce);let Z=a._nativePrimitivesFallback;if(Z&&!Z.except.some((ce)=>ce.toLowerCase()===l.toLowerCase()))L(Z.dir);if(l.startsWith("./")||l.startsWith("../"))return s(ge.resolve(ge.dirname(i),`${l}.stx`));let q=Oa(ge.resolve(import.meta.dir,"components")),G=j.map((ce)=>ge.isAbsolute(ce)?ce:ge.resolve(I,ce)),U=`${v.join("\x00")}\x00\x00${G.join("\x00")}`,H=Pr.get(U);if(H!==void 0)return H;let re=!1;e:for(let ce of G){if(Oa(ce)===q)continue;for(let le of v)if(await s(ge.join(ce,le))){re=!0;break e}}return Pr.set(U,re),re}function Oa(e){let n=Wr.get(e);if(n!==void 0)return n;let r=e;try{r=Is.realpathSync(e)}catch{}return Wr.set(e,r),r}function Wg(e){return e==="visible"||e==="idle"||e==="interaction"||e.startsWith("media:")}function Sl(e){if(!e)return!1;let n=e.replace(/<script[\s\S]*?<\/script>/gi,"").replace(/<style[\s\S]*?<\/style>/gi,"");return/\{\{[\s\S]*?\}\}|\{!![\s\S]*?!!\}/.test(n)}function Mp(e,n,r){if(!e.includes("{{")&&!e.includes("{!!"))return e;let i=(a,l)=>{let u;try{u=N(a,n)}catch{return l}if(u===void 0||u===null)return"";let f=String(u);if(/<\/style/i.test(f))return console.warn(`[stx] a <style> expression in ${r??"<unknown>"} evaluated to CSS containing a closing style tag, which would end the element early, so it was dropped rather than emitted.`),"";return f};return e.replace(/\{!!([\s\S]*?)!!\}/g,(a,l)=>i(l,a)).replace(/\{\{([\s\S]*?)\}\}/g,(a,l)=>i(l,a))}var ja=new Set;function Pa(e,n,r,i){let a=`${e}\x00${n}\x00${i??""}`;if(!process.env.STX_DEBUG&&ja.has(a))return;ja.add(a);let l=n?` used in ${n}`:"",u=i?` Cause: ${i}.`:"",f=r.length>0?`
|
|
1176
|
+
searched:
|
|
1177
|
+
${r.map((v)=>` - ${v}`).join(`
|
|
1178
|
+
`)}`:"";console.error(`[stx] component <${e}> could not be resolved${l}, so it rendered as nothing.${u}${f}`)}function Ma(e){return`<!-- stx: component "${e.replace(/--+/g,"-")}" could not be resolved; see the server log -->`}var Dp=new Set(["for","if","show","key","ref","class","className","style"]),Da=new Set,Wa="useMediaQuery|useDark|usePreferredDark|usePreferredLight|usePreferredReducedMotion|usePreferredContrast|useDocumentVisibility|useScrollLock",kl=new RegExp(`\\b(?:${Wa})\\s*(?:<[^>]*>)?\\s*\\(`);function Hi(e){let n=new Set,r=new RegExp(`\\b(?:const|let|var)\\s+([a-zA-Z_$][\\w$]*)\\s*=\\s*(?:state|derived|computed|ref|reactive|signal|useModel|useReactiveProp|useLocalStorage|useSessionStorage|keptState|useCookie|useDebouncedValue|${Wa})\\s*(?:<[^>]*>)?\\s*\\(`,"g");for(let i of e){let a;while((a=r.exec(i))!==null)n.add(a[1]);r.lastIndex=0}return[...n]}async function Ye(e,n,r,i,a,l,u,f=new Set,v,S=mt(a),I,j=e){let{extractVariables:L}=await o("stx/variable-extractor",()=>import("./chunk-kexqmwx8.js")),M=f??new Set;if(M.has(e))return`[Circular component reference: ${e}]`;let V=new Set(M);V.add(e);let W=typeof n.client==="string"?n.client.trim():"";if("client"in n)delete n.client;let Z=W&&W!=="load"&&Wg(W)?W:"";try{let q=(pe)=>pe.split("-").map((xe)=>xe.charAt(0).toUpperCase()+xe.slice(1)).join(""),G=j.endsWith(".stx")?j.slice(0,-4):j,U=null,H=a.__importedComponents;if(H){let pe=[G,G.toLowerCase(),q(G),J(G)];for(let xe of pe)if(H.has(xe)){U=H.get(xe);break}}let re=[];if(!U){let pe=[`${G}.stx`,`${q(G)}.stx`,`${J(G)}.stx`],xe=[...new Set(pe)],Me=a.__originalFilePath,$e=[];for(let Te of rs(l))if(!$e.includes(Te))$e.push(Te);let lt=$e.length;for(let Te of u._layerComponentDirs??[])if(!$e.includes(Te))$e.push(Te);if(Me){let Te=ge.join(ge.dirname(Me),"components");$e.push(Te)}let He=u._rootComponentsDir;if(typeof He==="string"&&Ba(i,u)&&!$e.includes(He))$e.push(He);if(i&&!$e.includes(i))$e.push(i);if(typeof He==="string"&&!$e.includes(He))$e.push(He);let Ot=ge.join(ge.dirname(l),"components");if(!$e.includes(Ot))$e.push(Ot);if(u.componentsDir&&u.componentsDir!==i&&!$e.includes(u.componentsDir))$e.push(u.componentsDir);for(let Te of u.additionalComponentsDirs??[])if(Te&&!$e.includes(Te))$e.push(Te);let Yt=u._nativeHostAttrs&&/^(?:checkbox|switch)$/i.test(G),Dt=(I?.events??[]).map((Te)=>Te.replace(/^@/,"").split(".")[0].toLowerCase().replace(/-/g,"")),Zn=Object.hasOwn(n,"checked")||Boolean(I?.reactiveProps?.includes("checked")),Ns=Object.hasOwn(n,"value")||Boolean(I?.reactiveProps?.includes("value")),Ls=!Dt.includes("valuechange")&&(Zn||Dt.includes("change")&&!Ns),Lt=u._nativeHostAttrs&&/^textinput$/i.test(G),Qt=Dt.includes("update:value")&&!Dt.includes("input"),yn=u._nativeHostAttrs&&/^video$/i.test(G),zs=u._nativeHostAttrs&&/^image$/i.test(G),Jn=Zs([...Object.keys(n),...I?.reactiveProps??[]],I?.events,n),en=Object.hasOwn(n,"src")||Boolean(I?.reactiveProps?.includes("src")),Xn=Object.hasOwn(n,"source")||Boolean(I?.reactiveProps?.includes("source")),Gn=yn&&(en||Xn)&&(I?.events??[]).every((Te)=>/^(?:play|pause|ended|timeupdate|loadedmetadata|loadstart|error)$/.test(Te.replace(/^@/,"").split(".")[0])),Yn=new Set(["","primary","secondary","outline","ghost","danger"]),Qn=typeof n.variant==="string"?n.variant.trim().toLowerCase():"",es=u._nativeHostAttrs&&/^button$/i.test(G)&&!Yn.has(Qn),Gr=u._targetComponentFallbackNames?.some((Te)=>Te.toLowerCase()===G.toLowerCase())??!1,Bs=Gr&&(!Yt||Ls)&&(!Lt||Qt)&&(!yn||Gn)&&(!zs||Jn)&&!es;for(let Te of Bs?[]:u._targetComponentDirs??[])if(Te&&!$e.includes(Te))$e.push(Te);let tn=typeof u.root==="string"?ge.resolve(u.root):void 0,Yr=tn??ge.dirname(l),nn=[];if(tn)nn.push(ge.resolve(tn,"resources/views/components")),nn.push(ge.resolve(tn,"resources/components")),nn.push(ge.resolve(tn,"src/components")),nn.push(ge.resolve(tn,"components"));nn.push(ge.resolve(import.meta.dir,"components"));for(let Te of nn)if(!$e.includes(Te))$e.push(Te);if(Gr){let Te=(u._componentPackageDirs??[]).filter((gt)=>typeof gt==="string"&>.length>0),jt=(Bs?Te.length?Te:u._pluginComponentDirs??[]:u._targetComponentDirs??[]).filter((gt)=>typeof gt==="string"&>.length>0);if(jt.length){let gt=$e.slice(lt).map((ut)=>ge.isAbsolute(ut)?ut:ge.resolve(Yr,ut)).filter((ut)=>!jt.includes(ut)),ns=`${G}\x00${gt.join("\x00")}`,kt=Ar.get(ns);if(kt===void 0){kt=!1;for(let ut of gt){for(let zt of xe)if(await s(ge.join(ut,zt))){kt=!0;break}if(kt)break}Ar.set(ns,kt)}if(!kt){for(let ut of jt){let zt=$e.indexOf(ut);if(zt>=0)$e.splice(zt,1)}$e.splice(lt,0,...jt)}}}let Qr=u._pluginComponentDirs;if(Array.isArray(Qr)){for(let Te of Qr)if(typeof Te==="string"&&!$e.includes(Te))$e.push(Te)}if(u.fallbackComponentsDir&&!$e.includes(u.fallbackComponentsDir))$e.push(u.fallbackComponentsDir);if(Bs){for(let Te of u._targetComponentDirs??[])if(Te&&!$e.includes(Te))$e.push(Te)}let ts=u._nativePrimitivesFallback;if(ts&&!ts.except.some((Te)=>Te.toLowerCase()===G.toLowerCase())&&!$e.includes(ts.dir))$e.push(ts.dir);let ei=[...new Set($e.map((Te)=>{if(!Te)return Te;return ge.isAbsolute(Te)?Te:ge.resolve(Yr,Te)}))];$e.length=0,$e.push(...ei);let Ws=`${G}\x00${l}\x00${ei.join("\x00")}`,Fs=Ts.get(Ws);if(Fs)if(await s(Fs))U=Fs;else Ts.delete(Ws);if(!U&&(G.startsWith("./")||G.startsWith("../")))U=ge.resolve(ge.dirname(l),`${G}.stx`),re.push(U);else if(!U)for(let Te of $e){if(!Te)continue;for(let jt of xe){let gt=ge.join(Te,jt);if(re.push(gt),await s(gt)){U=gt;break}}if(U)break;if(!U)try{let jt=await import("fs");if(!jt.statSync(Te,{throwIfNoEntry:!1})?.isDirectory())continue;let ns=8,kt=[{path:Te,depth:0}];while(kt.length>0&&!U){let ut=kt.pop();if(ut.depth>=ns)continue;let zt;try{zt=jt.readdirSync(ut.path,{withFileTypes:!0})}catch{continue}for(let ss of zt){if(!ss.isDirectory())continue;if(ss.name==="node_modules"||ss.name.startsWith("."))continue;let ti=ge.join(ut.path,ss.name);for(let tc of xe){let Vs=ge.join(ti,tc);if(re.push(Vs),await s(Vs)){U=Vs;break}}if(U)break;kt.push({path:ti,depth:ut.depth+1})}}}catch{}if(U)break}if(U)Ts.set(Ws,U)}if(!U||!await s(U))return Pa(e,l,re),Ma(e);v.add(U);let ce;if(Wn.has(U)&&Tr.get(U)===Ta(U))ce=Wn.get(U);else try{let pe=Ta(U);ce=await Bun.file(U).text(),Wn.set(U,ce),Tr.set(U,pe)}catch(pe){let xe=pe instanceof Error?pe.message:String(pe);return Pa(e,l,[U],xe),Ma(e)}if(I)for(let pe of new Set([...Object.keys(n),...I.reactiveProps??[]])){let xe=pe.toLowerCase();if(xe.startsWith("aria-")||xe.startsWith("data-"))continue;let Me=pe.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");if(new RegExp(`\\b${Me}\\b`).test(ce))I.declaredProps.add(pe);if(new RegExp(`\\$props\\s*(?:\\.\\s*${Me}\\b|\\[\\s*['"]${Me}['"]\\s*\\])`).test(ce)||new RegExp(`\\buseReactiveProp\\s*\\(\\s*['"]${Me}['"]`).test(ce))I.consumedProps?.add(pe)}if(I?.reactiveProps?.length&&/\bdefineProps\s*(?:<[^>]*>)?\s*\(/.test(ce))for(let pe of I.reactiveProps){if(Dp.has(pe)||I.consumedProps?.has(pe))continue;if(new RegExp(`\\buse(?:ReactiveProp|Model)\\s*\\(\\s*['"]${pe.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}['"]`).test(ce))continue;let xe=`${U}\x00${pe}`;if(Da.has(xe))continue;Da.add(xe),console.warn(`[stx] ${ge.basename(U)} reads \`${pe}\` with defineProps(), which is not live, but ${ge.basename(l)} binds it (:${pe}): the value can arrive empty or stale (on a native screen, and for a :for's rows, it does not arrive at all). Read it with useReactiveProp('${pe}').`)}let le=new Set(["__originalFilePath","__importedComponents",ls,"__stx_client_signal_names","__stx_client_declared_names","__stx_runtime_config","__stxServeContext","__stx_scope_seq"]),fe={};for(let[pe,xe]of Object.entries(a))if(!pe.startsWith("__")||le.has(pe))fe[pe]=xe;let we=S.length>0?{[ms]:[...S]}:{},Ee=r;if(r.includes("@include")){let{processIncludes:pe}=await o("stx/includes",()=>import("./chunk-qsv84cwm.js"));Ee=await pe(r,a,l,u,v)}if(/<[A-Z][\w.-]*[\s/>]/.test(Ee)){let{processComponents:pe}=await o("stx/component-renderer",()=>import("./chunk-t4gcsbna.js")),xe={...a,__processedComponents:M,...we};Ee=await pe(Ee,xe,l,u,v);let Me=xe.__stx_preserved_client_expressions;if(Array.isArray(Me)&&Me.length>0)a.__stx_preserved_client_expressions=[...new Set([...Array.isArray(a.__stx_preserved_client_expressions)?a.__stx_preserved_client_expressions:[],...Me])]}let Re=[];if(Sl(Ee)){let{processExpressions:pe}=await o("stx/expressions",()=>import("./chunk-wedwczed.js")),xe=a.__stx_signals_gate===void 0?{...a,__stx_signals_gate:!0,...we}:S.length>0?{...a,...we}:a;Ee=pe(Ee,xe,l);for(let Me of Ee.matchAll(/\{\{([\s\S]*?)\}\}/g))Re.push(Me[1].trim())}let ve=se(Ee),Qe=[],Be=ve.output.replace(/\x00STX_SCRIPT_(\d+)\x00/g,(pe,xe)=>{let Me=ve.scripts[Number(xe)]||"",$e=Me.match(/^<script\b([^>]*)>/i)?.[1]||"",lt=$e.match(/\btype\s*=\s*["']([^"']+)["']/i)?.[1]?.toLowerCase(),He=!lt||["module","text/javascript","application/javascript"].includes(lt),Ot=/\sdata-stx-(?:owner|instance)(?=[\s=/>])/i.test(` ${$e}`);if(!/\bserver\b/i.test($e)&&He&&!Ot)return Qe.push(Me),"";return Me}),{extractSlotContent:it}=await o("stx/slots",()=>import("./chunk-mtfymhy1.js")),rt=it(Be),wt={};if(rt.defaultSlot?.trim())wt.default=rt.defaultSlot;for(let[pe,xe]of rt.namedSlots)wt[pe]=xe.content;let ft=a.__stx_scope_seq??={n:0,key:co(String(a.__filename??l))},ot=za(e,process.cwd()),je=`stx_${(ot.endsWith(".stx")?ot.slice(0,-4):ot).replace(/[^a-zA-Z0-9]/g,"_")}_${++ft.n}_${ft.key}`,Ae={...fe,$uid:je,$native:u._nativeHostAttrs===!0,...n,props:n,slot:Be,$slots:wt,__processedComponents:V,__sections:{},__stx_signals_gate:Ne(ce)||Sl(r),__stx_preserved_client_expressions:[...Array.isArray(a.__stx_preserved_client_expressions)?a.__stx_preserved_client_expressions:[],...Re]};if(/import\s/.test(ce)){Ae.__importedComponents=new Map(Ae.__importedComponents);let{processESImports:pe}=await o("stx/component-renderer",()=>import("./chunk-t4gcsbna.js"));ce=await pe(ce,Ae,U,u,v)}jp(ce,Ae,n);let dt=ce,nt=B(dt);if(nt)dt=nt.content.trim();let pn=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,Pt=[...ce.matchAll(pn)];for(let[,pe,xe]of Pt)if(!/\bserver\b|\bsrc\s*=|\btype\s*=\s*["'](?!(?:text\/javascript|application\/javascript|module)["'])[^"']*["']/i.test(pe))We(xe,U,u.strict);let vt=[],fn=null,js=Pt.some((pe)=>/\bserver\b/.test(pe[1]||"")&&/\bcache\b/.test(pe[1]||"")),Jt=null,Rt=null,dn=null,Un=0,gn=null;if(Rp(u),js&&Vr>0){let pe=Tp({props:n,slot:Ee,slotContext:r.trim()?Ap(fe):void 0,buildMode:u.buildMode??"",skipEventDirectives:u.skipEventDirectives===!0,native:u._nativeHostAttrs===!0,clientLoopNames:[...S].sort(),layers:u._layerGraph?.layers.map((xe)=>xe.configFile),uid:je});if(pe!==null){Jt=`${U}\x00${E(ce)}\x00${pe}`;let xe=As.get(Jt);if(xe){for(let Me of xe.dependencies)v.add(Me);if(Ji(a,xe.clientFactories),ft.n+=xe.uidsConsumed,xe.preservedClientExpressions.length>0){let Me=new Set(Array.isArray(a.__stx_preserved_client_expressions)?a.__stx_preserved_client_expressions:[]);for(let $e of xe.preservedClientExpressions)Me.add($e);a.__stx_preserved_client_expressions=[...Me]}return xe.output}Rt=new Set(v),dn=qi(a),Un=ft.n,gn=new Set(Array.isArray(a.__stx_preserved_client_expressions)?a.__stx_preserved_client_expressions:[])}}let mn=new Set;for(let pe of Pt){let xe=pe[1]||"",Me=pe[2]||"",$e=xe.includes("server");if(Xe(xe)&&Me.trim())Me=Je(Me);if($e&&Me){for(let He of ye(Me))mn.add(He);try{await L(Me,Ae,U,{onFailure:(He)=>{if(He.kind!=="unknown")fn=He.kind}})}catch(He){}}if(!$e){let He=Me.replace(/^\s*const\s*\{[^}]+\}\s*=\s*window\.stx\s*;?\s*\n?/gm,""),Ot=He.includes("{{")&&He.includes("}}"),Yt=He.includes("{!!")&&He.includes("!!}");if(Ot||Yt)He=Ui(He,Ae,U);let Dt=xe.replace(/\s*\bts\b/g,"").replace(/\s*\blang\s*=\s*["']?(ts|typescript)["']?/gi,"");vt.push(`<script${Dt}>${He}</script>`)}}let St=se(ce).output.match(/<style\b([^>]*)>([\s\S]*?)<\/style>/i),hn=St?St[1]:"",Ps=St?St[2]:"",Tt="",ue=hn&&/\bscoped\b/i.test(hn);if(St)Tt=`<style${hn}>${Mp(Ps,Ae,U)}</style>`;let de=dt;if(de=de.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,""),St)de=de.replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,"");{let pe=/@push\s*\(\s*['"]styles['"]\s*\)([\s\S]*?)@endpush/gi,xe=[];if(de=de.replace(pe,(Me,$e)=>{let lt=$e.match(/<style\b([^>]*)>([\s\S]*?)<\/style>/i);if(lt)xe.push(`<style${lt[1]}>${lt[2]}</style>`);return""}),de=de.replace(/@push\s*\(\s*['"][^'"]+['"]\s*\)[\s\S]*?@endpush/gi,""),xe.length>0)Tt=`${Tt}${xe.join(`
|
|
1179
|
+
`)}`}if(r&&de.includes("{{ text || slot }}"))de=de.replace(/\{\{\s*text\s*\|\|\s*slot\s*\}\}/g,()=>r);let{applySlots:Se}=await o("stx/slots",()=>import("./chunk-mtfymhy1.js")),{defaultSlot:ze,namedSlots:tt}=rt,at=a.__stx_signals_gate===!0&&/\s(?:@[\w:.-]+|x-on:[\w:.-]+)\s*=/.test(Be),Et=vt.length>0&&fr(de)||u._nativeHostAttrs===!0&&vt.length>0||at&&vt.length>0||vt.some((pe)=>/\b(?:state|derived|effect|ref|useRef|reactive|computed|watch|watchEffect|useModel|useReactiveProp|onMount|onDestroy|defineProps|withDefaults|defineEmits|defineExpose|defineSlots)\s*(?:<[^<>()]*>)?\s*\(/.test(pe)),Ms=(pe)=>Et?Vo(pe,je):pe,Ds=new Map([...tt].map(([pe,xe])=>[pe,{...xe,content:Ms(xe.content)}]));de=await Se(de,Et?Fo(Ms(ze),je):ze,Ds,Ae,Et?je:"");let Hn=Hi(vt),xn=(Array.isArray(Ae.__stx_client_signal_names)?Ae.__stx_client_signal_names:[]).filter((pe)=>!mn.has(pe));if(Hn.length>0||xn.length>0)Ae.__stx_client_signal_names=[...new Set([...xn,...Hn])];else delete Ae.__stx_client_signal_names;let bn=S.filter((pe)=>!mn.has(pe)&&!(pe in n));if(bn.length>0)Ae[ms]=bn;let Kn={...u,_rootComponentsDir:u._rootComponentsDir||u.componentsDir,componentsDir:ge.dirname(U),skipSignalsRuntime:!0,skipEventDirectives:u._nativeHostAttrs===!0||Et||vt.length===0,defaultLayout:void 0};Ae.__stxProcessingDepth=(a.__stxProcessingDepth||0)+1;let{processDirectives:qn}=await o("stx/process",()=>import("./chunk-kpjq135z.js")),At=await qn(de,Ae,U,Kn,v),Mt=new Set(Array.isArray(a.__stx_preserved_client_expressions)?a.__stx_preserved_client_expressions:[]);for(let pe of At.matchAll(/\{\{([\s\S]*?)\}\}/g))Mt.add(pe[1].trim());if(Mt.size>0)a.__stx_preserved_client_expressions=[...Mt];let It=je,ct=At;if(Et){let pe="";if(Object.keys(n).length>0)try{pe=` data-stx-props="${Cr(JSON.stringify(n))}"`}catch{}let xe=Z?` stx-hydrate="${Cr(Z)}"`:"",Me=Object.fromEntries(Object.entries(wt).map(([Lt,Qt])=>[Lt,Boolean(Qt)])),$e=Object.keys(Me).length>0?` data-stx-slots="${Cr(JSON.stringify(Me))}"`:"",lt=` data-stx-scope="${It}"${pe}${$e}${xe}`,He=At.slice(Ut(At)),Ot=/^<span(?=[\s/>])/i.test(He),Yt=/^<[^>]+\bdata-stx-layout-root(?:\s|=|>)/i.test(He),Dt=/^<[^>]+\bdata-stx-fill-root(?:\s|=|>)/i.test(He),Zn=Ot?"span":"div",Ns=Yt&&u._nativeHostAttrs?' style="display:flex;flex-direction:column;flex:1;min-height:0;min-width:0"':Dt&&u._nativeHostAttrs?' style="width:100%;height:100%"':Ot||Yt?' style="display:contents"':"";ct=Ug(At,lt)??`<${Zn}${lt} data-stx-component-wrapper${Ns}>${At}</${Zn}>`;let Ls=await Promise.all(vt.map(async(Lt)=>{let Qt=Lt.match(/<script([^>]*)>([\s\S]*)<\/script>/i);if(!Qt)return Lt;let[,yn,zs]=Qt,Jn=Ra(Lt,Ae,U);if(Jn!==null)return Jn;let en=await Lp(zs,U,u.buildMode==="compile"),Xn=An(en.clientCode,Ke(Ae)),{vendorStyleTags:Gn}=en,Yn=Xn?`function(__scopeId) {
|
|
1180
|
+
${Xn}
|
|
1181
|
+
return (${en.factoryBody})(__scopeId);
|
|
1182
|
+
}`:en.factoryBody,Qn=Z?null:ir(a,Yn),es=Qn?`window.__stxComponentFactories[${JSON.stringify(Qn)}](${JSON.stringify(It)});`:`(${Yn})(${JSON.stringify(It)});`;if(Z)return`${Gn}<script type="stx/island" data-stx-island="${It}" data-stx-scoped data-stx-owner="${It}"${yn}>${me(es)}</script>`;return`${Gn}<script data-stx-scoped data-stx-run="always" data-stx-owner="${It}"${yn}>${me(es)}</script>`}));if(ct=ct+`
|
|
1183
|
+
`+Ls.join(`
|
|
1184
|
+
`),Tt)ct+=`
|
|
1185
|
+
`+Tt}else{if(Tt)ct+=`
|
|
1186
|
+
`+Tt;if(vt.length>0){let pe=Ae.__stx_event_bindings||[],xe=Ke(Ae),Me=await Promise.all(vt.map(async($e)=>{let lt=Ra($e,Ae,U);if(lt!==null)return lt;let He=$e.match(/<script\b[^>]*>([\s\S]*?)<\/script>/);if(!He)return $e;return await Ge(He[1],{eventBindings:pe,templateContent:ct,filePath:U,projectRoot:process.cwd(),serverData:xe,instanceId:je})}));ct+=`
|
|
1187
|
+
`+Me.join(`
|
|
1188
|
+
`),Ae.__stx_event_bindings=[]}}if(ue){let pe=so(ct,U);if(pe.hasScoped)ct=pe.html}if(Jt&&Rt){let pe=Array.isArray(a.__stx_preserved_client_expressions)?a.__stx_preserved_client_expressions:[];As.set(Jt,{output:ct,dependencies:[...v].filter((xe)=>!Rt.has(xe)),clientFactories:dn?Zi(a,dn):[],uidsConsumed:ft.n-Un,preservedClientExpressions:gn?pe.filter((xe)=>!gn.has(xe)):[]})}if(fn)ct=`<!--stx-render-failed:${fn}-->${ct}`;return Qe.length>0?`${ct}
|
|
1189
|
+
${Qe.join(`
|
|
1190
|
+
`)}`:ct}catch(q){if(q instanceof te)throw q;return`[Error processing component: ${q instanceof Error?q.message:String(q)}]`}finally{M.delete(e)}}async function s(e){return Bun.file(e).exists()}function Ur(e,n){let r=ge.resolve(n),i=ge.resolve(e),a=r.endsWith(ge.sep)?r:r+ge.sep;if(i===r||i.startsWith(a))return i;return null}async function Na(e,n,r,i){let a=n.startsWith("layouts/")?n.slice(8):n,l=ge.join(e,a);for(let u of l.endsWith(".stx")?[l]:[l,`${l}.stx`])if(await s(u)){if(i)console.log(`Found layout in ${e}: ${u}`);return r?.add(u),u}return null}async function Pn(e,n,r,i){let a=await Np(e,n,r,i);if(a===null)return null;let l=Ur(a,process.cwd());if(l)return l;let u=[r.root,r.layoutsDir,r.fallbackLayoutsDir,r.componentsDir,r.partialsDir,r.pagesDir,...r._layerLayoutDirs??[]].filter((f)=>typeof f==="string"&&f.length>0);for(let f of u){let v=ge.isAbsolute(f)?f:ge.resolve(process.cwd(),f);if(Ur(a,v))return ge.resolve(a)}return console.warn(`[stx] rejected resolved template path that escapes project root: ${a} (template: ${e}, from: ${n})`),null}async function Np(e,n,r,i){if(r.debug)console.log(`Resolving template path: ${e} from ${n}`);let a=ge.dirname(n),l=process.cwd();if(e.startsWith("/")){let M=ge.join(l,e),V=Ur(M,l);if(!V)return console.warn(`[stx] rejected template path that escapes project root: ${e} (from ${n})`),null;if(r.debug)console.log(`Checking absolute path: ${V}`);if(await s(V)&&i)i.add(V);return V}let u=async(M)=>{if(!r.layoutsDir||!r.fallbackLayoutsDir)return M;let V=ge.relative(ge.resolve(l,r.fallbackLayoutsDir),M);if(V.startsWith("..")||ge.isAbsolute(V))return M;return await Na(ge.resolve(l,r.layoutsDir),e,i,r.debug)??M},f=ge.join(a,e);if(await s(f)){if(r.debug)console.log(`Found direct path: ${f}`);let M=await u(f);if(i)i.add(M);return M}if(!e.endsWith(".stx")&&!e.endsWith(".jsx")&&!e.endsWith(".tsx"))for(let M of[".stx",".tsx",".jsx"]){let V=`${f}${M}`;if(await s(V)){if(r.debug)console.log(`Found direct path with extension: ${V}`);let W=await u(V);if(i)i.add(W);return W}}let v=[];if(v.push(...r._layerLayoutDirs??[]),r.layoutsDir)v.push(ge.isAbsolute(r.layoutsDir)?r.layoutsDir:ge.resolve(process.cwd(),r.layoutsDir));let S=ge.resolve(a),I=process.cwd();for(let M=0;M<10;M++){let V=ge.join(S,"layouts"),W=!1;try{W=Is.statSync(V,{throwIfNoEntry:!1})?.isDirectory()??!1}catch{}if(W){v.push(V);break}let Z=ge.dirname(S);if(Z===S||Z.length<I.length)break;S=Z}for(let M of v){let V=await Na(M,e,i,r.debug);if(V)return V}if(r.fallbackLayoutsDir){let M=ge.isAbsolute(r.fallbackLayoutsDir)?r.fallbackLayoutsDir:ge.resolve(process.cwd(),r.fallbackLayoutsDir),V=e.startsWith("layouts/")?e.slice(8):e,W=[ge.join(M,V)];if(!e.endsWith(".stx"))W.push(`${W[0]}.stx`);for(let Z of W)if(await s(Z)){if(r.debug)console.log(`Found in options.fallbackLayoutsDir: ${Z}`);if(i)i.add(Z);return Z}}if(e.startsWith("layouts/")||e.includes("/layouts/")){let M=e.split("layouts/"),V=ge.join(r.partialsDir||a,"layouts",M[1]);if(await s(V)){if(r.debug)console.log(`Found in layouts path: ${V}`);if(i)i.add(V);return V}if(!V.endsWith(".stx")){let W=`${V}.stx`;if(await s(W)){if(r.debug)console.log(`Found in layouts path with extension: ${W}`);if(i)i.add(W);return W}}}if(r.partialsDir){let M=ge.join(r.partialsDir,"layouts");if(await s(M)){let V=ge.join(M,e);if(await s(V)){if(r.debug)console.log(`Found in partials layouts dir: ${V}`);if(i)i.add(V);return V}if(!e.endsWith(".stx")){let W=`${V}.stx`;if(await s(W)){if(r.debug)console.log(`Found in partials layouts dir with extension: ${W}`);if(i)i.add(W);return W}}}}let j=r.partialsDir||ge.join(process.cwd(),"views"),L=ge.join(j,e);if(await s(L)){if(r.debug)console.log(`Found in views path: ${L}`);if(i)i.add(L);return L}if(!e.endsWith(".stx")){let M=`${L}.stx`;if(await s(M)){if(r.debug)console.log(`Found in views path with extension: ${M}`);if(i)i.add(M);return M}}if(a.includes("temp")){let M=ge.join(ge.dirname(a),"layouts",e);if(await s(M)){if(r.debug)console.log(`Found in temp layouts dir: ${M}`);if(i)i.add(M);return M}if(!e.endsWith(".stx")){let V=`${M}.stx`;if(await s(V)){if(r.debug)console.log(`Found in temp layouts dir with extension: ${V}`);if(i)i.add(V);return V}}}if(r.debug)console.warn(`Template not found after trying all paths: ${e} (referenced from ${n})`);else console.warn(`Template not found: ${e} (referenced from ${n})`);return null}function _l(e,n,r){let i=0,a="",l="";try{if(typeof n==="number"&&n>=0){let u=e.split(`
|
|
1191
|
+
`),f=0;for(let v=0;v<u.length;v++)if(f+=u[v].length+1,f>=n){i=v+1,a=u[v].trim();let S=Math.max(0,v-2),I=Math.min(u.length,v+3);l=u.slice(S,I).map((j,L)=>{let M=S+L+1;return`${M===i?"> ":" "}${M}: ${j}`}).join(`
|
|
1192
|
+
`);break}}else if(r){let u=e.indexOf(r);if(u>=0)return _l(e,u)}}catch{}return{lineNumber:i,lineContent:a,context:l}}var Ve={reset:"\x1B[0m",bold:"\x1B[1m",dim:"\x1B[2m",red:"\x1B[31m",yellow:"\x1B[33m",blue:"\x1B[34m",cyan:"\x1B[36m",gray:"\x1B[90m",bgRed:"\x1B[41m",bgYellow:"\x1B[43m"};function b(e,n,r,i,a,l){let{lineNumber:u,context:f}=_l(i,a,l),v=r.split("/").pop(),S=0;if(typeof a==="number"&&a>=0&&i){let j=i.lastIndexOf(`
|
|
1193
|
+
`,Math.max(0,a-1));S=a-(j+1)+1}let I="";if(u>0)I+=`
|
|
1194
|
+
${r}:${u}${S>0?`:${S}`:""}: ${e.toLowerCase()} error: ${n}
|
|
1195
|
+
`;if(I+=`
|
|
1196
|
+
${Ve.bold}${Ve.red}\u256D\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u256E${Ve.reset}
|
|
1197
|
+
`,I+=`${Ve.bold}${Ve.red}\u2502${Ve.reset} ${Ve.bold}${Ve.bgRed} ERROR ${Ve.reset} ${Ve.red}${e} Error${Ve.reset}${" ".repeat(Math.max(0,43-e.length))}${Ve.bold}${Ve.red}\u2502${Ve.reset}
|
|
1198
|
+
`,I+=`${Ve.bold}${Ve.red}\u2570\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u256F${Ve.reset}
|
|
1199
|
+
`,I+=`
|
|
1200
|
+
${Ve.cyan}${Ve.bold}File:${Ve.reset} ${Ve.dim}${v}${Ve.reset}`,u>0)I+=` ${Ve.gray}(line ${u}${S>0?`, col ${S}`:""})${Ve.reset}`;if(I+=`
|
|
1201
|
+
${Ve.yellow}${Ve.bold}Message:${Ve.reset} ${n}
|
|
1202
|
+
`,f)I+=`
|
|
1203
|
+
${Ve.blue}${Ve.bold}Context:${Ve.reset}
|
|
1204
|
+
${Ve.dim}${f}${Ve.reset}
|
|
1205
|
+
`;return I}function Ce(){Wn.clear(),Tr.clear(),Ts.clear(),Ar.clear(),Pr.clear(),Wr.clear(),As.clear()}function $y(){return{size:Wn.size,maxSize:500}}var Rr=k(128);async function Lp(e,n,r){let i=E(e,n,r),a=Rr.get(i);if(a){if(Qs(a.deps))return a;Rr.delete(i)}let l=Fi(e,{filePath:n,projectRoot:process.cwd()}),u=l.code,f=zi(l.styles);u=Xt(u).code;let{hasUserImports:v,bundleClientScript:S}=await o("stx/client-script-bundler",()=>import("./chunk-sztr4d5g.js")),I=[],j=!1;if(v(u)){let G=u;u=await S(G,n,{projectRoot:process.cwd(),minify:r,collectInputs:I}),j=u===G}let{stripStxRuntimeImports:L}=await o("stx/signal-processing",()=>import("./chunk-gfea8a9y.js"));u=L(u);let M=D(u),V=Op(M),W=new Set(X(M,!0).split(",").map((G)=>G.trim())),Z=`function(__scopeId) {
|
|
1206
|
+
${xt("const",[...Bl,...V],M)}
|
|
1207
|
+
const __scope = window.stx._scopes = window.stx._scopes || {};
|
|
1208
|
+
const __scopeVars = __scope[__scopeId] = __scope[__scopeId] || {};
|
|
1209
|
+
__scopeVars.$refs = __scopeVars.$refs || {};
|
|
1210
|
+
const __previousCurrentElement = window.__STX_CURRENT_ELEMENT__;
|
|
1211
|
+
const __previousCurrentProps = window.__STX_CURRENT_PROPS__;
|
|
1212
|
+
// A clone the runtime is setting up may not be in the document yet (rows
|
|
1213
|
+
// a loop builds inside a closed :if), where a lookup cannot see it, so the
|
|
1214
|
+
// runtime hands its root over in __STX_SETUP_ROOT__ (signals.ts).
|
|
1215
|
+
const __setupRoot = window.__STX_SETUP_ROOT__;
|
|
1216
|
+
const __componentElement = (__setupRoot && __setupRoot.getAttribute('data-stx-scope') === __scopeId && __setupRoot) || document.querySelector('[data-stx-scope="' + __scopeId + '"]');
|
|
1217
|
+
__scopeVars.$slots = Object.create(null);
|
|
1218
|
+
if (__componentElement) {
|
|
1219
|
+
try { Object.assign(__scopeVars.$slots, JSON.parse(__componentElement.getAttribute('data-stx-slots') || '{}')); }
|
|
1220
|
+
catch {}
|
|
1221
|
+
}
|
|
1222
|
+
window.__STX_CURRENT_ELEMENT__ = __componentElement;
|
|
1223
|
+
let __componentProps = __componentElement && __componentElement.__stx_props;
|
|
1224
|
+
if (!__componentProps && __componentElement) {
|
|
1225
|
+
try { __componentProps = JSON.parse(__componentElement.getAttribute('data-stx-props') || '{}'); }
|
|
1226
|
+
catch { __componentProps = {}; }
|
|
1227
|
+
}
|
|
1228
|
+
window.__STX_CURRENT_PROPS__ = __componentProps && typeof __componentProps === 'object' && !Array.isArray(__componentProps) ? __componentProps : {};
|
|
1229
|
+
const __scopeProps = window.__STX_CURRENT_PROPS__;
|
|
1230
|
+
Object.defineProperty(__scopeVars, '$props', { configurable: true, enumerable: true, get: function() {
|
|
1231
|
+
return (__componentElement && __componentElement.__stx_props) || __scopeProps;
|
|
1232
|
+
} });
|
|
1233
|
+
|
|
1234
|
+
// Scope-specific lifecycle callbacks. The queues drain as they run; the
|
|
1235
|
+
// hook lists keep what setup registered, because a component behind an :if
|
|
1236
|
+
// unmounts at each hide and mounts again at each show (signals.ts,
|
|
1237
|
+
// suspendSubtreeScopes).
|
|
1238
|
+
if (__scopeVars.__suspended && !__scopeVars.__mounted) {
|
|
1239
|
+
// Set up again after an :if hid it -- a <template :if> clones the
|
|
1240
|
+
// component afresh on every show, and the clone's script runs. This run's
|
|
1241
|
+
// hooks close over this run's state, so they replace the ones the hide
|
|
1242
|
+
// kept for a re-show rather than queueing beside them.
|
|
1243
|
+
__scopeVars.__mountCallbacks = [];
|
|
1244
|
+
__scopeVars.__destroyCallbacks = [];
|
|
1245
|
+
__scopeVars.__mountHooks = [];
|
|
1246
|
+
__scopeVars.__destroyHooks = [];
|
|
1247
|
+
// So do its effects: the last run's watched a clone that is gone.
|
|
1248
|
+
if (typeof __scopeVars.__disposeEffects === 'function') __scopeVars.__disposeEffects();
|
|
1249
|
+
__scopeVars.__disposeEffects = null;
|
|
1250
|
+
}
|
|
1251
|
+
__scopeVars.__mountCallbacks = __scopeVars.__mountCallbacks || [];
|
|
1252
|
+
__scopeVars.__destroyCallbacks = __scopeVars.__destroyCallbacks || [];
|
|
1253
|
+
__scopeVars.__mountHooks = __scopeVars.__mountHooks || [];
|
|
1254
|
+
__scopeVars.__destroyHooks = __scopeVars.__destroyHooks || [];
|
|
1255
|
+
let __registeringSetupHooks = true;
|
|
1256
|
+
const onMount = (fn) => { __scopeVars.__mountCallbacks.push(fn); __scopeVars.__mountHooks.push(fn); };
|
|
1257
|
+
const onDestroy = (fn) => {
|
|
1258
|
+
__scopeVars.__destroyCallbacks.push(fn);
|
|
1259
|
+
// A teardown registered inside onMount belongs to this mount alone.
|
|
1260
|
+
// Replaying it AND registering the next mount's teardown doubles cleanup.
|
|
1261
|
+
if (__registeringSetupHooks) __scopeVars.__destroyHooks.push(fn);
|
|
1262
|
+
};
|
|
1263
|
+
// The effects this setup makes (effect, watch) belong to the scope and are
|
|
1264
|
+
// disposed with it (disposeSubtreeScopes in the runtime), as its bindings
|
|
1265
|
+
// are. Untracked, one reading a store kept running for a component the
|
|
1266
|
+
// router had long swapped out.
|
|
1267
|
+
const __endEffects = window.stx._beginEffects ? window.stx._beginEffects() : null;
|
|
1268
|
+
|
|
1269
|
+
try {
|
|
1270
|
+
${M}
|
|
1271
|
+
|
|
1272
|
+
// Register all defined signals and functions in this scope
|
|
1273
|
+
const __localVars = {};
|
|
1274
|
+
try {
|
|
1275
|
+
${V.map((G)=>W.has(G)?`Object.defineProperty(__localVars, '${G}', ${Gs(G)});`:`if (typeof ${G} !== 'undefined') __localVars['${G}'] = ${G};`).join(`
|
|
1276
|
+
`)}
|
|
1277
|
+
}
|
|
1278
|
+
catch (e) {}
|
|
1279
|
+
Object.defineProperties(__scopeVars, Object.getOwnPropertyDescriptors(__localVars));
|
|
1280
|
+
if (typeof __stxLiveBindings !== 'undefined') Object.defineProperties(__scopeVars, Object.getOwnPropertyDescriptors(__stxLiveBindings));
|
|
1281
|
+
}
|
|
1282
|
+
finally {
|
|
1283
|
+
__registeringSetupHooks = false;
|
|
1284
|
+
if (__endEffects) {
|
|
1285
|
+
const __previousDispose = __scopeVars.__disposeEffects;
|
|
1286
|
+
const __disposeSetup = __endEffects();
|
|
1287
|
+
__scopeVars.__disposeEffects = typeof __previousDispose === 'function'
|
|
1288
|
+
? function() { __previousDispose(); __disposeSetup(); }
|
|
1289
|
+
: __disposeSetup;
|
|
1290
|
+
}
|
|
1291
|
+
window.__STX_CURRENT_ELEMENT__ = __previousCurrentElement;
|
|
1292
|
+
window.__STX_CURRENT_PROPS__ = __previousCurrentProps;
|
|
1293
|
+
}
|
|
1294
|
+
}`,q={vendorStyleTags:f,factoryBody:Z,clientCode:M,deps:Or([...I,...l.styles.map((G)=>G.resolvedPath)])};if(!j&&l.unresolved.length===0)Rr.set(i,q);return q}var zp=100,Bp=599,Kr="__stxResponseStatus",Vn="__stxResponseHeaders";function Os(e){return typeof e==="number"&&Number.isInteger(e)&&e>=zp&&e<=Bp}function $n(e){for(let n of e.matchAll(/\bdefinePageMeta\s*\(\s*\{([\s\S]*?)\}\s*\)/g)){let r=n[1].match(/(?:^|,)\s*status\s*:\s*(\d{3})(?=\s*(?:,|$))/);if(!r)continue;let i=Number(r[1]);if(Os(i))return i}return}function Hr(e,n){if(!e||typeof e!=="object")return!1;let r=typeof n==="string"&&/^\d+$/.test(n.trim())?Number(n.trim()):n;if(!Os(r))return!1;return e[Kr]=r,!0}function Wp(e,n,r){if(!e||typeof e!=="object")return;let i=String(n??"").trim();if(!i)return;e[Vn]={...e[Vn],[i]:String(r)}}function Kt(e){let n=e?.[Kr];return Os(n)?n:void 0}function Gt(e){let n=e?.[Vn];if(!n||typeof n!=="object")return;let r=Object.entries(n).map(([i,a])=>[i,String(a)]);return r.length>0?Object.fromEntries(r):void 0}function ul(e,n){if(!e||!n||e===n||typeof n!=="object")return;let r=Kt(e);if(r!==void 0)n[Kr]=r;let i=Gt(e);if(i)n[Vn]={...n[Vn],...i}}function oo(e){return{setResponseStatus:(n)=>{Hr(e,n)},notFound:(n=404)=>{let r=Os(n)&&n>=400?n:404;Hr(e,r)},setResponseHeader:(n,r)=>{Wp(e,n,r)}}}function dl(e,n,r={}){if(!e.includes("@status"))return e;let{filePath:i,buildMode:a}=r,l=a==="compile",u="",f=0,v=/@status\s*\(/g,S;while((S=v.exec(e))!==null){let I=Fp(e,S.index+S[0].length-1);if(I<0)break;let j=e.slice(S.index+S[0].length,I).trim(),L=/^\d+$/.test(j)?Number(j):d(j,n),M=i?` in ${i}`:"";if(l)console.warn(`[stx] @status(${j})${M} is skipped when precompiling: the build has no request, so the branch it sits in is not the one a visitor will get. Call notFound() or setResponseStatus(${j}) from <script server> instead \u2014 that runs per request.`);else if(!Hr(n,L))console.warn(`[stx] @status(${j})${M} is not an HTTP status (100-599) \u2014 ignoring it.`);u+=e.slice(f,S.index),f=I+1+(e.slice(I+1).match(/^[^\S\n]*\n?/)?.[0].length??0),v.lastIndex=f}return f===0?e:u+e.slice(f)}function Fp(e,n){let r=1,i=null,a=!1;for(let l=n+1;l<e.length;l++){let u=e[l];if(a){a=!1;continue}if(i){if(u==="\\")a=!0;else if(u===i)i=null;continue}if(u==='"'||u==="'"||u==="`"){i=u;continue}if(u==="(")r++;else if(u===")"&&--r===0)return l}return-1}var Fa=new Set(ht),Vp=new Set(["props","$props","defineProps"]),Up=new Set(["stx","@stacksjs/stx"]),Va=k(128),Ua=k(64);function Hp(e){let n=[],r=0,i=e.split(`
|
|
1295
|
+
`);for(let a of i){let l=r,u=null,f=!1;for(let v=0;v<a.length;v++){let S=a[v];if(f){f=!1;continue}if(S==="\\"){f=!0;continue}if(u){if(S===u)u=null;continue}if(S==="'"||S==='"'||S==="`"){u=S;continue}if(S==="/"&&v+1<a.length&&a[v+1]==="/")break;if(S==="{")r++;else if(S==="}")r--}if(l===0){let v=a.match(/(?:const|let|var)\s+(\w+)\s*=/);if(v)n.push(v[1]);else if(/^\s*(?:const|let|var)\s+\w+\s*;?\s*$/.test(a)){let S=a.match(/(?:const|let|var)\s+(\w+)/);if(S)n.push(S[1])}else{let S=a.match(/(?:const|let|var)\s+(\{[^}]+\}|\[[^\]]+\])\s*=/);if(S){let j=S[1].slice(1,-1).split(",").map((L)=>{let M=L.split(":");return(M.length>1?M[1]:M[0]).trim()}).filter((L)=>/^\w+$/.test(L));n.push(...j)}}}}return[...new Set(n)]}function Rg(e){let n=e;n=n.replace(/^\s*import\s+.*?from\s+['"][^'"]+['"]\s*;?\s*$/gm,""),n=n.replace(/^\s*import\s+['"][^'"]+['"]\s*;?\s*$/gm,""),n=n.replace(/^\s*interface\s+\w+\s*\{[\s\S]*?\n\}\s*$/gm,""),n=n.replace(/^\s*type\s+\w+\s*=[\s\S]*?(?=\n(?:const|let|var|function|export|interface|type|$))/gm,""),n=n.replace(/^(\s*(?:export\s+)?(?:const|let|var)\s+)(\w+|\{[^}]+\}|\[[^\]]+\])\s*:\s*[^=]+(\s*=)/gm,"$1$2$3");function r(i){if(!i.includes(":"))return i;let a=[],l="",u=0,f=0,v=null;for(let S=0;S<i.length;S++){let I=i[S];if(v){if(l+=I,I===v)v=null;continue}if(I==='"'||I==="'"||I==="`"){v=I,l+=I;continue}if(I==="<")u++;else if(I===">"&&u>0)u--;else if(I==="(")f++;else if(I===")")f--;if(I===","&&u===0&&f===0){a.push(l),l="";continue}l+=I}if(l)a.push(l);return a.map((S)=>{let I=S.trim(),j=I.startsWith("..."),L=j?I.slice(3):I,M=-1,V=0;for(let re=0;re<L.length;re++)if(L[re]==="<")V++;else if(L[re]===">")V--;else if(L[re]===":"&&V===0){M=re;break}if(M===-1)return S;let Z=L.substring(0,M).trim().replace(/\?$/,""),q=L.substring(M+1),G=-1,U=0;for(let re=0;re<q.length;re++)if(q[re]==="<")U++;else if(q[re]===">")U--;else if(q[re]==="="&&U===0){G=re;break}let H=j?"...":"";if(G!==-1)return`${H}${Z} = ${q.substring(G+1).trim()}`;return`${H}${Z}`}).join(", ")}n=n.replace(/\b(function\s+\w*\s*)\(([^)]*)\)/g,(i,a,l)=>{if(!l.includes(":"))return i;return`${a}(${r(l)})`});{let i=/\b(function\s+\w*\s*)\(/g,a,l=[];while((a=i.exec(n))!==null){let u=a.index+a[0].length-1,f=1,v=u+1,S=0,I=null;while(v<n.length&&f>0){let M=n[v];if(I){if(M===I)I=null;v++;continue}if(M==='"'||M==="'"||M==="`"){I=M,v++;continue}if(M==="<")S++;else if(M===">"&&S>0)S--;else if(S===0){if(M==="(")f++;else if(M===")")f--}if(f>0)v++}if(f!==0)continue;let j=n.substring(u+1,v);if(!j.includes(":"))continue;let L=r(j);l.push({start:u+1,end:v,replacement:L})}for(let u=l.length-1;u>=0;u--){let{start:f,end:v,replacement:S}=l[u];n=n.substring(0,f)+S+n.substring(v)}}return n=n.replace(/\(([^)]*)\)\s*(?::\s*[^=]+)?\s*=>/g,(i,a)=>{if(!a.includes(":"))return i;if(a.includes("{")||a.includes("}"))return i;return`(${a.split(",").map((u)=>{let[f,...v]=u.split("="),S=f.split(":")[0].trim();if(v.length>0)return`${S} = ${v.join("=").trim()}`;return S}).join(", ")}) =>`}),n=n.replace(/(\))\s*:\s*([A-Z]\w*|void|string|number|boolean|any|unknown|never|null|undefined)(?:<[^>]+>)?(?:\s*\|\s*(?:[A-Z]\w*|void|string|number|boolean|any|unknown|never|null|undefined))*\s*(\{)/g,"$1$3"),n=n.replace(/(\b(?:function|class|interface|type|extends|implements)\s+\w+)\s*<[^<>()]*>/g,"$1"),n=n.replace(/(\b(?:defineProps|withDefaults|defineEmits|defineSlots|Array|Promise|Map|Set|Record|Partial|Required|Readonly|Pick|Omit|Exclude|Extract))\s*<[^<>()]*>/g,"$1"),n=n.replace(/(\w+)\s*<[A-Z][^<>()]*>\s*(?=\()/g,"$1"),n=n.replace(/\s+as\s+(?:const|[A-Za-z]\w*(?:\[\])?(?:\s*\|\s*\w+(?:\[\])?)*)/g,""),n=n.replace(/\s+satisfies\s+\w+(?:<[^>]*>)?/g,""),n=n.replace(/(\w|\)|\])\s*!(?!=)/g,"$1"),n=n.replace(/^\s*(?:export\s+)?(?:const\s+)?enum\s+\w+\s*\{[^}]*\}\s*$/gm,""),n=n.replace(/(?<=[\s=,(])<[A-Z]\w*(?:\[\])?>/g,""),n=n.replace(/\n\s*\n\s*\n/g,`
|
|
1296
|
+
|
|
1297
|
+
`),n}function Ag(e){return e.replace(/\s*(?:imported from|from)\s+(?:(['"])([^'"\r\n]+)\1|(\S+))/g,(n,...r)=>{let[,i,a]=r,l=i??a;return/(?:[/\\]packages[/\\]stx[/\\]|@stacksjs[/\\]stx[/\\])/.test(l)?"":n})}function Pg(e){return/cannot find module|cannot find package|could not resolve|module not found|failed to resolve/i.test(e)}function Ig(e){if(e instanceof SyntaxError)return!0;let n=e instanceof Error?e.message:String(e);return/SyntaxError|Unexpected (token|identifier|string|number|keyword|end of)|Unterminated|Expected .+ but found/i.test(n)}function Og(e){if(!/is not defined|can't find variable/i.test(e))return!1;return!/\b(document|window|navigator|localStorage|sessionStorage|self)\b/.test(e)}var Ha=new Set;async function y(e,n,r,i={}){if(!e.trim())return;let a=A(),l=E(e,JSON.stringify(a)),u=Va.get(l);if(u===void 0){try{let ue=ie({loader:"ts",target:"browser",define:a}),de=e.replace(/^\s*import\s+\w+\s+from\s+['"][^'"]*\.stx['"]\s*;?\s*$/gm,"");de=de.replace(/^\s*import\s+['"][^'"]*\.stx['"]\s*;?\s*$/gm,""),u=ue.transformSync(de)}catch{u=Rg(e)}Va.set(l,u)}let f={exports:{}},v=f.exports,S=un.cwd(),I={},j=[...u.matchAll(/require\s*\(\s*['"]([^'"]+)['"]\s*\)/g)||[]].map((ue)=>ue[1]).filter((ue)=>!ue.startsWith("node:")&&!["fs","path","os","child_process","crypto","http","https","url","util","stream","events","buffer","net","querystring","zlib","tls"].includes(ue)),L=new Map;for(let ue of j)try{if(ue.startsWith(".")){I[ue]=await import(Ct.resolve(Ct.dirname(r),ue));continue}let de=Ct.resolve(S,"node_modules",ue),Se=Ct.join(de,"package.json"),ze=JSON.parse(w("fs").readFileSync(Se,"utf8")),tt=ze.main||"index.js";if(ze.exports){let at=typeof ze.exports==="string"?ze.exports:ze.exports["."];if(typeof at==="string")tt=at;else if(at?.bun)tt=at.bun;else if(at?.import)tt=at.import;else if(at?.default)tt=at.default}I[ue]=await import(Ct.resolve(de,tt))}catch(de){if(ue.startsWith("."))L.set(ue,de instanceof Error?de.message:String(de))}let M=(ue)=>{if(I[ue])return I[ue];let de=L.get(ue);if(de!==void 0)throw Error(`Cannot require '${ue}' from ${r}: ${de}`);return w(ue)},V=n.props||{},W=(ue)=>{if(!ue)return V;let de={};for(let[Se,ze]of Object.entries(ue)){let tt=V[Se];if(tt!==void 0)de[Se]=tt;else if(typeof ze==="function")de[Se]=ze();else de[Se]=ze}return de};for(let[ue,de]of Object.entries(V))Object.defineProperty(W,ue,{value:de,enumerable:!0,configurable:!0,writable:!0});let Z=(ue,de=!1)=>{if(ue===void 0||ue===null)return de;if(typeof ue==="string"){let Se=ue.trim().toLowerCase();if(Se===""||Se==="true"||Se==="1"||Se==="on"||Se==="yes")return!0;if(Se==="false"||Se==="0"||Se==="off"||Se==="no")return!1;return!0}return Boolean(ue)},q=(ue,de=0)=>{if(ue===void 0||ue===null)return de;if(typeof ue==="string"){let ze=ue.trim();if(ze==="")return de;let tt=Number(ze);return Number.isFinite(tt)?tt:de}let Se=Number(ue);return Number.isFinite(Se)?Se:de};for(let ue of["name","length","caller","arguments"]){if(Object.prototype.hasOwnProperty.call(V,ue))continue;try{Object.defineProperty(W,ue,{value:void 0,enumerable:!1,configurable:!0,writable:!0})}catch{}}let G=(ue)=>{if(!ue)return V;let de={...V};for(let[Se,ze]of Object.entries(ue)){let tt=ze&&typeof ze==="object"&&!Array.isArray(ze)?ze:{type:ze};if(de[Se]===void 0&&tt.default!==void 0)de[Se]=typeof tt.default==="function"?tt.default():tt.default}return de},U=()=>n.slots||{},H=(ue,de)=>{let Se={...ue};for(let[ze,tt]of Object.entries(de))if(Se[ze]===void 0)if(typeof tt==="function")Se[ze]=tt();else Se[ze]=tt;return Se},re=(ue)=>{let de=()=>ue;return de.set=(Se)=>{},de.update=(Se)=>{},de},ce=(ue)=>{let de,Se=!1;return()=>{if(!Se)try{de=ue(),Se=!0}catch{de=void 0}return de}},le=(ue)=>{},fe=(ue)=>ue(),we=(ue)=>{},Ee=(ue)=>{},Re=oo(n);function ve(ue){let de=ue||{};if(de.title!==void 0||de.description!==void 0)wt({title:de.title,description:de.description})}function Qe(ue){if(!ue||typeof ue!=="object")return;let de=n.__stxClientPayload??{};Object.assign(de,ue),n.__stxClientPayload=de}let Be=()=>{let ue=n.__stxServeContext,de=n.__stxServeSearch??ue?.search??"",Se=ue?.path??"",ze=Object.fromEntries(new URLSearchParams(de)),tt=n.query,at=Object.keys(ze).length>0?ze:tt??{},Et=de||(Object.keys(at).length>0?`?${new URLSearchParams(at).toString()}`:"");return{params:n.params??{},query:at,path:Se,name:"",fullPath:Se+Et,hash:"",matched:[]}},it=()=>({push:(ue)=>{},replace:(ue)=>{},back:()=>{},forward:()=>{},go:(ue)=>{}}),rt=(ue)=>{let de=n.__stx_runtime_head||{};n.__stx_runtime_head=et(de,De(ue||{},{known:ho,source:"useHead()"}))},wt=(ue)=>{rt(yo(ue||{}))},ft=(ue)=>({value:ue}),ot=(ue)=>ue,Nt=(ue)=>({value:typeof ue==="function"?ue():ue}),je=(ue,de)=>{},Ae=(ue)=>{},dt=(ue)=>{},nt=(ue)=>ue?ue():Promise.resolve(),pn=(ue)=>(de,...Se)=>{},Pt=(ue)=>{},vt=(ue,de)=>{},fn=(ue,de)=>de,js=()=>({value:"light"}),Jt=()=>re(!1),Rt=(ue)=>re(!1),dn=()=>re(!1),Un=()=>Rt("(prefers-color-scheme: dark)"),gn=()=>Rt("(prefers-color-scheme: light)"),mn=()=>Rt("(prefers-reduced-motion: reduce)"),Zr=()=>Rt("(prefers-contrast: more)"),St={siteId:void 0,API_ENDPOINT:"",ANALYTICS_SITE_ID:void 0,location:{href:"",pathname:"",search:"",hash:"",origin:"",host:"",hostname:"",protocol:"https:",assign:()=>{},replace:()=>{},reload:()=>{}},localStorage:{getItem:()=>null,setItem:()=>{},removeItem:()=>{},clear:()=>{}},sessionStorage:{getItem:()=>null,setItem:()=>{},removeItem:()=>{},clear:()=>{}},fetch:globalThis.fetch,addEventListener:()=>{},removeEventListener:()=>{},setTimeout:()=>0,clearTimeout:()=>{},setInterval:()=>0,clearInterval:()=>{},requestAnimationFrame:()=>0,cancelAnimationFrame:()=>{},alert:()=>{},confirm:()=>!1,prompt:()=>null,getComputedStyle:()=>({}),matchMedia:()=>({matches:!1,addListener:()=>{},removeListener:()=>{}}),getDateRangeParams:()=>"",stx:{}},hn=new Proxy(St,{get(ue,de){if(de in ue)return ue[de];return},set(ue,de,Se){return ue[de]=Se,!0}}),Ps={getElementById:()=>null,querySelector:()=>null,querySelectorAll:()=>[],createElement:()=>({}),createTextNode:()=>({}),body:{},head:{},documentElement:{},addEventListener:()=>{},removeEventListener:()=>{}},Tt=console;try{let ue=Bi(u,r),de=new Set(Object.keys(V)),Se=Object.keys(n).filter((pe)=>!de.has(pe)&&!Vp.has(pe)&&zr(pe)),ze=Se.map((pe)=>n[pe]);if(!Se.includes("__stxServeContext"))Se.push("__stxServeContext"),ze.push(void 0);if(!de.has("cookies")){let pe=n.cookies??n.__stxServeContext?.cookies??{},xe=Se.indexOf("cookies");if(xe<0)Se.push("cookies"),ze.push(pe);else ze[xe]=pe}let tt=new Set(["async","module","exports","require","params","window","document","console","state","derived","effect"]),at=[],Et=[];for(let[pe,xe]of Object.entries(V)){if(!zr(pe))continue;if(tt.has(pe))continue;if(new RegExp(`(?:^|[\\s;{])(?:const|let|var|function)\\s+${pe}\\b`).test(ue))continue;at.push(pe),Et.push(xe)}let Ds=Hp(ue).map((pe)=>`module.exports.${pe} = typeof ${pe} !== 'undefined' ? ${pe} : module.exports.${pe};`).join(`
|
|
1298
|
+
`),Hn=n.params??{},xn=[],bn=[];for(let pe=0;pe<Se.length;pe++){if(Se[pe]==="params")continue;xn.push(Se[pe]),bn.push(ze[pe])}let Kn=[...ht,...at,...xn],qn=`return (async () => {
|
|
1299
|
+
${ue}
|
|
1300
|
+
${Ds}
|
|
1301
|
+
return module.exports
|
|
1302
|
+
})()`,At=E(qn,Kn.join("\x00")),Mt=Ua.get(At);if(!Mt)Mt=Function(...Kn,qn),Ua.set(At,Mt);let It=n.__stx_options?.runtimeConfig;if(It||/\buse(?:Server)?RuntimeConfig\b/.test(u))await Nn(n,r,It);let ct=await Ze(n.__stx_runtime_config??Mn()??z(),()=>si(n,()=>Mt(f,v,M,V,W,Z,q,G,H,Qe,ri,Ki,uo,re,ce,le,fe,we,Ee,ve,Be,it,rt,wt,Re.setResponseStatus,Re.setResponseHeader,Re.notFound,ft,ot,Nt,je,Ae,dt,nt,pn,Pt,U,vt,fn,js,Jt,Rt,dn,Un,gn,mn,Zr,hn,Ps,Tt,St.confirm,St.alert,St.fetch,Hn,...Et,...bn)));if(i.preserveExisting){for(let[pe,xe]of Object.entries(ct))if(!(pe in n)||n[pe]===void 0)n[pe]=xe}else Object.assign(n,ct);for(let[pe,xe]of Object.entries(V))if(!(pe in n))n[pe]=xe}catch(ue){if(n.__stx_strict_hydration)throw ue;let de=Ag(ue instanceof Error?ue.message:String(ue));if(Pg(de))console.warn(`[stx] server <script> in ${r??"<unknown>"} imports a module that does not resolve, so every variable in that script is undefined. Cause: ${de}`),i.onFailure?.({kind:"module-resolution",message:de,error:ue});else if(Ig(ue))console.warn(`[stx] server <script> in ${r??"<unknown>"} does not parse, so every variable in that script is undefined. Cause: ${de}`),i.onFailure?.({kind:"syntax",message:de,error:ue});else if(Og(de))console.warn(`[stx] server <script> in ${r??"<unknown>"} names something that does not exist, so every variable in that script is undefined. Optional chaining does not help here: an undefined identifier throws before the chain is reached. Cause: ${de}`),i.onFailure?.({kind:"missing-binding",message:de,error:ue});else{let Se=`${r??"<unknown>"}\x00${de}`;if(un.env.STX_DEBUG||!Ha.has(Se))Ha.add(Se),console.warn(`[stx] server <script> in ${r??"<unknown>"} threw, so every variable in that script is undefined and anything that reads one renders empty. Cause: ${de}`);i.onFailure?.({kind:"unknown",message:de,error:ue})}try{await Gp(u,n,r)}catch(Se){if(un.env.STX_DEBUG){let ze=Se instanceof Error?Se.message:String(Se);console.warn(`[stx] fallback extraction also failed in ${r??"<unknown>"}: ${ze}`)}}}}function Ng(e){let n=0,r=null,i=!1,a=!1;for(let l=0;l<e.length;l++){let u=e[l];if(r){if(u===r){if(r=null,i||n===0)a=!0}continue}if(u==="'"||u==='"'||u==="`"){r=u;continue}if(u==="{")n++;else if(u==="}")n--;else if(e.startsWith("from",l)&&n===0)i=!0}return r===null&&n===0&&a}var Kp=/^(?:export\s+)?(?:const|let|var)\s+[A-Za-z_$][\w$]*(?:\s*,\s*[A-Za-z_$][\w$]*)*\s*;?$/;function Bi(e,n){let r=n?Ct.dirname(n):un.cwd(),i=un.cwd(),a=e.split(`
|
|
1303
|
+
`),l=[],u=0;while(u<a.length){let f=a[u].trim();if(f.startsWith("interface ")||f.startsWith("export interface ")||f.startsWith("type ")||f.startsWith("export type ")){if(f.includes("{")&&!f.includes("}")){let v=0;for(;u<a.length;u++){for(let S of a[u])if(S==="{")v++;else if(S==="}")v--;if(v<=0)break}}u++;continue}if(f.startsWith("definePageMeta(")){let v=0,S=!1,I=u;for(let M=u;M<a.length&&!S;M++){let V=null,W=!1,Z=a[M];for(let q=0;q<Z.length;q++){let G=Z[q];if(W){W=!1;continue}if(G==="\\"){W=!0;continue}if(V){if(G===V)V=null;continue}if(G==='"'||G==="'"||G==="`"){V=G;continue}if(G==="(")v++;else if(G===")"){if(v--,v===0){u=M+1,S=!0;break}}}}if(!S)u=a.length;let j=a.slice(I,u).join(`
|
|
1304
|
+
`),L=[];for(let M of["title","description"]){let V=new RegExp(`\\b${M}\\s*:\\s*(['"\`])((?:\\\\.|(?!\\1)[^\\\\])*)\\1`).exec(j);if(V)L.push(`${M}: ${JSON.stringify(V[2])}`)}if(L.length>0)l.push(`useSeoMeta({ ${L.join(", ")} });`);continue}if(f.startsWith("import ")||f==="import"||f.startsWith("import{")||/^import['"]/.test(f)){let v=f,S=0;while(!Ng(v)&&u+S+1<a.length)S++,v=`${v} ${a[u+S].trim()}`;u+=S;let I=v.match(/^import\s+(\w+)\s+from\s+['"](.+?)['"]/),j=v.match(/^import\s+\{([^}]*)\}\s+from\s+['"](.+?)['"]/),L=v.match(/^import\s*['"](.+?)['"]/),M=v,V=(W)=>{if(W.startsWith("."))return Ct.resolve(r,W);if(W.startsWith("~/")||W.startsWith("@/"))return Ct.resolve(i,W.slice(2));try{return Bun.resolveSync(W,r)}catch{return W}};if(I){let[,W,Z]=I,q=V(Z);l.push(`const ${W} = (await import('${q}')).default`),l.push(`module.exports.${W} = ${W};`)}else if(j){let[,W,Z]=j,q=V(Z),G=[],U=[],H=Up.has(Z);for(let re of W.split(",")){let ce=re.trim();if(!ce)continue;let le=ce.split(/\s+as\s+/);if(le.length===2){let[fe,we]=[le[0].trim(),le[1].trim()];if(H&&Fa.has(fe)){l.push(`const ${we} = ${fe};`);continue}G.push(`${fe}: ${we}`),U.push(we)}else{if(H&&Fa.has(ce))continue;G.push(ce),U.push(ce)}}if(G.length>0)l.push(`const { ${G.join(", ")} } = await import('${q}')`);for(let re of U)l.push(`module.exports.${re} = ${re};`)}else if(L){let W=V(L[1]);l.push(`await import('${W}')`)}else l.push(M);u++;continue}if(Kp.test(f))l.push(a[u]),u++;else if(f.startsWith("export const ")||f.startsWith("export let ")||f.startsWith("export var ")){let v=qa(a,u),{type:S,name:I,value:j}=v;l.push(`${S} ${I} = ${j};`),l.push(`module.exports.${I} = ${I};`),u=v.nextIndex}else if(f.startsWith("export function ")||f.startsWith("export async function ")){let v=qr(a,u);l.push(v.functionCode),l.push(`module.exports.${v.name} = ${v.name};`),u=v.nextIndex}else if(f.startsWith("const ")||f.startsWith("let ")||f.startsWith("var ")){let v=qa(a,u),{type:S,name:I,value:j}=v;l.push(`${S} ${I} = ${j};`),l.push(`module.exports.${I} = ${I};`),u=v.nextIndex}else if(f.startsWith("function ")||f.startsWith("async function ")){let v=qr(a,u);l.push(v.functionCode),l.push(`module.exports.${v.name} = ${v.name};`),u=v.nextIndex}else if(f.startsWith("export default function ")||f.startsWith("export default async function ")){let v=a[u].replace(/^(\s*)export\s+default\s+/,"$1"),S=[...a];S[u]=v;let I=qr(S,u);if(l.push(I.functionCode),I.name)l.push(`module.exports.default = ${I.name};`);u=I.nextIndex}else if(f.startsWith("export default ")){let v=f.replace(/^export\s+default\s+/,"").replace(/;$/,"");l.push(`module.exports.default = ${v};`),u++}else if(f.startsWith("class ")||f.startsWith("export class ")){let v=f.match(/(?:export\s+)?class\s+(\w+)/);if(v){let S=v[1],I=a[u].replace(/^export\s+/,""),j=0,L=u;for(;L<a.length;L++){let M=a[L];for(let V of M)if(V==="{")j++;else if(V==="}")j--;if(L>u)I+=`
|
|
1305
|
+
`+M;if(j<=0&&L>=u)break}l.push(I),l.push(`module.exports.${S} = ${S};`),u=L+1}else l.push(f),u++}else if(f.includes("module.exports"))l.push(f),u++;else if(f.trim()&&!f.startsWith("//"))l.push(f),u++;else u++}return qp(l.join(`
|
|
1306
|
+
`),r,i)}function qp(e,n,r){let i=e.length,a="",l=0,u=null,f=!1,v=!1,S=0;while(l<i){let I=e[l],j=e[l+1];if(f){if(a+=I,I===`
|
|
1307
|
+
`)f=!1;l++;continue}if(v){if(a+=I,I==="*"&&j==="/"){a+=j,l+=2,v=!1;continue}l++;continue}if(!u&&I==="/"&&j==="/"){f=!0,a+=I,l++;continue}if(!u&&I==="/"&&j==="*"){v=!0,a+=I,l++;continue}if(u){if(a+=I,I==="\\"){a+=j,l+=2;continue}if(I===u&&u!=="`"){u=null,l++;continue}if(u==="`"){if(I==="$"&&j==="{"){S++,a+=j,l+=2;continue}if(I==="`"){u=null,l++;continue}}l++;continue}if(S>0){if(I==="{")S++;else if(I==="}")S--}if(I==='"'||I==="'"||I==="`"){u=I,a+=I,l++;continue}if(I==="a"&&e.startsWith("await",l)){let L=Zp(e,l);if(L){let{quote:M,path:V,end:W}=L;if(V.startsWith(".")||V.startsWith("~/")||V.startsWith("@/")){let Z=V.startsWith(".")?Ct.resolve(n,V):Ct.resolve(r,V.slice(2));a+=`await import(${M}${Z}${M})`,l=W;continue}}}a+=I,l++}return a}function Zp(e,n){let r=n+5;if(r>=e.length)return null;if(!/\s/.test(e[r]))return null;while(r<e.length&&/\s/.test(e[r]))r++;if(!e.startsWith("import",r))return null;r+=6;while(r<e.length&&/\s/.test(e[r]))r++;if(e[r]!=="(")return null;r++;while(r<e.length&&/\s/.test(e[r]))r++;let i=e[r];if(i!=="'"&&i!=='"')return null;r++;let a=r;while(r<e.length&&e[r]!==i)if(e[r]==="\\")r+=2;else r++;if(r>=e.length)return null;let l=e.slice(a,r);r++;while(r<e.length&&/\s/.test(e[r]))r++;if(e[r]!==")")return null;return{quote:i,path:l,end:r+1}}function Ga(e,n){let r=e[n];if(r!=="{"&&r!=="[")return null;let a=_(e,r,r==="{"?"}":"]",n);if(a===-1)return null;return{pattern:e.slice(n,a+1),endPos:a+1}}function Ya(e){let n=[],r=e.slice(1,-1).trim();if(!r)return n;let i=0,a=0,l="";while(i<r.length){let u=r[i];if(u==="{"||u==="["){let f=a===0?Ga(r,i):null;if(f){n.push(...Ya(f.pattern)),i=f.endPos,l="";continue}a++}else if(u==="}"||u==="]")a--;if(a>0){i++;continue}if(u===","){if(l.trim())n.push(l.trim());l="",i++;continue}if(u===":"){l="",i++;continue}if(u==="="){if(l.trim())n.push(l.trim());l="",i++;while(i<r.length&&r[i]!==","&&a===0){if(r[i]==="{"||r[i]==="[")a++;else if(r[i]==="}"||r[i]==="]")a--;i++}continue}if(/[\w$]/.test(u))l+=u;i++}if(l.trim())n.push(l.trim());return n}function Mg(e){let n=/^(?:export\s+)?(const|let|var)\s+([A-Za-z_$][\w$]*)/.exec(e);if(!n)return null;let r=n[0].length,i=(a)=>a===" "||a==="\t";while(r<e.length&&i(e[r]))r++;if(e[r]===":"){let a=0,l=null;r++;for(;r<e.length;r++){let u=e[r];if(l){if(u==="\\"){r++;continue}if(u===l)l=null;continue}if(u==="'"||u==='"'||u==="`"){l=u;continue}if(u==="("||u==="["||u==="{"||u==="<"){a++;continue}if(u===")"||u==="]"||u==="}"||u===">"){a--;continue}if(u==="="&&a<=0){let f=e[r+1],v=e[r-1];if(f!=="="&&f!==">"&&v!=="="&&v!=="!"&&v!=="<"&&v!==">")break}}if(e[r]!=="=")return null}while(r<e.length&&i(e[r]))r++;if(e[r]!=="=")return null;return{type:n[1],name:n[2],value:e.slice(r+1).trim()}}function Ka(e,n,r,i){let a=null,l=!1;for(let u of e){if(l){l=!1;continue}if(u==="\\"){l=!0;continue}if(a){if(u===a)a=null;continue}if(u==="'"||u==='"'||u==="`"){a=u;continue}if(u===n)i++;else if(u===r)i--}return i}function qa(e,n){let r=e[n].trim(),i=Mg(r),a=i?[r,i.type,i.name,i.value]:null;if(!a){let I=r.match(/^(?:export\s+)?(const|let|var)\s+/);if(I){let j=r.slice(I[0].length),L=n;if(j.startsWith("{")||j.startsWith("[")){let V=j[0],W=V==="{"?"}":"]",Z=Ka(j,V,W,0),q=j;for(let G=n+1;G<e.length&&Z>0;G++)q+=` ${e[G].trim()}`,L=G,Z=Ka(e[G],V,W,Z);if(Z>0)q=j,L=n;j=q}let M=Ga(j,0);if(M){let V=I[1],W=M.pattern,Z=j.slice(M.endPos).trim();if(Z.startsWith("=")){let q=Z.slice(1).trim(),G=q,U=Math.max(L,n);if(Za(q)){let le=Ja(e,U,q);G=le.value,U=le.nextIndex}else U=U+1;G=G.trim().replace(/;$/,"");let H=Ya(W),re=`__stx_src_${n}`,ce=H.map((le)=>`module.exports.${le} = ${le};`).join(`
|
|
1308
|
+
`);return{type:V,name:re,value:`${G}; ${V} ${W} = ${re};
|
|
1309
|
+
${ce}`,nextIndex:U}}}}throw Error(`Failed to parse variable declaration: ${r}`)}let[,l,u,f]=a,v=f,S=n;if(Za(f)){let I=Ja(e,n,f);v=I.value,S=I.nextIndex}else S=n+1;while(S<e.length){let I=e[S].trim();if(I.startsWith(".")||I.startsWith("?."))v+=`
|
|
1310
|
+
${e[S]}`,S++;else break}return v=v.trim().replace(/;$/,""),{type:l,name:u,value:v,nextIndex:S}}function qr(e,n){let r=e[n].trim(),i=r.match(/^(?:export\s+)?(?:async\s+)?function\s+(\w+)/);if(!i)throw Error(`Failed to parse function declaration: ${r}`);let[,a]=i,l=r.replace(/^export\s+/,""),u=n;if(Jp(r)){let f=Xp(e,n,l);l=f.functionCode,u=f.nextIndex}else u=n+1;return{name:a,functionCode:l,nextIndex:u}}function Za(e){let n=e.trim();if(n.startsWith("{"))return _(n,"{","}",0)===-1;if(n.startsWith("["))return _(n,"[","]",0)===-1;return!Qa(n)}function Qa(e){let n={paren:0,bracket:0,brace:0},r=null,i=0;for(let a=0;a<e.length;a++){let l=e[a];if((a>0?e[a-1]:"")==="\\"&&r)continue;if((l==='"'||l==="'")&&!r){r=l;continue}if(l===r&&r!=="`"){r=null;continue}if(l==="`"&&!r){r="`";continue}if(l==="`"&&r==="`"&&i===0){r=null;continue}if(r==="`"&&l==="$"&&e[a+1]==="{"){i++,a++;continue}if(i>0&&l==="{"){i++;continue}if(i>0&&l==="}"){i--;continue}if(r)continue;if(l==="(")n.paren++;else if(l===")")n.paren--;else if(l==="[")n.bracket++;else if(l==="]")n.bracket--;else if(l==="{")n.brace++;else if(l==="}")n.brace--}return n.paren===0&&n.bracket===0&&n.brace===0&&r===null}function ec(e){let n=e.indexOf("(");if(n===-1)return e.indexOf("{");let r=_(e,"(",")",n);if(r===-1)return-1;return e.indexOf("{",r)}function Jp(e){let n=ec(e);if(n===-1)return!0;return _(e,"{","}",n)===-1}function Ja(e,n,r){let i=r,a=n+1;while(a<e.length&&!Qa(i)){let l=e[a];i+=`
|
|
1311
|
+
${l}`,a++}while(a<e.length){let l=e[a].trim();if(l.startsWith(".")||l.startsWith("?."))i+=`
|
|
1312
|
+
${e[a]}`,a++;else break}return{value:i,nextIndex:a}}function Xp(e,n,r){let i=r,a=n+1;while(a<e.length){let l=ec(i);if(l!==-1){if(_(i,"{","}",l)!==-1)break}let u=e[a];i+=`
|
|
1313
|
+
${u}`,a++}return{functionCode:i,nextIndex:a}}function Xa(e,n){let r=d(e,n)??d(`(${e})`,n);if(r!==void 0)return r;if(!/\bprocess\b/.test(e))return;let i={...n,process:Object.freeze({env:{...un.env}})},a=Object.keys(i).filter(zr),l=a.map((u)=>i[u]);try{return Function(...a,`'use strict'; return (${e});`)(...l)}catch{try{return Function(...a,`'use strict'; return ${e};`)(...l)}catch{return}}}async function Gp(e,n,r){let i=e.matchAll(/export\s+(const|let|var)\s+(\w+)\s*=\s*([\s\S]*?)(?=\s*(?:export\s+|$))/g);for(let l of i){let[,,u,f]=l;try{let v=f.trim().replace(/;$/,""),S=Xa(v,n);if(S!==void 0)n[u]=S}catch(v){console.warn(`Failed to parse export ${u} in fallback:`,v)}}let a=e.matchAll(/(?:^|\n)\s*(const|let|var)\s+(\w+)\s*=\s*([\s\S]*?)(?=\s*(?:(?:const|let|var|function|export)\s+|$))/g);for(let l of a){let[,,u,f]=l;if(!(u in n))try{let v=f.trim().replace(/;$/,""),S=Xa(v,n);if(S!==void 0)n[u]=S}catch{}}}function bl(e){let n=e.match(/<script\b[^>]*>([\s\S]*?)<\/script>/i),r=n?n[1]:"",i=n?e.replace(/<script\b[^>]*>[\s\S]*?<\/script>/i,""):e;return{scriptContent:r,templateWithoutScript:i}}function wl(e){let n=e.trim();if(!n)return!1;return/(?:const|let|var|function)\s+\w+/.test(n)}
|
|
1314
|
+
export{Ue,Pe,X,Gs,Xs,J,Ir,Js,Ys,Ti,$i,Ri,Zs,Ai,tl,Vt,o,me,k,nl,E,Or,Qs,Ie,A,We,B,Ut,Oe,Q,Cn,qe,x,rl,ke,se,Nr,ee,Mr,Dr,he,Wt,oe,F,mt,O,Lr,jr,ht,sl,qt,eo,to,_e,Pi,En,no,ye,ol,il,Ii,al,Oi,cl,ro,Ni,Mi,ll,Di,Li,Tn,so,$n,Kt,Gt,ul,oo,dl,pl,Rn,Br,io,ao,fl,ji,gl,ml,hl,yl,Rg,Ag,Pg,Ig,Og,y,Ng,Bi,Mg,bl,wl,Fi,zi,Dg,Xt,vl,Lg,xl,Ty,Ke,An,Ge,jg,Bg,Fg,zg,Hg,co,Vg,Xe,ie,Je,Ug,Fr,Wg,Sl,kl,Hi,Ye,s,Pn,_l,b,Ce,$y,Cl,El,Tl,Vi,lo,qg,Ry,Kg,Ay,In,g,Y,ae,On,Ne,Gg,Ui,Xg,Py,P,Wi,Jg,Iy,N,Oy};
|