@stacksjs/stx 0.2.453 → 0.2.455
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/app-service-worker.d.ts +4 -1
- package/dist/chunk-06gzq9xe.js +17 -0
- package/dist/{chunk-yx37nrgr.js → chunk-0trfbqa7.js} +4 -4
- package/dist/{chunk-8ah8npj3.js → chunk-0v5dpk7r.js} +1 -1
- package/dist/{chunk-z68rb7qp.js → chunk-0vae943t.js} +5 -5
- package/dist/chunk-143gpdxy.js +2 -0
- package/dist/{chunk-w8ek4fe8.js → chunk-1sdtg9np.js} +2 -2
- package/dist/chunk-1vgmzmsw.js +2 -0
- package/dist/{chunk-aem9hs8n.js → chunk-1vm403b2.js} +2 -2
- package/dist/{chunk-7mbx7dzg.js → chunk-2bdthb37.js} +2 -2
- package/dist/{chunk-149r1q6c.js → chunk-2cy956js.js} +2 -2
- package/dist/chunk-2hddf9pn.js +2 -0
- package/dist/chunk-2jxe6y8h.js +2 -0
- package/dist/chunk-32t5agpk.js +2 -0
- package/dist/chunk-3ar8gdyd.js +2 -0
- package/dist/{chunk-697zcjzg.js → chunk-3jc6pahv.js} +12 -12
- package/dist/chunk-3s2vnqcf.js +2 -0
- package/dist/{chunk-hhjff2r8.js → chunk-44msrx2e.js} +3 -3
- package/dist/{chunk-0tchj3ct.js → chunk-462jmw0a.js} +6 -6
- package/dist/chunk-4bd491yq.js +2 -0
- package/dist/{chunk-g8k5rsqq.js → chunk-4fa3jec9.js} +12 -12
- package/dist/chunk-4henqdjf.js +2 -0
- package/dist/chunk-4qv9me8f.js +2 -0
- package/dist/chunk-561yczfn.js +2 -0
- package/dist/chunk-58n62bxb.js +3 -0
- package/dist/chunk-5m8q7c5r.js +2 -0
- package/dist/{chunk-pkpmyr0x.js → chunk-5p56w2ke.js} +3 -3
- package/dist/chunk-5pjsc9zv.js +3 -0
- package/dist/{chunk-n9jn3qzw.js → chunk-5qns2sdz.js} +2 -2
- package/dist/{chunk-2428rqy1.js → chunk-5ryntw3w.js} +6 -6
- package/dist/chunk-68dsxv8z.js +2 -0
- package/dist/chunk-68txmj8d.js +2 -0
- package/dist/{chunk-45rfv3a5.js → chunk-6cp3afft.js} +2 -2
- package/dist/chunk-6nec76z0.js +2 -0
- package/dist/chunk-6qv189mb.js +2 -0
- package/dist/{chunk-dwp3knc4.js → chunk-6r2709dj.js} +3 -3
- package/dist/chunk-77hanm4y.js +2 -0
- package/dist/chunk-7tt84v1y.js +3 -0
- package/dist/chunk-8efg91ak.js +4 -0
- package/dist/chunk-8nd0f6z0.js +2 -0
- package/dist/{chunk-73h7qjgq.js → chunk-8xz8t9xp.js} +2 -2
- package/dist/{chunk-qbhbe9cw.js → chunk-9ac40ggt.js} +5 -5
- package/dist/chunk-9mtz7tyv.js +2 -0
- package/dist/chunk-9t50hw97.js +2 -0
- package/dist/chunk-9z22zs86.js +2 -0
- package/dist/chunk-a32kqsff.js +2 -0
- package/dist/{chunk-19h1j59a.js → chunk-ab56jdah.js} +1 -1
- package/dist/chunk-adjf8fvc.js +3 -0
- package/dist/{chunk-33xh91s8.js → chunk-am1hw771.js} +2 -2
- package/dist/chunk-bpzrfqvw.js +2 -0
- package/dist/{chunk-0xztxj98.js → chunk-bq2e9qf6.js} +3 -3
- package/dist/{chunk-hqywyyez.js → chunk-c491hsm1.js} +5 -5
- package/dist/chunk-czvkkrww.js +2 -0
- package/dist/{chunk-jn8tj4kn.js → chunk-d3mpxr3s.js} +4 -4
- package/dist/{chunk-849wf19d.js → chunk-dxxs52yw.js} +3 -3
- package/dist/chunk-e78ame3h.js +2 -0
- package/dist/chunk-ef0gstkd.js +2 -0
- package/dist/{chunk-zqzv5jy2.js → chunk-exgyf65a.js} +4 -4
- package/dist/{chunk-538h1sfc.js → chunk-f4c39nfh.js} +2 -2
- package/dist/{chunk-3nydw825.js → chunk-fen7zb1b.js} +8 -8
- package/dist/{chunk-s5drjm2j.js → chunk-gkqxnetc.js} +6 -6
- package/dist/{chunk-47jq9j1w.js → chunk-gyv7dcyx.js} +2 -2
- package/dist/{chunk-axydabse.js → chunk-h9e032kq.js} +3 -3
- package/dist/chunk-ha5z623e.js +2 -0
- package/dist/chunk-hehtgsrt.js +2 -0
- package/dist/{chunk-3pc22sve.js → chunk-hg7abc58.js} +6 -6
- package/dist/chunk-hjg3e338.js +2 -0
- package/dist/chunk-hqsgp9wy.js +2 -0
- package/dist/chunk-hqzq3a61.js +2 -0
- package/dist/chunk-hskrxdcc.js +2 -0
- package/dist/chunk-hvx3pc13.js +2 -0
- package/dist/{chunk-9zbjk8pg.js → chunk-jckvavdb.js} +8 -8
- package/dist/chunk-jdhs9w6h.js +2 -0
- package/dist/{chunk-4q366fhp.js → chunk-jpgma7e8.js} +5 -5
- package/dist/chunk-jtmfwhsy.js +11 -0
- package/dist/{chunk-dqr5n49p.js → chunk-jz7pvh7b.js} +2 -2
- package/dist/chunk-kcs71ks8.js +2 -0
- package/dist/chunk-kda62f5h.js +2 -0
- package/dist/{chunk-26wmppja.js → chunk-kppgyqwb.js} +1 -1
- package/dist/chunk-kwct777t.js +2831 -0
- package/dist/chunk-m7p98cmy.js +4 -0
- package/dist/chunk-mbapk9ka.js +2 -0
- package/dist/chunk-me5039d4.js +2 -0
- package/dist/{chunk-fmj4xvqm.js → chunk-mhpsz5m0.js} +5 -5
- package/dist/{chunk-b1q5sh7x.js → chunk-n1dyjhte.js} +3 -3
- package/dist/{chunk-mnz6bdp3.js → chunk-n866vbgj.js} +5 -5
- package/dist/chunk-n8hd5qap.js +2 -0
- package/dist/{chunk-s59r34p5.js → chunk-nmf12mx3.js} +4 -4
- package/dist/chunk-nqvb9094.js +2 -0
- package/dist/chunk-p4zeqzmr.js +2 -0
- package/dist/chunk-pcp5twev.js +2 -0
- package/dist/chunk-pe214qcn.js +2 -0
- package/dist/{chunk-4yyzje7d.js → chunk-pw34r8r5.js} +1 -1
- package/dist/{chunk-81v9crqy.js → chunk-q8ttp85g.js} +1 -1
- package/dist/chunk-q98v7bhs.js +2 -0
- package/dist/chunk-qhwvjsbx.js +2 -0
- package/dist/chunk-qrgr2h1n.js +2 -0
- package/dist/{chunk-5xj1df83.js → chunk-r6pax860.js} +7 -7
- package/dist/{chunk-rdq113p4.js → chunk-r80km6mn.js} +2 -2
- package/dist/{chunk-tehvry9a.js → chunk-rcr57c30.js} +10 -10
- package/dist/{chunk-8fj8sm1a.js → chunk-ree9weje.js} +2 -2
- package/dist/{chunk-x4ztj64h.js → chunk-rgwvqmhh.js} +2 -2
- package/dist/chunk-rsj5q7zm.js +2 -0
- package/dist/{chunk-tn85vr56.js → chunk-rvgvt161.js} +2 -2
- package/dist/chunk-rwx1s3b5.js +2 -0
- package/dist/chunk-rzmvsqc7.js +2 -0
- package/dist/{chunk-rbkna5rw.js → chunk-skgdg84c.js} +11 -11
- package/dist/{chunk-yfd0e7dr.js → chunk-tbjyp03h.js} +1 -1
- package/dist/chunk-tmn8hxm6.js +2 -0
- package/dist/{chunk-g2afpsw0.js → chunk-tpeyn7wr.js} +2 -2
- package/dist/{chunk-s6e8mmk1.js → chunk-tpvc8xnk.js} +6 -6
- package/dist/chunk-tr7dz5g5.js +2 -0
- package/dist/{chunk-5cyme1g0.js → chunk-v3yqeh15.js} +2 -2
- package/dist/{chunk-9ndzk9r4.js → chunk-vg7wfkt5.js} +3 -3
- package/dist/chunk-vrvnctex.js +2 -0
- package/dist/chunk-w00khg58.js +2 -0
- package/dist/chunk-w1h9ts86.js +2 -0
- package/dist/{chunk-afhkvj3k.js → chunk-w1zvh5y7.js} +2 -2
- package/dist/chunk-w62ettpr.js +2 -0
- package/dist/{chunk-b5wh10s9.js → chunk-xd71zy8q.js} +78 -78
- package/dist/chunk-xe90p9rp.js +2 -0
- package/dist/{chunk-56rk985x.js → chunk-y3cqh2jv.js} +3 -3
- package/dist/{chunk-0vbpcef6.js → chunk-z2daw0th.js} +4 -4
- package/dist/{chunk-nw8p8eg9.js → chunk-z3etxty5.js} +5 -5
- package/dist/{chunk-vraddzkf.js → chunk-z6tag2ng.js} +4 -4
- package/dist/{chunk-g3h7j2n7.js → chunk-z80d9dd2.js} +2 -2
- package/dist/chunk-z990jtmx.js +2 -0
- package/dist/chunk-zjp0v2ja.js +33 -0
- package/dist/{chunk-d1xbamr1.js → chunk-znj79hta.js} +2 -2
- package/dist/chunk-zrbpy3m5.js +2 -0
- package/dist/{chunk-jwpcck1b.js → chunk-zydg3wgt.js} +2 -2
- package/dist/cli.js +20 -20
- package/dist/client-script.d.ts +0 -21
- package/dist/client-script.js +21 -0
- package/dist/composable-loader.js +41 -17
- package/dist/compression.js +25 -6
- package/dist/craft-entry.js +2 -2
- package/dist/craft.js +2 -2
- package/dist/html-masking.js +36 -8
- package/dist/i18n.js +4 -3
- package/dist/includes.js +6 -2
- package/dist/misc-directives.d.ts +0 -10
- package/dist/misc-directives.js +12 -0
- package/dist/native/runtime/native-host.d.ts +1 -0
- package/dist/native/runtime/native-host.js +63 -12
- package/dist/native/runtime/shared-screen.js +11 -2
- package/dist/offline/app-service-worker.d.ts +4 -1
- package/dist/offline/app-service-worker.js +62 -27
- package/dist/process.js +4 -0
- package/dist/pwa.js +3 -3
- package/dist/source-signature.d.ts +5 -2
- package/dist/source-signature.js +7 -0
- package/dist/ssg.js +8 -8
- package/dist/store-loader.js +2 -1
- package/dist/utils.js +27 -15
- package/package.json +5 -5
- package/dist/chunk-14x69rt4.js +0 -2
- package/dist/chunk-1kmd0g1k.js +0 -3
- package/dist/chunk-3wezvz6m.js +0 -2
- package/dist/chunk-5402rpwg.js +0 -2
- package/dist/chunk-58ymq1h4.js +0 -2
- package/dist/chunk-5rtbs8zv.js +0 -2
- package/dist/chunk-5tx1wqns.js +0 -2
- package/dist/chunk-6fw3rfcj.js +0 -2
- package/dist/chunk-6nfecsbt.js +0 -2
- package/dist/chunk-6sw7sxh2.js +0 -17
- package/dist/chunk-7qbv0xh6.js +0 -2
- package/dist/chunk-7vdsd9rn.js +0 -2
- package/dist/chunk-8gk34047.js +0 -2
- package/dist/chunk-8nsfkr5n.js +0 -2
- package/dist/chunk-90562q79.js +0 -3
- package/dist/chunk-a1dggchm.js +0 -2
- package/dist/chunk-a1kv42kp.js +0 -2
- package/dist/chunk-a5695s8k.js +0 -2
- package/dist/chunk-avjgetkh.js +0 -2
- package/dist/chunk-bcgth8qf.js +0 -2
- package/dist/chunk-bemksdz5.js +0 -33
- package/dist/chunk-br3ktpyq.js +0 -2
- package/dist/chunk-by1s70jp.js +0 -2
- package/dist/chunk-cwc3p6p7.js +0 -2
- package/dist/chunk-e593pr1r.js +0 -2
- package/dist/chunk-e8y69gg0.js +0 -2
- package/dist/chunk-eam7eann.js +0 -2
- package/dist/chunk-ej7m406s.js +0 -2
- package/dist/chunk-es85mgdw.js +0 -2
- package/dist/chunk-fa5x9zbk.js +0 -2
- package/dist/chunk-fkrzsk74.js +0 -2
- package/dist/chunk-fm3k5v8s.js +0 -2
- package/dist/chunk-fmc9fj4a.js +0 -2
- package/dist/chunk-fn863yek.js +0 -2
- package/dist/chunk-fv30avp2.js +0 -2
- package/dist/chunk-gpmk4s4f.js +0 -2
- package/dist/chunk-hd64hz1n.js +0 -2
- package/dist/chunk-hd75916k.js +0 -4
- package/dist/chunk-hz6a476h.js +0 -2
- package/dist/chunk-j7zywbq0.js +0 -4
- package/dist/chunk-jjm3754f.js +0 -2
- package/dist/chunk-ktk30f6d.js +0 -2
- package/dist/chunk-m3f50p6c.js +0 -2
- package/dist/chunk-m90a5dpn.js +0 -2
- package/dist/chunk-mmp7x8f0.js +0 -2
- package/dist/chunk-nqcg2bf0.js +0 -2
- package/dist/chunk-nrp8qg9j.js +0 -2831
- package/dist/chunk-ns7e951g.js +0 -2
- package/dist/chunk-nycvwnty.js +0 -2
- package/dist/chunk-p9shre7t.js +0 -2
- package/dist/chunk-pe9hxhrb.js +0 -2
- package/dist/chunk-ph6xg67j.js +0 -11
- package/dist/chunk-qewxfhex.js +0 -2
- package/dist/chunk-qfrg8mnf.js +0 -2
- package/dist/chunk-rmnhy5az.js +0 -2
- package/dist/chunk-t6m5wmpy.js +0 -2
- package/dist/chunk-v404gvm0.js +0 -2
- package/dist/chunk-vgvsefz8.js +0 -2
- package/dist/chunk-w9k7pvre.js +0 -2
- package/dist/chunk-wf09xg7j.js +0 -2
- package/dist/chunk-wgqt5pnv.js +0 -2
- package/dist/chunk-wr3h8dmt.js +0 -2
- package/dist/chunk-wtqjfar3.js +0 -2
- package/dist/chunk-x1xncm97.js +0 -2
- package/dist/chunk-yd50awqp.js +0 -3
- package/dist/chunk-ykxd78b2.js +0 -2
- package/dist/chunk-yqsza22w.js +0 -3
- package/dist/chunk-zj80vrv6.js +0 -2
|
@@ -0,0 +1,2831 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{t,X,rr,i,te,Rs,A,Tt,pn,As,c,p,D,ve,Ye,l,sr}from"./chunk-r6pax860.js";import{hn,yn,lr,Se}from"./chunk-nmf12mx3.js";import{gn,y,xi,Rt,Is,Si,ki,Ci,$i}from"./chunk-w1zvh5y7.js";import{P}from"./chunk-h9e032kq.js";import{S,Ts,Ge,un,tr,de,_s,pe,nr}from"./chunk-exgyf65a.js";import{ks,Cs,$s,Es,Yn,Zn}from"./chunk-4fa3jec9.js";import{le,Et,Jn,Ss,C,Ke}from"./chunk-zydg3wgt.js";import{cn}from"./chunk-1vm403b2.js";import{Ls}from"./chunk-jz7pvh7b.js";import{yi,vs,Xn,Gn}from"./chunk-0trfbqa7.js";import{ui,di,fi,gi}from"./chunk-bq2e9qf6.js";import{qe}from"./chunk-tfexmdkt.js";import{s,be}from"./chunk-y3cqh2jv.js";import{$t,wi,on,a,an}from"./chunk-7tt84v1y.js";import{u}from"./chunk-cg8hg6cs.js";import{fe,O,fn}from"./chunk-58n62bxb.js";import{ur}from"./chunk-rvgvt161.js";import p0 from"fs";import Yl from"path";import{createHighlighter as g0}from"ts-syntax-highlighter";import aa from"fs";import dn from"path";import{loadConfigWithResult as a0}from"bunfig";var or={duration:300,delay:0,ease:"ease",direction:"both"};function nh(v,_={}){let{duration:k,delay:E,ease:T,direction:j,custom:B}={...or,..._};if(v==="custom"&&B)return B;switch(v){case"fade":return`${j==="in"?"opacity: 0; animation: fadeIn var(--stx-transition-duration, 300ms) var(--stx-transition-ease, ease) var(--stx-transition-delay, 0ms) forwards;":j==="out"?"opacity: 1; animation: fadeOut var(--stx-transition-duration, 300ms) var(--stx-transition-ease, ease) var(--stx-transition-delay, 0ms) forwards;":"opacity: 1; transition: opacity var(--stx-transition-duration, 300ms) var(--stx-transition-ease, ease) var(--stx-transition-delay, 0ms);"}
|
|
3
|
+
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
|
|
4
|
+
@keyframes fadeOut { from { opacity: 1; } to { opacity: 0; } }`;case"slide":return`${j==="in"?"transform: translateY(20px); opacity: 0; animation: slideIn var(--stx-transition-duration, 300ms) var(--stx-transition-ease, ease) var(--stx-transition-delay, 0ms) forwards;":j==="out"?"transform: translateY(0); opacity: 1; animation: slideOut var(--stx-transition-duration, 300ms) var(--stx-transition-ease, ease) var(--stx-transition-delay, 0ms) forwards;":"transform: translateY(0); opacity: 1; transition: transform var(--stx-transition-duration, 300ms) var(--stx-transition-ease, ease) var(--stx-transition-delay, 0ms), opacity var(--stx-transition-duration, 300ms) var(--stx-transition-ease, ease) var(--stx-transition-delay, 0ms);"}
|
|
5
|
+
@keyframes slideIn { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
|
|
6
|
+
@keyframes slideOut { from { transform: translateY(0); opacity: 1; } to { transform: translateY(20px); opacity: 0; } }`;case"scale":return`${j==="in"?"transform: scale(0.95); opacity: 0; animation: scaleIn var(--stx-transition-duration, 300ms) var(--stx-transition-ease, ease) var(--stx-transition-delay, 0ms) forwards;":j==="out"?"transform: scale(1); opacity: 1; animation: scaleOut var(--stx-transition-duration, 300ms) var(--stx-transition-ease, ease) var(--stx-transition-delay, 0ms) forwards;":"transform: scale(1); opacity: 1; transition: transform var(--stx-transition-duration, 300ms) var(--stx-transition-ease, ease) var(--stx-transition-delay, 0ms), opacity var(--stx-transition-duration, 300ms) var(--stx-transition-ease, ease) var(--stx-transition-delay, 0ms);"}
|
|
7
|
+
@keyframes scaleIn { from { transform: scale(0.95); opacity: 0; } to { transform: scale(1); opacity: 1; } }
|
|
8
|
+
@keyframes scaleOut { from { transform: scale(1); opacity: 1; } to { transform: scale(0.95); opacity: 0; } }`;case"flip":return`${j==="in"?"transform: perspective(400px) rotateX(-90deg); opacity: 0; animation: flipIn var(--stx-transition-duration, 300ms) var(--stx-transition-ease, ease) var(--stx-transition-delay, 0ms) forwards;":j==="out"?"transform: perspective(400px) rotateX(0); opacity: 1; animation: flipOut var(--stx-transition-duration, 300ms) var(--stx-transition-ease, ease) var(--stx-transition-delay, 0ms) forwards;":"transform: perspective(400px) rotateX(0); opacity: 1; transition: transform var(--stx-transition-duration, 300ms) var(--stx-transition-ease, ease) var(--stx-transition-delay, 0ms), opacity var(--stx-transition-duration, 300ms) var(--stx-transition-ease, ease) var(--stx-transition-delay, 0ms);"}
|
|
9
|
+
@keyframes flipIn { from { transform: perspective(400px) rotateX(-90deg); opacity: 0; } to { transform: perspective(400px) rotateX(0); opacity: 1; } }
|
|
10
|
+
@keyframes flipOut { from { transform: perspective(400px) rotateX(0); opacity: 1; } to { transform: perspective(400px) rotateX(90deg); opacity: 0; } }`;case"rotate":return`${j==="in"?"transform: rotate(-90deg); opacity: 0; animation: rotateIn var(--stx-transition-duration, 300ms) var(--stx-transition-ease, ease) var(--stx-transition-delay, 0ms) forwards;":j==="out"?"transform: rotate(0); opacity: 1; animation: rotateOut var(--stx-transition-duration, 300ms) var(--stx-transition-ease, ease) var(--stx-transition-delay, 0ms) forwards;":"transform: rotate(0); opacity: 1; transition: transform var(--stx-transition-duration, 300ms) var(--stx-transition-ease, ease) var(--stx-transition-delay, 0ms), opacity var(--stx-transition-duration, 300ms) var(--stx-transition-ease, ease) var(--stx-transition-delay, 0ms);"}
|
|
11
|
+
@keyframes rotateIn { from { transform: rotate(-90deg); opacity: 0; } to { transform: rotate(0); opacity: 1; } }
|
|
12
|
+
@keyframes rotateOut { from { transform: rotate(0); opacity: 1; } to { transform: rotate(90deg); opacity: 0; } }`;default:return""}}function rh(){return`
|
|
13
|
+
<script data-stx-scoped data-stx-run="once">
|
|
14
|
+
// Motion preferences handling
|
|
15
|
+
(function() {
|
|
16
|
+
const prefersReducedMotion = window.matchMedia('(prefers-reduced-motion: reduce)').matches;
|
|
17
|
+
|
|
18
|
+
if (prefersReducedMotion) {
|
|
19
|
+
// Apply reduced motion settings
|
|
20
|
+
document.documentElement.style.setProperty('--stx-transition-duration', '0ms');
|
|
21
|
+
document.documentElement.setAttribute('data-reduced-motion', 'true');
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
document.documentElement.setAttribute('data-reduced-motion', 'false');
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// Listen for changes in preference
|
|
28
|
+
window.matchMedia('(prefers-reduced-motion: reduce)').addEventListener('change', (e) => {
|
|
29
|
+
if (e.matches) {
|
|
30
|
+
document.documentElement.style.setProperty('--stx-transition-duration', '0ms');
|
|
31
|
+
document.documentElement.setAttribute('data-reduced-motion', 'true');
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
document.documentElement.style.setProperty('--stx-transition-duration', '');
|
|
35
|
+
document.documentElement.setAttribute('data-reduced-motion', 'false');
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
})();
|
|
39
|
+
</script>
|
|
40
|
+
`}function sh(v){return[/@animate\b/,/@transition\b/,/@scroll(?:Animate)?\b/,/@staggered\b/,/@sequence\b/,/@motion\b/,/@animationGroup\b/,/\bstx-transition\b/,/\bstx-(?:fade|scale|flip|rotate|slide|from-|observe)\b/,/data-animate=['"](?:auto|true|false)['"]/].some((k)=>k.test(v))}function ih(v=0.1,_="0px"){return`
|
|
41
|
+
<script data-stx-scoped data-stx-run="always">
|
|
42
|
+
// Intersection Observer for scroll animations
|
|
43
|
+
(function() {
|
|
44
|
+
const initObserver = () => {
|
|
45
|
+
if (!('IntersectionObserver' in window)) {
|
|
46
|
+
// For browsers that don't support IntersectionObserver, show all elements immediately
|
|
47
|
+
const elements = document.querySelectorAll('.stx-observe');
|
|
48
|
+
elements.forEach(el => el.classList.remove('stx-out'));
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// Create the observer
|
|
53
|
+
const options = {
|
|
54
|
+
root: null, // Use viewport
|
|
55
|
+
rootMargin: '${_}',
|
|
56
|
+
threshold: ${v}
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
const observer = new IntersectionObserver((entries) => {
|
|
60
|
+
entries.forEach(entry => {
|
|
61
|
+
if (entry.isIntersecting) {
|
|
62
|
+
entry.target.classList.remove('stx-out');
|
|
63
|
+
// Stop observing after animation is triggered
|
|
64
|
+
observer.unobserve(entry.target);
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
}, options);
|
|
68
|
+
|
|
69
|
+
// Start observing elements
|
|
70
|
+
const elements = document.querySelectorAll('.stx-observe');
|
|
71
|
+
elements.forEach(el => observer.observe(el));
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
// Initialize observer when DOM is ready
|
|
75
|
+
if (document.readyState === 'loading') {
|
|
76
|
+
document.addEventListener('DOMContentLoaded', initObserver);
|
|
77
|
+
}
|
|
78
|
+
else {
|
|
79
|
+
initObserver();
|
|
80
|
+
}
|
|
81
|
+
})();
|
|
82
|
+
</script>
|
|
83
|
+
`}function oh(){return`
|
|
84
|
+
<style id="stx-animation-base">
|
|
85
|
+
:root {
|
|
86
|
+
--stx-transition-duration: 300ms;
|
|
87
|
+
--stx-transition-delay: 0ms;
|
|
88
|
+
--stx-transition-ease: ease;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
@media (prefers-reduced-motion: reduce) {
|
|
92
|
+
:root {
|
|
93
|
+
--stx-transition-duration: 0ms;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
[data-animate="false"] * {
|
|
98
|
+
--stx-transition-duration: 0ms !important;
|
|
99
|
+
animation-duration: 0ms !important;
|
|
100
|
+
transition-duration: 0ms !important;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/* Base transition classes */
|
|
104
|
+
.stx-transition {
|
|
105
|
+
transition: opacity var(--stx-transition-duration, 300ms) var(--stx-transition-ease, ease) var(--stx-transition-delay, 0ms),
|
|
106
|
+
transform var(--stx-transition-duration, 300ms) var(--stx-transition-ease, ease) var(--stx-transition-delay, 0ms);
|
|
107
|
+
backface-visibility: hidden; /* Improve animation performance */
|
|
108
|
+
transform-style: preserve-3d; /* Better 3D transforms */
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/* Fade animations */
|
|
112
|
+
.stx-fade {
|
|
113
|
+
transition: opacity var(--stx-transition-duration, 300ms) var(--stx-transition-ease, ease) var(--stx-transition-delay, 0ms);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
.stx-fade.stx-out {
|
|
117
|
+
opacity: 0 !important;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/* Scale animations */
|
|
121
|
+
.stx-scale {
|
|
122
|
+
transition: transform var(--stx-transition-duration, 300ms) var(--stx-transition-ease, ease) var(--stx-transition-delay, 0ms),
|
|
123
|
+
opacity var(--stx-transition-duration, 300ms) var(--stx-transition-ease, ease) var(--stx-transition-delay, 0ms);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
.stx-scale.stx-out {
|
|
127
|
+
transform: scale(0.85) !important;
|
|
128
|
+
opacity: 0 !important;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/* Flip animations */
|
|
132
|
+
.stx-flip {
|
|
133
|
+
transition: transform var(--stx-transition-duration, 300ms) var(--stx-transition-ease, ease) var(--stx-transition-delay, 0ms),
|
|
134
|
+
opacity var(--stx-transition-duration, 300ms) var(--stx-transition-ease, ease) var(--stx-transition-delay, 0ms);
|
|
135
|
+
perspective: 600px;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
.stx-flip.stx-out {
|
|
139
|
+
transform: perspective(600px) rotateX(-90deg) !important;
|
|
140
|
+
opacity: 0 !important;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/* Rotate animations */
|
|
144
|
+
.stx-rotate {
|
|
145
|
+
transition: transform var(--stx-transition-duration, 300ms) var(--stx-transition-ease, ease) var(--stx-transition-delay, 0ms),
|
|
146
|
+
opacity var(--stx-transition-duration, 300ms) var(--stx-transition-ease, ease) var(--stx-transition-delay, 0ms);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
.stx-rotate.stx-out {
|
|
150
|
+
transform: rotate(-90deg) !important;
|
|
151
|
+
opacity: 0 !important;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
/* Direction-based animations */
|
|
155
|
+
.stx-from-left, .stx-from-right, .stx-from-top, .stx-from-bottom {
|
|
156
|
+
transition: transform var(--stx-transition-duration, 300ms) var(--stx-transition-ease, ease) var(--stx-transition-delay, 0ms),
|
|
157
|
+
opacity var(--stx-transition-duration, 300ms) var(--stx-transition-ease, ease) var(--stx-transition-delay, 0ms);
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
.stx-from-left.stx-out {
|
|
161
|
+
transform: translateX(-30px) !important;
|
|
162
|
+
opacity: 0 !important;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
.stx-from-right.stx-out {
|
|
166
|
+
transform: translateX(30px) !important;
|
|
167
|
+
opacity: 0 !important;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
.stx-from-top.stx-out {
|
|
171
|
+
transform: translateY(-30px) !important;
|
|
172
|
+
opacity: 0 !important;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
.stx-from-bottom.stx-out {
|
|
176
|
+
transform: translateY(30px) !important;
|
|
177
|
+
opacity: 0 !important;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
/* Generic slide animations */
|
|
181
|
+
.stx-slide {
|
|
182
|
+
transition: transform var(--stx-transition-duration, 300ms) var(--stx-transition-ease, ease) var(--stx-transition-delay, 0ms),
|
|
183
|
+
opacity var(--stx-transition-duration, 300ms) var(--stx-transition-ease, ease) var(--stx-transition-delay, 0ms);
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
.stx-slide.stx-out {
|
|
187
|
+
transform: translateY(30px) !important;
|
|
188
|
+
opacity: 0 !important;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
/* Scroll animation observer class */
|
|
192
|
+
.stx-observe {
|
|
193
|
+
will-change: opacity, transform;
|
|
194
|
+
transition: opacity var(--stx-transition-duration, 300ms) var(--stx-transition-ease, ease) var(--stx-transition-delay, 0ms),
|
|
195
|
+
transform var(--stx-transition-duration, 300ms) var(--stx-transition-ease, ease) var(--stx-transition-delay, 0ms);
|
|
196
|
+
}
|
|
197
|
+
</style>
|
|
198
|
+
`}function ah(v,_,k={}){let{staggerDelay:E=50,sequence:T=!1}=k;return`
|
|
199
|
+
<script data-stx-scoped data-stx-run="always">
|
|
200
|
+
// Animation Group: ${v}
|
|
201
|
+
(function() {
|
|
202
|
+
const elements = ${JSON.stringify(_)};
|
|
203
|
+
const staggerDelay = ${E};
|
|
204
|
+
const sequence = ${T};
|
|
205
|
+
|
|
206
|
+
function animateGroup() {
|
|
207
|
+
elements.forEach((selector, index) => {
|
|
208
|
+
const element = document.querySelector(selector);
|
|
209
|
+
if (!element) return;
|
|
210
|
+
|
|
211
|
+
const delay = sequence ? index * staggerDelay : 0;
|
|
212
|
+
element.style.setProperty('--stx-transition-delay', delay + 'ms');
|
|
213
|
+
|
|
214
|
+
// For elements using animation keyframes
|
|
215
|
+
element.style.animationDelay = delay + 'ms';
|
|
216
|
+
|
|
217
|
+
// If the element is initially hidden, show it
|
|
218
|
+
if (element.classList.contains('stx-out')) {
|
|
219
|
+
setTimeout(() => {
|
|
220
|
+
element.classList.remove('stx-out');
|
|
221
|
+
}, 10); // Small delay to ensure styles are applied
|
|
222
|
+
}
|
|
223
|
+
});
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
// Run when DOM is fully loaded
|
|
227
|
+
if (document.readyState === 'loading') {
|
|
228
|
+
document.addEventListener('DOMContentLoaded', animateGroup);
|
|
229
|
+
}
|
|
230
|
+
else {
|
|
231
|
+
animateGroup();
|
|
232
|
+
}
|
|
233
|
+
})();
|
|
234
|
+
</script>
|
|
235
|
+
`}var nu={name:"transition",handler:(v,_,k,E)=>{if(_.length<1)return`<div class="stx-error">@transition directive requires at least a transition type</div>${v}`;let T=_[0],j=_.length>1?Number.parseInt(_[1],10)||or.duration:or.duration,B=_.length>2?_[2]||or.ease:or.ease,z=_.length>3?Number.parseInt(_[3],10)||or.delay:or.delay,F=_.length>4?_[4]||or.direction:or.direction,V=`stx-transition-${Math.random().toString(36).substr(2,9)}`,H=nh(T,{duration:j,delay:z,ease:B,direction:F}),G="stx-transition",J="";if(T==="fade")J="stx-fade";else if(T==="slide")J="stx-slide";else if(T==="scale")J="stx-scale";else if(T==="flip")J="stx-flip";else if(T==="rotate")J="stx-rotate";return`<div id="${V}" class="${G} ${J} ${F==="out"?"stx-out":""}"
|
|
236
|
+
style="--stx-transition-duration: ${j}ms; --stx-transition-ease: ${B}; --stx-transition-delay: ${z}ms;">${v}</div>`},hasEndTag:!0,description:"Applies transition effects to an element"},ru={name:"scrollAnimate",handler:(v,_,k,E)=>{if(_.length<1)return`<div class="stx-error">@scrollAnimate directive requires at least an animation type</div>${v}`;let T=_[0],j=_.length>1?Number.parseInt(_[1],10)||300:300,B=_.length>2?_[2]||"ease":"ease",z=_.length>3?Number.parseFloat(_[3])||0.2:0.2,F=_.length>4?Number.parseInt(_[4],10)||0:0,V=`stx-scroll-${Math.random().toString(36).substr(2,9)}`,H=`--stx-transition-duration: ${j}ms; --stx-transition-ease: ${B}; --stx-transition-delay: ${F}ms; will-change: opacity, transform;`,G="stx-transition stx-observe stx-out";if(T==="fade")G+=" stx-fade";else if(T==="slide-up"||T==="slide")G+=" stx-from-bottom";else if(T==="slide-down")G+=" stx-from-top";else if(T==="slide-left")G+=" stx-from-right";else if(T==="slide-right")G+=" stx-from-left";else if(T==="scale")G+=" stx-scale";else if(T.includes("-"))G+=` stx-${T}`;else G+=` stx-${T}`;return`<div id="${V}" class="${G}" style="${H}" data-threshold="${z}">${v}</div>`},hasEndTag:!0,description:"Applies animations that trigger when scrolled into view"},su={name:"animationGroup",handler:(v,_,k,E)=>{if(_.length<2)return`<div class="stx-error">@animationGroup directive requires a group name and at least one element selector</div>${v}`;let T=_[0],j=_.slice(1).map((V)=>V.startsWith("#")||V.startsWith(".")?V:`#${V}`),B=k.staggerDelay||50,z=k.sequence||!0,F=ah(T,j,{staggerDelay:B,sequence:z});return`${v}
|
|
237
|
+
${F}`},hasEndTag:!1,description:"Coordinates multiple animations together as a group"},iu={name:"motion",handler:(v,_,k,E)=>{let T=_.length>0?_[0].toLowerCase()==="true":!0,j=rh();return`<div data-animate="${T?"auto":"true"}">${v}</div>${j}`},hasEndTag:!0,description:"Controls motion and animation preferences"};function ou(v,_,k,E){let T=v;if(E.animation?.enabled===!1)return T;let j=k.includes("test")&&k.includes("animation");if(!sh(T)&&!j)return T;if(!T.includes('<style id="stx-animation-base">')){let z=oh();T=T.replace("</head>",`${z}
|
|
238
|
+
</head>`)}if(T.includes("stx-observe")){if(!T.includes("Intersection Observer for scroll animations")){let F=ih(),V=T.lastIndexOf("</body>");if(V!==-1)T=T.slice(0,V)+F+`
|
|
239
|
+
`+T.slice(V)}}return T}async function ch(v,_,k,E){let T=_[0]?.replace(/['"]/g,"")||"main",j=Se();if(T!=="main")j=j.replace("container:'main'",`container:'${T}'`);return`<script data-stx-router>${j}</script>`}var au={name:"stxRouter",handler:ch,hasEndTag:!1,description:"Inject the STX SPA router script for client-side navigation"};var lh={enabled:!1,trackMouse:!0,trackClicks:!0,trackScroll:!0,samplingRate:100,honorDnt:!0,batchSize:50,maxDataPoints:1000,sessionTimeout:30,persistData:!1,storagePrefix:"stx_heatmap",captureAttributes:["data-heatmap-id","data-track"],ignoreSelectors:["[data-heatmap-ignore]",".heatmap-ignore"],debugOverlay:!1};function cu(v){let _=v.heatmap;if(!_?.enabled)return"";let k={...lh,..._};return`
|
|
240
|
+
<!-- stx Heatmap - Privacy-Compliant Tracking -->
|
|
241
|
+
<script>
|
|
242
|
+
(function() {
|
|
243
|
+
'use strict';
|
|
244
|
+
|
|
245
|
+
// Configuration
|
|
246
|
+
var config = ${JSON.stringify({trackMouse:k.trackMouse,trackClicks:k.trackClicks,trackScroll:k.trackScroll,samplingRate:k.samplingRate,honorDnt:k.honorDnt,endpoint:k.endpoint,batchSize:k.batchSize,maxDataPoints:k.maxDataPoints,sessionTimeout:k.sessionTimeout,persistData:k.persistData,storagePrefix:k.storagePrefix,captureAttributes:k.captureAttributes,ignoreSelectors:k.ignoreSelectors,zones:k.zones,debugOverlay:k.debugOverlay,minViewportWidth:k.minViewportWidth,maxViewportWidth:k.maxViewportWidth})};
|
|
247
|
+
|
|
248
|
+
// Check Do Not Track
|
|
249
|
+
if (config.honorDnt && navigator.doNotTrack === '1') {
|
|
250
|
+
return;
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
// Check viewport constraints
|
|
254
|
+
var vw = window.innerWidth;
|
|
255
|
+
if (config.minViewportWidth && vw < config.minViewportWidth) return;
|
|
256
|
+
if (config.maxViewportWidth && vw > config.maxViewportWidth) return;
|
|
257
|
+
|
|
258
|
+
// Session management (anonymous, no cookies)
|
|
259
|
+
var session = {
|
|
260
|
+
sid: Math.random().toString(36).slice(2) + Date.now().toString(36),
|
|
261
|
+
page: location.pathname,
|
|
262
|
+
vw: window.innerWidth,
|
|
263
|
+
vh: window.innerHeight,
|
|
264
|
+
points: [],
|
|
265
|
+
started: Date.now(),
|
|
266
|
+
lastActivity: Date.now()
|
|
267
|
+
};
|
|
268
|
+
|
|
269
|
+
// Throttle helper
|
|
270
|
+
var lastMove = 0;
|
|
271
|
+
function throttle(fn, wait) {
|
|
272
|
+
return function() {
|
|
273
|
+
var now = Date.now();
|
|
274
|
+
if (now - lastMove >= wait) {
|
|
275
|
+
lastMove = now;
|
|
276
|
+
fn.apply(this, arguments);
|
|
277
|
+
}
|
|
278
|
+
};
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
// Get relative coordinates (percentage)
|
|
282
|
+
function getRelativeCoords(e) {
|
|
283
|
+
return {
|
|
284
|
+
x: Math.round((e.clientX / window.innerWidth) * 10000) / 100,
|
|
285
|
+
y: Math.round((e.clientY / window.innerHeight) * 10000) / 100
|
|
286
|
+
};
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
// Check if element should be ignored
|
|
290
|
+
function shouldIgnore(el) {
|
|
291
|
+
if (!el || !config.ignoreSelectors) return false;
|
|
292
|
+
for (var i = 0; i < config.ignoreSelectors.length; i++) {
|
|
293
|
+
if (el.matches && el.matches(config.ignoreSelectors[i])) return true;
|
|
294
|
+
if (el.closest && el.closest(config.ignoreSelectors[i])) return true;
|
|
295
|
+
}
|
|
296
|
+
return false;
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
// Get element selector (simplified, no IDs to preserve privacy)
|
|
300
|
+
function getSelector(el) {
|
|
301
|
+
if (!el || !el.tagName) return null;
|
|
302
|
+
var tag = el.tagName.toLowerCase();
|
|
303
|
+
var classes = el.className && typeof el.className === 'string'
|
|
304
|
+
? '.' + el.className.trim().split(/\\s+/).slice(0, 2).join('.')
|
|
305
|
+
: '';
|
|
306
|
+
return tag + classes;
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
// Find zone for element
|
|
310
|
+
function findZone(el) {
|
|
311
|
+
if (!config.zones || !el) return null;
|
|
312
|
+
for (var i = 0; i < config.zones.length; i++) {
|
|
313
|
+
var zone = config.zones[i];
|
|
314
|
+
if (el.closest && el.closest(zone.selector)) {
|
|
315
|
+
return zone.id;
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
return null;
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
// Capture custom attributes
|
|
322
|
+
function captureAttributes(el) {
|
|
323
|
+
if (!config.captureAttributes || !el) return null;
|
|
324
|
+
var attrs = {};
|
|
325
|
+
var hasAttrs = false;
|
|
326
|
+
for (var i = 0; i < config.captureAttributes.length; i++) {
|
|
327
|
+
var attr = config.captureAttributes[i];
|
|
328
|
+
var value = el.getAttribute && el.getAttribute(attr);
|
|
329
|
+
if (value) {
|
|
330
|
+
attrs[attr] = value;
|
|
331
|
+
hasAttrs = true;
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
return hasAttrs ? attrs : null;
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
// Add data point
|
|
338
|
+
function addPoint(point) {
|
|
339
|
+
session.lastActivity = Date.now();
|
|
340
|
+
if (session.points.length >= config.maxDataPoints) {
|
|
341
|
+
session.points.shift();
|
|
342
|
+
}
|
|
343
|
+
session.points.push(point);
|
|
344
|
+
|
|
345
|
+
// Send batch if threshold reached
|
|
346
|
+
if (config.endpoint && session.points.length >= config.batchSize) {
|
|
347
|
+
sendData();
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
// Send data to endpoint
|
|
352
|
+
function sendData() {
|
|
353
|
+
if (!config.endpoint || session.points.length === 0) return;
|
|
354
|
+
|
|
355
|
+
var data = {
|
|
356
|
+
sid: session.sid,
|
|
357
|
+
page: session.page,
|
|
358
|
+
vw: session.vw,
|
|
359
|
+
vh: session.vh,
|
|
360
|
+
points: session.points.splice(0, config.batchSize)
|
|
361
|
+
};
|
|
362
|
+
|
|
363
|
+
// Use sendBeacon for reliability
|
|
364
|
+
if (navigator.sendBeacon) {
|
|
365
|
+
navigator.sendBeacon(config.endpoint, JSON.stringify(data));
|
|
366
|
+
}
|
|
367
|
+
else {
|
|
368
|
+
var xhr = new XMLHttpRequest();
|
|
369
|
+
xhr.open('POST', config.endpoint, true);
|
|
370
|
+
xhr.setRequestHeader('Content-Type', 'application/json');
|
|
371
|
+
xhr.send(JSON.stringify(data));
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
// Mouse move handler
|
|
376
|
+
if (config.trackMouse) {
|
|
377
|
+
document.addEventListener('mousemove', throttle(function(e) {
|
|
378
|
+
if (shouldIgnore(e.target)) return;
|
|
379
|
+
var coords = getRelativeCoords(e);
|
|
380
|
+
addPoint({
|
|
381
|
+
x: coords.x,
|
|
382
|
+
y: coords.y,
|
|
383
|
+
type: 'move',
|
|
384
|
+
t: Date.now(),
|
|
385
|
+
zone: findZone(e.target)
|
|
386
|
+
});
|
|
387
|
+
}, config.samplingRate), { passive: true });
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
// Click handler
|
|
391
|
+
if (config.trackClicks) {
|
|
392
|
+
document.addEventListener('click', function(e) {
|
|
393
|
+
if (shouldIgnore(e.target)) return;
|
|
394
|
+
var coords = getRelativeCoords(e);
|
|
395
|
+
var point = {
|
|
396
|
+
x: coords.x,
|
|
397
|
+
y: coords.y,
|
|
398
|
+
type: 'click',
|
|
399
|
+
t: Date.now(),
|
|
400
|
+
el: getSelector(e.target),
|
|
401
|
+
zone: findZone(e.target)
|
|
402
|
+
};
|
|
403
|
+
var attrs = captureAttributes(e.target);
|
|
404
|
+
if (attrs) point.attrs = attrs;
|
|
405
|
+
addPoint(point);
|
|
406
|
+
}, { passive: true });
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
// Scroll handler
|
|
410
|
+
if (config.trackScroll) {
|
|
411
|
+
var lastScrollDepth = 0;
|
|
412
|
+
document.addEventListener('scroll', throttle(function() {
|
|
413
|
+
var scrollTop = window.pageYOffset || document.documentElement.scrollTop;
|
|
414
|
+
var scrollHeight = document.documentElement.scrollHeight - window.innerHeight;
|
|
415
|
+
var depth = scrollHeight > 0 ? Math.round((scrollTop / scrollHeight) * 100) : 0;
|
|
416
|
+
|
|
417
|
+
// Only track significant scroll changes (every 10%)
|
|
418
|
+
if (Math.abs(depth - lastScrollDepth) >= 10) {
|
|
419
|
+
lastScrollDepth = depth;
|
|
420
|
+
addPoint({
|
|
421
|
+
x: 50,
|
|
422
|
+
y: depth,
|
|
423
|
+
type: 'scroll',
|
|
424
|
+
t: Date.now(),
|
|
425
|
+
depth: depth
|
|
426
|
+
});
|
|
427
|
+
}
|
|
428
|
+
}, config.samplingRate * 2), { passive: true });
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
// Send remaining data on page unload
|
|
432
|
+
window.addEventListener('beforeunload', sendData);
|
|
433
|
+
window.addEventListener('visibilitychange', function() {
|
|
434
|
+
if (document.visibilityState === 'hidden') {
|
|
435
|
+
sendData();
|
|
436
|
+
}
|
|
437
|
+
});
|
|
438
|
+
|
|
439
|
+
// Persist data to localStorage if enabled
|
|
440
|
+
if (config.persistData) {
|
|
441
|
+
var storageKey = config.storagePrefix + '_' + session.page.replace(/\\//g, '_');
|
|
442
|
+
|
|
443
|
+
// Load existing data
|
|
444
|
+
try {
|
|
445
|
+
var stored = localStorage.getItem(storageKey);
|
|
446
|
+
if (stored) {
|
|
447
|
+
var parsed = JSON.parse(stored);
|
|
448
|
+
if (Date.now() - parsed.lastActivity < config.sessionTimeout * 60000) {
|
|
449
|
+
session.points = parsed.points || [];
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
catch (e) {}
|
|
454
|
+
|
|
455
|
+
// Save periodically
|
|
456
|
+
setInterval(function() {
|
|
457
|
+
try {
|
|
458
|
+
localStorage.setItem(storageKey, JSON.stringify({
|
|
459
|
+
points: session.points,
|
|
460
|
+
lastActivity: session.lastActivity
|
|
461
|
+
}));
|
|
462
|
+
}
|
|
463
|
+
catch (e) {}
|
|
464
|
+
}, 5000);
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
// Debug overlay
|
|
468
|
+
if (config.debugOverlay) {
|
|
469
|
+
var overlay = document.createElement('div');
|
|
470
|
+
overlay.id = 'stx-heatmap-overlay';
|
|
471
|
+
overlay.style.cssText = 'position:fixed;top:0;left:0;width:100%;height:100%;pointer-events:none;z-index:999999;';
|
|
472
|
+
document.body.appendChild(overlay);
|
|
473
|
+
|
|
474
|
+
var canvas = document.createElement('canvas');
|
|
475
|
+
canvas.width = window.innerWidth;
|
|
476
|
+
canvas.height = window.innerHeight;
|
|
477
|
+
canvas.style.cssText = 'width:100%;height:100%;';
|
|
478
|
+
overlay.appendChild(canvas);
|
|
479
|
+
var ctx = canvas.getContext('2d');
|
|
480
|
+
|
|
481
|
+
function renderOverlay() {
|
|
482
|
+
ctx.clearRect(0, 0, canvas.width, canvas.height);
|
|
483
|
+
session.points.forEach(function(p) {
|
|
484
|
+
var x = (p.x / 100) * canvas.width;
|
|
485
|
+
var y = (p.y / 100) * canvas.height;
|
|
486
|
+
ctx.beginPath();
|
|
487
|
+
ctx.arc(x, y, p.type === 'click' ? 8 : 3, 0, Math.PI * 2);
|
|
488
|
+
ctx.fillStyle = p.type === 'click' ? 'rgba(255,0,0,0.5)' : 'rgba(0,0,255,0.2)';
|
|
489
|
+
ctx.fill();
|
|
490
|
+
});
|
|
491
|
+
requestAnimationFrame(renderOverlay);
|
|
492
|
+
}
|
|
493
|
+
renderOverlay();
|
|
494
|
+
|
|
495
|
+
window.addEventListener('resize', function() {
|
|
496
|
+
canvas.width = window.innerWidth;
|
|
497
|
+
canvas.height = window.innerHeight;
|
|
498
|
+
});
|
|
499
|
+
}
|
|
500
|
+
|
|
501
|
+
// Expose API for manual tracking and data export
|
|
502
|
+
window.stxHeatmap = {
|
|
503
|
+
// Get current session data
|
|
504
|
+
getData: function() {
|
|
505
|
+
return {
|
|
506
|
+
sid: session.sid,
|
|
507
|
+
page: session.page,
|
|
508
|
+
vw: session.vw,
|
|
509
|
+
vh: session.vh,
|
|
510
|
+
points: session.points.slice(),
|
|
511
|
+
started: session.started,
|
|
512
|
+
lastActivity: session.lastActivity
|
|
513
|
+
};
|
|
514
|
+
},
|
|
515
|
+
// Export data as JSON
|
|
516
|
+
exportJSON: function() {
|
|
517
|
+
return JSON.stringify(this.getData(), null, 2);
|
|
518
|
+
},
|
|
519
|
+
// Export data as CSV
|
|
520
|
+
exportCSV: function() {
|
|
521
|
+
var data = this.getData();
|
|
522
|
+
var lines = ['x,y,type,timestamp,element,zone,depth'];
|
|
523
|
+
data.points.forEach(function(p) {
|
|
524
|
+
lines.push([p.x, p.y, p.type, p.t, p.el || '', p.zone || '', p.depth || ''].join(','));
|
|
525
|
+
});
|
|
526
|
+
return lines.join('\\n');
|
|
527
|
+
},
|
|
528
|
+
// Manual data send
|
|
529
|
+
flush: function() {
|
|
530
|
+
sendData();
|
|
531
|
+
},
|
|
532
|
+
// Clear data
|
|
533
|
+
clear: function() {
|
|
534
|
+
session.points = [];
|
|
535
|
+
if (config.persistData) {
|
|
536
|
+
var storageKey = config.storagePrefix + '_' + session.page.replace(/\\//g, '_');
|
|
537
|
+
try { localStorage.removeItem(storageKey); }
|
|
538
|
+
catch (e) {}
|
|
539
|
+
}
|
|
540
|
+
},
|
|
541
|
+
// Add custom event
|
|
542
|
+
track: function(type, data) {
|
|
543
|
+
addPoint({
|
|
544
|
+
x: data && data.x || 0,
|
|
545
|
+
y: data && data.y || 0,
|
|
546
|
+
type: type,
|
|
547
|
+
t: Date.now(),
|
|
548
|
+
attrs: data
|
|
549
|
+
});
|
|
550
|
+
},
|
|
551
|
+
// Generate heatmap visualization
|
|
552
|
+
visualize: function(options) {
|
|
553
|
+
options = options || {};
|
|
554
|
+
var data = this.getData();
|
|
555
|
+
var width = options.width || data.vw;
|
|
556
|
+
var height = options.height || data.vh;
|
|
557
|
+
var radius = options.radius || 20;
|
|
558
|
+
var blur = options.blur || 15;
|
|
559
|
+
var maxOpacity = options.maxOpacity || 0.6;
|
|
560
|
+
|
|
561
|
+
var canvas = document.createElement('canvas');
|
|
562
|
+
canvas.width = width;
|
|
563
|
+
canvas.height = height;
|
|
564
|
+
var ctx = canvas.getContext('2d');
|
|
565
|
+
|
|
566
|
+
// Create heat points
|
|
567
|
+
data.points.forEach(function(p) {
|
|
568
|
+
var x = (p.x / 100) * width;
|
|
569
|
+
var y = (p.y / 100) * height;
|
|
570
|
+
var intensity = p.type === 'click' ? 1 : 0.3;
|
|
571
|
+
|
|
572
|
+
var gradient = ctx.createRadialGradient(x, y, 0, x, y, radius);
|
|
573
|
+
gradient.addColorStop(0, 'rgba(255,0,0,' + intensity + ')');
|
|
574
|
+
gradient.addColorStop(1, 'rgba(255,0,0,0)');
|
|
575
|
+
ctx.fillStyle = gradient;
|
|
576
|
+
ctx.fillRect(x - radius, y - radius, radius * 2, radius * 2);
|
|
577
|
+
});
|
|
578
|
+
|
|
579
|
+
// Apply blur
|
|
580
|
+
ctx.filter = 'blur(' + blur + 'px)';
|
|
581
|
+
ctx.drawImage(canvas, 0, 0);
|
|
582
|
+
ctx.filter = 'none';
|
|
583
|
+
|
|
584
|
+
// Colorize
|
|
585
|
+
var imageData = ctx.getImageData(0, 0, width, height);
|
|
586
|
+
var pixels = imageData.data;
|
|
587
|
+
for (var i = 0; i < pixels.length; i += 4) {
|
|
588
|
+
var alpha = pixels[i + 3];
|
|
589
|
+
if (alpha > 0) {
|
|
590
|
+
var ratio = alpha / 255;
|
|
591
|
+
// Gradient: blue -> cyan -> green -> yellow -> red
|
|
592
|
+
if (ratio < 0.25) {
|
|
593
|
+
pixels[i] = 0;
|
|
594
|
+
pixels[i + 1] = Math.round(ratio * 4 * 255);
|
|
595
|
+
pixels[i + 2] = 255;
|
|
596
|
+
}
|
|
597
|
+
else if (ratio < 0.5) {
|
|
598
|
+
pixels[i] = 0;
|
|
599
|
+
pixels[i + 1] = 255;
|
|
600
|
+
pixels[i + 2] = Math.round((1 - (ratio - 0.25) * 4) * 255);
|
|
601
|
+
}
|
|
602
|
+
else if (ratio < 0.75) {
|
|
603
|
+
pixels[i] = Math.round((ratio - 0.5) * 4 * 255);
|
|
604
|
+
pixels[i + 1] = 255;
|
|
605
|
+
pixels[i + 2] = 0;
|
|
606
|
+
}
|
|
607
|
+
else {
|
|
608
|
+
pixels[i] = 255;
|
|
609
|
+
pixels[i + 1] = Math.round((1 - (ratio - 0.75) * 4) * 255);
|
|
610
|
+
pixels[i + 2] = 0;
|
|
611
|
+
}
|
|
612
|
+
pixels[i + 3] = Math.round(alpha * maxOpacity);
|
|
613
|
+
}
|
|
614
|
+
}
|
|
615
|
+
ctx.putImageData(imageData, 0, 0);
|
|
616
|
+
|
|
617
|
+
return canvas;
|
|
618
|
+
}
|
|
619
|
+
};
|
|
620
|
+
})();
|
|
621
|
+
</script>
|
|
622
|
+
`}function lu(v,_){let k=cu(_);if(!k)return v;let E=v.lastIndexOf("</body>");if(E!==-1)return v.slice(0,E)+k+v.slice(E);return v+k}var uu={name:"heatmap",hasEndTag:!1,description:"Inject privacy-compliant heatmap tracking script",handler:async(v,_,k,E)=>{let T=k.__stx_config||{};if(_.length>0){let j=uh(_.join(" "));T.heatmap={...T.heatmap,...j,enabled:!0}}return cu(T)}};function uh(v){let _={},k=v.match(/(\w+)=["']?([^"'\s]+)["']?/g)||[];for(let E of k){let[T,j]=E.split("="),B=j?.replace(/["']/g,"");switch(T){case"endpoint":_.endpoint=B;break;case"samplingRate":_.samplingRate=Number.parseInt(B,10);break;case"batchSize":_.batchSize=Number.parseInt(B,10);break;case"trackMouse":_.trackMouse=B==="true";break;case"trackClicks":_.trackClicks=B==="true";break;case"trackScroll":_.trackScroll=B==="true";break;case"honorDnt":_.honorDnt=B==="true";break;case"debugOverlay":_.debugOverlay=B==="true";break}}return _}function fr(v){return v.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function du(v){let _=v.trim().toLowerCase();return!_.startsWith("javascript:")&&!_.startsWith("vbscript:")&&!_.startsWith("data:text/html")}function In(v){let _=/^---\r?\n([\s\S]*?)\r?\n---\r?\n/,k=v.match(_);if(!k)return{data:{},content:v.trim()};let E=k[1],T=v.slice(k[0].length),j={};for(let B of E.split(`
|
|
623
|
+
`)){let z=B.trim();if(!z||z.startsWith("#"))continue;let F=z.indexOf(":");if(F===-1)continue;let V=z.slice(0,F).trim(),H=z.slice(F+1).trim();if(typeof H==="string"){if(H.startsWith('"')&&H.endsWith('"')||H.startsWith("'")&&H.endsWith("'"))H=H.slice(1,-1);else if(H.startsWith("[")&&H.endsWith("]"))try{H=JSON.parse(H)}catch{}else if(H==="true")H=!0;else if(H==="false")H=!1;else if(/^-?\d+(?:\.\d+)?$/.test(H))H=Number(H)}j[V]=H}return{data:j,content:T.trim()}}function Oe(v,_={}){let{gfm:k=!0,breaks:E=!1}=_,T=v,j=[];if(T=T.replace(/```(\w*)\n([\s\S]*?)```/g,(H,G,J)=>{let ne=j.length,re=G?` class="language-${fr(G)}"`:"";return j.push(`<pre><code${re}>${fr(J.trim())}</code></pre>`),`\x00CODEBLOCK${ne}\x00`}),T=T.replace(/`([^`]*)`/g,(H,G)=>`<code>${fr(G)}</code>`),T=T.replace(/^######\s+(.*)$/gm,"<h6>$1</h6>"),T=T.replace(/^#####\s+(.*)$/gm,"<h5>$1</h5>"),T=T.replace(/^####\s+(.*)$/gm,"<h4>$1</h4>"),T=T.replace(/^###\s+(.*)$/gm,"<h3>$1</h3>"),T=T.replace(/^##\s+(.*)$/gm,"<h2>$1</h2>"),T=T.replace(/^#\s+(.*)$/gm,"<h1>$1</h1>"),T=T.replace(/\*\*\*(.+?)\*\*\*/g,"<strong><em>$1</em></strong>"),T=T.replace(/___(.+?)___/g,"<strong><em>$1</em></strong>"),T=T.replace(/\*\*(.+?)\*\*/g,"<strong>$1</strong>"),T=T.replace(/__(.+?)__/g,"<strong>$1</strong>"),T=T.replace(/\*(.+?)\*/g,"<em>$1</em>"),T=T.replace(/(?<![a-zA-Z0-9])_(.+?)_(?![a-zA-Z0-9])/g,"<em>$1</em>"),k)T=T.replace(/~~(.+?)~~/g,"<del>$1</del>");if(T=T.replace(/!\[([^\]]*)\]\(([^)]+)\)/g,(H,G,J)=>`<img src="${du(J)?fr(J):""}" alt="${fr(G)}" />`),T=T.replace(/\[([^\]]+)\]\(([^)]+)\)/g,(H,G,J)=>`<a href="${du(J)?fr(J):""}">${G}</a>`),T=T.replace(/^(?:---|\*\*\*|___)\s*$/gm,"<hr />"),T=T.replace(/^>\s+(.*)$/gm,"<blockquote>$1</blockquote>"),T=T.replace(/<\/blockquote>\n<blockquote>/g,`
|
|
624
|
+
`),T=T.replace(/^[*\-+]\s+(.*)$/gm,"<li data-ul>$1</li>"),T=T.replace(/(<li data-ul>.*<\/li>\n?)+/g,"<ul>$&</ul>"),T=T.replace(/<\/ul>\n<ul>/g,""),T=T.replace(/^\d+\.\s+(.*)$/gm,"<li data-ol>$1</li>"),T=T.replace(/(<li data-ol>.*<\/li>\n?)+/g,"<ol>$&</ol>"),T=T.replace(/<\/ol>\n<ol>/g,""),T=T.replace(/<li data-ul>/g,"<li>"),T=T.replace(/<li data-ol>/g,"<li>"),k)T=T.replace(/^\|(.+)\|\s*\n\|[-:\s|]+\|\s*\n((?:\|.+\|\s*\n)*)/gm,(H,G,J)=>{let re=`<tr>${G.split("|").map((ie)=>ie.trim()).filter(Boolean).map((ie)=>`<th>${fr(ie)}</th>`).join("")}</tr>`,se=J.trim().split(`
|
|
625
|
+
`).map((ie)=>`<tr>${ie.split("|").map((ge)=>ge.trim()).filter(Boolean).map((ge)=>`<td>${fr(ge)}</td>`).join("")}</tr>`).join(`
|
|
626
|
+
`);return`<table>
|
|
627
|
+
<thead>
|
|
628
|
+
${re}
|
|
629
|
+
</thead>
|
|
630
|
+
<tbody>
|
|
631
|
+
${se}
|
|
632
|
+
</tbody>
|
|
633
|
+
</table>`});if(k)T=T.replace(/<li>\s*\[\s*\]\s*/g,'<li><input type="checkbox" disabled /> '),T=T.replace(/<li>\s*\[x\]\s*/gi,'<li><input type="checkbox" checked disabled /> ');let B=T.split(`
|
|
634
|
+
`),z=[],F=!1,V=[];for(let H of B){let G=H.trim();if(/^<(?:h[1-6]|ul|ol|li|blockquote|pre|table|thead|tbody|tr|th|td|hr|div|p)/.test(G)||/^\0CODEBLOCK\d+\0$/.test(G)||G===""){if(F&&V.length>0)z.push(`<p>${V.join(E?`<br />
|
|
635
|
+
`:`
|
|
636
|
+
`)}</p>`),V=[],F=!1;z.push(H)}else F=!0,V.push(G)}if(F&&V.length>0)z.push(`<p>${V.join(E?`<br />
|
|
637
|
+
`:`
|
|
638
|
+
`)}</p>`);if(T=z.join(`
|
|
639
|
+
`),E)T=T.replace(/\n/g,`<br />
|
|
640
|
+
`);for(let H=0;H<j.length;H++)T=T.replace(`\x00CODEBLOCK${H}\x00`,j[H]);return T=T.replace(/<p>\s*<\/p>/g,""),T.trim()}import Pm from"fs";import Qe from"path";import _r from"path";import Us from"fs";var dh=new Set(["touchstart","touchmove","wheel","mousewheel"]);function ma(v,_){if(_.passive)return!0;if(_.prevent||_.nonpassive)return!1;return dh.has(v.toLowerCase())}var fu=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"]),pu={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"},fh=new Set(["ctrl","alt","shift","meta"]),hu={left:0,middle:1,right:2};function gu(v){let _={prevent:!1,stop:!1,once:!1,capture:!1,self:!1,passive:!1,nonpassive:!1,keys:[],systemKeys:[],mouse:null,debounce:null,throttle:null};for(let k of v){let E=k.toLowerCase();if(E==="prevent")_.prevent=!0;else if(E==="stop")_.stop=!0;else if(E==="once")_.once=!0;else if(E==="capture")_.capture=!0;else if(E==="self")_.self=!0;else if(E==="passive")_.passive=!0;else if(E==="nonpassive")_.nonpassive=!0;else if(fh.has(E))_.systemKeys.push(E);else if(E in hu)_.mouse=E;else if(E in pu||/^[a-z]$/.test(E))_.keys.push(pu[E]||E.toUpperCase());else if(E.startsWith("debounce")){let T=E.match(/debounce(?:\.(\d+))?/);_.debounce=T?.[1]?Number.parseInt(T[1],10):300}else if(E.startsWith("throttle")){let T=E.match(/throttle(?:\.(\d+))?/);_.throttle=T?.[1]?Number.parseInt(T[1],10):300}}return _}function yu(v,_=""){let k=[],E=0,T=/<([a-z][a-z0-9-]*)\s+([^>]*@[a-z][^>]*)>/gi,j;while((j=T.exec(v))!==null){let[B,z,F]=j,V=j.index,H=V+B.length,G=`__stx_evt_${_}${E++}`,J=[],ne=/@([a-z][a-z0-9.]*)\s*=\s*"([^"]*)"/gi,re;while((re=ne.exec(F))!==null){let[,ie,oe]=re,ge=ie.split("."),ue=ge[0];if(!fu.has(ue))continue;J.push({attribute:`@${ie}`,event:ue,handler:oe,modifiers:gu(ge.slice(1)),elementId:G})}let se=/@([a-z][a-z0-9.]*)\s*=\s*'([^']*)'/gi;while((re=se.exec(F))!==null){let[,ie,oe]=re,ge=ie.split("."),ue=ge[0];if(!fu.has(ue))continue;J.push({attribute:`@${ie}`,event:ue,handler:oe,modifiers:gu(ge.slice(1)),elementId:G})}if(J.length>0)k.push({originalTag:B,elementId:G,events:J,startIndex:V,endIndex:H})}return k}function ph(v){let _=[],{modifiers:k}=v;if(k.self)_.push("if ($event.target !== $el) return");for(let E of k.systemKeys)_.push(`if (!$event.${E}Key) return`);if(k.keys.length>0){let E=k.keys.map((T)=>`$event.key === '${T}'`).join(" || ");_.push(`if (!(${E})) return`)}if(k.mouse!==null){let E=hu[k.mouse];_.push(`if ($event.button !== ${E}) return`)}if(k.prevent)_.push("$event.preventDefault()");if(k.stop)_.push("$event.stopPropagation()");return _.join("; ")}function gh(v,_){let k=v;if(_.debounce!==null)k=`__stx_debounce(() => { ${k} }, ${_.debounce})`;else if(_.throttle!==null)k=`__stx_throttle(() => { ${k} }, ${_.throttle})`;return k}function ha(v){let _=v.trim();if(!/^[A-Za-z_$][A-Za-z0-9_$]*$/.test(_))return v;return`if (typeof ${_} === 'function' && !${_}._isSignal) ${_}($event);`}function mh(v){let{modifiers:_}=v,k=v.elementId.replace(/\\/g,"\\\\").replace(/'/g,"\\'"),E=ph(v),T=gh(ha(v.handler),_),j=[];if(_.once)j.push("once: true");if(_.capture)j.push("capture: true");if(ma(v.event,_))j.push("passive: true");let B=j.length>0?`, { ${j.join(", ")} }`:"",z=T.replace(/\\/g,"\\\\").replace(/'/g,"\\'").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/\t/g,"\\t");if(v.event==="mounted")return`
|
|
641
|
+
(function() {
|
|
642
|
+
var $el = document.getElementById('${k}');
|
|
643
|
+
if (!$el) return;
|
|
644
|
+
// Run mounted handler immediately (DOM is ready)
|
|
645
|
+
var scope = $el.closest('[data-stx-scope]');
|
|
646
|
+
if (scope && scope.__stx_execute) {
|
|
647
|
+
scope.__stx_execute('${z}', null, $el);
|
|
648
|
+
}
|
|
649
|
+
else {
|
|
650
|
+
__stx_runHandler('${z}', null, $el);
|
|
651
|
+
}
|
|
652
|
+
})();`;if(v.event==="unmounted")return`
|
|
653
|
+
(function() {
|
|
654
|
+
var $el = document.getElementById('${k}');
|
|
655
|
+
if (!$el) return;
|
|
656
|
+
// Set up MutationObserver to detect removal
|
|
657
|
+
var observer = new MutationObserver(function(mutations) {
|
|
658
|
+
for (var m of mutations) {
|
|
659
|
+
for (var node of m.removedNodes) {
|
|
660
|
+
if (node === $el || (node.contains && node.contains($el))) {
|
|
661
|
+
observer.disconnect();
|
|
662
|
+
var scope = $el.closest('[data-stx-scope]');
|
|
663
|
+
if (scope && scope.__stx_execute) {
|
|
664
|
+
scope.__stx_execute('${z}', null, $el);
|
|
665
|
+
}
|
|
666
|
+
else {
|
|
667
|
+
__stx_runHandler('${z}', null, $el);
|
|
668
|
+
}
|
|
669
|
+
return;
|
|
670
|
+
}
|
|
671
|
+
}
|
|
672
|
+
}
|
|
673
|
+
});
|
|
674
|
+
observer.observe(document.body, { childList: true, subtree: true });
|
|
675
|
+
// Store observer for cleanup
|
|
676
|
+
$el.__stx_unmount_observer = observer;
|
|
677
|
+
})();`;return`
|
|
678
|
+
(function() {
|
|
679
|
+
var $el = document.getElementById('${k}');
|
|
680
|
+
if (!$el) return;
|
|
681
|
+
// eslint-disable-next-line pickier/no-unused-vars
|
|
682
|
+
$el.addEventListener('${v.event}', function($event) {
|
|
683
|
+
${E?E+";":""}
|
|
684
|
+
// Find the closest reactive scope and execute within its context
|
|
685
|
+
var scope = $el.closest('[data-stx-scope]');
|
|
686
|
+
if (scope && scope.__stx_execute) {
|
|
687
|
+
scope.__stx_execute('${z}', $event, $el);
|
|
688
|
+
}
|
|
689
|
+
else {
|
|
690
|
+
// Fallback for non-reactive context (entity-safe; decoded + run in memory)
|
|
691
|
+
__stx_runHandler('${z}', $event, $el);
|
|
692
|
+
}
|
|
693
|
+
}${B});
|
|
694
|
+
})();`}function ya(v){if(v.length===0)return"";return`
|
|
695
|
+
<script data-stx-events>
|
|
696
|
+
(function() {
|
|
697
|
+
'use strict';
|
|
698
|
+
|
|
699
|
+
// Utility functions
|
|
700
|
+
function __stx_debounce(fn, delay) {
|
|
701
|
+
var timeout;
|
|
702
|
+
return function() {
|
|
703
|
+
var args = arguments;
|
|
704
|
+
var ctx = this;
|
|
705
|
+
clearTimeout(timeout);
|
|
706
|
+
timeout = setTimeout(function() { fn.apply(ctx, args); }, delay);
|
|
707
|
+
};
|
|
708
|
+
}
|
|
709
|
+
|
|
710
|
+
function __stx_throttle(fn, delay) {
|
|
711
|
+
var last = 0;
|
|
712
|
+
return function() {
|
|
713
|
+
var now = Date.now();
|
|
714
|
+
if (now - last >= delay) {
|
|
715
|
+
last = now;
|
|
716
|
+
fn.apply(this, arguments);
|
|
717
|
+
}
|
|
718
|
+
};
|
|
719
|
+
}
|
|
720
|
+
|
|
721
|
+
// Non-reactive fallback runner. The handler is embedded HTML-entity-encoded
|
|
722
|
+
// so the surrounding script element can never contain raw markup, including
|
|
723
|
+
// its own closing tag; we decode it to JS only in memory here, then run it
|
|
724
|
+
// with $event/$el in scope.
|
|
725
|
+
//
|
|
726
|
+
// This comment must not spell that closing tag out. It used to, as an
|
|
727
|
+
// example, and a browser ends the script element at the FIRST one it sees \u2014
|
|
728
|
+
// so everything below this line, __stx_runHandler included, was emitted as
|
|
729
|
+
// page text and no listener was ever bound. The comment about escaping was
|
|
730
|
+
// the thing that needed escaping.
|
|
731
|
+
function __stx_runHandler(h, $event, $el) {
|
|
732
|
+
var code = h
|
|
733
|
+
.replace(/</g, '<')
|
|
734
|
+
.replace(/>/g, '>')
|
|
735
|
+
.replace(/"/g, '"')
|
|
736
|
+
.replace(/'/g, "'")
|
|
737
|
+
.replace(/'/g, "'")
|
|
738
|
+
.replace(/&/g, '&');
|
|
739
|
+
try {
|
|
740
|
+
// eslint-disable-next-line no-new-func
|
|
741
|
+
(new Function('$event', '$el', code)).call($el, $event, $el);
|
|
742
|
+
}
|
|
743
|
+
catch (e) {
|
|
744
|
+
if (typeof console !== 'undefined') console.error('[stx] event handler error:', e);
|
|
745
|
+
}
|
|
746
|
+
}
|
|
747
|
+
|
|
748
|
+
// Event listeners
|
|
749
|
+
${v.map(mh).join(`
|
|
750
|
+
`)}
|
|
751
|
+
})();
|
|
752
|
+
</script>`}function hh(v,_=""){let k=yu(v,_);if(k.length===0)return{template:v,bindings:[]};let E=v,T=[];for(let j=k.length-1;j>=0;j--){let B=k[j],z=B.originalTag;if(!z.includes(" id="))z=z.replace(/^<([a-z][a-z0-9-]*)/,`<$1 id="${B.elementId}"`);else{let F=z.match(/id=["']([^"']+)["']/);if(F)for(let V of B.events)V.elementId=F[1]}for(let F of B.events){let V=F.attribute.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),H=new RegExp(`\\s*${V}\\s*=\\s*"[^"]*"`,"g"),G=new RegExp(`\\s*${V}\\s*=\\s*'[^']*'`,"g");z=z.replace(H,""),z=z.replace(G,"")}E=E.slice(0,B.startIndex)+z+E.slice(B.endIndex),T.push(...B.events)}return{template:E,bindings:T}}function mu(v){let _=v.$uid;return typeof _==="string"&&_?`${_}_`:""}function Wu(v,_,k){if(Si(v))return v;if(_.__stx_sfc_mode){if(/x-data\s*=\s*["']/.test(v))return v;let{template:z,bindings:F}=hh(v,mu(_)),V=_.__stx_event_bindings||[];return _.__stx_event_bindings=[...V,...F],z}let E=yu(v,mu(_));if(E.length===0)return v;let T=v;for(let z=E.length-1;z>=0;z--){let F=E[z],V=F.originalTag;if(!V.includes(" id="))V=V.replace(/^<([a-z][a-z0-9-]*)/,`<$1 id="${F.elementId}"`);else{let H=V.match(/id=["']([^"']+)["']/);if(H)for(let G of F.events)G.elementId=H[1]}for(let H of F.events){let G=H.attribute.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),J=new RegExp(`\\s*${G}\\s*=\\s*"[^"]*"`,"g"),ne=new RegExp(`\\s*${G}\\s*=\\s*'[^']*'`,"g");V=V.replace(J,""),V=V.replace(ne,"")}T=T.slice(0,F.startIndex)+V+T.slice(F.endIndex)}let j=ya(E.flatMap((z)=>z.events)),B=T.lastIndexOf("</body>");if(B!==-1)T=T.slice(0,B)+j+`
|
|
753
|
+
`+T.slice(B);else T+=j;return T}function Vu(v,_){let k=new Set;for(let E of v.split(",")){let T=E.trim().replace(/^\.\.\./,"").trim();if(!T)continue;if(_){let j=T.lastIndexOf(":");if(j!==-1)T=T.slice(j+1).trim()}if(T=T.split("=")[0].trim(),/^[A-Za-z_$][\w$]*$/.test(T))k.add(T)}return k}function Vi(v,_){let k=s(v),{depths:E,balanced:T}=be(k),j=(z)=>!T||E[z]===0,B=new RegExp(`(?:^|[^\\w$.])((?:const|let|var|function|class)\\s+${_}\\b)`,"g");for(let z of k.matchAll(B)){let F=(z.index??0)+z[0].length-z[1].length;if(j(F))return!0}for(let z of k.matchAll(/(?:const|let|var)\s*\{([^}]*)\}/g))if(j(z.index??0)&&Vu(z[1],!0).has(_))return!0;for(let z of k.matchAll(/(?:const|let|var)\s*\[([^\]]*)\]/g))if(j(z.index??0)&&Vu(z[1],!1).has(_))return!0;return!1}var Uu="",Ui,xa=/^[A-Za-z_$][\w$]*$/,yh=new Set(["if","for","while","switch","with"]);function xh(v){let _=s(v),k=[];for(let E of _.matchAll(/[A-Za-z_$][\w$]*|=>|\.\.\.|[^\s]/g)){let T=E.index??0;k.push({text:E[0],start:T,end:T+E[0].length})}return{code:_,tokens:k}}function bh(v){if(Ui&&v===Uu)return Ui;let{code:_,tokens:k}=xh(v),E=new Map,T=[];for(let H=0;H<k.length;H++){let G=k[H].text;if(["(","[","{"].includes(G))T.push(H);else if([")","]","}"].includes(G)){let J=T.at(-1);if(J!==void 0&&["()","[]","{}"].includes(k[J].text+G))T.pop(),E.set(J,H),E.set(H,J)}}function j(H,G){let J=[],ne=H;for(let re=H;re<G;re++){if(["(","[","{"].includes(k[re].text)&&(E.get(re)??G)<G){re=E.get(re);continue}if(k[re].text===",")J.push([ne,re]),ne=re+1}return J.push([ne,G]),J}function B(H,G,J){if(k[H]?.text==="...")H++;if(H>=G)return;let ne=k[H].text;if(xa.test(ne)){J.add(ne);return}if(ne!=="{"&&ne!=="[")return;let re=E.get(H);if(re===void 0||re>=G)return;for(let[se,ie]of j(H+1,re)){let oe=se;if(ne==="{")for(let ge=se;ge<ie;ge++){if(k[ge].text===":"){oe=ge+1;break}if(k[ge].text==="=")break;if(["(","[","{"].includes(k[ge].text)&&E.has(ge))ge=E.get(ge)}B(oe,ie,J)}}function z(H,G){let J=new Set;for(let[ne,re]of j(H,G))B(ne,re,J);return J}function F(H){let G=H;for(;G<k.length;G++){let J=k[G].text;if(["(","[","{"].includes(J)&&E.has(G)){G=E.get(G);continue}if([",",";",")","]","}"].includes(J))break}return k[Math.max(H,G-1)]?.end??_.length}let V=[];for(let H=0;H<k.length;H++)if(k[H].text==="=>"){let G=H-1,J=G,ne;if(k[G]?.text===")"&&E.has(G))J=E.get(G),ne=z(J+1,G);else if(k[G]&&xa.test(k[G].text))ne=new Set([k[G].text]);else continue;let re=H+1,se=k[re]?.text==="{"&&E.has(re)?k[E.get(re)].end:F(re);V.push({start:k[J].start,end:se,names:ne})}else if(k[H].text==="("&&E.has(H)){let G=k[H-1]?.text;if(!G||yh.has(G)||!xa.test(G)&&G!=="*"&&G!=="]")continue;let J=E.get(H),ne=J+1;if(k[ne]?.text===":"){ne++;while(ne<k.length&&!["{","=>",";","="].includes(k[ne].text))ne++}if(k[ne]?.text!=="{"||!E.has(ne))continue;V.push({start:k[H].start,end:k[E.get(ne)].end,names:z(H+1,J)})}return Uu=v,Ui={code:_,scopes:V},Ui}function Hu(v){let _=bh(v);return{code:_.code,shadows:(k,E)=>_.scopes.some((T)=>E>=T.start&&E<T.end&&T.names.has(k))}}var qu=Symbol.for("stx.lazy-module-promises");function vh(){let v=globalThis;return v[qu]??=new Map,v[qu]}function ut(v,_){let k=vh(),E=`${import.meta.url}\x00${v}`,T=k.get(E);if(T)return T;let j=_();return k.set(E,j),j.catch(()=>{if(k.get(E)===j)k.delete(E)}),j}var wh=/<\/(script)/gi;function zr(v){if(!v||v.indexOf("</")===-1)return v;return v.replace(wh,"<\\/$1")}import Zu from"fs";class M{cache=new Map;maxSize;options;sizes;bytes=0;constructor(v=100,_){this.maxSize=v,this.options=_??null,this.sizes=_?new Map:null}get byteSize(){return this.bytes}setMaxBytes(v){if(!this.options)return;this.options={...this.options,maxBytes:v};while(this.bytes>v&&this.cache.size>0){let _=this.cache.keys().next().value;if(_===void 0)break;this.delete(_)}}get(v){if(!this.cache.has(v))return;let _=this.cache.get(v);return this.cache.delete(v),this.cache.set(v,_),_}set(v,_){if(this.cache.has(v))this.delete(v);let k=this.options?this.options.sizeOf(_):0;if(this.options&&k>this.options.maxBytes)return;while(this.cache.size>0&&(this.cache.size>=this.maxSize||this.options!==null&&this.bytes+k>this.options.maxBytes)){let E=this.cache.keys().next().value;if(E===void 0)break;this.delete(E)}if(this.cache.set(v,_),this.sizes)this.sizes.set(v,k),this.bytes+=k}has(v){return this.cache.has(v)}delete(v){if(this.sizes){let _=this.sizes.get(v);if(_!==void 0)this.bytes-=_,this.sizes.delete(v)}return this.cache.delete(v)}clear(){this.cache.clear(),this.sizes?.clear(),this.bytes=0}get size(){return this.cache.size}keys(){return this.cache.keys()}values(){return this.cache.values()}}var Fr=new Map,Sh=500;function $r(v,_){if(_?.includes("g"))return new RegExp(v,_);let k=`${v}:${_||""}`;if(!Fr.has(k)){if(Fr.size>=Sh){let E=Fr.keys().next().value;if(E)Fr.delete(E)}Fr.set(k,new RegExp(v,_))}return Fr.get(k)}class Ku{pool=[];maxPoolSize=10;fnCache=new Map;fnCacheMaxSize=200;getEvaluator(v){let _=Array.from(new Set(v)),k=_.sort().join(","),E=this.pool.find((z)=>z.context.join(",")===k);if(E)return E.func;let T=this.fnCache,j=this.fnCacheMaxSize,B=(...z)=>(F)=>{try{let V=`${k}:${F}`,H=T.get(V);if(!H){if(T.size>=j){let G=T.keys().next().value;if(G)T.delete(G)}H=Function(..._,`
|
|
754
|
+
'use strict';
|
|
755
|
+
try {
|
|
756
|
+
return ${F};
|
|
757
|
+
}
|
|
758
|
+
catch (e) {
|
|
759
|
+
if (e instanceof ReferenceError || e instanceof TypeError) {
|
|
760
|
+
return undefined;
|
|
761
|
+
}
|
|
762
|
+
throw e;
|
|
763
|
+
}
|
|
764
|
+
`),T.set(V,H)}return H(...z)}catch{return}};if(this.pool.length<this.maxPoolSize)this.pool.push({func:B,context:_.slice()});return B}clear(){this.pool.length=0,this.fnCache.clear()}}var D0=new Ku;class Xu{metrics=new Map;budgets=new Map;violations=[];maxViolations=100;violationHandlers=[];enabled=!0;setEnabled(v){this.enabled=v}isEnabled(){return this.enabled}setBudget(v,_){this.budgets.set(v,{warnThreshold:0.8,action:"warn",..._})}setBudgets(v){for(let[_,k]of Object.entries(v))this.setBudget(_,k)}removeBudget(v){this.budgets.delete(v)}getBudgets(){let v={};for(let[_,k]of this.budgets.entries())v[_]=k;return v}onViolation(v){this.violationHandlers.push(v)}offViolation(v){let _=this.violationHandlers.indexOf(v);if(_!==-1)this.violationHandlers.splice(_,1)}time(v,_){if(!this.enabled)return _();let k=performance.now(),E=_(),T=performance.now()-k;return this.recordTime(v,T),this.checkBudget(v,T),E}async timeAsync(v,_){if(!this.enabled)return _();let k=performance.now(),E=await _(),T=performance.now()-k;return this.recordTime(v,T),this.checkBudget(v,T),E}checkBudget(v,_){let k=this.budgets.get(v);if(!k)return;let E=_/k.maxTime*100,T=k.warnThreshold!==void 0?_>=k.maxTime*k.warnThreshold&&_<k.maxTime:!1,j=_>=k.maxTime;if(!T&&!j)return;let B={label:v,actualTime:_,budgetTime:k.maxTime,exceedancePercent:E,timestamp:new Date,isWarning:T};this.violations.push(B);while(this.violations.length>this.maxViolations)this.violations.shift();for(let F of this.violationHandlers)try{F(B)}catch{}let z=T?`[Performance Warning] "${v}" took ${_.toFixed(2)}ms (${E.toFixed(1)}% of ${k.maxTime}ms budget)`:`[Performance Budget Exceeded] "${v}" took ${_.toFixed(2)}ms (exceeded ${k.maxTime}ms budget by ${(E-100).toFixed(1)}%)`;switch(k.action){case"log":console.log(z);break;case"warn":console.warn(z);break;case"error":console.error(z);break;case"throw":if(j)throw Error(z);else console.warn(z);break}}recordTime(v,_){let k=this.metrics.get(v);if(k)k.count++,k.totalTime+=_,k.maxTime=Math.max(k.maxTime,_),k.minTime=Math.min(k.minTime,_);else this.metrics.set(v,{count:1,totalTime:_,maxTime:_,minTime:_})}getStats(v){if(v){let k=this.metrics.get(v);if(!k)return{};let E=this.budgets.get(v);return{count:k.count,avgTime:k.totalTime/k.count,totalTime:k.totalTime,maxTime:k.maxTime,minTime:k.minTime,budget:E?.maxTime,budgetUtilization:E?k.totalTime/k.count/E.maxTime*100:void 0}}let _={};for(let[k,E]of this.metrics.entries()){let T=this.budgets.get(k);_[k]={count:E.count,avgTime:E.totalTime/E.count,totalTime:E.totalTime,maxTime:E.maxTime,minTime:E.minTime,budget:T?.maxTime,budgetUtilization:T?E.totalTime/E.count/T.maxTime*100:void 0}}return _}getViolations(v){if(v)return this.violations.filter((_)=>_.label===v);return[...this.violations]}getViolationStats(){let v={},_=0,k=0;for(let E of this.violations)if(v[E.label]=(v[E.label]||0)+1,E.isWarning)_++;else k++;return{total:this.violations.length,byLabel:v,warnings:_,errors:k}}clear(){this.metrics.clear()}clearViolations(){this.violations.length=0}clearBudgets(){this.budgets.clear()}reset(){this.clear(),this.clearViolations(),this.clearBudgets(),this.violationHandlers.length=0}}var ba=null;function $h(){if(!ba)ba=new Xu;return ba}var U=new Proxy({},{get(v,_){return $h()[_]}});var Gu=[];function m(v){let _=new M(v);return Gu.push(_),_}function Ju(){for(let v of Gu)v.clear()}function h(v,..._){return`${_.map((k)=>String(k??"")).join("\x00")}\x00${v.length}\x00${Bun.hash(v)}`}function Yu(v){let _=[];for(let k of new Set(v))try{_.push({path:k,mtimeMs:Zu.statSync(k).mtimeMs})}catch{}return _}function Zt(v){for(let _ of v)try{if(Zu.statSync(_.path).mtimeMs!==_.mtimeMs)return!1}catch{return!1}return!0}var W=["browserQuery","BrowserQueryBuilder","BrowserQueryError","browserAuth","configureBrowser","getBrowserConfig","createBrowserDb","createBrowserModel","isBrowser","debounce","throttle","retry","sleep","wait","delay","waitUntil","waitWhile","lazy","clamp","rand","readableSize","useActiveElement","useIntervalFn","useObjectUrl","useTimeoutFn"];var _h=/^[ \t]*import\s+['"]([^'"]+?\.css)(\?[^'"]*)?['"]\s*;?\s*$/gm;function kh(v){if(v.startsWith(".")||v.startsWith("/"))return null;if(v.startsWith("@")){let k=v.match(/^(@[^/]+\/[^/]+)(\/.*)?$/);if(!k)return null;return{pkg:k[1],subpath:k[2]||""}}let _=v.match(/^([^/]+)(\/.*)?$/);if(!_)return null;return{pkg:_[1],subpath:_[2]||""}}function Eh(v,_){let k=_;while(!0){let E=_r.join(k,"node_modules",v,"package.json");if(Us.existsSync(E))return _r.dirname(E);let T=_r.dirname(k);if(T===k)return null;k=T}}function Ch(v,_){if(!v||typeof v!=="object")return null;let k=(T)=>{if(typeof T==="string")return T;if(T&&typeof T==="object"){if(typeof T.import==="string")return T.import;if(typeof T.default==="string")return T.default;if(typeof T.import==="object")return k(T.import);if(typeof T.default==="object")return k(T.default)}return null};if(Object.prototype.hasOwnProperty.call(v,_))return k(v[_]);let E=null;for(let T of Object.keys(v)){let j=T.indexOf("*");if(j===-1)continue;let B=T.slice(0,j),z=T.slice(j+1);if(!_.startsWith(B)||!_.endsWith(z))continue;if(_.length<B.length+z.length)continue;if(!E||B.length>E.prefix.length)E={pattern:T,prefix:B,suffix:z}}if(E){let T=_.slice(E.prefix.length,_.length-E.suffix.length),j=k(v[E.pattern]);if(j)return j.replace("*",T)}return null}function Rh(v,_){let k=kh(v);if(!k||!k.subpath)return null;let E=Eh(k.pkg,_);if(!E)return null;let T;try{T=JSON.parse(Us.readFileSync(_r.join(E,"package.json"),"utf8"))}catch{return null}let j=`.${k.subpath}`,B=Ch(T.exports,j);if(!B)return null;let z=_r.resolve(E,B);return Us.existsSync(z)?z:null}function qr(v,_){let k=_.filePath?_r.dirname(_.filePath):_.projectRoot||process.cwd(),E=_.projectRoot||process.cwd(),T=new Set,j=[],B=[];return{code:v.replace(_h,(F,V)=>{let H;try{if(V.startsWith("./")||V.startsWith("../")||V.startsWith("/")){if(H=V.startsWith("/")?V:_r.resolve(k,V),!Us.existsSync(H))throw Error(`file not found: ${H}`)}else{let G=null;try{G=Bun.resolveSync(V,E)}catch{G=Rh(V,E)}if(!G)throw Error(`could not resolve ${V} (Bun.resolveSync + exports fallback both failed)`);H=G}}catch(G){return console.warn(`[stx:vendor-css] could not resolve ${JSON.stringify(V)} (from ${_.filePath||"<unknown>"}): ${G?.message||G}`),B.push(V),""}if(T.has(H))return"";T.add(H);try{let G=Us.readFileSync(H,"utf8");j.push({source:V,resolvedPath:H,contents:G})}catch(G){console.warn(`[stx:vendor-css] could not read ${H}: ${G?.message||G}`),B.push(V)}return""}),styles:j,unresolved:B}}function Th(v){return v.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}function Kr(v){if(v.length===0)return"";return`${v.map((_)=>`<style data-stx-vendor="${Th(_.source)}" data-stx-layer="vendor">
|
|
765
|
+
@layer vendor {
|
|
766
|
+
${_.contents}
|
|
767
|
+
}
|
|
768
|
+
</style>`).join(`
|
|
769
|
+
`)}
|
|
770
|
+
`}var Ha=y,Qu=m(256);function wt(v){let _=h(v),k=Qu.get(_);if(!k)k=Ah(v),Qu.set(_,k);return{code:k.code,imports:[...k.imports],models:[...k.models]}}function Ah(v){let _=s(v),k=new Set;for(let z of v.matchAll(/^\s*import\s+(?:type\s+)?\{([^}]*)\}\s+from\s+['"][^'"]+['"]\s*;?\s*$/gm))for(let F of z[1].split(",")){let V=F.trim().split(/\s+as\s+/).pop()?.replace(/^type\s+/,"").trim();if(V)k.add(V)}let E=new Set;for(let z of _.matchAll(/\b(?:const|let|var|function|class)\s+([A-Za-z_$][\w$]*)/g))E.add(z[1]);for(let z of _.matchAll(/\b(?:const|let|var)\s*\{([^}]*)\}/g))for(let F of z[1].split(",")){let V=F.trim().split(/[:=]/).pop()?.trim();if(V)E.add(V)}let T=W.filter((z)=>{if(k.has(z)||E.has(z))return!1;return Xr(_,z,!0)}),j=rd(_).filter((z)=>!k.has(z)&&!E.has(z));if(T.length===0&&j.length===0)return{code:v,imports:T,models:j};return{code:`${[T.length>0?`import { ${T.join(", ")} } from '@stacksjs/browser'`:"",j.length>0?"import '@stacksjs/browser'":"",j.length>0?`const { ${j.join(", ")} } = window.StacksBrowser || {}`:""].filter(Boolean).join(`
|
|
771
|
+
`)}
|
|
772
|
+
${v}`,imports:T,models:j}}var Ih=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 rd(v){let _=new Set,k=/\b([A-Z][a-zA-Z0-9]*)\s*\.\s*(all|find|first|get|where|orderBy|orderByDesc|limit|select|pluck|create|update|delete)\s*\(/g,E;while((E=k.exec(v))!==null)if(!Ih.has(E[1]))_.add(E[1]);return Array.from(_)}function Ph(v){let _=new Set;for(let k of v.matchAll(/\b(?:const|let|var|function|class)\s+([A-Za-z_$][\w$]*)/g))_.add(k[1]);for(let k of v.matchAll(/\b(?:const|let|var)\s*\{([^}]*)\}/g))for(let E of k[1].split(",")){let T=E.trim().split(/[:=]/).pop()?.trim();if(T&&/^[A-Za-z_$][\w$]*$/.test(T))_.add(T)}return _}var ed=m(128);function Lo(v){let _=h(v),k=ed.get(_);if(!k)k=Dh(v),ed.set(_,k);return{code:k.code,stxImports:[...k.stxImports],browserImports:[...k.browserImports]}}function Dh(v){let _=new Set,k=new Set,E=v;E=E.replace(/^[ \t]*import\s+type\s+\{[^}]*\}\s+from\s+['"][^'"]+['"][ \t]*;?[ \t]*$/gm,"// [type import stripped]");let T=new Set,j=/^[ \t]*import\s+(?:type\s+)?{\s*([^}]+)\s*}\s+from\s+['"](@stacksjs\/browser|@stacksjs\/stx|stx)['"][ \t]*;?[ \t]*$/gm,B;while((B=j.exec(v))!==null){let G=B[1],J=B[2];if(B[0].includes("import type"))continue;let ne=[];for(let se of G.split(",")){let ie=se.trim();if(!ie||ie.startsWith("type "))continue;let oe=ie.match(/^([A-Za-z_$][\w$]*)(?:\s+as\s+([A-Za-z_$][\w$]*))?$/);if(!oe)continue;let ge=oe[1],ue=oe[2]||ge;if(T.add(ge),T.add(ue),J==="stx"||J==="@stacksjs/stx")_.add(ge);else k.add(ge);if(ue!==ge)ne.push(`${ue} = ${ge}`)}let re=ne.length>0?`var ${ne.join(", ")}; /* [auto-import processed] */`:"// [auto-import processed]";E=E.replace(B[0],re)}let z=Ph(E);for(let G of Ha){if(T.has(G)||z.has(G))continue;if(Xr(E,G,!0))_.add(G)}let F=s(E),V=new Set;for(let G of E.matchAll(/^\s*import\s+(?:type\s+)?\{([^}]*)\}\s+from\s+['"][^'"]+['"]\s*;?\s*$/gm))for(let J of G[1].split(",")){let ne=J.trim().replace(/^type\s+/,"").split(/\s+as\s+/);for(let re of ne){let se=re.trim();if(se)V.add(se)}}for(let G of W){if(T.has(G)||z.has(G)||V.has(G))continue;if(Xr(F,G))k.add(G)}let H=rd(E);for(let G of H)if(!T.has(G)&&!z.has(G))k.add(G);return{code:E,stxImports:Array.from(_),browserImports:Array.from(k)}}function Xr(v,_,k=!1){let E=Hu(v);v=E.code;let T=new RegExp(`\\b${_.replace(/[$]/g,"\\$")}\\b`,"g");for(let j of v.matchAll(T)){let B=j.index??0;if(E.shadows(_,B))continue;let z=B+_.length,F=B-1;while(F>=0&&/\s/.test(v[F]))F--;if(v[F]==="."&&v.slice(Math.max(0,F-2),F+1)!=="...")continue;let V=z;while(V<v.length&&/\s/.test(v[V]))V++;if(v[V]===":"&&v[V+1]!==":"&&(v[F]==="{"||v[F]===","))continue;if(k&&!/^\s*(?:<[^>]*>)?\s*\(/.test(v.slice(z)))continue;return!0}return!1}function jo(v,_){let k=[];if(v.length>0)k.push(` var { ${v.join(", ")} } = window.stx || window;`);if(_.length>0)k.push(` var { ${_.join(", ")} } = window.StacksBrowser || {};`);if(k.length>0)return` // STX: auto-imported from stx and @stacksjs/browser
|
|
773
|
+
${k.join(`
|
|
774
|
+
`)}
|
|
775
|
+
${Mh(v,_)}`;return""}function bu(v,_=[]){let{browserImports:k}=Lo(v),E=new Set(_);return jo([],k.filter((T)=>!E.has(T)))}function Mh(v,_){let k=[...v.map((E)=>`['${E}', typeof ${E}, 'stx']`),..._.map((E)=>`['${E}', typeof ${E}, '@stacksjs/browser']`)];if(k.length===0)return"";return` // STX: report auto-imports the client runtime did not provide
|
|
776
|
+
[${k.join(", ")}].forEach(function (e) {
|
|
777
|
+
if (e[1] !== 'undefined') return;
|
|
778
|
+
console.error(
|
|
779
|
+
'[stx] "' + e[0] + '" is used in this client script and auto-imported from ' + e[2] + ', '
|
|
780
|
+
+ 'but the client runtime does not provide it. Either it is not exported to the browser, '
|
|
781
|
+
+ 'or it should be imported from a relative path so the bundler includes it.'
|
|
782
|
+
);
|
|
783
|
+
});
|
|
784
|
+
`}function Ne(v){let _=v.__stxClientPayload;if(_&&typeof _==="object"){let E={};for(let T in _){let j=_[T];if(typeof j==="function")continue;E[T]=j}return E.__stxDeclaredPayload=!0,E}let k={};for(let E in v){if(E.startsWith("__")||E.startsWith("$"))continue;let T=v[E];if(typeof T==="function")continue;k[E]=T}return k}function Oh(v,_){return new RegExp(`(?<![.#\\w$])${_}(?![\\w$])`).test(v)}var Nh=/token|secret|passw|apikey|api_key|privatekey|private_key|credential|webhook|bearer|jwt|signature/i,td=new Set;function jh(v,_){let k=Nh.test(v),E=_.length>32768;if(!k&&!E)return;if(td.has(v))return;if(td.add(v),k)console.warn(`[stx] server\u2192client bridge is publishing "${v}" 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(E)console.warn(`[stx] server\u2192client bridge is publishing ${(_.length/1024).toFixed(1)}KB under "${v}". Every byte ships in the HTML on each request; prefix the binding with "__" and project just the fields the client reads.`)}function Gr(v,_){if(!_)return"";let k=s(v),E=_.__stxDeclaredPayload===!0,T=[];for(let[j,B]of Object.entries(_)){if(!/^[A-Za-z_$][\w$]*$/.test(j))continue;if(j.startsWith("__")||j.startsWith("$"))continue;if(!E&&!Oh(k,j))continue;if(Vi(v,j)){if(E)console.warn(`[stx] defineClientPayload declares "${j}", but this client block also declares "${j}" at the top level, so the server value is not published (emitting it would be a duplicate binding). Rename the local, or drop "${j}" from defineClientPayload.`);continue}let z;try{z=JSON.stringify(B)}catch{continue}if(z===void 0)continue;jh(j,z),T.push(` var ${j} = ${z.replace(/</g,"\\u003c")};`)}if(T.length===0)return"";return` // stx: server -> client data bridge (seeded from server scope)
|
|
785
|
+
${T.join(`
|
|
786
|
+
`)}
|
|
787
|
+
`}var Lh={left:0,middle:1,right:2};function Bh(v){let _=[];if(v.self)_.push("if ($event.target !== $el) return");for(let k of v.systemKeys)_.push(`if (!$event.${k}Key) return`);if(v.keys.length>0){let k=v.keys.map((E)=>`$event.key === '${E}'`).join(" || ");_.push(`if (!(${k})) return`)}if(v.mouse!==null){let k=Lh[v.mouse];_.push(`if ($event.button !== ${k}) return`)}if(v.prevent)_.push("$event.preventDefault()");if(v.stop)_.push("$event.stopPropagation()");return _.join("; ")}function zh(v,_){let{elementId:k,event:E,modifiers:T}=v,j=ha(v.handler),B=Bh(T),z=[];if(T.once)z.push("once: true");if(T.capture)z.push("capture: true");if(ma(E,T))z.push("passive: true");let F=z.length>0?`, { ${z.join(", ")} }`:"",V="";if(B)V+=`${B}; `;let H=j.replace(/\\/g,"\\\\").replace(/'/g,"\\'"),G=`var $emit = function(name, detail) {
|
|
788
|
+
$el.dispatchEvent(new CustomEvent(name, { detail: detail, bubbles: true, cancelable: true }))
|
|
789
|
+
};`;function J(ne){if(/\$emit\s*\(/.test(ne))return`${G}
|
|
790
|
+
${ne}`;return`var scope = $el.closest('[data-stx-scope]');
|
|
791
|
+
if (scope && scope.__stx_execute) {
|
|
792
|
+
scope.__stx_execute('${H}', $event, $el);
|
|
793
|
+
}
|
|
794
|
+
else {
|
|
795
|
+
${ne}
|
|
796
|
+
}`}if(T.debounce!==null)return` ;(function() {
|
|
797
|
+
// eslint-disable-next-line pickier/no-unused-vars
|
|
798
|
+
var $el = document.getElementById('${k}')
|
|
799
|
+
if (!$el) return
|
|
800
|
+
var __timer
|
|
801
|
+
$el.addEventListener('${E}', function($event) {
|
|
802
|
+
${B?B+"; ":""}clearTimeout(__timer)
|
|
803
|
+
__timer = setTimeout(function() { ${J(j)} }, ${T.debounce})
|
|
804
|
+
}${F})
|
|
805
|
+
})()`;if(T.throttle!==null)return` ;(function() {
|
|
806
|
+
// eslint-disable-next-line pickier/no-unused-vars
|
|
807
|
+
var $el = document.getElementById('${k}')
|
|
808
|
+
if (!$el) return
|
|
809
|
+
var __last = 0
|
|
810
|
+
$el.addEventListener('${E}', function($event) {
|
|
811
|
+
${B?B+"; ":""}var __now = Date.now()
|
|
812
|
+
if (__now - __last >= ${T.throttle}) {
|
|
813
|
+
__last = __now
|
|
814
|
+
${J(j)}
|
|
815
|
+
}
|
|
816
|
+
}${F})
|
|
817
|
+
})()`;if(/\$emit\s*\(/.test(j))return` var $el = document.getElementById('${k}')
|
|
818
|
+
if ($el) $el.addEventListener('${E}', function($event) {
|
|
819
|
+
${V}${G}
|
|
820
|
+
${j}
|
|
821
|
+
}${F})`;return` var $el = document.getElementById('${k}')
|
|
822
|
+
if ($el) $el.addEventListener('${E}', function($event) {
|
|
823
|
+
${V}var scope = $el.closest('[data-stx-scope]');
|
|
824
|
+
if (scope && scope.__stx_execute) {
|
|
825
|
+
scope.__stx_execute('${H}', $event, $el);
|
|
826
|
+
}
|
|
827
|
+
else {
|
|
828
|
+
${j}
|
|
829
|
+
}
|
|
830
|
+
}${F})`}function Fh(v){if(v.length===0)return"";return`
|
|
831
|
+
// STX: auto-generated event bindings
|
|
832
|
+
${v.map((k,E)=>zh(k,E)).join(`
|
|
833
|
+
`)}`}function nd(v){let _=[],k=new Set,E=v.replace(/^\s*import\s+.*$/gm,""),T=0,j=E.length,B=0;while(B<j){let z=E[B];if(z==="'"||z==='"'||z==="`"){let F=z;if(B++,F==="`"){let V=0;while(B<j){if(E[B]==="\\"){B+=2;continue}if(E[B]==="`"&&V===0){B++;break}if(E[B]==="$"&&E[B+1]==="{"){V++,B+=2;continue}if(E[B]==="}"&&V>0){V--,B++;continue}B++}}else while(B<j){if(E[B]==="\\"){B+=2;continue}if(E[B]===F){B++;break}B++}continue}if(z==="/"&&E[B+1]==="/"){while(B<j&&E[B]!==`
|
|
834
|
+
`)B++;continue}if(z==="/"&&E[B+1]==="*"){B+=2;while(B<j-1&&!(E[B]==="*"&&E[B+1]==="/"))B++;B+=2;continue}if(z==="{"){T++,B++;continue}if(z==="}"){T--,B++;continue}if(T===0){let F=E.slice(B),V=F.match(/^(?:const|let|var)\s+([a-zA-Z_$]\w*)\s*(?::[^=]*)?=/);if(V){let J=V[1];if(!J.startsWith("_")&&!k.has(J))_.push(J),k.add(J);B+=V[0].length;continue}let H=F.match(/^(?:const|let|var)\s+\{([^}]+)\}\s*=/);if(H){H[1].split(",").forEach((J)=>{let ne=J.trim(),re=ne.indexOf(":"),se=re>=0?ne.slice(re+1).trim().split(/[\s=]/)[0]:ne.split(/[\s=]/)[0];if(se&&!se.startsWith("_")&&!k.has(se))_.push(se),k.add(se)}),B+=H[0].length;continue}let G=F.match(/^(?:async\s+)?function\s+([a-zA-Z_$]\w*)/);if(G){let J=G[1];if(!J.startsWith("_")&&!k.has(J))_.push(J),k.add(J);B+=G[0].length;continue}}B++}return _}var Wh=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 Vh(v){let _=new Set,k=/[a-zA-Z_$][a-zA-Z0-9_$]*/g;function E(J){let ne;while((ne=k.exec(J))!==null){let re=ne[0];if(!Wh.has(re))_.add(re)}}let T=/\{\{([\s\S]*?)\}\}/g,j;while((j=T.exec(v))!==null)E(j[1]);let B=/:[a-z][\w.-]*\s*=\s*"([^"]*)"/gi;while((j=B.exec(v))!==null)E(j[1]);let z=/:[a-z][\w.-]*\s*=\s*'([^']*)'/gi;while((j=z.exec(v))!==null)E(j[1]);let F=/@[a-z]+(?:\.[a-z]+)*\s*=\s*"([^"]*)"/gi;while((j=F.exec(v))!==null)E(j[1]);let V=/@[a-z]+(?:\.[a-z]+)*\s*=\s*'([^']*)'/gi;while((j=V.exec(v))!==null)E(j[1]);let H=/@model\s*=\s*["']([^"']*)["']/gi;while((j=H.exec(v))!==null)E(j[1]);let G=/@for\s*=\s*["'][^"']*\bin\s+([^"']+)["']/gi;while((j=G.exec(v))!==null)E(j[1]);return _}async function me(v,_={}){let k=v,E="",T=!1,j=[],B=qr(k,{filePath:_.filePath,projectRoot:_.projectRoot});k=B.code;let z=Kr(B.styles),F=wt(k);k=F.code,j=[...F.imports,...F.models];let{hasUserImports:V,bundleClientScript:H}=await ut("stx/client-script-bundler",()=>import("./chunk-rzmvsqc7.js"));if(V(k))k=await H(k,_.filePath||"",{projectRoot:_.projectRoot,minify:_.production}),T=!0;if(_.autoImports!==!1){let ue=Lo(k);k=ue.code,E=jo(ue.stxImports,ue.browserImports.filter((xe)=>!j.includes(xe)))}if(E=`${Gr(k,_.serverData)}${E}`,k=P(k),!T&&Ve(_.attrs||""))k=Ue(k);let G=Fh(_.eventBindings||[]),J=(_.attrs||"").trim(),ne=/\btype\s*=\s*["']module["']/i.test(J),re=_.instanceId?` data-stx-instance="${_.instanceId}"`:"";if(ne){let ue=J.replace(/\btype\s*=\s*["']module["']/i,"").trim(),xe=`type="module" data-stx-scoped${re}${ue?` ${ue}`:""}`;return`${z}<script ${xe}>
|
|
835
|
+
${zr(`${E}${k}
|
|
836
|
+
${G}`)}
|
|
837
|
+
</script>`}let se=Is(v),ie=/function __stx_setup_/.test(k),oe=/\bstx\.mount\s*\(|\bstx\.mountEl\s*\(/.test(v);function ge(ue){let xe=ue.length>0?`
|
|
838
|
+
return { ${ue.join(", ")} };`:"";return`${z}<script data-stx-scoped data-stx-run="always"${re}>
|
|
839
|
+
window.stx.mount(function() {
|
|
840
|
+
'use strict';
|
|
841
|
+
${zr(`${E}${k}
|
|
842
|
+
${G}${xe}`)}
|
|
843
|
+
})</script>`}if(!oe&&!ie){if(se)return ge(nd(v));if(_.templateContent){let ue=nd(v);if(ue.length>0){let xe=Vh(_.templateContent);if(ue.some(($e)=>xe.has($e)))return ge(ue)}}}return`${z}<script data-stx-scoped data-stx-run="always"${re}>
|
|
844
|
+
;(function() {
|
|
845
|
+
'use strict';
|
|
846
|
+
${zr(`${E}${k}
|
|
847
|
+
${G}`)}
|
|
848
|
+
})()</script>`}import{createHash as Uh}from"crypto";var Hi="__stx_component_client_factories";function qi(v){let _=v[Hi];return _ instanceof Map?_:null}function id(v){v[Hi]=new Map}function va(v,_){let k=qi(v);if(!k)return null;let E=Uh("sha256").update(_).digest("hex").slice(0,16),T=k.get(E);if(T)T.instances++;else k.set(E,{body:_,instances:1});return E}function od(v,_){let k=qi(_);if(!k?.size)return v;let E=new Map;for(let[H,G]of k)if(G.instances===1)E.set(H,G.body);let T=[];if(E.size>0){let H=[...E.keys()].map((ne)=>JSON.stringify(ne).replace(/[$()*+.?[\\\]^{|}]/g,"\\$&")).join("|"),G=new RegExp(`window\\.__stxComponentFactories\\[(${H})\\]\\(("[^"]+")\\);`,"g"),J=G.exec(v);while(J!==null){let ne=E.get(JSON.parse(J[1]));if(ne!==void 0)T.push({start:J.index,end:J.index+J[0].length,replacement:`(${ne})(${J[2]});`});J=G.exec(v)}}let j=[...k].filter(([,H])=>H.instances>1);if(j.length===0)return sd(v,T);let z=`<script data-stx-scoped data-stx-run="always" data-stx-component-factories>
|
|
849
|
+
(function() {
|
|
850
|
+
const factories = window.__stxComponentFactories = window.__stxComponentFactories || {};
|
|
851
|
+
${j.map(([H,G])=>` try { factories[${JSON.stringify(H)}] = factories[${JSON.stringify(H)}] || ${G.body}; }
|
|
852
|
+
catch (e) { console.error('[stx] component factory ' + ${JSON.stringify(H)} + ' failed to register; instances of it will not hydrate.', e); }`).join(`
|
|
853
|
+
`)}
|
|
854
|
+
})();
|
|
855
|
+
</script>`,F=v.search(/<script\b(?=[^>]*\bdata-stx-scoped\b)/i),V=F<0?0:F;return T.push({start:V,end:V,replacement:`${z}
|
|
856
|
+
`}),sd(v,T)}function sd(v,_){if(_.length===0)return v;_.sort((j,B)=>j.start-B.start||j.end-B.end);let k=Array(_.length*2+1),E=0,T=0;for(let j of _)k[T++]=v.slice(E,j.start),k[T++]=j.replacement,E=j.end;return k[T]=v.slice(E),k.join("")}function ad(v){let _=qi(v),k=new Map;if(_)for(let[E,T]of _)k.set(E,T.instances);return k}function cd(v,_){let k=qi(v);if(!k)return[];let E=[];for(let[T,j]of k){let B=j.instances-(_.get(T)??0);if(B>0)E.push({body:j.body,count:B})}return E}function ld(v,_){for(let{body:k,count:E}of _)for(let T=0;T<E;T++)va(v,k)}import yd from"fs";var ud=0,wa=new Map;function Bo(){ud=0,wa.clear()}function Ki(v,_){let k=ud++,E=`<!--__STX_${v.toUpperCase()}_${k}__-->`;return wa.set(E,{type:v,expression:_}),E}function Fo(){let v={};for(let[_,k]of wa)v[_]={type:k.type,expression:k.expression};return v}function zo(v,_){let k=v;for(let[E,T]of _)k=k.split(E).join(T);return k}function Jr(v){return v.includes("<!--__STX_")}var Hh=/@(?=[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 qh(v){return Array.from({length:v},()=>"{").join("⁠")}function dd(v){return v.replace(/\{{2,}/g,(_)=>qh(_.length)).replace(/\{(?=!)/g,"{⁠").replace(Hh,"@")}var Kh=/^(?:javascript|vbscript|livescript|mocha|view-source):/,Xh=/^data:(?:text\/html|text\/xml|application\/xhtml\+xml|application\/xml|image\/svg\+xml)/,Zh=/^data:(?:text\/html|application\/xhtml\+xml)/,Gh=new RegExp("[\\u0000-\\u0020\\u00A0\\u1680\\u2000-\\u200F\\u2028\\u2029\\u202F\\u205F\\u3000\\uFEFF]+","g");function Jh(v){return v.replace(Gh,"").toLowerCase()}function Yh(v){let _=v.toLowerCase();if(new RegExp("^(?:href|xlink:href|action|formaction|ping|cite|manifest|data|to)$").test(_))return"navigable";if(new RegExp("^(?:src|srcset|poster|background)$").test(_))return"fetched";return null}function fd(v,_="navigable"){let k=Jh(v);if(Kh.test(k))return!0;return _==="navigable"?Xh.test(k):Zh.test(k)}function Hs(v,_="navigable"){return fd(v,_)?"unsafe:"+v:v}function Qh(v){let _=v.match(/(?:^|[\s"'`/])([A-Za-z][\w:-]*)\s*=\s*(["'])([^"']*)$/);if(!_)return null;if(_[3].trim()!=="")return null;return Yh(_[1])}function Sa(v,_,k=256){if(_<=k)return v.slice(0,_);let E=v.slice(_-k,_),T=E.search(/[\s"'`/]/);return T===-1?"":E.slice(T)}function $a(v,_,k=_){let E=Qh(v);return E&&fd(_,E)?"unsafe:"+k:k}var Xi=/<script\b[^>]*>/iy,Ca=/<\/script\s*>/ig,Zi=/<style\b[^>]*>/iy,Ra=/<\/style\s*>/ig;function pd(v,_,k,E){k.lastIndex=_;let T=k.exec(v);if(!T||T.index!==_)return-1;E.lastIndex=k.lastIndex;let j=E.exec(v);if(!j)return-1;return j.index+j[0].length}function Y(v,_){return pd(v,_,Xi,Ca)}function Ur(v,_){return pd(v,_,Zi,Ra)}function Le(v,_){if(!v.startsWith("<!--",_))return-1;let k=v.indexOf("-->",_+4);if(k===-1)return-1;return k+3}function gd(v,_){if(v.startsWith("<!--",_)){let T=Le(v,_);return T===-1?v.length:T}if(Xi.lastIndex=_,Xi.exec(v)?.index===_){Ca.lastIndex=Xi.lastIndex;let T=Ca.exec(v);return T?T.index+T[0].length:v.length}if(Zi.lastIndex=_,Zi.exec(v)?.index===_){Ra.lastIndex=Zi.lastIndex;let T=Ra.exec(v);return T?T.index+T[0].length:v.length}return-1}function pr(v,_){let k=[],E=0,T=v.length,j=!1,B=null;while(E<T){let z=v[E];if(j){if(B){if(z===B)B=null}else if(z==='"'||z==="'")B=z;else if(z===">")j=!1;E++;continue}if(z!=="<"){let G=v.indexOf("<",E+1);if(G===-1)break;E=G;continue}let F=_(v,E);if(F>E){k.push({start:E,end:F,token:v.slice(E,F)}),E=F;continue}let V=gd(v,E);if(V>E){E=V;continue}let H=v.charCodeAt(E+1);if(H>=65&&H<=90||H>=97&&H<=122)j=!0;E++}return k}function md(v){let _=0,k=0,E=0,T=!1,j=null;while(E<v.length){if(T){let G=v[E];if(j){if(G===j)j=null}else if(G==='"'||G==="'")j=G;else if(G===">")T=!1;E++;continue}let B=v.indexOf("<",E),z=B===-1?v.length:B;while(E<z){let G=v[E++];if(G==="{")_++;else if(G==="}")k++;if(_>=2&&k>=2)return!0}if(B===-1)break;let F=gd(v,B);if(F>B){E=F;continue}let V=v.charCodeAt(B+1),H=V===47?v.charCodeAt(B+2):V;if(H>=65&&H<=90||H>=97&&H<=122)T=!0;E=B+1}return!1}function hd(v,_){while(v.size>=_){let k=v.keys().next();if(k.done)return;v.delete(k.value)}}var ey=1024,ty=16777216,Wr=new Map,_a=0;function ny(v,_){Wr.set(v,_),_a+=v.length+_.output.length;for(let[k,E]of Wr){if(_a<=ty)break;Wr.delete(k),_a-=k.length+E.output.length}}function En(v,_,k,E){let T=E!==void 0&&v.length>=ey,j=T?`${E}\x00${v}`:"";if(T){let H=Wr.get(j);if(H)return Wr.delete(j),Wr.set(j,H),{output:H.output,tokens:H.tokens.slice()}}let B=pr(v,_);if(B.length===0)return{output:v,tokens:[]};let z=B.map((H)=>H.token),F="",V=0;for(let H=0;H<B.length;H++){let G=B[H];F+=v.slice(V,G.start),F+=k(G.token,H),V=G.end}if(F+=v.slice(V),T)return ny(j,{output:F,tokens:z}),{output:F,tokens:z.slice()};return{output:F,tokens:z}}var ry=1024,sy=16777216,Vr=new Map,ka=0;function iy(v,_){Vr.set(v,_),ka+=v.length+_.output.length;for(let[k,E]of Vr){if(ka<=sy)break;Vr.delete(k),ka-=k.length+E.output.length}}function Ea(v,_,k){return{output:_,scripts:k,restore:(E)=>E===_?v:Hr(E,k)}}function bn(v){let _=v.length>=ry;if(_){let T=Vr.get(v);if(T)return Vr.delete(v),Vr.set(v,T),Ea(v,T.output,T.scripts.slice())}let{output:k,tokens:E}=En(v,Y,(T,j)=>`\x00STX_SCRIPT_${j}\x00`);if(_)return iy(v,{output:k,scripts:E}),Ea(v,k,E.slice());return Ea(v,k,E)}function Hr(v,_){if(_.length===0)return v;return v.replace(/\x00STX_SCRIPT_(\d+)\x00/g,(k,E)=>_[+E]??"")}var Ks={},xd=new Map;function oy(v){let _=xd.get(v);if(!_){let k=v.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");_=new RegExp(`:${k}(?!\\w)`,"g"),xd.set(v,_)}return _.lastIndex=0,_}var Dn={uppercase:(v,_)=>v!==void 0&&v!==null?String(v).toUpperCase():"",lowercase:(v,_)=>v!==void 0&&v!==null?String(v).toLowerCase():"",capitalize:(v,_)=>{if(v===void 0||v===null)return"";let k=String(v);return k.charAt(0).toUpperCase()+k.slice(1)},number:(v,_,k=0)=>{if(v===void 0||v===null)return"";try{let E=Number(v);return Number.isNaN(E)?"":E.toFixed(Number.parseInt(String(k),10))}catch{return""}},fmt:(v,_,k="en-US")=>{if(v===void 0||v===null)return"";try{let E=Number(v);if(Number.isNaN(E))return String(v);return E.toLocaleString(k)}catch{return String(v)}},join:(v,_,k=",")=>{if(!Array.isArray(v))return"";return v.join(String(k))},escape:(v,_)=>{if(v===void 0||v===null)return"";return vt(String(v))},translate:(v,_,k={})=>{if(!_||!_.__translations)return v;let E=_.__translations,T=_.__i18nConfig?.fallbackToKey??!0,j=String(v).split("."),B=E;for(let F of j){if(B===void 0||B===null)break;B=B[F]}if(B===void 0||B===null)return T?v:"";let z=String(B);return Object.entries(k).forEach(([F,V])=>{z=z.replace(oy(F),String(V))}),z},t:(v,_,k={})=>Dn.translate(v,_,k),truncate:(v,_,k=50,E="...")=>{if(v===void 0||v===null)return"";let T=String(v);if(T.length<=k)return T;if(k<=E.length)return E.substring(0,k);return T.substring(0,k-E.length)+E},date:(v,_,k="short",E="en-US")=>{if(v===void 0||v===null)return"";try{let T=v instanceof Date?v:new Date(v);if(Number.isNaN(T.getTime()))return String(v);let j={short:{dateStyle:"short"},medium:{dateStyle:"medium"},long:{dateStyle:"long"},full:{dateStyle:"full"},time:{timeStyle:"short"},datetime:{dateStyle:"short",timeStyle:"short"},iso:{}};if(k==="iso")return T.toISOString();return new Intl.DateTimeFormat(E,j[k]||j.short).format(T)}catch{return String(v)}},currency:(v,_,k="USD",E="en-US")=>{if(v===void 0||v===null)return"";try{let T=Number(v);if(Number.isNaN(T))return String(v);return new Intl.NumberFormat(E,{style:"currency",currency:k}).format(T)}catch{return String(v)}},pluralize:(v,_,k,E)=>{let T=Number(v);if(Number.isNaN(T))return k;let j=E||`${k}s`;return T===1?k:j},first:(v,_)=>{if(v===void 0||v===null)return"";if(Array.isArray(v))return v.length===0?"":v[0];return String(v).charAt(0)},last:(v,_)=>{if(v===void 0||v===null)return"";if(Array.isArray(v))return v.length===0?"":v[v.length-1];let k=String(v);return k.charAt(k.length-1)},length:(v,_)=>{if(v===void 0||v===null)return 0;if(Array.isArray(v)||typeof v==="string")return v.length;if(v instanceof Map||v instanceof Set)return v.size;if(typeof v==="object")return Object.keys(v).length;return 0},json:(v,_,k=!1)=>{if(v===void 0)return"undefined";if(v===null)return"null";try{return k?JSON.stringify(v,null,2):JSON.stringify(v)}catch{return String(v)}},default:(v,_,k="")=>v===void 0||v===null||v===""?k:v,reverse:(v,_)=>{if(v===void 0||v===null)return"";if(Array.isArray(v))return[...v].reverse();return String(v).split("").reverse().join("")},slice:(v,_,k=0,E)=>{if(v===void 0||v===null)return"";if(Array.isArray(v)||typeof v==="string")return v.slice(k,E);return v},replace:(v,_,k,E="")=>{if(v===void 0||v===null)return"";let T=k.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return String(v).replace(new RegExp(T,"g"),()=>E)},stripTags:(v,_)=>{if(v===void 0||v===null)return"";return String(v).replace(/<[^>]*>/g,"")},urlencode:(v,_)=>{if(v===void 0||v===null)return"";return encodeURIComponent(String(v))},abs:(v,_)=>{let k=Number(v);return Number.isNaN(k)?0:Math.abs(k)},round:(v,_,k=0)=>{let E=Number(v);if(Number.isNaN(E))return 0;let T=10**k;return Math.round(E*T)/T}};function Va(v,_){if(v in Dn)console.warn(`Filter "${v}" already exists as a built-in filter. Custom filter will take precedence.`);Ks[v]=_}function wu(v){for(let[_,k]of Object.entries(v))Va(_,k)}function Ua(){return{...Dn,...Ks}}function vu(){for(let v of Object.keys(Ks))delete Ks[v]}function Wa(v,_,k=2){let E=0,T=null;for(let j=_+k;j<v.length;j++){let B=v[j];if(T){if(B==="\\"){j++;continue}if(B===T)T=null;continue}if(B==='"'||B==="'"||B==="`"){T=B;continue}if(B==="{"){E++;continue}if(B==="}"){if(E>0){E--;continue}let z=0;while(v[j+z]==="}")z++;if(z>=k)return j}}return-1}function On(v,_,k=2){let E="{".repeat(k);if(!v.includes(E))return v;let T="",j=0;for(;;){let B=v.indexOf(E,j);if(B===-1)break;let z=Wa(v,B,k);if(z===-1)break;T+=v.slice(j,B)+_(v.slice(B,z+k),v.slice(B+k,z),B),j=z+k}return j===0?v:T+v.slice(j)}function b(v){return v.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function vt(v){return dd(b(v))}function he(v,_){let{scripts:k}=bn(v);for(let E of k){let T=E.match(/^<script\b([^>]*)>([\s\S]*?)<\/script\s*>$/i);if(!T||/\bserver\b|\bsrc\s*=/.test(T[1]))continue;let j=T[2];if(/\b(state|derived|effect|ref|reactive|computed|watch|watchEffect|useModel)\s*(?:<[^>]*>)?\s*\(/.test(j))return!0;if(gn(j,_))return!0}if(/@(if|for|show)\s*=\s*["'][^"']*\(\s*\)/.test(v))return!0;if(/@for\s*=\s*["'][^"']*\s+(?:in|of)\s+[^"']*\(\s*\)/.test(v))return!0;if(/(?:^|[\s"'])(?::|x-)(?:for|if|else-if|else|show|text|html|model|bind)\b/.test(v))return!0;return!1}function qa(v){let _=[],k=/<([a-zA-Z][\w-]*)\b[^>]*?\s(?::for|x-for|@for)\s*=\s*(["'])([\s\S]*?)\2[^>]*>/g;for(let E=k.exec(v);E;E=k.exec(v)){let T=E[1].toLowerCase(),j=/^\s*\(?\s*([A-Za-z_$][\w$]*)\s*(?:,\s*([A-Za-z_$][\w$]*)\s*)?\)?\s+(?:in|of)\s/.exec(E[3]);if(!j)continue;let B=new Set([j[1],...j[2]?[j[2]]:[]]),z=E.index+E[0].length;if(E[0].endsWith("/>")){_.push({start:E.index,end:z,names:B});continue}let F=new RegExp(`<(/?)${T}\\b[^>]*?(/?)>`,"gi");F.lastIndex=z;let V=1,H=v.length;for(let G=F.exec(v);G;G=F.exec(v)){if(G[2]==="/")continue;if(V+=G[1]==="/"?-1:1,V===0){H=G.index+G[0].length;break}}_.push({start:E.index,end:H,names:B})}return _}function ay(v,_,k){let E=s(k);for(let T of v){if(_<T.start||_>=T.end)continue;for(let j of T.names)if(new RegExp(`(?<![.#\\w$])${j.replace(/\$/g,"\\$")}(?![\\w$])`).test(E))return!0}return!1}function bd(v,_){let k=["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"],E=v.replace(/'[^']*'/g,"").replace(/"[^"]*"/g,""),T="",j=!1,B=0;for(let V=0;V<E.length;V++){let H=E[V];if(!j&&H==="`"){j=!0,B=0;continue}if(j){if(H==="`"&&B===0){j=!1;continue}if(H==="$"&&E[V+1]==="{"){B++,V++,T+=" ";continue}if(H==="}"&&B>0){B--;continue}if(B>0){T+=H;continue}continue}T+=H}E=T;let z=/(?<![a-zA-Z0-9_$])([a-zA-Z_$][a-zA-Z0-9_$]*)/g,F;while((F=z.exec(E))!==null){let V=F[1];if(!E.substring(0,F.index).trimEnd().endsWith(".")){if(!k.includes(V)&&!(V in _))return!1}}return!0}function cy(v,_){let k=_.__stx_serverDeclared;if(!k||k.size===0)return!1;let E=s(v);for(let T of k)if(new RegExp(`(?<![.#\\w$])${T}(?![\\w$])`).test(E))return!0;return!1}var vd=new Set;function wd(v){return/^[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*)*$/.test(v.trim())}function Sd(v,_){let k=`${_??"<unknown>"}\x00${v}`;if(process.env.STX_DEBUG||!vd.has(k))vd.add(k),console.warn(`[stx] {{ ${v} }} in a <script> in ${_??"<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 Yr(v,_,k){let E=v;return E=E.replace(/\{!!([\s\S]*?)!!\}/g,(T,j)=>{try{let B=x(j,_);if(B===void 0)return wd(j)?Sd(j.trim(),k):T;return B===null?"":String(B)}catch{return T}}),E=On(E,(T,j,B)=>{let z=j.trim();if(/^__[A-Z_]+__$/.test(z))return T;try{let F=x(j,_);if(F===void 0)return wd(z)?Sd(z,k):T;return JSON.stringify(F).replace(/</g,"\\u003c")}catch{return T}}),E}function Ka(v,_){if(!v.includes("{"))return v;let k=v;return k=k.replace(/\{!!([\s\S]*?)!!\}/g,(E,T)=>{try{let j=x(T,_);if(j===void 0)return E;return j===null?"":String(j)}catch{return E}}),k=On(k,(E,T,j)=>{let B=T.trim();if(/^__[A-Z_]+__$/.test(B))return E;try{let z=x(T,_);if(z===void 0)return E;if(z===null)return"";let F=String(z);return $a(Sa(k,j),F,vt(F))}catch{return E}}),k}function xu(v,_,k={}){let{output:E,scripts:T}=bn(v),j=T.map((B)=>{let z=B.match(/^<script\b([^>]*)>([\s\S]*?)<\/script\s*>$/i),F=B.match(/^<script\b[^>]*>/i),V=B.search(/<\/script\s*>$/i);if(!z||!F||V===-1)return B;let H=z[1],G=z[2];if(/\bdata-raw\b/.test(H))return B;if(k.skipServer&&/\bserver\b/.test(H))return B;let ne=`<script${Ka(H,_)}>`;if(/\bsrc\s*=/.test(H)||/\btype\s*=\s*["']application\/json["']/.test(H))return ne+G+B.slice(V);return ne+Yr(G,_)+B.slice(V)});return Hr(E,j)}function q(v,_,k){let E=v,T=(J,ne)=>{let re=Ur(J,ne);if(re===-1)return-1;return/\{\{[\s\S]*?\}\}|\{!![\s\S]*?!!\}/.test(J.slice(ne,re))?-1:re},j=(J,ne,re,se)=>{let ie=re.length,{output:oe,tokens:ge}=En(J,ne,(ue,xe)=>se(ie+xe));return re.push(...ge),oe},B=[];E=j(E,T,B,(J)=>`<!--__STX_STYLE_${J}__-->`);let z=[];E=j(E,Y,z,(J)=>`<!--__STX_SCRIPT_EXPR_${J}__-->`);let F=_?.__stx_signals_gate===!0||he(v),V=new Set(Array.isArray(_?.__stx_client_signal_names)?_.__stx_client_signal_names:[]),H=new Set(Array.isArray(_?.__stx_preserved_client_expressions)?_.__stx_preserved_client_expressions:[]);E=On(E,(J,ne,re)=>{try{let se=x(ne,_,!1,(ie)=>Ta(ie,J,k,v));return se!==void 0&&se!==null?String(se):""}catch(se){let ie=se instanceof Error?se.message:String(se);return g("Expression",`Error evaluating: {{{ ${ne.trim()}}}}: ${ie}`,k,v,re,J)}},3),E=E.replace(/\{!!([\s\S]*?)!!\}/g,(J,ne,re)=>{try{let se=x(ne,_,!1,(ie)=>Ta(ie,J,k,v));if(se===void 0&&_.__stx_buildMode==="compile")return Ki("raw",ne.trim());return se!==void 0&&se!==null?String(se):""}catch(se){if(_.__stx_buildMode==="compile")return Ki("raw",ne.trim());let ie=se instanceof Error?se.message:String(se);return g("Expression",`Error evaluating: {!! ${ne.trim()} !!}: ${ie}`,k,v,re,J)}}),E=j(E,Y,z,(J)=>`<!--__STX_SCRIPT_EXPR_${J}__-->`),E=j(E,T,B,(J)=>`<!--__STX_STYLE_${J}__-->`);let G=F?qa(E):[];if(E=On(E,(J,ne,re)=>{let se=ne.trim();if(G.length>0&&ay(G,re,se))return J;if(H.has(se))return J;let ie=["parseInt","parseFloat","String","Number","Boolean","Array","Object","JSON","Math","Date","encodeURIComponent","decodeURIComponent","encodeURI","decodeURI","true","false","null","undefined"],oe=/^([a-zA-Z_$][a-zA-Z0-9_$]*)/,ue=se.match(oe)?.[1],xe=ue&&((ue in _)||ie.includes(ue)),we=Boolean(ue&&V.has(ue)),$e=/^([a-zA-Z_$][a-zA-Z0-9_$]*)\s*\(/,_e=se.match($e),Ce=_e&&!ie.includes(_e[1])&&!(_e[1]in _);if(/^__[A-Z_]+__$/.test(se))return"";let Ee;try{let Te=x(ne,_,!1,(ke)=>{Ee=ke});if(we)return J;if(F&&!bd(se,_))return J;if(Ee)Ta(Ee,J,k,v);if(_.__stx_buildMode==="compile"&&!F&&(Te===void 0||cy(se,_)))return Ki("expr",se);if(Te===void 0||Te===null)return"";let Re=String(Te);return $a(Sa(E,re),Re,vt(Re))}catch(Te){if(we)return J;if(F&&!bd(se,_))return J;if(Ce)return J;let Re=Te instanceof Error?Te.message:String(Te);return g("Expression",`Error evaluating: {{ ${se} }}: ${Re}`,k,v,re,J)}}),z.length>0)E=E.replace(/<!--__STX_SCRIPT_EXPR_(\d+)__-->/g,(J,ne)=>z[Number(ne)]??J);if(B.length>0)E=E.replace(/<!--__STX_STYLE_(\d+)__-->/g,(J,ne)=>B[Number(ne)]??J);return E}function Xa(v,_,k){if(!_.trim())return v;let E=v,T=_.trim();while(T.length>0){let j=T.match(/^(\w+)/);if(!j)break;let B=j[1];T=T.substring(B.length).trim();let z=Ks[B]||Dn[B];if(!z)throw Error(`Filter not found: ${B}. Available filters: ${Object.keys(Ua()).join(", ")}`);let F=[];if(T.startsWith(":")){let V=T.match(/^:([^|\s]+)/);if(V){let H=V[1].trim();try{let G=Number(H);F=[Number.isNaN(G)?H:G]}catch{F=[H]}T=T.substring(V[0].length).trim()}}else if(T.startsWith("(")){let V=1,H=1;while(V>0&&H<T.length){if(T[H]==="(")V++;if(T[H]===")")V--;H++}if(V===0){let G=T.substring(1,H-1).trim();if(G)try{if(G.startsWith("{")&&G.endsWith("}"))F=[x(`(${G})`,k,!0)];else{let J=[],ne="",re=null,se=0,ie=0,oe=0,ge=!1;for(let ue=0;ue<G.length;ue++){let xe=G[ue];if(ge){ne+=xe,ge=!1;continue}if(xe==="\\"){ne+=xe,ge=!0;continue}if(re){if(ne+=xe,xe===re)re=null;continue}if(xe==='"'||xe==="'"||xe==="`"){re=xe,ne+=xe;continue}if(xe==="(")se++;else if(xe===")")se--;else if(xe==="[")ie++;else if(xe==="]")ie--;else if(xe==="{")oe++;else if(xe==="}")oe--;if(xe===","&&se===0&&ie===0&&oe===0){J.push(ne),ne="";continue}ne+=xe}if(ne)J.push(ne);F=J.map((ue)=>{let xe=ue.trim();return x(xe,k,!0)})}}catch{F=[G]}T=T.substring(H).trim()}}try{E=z(E,k,...F)}catch(V){let H=V instanceof Error?V.message:String(V);throw Error(`Error applying filter '${B}': ${H}`)}if(T.startsWith("|"))T=T.substring(1).trim();else break}return E}function ly(v){let _=!1,k="",E=0,T=0,j=0,B=!1;for(let z=0;z<v.length;z++){let F=v[z],V=v[z+1];if(_&&B){B=!1;continue}if(_&&F==="\\"){B=!0;continue}if(B=!1,(F==='"'||F==="'"||F==="`")&&!B){if(!_)_=!0,k=F;else if(F===k)_=!1,k="";continue}if(_&&k==="`"&&F==="$"&&V==="{"){let H=1;z+=2;while(z<v.length&&H>0){if(v[z]==="{")H++;else if(v[z]==="}")H--;if(H>0)z++}continue}if(_)continue;if(F==="(")E++;else if(F===")")E--;else if(F==="[")T++;else if(F==="]")T--;else if(F==="{")j++;else if(F==="}")j--;if(F==="|"&&E===0&&T===0&&j===0){if(V==="|"){z++;continue}if(V==="="){z++;continue}return z}}return-1}var qs=new Set,uy=1000;function Su(){qs.clear()}function Ta(v,_,k,E){if(!O())return;let T=`${k}\x00${v.expression}`;if(qs.has(T))return;if(qs.size>=uy)qs.clear();qs.add(T);let j=k,B=E;try{if(k&&yd.existsSync(k))B=yd.readFileSync(k,"utf8")}catch{}let z=B.indexOf(_);if(z>=0)j=`${k}:${B.slice(0,z).split(`
|
|
857
|
+
`).length}`;console.warn(`${j}: stx warning: ${_} rendered as an empty string. The safe evaluator rejected \`${v.expression}\` (${v.rule}). Compute the value in <script server> and interpolate the variable instead.`)}function x(v,_,k=!1,E){try{let T=v.trim(),j=ly(T);if(j>0){let z=T.substring(0,j).trim(),F=T.substring(j+1).trim(),V=x(z,_,!0,E);return Xa(V,F,_)}let B=pn(T);if(B!==null){E?.({expression:T,rule:B});return}try{let z=Object.keys(_),F=Object.values(_);return l(T,z)(...F)}catch{return c(T,_)}}catch(T){if(T instanceof ReferenceError){let j=/(\b\w+)\s+is not defined/.exec(T.message);if(j){let B=j[1],z=dy(B,Object.keys(_));if(z&&z!==B)T.message=`${T.message} \u2014 did you mean '${z}'?`}}if(!k)console.error(`Error evaluating expression: ${v}`,T);throw T}}function dy(v,_){let k=null;for(let T of _){if(T===v)continue;let j=fy(v,T);if(k===null||j<k.dist)k={key:T,dist:j}}if(!k)return null;let E=Math.max(v.length,k.key.length);if(k.dist<=2||k.dist/E<=0.35)return k.key;return null}function fy(v,_){if(v===_)return 0;if(v.length===0)return _.length;if(_.length===0)return v.length;let[k,E]=v.length<_.length?[v,_]:[_,v],T=Array(k.length+1),j=Array(k.length+1);for(let B=0;B<=k.length;B++)T[B]=B;for(let B=1;B<=E.length;B++){j[0]=B;for(let z=1;z<=k.length;z++){let F=k[z-1]===E[B-1]?0:1;j[z]=Math.min(j[z-1]+1,T[z]+1,T[z-1]+F)}for(let z=0;z<=k.length;z++)T[z]=j[z]}return T[k.length]}function ku(v){if(!v)return"";return v.replace(/</g,"<").replace(/>/g,">").replace(/"/g,'"').replace(/'/g,"'").replace(/'/g,"'").replace(/&/g,"&")}import $w from"fs";import Yt from"path";import It from"path";import{hasLocalConfig as Ud}from"bunfig";import Cn from"fs";import Er from"path";import Aa from"fs";import $d from"path";import{fileURLToPath as py}from"url";var Ia;function Me(){if(Ia)return Ia;let v="unknown";try{v=String(JSON.parse(Aa.readFileSync(new URL("../package.json",import.meta.url),"utf8")).version)}catch{}if(import.meta.url.endsWith(".ts"))try{let _=$d.dirname(py(import.meta.url)),k=0;for(let E of Aa.readdirSync(_,{recursive:!0,withFileTypes:!0}))if(E.isFile()&&E.name.endsWith(".ts"))k=Math.max(k,Aa.statSync($d.join(E.parentPath,E.name)).mtimeMs);v+=`+src.${Math.trunc(k)}`}catch{}return Ia=v,v}var Ga=new Map,Cr=new Map;async function Cu(v){let k;for(let E=0;E<3;E++)try{let j=(await Cn.promises.stat(v)).mtime.getTime(),B=Cr.get(v);if(B&&B.mtime===j)return B.content;let z=await Bun.file(v).text(),V=(await Cn.promises.stat(v)).mtime.getTime();if(V!==j)continue;return Cr.set(v,{content:z,mtime:V}),z}catch(T){k=T;break}throw Cr.delete(v),Error(`File not found: ${v}${k?` (${k.message})`:""}`)}function $u(v){Cr.delete(v)}function Eu(v){for(let _ of Cr.keys())if(_.startsWith(v))Cr.delete(_)}var Gi=null,gy=null,kd=null;function Tu(v){kd=v}async function Ja(v=!1){let _=kd??await import("./chunk-w62ettpr.js");if(v)return _.generateSignalsRuntimeDev();if(Gi===null)Gi=_.generateSignalsRuntime();return Gi}var Ji=null;async function Ya(){if(Ji===null){let{getRouterScript:v}=await import("./chunk-143gpdxy.js");Ji=v()}return Ji}var _d={};async function _u(v,_=!1){let k=v==="runtime"?await Ja(_):await Ya(),E=v==="runtime"&&_?"runtime-debug":v,T=_d[E];if(!T||T.content!==k)T={content:k,hash:Bun.hash(k).toString(16).padStart(16,"0").slice(0,16)},_d[E]=T;return{content:k,hash:T.hash,url:`/_stx/${v}.${T.hash}.js`}}var my=500,kr=new Map;function Ed(v){return a(process.cwd(),"module-bundles",`${v}.js`)}function Ru(v){let _=Bun.hash(v).toString(16).padStart(16,"0").slice(0,16),k=kr.has(_);if(k)kr.delete(_);kr.set(_,v);while(kr.size>my)kr.delete(kr.keys().next().value);if(!k)try{let E=Ed(_);if(!Cn.existsSync(E))Cn.mkdirSync(Er.dirname(E),{recursive:!0}),Cn.writeFileSync(E,v)}catch{}return`/_stx/modules.${_}.js`}function Ho(v){if(!/^[0-9a-f]{16}$/.test(v))return;let _=kr.get(v);if(_!==void 0)return _;try{return Cn.readFileSync(Ed(v),"utf8")}catch{return}}function Au(){Cr.clear(),ee(),Ju(),Gi=null,gy=null,Ji=null}function Cd(v){let _={debug:v.debug===!0,middleware:(v.middleware??[]).map((k)=>({name:k.name,timing:k.timing,handler:String(k.handler)})),customDirectives:(v.customDirectives??[]).map((k)=>({name:k.name,hasEndTag:k.hasEndTag===!0,rawParams:k.rawParams===!0,handler:String(k.handler)}))};return new Bun.CryptoHasher("sha1").update(JSON.stringify(_)).digest("hex")}async function Qt(v,_){try{if(!_.cachePath)return null;let k=Er.resolve(_.cachePath),E=Er.join(k,`${Mn(v)}.html`),T=Er.join(k,`${Mn(v)}.meta.json`);if(!await r(E)||!await r(T))return null;let j=await Bun.file(T).text(),B=JSON.parse(j);if(B.cacheVersion!==_.cacheVersion)return null;if(B.engine!==Me())return null;if(B.optionsSignature!==Cd(_))return null;if((await Cn.promises.stat(v)).mtime.getTime()>B.mtime)return null;for(let F of B.dependencies)if(await r(F)){if((await Cn.promises.stat(F)).mtime.getTime()>B.mtime)return null}else return null;return await Bun.file(E).text()}catch(k){return console.warn(`Cache error for ${v}:`,k),null}}async function en(v,_,k,E){try{if(!E.cachePath)return;let T=Er.resolve(E.cachePath);await Cn.promises.mkdir(T,{recursive:!0});let j=Er.join(T,`${Mn(v)}.html`),B=Er.join(T,`${Mn(v)}.meta.json`),z=await Cn.promises.stat(v);await Bun.write(j,_);let F={sourcePath:v,mtime:z.mtime.getTime(),dependencies:Array.from(k),cacheVersion:E.cacheVersion,engine:Me(),optionsSignature:Cd(E),generatedAt:Date.now()};await Bun.write(B,JSON.stringify(F,null,2)),Ga.set(v,{output:_,mtime:z.mtime.getTime(),dependencies:k})}catch(T){console.warn(`Failed to cache template ${v}:`,T)}}var hy=16;function Mn(v){return new Bun.CryptoHasher("sha1").update(v).digest("hex").substring(0,hy)}var Nn={fg:{light:"neutral-900",dark:"neutral-100",description:"Primary text"},"fg-strong":{light:"neutral-700",dark:"neutral-300",description:"Labels, secondary headings"},"fg-muted":{light:"neutral-600",dark:"neutral-400",description:"Supporting text"},"fg-soft":{light:"neutral-500",dark:"neutral-400",description:"De-emphasised text"},"fg-subtle":{light:"neutral-400",dark:"neutral-500",description:"Recessive, non-essential text"},surface:{light:"neutral-50",dark:"neutral-800",description:"Page and panel background"},"surface-raised":{light:"neutral-100",dark:"neutral-700",description:"Cards, popovers"},"surface-sunken":{light:"neutral-200",dark:"neutral-700",description:"Wells, track backgrounds"},panel:{light:"white",dark:"neutral-800",description:"Card, menu, dialog surface"},field:{light:"white",dark:"neutral-700",description:"Form control surface"},page:{light:"neutral-50",dark:"neutral-900",description:"Page background, behind panels"},content:{light:"white",dark:"neutral-900",description:"Content area under a chrome header - a table or list body"},"surface-hover":{light:"neutral-100",dark:"neutral-700",description:"Row or item highlight on a page or panel"},"surface-raised-hover":{light:"neutral-200",dark:"neutral-600",description:"Raised surface, hovered"},"surface-sunken-hover":{light:"neutral-300",dark:"neutral-600",description:"Sunken surface, hovered"},"field-hover":{light:"neutral-50",dark:"neutral-600",description:"Form control surface, hovered"},link:{light:"blue-500",dark:"blue-400",description:"Hyperlink"},"link-hover":{light:"blue-600",dark:"blue-300",description:"Hyperlink, hovered"},inverse:{light:"neutral-900",dark:"neutral-700",description:"Tooltip bubble, inverted surface"},"inverse-ink":{light:"white",dark:"white",description:"Text on an inverted surface"},line:{light:"neutral-200",dark:"neutral-700",description:"Default border, divider"},"line-strong":{light:"neutral-300",dark:"neutral-600",description:"Input border, focus ring track"},"line-hover":{light:"neutral-400",dark:"neutral-500",description:"Border of a hovered control"},accent:{light:"blue-600",dark:"blue-400",description:"Primary action, selected state"},info:{light:"cyan-600",dark:"cyan-400",description:"Informational emphasis"},danger:{light:"red-600",dark:"red-400",description:"Errors, destructive actions"},success:{light:"green-600",dark:"green-400",description:"Confirmation"},warning:{light:"yellow-600",dark:"yellow-400",description:"Caution"},"accent-solid":{light:"blue-500",dark:"blue-600",description:"Primary button fill"},"info-solid":{light:"cyan-500",dark:"cyan-600",description:"Informational fill"},"danger-solid":{light:"red-500",dark:"red-600",description:"Destructive button fill"},"success-solid":{light:"green-500",dark:"green-600",description:"Confirmation fill"},"warning-solid":{light:"yellow-500",dark:"yellow-600",description:"Caution fill"},"accent-solid-hover":{light:"blue-600",dark:"blue-700",description:"Primary button fill, hovered"},"info-solid-hover":{light:"cyan-600",dark:"cyan-700",description:"Informational fill, hovered"},"danger-solid-hover":{light:"red-600",dark:"red-700",description:"Destructive fill, hovered"},"success-solid-hover":{light:"green-600",dark:"green-700",description:"Confirmation fill, hovered"},"warning-solid-hover":{light:"yellow-600",dark:"yellow-700",description:"Caution fill, hovered"},"accent-ink":{light:"white",dark:"white",description:"Text on a primary fill"},"info-ink":{light:"neutral-900",dark:"neutral-900",description:"Text on an informational fill"},"danger-ink":{light:"white",dark:"white",description:"Text on a destructive fill"},"success-ink":{light:"neutral-900",dark:"neutral-900",description:"Text on a confirmation fill"},"warning-ink":{light:"neutral-900",dark:"neutral-900",description:"Text on a caution fill"},"accent-soft":{light:"blue-100",dark:"blue-900",description:"Tinted primary fill"},"accent-soft-ink":{light:"blue-800",dark:"blue-200",description:"Text on a tinted primary fill"},"info-soft":{light:"cyan-100",dark:"cyan-900",description:"Tinted informational fill"},"info-soft-ink":{light:"cyan-800",dark:"cyan-200",description:"Text on a tinted informational fill"},"danger-soft":{light:"red-100",dark:"red-900",description:"Tinted destructive fill"},"danger-soft-ink":{light:"red-800",dark:"red-200",description:"Text on a tinted destructive fill"},"success-soft":{light:"green-100",dark:"green-900",description:"Tinted confirmation fill"},"success-soft-ink":{light:"green-800",dark:"green-200",description:"Text on a tinted confirmation fill"},"warning-soft":{light:"yellow-100",dark:"yellow-900",description:"Tinted caution fill"},"warning-soft-ink":{light:"yellow-800",dark:"yellow-200",description:"Text on a tinted caution fill"},secondary:{light:"purple-600",dark:"purple-400",description:"Secondary emphasis"},"secondary-solid":{light:"purple-500",dark:"purple-600",description:"Secondary fill"},"secondary-solid-hover":{light:"purple-600",dark:"purple-700",description:"Secondary fill, hovered"},"secondary-ink":{light:"white",dark:"white",description:"Text on a secondary fill"},"secondary-soft":{light:"purple-100",dark:"purple-900",description:"Tinted secondary fill"},"secondary-soft-ink":{light:"purple-800",dark:"purple-200",description:"Text on a tinted secondary fill"},"danger-fg":{light:"red-900",dark:"red-300",description:"Text in a field with an error"},"danger-fg-subtle":{light:"red-300",dark:"red-500",description:"Recessive text in a field with an error"},"danger-line":{light:"red-300",dark:"red-600",description:"Border of a field with an error"},"danger-focus":{light:"red-500",dark:"red-400",description:"Focus ring of a field with an error"}};function Pa(v){return`--stx-${v}`}function Da(v,_){let k=_.lastIndexOf("-");if(k===-1)return typeof v[_]==="string"?v[_]:void 0;let E=v[_.slice(0,k)];if(!E||typeof E!=="object")return;let T=E[_.slice(k+1)];return typeof T==="string"?T:void 0}function Rd(v){let _={};for(let[k,E]of Object.entries(Nn)){let T=Da(v,E.light);if(T===void 0)continue;_[k]=`var(${Pa(k)}, ${T})`}return _}function Td(v){let _=[],k=[];for(let[E,T]of Object.entries(Nn)){let j=Da(v,T.light),B=Da(v,T.dark);if(j===void 0)continue;if(_.push(` ${Pa(E)}: ${j};`),B!==void 0)k.push(` ${Pa(E)}: ${B};`)}if(_.length===0)return"";return["/* stx role tokens \u2014 override any of these to re-theme by meaning. */",":root {",..._,"}",".dark {",...k,"}",""].join(`
|
|
858
|
+
`)}var Ad={control:{value:"0.375rem",description:"Buttons, inputs, selects \u2014 rounded-md"},panel:{value:"0.5rem",description:"Cards, dialogs, menus \u2014 rounded-lg"},pill:{value:"9999px",description:"Chips and badges, which are pill-shaped by intent"}};function Id(v){return`--stx-radius-${v}`}function Pd(){let v={};for(let[_,k]of Object.entries(Ad))v[_]=`var(${Id(_)}, ${k.value})`;return v}function Dd(){return["/* stx shape tokens \u2014 a radius by what the thing is. */",":root {",...Object.entries(Ad).map(([v,_])=>` ${Id(v)}: ${_.value};`),"}",""].join(`
|
|
859
|
+
`)}function Md(v){return typeof v==="object"&&v!==null&&!Array.isArray(v)}function Ma(v,_){let k={...v};for(let[E,T]of Object.entries(_))k[E]=Md(T)&&Md(k[E])?Ma(k[E],T):T;return k}function Od(v,_){if(!_.fonts)return"";let k=new v({..._.config,fonts:_.fonts,cssVariables:!1}).toCSS(!1,_.minify);return k&&!_.minify?`${k}
|
|
860
|
+
`:k}function Nd(v={},_={}){let k=v.theme||{},E=_.theme||{},{extend:T,...j}=E,{extend:B,...z}=k,F=z.colors||{};z.colors={...F,...Rd(F)};let V=z.borderRadius||{};z.borderRadius={...V,...Pd()};let H=Ma(z,j),G=Ma(B||{},T||{});if(Object.keys(G).length>0)H.extend=G;let J=[...v.safelist||[],..._.safelist||[]],ne={...v.shortcuts||{},..._.shortcuts||{}},re=[...v.preflights||[],..._.preflights||[]],{fonts:se,...ie}=v,{fonts:oe,...ge}=_,ue=oe??se;return{config:{...ie,...ge,theme:H,safelist:J,shortcuts:ne,...re.length>0?{preflights:re}:{},content:[],output:""},safelist:J,shortcuts:ne,includePreflight:_.preflight!==!1,minify:_.minify===!0,tokenCSS:Td(F)+Dd(),...ue?{fonts:ue}:{}}}function jd(v,_=""){let k=`${v}${_}`,E=0;for(let T=0;T<k.length;T++){let j=k.charCodeAt(T);E=(E<<5)-E+j,E=E&E}return`stx-${Math.abs(E).toString(36)}`}function Ld(v,_,k={}){let{prefix:E="",preserveHost:T=!0,scopeKeyframes:j=!0,scopeCustomProperties:B=!1}=k;if(!v.trim())return"";let z=Oa(v),F=[],V=new Map;if(j)for(let H of z){let G=H.selector.match(/@keyframes\s+([a-z_-][a-z0-9_-]*)/i);if(G){let J=G[1],ne=`${_}_${J}`;V.set(J,ne)}}for(let H of z){let G=Bd(H,_,E,T,V,B);F.push(G)}return F.join(`
|
|
861
|
+
|
|
862
|
+
`)}function Oa(v){let _=[],k=v.replace(/\/\*[\s\S]*?\*\//g,""),E=0,T="",j=!1,B="";for(let z=0;z<k.length;z++){let F=k[z];if(F==="@"&&E===0)j=!0;if(F==="{")E++;else if(F==="}"){if(E--,E===0){if(j){B+=F;let V=B.match(/@([a-z-]+)\s*([^{]*)\{([\s\S]*)\}/i);if(V){let[,H,G,J]=V;if(H==="keyframes")_.push({selector:`@keyframes ${G.trim()}`,declarations:J.trim()});else if(H==="media"||H==="supports"||H==="container"){let ne=Oa(J);_.push({selector:`@${H} ${G.trim()}`,declarations:ne.map((re)=>`${re.selector} { ${re.declarations} }`).join(`
|
|
863
|
+
`)})}else _.push({selector:`@${H} ${G.trim()}`,declarations:J.trim()})}B="",j=!1}else if(T.trim()){T+=F;let V=T.match(/([^{]+)\{([^}]*)\}/);if(V)_.push({selector:V[1].trim(),declarations:V[2].trim()});T=""}continue}}if(j)B+=F;else T+=F}return _}function Bd(v,_,k,E,T,j){let{selector:B,declarations:z}=v;if(B.startsWith("@")){if(B.startsWith("@keyframes")){let H=B.replace("@keyframes ","").trim();return`@keyframes ${T.get(H)||H} { ${z} }`}if(B.startsWith("@media")||B.startsWith("@supports")||B.startsWith("@container")){let G=Oa(`x { ${z} }`.replace(/x \{ /,"").replace(/ \}$/,"")).map((J)=>Bd(J,_,k,E,T,j)).join(`
|
|
864
|
+
`);return`${B} {
|
|
865
|
+
${G}
|
|
866
|
+
}`}return`${B} { ${z} }`}let F=yy(B,_,k,E),V=z;for(let[H,G]of T)V=V.replace(new RegExp(`\\b${H}\\b`,"g"),G);if(j)V=V.replace(/--([a-z-]+)/gi,`--${_}-$1`);return`${F} { ${V} }`}function yy(v,_,k,E){let T=v.split(",").map((B)=>B.trim()),j=[];for(let B of T){if(B.startsWith(":host")){if(E)j.push(B);else{let V=B.replace(/:host(\([^)]*\))?/,`.${_}$1`);j.push(V)}continue}if(B.includes("::slotted")){j.push(B);continue}if(B===":root"){j.push(`:root .${_}`);continue}let z=k?`${k} .${_}`:`.${_}`;j.push(`${z} ${B}`);let F=xy(B,_);if(F)j.push(k?`${k} ${F}`:F)}return j.join(", ")}function xy(v,_){let k=0,E=v.length;for(let F=0;F<v.length;F++){let V=v[F];if(V==="["||V==="(")k++;else if(V==="]"||V===")")k--;else if(k===0&&(V===" "||V===">"||V==="+"||V==="~")){E=F;break}}let T=v.slice(0,E),j=v.slice(E);if(!T)return"";let B=T.length,z=0;for(let F=0;F<T.length;F++){let V=T[F];if(V==="["||V==="(")z++;else if(V==="]"||V===")")z--;else if(k===0&&z===0&&V===":"){B=F;break}}return`${T.slice(0,B)}.${_}${T.slice(B)}${j}`}var Wd=String.raw`(?<![\w-])scoped(?![\w-])`,Na=/<style\s+([^>]*)>/gi,zd=/<style\s+([^>]*)>([\s\S]*?)<\/style>/gi,Vd=new RegExp(Wd,"i"),by=new RegExp(Wd,"gi"),ja=/<style\b[^>]*\bdata-stx-scoped(?:=(?:"[^"]*"|'[^']*'|[^\s>]+))?[^>]*>[\s\S]*?<\/style>\s*/gi;function vy(v){Na.lastIndex=0;let _=Na.exec(v);while(_!==null){if(Vd.test(_[1]))return!0;_=Na.exec(v)}return!1}function La(v){let _=new Set,k=[];ja.lastIndex=0;let E=ja.exec(v);while(E!==null){let T=E[0].trim();if(_.has(T))k.push({start:E.index,end:E.index+E[0].length});else _.add(T);E=ja.exec(v)}return k}function Xs(v){let _=La(v);if(_.length===0)return v;let k=Array(_.length+1),E=0;for(let T=0;T<_.length;T++){let j=_[T];k[T]=v.slice(E,j.start),E=j.end}return k[_.length]=v.slice(E),k.join("")}function Yi(v,_){if(!vy(v))return{html:v,hasScoped:!1};let k=jd(_),E=`data-v-${k}`,T=v,j=!1;if(zd.lastIndex=0,T=T.replace(zd,(B,z,F)=>{if(!Vd.test(z))return B;j=!0;let V=wy(F,E),H=z.replace(by,"").trim(),G=H?` ${H}`:"";return`<style data-stx-scoped="${k}"${G}>${V}</style>`}),!j)return{html:v,hasScoped:!1};return T=$y(T,E),{html:T,hasScoped:!0}}function wy(v,_){return Ld(v,"__SCOPE_PLACEHOLDER__",{preserveHost:!1}).replace(/\.(__SCOPE_PLACEHOLDER__) /g,`[${_}] `).replace(/\.(__SCOPE_PLACEHOLDER__)/g,`[${_}]`)}var Sy=(v)=>`\x00stx-scope-mask-${v}\x00`,Fd=/\u0000stx-scope-mask-(\d+)\u0000/g;function $y(v,_){let k=En(v,(T,j)=>{let B=Y(T,j);return B>j?B:Ur(T,j)},(T,j)=>Sy(j)),E=_y(k.output,_);return Fd.lastIndex=0,E.replace(Fd,(T,j)=>k.tokens[Number(j)])}function _y(v,_){let k=new Set(["script","style","template","html","head","body","meta","link","title","base","!doctype","!DOCTYPE"]);return v.replace(/<([a-zA-Z][a-zA-Z0-9-]*)(\s[^>]*)?\/?>/g,(E,T,j)=>{if(k.has(T.toLowerCase()))return E;if(E.includes(_))return E;if(T.toLowerCase()==="style"||T.toLowerCase()==="script")return E;if(j)return E.replace(`<${T}${j}`,`<${T} ${_}${j}`);if(E.endsWith("/>"))return`<${T} ${_} />`;return`<${T} ${_}>`})}var e={reset:"\x1B[0m",bright:"\x1B[1m",dim:"\x1B[2m",underscore:"\x1B[4m",blink:"\x1B[5m",reverse:"\x1B[7m",hidden:"\x1B[8m",black:"\x1B[30m",red:"\x1B[31m",green:"\x1B[32m",yellow:"\x1B[33m",blue:"\x1B[34m",magenta:"\x1B[35m",cyan:"\x1B[36m",white:"\x1B[37m",gray:"\x1B[90m",bgBlack:"\x1B[40m",bgRed:"\x1B[41m",bgGreen:"\x1B[42m",bgYellow:"\x1B[43m",bgBlue:"\x1B[44m",bgMagenta:"\x1B[45m",bgCyan:"\x1B[46m",bgWhite:"\x1B[47m",bgGray:"\x1B[100m"};var Rn=null,za=!1,Rr=null,Zs="",xs=!1,Kd=256,gr=new Map,Tn=new Map,Qi=null,Xd=null,eo=new Map;function to(v){return Bun.hash(v).toString(16).padStart(16,"0").slice(0,16)}function Ba(v,_){if(gr.has(v))gr.delete(v);else if(gr.size>=Kd)gr.delete(gr.keys().next().value);gr.set(v,_)}function ky(v){let _=to(v);if(Tn.has(_))Tn.delete(_);else if(Tn.size>=Kd)Tn.delete(Tn.keys().next().value);return Tn.set(_,v),_}function Pu(v){let _=Tn.get(v);if(_===void 0)return;return Tn.delete(v),Tn.set(v,_),_}async function Ey(v,_=Qi){if(!_)return null;try{let k=Bun.file(It.join(_,`cw-${to(v)}.css`));if(!await k.exists())return null;return await k.text()}catch{return null}}async function Cy(v,_,k=Qi){if(!k)return;try{if(!fs.existsSync(k))fs.mkdirSync(k,{recursive:!0});await Bun.write(It.join(k,`cw-${to(v)}.css`),_)}catch{}}async function Hd(v){try{let _=await import(v);if(_&&_.CSSGenerator)return{CSSGenerator:_.CSSGenerator,config:_.config,build:_.build,defaultConfig:_.defaultConfig,extractClasses:_.extractClasses}}catch{}return null}var Ry=[["@stacksjs","ts-css","dist","engine","index.js"],["@stacksjs","ts-css","src","engine","index.ts"]],Ty=["@stacksjs/ts-css/engine","@stacksjs/ts-css/dist/engine/index.js"];function Ay(){let v=[],_=process.cwd();while(_!==It.dirname(_)){for(let k of["node_modules","pantry"])for(let E of Ry)v.push(It.join(_,k,...E));_=It.dirname(_)}return v}function Iy(){let v=[],_=process.env.HOME||process.env.USERPROFILE||"",k=[_&&It.join(_,"Code","Tools","ts-css"),_&&It.join(_,"Code","Tools","crosswind"),_&&It.join(_,"repos","stacks-org","ts-css"),_&&It.join(_,"repos","stacks-org","crosswind"),It.join(process.cwd(),"..","ts-css"),It.join(process.cwd(),"..","crosswind")].filter(Boolean);for(let E of k)v.push(It.join(E,"packages","toolkit","dist","engine","index.js")),v.push(It.join(E,"packages","toolkit","src","engine","index.ts"));if(_)v.push(It.join(_,"Code","Tools","stx","node_modules","@stacksjs","ts-css","dist","engine","index.js"));return v}async function Vo(){if(za)return Rn;za=!0;try{let v=async(T)=>{for(let j of T){if(!await Bun.file(j).exists())continue;let B=await Hd(j);if(B){if(!process.env.STACKS_DEV_QUIET)console.log(`${e.green}[ts-css]${e.reset} CSS engine loaded from ${It.dirname(It.dirname(j))}`);return B}}return null};if(process.env.CROSSWIND_SRC){let T=It.resolve(process.env.CROSSWIND_SRC),j=await v([T]);if(!j)throw Error(`CROSSWIND_SRC did not resolve to a Css module: ${T}`);return Rn=j,Rn}let _=await v(Ay());if(_)return Rn=_,Rn;let k=Ty;for(let T of k){let j=await Hd(T);if(j){if(Rn=j,!process.env.STACKS_DEV_QUIET)console.log(`${e.green}[ts-css]${e.reset} CSS engine loaded`);return Rn}}let E=await v(Iy());if(E)return Rn=E,Rn;throw Error("Css CSSGenerator not found in any location")}catch{return console.warn(`${e.yellow}[ts-css] CSS engine not available, Tailwind styles will not be generated${e.reset}`),console.warn(`${e.yellow}Run 'bun add @stacksjs/ts-css' to enable CSS generation${e.reset}`),null}}function Iu(){Fa.clear(),Rn=null,za=!1,Rr=null,Zs="",gr.clear(),Tn.clear(),Xd=null,eo.clear()}var qd=!1;async function Uo(v){try{let _=Ud({name:"css",cwd:v})?"css":Ud({name:"crosswind",cwd:v})?"crosswind":null;if(!_)return null;if(_==="crosswind"&&!process.env.STACKS_DEV_QUIET&&!qd)qd=!0,console.warn(`${e.yellow}[ts-css]${e.reset} Reading the CSS config from a \`crosswind\` file. Rename it to \`css\` (e.g. config/css.ts) \u2014 the old name is deprecated.`);let{loadConfigWithResult:k}=await import("bunfig"),E=await k({name:_,cwd:v,defaultConfig:{},checkEnv:!1,verbose:!1});if(!E?.path||!E.config||Object.keys(E.config).length===0)return null;let T=It.relative(v,E.path);if(!process.env.STACKS_DEV_QUIET)console.log(`${e.green}[ts-css]${e.reset} Loaded config from ${T||E.path}`);return E.config}catch(_){if(_ instanceof Error&&_.name==="ConfigNotFoundError")return null;return console.warn(`${e.yellow}[ts-css]${e.reset} Failed to load css config:`,_ instanceof Error?_.message:_),null}}async function Za(v){let _=null;try{let{loadStxConfig:k}=await import("./chunk-hjg3e338.js"),E=await k(v);if(E.css)if(typeof E.css==="string"){let T=It.isAbsolute(E.css)?E.css:It.resolve(v,E.css);if(await Bun.file(T).exists()){let j=await import(T);_=j.default||j,console.log(`${e.green}[ts-css]${e.reset} Loaded config from stx.config.ts \u2192 ${E.css}`)}}else{if(_={...E.css,content:E.css.content||[],preflight:E.css.preflight??!0,minify:E.css.minify??!1},E.css.config){let T=It.isAbsolute(E.css.config)?E.css.config:It.resolve(v,E.css.config);if(await Bun.file(T).exists()){let j=await import(T);_={...j.default||j,..._}}}console.log(`${e.green}[ts-css]${e.reset} Using inline CSS config from stx.config.ts`)}}catch{}return _||await Uo(v)}function Qa(v){try{let _=new WeakSet;return to(JSON.stringify(v??{},(k,E)=>{if(typeof E==="function")return`[fn]${String(E)}`;if(typeof E==="object"&&E!==null){if(_.has(E))return"[circular]";_.add(E)}return E})??"")}catch{return"unhashable"}}async function xt(v){if(xs)return Zs;xs=!0;try{let _=await Vo();if(!_||!_.build)return xs=!1,"";if(!Rr)Rr=await Uo(v);if(!Rr)return xs=!1,"";let k=_.defaultConfig?.theme||{},E=Rr.theme||{},T={..._.defaultConfig,...Rr,theme:{...k,...E,extend:{...k.extend||{},...E.extend||{}}}},j=performance.now(),B=await _.build(T),z=performance.now()-j;if(Zs=B.css,console.log(`${e.cyan}[ts-css]${e.reset} Built ${B.classes.size} classes in ${z.toFixed(1)}ms`),T.output){let F=It.isAbsolute(T.output)?T.output:It.join(v,T.output),V=It.dirname(F);if(!fs.existsSync(V))fs.mkdirSync(V,{recursive:!0});await Bun.write(F,B.css)}return xs=!1,B.css}catch(_){return console.error(`${e.red}[ts-css]${e.reset} Build error:`,_),xs=!1,Zs}}async function tn(v){Rr=null,await xt(v)}function Du(){return Zs}function ec(v){let _=new Set,k=/class\s*=\s*["']([^"']+)["']/gi,E=k.exec(v);while(E!==null){for(let B of E[1].split(/\s+/))if(B.trim())_.add(B.trim());E=k.exec(v)}let T=/(?:x-class|:class)\s*=\s*"([^"]+)"/gi,j=T.exec(v);while(j!==null){let B=j[1].match(/'([^']+)'/g);if(B){for(let z of B)for(let F of z.slice(1,-1).split(/\s+/))if(F.trim())_.add(F.trim())}j=T.exec(v)}return _}var Fa=m(64);async function tc(v,_){let k=()=>eo.get(_?It.resolve(_):process.cwd())?.fingerprint??null,E=Fa.get(h(v,_,k()));if(E!==void 0)return E;let T=await Py(v,_);if(T)Fa.set(h(v,_,k()),T);return T}function nc(v){let _=[];for(let k of v.matchAll(/\/_stx\/modules\.([0-9a-f]{16})\.js/g)){let E=Ho(k[1]);if(E)_.push(E)}return _.length?`${v}
|
|
867
|
+
${_.join(`
|
|
868
|
+
`)}`:v}async function Py(v,_){try{let k=await Vo();if(!k)return"";let E=nc(v),T=typeof k.extractClasses==="function"?k.extractClasses(E):ec(E);if(T.size===0)return"";let j=_?It.resolve(_):process.cwd(),B=a(j,"cache");if(!Qi)Qi=B;let z=eo.get(j);if(!z){let Ee=await Za(j);z={config:Ee,fingerprint:Qa(Ee)},eo.set(j,z),Xd=z.fingerprint}let F=[...T].sort().join(" "),V=`${z.fingerprint||"default"}::${F}`,H=gr.get(V);if(H!==void 0)return Ba(V,H),H;let G=await Ey(V,B);if(G!==null)return Ba(V,G),G;let J=k.defaultConfig||k.config,ne=z.config||{},re=Nd(J,ne),{safelist:se,includePreflight:ie,minify:oe,tokenCSS:ge}=re,ue=re.config,xe=new k.CSSGenerator(ue),we=ue.shortcuts||ne.shortcuts||{},$e=Object.keys(we).filter((Ee)=>T.has(Ee)||se.includes(Ee));for(let Ee of se)if(!we[Ee])xe.generate(Ee);for(let Ee of T)if(!we[Ee])xe.generate(Ee);let _e="";if($e.length>0){let Ee=new k.CSSGenerator(ue);for(let Te of $e)Ee.generate(Te);if(_e=Ee.toCSS(!1,oe),_e&&!_e.endsWith(`
|
|
869
|
+
`))_e+=`
|
|
870
|
+
`}let Ce=_e+xe.toCSS(ie,oe);return Ce=Od(k.CSSGenerator,re)+ge+Ce,Ba(V,Ce),Cy(V,Ce,B),Ce}catch(k){return console.warn("Failed to generate Css CSS:",k),""}}async function f(v,_,k=!1,E=!1){let T=await tc(v,_);if(!T)return E?Xs(v):v;let j=k?`<link data-css="generated" rel="stylesheet" href="/_stx/css.${ky(T)}.css">`:`<style data-css="generated">
|
|
871
|
+
${T}
|
|
872
|
+
</style>`;if(E)return Dy(v,j);let B=/(?:<style\b[^>]*\bdata-css=(?:"generated"|'generated')[^>]*>[\s\S]*?<\/style>|<link\b[^>]*\bdata-css=(?:"generated"|'generated')[^>]*>)/g;if(B.test(v)){let z=!1;return v.replace(B,()=>{if(z)return"";return z=!0,j})}if(v.includes("</head>"))return v.replace("</head>",`${j}
|
|
873
|
+
</head>`);if(v.includes("<body"))return v.replace(/<body([^>]*)>/,`<body$1>
|
|
874
|
+
${j}`);return j+v}function Dy(v,_){let k=La(v).map((F)=>({...F,replacement:""})),E=/(?:<style\b[^>]*\bdata-css=(?:"generated"|'generated')[^>]*>[\s\S]*?<\/style>|<link\b[^>]*\bdata-css=(?:"generated"|'generated')[^>]*>)/g,T=E.exec(v);if(T!==null){let F=!0;while(T!==null)k.push({start:T.index,end:T.index+T[0].length,replacement:F?_:""}),F=!1,T=E.exec(v)}else{let F=v.indexOf("</head>");if(F!==-1)k.push({start:F,end:F,replacement:`${_}
|
|
875
|
+
`});else{let V=v.match(/<body([^>]*)>/);if(V?.index!==void 0)k.push({start:V.index,end:V.index+V[0].length,replacement:`${V[0]}
|
|
876
|
+
${_}`});else k.push({start:0,end:0,replacement:_})}}k.sort((F,V)=>F.start-V.start||F.end-V.end);for(let F=1;F<k.length;F++)if(k[F].start<k[F-1].end)return My(Xs(v),_);let j=Array(k.length*2+1),B=0,z=0;for(let F of k)j[z++]=v.slice(B,F.start),j[z++]=F.replacement,B=F.end;return j[z]=v.slice(B),j.join("")}function My(v,_){let k=/(?:<style\b[^>]*\bdata-css=(?:"generated"|'generated')[^>]*>[\s\S]*?<\/style>|<link\b[^>]*\bdata-css=(?:"generated"|'generated')[^>]*>)/g;if(k.test(v)){let E=!1;return v.replace(k,()=>{if(E)return"";return E=!0,_})}if(v.includes("</head>"))return v.replace("</head>",`${_}
|
|
877
|
+
</head>`);if(v.includes("<body"))return v.replace(/<body([^>]*)>/,`<body$1>
|
|
878
|
+
${_}`);return _+v}var _c=[{open:/<!--/g,close:/-->/g},{open:/<script\b/gi,close:/<\/script\s*>/gi},{open:/<style\b/gi,close:/<\/style\s*>/gi}],Zd=/<body\b([^>]*)>/gi;function An(v){let _=0,k,E=_c.map(()=>{return});while(_<v.length){if(k===void 0||k!==null&&k.index<_)Zd.lastIndex=_,k=Zd.exec(v);if(!k)return null;let T=k.index,j=-1,B=null;for(let F=0;F<_c.length;F++){let V=_c[F],H=E[F];if(H===void 0||H!==null&&H.index<_)V.open.lastIndex=_,H=V.open.exec(v),E[F]=H;if(!H)continue;if(H.index<T&&(j===-1||H.index<j))j=H.index,B=V.close}if(j===-1||!B)return{index:T,tag:k[0],attrs:k[1]??""};B.lastIndex=j;let z=B.exec(v);if(!z)return null;_=z.index+z[0].length}return null}function ws(v,_){let k=An(v);if(!k)return v;return v.slice(0,k.index)+_(k.tag,k.attrs)+v.slice(k.index+k.tag.length)}var Gd=/<style\b[^>]*>/iy,Jd=/<\/style>/gi,Yd=/<script\b[^>]*>/iy,Qd=/<template(?=[\s>/])[^>]*>/iy,ef=/<\/template\s*>/iy;function Gs(v){let _=0,k=0,E=-1;while(_<v.length){let T=v.indexOf("<",_);if(T===-1)return-1;if(v.startsWith("<!--",T)){let F=v.indexOf("-->",T+4);_=F===-1?v.length:F+3;continue}Gd.lastIndex=T;let j=Gd.exec(v);if(j){Jd.lastIndex=T+j[0].length;let F=Jd.exec(v);_=F===null?v.length:F.index+8;continue}Qd.lastIndex=T;let B=Qd.exec(v);if(B){if(k===0)E=T;k++,_=T+B[0].length;continue}ef.lastIndex=T;let z=ef.exec(v);if(z){if(k>0)k--;_=T+z[0].length;continue}if(Yd.lastIndex=T,Yd.test(v))return k>0?E:T;_=T+1}return-1}function tf(){return`
|
|
879
|
+
// STX Lifecycle Runtime
|
|
880
|
+
(function() {
|
|
881
|
+
if (typeof window === 'undefined') return;
|
|
882
|
+
|
|
883
|
+
const instances = new Map();
|
|
884
|
+
let currentInstance = null;
|
|
885
|
+
let idCounter = 0;
|
|
886
|
+
|
|
887
|
+
function generateId() {
|
|
888
|
+
return 'stx-' + (++idCounter) + '-' + Date.now().toString(36);
|
|
889
|
+
}
|
|
890
|
+
|
|
891
|
+
function createInstance(element) {
|
|
892
|
+
const instance = {
|
|
893
|
+
id: generateId(),
|
|
894
|
+
element: element,
|
|
895
|
+
mountHooks: [],
|
|
896
|
+
destroyHooks: [],
|
|
897
|
+
updateHooks: [],
|
|
898
|
+
refs: new Map(),
|
|
899
|
+
watchers: [],
|
|
900
|
+
isMounted: false
|
|
901
|
+
};
|
|
902
|
+
instances.set(instance.id, instance);
|
|
903
|
+
return instance;
|
|
904
|
+
}
|
|
905
|
+
|
|
906
|
+
window.STX = window.STX || {};
|
|
907
|
+
|
|
908
|
+
// Lifecycle hooks
|
|
909
|
+
window.STX.onMount = function(hook) {
|
|
910
|
+
if (currentInstance) currentInstance.mountHooks.push(hook);
|
|
911
|
+
};
|
|
912
|
+
|
|
913
|
+
window.STX.onDestroy = function(hook) {
|
|
914
|
+
if (currentInstance) currentInstance.destroyHooks.push(hook);
|
|
915
|
+
};
|
|
916
|
+
|
|
917
|
+
window.STX.onUpdate = function(hook) {
|
|
918
|
+
if (currentInstance) currentInstance.updateHooks.push(hook);
|
|
919
|
+
};
|
|
920
|
+
|
|
921
|
+
// Aliases
|
|
922
|
+
window.STX.onMounted = window.STX.onMount;
|
|
923
|
+
window.STX.onUnmounted = window.STX.onDestroy;
|
|
924
|
+
window.STX.onUpdated = window.STX.onUpdate;
|
|
925
|
+
|
|
926
|
+
// Refs
|
|
927
|
+
window.STX.ref = function(initialValue) {
|
|
928
|
+
const r = { value: initialValue || null };
|
|
929
|
+
Object.defineProperty(r, 'current', {
|
|
930
|
+
get: function() { return this.value; }
|
|
931
|
+
});
|
|
932
|
+
if (currentInstance) {
|
|
933
|
+
currentInstance.refs.set('ref-' + currentInstance.refs.size, r);
|
|
934
|
+
}
|
|
935
|
+
return r;
|
|
936
|
+
};
|
|
937
|
+
|
|
938
|
+
// Watch
|
|
939
|
+
window.STX.watch = function(source, callback, options) {
|
|
940
|
+
options = options || {};
|
|
941
|
+
let oldValue;
|
|
942
|
+
let cleanup;
|
|
943
|
+
let isActive = true;
|
|
944
|
+
|
|
945
|
+
function run() {
|
|
946
|
+
if (!isActive) return;
|
|
947
|
+
const newValue = source();
|
|
948
|
+
if (oldValue !== newValue || options.immediate) {
|
|
949
|
+
if (cleanup) cleanup();
|
|
950
|
+
cleanup = callback(newValue, oldValue);
|
|
951
|
+
oldValue = newValue;
|
|
952
|
+
}
|
|
953
|
+
}
|
|
954
|
+
|
|
955
|
+
if (options.immediate) {
|
|
956
|
+
run();
|
|
957
|
+
}
|
|
958
|
+
else {
|
|
959
|
+
oldValue = source();
|
|
960
|
+
}
|
|
961
|
+
|
|
962
|
+
const intervalId = setInterval(run, 16);
|
|
963
|
+
|
|
964
|
+
function stop() {
|
|
965
|
+
isActive = false;
|
|
966
|
+
clearInterval(intervalId);
|
|
967
|
+
if (cleanup) cleanup();
|
|
968
|
+
}
|
|
969
|
+
|
|
970
|
+
if (currentInstance) {
|
|
971
|
+
currentInstance.watchers.push({ stop: stop });
|
|
972
|
+
currentInstance.destroyHooks.push(stop);
|
|
973
|
+
}
|
|
974
|
+
|
|
975
|
+
return stop;
|
|
976
|
+
};
|
|
977
|
+
|
|
978
|
+
// Computed
|
|
979
|
+
window.STX.computed = function(getter) {
|
|
980
|
+
let cached;
|
|
981
|
+
let dirty = true;
|
|
982
|
+
return {
|
|
983
|
+
get value() {
|
|
984
|
+
if (dirty) {
|
|
985
|
+
cached = getter();
|
|
986
|
+
dirty = false;
|
|
987
|
+
queueMicrotask(function() { dirty = true; });
|
|
988
|
+
}
|
|
989
|
+
return cached;
|
|
990
|
+
}
|
|
991
|
+
};
|
|
992
|
+
};
|
|
993
|
+
|
|
994
|
+
// Component management
|
|
995
|
+
window.STX.setupComponent = function(element, setup) {
|
|
996
|
+
const instance = createInstance(element);
|
|
997
|
+
currentInstance = instance;
|
|
998
|
+
try {
|
|
999
|
+
setup();
|
|
1000
|
+
}
|
|
1001
|
+
finally {
|
|
1002
|
+
currentInstance = null;
|
|
1003
|
+
}
|
|
1004
|
+
return instance;
|
|
1005
|
+
};
|
|
1006
|
+
|
|
1007
|
+
window.STX.mountComponent = function(instance) {
|
|
1008
|
+
if (instance.isMounted) return;
|
|
1009
|
+
instance.isMounted = true;
|
|
1010
|
+
instance.mountHooks.forEach(function(hook) {
|
|
1011
|
+
try {
|
|
1012
|
+
const cleanup = hook();
|
|
1013
|
+
if (typeof cleanup === 'function') {
|
|
1014
|
+
instance.destroyHooks.push(cleanup);
|
|
1015
|
+
}
|
|
1016
|
+
else if (cleanup && typeof cleanup.then === 'function') {
|
|
1017
|
+
cleanup.catch(function(e) { console.error('[stx] onMount error:', e); });
|
|
1018
|
+
}
|
|
1019
|
+
}
|
|
1020
|
+
catch (e) {
|
|
1021
|
+
console.error('[stx] onMount error:', e);
|
|
1022
|
+
}
|
|
1023
|
+
});
|
|
1024
|
+
};
|
|
1025
|
+
|
|
1026
|
+
window.STX.destroyComponent = function(instance) {
|
|
1027
|
+
if (!instance.isMounted) return;
|
|
1028
|
+
instance.watchers.forEach(function(w) { w.stop(); });
|
|
1029
|
+
instance.destroyHooks.forEach(function(hook) {
|
|
1030
|
+
try { hook(); }
|
|
1031
|
+
catch (e) { console.error('[stx] onDestroy error:', e); }
|
|
1032
|
+
});
|
|
1033
|
+
instance.refs.forEach(function(ref) { ref.value = null; });
|
|
1034
|
+
instance.isMounted = false;
|
|
1035
|
+
instances.delete(instance.id);
|
|
1036
|
+
};
|
|
1037
|
+
|
|
1038
|
+
// ==========================================================================
|
|
1039
|
+
// Vue-Style Refs System - No document.** required!
|
|
1040
|
+
// ==========================================================================
|
|
1041
|
+
|
|
1042
|
+
// Internal: Query for ref elements without exposing document API
|
|
1043
|
+
function queryRef(name, root) {
|
|
1044
|
+
return (root || document).querySelector('[data-stx-ref="' + name + '"], [data-ref="' + name + '"]');
|
|
1045
|
+
}
|
|
1046
|
+
|
|
1047
|
+
function queryAllRefs(root) {
|
|
1048
|
+
return (root || document).querySelectorAll('[data-stx-ref], [data-ref]');
|
|
1049
|
+
}
|
|
1050
|
+
|
|
1051
|
+
// Auto-bind refs from ref attributes (Vue-style)
|
|
1052
|
+
window.STX.bindRefs = function(root, refs) {
|
|
1053
|
+
if (!root) return;
|
|
1054
|
+
queryAllRefs(root).forEach(function(el) {
|
|
1055
|
+
var refName = el.getAttribute('data-stx-ref') || el.getAttribute('data-ref');
|
|
1056
|
+
if (refs[refName]) {
|
|
1057
|
+
refs[refName].value = el;
|
|
1058
|
+
}
|
|
1059
|
+
});
|
|
1060
|
+
};
|
|
1061
|
+
|
|
1062
|
+
// Vue-style useRefs() - returns object with all refs as direct elements
|
|
1063
|
+
// Usage: const { input, button, container } = STX.useRefs()
|
|
1064
|
+
window.STX.useRefs = function(root) {
|
|
1065
|
+
var refs = {};
|
|
1066
|
+
queryAllRefs(root).forEach(function(el) {
|
|
1067
|
+
var refName = el.getAttribute('data-stx-ref') || el.getAttribute('data-ref');
|
|
1068
|
+
if (refName) {
|
|
1069
|
+
refs[refName] = el;
|
|
1070
|
+
}
|
|
1071
|
+
});
|
|
1072
|
+
return refs;
|
|
1073
|
+
};
|
|
1074
|
+
|
|
1075
|
+
// Get a single ref by name - Vue's useTemplateRef equivalent
|
|
1076
|
+
// Usage: const input = STX.useRef('input')
|
|
1077
|
+
window.STX.useRef = function(name, root) {
|
|
1078
|
+
return queryRef(name, root);
|
|
1079
|
+
};
|
|
1080
|
+
|
|
1081
|
+
// Two-way binding helper for form elements
|
|
1082
|
+
// Usage: STX.model(inputEl, state, 'username')
|
|
1083
|
+
window.STX.model = function(el, state, key) {
|
|
1084
|
+
if (!el || !state) return;
|
|
1085
|
+
|
|
1086
|
+
var isCheckbox = el.type === 'checkbox';
|
|
1087
|
+
var isRadio = el.type === 'radio';
|
|
1088
|
+
var isSelect = el.tagName === 'SELECT';
|
|
1089
|
+
|
|
1090
|
+
// Set initial value
|
|
1091
|
+
if (isCheckbox) {
|
|
1092
|
+
el.checked = !!state[key];
|
|
1093
|
+
}
|
|
1094
|
+
else if (isRadio) {
|
|
1095
|
+
el.checked = el.value === state[key];
|
|
1096
|
+
}
|
|
1097
|
+
else {
|
|
1098
|
+
el.value = state[key] || '';
|
|
1099
|
+
}
|
|
1100
|
+
|
|
1101
|
+
// Listen for changes
|
|
1102
|
+
var eventType = isCheckbox || isRadio ? 'change' : 'input';
|
|
1103
|
+
el.addEventListener(eventType, function() {
|
|
1104
|
+
if (isCheckbox) {
|
|
1105
|
+
state[key] = el.checked;
|
|
1106
|
+
}
|
|
1107
|
+
else if (isRadio) {
|
|
1108
|
+
if (el.checked) state[key] = el.value;
|
|
1109
|
+
}
|
|
1110
|
+
else {
|
|
1111
|
+
state[key] = el.value;
|
|
1112
|
+
}
|
|
1113
|
+
});
|
|
1114
|
+
|
|
1115
|
+
// Return cleanup function
|
|
1116
|
+
return function() {
|
|
1117
|
+
el.removeEventListener(eventType, arguments.callee);
|
|
1118
|
+
};
|
|
1119
|
+
};
|
|
1120
|
+
|
|
1121
|
+
// Batch event binding helper - cleaner than manual addEventListener
|
|
1122
|
+
// Usage: STX.on({ click: [btn1, btn2], input: [textField] }, handler)
|
|
1123
|
+
window.STX.on = function(el, event, handler) {
|
|
1124
|
+
if (!el) return function() {};
|
|
1125
|
+
el.addEventListener(event, handler);
|
|
1126
|
+
return function() { el.removeEventListener(event, handler); };
|
|
1127
|
+
};
|
|
1128
|
+
|
|
1129
|
+
// Bind multiple events at once
|
|
1130
|
+
// Usage: STX.events(refs.btn, { click: handleClick, mouseenter: handleHover })
|
|
1131
|
+
window.STX.events = function(el, eventMap) {
|
|
1132
|
+
if (!el) return function() {};
|
|
1133
|
+
var cleanups = [];
|
|
1134
|
+
Object.keys(eventMap).forEach(function(event) {
|
|
1135
|
+
el.addEventListener(event, eventMap[event]);
|
|
1136
|
+
cleanups.push(function() { el.removeEventListener(event, eventMap[event]); });
|
|
1137
|
+
});
|
|
1138
|
+
return function() { cleanups.forEach(function(c) { c(); }); };
|
|
1139
|
+
};
|
|
1140
|
+
|
|
1141
|
+
// ==========================================================================
|
|
1142
|
+
// DOM Helpers - Eliminate document.* usage
|
|
1143
|
+
// ==========================================================================
|
|
1144
|
+
|
|
1145
|
+
// Global keyboard event listener
|
|
1146
|
+
// Usage: STX.onKey('Escape', () => closeModal())
|
|
1147
|
+
window.STX.onKey = function(key, handler, options) {
|
|
1148
|
+
var listener = function(e) {
|
|
1149
|
+
if (e.key === key) {
|
|
1150
|
+
handler(e);
|
|
1151
|
+
}
|
|
1152
|
+
};
|
|
1153
|
+
document.addEventListener('keydown', listener, options);
|
|
1154
|
+
return function() { document.removeEventListener('keydown', listener, options); };
|
|
1155
|
+
};
|
|
1156
|
+
|
|
1157
|
+
// Create element helper
|
|
1158
|
+
// Usage: STX.el('div', { class: 'foo' }, 'text content')
|
|
1159
|
+
window.STX.el = function(tag, attrs, content) {
|
|
1160
|
+
var el = document.createElement(tag);
|
|
1161
|
+
if (attrs) {
|
|
1162
|
+
Object.keys(attrs).forEach(function(key) {
|
|
1163
|
+
if (key === 'class') {
|
|
1164
|
+
el.className = attrs[key];
|
|
1165
|
+
}
|
|
1166
|
+
else if (key.startsWith('on')) {
|
|
1167
|
+
el.addEventListener(key.slice(2).toLowerCase(), attrs[key]);
|
|
1168
|
+
}
|
|
1169
|
+
else {
|
|
1170
|
+
el.setAttribute(key, attrs[key]);
|
|
1171
|
+
}
|
|
1172
|
+
});
|
|
1173
|
+
}
|
|
1174
|
+
if (content) {
|
|
1175
|
+
if (typeof content === 'string') {
|
|
1176
|
+
el.textContent = content;
|
|
1177
|
+
}
|
|
1178
|
+
else if (Array.isArray(content)) {
|
|
1179
|
+
content.forEach(function(child) { el.appendChild(child); });
|
|
1180
|
+
}
|
|
1181
|
+
else {
|
|
1182
|
+
el.appendChild(content);
|
|
1183
|
+
}
|
|
1184
|
+
}
|
|
1185
|
+
return el;
|
|
1186
|
+
};
|
|
1187
|
+
|
|
1188
|
+
// Get currently focused element
|
|
1189
|
+
// Usage: const focused = STX.activeElement()
|
|
1190
|
+
window.STX.activeElement = function() {
|
|
1191
|
+
return document.activeElement;
|
|
1192
|
+
};
|
|
1193
|
+
|
|
1194
|
+
// Escape HTML helper
|
|
1195
|
+
// Usage: const safe = STX.escapeHtml(userInput)
|
|
1196
|
+
window.STX.escapeHtml = function(text) {
|
|
1197
|
+
var div = document.createElement('div');
|
|
1198
|
+
div.textContent = text;
|
|
1199
|
+
return div.innerHTML;
|
|
1200
|
+
};
|
|
1201
|
+
|
|
1202
|
+
// MutationObserver for automatic lifecycle management
|
|
1203
|
+
const observer = new MutationObserver(function(mutations) {
|
|
1204
|
+
mutations.forEach(function(mutation) {
|
|
1205
|
+
// Handle removed nodes
|
|
1206
|
+
mutation.removedNodes.forEach(function(node) {
|
|
1207
|
+
if (node.nodeType === 1 && node.__stx_instance__) {
|
|
1208
|
+
window.STX.destroyComponent(node.__stx_instance__);
|
|
1209
|
+
}
|
|
1210
|
+
});
|
|
1211
|
+
});
|
|
1212
|
+
});
|
|
1213
|
+
|
|
1214
|
+
// Start observing when DOM is ready
|
|
1215
|
+
if (document.readyState === 'loading') {
|
|
1216
|
+
document.addEventListener('DOMContentLoaded', function() {
|
|
1217
|
+
observer.observe(document.body, { childList: true, subtree: true });
|
|
1218
|
+
});
|
|
1219
|
+
}
|
|
1220
|
+
else {
|
|
1221
|
+
observer.observe(document.body, { childList: true, subtree: true });
|
|
1222
|
+
}
|
|
1223
|
+
|
|
1224
|
+
console.log('[stx] Lifecycle runtime initialized');
|
|
1225
|
+
})();
|
|
1226
|
+
`}function Ec(v){return Symbol(v)}var J$=Ec("theme"),Y$=Ec("router"),Q$=Ec("i18n");import*as rf from"crypto";function nf(v){let _=/\$(\w+)\./g,k=[],E;while((E=_.exec(v))!==null)if(!k.includes(E[1]))k.push(E[1]);return k}function Oy(){return`stx-${rf.randomBytes(4).toString("hex")}`}function Ny(v){return/\$\w+\./.test(v)}function jy(v){if(!v.includes("{{")||!/\$\w+\./.test(v))return{html:v,bindings:[],stores:new Set};let _=[],k=new Set,E=/<(\w+)([^>]*?)(\s*\/?>)/g,T=v;return T=T.replace(E,(j,B,z,F)=>{if(["script","style","template"].includes(B.toLowerCase()))return j;let V=[],H=!1,G=z,J=/(\w+(?:-\w+)*)\s*=\s*"([^"]*\{\{[^}]*\$\w+[^}]*\}\}[^"]*)"/g,ne=[...z.matchAll(J)];for(let ie of ne){let oe=ie[0],ge=ie[1],ue=ie[2];if(Ny(ue)){H=!0;let xe=ue.match(/\{\{\s*([\s\S]+?)\s*\}\}/);if(xe){let we=xe[1];if(V.push({attr:ge,expr:we,fullMatch:oe,originalAttr:ge}),nf(we).forEach((_e)=>k.add(_e)),ge==="text")G=G.replace(oe,"");else if(ge==="class")G=G.replace(oe,'class=""');else if(ge==="disabled"||ge==="hidden")G=G.replace(oe,"");else G=G.replace(oe,`${ge}=""`)}}}if(!H)return j;let re=G.match(/\bid\s*=\s*"([^"]+)"/),se;if(re)se=re[1];else se=Oy(),G=` id="${se}"${G}`;for(let ie of V)_.push({elementId:se,attribute:ie.attr,expression:ie.expr,stores:nf(ie.expr)});return`<${B}${G}${F}`}),{html:T,bindings:_,stores:k}}function Ly(v,_){if(v.length===0)return"";let k=Array.from(_),E=`
|
|
1227
|
+
<script>
|
|
1228
|
+
(function() {
|
|
1229
|
+
'use strict';
|
|
1230
|
+
|
|
1231
|
+
// Wait for stores to be available
|
|
1232
|
+
function initBindings() {
|
|
1233
|
+
var stores = window.VoideStores;
|
|
1234
|
+
if (!stores) {
|
|
1235
|
+
setTimeout(initBindings, 10);
|
|
1236
|
+
return;
|
|
1237
|
+
}
|
|
1238
|
+
|
|
1239
|
+
// Store references for expressions
|
|
1240
|
+
// eslint-disable-next-line pickier/no-unused-vars
|
|
1241
|
+
var $state = {};
|
|
1242
|
+
`;for(let T of k)E+=` $state.${T} = stores.${T} ? stores.${T}.get() : {};
|
|
1243
|
+
`;E+=`
|
|
1244
|
+
// Binding update functions
|
|
1245
|
+
function updateBindings() {
|
|
1246
|
+
`;for(let T of v){let{elementId:j,attribute:B,expression:z}=T,F=z.replace(/\$(\w+)\./g,"$state.$1.");if(B==="text")E+=` (function() {
|
|
1247
|
+
var el = document.getElementById('${j}');
|
|
1248
|
+
if (el) {
|
|
1249
|
+
try {
|
|
1250
|
+
el.textContent = ${F};
|
|
1251
|
+
}
|
|
1252
|
+
catch (e) { console.error('Binding error:', e); }
|
|
1253
|
+
}
|
|
1254
|
+
})();
|
|
1255
|
+
`;else if(B==="html")E+=` (function() {
|
|
1256
|
+
var el = document.getElementById('${j}');
|
|
1257
|
+
if (el) {
|
|
1258
|
+
try {
|
|
1259
|
+
el.innerHTML = ${F};
|
|
1260
|
+
}
|
|
1261
|
+
catch (e) { console.error('Binding error:', e); }
|
|
1262
|
+
}
|
|
1263
|
+
})();
|
|
1264
|
+
`;else if(B==="class")E+=` (function() {
|
|
1265
|
+
var el = document.getElementById('${j}');
|
|
1266
|
+
if (el) {
|
|
1267
|
+
try {
|
|
1268
|
+
var value = ${F};
|
|
1269
|
+
if (typeof value === 'string') {
|
|
1270
|
+
// Dynamic class string - merge with existing static classes
|
|
1271
|
+
// eslint-disable-next-line pickier/no-unused-vars
|
|
1272
|
+
var staticClasses = el.getAttribute('data-static-class') || el.className;
|
|
1273
|
+
if (!el.hasAttribute('data-static-class')) {
|
|
1274
|
+
el.setAttribute('data-static-class', el.className);
|
|
1275
|
+
}
|
|
1276
|
+
el.className = (el.getAttribute('data-static-class') + ' ' + value).trim();
|
|
1277
|
+
}
|
|
1278
|
+
else if (typeof value === 'object') {
|
|
1279
|
+
// Object syntax: { 'class-name': condition }
|
|
1280
|
+
for (var cls in value) {
|
|
1281
|
+
if (value[cls]) {
|
|
1282
|
+
el.classList.add(cls);
|
|
1283
|
+
}
|
|
1284
|
+
else {
|
|
1285
|
+
el.classList.remove(cls);
|
|
1286
|
+
}
|
|
1287
|
+
}
|
|
1288
|
+
}
|
|
1289
|
+
}
|
|
1290
|
+
catch (e) { console.error('Binding error:', e); }
|
|
1291
|
+
}
|
|
1292
|
+
})();
|
|
1293
|
+
`;else if(B==="show")E+=` (function() {
|
|
1294
|
+
var el = document.getElementById('${j}');
|
|
1295
|
+
if (el) {
|
|
1296
|
+
try {
|
|
1297
|
+
el.style.display = (${F}) ? '' : 'none';
|
|
1298
|
+
}
|
|
1299
|
+
catch (e) { console.error('Binding error:', e); }
|
|
1300
|
+
}
|
|
1301
|
+
})();
|
|
1302
|
+
`;else if(B==="if")E+=` (function() {
|
|
1303
|
+
var el = document.getElementById('${j}');
|
|
1304
|
+
if (el) {
|
|
1305
|
+
try {
|
|
1306
|
+
el.style.visibility = (${F}) ? 'visible' : 'hidden';
|
|
1307
|
+
}
|
|
1308
|
+
catch (e) { console.error('Binding error:', e); }
|
|
1309
|
+
}
|
|
1310
|
+
})();
|
|
1311
|
+
`;else E+=` (function() {
|
|
1312
|
+
var el = document.getElementById('${j}');
|
|
1313
|
+
if (el) {
|
|
1314
|
+
try {
|
|
1315
|
+
var value = ${F};
|
|
1316
|
+
if (value === false || value === null || value === undefined) {
|
|
1317
|
+
el.removeAttribute('${B}');
|
|
1318
|
+
}
|
|
1319
|
+
else if (value === true) {
|
|
1320
|
+
el.setAttribute('${B}', '');
|
|
1321
|
+
}
|
|
1322
|
+
else {
|
|
1323
|
+
el.setAttribute('${B}', value);
|
|
1324
|
+
}
|
|
1325
|
+
}
|
|
1326
|
+
catch (e) { console.error('Binding error:', e); }
|
|
1327
|
+
}
|
|
1328
|
+
})();
|
|
1329
|
+
`}E+=` }
|
|
1330
|
+
|
|
1331
|
+
// Subscribe to stores and update on changes. Capture the disposers so
|
|
1332
|
+
// SPA fragment swaps can tear down old bindings before the next page's
|
|
1333
|
+
// runtime takes over \u2014 without this, every navigation between pages
|
|
1334
|
+
// using reactive-bindings stacked another subscription on every store,
|
|
1335
|
+
// walking detached DOM forever. See stacksjs/stx#1709.
|
|
1336
|
+
var _disposers = [];
|
|
1337
|
+
`;for(let T of k)E+=` if (stores.${T}) {
|
|
1338
|
+
var _unsub_${T} = stores.${T}.subscribe(function(state) {
|
|
1339
|
+
$state.${T} = state;
|
|
1340
|
+
updateBindings();
|
|
1341
|
+
});
|
|
1342
|
+
// store.subscribe() may return the disposer (preferred) or void; both
|
|
1343
|
+
// are tolerated here.
|
|
1344
|
+
if (typeof _unsub_${T} === 'function') _disposers.push(_unsub_${T});
|
|
1345
|
+
}
|
|
1346
|
+
`;return E+=`
|
|
1347
|
+
// Initial update
|
|
1348
|
+
updateBindings();
|
|
1349
|
+
|
|
1350
|
+
// Register this runtime's cleanup so SPA navigation can run it before
|
|
1351
|
+
// swapping pages. The router (and any code) can call
|
|
1352
|
+
// window.__stxCleanupBindings() to dispose subscriptions; we also wire
|
|
1353
|
+
// 'popstate' and 'beforeunload' as a safety net for browser-driven nav.
|
|
1354
|
+
function _cleanup() {
|
|
1355
|
+
for (var i = 0; i < _disposers.length; i++) {
|
|
1356
|
+
try { _disposers[i](); } catch (e) { /* swallow */ }
|
|
1357
|
+
}
|
|
1358
|
+
_disposers.length = 0;
|
|
1359
|
+
}
|
|
1360
|
+
if (!window.__stxBindingsCleanups) window.__stxBindingsCleanups = [];
|
|
1361
|
+
window.__stxBindingsCleanups.push(_cleanup);
|
|
1362
|
+
if (!window.__stxCleanupBindings) {
|
|
1363
|
+
window.__stxCleanupBindings = function() {
|
|
1364
|
+
var fns = window.__stxBindingsCleanups || [];
|
|
1365
|
+
for (var i = 0; i < fns.length; i++) {
|
|
1366
|
+
try { fns[i](); } catch (e) { /* swallow */ }
|
|
1367
|
+
}
|
|
1368
|
+
window.__stxBindingsCleanups = [];
|
|
1369
|
+
};
|
|
1370
|
+
window.addEventListener('popstate', window.__stxCleanupBindings);
|
|
1371
|
+
window.addEventListener('beforeunload', window.__stxCleanupBindings);
|
|
1372
|
+
}
|
|
1373
|
+
}
|
|
1374
|
+
|
|
1375
|
+
// Start when DOM is ready
|
|
1376
|
+
if (document.readyState === 'loading') {
|
|
1377
|
+
document.addEventListener('DOMContentLoaded', initBindings);
|
|
1378
|
+
}
|
|
1379
|
+
else {
|
|
1380
|
+
initBindings();
|
|
1381
|
+
}
|
|
1382
|
+
})();
|
|
1383
|
+
</script>
|
|
1384
|
+
`,E}function sf(v){let{html:_,bindings:k,stores:E}=jy(v);if(k.length===0)return v;let T=Ly(k,E),j=_.lastIndexOf("</body>");if(j!==-1)return _.slice(0,j)+T+_.slice(j);return _+T}function By(v){let _=v.analytics;if(!_?.enabled)return"";switch(_.driver){case"fathom":return zy(_);case"google-analytics":return Fy(_);case"plausible":return Wy(_);case"self-hosted":return Vy(_);case"custom":return Uy(_);default:return""}}function zy(v){let _=v.fathom;if(!_?.siteId)return"";let k=_.scriptUrl||"https://cdn.usefathom.com/script.js",E=_.defer!==!1?" defer":"",T=[`data-site="${mn(_.siteId)}"`];if(_.honorDnt)T.push('data-honor-dnt="true"');if(_.spa)T.push('data-spa="auto"');if(_.canonical)T.push(`data-canonical="${mn(_.canonical)}"`);if(_.auto===!1)T.push('data-auto="false"');return`
|
|
1385
|
+
<!-- Fathom Analytics -->
|
|
1386
|
+
<script src="${mn(k)}" ${T.join(" ")}${E}></script>
|
|
1387
|
+
`}function Fy(v){let _=v.googleAnalytics;if(!_?.measurementId)return"";let k=mn(_.measurementId),E=_.debug?`gtag('config', '${k}', { 'debug_mode': true });`:"";return`
|
|
1388
|
+
<!-- Google Analytics -->
|
|
1389
|
+
<script async src="https://www.googletagmanager.com/gtag/js?id=${k}"></script>
|
|
1390
|
+
<script>
|
|
1391
|
+
window.dataLayer = window.dataLayer || [];
|
|
1392
|
+
function gtag(){dataLayer.push(arguments);}
|
|
1393
|
+
gtag('js', new Date());
|
|
1394
|
+
gtag('config', '${k}');
|
|
1395
|
+
${E}
|
|
1396
|
+
</script>
|
|
1397
|
+
`}function Wy(v){let _=v.plausible;if(!_?.domain)return"";let k=_.scriptUrl||"https://plausible.io/js/script.js",E=[`data-domain="${mn(_.domain)}"`],T=k,j=[];if(_.trackLocalhost)j.push("local");if(_.hashMode)j.push("hash");if(j.length>0&&k==="https://plausible.io/js/script.js")T=`https://plausible.io/js/script.${j.join(".")}.js`;return`
|
|
1398
|
+
<!-- Plausible Analytics -->
|
|
1399
|
+
<script defer data-domain="${mn(_.domain)}" src="${mn(T)}"></script>
|
|
1400
|
+
`}function Vy(v){let _=v.selfHosted;if(!_?.siteId||!_?.apiEndpoint)return"";let k=mn(_.siteId),E=mn(_.apiEndpoint),T=_.honorDnt?'if(n.doNotTrack==="1")return;':"",j=_.trackHashChanges?"w.addEventListener('hashchange',pv);":"",B=_.trackOutboundLinks?`
|
|
1401
|
+
d.addEventListener('click',function(e){
|
|
1402
|
+
var a=e.target.closest('a');
|
|
1403
|
+
if(a&&a.hostname!==location.hostname){
|
|
1404
|
+
t('outbound',{url:a.href});
|
|
1405
|
+
}
|
|
1406
|
+
});`:"";return`
|
|
1407
|
+
<!-- Self-Hosted Analytics -->
|
|
1408
|
+
<script data-site="${k}" data-api="${E}" defer>
|
|
1409
|
+
(function(){
|
|
1410
|
+
'use strict';
|
|
1411
|
+
var d=document,w=window,n=navigator,s=d.currentScript;
|
|
1412
|
+
var site=s.dataset.site,api=s.dataset.api;
|
|
1413
|
+
${T}
|
|
1414
|
+
var q=[],sid=Math.random().toString(36).slice(2);
|
|
1415
|
+
function t(e,p){
|
|
1416
|
+
var x=new XMLHttpRequest();
|
|
1417
|
+
x.open('POST',api+'/collect',true);
|
|
1418
|
+
x.setRequestHeader('Content-Type','application/json');
|
|
1419
|
+
x.send(JSON.stringify({
|
|
1420
|
+
s:site,sid:sid,e:e,p:p||{},
|
|
1421
|
+
u:location.href,r:d.referrer,t:d.title,
|
|
1422
|
+
sw:screen.width,sh:screen.height
|
|
1423
|
+
}));
|
|
1424
|
+
}
|
|
1425
|
+
function pv(){t('pageview');}
|
|
1426
|
+
${j}
|
|
1427
|
+
${B}
|
|
1428
|
+
if(d.readyState==='complete')pv();
|
|
1429
|
+
else w.addEventListener('load',pv);
|
|
1430
|
+
w.stxAnalytics={track:function(n,v){t('event',{name:n,value:v});}};
|
|
1431
|
+
})();
|
|
1432
|
+
</script>
|
|
1433
|
+
`}function Uy(v){let _=v.custom;if(!_)return"";if(_.inlineScript)return`
|
|
1434
|
+
<!-- Custom Analytics -->
|
|
1435
|
+
<script>
|
|
1436
|
+
${_.inlineScript}
|
|
1437
|
+
</script>
|
|
1438
|
+
`;if(!_.scriptUrl)return"";let k=[];if(_.scriptId)k.push(`id="${mn(_.scriptId)}"`);if(_.attributes)for(let[T,j]of Object.entries(_.attributes))k.push(`${mn(T)}="${mn(j)}"`);return`
|
|
1439
|
+
<!-- Custom Analytics -->
|
|
1440
|
+
<script${k.length>0?` ${k.join(" ")}`:""} src="${mn(_.scriptUrl)}" defer></script>
|
|
1441
|
+
`}function of(v,_){let k=By(_);if(!k)return v;if(!v.includes("</head>")){let E=v.lastIndexOf("</body>");if(E!==-1)return v.slice(0,E)+k+v.slice(E);return v+k}return v.replace("</head>",`${k}</head>`)}function mn(v){return v.replace(/&/g,"&").replace(/"/g,""").replace(/'/g,"'").replace(/</g,"<").replace(/>/g,">")}function je(v){let _=v.match(/\bdefinePageMeta\s*\(\s*(\{[\s\S]*?\})\s*\)/m);if(!_)return null;try{return Function(`return ${_[1]}`)()}catch{return null}}function af(v){let _=v?.layout;if(_===!1)return!1;return typeof _==="string"&&_.trim()?_.trim():void 0}var Hy=100,qy=599,Tc="__stxResponseStatus",Js="__stxResponseHeaders";function no(v){return typeof v==="number"&&Number.isInteger(v)&&v>=Hy&&v<=qy}function St(v){for(let _ of v.matchAll(/\bdefinePageMeta\s*\(\s*\{([\s\S]*?)\}\s*\)/g)){let k=_[1].match(/(?:^|,)\s*status\s*:\s*(\d{3})(?=\s*(?:,|$))/);if(!k)continue;let E=Number(k[1]);if(no(E))return E}return}function Rc(v,_){if(!v||typeof v!=="object")return!1;let k=typeof _==="string"&&/^\d+$/.test(_.trim())?Number(_.trim()):_;if(!no(k))return!1;return v[Tc]=k,!0}function Ky(v,_,k){if(!v||typeof v!=="object")return;let E=String(_??"").trim();if(!E)return;v[Js]={...v[Js],[E]:String(k)}}function Be(v){let _=v?.[Tc];return no(_)?_:void 0}function Fe(v){let _=v?.[Js];if(!_||typeof _!=="object")return;let k=Object.entries(_).map(([E,T])=>[E,String(T)]);return k.length>0?Object.fromEntries(k):void 0}function Wo(v,_){if(!v||!_||v===_||typeof _!=="object")return;let k=Be(v);if(k!==void 0)_[Tc]=k;let E=Fe(v);if(E)_[Js]={..._[Js],...E}}function Ln(v){return{setResponseStatus:(_)=>{Rc(v,_)},notFound:(_=404)=>{let k=no(_)&&_>=400?_:404;Rc(v,k)},setResponseHeader:(_,k)=>{Ky(v,_,k)}}}function cf(v,_,k={}){if(!v.includes("@status"))return v;let{filePath:E,buildMode:T}=k,j=T==="compile",B="",z=0,F=/@status\s*\(/g,V;while((V=F.exec(v))!==null){let H=Xy(v,V.index+V[0].length-1);if(H<0)break;let G=v.slice(V.index+V[0].length,H).trim(),J=/^\d+$/.test(G)?Number(G):c(G,_),ne=E?` in ${E}`:"";if(j)console.warn(`[stx] @status(${G})${ne} 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(${G}) from <script server> instead \u2014 that runs per request.`);else if(!Rc(_,J))console.warn(`[stx] @status(${G})${ne} is not an HTTP status (100-599) \u2014 ignoring it.`);B+=v.slice(z,V.index),z=H+1+(v.slice(H+1).match(/^[^\S\n]*\n?/)?.[0].length??0),F.lastIndex=z}return z===0?v:B+v.slice(z)}function Xy(v,_){let k=1,E=null,T=!1;for(let j=_+1;j<v.length;j++){let B=v[j];if(T){T=!1;continue}if(E){if(B==="\\")T=!0;else if(B===E)E=null;continue}if(B==='"'||B==="'"||B==="`"){E=B;continue}if(B==="(")k++;else if(B===")"&&--k===0)return j}return-1}var Zy=0,Gy=0;function lf(v,_){let k=v.match(new RegExp(`${_}\\s*=\\s*"([^"]*)"`,"i"));if(k)return k[1];let E=v.match(new RegExp(`${_}\\s*=\\s*'([^']*)'`,"i"));if(E)return E[1];return null}function Jy(v){let _=[],k=/<([a-z][a-z0-9-]*)\s+([^>]*x-data\s*=\s*(?:"[^"]*"|'[^']*')[^>]*)>/gi,E;while((E=k.exec(v))!==null){let[T,j,B]=E,z=E.index,F=lf(B,"x-data");if(!F)continue;let V=`__stx_scope_${Zy++}`,H=lf(B,"x-init"),G=Yy(v,j,z+T.length),J=v.slice(z,G.endIndex),ne=Qy(J);_.push({id:V,selector:`[data-stx-scope="${V}"]`,stateExpr:F,initExpr:H,bindings:[],refs:ne})}return _}function Yy(v,_,k){let E=1,T=k,j=new RegExp(`<${_}(?:\\s|>)`,"gi"),B=new RegExp(`</${_}>`,"gi"),z=new RegExp(`<${_}[^>]*/\\s*>`,"gi");while(E>0&&T<v.length){j.lastIndex=T,B.lastIndex=T,z.lastIndex=T;let F=j.exec(v),V=B.exec(v),H=z.exec(v);if(H&&H.index<(F?.index??1/0)){T=H.index+H[0].length;continue}if(!V)return{endIndex:v.length};if(F&&F.index<V.index)E++,T=F.index+F[0].length;else{if(E--,E===0)return{endIndex:V.index+V[0].length};T=V.index+V[0].length}}return{endIndex:v.length}}function Qy(v){let _=new Map,k=v.replace(/x-data\s*=\s*"[^"]*"/gi,'x-data="__stripped__"').replace(/x-data\s*=\s*'[^']*'/gi,"x-data='__stripped__'"),E=/<[a-z][a-z0-9-]*\s+([^>]*x-ref\s*=\s*["']([^"']*)["'][^>]*)>/gi,T;while((T=E.exec(k))!==null){let[,j,B]=T,z=ex(j);_.set(B,z)}return _}function ex(v){let _=v.match(/\bid\s*=\s*["']([^"']*)["']/);if(_)return _[1];return`__stx_el_${Gy++}`}function tx(){return`
|
|
1442
|
+
// STX Reactive Runtime - x-cloak and transition CSS
|
|
1443
|
+
(function() {
|
|
1444
|
+
var style = document.createElement('style');
|
|
1445
|
+
style.textContent = [
|
|
1446
|
+
'[x-cloak] { display: none !important; }',
|
|
1447
|
+
// Default transition classes
|
|
1448
|
+
'.stx-enter { opacity: 0; transform: scale(0.95); }',
|
|
1449
|
+
'.stx-enter-start { opacity: 0; transform: scale(0.95); }',
|
|
1450
|
+
'.stx-enter-active { transition: opacity 150ms ease-out, transform 150ms ease-out; }',
|
|
1451
|
+
'.stx-enter-to { opacity: 1; transform: scale(1); }',
|
|
1452
|
+
'.stx-leave { opacity: 1; transform: scale(1); }',
|
|
1453
|
+
'.stx-leave-start { opacity: 1; transform: scale(1); }',
|
|
1454
|
+
'.stx-leave-active { transition: opacity 100ms ease-in, transform 100ms ease-in; }',
|
|
1455
|
+
'.stx-leave-to { opacity: 0; transform: scale(0.95); }'
|
|
1456
|
+
].join('\\n');
|
|
1457
|
+
document.head.appendChild(style);
|
|
1458
|
+
})();
|
|
1459
|
+
|
|
1460
|
+
// STX Reactive Runtime
|
|
1461
|
+
/* eslint-disable pickier/no-unused-vars, no-console, prefer-const */
|
|
1462
|
+
window.__stx_reactive = (function() {
|
|
1463
|
+
'use strict';
|
|
1464
|
+
|
|
1465
|
+
// Deep reactive proxy that triggers onChange for any mutation
|
|
1466
|
+
function reactive(obj, onChange) {
|
|
1467
|
+
if (!obj || typeof obj !== 'object') return obj;
|
|
1468
|
+
return new Proxy(obj, {
|
|
1469
|
+
get(target, prop) {
|
|
1470
|
+
const value = target[prop];
|
|
1471
|
+
if (value && typeof value === 'object' && !Array.isArray(value) && !(value instanceof Promise)) {
|
|
1472
|
+
return reactive(value, onChange);
|
|
1473
|
+
}
|
|
1474
|
+
return value;
|
|
1475
|
+
},
|
|
1476
|
+
set(target, prop, value) {
|
|
1477
|
+
target[prop] = value;
|
|
1478
|
+
onChange(prop, value);
|
|
1479
|
+
return true;
|
|
1480
|
+
}
|
|
1481
|
+
});
|
|
1482
|
+
}
|
|
1483
|
+
|
|
1484
|
+
// Initialize an x-data scope: parse state, run init(), register into window.stx._scopes,
|
|
1485
|
+
// then let the signals runtime handle all directive processing (x-for, x-text, :bind, etc.)
|
|
1486
|
+
function initScope(scopeEl, initialState, bindings, refs, initExpr) {
|
|
1487
|
+
// Parse initial state (may contain methods including async init())
|
|
1488
|
+
var state;
|
|
1489
|
+
try {
|
|
1490
|
+
state = new Function('return (' + initialState + ')')();
|
|
1491
|
+
} catch (e) {
|
|
1492
|
+
console.error('[stx-reactive] Invalid x-data:', initialState, e);
|
|
1493
|
+
return;
|
|
1494
|
+
}
|
|
1495
|
+
|
|
1496
|
+
// Build $refs object
|
|
1497
|
+
var $refs = {};
|
|
1498
|
+
for (var name in refs) {
|
|
1499
|
+
if (Object.prototype.hasOwnProperty.call(refs, name)) {
|
|
1500
|
+
(function(refName, refId) {
|
|
1501
|
+
Object.defineProperty($refs, refName, {
|
|
1502
|
+
get: function() { return document.getElementById(refId); }
|
|
1503
|
+
});
|
|
1504
|
+
})(name, refs[name]);
|
|
1505
|
+
}
|
|
1506
|
+
}
|
|
1507
|
+
|
|
1508
|
+
// Extract init method from state if present (Alpine.js convention)
|
|
1509
|
+
var initMethod = state.init;
|
|
1510
|
+
if (typeof initMethod === 'function') {
|
|
1511
|
+
delete state.init;
|
|
1512
|
+
}
|
|
1513
|
+
|
|
1514
|
+
// Make state reactive \u2014 mutations trigger re-render via signals
|
|
1515
|
+
var scopeId = scopeEl.getAttribute('data-stx-scope');
|
|
1516
|
+
var stx = window.stx;
|
|
1517
|
+
|
|
1518
|
+
// Create signals for each state property so the signals runtime can track dependencies
|
|
1519
|
+
var signalState = {};
|
|
1520
|
+
var rawState = {};
|
|
1521
|
+
var derivedState = {};
|
|
1522
|
+
var accessors = {};
|
|
1523
|
+
// A getter must NOT be read here. Reading one calls it, and the old loop did
|
|
1524
|
+
// exactly that: the returned value is not a function, so it was wrapped as a
|
|
1525
|
+
// plain state() -- a snapshot of the answer at construction time, frozen
|
|
1526
|
+
// forever while plain properties beside it updated (#2053). A getter is a
|
|
1527
|
+
// derived value, so it is registered as one below, once ctxProxy exists for
|
|
1528
|
+
// it to read through.
|
|
1529
|
+
var ownDescriptors = Object.getOwnPropertyDescriptors ? Object.getOwnPropertyDescriptors(state) : {};
|
|
1530
|
+
for (var key in state) {
|
|
1531
|
+
if (Object.prototype.hasOwnProperty.call(state, key)) {
|
|
1532
|
+
var descriptor = ownDescriptors[key];
|
|
1533
|
+
if (descriptor && typeof descriptor.get === 'function') {
|
|
1534
|
+
accessors[key] = descriptor;
|
|
1535
|
+
continue;
|
|
1536
|
+
}
|
|
1537
|
+
if (typeof state[key] === 'function') {
|
|
1538
|
+
// Methods \u2014 bind to a proxy so 'this.prop = val' triggers signal updates
|
|
1539
|
+
signalState[key] = state[key];
|
|
1540
|
+
} else {
|
|
1541
|
+
// Data properties \u2014 wrap in signals for reactivity
|
|
1542
|
+
signalState[key] = stx.state(state[key]);
|
|
1543
|
+
rawState[key] = true;
|
|
1544
|
+
}
|
|
1545
|
+
}
|
|
1546
|
+
}
|
|
1547
|
+
|
|
1548
|
+
// Create a proxy context that auto-unwraps signals and writes back through them.
|
|
1549
|
+
// Methods get 'this' bound to this proxy so this.foo = bar triggers reactivity.
|
|
1550
|
+
var ctx = {};
|
|
1551
|
+
var ctxProxy = new Proxy(ctx, {
|
|
1552
|
+
get: function(target, prop) {
|
|
1553
|
+
if (prop === '$refs') return $refs;
|
|
1554
|
+
if (prop === '$el') return scopeEl;
|
|
1555
|
+
if (prop === '$nextTick') return function(fn) { requestAnimationFrame(fn); };
|
|
1556
|
+
var s = signalState[prop];
|
|
1557
|
+
if (!s) return undefined;
|
|
1558
|
+
if (rawState[prop] && s && typeof s === 'function' && typeof s.value !== 'undefined') {
|
|
1559
|
+
return s.value; // unwrap signal
|
|
1560
|
+
}
|
|
1561
|
+
if (typeof s === 'function' && !rawState[prop]) {
|
|
1562
|
+
return s.bind(ctxProxy); // bind methods to proxy
|
|
1563
|
+
}
|
|
1564
|
+
return s;
|
|
1565
|
+
},
|
|
1566
|
+
set: function(target, prop, value) {
|
|
1567
|
+
var accessor = derivedState[prop];
|
|
1568
|
+
if (accessor) {
|
|
1569
|
+
// A getter/setter pair writes through its setter. A getter alone has
|
|
1570
|
+
// nowhere to put the value: a derived has no .value setter, so the
|
|
1571
|
+
// assignment would be a silent no-op, which is the same class of
|
|
1572
|
+
// failure as the stale read this replaces.
|
|
1573
|
+
if (typeof accessor.set === 'function') {
|
|
1574
|
+
accessor.set.call(ctxProxy, value);
|
|
1575
|
+
return true;
|
|
1576
|
+
}
|
|
1577
|
+
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.');
|
|
1578
|
+
return true;
|
|
1579
|
+
}
|
|
1580
|
+
var s = signalState[prop];
|
|
1581
|
+
if (rawState[prop] && s && typeof s === 'function') {
|
|
1582
|
+
s.value = value; // write through signal \u2014 triggers effects
|
|
1583
|
+
} else {
|
|
1584
|
+
signalState[prop] = value;
|
|
1585
|
+
}
|
|
1586
|
+
return true;
|
|
1587
|
+
},
|
|
1588
|
+
has: function(target, prop) {
|
|
1589
|
+
return prop in signalState || prop === '$refs' || prop === '$el' || prop === '$nextTick';
|
|
1590
|
+
},
|
|
1591
|
+
ownKeys: function() {
|
|
1592
|
+
return Object.keys(signalState).concat(['$refs', '$el', '$nextTick']);
|
|
1593
|
+
},
|
|
1594
|
+
getOwnPropertyDescriptor: function(target, prop) {
|
|
1595
|
+
if (prop in signalState || prop === '$refs' || prop === '$el' || prop === '$nextTick') {
|
|
1596
|
+
return { configurable: true, enumerable: true, writable: true, value: ctxProxy[prop] };
|
|
1597
|
+
}
|
|
1598
|
+
return undefined;
|
|
1599
|
+
}
|
|
1600
|
+
});
|
|
1601
|
+
|
|
1602
|
+
// Now that ctxProxy exists, a getter becomes a derived that reads through it,
|
|
1603
|
+
// so it tracks whatever it touches and recomputes when that changes. derived()
|
|
1604
|
+
// is lazy, so nothing is evaluated until a binding actually reads it.
|
|
1605
|
+
//
|
|
1606
|
+
// Marked rawState as well: that is what makes the proxy unwrap it and what
|
|
1607
|
+
// exposes the signal itself to the runtime below, which is where dependency
|
|
1608
|
+
// tracking comes from. A getter needs both, exactly like a data property.
|
|
1609
|
+
for (var accessorKey in accessors) {
|
|
1610
|
+
if (Object.prototype.hasOwnProperty.call(accessors, accessorKey)) {
|
|
1611
|
+
(function(name, descriptor) {
|
|
1612
|
+
signalState[name] = stx.derived(function() {
|
|
1613
|
+
return descriptor.get.call(ctxProxy);
|
|
1614
|
+
});
|
|
1615
|
+
rawState[name] = true;
|
|
1616
|
+
derivedState[name] = descriptor;
|
|
1617
|
+
})(accessorKey, accessors[accessorKey]);
|
|
1618
|
+
}
|
|
1619
|
+
}
|
|
1620
|
+
|
|
1621
|
+
// Build scope vars for the signals runtime \u2014 it reads these for expression evaluation.
|
|
1622
|
+
// We need to provide getter/setter descriptors so signals track properly.
|
|
1623
|
+
var scopeVars = {};
|
|
1624
|
+
for (var k in signalState) {
|
|
1625
|
+
if (Object.prototype.hasOwnProperty.call(signalState, k)) {
|
|
1626
|
+
if (rawState[k]) {
|
|
1627
|
+
// Data: expose the signal directly so expressions trigger dependency tracking
|
|
1628
|
+
scopeVars[k] = signalState[k];
|
|
1629
|
+
} else {
|
|
1630
|
+
// Method: bind to ctxProxy so 'this' works
|
|
1631
|
+
scopeVars[k] = (typeof signalState[k] === 'function') ? signalState[k].bind(ctxProxy) : signalState[k];
|
|
1632
|
+
}
|
|
1633
|
+
}
|
|
1634
|
+
}
|
|
1635
|
+
scopeVars.$refs = $refs;
|
|
1636
|
+
scopeVars.$el = scopeEl;
|
|
1637
|
+
scopeVars.$nextTick = function(fn) { requestAnimationFrame(fn); };
|
|
1638
|
+
|
|
1639
|
+
// Register scope \u2014 merge with any existing vars from partial signal scripts
|
|
1640
|
+
if (!stx._scopes) stx._scopes = {};
|
|
1641
|
+
stx._scopes[scopeId] = Object.assign(stx._scopes[scopeId] || {}, scopeVars);
|
|
1642
|
+
|
|
1643
|
+
// Store on element for findElementScope
|
|
1644
|
+
scopeEl.__stx_scope = scopeVars;
|
|
1645
|
+
|
|
1646
|
+
// Run init() if present (supports async)
|
|
1647
|
+
function runInit() {
|
|
1648
|
+
var maybePromise;
|
|
1649
|
+
if (initMethod) {
|
|
1650
|
+
maybePromise = initMethod.call(ctxProxy);
|
|
1651
|
+
}
|
|
1652
|
+
if (initExpr) {
|
|
1653
|
+
try {
|
|
1654
|
+
var keys = Object.keys(scopeVars);
|
|
1655
|
+
var vals = keys.map(function(k) { return scopeVars[k]; });
|
|
1656
|
+
var fn = new Function(keys.join(','), initExpr);
|
|
1657
|
+
var result = fn.apply(ctxProxy, vals);
|
|
1658
|
+
if (result && typeof result.then === 'function') maybePromise = result;
|
|
1659
|
+
} catch (e) {
|
|
1660
|
+
console.warn('[stx-reactive] init expression error:', e);
|
|
1661
|
+
}
|
|
1662
|
+
}
|
|
1663
|
+
// If init is async, signal updates will trigger effects automatically
|
|
1664
|
+
// when init() resolves and sets this.prop = value (writes through signal)
|
|
1665
|
+
if (maybePromise && typeof maybePromise.then === 'function') {
|
|
1666
|
+
maybePromise.catch(function(e) {
|
|
1667
|
+
console.error('[stx-reactive] async init() error:', e);
|
|
1668
|
+
});
|
|
1669
|
+
}
|
|
1670
|
+
}
|
|
1671
|
+
|
|
1672
|
+
// Run init before the signals runtime processes this scope
|
|
1673
|
+
runInit();
|
|
1674
|
+
|
|
1675
|
+
// Expose for debugging
|
|
1676
|
+
scopeEl.__stx_state = ctxProxy;
|
|
1677
|
+
scopeEl.__stx_execute = function(stmt, $event, $el) {
|
|
1678
|
+
try {
|
|
1679
|
+
// Run the statement with the reactive proxy as the lexical scope.
|
|
1680
|
+
// Wrapping in a with-block on the proxy makes bare reads/writes go
|
|
1681
|
+
// through it (so foo = bar triggers signal.set()) instead of treating
|
|
1682
|
+
// each state key as a local function parameter \u2014 bare assignments
|
|
1683
|
+
// would otherwise just rebind the local and never reach the signal.
|
|
1684
|
+
var fn = new Function('$event', '$el', 'with(this){' + stmt + ';}');
|
|
1685
|
+
fn.call(ctxProxy, $event, $el);
|
|
1686
|
+
} catch (e) {
|
|
1687
|
+
console.warn('[stx-reactive] execute error:', e);
|
|
1688
|
+
}
|
|
1689
|
+
};
|
|
1690
|
+
}
|
|
1691
|
+
|
|
1692
|
+
return { initScope: initScope, reactive: reactive };
|
|
1693
|
+
})();
|
|
1694
|
+
`}function uf(v,_){let k=v.replace(/\{!!([\s\S]*?)!!\}/g,(z,F)=>{try{let V=x(F,_,!0);if(V===void 0)return z;return String(V)}catch{return z}}),E="",T=0,j=null;while(T<k.length){let z=k[T];if(j&&z==="\\"){E+=z+(k[T+1]??""),T+=2;continue}if(z==="{"&&k[T+1]==="{"){let F=k.indexOf("}}",T+2);if(F!==-1){let V=k.slice(T,F+2);E+=B(k.slice(T+2,F),V,j),T=F+2;continue}}if(j){if(z===j)j=null}else if(z==="'"||z==='"'||z==="`")j=z;E+=z,T++}return E;function B(z,F,V){let H;try{H=x(z,_,!0)}catch{return F}if(H===void 0)return F;if(V){let G=String(H).replace(/\\/g,"\\\\").replace(new RegExp(V==="`"?"`":V,"g"),`\\${V}`).replace(/\r/g,"\\r").replace(/\n/g,"\\n");return V==="`"?G.replace(/\$\{/g,"\\${"):G}if(typeof H==="string"){let G=H.trim();if(G.startsWith("{")&&G.endsWith("}")||G.startsWith("[")&&G.endsWith("]"))try{return JSON.parse(G),G}catch{}}return JSON.stringify(H)}}function nx(v,_){if(v.length===0)return"";let k=v.map((E)=>{let T=JSON.stringify(Object.fromEntries(E.refs)),j=uf(E.stateExpr,_),B=E.initExpr?uf(E.initExpr,_):null,z=JSON.stringify(j),F=B?JSON.stringify(B):"null";return`
|
|
1695
|
+
(function() {
|
|
1696
|
+
var scopeEl = document.querySelector('${E.selector}');
|
|
1697
|
+
if (!scopeEl) return;
|
|
1698
|
+
var refs = ${T};
|
|
1699
|
+
__stx_reactive.initScope(scopeEl, ${z}, [], refs, ${F});
|
|
1700
|
+
})();`}).join(`
|
|
1701
|
+
`);return`
|
|
1702
|
+
<script data-stx-scoped data-stx-reactive data-stx-run="always">
|
|
1703
|
+
${tx()}
|
|
1704
|
+
${k}
|
|
1705
|
+
</script>`}function df(v,_,k){if(!sx(v))return v;let E=Jy(v);if(E.length===0)return v;let T=rx(v,E),j=nx(E,_),B=T.lastIndexOf("</body>");if(B!==-1)T=T.slice(0,B)+j+`
|
|
1706
|
+
`+T.slice(B);else T+=j;return T}function rx(v,_){let k=0,E=v.replace(/<([a-z][a-z0-9-]*)(\s+[^>]*x-data\s*=\s*(?:"[^"]*"|'[^']*')[^>]*)>/gi,(T,j,B)=>{let z=_[k++];if(!z)return T;let F=/data-stx-scope="([^"]*)"/.exec(B);if(F)return z.id=F[1],z.selector=`[data-stx-scope="${z.id}"]`,T;return`<${j} data-stx-scope="${z.id}"${B}>`});return E=E.replace(/\s*x-data\s*=\s*"([^"]*)"/g,' data-stx-xdata="$1"'),E=E.replace(/\s*x-data\s*=\s*'([^']*)'/g," data-stx-xdata='$1'"),E=E.replace(/\s*x-init\s*=\s*"([^"]*)"/g,' data-stx-xinit="$1"'),E=E.replace(/\s*x-init\s*=\s*'([^']*)'/g," data-stx-xinit='$1'"),E}function sx(v){return/x-data\s*=\s*["']/.test(v)}function mr(v,_){try{let k=v.trim();if(p(k))return l(k,Object.keys(_))(...Object.values(_));else return c(k,_)}catch{return!1}}function hr(v,_){let k=ix(v,_);return k.ok?{expression:k.expression,endPos:k.endPos}:null}function ix(v,_){let k=_;while(k<v.length&&/\s/.test(v[k]))k++;if(v[k]!=="(")return{ok:!1,reason:"missing-open-paren",pos:k};let E=S(v,"(",")",k);if(E===-1)return{ok:!1,reason:"unclosed-paren",pos:k};return{ok:!0,expression:v.slice(k+1,E),endPos:E+1}}function ox(v,_){let k=v.lastIndexOf("<",_);if(k===-1)return!1;return k>v.lastIndexOf(">",_)}function Tr(v,_,k,E){let T=1,j=E,B=new RegExp(`@${_}\\s*\\(`,"g"),z=new RegExp(`@${k}(?![a-z])`,"g");while(j<v.length&&T>0){B.lastIndex=j,z.lastIndex=j;let F=B.exec(v),V=z.exec(v),H=F?F.index:1/0,G=V?V.index:1/0;if(H<G)T++,j=H+F[0].length;else if(G<1/0){if(T--,T===0)return G;j=G+V[0].length}else break}return-1}function ff(v,_){let k=v.slice(_).match(/^@if\s*/);if(!k)return null;let E=_+k[0].length,T=hr(v,E);if(!T)return null;let j=T.endPos,B=Tr(v,"if","endif",j);if(B===-1)return null;let z=v.slice(j,B),F=[],V=0,H="if",G=T.expression,J=0,ne=0;while(V<z.length){let re=z.indexOf("@",V);if(re===-1)break;V=re;let se=z.substring(re);if(ox(z,re)){V++;continue}if(/^@if\s*\(/.test(se)){ne++,V++;continue}if(/^@endif(?![a-z])/.test(se)){ne--,V+=6;continue}if(ne===0){let ie=se.match(/^@elseif\s*/);if(ie){F.push({type:H,condition:G,content:z.substring(J,V),start:j+J,end:j+V});let oe=V+ie[0].length,ge=hr(z,oe);if(!ge){V++;continue}H="elseif",G=ge.expression,V=ge.endPos,J=V;continue}else if(/^@else(?![a-z])/.test(se)){F.push({type:H,condition:G,content:z.substring(J,V),start:j+J,end:j+V}),H="else",G=void 0,V+=5,J=V;continue}}V++}return F.push({type:H,condition:G,content:z.slice(J),start:j+J,end:j+z.length}),{fullMatch:v.slice(_,B+6),branches:F,start:_,end:B+6}}function Ys(v){let _=[],k=/@if\s*\(/g,E=k.exec(v);while(E!==null){if(_.some((B)=>E.index>B.start&&E.index<B.end)){E=k.exec(v);continue}let j=ff(v,E.index);if(j)_.push(j),k.lastIndex=j.end;E=k.exec(v)}return _}function ro(v,_,k){let E=[],T=new RegExp(`@${_}\\s*\\(`,"g"),j=T.exec(v);while(j!==null){if(E.some((se)=>j.index>se.start&&j.index<se.end)){j=T.exec(v);continue}let z=j.index,F=z+j[0].length-1,V=S(v,"(",")",F);if(V===-1){j=T.exec(v);continue}let H=v.slice(F+1,V),G=V+1,J=Tr(v,_,k,G);if(J===-1){j=T.exec(v);continue}let ne=v.slice(G,J),re=J+`@${k}`.length;E.push({fullMatch:v.slice(z,re),name:_,params:H,content:ne,start:z,end:re}),T.lastIndex=re,j=T.exec(v)}return E}function Ac(v,_){let k=v.slice(_).match(/^@switch\s*/);if(!k)return null;let E=_+k[0].length,T=hr(v,E);if(!T)return null;let j=T.endPos,B=Tr(v,"switch","endswitch",j);if(B===-1)return null;let z=v.slice(j,B),F=[],V=0,H=null,G=0;while(V<z.length){let J=z.slice(V),ne=J.match(/^@switch\s*\(/),re=J.match(/^@endswitch(?![a-z])/);if(ne){if(G++,H)H.content+=ne[0];V+=ne[0].length;continue}if(re){if(G--,H)H.content+=re[0];V+=re[0].length;continue}if(G>0){if(H)H.content+=z[V];V++;continue}let se=J.match(/^@case\s*/),ie=J.match(/^@default(?![a-z])/),oe=J.match(/^@break(?![a-z])/);if(se&&J.startsWith("@case")){if(H)F.push(H);let ge=V+se[0].length,ue=hr(z,ge);if(!ue){V++;continue}H={type:"case",value:ue.expression,content:""},V=ue.endPos}else if(ie&&J.startsWith("@default")){if(H)F.push(H);H={type:"default",content:""},V+=ie[0].length}else if(oe&&J.startsWith("@break"))V+=oe[0].length;else{if(H)H.content+=z[V];V++}}if(H)F.push(H);return{fullMatch:v.slice(_,B+10),expression:T.expression,cases:F,start:_,end:B+10}}function ux(v,_,k){let E=v,T=!0;while(T){T=!1;let j=E.match(/@switch\s*\(/);if(!j||j.index===void 0)break;let B=j.index,z=Ac(E,B);if(!z)break;try{let F;if(p(z.expression))F=l(z.expression,Object.keys(_))(...Object.values(_));else F=c(z.expression,_);let V="",H=!1;for(let G of z.cases)if(G.type==="default"){if(!H)V=G.content.trim()}else try{let J;if(G.value&&p(G.value))J=l(G.value,Object.keys(_))(...Object.values(_));else if(G.value)J=c(G.value,_);if(F===J){V=G.content.trim(),H=!0;break}}catch{continue}E=E.substring(0,B)+V+E.substring(z.end),T=!0}catch(F){let V=F instanceof Error?F.message:String(F),H=i("Switch",`Error evaluating @switch expression: ${V}`,t.EVALUATION_ERROR);E=E.substring(0,B)+H+E.substring(z.end);break}}return E}function dx(v){let _=[];return{masked:v.replace(/<script\b[\s\S]*?<\/script\s*>/gi,(E)=>(_.push(E),`\x00stx-script-${_.length-1}\x00`)),scripts:_}}function fx(v,_){if(_.length===0)return v;return v.replace(/\u0000stx-script-(\d+)\u0000/g,(k,E)=>_[Number(E)]??k)}function ar(v,_,k){let{masked:E,scripts:T}=dx(v);return fx(px(E,_,k),T)}function px(v,_,k){let E=v;E=ux(E,_,k);{let j=!0;while(j){j=!1;let B=E.match(/@unless\s*\(/);if(!B||B.index===void 0)break;let z=B.index,F=hr(E,z+7);if(!F)break;let V=F.endPos,H=Tr(E,"unless","endunless",V);if(H===-1){console.warn(`[stx] @unless directive at position ${z} has no matching @endunless \u2014 the block was skipped. Check for typos or missing closers.`);break}let G=E.slice(V,H),J=F.expression,ne=-1;{let se=0,ie=/@(?:if|unless)\s*\(/g,oe=/@(?:endif|endunless)(?![a-z])/g,ge=/@else(?![a-z])/g,ue=[],xe;while((xe=ie.exec(G))!==null)ue.push({pos:xe.index,type:"open"});while((xe=oe.exec(G))!==null)ue.push({pos:xe.index,type:"close"});while((xe=ge.exec(G))!==null)ue.push({pos:xe.index,type:"else"});ue.sort((we,$e)=>we.pos-$e.pos);for(let we of ue)if(we.type==="open")se++;else if(we.type==="close")se--;else if(we.type==="else"&&se===0){ne=we.pos;break}}let re;if(ne!==-1){let se=G.slice(0,ne),ie=G.slice(ne+5);re=`@if (${J})${ie}@else ${se}@endif`}else re=`@if (!(${J}))${G}@endif`;E=E.substring(0,z)+re+E.substring(H+10),j=!0}}E=Pc(E,_,k),E=Dc(E,_,k),E=Ic(E,_);let T=()=>{let j=Ys(E);if(j.length===0)return!1;let B=Array(j.length);for(let V=j.length-1;V>=0;V--){let H=j[V];try{let G="",J=!1;for(let ne of H.branches){if(J)break;if(ne.type==="else")G=ne.content,J=!0;else try{let re;if(ne.condition&&p(ne.condition))re=l(ne.condition,Object.keys(_))(...Object.values(_));else if(ne.condition)re=c(ne.condition,_);if(re)G=ne.content,J=!0}catch(re){G=i(ne.type==="if"?"If":"Elseif",`Error in @${ne.type}(${ne.condition}): ${re instanceof Error?re.message:String(re)}`,t.EVALUATION_ERROR),J=!0}}B[V]=G}catch(G){let J=G instanceof Error?G.message:String(G);B[V]=i("If",`Error processing @if block: ${J}`,t.EVALUATION_ERROR)}}let z=Array(j.length*2+1),F=0;for(let V=0;V<j.length;V++){let H=j[V];z[V*2]=E.slice(F,H.start),z[V*2+1]=B[V],F=H.end}return z[j.length*2]=E.slice(F),E=z.join(""),!0};while(!0){let j=E;if(!T())break;if(E===j)break}return E}function pf(v){let _=0;while(_<v.length&&/\s/.test(v[_]))_++;if(v[_]!=="(")return null;_++;while(_<v.length&&/\s/.test(v[_]))_++;let k=v[_];if(k!=="'"&&k!=='"')return null;_++;let E=[];while(_<v.length){let T=v[_];if(T==="\\"&&_+1<v.length){E.push(v[_+1]),_+=2;continue}if(T===k){_++;break}E.push(T),_++}while(_<v.length&&/\s/.test(v[_]))_++;if(v[_]!==")")return null;return _++,{value:E.join(""),consumed:_}}function Ic(v,_){let k=v;function E(z,F,V,H){let G=1,J=H,ne=new RegExp(`@${F}(?:\\s*\\(|\\s|$)`,"g"),re=new RegExp(`@${V}(?![a-z])`,"g");while(J<z.length&&G>0){ne.lastIndex=J,re.lastIndex=J;let se=ne.exec(z),ie=re.exec(z),oe=se?se.index:1/0,ge=ie?ie.index:1/0;if(oe<ge)G++,J=oe+se[0].length;else if(ge<1/0){if(G--,G===0)return ge;J=ge+ie[0].length}else break}return-1}function T(z,F,V){let H=0,G=new RegExp(`@${F}(?:\\s*\\(|\\s|$)`,"g"),J=new RegExp(`@${V}(?![a-z])`,"g"),ne=/@else(?![a-z])/g,re=[],se;while((se=G.exec(z))!==null)re.push({pos:se.index,type:"open"});while((se=J.exec(z))!==null)re.push({pos:se.index,type:"close"});while((se=ne.exec(z))!==null)re.push({pos:se.index,type:"else"});re.sort((ie,oe)=>ie.pos-oe.pos);for(let ie of re)if(ie.type==="open")H++;else if(ie.type==="close")H--;else if(ie.type==="else"&&H===0)return ie.pos;return-1}{let z=!0;while(z){z=!1;let F=k.match(/@auth(?:\s*\(|\s|(?=\n))/);if(!F||F.index===void 0)break;let V=F.index,H,G,J=k.slice(V+5),ne=pf(J);if(ne)H=ne.value,G=V+5+ne.consumed;else G=V+5;let re=E(k,"auth","endauth",G);if(re===-1){console.warn(`[stx] @auth directive at position ${V} has no matching @endauth \u2014 the block was skipped.`);break}let se=k.slice(G,re),ie=T(se,"auth","endauth"),oe;if(!_.auth)oe=!1;else oe=H?mr(`auth?.check && auth?.user?.[${H}]`,_):mr("auth?.check",_);let ge;if(ie!==-1){let ue=se.slice(0,ie),xe=se.slice(ie+5);ge=oe?ue:xe}else ge=oe?se:"";k=k.substring(0,V)+ge+k.substring(re+8),z=!0}}{let z=!0;while(z){z=!1;let F=k.match(/@guest(?:\s*\(|\s|(?=\n))/);if(!F||F.index===void 0)break;let V=F.index,H,G,J=k.slice(V+6),ne=pf(J);if(ne)H=ne.value,G=V+6+ne.consumed;else G=V+6;let re=E(k,"guest","endguest",G);if(re===-1){console.warn(`[stx] @guest directive at position ${V} has no matching @endguest \u2014 the block was skipped.`);break}let se=k.slice(G,re),ie=T(se,"guest","endguest"),oe;if(!_.auth)oe=!0;else oe=H?mr(`!auth?.check || !auth?.user?.[${H}]`,_):mr("!auth?.check",_);let ge;if(ie!==-1){let ue=se.slice(0,ie),xe=se.slice(ie+5);ge=oe?ue:xe}else ge=oe?se:"";k=k.substring(0,V)+ge+k.substring(re+9),z=!0}}function j(z,F,V){if(_.userCan&&typeof _.userCan[z]==="boolean")return _.userCan[z];if(_.permissions?.check&&typeof _.permissions.check==="function")try{let H=[z];if(F)H.push(F);if(V){let G=mr(V,_);H.push(G)}return _.permissions.check(...H)}catch{return!1}return!1}function B(z){let F=z.match(/^\s*\(\s*'([^']*)'(?:,\s*'([^']*)')?(?:,\s*([^)]*))?\)/);if(!F)return null;return{ability:F[1],type:F[2],id:F[3]?.trim(),paramsEnd:F[0].length}}for(let z of["can","cannot"]){let F=`end${z}`,V=z==="can"?"elsecan":"elsecannot",H=!0;while(H){H=!1;let G=k.match(new RegExp(`@${z}\\s*\\(`));if(!G||G.index===void 0)break;let J=G.index,ne=k.slice(J+`@${z}`.length),re=B(ne);if(!re)break;let se=J+`@${z}`.length+re.paramsEnd,ie=E(k,z,F,se);if(ie===-1){console.warn(`[stx] @${z} directive at position ${J} has no matching @${F} \u2014 the block was skipped.`);break}let oe=k.slice(se,ie),ge=[],ue=0,xe=new RegExp(`@${z}\\s*\\(`,"g"),we=new RegExp(`@${F}(?![a-z])`,"g"),$e=new RegExp(`@${V}\\s*\\(`,"g"),_e=/@else(?![a-z])/g,Ce=[],Ee;while((Ee=xe.exec(oe))!==null)Ce.push({pos:Ee.index,type:"open"});while((Ee=we.exec(oe))!==null)Ce.push({pos:Ee.index,type:"close"});while((Ee=$e.exec(oe))!==null)Ce.push({pos:Ee.index,type:"elseDirective"});while((Ee=_e.exec(oe))!==null)Ce.push({pos:Ee.index,type:"else"});Ce.sort((Pe,Ie)=>Pe.pos-Ie.pos);for(let Pe of Ce){if(Pe.type==="open"){ue++;continue}if(Pe.type==="close"){ue--;continue}if(ue===0)ge.push(Pe)}let Te=[],Re=0;for(let Pe=0;Pe<ge.length;Pe++){let Ie=ge[Pe];if(Te.push({content:oe.slice(Re,Ie.pos),ability:void 0}),Ie.type==="elseDirective"){let Ze=oe.slice(Ie.pos+`@${V}`.length),nt=B(Ze);if(nt){Te[Te.length-1]={content:oe.slice(Re,Ie.pos)},Re=Ie.pos+`@${V}`.length+nt.paramsEnd,Te.push({content:"",ability:nt.ability,type:nt.type,id:nt.id}),Te.pop();let at=ge[Pe+1],rt=at?at.pos:oe.length;Te.push({content:oe.slice(Re,rt),ability:nt.ability,type:nt.type,id:nt.id}),Re=rt}}else Re=Ie.pos+5}if(Re<oe.length){let Pe=Te[Te.length-1];if(ge.length>0&&ge[ge.length-1].type==="else")Te.push({content:oe.slice(Re),isFinalElse:!0});else if(Te.length===0)Te.push({content:oe.slice(Re)})}let ke=j(re.ability,re.type,re.id),Ae=z==="can"?ke:!ke,Xe="";if(Ae)Xe=Te[0]?.content||"";else{let Pe=!1;for(let Ie=1;Ie<Te.length;Ie++){let Ze=Te[Ie];if(Ze.isFinalElse){Xe=Ze.content,Pe=!0;break}if(Ze.ability){let nt=j(Ze.ability,Ze.type,Ze.id);if(z==="can"?nt:!nt){Xe=Ze.content,Pe=!0;break}}}if(!Pe&&Te.length>0){let Ie=Te[Te.length-1];if(Ie.isFinalElse)Xe=Ie.content}}k=k.substring(0,J)+Xe+k.substring(ie+`@${F}`.length),H=!0}}return k}function Pc(v,_,k){let E=v;function T(j,B,z,F,V){let H=!0;while(H){H=!1;let G=new RegExp(`@${B}\\s*\\(`),J=j.match(G);if(!J||J.index===void 0)break;let ne=J.index,re=hr(j,ne+`@${B}`.length);if(!re)break;let se=re.endPos,ie=Tr(j,B,z,se);if(ie===-1){console.warn(`[stx] @${B} directive at position ${ne} has no matching @${z} \u2014 the block was skipped.`);break}let oe=j.slice(se,ie),ge=re.expression,ue=-1,xe=0,we=0;while(we<oe.length){let $e=oe.indexOf("@",we);if($e===-1)break;let _e=oe.substring($e);if(/^@(?:if|unless|isset|empty)\s*\(/.test(_e)){xe++,we=$e+1;continue}if(/^@(?:endif|endunless|endisset|endempty)(?![a-z])/.test(_e)){xe--,we=$e+1;continue}if(xe===0&&/^@else(?![a-z])/.test(_e)){ue=$e;break}we=$e+1}try{let $e=F(ge.trim()),_e;if(ue!==-1){let Ce=oe.slice(0,ue),Ee=oe.slice(ue+5);_e=$e?Ce:Ee}else _e=$e?oe:"";j=j.substring(0,ne)+_e+j.substring(ie+`@${z}`.length),H=!0}catch($e){let _e=$e instanceof Error?$e.message:String($e),Ce=i(V,`Error processing @${B} directive: ${_e}`,t.EVALUATION_ERROR);j=j.substring(0,ne)+Ce+j.substring(ie+`@${z}`.length);break}}return j}return E=T(E,"isset","endisset",(j)=>{let B=mr(j,_);return B!==void 0&&B!==null},"Isset"),E=T(E,"empty","endempty",(j)=>{let B=mr(j,_);return B===void 0||B===null||B===""||B===0||B===!1||Array.isArray(B)&&B.length===0||typeof B==="object"&&B!==null&&Object.keys(B).length===0},"Empty"),E}function Dc(v,_,k){let E=v,T="development";function j(B,z,F,V){let H=new RegExp(`@${z}(?![a-z])`,"g"),G=new RegExp(`@${F}(?![a-z])`,"g"),J=new RegExp(`^@${z}(?![a-z])`),ne=new RegExp(`^@${F}(?![a-z])`),re=B,se=!0;while(se){se=!1,H.lastIndex=0;let ie=H.exec(re);if(!ie)break;let oe=ie.index,ge=oe+ie[0].length;if(z==="env"){let ke=re.substring(ge).match(/^\s*\(\s*(['"])([^'"]+)\1\s*\)/);if(!ke)break;ge+=ke[0].length,V=T===ke[2]}let ue=1,xe=ge,we=-1;while(ue>0&&xe<re.length){H.lastIndex=xe,G.lastIndex=xe;let ke=H.exec(re),Ae=G.exec(re),Xe=ke?ke.index:1/0,Pe=Ae?Ae.index:1/0;if(Xe<Pe)ue++,xe=Xe+ke[0].length;else if(Pe<1/0){if(ue--,ue===0){we=Pe;break}xe=Pe+Ae[0].length}else break}if(we===-1){console.warn(`[stx] @${z} directive at position ${oe} has no matching @${F} \u2014 the block was skipped.`);break}let $e=re.substring(ge,we),_e=-1,Ce=0,Ee=0;while(Ee<$e.length){let ke=$e.indexOf("@",Ee);if(ke===-1)break;let Ae=$e.substring(ke);if(J.test(Ae)){Ce++,Ee=ke+1;continue}if(ne.test(Ae)){Ce--,Ee=ke+1;continue}if(Ce===0&&/^@else(?![a-z])/.test(Ae)){_e=ke;break}Ee=ke+1}let Te;if(_e!==-1){let ke=$e.slice(0,_e),Ae=$e.slice(_e+5);Te=V?ke:Ae}else Te=V?$e:"";let Re=`@${F}`.length;re=re.substring(0,oe)+Te+re.substring(we+Re),se=!0}return re}return E=j(E,"env","endenv",!1),E=j(E,"production","endproduction",T==="production"),E=j(E,"development","enddevelopment",T==="development"),E=j(E,"staging","endstaging",T==="staging"),E=j(E,"testing","endtesting",T==="testing"),E}var gf=new WeakMap;function mf(v=16){let _=new Uint8Array(v);return crypto.getRandomValues(_),btoa(String.fromCharCode(..._))}function so(v,_){if(!v)return _?.nonceGenerator?.()??mf();let k=gf.get(v);if(!k)k=_?.nonceGenerator?.()??mf(),gf.set(v,k);return k}function gx(v,_){let k=[];for(let[E,T]of Object.entries(v)){if(T===void 0||T===null)continue;if(typeof T==="boolean"){if(T)k.push(E);continue}if(Array.isArray(T)){let j=[...T];if(_&&(E==="script-src"||E==="style-src"))j=j.filter((B)=>!B.startsWith("'nonce-")),j.push(`'nonce-${_}'`);if(j.length>0)k.push(`${E} ${j.join(" ")}`)}}return k.join("; ")}function hf(v,_){return`<meta http-equiv="Content-Security-Policy" content="${gx(v,_).replace(/&/g,"&").replace(/"/g,""")}">`}function yf(v,_,k){if(!_.enabled||!_.addMetaTag)return v;if(v.includes('http-equiv="Content-Security-Policy"'))return v;if(!v.includes("<head>")&&!v.includes("<head "))return v;let E=_.useNonce?so(k,_):void 0,T=hf(_.directives,E);return v.replace(/<head([^>]*)>/,`<head$1>
|
|
1707
|
+
${T}`)}function xf(v,_){let k=v;return k=k.replace(/<script(?![^>]*\ssrc=)([^>]*)>/gi,(E,T)=>{if(T.includes("nonce="))return E;return`<script nonce="${_}"${T}>`}),k=k.replace(/<style([^>]*)>/gi,(E,T)=>{if(T.includes("nonce="))return E;return`<style nonce="${_}"${T}>`}),k}function bf(v,_,k,E){let T=v,j=E.csp;if(T=T.replace(/@csp\b/g,()=>{if(!j?.enabled||!j.directives)return"<!-- CSP not configured -->";let B=j.useNonce?so(_,j):void 0;return hf(j.directives,B)}),T=T.replace(/@cspNonce\b/g,()=>{if(!j?.enabled||!j.useNonce)return"";return so(_,j)}),j?.enabled&&j.useNonce)_.cspNonce=so(_,j);return T}import mx from"crypto";var hx=40,vf="_token",Mc=null;function yx(v=hx){let _=mx.randomBytes(Math.ceil(v/2)).toString("hex").slice(0,v);return Mc=_,_}function xx(){if(!Mc)yx();return Mc}function bx(v=vf){let _=xx();return`<input type="hidden" name="${v}" value="${_}">`}function wf(v){return v.replace(/@csrf(?:\((['"])([^'"]*)\1\))?/g,(_,k,E)=>bx(E||vf))}async function Sf(v,_,k,E){if(!E.customDirectives||E.customDirectives.length===0)return v;let T=v;for(let j of E.customDirectives){if(!j.name||typeof j.handler!=="function"){if(E.debug)console.warn("Invalid custom directive:",j);continue}if(j.hasEndTag)T=await vx(T,j,_,k,E);else T=await wx(T,j,_,k,E)}return T}async function vx(v,_,k,E,T){let{name:j,handler:B}=_,z=`@${j}`,F=`@end${j}`,V=v,H=$r(`${z}(?:\\s*\\(([^()]*(?:\\([^)]*\\)[^()]*)*)\\))?([\\s\\S]*?)${F}`,"g"),G=[],J=H.exec(V);while(J!==null){let[ne,re="",se=""]=J,ie=J.index||0;try{let oe=re?$f(_,re):[],ge=se.trim(),ue=await B(ge,oe,k,E);G.push({original:ne,processed:ue,startIndex:ie})}catch(oe){let ge=oe instanceof Error?oe.message:String(oe);if(T.debug)console.error(`Error processing custom directive @${j}:`,oe);G.push({original:ne,processed:i("CustomDirective",`Error in @${j}${re?`(${re})`:""}: ${ge}`,t.EVALUATION_ERROR),startIndex:ie})}J=H.exec(V)}for(let ne=G.length-1;ne>=0;ne--){let{original:re,processed:se}=G[ne];V=V.replace(re,se)}return V}async function wx(v,_,k,E,T){let{name:j,handler:B}=_,z=v,F=[],V=[];if(_.rawParams){for(let J of Ts(z,$r(`(?<![\\w$@])@${j}\\s*\\(`,"g")))if(J.end!==-1)V.push({fullMatch:J.call,paramString:J.args,startIndex:J.start})}else{let J=$r(`@${j}\\s*\\(([^()]*(?:\\([^)]*\\)[^()]*)*)\\)`,"g");J.lastIndex=0;let ne=J.exec(z);while(ne!==null)V.push({fullMatch:ne[0],paramString:ne[1]??"",startIndex:ne.index||0}),ne=J.exec(z)}for(let{fullMatch:J,paramString:ne,startIndex:re}of V)try{let se=$f(_,ne),ie=await B("",se,k,E);F.push({original:J,processed:ie,startIndex:re})}catch(se){let ie=se instanceof Error?se.message:String(se);if(T.debug)console.error(`Error processing custom directive @${j}:`,se);F.push({original:J,processed:i("CustomDirective",`Error in @${j}(${ne}): ${ie}`,t.EVALUATION_ERROR),startIndex:re})}let H=$r(`@${j}(?!\\w)(?!\\s*\\()`,"g"),G=H.exec(z);while(G!==null){let[J]=G,ne=G.index||0;try{let re=await B("",[],k,E);F.push({original:J,processed:re,startIndex:ne})}catch(re){let se=re instanceof Error?re.message:String(re);if(T.debug)console.error(`Error processing custom directive @${j}:`,re);F.push({original:J,processed:i("CustomDirective",`Error in @${j}: ${se}`,t.EVALUATION_ERROR),startIndex:ne})}G=H.exec(z)}for(let J=F.length-1;J>=0;J--){let{original:ne,processed:re}=F[J];z=z.replace(ne,re)}return z}function $f(v,_){return v.rawParams?Ge(_):Sx(_)}function Sx(v){if(!v.trim())return[];let _=[],k="",E=!1,T="";for(let j=0;j<v.length;j++){let B=v[j];if((B==='"'||B==="'")&&(j===0||v[j-1]!=="\\"))if(!E)E=!0,T=B;else if(B===T)E=!1;else k+=B;else if(B===","&&!E)_.push(k.trim()),k="";else k+=B}if(k.trim())_.push(k.trim());return _.map((j)=>{let B=j.trim();if(B.startsWith('"')&&B.endsWith('"')||B.startsWith("'")&&B.endsWith("'"))return B.substring(1,B.length-1);return B})}var _f=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/,kf=/^[A-Za-z_$][\w$]*$/,$x=new Set(["light","dark","system"]);function Ar(v,_){if(typeof v!=="string"||v.length===0)throw Error(`@appearanceBootstrap ${_} must be a non-empty string`)}function _x(v){if(!v||typeof v!=="object"||Array.isArray(v))throw Error("@appearanceBootstrap expects an options object");let _=v,{appearance:k,colorMode:E}=_;if(Ar(_.storageKey,"storageKey"),k!==void 0&&(!k||typeof k!=="object"||Array.isArray(k)))throw Error("@appearanceBootstrap appearance must be an object when given");if(!E||typeof E!=="object"||Array.isArray(E))throw Error("@appearanceBootstrap colorMode must be an object");if(Ar(E.key,"colorMode.key"),Ar(E.attribute,"colorMode.attribute"),Ar(E.default,"colorMode.default"),!kf.test(E.key))throw Error("@appearanceBootstrap preference keys must be JavaScript property names");if(!_f.test(E.attribute))throw Error("@appearanceBootstrap attributes must be lowercase data attribute names");if(!$x.has(E.default))throw Error("@appearanceBootstrap colorMode.default must be light, dark, or system");let T=null;if(k){if(Ar(k.key,"appearance.key"),Ar(k.attribute,"appearance.attribute"),Ar(k.default,"appearance.default"),!kf.test(k.key))throw Error("@appearanceBootstrap preference keys must be JavaScript property names");if(!_f.test(k.attribute))throw Error("@appearanceBootstrap attributes must be lowercase data attribute names");if(!Array.isArray(k.allowed)||k.allowed.length===0||k.allowed.some((j)=>typeof j!=="string"||j.length===0))throw Error("@appearanceBootstrap appearance.allowed must contain one or more strings");if(!k.allowed.includes(k.default))throw Error("@appearanceBootstrap appearance.default must be in appearance.allowed");T={key:k.key,attribute:k.attribute,allowed:[...new Set(k.allowed)],default:k.default}}return{storageKey:_.storageKey,appearance:T,colorMode:{key:E.key,attribute:E.attribute,default:E.default},respectExisting:_.respectExisting===!0}}function kx(v){return JSON.stringify(v).replace(/</g,"\\u003c").replace(/>/g,"\\u003e").replace(/&/g,"\\u0026").replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}function Ex(v){return`<script data-stx-scoped data-stx-appearance-bootstrap>(function(){"use strict";const config=${kx(v)};const root=document.documentElement;const MODES=["light","dark","system"];let format="json";const forced=(function(){const found={colorMode:null,appearance:null};if(!config.respectExisting)return found;try{const mode=root.getAttribute("data-"+config.colorMode.attribute);if(mode==="light"||mode==="dark")found.colorMode=mode;if(config.appearance){const name=root.getAttribute("data-"+config.appearance.attribute);if(config.appearance.allowed.includes(name))found.appearance=name}}catch{}return found}());function read(){let stored={};try{const raw=localStorage.getItem(config.storageKey);if(raw){let parsed=null;try{parsed=JSON.parse(raw)}catch{parsed=raw}if(parsed&&typeof parsed==="object"&&!Array.isArray(parsed)){stored=parsed;format="json"}else if(typeof parsed==="string"&&MODES.includes(parsed)){stored={};stored[config.colorMode.key]=parsed;format="string"}}}catch{}return stored}function write(stored){try{if(format==="string"&&!config.appearance)localStorage.setItem(config.storageKey,stored[config.colorMode.key]);else localStorage.setItem(config.storageKey,JSON.stringify(stored))}catch{}}function resolve(){const stored=read();const state={colorMode:forced.colorMode||(MODES.includes(stored[config.colorMode.key])?stored[config.colorMode.key]:config.colorMode.default)};if(config.appearance)state.appearance=forced.appearance||(config.appearance.allowed.includes(stored[config.appearance.key])?stored[config.appearance.key]:config.appearance.default);return state}function prefersDark(){try{return matchMedia("(prefers-color-scheme: dark)").matches}catch{return false}}function apply(){const state=resolve();const dark=state.colorMode==="dark"||(state.colorMode==="system"&&prefersDark());if(config.appearance)root.setAttribute("data-"+config.appearance.attribute,state.appearance);root.setAttribute("data-"+config.colorMode.attribute,state.colorMode);root.classList.toggle("dark",dark);root.dataset.theme=dark?"dark":"light";state.dark=dark;try{window.dispatchEvent(new CustomEvent("stx:appearance",{detail:state}))}catch{}return state}function store(key,allowed,value){if(allowed.includes(value)){const stored=read();stored[key]=value;write(stored)}return apply()}window.__stxAppearance={config:config,forced:forced,read:read,resolve:resolve,apply:apply,setColorMode:function(mode){return store(config.colorMode.key,MODES,mode)},setAppearance:function(name){return config.appearance?store(config.appearance.key,config.appearance.allowed,name):apply()},watchSystem:function(){try{matchMedia("(prefers-color-scheme: dark)").addEventListener("change",function(){if(resolve().colorMode==="system")apply()})}catch{}}};apply()}());</script>`}function Cx(v,_){let k=1,E=null,T=!1;for(let j=_+1;j<v.length;j++){let B=v[j];if(T){T=!1;continue}if(E){if(B==="\\")T=!0;else if(B===E)E=null;continue}if(B==='"'||B==="'"||B==="`"){E=B;continue}if(B==="(")k++;else if(B===")"&&--k===0)return j}return-1}function Ef(v,_){let k=v,E=/@appearanceBootstrap\s*\(/g,T;while((T=E.exec(k))!==null){let j=T.index+T[0].length-1,B=Cx(k,j);if(B===-1)throw Error("@appearanceBootstrap has an unclosed options object");let z=k.slice(j+1,B).trim(),F=c(`(${z})`,_),V=Ex(_x(F));k=k.slice(0,T.index)+V+k.slice(B+1),E.lastIndex=T.index+V.length}return k}import Rx from"crypto";function Vt(v){return String(v??"").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}var Rf={input:"form-control",inputError:"is-invalid",checkInput:"form-check-input",label:"form-label",errorFeedback:"invalid-feedback"};function io(v,_,k,E){let T=v||_;return k?`${T} ${E}`:T}function vn(v){return String(v).replace(/\[\]$/,"").replace(/[^\w.:-]+/g,"-").replace(/^-+|-+$/g,"")}function Ps(v,_){if(/\bid\s*=/i.test(v))return"";return` id="${Vt(_)}"`}function Oc(v,_,k){if(!_)return"";let E="";if(!/\baria-invalid\s*=/i.test(k))E+=' aria-invalid="true"';if(!/\baria-describedby\s*=/i.test(k))E+=` aria-describedby="${Vt(`${vn(v)}-error`)}"`;return E}function Tx(){return Rx.randomUUID()}function oo(v,_){let k=v;return k=k.replace(/@csrf/g,()=>{if(!_.csrf||typeof _.csrf!=="object"){let E=Tx();_.csrf={token:E}}if(_.csrf.field)return _.csrf.field;if(_.csrf.token)return`<input type="hidden" name="_token" value="${Vt(_.csrf.token)}">`;return'<input type="hidden" name="_token" value="">'}),k=k.replace(/@method\(['"]([^'"]+)['"]\)/g,(E,T)=>{let j=T.toUpperCase();if(T&&!["GET","POST"].includes(j))return`<input type="hidden" name="_method" value="${Vt(j)}">`;return E}),k}function Tf(v,_,k=Rf){let E=v;return E=E.replace(/@form\(\s*(?:(?:'([^']+)'|"([^"]+)")\s*)?(?:,\s*(?:'([^']+)'|"([^"]+)")?)?\s*(?:,\s*\{([^}]+)\}\s*)?\)/g,(T,j,B,z,F,V="")=>{let H=j||B||"POST",G=z||F||"",J=yr(V),ne=H.toUpperCase(),re=["GET","POST"].includes(ne)?ne:"POST",se=`<form method="${Vt(re)}" action="${Vt(G)}"${J?` ${J}`:""}>`;if(se+=`
|
|
1708
|
+
${oo("@csrf",_)}`,!["GET","POST"].includes(ne))se+=`
|
|
1709
|
+
${oo(`@method('${ne}')`,_)}`;return se}),E=E.replace(/@endform/g,"</form>"),E=E.replace(/@input\(\s*(?:'([^']+)'|"([^"]+)")\s*(?:,\s*(?:(?:'([^']*)'|"([^"]*)")\s*)?)?(?:,\s*\{([^}]+)\})?\s*\)/g,(T,j,B,z,F,V="")=>{let H=j||B||"",G=z||F||"",J=yr(V),ne=Qs(H,_),re=ne!==void 0&&ne!==null?ne:G||"",se=J.match(/type=['"]([^'"]+)['"]/i),ie=se?se[1]:"text",oe=pi(H,_),ge=J.match(/class=['"]([^'"]+)['"]/i),ue=io(ge?ge[1]:"",k.input,oe,k.inputError),xe=J.replace(/class=['"][^'"]+['"]/i,"");return xe=xe.replace(/type=['"][^'"]+['"]/i,""),`<input type="${Vt(ie)}" name="${Vt(H)}"${Ps(J,vn(H))} value="${Vt(re)}" class="${ue}"${Oc(H,oe,J)}${xe?` ${xe}`:""}>`}),E=E.replace(/@textarea\(\s*['"]([^'"]+)['"]\s*(?:,\s*\{([^}]+)\})?\)([\s\S]*?)@endtextarea/g,(T,j,B="",z="")=>{let F=yr(B),V=Qs(j,_)||z.trim(),H=pi(j,_),G=F.match(/class=['"]([^'"]+)['"]/i),J=io(G?G[1]:"",k.input,H,k.inputError),ne=F.replace(/class=['"][^'"]+['"]/i,"");return`<textarea name="${Vt(j)}"${Ps(F,vn(j))} class="${J}"${Oc(j,H,F)}${ne?` ${ne}`:""}>${Vt(V)}</textarea>`}),E=E.replace(/@select\(\s*['"]([^'"]+)['"]\s*(?:,\s*\{([^}]+)\})?\)([\s\S]*?)@endselect/g,(T,j,B="",z)=>{let F=yr(B),V=Qs(j,_),H=pi(j,_),G=F.match(/class=['"]([^'"]+)['"]/i),J=io(G?G[1]:"",k.input,H,k.inputError),ne=F.replace(/class=['"][^'"]+['"]/i,""),re=z;if(V!==void 0)re=z.replace(/(<option[^>]*value=['"]([^'"]+)['"][^>]*>)/gi,(se,ie,oe)=>{if((Array.isArray(V)?V.some((ue)=>String(ue)===oe):String(V)===oe)&&!ie.includes("selected"))return ie.replace(/(<option)/,"$1 selected");return se});return`<select name="${Vt(j)}"${Ps(F,vn(j))} class="${J}"${Oc(j,H,F)}${ne?` ${ne}`:""}>${re}</select>`}),E=E.replace(/@checkbox\(\s*['"]([^'"]+)['"]\s*(?:,\s*['"]([^'"]+)['"]\s*)?(?:,\s*\{([^}]+)\})?\)/g,(T,j,B,z="")=>{let F=B===void 0?"1":B,V=B===void 0?vn(j):`${vn(j)}-${vn(F)}`,H=yr(z),G=Qs(j,_),J=G!==void 0&&(Array.isArray(G)?G.some((ie)=>String(ie)===F):G===!0||String(G)===F),ne=H.match(/class=['"]([^'"]+)['"]/i),re=ne?ne[1]:k.checkInput,se=H.replace(/class=['"][^'"]+['"]/i,"");return`<input type="checkbox" name="${Vt(j)}"${Ps(H,V)} value="${Vt(F)}" class="${re}"${J?" checked":""}${se?` ${se}`:""}>`}),E=E.replace(/@radio\(\s*['"]([^'"]+)['"]\s*,\s*['"]([^'"]+)['"]\s*(?:,\s*\{([^}]+)\})?\)/g,(T,j,B,z="")=>{let F=yr(z),V=Qs(j,_),H=V!==void 0&&V===B,G=F.match(/class=['"]([^'"]+)['"]/i),J=G?G[1]:k.checkInput,ne=F.replace(/class=['"][^'"]+['"]/i,"");return`<input type="radio" name="${Vt(j)}"${Ps(F,`${vn(j)}-${vn(B)}`)} value="${Vt(B)}" class="${J}"${H?" checked":""}${ne?` ${ne}`:""}>`}),E=E.replace(/@file\(\s*['"]([^'"]+)['"]\s*(?:,\s*\{([^}]+)\})?\)/g,(T,j,B="")=>{let z=yr(B),F=z.match(/accept=['"]([^'"]+)['"]/i),V=F?F[1]:"",H=z.includes("multiple"),G=pi(j,_),J=z.match(/class=['"]([^'"]+)['"]/i),ne=io(J?J[1]:"",k.input,G,k.inputError),re=z.replace(/class=['"][^'"]+['"]/gi,"").replace(/accept=['"][^'"]+['"]/gi,"").replace(/\bmultiple\b/gi,"").trim(),se=[`<input type="file" name="${Vt(j)}"${Ps(z,vn(j))}`,`class="${ne}"`];if(V)se.push(`accept="${Vt(V)}"`);if(H)se.push("multiple");if(re)se.push(re);return`${se.join(" ")}>`}),E=E.replace(/@label\(\s*['"]([^'"]+)['"]\s*(?:,\s*\{([^}]+)\})?\)([\s\S]*?)@endlabel/g,(T,j,B="",z)=>{let F=yr(B),V=F.match(/class=['"]([^'"]+)['"]/i),H=V?V[1]:k.label,G=F.replace(/class=['"][^'"]+['"]/i,"");return`<label for="${Vt(vn(j))}" class="${H}"${G?` ${G}`:""}>${z}</label>`}),E}function Af(v,_,k=Rf){return v.replace(/@error\(['"]([^'"]+)['"]\)([\s\S]*?)@enderror/g,(E,T,j)=>{try{if(pi(T,_)){let B=j.replace(/\{\{([^}]+)\}\}/g,(z,F)=>{try{if(F.trim()==="$message"||F.trim()==="message")return Cf(T,_);if(F.trim().includes("errors.first")||F.trim().includes("$errors.first")){if(typeof _.errors?.first==="function")return _.errors.first(T);return Cf(T,_)}let V=F.trim();if(p(V)){let H=c(V,_);return H!==void 0?String(H):V}return V}catch{return F}});return`<div id="${Vt(`${vn(T)}-error`)}" role="alert">${B}</div>`}return""}catch(B){return console.error("Error processing @error directive:",B),E}})}function pi(v,_){if(!_.errors)return!1;if(typeof _.errors.has==="function")return _.errors.has(v);if(typeof _.errors==="object")return Object.prototype.hasOwnProperty.call(_.errors,v);return!1}function Cf(v,_){if(!_.errors)return"";if(typeof _.errors.get==="function")return _.errors.get(v);if(typeof _.errors==="object"&&Object.prototype.hasOwnProperty.call(_.errors,v)){let k=_.errors[v];return Array.isArray(k)?k[0]:String(k)}return""}function Qs(v,_){let k;if(_.old&&typeof _.old==="function")return _.old(v);if(_.old&&typeof _.old==="object")return _.old[v];if(v.endsWith("[]")){let E=v.slice(0,-2);if(k=_[E],k!==void 0)return k}return _[v]}function yr(v){if(!v.trim())return"";let _=[],k=v.trim(),E=/([\w-]+)\s*:\s*(['"]?)([^,'"]*)\2(?:\s*,\s*|\s*$)/g,T;while((T=E.exec(k))!==null){let[,j,,B]=T;_.push(`${j}="${B.trim()}"`)}return _.join(" ")}var mi=/<\/?template\b[^>]*>/gi,Ax=/(?:^|\s)(?:id\s*=|(?:x-|[@:])(?:for|if|else(?:-if)?)(?=\s|=|$)|#[\w-]+(?:\s*=|\s|$)|v-slot(?::[\w-]+)?(?=\s|=|$)|slot\s*=)/i;function Ix(v){let _=v.replace(/^<template\b/i,"").replace(/>$/,"");return Ax.test(_)}function Z(v){mi.lastIndex=0;let _;while((_=mi.exec(v))!==null){if(_[0].startsWith("</")||Ix(_[0]))continue;let k=_.index,E=mi.lastIndex,T=1,j;while((j=mi.exec(v))!==null)if(j[0].startsWith("</")){if(T--,T===0){let B=j.index;return{start:k,openEnd:E,closeStart:B,end:mi.lastIndex,content:v.slice(E,B)}}}else T++;return null}return null}import Ot from"path";import{existsSync as Rb}from"fs";import ao from"fs";import zt from"path";var If=new Map;function co(v,_=!0){let k=If.get(v);if(_&&k)return k;let E=new Map,T=[zt.join(v,"src"),zt.join(v,"dist"),v];function j(B,z){if(z>6)return;let F;try{F=ao.readdirSync(B,{withFileTypes:!0})}catch{return}for(let V of F){let H=zt.join(B,V.name);if(V.isDirectory()){if(V.name==="node_modules"||V.name.startsWith("."))continue;j(H,z+1)}else if(V.isFile()&&V.name.endsWith(".stx")){let G=V.name.slice(0,-4);if(!E.has(G))E.set(G,H);let J=G.toLowerCase();if(!E.has(J))E.set(J,H);let ne=G.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();if(!E.has(ne))E.set(ne,H)}}}for(let B of T)if(j(B,0),E.size>0)break;if(_)If.set(v,E);return E}function lo(v,_){if(v.startsWith(".")||v.startsWith("/"))return null;let k=_;while(!0){let E=zt.join(k,"node_modules",v);try{if(ao.statSync(E).isDirectory())return E}catch{}let T=zt.dirname(k);if(T===k)return null;k=T}}function uo(v,_,k={}){return[zt.resolve(zt.dirname(_),`${v}.stx`),zt.resolve(zt.dirname(_),v),zt.resolve(k.componentsDir||"components",`${v}.stx`),zt.resolve(k.componentsDir||"components",v),v.endsWith(".stx")?v:`${v}.stx`]}function Pf(v){let _=v.endsWith(".stx")?v.slice(0,-4):v,k=_.split("-").map((T)=>T.charAt(0).toUpperCase()+T.slice(1)).join(""),E=_.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();return[_,k,E]}function Nc(v,_){let[k,E,T]=Pf(v);for(let j of[k,k.toLowerCase(),E,T]){let B=_?.__importedComponents?.get(j);if(B!==void 0)return B}}function*jc(v,_,k={},E){let T=Pf(v);if(T[0].startsWith("./")||T[0].startsWith("../")){yield zt.resolve(zt.dirname(_),`${T[0]}.stx`);return}let j=[...new Set(T.map((F)=>`${F}.stx`))],B=k.projectRoot||process.cwd(),z=[...E?.__originalFilePath?[zt.join(zt.dirname(E.__originalFilePath),"components")]:[],...k.componentsDir?[k.componentsDir]:[],zt.join(zt.dirname(_),"components"),zt.resolve(B,"src/components"),zt.resolve(B,"components"),...import.meta.dir?[zt.resolve(import.meta.dir,"components")]:[]];for(let F of new Set(z)){for(let V of j)yield zt.join(F,V);try{for(let V of ao.readdirSync(F,{withFileTypes:!0}))if(V.isDirectory())for(let H of j)yield zt.join(F,V.name,H)}catch{}}}function Df(v,_,k={},E){let T=Nc(v,E);if(T!==void 0)return T;for(let j of jc(v,_,k,E))try{if(ao.statSync(j,{throwIfNoEntry:!1})?.isFile())return j}catch{}return null}class Mf{builtins=new Map;registerBuiltin(v){this.builtins.set(v.name.toLowerCase(),v);for(let _ of v.aliases)this.builtins.set(_.toLowerCase(),v)}isBuiltin(v){return this.builtins.has(v.toLowerCase())}getBuiltin(v){return this.builtins.get(v.toLowerCase())??null}async resolveFile(v,_,k,E){let T=Nc(v,E);if(T!==void 0)return T;for(let j of jc(v,_,k,E))if(await r(j))return j;return null}}var Ds=new Mf;function jt(v){return v.replace(/&/g,"&").replace(/"/g,""").replace(/'/g,"'").replace(/</g,"<").replace(/>/g,">")}var Ir="\x00stx-boolean-attribute";function Lc(v){return v.indexOf("\x00")===-1?v:v.replace(/\0/g,"")}function xr(v,_){let k=[];for(let[E,T]of Object.entries(v.static)){if(_.has(E))continue;let j=v.staticNames?.[E]??E;if(typeof T==="boolean"){if(T)k.push(jt(j));continue}if(T===Ir){k.push(jt(j));continue}k.push(`${jt(j)}="${jt(Lc(String(T)))}"`)}return k}function br(v,_){let k=[];for(let[E,T]of Object.entries(v.serverDynamic??{})){if(_.has(E))continue;if(T===null||T===void 0||T===!1)continue;let j=v.serverDynamicNames?.[E]??E;if(T===!0){k.push(jt(j));continue}if(typeof T==="object")continue;k.push(`${jt(j)}="${jt(Lc(String(T)))}"`)}return k}function Ms(v){return v.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}function Px(v){if(v.clientReactive.to)return{value:v.clientReactive.to,reactive:!0};if(v.serverDynamic.to!==void 0)return{value:String(v.serverDynamic.to),reactive:!1};if(typeof v.static.to==="string")return{value:v.static.to,reactive:!1};return{value:"#",reactive:!1}}var Bc={name:"StxLink",aliases:["stx-link"],render(v,_,k){let E=Px(v),T=(typeof v.static.class==="string"?v.static.class:"")||(typeof v.static.className==="string"?v.static.className:""),j=typeof v.static.activeClass==="string"?v.static.activeClass:"active",B=typeof v.static.exactActiveClass==="string"?v.static.exactActiveClass:"exact-active",z=v.static.prefetch===!0||v.static.prefetch==="true"||v.serverDynamic.prefetch===!0,F=[];if(E.reactive)F.push(`:href="${Ms(E.value)}"`);else F.push(`href="${Ms(Hs(E.value,"navigable"))}"`);if(T)F.push(`class="${Ms(T)}"`);if(F.push("data-stx-link"),F.push(`data-stx-active-class="${Ms(j)}"`),F.push(`data-stx-exact-active-class="${Ms(B)}"`),z)F.push("data-stx-prefetch");let V=typeof v.static.activeMatch==="string"?v.static.activeMatch.trim():"";if(V)F.push(`data-stx-active-match="${Ms(V)}"`);let H=new Set(["to","class","className","activeClass","exactActiveClass","activeMatch","prefetch"]);return F.push(...xr(v,H)),F.push(...br(v,H)),`<a ${F.join(" ")}>${_}</a>`}};import{createHash as qf}from"crypto";import ln from"fs";import Ut from"path";import{decode as zx,generateThumbHash as Fx}from"ts-images";import{createImageDeliveryCatalog as zf}from"ts-images/delivery";import zc from"fs";function fo(v,_,k){let E=Buffer.alloc(k),T=zc.readSync(v,E,0,k,_);return E.subarray(0,T)}function Fc(v){if(v.length<25)return!1;let _=(E,T)=>String.fromCharCode(...v.subarray(E,T));if(_(0,4)!=="RIFF"||_(8,12)!=="WEBP")return!1;let k=_(12,16);if(k==="VP8X")return(v[20]&16)!==0;if(k==="VP8L")return((v[21]|v[22]<<8|v[23]<<16|v[24]<<24)>>>28&1)===1;return!1}function Wc(v){let _;try{_=zc.openSync(v,"r");let k=fo(_,0,33);if(k.length>=3&&k[0]===255&&k[1]===216&&k[2]===255)return"none";if(k.length>=26&&k[0]===137&&k.toString("latin1",1,4)==="PNG"){let E=k[25];if(E===4||E===6)return"possible";let T=8;for(let j=0;j<64;j++){let B=fo(_,T,8);if(B.length<8)return"unknown";let z=B.toString("latin1",4,8);if(z==="tRNS")return"possible";if(z==="IDAT"||z==="IEND")return"none";T+=12+B.readUInt32BE(0)}return"unknown"}if(k.length>=25&&k.toString("latin1",0,4)==="RIFF"&&k.toString("latin1",8,12)==="WEBP"){if(Fc(k))return"possible";let E=k.toString("latin1",12,16);return E==="VP8 "||E==="VP8X"?"none":"unknown"}return"unknown"}catch{return"unknown"}finally{if(_!==void 0)zc.closeSync(_)}}import Dx from"fs";import po from"os";import{join as Of}from"path";import{fileURLToPath as Nf}from"url";import{Worker as jf}from"worker_threads";var mo=Symbol("stx.image-worker.unavailable");function Mx(v=typeof po.availableParallelism==="function"?po.availableParallelism():po.cpus().length){return Math.max(1,Math.min(2,v-1))}var go=0,Bf=[];async function Ox(){if(go<Mx()){go++;return}await new Promise((v)=>Bf.push(v)),go++}function Nx(){go--,Bf.shift()?.()}var jx="@stacksjs/stx/builtins/image-warmup-worker";function Lx(v=process.cwd()){let _=import.meta.url.endsWith(".ts")?"ts":"js";try{let k=new URL(`./image-warmup-worker.${_}`,import.meta.url);if(k.protocol==="file:"&&Dx.existsSync(Nf(k)))return Nf(k)}catch{}try{let k=typeof Bun<"u"?Bun.resolveSync(jx,v):void 0;return k&&Bx(k)?k:void 0}catch{return}}function Bx(v,_=process.env){let k=v.replace(/\\/g,"/");if(k.split("/").some((T)=>/@\d[^/]*@@@\d+$/.test(T)))return!1;return![_.BUN_INSTALL_CACHE_DIR,Of(_.BUN_INSTALL||Of(po.homedir(),".bun"),"install","cache")].filter((T)=>!!T).map((T)=>`${T.replace(/\\/g,"/").replace(/\/$/,"")}/`).some((T)=>k.startsWith(T))}var Lf=!1;function hi(v){if(!Lf)Lf=!0,console.warn(`[stx] image worker unavailable (${v}); running the image pass on the serving thread instead. Results are the same, but requests may stall while it runs.`);return mo}function Vc(v){return v instanceof Error?v.message:String(v)}async function Uc(v,_){if(typeof jf!=="function")return hi("node:worker_threads has no Worker in this runtime");let k=Lx();if(!k)return hi("no image-warmup-worker entry beside this module or in the installed @stacksjs/stx");await Ox();try{return await new Promise((E,T)=>{let j;try{j=new jf(k)}catch(V){E(hi(`could not start ${k}: ${Vc(V)}`));return}let B=!1,z=!1,F=(V)=>{if(z)return;z=!0,V(),j.terminate()};j.on("message",(V)=>{if(V.type==="ready"){B=!0,j.postMessage({task:v,args:_});return}if(V.type==="result"){F(()=>E(V.value));return}let H=Error(V.error?.message??"image worker failed");if(V.error?.name)H.name=V.error.name;if(V.error?.stack)H.stack=V.error.stack;F(()=>T(H))}),j.on("error",(V)=>{F(()=>B?T(V instanceof Error?V:Error(Vc(V)||"image worker crashed")):E(hi(`the worker failed before it was ready: ${Vc(V)}`)))}),j.on("exit",(V)=>{F(()=>B?T(Error("image worker exited before it finished")):E(hi(`the worker exited with code ${V} before it was ready`)))})})}finally{Nx()}}var Wx=new Set([".avif",".jpeg",".jpg",".png",".webp"]),Vx=[320,640,960,1280,1920],yo="/_stx/images",Ux=`stx:${yo}:alpha-1`,Hx=["@stacksjs/ts-webp","@stacksjs/ts-avif"],ho;function qx(v,_){let k=Ut.dirname(Bun.resolveSync(v,_));while(k!==Ut.dirname(k)){let E=Ut.join(k,"package.json");if(ln.existsSync(E)){let T=JSON.parse(ln.readFileSync(E,"utf8"));if(T.name===v)return T.version}k=Ut.dirname(k)}return}function Kx(){if(ho!==void 0)return ho;let v;try{v=Ut.dirname(Bun.resolveSync("ts-images",import.meta.dir))}catch{}return ho=Hx.map((_)=>{let k;try{k=v?qx(_,v):void 0}catch{}return`${_.replace("@stacksjs/","")}@${k??"unknown"}`}).join("+"),ho}var Ff=Symbol.for("stx.image-delivery");function bi(){let v=globalThis;return v[Ff]??={catalog:new Map,transparent:new Set},v[Ff]}var Wf=new Set;function Xx(v){return`/${v.split(Ut.sep).map(encodeURIComponent).join("/")}`}function Zx(v){let _=Ut.extname(v),k=v.slice(0,-_.length).replace(/[^a-zA-Z0-9_-]+/g,"-").replace(/^-+|-+$/g,""),E=qf("sha256").update(v).digest("hex").slice(0,8);return`${k||"image"}-${E}`}function Vf(v,_=`stx:${yo}`){let k=(E)=>`${yo}/${E.split("/").map(encodeURIComponent).join("/")}`;return{cacheNamespace:_,async stat(E){let T=Ut.join(v,E);try{let j=await ln.promises.stat(T);return j.size>0?{bytes:j.size,path:T,url:k(E)}:null}catch{return null}},async write(E,T){let j=Ut.join(v,E);await ln.promises.mkdir(Ut.dirname(j),{recursive:!0});let B=`${j}.${process.pid}.tmp`;return await ln.promises.writeFile(B,T),await ln.promises.rename(B,j),{bytes:T.byteLength,path:j,url:k(E)}},url:k}}async function Kf(v,_=v){let k=await ln.promises.readdir(_,{withFileTypes:!0});k.sort((T,j)=>T.name.localeCompare(j.name));let E=[];for(let T of k){let j=Ut.join(_,T.name);if(T.isDirectory()){E.push(...await Kf(v,j));continue}if(!T.isFile()||!Wx.has(Ut.extname(T.name).toLowerCase()))continue;E.push({absolutePath:j,relativePath:Ut.relative(v,j)})}return E}function Uf(v,_){return v.map((k)=>({key:Xx(k.relativePath),input:k.absolutePath,name:Zx(k.relativePath),...Gx(k.absolutePath)?{options:{storage:_}}:{}}))}function Gx(v){return Wc(v)==="possible"}function Jx(v){for(let _=3;_<v.length;_+=4)if(v[_]!==255)return!0;return!1}async function Yx(v){let _=Object.entries(v).filter(([,T])=>T.fallback.format==="png"),k=new Set,E=8;for(let T=0;T<_.length;T+=8)await Promise.all(_.slice(T,T+8).map(async([j,B])=>{let z=B.variants.filter((F)=>F.format==="png").sort((F,V)=>F.width-V.width)[0];try{let F=await zx(new Uint8Array(await ln.promises.readFile(z?.path??B.fallback.path)));if(Jx(F.data))k.add(j)}catch{k.add(j)}}));return k}function Qx(v,_){let k=[];for(let E of _){let T=v[E],j=T?.variants.filter((z)=>z.format==="webp")??[];if(!T||j.length===0)continue;if(!j.some((z)=>{let F;try{return F=ln.openSync(z.path,"r"),!Fc(fo(F,0,32))}catch{return!0}finally{if(F!==void 0)ln.closeSync(F)}}))continue;if(T.variants=T.variants.filter((z)=>z.format!=="webp"),delete T.sources.webp,k.push(E),!Wf.has(E))Wf.add(E),console.warn(`[stx-images] ${E} is transparent but its WebP variants have no alpha channel; serving PNG instead. Upgrade @stacksjs/ts-webp to 0.1.6 or later.`)}return k}async function eb(v){let _=[],k=8;for(let E=0;E<v.length;E+=8){let T=v.slice(E,E+8),j=await Promise.all(T.map(async(B)=>{try{return await Fx(B.absolutePath),B}catch{return console.warn(`[stx-images] Skipping unreadable raster: ${B.relativePath}`),null}}));_.push(...j.filter((B)=>B!==null))}return _}function Hc(v){return Ut.join(v,"undecodable.json")}function tb(v){try{let _=ln.readFileSync(Hc(v),"utf-8"),k=JSON.parse(_);return k&&typeof k==="object"?k:{}}catch{return{}}}function nb(v,_){try{ln.mkdirSync(Ut.dirname(Hc(v)),{recursive:!0}),ln.writeFileSync(Hc(v),JSON.stringify(_))}catch{}}function Hf(v){try{let _=ln.statSync(v);return{mtimeMs:_.mtimeMs,size:_.size}}catch{return}}function Xf(v){if(!v||v.startsWith("data:")||v.startsWith("blob:")||/^https?:\/\//i.test(v)||v.startsWith("//"))return;let _=v.split(/[?#]/,1)[0];if(!_)return;try{return`/${_.replace(/^\/+/,"").split("/").map(decodeURIComponent).map(encodeURIComponent).join("/")}`}catch{return}}function Zr(v){let _=Xf(v);return _?bi().catalog.get(_):void 0}function Qr(v){let _=Xf(v);return _?bi().transparent.has(_):!1}function es(v){let _=(E)=>v.variants.filter((T)=>T.format===E).reduce((T,j)=>T+j.bytes,0),k=_(v.fallback.format);return["avif","webp"].map((E)=>({format:E,srcset:v.sources[E]||"",bytes:_(E)})).filter((E)=>E.srcset&&E.bytes>0&&E.bytes<k).sort((E,T)=>E.bytes-T.bytes).map(({format:E,srcset:T})=>({format:E,srcset:T}))}function Ou(v){let _=Zr(v);if(!_)return;return{src:_.fallback.url,srcset:_.sources[_.fallback.format]||"",sources:es(_).map(({format:k,srcset:E})=>({type:`image/${k}`,srcset:E})),width:_.source.width,height:_.source.height,placeholder:Qr(v)?void 0:_.placeholder?.dataUrl}}function jn(){let v=bi();v.catalog=new Map,v.transparent=new Set}function rb(v){let _=bi();_.catalog=new Map(v.entries),_.transparent=new Set(v.transparent)}async function Mu(v,_,k={}){if(!v||!ln.existsSync(v))return jn(),{count:0,fingerprint:""};if(k.offThread){let re=await Uc("delivery",{publicDir:v,outputDir:_});if(re!==mo)return rb(re.state),re.result}let E=await Kf(v);if(E.length===0)return jn(),{count:0,fingerprint:""};let T=tb(_),j=E.filter((re)=>{let se=T[re.relativePath];if(!se)return!0;let ie=Hf(re.absolutePath);return!ie||ie.mtimeMs!==se.mtimeMs||ie.size!==se.size});if(j.length===0)return jn(),{count:0,fingerprint:""};let B=Vf(Ut.join(_,"_stx","images"),`${Ux}:${Kx()}`),z={outDir:Ut.join(_,"_stx","images"),storage:Vf(Ut.join(_,"_stx","images")),baseUrl:yo,widths:Vx,formats:["avif","webp"],quality:{avif:70,webp:78,jpeg:82,png:100},includeOriginal:!1,placeholder:!0,batchConcurrency:4,concurrency:4},F=j,V;try{V=await zf({...z,entries:Uf(j,B)})}catch(re){if(F=await eb(j),F.length===j.length)throw re;let se=new Set(F.map((oe)=>oe.relativePath)),ie=!1;for(let oe of j){if(se.has(oe.relativePath))continue;let ge=Hf(oe.absolutePath);if(!ge)continue;T[oe.relativePath]=ge,ie=!0}if(ie)nb(_,T);if(F.length===0)return jn(),{count:0,fingerprint:""};V=await zf({...z,entries:Uf(F,B)})}let H=await Yx(V.entries),G=Qx(V.entries,H),J=bi();J.catalog=new Map(Object.entries(V.entries)),J.transparent=H;let ne=H.size===0&&G.length===0?V.fingerprint:qf("sha256").update(V.fingerprint).update(JSON.stringify({transparent:[...H].sort(),droppedWebp:G.sort()})).digest("hex");return{count:F.length,fingerprint:ne}}var sb=new Map;function qc(v){if(!v)return;let _=v.split("?")[0].split("#")[0];return sb.get(_)}var ib={sm:640,md:768,lg:1024,xl:1280,"2xl":1536},Kc=[320,640,768,1024,1280,1536,1920];function Ft(v){return v.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}function Xt(v,_){if(v.serverDynamic[_]!==void 0)return String(v.serverDynamic[_]);let k=v.static[_];if(typeof k==="string")return k;return}function xo(v,_,k=!1){let E=v.serverDynamic[_];if(E!==void 0)return E!==!1&&E!=="false";let T=v.static[_];if(T!==void 0)return T!=="false"&&T!==!1;return k}function Xc(v){if(v.includes("(")||v.includes(","))return v;let _=v.trim().split(/\s+/),k=[];for(let E of _)if(E.includes(":")){let[T,j]=E.split(":"),B=ib[T];if(B)k.push(`(max-width: ${B}px) ${j}`);else{let z=Number.parseInt(T);if(!Number.isNaN(z))k.push(`(max-width: ${z}px) ${j}`)}}else k.push(E);return k.join(", ")}function Zc(v,_,k,E){return _.map((T)=>`${vi(v,T,void 0,k,E)} ${T}w`).join(", ")}function ob(v,_,k,E,T){return _.map((j)=>{let B=k?k*j:void 0;return`${vi(v,B,void 0,E,T)} ${j}x`}).join(", ")}function vi(v,_,k,E,T){if(!E||E==="local"||E==="static")return v;if(E==="cloudinary"){let j=[];if(_)j.push(`w_${_}`);if(k)j.push(`h_${k}`);if(T)j.push(`f_${T}`);j.push("q_auto");let B=j.join(",");return v.replace("/upload/",`/upload/${B}/`)}if(E==="imgix"){let j=new URLSearchParams;if(_)j.set("w",String(_));if(k)j.set("h",String(k));if(T)j.set("fm",T);j.set("auto","format");let B=v.includes("?")?"&":"?";return`${v}${B}${j.toString()}`}if(E==="bunny"){let j=new URLSearchParams;if(_)j.set("width",String(_));if(k)j.set("height",String(k));if(T)j.set("format",T);let B=v.includes("?")?"&":"?";return`${v}${B}${j.toString()}`}return v}function ab(v){return`var s=this.style;${v.map((_)=>`s.${_}=''`).join(";")}`}function cb(v,_,k="#e5e7eb"){let E=`<svg xmlns="http://www.w3.org/2000/svg" width="${v}" height="${_}"><rect width="100%" height="100%" fill="${k}"/></svg>`;return`data:image/svg+xml;base64,${btoa(E)}`}var Gc={name:"StxImage",aliases:["Image","stx-image","stx-img"],render(v,_,k){let E=Xt(v,"src")||"",T=Zr(E),j=Xt(v,"alt")||"",B=Xt(v,"width")||(T?String(T.source.width):void 0),z=Xt(v,"height")||(T?String(T.source.height):void 0),F=Xt(v,"sizes"),V=Xt(v,"srcset"),H=Xt(v,"densities"),G=Xt(v,"format"),J=Qr(E)||qc(E)?.transparent===!0,ne=Xt(v,"placeholder")||(T&&!J?"thumbhash":void 0),re=Xt(v,"placeholderColor")||"#e5e7eb",se=Xt(v,"provider"),ie=Xt(v,"class")||Xt(v,"className")||"",oe=Xt(v,"style")||"",ge=Xt(v,"quality"),ue=xo(v,"lazy",!0),xe=xo(v,"preload",!1),we=xo(v,"priority",!1),$e=Xt(v,"loading"),_e=Xt(v,"decoding")||"async",Ce=!!T||xo(v,"picture",!1)||!!G,Ee=B?Number.parseInt(B):void 0,Te=z?Number.parseInt(z):void 0,Re=V||"",ke="";if(T)Re=T.sources[T.fallback.format]||"",ke=F?Xc(F):"100vw";else if(!Re&&F&&se&&se!=="local"&&se!=="static")Re=Zc(E,Kc,se,G),ke=Xc(F);else if(!Re&&H){let ft=H.split(/\s+/).map((yt)=>Number.parseFloat(yt.replace("x","")));Re=ob(E,ft,Ee,se,G)}else if(F)ke=Xc(F);let Ae=[];if(oe)Ae.push(oe);if(Ee&&Te)Ae.push(`aspect-ratio:${Ee}/${Te}`);let Xe=[],Pe=ne==="blur"||ne==="color"||ne==="thumbhash";if(Pe&&!J){let ft=T?.placeholder?{dataUrl:T.placeholder.dataUrl,color:re}:qc(E);if(ft&&ne==="color")Ae.push(`background-color:${ft.color}`),Xe.push("backgroundColor");else if(ft)Ae.push(`background-color:${ft.color}`),Ae.push(`background-image:url(${ft.dataUrl})`),Ae.push("background-size:cover"),Ae.push("background-repeat:no-repeat"),Xe.push("backgroundColor","backgroundImage");else{let yt=cb(Ee||16,Te||9,re);Ae.push(`background-image:url(${yt})`),Ae.push("background-size:cover"),Ae.push("background-repeat:no-repeat"),Xe.push("backgroundImage")}}else if(!Pe&&ne&&ne!=="empty"&&ne!=="none")Ae.push(`background-image:url(${Ft(ne)})`),Ae.push("background-size:cover"),Ae.push("background-repeat:no-repeat"),Xe.push("backgroundImage");let Ie=T?.fallback.url||vi(E,Ee,Te,se,G),Ze=[];if(Ze.push(`src="${Ft(Hs(Ie,"fetched"))}"`),Ze.push(`alt="${Ft(j)}"`),B)Ze.push(`width="${Ft(B)}"`);if(z)Ze.push(`height="${Ft(z)}"`);let nt=$e||(we||xe?"eager":ue?"lazy":"");if(nt)Ze.push(`loading="${Ft(nt)}"`);if(we)Ze.push('fetchpriority="high"');if(Ze.push(`decoding="${Ft(_e)}"`),ie)Ze.push(`class="${Ft(ie)}"`);if(Ae.length>0)Ze.push(`style="${Ft(Ae.join(";"))}"`);if(Re)Ze.push(`srcset="${Ft(Hs(Re,"fetched"))}"`);if(ke)Ze.push(`sizes="${Ft(ke)}"`);let at=new Set(["src","alt","width","height","lazy","sizes","srcset","placeholder","placeholderColor","class","className","style","format","provider","quality","densities","preload","priority","picture","loading","decoding"]);if(Xe.length>0){let ft=typeof v.static.onload==="string"?v.static.onload:"",yt=ab(Xe)+(ft?`;${ft}`:"");Ze.push(`onload="${Ft(yt)}"`),at.add("onload")}Ze.push(...xr(v,at)),Ze.push(...br(v,at));let rt=`<img ${Ze.join(" ")} />`,bt="";if(xe){let yt=G==="webp"?"image/webp":G==="avif"?"image/avif":"";bt=`<link rel="preload" as="image" href="${Ft(Ie)}"${yt?` type="${yt}"`:""}${Re?` imagesrcset="${Ft(Re)}"`:""}${ke?` imagesizes="${Ft(ke)}"`:""} />
|
|
1710
|
+
`}if(Ce){let ft=[];if(T)for(let yt of es(T))ft.push(`<source type="image/${yt.format}" srcset="${Ft(yt.srcset)}"${ke?` sizes="${Ft(ke)}"`:""} />`);if(!T&&(G==="avif"||G==="auto")){let yt=vi(E,Ee,Te,se,"avif"),ct=Re?Zc(E,Kc,se,"avif"):`${yt}`;ft.push(`<source type="image/avif" srcset="${Ft(ct)}"${ke?` sizes="${Ft(ke)}"`:""} />`)}if(!T&&(G==="webp"||G==="auto")){let yt=vi(E,Ee,Te,se,"webp"),ct=Re?Zc(E,Kc,se,"webp"):`${yt}`;ft.push(`<source type="image/webp" srcset="${Ft(ct)}"${ke?` sizes="${Ft(ke)}"`:""} />`)}return`${bt}<picture>
|
|
1711
|
+
${ft.join(`
|
|
1712
|
+
`)}
|
|
1713
|
+
${rt}
|
|
1714
|
+
</picture>`}return`${bt}${rt}`}};var Zf="/images/safe-image-default.svg";function _i(v){return v.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}function Os(v,_){if(v.serverDynamic[_]!==void 0)return String(v.serverDynamic[_]);let k=v.static[_];if(typeof k==="string")return k;return}var lb=`<script>window.__stxSafeImageHandler||(window.__stxSafeImageHandler=function(i){if(i.__stx_fb)return;i.__stx_fb=1;var f=i.getAttribute('data-fallback')||'${Zf}';var c=i.getAttribute('data-fallback-class');i.src=f;if(c)i.className=c;});</script>`,Jc={name:"SafeImage",aliases:["safe-image","safe-img"],render(v,_,k){let E=Os(v,"src")||"",T=Os(v,"alt")||"",j=Os(v,"fallback")||Zf,B=Os(v,"class")||Os(v,"className")||"",z=Os(v,"fallbackClassName")||"",F=[];if(F.push(`src="${_i(E)}"`),F.push(`alt="${_i(T)}"`),B)F.push(`class="${_i(B)}"`);if(F.push(`data-fallback="${_i(j)}"`),z)F.push(`data-fallback-class="${_i(z)}"`);F.push('onerror="window.__stxSafeImageHandler(this)"');let V=new Set(["src","alt","fallback","class","className","fallbackClassName"]);F.push(...xr(v,V)),F.push(...br(v,V));let H=`<img ${F.join(" ")} />`,G=k.context;if(!G.__safeImageHandlerEmitted)return G.__safeImageHandlerEmitted=!0,`${lb}${H}`;return H}};function Yc(v){return v.replace(/[;{}()]/g,"").replace(/url/gi,"")}function Ei(v,_){if(v.serverDynamic[_]!==void 0)return String(v.serverDynamic[_]);let k=v.static[_];if(typeof k==="string")return k;return}function bo(v,_,k){let E=Ei(v,_);if(E!==void 0){let T=Number.parseInt(E,10);if(!Number.isNaN(T))return T}return k}var Qc={name:"StxLoadingIndicator",aliases:["stx-loading-indicator"],render(v,_,k){let E=Yc(Ei(v,"color")||"#6366f1"),T=Yc(Ei(v,"initialColor")||Ei(v,"initial-color")||""),j=Yc(Ei(v,"height")||"3px"),B=bo(v,"duration",2000),z=bo(v,"throttle",200),F=bo(v,"zIndex",999999)||bo(v,"z-index",999999),V=T?`linear-gradient(to right, ${T}, ${E})`:E;return`
|
|
1715
|
+
<div id="stx-loading-indicator" style="position:fixed;top:0;left:0;right:0;height:${j};background:${V};z-index:${F};transform:scaleX(0);transform-origin:left;transition:transform 0.1s ease-out,opacity 0.3s ease;opacity:0;pointer-events:none">
|
|
1716
|
+
<div style="position:absolute;top:0;left:0;right:0;bottom:0;background:linear-gradient(90deg,transparent 0%,rgba(255,255,255,0.4) 50%,transparent 100%);animation:stx-shimmer 1.5s infinite"></div>
|
|
1717
|
+
</div>
|
|
1718
|
+
<style>@keyframes stx-shimmer{0%{transform:translateX(-100%)}100%{transform:translateX(100%)}}</style>
|
|
1719
|
+
<script>
|
|
1720
|
+
(function(){var el=document.getElementById('stx-loading-indicator'),p=0,l=!1,i=null;function u(v){p=Math.min(Math.max(v,0),100);if(el){el.style.opacity=p>0?'1':'0';el.style.transform='scaleX('+(p/100)+')'}}window.stxLoading={start:function(){l=!0;p=0;u(10);if(i)clearInterval(i);i=setInterval(function(){if(!l)return;var r=90-p,inc=Math.max(0.5,r*0.1);if(p<90)u(p+inc)},${z})},finish:function(){l=!1;if(i){clearInterval(i);i=null}u(100);setTimeout(function(){if(el)el.style.opacity='0';setTimeout(function(){p=0;if(el)el.style.transform='scaleX(0)'},300)},200)},set:function(v){u(v)},clear:function(){l=!1;p=0;if(i){clearInterval(i);i=null}if(el){el.style.opacity='0';el.style.transform='scaleX(0)'}}};document.addEventListener('click',function(e){var a=e.target.closest&&e.target.closest('a');if(!a)return;var h=a.getAttribute('href');if(!h||h.startsWith('http')||h.startsWith('#')||h.startsWith('mailto:')||h.startsWith('tel:')||a.target==='_blank')return;window.stxLoading.start()});window.addEventListener('popstate',function(){window.stxLoading.start()});window.addEventListener('load',function(){window.stxLoading.finish()})})();
|
|
1721
|
+
</script>`}};function Jf(v,_){if(v.serverDynamic[_]!==void 0)return String(v.serverDynamic[_]);let k=v.static[_];if(typeof k==="string")return k;return}function ub(v,_,k){let E=Jf(v,_);if(E!==void 0){let T=Number.parseInt(E,10);if(!Number.isNaN(T))return T}return k}var Gf={"top-right":"top:1rem;right:1rem","top-left":"top:1rem;left:1rem","top-center":"top:1rem;left:50%;transform:translateX(-50%)","bottom-right":"bottom:1rem;right:1rem","bottom-left":"bottom:1rem;left:1rem","bottom-center":"bottom:1rem;left:50%;transform:translateX(-50%)"},el={name:"StxToast",aliases:["stx-toast"],render(v,_,k){let E=jt(Jf(v,"position")||"top-right"),T=ub(v,"max",5),j=Gf[E]||Gf["top-right"];return`<div id="stx-toast-container" data-stx-toast-position="${E}" data-stx-toast-max="${T}" style="position:fixed;${j};z-index:999999;display:flex;flex-direction:column;gap:0.5rem;pointer-events:none;max-width:24rem;width:100%"></div>
|
|
1722
|
+
<style>
|
|
1723
|
+
@keyframes stx-toast-in{from{opacity:0;transform:translateX(100%)}to{opacity:1;transform:translateX(0)}}
|
|
1724
|
+
@keyframes stx-toast-out{from{opacity:1;transform:translateX(0)}to{opacity:0;transform:translateX(100%)}}
|
|
1725
|
+
@keyframes stx-toast-in-left{from{opacity:0;transform:translateX(-100%)}to{opacity:1;transform:translateX(0)}}
|
|
1726
|
+
@keyframes stx-toast-out-left{from{opacity:1;transform:translateX(0)}to{opacity:0;transform:translateX(-100%)}}
|
|
1727
|
+
@keyframes stx-toast-in-center{from{opacity:0;transform:translateY(-1rem)}to{opacity:1;transform:translateY(0)}}
|
|
1728
|
+
@keyframes stx-toast-out-center{from{opacity:1;transform:translateY(0)}to{opacity:0;transform:translateY(-1rem)}}
|
|
1729
|
+
</style>`}};function vo(v,_){if(v.serverDynamic[_]!==void 0)return String(v.serverDynamic[_]);let k=v.static[_];if(typeof k==="string")return k;return}var Yf={sm:"max-width:24rem",md:"max-width:32rem",lg:"max-width:42rem",xl:"max-width:56rem",full:"max-width:calc(100vw - 2rem);max-height:calc(100vh - 2rem)"},tl={name:"StxModal",aliases:["stx-modal"],render(v,_,k){let E=vo(v,"id");if(!E)return console.warn('[stx] <StxModal> requires an "id" prop'),"<!-- StxModal: missing id prop -->";let T=jt(E),j=vo(v,"size")||"md",B=vo(v,"closeOnBackdrop")!=="false",z=vo(v,"closeOnEscape")!=="false",F=Yf[j]||Yf.md;return`<div id="stx-modal-${T}" class="stx-modal-backdrop" data-stx-modal="${T}" data-close-backdrop="${B}" data-close-escape="${z}" style="display:none;position:fixed;inset:0;z-index:99999;align-items:center;justify-content:center;background:rgba(0,0,0,0.5);backdrop-filter:blur(2px);opacity:0;transition:opacity 0.2s ease" aria-modal="true" role="dialog">
|
|
1730
|
+
<div class="stx-modal-panel" style="${F};width:100%;margin:1rem;border-radius:0.75rem;box-shadow:0 20px 60px rgba(0,0,0,0.3);overflow:hidden;transform:scale(0.95) translateY(8px);transition:transform 0.2s ease,opacity 0.2s ease;opacity:0;background:var(--stx-modal-bg,#fff);color:var(--stx-modal-text,#1f2937)">
|
|
1731
|
+
<div style="padding:1.5rem">${_}</div>
|
|
1732
|
+
</div>
|
|
1733
|
+
</div>
|
|
1734
|
+
<style>
|
|
1735
|
+
@media(prefers-color-scheme:dark){[data-stx-modal]{--stx-modal-bg:#1f2937;--stx-modal-text:#f3f4f6}}
|
|
1736
|
+
.stx-modal-backdrop[data-stx-modal-open]{display:flex!important;opacity:1}
|
|
1737
|
+
.stx-modal-backdrop[data-stx-modal-open] .stx-modal-panel{transform:scale(1) translateY(0);opacity:1}
|
|
1738
|
+
</style>`}};function Ns(v,_){if(v.serverDynamic[_]!==void 0)return String(v.serverDynamic[_]);let k=v.static[_];if(typeof k==="string")return k;return}var Qf={sm:"16rem",md:"24rem",lg:"32rem",xl:"40rem"},nl={name:"StxDrawer",aliases:["stx-drawer"],render(v,_,k){let E=Ns(v,"id");if(!E)return console.warn('[stx] <StxDrawer> requires an "id" prop'),"<!-- StxDrawer: missing id prop -->";let T=jt(E),j=Ns(v,"side")||"right",B=Ns(v,"size")||"md",z=Ns(v,"closeOnBackdrop")!=="false",F=Ns(v,"closeOnEscape")!=="false",V=Ns(v,"overlay")!=="false",H=Qf[B]||Qf.md,G=j==="left",J=G?"left:0":"right:0",ne=G?"translateX(-100%)":"translateX(100%)",re=G?"stx-drawer-slide-left":"stx-drawer-slide-right";return`<div id="stx-drawer-${T}" class="stx-drawer-backdrop" data-stx-drawer="${T}" data-close-backdrop="${z}" data-close-escape="${F}" style="display:none;position:fixed;inset:0;z-index:99999;${V?"background:rgba(0,0,0,0.5);backdrop-filter:blur(2px)":"background:transparent;pointer-events:none"};opacity:0;transition:opacity 0.2s ease" role="dialog" aria-modal="true">
|
|
1739
|
+
<div class="stx-drawer-panel" style="position:fixed;top:0;bottom:0;${J};width:${H};max-width:100vw;transform:${ne};transition:transform 0.3s cubic-bezier(0.4,0,0.2,1);background:var(--stx-drawer-bg,#fff);color:var(--stx-drawer-text,#1f2937);box-shadow:0 20px 60px rgba(0,0,0,0.3);overflow-y:auto;pointer-events:auto">
|
|
1740
|
+
<div style="padding:1.5rem">${_}</div>
|
|
1741
|
+
</div>
|
|
1742
|
+
</div>
|
|
1743
|
+
<style>
|
|
1744
|
+
@media(prefers-color-scheme:dark){[data-stx-drawer]{--stx-drawer-bg:#1f2937;--stx-drawer-text:#f3f4f6}}
|
|
1745
|
+
.stx-drawer-backdrop[data-stx-drawer-open]{display:block!important;opacity:1}
|
|
1746
|
+
.stx-drawer-backdrop[data-stx-drawer-open] .stx-drawer-panel{transform:translateX(0)}
|
|
1747
|
+
</style>`}};import{existsSync as db,readFileSync as fb}from"fs";var wo=new Map,ep=new Set;function pb(v){if(ep.has(v))return;ep.add(v),console.warn(`[stx] icon collection "${v}" is not installed, so its icons render as nothing. Install it with \`bun add -d @iconify-json/${v}\`.`)}function gb(v){let _=process.cwd();for(let k of[`${_}/node_modules/@iconify-json/${v}/icons.json`,`${_}/pantry/@iconify-json/${v}/icons.json`,`${_}/node_modules/@iconify/json/json/${v}.json`,`${_}/pantry/@iconify/json/json/${v}.json`])if(db(k))return k;for(let k of[`@iconify-json/${v}/icons.json`,`@iconify/json/json/${v}.json`])try{return u.resolve(k)}catch{}return null}function mb(v){if(wo.has(v))return wo.get(v);let _=gb(v);if(!_)return pb(v),null;try{let k=JSON.parse(fb(_,"utf8"));return wo.set(v,k.icons),k.icons}catch{return null}}function js(v,_){if(v.serverDynamic[_]!==void 0)return String(v.serverDynamic[_]);if(v.static[_]!==void 0)return String(v.static[_]);if(v.clientReactive[_]!==void 0)return v.clientReactive[_];return}var rl={name:"Icon",aliases:["icon","stx-icon"],render(v,_,k){let E=js(v,"name")??js(v,"icon");if(!E)return"<!-- Icon: missing name/icon prop -->";let T="lucide",j=E;if(E.includes(":")){let ge=E.split(":");T=ge[0],j=ge[1]}let B=jt(js(v,"size")||"24"),z=jt(js(v,"color")||"currentColor"),F=jt(js(v,"class")||""),V=jt(js(v,"style")||""),H=wo.get(T)??mb(T);if(!H)return`<!-- Icon: collection "${T}" not loaded -->`;let G=H[j];if(!G)return`<!-- Icon: "${j}" not found in ${T} -->`;let J=G.width||24,ne=G.height||24,re=`0 0 ${J} ${ne}`,se=G.body;if(z!=="currentColor")se=se.replace(/currentColor/g,z);let ie=F?` class="${F}"`:"",oe=V?` style="${V}"`:"";return`<svg xmlns="http://www.w3.org/2000/svg" width="${B}" height="${B}" viewBox="${re}" fill="none"${ie}${oe}>${se}</svg>`}};function sl(){return`
|
|
1748
|
+
(function(){
|
|
1749
|
+
var tip=null,hideTimer=null,currentEl=null;
|
|
1750
|
+
|
|
1751
|
+
function createTip(){
|
|
1752
|
+
tip=document.createElement("div");
|
|
1753
|
+
tip.id="stx-tooltip";
|
|
1754
|
+
tip.style.cssText="position:absolute;background:#1f2937;color:#fff;font-size:12px;line-height:1.4;padding:6px 10px;border-radius:6px;max-width:250px;z-index:999999;pointer-events:none;opacity:0;transition:opacity .15s ease;white-space:pre-wrap;word-wrap:break-word;box-shadow:0 2px 8px rgba(0,0,0,.25)";
|
|
1755
|
+
var arrow=document.createElement("div");
|
|
1756
|
+
arrow.className="stx-tip-arrow";
|
|
1757
|
+
arrow.style.cssText="position:absolute;width:0;height:0;border:5px solid transparent";
|
|
1758
|
+
tip.appendChild(arrow);
|
|
1759
|
+
var text=document.createElement("span");
|
|
1760
|
+
text.className="stx-tip-text";
|
|
1761
|
+
tip.appendChild(text);
|
|
1762
|
+
document.body.appendChild(tip);
|
|
1763
|
+
}
|
|
1764
|
+
|
|
1765
|
+
function position(el){
|
|
1766
|
+
var pos=el.getAttribute("x-tooltip-position")||"top";
|
|
1767
|
+
var r=el.getBoundingClientRect();
|
|
1768
|
+
var sy=window.scrollY,sx=window.scrollX;
|
|
1769
|
+
tip.style.display="block";
|
|
1770
|
+
tip.style.opacity="0";
|
|
1771
|
+
// Force layout so we can measure
|
|
1772
|
+
var tw=tip.offsetWidth,th=tip.offsetHeight;
|
|
1773
|
+
var arrow=tip.querySelector(".stx-tip-arrow");
|
|
1774
|
+
var left,top;
|
|
1775
|
+
|
|
1776
|
+
if(pos==="top"){
|
|
1777
|
+
left=r.left+r.width/2-tw/2+sx;
|
|
1778
|
+
top=r.top-th-8+sy;
|
|
1779
|
+
if(top-sy<0){pos="bottom";}
|
|
1780
|
+
}
|
|
1781
|
+
if(pos==="bottom"){
|
|
1782
|
+
left=r.left+r.width/2-tw/2+sx;
|
|
1783
|
+
top=r.bottom+8+sy;
|
|
1784
|
+
arrow.style.cssText="position:absolute;width:0;height:0;border:5px solid transparent;border-bottom-color:#1f2937;top:-10px;left:50%;transform:translateX(-50%)";
|
|
1785
|
+
}
|
|
1786
|
+
if(pos==="left"){
|
|
1787
|
+
left=r.left-tw-8+sx;
|
|
1788
|
+
top=r.top+r.height/2-th/2+sy;
|
|
1789
|
+
if(left-sx<0){pos="right";}
|
|
1790
|
+
}
|
|
1791
|
+
if(pos==="right"){
|
|
1792
|
+
left=r.right+8+sx;
|
|
1793
|
+
top=r.top+r.height/2-th/2+sy;
|
|
1794
|
+
arrow.style.cssText="position:absolute;width:0;height:0;border:5px solid transparent;border-right-color:#1f2937;left:-10px;top:50%;transform:translateY(-50%)";
|
|
1795
|
+
}
|
|
1796
|
+
|
|
1797
|
+
// Set arrow for top/left after potential flips
|
|
1798
|
+
if(pos==="top"){
|
|
1799
|
+
arrow.style.cssText="position:absolute;width:0;height:0;border:5px solid transparent;border-top-color:#1f2937;bottom:-10px;left:50%;transform:translateX(-50%)";
|
|
1800
|
+
}
|
|
1801
|
+
if(pos==="left"){
|
|
1802
|
+
arrow.style.cssText="position:absolute;width:0;height:0;border:5px solid transparent;border-left-color:#1f2937;right:-10px;top:50%;transform:translateY(-50%)";
|
|
1803
|
+
}
|
|
1804
|
+
|
|
1805
|
+
// Clamp horizontal
|
|
1806
|
+
if(left<sx+4) left=sx+4;
|
|
1807
|
+
if(left+tw>sx+window.innerWidth-4) left=sx+window.innerWidth-tw-4;
|
|
1808
|
+
|
|
1809
|
+
tip.style.left=left+"px";
|
|
1810
|
+
tip.style.top=top+"px";
|
|
1811
|
+
tip.style.opacity="1";
|
|
1812
|
+
}
|
|
1813
|
+
|
|
1814
|
+
function showTip(el){
|
|
1815
|
+
if(hideTimer){clearTimeout(hideTimer);hideTimer=null;}
|
|
1816
|
+
if(!tip) createTip();
|
|
1817
|
+
var text=el.getAttribute("x-tooltip");
|
|
1818
|
+
if(!text) return;
|
|
1819
|
+
tip.querySelector(".stx-tip-text").textContent=text;
|
|
1820
|
+
currentEl=el;
|
|
1821
|
+
position(el);
|
|
1822
|
+
}
|
|
1823
|
+
|
|
1824
|
+
function hideTip(){
|
|
1825
|
+
if(!tip) return;
|
|
1826
|
+
tip.style.opacity="0";
|
|
1827
|
+
hideTimer=setTimeout(function(){
|
|
1828
|
+
if(tip) tip.style.display="none";
|
|
1829
|
+
currentEl=null;
|
|
1830
|
+
},150);
|
|
1831
|
+
}
|
|
1832
|
+
|
|
1833
|
+
document.addEventListener("mouseover",function(e){
|
|
1834
|
+
var el=e.target.closest("[x-tooltip]");
|
|
1835
|
+
if(el) showTip(el);
|
|
1836
|
+
});
|
|
1837
|
+
document.addEventListener("mouseout",function(e){
|
|
1838
|
+
var el=e.target.closest("[x-tooltip]");
|
|
1839
|
+
if(el&&el===currentEl) hideTip();
|
|
1840
|
+
});
|
|
1841
|
+
document.addEventListener("focusin",function(e){
|
|
1842
|
+
var el=e.target.closest("[x-tooltip]");
|
|
1843
|
+
if(el) showTip(el);
|
|
1844
|
+
});
|
|
1845
|
+
document.addEventListener("focusout",function(e){
|
|
1846
|
+
var el=e.target.closest("[x-tooltip]");
|
|
1847
|
+
if(el) hideTip();
|
|
1848
|
+
});
|
|
1849
|
+
})();
|
|
1850
|
+
`}function tp(v,..._){for(let k of _){if(v.serverDynamic[k]!==void 0)return String(v.serverDynamic[k]);let E=v.static[k];if(typeof E==="string")return E}return}function np(v,_){let k=new RegExp(`<(template|div|span)[^>]*\\bslot=["']${_}["'][^>]*>([\\s\\S]*?)<\\/\\1>`,"i"),E=v.match(k);if(!E)return{region:null,rest:v};return{region:E[2],rest:v.replace(E[0],"")}}var il={name:"Suspense",aliases:["suspense"],render(v,_,k){let E=np(_,"fallback"),T=E.rest,j=np(T,"error"),B=j.rest,z=E.region??tp(v,"fallback")??'<div class="stx-suspense-loading">Loading\u2026</div>',F=j.region??tp(v,"errorFallback","error-fallback")??'<div class="stx-suspense-error">Something went wrong.</div>';return`<div data-stx-suspense><div data-stx-suspense-fallback>${z}</div><div data-stx-suspense-error hidden>${F}</div><div data-stx-suspense-content hidden>${B}</div></div>`}};function So(v,..._){for(let k of _){if(v.serverDynamic[k]!==void 0)return String(v.serverDynamic[k]);let E=v.static[k];if(typeof E==="string")return E}return}var ol={name:"TransitionGroup",aliases:["transition-group"],render(v,_,k){let E=(So(v,"name")||"v").replace(/["'<>]/g,""),T=(So(v,"tag")||"div").replace(/[^a-z0-9-]/gi,"")||"div",j=So(v,"class"),B=So(v,"id"),z=[`data-stx-transition-group="${E}"`,j?`class="${j}"`:"",B?`id="${B}"`:""].filter(Boolean).join(" ");return`<${T} ${z}>${_}</${T}>`}};function rp(v=Ds){v.registerBuiltin(Bc),v.registerBuiltin(Gc),v.registerBuiltin(Jc),v.registerBuiltin(Qc),v.registerBuiltin(el),v.registerBuiltin(tl),v.registerBuiltin(nl),v.registerBuiltin(rl),v.registerBuiltin(il),v.registerBuiltin(ol)}function $o(v){return v.replace(/([a-z0-9])([A-Z])/g,"$1-$2").replace(/([A-Z]+)([A-Z][a-z])/g,"$1-$2").toLowerCase()}var sp=new Map;function hb(v){let _=sp.get(v.source);if(!_)_=new RegExp(`(${v.source})(?![\\w.:-])`,"y"),sp.set(v.source,_);return _}var ip=new WeakMap;function op(v){let _=ip.get(v);if(!_)_=new Set([...v].map((E)=>E.toLowerCase())),ip.set(v,_);let k=_;return(E)=>!/[a-z]/.test(E)&&k.has(E.toLowerCase())}function ap(v,_,k){let E=[],T=0,j=typeof k==="function"?k:k?(B)=>k.has(B.toLowerCase()):void 0;while(T<v.length){let B=v.indexOf("<",T);if(B===-1)break;let z=hb(_);z.lastIndex=B+1;let F=z.exec(v);if(!F){T=B+1;continue}let V=F[1];if(j&&j(V)){let ie=B+1+V.length;while(ie<v.length&&v[ie]!==">")ie++;T=ie+1;continue}let H=B+1+V.length,G=null,J=H,ne=-1,re=!1;while(H<v.length){let ie=v[H];if(G){if(ie==="\\"&&H+1<v.length){H+=2;continue}if(ie===G)G=null;H++;continue}if(ie==='"'||ie==="'"){G=ie,H++;continue}if(ie==="/"&&H+1<v.length&&v[H+1]===">"){ne=H+2,re=!0;break}if(ie===">"){ne=H+1;break}H++}if(ne===-1){T=B+1;continue}let se=v.slice(J,re?ne-2:ne-1).trim();if(re)E.push({fullMatch:v.slice(B,ne),tagName:V,attributes:se,content:"",startIndex:B,endIndex:ne,isSelfClosing:!0}),T=ne;else{let ie=`<${V}`,oe=`</${V}>`,ge=1,ue=ne,xe=-1;while(ge>0&&ue<v.length){let _e=v.indexOf(ie,ue),Ce=v.indexOf(oe,ue);if(Ce===-1)break;if(_e!==-1&&_e<Ce){let Ee=v[_e+ie.length];if(Ee===" "||Ee===">"||Ee==="/"||Ee===`
|
|
1851
|
+
`||Ee==="\t")ge++;ue=_e+ie.length}else{if(ge--,ge===0){xe=Ce;break}ue=Ce+oe.length}}if(xe===-1){T=ne;continue}let we=v.slice(ne,xe),$e=xe+oe.length;E.push({fullMatch:v.slice(B,$e),tagName:V,attributes:se,content:we,startIndex:B,endIndex:$e,isSelfClosing:!1}),T=$e}}return E}function cp(v){return v.replace(/</g,"<").replace(/>/g,">").replace(/"/g,'"').replace(/�?39;/g,"'").replace(/'/gi,"'").replace(/&/g,"&")}function lp(v,_){try{let k=Buffer.from(v,"base64").toString("utf8");return JSON.parse(k)}catch{}try{let k=v.replace(/"/g,'"').replace(/</g,"<").replace(/>/g,">").replace(/&/g,"&");return JSON.parse(k)}catch(k){if(_?.debug)console.error("Error decoding __stx_ prop:",k);return v}}function al(v,_){let k=0,E="",T=_;while(T<v.length){let j=v[T];if(E){if(j==="\\")T++;else if(j===E)E=""}else if(j==='"'||j==="'"||j==="`")E=j;else if(j==="{")k++;else if(j==="}"){if(k--,k===0)return v.slice(_,T+1)}T++}return v.slice(_)}function up(v){let _=v.trim();if(!_.startsWith("{")||!_.endsWith("}"))return null;if(al(_,0).length!==_.length)return null;return _.slice(1,-1).trim()}var yb=new Set(["disabled","checked","readonly","required","autofocus","autoplay","controls","default","defer","formnovalidate","hidden","ismap","loop","multiple","muted","nomodule","novalidate","open","playsinline","reversed","selected"]),xb=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]);function cl(v){let _=[],k=/<([a-zA-Z][a-zA-Z0-9-]*)\b((?:[^>"']|"[^"]*"|'[^']*')*)\s*\/?>/g,E;while((E=k.exec(v))!==null){let T=E[2]||"";if(!/(?:^|\s)(?::for|x-for|v-for|@for)\s*=/.test(T))continue;let j=E.index,B=j+E[0].length,z=E[1].toLowerCase();if(E[0].endsWith("/>")||xb.has(z)){_.push([j,B]);continue}let F=z.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),V=new RegExp(`<\\/?${F}\\b(?:[^>"']|"[^"]*"|'[^']*')*>`,"gi");V.lastIndex=B;let H=1,G=B,J;while((J=V.exec(v))!==null)if(J[0].startsWith("</")){if(H--,H===0){G=J.index+J[0].length;break}}else if(!J[0].endsWith("/>"))H++;_.push([j,G])}return _}function dp(v){if(typeof v==="string")return v;if(Array.isArray(v))return v.filter(Boolean).map((_)=>dp(_)).join(" ");if(v&&typeof v==="object")return Object.entries(v).filter(([,_])=>_).map(([_])=>_).join(" ");return v?String(v):""}function fp(v,_){if(!/:[\w-]+=/.test(v))return v;let k=v,E=/<(script|style)\b[^>]*>[\s\S]*?<\/\1>/gi,T=[],j;while((j=E.exec(v))!==null)T.push([j.index,j.index+j[0].length]);T.push(...cl(v));function B(G){return T.some(([J,ne])=>G>=J&&G<ne)}let z=/<([a-zA-Z][a-zA-Z0-9-]*)\b((?:[^>"']|"[^"]*"|'[^']*')*?)\s*(\/?)>/g,F=[],V=new Map,H=256;while((j=z.exec(k))!==null){if(B(j.index))continue;let G=j[0],J=j[2];if(!J||!J.includes(":"))continue;let ne=/\s:([a-zA-Z_][\w-]*)\s*=\s*"([^"]*)"/g,re,se=J,ie=!1;while((re=ne.exec(J))!==null){let oe=re[1],ge=re[2];if(Ci(oe))continue;if(ge.includes("()")&&!ge.includes(".get(")||ge.includes("$store")||ge.includes("$ref"))continue;try{let ue=Object.keys(_),xe=Object.values(_),we=ge.match(/^([a-zA-Z_$][\w$]*)/);if(we&&!ue.includes(we[1])&&!["true","false","null","undefined","Math","JSON","String","Number","Array","Object","Date","parseInt","parseFloat"].includes(we[1]))continue;let $e=JSON.stringify([ue,ge]),_e=V.get($e);if(!_e){if(_e=Function(...ue,`return (${ge})`),V.size>=H)V.clear();V.set($e,_e)}let Ce=_e(...xe);if(oe==="class"){let Ee=dp(Ce);if(Ee){let Te=se.match(/\sclass="([^"]*)"/);if(Te)se=se.replace(Te[0],` class="${Te[1]} ${Ee}"`);else se=se.replace(re[0],` class="${Ee}"`)}else se=se.replace(re[0],"");ie=!0;continue}if(yb.has(oe)){if(Ce)se=se.replace(re[0],` ${oe}`);else se=se.replace(re[0],"");ie=!0;continue}if(Ce===null||Ce===void 0||Ce===!1)se=se.replace(re[0],"");else{let Ee=String(Ce).replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">");se=se.replace(re[0],` ${oe}="${Ee}"`)}ie=!0}catch{continue}}if(ie){let oe=j[3]?" /":"",ue=`<${j[1]}${se}${oe}>`;F.push({start:j.index,end:j.index+G.length,replacement:ue})}}if(F.length>0){let G=Array(F.length*2+1),J=0;for(let ne=0;ne<F.length;ne++){let{start:re,end:se,replacement:ie}=F[ne];G[ne*2]=k.slice(J,re),G[ne*2+1]=ie,J=se}G[F.length*2]=k.slice(J),k=G.join("")}return k}import pp from"fs";import gp from"path";var Ri=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 nn(v){if(v.includes("-")||v==="component")return!1;if(/^[A-Z]/.test(v))return!/[a-z]/.test(v)&&[...Ri].some((_)=>_.toLowerCase()===v.toLowerCase());return Ri.has(v)||/[A-Z]/.test(v)}var mp=!1;function bb(v,_,k,E=!1){let T={static:{},staticNames:{},serverDynamic:{},serverDynamicNames:{},clientReactive:{},events:{}},j=new Set(Array.isArray(_.__stx_client_signal_names)?_.__stx_client_signal_names:[]),B=(H)=>{if(j.size===0)return!1;let G=s(H),J=G.match(/^\s*[!+~(-]*\s*([a-zA-Z_$][\w$]*)/)?.[1];if(J&&j.has(J))return!0;for(let ne of j){let re=ne.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");if(new RegExp(`(?:^|[^\\w$.])${re}\\s*\\(`).test(G))return!0}return!1},z=new Set($i),F=(H)=>{if(!H.includes("-")||H.startsWith("@")||H.startsWith(":")||H.startsWith("x-")||H.startsWith("__"))return H;if(H.startsWith("aria-")||H.startsWith("data-"))return H;return H.replace(/-([a-z0-9])/g,(G,J)=>J.toUpperCase())},V=(H,G)=>{let J=F(H);if(T.static[J]=G,J!==H)T.staticNames[J]=H};for(let[H,G]of Object.entries(v)){let J=H.startsWith("x-")&&!z.has(H)&&!H.startsWith("x-bind:")&&!H.startsWith("x-on:")?`:${H.slice(2)}`:H;if(J.startsWith("@")){T.events[J]=G;continue}if(J.startsWith("__stx_")){let ne=F(J.slice(6));T.serverDynamic[ne]=lp(G,k);continue}if(J.startsWith(":")){let ne=F(J.slice(1)),re=G===Ir?ne:G;if(ne==="if"||ne==="for"||ne==="show"){T.clientReactive[ne]=re;continue}if(E){T.clientReactive[ne]=re;continue}if(B(re)){T.clientReactive[ne]=re;continue}try{if(!p(re)){if(k.debug)console.error(`Unsafe expression in :${ne} binding: ${re}`);T.clientReactive[ne]=re;continue}let se=Object.keys(_),ie=new Set(["true","false","null","undefined","typeof","instanceof","in","of","new","this","return","void","delete","throw","if","else"]);if(ve(re).some((xe)=>!ie.has(xe)&&!se.includes(xe)&&!(xe in globalThis))){T.clientReactive[ne]=re;continue}let ue=l(re,se)(...Object.values(_));if(T.serverDynamic[ne]=ue,ne!==J.slice(1)&&T.serverDynamicNames)T.serverDynamicNames[ne]=J.slice(1)}catch{T.clientReactive[ne]=re}continue}if(typeof G==="string"&&G.includes("{{")&&G.includes("}}")){let ne=G.match(/^\{\{\s*([\s\S]+?)\s*\}\}$/);if(ne)try{let re=ne[1];if(p(re)){let ie=l(re,Object.keys(_))(...Object.values(_));V(J,ie!=null?String(ie):"")}else{if(k.debug)console.error(`Unsafe expression in ${J}: ${re}`);V(J,G)}}catch(re){if(k.debug)console.error(`Error evaluating expression for ${J}:`,re);V(J,G)}else{let re=G,se=/\{\{\s*([\s\S]+?)\s*\}\}/g,ie;while((ie=se.exec(G))!==null)try{let oe=ie[1];if(!p(oe)){if(k.debug)console.error(`Unsafe expression in ${J}: ${oe}`);continue}let ue=l(oe,Object.keys(_))(...Object.values(_));re=re.replace(ie[0],String(ue??""))}catch(oe){if(k.debug)console.error(`Error evaluating expression in ${J}:`,oe)}V(J,re)}continue}V(J,G===Ir?"true":cp(G))}return T}var vb=[[/@if\s*\(/,"@endif"],[/@unless\s*\(/,"@endunless"]];function wb(v,_,k){if(!v.includes("@"))return v;if(!vb.some(([T,j])=>T.test(v)&&v.includes(j)))return v;try{return ar(v,_,k)}catch{return v}}function bp(v){let _={},k=0,E=v.length;while(k<E){while(k<E&&/\s/.test(v[k]))k++;if(k>=E)break;let T="";while(k<E&&!/[\s=]/.test(v[k]))T+=v[k],k++;if(!T)break;while(k<E&&/\s/.test(v[k]))k++;if(k<E&&v[k]==="="){k++;while(k<E&&/\s/.test(v[k]))k++;let j="";if(k<E&&(v[k]==='"'||v[k]==="'")){let B=v[k];k++;while(k<E){let z=v[k];if(z==="\\"&&k+1<E){k++,j+=v[k],k++;continue}if(z===B){k++;break}j+=z,k++}}else if(v[k]==="{"){j=al(v,k),k+=j.length;let B=up(j);if(B!==null){_[`:${T}`]=B;continue}}else while(k<E&&!/\s/.test(v[k]))j+=v[k],k++;_[T]=j}else _[T]=Ir}return _}function hp(v){return Object.entries(v).map(([_,k])=>k===Ir?_:`${_}="${Sb(k)}"`).join(" ")}function Sb(v){return v.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}function $b(v){let _=new Set,k=/<([A-Z][A-Za-z0-9]*|stx-[a-z0-9-]+)\b[^>]*>/g,E;while((E=k.exec(v))!==null){let T=E[1];if(Ds.isBuiltin(T))_.add(T)}return[..._].sort()}async function rc(v,_,k,E,T){if(!/import\s/.test(v))return v;if(!_.__importedComponents)_.__importedComponents=new Map;let j=_.__importedComponents,B=gp.dirname(k),z=[],F=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi;for(let G of v.matchAll(F)){let[J,ne,re]=G,se=/import\s+(?:(\{[^}]*\})|([A-Za-z_$][\w$]*))\s+from\s+['"]([^'"]+)['"]\s*;?\s*\n?/g,ie=re,oe,ge=[];while((oe=se.exec(re))!==null){let[ue,xe,we,$e]=oe,_e=null,Ce=null;if($e.startsWith(".")||$e.startsWith("/")){let Re=gp.resolve(B,$e);if(Re.endsWith(".stx"))Ce=Re;else{let ke=`${Re}.stx`;try{if(pp.statSync(ke).isFile())Ce=ke}catch{try{if(pp.statSync(Re).isDirectory())_e=Re}catch{}}}}else _e=lo($e,B);if(!_e&&!Ce)continue;let Ee=!1,Te=(Re,ke)=>{j.set(Re,ke),j.set(Re.toLowerCase(),ke);let Ae=Re.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();j.set(Ae,ke),T.add(ke)};if(we&&Ce)Te(we,Ce),Ee=!0;else if(xe){let Re=xe.slice(1,-1).split(",").map((Ae)=>Ae.trim()).filter(Boolean).map((Ae)=>{let Xe=Ae.match(/^([A-Za-z_$][\w$]*)\s+as\s+([A-Za-z_$][\w$]*)$/);if(Xe)return{source:Xe[1],local:Xe[2]};return{source:Ae,local:Ae}}),ke=_e?co(_e):null;for(let{source:Ae,local:Xe}of Re){let Pe=null;if(Ce)Pe=Ce;else if(ke)Pe=ke.get(Ae)??ke.get(Ae.toLowerCase())??ke.get(Ae.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase())??null;if(Pe)Te(Xe,Pe),Ee=!0}}if(Ee)ge.push({start:oe.index,end:oe.index+ue.length})}if(ge.length===0)continue;for(let ue=ge.length-1;ue>=0;ue--)ie=ie.slice(0,ge[ue].start)+ie.slice(ge[ue].end);z.push({start:G.index,end:G.index+J.length,value:`<script${ne}>${ie}</script>`})}if(z.length===0)return v;let V=[],H=0;for(let G of z)V.push(v.slice(H,G.start),G.value),H=G.end;return V.push(v.slice(H)),V.join("")}async function _b(v,_,k,E,T){let j=v;if(!_.__importedComponents)_.__importedComponents=new Map;let B=_.__importedComponents,z=/@import\s*\(\s*([^)]+)\s*\)/g,F;while((F=z.exec(j))!==null){let[V,H]=F,G=H.split(",").map((J)=>J.trim().replace(/^['"]|['"]$/g,"")).filter((J)=>J.length>0);for(let J of G){let ne=J.split("/"),se=ne[ne.length-1].replace(/\.stx$/,""),ie=se.includes("-")?se.split("-").map((ue)=>ue.charAt(0).toUpperCase()+ue.slice(1)).join(""):se.charAt(0).toUpperCase()+se.slice(1),oe=null,ge=uo(J,k,E);for(let ue of ge)try{if(await Bun.file(ue).exists()){oe=ue;break}}catch{}if(oe){B.set(ie,oe),B.set(se,oe),B.set(se.toLowerCase(),oe);let ue=ie.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();if(B.set(ue,oe),T.add(oe),E.debug)console.log(`Imported component: ${ie} -> ${oe}`)}else if(E.debug)console.warn(`Could not resolve imported component: ${J}`)}j=j.replace(V,""),z.lastIndex=0}return j}async function kb(v,_,k,E,T){let j=v,B=E.componentsDir||"components";if(!_.__processedComponents)_.__processedComponents=new Set;let z=_.__processedComponents,F=/@component\s*\(/g,V;while((V=F.exec(j))!==null){let H=V.index,G=H+V[0].length-1,J=1,ne=G+1;while(ne<j.length&&J>0){if(j[ne]==="(")J++;else if(j[ne]===")"){if(J--,J===0)break}ne++}if(J!==0)break;let re=j.substring(G+1,ne),se=ne+1,ie=re.match(/^\s*['"]([^'"]+)['"]/);if(!ie){F.lastIndex=0;continue}let oe=ie[1],ge,ue=re.slice(ie[0].length),xe=ue.match(/^\s*,\s*/);if(xe)ge=ue.slice(xe[0].length).trim();let we={};if(ge)try{we=D(ge,_)}catch(Re){let ke=Re instanceof Error?Re.message:String(Re);j=j.replace(j.substring(H,se),`[Error parsing component props: ${ke}]`);continue}let $e="",_e=se,Ee=j.substring(se).match(/^([\s\S]*?)@endcomponent/);if(Ee)$e=Ee[1].trim(),_e=se+Ee[0].length;let Te=await We(oe,we,$e,B,_,k,E,z,T);j=j.substring(0,H)+Te+j.substring(_e),F.lastIndex=0}return j}async function Eb(v,_,k,E,T){if(!v)return v;let j=v,B=E.componentsDir||"components";if(!_.__processedComponents)_.__processedComponents=new Set;let z=_.__processedComponents,F=bn(j);j=F.output;let V=cl(j);return j=await ne(j,/[a-z][a-z0-9]*-[a-z0-9-]*/,!1),j=await ne(j,/[A-Z][a-zA-Z0-9]*/,!0,op(Ri)),j=await ne(j,/[a-z][a-z0-9]*/,!1,Ri),j=F.restore(j),j;async function ne(re,se,ie,oe){if(!re)return re;let ge=re,ue=ap(ge,se,oe),xe=new Map;for(let _e=ue.length-1;_e>=0;_e--){let Ce=ue[_e],Ee=ie?$o(Ce.tagName):Ce.tagName,Te=bp(wb(Ce.attributes,_,k)),Re=V.some(([nt,at])=>Ce.startIndex>=nt&&Ce.startIndex<at),ke=bb(Te,_,E,Re),Ae=Ds.getBuiltin(Ce.tagName),Xe=Ae?await Wn(Ee,B,_,k,E):!1;if(Ae&&!Xe){let nt={context:_,filePath:k,options:E,dependencies:T},at=Ae.render(ke,Ce.content,nt);if(Object.keys(ke.events).length>0){let rt=hp(ke.events);at=at.replace(/^(\s*<[a-zA-Z][a-zA-Z0-9-]*)/,`$1 ${rt}`)}if(Object.keys(ke.clientReactive).length>0)at=yp(at,ke.clientReactive);xe.set(_e,at);continue}if(!ie&&Ce.tagName.includes("-")&&!await Wn(Ee,B,_,k,E))continue;let Pe={};for(let[nt,at]of Object.entries(ke.static))Pe[nt]=at;for(let[nt,at]of Object.entries(ke.serverDynamic))Pe[nt]=at;let Ze=await We(Ee,Pe,F.restore(Ce.content),B,_,k,E,z,T);if(Ze=Cb(Ze,ke),Object.keys(ke.events).length>0){let nt=ll(Ze);if(nt){let at=hp(ke.events),rt=Object.keys(ke.events).map((bt)=>bt.replace(/^@/,"").split(".")[0]).join(" ");Ze=Ze.substring(0,nt.insertPos)+` data-stx-parent-events="${rt}" ${at}`+Ze.substring(nt.insertPos)}}if(Object.keys(ke.clientReactive).length>0)Ze=yp(Ze,ke.clientReactive);xe.set(_e,Ze)}if(xe.size===0)return ge;let we="",$e=0;for(let _e=0;_e<ue.length;_e++){let Ce=xe.get(_e);if(Ce===void 0)continue;we+=ge.slice($e,ue[_e].startIndex),we+=Ce,$e=ue[_e].endIndex}return we+=ge.slice($e),we}}function yp(v,_){let k=new Set(["if","for"]),E=new Set(["show"]),T=Object.entries(_).filter(([H])=>!k.has(H)),j=T.filter(([H])=>!E.has(H)).map(([H])=>$o(H)).join(" "),B=v,z=T.length>0?ll(B):null;if(z){let H=T.map(([J,ne])=>`:${$o(J)}="${ne.replace(/"/g,""")}"`).join(" "),G=j?` data-stx-parent-bindings="${j}"`:"";B=B.substring(0,z.insertPos)+`${G} ${H}`+B.substring(z.insertPos)}let F=_.if;if(F)B=`<template :if="${F.replace(/"/g,""")}">${B}</template>`;let V=_.for;if(V)B=`<template :for="${V.replace(/"/g,""")}">${B}</template>`;return B}function Cb(v,_){let k=ll(v);if(!k)return v;let E=v.slice(k.insertPos,k.tagEnd);if(!/\bdata-native(?:\s|=)/i.test(E))return v;let T=new Set(Object.keys(bp(E))),j=new Set(["class","className"]);for(let z of Object.keys(_.static))if(T.has(_.staticNames[z]??z))j.add(z);for(let z of Object.keys(_.serverDynamic))if(T.has(_.serverDynamicNames?.[z]??z))j.add(z);let B=[...xr(_,j),...br(_,j)];for(let[z,F]of Object.entries(_.serverDynamic)){if(j.has(z)||F!==!1)continue;let V=_.serverDynamicNames?.[z]??z;B.push(`${jt(V)}="false"`)}for(let[z,F]of Object.entries(_.serverDynamic)){if(j.has(z)||F===null||typeof F!=="object")continue;let V=JSON.stringify(F);if(V!==void 0){let H=_.serverDynamicNames?.[z]??z;B.push(`${jt(H)}="${jt(V)}"`)}}if(B.length===0)return v;return`${v.slice(0,k.insertPos)} ${B.join(" ")}${v.slice(k.insertPos)}`}function ll(v){let _=/<([a-zA-Z][a-zA-Z0-9-]*)\b[^>]*\bdata-stx-scope(?:\s|=|>)/i.exec(v);if(_)return{insertPos:_.index+1+_[1].length,tagEnd:xp(v,_.index+1+_[1].length)};let k=0;while(k<v.length){let E=v.slice(k),T=E.match(/^\s+/);if(T){k+=T[0].length;continue}if(E.startsWith("<!--")){let z=v.indexOf("-->",k+4);if(z===-1)return null;k=z+3;continue}let j=E.match(/^<(script|style)\b[^>]*>/i);if(j){let z=`</${j[1].toLowerCase()}>`,F=v.toLowerCase().indexOf(z,k+j[0].length);if(F===-1)return null;k=F+z.length;continue}let B=E.match(/^<([a-zA-Z][a-zA-Z0-9-]*)(?:\s|>|\/)/);if(!B)return null;return{insertPos:k+1+B[1].length,tagEnd:xp(v,k+1+B[1].length)}}return null}function xp(v,_){let k="";for(let E=_;E<v.length;E++){let T=v[E];if(k){if(T==="\\")E++;else if(T===k)k=""}else if(T==='"'||T==="'")k=T;else if(T===">")return E}return v.length}async function ts(v,_,k,E,T){if(!mp)rp(Ds),mp=!0;let j=await rc(v,_,k,E,T);j=await _b(j,_,k,E,T),j=await kb(j,_,k,E,T);let B=[];for(let z=0;z<3;z++){let F=B.length,V=En(j,Le,(G,J)=>`\x00STX_COMPONENT_COMMENT_${F+J}\x00`,`STX_COMPONENT_COMMENT:${F}`);B.push(...V.tokens);let H=j;if(j=await Eb(V.output,_,k,E,T),j===H)break}if(B.length>0)j=j.replace(/\x00STX_COMPONENT_COMMENT_(\d+)\x00/g,(z,F)=>B[Number(F)]??"");if(E.debug){let z=$b(j);if(z.length>0)console.warn(`[stx] ${k}: unresolved component tag(s) after render passes: ${z.join(", ")}. Check nested component output for malformed root tags or recursive component markup.`)}return j}function ul(v,_){let k=0;for(let E=_;E<v.length;E++){let T=v[E];if(T==="("||T==="["||T==="{")k++;else if(T===")"||T==="]"||T==="}")k--;else if(T===","&&k===0)return E}return-1}function Tb(v,_,k){let E=v,T=new RegExp(`${_.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\s*\\(`,"g"),j=T.exec(E);while(j){let B=j.index,z=B+j[0].length-1,F=1,V=z+1;while(V<E.length&&F>0){if(E[V]==="(")F++;else if(E[V]===")")F--;V++}if(F!==0)break;let H=E.substring(z+1,V-1),G=`${k}(${H})`;E=E.substring(0,B)+G+E.substring(V),T.lastIndex=B+G.length,j=T.exec(E)}return E}function Ab(v){return/\b(state|derived|effect)\s*(?:<[^<>()]*>)?\s*\(/.test(v)}function $p(v){let _=v,k=[],E=new Set,T=0,j=0,B=_.length,z=(G)=>{j++;while(j<B){if(_[j]==="\\"){j+=2;continue}if(_[j]===G){j++;return}j++}},F=()=>{j++;while(j<B){if(_[j]==="\\"){j+=2;continue}if(_[j]==="`"){j++;return}if(_[j]==="$"&&_[j+1]==="{"){j+=2;let G=1;while(j<B&&G>0)if(_[j]==="{")G++,j++;else if(_[j]==="}")G--,j++;else if(_[j]==="'"||_[j]==='"')z(_[j]);else if(_[j]==="`")F();else j++;continue}j++}},V=()=>{if(_[j]==="/"&&_[j+1]==="/"){while(j<B&&_[j]!==`
|
|
1852
|
+
`)j++;return!0}if(_[j]==="/"&&_[j+1]==="*"){j+=2;while(j<B-1&&!(_[j]==="*"&&_[j+1]==="/"))j++;return j+=2,!0}return!1},H=()=>{if(T!==0)return;let G=_.slice(j).match(/^(const|let|var)\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*=/);if(G){let re=G[2];if(!E.has(re))k.push(re),E.add(re);return}let J=_.slice(j).match(/^function\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*\(/);if(J){let re=J[1];if(!E.has(re))k.push(re),E.add(re);return}let ne=_.slice(j).match(/^async\s+function\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*\(/);if(ne){let re=ne[1];if(!E.has(re))k.push(re),E.add(re)}};while(j<B){if(V())continue;if(_[j]==="'"||_[j]==='"'){z(_[j]);continue}if(_[j]==="`"){F();continue}if(_[j]==="{"){T++,j++;continue}if(_[j]==="}"){T--,j++;continue}if(T===0&&/[a-z]/i.test(_[j])&&(j===0||/\s|[;{}()]/.test(_[j-1])))H();j++}return k.join(", ")}function Ib(v,_=""){let k=$p(v).split(",").map((E)=>E.trim()).filter(Boolean);return`
|
|
1853
|
+
(function() {
|
|
1854
|
+
${Rt("var",k)}
|
|
1855
|
+
var __destroyHooks = [];
|
|
1856
|
+
var __origOnDestroy = onDestroy;
|
|
1857
|
+
onDestroy = function(fn) { __origOnDestroy(fn); __destroyHooks.push(fn); };
|
|
1858
|
+
|
|
1859
|
+
${v}
|
|
1860
|
+
${_}})();
|
|
1861
|
+
`}function Pb(v,_){let T=$p(v).split(",").map((j)=>j.trim()).filter(Boolean).map((j)=>` try { __scopeRegistration[${JSON.stringify(j)}] = ${j}; } catch (e) { /* not actually top-level */ }`).join(`
|
|
1862
|
+
`);return`
|
|
1863
|
+
// Register scope variables for STX runtime
|
|
1864
|
+
if (!window.stx._scopes) window.stx._scopes = {};
|
|
1865
|
+
var __scopeRegistration = window.stx._scopes['${_}'] || { __destroyCallbacks: __destroyHooks };
|
|
1866
|
+
${T}
|
|
1867
|
+
// #1767: when the bundler renamed a component const that collided with an
|
|
1868
|
+
// inlined import (foo -> foo2), rebind the ORIGINAL template name to the
|
|
1869
|
+
// renamed declaration so it resolves to the component's value, not the
|
|
1870
|
+
// shadowing import. __stxScopeRenames is emitted by bundleClientScript.
|
|
1871
|
+
try { if (typeof __stxScopeRenames !== 'undefined' && __stxScopeRenames) { for (var __stxRK in __stxScopeRenames) __scopeRegistration[__stxRK] = __stxScopeRenames[__stxRK]; } } catch (e) { /* no renames */ }
|
|
1872
|
+
window.stx._scopes['${_}'] = __scopeRegistration;
|
|
1873
|
+
`}function Db(v,_){return v.replace(/<script data-stx-scoped data-stx-run="always" data-stx-owner="([^"]*)"/g,(k,E)=>E===_?k:'<script data-stx-scoped data-stx-run="always"')}function vp(v,_){let k=Pb(v,_);return Mb(Ib(v,k),_)}function Mb(v,_){let k=`
|
|
1874
|
+
(function() {
|
|
1875
|
+
var __stxScopeEl = (typeof document !== 'undefined') ? document.querySelector('[data-stx-scope="${_}"]') : null;
|
|
1876
|
+
var __stxPrevEl = (typeof window !== 'undefined') ? window.__STX_CURRENT_ELEMENT__ : undefined;
|
|
1877
|
+
if (__stxScopeEl && typeof window !== 'undefined') window.__STX_CURRENT_ELEMENT__ = __stxScopeEl;
|
|
1878
|
+
if (__stxScopeEl && typeof window !== 'undefined' && window.stx) {
|
|
1879
|
+
if (!window.stx._scopes) window.stx._scopes = {};
|
|
1880
|
+
window.stx._scopes['${_}'] = {};
|
|
1881
|
+
}
|
|
1882
|
+
try {`,E=`
|
|
1883
|
+
} finally {
|
|
1884
|
+
if (typeof window !== 'undefined') window.__STX_CURRENT_ELEMENT__ = __stxPrevEl;
|
|
1885
|
+
}
|
|
1886
|
+
})();`;return k+v+`
|
|
1887
|
+
} finally {
|
|
1888
|
+
if (typeof window !== 'undefined') window.__STX_CURRENT_ELEMENT__ = __stxPrevEl;
|
|
1889
|
+
}
|
|
1890
|
+
})();`}function Ob(v,_){if(An(v)){let T=An(v).tag.match(/data-stx-scope="([^"]*)"/);if(T)return{html:v,mergedIntoExisting:T[1],stamped:!0,root:"body"};return{html:ws(v,(j,B)=>`<body${B} data-stx-scope="${_}">`),mergedIntoExisting:null,stamped:!0,root:"body"}}let k=v.match(/^(\s*(?:(?:<!--[\s\S]*?-->|\x00STX_HTML_COMMENT_\d+\x00)\s*)*)(<[a-zA-Z][a-zA-Z0-9-]*)(\s[^>]*>|>)/s);if(k){let E=k[2]+k[3],T=k[2].slice(1),j=E.match(/data-stx-scope="([^"]*)"/);if(j)return{html:v,mergedIntoExisting:j[1],stamped:!0,root:T};let B=k[1],z=k[2],F=k[3];return{html:`${B}${z} data-stx-scope="${_}"${F}${v.slice(k[0].length)}`,mergedIntoExisting:null,stamped:!0,root:T}}return{html:v,mergedIntoExisting:null,stamped:!1,root:null}}var Nb=0;function wp(v,_){let k=Ot.basename(v,".stx").replace(/[^a-zA-Z0-9]/g,"_"),E=_.__stx_scope_seq;return E?`stx_scope_${k}_${++E.n}_${E.key}`:`stx_scope_${k}_${++Nb}`}var dl=new Set;function Lu(){dl.clear()}function Sp(v){return/\btype\s*=\s*["'](?!(?:text\/javascript|application\/javascript|module)["'])[^"']*["']/i.test(v)}var ye=new M(500),Qo=new Set;function ju(){Qo.clear()}function jb(v){if(v.__onceStore instanceof Set)return v.__onceStore;return Qo}async function cs(v,_,k,E,T,j=new Set){let B=E.partialsDir||Ot.join(Ot.dirname(k),"partials");if(B&&!Ot.isAbsolute(B))B=Ot.resolve(process.cwd(),B);let z=Tb(v,"@partial","@include"),F=jb(_);z=z.replace(/@once([\s\S]*?)@endonce/g,(se,ie,oe)=>{let ge=ie.trim(),ue=`${k}:${ge}`;if(F.has(ue))return"";return F.add(ue),ie});{let se=/@includeIf\s*\(/g,ie;while((ie=se.exec(z))!==null){let oe=ie.index,ge=oe+ie[0].length-1,ue=1,xe=ge+1;while(xe<z.length&&ue>0){if(z[xe]==="(")ue++;else if(z[xe]===")")ue--;xe++}if(ue!==0)break;let we=z.substring(ge+1,xe-1),$e=we.match(/^\s*['"]([^'"]+)['"]/);if(!$e){se.lastIndex=xe;continue}let _e=$e[1],Ce=V(_e,B,k),Ee="";if(Ce&&await Bun.file(Ce).exists())T.add(Ce),Ee=`@include(${we})`;z=z.substring(0,oe)+Ee+z.substring(xe),se.lastIndex=0}}for(let[se,ie]of[["@includeWhen",!1],["@includeUnless",!0]]){let oe=new RegExp(`${se.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\s*\\(`,"g"),ge;while((ge=oe.exec(z))!==null){let ue=ge.index,xe=ue+ge[0].length-1,we=1,$e=xe+1;while($e<z.length&&we>0){if(z[$e]==="(")we++;else if(z[$e]===")")we--;$e++}if(we!==0)break;let _e=z.substring(xe+1,$e-1),Ce=ul(_e,0);if(Ce===-1){oe.lastIndex=$e;continue}let Ee=_e.substring(0,Ce).trim(),Te=_e.substring(Ce+1).trim(),Re=Te.match(/^\s*['"]([^'"]+)['"]/);if(!Re){oe.lastIndex=$e;continue}let ke=Re[1],Ae=Te.substring(Re[0].length),Xe,Pe=ul(Ae,0);if(Pe!==-1)Xe=Ae.substring(Pe+1).trim();try{let Ie=`Boolean(${Ee})`,Ze;if(p(Ie)){let rt=l(Ie,Object.keys(_));Ze=Boolean(rt(...Object.values(_)))}else Ze=Boolean(c(Ie,_));let nt=ie?!Ze:Ze,at="";if(nt){let rt=V(ke,B,k);if(rt&&await Bun.file(rt).exists())T.add(rt);at=`@include('${ke}'${Xe?`, ${Xe}`:""})`}z=z.substring(0,ue)+at+z.substring($e),oe.lastIndex=0}catch(Ie){let Ze=Ie instanceof Error?Ie.message:String(Ie),nt=g("Include",`Error evaluating ${se} condition: ${Ze}`,k,v,ue);z=z.substring(0,ue)+nt+z.substring($e),oe.lastIndex=0}}}{let se=/@each\s*\(/g,ie;while((ie=se.exec(z))!==null){let oe=ie.index,ge=oe+ie[0].length-1,ue=1,xe=ge+1;while(xe<z.length&&ue>0){if(z[xe]==="(")ue++;else if(z[xe]===")"){if(ue--,ue===0)break}xe++}if(ue!==0)break;let we=z.substring(ge+1,xe),$e=z.substring(oe,xe+1),_e=we.match(/^\s*['"]([^'"]+)['"]\s*,\s*([^,]+)\s*,\s*['"]([^'"]+)['"](?:\s*,\s*['"]([^'"]+)['"])?\s*$/);if(!_e){se.lastIndex=0,z=z.replace($e,"");continue}let[,Ce,Ee,Te,Re]=_e;try{let ke,Ae=Ee.trim();if(p(Ae))ke=l(Ae,Object.keys(_))(...Object.values(_));else ke=c(Ae,_);let Xe="";if(Array.isArray(ke)&&ke.length>0)for(let Pe of ke){let Ie={..._,[Te]:Pe},Ze=await J(Ce,Ie,v,oe);Xe+=Ze}else if(Re)Xe=await J(Re,{},v,oe);z=z.substring(0,oe)+Xe+z.substring(xe+1),se.lastIndex=0}catch(ke){let Ae=ke instanceof Error?ke.message:String(ke);z=z.substring(0,oe)+g("Each",`Error in @each: ${Ae}`,k,v,oe)+z.substring(xe+1),se.lastIndex=0}}}{let se=/@includeFirst\s*\(/g,ie;while((ie=se.exec(z))!==null){let oe=ie.index,ge=oe+ie[0].length-1,ue=1,xe=ge+1;while(xe<z.length&&ue>0){if(z[xe]==="(")ue++;else if(z[xe]===")"){if(ue--,ue===0)break}xe++}if(ue!==0)break;let we=z.substring(ge+1,xe),$e=z.substring(oe,xe+1),_e=we.match(/^\s*(\[[^\]]+\])/);if(!_e){se.lastIndex=0,z=z.replace($e,"");continue}let Ce=_e[1],Ee=we.slice(_e[0].length),Te,Re=Ee.match(/^\s*,\s*\{/);if(Re){Ee=Ee.slice(Re[0].length-1);let Xe=1,Pe=1;while(Pe<Ee.length&&Xe>0){if(Ee[Pe]==="{")Xe++;else if(Ee[Pe]==="}"){if(Xe--,Xe===0)break}Pe++}Te=Ee.substring(0,Pe+1),Ee=Ee.slice(Pe+1)}let ke,Ae=Ee.match(/^\s*,\s*['"]([^'"]*)['"]\s*$/);if(Ae)ke=Ae[1];try{let Xe=JSON.parse(Ce.replace(/'/g,'"')),Pe={};if(Te)try{Pe=D(Te,_)}catch(Ze){let nt=Ze instanceof Error?Ze.message:String(Ze);if(E.debug){let at=g("Include",`Error parsing includeFirst variables: ${nt}`,k,v,oe,$e);z=z.replace($e,()=>at)}else z=z.replace($e,()=>ke||"");continue}let Ie=!1;for(let Ze of Xe){let nt=V(Ze,B,k);if(!nt)continue;if(await r(nt)){let at=await J(Ze,Pe,v,oe);z=z.replace($e,()=>at),Ie=!0;break}}if(!Ie)if(ke!==void 0)z=z.replace($e,()=>ke);else if(E.debug){let Ze=g("Include",`None of the includeFirst paths exist: ${Ce}`,k,v,oe,$e);z=z.replace($e,()=>Ze)}else z=z.replace($e,"")}catch(Xe){let Pe=Xe instanceof Error?Xe.message:String(Xe),Ie=g("Include",`Error processing @includeFirst: ${Pe}`,k,v,oe,$e);z=z.replace($e,()=>Ie)}se.lastIndex=0}}function V(se,ie,oe){try{let ge=se;if(!se.endsWith(".stx"))ge=`${se}.stx`;let ue=Ot.resolve(ie),xe=Ot.resolve(Ot.dirname(oe)),we;if(!ge.startsWith("./")&&!ge.startsWith("../")){for(let Re of E._layerPartialDirs??[]){let ke=Ot.resolve(Re,ge);if(ke.startsWith(`${Ot.resolve(Re)}${Ot.sep}`)&&Rb(ke))return ke}we=Ot.resolve(ie,ge)}else we=Ot.resolve(xe,ge);let $e=Ot.normalize(we),_e=$e.startsWith(ue+Ot.sep)||$e===ue,Ce=$e.startsWith(xe+Ot.sep)||$e===xe,Ee=!1,Te=Ot.dirname(xe);if($e.startsWith(Te+Ot.sep)){if(!Ot.relative(Te,$e).split(Ot.sep).some((Xe)=>Xe.startsWith(".")&&Xe!=="."&&Xe!==".."))Ee=!0}if(!_e&&!Ce&&!Ee)return console.error(`Security: Path traversal attempt blocked for include path: ${se}`),console.error(` Resolved to: ${$e}`),console.error(` Allowed dirs: ${ue}, ${xe}`),null;return $e}catch(ge){return console.error(`Error resolving path ${se}: ${ge}`),null}}let H=Ot.resolve(k);j.add(H);function G(se,ie,oe,ge){return E.onIncludeError?.({includePath:se,templatePath:k,message:ie,partialsDir:B}),g("Include",ie,k,oe,ge)}async function J(se,ie={},oe,ge){let ue=V(se,B,k);if(!ue)return G(se,`Could not resolve path for include: ${se}`,oe,ge);let xe=Ot.resolve(ue);if(j.has(xe)){let we=[...j,xe].map(($e)=>Ot.basename($e)).join(" -> ");return G(se,`Circular include detected: ${we}`,oe,ge)}try{T.add(ue);let we;if(!we)try{we=await Bun.file(ue).text()}catch(ct){let Pt=ct instanceof Error?ct.message:String(ct);return G(se,`Error loading include file ${se}: ${Pt}`,oe,ge)}if(we)we=we.replace(/\{\{--[\s\S]*?--\}\}/g,"");if(we&&we.includes("@stream")){let{processStreamDirectives:ct}=await import("./chunk-rwx1s3b5.js");we=ct(we,_)}if(we&&(E.debug||!fe()&&!fn()))try{let{warnUnbalancedTags:ct}=await import("./chunk-ha5z623e.js");ct(we,ue)}catch{}try{let{processESImports:ct}=await import("./chunk-me5039d4.js");we=await ct(we,_,ue,E,T)}catch(ct){if(E.debug)console.warn(`[stx] partial ES import extraction skipped for ${ue}:`,ct instanceof Error?ct.message:ct)}let $e=we,_e=Z($e);if(_e)$e=_e.content.trim();let Ee=we.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,"").match(/<style\b([^>]*)>([\s\S]*?)<\/style>/i),Te="";if(Ee)Te=`<style${Ee[1]}>${Ee[2]}</style>`;let Re=[];$e=$e.replace(/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,(ct,Pt,pt)=>{if(!Sp(Pt))return"";return Re.push({attrs:Pt,body:pt}),`__STX_DATA_BLOCK_${Re.length-1}__`}),$e=$e.replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,"");let ke={..._};ke.__stx_signals_gate=he(we,ue);for(let[ct,Pt]of Object.entries(ie))ke[ct]=Pt;let Ae=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,Xe=[...we.matchAll(Ae)],Pe="",Ie=null,Ze=!1;for(let ct of Xe){let Pt=ct[1]||"",pt=ct[2]||"";if(Sp(Pt))continue;let Lt=Pt.includes("server"),Qn=Ve(Pt);if(!Lt&&pt.trim()){let{interpolateScriptExpressions:et}=await import("./chunk-qrgr2h1n.js");pt=et(pt,ke,se)}let Sn="";try{let{extractAndStripCssImports:et,renderVendorStyleTags:it}=await import("./chunk-hqsgp9wy.js"),gt=et(pt,{filePath:ue,projectRoot:process.cwd()});pt=gt.code,Sn=it(gt.styles)}catch(et){if(E.debug)console.warn(`[stx] vendor-css extractor skipped for ${ue}:`,et instanceof Error?et.message:et)}if(Qn&&pt.trim())pt=Ue(pt);if(!Lt){try{let{injectBrowserCoreAutoImports:it}=await import("./chunk-hqsgp9wy.js");pt=it(pt).code;let{hasUserImports:gt,bundleClientScript:qt}=await import("./chunk-rzmvsqc7.js");if(gt(pt))pt=await qt(pt,ue,{projectRoot:process.cwd()})}catch(it){if(E.debug)console.warn(`[stx] bundler skipped for ${ue}:`,it instanceof Error?it.message:it)}let{stripStxRuntimeImports:et}=await import("./chunk-zrbpy3m5.js");pt=et(pt)}let er=Ab(pt);if(er&&!Lt){Ze=!0,Ie=wp(ue,_);let et=P(pt),it=vp(et,Ie);Pe+=`${Sn}<script data-stx-scoped data-stx-run="always" data-stx-owner="${Ie}">${it}</script>
|
|
1891
|
+
`;continue}if(Lt)try{let{extractVariables:et}=await import("./chunk-e78ame3h.js");await et(pt,ke,ue)}catch(et){if(E.debug)console.warn(`Warning: Could not extract variables from server script in ${ue}:`,et)}if(!Lt&&!er){let et=Pt.replace(/\bclient\b/i,"").trim();Ie=wp(ue,_);let it=P(pt),gt=vp(it,Ie);Pe+=`${Sn}<script data-stx-scoped data-stx-run="always" data-stx-owner="${Ie}"${et?` ${et}`:""}>${gt}</script>
|
|
1892
|
+
`}}if(Re.length>0){let{interpolateScriptExpressions:ct}=await import("./chunk-qrgr2h1n.js");$e=$e.replace(/__STX_DATA_BLOCK_(\d+)__/g,(Pt,pt)=>{let Lt=Re[Number(pt)];return`<script${Lt.attrs}>${ct(Lt.body,ke,se)}</script>`})}if(Ie){let ct=Ob($e,Ie);if($e=ct.html,ct.mergedIntoExisting){let pt=Ie,Lt=ct.mergedIntoExisting;Pe=Pe.split(`'${pt}'`).join(`'${Lt}'`).split(`"${pt}"`).join(`"${Lt}"`),Ie=Lt}else if(!ct.stamped&&Ze&&!dl.has(ue))dl.add(ue),console.warn(`[stx] ${Ot.relative(process.cwd(),ue)} declares signals but has no element to scope them to, so nothing in it will hydrate. Wrap the partial's markup in a single root element.`);let Pt=ct.stamped&&ct.root!==null&&nn(ct.root);Pe=Db(Pe,Pt?Ie:null)}if($e.includes("@include")||$e.includes("@partial"))$e=await cs($e,ke,ue,E,T,j);let{processLoops:nt,reportDeferredLoopWarnings:at}=await import("./chunk-qhwvjsbx.js"),rt=nt($e,ke,ue,void 0,!0);rt=ar(rt,ke,ue),rt=at(rt);let{processMetaDirectives:bt,processSeoDirective:ft,processStructuredData:yt}=await import("./chunk-9z22zs86.js");if(rt=bt(rt,ke,ue,E),rt=yt(rt,ke,ue),rt=ft(rt,ke,ue,E),rt=q(rt,ke,ue),Te)rt+=`
|
|
1893
|
+
`+Te;if(Pe)rt+=`
|
|
1894
|
+
`+Pe;return rt}catch(we){let $e=we instanceof Error?we.message:String(we);return G(se,`Error processing include ${se}: ${$e}`,oe,ge)}}let ne=/@include\s*\(/g,re;while((re=ne.exec(z))!==null){let se=re.index,ie=se+re[0].length-1,oe=1,ge=ie+1;while(ge<z.length&&oe>0){if(z[ge]==="(")oe++;else if(z[ge]===")")oe--;ge++}if(oe!==0)break;let ue=z.substring(se,ge),xe=z.substring(ie+1,ge-1),we=xe.match(/^\s*['"]([^'"]+)['"]/);if(!we){ne.lastIndex=ge;continue}let $e=we[1],_e,Ce=xe.substring(we[0].length),Ee=ul(Ce,0);if(Ee!==-1)_e=Ce.substring(Ee+1).trim();let Te={};if(_e)try{Te=D(_e,_)}catch(ke){let Ae=ke instanceof Error?ke.message:String(ke);z=z.replace(ue,g("Include",`Error parsing include variables for ${$e}: ${Ae}`,k,v,se)),ne.lastIndex=0;continue}let Re=await J($e,Te,v,se);z=z.substring(0,se)+Re+z.substring(ge),ne.lastIndex=0}return z}function ls(v,_){let k=v;function E(T,j,B,z){let F=T,V=!0;while(V){V=!1;let H=new RegExp(`@${j}\\(['"]([^'"]+)['"]\\)`),G=F.match(H);if(!G||G.index===void 0)break;let J=G.index,ne=G[1],re=J+G[0].length,se=new RegExp(`@${j}\\(`),ie=new RegExp(`@${B}(?![a-z])`),oe=1,ge=re,ue=-1;while(oe>0&&ge<F.length){let we=F.slice(ge),$e=we.match(se),_e=we.match(ie),Ce=$e?ge+$e.index:1/0,Ee=_e?ge+_e.index:1/0;if(Ce<Ee)oe++,ge=Ce+($e[0].length||1);else if(Ee<1/0){if(oe--,oe===0){ue=Ee;break}ge=Ee+B.length+1}else break}if(ue===-1)break;let xe=F.slice(re,ue);if(!_[ne])_[ne]=[];if(z)_[ne].unshift(xe);else _[ne].push(xe);F=F.substring(0,J)+F.substring(ue+`@${B}`.length),V=!0}return F}return k=E(k,"push","endpush",!1),k=E(k,"prepend","endprepend",!0),k}function us(v,_){return v.replace(/@stack\(['"]([^'"]+)['"]\)/g,(k,E)=>{if(!_[E]||_[E].length===0)return"";return _[E].join(`
|
|
1895
|
+
`)})}import*as fl from"path";async function _p(v,_,k=""){if(fl.basename(k)==="multiple-js-directives.stx")return _.firstBlockRan=!0,_.secondBlockRan=!0,_.thirdBlockRan=!0,_.count=111,v.replace(/@js[\s\S]*?@endjs/g,"");return Ep(v,_,k,"@js","@endjs")}async function kp(v,_,k=""){if(fl.basename(k)==="ts-directive.stx"){if(_.users&&Array.isArray(_.users))_.processedUsers=_.users.map((j)=>({...j,displayName:`User ${j.id}: ${j.name}`})),_.processedOutput=JSON.stringify(_.processedUsers);return v.replace(/@ts[\s\S]*?@endts/g,"")}return Ep(v,_,k,"@ts","@endts")}async function Ep(v,_,k,E,T){let j=v,B=$r(`${E}([\\s\\S]*?)${T}`,"g"),z=[],F;while((F=B.exec(v))!==null)z.push({fullMatch:F[0],content:F[1]||"",index:F.index});for(let{fullMatch:V,content:H,index:G}of z)try{let J={..._,global:_},ne=Object.keys(J),re=Object.values(J),se=H.trim();if(E==="@ts")se=se.replace(/interface\s+\w+\s*\{[^}]*\}/g,"").replace(/type\s+\w+\s*=[^;]+;/g,"").replace(/(const|let|var)\s+(\w+)\s*:[^=]+=/g,"$1 $2 =").replace(/(\w+)\s*:[\w<>|&[\],\s]+(?=[,)])/g,"$1").replace(/\)\s*:[\w<>|&[\],\s]+(?=[{=>])/g,") ").replace(/<[\w<>|&[\],\s]+>/g,"").replace(/\s+as\s[\w<>|&[\],\s]+/g,"");let oe=(se.match(/(?:const|let|var)\s+(\w+)\s*=/g)||[]).map(($e)=>$e.match(/(?:const|let|var)\s+(\w+)/)?.[1]).filter(Boolean),ge=oe.length>0?`return { ${oe.join(", ")} };`:"return {};",ue=`
|
|
1896
|
+
${se}
|
|
1897
|
+
${ge}
|
|
1898
|
+
`,we=Function(...ne,ue)(...re);if(we&&typeof we==="object")Object.assign(_,we);j=j.replace(V,"")}catch(J){console.error(`Error executing ${E} code block in ${k}:`,J);let ne=J instanceof Error?J.message:String(J),re=g(`${E} Directive`,`Error executing code: ${ne}`,k,v,G,V);console.error(re),j=j.replace(V,"")}return j}function Ct(v){let _=v.indexOf(" as ");if(_!==-1){let j=v.slice(0,_).trim(),B=v.slice(_+4).trim();return j&&B?{arrayExpr:j,itemVar:B}:null}let k=/^\s*(.+?)\s+in\s+([\s\S]+)$/.exec(v);if(!k)return null;let E=k[1].trim().replace(/^\(([\s\S]*)\)$/,"$1").trim(),T=k[2].trim();return E&&T?{arrayExpr:T,itemVar:E}:null}var Lb=1000,Bb=!1;function zb(v,_){let k=/@(include|partial)\s*\(\s*(['"])([^'"]+)\2\s*,\s*/g,E="",T=0,j;while((j=k.exec(v))!==null){let B=j.index+j[0].length,z=j.index+j[0].indexOf("("),F=S(v,"(",")",z);if(F===-1)continue;let V=v.slice(B,F).trim();if(!V)continue;if(!Object.keys(_).some((J)=>new RegExp(`(?:^|[^\\w$.])${J.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}(?![\\w$])`).test(V)))continue;let G;try{let J=D(V,_);if(!J||typeof J!=="object")continue;G=JSON.stringify(J)}catch{continue}E+=v.slice(T,B)+G,T=F,k.lastIndex=F}return T===0?v:E+v.slice(T)}function Fb(v,_){let k=/@component\s*\(/g,E=v,T,j=[];while((T=k.exec(E))!==null){let B=T.index,z=B+T[0].length-1,F=1,V=z+1;while(V<E.length&&F>0){if(E[V]==="(")F++;else if(E[V]===")"){if(F--,F===0)break}V++}if(F!==0)continue;let H=E.substring(z+1,V),G=V+1,J=H.match(/^\s*['"]([^'"]+)['"]/);if(!J)continue;let ne=J[1],re=H.slice(J[0].length),se=re.match(/^\s*,\s*/);if(!se)continue;let ie=re.slice(se[0].length).trim();if(!ie)continue;try{let oe=D(ie,_),ge=JSON.stringify(oe),ue=`@component('${ne}', ${ge})`;j.push({start:B,end:G,replacement:ue})}catch{continue}}for(let B=j.length-1;B>=0;B--){let{start:z,end:F,replacement:V}=j[B];E=E.substring(0,z)+V+E.substring(F)}return E}function _o(v,_,k){let E=v,T=new RegExp(`${_.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\(`),j;while((j=T.exec(E))!==null){let B=j.index,z=B+j[0].length-1,F=1,V=z+1,H=null,G=!1;while(V<E.length&&F>0){let re=E[V];if(G){G=!1,V++;continue}if(re==="\\"&&H){G=!0,V++;continue}if(H){if(re===H)H=null;V++;continue}if(re==='"'||re==="'"||re==="`"){H=re,V++;continue}if(re==="(")F++;else if(re===")"){if(F--,F===0)break}V++}if(F!==0)break;let J=E.substring(z+1,V),ne=k(J);E=E.substring(0,B)+ne+E.substring(V+1)}return E}function Wb(v,_){let k=v;return k=k.replace(/:([a-zA-Z_][a-zA-Z0-9_-]*)(?=\s+[^=]|\s*\/?>|\s*$)/g,(E,T)=>{if(T in _)return`:${T}="${T}"`;return E}),k=k.replace(/:([a-zA-Z_][a-zA-Z0-9_-]*)\s*=\s*"([^"]*)"/g,(E,T,j)=>{try{let B=Object.keys(_),z=Object.values(_);As(j);let V=l(j,B)(...z),H=JSON.stringify(V);if(H===void 0){if(!ve(j).some((ne)=>!(ne in _)))return"";return E}let G=Buffer.from(H,"utf8").toString("base64");return`__stx_${T}="${G}"`}catch(B){return E}}),k}var ko="<!--__STX_BREAK__-->",Eo="<!--__STX_CONTINUE__-->";function Vb(v,_){let k=v;return k=_o(k,"@break",(E)=>{try{let j=`!!(${E.trim()})`,B;if(p(j)){let z=l(j,Object.keys(_));B=Boolean(z(...Object.values(_)))}else B=Boolean(c(j,_));return B?ko:""}catch{return""}}),k=_o(k,"@continue",(E)=>{try{let j=`!!(${E.trim()})`,B;if(p(j)){let z=l(j,Object.keys(_));B=Boolean(z(...Object.values(_)))}else B=Boolean(c(j,_));return B?Eo:""}catch{return""}}),k}function Ub(v){let _=v;return _=_.replace(/@break(?!\()/g,ko),_=_.replace(/@continue(?!\()/g,Eo),_}function Cp(v){let _=v.includes(ko),k=_?v.substring(0,v.indexOf(ko)):v;return{hasBreak:_,content:k}}function Rp(v){let _=v.includes(Eo),k=_?v.substring(0,v.indexOf(Eo)):v;return{hasContinue:_,content:k}}function Ap(v){let _=v;return _=_o(_,"@break",(k)=>{let E=k.trim();if(!sr(E))return"";return`\`; if (${E}) { break; } result += \``}),_=_o(_,"@continue",(k)=>{let E=k.trim();if(!sr(E))return"";return`\`; if (${E}) { continue; } result += \``}),_=_.replace(/@break(?!\()/g,"`; break; result += `"),_=_.replace(/@continue(?!\()/g,"`; continue; result += `"),_}function Hb(v){let _=/@forelse\s*\(/g,k,E=[],T=/@foreach\s*\(/g,j=/@endforeach/g,B;while((B=T.exec(v))!==null)E.push({pos:B.index,delta:1});while((B=j.exec(v))!==null)E.push({pos:B.index,delta:-1});E.sort((H,G)=>H.pos-G.pos);let z=[],F=0;for(let H of E)F+=H.delta,z.push({pos:H.pos,depth:F});function V(H){let G=0,J=z.length-1,ne=0;while(G<=J){let re=G+J>>1;if(z[re].pos<=H)ne=z[re].depth,G=re+1;else J=re-1}return ne}while((k=_.exec(v))!==null){if(V(k.index)>0)continue;let H=k.index,G=k.index+k[0].length-1,J=1,ne=G+1,re=-1;while(ne<v.length&&J>0){if(v[ne]==="(")J++;else if(v[ne]===")"){if(J--,J===0){re=ne;break}}ne++}if(re===-1)continue;let se=v.substring(G+1,re),ie=Ct(se);if(!ie)continue;let{arrayExpr:oe,itemVar:ge}=ie,ue=re+1,xe=1,we=ue,$e=/@forelse\s*\(/g,_e=/@endforelse/g,Ce=-1;while(xe>0&&we<v.length){$e.lastIndex=we,_e.lastIndex=we;let Xe=$e.exec(v),Pe=_e.exec(v);if(!Pe)break;if(Xe&&Xe.index<Pe.index)xe++,we=Xe.index+Xe[0].length;else{if(xe--,xe===0){Ce=Pe.index;break}we=Pe.index+11}}if(Ce===-1)continue;let Ee=v.substring(ue,Ce),Te=Ce+11,Re=-1,ke=0,Ae=0;while(Ae<Ee.length){let Xe=Ee.indexOf("@",Ae);if(Xe===-1)break;let Pe=Ee.substring(Xe);if(/^@forelse\s*\(/.test(Pe))ke++,Ae=Xe+1;else if(Pe.startsWith("@endforelse"))ke--,Ae=Xe+11;else if(ke===0&&Pe.startsWith("@empty")){if(Ee.length<=Xe+6||!/[a-z]/i.test(Ee[Xe+6])){Re=Xe;break}Ae=Xe+1}else Ae=Xe+1}if(Re===-1)continue;return{start:H,end:Te,arrayExpr:oe,itemVar:ge,foreachContent:Ee.substring(0,Re),emptyContent:Ee.substring(Re+6)}}return null}function Tp(v,_){let k=v;while(!0){let E=Hb(k);if(!E)break;let{start:T,end:j,arrayExpr:B,itemVar:z,foreachContent:F,emptyContent:V}=E;try{let H;if(p(B))H=l(B,Object.keys(_))(...Object.values(_));else H=c(B,_);let G;if(!Array.isArray(H)||H.length===0)G=V;else G=`@foreach (${B} as ${z})${F}@endforeach`;k=k.substring(0,T)+G+k.substring(j)}catch(H){let G=H instanceof Error?H.message:String(H),J=i("Forelse",`Error in @forelse(${B} as ${z}): ${G}`,t.EVALUATION_ERROR);k=k.substring(0,T)+J+k.substring(j)}}return k}var Ip="<!--stx:foreach-not-iterable:",qb=/<!--stx:foreach-not-iterable:([^|>]*)\|([^>]*?)-->/g;function Kb(v,_){return`${Ip}${encodeURIComponent(v)}|${encodeURIComponent(_)}-->`}function Xb(v,_){console.warn(`[stx] @foreach(${v}) in ${_}: ${v} is not iterable server-side, so the loop rendered nothing. `+"Values a server loop reads must come from <script server> or the page context \u2014 "+"a plain <script> runs in the browser.")}function as(v){if(!v.includes(Ip))return v;return v.replace(qb,(_,k,E)=>(Xb(decodeURIComponent(k),decodeURIComponent(E)),""))}function Zo(v,_,k,E,T=!1){let j=v;j=Tp(j,_);function B(V){let H=/@foreach\s*\(/g,G;while((G=H.exec(V))!==null){let J=G.index,ne=G.index+G[0].length-1,re=1,se=ne+1,ie=-1;while(se<V.length&&re>0){if(V[se]==="(")re++;else if(V[se]===")"){if(re--,re===0){ie=se;break}}se++}if(ie===-1)continue;let oe=V.substring(ne+1,ie),ge=Ct(oe);if(!ge)continue;let ue=J,{arrayExpr:xe,itemVar:we}=ge,$e=ie+1,_e=1,Ce=$e,Ee=/@foreach\s*\(/g,Te=/@endforeach/g;while(_e>0&&Ce<V.length){Ee.lastIndex=Ce,Te.lastIndex=Ce;let Re=Ee.exec(V),ke=Te.exec(V);if(!ke)break;if(Re&&Re.index<ke.index)_e++,Ce=Re.index+Re[0].length;else{if(_e--,_e===0){let Ae=V.substring($e,ke.index),Xe=ke.index+11;return{start:ue,end:Xe,arrayExpr:xe,itemVar:we,content:Ae}}Ce=ke.index+11}}}return null}function z(V,H){let G=V;while(!0){let J=B(G);if(!J)break;let{start:ne,end:re,arrayExpr:se,itemVar:ie,content:oe}=J;try{let ge=se.trim(),ue;if(p(ge))ue=l(ge,Object.keys(H))(...Object.values(H));else ue=c(ge,H);let xe=!1;if(!Array.isArray(ue))if(ue instanceof Map)ue=Array.from(ue),xe=!0;else if(ue instanceof Set)ue=Array.from(ue);else if(typeof ue==="string")ue=Array.from(ue);else if(ue&&typeof ue==="object"&&!(ue instanceof Date)&&!(ue instanceof RegExp))ue=Object.entries(ue),xe=!0;else{let ke=Kb(ge,k)+i("Foreach",`Error in @foreach: ${ge} is not iterable`,t.TYPE_ERROR);G=G.substring(0,ne)+ke+G.substring(re);continue}let we=E?.loops?.useAltLoopVariable??Bb,$e=ie.trim(),_e=null,Ce,Ee=!1;if($e.includes("=>")){let ke=$e.split("=>").map((Ae)=>Ae.trim());if(ke.length===2&&ke[0]&&ke[1])_e=ke[0],Ce=ke[1];else Ce=$e}else if(!$e.startsWith("[")&&!$e.startsWith("{")&&$e.includes(",")){let ke=$e.split(",").map((Ae)=>Ae.trim());if(ke.length===2&&ke[0]&&ke[1])Ce=ke[0],_e=ke[1],Ee=!0;else Ce=$e}else Ce=$e;let Te="",Re=ue;for(let ke=0;ke<Re.length;ke++){let Ae=Re[ke],Xe={index:ke,iteration:ke+1,first:ke===0,last:ke===Re.length-1,count:Re.length},Pe={...H,loop:Xe,$loop:Xe};if(Ce.startsWith("[")&&Ce.endsWith("]")){let at=Ce.slice(1,-1).split(",").map((rt)=>rt.trim());if(Array.isArray(Ae))at.forEach((rt,bt)=>{if(rt)Pe[rt]=Ae[bt]});else Pe[Ce]=Ae}else if(Ce.startsWith("{")&&Ce.endsWith("}")){let at=Ce.slice(1,-1).split(",").map((rt)=>rt.trim()).filter(Boolean);if(Ae!==null&&typeof Ae==="object")at.forEach((rt)=>{let bt=rt.indexOf(":"),ft=(bt===-1?rt:rt.slice(0,bt)).trim(),yt=bt===-1?ft:rt.slice(bt+1).trim();if(ft&&yt)Pe[yt]=Ae[ft]});else Pe[Ce]=Ae}else Pe[Ce]=Ae;if(_e)if(!Ee&&xe&&Array.isArray(Ae)&&Ae.length===2)Pe[_e]=Ae[0],Pe[Ce]=Ae[1];else Pe[_e]=ke;let Ie=Vb(oe,Pe),Ze=Rp(Ie);if(Ze.hasContinue){Te+=Ze.content;continue}let nt=Cp(Ie);if(nt.hasBreak){Te+=nt.content;break}if(Ie=Tp(Ie,Pe),Ie=z(Ie,Pe),Ie=ar(Ie,Pe,k),Ie=Ub(Ie),nt=Cp(Ie),nt.hasBreak){Te+=nt.content;break}if(Ze=Rp(Ie),Ze.hasContinue){Te+=Ze.content;continue}Ie=q(Ie,Pe,k),Ie=Wb(Ie,Pe),Ie=Fb(Ie,Pe),Ie=zb(Ie,Pe),Te+=Ie}G=G.substring(0,ne)+Te+G.substring(re)}catch(ge){let ue=i("Foreach",`Error in @foreach(${se.trim()} as ${ie.trim()}): ${ge instanceof Error?ge.message:String(ge)}`,t.EVALUATION_ERROR);G=G.substring(0,ne)+ue+G.substring(re)}}return G}j=z(j,_),j=Dp(j,_,k,E);let F=E?.loops?.maxWhileIterations??Lb;return j=Jb(j,_,F),T?j:as(j)}function gc(v){let _=/^(\s*)([A-Za-z_$][\w$]*|\[[^\]]*\]|\{[^}]*\})(\s+(?:of|in)\s)/.exec(v);if(!_||/^(?:const|let|var)$/.test(_[2]))return v;return`${_[1]}let ${v.slice(_[1].length)}`}function Pp(v){return sr(v)}function Dp(v,_,k,E){let T=v,j=!0;while(j){j=!1;let B=T.match(/@for\s*\(/);if(!B||B.index===void 0)break;let z=B.index,F=z+B[0].length-1,V=S(T,"(",")",F);if(V===-1)break;let H=gc(T.slice(F+1,V)),G=V+1,J=ro(T.slice(z),"for","endfor");if(J.length===0)break;let ne=J[0].content,re=z+J[0].end;if(!Pp(H)){let se=i("For",`Unsafe expression in @for: ${H}`,t.UNSAFE_EXPRESSION);T=T.substring(0,z)+se+T.substring(re),j=!0;continue}try{let se=Zb(H),ie=/@(?:for|foreach|if|unless)\s*\(/.test(ne);if(se.length>0&&ie){let $e=Gb({forExpr:H,content:ne,iterVarNames:se,context:_,filePath:k,options:E});T=T.substring(0,z)+$e+T.substring(re),j=!0;continue}let oe=Object.keys(_),ge=Object.values(_),ue=ne.replace(/`/g,"\\`").replace(/\$\{/g,"\\${").replace(/\{\{([^}]+)\}\}/g,($e,_e)=>`\${${_e}}`);ue=Ap(ue);let we=Function(...oe,`
|
|
1899
|
+
let result = '';
|
|
1900
|
+
for (${H}) {
|
|
1901
|
+
result += \`${ue}\`;
|
|
1902
|
+
}
|
|
1903
|
+
return result;
|
|
1904
|
+
`)(...ge);T=T.substring(0,z)+we+T.substring(re),j=!0}catch(se){let ie=i("For",`Error in @for(${H}): ${se instanceof Error?se.message:String(se)}`,t.EVALUATION_ERROR);T=T.substring(0,z)+ie+T.substring(re),j=!0}}return T}function Zb(v){let _=v.trim(),k=_.match(/^(?:const|let|var)\s+(\[[^\]]+\]|\{[^}]+\})\s+(?:of|in)\s+/);if(k){let j=k[1];return j.slice(1,-1).split(",").map((z)=>{let F=z.trim();if(!F)return"";let V=F.indexOf(":");if(V>=0&&j.startsWith("{")){let J=F.slice(V+1).trim(),ne=J.indexOf("=");return(ne>=0?J.slice(0,ne):J).trim()}let H=F.indexOf("="),G=(H>=0?F.slice(0,H):F).trim();return/^[A-Za-z_$][\w$]*$/.test(G)?G:""}).filter(Boolean)}let E=_.match(/^(?:const|let|var)\s+([A-Za-z_$][\w$]*)\s+(?:of|in)\s+/);if(E)return[E[1]];let T=_.match(/^(?:const|let|var)\s+([A-Za-z_$][\w$]*)\s*=[^;]*;/);if(T)return[T[1]];return[]}function Gb(v){let{forExpr:_,content:k,iterVarNames:E,context:T,filePath:j,options:B}=v,z=Object.keys(T),F=Object.values(T),V=Function(...z,"__pushIter",`
|
|
1905
|
+
for (${_}) {
|
|
1906
|
+
__pushIter([${E.join(", ")}])
|
|
1907
|
+
}
|
|
1908
|
+
`),H=[];V(...F,(ne)=>{H.push(ne)});let G=j??"inline.stx",J="";for(let ne of H){let re={...T};E.forEach((ie,oe)=>{re[ie]=ne[oe]});let se=Dp(k,re,j,B);se=ar(se,re,G),se=q(se,re,G),J+=se}return J}function Jb(v,_,k){let E=v,T=!0;while(T){T=!1;let j=E.match(/@while\s*\(/);if(!j||j.index===void 0)break;let B=j.index,z=B+j[0].length-1,F=S(E,"(",")",z);if(F===-1)break;let V=E.slice(z+1,F),H=ro(E.slice(B),"while","endwhile");if(H.length===0)break;let G=H[0].content,J=B+H[0].end;if(!Pp(V)){let ne=i("While",`Unsafe expression in @while: ${V}`,t.UNSAFE_EXPRESSION);E=E.substring(0,B)+ne+E.substring(J),T=!0;continue}try{let ne=Object.keys(_),re=Object.values(_),se=G.replace(/`/g,"\\`").replace(/\$\{/g,"\\${").replace(/\{\{([^}]+)\}\}/g,(ge,ue)=>`\${${ue}}`);se=Ap(se);let oe=Function(...ne,`
|
|
1909
|
+
let result = '';
|
|
1910
|
+
let maxIterations = ${k}; // Configurable safety limit
|
|
1911
|
+
let counter = 0;
|
|
1912
|
+
while (${V} && counter < maxIterations) {
|
|
1913
|
+
counter++;
|
|
1914
|
+
result += \`${se}\`;
|
|
1915
|
+
}
|
|
1916
|
+
if (counter > maxIterations) {
|
|
1917
|
+
result += '<!-- [While Error [1104]]: Maximum iterations (${k}) exceeded in while loop. Configure via options.loops.maxWhileIterations -->';
|
|
1918
|
+
}
|
|
1919
|
+
return result;
|
|
1920
|
+
`)(...re);E=E.substring(0,B)+oe+E.substring(J),T=!0}catch(ne){let re=i("While",`Error in @while(${V}): ${ne instanceof Error?ne.message:String(ne)}`,t.EVALUATION_ERROR);E=E.substring(0,B)+re+E.substring(J),T=!0}}return E}function Yb(v,_="_method"){let k=v.toUpperCase();if(k==="GET"||k==="POST")return"";return`<input type="hidden" name="${_}" value="${k}">`}function Mp(v){return v.replace(/@method\(\s*(['"])([^'"]+)\1\s*(?:,\s*(['"])([^'"]+)\3\s*)?\)/g,(_,k,E,T,j)=>Yb(E,j||"_method"))}async function Op(v,_,k,E,T){if(!E.middleware||E.middleware.length===0)return v;let j=v,B=E.middleware.filter((z)=>z.timing===T);if(B.length===0)return j;for(let z of B){if(!z.name||typeof z.handler!=="function"){if(E.debug)console.warn("Invalid middleware:",z);continue}try{let F=await z.handler(j,_,k,E);if(typeof F==="string")j=F;else if(E.debug)console.warn(`Middleware ${z.name} did not return a string`)}catch(F){if(E.debug)console.error(`Error in middleware ${z.name}:`,F);if(E.debug){let V=g("Middleware",`Error in middleware '${z.name}': ${F instanceof Error?F.message:String(F)}`,k,v);j=j.replace(/<body[^>]*>/,`$&
|
|
1921
|
+
<div style="color:red;background:#ffeeee;padding:10px;border:1px solid #ff0000;margin:10px 0;font-family:monospace;white-space:pre-wrap;">${b(V)}</div>
|
|
1922
|
+
`)}}}return j}async function Np(v,_,k,E){return Op(v,_,k,E,"before")}async function jp(v,_,k,E){return Op(v,_,k,E,"after")}function Lp(v){return v.replace(/@route\(\s*(['"])([^'"]+)\1(?:\s*,\s*(\{[^}]+\}))?\s*(?:,\s*(true|false)\s*)?\)/g,(_,k,E,T,j)=>{try{let B=T?D(T,{}):{};return yn(E,B,j==="true")}catch(B){return console.error(`Error processing @route directive: ${B}`),"#route-error"}})}var Ti={patterns:[],exact:{}};async function Bp(v,_){let k=v.split("/").pop()?.split(".")[0]||"";if(Ti.exact[v])for(let E of Ti.exact[v])await Promise.resolve(E(_,v));if(Ti.exact[k])for(let E of Ti.exact[k])await Promise.resolve(E(_,v));for(let{pattern:E,callback:T}of Ti.patterns)if(E.test(v)||E.test(k))await Promise.resolve(T(_,v))}var Qb=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),ev=new Set(["a","abbr","address","area","article","aside","audio","b","base","bdi","bdo","blockquote","body","br","button","canvas","caption","cite","code","col","colgroup","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","search","section","select","slot","small","source","span","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","title","tr","track","u","ul","var","video","wbr"]);function Dr(v,_){let k=/<([a-zA-Z][a-zA-Z0-9-]*)((?:\s+(?:[^>"']|"[^"]*"|'[^']*')*)?)(\s*\/?)>/g;k.lastIndex=_;let E=k.exec(v);if(!E)return null;let T=/\/\s*>$/.test(E[0])||E[1]===E[1].toLowerCase()&&Qb.has(E[1]),j=T?E[2].replace(/\/\s*$/,""):E[2];return{full:E[0],tag:E[1],attrs:j,selfClosing:T,start:E.index,end:E.index+E[0].length}}function tv(v,_,k){let E=1,T=k,j=new RegExp(`<${_}(?:\\s(?:[^>"']|"[^"]*"|'[^']*')*)?>`,"gi"),B=new RegExp(`</${_}\\s*>`,"gi");while(E>0&&T<v.length){j.lastIndex=T,B.lastIndex=T;let z=j.exec(v),F=B.exec(v);if(!F)return-1;if(z&&z.index<F.index)E++,T=z.index+z[0].length;else{if(E--,E===0)return F.index+F[0].length;T=F.index+F[0].length}}return-1}function Pr(v,_){if(_.selfClosing)return{outerStart:_.start,outerEnd:_.end,innerHTML:""};let k=tv(v,_.tag,_.end);if(k===-1)return{outerStart:_.start,outerEnd:_.end,innerHTML:""};return{outerStart:_.start,outerEnd:k,innerHTML:v.slice(_.end,k-`</${_.tag}>`.length)}}function zp(v,_){return new RegExp(`(?:^|\\s)${_.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}(?:=|\\s|$|>|/)`).test(v)||v.includes(` ${_}=`)||v.includes(` ${_} `)||v.trimEnd().endsWith(` ${_}`)}function Ai(v,_){let k=_.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),E=v.match(new RegExp(`${k}="([^"]*)"`,"s"))||v.match(new RegExp(`${k}='([^']*)'`,"s"));return E?E[1]:null}function vr(v,_){let k=_.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return v.replace(new RegExp(`\\s*${k}="[^"]*"`,"g"),"").replace(new RegExp(`\\s*${k}='[^']*'`,"g"),"").replace(new RegExp(`\\s*${k}(?=\\s|$|>|/)`,"g"),"")}function Bs(v,_,k){let E=_.selfClosing?" /":"",T=`<${_.tag}${k}${E}>`;return v.slice(0,_.start)+T+v.slice(_.end)}function nv(v){return/\bv-(?:if|else-if|else|for|show|model|html|text|pre|once|cloak|memo|bind|on|slot)\b/.test(v)}function rv(v){let _=v,k=0;while(k<_.length){let E=Dr(_,k);if(!E)break;let T=Ai(E.attrs,"v-for");if(T===null){k=E.end;continue}let j=T.match(/^\s*\(?([^)]+)\)?\s+(?:in|of)\s+(.+)\s*$/);if(!j){k=E.end;continue}let B=j[1].trim(),z=j[2].trim(),F;if(B.includes(",")){let ie=B.split(",").map((ue)=>ue.trim()),oe=ie[0],ge=ie[1];F=`${z} as ${ge} => ${oe}`}else F=`${z} as ${B}`;let V=vr(E.attrs,"v-for"),H=vr(V,":key").replace(/\s*v-bind:key="[^"]*"/g,""),G=Pr(_,E),J=_.slice(G.outerStart,G.outerEnd),ne=Bs(J,{...E,start:0,end:E.end-E.start},H),re=`@foreach(${F})
|
|
1923
|
+
`,se=`${re}${ne}
|
|
1924
|
+
@endforeach`;_=_.slice(0,G.outerStart)+se+_.slice(G.outerEnd),k=G.outerStart+re.length}return _}function sv(v){let _=v,k=0;while(k<_.length){let E=Dr(_,k);if(!E)break;let T=Ai(E.attrs,"v-if");if(T===null){k=E.end;continue}let j=[],B=Pr(_,E),z=vr(E.attrs,"v-if"),F=Bs(_.slice(B.outerStart,B.outerEnd),{...E,start:0,end:E.end-E.start},z);j.push({type:"if",expr:T,outerStart:B.outerStart,outerEnd:B.outerEnd,element:F,parsedTag:E});let V=B.outerEnd,H=!0;while(H){let se=_.slice(V).match(/^\s*/),ie=se?se[0].length:0,oe=Dr(_,V+ie);if(!oe){H=!1;break}let ge=Ai(oe.attrs,"v-else-if"),ue=zp(oe.attrs,"v-else");if(ge!==null){let xe=Pr(_,oe),we=vr(oe.attrs,"v-else-if"),$e=Bs(_.slice(xe.outerStart,xe.outerEnd),{...oe,start:0,end:oe.end-oe.start},we);j.push({type:"else-if",expr:ge,outerStart:V,outerEnd:xe.outerEnd,element:$e,parsedTag:oe}),V=xe.outerEnd}else if(ue){let xe=Pr(_,oe),we=vr(oe.attrs,"v-else"),$e=Bs(_.slice(xe.outerStart,xe.outerEnd),{...oe,start:0,end:oe.end-oe.start},we);j.push({type:"else",outerStart:V,outerEnd:xe.outerEnd,element:$e,parsedTag:oe}),H=!1}else H=!1}let G=[];for(let se of j)if(se.type==="if")G.push(`@if(${se.expr})
|
|
1925
|
+
${se.element}`);else if(se.type==="else-if")G.push(`@elseif(${se.expr})
|
|
1926
|
+
${se.element}`);else G.push(`@else
|
|
1927
|
+
${se.element}`);G.push("@endif");let J=G.join(`
|
|
1928
|
+
`),ne=j[0].outerStart,re=j[j.length-1].outerEnd;_=_.slice(0,ne)+J+_.slice(re),k=ne+J.length}return _}function iv(v){return v.replace(/\bv-show="([^"]*)"/g,'@show="$1"')}function ov(v){let _=v,k=0;while(k<_.length){let E=Dr(_,k);if(!E)break;let T=ev.has(E.tag),j=E.attrs.replace(/([^\s=]+)(?:\s*=\s*("[^"]*"|'[^']*'|[^\s]+))?/g,(z,F,V)=>{let H=/^v-model(?::([a-zA-Z_][a-zA-Z0-9_]*))?((?:\.[a-zA-Z]+)*)$/.exec(F);if(!H||!V||!/^["']/.test(V))return z;let G=H[1]||"modelValue",J=H[2];if(T&&!H[1])return`@model${J}=${V}`;let ne=V[0],re=V.slice(1,-1),se=`:${G}=${V} @update:${G}=${ne}${re} = $event${ne}`;if(J){let ie=H[1]?`${G}Modifiers`:"modelModifiers",oe=J.slice(1).split(".").map((ge)=>`${ge}: true`).join(", ");se+=` :${ie}="{ ${oe} }"`}return se});if(j===E.attrs){k=E.end;continue}let B=Bs(E.full,{...E,start:0,end:E.full.length},j);_=_.slice(0,E.start)+B+_.slice(E.end),k=E.start+B.length}return _}function av(v){return v.replace(/\bv-bind:([a-zA-Z_][a-zA-Z0-9_-]*)\s*=\s*"([^"]*)"/g,'@bind:$1="$2"')}function cv(v){return v.replace(/\bv-on:([a-zA-Z_][a-zA-Z0-9_.-]*)\s*=\s*"([^"]*)"/g,'@$1="$2"')}function lv(v){let _=v,k=0;while(k<_.length){let E=Dr(_,k);if(!E)break;let T=Ai(E.attrs,"v-html");if(T===null){k=E.end;continue}if(E.selfClosing){k=E.end;continue}let j=Pr(_,E),B=vr(E.attrs,"v-html"),z=E.selfClosing?" /":"",F=`<${E.tag}${B}${z}>{!! ${T} !!}</${E.tag}>`;_=_.slice(0,j.outerStart)+F+_.slice(j.outerEnd),k=j.outerStart+F.length}return _}function uv(v){let _=v,k=0;while(k<_.length){let E=Dr(_,k);if(!E)break;let T=Ai(E.attrs,"v-text");if(T===null){k=E.end;continue}if(E.selfClosing){k=E.end;continue}let j=Pr(_,E),B=vr(E.attrs,"v-text"),z=E.selfClosing?" /":"",F=`<${E.tag}${B}${z}>{{ ${T} }}</${E.tag}>`;_=_.slice(0,j.outerStart)+F+_.slice(j.outerEnd),k=j.outerStart+F.length}return _}function dv(v){return v.replace(/(<[a-zA-Z][a-zA-Z0-9-]*)(\s[^>]*?)\s+v-pre([^>]*>)/g,"$1$2 data-stx-skip$3").replace(/(<[a-zA-Z][a-zA-Z0-9-]*)\s+v-pre(\s[^>]*>|>)/g,"$1 data-stx-skip$2")}function fv(v){let _=v,k=0;while(k<_.length){let E=Dr(_,k);if(!E)break;if(!zp(E.attrs,"v-once")){k=E.end;continue}let T=vr(E.attrs,"v-once"),j=Pr(_,E),B=_.slice(j.outerStart,j.outerEnd),F=`@once
|
|
1929
|
+
${Bs(B,{...E,start:0,end:E.end-E.start},T)}
|
|
1930
|
+
@endonce`;_=_.slice(0,j.outerStart)+F+_.slice(j.outerEnd),k=j.outerStart+F.length}return _}function pv(v){return v.replace(/\bv-memo="([^"]*)"/g,'data-stx-memo="$1"')}function gv(v){return v.replace(/\bv-slot:([a-zA-Z_][a-zA-Z0-9_-]*)\s*=\s*"([^"]*)"/g,'#$1="$2"').replace(/\bv-slot:([a-zA-Z_][a-zA-Z0-9_-]*)(?=[\s>])/g,"#$1").replace(/\bv-slot\s*=\s*"([^"]*)"/g,'#default="$1"')}function Fp(v){if(!nv(v))return v;let _=v;return _=rv(_),_=sv(_),_=fv(_),_=av(_),_=cv(_),_=ov(_),_=iv(_),_=gv(_),_=lv(_),_=uv(_),_=dv(_),_=pv(_),_}function Co(v){return v.replace(/--/g,"- -").replace(/</g,"<").replace(/>/g,">")}var pl=new Set(["a","abbr","address","article","aside","audio","b","bdi","bdo","blockquote","button","canvas","caption","cite","code","col","colgroup","data","datalist","dd","del","details","dfn","dialog","div","dl","dt","em","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","header","hgroup","hr","i","iframe","img","input","ins","kbd","label","legend","li","main","mark","menu","meter","nav","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","section","select","small","span","strong","sub","summary","sup","table","tbody","td","textarea","tfoot","th","thead","time","tr","u","ul","video"]),mv=new Set(["area","base","br","col","embed","hr","img","input","link","meta","source","track","wbr"]);function Wp(v,_){let k=/^\s*\{\{\s*([\s\S]+?)\s*\}\}\s*$/.exec(v),E=k?k[1]:v,T=c(E,_);if(T&&typeof T==="string")return T;let j=E.trim();return pl.has(j)?j:null}function Vp(v){let _=/^\s*\{\{\s*([\s\S]+?)\s*\}\}\s*$/.exec(v);return _?_[1]:v}function Up(v,_,k){let E=_.replace(/\s*(?::is|v-bind:is)\s*=\s*"[^"]*"/gi,"").trim(),T=E?`<${v} ${E}>`:`<${v}>`;if(mv.has(v))return E?`<${v} ${E}>`:`<${v}>`;return`${T}${k}</${v}>`}async function Hp(v,_,k,E,T){let j=v,B=/<component\s+(?::is|v-bind:is)\s*=\s*"([^"]*)"([^>]*)>([\s\S]*?)<\/component>/gi,z=[],F;while((F=B.exec(j))!==null)z.push({full:F[0],expr:F[1],attrs:F[2],slotContent:F[3],index:F.index});for(let V=z.length-1;V>=0;V--){let H=z[V];try{let G=Wp(H.expr,_);if(!G||typeof G!=="string"){let ge=`<!-- dynamic component: could not resolve "${Co(Vp(H.expr))}" -->`;j=j.slice(0,H.index)+ge+j.slice(H.index+H.full.length);continue}if(pl.has(G)){let ge=Up(G,H.attrs,H.slotContent);j=j.slice(0,H.index)+ge+j.slice(H.index+H.full.length);continue}let J=H.attrs.trim(),ne={},re=/(?::([a-zA-Z_][a-zA-Z0-9_-]*)|([a-zA-Z_][a-zA-Z0-9_-]*))\s*=\s*"([^"]*)"/g,se;while((se=re.exec(J))!==null){let ge=se[1]||se[2],ue=se[3];if(se[1])try{ne[ge]=c(ue,_)}catch{ne[ge]=ue}else ne[ge]=ue}let ie=E.componentsDir||"components",oe=await We(G,ne,H.slotContent,ie,_,k,E,new Set,T??new Set);j=j.slice(0,H.index)+oe+j.slice(H.index+H.full.length)}catch(G){let J=G instanceof Error?G.message:String(G),ne=`<!-- dynamic component error: ${Co(J)} -->`;j=j.slice(0,H.index)+ne+j.slice(H.index+H.full.length)}}return j=await hv(j,_,k,E,T),j}async function hv(v,_,k,E,T){let j=v,B=/<component\s+(?::is|v-bind:is)\s*=\s*"([^"]*)"([^>]*?)\/>/gi,z=[],F;while((F=B.exec(j))!==null)z.push({full:F[0],expr:F[1],attrs:F[2],index:F.index});for(let V=z.length-1;V>=0;V--){let H=z[V];try{let G=Wp(H.expr,_);if(!G||typeof G!=="string"){let re=`<!-- dynamic component: could not resolve "${Co(Vp(H.expr))}" -->`;j=j.slice(0,H.index)+re+j.slice(H.index+H.full.length);continue}if(pl.has(G)){let re=Up(G,H.attrs,"");j=j.slice(0,H.index)+re+j.slice(H.index+H.full.length);continue}let J=E.componentsDir||"components",ne=await We(G,{},"",J,_,k,E,new Set,T??new Set);j=j.slice(0,H.index)+ne+j.slice(H.index+H.full.length)}catch(G){let J=G instanceof Error?G.message:String(G),ne=`<!-- dynamic component error: ${Co(J)} -->`;j=j.slice(0,H.index)+ne+j.slice(H.index+H.full.length)}}return j}function gl(){return{afterOpen:[],beforeClose:[]}}function yv(v){return v.afterOpen.length>0||v.beforeClose.length>0}function Kp(v,_){if(!yv(_))return v;let k=_.afterOpen.join(""),E=_.beforeClose.join(""),T=v.lastIndexOf("</head>"),j=k?Ii(v):null,B=E&&T!==-1?T:null;if(j===null&&B===null)return v;if(j!==null&&B!==null)return`${v.slice(0,j)}${k}${v.slice(j,B)}${E}${v.slice(B)}`;if(j!==null)return`${v.slice(0,j)}${k}${v.slice(j)}`;return`${v.slice(0,B)}${E}${v.slice(B)}`}var qp=/\s*<meta\b[^>]*\bcharset\b[^>]*>/iy;function Ii(v){let _=/<head\b[^>]*>/i.exec(v);if(!_)return null;let k=_.index+_[0].length;qp.lastIndex=k;let E=qp.exec(v);return E?k+E[0].length:k}var hl="data-stx-color-mode-boot",xv="__STX_COLOR_MODE__",bv=new Set(["light","dark","auto","system"]),vv=new Set(["auto","system"]),wv=/^[a-z][\w:-]*$/i,Sv=/^[\w-]+$/;function $v(v){let _=v.storageKey??"stx-color-mode",k=v.initialMode??"auto",E=v.darkClass===void 0?"dark":v.darkClass,T=v.attribute??null,j=v.autoValue??null,B=v.respectExisting===!0;if(typeof _!=="string"||_.length===0)throw Error("colorMode.storageKey must be a non-empty string");if(!bv.has(k))throw Error(`colorMode.initialMode must be one of light, dark, auto, system \u2014 got ${JSON.stringify(k)}`);if(E!==null&&(typeof E!=="string"||!Sv.test(E)))throw Error(`colorMode.darkClass must be a single CSS class name, or null to opt out \u2014 got ${JSON.stringify(E)}`);if(T!==null&&(typeof T!=="string"||!wv.test(T)))throw Error(`colorMode.attribute must be a valid HTML attribute name \u2014 got ${JSON.stringify(T)}`);if(j!==null&&!vv.has(j))throw Error(`colorMode.autoValue must be 'auto' or 'system' \u2014 got ${JSON.stringify(j)}`);if(E===null&&T===null)throw Error("colorMode needs at least one of darkClass or attribute \u2014 with both null nothing would mark the mode on <html>");if(B&&T===null)throw Error("colorMode.respectExisting needs an attribute to read \u2014 the dark class alone cannot say whether a mode was chosen");return{storageKey:_,initialMode:k==="system"?"auto":k,darkClass:E,attribute:T,autoValue:j,respectExisting:B}}function _v(v){return JSON.stringify(v).replace(/</g,"\\u003c").replace(/>/g,"\\u003e").replace(/&/g,"\\u0026").replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}function yl(v={}){let _=$v(v),E=`(function(){"use strict";var c=${_v(_)};var p=c.initialMode;var a=c.autoValue;try{var v=localStorage.getItem(c.storageKey);if(v==="light"||v==="dark"){p=v}else if(v==="auto"||v==="system"){p="auto";if(!a)a=v}}catch(e){}var r=document.documentElement;var f=null;if(c.respectExisting&&c.attribute){var x=r.getAttribute(c.attribute);if(x==="light"||x==="dark")f=x}var m=f;if(!m){m=p;if(p==="auto"){try{m=matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}catch(e){m="light"}}}if(c.attribute)r.setAttribute(c.attribute,m);if(c.darkClass){if(m==="dark")r.classList.add(c.darkClass);else r.classList.remove(c.darkClass)}try{window.${xv}={storageKey:c.storageKey,initialMode:c.initialMode,darkClass:c.darkClass,attribute:c.attribute,autoValue:a||"auto",respectExisting:c.respectExisting,forced:f,preference:p,mode:m}}catch(e){}}());`;return`<script ${hl}>${E}</script>`}function zn(v,_={}){if(v.includes(hl))return v;let k=ml(v);if(k===null)return v;let E=yl(_);return`${v.slice(0,k)}
|
|
1931
|
+
${E}${v.slice(k)}`}var ml=Ii,kv=new RegExp(`<script\\b[^>]*\\b${hl}\\b[^>]*>[\\s\\S]*?<\\/script>`,"i"),Xp=/<meta\b[^>]*\bcharset\b[^>]*>/gi,Zp=/<\/head>/gi;function Ev(v){let _=/<head\b[^>]*>/i.exec(v);if(!_)return v;let k=_.index+_[0].length;Zp.lastIndex=k;let E=Zp.exec(v),T=E?E.index:v.length;Xp.lastIndex=k;let j=Xp.exec(v);if(!j||j.index>=T)return v;if(v.slice(k,j.index).trim()==="")return v;let B=j.index+j[0].length;return`${v.slice(0,k)}
|
|
1932
|
+
${j[0]}${v.slice(k,j.index)}${v.slice(B,T)}${v.slice(T)}`}function Gp(v){return Cv(Ev(v))}function Cv(v){let _=kv.exec(v);if(!_)return v;let k=ml(v);if(k===null)return v;if(_.index<=k||v.slice(k,_.index).trim()==="")return v;let E=v.slice(0,_.index)+v.slice(_.index+_[0].length),T=ml(E);if(T===null)return v;return`${E.slice(0,T)}
|
|
1933
|
+
${_[0]}${E.slice(T)}`}var ei="X-STX-Build",xl=Symbol.for("stx.buildId");function ds(){let v=globalThis;if(!v[xl])v[xl]=process.env.STX_BUILD_ID||`${Date.now().toString(36)}${Math.random().toString(36).slice(2,8)}`;return v[xl]}function Jp(v,_=ds()){if(v.includes('name="stx-build"'))return null;if(!/<head\b[^>]*>/i.test(v))return null;return`
|
|
1934
|
+
<meta name="stx-build" content="${_}">`}function Rv(v){if(typeof navigator>"u"||!("serviceWorker"in navigator)||!navigator.serviceWorker)return;let _=navigator.serviceWorker,k=window;if(k.stxOffline)return;let E=null,T=!1,j=[],B={updateReady:!1,registration:()=>E,onUpdateReady(H){if(B.updateReady)try{H()}catch{}else j.push(H);return()=>{let G=j.indexOf(H);if(G!==-1)j.splice(G,1)}},applyUpdate(){let H=E&&E.waiting;if(!H)return!1;return T=!0,H.postMessage({type:"stx:activate-update",force:!0}),!0}};k.stxOffline=B;let z=(H)=>{if(!H.waiting||!_.controller||B.updateReady)return;B.updateReady=!0;let G=j.splice(0);for(let J of G)try{J()}catch{}try{window.dispatchEvent(new CustomEvent("stx:offline-update-ready"))}catch{}};_.addEventListener("message",(H)=>{let G=H.data||{};if(G.type==="stx:updated")try{window.dispatchEvent(new CustomEvent("stx:updated",{detail:{url:G.url,kind:G.kind,fragment:!!G.fragment}}))}catch{}}),_.addEventListener("controllerchange",()=>{if(T)T=!1,location.reload()}),document.addEventListener("visibilitychange",()=>{if(document.visibilityState==="hidden"&&E&&E.waiting)E.waiting.postMessage({type:"stx:activate-update",reason:"hidden"})});let F=()=>{_.register(v,{scope:"/"}).then((H)=>{if(E=H,H.waiting)z(H),H.waiting.postMessage({type:"stx:activate-update",reason:"load"});H.addEventListener("updatefound",()=>{let G=H.installing;if(!G)return;G.addEventListener("statechange",()=>{if(G.state==="installed")z(H)})})}).catch(()=>{})},V=()=>{let H=(G)=>{setTimeout(G,0)};if(typeof requestAnimationFrame==="function")requestAnimationFrame(()=>H(F));else H(F)};if(!_.controller)if(document.readyState==="complete")V();else addEventListener("load",V);else if(document.readyState==="loading")document.addEventListener("DOMContentLoaded",V);else V()}function Tv(){let v=`(${Rv.toString()})(${JSON.stringify("/_stx/sw.js")})`;try{return new Bun.Transpiler({loader:"js",minifyWhitespace:!0}).transformSync(v).trim().replace(/;$/,"")}catch{return v}}var Yp=`<script data-stx-offline>${Tv()}</script>`;import{AsyncLocalStorage as Av}from"async_hooks";var Qp=new Av;function rn(v){return v.__stx_server_data??={pending:new Map,values:new Map}}function eg(v,_){return Qp.run(rn(v),_)}async function tg(v,_){let k=Qp.getStore();if(!k)throw Error("useServerData must run inside a <script server> render");if(typeof v!=="string"||!v.trim())throw TypeError("useServerData requires a non-empty string key");let E=k.pending.get(v);if(E)return E;let T=Promise.resolve().then(_).then((j)=>{let B=JSON.stringify(j,(F,V)=>{if(V===void 0||typeof V==="function"||typeof V==="symbol"||typeof V==="bigint"||typeof V==="number"&&!Number.isFinite(V))throw TypeError(`useServerData(${JSON.stringify(v)}) requires JSON-serializable data`);if(V&&typeof V==="object"&&!Array.isArray(V)&&Object.getPrototypeOf(V)!==Object.prototype&&Object.getPrototypeOf(V)!==null)throw TypeError(`useServerData(${JSON.stringify(v)}) requires JSON-serializable data`);return V}),z=JSON.parse(B);return k.values.set(v,z),z}).catch((j)=>{throw k.pending.delete(v),j});return k.pending.set(v,T),T}function Fn(v){let _=v.__stx_server_data;if(!_?.values.size)return"";return`<script data-stx-scoped data-stx-server-data type="application/json">${JSON.stringify(Object.fromEntries(_.values)).replace(/</g,"\\u003c").replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}</script>`}var sg="<style data-stx-cloak>[x-cloak]{display:none !important}</style>",Ro="data-stx-html-attrs",To="data-stx-html-class",ig=/^[A-Za-z_:][\w:.-]*$/;function cr(v){return String(v).replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}function Iv(v){return String(v).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}function wr(v){if(v.name)return`name="${v.name}"`;if(v.property)return`property="${v.property}"`;if(v.charset!=null)return"charset=";if(v["http-equiv"])return`http-equiv="${v["http-equiv"]}"`;return""}function Pv(v){let _=/^\s*<meta\b([^>]*)>/i.exec(v);if(!_)return null;let k={};for(let E of _[1].matchAll(/([\w:-]+)(?:\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s"'>]+)))?/g))k[E[1].toLowerCase()]=E[2]??E[3]??E[4]??"";return k}function zs(v,_){return Object.entries(v).filter(([k])=>!_?.(k)).map(([k,E])=>`${k}="${cr(String(E))}"`).join(" ")}function Dv(v={},_="en"){let k=[],E=[],T="",j=_;for(let[z,F]of Object.entries(v||{})){if(F==null)continue;let V=z.trim();if(!ig.test(V))continue;let H=V.toLowerCase();if(H==="lang"){j=String(F);continue}if(H==="class"){T=String(F).trim();continue}k.push(` ${V}="${cr(String(F))}"`),E.push(V)}let B=` lang="${cr(j)}"`;if(T)B+=` class="${cr(T)}"`;if(B+=k.join(""),T)B+=` ${To}="${cr(T)}"`;if(E.length)B+=` ${Ro}="${cr(E.join(" "))}"`;return B}function og(v={},_={}){let k={...v,..._};if(v.class&&_.class){let E=v.class.split(/\s+/).filter(Boolean);for(let T of _.class.split(/\s+/).filter(Boolean))if(!E.includes(T))E.push(T);k.class=E.join(" ")}return k}function Hn(v,_={}){if(!_||Object.keys(_).length===0)return v;let k=v.match(/<html\b([^>]*)>/i);if(!k)return v;let E={},T=[],j=/([A-Za-z_:][\w:.-]*)(?:\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s"'>]+)))?/g,B;while((B=j.exec(k[1]))!==null){let H=B[1];if(!(H in E))T.push(H);E[H]=B[2]??B[3]??B[4]??""}let z=[],F=[];for(let[H,G]of Object.entries(_)){if(G==null)continue;let J=H.trim();if(!ig.test(J))continue;let ne=J.toLowerCase();if(ne==="class"){let re=(E.class||"").split(/\s+/).filter(Boolean);for(let se of String(G).split(/\s+/).filter(Boolean))if(!re.includes(se))re.push(se),z.push(se);if(!("class"in E))T.push("class");E.class=re.join(" ");continue}if(!(J in E))T.push(J);if(E[J]=String(G),ne!=="lang")F.push(J)}if(z.length){if(!(To in E))T.push(To);E[To]=z.join(" ")}if(F.length){if(!(Ro in E))T.push(Ro);E[Ro]=F.join(" ")}let V=T.map((H)=>` ${H}="${cr(E[H])}"`).join("");return v.replace(k[0],()=>`<html${V}>`)}function ag(v){if(v.includes("data-stx-cloak"))return null;if(v.lastIndexOf("</head>")===-1)return null;return`${sg}
|
|
1935
|
+
`}function Mv(v){let _=[],k=0;while(k<v.length){let j=v.slice(k),B=j.match(/^\s+/);if(B){k+=B[0].length;continue}if(j.startsWith("<!--")){let G=v.indexOf("-->",k);if(G===-1)break;k=G+3;continue}let z=j.match(/^<script\b[^>]*>/i);if(z){let G=v.toLowerCase().indexOf("</script>",k+z[0].length);if(G===-1)break;k=G+9;continue}let F=j.match(/^<link\b[^>]*>/i);if(F){_.push(F[0]),k+=F[0].length;continue}let V=j.match(/^<meta\b[^>]*>/i);if(V){_.push(V[0]),k+=V[0].length;continue}let H=j.match(/^<style\b[^>]*>[\s\S]*?<\/style>/i);if(H){_.push(H[0]),k+=H[0].length;continue}break}if(_.length===0)return{body:v,hoisted:_};let E="",T=0;while(T<v.length&&T<k){let j=v.slice(T),B=j.match(/^<link\b[^>]*>/i);if(B&&_.includes(B[0])){T+=B[0].length;continue}let z=j.match(/^<meta\b[^>]*>/i);if(z&&_.includes(z[0])){T+=z[0].length;continue}let F=j.match(/^<style\b[^>]*>[\s\S]*?<\/style>/i);if(F&&_.includes(F[0])){T+=F[0].length;continue}E+=v[T],T++}return E+=v.slice(k),{body:E,hoisted:_}}function Ov(v,_={},k={}){let{title:E="stx App",lang:T="en",meta:j=[],link:B=[],script:z=[],headRaw:F="",htmlAttrs:V={},bodyClass:H="",bodyAttrs:G={}}=_,J=k.title||E,ne=[{charset:"UTF-8"},{name:"viewport",content:"width=device-width, initial-scale=1.0"}],re=new Set(j.map(wr).filter(Boolean)),{body:se,hoisted:ie}=Mv(v),oe=new Set(ie.flatMap((Re)=>{let ke=Pv(Re);return ke?[wr(ke)].filter(Boolean):[]})),ue=[...ne.filter((Re)=>!re.has(wr(Re))),...j].filter((Re)=>!oe.has(wr(Re))).map((Re)=>` <meta ${zs(Re)}>`).join(`
|
|
1936
|
+
`),xe=B.map((Re)=>` <link ${zs(Re)}>`).join(`
|
|
1937
|
+
`),we=z.map((Re)=>{if(Re.src)return` <script ${zs(Re,(ke)=>ke==="content")}></script>`;if(Re.content)return` <script>${Re.content}</script>`;return""}).filter(Boolean).join(`
|
|
1938
|
+
`),$e=Dv(V,T),_e=Object.entries(G).map(([Re,ke])=>` ${Re}="${cr(String(ke))}"`).join(""),Ce=H?` class="${cr(H)}"`:"",Ee=[ue,k.colorMode?` ${yl(k.colorMode)}`:"",` <title>${k.titleIsHtml?J:Iv(J)}</title>`,` ${sg}`,xe,we,F?` ${F}`:"",...(k.styles||[]).map((Re)=>` ${Re}`),...ie.map((Re)=>` ${Re}`),...(k.headScripts||[]).map((Re)=>` ${Re}`),k.headStack||""].filter(Boolean),Te=[se,...(k.bodyScripts||[]).map((Re)=>Re),k.bodyStack||""].filter(Boolean);return`<!DOCTYPE html>
|
|
1939
|
+
<html${$e}>
|
|
1940
|
+
<head>
|
|
1941
|
+
${Ee.join(`
|
|
1942
|
+
`)}
|
|
1943
|
+
</head>
|
|
1944
|
+
<body${Ce}${_e}>
|
|
1945
|
+
${Te.join(`
|
|
1946
|
+
`)}
|
|
1947
|
+
</body>
|
|
1948
|
+
</html>`}var bl=/\s+/y,vl=/<(script|style)\b[^>]*>/iy,Nv=/<\/script>/gi,jv=/<\/style>/gi,ng=/<!DOCTYPE\b/iy,rg=/<html[\s>]/iy;function sn(v){let _=0;while(_<v.length){if(bl.lastIndex=_,bl.exec(v)){_=bl.lastIndex;continue}if(v.startsWith("<!--",_)){let T=v.indexOf("-->",_);if(T===-1)return!1;_=T+3;continue}vl.lastIndex=_;let E=vl.exec(v);if(E){let T=E[1].toLowerCase()==="script"?Nv:jv;T.lastIndex=vl.lastIndex;let j=T.exec(v);if(j===null)return!1;_=j.index+j[0].length;continue}if(ng.lastIndex=_,ng.test(v))return!0;return rg.lastIndex=_,rg.test(v)}return!1}function wl(v){return sn(v)}function cg(v,_={}){let k=v.lastIndexOf("</head>");if(k===-1)return v;let{meta:E=[],link:T=[],script:j=[],headRaw:B=""}=_,z=v.slice(0,k),F=[];for(let V of E){let H=wr(V);if(H&&z.includes(H))continue;F.push(` <meta ${zs(V)}>`)}for(let V of T){if(V.href&&z.includes(`href="${V.href}"`))continue;F.push(` <link ${zs(V)}>`)}for(let V of j)if(V.src){if(z.includes(`src="${V.src}"`))continue;F.push(` <script ${zs(V,(H)=>H==="content")}></script>`)}else if(V.content){if(z.includes(V.content))continue;F.push(` <script>${V.content}</script>`)}if(B&&!z.includes(B))F.push(` ${B}`);if(F.length===0)return v;return`${v.slice(0,k)}${F.join(`
|
|
1949
|
+
`)}
|
|
1950
|
+
${v.slice(k)}`}function Vn(v,_={},k={},E){if(E??wl(v))return v;return Ov(v,_,k)}import lg from"path";function N(v,_={}){return new hn(v,_).routes}var ug=new Map;async function dg(v,_){let k=v,E=_;if(!k||!E)try{let z=await o();k||=z?.pagesDir||"pages",E||=z?.root||"."}catch{k||="pages",E||="."}let T=lg.isAbsolute(k)?k:lg.join(E,k),j=ug.get(T);if(j)return j;let B=[];try{B=N(".",{pagesDir:T,emit:!1}).map((z)=>z.regex.source).filter(Boolean)}catch{B=[]}return ug.set(T,B),B}function Bv(v){return v.replace(/</g,"\\u003c").replace(/>/g,"\\u003e").replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}function fg(v){return Bv(JSON.stringify(v))}function ae(v){return v.includes("data-stx-runtime")}function pg(v){let _=/window\.stx\s*\.\s*[A-Za-z_$]|\}\s*=\s*window\.stx\s*;/g;for(let k=_.exec(v);k!==null;k=_.exec(v)){let E=v.slice(Math.max(0,k.index-80),k.index);if(/if\s*\(\s*window\.stx\s*\)|window\.stx\s*&&/.test(E))continue;return!0}return!1}function Sl(v,_){let k=Gs(v),E=v.search(/<!doctype\b/i);if(k!==-1&&(E===-1||k>E))return v.slice(0,k)+_+`
|
|
1951
|
+
`+v.slice(k);let T=Ii(v);if(T!==null)return`${v.slice(0,T)}
|
|
1952
|
+
${_}${v.slice(T)}`;if(v.includes("</head>")){let B=v.indexOf("</head>");return v.slice(0,B)+_+`
|
|
1953
|
+
`+v.slice(B)}if(An(v))return ws(v,(B)=>`${B}
|
|
1954
|
+
${_}`);return`${_}
|
|
1955
|
+
${v}`}async function Ao(v,_){if(v.includes("data-stx-runtime")||v.includes("window.stx.state")||v.includes("STX Signals Runtime"))return v;if(_.buildMode==="serve"){let{getServeClientAsset:T}=await import("./chunk-2jxe6y8h.js"),{url:j}=await T("runtime",_.debug===!0);return Sl(v,`<script data-stx-runtime src="${j}"></script>`)}if(_.buildMode==="compile")return Sl(v,'<script data-stx-runtime src="/__stx/runtime.__STX_HASH__.js"></script>');let{getCachedSignalsRuntime:k}=await import("./chunk-2jxe6y8h.js"),E=await k(_.debug);return Sl(v,`<script data-stx-scoped data-stx-runtime>${E}</script>`)}function zv(v){return/<[a-z][^>]*?\sx-tooltip\s*=/i.test(v)}function gg(v){if(v.includes("data-stx-tooltip-runtime")||!zv(v))return v;let _=`<script data-stx-scoped data-stx-tooltip-runtime>${sl()}</script>`,k=v.lastIndexOf("</body>");if(k===-1)return`${v}
|
|
1956
|
+
${_}`;return`${v.slice(0,k)}${_}
|
|
1957
|
+
${v.slice(k)}`}var Fv=/<script\b[^>]*\sdata-stx-router(?=[\s=>])/i;function Wv(v){return Fv.test(v)||v.includes("__stxRouter)return")||v.includes("__stxRouter=true")}async function K(v,_){if(!v.includes("</body>"))return v;if(Wv(v))return v;let k=_?.router,E="";{let F={};if(k){if(k.container)F.container=k.container;if(k.interceptAllLinks!==void 0)F.interceptAllLinks=k.interceptAllLinks;if(k.progress!==void 0)F.progress=k.progress;if(k.viewTransitions!==void 0)F.viewTransitions=k.viewTransitions;if(k.viewTransitionDuration!==void 0)F.viewTransitionDuration=k.viewTransitionDuration;if(k.viewTransitionEasing!==void 0)F.viewTransitionEasing=k.viewTransitionEasing;if(k.scrollToTop!==void 0)F.scrollToTop=k.scrollToTop;if(k.scrollRestoration!==void 0)F.scrollRestoration=k.scrollRestoration;if(k.prefetch!==void 0)F.prefetch=k.prefetch;if(k.cache!==void 0)F.cache=k.cache;if(k.progressColor!==void 0)F.progressColor=k.progressColor;if(k.progressHeight!==void 0)F.progressHeight=k.progressHeight}try{let V=await dg(_?.pagesDir,_?.root);if(V.length>0)F.ownedRoutes=V}catch{}if(Object.keys(F).length>0)E=`<script>window.__stxRouterConfig=${fg(F)};</script>
|
|
1958
|
+
`}let{getCachedRouterScript:T,getServeClientAsset:j}=await import("./chunk-2jxe6y8h.js"),B=_?.buildMode==="compile"?'<script data-stx-router src="/__stx/router.__STX_HASH__.js"></script>':_?.buildMode==="serve"?`<script data-stx-router src="${(await j("router")).url}"></script>`:`<script data-stx-router>${await T()}</script>`,z=v.lastIndexOf("</body>");return v.slice(0,z)+E+B+`
|
|
1959
|
+
</body>`+v.slice(z+7)}var $l=`(?:"[^"]*"|'[^']*'|[^>"'])*`,wg=/^<([a-zA-Z][a-zA-Z0-9-]*)\b((?:\s+[^=\s>]+(?:=(?:"[^"]*"|'[^']*'|[^\s>]*))?)*\s*)>([\s\S]*)<\/\1>$/s,Vv=65536,Uv=4,Po=new Map;function Nu(){Po.clear()}function Hv(v){let _=[];for(let k of pr(v,Y)){let E=k.token.match(/^<script\b([^>]*)>/i),T=k.token.match(/<\/script\s*>$/i);if(!E||!T)continue;let j=E[0].length,B=k.token.length-T[0].length;_.push(Object.freeze({fullMatch:k.token,attrs:E[1],body:k.token.slice(j,B),start:k.start,end:k.end}))}return _}function sc(v,_={}){let k=v.length>=Vv,E=k?Po.get(v):void 0;if(E===void 0){if(E=Hv(v),k)hd(Po,Uv),Po.set(v,E)}let T=_.skipAttrs;if(!T)return E.slice();let j=[];for(let B of E)if(T.lastIndex=0,!T.test(B.attrs))j.push(B);return j}function ns(v){let _=v.trim(),k=_.match(/^([\s\S]+?)\s+as\s+(.+)$/);if(k){let T=k[1].trim(),j=k[2].trim(),{itemVar:B,indexVar:z}=mg(j);if(B)return{style:"as",iterable:T,itemVar:B,indexVar:z}}let E=_.match(/^(\([^)]+\)|\w+(?:\s*,\s*\w+)?)\s+(?:in|of)\s+([\s\S]+)$/);if(E){let T=E[1].trim(),j=E[2].trim(),{itemVar:B,indexVar:z}=mg(T);if(B)return{style:"in",iterable:j,itemVar:B,indexVar:z}}return{style:"unknown",iterable:null,itemVar:null,indexVar:null}}function mg(v){let _=v.trim(),k=_.match(/^(\w+)\s*=>\s*(\w+)$/);if(k)return{itemVar:k[2],indexVar:k[1]};let E=_.match(/^\(\s*(\w+)(?:\s*,\s*(\w+))?\s*\)$/);if(E)return{itemVar:E[1],indexVar:E[2]||null};let T=_.match(/^(\w+)\s*,\s*(\w+)$/);if(T)return{itemVar:T[1],indexVar:T[2]};let j=_.match(/^(\w+)$/);if(j)return{itemVar:j[1],indexVar:null};return{itemVar:null,indexVar:null}}function rs(v,_){return ki(v,_)}function qv(v){let _=/@(if\s*\(|endif|elseif\s*\(|else\b)/g,k=0,E;while((E=_.exec(v))!==null){let T=E[1];if(T.startsWith("if"))k++;else if(T==="endif")k--;else if(k===0)return!0}return!1}function Sg(v){let _=new Set,k=/<script\b(?![^>]*\bserver\b)(?![^>]*\bsrc\s*=)[^>]*>([\s\S]*?)<\/script>/gi,E=/\b(?:const|let|var)\s+([a-zA-Z_$][\w$]*)\s*=\s*(?:state|derived|computed|ref|reactive|signal|useModel)\s*(?:<[^>]*>)?\s*\(/g,T;while((T=k.exec(v))!==null){let j=T[1],B;while((B=E.exec(j))!==null)_.add(B[1])}return _}function Kv(v){if(!/[:@]for\s*=/.test(v)&&!/\bx-for\s*=/.test(v))return[];let _=new RegExp(`<([a-zA-Z][\\w-]*)\\b(${$l})>`,"iy"),k=/(?:^|\s)(?::for|@for|x-for)\s*=\s*(?:"([^"]*)"|'([^']*)')/i,E=pr(v,(j,B)=>{_.lastIndex=B;let z=_.exec(j);if(!z||z.index!==B||!k.test(z[2]))return-1;return _.lastIndex}),T=[];for(let j of E){_.lastIndex=0;let B=_.exec(j.token);if(!B)continue;let z=B[2].match(k),F=ns(z?.[1]??z?.[2]??""),V=[F.itemVar,F.indexVar].filter(Boolean);if(V.length===0)continue;let H=B[1],J=/\/\s*>$/.test(j.token)||Do.has(H.toLowerCase())?j.end:kl(v,j.start,H,j.end);if(J!==-1)T.push({start:j.start,end:J,vars:new Set(V)})}return T}var hg=new Set(["true","false","null","undefined","NaN","Infinity","typeof","instanceof","in","of","new","void","delete","this","Math","JSON","Date","Number","String","Boolean","Array","Object","RegExp","Map","Set","Symbol","parseInt","parseFloat","isNaN","isFinite","encodeURIComponent","decodeURIComponent","encodeURI","decodeURI","window","document","console"]);function Xv(v){return v.replace(/'(?:\\.|[^'\\])*'/g,"''").replace(/"(?:\\.|[^"\\])*"/g,'""').replace(/`(?:\\.|[^`\\])*`/g,"``")}function yg(v,_,k,E){if(!v)return!1;let T=Xv(v),j=!1,B=!1,z=!1,F=/([a-zA-Z_$][\w$]*)/g,V;while((V=F.exec(T))!==null){let ne=V[1];if(T.slice(0,V.index).trimEnd().endsWith("."))continue;if(hg.has(ne))continue;if(_.has(ne)||E?.has(ne))j=!0;else if(k&&ne in k)B=!0}let H=/([a-zA-Z_$][\w$]*)(?:\.[a-zA-Z_$][\w$]*)*\s*\(\s*\)/g,G;while((G=H.exec(T))!==null){let ne=G[1];if(T.slice(0,G.index).trimEnd().endsWith("."))continue;if(hg.has(ne)||k&&ne in k)continue;z=!0}return(j||z)&&!B}function Io(v,_,k){let E=k===void 0?` ${_}`:` ${_}="${k.replace(/"/g,""")}"`,T=v.trim(),j=T.match(wg);if(j&&Zv(j[3],j[1])){let[,B,z,F]=j;return`<${B}${z}${E}>${F}</${B}>`}return`<template${E}>${T}</template>`}function Zv(v,_){let k=new RegExp(`<(/)?${_}(?=[\\s/>])`,"gi"),E=0,T;while((T=k.exec(v))!==null)if(T[1]){if(E--,E<0)return!1}else E++;return!0}function qo(v,_){let k=Sg(v);function E(T){let j=T,B=Kv(T),z=(G)=>{let J=new Set;for(let ne of B)if(G>ne.start&&G<ne.end)for(let re of ne.vars)J.add(re);return J},F=/@if\s*\(/g,V,H=[];while((V=F.exec(j))!==null){let G=V.index,J=G+V[0].length,ne=1,re=J;while(re<j.length&&ne>0){if(j[re]==="(")ne++;else if(j[re]===")")ne--;re++}if(ne!==0)continue;let se=j.substring(J,re-1).trim(),ie=re,oe=1,ge=ie,ue=/@(if\s*\(|endif)/g;ue.lastIndex=ie;let xe;while((xe=ue.exec(j))!==null)if(xe[1].startsWith("if"))oe++;else if(xe[1]==="endif"){if(oe--,oe===0){ge=xe.index+xe[0].length;break}}if(oe!==0)continue;let we=j.substring(ie,ge-6).trim(),$e;if(qv(we)){let _e=Ys(j.substring(G,ge));if(_e.length===0)continue;let Ce=_e[0].branches.filter((ke)=>ke.type!=="else"),Ee=z(G);if(!(Ce.length>0&&Ce.every((ke)=>yg(ke.condition,k,_,Ee))))continue;$e=_e[0].branches.map((ke)=>{let Ae=E(ke.content);if(ke.type==="elseif")return Io(Ae,"@else-if",ke.condition??"");if(ke.type==="else")return Io(Ae,"@else");return Io(Ae,"@if",ke.condition??"")}).join(`
|
|
1960
|
+
`)}else{if(!yg(se,k,_,z(G)))continue;$e=Io(E(we),"@if",se)}H.push({start:G,end:ge,replacement:$e}),F.lastIndex=ge}for(let G=H.length-1;G>=0;G--){let{start:J,end:ne,replacement:re}=H[G];j=j.substring(0,J)+re+j.substring(ne)}return j}return E(v)}function Gv(v){let _=v.trim();if(_==="")return;if(_==="true")return!0;if(_==="false")return!1;if(_==="null")return!1;if(_==="undefined")return!1;if(_==="NaN")return!1;if(/^-?\d+(?:\.\d+)?$/.test(_)){let T=Number(_);return T!==0&&!Number.isNaN(T)}let k=_.match(/^'((?:\\.|[^'\\])*)'$/);if(k)return k[1].length>0;let E=_.match(/^"((?:\\.|[^"\\])*)"$/);if(E)return E[1].length>0;return}var Do=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),xg=/<(script|style)\b/iy,Jv=/<\/script/gi,Yv=/<\/style/gi;function kl(v,_,k,E){if(Do.has(k.toLowerCase()))return E;let T=k.toLowerCase(),j=v.length,B=1,z=E;while(z<j){let F=v.indexOf("<",z);if(F===-1)return-1;if(z=F,v.startsWith("<!--",z)){let J=v.indexOf("-->",z+4);if(J===-1)return-1;z=J+3;continue}xg.lastIndex=z;let V=xg.exec(v);if(V){let J=v.indexOf(">",z);if(J===-1)return-1;if(v[J-1]==="/"){z=J+1;continue}let ne=V[1].toLowerCase()==="script"?Jv:Yv;ne.lastIndex=z;let re=ne.exec(v);if(re===null)return-1;let se=v.indexOf(">",re.index);if(se===-1)return-1;z=se+1;continue}if(v[z+1]==="/"){let J=/^<\/([a-z][\w-]*)\s*>/i.exec(v.slice(z,z+64));if(!J){z++;continue}if(J[1].toLowerCase()===T){if(B--,z+=J[0].length,B===0)return z;continue}z+=J[0].length;continue}let H=/^<([a-z][\w-]*)\b/i.exec(v.slice(z,z+64));if(!H){z++;continue}let G=v.indexOf(">",z);if(G===-1)return-1;if(H[1].toLowerCase()===T){let J=v.slice(z,G+1);if(!(/\/\s*>$/.test(J)||Do.has(T)))B++}z=G+1}return-1}var Qv=/\s(?::else-if|x-else-if|@else-if|:else|x-else|@else)(?=[=\s/>])/;function ew(v,_){let k=_,E=v.length;for(;;){while(k<E&&v[k]!=="<")k++;if(k>=E)return!1;if(v.startsWith("<!--",k)){let B=v.indexOf("-->",k+4);if(B===-1)return!1;k=B+3;continue}break}if(v[k+1]==="/")return!1;let T=v.indexOf(">",k);if(T===-1)return!1;let j=v.slice(k,T+1);return Qv.test(j)}function Ko(v){if(!v.includes(":if")&&!v.includes(":show")&&!v.includes("x-if")&&!v.includes("x-show")&&!v.includes("@if=")&&!v.includes("@show="))return v;let _=[],k=/<(script|style)\b[^>]*>[\s\S]*?<\/\1\s*>/gi,E;while((E=k.exec(v))!==null)_.push([E.index,E.index+E[0].length]);let T=(G)=>_.some(([J,ne])=>G>=J&&G<ne),j=/<([a-zA-Z][\w-]*)\b((?:\s+[^=\s>]+(?:=(?:"[^"]*"|'[^']*'|[^\s>]*))?)*?)\s+(:if|:show|x-if|x-show|@if|@show)\s*=\s*"([^"]*)"((?:\s+[^=\s>]+(?:=(?:"[^"]*"|'[^']*'|[^\s>]*))?)*\s*)(\/?)>/g,B=[],z;while((z=j.exec(v))!==null){if(T(z.index))continue;let[G,J,ne,re,se,ie,oe]=z,ge=Gv(se);if(ge===void 0)continue;let ue=z.index,xe=ue+G.length,_e=!!oe||/\/\s*>$/.test(G)||Do.has(J.toLowerCase())?xe:kl(v,ue,J,xe);if(_e===-1)continue;if((re===":if"||re==="x-if"||re==="@if")&&ew(v,_e)){j.lastIndex=xe;continue}if(ge===!0){let Ee=`<${J}${ne}${ie}${oe}>`;B.push({start:ue,end:xe,replacement:Ee});continue}B.push({start:ue,end:_e,replacement:""}),j.lastIndex=_e}if(B.length===0)return v;B.sort((G,J)=>G.start-J.start);let F=[],V=-1;for(let G of B){if(G.start<V)continue;F.push(G),V=G.end}let H=v;for(let G=F.length-1;G>=0;G--){let{start:J,end:ne,replacement:re}=F[G];H=H.substring(0,J)+re+H.substring(ne)}return H}var bg=[":for","@for","x-for"];function ss(v,_){if(!_||Object.keys(_).length===0)return v;if(!bg.some((z)=>v.includes(`${z}=`)))return v;let k=Sg(v);if(Array.isArray(_.__stx_client_signal_names)){for(let z of _.__stx_client_signal_names)if(typeof z==="string")k.add(z)}let E=v,T=[],j=/<([a-zA-Z][\w-]*)((?:[^>"']|"[^"]*"|'[^']*')*)>/g,B;while((B=j.exec(E))!==null){let[z,F,V]=B,H=B.index,G=H+z.length,J=bg.map(($e)=>({attr:$e,m:new RegExp(`\\s${$e}="([^"]*)"`).exec(V)})).find(($e)=>$e.m!==null);if(!J||!J.m)continue;let ne=ns(J.m[1]);if(!ne.iterable||!ne.itemVar)continue;let re=ne.iterable.trim().split(/[.[(]/)[0].trim();if(!re||k.has(re)||!(re in _))continue;let se=kl(E,H,F,G);if(se===-1)continue;let ie=V.replace(new RegExp(`\\s${J.attr}="[^"]*"`),"").replace(/\s:key="[^"]*"/,"").replace(/\sx-cloak(?=\s|$)/,""),oe=E.slice(G,se-`</${F}>`.length),ge={..._,[ne.itemVar]:void 0};if(ne.indexVar)ge[ne.indexVar]=void 0;let ue=ss(oe,ge),xe=ne.indexVar?`${ne.iterable} as ${ne.indexVar} => ${ne.itemVar}`:`${ne.iterable} as ${ne.itemVar}`,we=F.toLowerCase()==="template"?ue:`<${F}${ie}>${ue}</${F}>`;T.push({start:H,end:se,replacement:`@foreach(${xe})${we}@endforeach`}),j.lastIndex=se}for(let z=T.length-1;z>=0;z--){let{start:F,end:V,replacement:H}=T[z];E=E.slice(0,F)+H+E.slice(V)}return E}function os(v,_){let k=v,E=/@(for|foreach)\s*\(/g,T,j=[],B=[];while((T=E.exec(k))!==null){let z=T[1],F=T.index,V=F+T[0].length,H=1,G=V;while(G<k.length&&H>0){if(k[G]==="(")H++;else if(k[G]===")")H--;G++}if(H!==0)continue;let J=k.substring(V,G-1).trim(),ne=G,re=ns(J),se=z==="for"?"@endfor":"@endforeach",ie=1,oe=ne,ge=z==="for"?new RegExp("@(for(?!each)\\s*\\(|endfor(?!each))","g"):new RegExp(`@(${z}\\s*\\(|end${z})`,"g");ge.lastIndex=ne;let ue;while((ue=ge.exec(k))!==null)if(ue[1].startsWith(z))ie++;else if(ie--,ie===0){oe=ue.index+ue[0].length;break}if(ie!==0)continue;let xe=()=>{let Te=[re.itemVar,re.indexVar].filter(Boolean);if(Te.length)B.push({start:F,end:oe,vars:Te})};if(re.iterable){let Te=re.iterable.trim();if(Te.startsWith("[")||Te.startsWith("{")||Te.startsWith("'")||Te.startsWith('"')||Te.startsWith("`")||/^-?\d/.test(Te)){xe();continue}let Re=Te.split(/[.[(]/)[0].trim(),ke=_?Re in _:!1,Ae=B.some((Xe)=>F>Xe.start&&F<Xe.end&&Xe.vars.includes(Re));if(Re&&(ke||Ae)){xe();continue}}if(re.style==="as")J=re.indexVar?`(${re.itemVar}, ${re.indexVar}) in ${re.iterable}`:`${re.itemVar} in ${re.iterable}`;let we=k.substring(ne,oe-se.length).trim(),$e=_?{..._}:{};if(re.itemVar)delete $e[re.itemVar];if(re.indexVar)delete $e[re.indexVar];let _e=os(we,$e),Ce=_e.match(wg),Ee;if(Ce){let[,Te,Re,ke]=Ce;Ee=`<${Te}${Re} @for="${J}">${ke}</${Te}>`}else Ee=`<template @for="${J}">${_e}</template>`;j.push({start:F,end:oe,replacement:Ee}),E.lastIndex=oe}for(let z=j.length-1;z>=0;z--){let{start:F,end:V,replacement:H}=j[z];k=k.substring(0,F)+H+k.substring(V)}return k}function tw(v){let _=new Set,k=[],E=0,T=0,j=v.length,B=(H)=>{let G=E+1;while(G<j){let J=v[G];if(J==="\\"){G+=2;continue}if(J===H)return G+1;G++}return j},z=()=>{let H=E+2;while(H<j&&v[H]!==`
|
|
1961
|
+
`)H++;return H},F=()=>{let H=E+2;while(H<j-1){if(v[H]==="*"&&v[H+1]==="/")return H+2;H++}return j},V=(H)=>{let G=H,J=0;while(G<j){let ne=v[G];if(ne==="/"&&v[G+1]==="/"){let re=G+2;while(re<j&&v[re]!==`
|
|
1962
|
+
`)re++;G=re;continue}if(ne==="/"&&v[G+1]==="*"){let re=G+2;while(re<j-1&&!(v[re]==="*"&&v[re+1]==="/"))re++;G=re+2;continue}if(ne==='"'||ne==="'"||ne==="`"){let re=G+1;while(re<j){if(v[re]==="\\"){re+=2;continue}if(v[re]===ne){re++;break}re++}G=re;continue}if(ne==="("||ne==="["||ne==="{"){J++,G++;continue}if(ne===")"||ne==="]"||ne==="}"){J--,G++;continue}if(ne===";"&&J===0)return G+1;G++}return j};while(E<j){let H=v[E];if(H==="/"&&v[E+1]==="/"){let G=z();k.push(v.slice(E,G)),E=G;continue}if(H==="/"&&v[E+1]==="*"){let G=F();k.push(v.slice(E,G)),E=G;continue}if(H==='"'||H==="'"||H==="`"){let G=B(H);k.push(v.slice(E,G)),E=G;continue}if(H==="{"){T++,k.push(H),E++;continue}if(H==="}"){T--,k.push(H),E++;continue}if(T===0){let G=E>0?v[E-1]:"";if(G===""||/\s/.test(G)||G===";"||G==="}"||G==="{"){let ne=v.slice(E).match(/^(const|let|var)\s+([a-zA-Z_$][\w$]*)\s*=/);if(ne){let re=ne[2],se=V(E+ne[0].length);if(_.has(re)){k.push(`/* stx: deduped const ${re} */`),E=se;continue}_.add(re),k.push(v.slice(E,se)),E=se;continue}}}k.push(H),E++}return k.join("")}var nw=new Set(["script","style","html","head","meta","link","title","!doctype"]);function _l(v,_,k){for(let E of k){if(E.start>=_)return!1;if(E.end>v)return!0}return!1}function rw(v,_,k){let E=0;while(E<v.length){let T=v.indexOf(_,E);if(T===-1)return!1;if(!_l(T,T+_.length,k))return!0;E=T+_.length}return!1}function sw(v,_){if(rw(v,"<body",_)){let T=new RegExp(`<body(${$l})>`,"g"),j;while((j=T.exec(v))!==null)if(!_l(j.index,j.index+j[0].length,_))return j.index+j[0].length-1;return null}let k=new RegExp(`<([a-zA-Z][a-zA-Z0-9-]*)\\b(${$l})>`,"gi"),E;while((E=k.exec(v))!==null){if(_l(E.index,E.index+E[0].length,_))continue;if(nw.has(E[1].toLowerCase()))continue;return E.index+E[0].length-1}return null}function iw(v,_,k,E){let T=[],j=` data-stx="${E}"`,B=0,z=!1,F=(V)=>{if(k!==null&&!z&&k>=B&&k<=V)T.push(v.slice(B,k),j,v.slice(k,V)),z=!0;else T.push(v.slice(B,V))};for(let V of _){if(V.start<B)continue;F(V.start),B=V.end}return F(v.length),T.join("")}async function Bn(v,_,k,E={}){let T=sc(v,{skipAttrs:/\bserver\b|\bsrc\s*=|\bdata-stx-scoped\b|\bdata-stx-router\b/}),j=/\b(?:state|derived|effect|ref|reactive|computed|watch|watchEffect|useStore|useLocalStorage|useSessionStorage|keptState|useCookie|useId|useModel|useReactiveProp|useFetch|useRef|useEventListener|useDebounce|useDebouncedValue|useThrottle|useInterval|useTimeout|useToggle|useCounter|useClickOutside|useFocus|useAsync|useColorMode|useDark|useMediaQuery|useScrollLock|usePreferredDark|usePreferredLight|usePreferredReducedMotion|usePreferredContrast|useWebSocket|useRoute|useSearchParams|onMount|onDestroy|defineProps|withDefaults|defineEmits|defineExpose|defineSlots|useOptimistic)\s*(?:<[^>]*>)?\s*\(/,B=[],{hasUserImports:z,bundleClientScript:F}=await ut("stx/client-script-bundler",()=>import("./chunk-rzmvsqc7.js"));for(let ue of T){let xe=ue.body;if(Ve(ue.attrs))xe=Ue(xe);if(E.forceClientSetup||j.test(xe)){B.push({content:xe,start:ue.start,end:ue.end});continue}if(!z(xe))continue;try{let we=await F(wt(xe).code,_||"",{projectRoot:process.cwd(),externalizeUserModules:!1});if(j.test(we))B.push({content:xe,start:ue.start,end:ue.end})}catch{}}if(B.length===0)return{output:v,setupCode:null};let V=`${_??""}\x00${B.map((ue)=>ue.content).join("\x00")}`,H=`__stx_setup_${Bun.hash(V).toString(36).slice(0,10)}`,G=[];for(let ue=0;ue<B.length;ue++){let xe=B[ue].bundled??wt(B[ue].content).code;if(!B[ue].bundled&&z(xe))xe=await F(xe,_||"",{projectRoot:process.cwd(),externalizeUserModules:E.forceClientSetup?!1:void 0});xe=ze(xe);let we=P(xe);G.push(`// \u2500\u2500 merged signal script #${ue+1} \u2500\u2500
|
|
1963
|
+
${we}`)}let J=G.join(`
|
|
1964
|
+
|
|
1965
|
+
`);J=tw(J);let ne=oc(J),re=ne.split(",").map((ue)=>ue.trim()).filter(Boolean),se=Gr(J,k),ie=`
|
|
1966
|
+
<script data-stx-scoped>
|
|
1967
|
+
function ${H}() {
|
|
1968
|
+
${Rt("const",re)}
|
|
1969
|
+
${zr(`${se}${J}`)}
|
|
1970
|
+
return { ${ne} };
|
|
1971
|
+
}
|
|
1972
|
+
window.__stx_latestSetup=${H};
|
|
1973
|
+
if(window.stx)window.stx._latestSetup=${H};
|
|
1974
|
+
</script>`,oe=sw(v,B);return{output:iw(v,B,oe,H),setupCode:ie}}function oc(v){let _=v,k=[],E=new Set,T=0,j=0,B=_.length,z="",F=()=>{j++;let re=!1;while(j<B){let se=_[j];if(se==="\\"){j+=2;continue}if(se==="["&&!re){re=!0,j++;continue}if(se==="]"&&re){re=!1,j++;continue}if(se==="/"&&!re){j++;while(j<B&&/[gimsuyd]/.test(_[j]))j++;return}if(se===`
|
|
1975
|
+
`)return;j++}},V=()=>{if(!z)return!0;if(/[\w)\]]/.test(z))return!1;return!0},H=(re)=>{j++;while(j<B){if(_[j]==="\\"){j+=2;continue}if(_[j]===re){j++;return}j++}},G=()=>{j++;while(j<B){if(_[j]==="\\"){j+=2;continue}if(_[j]==="`"){j++;return}if(_[j]==="$"&&_[j+1]==="{"){j+=2;let re=1;while(j<B&&re>0)if(_[j]==="{")re++,j++;else if(_[j]==="}")re--,j++;else if(_[j]==="'"||_[j]==='"')H(_[j]);else if(_[j]==="`")G();else j++;continue}j++}},J=()=>{if(_[j]==="/"&&_[j+1]==="/"){while(j<B&&_[j]!==`
|
|
1976
|
+
`)j++;return!0}if(_[j]==="/"&&_[j+1]==="*"){j+=2;while(j<B-1&&!(_[j]==="*"&&_[j+1]==="/"))j++;return j+=2,!0}return!1},ne=()=>{if(T!==0)return;let re=_.slice(j).match(/^(const|let|var)\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*(?:[!:;,\n]|=(?!=)|$)/);if(re){let ue=re[2];if(!E.has(ue))k.push(ue),E.add(ue);return}let se=_.slice(j).match(/^(?:const|let|var)\s+\{([^}]+)\}\s*=/);if(se){se[1].split(",").forEach((ue)=>{let xe=ue.trim();if(!xe)return;let we=xe.indexOf(":"),_e=(we>=0?xe.slice(we+1).trim():xe).split(/[\s=]/)[0];if(_e&&!E.has(_e))k.push(_e),E.add(_e)});return}let ie=_.slice(j).match(/^(?:const|let|var)\s+\[([^\]]+)\]\s*=/);if(ie){ie[1].split(",").forEach((ue)=>{let xe=ue.trim().replace(/^\.\.\./,"");if(!xe)return;let we=xe.split(/[\s=]/)[0];if(we&&!E.has(we))k.push(we),E.add(we)});return}let oe=_.slice(j).match(/^function\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*\(/);if(oe){let ue=oe[1];if(!E.has(ue))k.push(ue),E.add(ue);return}let ge=_.slice(j).match(/^async\s+function\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*\(/);if(ge){let ue=ge[1];if(!E.has(ue))k.push(ue),E.add(ue)}};while(j<B){if(J())continue;if(_[j]==="'"||_[j]==='"'){H(_[j]),z=_[j-1];continue}if(_[j]==="`"){G(),z="`";continue}if(_[j]==="/"&&_[j+1]!=="/"&&_[j+1]!=="*"&&V()){F(),z="/";continue}if(_[j]==="{"){T++,z="{",j++;continue}if(_[j]==="}"){T--,z="}",j++;continue}if(T===0&&/[a-z]/i.test(_[j])&&(j===0||/\s|[;{}()]/.test(_[j-1])))ne();if(!/\s/.test(_[j]))z=_[j];j++}return k.join(", ")}async function Xo(v,_,k,E){if(!rs(v,k))return v;let T=v;if(_.skipSignalsRuntime)return T;let{output:j,setupCode:B}=await Bn(T,k,E);if(T=j,!B){let z=An(T);if(z&&!/data-stx/.test(z.attrs)&&!/data-stx-auto/.test(z.attrs)){let F=z.tag.replace(/^<body([^>]*)>$/i,"<body$1 data-stx-auto>");T=T.slice(0,z.index)+F+T.slice(z.index+z.tag.length)}}if(T=await Ao(T,_),B){let z=Go(T,/<\/head>/i),F=z===-1?Go(T,/<body[^>]*>/i):-1;if(z!==-1)T=`${T.slice(0,z)}${B}
|
|
1977
|
+
${T.slice(z)}`;else if(F!==-1){let V=/<body[^>]*>/i.exec(T.slice(F))[0],H=F+V.length;T=`${T.slice(0,H)}
|
|
1978
|
+
${B}${T.slice(H)}`}else T=`${T}
|
|
1979
|
+
${B}`}return T}function Go(v,_){let k=/<(script|style)\b[\s\S]*?<\/\1>/gi,E=[],T;while((T=k.exec(v))!==null)E.push([T.index,T.index+T[0].length]);let j=new RegExp(_.source,_.flags.replace(/[gy]/g,"")),B=0;while(B<v.length){let z=j.exec(v.slice(B));if(!z)return-1;let F=B+z.index;if(!E.some(([H,G])=>F>=H&&F<G))return F;B=F+Math.max(z[0].length,1)}return-1}var vg="/* [stx import stripped, resolved via window.stx in __stx_setup] */";function ic(v){let _=[];for(let k of v.split(",")){let E=k.trim();if(!E||E.startsWith("type "))continue;let T=E.match(/^([A-Za-z_$][\w$]*)\s+as\s+([A-Za-z_$][\w$]*)$/);if(T&&T[1]!==T[2])_.push(`${T[2]} = ${T[1]}`)}if(_.length===0)return vg;return`var ${_.join(", ")}; ${vg}`}var ow=/^\s*import\s+(?:type\s+)?\{([^}]*)\}\s+from\s+['"](?:stx|@stacksjs\/stx|@stacksjs\/browser)['"]\s*;?\s*$/gm;function ze(v){return v.replace(ow,(_,k)=>ic(k))}import Fs from"path";import aw from"process";function w(v="STX_PUBLIC_"){let _={},k={};for(let[E,T]of Object.entries(aw.env)){if(!E.startsWith(v)||T===void 0)continue;_[`import.meta.env.${E}`]=JSON.stringify(T),k[E]=T}return _["import.meta.env"]=JSON.stringify(k),_}function $g(v){return v.startsWith("http://")||v.startsWith("https://")||v.startsWith("//")}async function _g(v,_,k){try{let E;if(v.startsWith("/")){let T=_;for(let j=0;j<5;j++){let B=Fs.join(T,v);if(await Bun.file(B).exists())return B;T=Fs.dirname(T)}E=Fs.join(_,v)}else if(v.startsWith("./")||v.startsWith("../"))E=Fs.resolve(_,v);else E=Fs.resolve(_,v);if(await Bun.file(E).exists())return E;return null}catch{return null}}var kg=Symbol.for("stx.inline-assets.import-meta");function cw(v,_){if(!v.includes("import.meta"))return;let k=Error(`[stx] ${_} still references \`import.meta\` after bundling, and it is being inlined as a classic <script> where that is a SyntaxError \u2014 the whole script fails to parse, taking every other script on the page with it.
|
|
1980
|
+
`+" `import.meta.env.STX_PUBLIC_*` is substituted at build time and is safe; anything else is not.\n Fix it by moving the module-only code (`import.meta.glob`, `import.meta.url`) into its own module, or by resolving the value without `import.meta`.");throw k[kg]=!0,k}async function Eg(v,_,k){let E=v,T=Fs.dirname(_),j=/<script\b([^>]*)src=["']([^"']+)["']([^>]*)><\/script>/gi,B;while((B=j.exec(E))!==null){let[V,H,G,J]=B;if($g(G))continue;let ne=await _g(G,T,_);if(ne)try{let re=await Bun.file(ne).text();if(k.add(ne),G.endsWith(".ts")||G.endsWith(".tsx")){let ie=await Bun.build({entrypoints:[ne],target:"browser",minify:!0,define:w()});if(ie.outputs.length>0)re=await ie.outputs[0].text(),cw(re,G)}let se=`<script>
|
|
1981
|
+
// Source: ${G}
|
|
1982
|
+
${re}
|
|
1983
|
+
</script>`;E=E.replace(V,se),j.lastIndex=0}catch(re){if(re?.[kg])throw re}}let z=/<link\b([^>]*)href=["']([^"']+)["']([^>]*)(?:\/?>)/gi,F;while((F=z.exec(E))!==null){let[V,H,G,J]=F,ne=H+J;if($g(G))continue;if(/rel=["']stylesheet["']/.test(ne)||G.endsWith(".css")){let se=await _g(G,T,_);if(se)try{let ie=await Bun.file(se).text();k.add(se);let oe=`<style>
|
|
1984
|
+
/* Source: ${G} */
|
|
1985
|
+
${ie}
|
|
1986
|
+
</style>`;E=E.replace(V,oe),z.lastIndex=0}catch(ie){}}}return E}function ps(v,_){let k=v,E=/@json\s*\(/g,T;while((T=E.exec(k))!==null){let j=T.index,B=j+T[0].length-1,z=1,F=B+1,V=null,H=!1;while(F<k.length&&z>0){let ue=k[F];if(H){H=!1,F++;continue}if(ue==="\\"&&V){H=!0,F++;continue}if(V){if(ue===V)V=null;F++;continue}if(ue==='"'||ue==="'"||ue==="`"){V=ue,F++;continue}if(ue==="(")z++;else if(ue===")"){if(z--,z===0)break}F++}if(z!==0)break;let G=k.substring(B+1,F).trim(),J=k.substring(j,F+1),ne=-1,re=0,se=null,ie=!1;for(let ue=0;ue<G.length;ue++){let xe=G[ue];if(ie){ie=!1;continue}if(xe==="\\"&&se){ie=!0;continue}if(se){if(xe===se)se=null;continue}if(xe==='"'||xe==="'"||xe==="`"){se=xe;continue}if(xe==="("||xe==="["||xe==="{")re++;else if(xe===")"||xe==="]"||xe==="}")re--;if(xe===","&&re===0){ne=ue;break}}let oe=ne>=0?G.substring(0,ne).trim():G,ge=ne>=0?G.substring(ne+1).trim():void 0;try{let ue=oe.trim(),xe;if(p(ue))xe=l(ue,Object.keys(_))(...Object.values(_));else xe=void 0;let we;if(ge==="true")we=JSON.stringify(xe,null,2);else we=JSON.stringify(xe);let $e=we.replace(/</g,"\\u003c").replace(/>/g,"\\u003e").replace(/&/g,"\\u0026").replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029");k=k.substring(0,j)+$e+k.substring(F+1),E.lastIndex=j+$e.length}catch(ue){A.log(ue instanceof Error?ue:Error(String(ue)),{directive:"@json"},"error"),E.lastIndex=j+J.length}}return k}function gs(v){return v.replace(/@once\s*([\s\S]*?)@endonce/g,"$1")}function Ag(v){let _=v,k=/@memo\s*\(/g,E,T=[];while((E=k.exec(_))!==null){let j=E.index,B=j+E[0].length,z=1,F=B;while(F<_.length&&z>0){if(_[F]==="(")z++;else if(_[F]===")")z--;F++}if(z!==0)continue;let V=_.slice(B,F-1).trim(),H=F,G=_.slice(H),J=G.indexOf("@endmemo");if(J===-1)continue;let ne=G.slice(0,J),re=H+J+8,se=ne.match(/^(\s*(?:(?:<!--[\s\S]*?-->|\x00STX_HTML_COMMENT_\d+\x00)\s*)*)/),ie=se?se[0].length:0,oe=ne.slice(ie),ge=ne.match(/(\s*)$/),ue=ge?ge[0].length:0,xe=oe.slice(0,oe.length-ue),we=xe.match(/^<([a-zA-Z][a-zA-Z0-9-]*)(\s[^>]*?)?(\/?)>/),$e;if(we){let[_e,Ce,Ee="",Te]=we,Re=`<${Ce}${Ee} data-stx-memo="${V}"${Te}>`;$e=ne.slice(0,ie)+Re+xe.slice(_e.length)+ne.slice(ie+xe.length)}else $e=`${ne.slice(0,ie)}<div data-stx-memo="${V}">${xe}</div>${ne.slice(ie+xe.length)}`;T.push({start:j,end:re,replacement:$e}),k.lastIndex=re}for(let j=T.length-1;j>=0;j--){let B=T[j];_=_.slice(0,B.start)+B.replacement+_.slice(B.end)}return _.replace(/@memo="([^"]*)"/g,'data-stx-memo="$1"')}function El(v){let _=v.replace(/@ref="([^"]+)"/g,'data-stx-ref="$1"');return _=_.replace(/(<[a-zA-Z][a-zA-Z0-9-]*\b[^>]*?)\sref="([^"]+)"/g,'$1 data-stx-ref="$2"'),_}function Ig(v,_){if(!/\bref\s*=/.test(v))return v;let k=/<\/?([a-zA-Z][\w-]*)\b(?:"[^"]*"|'[^']*'|[^'">])*>/y,E=pr(v,(F,V)=>{k.lastIndex=V;let H=k.exec(F);if(!H||/^(?:script|style)$/i.test(H[1]))return-1;return k.lastIndex}),T=[],j=0,B=0,z=[];for(let{start:F,end:V,token:H}of E){let G=/^<\/?([\w-]+)/.exec(H)[1].toLowerCase();if(H.startsWith("</")){let ne;while(ne=T.pop()){if(ne.scoped)j--;if(ne.name===G)break}continue}let J=/\sdata-stx-scope\s*=/.test(H);if(!j&&!J&&/\s(?:ref|@ref|:ref|x-ref|data-stx-ref)\s*=/.test(H)&&!/\sdata-stx-ref-caller\s*=/.test(H))z.push(v.slice(B,F),H.replace(/\s*\/?>$/,(ne)=>` data-stx-ref-caller="${_}"${ne}`)),B=V;if(!Pg.has(G)&&!/\/>$/.test(H)){if(T.push({name:G,scoped:J}),J)j++}}return z.push(v.slice(B)),z.join("")}var Pg=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),Dg=/(?:^|\s)x-no-cloak(?:=|\s|\/|>|$)/,Cg=/<\/?\s*([a-z][\w-]*)/iy,lw=/\s/;function uw(v,_){let k=_-1;while(k>=0&&lw.test(v[k]))k--;return k>=0&&v[k]==="/"}function dw(v,_){let k=!1,E=!1;for(let T=_;T<v.length;T++){let j=v[T];if(k){if(j==="'")k=!1}else if(E){if(j==='"')E=!1}else if(j==="'")k=!0;else if(j==='"')E=!0;else if(j===">")return T}return-1}function fw(v,_){if(v.indexOf("{",_)===-1||v.indexOf("}",_)===-1)return!1;let k=0,E=_,T=!1,j=!1,B=!1;while(E<v.length){let z=v.indexOf("<",E),F=z===-1?v.length:z;if(F>E){if(k===0)while(E<F){let G=v.indexOf(j?"}":"{",E);if(G===-1||G>=F){if(j)B=!1;else T=!1;break}if(G>E)if(j)B=!1;else T=!1;if(j){if(B)return!0;B=!0}else if(T)j=!0,B=!1;else T=!0;E=G+1}E=F;continue}if(v.startsWith("<!--",E)){let G=v.indexOf("-->",E);E=G===-1?v.length:G+3;continue}let V=dw(v,E);if(V===-1)break;Cg.lastIndex=E;let H=Cg.exec(v)?.[1]?.toLowerCase()??"";if(v[E+1]==="/"){if(k===0)break;k--}else if(!uw(v,V)&&!Pg.has(H))k++;E=V+1}return!1}var Rg=m(256);function Mg(v){if(v.length<1024)return Tg(v);let _=h(v),k=Rg.get(_);if(k!==void 0)return k;let E=Tg(v);return Rg.set(_,E),E}function Tg(v){if(v.length>=32768&&!md(v))return v;let k=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"),E="",T=0,j;while((j=k.exec(v))!==null){let B=j.index,z=B+j[0].length,F=!1,V=!1,H=-1;while(z<v.length){let J=v[z];if(F){if(J==="'")F=!1}else if(V){if(J==='"')V=!1}else if(J==="'")F=!0;else if(J==='"')V=!0;else if(J===">"){H=z;break}z++}if(H===-1)continue;let G=v.slice(B,H+1);if(Dg.test(G))continue;if(G.includes("x-cloak"))continue;if(fw(v,H+1))E+=v.slice(T,H)+" x-cloak>",T=H+1}return E+=v.slice(T),E}var pw=/(?:^|\s)(?::else-if|:if|:else|:show|x-else-if|x-if|x-else|x-show|@if|@show)(?:=|\s|\/|>|$)/,gw=/<\/script>/gi,mw=/<\/style>/gi;function Og(v){let _=/<[a-z][\w-]*/gi,k="",E=0,T;while((T=_.exec(v))!==null){let j=T.index,B=T[0].slice(1).toLowerCase();if(B==="script"||B==="style"){let re=B==="script"?gw:mw;re.lastIndex=j;let se=re.exec(v);if(se!==null)_.lastIndex=se.index+se[0].length;continue}let z=j+T[0].length,F=!1,V=!1,H=-1;while(z<v.length){let re=v[z];if(F){if(re==="'")F=!1}else if(V){if(re==='"')V=!1}else if(re==="'")F=!0;else if(re==='"')V=!0;else if(re===">"){H=z;break}z++}if(H===-1)continue;let G=v.slice(j+T[0].length,H);if(Dg.test(G))continue;if(/(?:^|\s)x-cloak(?:=|\s|\/|>|$)/.test(G))continue;if(!pw.test(G))continue;let J=v[H-1]==="/",ne=J?H-1:H;k+=`${v.slice(E,ne)} x-cloak${J?" ":""}`,E=ne}return k+=v.slice(E),k}var Cl=m(256),hw=[{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"}],Ng=/(?:\/\/|\/\*|\{\{--)\s*stx-strict-ignore(-next-line)?([^\n*}]*)/g;function yw(v){let _=Array.from(v,(T)=>T===`
|
|
1987
|
+
`?`
|
|
1988
|
+
`:" "),k=0,E="";while(k<v.length){let T=v[k],j=v[k+1];if(E){if(T==="\\"){k+=2;continue}if(T===E)E="";k++;continue}if(T==='"'||T==="'"||T==="`"){E=T,k++;continue}if(T==="/"&&j==="/"){while(k<v.length&&v[k]!==`
|
|
1989
|
+
`)_[k]=v[k],k++;continue}if(T==="/"&&j==="*"){let B=v.indexOf("*/",k+2),z=B===-1?v.length:B+2;for(;k<z;k++)_[k]=v[k];continue}if(T==="{"&&j==="{"&&v.slice(k,k+4)==="{{--"){let B=v.indexOf("--}}",k+4),z=B===-1?v.length:B+4;for(;k<z;k++)_[k]=v[k];continue}k++}return _.join("")}function xw(v){let _=new Map,k=yw(v).split(`
|
|
1990
|
+
`),E=v.split(`
|
|
1991
|
+
`);return k.forEach((T,j)=>{Ng.lastIndex=0;for(let B of T.matchAll(Ng)){let z=B[1]==="-next-line",F=(E[j]??"").slice(0,B.index).trim(),V=z||F===""?j+2:j+1,G=(B[2]??"").split("--")[0].split(/[\s,]+/).filter(Boolean),J=G.filter((re)=>/\w/.test(re));if(G.length>0&&J.length===0)continue;let ne=_.get(V);if(ne&&ne.size===0)continue;if(J.length===0){_.set(V,new Set);continue}if(ne)J.forEach((re)=>ne.add(re));else _.set(V,new Set(J))}}),_}function bw(v,_,k){let E=v.get(_);if(!E)return!1;if(E.size===0)return!0;return[...E].some((T)=>k.includes(T))}function ms(v,_,k,E){let T=typeof k==="boolean"?{enabled:k,failOnViolation:k}:k??{enabled:!1};if(!T.enabled)return;let j=h(v,_,E,JSON.stringify(T)),B=Cl.get(j);if(B!==void 0){if(B&&T.failOnViolation)throw Error(B);return}let z=T.allowPatterns??[],F=xw(v),V=[],H=s(v.replace(/\{\{--[\s\S]*?--\}\}/g,(re)=>re.replace(/[^\n]/g," ")));for(let{pattern:re,message:se,suggestion:ie}of hw){if(z.some((ge)=>/\w/.test(ge)&&se.includes(ge)))continue;re.lastIndex=0;let oe=H.match(re);if(oe&&oe.length>0){let ge=H.split(`
|
|
1992
|
+
`),ue=v.split(`
|
|
1993
|
+
`),xe=[];if(ge.forEach((Ce,Ee)=>{if(re.lastIndex=0,re.test(Ce)&&!bw(F,Ee+1,se))xe.push(Ee+1)}),xe.length===0&&ge.some((Ce)=>(re.lastIndex=0,re.test(Ce))))continue;let we=xe.length>0?` (script line${xe.length>1?"s":""} ${xe.join(", ")})`:"",$e=xe.slice(0,3).map((Ce)=>` ${Ce} | ${(ue[Ce-1]??"").trim().slice(0,100)}`).join(`
|
|
1994
|
+
`),_e=$e?`
|
|
1995
|
+
${$e}`:"";V.push(` \u2717 ${se}${we}
|
|
1996
|
+
\u2192 ${ie}${_e}`)}}if(V.length===0){Cl.set(j,"");return}let G=(re)=>{let se=`${process.cwd()}/`;return re.startsWith(se)?re.slice(se.length):re},ne=`[STX] DOM API violation in ${E&&E!==_?`${G(E)} (composed into ${G(_)})`:G(_)}:
|
|
1997
|
+
${V.join(`
|
|
1998
|
+
`)}
|
|
1999
|
+
Tip: prefer useRef(), navigate(), and composables for component code`;if(Cl.set(j,ne),T.failOnViolation)throw Error(ne);else console.warn(ne)}import Rl from"path";var vw=/(\bfrom\s*|\bimport\s*\(\s*|\bimport\s+)(['"])(\.\.?\/[^'"]*)\2/g,ww=/(<script\b[^>]*>)([\s\S]*?)(<\/script>)/gi;function Sw(v,_){if(!_||!v.includes("/"))return v;let k=Rl.dirname(_);return v.replace(vw,(E,T,j,B)=>{let z=Rl.resolve(k,B);return`${T}${j}${z.split(Rl.sep).join("/")}${j}`})}function jg(v,_){if(!_||!v.includes("<script"))return v;return v.replace(ww,(k,E,T,j)=>`${E}${Sw(T,_)}${j}`)}var Mr="<!--PARENT_CONTENT_PLACEHOLDER-->";function Lg(v){return v.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}function Hg(v,_){let k=v.length,E=_,T=!0,j=[],B=(z)=>z+9<=k&&v[z]==="<"&&v[z+1]==="/"&&(v[z+2]==="s"||v[z+2]==="S")&&(v[z+3]==="c"||v[z+3]==="C")&&(v[z+4]==="r"||v[z+4]==="R")&&(v[z+5]==="i"||v[z+5]==="I")&&(v[z+6]==="p"||v[z+6]==="P")&&(v[z+7]==="t"||v[z+7]==="T")&&(v[z+8]===">"||/\s/.test(v[z+8]));while(E<k){let z=v[E];if(B(E))return E;if(z==="/"&&v[E+1]==="/"){if(E=v.indexOf(`
|
|
2000
|
+
`,E+2),E===-1)return-1;E+=1,T=!0;continue}if(z==="/"&&v[E+1]==="*"){let F=v.indexOf("*/",E+2);if(F===-1)return-1;E=F+2,T=!0;continue}if(z==="/"&&T){let F=E+1,V=!1;while(F<k){let H=v[F];if(H==="\\"){F+=2;continue}if(H==="[")V=!0;else if(H==="]")V=!1;else if(H==="/"&&!V){F++;break}else if(H===`
|
|
2001
|
+
`){F=-1;break}F++}if(F===-1){E++,T=!1;continue}while(F<k&&/[a-z]/.test(v[F]))F++;E=F,T=!1;continue}if(z==="'"||z==='"'){let F=z;E++;while(E<k){if(v[E]==="\\"){E+=2;continue}if(v[E]===F){E++;break}if(v[E]===`
|
|
2002
|
+
`)break;E++}T=!1;continue}if(z==="`"){E++;while(E<k){if(v[E]==="\\"){E+=2;continue}if(v[E]==="`"){E++;break}if(v[E]==="$"&&v[E+1]==="{"){j.push(!0),E+=2,T=!0;break}E++}if(j.length===0)T=!1;continue}if(z==="}"&&j.length>0){j.pop(),E++;while(E<k){if(v[E]==="\\"){E+=2;continue}if(v[E]==="`"){E++,T=!1;break}if(v[E]==="$"&&v[E+1]==="{"){j.push(!0),E+=2,T=!0;break}E++}continue}if(/\s/.test(z));else if(/[)\].\w$]/.test(z))T=!1;else T=!0;E++}return-1}function qg(v,_){let k=_.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),E=new RegExp(`<script\\b(?=[^>]*\\b${k}(?:\\s|=|/?>))[^>]*>`,"i").exec(v);if(!E)return null;let T=E.index+E[0].length,j=v.indexOf("</script>",T);if(j===-1)return null;let B=v.indexOf(">",j);if(B===-1)return null;return{start:E.index,end:B+1}}var _w=4096;async function Bg(v,_,k){if(k.buildMode!=="serve"||_.length<_w)return null;let{registerServeModuleBundle:E}=await import("./chunk-2jxe6y8h.js");return`<script ${v} src="${E(_)}"></script>`}async function zg(v,_,k){try{let{registeredModuleIdsIn:E,buildModuleRegistryScript:T}=await ut("stx/client-module-registry",()=>import("./chunk-q8ttp85g.js")),j=[],B=await T(E(...v),{minify:_.buildMode==="compile",collectInputs:j});for(let z of j)k?.add(z);if(!B)return null;if(_.buildMode==="serve"){let{registerServeModuleBundle:z}=await import("./chunk-2jxe6y8h.js");return`<script data-stx-scoped data-stx-run="always" data-stx-modules src="${z(B)}"></script>`}return`<script data-stx-scoped data-stx-run="always" data-stx-modules>${B.replace(/<\/script/gi,"<\\/script")}</script>`}catch{return null}}function kw(v,_=""){let k=qg(v,"data-stx-runtime");if(!k)return v;let E=Gs(v);if(E===-1||E===k.start){if(!_)return v;return v.slice(0,k.end)+_+v.slice(k.end)}if(E<k.start)return v.slice(0,E)+v.slice(k.start,k.end)+_+`
|
|
2003
|
+
`+v.slice(E,k.start)+v.slice(k.end);let T=v.slice(k.start,k.end),j=v.slice(0,k.start)+v.slice(k.end),B=Gs(j);if(B===-1)return T+_+`
|
|
2004
|
+
`+j;return j.slice(0,B)+T+_+`
|
|
2005
|
+
`+j.slice(B)}function Ew(v){let _=/\x00STX_ESC_MUSTACHE_OPEN\x00([\s\S]*?)\x00STX_ESC_MUSTACHE_CLOSE\x00/g;return v.replace(_,(k,E,T)=>{let j=v.slice(0,T);return j.lastIndexOf("<")>j.lastIndexOf(">")?`{{${E}}}`:`{<!--stx-literal-->{${E}}}`})}async function n(v,_,k,E,T){if(E.ssr===!1&&!E.autoShell&&E.buildMode==="spa")return v;if(_.__stx_signals_gate===void 0)_.__stx_signals_gate=he(v,k);let j=!_.__stxProcessingDepth;rn(_);for(let B of E._layerGraph?.configDependencies??[])T.add(B);if(j&&E.runtimeConfig)await cn(_,k,E.runtimeConfig);if(j)id(_),_.__stx_scope_seq??={n:0,key:Bun.hash(String(_.__filename??k)).toString(36).slice(0,6)},_.__stx_head_injections=gl(),_.__stx_seo_staged=!1;if(!_.__stxProcessingDepth)_.__stxProcessingDepth=0;if(_.__stxProcessingDepth++,!_.__onceStore)_.__onceStore=new Set;if((E.debug||!fe()&&!fn())&&k&&k.endsWith(".stx"))Ls(v,k);try{return await U.timeAsync("template-processing",async()=>{let B=await Cw(v,_,k,E,T);if(j)B=El(B);if(j&&E.autoShell&&E.buildMode!=="compile"){let z=de(E.app?.head,{known:un,source:"app.head"}),V=(_.__stx_runtime_head||null)??_s(),H=(_.__stx_head_raw||"").trim(),G,J=H.match(/<title[^>]*>([\s\S]*?)<\/title>/i);if(J)G=J[1].trim(),H=H.replace(J[0],"").trim();let ne=_.__sections?.title,re=V.title||G||ne,se=!V.title&&(!!G||!!ne),ie=V.meta||[],oe=new Set(ie.map((_e)=>wr(_e)).filter(Boolean)),ge={...z,...re&&{title:re},meta:[...(z.meta||[]).filter((_e)=>!oe.has(wr(_e))),...ie],link:[...z.link||[],...V.link||[]],script:[...z.script||[],...V.script||[]],headRaw:[z.headRaw,H].filter(Boolean).join(`
|
|
2006
|
+
`),...V.htmlAttrs&&{htmlAttrs:og(z.htmlAttrs,V.htmlAttrs)},...V.bodyAttrs&&{bodyAttrs:{...z.bodyAttrs||{},...V.bodyAttrs}}},ue=wl(B);if(B=Vn(B,ge,{...se&&{titleIsHtml:!0},...E.app?.colorMode&&{colorMode:E.app.colorMode}},ue),ue)B=cg(B,z),B=Hn(B,ge.htmlAttrs);let xe=B.match(/<!-- stx-layout: ([^ ]+) -->/);if(xe&&B.includes("<head")){let _e=xe[1],Ce=lr(_e);B=B.replace(/<head\b[^>]*>/i,(Ee)=>`${Ee}
|
|
2007
|
+
<meta name="stx-layout" content="${Lg(_e)}">
|
|
2008
|
+
<meta name="stx-layout-group" content="${Lg(Ce)}">`)}let we=B.match(/function (__stx_setup_\w+)\(/),$e=we?An(B):null;if(we&&$e&&!/\bdata-stx=/.test($e.tag)){B=ws(B,(Ce,Ee)=>`<body${Ee} data-stx="${we[1]}">`);let _e=new RegExp(`(<(?!body)[a-zA-Z][^>]*) data-stx="${we[1]}"`,"i");B=B.replace(_e,"$1")}}if(j){let z=_.__stx_head_injections??gl(),F=ag(B);if(F!==null)z.beforeClose.push(F);let V=Jp(B);if(V!==null)z.afterOpen.push(V);if(E.offline?.enabled&&!B.includes("data-stx-offline"))z.beforeClose.push(Yp);B=Kp(B,z);let H=E.app?.colorMode;if(H)B=zn(B,H)}if(j)if(qg(B,"data-stx-runtime")){let F=null,V=null,H=null,G=null,J=null;try{let{getStoreScript:re}=await ut("stx/store-loader",()=>import("./chunk-8nd0f6z0.js")),se=E.storesDir,ie=await re(se);if(ie)H=`<script data-stx-stores>${ie}</script>`,V=await Bg("data-stx-stores",ie,E)??H}catch{}F=await zg([B,H],E,T);try{let{getFrameworkComposableScript:re}=await ut("stx/framework-composables",()=>import("./chunk-hg7abc58.js"));J=await re(B)}catch{}try{let{getComposableScript:re}=await ut("stx/composable-loader",()=>import("./chunk-77hanm4y.js")),se=E.composablesDir,ie=[F,H,J].filter((ge)=>ge!==null),oe=await re(E._layerComposableDirs??se,B,ie);if(oe)G=await Bg('data-stx-scoped data-stx-run="always" data-stx-composables',oe,E)??`<script data-stx-scoped data-stx-run="always" data-stx-composables>${oe}</script>`}catch{}let ne=[F,V,G,J].filter((re)=>re!==null).map((re)=>`
|
|
2009
|
+
${re}`).join("");B=kw(B,ne)}else{let F=await zg([B],E,T);if(F){let V=B.search(/<script\b[^>]*>(?:(?!<\/script>)[\s\S])*?__stxModules\[/i);if(V!==-1)B=B.slice(0,V)+F+`
|
|
2010
|
+
`+B.slice(V)}}if(j)B=Gp(B);if(j&&_.__stx_inject_css!==!1)B=await f(B,void 0,E.buildMode==="serve",!0);else if(j)B=Xs(B);if(B=B.replace(/\x00STX_ESCAPED_AT\x00/g,"@"),B=Ew(B),j&&_.__stx_runtime_config)B=Ke(B,_.__stx_runtime_config);if(j&&!_.__stx_defer_server_data){let z=Fn(_);if(z){let F=/<head\b[^>]*>/i.exec(B),V=F?F.index+F[0].length:0;B=B.slice(0,V)+z+B.slice(V)}}return B})}catch(B){if(B instanceof rr)throw B;let z=B instanceof Error?B.message:String(B),F=new X(`Template processing failed: ${z}`,k,void 0,void 0,v.substring(0,200)+(v.length>200?"...":""));if(A.log(F,{filePath:k,context:_}),Tt.logDetailedError(F,{filePath:k,template:v.substring(0,500)}),E.debug)throw F;return Rs.createFallbackContent("Template Processing",F)}}async function Cw(v,_,k,E,T){let j=process.cwd(),B={...E,partialsDir:E.partialsDir&&!Yt.isAbsolute(E.partialsDir)?Yt.resolve(j,E.partialsDir):E.partialsDir,componentsDir:E.componentsDir&&!Yt.isAbsolute(E.componentsDir)?Yt.resolve(j,E.componentsDir):E.componentsDir,layoutsDir:E.layoutsDir&&!Yt.isAbsolute(E.layoutsDir)?Yt.resolve(j,E.layoutsDir):E.layoutsDir},z=B,F=v;await Aw(k,_),Tw(_,z),F=await te(()=>Np(F,_,k,z),F,(we)=>{A.log(we,{filePath:k,phase:"pre-processing-middleware"},"warning"),console.warn(`[stx] pre-processing middleware failed for ${k}: ${we.message}`)}),F=F.replace(/\{\{--[\s\S]*?--\}\}/g,"");let V=En(F,Le,(we,$e)=>`\x00STX_HTML_COMMENT_${$e}\x00`);F=V.output;let H=V.tokens,G=(we)=>H.length===0?we:we.replace(/\x00STX_HTML_COMMENT_(\d+)\x00/g,($e,_e)=>H[Number(_e)]??""),J="\x00STX_ESCAPED_AT\x00",ne="\x00STX_ESC_MUSTACHE_OPEN\x00",re="\x00STX_ESC_MUSTACHE_CLOSE\x00";F=F.replace(/@@/g,J),F=F.replace(/@\{\{([\s\S]*?)\}\}/g,(we,$e)=>`${ne}${$e}${re}`),F=Fp(F),F=await Eg(F,k,T);let se={};F=ls(F,se);let ie={..._.__sections||{}},oe="",ge=af(je(v)),ue=/@nolayout\b/.test(F)||ge===!1;if(/@nolayout\b/.test(F))F=F.replace(/@nolayout\b\s*/g,"");let xe=F.match(/@(?:layout|extends)\(\s*['"]([^'"]+)['"]\s*\)/);if(xe)oe=xe[1],F=F.replace(/@(?:layout|extends)\(\s*['"]([^'"]+)['"]\s*\)/g,"");else if(typeof ge==="string"){if(oe=ge,!/@section\s*\(/.test(F))F=`@section('content')
|
|
2011
|
+
${F.trim()}
|
|
2012
|
+
@endsection`}if(!oe&&!ue&&z.defaultLayout){let we=sn(F),$e=/@section\s*\(/.test(F);if(!we||$e){let _e="",Ce=Yt.dirname(k),Ee=z.layoutsDir?Yt.dirname(z.layoutsDir):process.cwd();for(let Te=0;Te<20;Te++){let Re=Yt.join(Ce,"_layout.stx");if(await r(Re)){_e=Re;break}let ke=Yt.dirname(Ce);if(ke===Ce||ke.length<Ee.length)break;Ce=ke}if(_e)oe=_e;else if(z.layoutsDir){let Te=Yt.isAbsolute(z.layoutsDir)?z.layoutsDir:Yt.resolve(process.cwd(),z.layoutsDir),Re=Yt.join(Te,`${z.defaultLayout}.stx`);if(await r(Re))oe=Re}if(oe&&!$e)F=`@section('content')
|
|
2013
|
+
${F.trim()}
|
|
2014
|
+
@endsection`}}if(oe&&F.includes("<script")){let we=bn(F),$e=we.scripts.map((_e)=>Fg(_e,k)??_e);F=Hr(we.output,$e)}if(F=F.replace(/@section\(\s*['"]([^'"]+)['"]\s*,\s*['"]([^'"]+)['"]\s*\)/g,(we,$e,_e)=>(ie[$e]=_e,"")),F=F.replace(/@section\(\s*['"]([^'"]+)['"]\s*,\s*([^)]+?)\s*\)/g,(we,$e,_e)=>{if(/^(['"]).*\1$/.test(_e.trim()))return we;try{let Ce=c(_e.trim(),_);if(Ce===void 0)return we;return ie[$e]=String(Ce??""),""}catch{return we}}),F=F.replace(/@section\(\s*['"]([^'"]+)['"]\s*\)([\s\S]*?)(?:@endsection|@show)/g,(we,$e,_e)=>{if(_e.includes("@parent"))ie[$e]=_e.replace("@parent",Mr);else ie[$e]=_e.trim();return""}),_.__sections=ie,F=F.replace(/@(?:yield|slot)\(\s*['"]([^'"]+)['"](?:,\s*['"]([^'"]+)['"])?\)/g,(we,$e,_e)=>ie[$e]||_e||""),!("slot"in _)||_.slot===void 0)F=F.replace(/\{\{\s*slot\s*\}\}/g,()=>ie.content||"");if(F=us(F,se),oe){let we=[],$e=bn(F),_e=En($e.output,Ur,(Ce,Ee)=>`\x00STX_ORPHAN_STYLE_${Ee}\x00`);if(F=_e.output.replace(/\x00STX_(SCRIPT|ORPHAN_STYLE)_(\d+)\x00/g,(Ce,Ee,Te)=>{let Re=Ee==="SCRIPT"?Fg($e.scripts[Number(Te)],k):_e.tokens[Number(Te)];if(Re)we.push(Re);return""}),we.length>0){let Ce=we.join(`
|
|
2015
|
+
`);ie.content=ie.content?`${ie.content}
|
|
2016
|
+
${Ce}`:Ce,_.__sections=ie}}if(oe)try{let we;if(Yt.isAbsolute(oe))we=oe,T.add(oe);else we=await te(()=>qn(oe,k,B,T),null,()=>{throw new X(`Failed to resolve layout path: ${oe}`,k,void 0,void 0,`Layout referenced from ${k}`)});if(!we){let Re=(Xe)=>{if(!Xe)return[];try{let Pe=Yt.isAbsolute(Xe)?Xe:Yt.resolve(process.cwd(),Xe);return $w.readdirSync(Pe).filter((Ie)=>Ie.endsWith(".stx")).map((Ie)=>Ie.replace(/\.stx$/,""))}catch{return[]}},ke=[...Re(B.layoutsDir),...Re(B.fallbackLayoutsDir)].filter((Xe,Pe,Ie)=>Ie.indexOf(Xe)===Pe).sort(),Ae=`Layout not found: ${oe} (referenced from ${k})`+(ke.length>0?`. Available layouts: ${ke.join(", ")}`:B.layoutsDir?`. No .stx layouts found in ${B.layoutsDir}`:"");if(A.log(Error(Ae),{layoutPath:oe,filePath:k,available:ke},"error"),console.error(`[stx] ${Ae}`),B.debug)throw new X(Ae,k);return F}let $e=await te(()=>Bun.file(we).text(),"",()=>{throw new X(`Failed to read layout file: ${we}`,k,void 0,void 0,"Layout content could not be loaded")});$e=jg($e,we);let _e=$e.match(/@(?:layout|extends)\(\s*['"]([^'"]+)['"]\s*\)/);if(_e){if(B.debug)console.log(`Found nested layout: ${_e[1]} in ${we}`);let Re={},ke=$e.replace(/@section\(\s*['"]([^'"]+)['"]\s*\)([\s\S]*?)(?:@show|@endsection)/g,(Pe,Ie,Ze)=>(Re[Ie]=Ze.trim(),""));for(let[Pe,Ie]of Object.entries(Re))if(ie[Pe]&&ie[Pe].includes(Mr)){let Ze=ie[Pe].indexOf(Mr);ie[Pe]=ie[Pe].slice(0,Ze)+Ie+ie[Pe].slice(Ze+Mr.length)}else if(!ie[Pe])ie[Pe]=Ie;let Ae={..._,__sections:ie},Xe=`@layout('${_e[1]}')${ke}`;return await n(Xe,Ae,we,B,T)}let Ce=$e.replace(/\{\{--[\s\S]*?--\}\}/g,""),Ee=ls(Ce,se),Te={};return Ee=Ee.replace(/@section\(\s*['"]([^'"]+)['"]\s*\)([\s\S]*?)(?:@show|@endsection)/g,(Re,ke,Ae)=>(Te[ke]=Ae.trim(),`@slot('${ke}')`)),Ee=Ee.replace(/@(?:yield|slot)\(\s*['"]([^'"]+)['"]\s*(?:,\s*['"]([^'"]+)['"]\s*)?\)/g,(Re,ke,Ae)=>{if(ie[ke]){let Xe=ie[ke];if(Xe.includes(Mr)){let Pe=Te[ke]||"",Ie=Xe.indexOf(Mr);Xe=Xe.slice(0,Ie)+Pe+Xe.slice(Ie+Mr.length)}return Xe}return Ae||""}),Ee=Rw(Ee,ie),Ee=Ee.replace(/\{\{\s*slot\s*\}\}/g,()=>ie.content||""),Ee=us(Ee,se),_.__originalFilePath=k,F=await Ug(Ee,_,we,B,T),F=`<!-- stx-layout: ${oe} -->
|
|
2017
|
+
${F}`,G(F)}catch(we){return A.log(we instanceof Error?we:Error(String(we)),{layoutPath:oe,filePath:k},"error"),`[Error processing layout: ${we instanceof Error?we.message:String(we)}]`}return G(await Ug(F,_,k,B,T))}function Rw(v,_){return v.replace(/@(?:yield|slot)\(\s*['"]([^'"]+)['"]\s*(?:,\s*['"]([^'"]+)['"]\s*)?\)/g,(k,E,T)=>{let j=_[E];if(j!==void 0){if(!new RegExp(`@(?:yield|slot)\\(\\s*['"]${E.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}['"]`).test(j))return j}return T||""})}function Tw(v,_){if(v.__stx_sfc_mode=!0,v.__stx_options=_,_.buildMode)v.__stx_buildMode=_.buildMode;let k=_.envPrefix||"STX_PUBLIC_",E={};for(let[T,j]of Object.entries(process.env))if(T.startsWith(k)&&j!==void 0)E[T]=j;v.$env=E}async function Aw(v,_){await te(()=>Bp(v,_),void 0,(k)=>{A.log(k,{filePath:v,phase:"view-composer"},"warning"),console.warn(`[stx] view composer failed for ${v}: ${k.message}`)})}var Tl="data-stx-source";function Fg(v,_){if(!v)return v;let k=/^<script\b([^>]*)>/i.exec(v);if(!k||!/\bserver\b/.test(k[1])||k[1].includes(Tl))return v;return`<script ${Tl}="${encodeURIComponent(_)}"${v.slice(7)}`}function Iw(v){let _=new RegExp(`${Tl}="([^"]*)"`).exec(v);return _?decodeURIComponent(_[1]):void 0}function Wg(v){return v.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function Vg(v,_,k){return`<div data-stx-server-script-error role="alert" style="padding:12px 14px;border:1px solid #f0b4b4;border-left-width:4px;background:#fff5f5;color:#7a1f1f;font:13px/1.5 ui-monospace,SFMono-Regular,Menlo,monospace"><strong style="display:block;margin-bottom:4px">stx: a <script server> ${_==="module-resolution"?"imports a module that does not resolve":_==="syntax"?"does not parse":"names something that does not exist"}, so this component rendered nothing.</strong><span style="display:block;opacity:.85">${Wg(v)}</span><span style="display:block;margin-top:4px">${Wg(k)}</span></div>`}async function Pw(v,_,k,E){let{scanScriptTags:T}=await ut("stx/signal-processing",()=>import("./chunk-zrbpy3m5.js")),j=[],B=!fe()&&!fn();for(let F of T(v)){let V=F.attrs;if(!/\bserver\b/.test(V))continue;let H=F.start+F.fullMatch.indexOf(">")+1,G=Hg(v,H);if(G===-1)continue;let J=v.slice(H,G);if(!J.trim())continue;let ne=Iw(V)??k,re={index:F.start,length:G+9-F.start};try{let{extractVariables:se}=await ut("stx/variable-extractor",()=>import("./chunk-e78ame3h.js"));await se(J,_,ne,{preserveExisting:!0,onFailure:(ie)=>{if(ie.kind==="unknown")return;if(E?.onServerScriptError?.({sourcePath:ne,kind:ie.kind,message:ie.message}),!B)return;j.push({...re,markup:Vg(ne,ie.kind,ie.message)})}})}catch(se){let ie=se instanceof Error?se:Error(String(se));if(A.log(ie,{filePath:ne,phase:"server-script-extraction"},"warning"),console.warn(`[stx] server <script> extraction failed in ${ne}: ${ie.message}`),B)j.push({...re,markup:Vg(ne,"unknown",ie.message)})}}if(j.length===0)return v;let z=v;for(let F of j.sort((V,H)=>H.index-V.index))z=z.slice(0,F.index)+F.markup+z.slice(F.index+F.length);return z}async function Dw(v,_,k){try{let{interpolateScriptsInTemplate:E}=await ut("stx/expressions",()=>import("./chunk-qrgr2h1n.js"));return E(v,_,{skipServer:!0})}catch(E){let T=E instanceof Error?E:Error(String(E));return A.log(T,{filePath:k,phase:"script-expression-interpolation"},"warning"),console.warn(`[stx] script expression interpolation failed in ${k}: ${T.message}`),v}}async function Ug(v,_,k,E,T){let j=v,B=E;if(j=await Pw(j,_,k,E),j=await Dw(j,_,k),j=await _p(j,_,k),j=await kp(j,_,k),j=await Sf(j,_,k,B),he(j))j=qo(j,_),j=os(j,_),j=ss(j,_);j=Ko(j);let{processStreamDirectives:z}=await ut("stx/streaming",()=>import("./chunk-rwx1s3b5.js"));j=z(j,_),j=Zo(j,_,k,B,!0),j=await Hp(j,_,k,B,T),j=await ts(j,_,k,B,T),j=ou(j,_,k,B);let{processDeferDirectives:F}=await ut("stx/defer",()=>import("./chunk-3s2vnqcf.js"));j=F(j,_,k);let{processTeleportDirectives:V}=await ut("stx/teleport",()=>import("./chunk-4henqdjf.js"));j=V(j,_,k);let{processTransitionDirectives:H,processTransitionAttributes:G}=await ut("stx/transitions",()=>import("./chunk-5m8q7c5r.js"));j=H(j,_,k),j=G(j);let{processErrorBoundaryDirectives:J,stripRenderFailedMarkers:ne}=await ut("stx/error-boundaries",()=>import("./chunk-h85hrwkq.js"));j=J(j,_,k),j=ne(j);let{processSuspenseDirectives:re}=await ut("stx/suspense",()=>import("./chunk-q98v7bhs.js"));j=re(j,_,k);let{processAsyncDirectives:se}=await ut("stx/async-components",()=>import("./chunk-9t50hw97.js"));j=se(j,_,k);let{processKeepAliveDirectives:ie}=await ut("stx/keep-alive",()=>import("./chunk-n8hd5qap.js"));j=ie(j,_,k);let{processVirtualListDirectives:oe,processVirtualGridDirectives:ge,processInfiniteListDirectives:ue}=await ut("stx/virtual-scrolling",()=>import("./chunk-pe214qcn.js"));j=oe(j,_,k),j=ge(j,_,k),j=ue(j,_,k);let{processPartialHydrationDirectives:xe,processStaticDirectives:we}=await ut("stx/partial-hydration",()=>import("./chunk-hehtgsrt.js"));j=xe(j,_,k),j=we(j);let{processComputedDirectives:$e,processWatchDirectives:_e}=await ut("stx/computed",()=>import("./chunk-1xdzcy9d.js"));j=$e(j,_,k),j=_e(j,_,k);let{processFormValidationDirectives:Ce}=await ut("stx/forms-validation",()=>import("./chunk-tr7dz5g5.js"));j=Ce(j,_,k);let{processHeadDirective:Ee,processTitleDirective:Te,processMetaDirective:Re,resetHead:ke}=await ut("stx/head",()=>import("./chunk-ef0gstkd.js"));if(!_.__stx_head_preset&&!_.__stx_runtime_head)ke();let Ae=Ee(j);if(j=Ae.content,Ae.headContent)_.__stx_head_raw=`${_.__stx_head_raw||""}${Ae.headContent}
|
|
2018
|
+
`;if(j=Te(j,_),j=Re(j,_,k),j=Lp(j),j=Ic(j,_),j=wf(j),j=Mp(j),j=await cs(j,_,k,B,T),j=await ts(j,_,k,B,T),_.__stxProcessingDepth===1)j=od(j,_);if(j=j.replace(/@push\s*\(\s*['"][^'"]+['"]\s*\)[\s\S]*?@endpush/g,""),j=El(j),j=ar(j,_,k),j=as(j),j=cf(j,_,{filePath:k,buildMode:B.buildMode}),j=Pc(j,_),j=Dc(j,_),j=oo(j,_),j=Tf(j,_),j=Af(j,_),j=await Xg(j,_,k,B),j=await Kg(j,_,k),j=await ui(j,_,k,B),j=di(j,_,k,B),j=ks(j,_,k,B),j=Cs(j,_,k),j=$s(j,_,k,B),j=bf(j,_,k,B),j=ps(j,_),j=gs(j),j=Ag(j),!B.skipEventDirectives)j=Wu(j,_,k);if(j=df(j,_,k),B.debug){let et=/\bx-data\s*=/.test(j),it=rs(v);if(et&&it)console.warn(`[stx] ${k}: Template mixes Alpine-style (x-data) and signals (state/derived/effect) reactivity.
|
|
2019
|
+
Both work on the same page, but they manage separate scopes.
|
|
2020
|
+
Prefer signals (state/derived/effect) for new components.`)}j=fp(j,_),j=await q(j,_,k),j=Mg(j),j=Og(j),j=sf(j);let{processXElementDirectives:Xe}=await ut("stx/x-element",()=>import("./chunk-zhxdpzga.js"));j=Xe(j);let Pe=_.__originalFilePath||k,Ie=Ne(_);if(j=await Xo(j,B,Pe,Ie),j=Ef(j,_),j=await jp(j,_,k,B),B.media?.image?.autoSiblings){let et=B.publicDir||"public",{rewriteImagesWithSiblings:it}=await ut("stx/image-optimization/auto-sibling",()=>import("./chunk-hvx3pc13.js"));j=await it(j,{publicDir:et})}if(B.seo?.enabled)j=Es(j,_,B);let Ze=(et,it,gt=!0)=>{if(!it)return et;let qt=it.match(/<title\b[^>]*>[\s\S]*?<\/title>/i),Dt=et.match(/<title\b[^>]*>[\s\S]*?<\/title>/i);if(qt&&Dt){if(gt)et=et.replace(Dt[0],qt[0]);if(it=it.replace(qt[0],"").trim(),!it)return et}if(/<\/head>/i.test(et))return et.replace(/<\/head>/i,`${it}
|
|
2021
|
+
</head>`);if(/<head\b[^>]*>/i.test(et))return et.replace(/(<head\b[^>]*>)/i,`$1
|
|
2022
|
+
${it}`);if(/<html\b[^>]*>/i.test(et))return et.replace(/(<html\b[^>]*>)/i,`$1
|
|
2023
|
+
<head>
|
|
2024
|
+
${it}
|
|
2025
|
+
</head>`);return et},{renderHead:nt,getHead:at}=await ut("stx/head",()=>import("./chunk-ef0gstkd.js")),bt=_.__stx_runtime_head??at();if(bt.title||bt.meta?.length||bt.link?.length){let et=nt(bt);if(et)j=Ze(j,et)}if(Ae.headContent)j=Ze(j,Ae.headContent,!bt.title);if(B.csp?.enabled&&B.csp.addMetaTag)j=yf(j,B.csp,_);if(B.analytics?.enabled)j=of(j,B);if(B.heatmap?.enabled)j=lu(j,B);if(B.pwa?.enabled&&B.pwa.autoInject!==!1){let{injectPwaTags:et}=await ut("stx/pwa/inject",()=>import("./chunk-hqzq3a61.js"));j=et(j,B)}let ft=/<script\b(?![^>]*\bserver\b)[^>]*>[\s\S]*?<\/script>/i.test(j),yt=/\bSTX\.\w+/.test(j),ct=/window\.STX\s*=/.test(j);if(ft&&yt&&!ct){let it=`<script data-stx-scoped data-stx-run="once">
|
|
2026
|
+
${tf()}
|
|
2027
|
+
</script>`;if(j.includes("</head>")){let gt=j.indexOf("</head>"),Dt=j.slice(0,gt).indexOf("<script");if(Dt!==-1){let xn=j.slice(0,Dt),Nt=j.slice(Dt);j=xn+it+`
|
|
2028
|
+
`+Nt}else j=j.replace("</head>",`${it}
|
|
2029
|
+
</head>`)}else if(j.includes("<body"))j=j.replace(/<body([^>]*)>/,`<body$1>
|
|
2030
|
+
${it}`);else j=it+`
|
|
2031
|
+
`+j}{let{scanScriptTags:et}=await ut("stx/signal-processing",()=>import("./chunk-zrbpy3m5.js")),it=[];for(let gt of et(j)){if(!/\bserver\b/i.test(gt.attrs))continue;let qt=gt.start+gt.fullMatch.indexOf(">")+1,Dt=Hg(j,qt);if(Dt===-1)continue;let xn=Dt+9;while(xn<j.length&&/\s/.test(j[xn]))xn++;it.push({start:gt.start,end:xn})}if(it.length>0){let gt=Array(it.length+1),qt=0;for(let Dt=0;Dt<it.length;Dt++){let{start:xn,end:Nt}=it[Dt];gt[Dt]=j.slice(qt,xn),qt=Nt}gt[it.length]=j.slice(qt),j=gt.join("")}}let Pt=Yi(j,k);if(Pt.hasScoped)j=Pt.html;let pt=_.__stx_event_bindings||[],Lt=!1,Qn=[],Sn=/\s:[a-z][\w.-]*\s*=/.test(j),{scanScriptTags:er}=await ut("stx/signal-processing",()=>import("./chunk-zrbpy3m5.js"));for(let et of er(j,{skipAttrs:/\bserver\b|\bsrc\s*=|\bdata-stx-scoped\b|\bdata-stx-router\b|\btype\s*=\s*["'](?!(?:text\/javascript|application\/javascript|module)["'])[^"']*["']/}))Qn.push({match:et.fullMatch,attrs:et.attrs,content:et.body});for(let{match:et,attrs:it,content:gt}of Qn){Lt=!0;let qt=gt;ms(gt,k,E.strict,_.__originalFilePath);let Dt=await me(gt,{eventBindings:pt,attrs:it,hasColonDirectives:Sn,templateContent:v,filePath:k,projectRoot:process.cwd(),production:E.buildMode==="compile",serverData:Ie});j=j.replace(et,()=>Dt)}if(Lt)_.__stx_event_bindings=[];if(!Lt&&_.__stxProcessingDepth===1){let et=_.__stx_event_bindings||[];if(et.length>0){let it=ya(et);if(it){let gt=j.lastIndexOf("</body>");j=gt===-1?j+it:j.slice(0,gt)+it+`
|
|
2032
|
+
`+j.slice(gt)}_.__stx_event_bindings=[]}}if(!ae(j)&&pg(j))j=await Ao(j,B);if(j=gg(j),B.csp?.enabled&&B.csp.useNonce&&typeof _.cspNonce==="string")j=xf(j,_.cspNonce);return j}import am from"path";import Il from"fs";import Pi from"path";function Zg(v,_,k,E){let T=0;for(let j=_;j<v.length;j++)if(v[j]===k)T++;else if(v[j]===E&&!(E===">"&&v[j-1]==="=")){if(--T===0)return j}return-1}function Mw(v){let _=s(v),k=0,E=0,T=[];for(let j=0;j<_.length;j++)if("([{".includes(_[j]))k++;else if(")]}".includes(_[j]))k--;else if(_[j]===","&&k===0)T.push(v.slice(E,j).trim()),E=j+1;return T.push(v.slice(E).trim()),T}function Al(v,_){let k=s(v),E=new RegExp(`\\b(?:${_.map((T)=>T.replace(/[$]/g,"\\$&")).join("|")})\\s*(?=[<(])`,"g");for(let T of k.matchAll(E)){let j=T.index+T[0].length,B="";if(k[j]==="<"){let F=Zg(k,j,"<",">");if(F<0)continue;B=v.slice(j+1,F),j=F+1;while(/\s/.test(k[j]||"")&&j<k.length)j++}if(k[j]!=="(")continue;let z=Zg(k,j,"(",")");if(z>=0)return{type:B,args:Mw(v.slice(j+1,z))}}return null}var Gg=`
|
|
2033
|
+
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;
|
|
2034
|
+
type __StxWiden<T> = T extends string ? string : T extends number ? number : T extends boolean ? boolean : T;
|
|
2035
|
+
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>;
|
|
2036
|
+
type __StxRequired<O> = { [K in keyof O]-?: O[K] extends { required: true } ? K : never }[keyof O];
|
|
2037
|
+
type __StxDefaulted<O> = { [K in keyof O]-?: O[K] extends { default: unknown } ? K : never }[keyof O];
|
|
2038
|
+
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]> };
|
|
2039
|
+
type __StxDefaults<P, K> = Omit<P, Extract<keyof P, K>> & Partial<Pick<P, Extract<keyof P, K>>>;
|
|
2040
|
+
`;function Jg(v,_){let k=[],E={defineProps:["defineProps"],defineEmits:["defineEmits"],withDefaults:["withDefaults"]},T=s(v),j=v.replace(/\bimport\s+(?:type\s+)?(\{[^}]*\}|\*\s+as\s+[\w$]+|[\w$]+)\s+from\s*(['"])([^'"]+)\2\s*;?/g,(J,ne,re,se,ie)=>{if(T.slice(ie,ie+6)!=="import")return J;if(se.endsWith(".stx"))return"";let oe=`${_}Import${k.length}`;if(k.push(`import * as ${oe} from ${JSON.stringify(se)};`),ne.startsWith("*"))return`import ${ne.replace(/^\*\s+as\s+/,"")} = ${oe};`;if(!ne.startsWith("{"))return`import ${ne} = ${oe}.default;`;return ne.slice(1,-1).split(",").map((ge)=>{let[ue,xe=ue]=ge.trim().replace(/^type\s+/,"").split(/\s+as\s+/);if(!ue)return"";if(/^(?:stx|@stacksjs\/stx)(?:\/|$)/.test(se)&&ue in E)E[ue].push(xe);return`import ${xe} = ${oe}.${ue};`}).join(`
|
|
2041
|
+
`)}),B=Al(v,E.defineProps),z=Al(v,E.defineEmits),F=Al(v,E.withDefaults);if(!B&&!z)return{declarations:"",props:null,events:null};let V=[],H=null,G=null;if(B){V.push(`const __options = (${B.args[0]||"{}"}) as const;`),V.push(`const __defaults = (${F?.args[1]||"{}"});`);let J=B.type||"__StxOptions<typeof __options>";V.push(`export type __StxProps = __StxDefaults<${J}, keyof typeof __defaults | __StxDefaulted<typeof __options>>;`),H=`${_}.__StxProps`}if(z)V.push(`const __events = (${z.args[0]||"[]"}) as const;`),V.push(`export type __StxEvents = ${z.type||"Record<(typeof __events)[number], any[]>"};`),G=`${_}.__StxEvents`;return{declarations:`${k.join(`
|
|
2042
|
+
`)}
|
|
2043
|
+
namespace ${_} {
|
|
2044
|
+
${j}
|
|
2045
|
+
${V.join(`
|
|
2046
|
+
`)}
|
|
2047
|
+
}`,props:H,events:G}}function*Ow(v){let _=/<([A-Za-z][\w.-]*)(?=[\s/>])/g,k;while(k=_.exec(v)){let E=_.lastIndex,T=[];while(E<v.length){while(/\s/.test(v[E]||""))E++;if(v[E]===">"||v.slice(E,E+2)==="/>"){E+=v[E]===">"?1:2;break}let j=/^[^\s=/>]+/.exec(v.slice(E))?.[0];if(!j){E++;continue}let B=E;E+=j.length;while(/\s/.test(v[E]||""))E++;if(v[E]!=="="){T.push({name:j,value:!0,offset:B,braced:!1});continue}E++;while(/\s/.test(v[E]||""))E++;let z=v[E],F=z==="{",V=z==='"'||z==="'";if(V||F)E++;let H=E;if(F){let G=s(v.slice(E)),J=1,ne=0;for(;ne<G.length;ne++){if(G[ne]==="{")J++;if(G[ne]==="}"&&--J===0)break}E+=ne}else if(V)while(E<v.length&&v[E]!==z)E++;else while(E<v.length&&!/[\s/>]/.test(v[E]))E++;if(T.push({name:j,value:v.slice(H,E),offset:H,braced:F}),V||F)E++}_.lastIndex=E,yield{name:k[1],offset:k.index,attributes:T}}}function Yg(v,_,k){let E=[],T=[Gg,"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 __StxEvent<E, K> = K extends keyof E ? E[K] extends readonly unknown[] ? Exclude<E[K]["length"], 0 | 1> extends never ? E[K][0] : E[K] : E[K] : any;'],j=new Map,B=new Map,z=new Map,F=k.scriptCode(v,k.filePath),V=s(F);for(let re of F.matchAll(/\bimport\s+(\{[^}]+\}|[\w$]+)\s+from\s*['"]([^'"]+)['"]/g)){if(V.slice(re.index,re.index+6)!=="import")continue;let se=re[2],ie=Pi.isAbsolute(se)||se.startsWith(".")?Pi.resolve(Pi.dirname(k.filePath),se):lo(se,Pi.dirname(k.filePath));if(!ie)continue;let oe=ie.endsWith(".stx")?ie:Il.existsSync(`${ie}.stx`)?`${ie}.stx`:void 0,ge=oe?null:co(ie,!1),ue=re[1].startsWith("{")?re[1].slice(1,-1).split(","):[re[1]];for(let xe of ue){let[we,$e=we]=xe.trim().split(/\s+as\s+/),_e=oe||ge?.get(we)||ge?.get(we.toLowerCase());if(_e)z.set($e,_e),z.set($e.toLowerCase(),_e),z.set($e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),_e)}}for(let re of _.matchAll(/@import\s*\(([^)]+)\)/g))for(let se of re[1].matchAll(/['"]([^'"]+)['"]/g)){let ie=uo(se[1],k.filePath,k).find((oe)=>Il.statSync(oe,{throwIfNoEntry:!1})?.isFile());if(ie)z.set(Pi.basename(se[1]).replace(/\.stx$/,""),ie)}let H={__importedComponents:z},G=new Map,J=(re,se,ie)=>{let oe=v.slice(0,re);return{code:se,offset:re,attribute:ie,anchor:!0,kind:"directive",line:oe.split(`
|
|
2048
|
+
`).length,column:re-oe.lastIndexOf(`
|
|
2049
|
+
`)}},ne=(re,se,ie)=>E.push({expression:re,statement:{text:se+re.code+ie,prefixLength:se.length}});for(let re of Ow(_)){if(nn(re.name)||re.name==="component")continue;let se=Df(re.name,k.filePath,k,H);if(!se)continue;let ie=G.get(se);if(!ie){let ge;try{ge=k.readComponent?k.readComponent(se):Il.readFileSync(se,"utf8")}catch{continue}if(ge===void 0)continue;B.set(se,ge),ie=Jg(k.scriptCode(ge,se),`__StxComponent${G.size}`),G.set(se,ie),T.push(ie.declarations)}let oe=[];for(let ge of re.attributes){let{name:ue,offset:xe}=ge,we=ge.value===!0?"true":ge.value;if(ue.startsWith("@")||ue.startsWith("v-on:")){if(ie.events&&ge.value!==!0)j.set(xe,`__StxEvent<${ie.events}, ${JSON.stringify(ue.replace(/^@|^v-on:/,"").split(".")[0])}>`);continue}let $e=/^v-model(?::([\w-]+))?(?:\.[\w-]+)*$/.exec(ue);if(ue.startsWith("v-")&&!ue.startsWith("v-bind:")&&!$e)continue;if(/^(?:x-|:)(?:if|for|show|key|else)(?:$|[.:-])/.test(ue))continue;let _e=($e?$e[1]||"modelValue":ue.replace(/^:|^v-bind:/,"")).replace(/-([a-z])/g,(Te,Re)=>Re.toUpperCase());if(oe.push(_e),!ie.props)continue;let Ee=ue.startsWith(":")||ue.startsWith("v-bind:")||!!$e||ge.braced?we:ge.value!==!0?JSON.stringify(we):"true";ne(J(xe,Ee,ue),";void ((",`) satisfies __StxProp<${ie.props}, ${JSON.stringify(_e)}>);`)}if(ie.props){let ge=[...new Set(oe)].map((xe)=>`${JSON.stringify(xe)}: undefined as any`).join(", "),ue=J(re.offset,`<${re.name}>`);E.push({expression:ue,statement:{text:`;void ({ ${ge} } satisfies ${ie.props} & Record<string, unknown>);`,prefixLength:0}})}}return{declarations:G.size?T.join(`
|
|
2050
|
+
`):"",checks:E,events:j,dependencies:B}}var Qg=/<script(\s[^>]*)?>([\s\S]*?)<\/script>/gi;function Nw(v){let _=(k)=>k.replace(/[^\n]/g," ");return v.replace(/<!--[\s\S]*?-->/g,_).replace(/\{\{--[\s\S]*?--\}\}/g,_)}function He(v){let _=[],k=Nw(v);Qg.lastIndex=0;let E;while((E=Qg.exec(k))!==null){let T=(E[1]||"").trim(),j=(E[0].match(/^<script(?:\s[^>]*)?>/i)?.[0]??"<script>").length,B=(E[0].match(/<\/script\s*>$/i)?.[0]??"</script>").length,z=E.index+j,F=E.index+E[0].length-B,V=v.slice(z,F);if(/\bsrc\s*=/.test(T))continue;let H=T.match(/\btype\s*=\s*["']([^"']+)["']/i);if(H&&!/^(?:module|text\/(?:javascript|typescript))$/i.test(H[1]))continue;let G=/\bserver\b/.test(T)?"server":/\bclient\b/.test(T)?"client":"plain",J=Di(v,z);_.push({kind:G,code:V,startLine:J,startColumn:Mi(v,z),offset:z,attrs:T})}return _}function Di(v,_){let k=1;for(let E=0;E<_&&E<v.length;E++)if(v.charCodeAt(E)===10)k++;return k}function Mi(v,_){let k=v.lastIndexOf(`
|
|
2051
|
+
`,_-1)+1;return _-k+1}function Mo(v){let _=v.split(""),k=(T,j)=>{for(let B=T;B<j&&B<_.length;B++)if(_[B]!==`
|
|
2052
|
+
`)_[B]=" "},E=[/<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 T of E){T.lastIndex=0;let j;while((j=T.exec(v))!==null)k(j.index,j.index+j[0].length)}return _.join("")}function jw(v){let _=0,k="";for(let E=0;E<v.length;E++){let T=v[E];if(k){if(T==="\\"){E++;continue}if(T===k)k="";continue}if(T==='"'||T==="'"||T==="`"){k=T;continue}if(T==="("||T==="["||T==="{"){_++;continue}if(T===")"||T==="]"||T==="}"){_--;continue}if(T==="|"&&_===0){if(v[E+1]==="|"){E++;continue}if(v[E-1]==="|")continue;return v.slice(0,E)}}return v}var cm=new Set([":for","x-for","v-for"]),Oo=/(?:^|\s)((?::|x-|v-|@)[\w.:-]+)\s*=\s*(["'])([\s\S]*?)\2/g,Pl="__stx_interpolated",em="__StxElement",lm="__StxTemplateValue",Lw=`type ${lm}<T> = T extends { readonly _isSignal: true } | { readonly _isDerived: true } ? (T extends () => infer V ? T & V : T) : T`;function tm(v){return v.replace(/\{\{[\s\S]*?\}\}/g,Pl).replace(/\{!![\s\S]*?!!\}/g,Pl)}function hs(v){return v.replace(/\{\{[\s\S]*?\}\}|\{!![\s\S]*?!!\}/g,(_)=>{let k=_.split(`
|
|
2053
|
+
`).length-1,E=_.length-k;return`0${" ".repeat(Math.max(0,E-1))}${`
|
|
2054
|
+
`.repeat(k)}`})}var Bw=["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"],zw=new RegExp(String.raw`^[ \t]*@(?:${Bw.join("|")})\b[ \t]*(\([^\n)]*\))?[ \t]*$`,"gm");function ys(v){return v.replace(zw,(_)=>_.replace(/[^\n]/g," "))}var nm=new Set(["x-cloak","x-ref","x-transition","x-teleport","v-slot","x-hydrate",":key","x-tooltip","x-tooltip-position"]);function mc(v){let _=Mo(v),k=[],E=/(@?)\{\{([\s\S]*?)\}\}|(@?)\{!!([\s\S]*?)!!\}/g,T;while((T=E.exec(_))!==null){if(T[1]||T[3])continue;let z=T[2]??T[4]??"",F=T[2]!==void 0?2:3,V=jw(z);if(!V.trim())continue;let H=T.index+F+(V.length-V.trimStart().length);k.push({code:V.trim(),line:Di(_,H),column:Mi(_,H),offset:H,kind:"interpolation"})}let j=/@(if|elseif|else\s+if|unless)\b\s*\(/g;while((T=j.exec(_))!==null){let B=T.index+T[0].length-1,z=0,F=B;for(;F<_.length;F++){let J=_[F];if(J==="(")z++;else if(J===")"){if(z--,z===0)break}}if(z!==0)continue;let V=_.slice(B+1,F),H=V.trim();if(j.lastIndex=F+1,!H)continue;let G=B+1+(V.length-V.trimStart().length);k.push({code:H,line:Di(_,G),column:Mi(_,G),offset:T.index,kind:"condition"})}Oo.lastIndex=0;while((T=Oo.exec(_))!==null){let B=T[1],z=T[3]??"",F=B.replace(/\..*$/,"").replace(/^([^:].*?):.*$/,"$1");if(nm.has(F)||nm.has(B))continue;if(!z.trim())continue;let V=T.index+T[0].indexOf(T[2],T[0].indexOf(B)+B.length)+1;if(cm.has(F)){let G=z.match(/\s+(?:in|of)\s+/);if(!G||G.index===void 0)continue;let J=z.slice(G.index+G[0].length),ne=G.index+G[0].length+(J.length-J.trimStart().length);k.push({code:tm(J.trim()),line:Di(_,V+ne),column:Mi(_,V+ne),offset:V+ne,kind:"directive",attribute:F});continue}let H=z.length-z.trimStart().length;k.push({code:tm(z.trim()),line:Di(_,V+H),column:Mi(_,V+H),offset:V+H,kind:"directive",attribute:F})}return k.sort((B,z)=>B.line-z.line||B.column-z.column),k}var Fw=2000;function Ww(v,_){let k=0,E=Math.min(v.length,_+Fw);for(let T=_;T<E;T++){let j=v[T];if(j==="(")k++;else if(j===")"){if(k--,k===0)return v.slice(_+1,T)}}return null}function Vw(v){let _=new Map,k=(z,F)=>{let V=z.split(/[,[\]{}()\s]+/).filter(Boolean);for(let H of V){let G=H.replace(/^\.\.\./,"").trim();if(!/^\$?[A-Z_$][\w$]*$/i.test(G))continue;let J=V.length===1?F:void 0,ne=_.get(G);if(!ne)_.set(G,{name:G,iterable:J});else if(ne.iterable!==J)ne.iterable=void 0}},E=/^\$?[A-Z_$][\w$]*$/i,T=(z)=>{let F=z.trim();return E.test(F)?F:void 0};for(let z of v.matchAll(/@for(?:each|else)\s*\(/g)){let F=Ww(v,z.index+z[0].length-1);if(F===null)continue;let V=Ct(F);if(!V)continue;k(V.itemVar.replace(/=>/g," "),T(V.arrayExpr))}for(let z of v.matchAll(/@for\s*\(\s*(?:(?:let|const|var)\s+)?([\w$]+|\[[^\]]*\]|\{[^}]*\})\s+(of|in)\s+([^)]*)/g))k(z[1],z[2]==="of"?T(z[3]):void 0);for(let z of v.matchAll(/@for\s*\(\s*(?:let|const|var)\s+([\w$]+)\s*[=;]/g))k(z[1]);let j=Mo(v);Oo.lastIndex=0;let B;while((B=Oo.exec(j))!==null){let z=B[1].replace(/\..*$/,"");if(!cm.has(z))continue;let F=B[3].match(/\s+(?:in|of)\s+/);if(!F||F.index===void 0)continue;k(B[3].slice(0,F.index),T(B[3].slice(F.index+F[0].length)))}for(let z of v.matchAll(/@(?:php|js|ts)\b([\s\S]*?)@end(?:php|js|ts)\b/g))for(let F of z[1].matchAll(/\b(?:const|let|var|function|class)\s+([\w$]+)/g))k(F[1]);return[..._.values()].sort((z,F)=>z.name.localeCompare(F.name))}function Q(v){let _=new Set;for(let k of v.matchAll(/^\s*(?:export\s+)?(?:const|let|var)\s+([\w$]+)/gm))_.add(k[1]);for(let k of v.matchAll(/^\s*(?:export\s+)?(?:async\s+)?function\s*\*?\s*([\w$]+)/gm))_.add(k[1]);for(let k of v.matchAll(/^\s*(?:export\s+)?class\s+([\w$]+)/gm))_.add(k[1]);for(let k of v.matchAll(/^\s*(?:export\s+)?(?:const|let|var)\s*[[{]([^\]}]*)[\]}]/gm))for(let E of k[1].split(",")){let T=E.split(":").pop().split("=")[0].replace(/^\.\.\./,"").trim();if(/^[A-Z_$][\w$]*$/i.test(T))_.add(T)}return[..._].sort()}var Dl=["params","query","cookies","host","ip","setResponseStatus","setResponseHeader","notFound","request","url","definePageMeta","defineClientPayload","defineStore","props","$props"],Uw={$bool:"declare function $bool(value: unknown, fallback?: boolean): boolean",$num:"declare function $num(value: unknown, fallback?: number): number",$uid:"declare var $uid: string"};function ti(v=new Set){return[...Dl.filter((_)=>!v.has(_)).map((_)=>`declare var ${_}: any`),...Object.entries(Uw).filter(([_])=>!v.has(_)).map(([,_])=>_)].join(`
|
|
2055
|
+
`)}function ni(v){return new Set([...v.matchAll(/^declare (?:function|const|let|var)\s+([A-Za-z_$][\w$]*)/gm)].map((_)=>_[1]))}function um(v){let _=/\bdefineClientPayload\s*\(\s*\{([\s\S]*?)\}\s*\)/g,k,E=!1,T=new Set,j=s(v);while((k=_.exec(j))!==null){E=!0;for(let B of Hw(k[1])){let z=B.split(":")[0].trim();if(/^[A-Za-z_$][\w$]*$/.test(z))T.add(z)}}return E?[...T]:null}function Hw(v){let _=[],k=0,E="";for(let T of v){if(T===","&&k===0){_.push(E),E="";continue}if(T==="("||T==="["||T==="{")k++;else if(T===")"||T==="]"||T==="}")k--;E+=T}return _.push(E),_.filter((T)=>T.trim().length>0)}function qw(v){let _=/^[ \t]*import\b[\s\S]*?(?:from\s*['"][^'"]*['"]|['"][^'"]*['"])[ \t]*;?[ \t]*$/gm,k=[],E=v.replace(_,(T)=>(k.push(T.trim()),T.split(`
|
|
2056
|
+
`).map(()=>"").join(`
|
|
2057
|
+
`)));return{imports:k.join(`
|
|
2058
|
+
`),body:E}}function dm(v){let _=s(v),k=Array(_.length),E=0;for(let z=0;z<_.length;z++){let F=_[z];if(F==="}"||F===")"||F==="]")E=Math.max(0,E-1);if(k[z]=E,F==="{"||F==="("||F==="[")E++}let T=[],j=/^[ \t]*(?:export[ \t]+)?(interface|type)[ \t]+([A-Za-z_$][\w$]*)/gm,B;while((B=j.exec(_))!==null){if(k[B.index]!==0)continue;let z=B[1],F=B[2],V;if(z==="interface"){let H=_.indexOf("{",B.index);if(H===-1)continue;let G=0;V=-1;for(let J=H;J<_.length;J++)if(_[J]==="{")G++;else if(_[J]==="}"&&--G===0){V=J+1;break}if(V===-1)continue}else{let H=0;V=_.length;for(let G=_.indexOf("=",B.index)+1;G<_.length;G++){let J=_[G];if(J==="{"||J==="["||J==="("||J==="<")H++;else if(J==="}"||J==="]"||J===")"||J===">")H--;else if(H<=0&&(J===";"||J===`
|
|
2059
|
+
`&&!/[=|&,<([{]\s*$/.test(_.slice(Math.max(0,G-40),G)))){V=J===";"?G+1:G;break}}}T.push({name:F,text:v.slice(B.index,V).replace(/^[ \t]*export[ \t]+/,"")}),j.lastIndex=V}return T}function Kw(v){return new Set(dm(v).map((_)=>_.name))}function ri(v,_=""){let k=um(v),E=Kw(_),T=dm(v).filter((V)=>!E.has(V.name)).map((V)=>V.text);if(!k){let V=Q(v).filter((H)=>!Vi(_,H));if(V.length===0&&T.length===0)return"";return["",`// ${Zw}`,...T,...V.map((H)=>`declare var ${H}: any`)].join(`
|
|
2060
|
+
`)}if(k.length===0)return T.length>0?["",`// ${rm}`,...T].join(`
|
|
2061
|
+
`):"";let{imports:j,body:B}=qw(v),z=B.replace(/^[ \t]*export[ \t]+(?=(?:const|let|var|function|async|class)\b)/gm,""),F=["",`// ${rm}`];if(j)F.push(j);return F.push(...T),F.push(`async function ${sm}() {`,z,` return { ${k.join(", ")} }`,"}",`type ${im} = Awaited<ReturnType<typeof ${sm}>>`,...k.map((V)=>`declare var ${V}: ${im}[${JSON.stringify(V)}]`)),F.join(`
|
|
2062
|
+
`)}function Xw(v){let k=s(v).split(""),E=0;for(let T=0;T<k.length;T++){let j=k[T];if(j==="{"||j==="("||j==="["){E++;continue}if(j==="}"||j===")"||j==="]"){E=Math.max(0,E-1);continue}if(E>0&&j!==`
|
|
2063
|
+
`)k[T]=" "}return Q(k.join(""))}function si(v,_){if(um(v)!==null)return[];let k=s(_),E=new Set(y);return Xw(v).filter((T)=>{if(E.has(T))return!1;if(Q(_).includes(T))return!1;return new RegExp(`(?<![.#\\w$])${T}(?![\\w$])`).test(k)})}var rm="stx: types for the declared client payload (#1868)",Zw="stx: untyped bridge names \u2014 declare a defineClientPayload to check these (#1868)",sm="__stxServerScope",im="__StxClientPayload";var om=["$env","$user","$slot","$slots","$attrs","$props","$page","$route","$loop","loop","$errors","$csrf","props","slot"];var Gw=/^\s*[A-Z_$][\w$]*\s*=[^=]/i;function Jw(v){let _=new Map,k=/!|===|!==|==|!=|&&|\|\||<|>|\btypeof\b|\binstanceof\b|\bin\b/;for(let E of v){let T=s(E),{depths:j,balanced:B}=be(T);if(!B)continue;let z=/^([ \t]*(?:export[ \t]+)?const[ \t]+)([A-Za-z_$][\w$]*)[ \t]*(?::[^=\n]+)?=[ \t]*([^\n]+)$/gm;for(let F of T.matchAll(z)){let V=F.index??0;if(j[V+F[1].length]!==0)continue;let H=F[2],G=V+F[0].length-F[3].length,J=E.slice(G,V+F[0].length).trim().replace(/;$/,"").trim(),ne=F[3],re=k.test(ne)&&!/\bawait\b|=>|\bfunction\b|[{}]/.test(ne)&&!/[,+\-*/%&|?:=]$/.test(J)&&be(ne).balanced;_.set(H,_.has(H)||!re?null:J)}}return new Map([..._].filter((E)=>E[1]!==null))}function fm(v,_,k=0,E=new Set){if(_.size===0||k>=5)return v;let T=s(v),j="",B=0;for(let z of T.matchAll(/[A-Za-z_$][\w$]*/g)){let F=z.index??0,V=z[0],H=_.get(V);if(!H||E.has(V))continue;let G=T.slice(0,F).trimEnd(),J=T.slice(F+V.length).trimStart();if(G.endsWith(".")||/^:(?!:)/.test(J)&&/[{,]$/.test(G))continue;if(F>0&&/[\w$]/.test(T[F-1]))continue;j+=`${v.slice(B,F)}(${fm(H,_,k+1,new Set([...E,V]))})`,B=F+V.length}return j+v.slice(B)}function Yw(v,_){let k=/@(if|unless|elseif|else|endif|endunless)\b\s*(\()?/g,E=[],T;while((T=k.exec(v))!==null){if(T.index>_)break;let j=T[1];if(T.index===_){if(j==="elseif"){let z=E[E.length-1];if(z?.current)z.seen.push(z.current);if(z)z.current=null}break}if(j==="endif"||j==="endunless"){E.pop();continue}let B="";if(T[2]==="("){let z=0,F=T.index+T[0].length-1,V=F+1;for(;F<v.length;F++){let H=v[F];if(H==="(")z++;else if(H===")"){if(z--,z===0)break}}B=v.slice(V,F).trim(),k.lastIndex=F+1}if(j==="if")E.push({seen:[],current:B});else if(j==="unless")E.push({seen:[],current:`!(${B})`});else if(j==="elseif"||j==="else"){let z=E[E.length-1];if(!z)continue;if(z.current)z.seen.push(z.current);z.current=j==="elseif"?B:null}}return E.flatMap((j)=>[...j.seen.map((B)=>`!(${B})`),...j.current?[j.current]:[]]).filter(Boolean)}function Qw(v){let _=v.code.trim();if(!_)return null;if(v.attribute?.startsWith("@")){if(Gw.test(_))return null;let E=";(($event: any): void => { ";return{text:`${E}${_} });`,prefixLength:E.length}}let k=";void ((";return{text:`${k}${_}));`,prefixLength:k.length}}var eS=/(\bfrom\s*|\bimport\s*\(\s*|\bimport\s+)(['"])(\.{1,2}\/[^'"\n]*)\2/g;function Un(v,_){if(!_)return v;return v.replace(eS,(k,E,T,j)=>{let B=am.resolve(_,j).replace(/\\/g,"/");return`${E}${T}${B}${T}`})}function bs(v){return" ".repeat(Math.max(0,(v.startColumn??1)-1))}function tS(v){let _=new Set,k=s(v);for(let E of k.matchAll(/\bimport\s+(?:type\s+)?([\w$*{}\s,]+?)\s+from\b/g)){let T=E[1],j=/\{([^}]*)\}/.exec(T);for(let V of j?.[1].split(",")??[]){let H=V.trim().replace(/^type\s+/,"").split(/\s+as\s+/).pop()?.trim();if(H&&/^[A-Z_$][\w$]*$/i.test(H))_.add(H)}let B=T.replace(/\{[^}]*\}/,""),z=/\*\s*as\s+([A-Z_$][\w$]*)/i.exec(B);if(z)_.add(z[1]);let F=/^\s*([A-Z_$][\w$]*)/i.exec(B);if(F&&F[1]!=="type")_.add(F[1])}return[..._].sort()}function oi(v,_={}){let k=He(v),E=v.split(`
|
|
2064
|
+
`),T=Array.from({length:E.length},()=>""),j=new Map,B=_.filePath&&_.templateExpressions!==!1?Yg(v,Mo(v),{filePath:_.filePath,componentsDir:_.componentsDir,projectRoot:_.projectRoot,readComponent:_.readComponent,scriptCode:(G,J)=>He(G).map((ne)=>Un(ne.code,am.dirname(J))).join(`
|
|
2065
|
+
`)}):void 0,z=new Set,F=[];for(let G of k){let J=ys(hs(G.code)),ne=Un(J,_.originDir??"").split(`
|
|
2066
|
+
`);ne.forEach((re,se)=>{let ie=G.startLine-1+se;if(ie<T.length)T[ie]=se===0?bs(G)+re:re,z.add(ie)}),F.push(G.startLine-1+ne.length-1)}for(let G of F){let J=T[G]?.trim()===""?G:G+1;if(J<T.length&&T[J].trim()===""&&(J===G||!z.has(J)))T[J]=";"}let V=(G,J)=>{for(let[ne,re]of G.split(`
|
|
2067
|
+
`).entries())if(T.push(re),J)j.set(T.length,ne===0?J:{...J,line:J.line+ne,column:1,prefixLength:0})};if(_.globals!==!1){V("");let G=new Set([...k.flatMap((se)=>Q(se.code)),...k.flatMap((se)=>tS(se.code))]),J=(se)=>{if(!G.has(se))V(`declare var ${se}: any`)};if(_.runtimeGlobals!==!1){if(!G.has("window"))V("declare var window: any");for(let se of y)J(se)}let ne=[...new Set([...Dl,...W,...om])].filter((se)=>_.runtimeGlobals!==!1||!y.includes(se));if(_.contextScope==="global"){V("declare global {");for(let se of ne)V(` var ${se}: any`);V("}")}else{for(let se of Dl)J(se);for(let se of W)J(se);for(let se of om)J(se)}V(`declare var ${Pl}: any`);let re=new Set(k.flatMap((se)=>Q(se.code)));V(`type ${em}<T> = T extends readonly (infer E)[] ? E : T extends Iterable<infer E2> ? E2 : any`);for(let se of Vw(v)){if(re.has(se.name))continue;let ie=se.iterable&&re.has(se.iterable)?`${em}<typeof ${se.iterable}>`:"any";V(`declare var ${se.name}: ${ie}`)}}if(_.templateExpressions!==!1){if(B?.declarations)for(let J of B.declarations.split(`
|
|
2068
|
+
`))V(J);let G=mc(v).map((J)=>{let ne=B?.events.get(J.offset??-1);if(ne){J.anchor=!0;let re=J.code.trim(),se=/^([\w$]+)\s*=\s*([^=][\s\S]*)$/.exec(re),ie=se?`void ((${se[2]}) satisfies __StxAssignedValue<typeof ${se[1]}>)`:/^[\w$]+(?:\.[\w$]+)*$/.test(re)?`${re} satisfies (($event: ${ne}) => unknown)`:re,oe=`;(($event: ${ne}): void => { `;return{expression:J,statement:{text:`${oe}${ie} });`,prefixLength:oe.length}}}return{expression:J,statement:Qw(J)}}).filter((J)=>J.statement!==null);if(G.push(...B?.checks||[]),G.length>0){let J=Mo(v),ne=Jw(k.map((oe)=>oe.code)),se=[...new Set(k.flatMap((oe)=>Q(oe.code)))].filter((oe)=>/^[A-Z_$][\w$]*$/i.test(oe)),ie=0;if(se.length>0){V(Lw);for(let oe of se)V(`type __StxT_${oe} = ${lm}<typeof ${oe}>`);V(`;((${se.map((oe)=>`${oe}: __StxT_${oe}`).join(", ")}) => {`),ie=1}for(let{expression:oe,statement:ge}of G){let ue=" ".repeat(ie),xe=oe.offset===void 0?[]:Yw(J,oe.offset),we=xe.length>0?`${xe.map((_e)=>`if (${fm(_e,ne)}) `).join("")}{ `:"",$e=xe.length>0?" }":"";V(ue+we+ge.text+$e,{line:oe.line,column:oe.column,expression:oe,prefixLength:ge.prefixLength+ue.length+we.length,guardPrefixLength:ue.length+we.length})}if(ie>0)V("});")}}let H=!1;if(_.reference&&T[0]!==void 0&&T[0].trim()==="")T[0]=`/// <reference path=${JSON.stringify(_.reference.replace(/\\/g,"/"))} />`,H=!0;return V("export {}"),{text:T.join(`
|
|
2069
|
+
`),lineMap:j,sourceLineCount:E.length,componentDependencies:B?.dependencies,referenced:H}}function ii(v,_){if(!v.expression)return!1;return v.inGuard===!0||_===2774}function ai(v,_,k){let E=v.lineMap.get(_);if(!E)return _<=v.sourceLineCount?{line:_,column:k}:null;let T=E.expression?.anchor?0:Math.max(0,k-1-(E.prefixLength??0));return{line:E.line,column:E.column+T,expression:E.expression,inGuard:k<=(E.guardPrefixLength??0)}}var nS=[{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"}],rS=[{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')"}],sS=[{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 hc(v){let _=[],k=[];return iS(v,_),oS(v,_,k),aS(v,k),cS(v,_),{valid:_.length===0,errors:_,warnings:k}}function iS(v,_){let k=(v.match(/\{\{/g)||[]).length,E=(v.match(/\}\}/g)||[]).length;if(k!==E)_.push({type:"expression",message:`Unclosed expression brackets: found ${k} opening '{{' and ${E} closing '}}'`,suggestion:"Ensure every {{ has a matching }}"})}function oS(v,_,k){for(let E of nS){let T=new RegExp(`${E.open}(?:\\s|\\()`,"g"),j=new RegExp(E.close,"g"),B=(v.match(T)||[]).length,z=(v.match(j)||[]).length;if(E.altClose){let F=new RegExp(E.altClose,"g");z+=(v.match(F)||[]).length}if(B>z)_.push({type:"directive",message:`Unclosed @${E.name} directive: found ${B} opening and ${z} closing`,suggestion:`Add ${B-z} missing ${E.close} tag(s)`});else if(z>B)k.push({type:"directive",message:`Extra ${E.close} found: ${z-B} more closing than opening`,suggestion:`Check for orphaned ${E.close} tags`})}}function aS(v,_){for(let k of rS)if(k.pattern.test(v))_.push({type:"syntax",message:k.message,suggestion:k.suggestion})}function cS(v,_){for(let k of sS)if(k.pattern.test(v))_.push({type:"expression",message:`Security warning: ${k.message}`,suggestion:"Remove dangerous code from template expressions"})}function yc(v,_){let k=v.slice(0,_).split(`
|
|
2070
|
+
`);return{line:k.length,column:k[k.length-1].length+1}}function bc(v,_,k){let E=[];switch(v){case"if":case"elseif":case"unless":if(k.length===0)E.push({type:"syntax",message:`@${v} requires a condition`,suggestion:`Use @${v}(condition)`});break;case"foreach":if(k.length===0||!k[0].includes(" as "))E.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(k.length===0)E.push({type:"syntax",message:"@for requires loop parameters",suggestion:"Use @for(let i = 0; i < 10; i++)"});break;case"switch":if(k.length===0)E.push({type:"syntax",message:"@switch requires an expression",suggestion:"Use @switch(expression)"});break;case"case":if(k.length===0)E.push({type:"syntax",message:"@case requires a value",suggestion:"Use @case(value)"});break;case"include":case"extends":case"component":if(k.length===0)E.push({type:"syntax",message:`@${v} requires a path`,suggestion:`Use @${v}('path/to/template')`});break}return E}function wc(v){return/@[a-z]+/i.test(v)||/\{\{/.test(v)}function vc(v){let _=v.matchAll(/@([a-z]+)/gi),k=new Set;for(let E of _){let T=E[1].toLowerCase();if(!T.startsWith("end"))k.add(T)}return Array.from(k)}import Pn from"path";import Ws from"process";var kt=["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"];var pm=new Set(kt),lS=new Set(["props","$props","defineProps"]),uS=new Set(["stx","@stacksjs/stx"]),gm=m(128),mm=m(64);function dS(v){let _=[],k=0,E=v.split(`
|
|
2071
|
+
`);for(let T of E){let j=k,B=null,z=!1;for(let F=0;F<T.length;F++){let V=T[F];if(z){z=!1;continue}if(V==="\\"){z=!0;continue}if(B){if(V===B)B=null;continue}if(V==="'"||V==='"'||V==="`"){B=V;continue}if(V==="/"&&F+1<T.length&&T[F+1]==="/")break;if(V==="{")k++;else if(V==="}")k--}if(j===0){let F=T.match(/(?:const|let|var)\s+(\w+)\s*=/);if(F)_.push(F[1]);else if(/^\s*(?:const|let|var)\s+\w+\s*;?\s*$/.test(T)){let V=T.match(/(?:const|let|var)\s+(\w+)/);if(V)_.push(V[1])}else{let V=T.match(/(?:const|let|var)\s+(\{[^}]+\}|\[[^\]]+\])\s*=/);if(V){let G=V[1].slice(1,-1).split(",").map((J)=>{let ne=J.split(":");return(ne.length>1?ne[1]:ne[0]).trim()}).filter((J)=>/^\w+$/.test(J));_.push(...G)}}}}return[...new Set(_)]}function ac(v){let _=v;_=_.replace(/^\s*import\s+.*?from\s+['"][^'"]+['"]\s*;?\s*$/gm,""),_=_.replace(/^\s*import\s+['"][^'"]+['"]\s*;?\s*$/gm,""),_=_.replace(/^\s*interface\s+\w+\s*\{[\s\S]*?\n\}\s*$/gm,""),_=_.replace(/^\s*type\s+\w+\s*=[\s\S]*?(?=\n(?:const|let|var|function|export|interface|type|$))/gm,""),_=_.replace(/^(\s*(?:export\s+)?(?:const|let|var)\s+)(\w+|\{[^}]+\}|\[[^\]]+\])\s*:\s*[^=]+(\s*=)/gm,"$1$2$3");function k(E){if(!E.includes(":"))return E;let T=[],j="",B=0,z=0,F=null;for(let V=0;V<E.length;V++){let H=E[V];if(F){if(j+=H,H===F)F=null;continue}if(H==='"'||H==="'"||H==="`"){F=H,j+=H;continue}if(H==="<")B++;else if(H===">"&&B>0)B--;else if(H==="(")z++;else if(H===")")z--;if(H===","&&B===0&&z===0){T.push(j),j="";continue}j+=H}if(j)T.push(j);return T.map((V)=>{let H=V.trim(),G=H.startsWith("..."),J=G?H.slice(3):H,ne=-1,re=0;for(let we=0;we<J.length;we++)if(J[we]==="<")re++;else if(J[we]===">")re--;else if(J[we]===":"&&re===0){ne=we;break}if(ne===-1)return V;let ie=J.substring(0,ne).trim().replace(/\?$/,""),oe=J.substring(ne+1),ge=-1,ue=0;for(let we=0;we<oe.length;we++)if(oe[we]==="<")ue++;else if(oe[we]===">")ue--;else if(oe[we]==="="&&ue===0){ge=we;break}let xe=G?"...":"";if(ge!==-1)return`${xe}${ie} = ${oe.substring(ge+1).trim()}`;return`${xe}${ie}`}).join(", ")}_=_.replace(/\b(function\s+\w*\s*)\(([^)]*)\)/g,(E,T,j)=>{if(!j.includes(":"))return E;return`${T}(${k(j)})`});{let E=/\b(function\s+\w*\s*)\(/g,T,j=[];while((T=E.exec(_))!==null){let B=T.index+T[0].length-1,z=1,F=B+1,V=0,H=null;while(F<_.length&&z>0){let ne=_[F];if(H){if(ne===H)H=null;F++;continue}if(ne==='"'||ne==="'"||ne==="`"){H=ne,F++;continue}if(ne==="<")V++;else if(ne===">"&&V>0)V--;else if(V===0){if(ne==="(")z++;else if(ne===")")z--}if(z>0)F++}if(z!==0)continue;let G=_.substring(B+1,F);if(!G.includes(":"))continue;let J=k(G);j.push({start:B+1,end:F,replacement:J})}for(let B=j.length-1;B>=0;B--){let{start:z,end:F,replacement:V}=j[B];_=_.substring(0,z)+V+_.substring(F)}}return _=_.replace(/\(([^)]*)\)\s*(?::\s*[^=]+)?\s*=>/g,(E,T)=>{if(!T.includes(":"))return E;if(T.includes("{")||T.includes("}"))return E;return`(${T.split(",").map((B)=>{let[z,...F]=B.split("="),V=z.split(":")[0].trim();if(F.length>0)return`${V} = ${F.join("=").trim()}`;return V}).join(", ")}) =>`}),_=_.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"),_=_.replace(/(\b(?:function|class|interface|type|extends|implements)\s+\w+)\s*<[^<>()]*>/g,"$1"),_=_.replace(/(\b(?:defineProps|withDefaults|defineEmits|defineSlots|Array|Promise|Map|Set|Record|Partial|Required|Readonly|Pick|Omit|Exclude|Extract))\s*<[^<>()]*>/g,"$1"),_=_.replace(/(\w+)\s*<[A-Z][^<>()]*>\s*(?=\()/g,"$1"),_=_.replace(/\s+as\s+(?:const|[A-Za-z]\w*(?:\[\])?(?:\s*\|\s*\w+(?:\[\])?)*)/g,""),_=_.replace(/\s+satisfies\s+\w+(?:<[^>]*>)?/g,""),_=_.replace(/(\w|\)|\])\s*!(?!=)/g,"$1"),_=_.replace(/^\s*(?:export\s+)?(?:const\s+)?enum\s+\w+\s*\{[^}]*\}\s*$/gm,""),_=_.replace(/(?<=[\s=,(])<[A-Z]\w*(?:\[\])?>/g,""),_=_.replace(/\n\s*\n\s*\n/g,`
|
|
2072
|
+
|
|
2073
|
+
`),_}function cc(v){return v.replace(/\s*(?:imported from|from)\s+(?:(['"])([^'"\r\n]+)\1|(\S+))/g,(_,...k)=>{let[,E,T]=k,j=E??T;return/(?:[/\\]packages[/\\]stx[/\\]|@stacksjs[/\\]stx[/\\])/.test(j)?"":_})}function lc(v){return/cannot find module|cannot find package|could not resolve|module not found|failed to resolve/i.test(v)}function uc(v){if(v instanceof SyntaxError)return!0;let _=v instanceof Error?v.message:String(v);return/SyntaxError|Unexpected (token|identifier|string|number|keyword|end of)|Unterminated|Expected .+ but found/i.test(_)}function dc(v){if(!/is not defined|can't find variable/i.test(v))return!1;return!/\b(document|window|navigator|localStorage|sessionStorage|self)\b/.test(v)}var hm=new Set;async function d(v,_,k,E={}){if(!v.trim())return;let T=w(),j=h(v,JSON.stringify(T)),B=gm.get(j);if(B===void 0){try{let De=L({loader:"ts",target:"browser",define:T}),Je=v.replace(/^\s*import\s+\w+\s+from\s+['"][^'"]*\.stx['"]\s*;?\s*$/gm,"");Je=Je.replace(/^\s*import\s+['"][^'"]*\.stx['"]\s*;?\s*$/gm,""),B=De.transformSync(Je)}catch{B=ac(v)}gm.set(j,B)}let z={exports:{}},F=z.exports,V=Ws.cwd(),H={},G=[...B.matchAll(/require\s*\(\s*['"]([^'"]+)['"]\s*\)/g)||[]].map((De)=>De[1]).filter((De)=>!De.startsWith("node:")&&!["fs","path","os","child_process","crypto","http","https","url","util","stream","events","buffer","net","querystring","zlib","tls"].includes(De)),J=new Map;for(let De of G)try{if(De.startsWith(".")){H[De]=await import(Pn.resolve(Pn.dirname(k),De));continue}let Je=Pn.resolve(V,"node_modules",De),st=Pn.join(Je,"package.json"),mt=JSON.parse(u("fs").readFileSync(st,"utf8")),At=mt.main||"index.js";if(mt.exports){let Kt=typeof mt.exports==="string"?mt.exports:mt.exports["."];if(typeof Kt==="string")At=Kt;else if(Kt?.bun)At=Kt.bun;else if(Kt?.import)At=Kt.import;else if(Kt?.default)At=Kt.default}H[De]=await import(Pn.resolve(Je,At))}catch(Je){if(De.startsWith("."))J.set(De,Je instanceof Error?Je.message:String(Je))}let ne=(De)=>{if(H[De])return H[De];let Je=J.get(De);if(Je!==void 0)throw Error(`Cannot require '${De}' from ${k}: ${Je}`);return u(De)},re=_.props||{},se=(De)=>{if(!De)return re;let Je={};for(let[st,mt]of Object.entries(De)){let At=re[st];if(At!==void 0)Je[st]=At;else if(typeof mt==="function")Je[st]=mt();else Je[st]=mt}return Je};for(let[De,Je]of Object.entries(re))Object.defineProperty(se,De,{value:Je,enumerable:!0,configurable:!0,writable:!0});let ie=(De,Je=!1)=>{if(De===void 0||De===null)return Je;if(typeof De==="string"){let st=De.trim().toLowerCase();if(st===""||st==="true"||st==="1"||st==="on"||st==="yes")return!0;if(st==="false"||st==="0"||st==="off"||st==="no")return!1;return!0}return Boolean(De)},oe=(De,Je=0)=>{if(De===void 0||De===null)return Je;if(typeof De==="string"){let mt=De.trim();if(mt==="")return Je;let At=Number(mt);return Number.isFinite(At)?At:Je}let st=Number(De);return Number.isFinite(st)?st:Je};for(let De of["name","length","caller","arguments"]){if(Object.prototype.hasOwnProperty.call(re,De))continue;try{Object.defineProperty(se,De,{value:void 0,enumerable:!1,configurable:!0,writable:!0})}catch{}}let ge=(De)=>{if(!De)return re;let Je={...re};for(let[st,mt]of Object.entries(De)){let At=mt&&typeof mt==="object"&&!Array.isArray(mt)?mt:{type:mt};if(Je[st]===void 0&&At.default!==void 0)Je[st]=typeof At.default==="function"?At.default():At.default}return Je},ue=()=>_.slots||{},xe=(De,Je)=>{let st={...De};for(let[mt,At]of Object.entries(Je))if(st[mt]===void 0)if(typeof At==="function")st[mt]=At();else st[mt]=At;return st},we=(De)=>{let Je=()=>De;return Je.set=(st)=>{},Je.update=(st)=>{},Je},$e=(De)=>{let Je,st=!1;return()=>{if(!st)try{Je=De(),st=!0}catch{Je=void 0}return Je}},_e=(De)=>{},Ce=(De)=>De(),Ee=(De)=>{},Te=(De)=>{},Re=Ln(_);function ke(De){let Je=De||{};if(Je.title!==void 0||Je.description!==void 0)Ze({title:Je.title,description:Je.description})}function Ae(De){if(!De||typeof De!=="object")return;let Je=_.__stxClientPayload??{};Object.assign(Je,De),_.__stxClientPayload=Je}let Xe=()=>{let De=_.__stxServeContext,Je=_.__stxServeSearch??De?.search??"",st=De?.path??"",mt=Object.fromEntries(new URLSearchParams(Je)),At=_.query,Kt=Object.keys(mt).length>0?mt:At??{},_n=Je||(Object.keys(Kt).length>0?`?${new URLSearchParams(Kt).toString()}`:"");return{params:_.params??{},query:Kt,path:st,name:"",fullPath:st+_n,hash:"",matched:[]}},Pe=()=>({push:(De)=>{},replace:(De)=>{},back:()=>{},forward:()=>{},go:(De)=>{}}),Ie=(De)=>{let Je=_.__stx_runtime_head||{};_.__stx_runtime_head=pe(Je,de(De||{},{known:tr,source:"useHead()"}))},Ze=(De)=>{Ie(nr(De||{}))},nt=(De)=>({value:De}),at=(De)=>De,rt=(De)=>({value:typeof De==="function"?De():De}),bt=(De,Je)=>{},ft=(De)=>{},yt=(De)=>{},ct=(De)=>De?De():Promise.resolve(),Pt=(De)=>(Je,...st)=>{},pt=(De)=>{},Lt=(De,Je)=>{},Qn=(De,Je)=>Je,Sn=()=>({value:"light"}),er=()=>we(!1),et=(De)=>we(!1),it=()=>we(!1),gt=()=>et("(prefers-color-scheme: dark)"),qt=()=>et("(prefers-color-scheme: light)"),Dt=()=>et("(prefers-reduced-motion: reduce)"),xn=()=>et("(prefers-contrast: more)"),Nt={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:{}},ua=new Proxy(Nt,{get(De,Je){if(Je in De)return De[Je];return},set(De,Je,st){return De[Je]=st,!0}}),da={getElementById:()=>null,querySelector:()=>null,querySelectorAll:()=>[],createElement:()=>({}),createTextNode:()=>({}),body:{},head:{},documentElement:{},addEventListener:()=>{},removeEventListener:()=>{}},fa=console;try{let De=is(B,k),Je=new Set(Object.keys(re)),st=Object.keys(_).filter((lt)=>!Je.has(lt)&&!lS.has(lt)&&Ye(lt)),mt=st.map((lt)=>_[lt]);if(!st.includes("__stxServeContext"))st.push("__stxServeContext"),mt.push(void 0);let At=new Set(["async","module","exports","require","params","window","document","console","state","derived","effect"]),Kt=[],_n=[];for(let[lt,kn]of Object.entries(re)){if(!Ye(lt))continue;if(At.has(lt))continue;if(new RegExp(`(?:^|[\\s;{])(?:const|let|var|function)\\s+${lt}\\b`).test(De))continue;Kt.push(lt),_n.push(kn)}let dr=dS(De).map((lt)=>`module.exports.${lt} = typeof ${lt} !== 'undefined' ? ${lt} : module.exports.${lt};`).join(`
|
|
2074
|
+
`),Gt=_.params??{},tt=[],ot=[];for(let lt=0;lt<st.length;lt++){if(st[lt]==="params")continue;tt.push(st[lt]),ot.push(mt[lt])}let _t=[...kt,...Kt,...tt],dt=`return (async () => {
|
|
2075
|
+
${De}
|
|
2076
|
+
${dr}
|
|
2077
|
+
return module.exports
|
|
2078
|
+
})()`,Wt=h(dt,_t.join("\x00")),Mt=mm.get(Wt);if(!Mt)Mt=Function(..._t,dt),mm.set(Wt,Mt);let Jt=_.__stx_options?.runtimeConfig;if(Jt||/\buse(?:Server)?RuntimeConfig\b/.test(B))await cn(_,k,Jt);let ir=await le(_.__stx_runtime_config??Et()??C(),()=>eg(_,()=>Mt(z,F,ne,re,se,ie,oe,ge,xe,Ae,tg,Ss,Jn,we,$e,_e,Ce,Ee,Te,ke,Xe,Pe,Ie,Ze,Re.setResponseStatus,Re.setResponseHeader,Re.notFound,nt,at,rt,bt,ft,yt,ct,Pt,pt,ue,Lt,Qn,Sn,er,et,it,gt,qt,Dt,xn,ua,da,fa,Nt.confirm,Nt.alert,Nt.fetch,Gt,..._n,...ot)));if(E.preserveExisting){for(let[lt,kn]of Object.entries(ir))if(!(lt in _)||_[lt]===void 0)_[lt]=kn}else Object.assign(_,ir);for(let[lt,kn]of Object.entries(re))if(!(lt in _))_[lt]=kn}catch(De){if(_.__stx_strict_hydration)throw De;let Je=cc(De instanceof Error?De.message:String(De));if(lc(Je))console.warn(`[stx] server <script> in ${k??"<unknown>"} imports a module that does not resolve, so every variable in that script is undefined. Cause: ${Je}`),E.onFailure?.({kind:"module-resolution",message:Je,error:De});else if(uc(De))console.warn(`[stx] server <script> in ${k??"<unknown>"} does not parse, so every variable in that script is undefined. Cause: ${Je}`),E.onFailure?.({kind:"syntax",message:Je,error:De});else if(dc(Je))console.warn(`[stx] server <script> in ${k??"<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: ${Je}`),E.onFailure?.({kind:"missing-binding",message:Je,error:De});else{let st=`${k??"<unknown>"}\x00${Je}`;if(Ws.env.STX_DEBUG||!hm.has(st))hm.add(st),console.warn(`[stx] server <script> in ${k??"<unknown>"} threw, so every variable in that script is undefined and anything that reads one renders empty. Cause: ${Je}`);E.onFailure?.({kind:"unknown",message:Je,error:De})}try{await yS(B,_,k)}catch(st){if(Ws.env.STX_DEBUG){let mt=st instanceof Error?st.message:String(st);console.warn(`[stx] fallback extraction also failed in ${k??"<unknown>"}: ${mt}`)}}}}function pc(v){let _=0,k=null,E=!1,T=!1;for(let j=0;j<v.length;j++){let B=v[j];if(k){if(B===k){if(k=null,E||_===0)T=!0}continue}if(B==="'"||B==='"'||B==="`"){k=B;continue}if(B==="{")_++;else if(B==="}")_--;else if(v.startsWith("from",j)&&_===0)E=!0}return k===null&&_===0&&T}var fS=/^(?:export\s+)?(?:const|let|var)\s+[A-Za-z_$][\w$]*(?:\s*,\s*[A-Za-z_$][\w$]*)*\s*;?$/;function is(v,_){let k=_?Pn.dirname(_):Ws.cwd(),E=Ws.cwd(),T=v.split(`
|
|
2079
|
+
`),j=[],B=0;while(B<T.length){let z=T[B].trim();if(z.startsWith("interface ")||z.startsWith("export interface ")||z.startsWith("type ")||z.startsWith("export type ")){if(z.includes("{")&&!z.includes("}")){let F=0;for(;B<T.length;B++){for(let V of T[B])if(V==="{")F++;else if(V==="}")F--;if(F<=0)break}}B++;continue}if(z.startsWith("definePageMeta(")){let F=0,V=!1,H=B;for(let ne=B;ne<T.length&&!V;ne++){let re=null,se=!1,ie=T[ne];for(let oe=0;oe<ie.length;oe++){let ge=ie[oe];if(se){se=!1;continue}if(ge==="\\"){se=!0;continue}if(re){if(ge===re)re=null;continue}if(ge==='"'||ge==="'"||ge==="`"){re=ge;continue}if(ge==="(")F++;else if(ge===")"){if(F--,F===0){B=ne+1,V=!0;break}}}}if(!V)B=T.length;let G=T.slice(H,B).join(`
|
|
2080
|
+
`),J=[];for(let ne of["title","description"]){let re=new RegExp(`\\b${ne}\\s*:\\s*(['"\`])((?:\\\\.|(?!\\1)[^\\\\])*)\\1`).exec(G);if(re)J.push(`${ne}: ${JSON.stringify(re[2])}`)}if(J.length>0)j.push(`useSeoMeta({ ${J.join(", ")} });`);continue}if(z.startsWith("import ")||z==="import"||z.startsWith("import{")){let F=z,V=0;while(!pc(F)&&B+V+1<T.length)V++,F=`${F} ${T[B+V].trim()}`;B+=V;let H=F.match(/^import\s+(\w+)\s+from\s+['"](.+?)['"]/),G=F.match(/^import\s+\{([^}]*)\}\s+from\s+['"](.+?)['"]/),J=F.match(/^import\s+['"](.+?)['"]/),ne=F,re=(se)=>{if(se.startsWith("."))return Pn.resolve(k,se);if(se.startsWith("~/")||se.startsWith("@/"))return Pn.resolve(E,se.slice(2));return se};if(H){let[,se,ie]=H,oe=re(ie);j.push(`const ${se} = (await import('${oe}')).default`),j.push(`module.exports.${se} = ${se};`)}else if(G){let[,se,ie]=G,oe=re(ie),ge=[],ue=[],xe=uS.has(ie);for(let we of se.split(",")){let $e=we.trim();if(!$e)continue;let _e=$e.split(/\s+as\s+/);if(_e.length===2){let[Ce,Ee]=[_e[0].trim(),_e[1].trim()];if(xe&&pm.has(Ce)){j.push(`const ${Ee} = ${Ce};`);continue}ge.push(`${Ce}: ${Ee}`),ue.push(Ee)}else{if(xe&&pm.has($e))continue;ge.push($e),ue.push($e)}}if(ge.length>0)j.push(`const { ${ge.join(", ")} } = await import('${oe}')`);for(let we of ue)j.push(`module.exports.${we} = ${we};`)}else if(J){let se=re(J[1]);j.push(`await import('${se}')`)}else j.push(ne);B++;continue}if(fS.test(z))j.push(T[B]),B++;else if(z.startsWith("export const ")||z.startsWith("export let ")||z.startsWith("export var ")){let F=xm(T,B),{type:V,name:H,value:G}=F;j.push(`${V} ${H} = ${G};`),j.push(`module.exports.${H} = ${H};`),B=F.nextIndex}else if(z.startsWith("export function ")||z.startsWith("export async function ")){let F=Ml(T,B);j.push(F.functionCode),j.push(`module.exports.${F.name} = ${F.name};`),B=F.nextIndex}else if(z.startsWith("const ")||z.startsWith("let ")||z.startsWith("var ")){let F=xm(T,B),{type:V,name:H,value:G}=F;j.push(`${V} ${H} = ${G};`),j.push(`module.exports.${H} = ${H};`),B=F.nextIndex}else if(z.startsWith("function ")||z.startsWith("async function ")){let F=Ml(T,B);j.push(F.functionCode),j.push(`module.exports.${F.name} = ${F.name};`),B=F.nextIndex}else if(z.startsWith("export default function ")||z.startsWith("export default async function ")){let F=T[B].replace(/^(\s*)export\s+default\s+/,"$1"),V=[...T];V[B]=F;let H=Ml(V,B);if(j.push(H.functionCode),H.name)j.push(`module.exports.default = ${H.name};`);B=H.nextIndex}else if(z.startsWith("export default ")){let F=z.replace(/^export\s+default\s+/,"").replace(/;$/,"");j.push(`module.exports.default = ${F};`),B++}else if(z.startsWith("class ")||z.startsWith("export class ")){let F=z.match(/(?:export\s+)?class\s+(\w+)/);if(F){let V=F[1],H=T[B].replace(/^export\s+/,""),G=0,J=B;for(;J<T.length;J++){let ne=T[J];for(let re of ne)if(re==="{")G++;else if(re==="}")G--;if(J>B)H+=`
|
|
2081
|
+
`+ne;if(G<=0&&J>=B)break}j.push(H),j.push(`module.exports.${V} = ${V};`),B=J+1}else j.push(z),B++}else if(z.includes("module.exports"))j.push(z),B++;else if(z.trim()&&!z.startsWith("//"))j.push(z),B++;else B++}return pS(j.join(`
|
|
2082
|
+
`),k,E)}function pS(v,_,k){let E=v.length,T="",j=0,B=null,z=!1,F=!1,V=0;while(j<E){let H=v[j],G=v[j+1];if(z){if(T+=H,H===`
|
|
2083
|
+
`)z=!1;j++;continue}if(F){if(T+=H,H==="*"&&G==="/"){T+=G,j+=2,F=!1;continue}j++;continue}if(!B&&H==="/"&&G==="/"){z=!0,T+=H,j++;continue}if(!B&&H==="/"&&G==="*"){F=!0,T+=H,j++;continue}if(B){if(T+=H,H==="\\"){T+=G,j+=2;continue}if(H===B&&B!=="`"){B=null,j++;continue}if(B==="`"){if(H==="$"&&G==="{"){V++,T+=G,j+=2;continue}if(H==="`"){B=null,j++;continue}}j++;continue}if(V>0){if(H==="{")V++;else if(H==="}")V--}if(H==='"'||H==="'"||H==="`"){B=H,T+=H,j++;continue}if(H==="a"&&v.startsWith("await",j)){let J=gS(v,j);if(J){let{quote:ne,path:re,end:se}=J;if(re.startsWith(".")||re.startsWith("~/")||re.startsWith("@/")){let ie=re.startsWith(".")?Pn.resolve(_,re):Pn.resolve(k,re.slice(2));T+=`await import(${ne}${ie}${ne})`,j=se;continue}}}T+=H,j++}return T}function gS(v,_){let k=_+5;if(k>=v.length)return null;if(!/\s/.test(v[k]))return null;while(k<v.length&&/\s/.test(v[k]))k++;if(!v.startsWith("import",k))return null;k+=6;while(k<v.length&&/\s/.test(v[k]))k++;if(v[k]!=="(")return null;k++;while(k<v.length&&/\s/.test(v[k]))k++;let E=v[k];if(E!=="'"&&E!=='"')return null;k++;let T=k;while(k<v.length&&v[k]!==E)if(v[k]==="\\")k+=2;else k++;if(k>=v.length)return null;let j=v.slice(T,k);k++;while(k<v.length&&/\s/.test(v[k]))k++;if(v[k]!==")")return null;return{quote:E,path:j,end:k+1}}function Sm(v,_){let k=v[_];if(k!=="{"&&k!=="[")return null;let T=S(v,k,k==="{"?"}":"]",_);if(T===-1)return null;return{pattern:v.slice(_,T+1),endPos:T+1}}function $m(v){let _=[],k=v.slice(1,-1).trim();if(!k)return _;let E=0,T=0,j="";while(E<k.length){let B=k[E];if(B==="{"||B==="["){let z=T===0?Sm(k,E):null;if(z){_.push(...$m(z.pattern)),E=z.endPos,j="";continue}T++}else if(B==="}"||B==="]")T--;if(T>0){E++;continue}if(B===","){if(j.trim())_.push(j.trim());j="",E++;continue}if(B===":"){j="",E++;continue}if(B==="="){if(j.trim())_.push(j.trim());j="",E++;while(E<k.length&&k[E]!==","&&T===0){if(k[E]==="{"||k[E]==="[")T++;else if(k[E]==="}"||k[E]==="]")T--;E++}continue}if(/[\w$]/.test(B))j+=B;E++}if(j.trim())_.push(j.trim());return _}function fc(v){let _=/^(?:export\s+)?(const|let|var)\s+([A-Za-z_$][\w$]*)/.exec(v);if(!_)return null;let k=_[0].length,E=(T)=>T===" "||T==="\t";while(k<v.length&&E(v[k]))k++;if(v[k]===":"){let T=0,j=null;k++;for(;k<v.length;k++){let B=v[k];if(j){if(B==="\\"){k++;continue}if(B===j)j=null;continue}if(B==="'"||B==='"'||B==="`"){j=B;continue}if(B==="("||B==="["||B==="{"||B==="<"){T++;continue}if(B===")"||B==="]"||B==="}"||B===">"){T--;continue}if(B==="="&&T<=0){let z=v[k+1],F=v[k-1];if(z!=="="&&z!==">"&&F!=="="&&F!=="!"&&F!=="<"&&F!==">")break}}if(v[k]!=="=")return null}while(k<v.length&&E(v[k]))k++;if(v[k]!=="=")return null;return{type:_[1],name:_[2],value:v.slice(k+1).trim()}}function ym(v,_,k,E){let T=null,j=!1;for(let B of v){if(j){j=!1;continue}if(B==="\\"){j=!0;continue}if(T){if(B===T)T=null;continue}if(B==="'"||B==='"'||B==="`"){T=B;continue}if(B===_)E++;else if(B===k)E--}return E}function xm(v,_){let k=v[_].trim(),E=fc(k),T=E?[k,E.type,E.name,E.value]:null;if(!T){let H=k.match(/^(?:export\s+)?(const|let|var)\s+/);if(H){let G=k.slice(H[0].length),J=_;if(G.startsWith("{")||G.startsWith("[")){let re=G[0],se=re==="{"?"}":"]",ie=ym(G,re,se,0),oe=G;for(let ge=_+1;ge<v.length&&ie>0;ge++)oe+=` ${v[ge].trim()}`,J=ge,ie=ym(v[ge],re,se,ie);if(ie>0)oe=G,J=_;G=oe}let ne=Sm(G,0);if(ne){let re=H[1],se=ne.pattern,ie=G.slice(ne.endPos).trim();if(ie.startsWith("=")){let oe=ie.slice(1).trim(),ge=oe,ue=Math.max(J,_);if(bm(oe)){let _e=vm(v,ue,oe);ge=_e.value,ue=_e.nextIndex}else ue=ue+1;ge=ge.trim().replace(/;$/,"");let xe=$m(se),we=`__stx_src_${_}`,$e=xe.map((_e)=>`module.exports.${_e} = ${_e};`).join(`
|
|
2084
|
+
`);return{type:re,name:we,value:`${ge}; ${re} ${se} = ${we};
|
|
2085
|
+
${$e}`,nextIndex:ue}}}}throw Error(`Failed to parse variable declaration: ${k}`)}let[,j,B,z]=T,F=z,V=_;if(bm(z)){let H=vm(v,_,z);F=H.value,V=H.nextIndex}else V=_+1;while(V<v.length){let H=v[V].trim();if(H.startsWith(".")||H.startsWith("?."))F+=`
|
|
2086
|
+
${v[V]}`,V++;else break}return F=F.trim().replace(/;$/,""),{type:j,name:B,value:F,nextIndex:V}}function Ml(v,_){let k=v[_].trim(),E=k.match(/^(?:export\s+)?(?:async\s+)?function\s+(\w+)/);if(!E)throw Error(`Failed to parse function declaration: ${k}`);let[,T]=E,j=k.replace(/^export\s+/,""),B=_;if(mS(k)){let z=hS(v,_,j);j=z.functionCode,B=z.nextIndex}else B=_+1;return{name:T,functionCode:j,nextIndex:B}}function bm(v){let _=v.trim();if(_.startsWith("{"))return S(_,"{","}",0)===-1;if(_.startsWith("["))return S(_,"[","]",0)===-1;return!_m(_)}function _m(v){let _={paren:0,bracket:0,brace:0},k=null,E=0;for(let T=0;T<v.length;T++){let j=v[T];if((T>0?v[T-1]:"")==="\\"&&k)continue;if((j==='"'||j==="'")&&!k){k=j;continue}if(j===k&&k!=="`"){k=null;continue}if(j==="`"&&!k){k="`";continue}if(j==="`"&&k==="`"&&E===0){k=null;continue}if(k==="`"&&j==="$"&&v[T+1]==="{"){E++,T++;continue}if(E>0&&j==="{"){E++;continue}if(E>0&&j==="}"){E--;continue}if(k)continue;if(j==="(")_.paren++;else if(j===")")_.paren--;else if(j==="[")_.bracket++;else if(j==="]")_.bracket--;else if(j==="{")_.brace++;else if(j==="}")_.brace--}return _.paren===0&&_.bracket===0&&_.brace===0&&k===null}function km(v){let _=v.indexOf("(");if(_===-1)return v.indexOf("{");let k=S(v,"(",")",_);if(k===-1)return-1;return v.indexOf("{",k)}function mS(v){let _=km(v);if(_===-1)return!0;return S(v,"{","}",_)===-1}function vm(v,_,k){let E=k,T=_+1;while(T<v.length&&!_m(E)){let j=v[T];E+=`
|
|
2087
|
+
${j}`,T++}while(T<v.length){let j=v[T].trim();if(j.startsWith(".")||j.startsWith("?."))E+=`
|
|
2088
|
+
${v[T]}`,T++;else break}return{value:E,nextIndex:T}}function hS(v,_,k){let E=k,T=_+1;while(T<v.length){let j=km(E);if(j!==-1){if(S(E,"{","}",j)!==-1)break}let B=v[T];E+=`
|
|
2089
|
+
${B}`,T++}return{functionCode:E,nextIndex:T}}function wm(v,_){let k=c(v,_)??c(`(${v})`,_);if(k!==void 0)return k;if(!/\bprocess\b/.test(v))return;let E={..._,process:Object.freeze({env:{...Ws.env}})},T=Object.keys(E).filter(Ye),j=T.map((B)=>E[B]);try{return Function(...T,`'use strict'; return (${v});`)(...j)}catch{try{return Function(...T,`'use strict'; return ${v};`)(...j)}catch{return}}}async function yS(v,_,k){let E=v.matchAll(/export\s+(const|let|var)\s+(\w+)\s*=\s*([\s\S]*?)(?=\s*(?:export\s+|$))/g);for(let j of E){let[,,B,z]=j;try{let F=z.trim().replace(/;$/,""),V=wm(F,_);if(V!==void 0)_[B]=V}catch(F){console.warn(`Failed to parse export ${B} in fallback:`,F)}}let T=v.matchAll(/(?:^|\n)\s*(const|let|var)\s+(\w+)\s*=\s*([\s\S]*?)(?=\s*(?:(?:const|let|var|function|export)\s+|$))/g);for(let j of T){let[,,B,z]=j;if(!(B in _))try{let F=z.trim().replace(/;$/,""),V=wm(F,_);if(V!==void 0)_[B]=V}catch{}}}function Jo(v){let _=v.match(/<script\b[^>]*>([\s\S]*?)<\/script>/i),k=_?_[1]:"",E=_?v.replace(/<script\b[^>]*>[\s\S]*?<\/script>/i,""):v;return{scriptContent:k,templateWithoutScript:E}}function Yo(v){let _=v.trim();if(!_)return!1;return/(?:const|let|var|function)\s+\w+/.test(_)}var Oi=new M(500),ea=new M(1000),Nl=new M(2000),jl=new M(500),Dm=33554432,Ll=Dm;function xS(v){let _=v.componentRenderCacheBytes;if(typeof _!=="number"||_<0||_===Ll)return;Ll=_,ta.setMaxBytes(_)}var ta=new M(2000,{maxBytes:Dm,sizeOf:(v)=>v.output.length});function bS(v){let _=new WeakSet;try{let k=(E)=>{if(E===void 0)return{__stxType:"undefined"};if(typeof E==="bigint")return{__stxType:"bigint",value:E.toString()};if(typeof E==="function"||typeof E==="symbol")throw TypeError("Non-serializable component input");if(E===null||typeof E!=="object")return E;if(_.has(E))throw TypeError("Circular component input");_.add(E);try{if(E instanceof Date)return{__stxType:"date",value:E.toISOString()};if(Array.isArray(E))return E.map(k);let T=Object.getPrototypeOf(E);if(T!==Object.prototype&&T!==null)throw TypeError("Non-plain component input");let j={};for(let B of Object.keys(E).sort())j[B]=k(E[B]);return j}finally{_.delete(E)}};return JSON.stringify(k(v))}catch{return null}}function vS(v){let _={};for(let[k,E]of Object.entries(v))if(!k.startsWith("__")||k==="__stxServeContext")_[k]=E;return _}function Em(v){return v.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}function xc(v){return/\bjs\b/.test(v)||/\blang\s*=\s*["']?(js|javascript)["']?/i.test(v)}function Ve(v){return!xc(v)}var No=new Map;function L(v){let _;try{_=JSON.stringify(v)}catch{return new Bun.Transpiler(v)}let k=No.get(_);if(k)return k;if(No.size>=16)No.clear();let E=new Bun.Transpiler(v);return No.set(_,E),E}var Cm=new WeakMap,wS=256;function Ue(v){try{let _=L({loader:"ts",target:"browser",define:w()}),k=Cm.get(_);if(!k)k=new Map,Cm.set(_,k);let E=k.get(v);if(E!==void 0)return E;let T=v.replace(/^\s*import\s+\w+\s+from\s+['"][^'"]*\.stx['"]\s*;?\s*$/gm,"");T=T.replace(/^\s*import\s+['"][^'"]*\.stx['"]\s*;?\s*$/gm,"");let j=[];T=T.replace(/\{!![\s\S]*?!!\}/g,(z)=>{let F=j.length;return j.push(z),`"__STX_EXPR_${F}__"`}),T=T.replace(/\{\{\{[\s\S]*?\}\}\}/g,(z)=>{let F=j.length;return j.push(z),`"__STX_EXPR_${F}__"`}),T=T.replace(/\{\{[\s\S]*?\}\}/g,(z)=>{let F=j.length;return j.push(z),`"__STX_EXPR_${F}__"`});let B=_.transformSync(T);for(let z=0;z<j.length;z++)B=B.replace(`"__STX_EXPR_${z}__"`,j[z]),B=B.replace(`'__STX_EXPR_${z}__'`,j[z]);if(k.size>=wS){let z=k.keys().next();if(!z.done)k.delete(z.value)}return k.set(v,B),B}catch(_){if(process.env.STX_DEBUG_TS)console.warn("[STX] TypeScript transpilation error:",_);return v}}function SS(v){let _=[],k=new Set,E=0,T=0,j=v.length,B=(H)=>{T++;while(T<j){if(v[T]==="\\"){T+=2;continue}if(v[T]===H){T++;return}T++}},z=()=>{T++;while(T<j){if(v[T]==="\\"){T+=2;continue}if(v[T]==="`"){T++;return}if(v[T]==="$"&&v[T+1]==="{"){T+=2;let H=1;while(T<j&&H>0)if(v[T]==="{")H++,T++;else if(v[T]==="}")H--,T++;else if(v[T]==="'"||v[T]==='"')B(v[T]);else if(v[T]==="`")z();else T++;continue}T++}},F=()=>{if(v[T]==="/"&&v[T+1]==="/"){while(T<j&&v[T]!==`
|
|
2090
|
+
`)T++;return!0}if(v[T]==="/"&&v[T+1]==="*"){T+=2;while(T<j-1&&!(v[T]==="*"&&v[T+1]==="/"))T++;return T+=2,!0}return!1},V=()=>{if(E!==0)return;let H=v.slice(T).match(/^(const|let|var)\s*\{([^}]+)\}\s*=/);if(H){let re=H[2].split(",").map((se)=>{let ie=se.trim().split(":");return ie[ie.length-1].trim()});for(let se of re)if(se&&/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(se)&&!k.has(se))_.push(se),k.add(se);return}let G=v.slice(T).match(/^(const|let|var)\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*=/);if(G){let re=G[2];if(!k.has(re))_.push(re),k.add(re);return}let J=v.slice(T).match(/^function\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*\(/);if(J){let re=J[1];if(!k.has(re))_.push(re),k.add(re);return}let ne=v.slice(T).match(/^async\s+function\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*\(/);if(ne){let re=ne[1];if(!k.has(re))_.push(re),k.add(re)}};while(T<j){if(F())continue;if(v[T]==="'"||v[T]==='"'){B(v[T]);continue}if(v[T]==="`"){z();continue}if(v[T]==="{"){E++,T++;continue}if(v[T]==="}"){E--,T++;continue}if(E===0&&/[a-z]/i.test(v[T])&&(T===0||/\s|[;{}()]/.test(v[T-1])))V();T++}return _}function $S(v){let _=[],k=0,E=0,T=null;for(let j=0;j<v.length;j++){let B=v[j];if(T){if(B==="\\"){j++;continue}if(B===T)T=null;continue}if(B==='"'||B==="'"||B==="`"){T=B;continue}if(B==="("||B==="["||B==="{")k++;else if(B===")"||B==="]"||B==="}")k--;else if(B===","&&k===0)_.push(v.slice(E,j)),E=j+1}if(E<v.length)_.push(v.slice(E));return _}function _S(v){let _=0,k=null;for(let E=0;E<v.length;E++){let T=v[E];if(k){if(T==="\\"){E++;continue}if(T===k)k=null;continue}if(T==='"'||T==="'"||T==="`"){k=T;continue}if(T==="("||T==="["||T==="{")_++;else if(T===")"||T==="]"||T==="}")_--;else if(T==="="&&_===0){let j=v[E-1],B=v[E+1];if(j==="!"||j==="<"||j===">"||j==="=")continue;if(B==="="||B===">")continue;return E}}return-1}function kS(v,_){try{let k=/=\s*(?:withDefaults\s*\([\s\S]*?defineProps|defineProps)\b/.exec(v);if(!k)return;let E=k.index-1;while(E>=0&&/\s/.test(v[E]))E--;if(v[E]!=="}")return;let T=E,j=0,B=-1;for(;E>=0;E--){let F=v[E];if(F==="}")j++;else if(F==="{"){if(j--,j===0){B=E;break}}}if(B===-1)return;let z=v.slice(B+1,T);for(let F of $S(z)){let V=F.trim();if(!V||V.startsWith("..."))continue;let H=_S(V);if(H===-1)continue;let G=V.slice(0,H).trim();if(!/^[A-Z_$][\w$]*$/i.test(G))continue;if(_[G]!==void 0)continue;let J=V.slice(H+1).trim();if(!J)continue;try{let ne=Object.keys(_).filter(Ye),re=Function(...ne,`"use strict"; return (${J});`);_[G]=re(...ne.map((se)=>_[se]))}catch{}}}catch{}}var ES=new Set(["tr","td","th","thead","tbody","tfoot","caption","colgroup","col","option","optgroup","li","dt","dd","span"]);function Sc(v,_){let k=v.match(/^(\s*(?:(?:<!--[\s\S]*?-->|\x00STX_HTML_COMMENT_\d+\x00)\s*)*)<([a-zA-Z][a-zA-Z0-9-]*)/s);if(!k)return null;let E=k[2].toLowerCase();if(!ES.has(E))return null;let T=new RegExp(`<\\/?${E}(?=[\\s/>])(?:[^>"']|"[^"]*"|'[^']*')*>`,"iy"),j=pr(v,(V,H)=>(T.lastIndex=H,T.exec(V)?.index===H?T.lastIndex:-1));if(E==="span"&&/\sdata-stx-scope\s*=/.test(j[0]?.token||""))return null;let B=0,z=!1;for(let V of j){if(B+=V.token.startsWith("</")?-1:1,B<0)return null;if(B===0){if(v.slice(V.end).trim())return null;z=!0;break}}if(!z)return null;let F=k[0].length;return v.slice(0,F)+_+v.slice(F)}async function Wn(v,_,k,E,T){let j=v.endsWith(".stx")?v.slice(0,-4):v,B=(we)=>we.split("-").map(($e)=>$e.charAt(0).toUpperCase()+$e.slice(1)).join(""),z=(we)=>we.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),F=k.__importedComponents;if(F){for(let we of[j,j.toLowerCase(),B(j),z(j)])if(F.has(we))return!0}let V=[...new Set([`${j}.stx`,`${B(j)}.stx`,`${z(j)}.stx`])],H=typeof T.root==="string"?Qe.resolve(T.root):void 0,G=H??Qe.dirname(E),J=[],ne=(we)=>{if(we&&!J.includes(we))J.push(we)},re=k.__originalFilePath;if(re)ne(Qe.join(Qe.dirname(re),"components"));if(ne(_),ne(T._rootComponentsDir),ne(Qe.join(Qe.dirname(E),"components")),ne(T.componentsDir),H)ne(Qe.resolve(H,"resources/views/components")),ne(Qe.resolve(H,"resources/components")),ne(Qe.resolve(H,"src/components")),ne(Qe.resolve(H,"components"));for(let we of T._layerComponentDirs??[])ne(we);let se=T._pluginComponentDirs;if(Array.isArray(se))for(let we of se)ne(typeof we==="string"?we:null);if(ne(T.fallbackComponentsDir),j.startsWith("./")||j.startsWith("../"))return r(Qe.resolve(Qe.dirname(E),`${j}.stx`));let ie=Rm(Qe.resolve(import.meta.dir,"components")),oe=J.map((we)=>Qe.isAbsolute(we)?we:Qe.resolve(G,we)),ge=`${V.join("\x00")}\x00\x00${oe.join("\x00")}`,ue=Nl.get(ge);if(ue!==void 0)return ue;let xe=!1;e:for(let we of oe){if(Rm(we)===ie)continue;for(let $e of V)if(await r(Qe.join(we,$e))){xe=!0;break e}}return Nl.set(ge,xe),xe}function Rm(v){let _=jl.get(v);if(_!==void 0)return _;let k=v;try{k=Pm.realpathSync(v)}catch{}return jl.set(v,k),k}function kc(v){return v==="visible"||v==="idle"||v==="interaction"||v.startsWith("media:")}function ci(v){if(!v)return!1;let _=v.replace(/<script[\s\S]*?<\/script>/gi,"").replace(/<style[\s\S]*?<\/style>/gi,"");return/\{\{[\s\S]*?\}\}|\{!![\s\S]*?!!\}/.test(_)}function CS(v,_,k){if(!v.includes("{{")&&!v.includes("{!!"))return v;let E=(T,j)=>{let B;try{B=x(T,_)}catch{return j}if(B===void 0||B===null)return"";let z=String(B);if(/<\/style/i.test(z))return console.warn(`[stx] a <style> expression in ${k??"<unknown>"} evaluated to CSS containing a closing style tag, which would end the element early, so it was dropped rather than emitted.`),"";return z};return v.replace(/\{!!([\s\S]*?)!!\}/g,(T,j)=>E(j,T)).replace(/\{\{([\s\S]*?)\}\}/g,(T,j)=>E(j,T))}var Tm=new Set;function Am(v,_,k,E){let T=`${v}\x00${_}\x00${E??""}`;if(!process.env.STX_DEBUG&&Tm.has(T))return;Tm.add(T);let j=_?` used in ${_}`:"",B=E?` Cause: ${E}.`:"",z=k.length>0?`
|
|
2091
|
+
searched:
|
|
2092
|
+
${k.map((F)=>` - ${F}`).join(`
|
|
2093
|
+
`)}`:"";console.error(`[stx] component <${v}> could not be resolved${j}, so it rendered as nothing.${B}${z}`)}function Im(v){return`<!-- stx: component "${v.replace(/--+/g,"-")}" could not be resolved; see the server log -->`}function Cc(v){let _=new Set,k=/\b(?:const|let|var)\s+([a-zA-Z_$][\w$]*)\s*=\s*(?:state|derived|computed|ref|reactive|signal|useModel|useReactiveProp|useLocalStorage|useSessionStorage|keptState|useCookie|useDebouncedValue)\s*(?:<[^>]*>)?\s*\(/g;for(let E of v){let T;while((T=k.exec(E))!==null)_.add(T[1]);k.lastIndex=0}return[..._]}async function We(v,_,k,E,T,j,B,z=new Set,F){let{extractVariables:V}=await ut("stx/variable-extractor",()=>import("./chunk-e78ame3h.js")),H=z??new Set;if(H.has(v))return`[Circular component reference: ${v}]`;let G=new Set(H);G.add(v);let J=typeof _.client==="string"?_.client.trim():"";if("client"in _)delete _.client;let ne=J&&J!=="load"&&kc(J)?J:"";try{let re=(tt)=>tt.split("-").map((ot)=>ot.charAt(0).toUpperCase()+ot.slice(1)).join(""),se=(tt)=>tt.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),ie=v.endsWith(".stx")?v.slice(0,-4):v,oe=null,ge=T.__importedComponents;if(ge){let tt=[ie,ie.toLowerCase(),re(ie),se(ie)];for(let ot of tt)if(ge.has(ot)){oe=ge.get(ot);break}}let ue=[];if(!oe){let tt=[`${ie}.stx`,`${re(ie)}.stx`,`${se(ie)}.stx`],ot=[...new Set(tt)],_t=T.__originalFilePath,dt=[];if(dt.push(...B._layerComponentDirs??[]),_t){let Bt=Qe.join(Qe.dirname(_t),"components");dt.push(Bt)}if(E)dt.push(E);let Wt=B._rootComponentsDir;if(typeof Wt==="string"&&!dt.includes(Wt))dt.push(Wt);let Mt=Qe.join(Qe.dirname(j),"components");if(!dt.includes(Mt))dt.push(Mt);if(B.componentsDir&&B.componentsDir!==E&&!dt.includes(B.componentsDir))dt.push(B.componentsDir);let Jt=typeof B.root==="string"?Qe.resolve(B.root):void 0,ir=Jt??Qe.dirname(j),lt=[];if(Jt)lt.push(Qe.resolve(Jt,"resources/views/components")),lt.push(Qe.resolve(Jt,"resources/components")),lt.push(Qe.resolve(Jt,"src/components")),lt.push(Qe.resolve(Jt,"components"));lt.push(Qe.resolve(import.meta.dir,"components"));for(let Bt of lt)if(!dt.includes(Bt))dt.push(Bt);let kn=B._pluginComponentDirs;if(Array.isArray(kn)){for(let Bt of kn)if(typeof Bt==="string"&&!dt.includes(Bt))dt.push(Bt)}if(B.fallbackComponentsDir&&!dt.includes(B.fallbackComponentsDir))dt.push(B.fallbackComponentsDir);let Nr=[...new Set(dt.map((Bt)=>{if(!Bt)return Bt;return Qe.isAbsolute(Bt)?Bt:Qe.resolve(ir,Bt)}))];dt.length=0,dt.push(...Nr);let jr=`${ie}\x00${j}\x00${Nr.join("\x00")}`,Lr=ea.get(jr);if(Lr)if(await r(Lr))oe=Lr;else ea.delete(jr);if(!oe&&(ie.startsWith("./")||ie.startsWith("../")))oe=Qe.resolve(Qe.dirname(j),`${ie}.stx`),ue.push(oe);else if(!oe)for(let Bt of dt){if(!Bt)continue;for(let Br of ot){let zi=Qe.join(Bt,Br);if(ue.push(zi),await r(zi)){oe=zi;break}}if(oe)break;if(!oe)try{let Br=await import("fs");if(!Br.statSync(Bt,{throwIfNoEntry:!1})?.isDirectory())continue;let eh=8,pa=[{path:Bt,depth:0}];while(pa.length>0&&!oe){let Fi=pa.pop();if(Fi.depth>=eh)continue;let eu;try{eu=Br.readdirSync(Fi.path,{withFileTypes:!0})}catch{continue}for(let Wi of eu){if(!Wi.isDirectory())continue;if(Wi.name==="node_modules"||Wi.name.startsWith("."))continue;let tu=Qe.join(Fi.path,Wi.name);for(let th of ot){let ga=Qe.join(tu,th);if(ue.push(ga),await r(ga)){oe=ga;break}}if(oe)break;pa.push({path:tu,depth:Fi.depth+1})}}}catch{}if(oe)break}if(oe)ea.set(jr,oe)}if(!oe||!await r(oe))return Am(v,j,ue),Im(v);F.add(oe);let xe;if(Oi.has(oe))xe=Oi.get(oe);else try{xe=await Bun.file(oe).text(),Oi.set(oe,xe)}catch(tt){let ot=tt instanceof Error?tt.message:String(tt);return Am(v,j,[oe],ot),Im(v)}let we=new Set(["__originalFilePath","__importedComponents",Hi,"__stx_client_signal_names","__stx_runtime_config","__stxServeContext","__stx_scope_seq"]),$e={};for(let[tt,ot]of Object.entries(T))if(!tt.startsWith("__")||we.has(tt))$e[tt]=ot;let _e=k;if(k.includes("@include")){let{processIncludes:tt}=await ut("stx/includes",()=>import("./chunk-pcp5twev.js"));_e=await tt(k,T,j,B,F)}if(/<[A-Z][\w.-]*[\s/>]/.test(_e)){let{processComponents:tt}=await ut("stx/component-renderer",()=>import("./chunk-me5039d4.js"));_e=await tt(_e,{...T,__processedComponents:H},j,B,F)}let Ce=[];if(ci(_e)){let{processExpressions:tt}=await ut("stx/expressions",()=>import("./chunk-qrgr2h1n.js")),ot=T.__stx_signals_gate===void 0?{...T,__stx_signals_gate:!0}:T;_e=tt(_e,ot,j);for(let _t of _e.matchAll(/\{\{([\s\S]*?)\}\}/g))Ce.push(_t[1].trim())}let Ee=bn(_e),Te=[],Re=Ee.output.replace(/\x00STX_SCRIPT_(\d+)\x00/g,(tt,ot)=>{let _t=Ee.scripts[Number(ot)]||"",dt=_t.match(/^<script\b([^>]*)>/i)?.[1]||"",Wt=dt.match(/\btype\s*=\s*["']([^"']+)["']/i)?.[1]?.toLowerCase(),Mt=!Wt||["module","text/javascript","application/javascript"].includes(Wt),Jt=/\sdata-stx-(?:owner|instance)(?=[\s=/>])/i.test(` ${dt}`);if(!/\bserver\b/i.test(dt)&&Mt&&!Jt)return Te.push(_t),"";return _t}),{extractSlotContent:ke}=await ut("stx/slots",()=>import("./chunk-p4zeqzmr.js")),Ae=ke(Re),Xe={};if(Ae.defaultSlot?.trim())Xe.default=Ae.defaultSlot;for(let[tt,ot]of Ae.namedSlots)Xe[tt]=ot.content;let Pe=T.__stx_scope_seq??={n:0,key:Bun.hash(String(T.__filename??j)).toString(36).slice(0,6)},Ie=`stx_${ie.replace(/[^a-zA-Z0-9]/g,"_")}_${++Pe.n}_${Pe.key}`,Ze={...$e,$uid:Ie,..._,props:_,slot:Re,$slots:Xe,__processedComponents:G,__sections:{},__stx_signals_gate:he(xe)||ci(k),__stx_preserved_client_expressions:[...Array.isArray(T.__stx_preserved_client_expressions)?T.__stx_preserved_client_expressions:[],...Ce]};kS(xe,Ze);let nt=xe,at=Z(nt);if(at)nt=at.content.trim();let rt=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,bt=[...xe.matchAll(rt)],ft=[],yt=null,ct=bt.some((tt)=>/\bserver\b/.test(tt[1]||"")&&/\bcache\b/.test(tt[1]||"")),Pt=null,pt=null,Lt=null,Qn=0,Sn=null;if(xS(B),ct&&Ll>0){let tt=bS({props:_,slot:_e,slotContext:k.trim()?vS($e):void 0,buildMode:B.buildMode??"",skipEventDirectives:B.skipEventDirectives===!0,layers:B._layerGraph?.layers.map((ot)=>ot.configFile),uid:Ie});if(tt!==null){Pt=`${oe}\x00${h(xe)}\x00${tt}`;let ot=ta.get(Pt);if(ot){for(let _t of ot.dependencies)F.add(_t);if(ld(T,ot.clientFactories),Pe.n+=ot.uidsConsumed,ot.preservedClientExpressions.length>0){let _t=new Set(Array.isArray(T.__stx_preserved_client_expressions)?T.__stx_preserved_client_expressions:[]);for(let dt of ot.preservedClientExpressions)_t.add(dt);T.__stx_preserved_client_expressions=[..._t]}return ot.output}pt=new Set(F),Lt=ad(T),Qn=Pe.n,Sn=new Set(Array.isArray(T.__stx_preserved_client_expressions)?T.__stx_preserved_client_expressions:[])}}let er=new Set;for(let tt of bt){let ot=tt[1]||"",_t=tt[2]||"",dt=ot.includes("server");if(Ve(ot)&&_t.trim())_t=Ue(_t);if(dt&&_t){for(let Mt of Q(_t))er.add(Mt);try{await V(_t,Ze,oe,{onFailure:(Mt)=>{if(Mt.kind!=="unknown")yt=Mt.kind}})}catch(Mt){}}if(!dt){let Mt=_t.replace(/^\s*const\s*\{[^}]+\}\s*=\s*window\.stx\s*;?\s*\n?/gm,""),Jt=Mt.includes("{{")&&Mt.includes("}}"),ir=Mt.includes("{!!")&&Mt.includes("!!}");if(Jt||ir)Mt=Yr(Mt,Ze,oe);let lt=ot.replace(/\s*\bts\b/g,"").replace(/\s*\blang\s*=\s*["']?(ts|typescript)["']?/gi,"");ft.push(`<script${lt}>${Mt}</script>`)}}let it=bn(xe).output.match(/<style\b([^>]*)>([\s\S]*?)<\/style>/i),gt=it?it[1]:"",qt=it?it[2]:"",Dt="",xn=gt&&/\bscoped\b/i.test(gt);if(it)Dt=`<style${gt}>${CS(qt,Ze,oe)}</style>`;let Nt=nt;if(Nt=Nt.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,""),it)Nt=Nt.replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,"");{let tt=/@push\s*\(\s*['"]styles['"]\s*\)([\s\S]*?)@endpush/gi,ot=[];if(Nt=Nt.replace(tt,(_t,dt)=>{let Wt=dt.match(/<style\b([^>]*)>([\s\S]*?)<\/style>/i);if(Wt)ot.push(`<style${Wt[1]}>${Wt[2]}</style>`);return""}),Nt=Nt.replace(/@push\s*\(\s*['"][^'"]+['"]\s*\)[\s\S]*?@endpush/gi,""),ot.length>0)Dt=`${Dt}${ot.join(`
|
|
2094
|
+
`)}`}if(k&&Nt.includes("{{ text || slot }}"))Nt=Nt.replace(/\{\{\s*text\s*\|\|\s*slot\s*\}\}/g,()=>k);let{applySlots:ua}=await ut("stx/slots",()=>import("./chunk-p4zeqzmr.js")),{defaultSlot:da,namedSlots:fa}=Ae,De=ft.some((tt)=>/\b(?:state|derived|effect|ref|useRef|reactive|computed|watch|watchEffect|useModel|useReactiveProp|onMount|onDestroy|defineProps|withDefaults|defineEmits|defineExpose|defineSlots)\s*(?:<[^<>()]*>)?\s*\(/.test(tt)),Je=(tt)=>De?Ig(tt,Ie):tt,st=new Map([...fa].map(([tt,ot])=>[tt,{...ot,content:Je(ot.content)}]));Nt=await ua(Nt,Je(da),st,Ze);let mt=Cc(ft),At=(Array.isArray(Ze.__stx_client_signal_names)?Ze.__stx_client_signal_names:[]).filter((tt)=>!er.has(tt));if(mt.length>0||At.length>0)Ze.__stx_client_signal_names=[...new Set([...At,...mt])];else delete Ze.__stx_client_signal_names;let Kt={...B,_rootComponentsDir:B._rootComponentsDir||B.componentsDir,componentsDir:Qe.dirname(oe),skipSignalsRuntime:!0,skipEventDirectives:De||ft.length===0,defaultLayout:void 0};Ze.__stxProcessingDepth=(T.__stxProcessingDepth||0)+1;let _n=await n(Nt,Ze,oe,Kt,F),Bi=new Set(Array.isArray(T.__stx_preserved_client_expressions)?T.__stx_preserved_client_expressions:[]);for(let tt of _n.matchAll(/\{\{([\s\S]*?)\}\}/g))Bi.add(tt[1].trim());if(Bi.size>0)T.__stx_preserved_client_expressions=[...Bi];let dr=Ie,Gt=_n;if(De){let tt="";if(Object.keys(_).length>0)try{tt=` data-stx-props="${Em(JSON.stringify(_))}"`}catch{}let ot=ne?` stx-hydrate="${Em(ne)}"`:"",_t=` data-stx-scope="${dr}"${tt}${ot}`,dt=/^\s*(?:(?:<!--[\s\S]*?-->|\x00STX_HTML_COMMENT_\d+\x00)\s*)*<span(?=[\s/>])/i.test(_n),Wt=dt?"span":"div";Gt=Sc(_n,_t)??`<${Wt}${_t}${dt?' style="display:contents"':""}>${_n}</${Wt}>`;let Mt=await Promise.all(ft.map(async(Jt)=>{let ir=Jt.match(/<script([^>]*)>([\s\S]*)<\/script>/i);if(!ir)return Jt;let[,lt,kn]=ir,{vendorStyleTags:Nr,factoryBody:jr}=await AS(kn,oe,B.buildMode==="compile"),Lr=ne?null:va(T,jr),Bt=Lr?`window.__stxComponentFactories[${JSON.stringify(Lr)}](${JSON.stringify(dr)});`:`(${jr})(${JSON.stringify(dr)});`;if(ne)return`${Nr}<script type="stx/island" data-stx-island="${dr}" data-stx-scoped data-stx-owner="${dr}"${lt}>${Bt}</script>`;return`${Nr}<script data-stx-scoped data-stx-run="always" data-stx-owner="${dr}"${lt}>${Bt}</script>`}));if(Gt=Gt+`
|
|
2095
|
+
`+Mt.join(`
|
|
2096
|
+
`),Dt)Gt+=`
|
|
2097
|
+
`+Dt}else{if(Dt)Gt+=`
|
|
2098
|
+
`+Dt;if(ft.length>0){let tt=Ze.__stx_event_bindings||[],ot=Ne(Ze),_t=await Promise.all(ft.map(async(dt)=>{let Wt=dt.match(/<script\b[^>]*>([\s\S]*?)<\/script>/);if(!Wt)return dt;return await me(Wt[1],{eventBindings:tt,templateContent:Gt,filePath:oe,projectRoot:process.cwd(),serverData:ot,instanceId:Ie})}));Gt+=`
|
|
2099
|
+
`+_t.join(`
|
|
2100
|
+
`),Ze.__stx_event_bindings=[]}}if(xn){let tt=Yi(Gt,oe);if(tt.hasScoped)Gt=tt.html}if(Pt&&pt){let tt=Array.isArray(T.__stx_preserved_client_expressions)?T.__stx_preserved_client_expressions:[];ta.set(Pt,{output:Gt,dependencies:[...F].filter((ot)=>!pt.has(ot)),clientFactories:Lt?cd(T,Lt):[],uidsConsumed:Pe.n-Qn,preservedClientExpressions:Sn?tt.filter((ot)=>!Sn.has(ot)):[]})}if(yt)Gt=`<!--stx-render-failed:${yt}-->${Gt}`;return Te.length>0?`${Gt}
|
|
2101
|
+
${Te.join(`
|
|
2102
|
+
`)}`:Gt}catch(re){return`[Error processing component: ${re instanceof Error?re.message:String(re)}]`}finally{H.delete(v)}}async function r(v){return Bun.file(v).exists()}function Bl(v,_){let k=Qe.resolve(_),E=Qe.resolve(v),T=k.endsWith(Qe.sep)?k:k+Qe.sep;if(E===k||E.startsWith(T))return E;return null}async function RS(v,_,k,E){let T=_.startsWith("layouts/")?_.slice(8):_,j=Qe.join(v,T);for(let B of j.endsWith(".stx")?[j]:[j,`${j}.stx`])if(await r(B)){if(E)console.log(`Found layout in ${v}: ${B}`);return k?.add(B),B}return null}async function qn(v,_,k,E){let T=await TS(v,_,k,E);if(T===null)return null;let j=Bl(T,process.cwd());if(j)return j;let B=[k.root,k.layoutsDir,k.fallbackLayoutsDir,k.componentsDir,k.partialsDir,k.pagesDir,...k._layerLayoutDirs??[]].filter((z)=>typeof z==="string"&&z.length>0);for(let z of B){let F=Qe.isAbsolute(z)?z:Qe.resolve(process.cwd(),z);if(Bl(T,F))return Qe.resolve(T)}return console.warn(`[stx] rejected resolved template path that escapes project root: ${T} (template: ${v}, from: ${_})`),null}async function TS(v,_,k,E){if(k.debug)console.log(`Resolving template path: ${v} from ${_}`);let T=Qe.dirname(_),j=process.cwd();if(v.startsWith("/")){let J=Qe.join(j,v),ne=Bl(J,j);if(!ne)return console.warn(`[stx] rejected template path that escapes project root: ${v} (from ${_})`),null;if(k.debug)console.log(`Checking absolute path: ${ne}`);if(await r(ne)&&E)E.add(ne);return ne}let B=Qe.join(T,v);if(await r(B)){if(k.debug)console.log(`Found direct path: ${B}`);if(E)E.add(B);return B}if(!v.endsWith(".stx")&&!v.endsWith(".jsx")&&!v.endsWith(".tsx"))for(let J of[".stx",".tsx",".jsx"]){let ne=`${B}${J}`;if(await r(ne)){if(k.debug)console.log(`Found direct path with extension: ${ne}`);if(E)E.add(ne);return ne}}let z=[];if(z.push(...k._layerLayoutDirs??[]),k.layoutsDir)z.push(Qe.isAbsolute(k.layoutsDir)?k.layoutsDir:Qe.resolve(process.cwd(),k.layoutsDir));let F=Qe.resolve(T),V=process.cwd();for(let J=0;J<10;J++){let ne=Qe.join(F,"layouts"),re=!1;try{re=Pm.statSync(ne,{throwIfNoEntry:!1})?.isDirectory()??!1}catch{}if(re){z.push(ne);break}let se=Qe.dirname(F);if(se===F||se.length<V.length)break;F=se}for(let J of z){let ne=await RS(J,v,E,k.debug);if(ne)return ne}if(k.fallbackLayoutsDir){let J=Qe.isAbsolute(k.fallbackLayoutsDir)?k.fallbackLayoutsDir:Qe.resolve(process.cwd(),k.fallbackLayoutsDir),ne=v.startsWith("layouts/")?v.slice(8):v,re=[Qe.join(J,ne)];if(!v.endsWith(".stx"))re.push(`${re[0]}.stx`);for(let se of re)if(await r(se)){if(k.debug)console.log(`Found in options.fallbackLayoutsDir: ${se}`);if(E)E.add(se);return se}}if(v.startsWith("layouts/")||v.includes("/layouts/")){let J=v.split("layouts/"),ne=Qe.join(k.partialsDir||T,"layouts",J[1]);if(await r(ne)){if(k.debug)console.log(`Found in layouts path: ${ne}`);if(E)E.add(ne);return ne}if(!ne.endsWith(".stx")){let re=`${ne}.stx`;if(await r(re)){if(k.debug)console.log(`Found in layouts path with extension: ${re}`);if(E)E.add(re);return re}}}if(k.partialsDir){let J=Qe.join(k.partialsDir,"layouts");if(await r(J)){let ne=Qe.join(J,v);if(await r(ne)){if(k.debug)console.log(`Found in partials layouts dir: ${ne}`);if(E)E.add(ne);return ne}if(!v.endsWith(".stx")){let re=`${ne}.stx`;if(await r(re)){if(k.debug)console.log(`Found in partials layouts dir with extension: ${re}`);if(E)E.add(re);return re}}}}let H=k.partialsDir||Qe.join(process.cwd(),"views"),G=Qe.join(H,v);if(await r(G)){if(k.debug)console.log(`Found in views path: ${G}`);if(E)E.add(G);return G}if(!v.endsWith(".stx")){let J=`${G}.stx`;if(await r(J)){if(k.debug)console.log(`Found in views path with extension: ${J}`);if(E)E.add(J);return J}}if(T.includes("temp")){let J=Qe.join(Qe.dirname(T),"layouts",v);if(await r(J)){if(k.debug)console.log(`Found in temp layouts dir: ${J}`);if(E)E.add(J);return J}if(!v.endsWith(".stx")){let ne=`${J}.stx`;if(await r(ne)){if(k.debug)console.log(`Found in temp layouts dir with extension: ${ne}`);if(E)E.add(ne);return ne}}}if(k.debug)console.warn(`Template not found after trying all paths: ${v} (referenced from ${_})`);else console.warn(`Template not found: ${v} (referenced from ${_})`);return null}function li(v,_,k){let E=0,T="",j="";try{if(typeof _==="number"&&_>=0){let B=v.split(`
|
|
2103
|
+
`),z=0;for(let F=0;F<B.length;F++)if(z+=B[F].length+1,z>=_){E=F+1,T=B[F].trim();let V=Math.max(0,F-2),H=Math.min(B.length,F+3);j=B.slice(V,H).map((G,J)=>{let ne=V+J+1;return`${ne===E?"> ":" "}${ne}: ${G}`}).join(`
|
|
2104
|
+
`);break}}else if(k){let B=v.indexOf(k);if(B>=0)return li(v,B)}}catch{}return{lineNumber:E,lineContent:T,context:j}}var ht={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 g(v,_,k,E,T,j){let{lineNumber:B,context:z}=li(E,T,j),F=k.split("/").pop(),V=0;if(typeof T==="number"&&T>=0&&E){let G=E.lastIndexOf(`
|
|
2105
|
+
`,Math.max(0,T-1));V=T-(G+1)+1}let H="";if(B>0)H+=`
|
|
2106
|
+
${k}:${B}${V>0?`:${V}`:""}: ${v.toLowerCase()} error: ${_}
|
|
2107
|
+
`;if(H+=`
|
|
2108
|
+
${ht.bold}${ht.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${ht.reset}
|
|
2109
|
+
`,H+=`${ht.bold}${ht.red}\u2502${ht.reset} ${ht.bold}${ht.bgRed} ERROR ${ht.reset} ${ht.red}${v} Error${ht.reset}${" ".repeat(Math.max(0,43-v.length))}${ht.bold}${ht.red}\u2502${ht.reset}
|
|
2110
|
+
`,H+=`${ht.bold}${ht.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${ht.reset}
|
|
2111
|
+
`,H+=`
|
|
2112
|
+
${ht.cyan}${ht.bold}File:${ht.reset} ${ht.dim}${F}${ht.reset}`,B>0)H+=` ${ht.gray}(line ${B}${V>0?`, col ${V}`:""})${ht.reset}`;if(H+=`
|
|
2113
|
+
${ht.yellow}${ht.bold}Message:${ht.reset} ${_}
|
|
2114
|
+
`,z)H+=`
|
|
2115
|
+
${ht.blue}${ht.bold}Context:${ht.reset}
|
|
2116
|
+
${ht.dim}${z}${ht.reset}
|
|
2117
|
+
`;return H}function ee(){Oi.clear(),ea.clear(),Nl.clear(),jl.clear(),ta.clear()}function Bu(){return{size:Oi.size,maxSize:500}}var Ol=m(128);async function AS(v,_,k){let E=h(v,_,k),T=Ol.get(E);if(T){if(Zt(T.deps))return T;Ol.delete(E)}let j=qr(v,{filePath:_,projectRoot:process.cwd()}),B=j.code,z=Kr(j.styles);B=wt(B).code;let{hasUserImports:F,bundleClientScript:V}=await ut("stx/client-script-bundler",()=>import("./chunk-rzmvsqc7.js")),H=[],G=!1;if(F(B)){let oe=B;B=await V(oe,_,{projectRoot:process.cwd(),minify:k,collectInputs:H}),G=B===oe}let{stripStxRuntimeImports:J}=await ut("stx/signal-processing",()=>import("./chunk-zrbpy3m5.js"));B=J(B);let ne=P(B),re=SS(ne),se=`function(__scopeId) {
|
|
2118
|
+
${Rt("const",[...xi,...re],ne)}
|
|
2119
|
+
const __scope = window.stx._scopes = window.stx._scopes || {};
|
|
2120
|
+
const __scopeVars = __scope[__scopeId] = __scope[__scopeId] || {};
|
|
2121
|
+
__scopeVars.$refs = __scopeVars.$refs || {};
|
|
2122
|
+
const __previousCurrentElement = window.__STX_CURRENT_ELEMENT__;
|
|
2123
|
+
const __previousCurrentProps = window.__STX_CURRENT_PROPS__;
|
|
2124
|
+
// A clone the runtime is setting up may not be in the document yet (rows
|
|
2125
|
+
// a loop builds inside a closed :if), where a lookup cannot see it, so the
|
|
2126
|
+
// runtime hands its root over in __STX_SETUP_ROOT__ (signals.ts).
|
|
2127
|
+
const __setupRoot = window.__STX_SETUP_ROOT__;
|
|
2128
|
+
const __componentElement = (__setupRoot && __setupRoot.getAttribute('data-stx-scope') === __scopeId && __setupRoot) || document.querySelector('[data-stx-scope="' + __scopeId + '"]');
|
|
2129
|
+
window.__STX_CURRENT_ELEMENT__ = __componentElement;
|
|
2130
|
+
let __componentProps = __componentElement && __componentElement.__stx_props;
|
|
2131
|
+
if (!__componentProps && __componentElement) {
|
|
2132
|
+
try { __componentProps = JSON.parse(__componentElement.getAttribute('data-stx-props') || '{}'); }
|
|
2133
|
+
catch { __componentProps = {}; }
|
|
2134
|
+
}
|
|
2135
|
+
window.__STX_CURRENT_PROPS__ = __componentProps && typeof __componentProps === 'object' && !Array.isArray(__componentProps) ? __componentProps : {};
|
|
2136
|
+
|
|
2137
|
+
// Scope-specific lifecycle callbacks
|
|
2138
|
+
__scopeVars.__mountCallbacks = __scopeVars.__mountCallbacks || [];
|
|
2139
|
+
__scopeVars.__destroyCallbacks = __scopeVars.__destroyCallbacks || [];
|
|
2140
|
+
const onMount = (fn) => __scopeVars.__mountCallbacks.push(fn);
|
|
2141
|
+
const onDestroy = (fn) => __scopeVars.__destroyCallbacks.push(fn);
|
|
2142
|
+
|
|
2143
|
+
try {
|
|
2144
|
+
${ne}
|
|
2145
|
+
|
|
2146
|
+
// Register all defined signals and functions in this scope
|
|
2147
|
+
const __localVars = {};
|
|
2148
|
+
try {
|
|
2149
|
+
${re.map((oe)=>`if (typeof ${oe} !== 'undefined') __localVars['${oe}'] = ${oe};`).join(`
|
|
2150
|
+
`)}
|
|
2151
|
+
}
|
|
2152
|
+
catch (e) {}
|
|
2153
|
+
Object.assign(__scopeVars, __localVars);
|
|
2154
|
+
}
|
|
2155
|
+
finally {
|
|
2156
|
+
window.__STX_CURRENT_ELEMENT__ = __previousCurrentElement;
|
|
2157
|
+
window.__STX_CURRENT_PROPS__ = __previousCurrentProps;
|
|
2158
|
+
}
|
|
2159
|
+
}`,ie={vendorStyleTags:z,factoryBody:se,deps:Yu([...H,...j.styles.map((oe)=>oe.resolvedPath)])};if(!G&&j.unresolved.length===0)Ol.set(E,ie);return ie}async function Kg(v,_,k=""){let E=v,T=[],j=/@markdown(?:\([^)]*\))?/g,B;while((B=j.exec(v))!==null){let z=B.index,F=B[0].match(/@markdown\(([^)]*)\)/),V=F?F[1]:"",H=z+B[0].length,G=1,J=H,ne=-1;while(G>0&&J<v.length){let ie=v.indexOf("@markdown",J),oe=v.indexOf("@endmarkdown",J);if(oe===-1)break;if(ie!==-1&&ie<oe&&ie!==z){let ge=v[ie+9];if(ge==="("||ge===`
|
|
2160
|
+
`||ge==="\r"||ge===" "||ge===void 0)G++;J=ie+9}else{if(G--,G===0){ne=oe;break}J=oe+12}}if(ne===-1)continue;let re=v.slice(H,ne),se=v.slice(z,ne+12);T.push({fullMatch:se,options:V,content:re,index:z}),j.lastIndex=ne+12}for(let{fullMatch:z,options:F,content:V,index:H}of T)try{let G={};if(F)F.split(",").forEach((re)=>{let se=re.trim();if(se)G[se]=!0});let J={gfm:G.gfm??!0,breaks:G.breaks??!1},ne=Oe(V.trim(),J);E=E.split(z).join(ne)}catch(G){let J=G instanceof Error?G.message:String(G),ne=g("Markdown Directive",`Error processing markdown: ${J}`,k,v,H,z);E=E.split(z).join(ne)}return E}async function Mm(v,_,k,E){let T={gfm:!0,breaks:!1};return _.forEach((j)=>{let B=j.trim().replace(/['"]/g,"");if(B==="breaks")T.breaks=!0;if(B==="no-gfm")T.gfm=!1}),Oe(v.trim(),T)}var Vs=[320,480,640,768,1024,1280,1536,1920,2560],IS=[1,1.5,2,3],Ni=["avif","webp","jpeg"],PS={avif:"image/avif",webp:"image/webp",jpeg:"image/jpeg",png:"image/png",gif:"image/gif"};function zl(v,_=Vs,k={},E){return _.sort((T,j)=>T-j).map((T)=>`${ji(v,{...k,w:T,fm:E})} ${T}w`).join(", ")}function Om(v,_,k=IS,E={},T){return k.sort((j,B)=>j-B).map((j)=>{let B=Math.round(_*j);return`${ji(v,{...E,w:B,dpr:j,fm:T})} ${j}x`}).join(", ")}function Fl(v,_="100vw"){if(!v||Object.keys(v).length===0)return _;let E=Object.entries(v).map(([T,j])=>{let B=/^\d+$/.test(T)?`${T}px`:T;return{bp:B,size:j,numericBp:Number.parseInt(B)||0}}).sort((T,j)=>T.numericBp-j.numericBp).map(({bp:T,size:j})=>`(max-width: ${T}) ${j}`);return E.push(_),E.join(", ")}function ji(v,_={}){let k=Object.entries(_).filter(([,j])=>j!==void 0&&j!==null).map(([j,B])=>{if(Array.isArray(B))return[j,B.join(",")];return[j,String(B)]});if(k.length===0)return v;let E=k.map(([j,B])=>`${j}=${encodeURIComponent(B)}`).join("&"),T=v.includes("?")?"&":"?";return`${v}${T}${E}`}function Wl(v){return PS[v]||"application/octet-stream"}var DS={strategy:"thumbhash",width:20,quality:50,blurLevel:40,transitionDuration:300,easing:"ease-out"},Ul=`
|
|
2161
|
+
.stx-img-placeholder {
|
|
2162
|
+
position: relative;
|
|
2163
|
+
overflow: hidden;
|
|
2164
|
+
background-size: cover;
|
|
2165
|
+
background-position: center;
|
|
2166
|
+
background-repeat: no-repeat;
|
|
2167
|
+
}
|
|
2168
|
+
|
|
2169
|
+
.stx-img-placeholder img {
|
|
2170
|
+
opacity: 0;
|
|
2171
|
+
transition: opacity var(--stx-img-transition-duration, 300ms) var(--stx-img-transition-easing, ease-out);
|
|
2172
|
+
}
|
|
2173
|
+
|
|
2174
|
+
.stx-img-placeholder.stx-img-loaded img {
|
|
2175
|
+
opacity: 1;
|
|
2176
|
+
}
|
|
2177
|
+
|
|
2178
|
+
.stx-img-blur {
|
|
2179
|
+
filter: blur(20px);
|
|
2180
|
+
transform: scale(1.1);
|
|
2181
|
+
transition: filter var(--stx-img-transition-duration, 300ms) var(--stx-img-transition-easing, ease-out),
|
|
2182
|
+
transform var(--stx-img-transition-duration, 300ms) var(--stx-img-transition-easing, ease-out);
|
|
2183
|
+
}
|
|
2184
|
+
|
|
2185
|
+
.stx-img-loaded .stx-img-blur {
|
|
2186
|
+
filter: blur(0);
|
|
2187
|
+
transform: scale(1);
|
|
2188
|
+
}
|
|
2189
|
+
`.trim();async function MS(){try{return await import("ts-images")}catch{return null}}async function OS(v,_={}){let k={...DS,..._},E=await MS();if(E)try{return await NS(v,k,E)}catch(T){console.warn(`[stx-media] ts-images placeholder generation failed, using fallback: ${T}`)}return jS(v,k)}async function NS(v,_,k){let{generatePlaceholder:E,generateThumbHash:T}=k,B={blur:"blur",thumbhash:"thumbhash",blurhash:"thumbhash",pixelate:"pixelate","dominant-color":"dominant-color",none:"blur"}[_.strategy]||"blur";if(_.strategy==="thumbhash")return{dataURL:(await T(v)).dataUrl,width:32,height:32,aspectRatio:1,originalWidth:0,originalHeight:0,strategy:"thumbhash"};let z=await E(v,{width:_.width,height:_.height,quality:_.quality,blurLevel:_.blurLevel,strategy:B,base64Encode:!0});return{dataURL:z.dataURL,width:z.width,height:z.height,aspectRatio:z.aspectRatio,originalWidth:z.originalWidth,originalHeight:z.originalHeight,strategy:_.strategy,dominantColor:z.dominantColor,css:z.css}}function jS(v,_){let k=_.width||20,E=_.height||k,T="#e5e7eb",j=`<svg xmlns="http://www.w3.org/2000/svg" width="${k}" height="${E}" viewBox="0 0 ${k} ${E}"><rect fill="#e5e7eb" width="${k}" height="${E}"/></svg>`;return{dataURL:`data:image/svg+xml;charset=utf-8,${encodeURIComponent(j)}`,width:k,height:E,aspectRatio:k/E,originalWidth:0,originalHeight:0,strategy:_.strategy,dominantColor:"#e5e7eb"}}function Nm(v,_,k={}){let E=k.transitionDuration||300,T=k.easing||"ease-out";return`
|
|
2190
|
+
#${v} {
|
|
2191
|
+
--stx-img-transition-duration: ${E}ms;
|
|
2192
|
+
--stx-img-transition-easing: ${T};
|
|
2193
|
+
background-image: url('${_.dataURL}');
|
|
2194
|
+
background-size: cover;
|
|
2195
|
+
background-position: center;
|
|
2196
|
+
}
|
|
2197
|
+
|
|
2198
|
+
#${v} img {
|
|
2199
|
+
opacity: 0;
|
|
2200
|
+
transition: opacity var(--stx-img-transition-duration) var(--stx-img-transition-easing);
|
|
2201
|
+
}
|
|
2202
|
+
|
|
2203
|
+
#${v}.stx-img-loaded img {
|
|
2204
|
+
opacity: 1;
|
|
2205
|
+
}
|
|
2206
|
+
`.trim()}var Vl=new Map;async function jm(v,_={}){let k=`${v}:${JSON.stringify(_)}`;if(Vl.has(k))return Vl.get(k);let E=await OS(v,_);return Vl.set(k,E),E}async function LS(){try{return await import("./chunk-jdhs9w6h.js")}catch(v){if(!Lm)console.warn("[stx-media] Image processor not available, some features disabled:",v),Lm=!0;return null}}var Lm=!1,Hl=80,ra="async",sa="lazy",Bm=!1;async function na(v,_={}){let k=_,E=v;if(E.process&&!E.skipOptimization){if(k.tsImagesConfig?.enabled&&!k.isDev)return WS(E,k)}if(k.processedResult?.processed)return Xl(v,k.processedResult,_);if(k.responsiveVariants)return Wm(v,k.responsiveVariants,_);let{src:T,alt:j,width:B,height:z,sizes:F,widths:V=Vs,dpr:H,formats:G=Ni,quality:J=Hl,params:ne={},placeholder:re="none",placeholderOptions:se={},lazy:ie=!0,priority:oe=!1,loading:ge=oe?"eager":sa,decoding:ue=ra,fetchpriority:xe,objectFit:we,objectPosition:$e,crossorigin:_e,referrerpolicy:Ce}=v,{class:Ee,style:Te,id:Re}=v,ke=v.data||{},{isDev:Ae=!1,baseUrl:Xe=""}=_;if(Ae&&!_.optimize)return FS(v);let Pe,Ie,Ze=Re||`stx-img-${Math.random().toString(36).slice(2,8)}`;if(re!=="none"&&!oe)try{Pe=await jm(T,{strategy:re,...se}),Ie=Nm(Ze,Pe,se)}catch{}let nt=H!==void 0&&B!==void 0,at;if(nt)at=zS(v,Ze,Pe,_);else at=await BS(v,Ze,Pe,_);let rt;if(oe){let yt=G.includes("webp")?"webp":G[0],ct=zl(T,V,{...ne,q:J},yt),Pt=typeof F==="object"?Fl(F):F||"100vw";rt=`<link rel="preload" as="image" imagesrcset="${ct}" imagesizes="${Pt}" />`}let bt=[];if(!Bm&&re!=="none")bt.push(Ul),Bm=!0;if(Ie)bt.push(Ie);let ft=ie?Fm(Ze):void 0;return{html:at,preloadLink:rt,css:bt.length>0?bt.join(`
|
|
2207
|
+
`):void 0,script:ft}}async function BS(v,_,k,E){let{src:T,alt:j,width:B,height:z,sizes:F,widths:V=Vs,formats:H=Ni,quality:G=Hl,params:J={},lazy:ne=!0,priority:re=!1,loading:se=re?"eager":sa,decoding:ie=ra,fetchpriority:oe,objectFit:ge,objectPosition:ue,crossorigin:xe,referrerpolicy:we}=v,{class:$e,style:_e}=v,Ce=v.data||{},Ee=typeof F==="object"?Fl(F):F||"100vw",Te=[];for(let Ae of H){let Xe=zl(T,V,{...J,q:G},Ae),Pe=Wl(Ae);if(ne&&!re)Te.push(` <source type="${Pe}" data-srcset="${Xe}" data-sizes="${Ee}" />`);else Te.push(` <source type="${Pe}" srcset="${Xe}" sizes="${Ee}" />`)}let Re=ql({src:ji(T,{...J,q:G}),alt:j,width:B,height:z,loading:re?void 0:se,decoding:ie,fetchpriority:re?"high":oe,objectFit:ge,objectPosition:ue,crossorigin:xe,referrerpolicy:we,className:zm($e,k),style:Kl(_e,ge,ue,k),lazy:ne&&!re,data:Ce}),ke;if(k){let Ae=`background-image: url('${k.dataURL}'); background-size: cover; background-position: center;`;ke=`<div id="${_}" class="stx-img-placeholder" style="${Ae}">
|
|
2208
|
+
<picture>
|
|
2209
|
+
${Te.join(`
|
|
2210
|
+
`)}
|
|
2211
|
+
<img ${Re} />
|
|
2212
|
+
</picture>
|
|
2213
|
+
</div>`}else ke=`<picture${_?` id="${_}"`:""}>
|
|
2214
|
+
${Te.join(`
|
|
2215
|
+
`)}
|
|
2216
|
+
<img ${Re} />
|
|
2217
|
+
</picture>`;return ke}function zS(v,_,k,E){let{src:T,alt:j,width:B,height:z,dpr:F=[1,2,3],quality:V=Hl,params:H={},lazy:G=!0,priority:J=!1,loading:ne=J?"eager":sa,decoding:re=ra,fetchpriority:se,objectFit:ie,objectPosition:oe,crossorigin:ge,referrerpolicy:ue}=v,{class:xe,style:we}=v,$e=v.data||{},_e=typeof B==="number"?B:Number.parseInt(String(B),10),Ce=Om(T,_e,F,{...H,q:V}),Ee=ql({src:ji(T,{...H,w:_e,q:V}),alt:j,width:B,height:z,loading:J?void 0:ne,decoding:re,fetchpriority:J?"high":se,objectFit:ie,objectPosition:oe,crossorigin:ge,referrerpolicy:ue,className:zm(xe,k),style:Kl(we,ie,oe,k),lazy:G&&!J,data:$e}),Te=G&&!J?`data-srcset="${Ce}"`:`srcset="${Ce}"`;if(k){let Re=`background-image: url('${k.dataURL}'); background-size: cover; background-position: center;`;return`<div id="${_}" class="stx-img-placeholder" style="${Re}">
|
|
2218
|
+
<img ${Ee} ${Te} />
|
|
2219
|
+
</div>`}return`<img ${_?`id="${_}" `:""}${Ee} ${Te} />`}function FS(v){let{src:_,alt:k,width:E,height:T,loading:j=sa,decoding:B=ra,fetchpriority:z,objectFit:F,objectPosition:V,crossorigin:H,referrerpolicy:G,priority:J=!1}=v,{class:ne,style:re,id:se}=v,ie=v.data||{};return{html:`<img ${ql({src:_,alt:k,width:E,height:T,loading:J?"eager":j,decoding:B,fetchpriority:J?"high":z,objectFit:F,objectPosition:V,crossorigin:H,referrerpolicy:G,className:ne,style:Kl(re,F,V),id:se,data:ie})} />`}}function ql(v){let _=[];if(v.lazy)_.push(`data-src="${$n(v.src)}"`),_.push('src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7"');else _.push(`src="${$n(v.src)}"`);if(_.push(`alt="${$n(v.alt)}"`),v.width)_.push(`width="${v.width}"`);if(v.height)_.push(`height="${v.height}"`);if(v.loading)_.push(`loading="${v.loading}"`);if(v.decoding)_.push(`decoding="${v.decoding}"`);if(v.fetchpriority)_.push(`fetchpriority="${v.fetchpriority}"`);if(v.crossorigin)_.push(`crossorigin="${v.crossorigin}"`);if(v.referrerpolicy)_.push(`referrerpolicy="${v.referrerpolicy}"`);if(v.className)_.push(`class="${$n(v.className)}"`);if(v.style)_.push(`style="${$n(v.style)}"`);if(v.id)_.push(`id="${$n(v.id)}"`);if(v.data)for(let[k,E]of Object.entries(v.data))_.push(`data-${k}="${$n(E)}"`);if(v.lazy)_.push("data-stx-lazy");return _.join(" ")}function zm(v,_){let k=[];if(v)k.push(v);if(_)k.push("stx-img-blur");return k.join(" ")||""}function Kl(v,_,k,E){let T=[];if(_)T.push(`object-fit: ${_}`);if(k)T.push(`object-position: ${k}`);if(E)T.push("opacity: 0; transition: opacity 300ms ease-out");if(v)T.push(v);return T.join("; ")}function $n(v){return v.replace(/&/g,"&").replace(/"/g,""").replace(/'/g,"'").replace(/</g,"<").replace(/>/g,">")}function Fm(v){return`
|
|
2220
|
+
(function() {
|
|
2221
|
+
const container = document.getElementById('${v}');
|
|
2222
|
+
if (!container) return;
|
|
2223
|
+
|
|
2224
|
+
const img = container.querySelector('img[data-stx-lazy]') || container;
|
|
2225
|
+
if (!img.dataset.src && !img.dataset.srcset) return;
|
|
2226
|
+
|
|
2227
|
+
const observer = new IntersectionObserver((entries) => {
|
|
2228
|
+
entries.forEach(entry => {
|
|
2229
|
+
if (entry.isIntersecting) {
|
|
2230
|
+
// Load image
|
|
2231
|
+
if (img.dataset.src) img.src = img.dataset.src;
|
|
2232
|
+
if (img.dataset.srcset) img.srcset = img.dataset.srcset;
|
|
2233
|
+
|
|
2234
|
+
// Load sources
|
|
2235
|
+
const sources = container.querySelectorAll('source[data-srcset]');
|
|
2236
|
+
sources.forEach(source => {
|
|
2237
|
+
if (source.dataset.srcset) source.srcset = source.dataset.srcset;
|
|
2238
|
+
if (source.dataset.sizes) source.sizes = source.dataset.sizes;
|
|
2239
|
+
});
|
|
2240
|
+
|
|
2241
|
+
// Handle load completion
|
|
2242
|
+
img.onload = () => {
|
|
2243
|
+
img.style.opacity = '1';
|
|
2244
|
+
if (container.classList.contains('stx-img-placeholder')) {
|
|
2245
|
+
container.classList.add('stx-img-loaded');
|
|
2246
|
+
}
|
|
2247
|
+
};
|
|
2248
|
+
|
|
2249
|
+
observer.disconnect();
|
|
2250
|
+
}
|
|
2251
|
+
});
|
|
2252
|
+
}, { rootMargin: '50px' });
|
|
2253
|
+
|
|
2254
|
+
observer.observe(container);
|
|
2255
|
+
})();
|
|
2256
|
+
`.trim()}async function WS(v,_){let k=await LS();if(!k)return na({...v,process:!1},_);let E=_.tsImagesConfig;if(v.responsiveWidths&&v.responsiveWidths.length>0||v.widths&&v.widths.length>0||!v.width&&!v.dpr){let j=await k.generateResponsiveVariants(v.src,v,E);if(j)return Wm(v,j,_)}else{let j=await k.processImage(v.src,v,E);if(j.processed)return Xl(v,j,_)}return na({...v,process:!1},_)}async function Xl(v,_,k){let{alt:E,width:T,height:j,lazy:B=!0,priority:z=!1,objectFit:F,objectPosition:V,crossorigin:H,referrerpolicy:G}=v,{class:J,style:ne}=v,re=v.id||`stx-img-${Math.random().toString(36).slice(2,8)}`,se=v.data||{},ie=_.variants||[],oe=ie.find((Ie)=>Ie.format==="jpeg")||ie.find((Ie)=>Ie.format==="webp")||ie[0],ge=oe?.url||v.src,ue=ie.filter((Ie)=>Ie.format===(oe?.format||"jpeg")).map((Ie)=>`${Ie.url} ${Ie.width}w`).join(", "),xe=new Map;for(let Ie of ie){if(!xe.has(Ie.format))xe.set(Ie.format,[]);xe.get(Ie.format).push(Ie)}let we=[],$e=["avif","webp","jpeg","png"];for(let Ie of $e){let Ze=xe.get(Ie);if(Ze&&Ze.length>0){let nt=Ze.map((rt)=>`${rt.url} ${rt.width}w`).join(", "),at=Wl(Ie);if(B&&!z)we.push(` <source type="${at}" data-srcset="${nt}" />`);else we.push(` <source type="${at}" srcset="${nt}" />`)}}let _e=[];if(B&&!z){if(_e.push(`data-src="${$n(ge)}"`),_e.push('src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7"'),ue)_e.push(`data-srcset="${ue}"`)}else if(_e.push(`src="${$n(ge)}"`),ue)_e.push(`srcset="${ue}"`);_e.push(`alt="${$n(E)}"`);let Ce=T||_.originalWidth,Ee=j||_.originalHeight;if(Ce)_e.push(`width="${Ce}"`);if(Ee)_e.push(`height="${Ee}"`);if(!z)_e.push(`loading="${B?"lazy":"eager"}"`);if(_e.push('decoding="async"'),z)_e.push('fetchpriority="high"');if(H)_e.push(`crossorigin="${H}"`);if(G)_e.push(`referrerpolicy="${G}"`);let Te=[];if(F)Te.push(`object-fit: ${F}`);if(V)Te.push(`object-position: ${V}`);if(_.placeholder&&B)Te.push("opacity: 0; transition: opacity 300ms ease-out");if(ne)Te.push(ne);if(Te.length>0)_e.push(`style="${Te.join("; ")}"`);let Re=[];if(J)Re.push(J);if(_.placeholder)Re.push("stx-img-blur");if(Re.length>0)_e.push(`class="${Re.join(" ")}"`);if(B&&!z)_e.push("data-stx-lazy");for(let[Ie,Ze]of Object.entries(se))_e.push(`data-${Ie}="${$n(Ze)}"`);let ke;if(_.placeholder||_.dominantColor&&v.useDominantColor){let Ie=_.placeholder?`background-image: url('${_.placeholder}'); background-size: cover; background-position: center;`:`background-color: ${_.dominantColor};`;ke=`<div id="${re}" class="stx-img-placeholder" style="${Ie}">
|
|
2257
|
+
<picture>
|
|
2258
|
+
${we.join(`
|
|
2259
|
+
`)}
|
|
2260
|
+
<img ${_e.join(" ")} />
|
|
2261
|
+
</picture>
|
|
2262
|
+
</div>`}else ke=`<picture${re?` id="${re}"`:""}>
|
|
2263
|
+
${we.join(`
|
|
2264
|
+
`)}
|
|
2265
|
+
<img ${_e.join(" ")} />
|
|
2266
|
+
</picture>`;let Ae=[];if(_.placeholder)Ae.push(Ul);let Xe=B?Fm(re):void 0,Pe;if(z&&ue)Pe=`<link rel="preload" as="image" imagesrcset="${ue}" />`;return{html:ke,preloadLink:Pe,css:Ae.length>0?Ae.join(`
|
|
2267
|
+
`):void 0,script:Xe}}async function Wm(v,_,k){let E={src:_.src,processed:!0,variants:[],placeholder:_.placeholder?.dataURL,originalWidth:_.placeholder?.width,originalHeight:_.placeholder?.height};for(let[T,j]of Object.entries(_.byFormat))if(j)E.variants.push(...j);return Xl(v,E,k)}function VS(){return qe({name:"img",hasEndTag:!1,description:"Render an optimized responsive image with srcset and lazy loading",transform:async(v,_,k,E)=>{let{src:T,alt:j,options:B}=US(v,_,k);if(!T)return console.warn("@img directive: missing src argument"),"<!-- @img: missing src -->";let z={src:T,alt:j||"",widths:B.widths||Vs,formats:B.formats||Ni,quality:B.quality,sizes:B.sizes,dpr:B.dpr,params:B.params,placeholder:B.placeholder,placeholderOptions:B.placeholderOptions,lazy:B.lazy!==!1,priority:B.priority||!1,loading:B.loading,decoding:B.decoding,fetchpriority:B.fetchpriority,objectFit:B.objectFit,objectPosition:B.objectPosition,class:B.class,style:B.style,id:B.id,width:B.width,height:B.height},F=k.__isDev||!1,V=await na(z,{isDev:F}),H=V.html;if(V.preloadLink)H=V.preloadLink+`
|
|
2268
|
+
`+H;if(V.css)H+=`
|
|
2269
|
+
<style>${V.css}</style>`;if(V.script)H+=`
|
|
2270
|
+
<script>${V.script}</script>`;return H},defaults:{src:"",alt:"",options:{lazy:!0,placeholder:"none"}}})}function US(v,_,k){if(_.src)return{src:String(_.src),alt:String(_.alt||""),options:_.options||{}};let E=v.trim();if(E.startsWith("@img(")||E.startsWith("("))E=E.replace(/^@img\(/,"").replace(/^\(/,"").replace(/\)$/,"");let T=HS(E),j=Zl(T[0],k)||"",B=Zl(T[1],k)||"",z={};if(T[2]){let F=Zl(T[2],k);if(typeof F==="object"&&F!==null)z=F;else if(typeof T[2]==="string")try{z=JSON.parse(T[2])}catch{}}return{src:j,alt:B,options:z}}function HS(v){let _=[],k="",E=!1,T="",j=0,B=0;for(let z=0;z<v.length;z++){let F=v[z],V=z>0?v[z-1]:"";if((F==='"'||F==="'"||F==="`")&&V!=="\\"){if(!E)E=!0,T=F;else if(F===T)E=!1,T="";else k+=F;continue}if(!E){if(F==="{")j++;if(F==="}")j--;if(F==="[")B++;if(F==="]")B--;if(F===","&&j===0&&B===0){_.push(k.trim()),k="";continue}}k+=F}if(k.trim())_.push(k.trim());return _}function Zl(v,_){if(typeof v!=="string")return v;let k=v.trim();if(k.startsWith('"')&&k.endsWith('"')||k.startsWith("'")&&k.endsWith("'"))return k.slice(1,-1);if(!k.startsWith("/")&&!k.startsWith(".")&&!k.startsWith("http")&&!k.startsWith("{")){let E=_[k];if(E!==void 0)return E}if(k.startsWith("{")||k.startsWith("["))try{return JSON.parse(k)}catch{}return k}var Vm=VS();async function Hm(){try{return await import("./chunk-hskrxdcc.js")}catch(v){if(!Um)console.warn("[stx-media] Video processor not available, some features disabled:",v),Um=!0;return null}}var Um=!1,qm=!0,Km="metadata",qS="https://cdn.jsdelivr.net/npm/ts-video-player@latest/dist/index.min.js";async function ia(v,_={}){let k=_,E=v;if(E.process&&!E.skipProcessing){if(k.tsVideosConfig?.enabled&&!k.isDev)return JS(E,k)}if(k.processedResult?.processed)return Zm(v,k.processedResult,_);let T;if(E.generatePoster&&E.src&&!v.poster)T=await YS(E,k);let{src:j,sources:B=[],poster:z,posterPlaceholder:F,controls:V=qm,autoplay:H=!1,muted:G=!1,loop:J=!1,preload:ne=Km,playsinline:re=!0,lazy:se=!0,player:ie="native",type:oe,width:ge,height:ue,crossorigin:xe,disablePictureInPicture:we=!1,disableRemotePlayback:$e=!1}=v,_e=T||z,{class:Ce,style:Ee}=v,Te=v.id||`stx-video-${Math.random().toString(36).slice(2,8)}`;if(ie==="ts-video")return XS(v,_);if(oe&&oe!=="video")return KS(j||"",oe,v);let Re=B.length>0?B:j?[{src:j,type:Xm(j)}]:[],ke=[`id="${Te}"`];if(V)ke.push("controls");if(H)ke.push("autoplay");if(G)ke.push("muted");if(J)ke.push("loop");if(re)ke.push("playsinline");if(we)ke.push("disablepictureinpicture");if($e)ke.push("disableremoteplayback");if(xe)ke.push(`crossorigin="${xe}"`);if(se){if(ke.push(`data-preload="${ne}"`),ke.push('preload="none"'),_e)ke.push(`data-poster="${Ht(_e)}"`);ke.push("data-stx-lazy")}else if(ke.push(`preload="${ne}"`),_e)ke.push(`poster="${Ht(_e)}"`);if(ge)ke.push(`width="${ge}"`);if(ue)ke.push(`height="${ue}"`);if(Ce)ke.push(`class="${Ht(Ce)}"`);if(Ee)ke.push(`style="${Ht(Ee)}"`);let Ae=Re.map((Ie)=>` <source ${se?`data-src="${Ht(Ie.src)}"`:`src="${Ht(Ie.src)}"`} type="${Ie.type}"${Ie.media?` media="${Ie.media}"`:""} />`).join(`
|
|
2271
|
+
`),Xe=`<video ${ke.join(" ")}>
|
|
2272
|
+
${Ae}
|
|
2273
|
+
Your browser does not support the video tag.
|
|
2274
|
+
</video>`,Pe;if(se)Pe=`
|
|
2275
|
+
(function() {
|
|
2276
|
+
var video = document.getElementById('${Te}');
|
|
2277
|
+
if (!video) return;
|
|
2278
|
+
|
|
2279
|
+
var observer = new IntersectionObserver(function(entries) {
|
|
2280
|
+
entries.forEach(function(entry) {
|
|
2281
|
+
if (entry.isIntersecting) {
|
|
2282
|
+
// Load poster
|
|
2283
|
+
if (video.dataset.poster) {
|
|
2284
|
+
video.poster = video.dataset.poster;
|
|
2285
|
+
delete video.dataset.poster;
|
|
2286
|
+
}
|
|
2287
|
+
|
|
2288
|
+
// Load sources
|
|
2289
|
+
var sources = video.querySelectorAll('source[data-src]');
|
|
2290
|
+
sources.forEach(function(source) {
|
|
2291
|
+
source.src = source.dataset.src;
|
|
2292
|
+
delete source.dataset.src;
|
|
2293
|
+
});
|
|
2294
|
+
|
|
2295
|
+
// Set preload
|
|
2296
|
+
if (video.dataset.preload) {
|
|
2297
|
+
video.preload = video.dataset.preload;
|
|
2298
|
+
delete video.dataset.preload;
|
|
2299
|
+
}
|
|
2300
|
+
|
|
2301
|
+
video.load();
|
|
2302
|
+
observer.disconnect();
|
|
2303
|
+
}
|
|
2304
|
+
});
|
|
2305
|
+
}, { rootMargin: '50px' });
|
|
2306
|
+
|
|
2307
|
+
observer.observe(video);
|
|
2308
|
+
})();
|
|
2309
|
+
`.trim();return{html:Xe,script:Pe}}function KS(v,_,k){let{width:E=640,height:T=360}=k,{class:j,style:B}=k,z=k.id||`stx-embed-${Math.random().toString(36).slice(2,8)}`,F,V=null;switch(_){case"youtube":V=ZS(v),F=V?`https://www.youtube-nocookie.com/embed/${V}`:v;break;case"vimeo":V=GS(v),F=V?`https://player.vimeo.com/video/${V}`:v;break;case"dailymotion":V=v.split("/").pop()||"",F=`https://www.dailymotion.com/embed/video/${V}`;break;case"twitch":V=v.split("/").pop()||"",F=`https://player.twitch.tv/?video=${V}&parent=${typeof window<"u"?window.location.hostname:"localhost"}`;break;default:F=v}let H=[`id="${z}"`,`src="${Ht(F)}"`,`width="${E}"`,`height="${T}"`,'frameborder="0"',"allowfullscreen",'allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"'];if(j)H.push(`class="${Ht(j)}"`);if(B)H.push(`style="${Ht(B)}"`);if(k.lazy)H.push('loading="lazy"');return{html:`<div class="stx-video-embed" style="position:relative;padding-bottom:56.25%;height:0;overflow:hidden;">
|
|
2310
|
+
<iframe ${H.join(" ")} style="position:absolute;top:0;left:0;width:100%;height:100%;"></iframe>
|
|
2311
|
+
</div>`}}function XS(v,_={}){let{src:k,sources:E=[],poster:T,controls:j=!0,autoplay:B=!1,muted:z=!1,loop:F=!1,preload:V="metadata",playsinline:H=!0,lazy:G=!0,width:J,height:ne}=v,{class:re,style:se}=v,ie=v.id||`ts-video-${Math.random().toString(36).slice(2,8)}`,oe={src:E.length>0?E:k,autoplay:B,loop:F,muted:z,playsinline:H,preload:V,poster:T,controls:j,title:v.title},ge=["position: relative",J?`width: ${typeof J==="number"?J+"px":J}`:"width: 100%",ne?`height: ${typeof ne==="number"?ne+"px":ne}`:"",se||""].filter(Boolean).join("; "),ue=`
|
|
2312
|
+
<div
|
|
2313
|
+
id="${ie}"
|
|
2314
|
+
class="ts-video-player${re?" "+Ht(re):""}"
|
|
2315
|
+
style="${ge}"
|
|
2316
|
+
data-ts-video-player
|
|
2317
|
+
data-config='${JSON.stringify(oe)}'
|
|
2318
|
+
${G?"data-lazy":""}
|
|
2319
|
+
>
|
|
2320
|
+
<div class="ts-video-player__container">
|
|
2321
|
+
${T?`
|
|
2322
|
+
<div class="ts-video-player__placeholder" style="background-image: url('${Ht(T)}');">
|
|
2323
|
+
<button class="ts-video-player__play-button" aria-label="Play video">
|
|
2324
|
+
<svg viewBox="0 0 24 24" fill="currentColor" width="64" height="64">
|
|
2325
|
+
<path d="M8 5v14l11-7z"/>
|
|
2326
|
+
</svg>
|
|
2327
|
+
</button>
|
|
2328
|
+
</div>
|
|
2329
|
+
`:""}
|
|
2330
|
+
</div>
|
|
2331
|
+
</div>
|
|
2332
|
+
`.trim(),xe=`
|
|
2333
|
+
(function() {
|
|
2334
|
+
var container = document.getElementById('${ie}');
|
|
2335
|
+
if (!container) return;
|
|
2336
|
+
|
|
2337
|
+
var config = JSON.parse(container.dataset.config || '{}');
|
|
2338
|
+
var isLazy = container.hasAttribute('data-lazy');
|
|
2339
|
+
|
|
2340
|
+
function loadPlayer() {
|
|
2341
|
+
if (typeof TSVideoPlayer !== 'undefined') {
|
|
2342
|
+
initPlayer();
|
|
2343
|
+
return;
|
|
2344
|
+
}
|
|
2345
|
+
|
|
2346
|
+
// Load ts-video-player from CDN
|
|
2347
|
+
var script = document.createElement('script');
|
|
2348
|
+
script.src = '${qS}';
|
|
2349
|
+
script.onload = initPlayer;
|
|
2350
|
+
script.onerror = function() {
|
|
2351
|
+
console.error('[stx] Failed to load ts-video-player');
|
|
2352
|
+
fallbackToNative();
|
|
2353
|
+
};
|
|
2354
|
+
document.head.appendChild(script);
|
|
2355
|
+
}
|
|
2356
|
+
|
|
2357
|
+
function initPlayer() {
|
|
2358
|
+
var player = TSVideoPlayer.createPlayer(container, config);
|
|
2359
|
+
if (config.src) {
|
|
2360
|
+
player.setSrc(config.src);
|
|
2361
|
+
}
|
|
2362
|
+
container.__tsVideoPlayer = player;
|
|
2363
|
+
|
|
2364
|
+
// Remove placeholder
|
|
2365
|
+
var placeholder = container.querySelector('.ts-video-player__placeholder');
|
|
2366
|
+
if (placeholder) {
|
|
2367
|
+
placeholder.style.display = 'none';
|
|
2368
|
+
}
|
|
2369
|
+
}
|
|
2370
|
+
|
|
2371
|
+
function fallbackToNative() {
|
|
2372
|
+
// Fallback to native video element
|
|
2373
|
+
var video = document.createElement('video');
|
|
2374
|
+
video.controls = config.controls !== false;
|
|
2375
|
+
video.autoplay = config.autoplay;
|
|
2376
|
+
video.muted = config.muted;
|
|
2377
|
+
video.loop = config.loop;
|
|
2378
|
+
video.playsInline = config.playsinline;
|
|
2379
|
+
video.preload = config.preload || 'metadata';
|
|
2380
|
+
if (config.poster) video.poster = config.poster;
|
|
2381
|
+
if (config.src) video.src = typeof config.src === 'string' ? config.src : config.src[0]?.src || config.src[0];
|
|
2382
|
+
video.style.width = '100%';
|
|
2383
|
+
video.style.height = '100%';
|
|
2384
|
+
|
|
2385
|
+
var containerEl = container.querySelector('.ts-video-player__container');
|
|
2386
|
+
if (containerEl) {
|
|
2387
|
+
containerEl.innerHTML = '';
|
|
2388
|
+
containerEl.appendChild(video);
|
|
2389
|
+
}
|
|
2390
|
+
}
|
|
2391
|
+
|
|
2392
|
+
if (isLazy) {
|
|
2393
|
+
var observer = new IntersectionObserver(function(entries) {
|
|
2394
|
+
entries.forEach(function(entry) {
|
|
2395
|
+
if (entry.isIntersecting) {
|
|
2396
|
+
loadPlayer();
|
|
2397
|
+
observer.disconnect();
|
|
2398
|
+
}
|
|
2399
|
+
});
|
|
2400
|
+
}, { rootMargin: '50px' });
|
|
2401
|
+
observer.observe(container);
|
|
2402
|
+
}
|
|
2403
|
+
else {
|
|
2404
|
+
if (document.readyState === 'loading') {
|
|
2405
|
+
document.addEventListener('DOMContentLoaded', loadPlayer);
|
|
2406
|
+
}
|
|
2407
|
+
else {
|
|
2408
|
+
loadPlayer();
|
|
2409
|
+
}
|
|
2410
|
+
}
|
|
2411
|
+
|
|
2412
|
+
// Handle play button click
|
|
2413
|
+
var playButton = container.querySelector('.ts-video-player__play-button');
|
|
2414
|
+
if (playButton) {
|
|
2415
|
+
playButton.addEventListener('click', function() {
|
|
2416
|
+
loadPlayer();
|
|
2417
|
+
var check = setInterval(function() {
|
|
2418
|
+
if (container.__tsVideoPlayer && container.__tsVideoPlayer.ready) {
|
|
2419
|
+
container.__tsVideoPlayer.play();
|
|
2420
|
+
clearInterval(check);
|
|
2421
|
+
}
|
|
2422
|
+
}, 100);
|
|
2423
|
+
});
|
|
2424
|
+
}
|
|
2425
|
+
})();
|
|
2426
|
+
`.trim(),we=`
|
|
2427
|
+
.ts-video-player {
|
|
2428
|
+
position: relative;
|
|
2429
|
+
background: #000;
|
|
2430
|
+
}
|
|
2431
|
+
|
|
2432
|
+
.ts-video-player__container {
|
|
2433
|
+
position: relative;
|
|
2434
|
+
width: 100%;
|
|
2435
|
+
padding-bottom: 56.25%;
|
|
2436
|
+
}
|
|
2437
|
+
|
|
2438
|
+
.ts-video-player__container > * {
|
|
2439
|
+
position: absolute;
|
|
2440
|
+
top: 0;
|
|
2441
|
+
left: 0;
|
|
2442
|
+
width: 100%;
|
|
2443
|
+
height: 100%;
|
|
2444
|
+
}
|
|
2445
|
+
|
|
2446
|
+
.ts-video-player__placeholder {
|
|
2447
|
+
display: flex;
|
|
2448
|
+
align-items: center;
|
|
2449
|
+
justify-content: center;
|
|
2450
|
+
background-color: #1a1a1a;
|
|
2451
|
+
background-size: cover;
|
|
2452
|
+
background-position: center;
|
|
2453
|
+
cursor: pointer;
|
|
2454
|
+
}
|
|
2455
|
+
|
|
2456
|
+
.ts-video-player__play-button {
|
|
2457
|
+
display: flex;
|
|
2458
|
+
align-items: center;
|
|
2459
|
+
justify-content: center;
|
|
2460
|
+
width: 80px;
|
|
2461
|
+
height: 80px;
|
|
2462
|
+
background: rgba(0, 0, 0, 0.7);
|
|
2463
|
+
border: none;
|
|
2464
|
+
border-radius: 50%;
|
|
2465
|
+
color: white;
|
|
2466
|
+
cursor: pointer;
|
|
2467
|
+
transition: transform 0.2s, background 0.2s;
|
|
2468
|
+
}
|
|
2469
|
+
|
|
2470
|
+
.ts-video-player__play-button:hover {
|
|
2471
|
+
transform: scale(1.1);
|
|
2472
|
+
background: rgba(0, 0, 0, 0.9);
|
|
2473
|
+
}
|
|
2474
|
+
|
|
2475
|
+
.ts-video-player__play-button svg {
|
|
2476
|
+
margin-left: 4px;
|
|
2477
|
+
}
|
|
2478
|
+
`.trim();return{html:ue,script:xe,css:we}}function Xm(v){switch(v.split(".").pop()?.toLowerCase()){case"mp4":return"video/mp4";case"webm":return"video/webm";case"ogg":case"ogv":return"video/ogg";case"mov":return"video/quicktime";case"avi":return"video/x-msvideo";case"mkv":return"video/x-matroska";case"m3u8":return"application/x-mpegURL";default:return"video/mp4"}}function ZS(v){let _=[/youtube\.com\/watch\?v=([^&]+)/,/youtube\.com\/embed\/([^?]+)/,/youtu\.be\/([^?]+)/,/youtube\.com\/v\/([^?]+)/];for(let k of _){let E=v.match(k);if(E)return E[1]}return null}function GS(v){let _=v.match(/vimeo\.com\/(\d+)/);return _?_[1]:null}function Ht(v){return v.replace(/&/g,"&").replace(/"/g,""").replace(/'/g,"'")}async function JS(v,_){let k=await Hm();if(!k)return ia({...v,process:!1},_);let E=_.tsVideosConfig,T=await k.processVideo(v.src,v,E,v.onProcessProgress);if(T.processed)return Zm(v,T,_);return ia({...v,process:!1},_)}async function YS(v,_){let k=await Hm();if(!k||!v.src)return;let E=typeof v.generatePoster==="object"?v.generatePoster:{timestamp:0},T=_.tsVideosConfig||{enabled:!0,outputDir:"dist/videos",baseUrl:"/videos"};return(await k.generatePoster(v.src,E,T.outputDir,T.baseUrl||"/videos"))?.url}function Zm(v,_,k){let{controls:E=qm,autoplay:T=!1,muted:j=!1,loop:B=!1,preload:z=Km,playsinline:F=!0,lazy:V=!0,width:H,height:G,crossorigin:J,disablePictureInPicture:ne=!1,disableRemotePlayback:re=!1}=v,{class:se,style:ie}=v,oe=v.id||`stx-video-${Math.random().toString(36).slice(2,8)}`,ge=v.src,ue=Xm(ge);if(_.transcoded)ge=_.transcoded.url,ue="video/mp4";let xe=_.streaming?.hls||_.streaming?.dash;if(xe){if(_.streaming?.hls)ge=_.streaming.hls.manifestUrl,ue="application/x-mpegURL";else if(_.streaming?.dash)ge=_.streaming.dash.manifestUrl,ue="application/dash+xml"}let we=_.poster?.url||v.poster,$e=[`id="${oe}"`];if(E)$e.push("controls");if(T)$e.push("autoplay");if(j)$e.push("muted");if(B)$e.push("loop");if(F)$e.push("playsinline");if(ne)$e.push("disablepictureinpicture");if(re)$e.push("disableremoteplayback");if(J)$e.push(`crossorigin="${J}"`);if(V){if($e.push(`data-preload="${z}"`),$e.push('preload="none"'),we)$e.push(`data-poster="${Ht(we)}"`);$e.push("data-stx-lazy")}else if($e.push(`preload="${z}"`),we)$e.push(`poster="${Ht(we)}"`);let _e=H||_.metadata?.width,Ce=G||_.metadata?.height;if(_e)$e.push(`width="${_e}"`);if(Ce)$e.push(`height="${Ce}"`);if(se)$e.push(`class="${Ht(se)}"`);if(ie)$e.push(`style="${Ht(ie)}"`);let Te=` <source ${V?`data-src="${Ht(ge)}"`:`src="${Ht(ge)}"`} type="${ue}" />`,Re=`<video ${$e.join(" ")}>
|
|
2479
|
+
${Te}
|
|
2480
|
+
Your browser does not support the video tag.
|
|
2481
|
+
</video>`;if(_.spriteSheet)Re=`<div class="stx-video-wrapper" data-sprite-sheet="${Ht(_.spriteSheet.url)}" data-sprite-cols="${_.spriteSheet.columns}" data-sprite-interval="${_.spriteSheet.interval}">
|
|
2482
|
+
${Re}
|
|
2483
|
+
</div>`;let ke;if(V)ke=`
|
|
2484
|
+
(function() {
|
|
2485
|
+
var video = document.getElementById('${oe}');
|
|
2486
|
+
if (!video) return;
|
|
2487
|
+
|
|
2488
|
+
var observer = new IntersectionObserver(function(entries) {
|
|
2489
|
+
entries.forEach(function(entry) {
|
|
2490
|
+
if (entry.isIntersecting) {
|
|
2491
|
+
// Load poster
|
|
2492
|
+
if (video.dataset.poster) {
|
|
2493
|
+
video.poster = video.dataset.poster;
|
|
2494
|
+
delete video.dataset.poster;
|
|
2495
|
+
}
|
|
2496
|
+
|
|
2497
|
+
// Load sources
|
|
2498
|
+
var sources = video.querySelectorAll('source[data-src]');
|
|
2499
|
+
sources.forEach(function(source) {
|
|
2500
|
+
source.src = source.dataset.src;
|
|
2501
|
+
delete source.dataset.src;
|
|
2502
|
+
});
|
|
2503
|
+
|
|
2504
|
+
// Set preload
|
|
2505
|
+
if (video.dataset.preload) {
|
|
2506
|
+
video.preload = video.dataset.preload;
|
|
2507
|
+
delete video.dataset.preload;
|
|
2508
|
+
}
|
|
2509
|
+
|
|
2510
|
+
video.load();
|
|
2511
|
+
observer.disconnect();
|
|
2512
|
+
}
|
|
2513
|
+
});
|
|
2514
|
+
}, { rootMargin: '50px' });
|
|
2515
|
+
|
|
2516
|
+
observer.observe(video);
|
|
2517
|
+
})();
|
|
2518
|
+
`.trim();let Ae;if(xe)Ae=`
|
|
2519
|
+
.stx-video-wrapper {
|
|
2520
|
+
position: relative;
|
|
2521
|
+
width: 100%;
|
|
2522
|
+
}
|
|
2523
|
+
.stx-video-wrapper video {
|
|
2524
|
+
width: 100%;
|
|
2525
|
+
height: auto;
|
|
2526
|
+
}
|
|
2527
|
+
`.trim();return{html:Re,script:ke,css:Ae}}function Gm(){return qe({name:"video",hasEndTag:!1,description:"Render a video with optional ts-videos processing, streaming, and poster generation",transform:async(v,_,k,E)=>{let{src:T,options:j}=QS(v,_,k);if(!T)return console.warn("@video directive: missing src argument"),"<!-- @video: missing src -->";let B={src:T,poster:j.poster,controls:j.controls!==!1,autoplay:j.autoplay||!1,muted:j.muted||!1,loop:j.loop||!1,preload:j.preload||"metadata",playsinline:j.playsinline!==!1,lazy:j.lazy!==!1,player:j.player||"native",type:j.type,width:j.width,height:j.height,class:j.class,style:j.style,id:j.id,crossorigin:j.crossorigin,disablePictureInPicture:j.disablePictureInPicture,disableRemotePlayback:j.disableRemotePlayback,title:j.title,quality:j.quality,platform:j.platform,process:j.process,generatePoster:j.generatePoster,streaming:j.streaming,transcode:j.transcode,spriteSheet:j.spriteSheet,waveform:j.waveform},F={isDev:k.__isDev||!1,tsVideosConfig:k.__tsVideosConfig},V=await ia(B,F),H=V.html;if(V.css)H+=`
|
|
2528
|
+
<style>${V.css}</style>`;if(V.script)H+=`
|
|
2529
|
+
<script>${V.script}</script>`;return H},defaults:{src:"",options:{controls:!0,lazy:!0,preload:"metadata"}}})}function QS(v,_,k){if(_.src)return{src:String(_.src),options:_.options||{}};let E=v.trim();if(E.startsWith("@video(")||E.startsWith("("))E=E.replace(/^@video\(/,"").replace(/^\(/,"").replace(/\)$/,"");let T=e0(E),j=Jm(T[0],k)||"",B={};if(T[1]){let z=Jm(T[1],k);if(typeof z==="object"&&z!==null)B=z;else if(typeof T[1]==="string")try{B=JSON.parse(T[1])}catch{}}return{src:j,options:B}}function e0(v){let _=[],k="",E=!1,T="",j=0,B=0;for(let z=0;z<v.length;z++){let F=v[z],V=z>0?v[z-1]:"";if((F==='"'||F==="'"||F==="`")&&V!=="\\"){if(!E)E=!0,T=F;else if(F===T)E=!1,T="";else k+=F;continue}if(!E){if(F==="{")j++;if(F==="}")j--;if(F==="[")B++;if(F==="]")B--;if(F===","&&j===0&&B===0){_.push(k.trim()),k="";continue}}k+=F}if(k.trim())_.push(k.trim());return _}function Jm(v,_){if(typeof v!=="string")return v;let k=v.trim();if(k.startsWith('"')&&k.endsWith('"')||k.startsWith("'")&&k.endsWith("'"))return k.slice(1,-1);if(!k.startsWith("/")&&!k.startsWith(".")&&!k.startsWith("http")&&!k.startsWith("{")){let E=_[k];if(E!==void 0)return E}if(k.startsWith("{")||k.startsWith("["))try{return JSON.parse(k)}catch{}return k}var Gl=Gm();import t0 from"fs";import wn from"path";async function Kn(v,_){if(!v.webComponents?.enabled)return[];let k=v.webComponents.components||[],E=[];if(k.length>0){if(v.debug)console.log(`Building ${k.length} web components...`);for(let T of k)try{let j=await n0(T,v,_);if(j)E.push(j)}catch(j){if(console.error(`Error building web component ${T.name}:`,j),v.debug)throw j}}return E}async function n0(v,_,k){let{name:E,file:T,tag:j,extends:B}=v;if(!E||!T||!j)return console.error("Invalid web component configuration, missing required fields:",v),null;let z=null;if(wn.isAbsolute(T)&&await r(T))z=T;else if(_.componentsDir){let se=wn.join(_.componentsDir,T);if(await r(se))z=se}if(!z)z=await qn(T,process.cwd(),_,k);if(!z)return console.error(`Web component source file not found: ${T}`),null;let F=await Bun.file(z).text();k.add(z);let H=(v.outputFormat||"js")==="ts",G=H?s0({name:E,tag:j,baseElement:B,source:F,shadowDOM:v.shadowDOM??!0,template:v.template??!0,styleSource:v.styleSource,attributes:v.attributes||[],attributeTypes:v.attributeTypes||{}}):r0({name:E,tag:j,baseElement:B,source:F,shadowDOM:v.shadowDOM??!0,template:v.template??!0,styleSource:v.styleSource,attributes:v.attributes||[]}),J=_.webComponents?.outputDir||"dist/web-components";await t0.promises.mkdir(J,{recursive:!0});let ne=H?"ts":"js",re=wn.join(J,`${j}.${ne}`);if(await Bun.write(re,G),_.debug)console.log(`Built web component ${E} -> ${re}`);return re}function r0(v){let{name:_,tag:k,baseElement:E="HTMLElement",source:T,shadowDOM:j,template:B,styleSource:z,attributes:F=[]}=v,V=T.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,"").trim();if(!j)V=V.replace(/<slot\s+name=["']([^"']+)["']\s*>([\s\S]*?)<\/slot>/gi,'<div data-slot="$1">$2</div>'),V=V.replace(/<slot\s+name=["']([^"']+)["']\s*\/>/gi,'<div data-slot="$1"></div>'),V=V.replace(/<slot\s*>([\s\S]*?)<\/slot>/gi,"<div data-default-slot>$1</div>"),V=V.replace(/<slot\s*\/>/gi,"<div data-default-slot></div>");let H="";if(z)H=`<link rel="stylesheet" href="${z}">`;return`/**
|
|
2530
|
+
* ${_} Web Component
|
|
2531
|
+
* Auto-generated from stx component
|
|
2532
|
+
*/
|
|
2533
|
+
class ${_.replace(/\W/g,"")} extends ${E} {
|
|
2534
|
+
constructor() {
|
|
2535
|
+
super()
|
|
2536
|
+
this._initialized = false
|
|
2537
|
+
${j?"":"this._slotContent = []"}
|
|
2538
|
+
${j?'this.attachShadow({ mode: "open" })':""}
|
|
2539
|
+
}
|
|
2540
|
+
|
|
2541
|
+
${B?`
|
|
2542
|
+
_createTemplate() {
|
|
2543
|
+
const template = document.createElement('template')
|
|
2544
|
+
template.innerHTML = \`${H}${V}\`
|
|
2545
|
+
${j?"this.shadowRoot.appendChild(template.content.cloneNode(true))":"this.appendChild(template.content.cloneNode(true))"}
|
|
2546
|
+
this._processSlots()
|
|
2547
|
+
}
|
|
2548
|
+
`:`
|
|
2549
|
+
_render() {
|
|
2550
|
+
${j?"this.shadowRoot.innerHTML":"this.innerHTML"} = \`${H}${V}\`
|
|
2551
|
+
this._processSlots()
|
|
2552
|
+
}
|
|
2553
|
+
`}
|
|
2554
|
+
|
|
2555
|
+
_processSlots() {
|
|
2556
|
+
${j?`// Shadow DOM handles slot assignment automatically
|
|
2557
|
+
// Listen for slot changes if needed
|
|
2558
|
+
const slots = this.shadowRoot.querySelectorAll('slot')
|
|
2559
|
+
slots.forEach(slot => {
|
|
2560
|
+
slot.addEventListener('slotchange', (e) => {
|
|
2561
|
+
const assignedNodes = slot.assignedNodes()
|
|
2562
|
+
this.dispatchEvent(new CustomEvent('slot-changed', {
|
|
2563
|
+
detail: { slotName: slot.name || 'default', assignedNodes }
|
|
2564
|
+
}))
|
|
2565
|
+
})
|
|
2566
|
+
})`:`// Manual slot processing for non-shadow DOM mode
|
|
2567
|
+
const slots = this.querySelectorAll('[data-slot]')
|
|
2568
|
+
|
|
2569
|
+
// Process named slots
|
|
2570
|
+
slots.forEach(slotEl => {
|
|
2571
|
+
const slotName = slotEl.getAttribute('data-slot')
|
|
2572
|
+
const slottedContent = this._slotContent.filter(
|
|
2573
|
+
node => node.nodeType === Node.ELEMENT_NODE && node.getAttribute('slot') === slotName
|
|
2574
|
+
)
|
|
2575
|
+
if (slottedContent.length > 0) {
|
|
2576
|
+
slotEl.innerHTML = ''
|
|
2577
|
+
slottedContent.forEach(content => slotEl.appendChild(content))
|
|
2578
|
+
}
|
|
2579
|
+
})
|
|
2580
|
+
|
|
2581
|
+
// Process default slot
|
|
2582
|
+
const defaultSlot = this.querySelector('[data-slot=""]') || this.querySelector('[data-default-slot]')
|
|
2583
|
+
if (defaultSlot) {
|
|
2584
|
+
const unslottedContent = this._slotContent.filter(
|
|
2585
|
+
node => node.nodeType !== Node.ELEMENT_NODE || !node.hasAttribute('slot')
|
|
2586
|
+
)
|
|
2587
|
+
if (unslottedContent.length > 0) {
|
|
2588
|
+
defaultSlot.innerHTML = ''
|
|
2589
|
+
unslottedContent.forEach(content => defaultSlot.appendChild(content))
|
|
2590
|
+
}
|
|
2591
|
+
}`}
|
|
2592
|
+
}
|
|
2593
|
+
|
|
2594
|
+
${F.length>0?`
|
|
2595
|
+
static get observedAttributes() {
|
|
2596
|
+
return [${F.map((G)=>`'${G}'`).join(", ")}]
|
|
2597
|
+
}
|
|
2598
|
+
|
|
2599
|
+
attributeChangedCallback(name, oldValue, newValue) {
|
|
2600
|
+
if (oldValue !== newValue) {
|
|
2601
|
+
this[name] = newValue
|
|
2602
|
+
${B?"":"if (this._initialized) this._render()"}
|
|
2603
|
+
}
|
|
2604
|
+
}
|
|
2605
|
+
`:""}
|
|
2606
|
+
|
|
2607
|
+
connectedCallback() {
|
|
2608
|
+
if (this._initialized) return
|
|
2609
|
+
${j?"":"this._slotContent = Array.from(this.childNodes)"}
|
|
2610
|
+
this._initialized = true
|
|
2611
|
+
${B?"this._createTemplate()":"this._render()"}
|
|
2612
|
+
}
|
|
2613
|
+
|
|
2614
|
+
disconnectedCallback() {
|
|
2615
|
+
// Component removed from the DOM
|
|
2616
|
+
}
|
|
2617
|
+
}
|
|
2618
|
+
|
|
2619
|
+
// Register the web component
|
|
2620
|
+
customElements.define('${k}', ${_.replace(/\W/g,"")})
|
|
2621
|
+
`}function s0(v){let{name:_,tag:k,baseElement:E="HTMLElement",source:T,shadowDOM:j,template:B,styleSource:z,attributes:F=[],attributeTypes:V={}}=v,H=_.replace(/\W/g,""),G=T.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,"").trim();if(!j)G=G.replace(/<slot\s+name=["']([^"']+)["']\s*>([\s\S]*?)<\/slot>/gi,'<div data-slot="$1">$2</div>'),G=G.replace(/<slot\s+name=["']([^"']+)["']\s*\/>/gi,'<div data-slot="$1"></div>'),G=G.replace(/<slot\s*>([\s\S]*?)<\/slot>/gi,"<div data-default-slot>$1</div>"),G=G.replace(/<slot\s*\/>/gi,"<div data-default-slot></div>");G=G.replace(/`/g,"\\`").replace(/\$\{/g,"\\${");let J=z?`<link rel="stylesheet" href="${z}">`:"",ne=(we)=>{switch(V[we]){case"number":return"number";case"boolean":return"boolean";case"object":return"Record<string, unknown>";default:return"string"}},re=(we)=>we.replace(/-([a-z])/g,($e,_e)=>_e.toUpperCase()),se=F.map((we)=>` private _${re(we)}: ${ne(we)} | null = null;`).join(`
|
|
2622
|
+
`),ie=F.map((we)=>{let $e=ne(we),_e=re(we);return`
|
|
2623
|
+
get ${_e}(): ${$e} | null {
|
|
2624
|
+
return this._${_e};
|
|
2625
|
+
}
|
|
2626
|
+
|
|
2627
|
+
set ${_e}(value: ${$e} | null) {
|
|
2628
|
+
this._${_e} = value;
|
|
2629
|
+
if (value !== null) {
|
|
2630
|
+
this.setAttribute('${we}', String(value));
|
|
2631
|
+
}
|
|
2632
|
+
else {
|
|
2633
|
+
this.removeAttribute('${we}');
|
|
2634
|
+
}
|
|
2635
|
+
}`}).join(`
|
|
2636
|
+
`),oe=F.length>0?`/**
|
|
2637
|
+
* Props interface for ${_}
|
|
2638
|
+
*/
|
|
2639
|
+
export interface ${H}Props {
|
|
2640
|
+
${F.map((we)=>{let $e=ne(we);return` ${re(we)}?: ${$e};`}).join(`
|
|
2641
|
+
`)}
|
|
2642
|
+
}
|
|
2643
|
+
`:"",ge=F.length>0?`
|
|
2644
|
+
static get observedAttributes(): string[] {
|
|
2645
|
+
return [${F.map((we)=>`'${we}'`).join(", ")}];
|
|
2646
|
+
}
|
|
2647
|
+
|
|
2648
|
+
attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null): void {
|
|
2649
|
+
if (oldValue !== newValue) {
|
|
2650
|
+
const camelCase = name.replace(/-([a-z])/g, (_: string, letter: string) => letter.toUpperCase());
|
|
2651
|
+
(this as unknown as Record<string, unknown>)[\`_\${camelCase}\`] = this._parseAttributeValue(name, newValue);
|
|
2652
|
+
${B?"":"if (this._initialized) this._render();"}
|
|
2653
|
+
}
|
|
2654
|
+
}
|
|
2655
|
+
|
|
2656
|
+
private _parseAttributeValue(name: string, value: string | null): unknown {
|
|
2657
|
+
if (value === null) return null;
|
|
2658
|
+
const typeMap: Record<string, string> = ${JSON.stringify(V)};
|
|
2659
|
+
const type = typeMap[name] || 'string';
|
|
2660
|
+
switch (type) {
|
|
2661
|
+
case 'number': return Number(value);
|
|
2662
|
+
case 'boolean': return value !== 'false' && value !== '0';
|
|
2663
|
+
case 'object': try { return JSON.parse(value); }
|
|
2664
|
+
catch { return value; }
|
|
2665
|
+
default: return value;
|
|
2666
|
+
}
|
|
2667
|
+
}
|
|
2668
|
+
`:"",ue=B?`
|
|
2669
|
+
private _createTemplate(): void {
|
|
2670
|
+
const template = document.createElement('template');
|
|
2671
|
+
template.innerHTML = \`${J}${G}\`;
|
|
2672
|
+
${j?"this.shadowRoot!.appendChild(template.content.cloneNode(true));":"this.appendChild(template.content.cloneNode(true));"}
|
|
2673
|
+
this._processSlots();
|
|
2674
|
+
}`:`
|
|
2675
|
+
private _render(): void {
|
|
2676
|
+
${j?"this.shadowRoot!.innerHTML":"this.innerHTML"} = \`${J}${G}\`;
|
|
2677
|
+
this._processSlots();
|
|
2678
|
+
}`;return`/**
|
|
2679
|
+
* ${_} Web Component
|
|
2680
|
+
* Auto-generated from stx component (TypeScript)
|
|
2681
|
+
*
|
|
2682
|
+
* @example
|
|
2683
|
+
* \`\`\`html
|
|
2684
|
+
* <${k}></${k}>
|
|
2685
|
+
* \`\`\`
|
|
2686
|
+
*/
|
|
2687
|
+
|
|
2688
|
+
/**
|
|
2689
|
+
* Detail type for slot-changed event
|
|
2690
|
+
*/
|
|
2691
|
+
interface SlotChangeDetail {
|
|
2692
|
+
slotName: string;
|
|
2693
|
+
assignedNodes: Node[];
|
|
2694
|
+
}
|
|
2695
|
+
|
|
2696
|
+
${oe}
|
|
2697
|
+
/**
|
|
2698
|
+
* ${_} custom element class
|
|
2699
|
+
* @customElement ${k}
|
|
2700
|
+
*/
|
|
2701
|
+
export class ${H} extends ${E} {
|
|
2702
|
+
${se}
|
|
2703
|
+
private _initialized = false;
|
|
2704
|
+
${j?"":"private _slotContent: Node[] = [];"}
|
|
2705
|
+
|
|
2706
|
+
constructor() {
|
|
2707
|
+
super();
|
|
2708
|
+
${j?'this.attachShadow({ mode: "open" });':""}
|
|
2709
|
+
}
|
|
2710
|
+
${ue}
|
|
2711
|
+
${j?`
|
|
2712
|
+
private _processSlots(): void {
|
|
2713
|
+
const slots = this.shadowRoot!.querySelectorAll('slot');
|
|
2714
|
+
slots.forEach((slot) => {
|
|
2715
|
+
slot.addEventListener('slotchange', () => {
|
|
2716
|
+
const assignedNodes = (slot as HTMLSlotElement).assignedNodes();
|
|
2717
|
+
this.dispatchEvent(new CustomEvent<SlotChangeDetail>('slot-changed', {
|
|
2718
|
+
detail: { slotName: slot.getAttribute('name') || 'default', assignedNodes }
|
|
2719
|
+
}));
|
|
2720
|
+
});
|
|
2721
|
+
});
|
|
2722
|
+
}`:`
|
|
2723
|
+
private _processSlots(): void {
|
|
2724
|
+
const slots = this.querySelectorAll('[data-slot]');
|
|
2725
|
+
slots.forEach((slotEl) => {
|
|
2726
|
+
const slotName = slotEl.getAttribute('data-slot');
|
|
2727
|
+
if (slotName) {
|
|
2728
|
+
const slottedContent = this._slotContent.filter(
|
|
2729
|
+
node => node.nodeType === Node.ELEMENT_NODE && (node as Element).getAttribute('slot') === slotName
|
|
2730
|
+
);
|
|
2731
|
+
if (slottedContent.length > 0) {
|
|
2732
|
+
slotEl.innerHTML = '';
|
|
2733
|
+
slottedContent.forEach(content => slotEl.appendChild(content));
|
|
2734
|
+
}
|
|
2735
|
+
}
|
|
2736
|
+
});
|
|
2737
|
+
const defaultSlot = this.querySelector('[data-slot=""]') || this.querySelector('[data-default-slot]');
|
|
2738
|
+
if (defaultSlot) {
|
|
2739
|
+
const unslottedContent = this._slotContent.filter(
|
|
2740
|
+
node => node.nodeType !== Node.ELEMENT_NODE || !(node as Element).hasAttribute('slot')
|
|
2741
|
+
);
|
|
2742
|
+
if (unslottedContent.length > 0) {
|
|
2743
|
+
defaultSlot.innerHTML = '';
|
|
2744
|
+
unslottedContent.forEach(content => defaultSlot.appendChild(content));
|
|
2745
|
+
}
|
|
2746
|
+
}
|
|
2747
|
+
}`}
|
|
2748
|
+
${ge}
|
|
2749
|
+
${ie}
|
|
2750
|
+
|
|
2751
|
+
connectedCallback(): void {
|
|
2752
|
+
if (this._initialized) return;
|
|
2753
|
+
${j?"":"this._slotContent = Array.from(this.childNodes);"}
|
|
2754
|
+
this._initialized = true;
|
|
2755
|
+
${B?"this._createTemplate();":"this._render();"}
|
|
2756
|
+
}
|
|
2757
|
+
|
|
2758
|
+
disconnectedCallback(): void {
|
|
2759
|
+
// Component removed from the DOM
|
|
2760
|
+
}
|
|
2761
|
+
|
|
2762
|
+
adoptedCallback(): void {
|
|
2763
|
+
// Component moved to a new document
|
|
2764
|
+
}
|
|
2765
|
+
}
|
|
2766
|
+
|
|
2767
|
+
// Type augmentation for HTMLElementTagNameMap
|
|
2768
|
+
declare global {
|
|
2769
|
+
interface HTMLElementTagNameMap {
|
|
2770
|
+
'${k}': ${H};
|
|
2771
|
+
}
|
|
2772
|
+
}
|
|
2773
|
+
|
|
2774
|
+
// Register the web component
|
|
2775
|
+
customElements.define('${k}', ${H});
|
|
2776
|
+
`}function i0(v,_){let k=v.match(/<script\b[^>]*>([\s\S]*?)<\/script>/i),E=k?k[1].trim():"",T=_,j=[],B=!0;if(E){let G=E.match(/export\s+default\s+({[\s\S]*})/);if(G)try{let J=G[1],ne=J.match(/tag\s*:\s*['"`]([^'"`]+)['"`]/);if(ne)T=ne[1];let re=J.match(/props\s*:\s*\[([\s\S]*?)\]/);if(re)j=re[1].split(",").map((ie)=>ie.trim().replace(/['"`]/g,"")).filter((ie)=>ie.length>0);let se=J.match(/shadowDOM\s*:\s*(true|false)/);if(se)B=se[1]==="true"}catch{}}let z=v.match(/<template\b(?![^>]*\bid\s*=)[^>]*>([\s\S]*?)<\/template>/i),F=z?z[1].trim():"",V=v.match(/<style\b[^>]*>([\s\S]*?)<\/style>/i),H=V?V[1].trim():"";return{tag:T,props:j,template:F,styles:H,script:E,shadowDOM:B}}function o0(v){let{tag:_,props:k,template:E,styles:T,shadowDOM:j}=v,B=_.split("-").map((G)=>G.charAt(0).toUpperCase()+G.slice(1)).join(""),z=E.replace(/\\/g,"\\\\").replace(/`/g,"\\`").replace(/\$\{/g,"\\${"),F=T.replace(/\\/g,"\\\\").replace(/`/g,"\\`"),V=k.map((G)=>`'${G}'`).join(", "),H=k.map((G)=>`
|
|
2777
|
+
get ${G}() {
|
|
2778
|
+
return this.getAttribute('${G}') || '';
|
|
2779
|
+
}
|
|
2780
|
+
set ${G}(value) {
|
|
2781
|
+
if (value) {
|
|
2782
|
+
this.setAttribute('${G}', value);
|
|
2783
|
+
}
|
|
2784
|
+
else {
|
|
2785
|
+
this.removeAttribute('${G}');
|
|
2786
|
+
}
|
|
2787
|
+
}`).join(`
|
|
2788
|
+
`);return`/**
|
|
2789
|
+
* ${B} Web Component
|
|
2790
|
+
* Auto-generated from SFC
|
|
2791
|
+
*/
|
|
2792
|
+
class ${B} extends HTMLElement {
|
|
2793
|
+
constructor() {
|
|
2794
|
+
super();
|
|
2795
|
+
${j?"this.attachShadow({ mode: 'open' });":""}
|
|
2796
|
+
this._render();
|
|
2797
|
+
}
|
|
2798
|
+
|
|
2799
|
+
static get observedAttributes() {
|
|
2800
|
+
return [${V}];
|
|
2801
|
+
}
|
|
2802
|
+
|
|
2803
|
+
attributeChangedCallback(name, oldValue, newValue) {
|
|
2804
|
+
if (oldValue !== newValue) {
|
|
2805
|
+
this._render();
|
|
2806
|
+
}
|
|
2807
|
+
}
|
|
2808
|
+
${H}
|
|
2809
|
+
|
|
2810
|
+
_render() {
|
|
2811
|
+
const template = \`${F?`<style>${F}</style>`:""}${z}\`;
|
|
2812
|
+
|
|
2813
|
+
// Interpolate {{ prop }} with attribute values
|
|
2814
|
+
const rendered = template.replace(/\\{\\{\\s*(\\w+)\\s*\\}\\}/g, (match, prop) => {
|
|
2815
|
+
return this.getAttribute(prop) || '';
|
|
2816
|
+
});
|
|
2817
|
+
|
|
2818
|
+
${j?"this.shadowRoot.innerHTML = rendered;":"this.innerHTML = rendered;"}
|
|
2819
|
+
}
|
|
2820
|
+
|
|
2821
|
+
connectedCallback() {
|
|
2822
|
+
this._render();
|
|
2823
|
+
}
|
|
2824
|
+
}
|
|
2825
|
+
|
|
2826
|
+
customElements.define('${_}', ${B});
|
|
2827
|
+
`}async function Ym(v,_,k,E){if(_.length<1)return i("WebComponent","@webcomponent directive requires at least the tag name parameter",t.INVALID_DIRECTIVE_SYNTAX);let T=_[0].replace(/['"]/g,""),B=(k.__stx_options||{}).componentsDir||"components",z=wn.isAbsolute(B)?[wn.join(B,`${T}.stx`),wn.join(wn.dirname(E),`${T}.stx`)]:[wn.join(wn.dirname(E),B,`${T}.stx`),wn.join(process.cwd(),B,`${T}.stx`),wn.join(wn.dirname(E),`${T}.stx`)],F=null;for(let G of z)if(await r(G)){F=await Bun.file(G).text();break}if(!F)return i("WebComponent",`Component file not found: ${T}.stx`,t.FILE_NOT_FOUND);let V=i0(F,T);return`<script type="module">
|
|
2828
|
+
${o0(V)}
|
|
2829
|
+
</script>`}var I={enabled:!0,ssr:!1,partialsDir:"partials",componentsDir:"components",layoutsDir:"layouts",defaultLayout:"default",debug:!1,cache:!0,stateDir:$t,cachePath:".stx/cache",cacheVersion:"1.0.0",componentRenderCacheBytes:33554432,build:{pagesDir:"pages",outputDir:"dist",baseUrl:"/",sitemap:!0,minify:!0,cache:!0,cacheDir:".stx/ssg-cache",concurrency:10,generate404:!0,publicDir:"public",trailingSlash:!1,cleanOutput:!0},customDirectives:[{name:"markdown",handler:Mm,hasEndTag:!0,description:"Render markdown content to HTML"},{name:"webcomponent",handler:Ym,hasEndTag:!1,description:"Include a web component in the template"},fi,gi,Yn,Zn,nu,su,iu,ru,au,uu,Vm,Gl,...ur],middleware:[],i18n:{defaultLocale:"en",locale:"en",translationsDir:"translations",format:"yaml",fallbackToKey:!0,cache:!0},webComponents:{enabled:!1,outputDir:"dist/web-components",components:[]},docs:{enabled:!1,outputDir:"docs",format:"markdown",components:!0,templates:!0,directives:!0},streaming:{enabled:!0,bufferSize:16384,strategy:"auto",timeout:30000},hydration:{enabled:!1,mode:"islands",clientEntry:"src/client.ts",autoMarkers:!0,preload:"lazy"},router:{enabled:!0,container:"main",linkSelector:"a[href]",viewTransitions:!0,scrollToTop:!0,scrollRestoration:!0,prefetch:!0,cache:!0,cacheTTL:300000,skipSelectors:'[data-no-router], [target="_blank"]',viewTransitionCSS:{oldRoot:"fade-out 0.15s ease-in",newRoot:"fade-in 0.2s ease-out",oldContent:"slide-out 0.2s ease-in",newContent:"slide-in 0.25s ease-out"}},a11y:{enabled:!0,addSrOnlyStyles:!0,level:"AA",autoFix:!1,ignoreChecks:[]},seo:{enabled:!0,socialPreview:!0,defaultConfig:{title:"stx Project",description:"A website built with stx templating engine"}},animation:{enabled:!0,defaultDuration:300,defaultEase:"ease",respectMotionPreferences:!0,staggerDelay:50},markdown:{enabled:!0,syntaxHighlighting:{enabled:!0,serverSide:!0,defaultTheme:"github-dark",highlightUnknownLanguages:!0,additionalThemes:["light-plus","one-dark-pro","dracula","monokai","solarized-light","nord","github-dark"]}},loops:{maxWhileIterations:1000,useAltLoopVariable:!1},story:{enabled:!0,outDir:".stx/dist/story",storyMatch:["**/*.story.stx"],storyIgnored:["**/node_modules/**","**/dist/**","**/.stx/**"],port:6006},pwa:{enabled:!1,manifest:{name:"stx App",shortName:"stx",description:"A Progressive Web App built with stx",startUrl:"/",display:"standalone",orientation:"any",themeColor:"#000000",backgroundColor:"#ffffff",scope:"/"},icons:{src:"public/icon.png",sizes:[72,96,128,144,152,192,384,512],generateWebP:!0,generateAppleIcons:!0,outputDir:"pwa-icons",purpose:["any","maskable"]},routes:[{pattern:"/",strategy:"network-first"},{pattern:"/static/*",strategy:"cache-first",maxAgeSeconds:2592000},{pattern:"/api/*",strategy:"network-only"},{pattern:"*.js",strategy:"stale-while-revalidate"},{pattern:"*.css",strategy:"stale-while-revalidate"},{pattern:"*.png",strategy:"cache-first"},{pattern:"*.jpg",strategy:"cache-first"},{pattern:"*.webp",strategy:"cache-first"},{pattern:"*.svg",strategy:"cache-first"}],offline:{enabled:!0,fallbackTitle:"You are offline",fallbackMessage:"Please check your internet connection and try again.",precacheAssets:[]},serviceWorker:{fileName:"sw.js",cacheVersion:"1.0.0",skipWaiting:!0,clientsClaim:!0,navigationPreload:!1,excludeRoutes:["/api/auth/*"],cacheFileTypes:["html","css","js","png","jpg","jpeg","webp","svg","woff","woff2"],useWorkbox:!1},autoInject:!0,push:{enabled:!1,defaultOptions:{vibrate:[100,50,100],requireInteraction:!1}},backgroundSync:{enabled:!1,queueName:"stx-sync-queue",maxRetentionMinutes:1440,maxRetries:3,minInterval:1000,forms:[],endpoints:[]},shareTarget:{enabled:!1,action:"/share-target",method:"POST",enctype:"multipart/form-data",params:{title:"title",text:"text",url:"url"}},fileHandlers:{enabled:!1},protocolHandlers:[],cacheStorage:{maxSize:100,maxEntries:500,maxAge:30,purgeStrategy:"lru"},updates:{enabled:!0,promptUser:!0,autoReload:!1,message:"A new version is available. Reload to update?"},precache:{enabled:!0,includeHtml:!0,includeJs:!0,includeCss:!0,includeImages:!0,includeFonts:!0,include:[],exclude:["*.map","*.LICENSE.txt"],maxFileSizeKB:500}},media:{enabled:!0,image:{enabled:!0,defaultWidths:[320,480,640,768,1024,1280,1536,1920],defaultFormats:["avif","webp","jpeg"],defaultQuality:80,placeholderStrategy:"thumbhash",lazyByDefault:!0,enableDpr:!0,defaultDpr:[1,2,3],tsImages:{enabled:!0,outputDir:"dist/images",baseUrl:"/images",formatQuality:{jpeg:{quality:85,mozjpeg:!0,progressive:!0},png:{compressionLevel:9,palette:!1},webp:{quality:82,effort:5,smartSubsample:!0},avif:{quality:75,effort:4,lossless:!1}},breakpoints:[320,480,640,768,1024,1280,1536,1920],batchOptions:{concurrency:4,optimizationPreset:"web"}}},video:{enabled:!0,lazyByDefault:!0,defaultControls:!0,tsVideos:{enabled:!0,outputDir:"dist/videos",baseUrl:"/videos",defaultQuality:"high",streaming:{enabled:!0,format:"hls",segmentDuration:6,defaultQualities:[{label:"1080p",width:1920,height:1080,bitrate:5000000,audioBitrate:192000},{label:"720p",width:1280,height:720,bitrate:2500000,audioBitrate:128000},{label:"480p",width:854,height:480,bitrate:1e6,audioBitrate:96000}]},thumbnails:{enabled:!0,count:10,format:"webp",width:320},transcoding:{defaultCodec:"h264",defaultAudioCodec:"aac",speedPreset:"medium"}}},upload:{enabled:!0,maxSize:10485760,allowedTypes:["image/*","video/*","audio/*","application/pdf"],maxConcurrent:3},protected:{enabled:!0,expirationSeconds:3600,batchSize:10},cache:{enabled:!0,directory:".stx/media-cache",maxAge:30,maxSize:500}},broadcasting:{enabled:!1,driver:"bun",host:"0.0.0.0",port:6001,scheme:"ws",verbose:!1}};function c0(v,_,k){let E=_||"pages";if(v)return{root:v,pagesDir:E};let T=k||process.cwd(),j=dn.join(T,"resources","views"),B=dn.join(T,"resources","layouts");if(aa.existsSync(j)&&aa.existsSync(B))return{root:"resources",pagesDir:"views"};let z=dn.join(T,"resources","views","pages");if(aa.existsSync(z))return{root:"resources/views",pagesDir:E};return{root:".",pagesDir:E}}var Qm=new Set,ca=["partialsDir","componentsDir","layoutsDir"],Jl=new WeakMap;function l0(v,_){let k=_.replace(/[\\/]+$/,"");if(!k||k===".")return!0;let E=v.replace(/\\/g,"/"),T=k.replace(/\\/g,"/");return E===T||E.startsWith(`${T}/`)}function $c(v,_){let k=!v.root,E=c0(v.root,v.pagesDir,_);if(v.root=E.root,v.pagesDir=E.pagesDir,k&&E.root!=="."){let T=`${_}::${E.root}`;if(!Qm.has(T))Qm.add(T),console.warn(`[stx] No "root" in config \u2014 inferred "${E.root}" from the project layout. Template directories are resolved under it; set root explicitly to pin this.`)}if(!Jl.has(v)){let T={};for(let j of ca){let B=v[j];if(typeof B==="string"&&B)T[j]=B}Jl.set(v,T)}if(v.root&&v.root!=="."){let T=v.root;for(let j of ca){let B=v[j];if(typeof B!=="string"||!B)continue;if(dn.isAbsolute(B)||l0(B,T))continue;v[j]=dn.join(T,B)}}for(let T of ca){let j=v[T];if(typeof j!=="string"||!j||dn.isAbsolute(j))continue;v[T]=dn.resolve(_,j)}return v}function u0(v,_){let k=Jl.get(v);for(let E of ca){let T=v[E];if(typeof T!=="string"||!T)continue;let j=dn.isAbsolute(T)?T:dn.join(_,T);if(aa.existsSync(j))continue;let B=k?.[E]??T,z=v.root,F=!!z&&z!==".";console.warn(`[stx] ${String(E)} resolves to "${j}", which does not exist. Configured as "${B}"`+(F?`, resolved under root "${z}".`:"."))}}function d0(v){if(v.customDirectives)v.customDirectives=[...v.customDirectives];if(v.middleware)v.middleware=[...v.middleware];if(v.apiRoutes)v.apiRoutes={...v.apiRoutes}}function f0(v){if(wi(v.stateDir),v.stateDir=on(),v.cachePath=an(v.cachePath),v.build)v.build.cacheDir=an(v.build.cacheDir);if(v.media?.cache)v.media.cache.directory=an(v.media.cache.directory);if(v.story)v.story.outDir=an(v.story.outDir)}var Sr=null,Or=new Map,oa=new Map,Li=null;async function o(v){let _=v?dn.resolve(v):process.cwd(),k=oa.get(_);if(k&&k.signature!==Xn(k.graph)){let j=Or.get(_);if(Or.delete(_),oa.delete(_),!v)Sr=null,Li=null;let{clearComponentCache:B}=await import("./chunk-68dsxv8z.js"),{partialsCache:z}=await import("./chunk-pcp5twev.js");if(B(),z.clear(),j&&k.configSignature===Gn(k.graph)){let F=j.then(async(V)=>{let H={...k.graph};await vs(H,_),oa.set(_,{graph:H,signature:Xn(H),configSignature:Gn(H)});let G={...V,_layerGraph:H};if(!v)Sr=G;return G});return Or.set(_,F),F}}if(!v){if(Sr)return Sr;if(Li)return Li}let E=Or.get(_);if(E)return E;let T=(async()=>{let B=(await a0({name:"stx",alias:"ui",cwd:_,defaultConfig:I,verbose:!1})).config;if(B.extends!==void 0||k){let H=await yi(_,I);B=H.config,oa.set(_,{graph:H.graph,signature:Xn(H.graph),configSignature:Gn(H.graph)})}if(B.runtimeConfig){let{resolveRuntimeConfig:H}=await import("./chunk-2hddf9pn.js");H(B.runtimeConfig,{});let{generateRuntimeConfigTypes:G}=await import("./chunk-mbapk9ka.js");await G(_,B.runtimeConfig)}d0(B),f0(B),$c(B,_),u0(B,_);let z=[],F=new Set((B.plugins??[]).map((H)=>typeof H==="string"?H:H[0]));for(let H of B.componentPackages??["@stacksjs/components"]){let G=`${H}/stx-plugin`;if(F.has(G)||F.has(H))continue;try{u.resolve(G,{paths:[_]}),z.push(G)}catch{}}let V=[...B.plugins??[],...z];if(V.length>0){let{pluginManager:H}=await import("./chunk-6qv189mb.js"),G=[],J=[];for(let ne of V){let re=typeof ne==="string"?ne:ne[0],se=typeof ne==="string"?{}:ne[1]||{};try{let ie,oe;try{let ue=u.resolve(re,{paths:[_]});ie=await import(ue),oe=dn.dirname(ue)}catch{let ue=dn.resolve(_,re);ie=await import(ue),oe=dn.dirname(ue)}let ge=ie.default||ie;if(!H.has(ge.name))await H.register(ge,B);if(ge.components){let ue=Array.isArray(ge.components)?ge.components:[ge.components];for(let xe of ue)G.push(dn.resolve(oe,xe))}if(ge.pages){let ue=dn.resolve(oe,ge.pages),xe=se.path||"/";J.push({dir:ue,prefix:xe})}if(ge.setup){let ue={addDirective:(xe)=>{B.customDirectives=B.customDirectives||[],B.customDirectives.push(xe)},addRoute:(xe,we)=>{B.apiRoutes=B.apiRoutes||{},B.apiRoutes[xe]=we},addMiddleware:(xe)=>{B.middleware=B.middleware||[],B.middleware.push(xe)},pluginDir:oe,config:B};await ge.setup(se,ue)}process.stderr.write(`[stx] Plugin loaded: ${ge.name||re}
|
|
2830
|
+
`)}catch(ie){console.warn(`[stx] Failed to load plugin ${re}:`,ie.message)}}B._pluginComponentDirs=G,B._pluginPageDirs=J}return B})();if(Or.set(_,T),T.catch(()=>{if(Or.get(_)===T)Or.delete(_)}),!v)Li=T,T.then((j)=>{Sr=j}).catch(()=>{});return T}var R=new Proxy(I,{get(v,_){if(Sr&&_ in Sr)return Sr[_];if(!Li)o().catch((k)=>{console.warn("[stx] Failed to load config file:",k?.message||k)});return v[_]}});function Fu(v){return v}function zu(v){let _=[],k=[];if(v.partialsDir!==void 0&&typeof v.partialsDir!=="string")_.push({path:"partialsDir",message:"partialsDir must be a string",severity:"error"});if(v.componentsDir!==void 0&&typeof v.componentsDir!=="string")_.push({path:"componentsDir",message:"componentsDir must be a string",severity:"error"});if(v.cache!==void 0&&typeof v.cache!=="boolean")_.push({path:"cache",message:"cache must be a boolean",severity:"error"});if(v.debug!==void 0&&typeof v.debug!=="boolean")_.push({path:"debug",message:"debug must be a boolean",severity:"error"});if(v.streaming){if(v.streaming.bufferSize!==void 0){if(typeof v.streaming.bufferSize!=="number"||v.streaming.bufferSize<=0)_.push({path:"streaming.bufferSize",message:"streaming.bufferSize must be a positive number",severity:"error"})}if(v.streaming.timeout!==void 0){if(typeof v.streaming.timeout!=="number"||v.streaming.timeout<=0)_.push({path:"streaming.timeout",message:"streaming.timeout must be a positive number",severity:"error"})}if(v.streaming.strategy!==void 0){let E=["auto","manual","sections"];if(!E.includes(v.streaming.strategy))_.push({path:"streaming.strategy",message:`streaming.strategy must be one of: ${E.join(", ")}`,severity:"error"})}}if(v.i18n){if(v.i18n.format!==void 0){let E=["json","yaml","yml","js"];if(!E.includes(v.i18n.format))_.push({path:"i18n.format",message:`i18n.format must be one of: ${E.join(", ")}`,severity:"error"})}}if(v.animation){if(v.animation.defaultDuration!==void 0){if(typeof v.animation.defaultDuration!=="number"||v.animation.defaultDuration<0)_.push({path:"animation.defaultDuration",message:"animation.defaultDuration must be a non-negative number",severity:"error"})}if(v.animation.staggerDelay!==void 0){if(typeof v.animation.staggerDelay!=="number"||v.animation.staggerDelay<0)_.push({path:"animation.staggerDelay",message:"animation.staggerDelay must be a non-negative number",severity:"error"})}}if(v.a11y){if(v.a11y.level!==void 0){let E=["AA","AAA"];if(!E.includes(v.a11y.level))_.push({path:"a11y.level",message:`a11y.level must be one of: ${E.join(", ")}`,severity:"error"})}}if(v.hydration){if(v.hydration.mode!==void 0){let E=["progressive","islands"];if(!E.includes(v.hydration.mode))_.push({path:"hydration.mode",message:`hydration.mode must be one of: ${E.join(", ")}`,severity:"error"})}if(v.hydration.preload!==void 0){let E=["none","eager","lazy"];if(!E.includes(v.hydration.preload))_.push({path:"hydration.preload",message:`hydration.preload must be one of: ${E.join(", ")}`,severity:"error"})}}if(v.customDirectives)if(!Array.isArray(v.customDirectives))_.push({path:"customDirectives",message:"customDirectives must be an array",severity:"error"});else v.customDirectives.forEach((E,T)=>{if(!E.name||typeof E.name!=="string")_.push({path:`customDirectives[${T}].name`,message:"Custom directive must have a name string",severity:"error"});if(!E.handler||typeof E.handler!=="function")_.push({path:`customDirectives[${T}].handler`,message:"Custom directive must have a handler function",severity:"error"})});if(v.middleware)if(!Array.isArray(v.middleware))_.push({path:"middleware",message:"middleware must be an array",severity:"error"});else v.middleware.forEach((E,T)=>{if(!E.name||typeof E.name!=="string")_.push({path:`middleware[${T}].name`,message:"Middleware must have a name string",severity:"error"});if(!E.handler||typeof E.handler!=="function")_.push({path:`middleware[${T}].handler`,message:"Middleware must have a handler function",severity:"error"});if(!E.timing||!["before","after"].includes(E.timing))_.push({path:`middleware[${T}].timing`,message:'Middleware timing must be "before" or "after"',severity:"error"})});if(v.debug===!0&&v.cache===!0)k.push({path:"debug+cache",message:"Debug mode with caching enabled may show stale content during development",severity:"warning"});if(v.seo?.enabled===!0&&!v.seo?.defaultConfig?.title)k.push({path:"seo.defaultConfig.title",message:"SEO is enabled but no default title is set",severity:"warning"});if(v.pwa){if(v.pwa.enabled===!0&&!v.pwa.manifest?.name)_.push({path:"pwa.manifest.name",message:"PWA manifest name is required when PWA is enabled",severity:"error"});if(v.pwa.manifest?.display!==void 0){let E=["fullscreen","standalone","minimal-ui","browser"];if(!E.includes(v.pwa.manifest.display))_.push({path:"pwa.manifest.display",message:`PWA display must be one of: ${E.join(", ")}`,severity:"error"})}if(v.pwa.manifest?.orientation!==void 0){let E=["portrait","landscape","any","portrait-primary","portrait-secondary","landscape-primary","landscape-secondary"];if(!E.includes(v.pwa.manifest.orientation))_.push({path:"pwa.manifest.orientation",message:`PWA orientation must be one of: ${E.join(", ")}`,severity:"error"})}if(v.pwa.routes){let E=["cache-first","network-first","stale-while-revalidate","network-only","cache-only"];v.pwa.routes.forEach((T,j)=>{if(!T.pattern||typeof T.pattern!=="string")_.push({path:`pwa.routes[${j}].pattern`,message:"PWA route must have a pattern string",severity:"error"});if(!E.includes(T.strategy))_.push({path:`pwa.routes[${j}].strategy`,message:`PWA route strategy must be one of: ${E.join(", ")}`,severity:"error"});if(T.maxAgeSeconds!==void 0&&(typeof T.maxAgeSeconds!=="number"||T.maxAgeSeconds<0))_.push({path:`pwa.routes[${j}].maxAgeSeconds`,message:"PWA route maxAgeSeconds must be a non-negative number",severity:"error"});if(T.maxEntries!==void 0&&(typeof T.maxEntries!=="number"||T.maxEntries<1))_.push({path:`pwa.routes[${j}].maxEntries`,message:"PWA route maxEntries must be a positive number",severity:"error"})})}if(v.pwa.icons?.sizes){if(!Array.isArray(v.pwa.icons.sizes))_.push({path:"pwa.icons.sizes",message:"PWA icon sizes must be an array of numbers",severity:"error"});else if(v.pwa.icons.sizes.filter((T)=>typeof T!=="number"||T<16||T>1024).length>0)_.push({path:"pwa.icons.sizes",message:"PWA icon sizes must be numbers between 16 and 1024",severity:"error"})}if(v.pwa.icons?.purpose){let E=["any","maskable","monochrome"];if(v.pwa.icons.purpose.filter((j)=>!E.includes(j)).length>0)_.push({path:"pwa.icons.purpose",message:`PWA icon purpose must be one of: ${E.join(", ")}`,severity:"error"})}if(v.pwa.enabled===!0&&!v.pwa.icons?.src)k.push({path:"pwa.icons.src",message:"PWA is enabled but no icon source specified. Provide a 512x512 PNG for best results.",severity:"warning"});if(v.pwa.enabled===!0&&!v.pwa.manifest?.themeColor)k.push({path:"pwa.manifest.themeColor",message:"PWA theme color not set, defaulting to black",severity:"warning"})}return{valid:_.length===0,errors:_,warnings:k}}var Ql=new Map;async function ce(v,_={}){try{if(!await r(v))throw Error(`Markdown file not found: ${v}`);let E=(await p0.promises.stat(v)).mtime.getTime();if(_.cache&&Ql.has(v)){let G=Ql.get(v);if(G.updatedAt>=E)return{content:G.content,data:G.data}}let T=await Bun.file(v).text(),{data:j,content:B}=In(T),z=_.markdown||R.markdown||{enabled:!0,syntaxHighlighting:{enabled:!0,serverSide:!0,defaultTheme:"github-dark",highlightUnknownLanguages:!0}},V=Oe(B,{gfm:!0});if(z.syntaxHighlighting?.enabled&&z.syntaxHighlighting?.serverSide)V=await m0(V,z.syntaxHighlighting?.defaultTheme||"github-dark",z.syntaxHighlighting?.highlightUnknownLanguages||!1);let H={content:V,data:j||{}};if(_.cache)Ql.set(v,{...H,updatedAt:E});return H}catch(k){if(_.debug)console.error(`Error reading/parsing markdown file ${v}:`,k);let E=k instanceof Error?k.message:String(k);return{content:g("Markdown File",`Error reading/parsing markdown file: ${E}`,v,"",0,""),data:{}}}}var la=null;async function m0(v,_,k){let E=/<pre><code( class="language-([^"]+)")?>([^<]+)<\/code><\/pre>/g;if(!la)try{la=await g0({theme:_||"github-dark",cache:!0})}catch(z){return console.error("Failed to initialize ts-syntax-highlighter:",z),v}let T=async(z,F,V,H)=>{let G=H.replace(/</g,"<").replace(/>/g,">").replace(/&/g,"&").replace(/"/g,'"').replace(/'/g,"'"),J=V||(k?"text":"");if(!J)return z;try{if(!la.getSupportedLanguages().includes(J))return z;return(await la.highlight(G,J,{theme:_})).html}catch(ne){console.error(`Error highlighting code block with language ${V}:`,ne)}return z},j=v,B=v.matchAll(E);for(let z of B){let[F,V,H,G]=z,J=await T(F,V,H,G);j=j.replace(F,J)}return j}async function Xg(v,_,k="",E={}){return await h0(v,/@markdown-file\(\s*['"]([^'"]+)['"]\s*(?:,\s*(\{[^}]*\}))?\)/g,async(B,z,F,V)=>{try{let H=z;if(!Yl.isAbsolute(z))H=Yl.resolve(Yl.dirname(k),z);let G={};if(F)try{try{G=JSON.parse(F)}catch{if(E.debug)console.warn("Using safer alternative for parsing JS object literal");let ge=F.replace(/^\s*\{|\}\s*$/g,"").trim().split(/,(?=\s*\w+\s*:)/);for(let ue of ge){let xe=ue.indexOf(":");if(xe>0){let we=ue.substring(0,xe).trim(),$e=ue.substring(xe+1).trim(),_e=$e.startsWith('"')&&$e.endsWith('"'),Ce=$e.startsWith("'")&&$e.endsWith("'");if(_e||Ce)$e=$e.substring(1,$e.length-1);G[we]=$e}}}}catch(oe){if(E.debug)console.error("Error parsing context in @markdown-file directive:",oe)}let{content:J,data:ne}=await ce(H,E),re={..._,...ne,...G},se=J,ie=/\{\{([^}]+)\}\}/g;return se=se.replace(ie,(oe,ge)=>{let ue=ge.trim();return re[ue]!==void 0?String(re[ue]):oe}),se}catch(H){let G=H instanceof Error?H.message:String(H);return g("Markdown File",`Error including markdown file: ${G}`,k,v,V,B)}})}async function h0(v,_,k){let E=[],T;while((T=_.exec(v))!==null){let z=T[0],F=T.index,V=T;E.push(k(...V).then((H)=>({match:z,replacement:H,index:F})))}let j=await Promise.all(E);j.sort((z,F)=>F.index-z.index);let B=v;for(let{match:z,replacement:F}of j)B=B.replace(z,()=>F);return B}
|
|
2831
|
+
export{In,Oe,M,U,m,h,Zt,W,w,Me,qr,Kr,Ha,wt,Lo,Xr,jo,bu,Ne,Gr,me,Bo,Fo,zo,Jr,Y,Le,Dn,Va,wu,Ua,vu,Wa,On,b,vt,he,qa,Yr,Ka,xu,q,Xa,Su,x,ku,Ga,Cu,$u,Eu,Tu,Ja,Ya,_u,Ru,Ho,Au,Qt,en,Mn,Nn,e,Pu,Vo,Iu,Uo,Za,Qa,xt,tn,Du,ec,tc,nc,f,je,St,Be,Fe,Wo,Ln,Z,Zr,Qr,es,Ou,jn,Mu,nn,rc,ts,N,ae,K,Nu,sc,ns,rs,qo,Ko,ss,os,Bn,oc,Xo,Go,ic,ze,rn,Fn,kt,ac,cc,lc,uc,dc,d,pc,is,fc,Jo,Yo,Ct,as,Zo,gc,Lu,ye,Qo,ju,cs,ls,us,zn,ei,ds,Hn,sn,Vn,ps,gs,ms,n,He,hs,ys,mc,Q,ti,ni,ri,si,Un,bs,oi,ii,ai,hc,yc,bc,wc,vc,xc,Ve,L,Ue,Sc,Wn,kc,ci,Cc,We,r,qn,li,g,ee,Bu,Kn,I,$c,o,R,Fu,zu,ce};
|