@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
package/dist/chunk-nrp8qg9j.js
DELETED
|
@@ -1,2831 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
import{t,K,nr,i,te,_s,_,Et,dn,Rs,c,p,P,ve,Ye,l,rr}from"./chunk-5xj1df83.js";import{mn,hn,cr,Se}from"./chunk-s59r34p5.js";import{fn,m,vi,_t,Ps,xi,Si,ki,Ci}from"./chunk-afhkvj3k.js";import{R}from"./chunk-axydabse.js";import{w,Es,Ge,ln,er,de,Ts,pe,tr}from"./chunk-zqzv5jy2.js";import{Ss,ks,Cs,$s,Jn,Yn}from"./chunk-g8k5rsqq.js";import{le,$t,Gn,xs,S,Ke}from"./chunk-jwpcck1b.js";import{an}from"./chunk-aem9hs8n.js";import{Ns}from"./chunk-dqr5n49p.js";import{hi,ws,Kn,Xn}from"./chunk-yx37nrgr.js";import{li,ui,pi,fi}from"./chunk-0xztxj98.js";import{qe}from"./chunk-tfexmdkt.js";import{s,be}from"./chunk-56rk985x.js";import{Ct,bi,sn,a,on}from"./chunk-90562q79.js";import{u}from"./chunk-cg8hg6cs.js";import{fe,D,pn}from"./chunk-yqsza22w.js";import{lr}from"./chunk-tn85vr56.js";import e0 from"fs";import Zl from"path";import{createHighlighter as t0}from"ts-syntax-highlighter";import oa from"fs";import gn from"path";import{loadConfigWithResult as XS}from"bunfig";var or={duration:300,delay:0,ease:"ease",direction:"both"};function Xm(x,v={}){let{duration:k,delay:E,ease:C,direction:j,custom:L}={...or,...v};if(x==="custom"&&L)return L;switch(x){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 Zm(){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 Gm(x){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(x))}function Jm(x=0.1,v="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: '${v}',
|
|
56
|
-
threshold: ${x}
|
|
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 Ym(){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 Qm(x,v,k={}){let{staggerDelay:E=50,sequence:C=!1}=k;return`
|
|
199
|
-
<script data-stx-scoped data-stx-run="always">
|
|
200
|
-
// Animation Group: ${x}
|
|
201
|
-
(function() {
|
|
202
|
-
const elements = ${JSON.stringify(v)};
|
|
203
|
-
const staggerDelay = ${E};
|
|
204
|
-
const sequence = ${C};
|
|
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 Ql={name:"transition",handler:(x,v,k,E)=>{if(v.length<1)return`<div class="stx-error">@transition directive requires at least a transition type</div>${x}`;let C=v[0],j=v.length>1?Number.parseInt(v[1],10)||or.duration:or.duration,L=v.length>2?v[2]||or.ease:or.ease,B=v.length>3?Number.parseInt(v[3],10)||or.delay:or.delay,z=v.length>4?v[4]||or.direction:or.direction,F=`stx-transition-${Math.random().toString(36).substr(2,9)}`,X=Xm(C,{duration:j,delay:B,ease:L,direction:z}),G="stx-transition",J="";if(C==="fade")J="stx-fade";else if(C==="slide")J="stx-slide";else if(C==="scale")J="stx-scale";else if(C==="flip")J="stx-flip";else if(C==="rotate")J="stx-rotate";return`<div id="${F}" class="${G} ${J} ${z==="out"?"stx-out":""}"
|
|
236
|
-
style="--stx-transition-duration: ${j}ms; --stx-transition-ease: ${L}; --stx-transition-delay: ${B}ms;">${x}</div>`},hasEndTag:!0,description:"Applies transition effects to an element"},eu={name:"scrollAnimate",handler:(x,v,k,E)=>{if(v.length<1)return`<div class="stx-error">@scrollAnimate directive requires at least an animation type</div>${x}`;let C=v[0],j=v.length>1?Number.parseInt(v[1],10)||300:300,L=v.length>2?v[2]||"ease":"ease",B=v.length>3?Number.parseFloat(v[3])||0.2:0.2,z=v.length>4?Number.parseInt(v[4],10)||0:0,F=`stx-scroll-${Math.random().toString(36).substr(2,9)}`,X=`--stx-transition-duration: ${j}ms; --stx-transition-ease: ${L}; --stx-transition-delay: ${z}ms; will-change: opacity, transform;`,G="stx-transition stx-observe stx-out";if(C==="fade")G+=" stx-fade";else if(C==="slide-up"||C==="slide")G+=" stx-from-bottom";else if(C==="slide-down")G+=" stx-from-top";else if(C==="slide-left")G+=" stx-from-right";else if(C==="slide-right")G+=" stx-from-left";else if(C==="scale")G+=" stx-scale";else if(C.includes("-"))G+=` stx-${C}`;else G+=` stx-${C}`;return`<div id="${F}" class="${G}" style="${X}" data-threshold="${B}">${x}</div>`},hasEndTag:!0,description:"Applies animations that trigger when scrolled into view"},tu={name:"animationGroup",handler:(x,v,k,E)=>{if(v.length<2)return`<div class="stx-error">@animationGroup directive requires a group name and at least one element selector</div>${x}`;let C=v[0],j=v.slice(1).map((F)=>F.startsWith("#")||F.startsWith(".")?F:`#${F}`),L=k.staggerDelay||50,B=k.sequence||!0,z=Qm(C,j,{staggerDelay:L,sequence:B});return`${x}
|
|
237
|
-
${z}`},hasEndTag:!1,description:"Coordinates multiple animations together as a group"},nu={name:"motion",handler:(x,v,k,E)=>{let C=v.length>0?v[0].toLowerCase()==="true":!0,j=Zm();return`<div data-animate="${C?"auto":"true"}">${x}</div>${j}`},hasEndTag:!0,description:"Controls motion and animation preferences"};function ru(x,v,k,E){let C=x;if(E.animation?.enabled===!1)return C;let j=k.includes("test")&&k.includes("animation");if(!Gm(C)&&!j)return C;if(!C.includes('<style id="stx-animation-base">')){let B=Ym();C=C.replace("</head>",`${B}
|
|
238
|
-
</head>`)}if(C.includes("stx-observe")){if(!C.includes("Intersection Observer for scroll animations")){let z=Jm(),F=C.lastIndexOf("</body>");if(F!==-1)C=C.slice(0,F)+z+`
|
|
239
|
-
`+C.slice(F)}}return C}async function eh(x,v,k,E){let C=v[0]?.replace(/['"]/g,"")||"main",j=Se();if(C!=="main")j=j.replace("container:'main'",`container:'${C}'`);return`<script data-stx-router>${j}</script>`}var su={name:"stxRouter",handler:eh,hasEndTag:!1,description:"Inject the STX SPA router script for client-side navigation"};var th={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 iu(x){let v=x.heatmap;if(!v?.enabled)return"";let k={...th,...v};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 ou(x,v){let k=iu(v);if(!k)return x;let E=x.lastIndexOf("</body>");if(E!==-1)return x.slice(0,E)+k+x.slice(E);return x+k}var au={name:"heatmap",hasEndTag:!1,description:"Inject privacy-compliant heatmap tracking script",handler:async(x,v,k,E)=>{let C=k.__stx_config||{};if(v.length>0){let j=nh(v.join(" "));C.heatmap={...C.heatmap,...j,enabled:!0}}return iu(C)}};function nh(x){let v={},k=x.match(/(\w+)=["']?([^"'\s]+)["']?/g)||[];for(let E of k){let[C,j]=E.split("="),L=j?.replace(/["']/g,"");switch(C){case"endpoint":v.endpoint=L;break;case"samplingRate":v.samplingRate=Number.parseInt(L,10);break;case"batchSize":v.batchSize=Number.parseInt(L,10);break;case"trackMouse":v.trackMouse=L==="true";break;case"trackClicks":v.trackClicks=L==="true";break;case"trackScroll":v.trackScroll=L==="true";break;case"honorDnt":v.honorDnt=L==="true";break;case"debugOverlay":v.debugOverlay=L==="true";break}}return v}function fr(x){return x.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function cu(x){let v=x.trim().toLowerCase();return!v.startsWith("javascript:")&&!v.startsWith("vbscript:")&&!v.startsWith("data:text/html")}function Pn(x){let v=/^---\r?\n([\s\S]*?)\r?\n---\r?\n/,k=x.match(v);if(!k)return{data:{},content:x.trim()};let E=k[1],C=x.slice(k[0].length),j={};for(let L of E.split(`
|
|
623
|
-
`)){let B=L.trim();if(!B||B.startsWith("#"))continue;let z=B.indexOf(":");if(z===-1)continue;let F=B.slice(0,z).trim(),X=B.slice(z+1).trim();if(typeof X==="string"){if(X.startsWith('"')&&X.endsWith('"')||X.startsWith("'")&&X.endsWith("'"))X=X.slice(1,-1);else if(X.startsWith("[")&&X.endsWith("]"))try{X=JSON.parse(X)}catch{}else if(X==="true")X=!0;else if(X==="false")X=!1;else if(/^-?\d+(?:\.\d+)?$/.test(X))X=Number(X)}j[F]=X}return{data:j,content:C.trim()}}function Oe(x,v={}){let{gfm:k=!0,breaks:E=!1}=v,C=x,j=[];if(C=C.replace(/```(\w*)\n([\s\S]*?)```/g,(X,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`}),C=C.replace(/`([^`]*)`/g,(X,G)=>`<code>${fr(G)}</code>`),C=C.replace(/^######\s+(.*)$/gm,"<h6>$1</h6>"),C=C.replace(/^#####\s+(.*)$/gm,"<h5>$1</h5>"),C=C.replace(/^####\s+(.*)$/gm,"<h4>$1</h4>"),C=C.replace(/^###\s+(.*)$/gm,"<h3>$1</h3>"),C=C.replace(/^##\s+(.*)$/gm,"<h2>$1</h2>"),C=C.replace(/^#\s+(.*)$/gm,"<h1>$1</h1>"),C=C.replace(/\*\*\*(.+?)\*\*\*/g,"<strong><em>$1</em></strong>"),C=C.replace(/___(.+?)___/g,"<strong><em>$1</em></strong>"),C=C.replace(/\*\*(.+?)\*\*/g,"<strong>$1</strong>"),C=C.replace(/__(.+?)__/g,"<strong>$1</strong>"),C=C.replace(/\*(.+?)\*/g,"<em>$1</em>"),C=C.replace(/(?<![a-zA-Z0-9])_(.+?)_(?![a-zA-Z0-9])/g,"<em>$1</em>"),k)C=C.replace(/~~(.+?)~~/g,"<del>$1</del>");if(C=C.replace(/!\[([^\]]*)\]\(([^)]+)\)/g,(X,G,J)=>`<img src="${cu(J)?fr(J):""}" alt="${fr(G)}" />`),C=C.replace(/\[([^\]]+)\]\(([^)]+)\)/g,(X,G,J)=>`<a href="${cu(J)?fr(J):""}">${G}</a>`),C=C.replace(/^(?:---|\*\*\*|___)\s*$/gm,"<hr />"),C=C.replace(/^>\s+(.*)$/gm,"<blockquote>$1</blockquote>"),C=C.replace(/<\/blockquote>\n<blockquote>/g,`
|
|
624
|
-
`),C=C.replace(/^[*\-+]\s+(.*)$/gm,"<li data-ul>$1</li>"),C=C.replace(/(<li data-ul>.*<\/li>\n?)+/g,"<ul>$&</ul>"),C=C.replace(/<\/ul>\n<ul>/g,""),C=C.replace(/^\d+\.\s+(.*)$/gm,"<li data-ol>$1</li>"),C=C.replace(/(<li data-ol>.*<\/li>\n?)+/g,"<ol>$&</ol>"),C=C.replace(/<\/ol>\n<ol>/g,""),C=C.replace(/<li data-ul>/g,"<li>"),C=C.replace(/<li data-ol>/g,"<li>"),k)C=C.replace(/^\|(.+)\|\s*\n\|[-:\s|]+\|\s*\n((?:\|.+\|\s*\n)*)/gm,(X,G,J)=>{let re=`<tr>${G.split("|").map((oe)=>oe.trim()).filter(Boolean).map((oe)=>`<th>${fr(oe)}</th>`).join("")}</tr>`,se=J.trim().split(`
|
|
625
|
-
`).map((oe)=>`<tr>${oe.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)C=C.replace(/<li>\s*\[\s*\]\s*/g,'<li><input type="checkbox" disabled /> '),C=C.replace(/<li>\s*\[x\]\s*/gi,'<li><input type="checkbox" checked disabled /> ');let L=C.split(`
|
|
634
|
-
`),B=[],z=!1,F=[];for(let X of L){let G=X.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(z&&F.length>0)B.push(`<p>${F.join(E?`<br />
|
|
635
|
-
`:`
|
|
636
|
-
`)}</p>`),F=[],z=!1;B.push(X)}else z=!0,F.push(G)}if(z&&F.length>0)B.push(`<p>${F.join(E?`<br />
|
|
637
|
-
`:`
|
|
638
|
-
`)}</p>`);if(C=B.join(`
|
|
639
|
-
`),E)C=C.replace(/\n/g,`<br />
|
|
640
|
-
`);for(let X=0;X<j.length;X++)C=C.replace(`\x00CODEBLOCK${X}\x00`,j[X]);return C=C.replace(/<p>\s*<\/p>/g,""),C.trim()}import _m from"fs";import Qe from"path";import $r from"path";import Ws from"fs";var rh=new Set(["touchstart","touchmove","wheel","mousewheel"]);function ga(x,v){if(v.passive)return!0;if(v.prevent||v.nonpassive)return!1;return rh.has(x.toLowerCase())}var lu=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"]),uu={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"},sh=new Set(["ctrl","alt","shift","meta"]),pu={left:0,middle:1,right:2};function du(x){let v={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 x){let E=k.toLowerCase();if(E==="prevent")v.prevent=!0;else if(E==="stop")v.stop=!0;else if(E==="once")v.once=!0;else if(E==="capture")v.capture=!0;else if(E==="self")v.self=!0;else if(E==="passive")v.passive=!0;else if(E==="nonpassive")v.nonpassive=!0;else if(sh.has(E))v.systemKeys.push(E);else if(E in pu)v.mouse=E;else if(E in uu||/^[a-z]$/.test(E))v.keys.push(uu[E]||E.toUpperCase());else if(E.startsWith("debounce")){let C=E.match(/debounce(?:\.(\d+))?/);v.debounce=C?.[1]?Number.parseInt(C[1],10):300}else if(E.startsWith("throttle")){let C=E.match(/throttle(?:\.(\d+))?/);v.throttle=C?.[1]?Number.parseInt(C[1],10):300}}return v}function gu(x,v=""){let k=[],E=0,C=/<([a-z][a-z0-9-]*)\s+([^>]*@[a-z][^>]*)>/gi,j;while((j=C.exec(x))!==null){let[L,B,z]=j,F=j.index,X=F+L.length,G=`__stx_evt_${v}${E++}`,J=[],ne=/@([a-z][a-z0-9.]*)\s*=\s*"([^"]*)"/gi,re;while((re=ne.exec(z))!==null){let[,oe,ie]=re,ge=oe.split("."),ue=ge[0];if(!lu.has(ue))continue;J.push({attribute:`@${oe}`,event:ue,handler:ie,modifiers:du(ge.slice(1)),elementId:G})}let se=/@([a-z][a-z0-9.]*)\s*=\s*'([^']*)'/gi;while((re=se.exec(z))!==null){let[,oe,ie]=re,ge=oe.split("."),ue=ge[0];if(!lu.has(ue))continue;J.push({attribute:`@${oe}`,event:ue,handler:ie,modifiers:du(ge.slice(1)),elementId:G})}if(J.length>0)k.push({originalTag:L,elementId:G,events:J,startIndex:F,endIndex:X})}return k}function ih(x){let v=[],{modifiers:k}=x;if(k.self)v.push("if ($event.target !== $el) return");for(let E of k.systemKeys)v.push(`if (!$event.${E}Key) return`);if(k.keys.length>0){let E=k.keys.map((C)=>`$event.key === '${C}'`).join(" || ");v.push(`if (!(${E})) return`)}if(k.mouse!==null){let E=pu[k.mouse];v.push(`if ($event.button !== ${E}) return`)}if(k.prevent)v.push("$event.preventDefault()");if(k.stop)v.push("$event.stopPropagation()");return v.join("; ")}function oh(x,v){let k=x;if(v.debounce!==null)k=`__stx_debounce(() => { ${k} }, ${v.debounce})`;else if(v.throttle!==null)k=`__stx_throttle(() => { ${k} }, ${v.throttle})`;return k}function ma(x){let v=x.trim();if(!/^[A-Za-z_$][A-Za-z0-9_$]*$/.test(v))return x;return`if (typeof ${v} === 'function' && !${v}._isSignal) ${v}($event);`}function ah(x){let{modifiers:v}=x,k=x.elementId.replace(/\\/g,"\\\\").replace(/'/g,"\\'"),E=ih(x),C=oh(ma(x.handler),v),j=[];if(v.once)j.push("once: true");if(v.capture)j.push("capture: true");if(ga(x.event,v))j.push("passive: true");let L=j.length>0?`, { ${j.join(", ")} }`:"",B=C.replace(/\\/g,"\\\\").replace(/'/g,"\\'").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/\t/g,"\\t");if(x.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('${B}', null, $el);
|
|
648
|
-
}
|
|
649
|
-
else {
|
|
650
|
-
__stx_runHandler('${B}', null, $el);
|
|
651
|
-
}
|
|
652
|
-
})();`;if(x.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('${B}', null, $el);
|
|
665
|
-
}
|
|
666
|
-
else {
|
|
667
|
-
__stx_runHandler('${B}', 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('${x.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('${B}', $event, $el);
|
|
688
|
-
}
|
|
689
|
-
else {
|
|
690
|
-
// Fallback for non-reactive context (entity-safe; decoded + run in memory)
|
|
691
|
-
__stx_runHandler('${B}', $event, $el);
|
|
692
|
-
}
|
|
693
|
-
}${L});
|
|
694
|
-
})();`}function ha(x){if(x.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
|
-
${x.map(ah).join(`
|
|
750
|
-
`)}
|
|
751
|
-
})();
|
|
752
|
-
</script>`}function ch(x,v=""){let k=gu(x,v);if(k.length===0)return{template:x,bindings:[]};let E=x,C=[];for(let j=k.length-1;j>=0;j--){let L=k[j],B=L.originalTag;if(!B.includes(" id="))B=B.replace(/^<([a-z][a-z0-9-]*)/,`<$1 id="${L.elementId}"`);else{let z=B.match(/id=["']([^"']+)["']/);if(z)for(let F of L.events)F.elementId=z[1]}for(let z of L.events){let F=z.attribute.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),X=new RegExp(`\\s*${F}\\s*=\\s*"[^"]*"`,"g"),G=new RegExp(`\\s*${F}\\s*=\\s*'[^']*'`,"g");B=B.replace(X,""),B=B.replace(G,"")}E=E.slice(0,L.startIndex)+B+E.slice(L.endIndex),C.push(...L.events)}return{template:E,bindings:C}}function fu(x){let v=x.$uid;return typeof v==="string"&&v?`${v}_`:""}function mu(x,v,k){if(xi(x))return x;if(v.__stx_sfc_mode){if(/x-data\s*=\s*["']/.test(x))return x;let{template:B,bindings:z}=ch(x,fu(v)),F=v.__stx_event_bindings||[];return v.__stx_event_bindings=[...F,...z],B}let E=gu(x,fu(v));if(E.length===0)return x;let C=x;for(let B=E.length-1;B>=0;B--){let z=E[B],F=z.originalTag;if(!F.includes(" id="))F=F.replace(/^<([a-z][a-z0-9-]*)/,`<$1 id="${z.elementId}"`);else{let X=F.match(/id=["']([^"']+)["']/);if(X)for(let G of z.events)G.elementId=X[1]}for(let X of z.events){let G=X.attribute.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),J=new RegExp(`\\s*${G}\\s*=\\s*"[^"]*"`,"g"),ne=new RegExp(`\\s*${G}\\s*=\\s*'[^']*'`,"g");F=F.replace(J,""),F=F.replace(ne,"")}C=C.slice(0,z.startIndex)+F+C.slice(z.endIndex)}let j=ha(E.flatMap((B)=>B.events)),L=C.lastIndexOf("</body>");if(L!==-1)C=C.slice(0,L)+j+`
|
|
753
|
-
`+C.slice(L);else C+=j;return C}function hu(x,v){let k=new Set;for(let E of x.split(",")){let C=E.trim().replace(/^\.\.\./,"").trim();if(!C)continue;if(v){let j=C.lastIndexOf(":");if(j!==-1)C=C.slice(j+1).trim()}if(C=C.split("=")[0].trim(),/^[A-Za-z_$][\w$]*$/.test(C))k.add(C)}return k}function zi(x,v){let k=s(x),{depths:E,balanced:C}=be(k),j=(B)=>!C||E[B]===0,L=new RegExp(`(?:^|[^\\w$.])((?:const|let|var|function|class)\\s+${v}\\b)`,"g");for(let B of k.matchAll(L)){let z=(B.index??0)+B[0].length-B[1].length;if(j(z))return!0}for(let B of k.matchAll(/(?:const|let|var)\s*\{([^}]*)\}/g))if(j(B.index??0)&&hu(B[1],!0).has(v))return!0;for(let B of k.matchAll(/(?:const|let|var)\s*\[([^\]]*)\]/g))if(j(B.index??0)&&hu(B[1],!1).has(v))return!0;return!1}var zu="",Fi,ya=/^[A-Za-z_$][\w$]*$/,lh=new Set(["if","for","while","switch","with"]);function uh(x){let v=s(x),k=[];for(let E of v.matchAll(/[A-Za-z_$][\w$]*|=>|\.\.\.|[^\s]/g)){let C=E.index??0;k.push({text:E[0],start:C,end:C+E[0].length})}return{code:v,tokens:k}}function dh(x){if(Fi&&x===zu)return Fi;let{code:v,tokens:k}=uh(x),E=new Map,C=[];for(let X=0;X<k.length;X++){let G=k[X].text;if(["(","[","{"].includes(G))C.push(X);else if([")","]","}"].includes(G)){let J=C.at(-1);if(J!==void 0&&["()","[]","{}"].includes(k[J].text+G))C.pop(),E.set(J,X),E.set(X,J)}}function j(X,G){let J=[],ne=X;for(let re=X;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 L(X,G,J){if(k[X]?.text==="...")X++;if(X>=G)return;let ne=k[X].text;if(ya.test(ne)){J.add(ne);return}if(ne!=="{"&&ne!=="[")return;let re=E.get(X);if(re===void 0||re>=G)return;for(let[se,oe]of j(X+1,re)){let ie=se;if(ne==="{")for(let ge=se;ge<oe;ge++){if(k[ge].text===":"){ie=ge+1;break}if(k[ge].text==="=")break;if(["(","[","{"].includes(k[ge].text)&&E.has(ge))ge=E.get(ge)}L(ie,oe,J)}}function B(X,G){let J=new Set;for(let[ne,re]of j(X,G))L(ne,re,J);return J}function z(X){let G=X;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(X,G-1)]?.end??v.length}let F=[];for(let X=0;X<k.length;X++)if(k[X].text==="=>"){let G=X-1,J=G,ne;if(k[G]?.text===")"&&E.has(G))J=E.get(G),ne=B(J+1,G);else if(k[G]&&ya.test(k[G].text))ne=new Set([k[G].text]);else continue;let re=X+1,se=k[re]?.text==="{"&&E.has(re)?k[E.get(re)].end:z(re);F.push({start:k[J].start,end:se,names:ne})}else if(k[X].text==="("&&E.has(X)){let G=k[X-1]?.text;if(!G||lh.has(G)||!ya.test(G)&&G!=="*"&&G!=="]")continue;let J=E.get(X),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;F.push({start:k[X].start,end:k[E.get(ne)].end,names:B(X+1,J)})}return zu=x,Fi={code:v,scopes:F},Fi}function Wu(x){let v=dh(x);return{code:v.code,shadows:(k,E)=>v.scopes.some((C)=>E>=C.start&&E<C.end&&C.names.has(k))}}var Vu=Symbol.for("stx.lazy-module-promises");function fh(){let x=globalThis;return x[Vu]??=new Map,x[Vu]}function ut(x,v){let k=fh(),E=`${import.meta.url}\x00${x}`,C=k.get(E);if(C)return C;let j=v();return k.set(E,j),j.catch(()=>{if(k.get(E)===j)k.delete(E)}),j}var ph=/<\/(script)/gi;function zr(x){if(!x||x.indexOf("</")===-1)return x;return x.replace(ph,"<\\/$1")}var H=["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 gh=/^[ \t]*import\s+['"]([^'"]+?\.css)(\?[^'"]*)?['"]\s*;?\s*$/gm;function mh(x){if(x.startsWith(".")||x.startsWith("/"))return null;if(x.startsWith("@")){let k=x.match(/^(@[^/]+\/[^/]+)(\/.*)?$/);if(!k)return null;return{pkg:k[1],subpath:k[2]||""}}let v=x.match(/^([^/]+)(\/.*)?$/);if(!v)return null;return{pkg:v[1],subpath:v[2]||""}}function hh(x,v){let k=v;while(!0){let E=$r.join(k,"node_modules",x,"package.json");if(Ws.existsSync(E))return $r.dirname(E);let C=$r.dirname(k);if(C===k)return null;k=C}}function yh(x,v){if(!x||typeof x!=="object")return null;let k=(C)=>{if(typeof C==="string")return C;if(C&&typeof C==="object"){if(typeof C.import==="string")return C.import;if(typeof C.default==="string")return C.default;if(typeof C.import==="object")return k(C.import);if(typeof C.default==="object")return k(C.default)}return null};if(Object.prototype.hasOwnProperty.call(x,v))return k(x[v]);let E=null;for(let C of Object.keys(x)){let j=C.indexOf("*");if(j===-1)continue;let L=C.slice(0,j),B=C.slice(j+1);if(!v.startsWith(L)||!v.endsWith(B))continue;if(v.length<L.length+B.length)continue;if(!E||L.length>E.prefix.length)E={pattern:C,prefix:L,suffix:B}}if(E){let C=v.slice(E.prefix.length,v.length-E.suffix.length),j=k(x[E.pattern]);if(j)return j.replace("*",C)}return null}function xh(x,v){let k=mh(x);if(!k||!k.subpath)return null;let E=hh(k.pkg,v);if(!E)return null;let C;try{C=JSON.parse(Ws.readFileSync($r.join(E,"package.json"),"utf8"))}catch{return null}let j=`.${k.subpath}`,L=yh(C.exports,j);if(!L)return null;let B=$r.resolve(E,L);return Ws.existsSync(B)?B:null}function Wr(x,v){let k=v.filePath?$r.dirname(v.filePath):v.projectRoot||process.cwd(),E=v.projectRoot||process.cwd(),C=new Set,j=[],L=[];return{code:x.replace(gh,(z,F)=>{let X;try{if(F.startsWith("./")||F.startsWith("../")||F.startsWith("/")){if(X=F.startsWith("/")?F:$r.resolve(k,F),!Ws.existsSync(X))throw Error(`file not found: ${X}`)}else{let G=null;try{G=Bun.resolveSync(F,E)}catch{G=xh(F,E)}if(!G)throw Error(`could not resolve ${F} (Bun.resolveSync + exports fallback both failed)`);X=G}}catch(G){return console.warn(`[stx:vendor-css] could not resolve ${JSON.stringify(F)} (from ${v.filePath||"<unknown>"}): ${G?.message||G}`),L.push(F),""}if(C.has(X))return"";C.add(X);try{let G=Ws.readFileSync(X,"utf8");j.push({source:F,resolvedPath:X,contents:G})}catch(G){console.warn(`[stx:vendor-css] could not read ${X}: ${G?.message||G}`),L.push(F)}return""}),styles:j,unresolved:L}}function bh(x){return x.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}function qr(x){if(x.length===0)return"";return`${x.map((v)=>`<style data-stx-vendor="${bh(v.source)}" data-stx-layer="vendor">
|
|
754
|
-
@layer vendor {
|
|
755
|
-
${v.contents}
|
|
756
|
-
}
|
|
757
|
-
</style>`).join(`
|
|
758
|
-
`)}
|
|
759
|
-
`}var za=m;function bt(x){let v=s(x),k=new Set;for(let B of x.matchAll(/^\s*import\s+(?:type\s+)?\{([^}]*)\}\s+from\s+['"][^'"]+['"]\s*;?\s*$/gm))for(let z of B[1].split(",")){let F=z.trim().split(/\s+as\s+/).pop()?.replace(/^type\s+/,"").trim();if(F)k.add(F)}let E=new Set;for(let B of v.matchAll(/\b(?:const|let|var|function|class)\s+([A-Za-z_$][\w$]*)/g))E.add(B[1]);for(let B of v.matchAll(/\b(?:const|let|var)\s*\{([^}]*)\}/g))for(let z of B[1].split(",")){let F=z.trim().split(/[:=]/).pop()?.trim();if(F)E.add(F)}let C=H.filter((B)=>{if(k.has(B)||E.has(B))return!1;return Kr(v,B,!0)}),j=qu(v).filter((B)=>!k.has(B)&&!E.has(B));if(C.length===0&&j.length===0)return{code:x,imports:C,models:j};return{code:`${[C.length>0?`import { ${C.join(", ")} } from '@stacksjs/browser'`:"",j.length>0?"import '@stacksjs/browser'":"",j.length>0?`const { ${j.join(", ")} } = window.StacksBrowser || {}`:""].filter(Boolean).join(`
|
|
760
|
-
`)}
|
|
761
|
-
${x}`,imports:C,models:j}}var vh=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 qu(x){let v=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(x))!==null)if(!vh.has(E[1]))v.add(E[1]);return Array.from(v)}function wh(x){let v=new Set;for(let k of x.matchAll(/\b(?:const|let|var|function|class)\s+([A-Za-z_$][\w$]*)/g))v.add(k[1]);for(let k of x.matchAll(/\b(?:const|let|var)\s*\{([^}]*)\}/g))for(let E of k[1].split(",")){let C=E.trim().split(/[:=]/).pop()?.trim();if(C&&/^[A-Za-z_$][\w$]*$/.test(C))v.add(C)}return v}function No(x){let v=new Set,k=new Set,E=x;E=E.replace(/^[ \t]*import\s+type\s+\{[^}]*\}\s+from\s+['"][^'"]+['"][ \t]*;?[ \t]*$/gm,"// [type import stripped]");let C=new Set,j=/^[ \t]*import\s+(?:type\s+)?{\s*([^}]+)\s*}\s+from\s+['"](@stacksjs\/browser|@stacksjs\/stx|stx)['"][ \t]*;?[ \t]*$/gm,L;while((L=j.exec(x))!==null){let G=L[1],J=L[2];if(L[0].includes("import type"))continue;let ne=[];for(let se of G.split(",")){let oe=se.trim();if(!oe||oe.startsWith("type "))continue;let ie=oe.match(/^([A-Za-z_$][\w$]*)(?:\s+as\s+([A-Za-z_$][\w$]*))?$/);if(!ie)continue;let ge=ie[1],ue=ie[2]||ge;if(C.add(ge),C.add(ue),J==="stx"||J==="@stacksjs/stx")v.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(L[0],re)}let B=wh(E);for(let G of za){if(C.has(G)||B.has(G))continue;if(Kr(E,G,!0))v.add(G)}let z=s(E),F=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)F.add(se)}}for(let G of H){if(C.has(G)||B.has(G)||F.has(G))continue;if(Kr(z,G))k.add(G)}let X=qu(E);for(let G of X)if(!C.has(G)&&!B.has(G))k.add(G);return{code:E,stxImports:Array.from(v),browserImports:Array.from(k)}}function Kr(x,v,k=!1){let E=Wu(x);x=E.code;let C=new RegExp(`\\b${v.replace(/[$]/g,"\\$")}\\b`,"g");for(let j of x.matchAll(C)){let L=j.index??0;if(E.shadows(v,L))continue;let B=L+v.length,z=L-1;while(z>=0&&/\s/.test(x[z]))z--;if(x[z]==="."&&x.slice(Math.max(0,z-2),z+1)!=="...")continue;let F=B;while(F<x.length&&/\s/.test(x[F]))F++;if(x[F]===":"&&x[F+1]!==":"&&(x[z]==="{"||x[z]===","))continue;if(k&&!/^\s*(?:<[^>]*>)?\s*\(/.test(x.slice(B)))continue;return!0}return!1}function Lo(x,v){let k=[];if(x.length>0)k.push(` var { ${x.join(", ")} } = window.stx || window;`);if(v.length>0)k.push(` var { ${v.join(", ")} } = window.StacksBrowser || {};`);if(k.length>0)return` // STX: auto-imported from stx and @stacksjs/browser
|
|
762
|
-
${k.join(`
|
|
763
|
-
`)}
|
|
764
|
-
${Sh(x,v)}`;return""}function yu(x,v=[]){let{browserImports:k}=No(x),E=new Set(v);return Lo([],k.filter((C)=>!E.has(C)))}function Sh(x,v){let k=[...x.map((E)=>`['${E}', typeof ${E}, 'stx']`),...v.map((E)=>`['${E}', typeof ${E}, '@stacksjs/browser']`)];if(k.length===0)return"";return` // STX: report auto-imports the client runtime did not provide
|
|
765
|
-
[${k.join(", ")}].forEach(function (e) {
|
|
766
|
-
if (e[1] !== 'undefined') return;
|
|
767
|
-
console.error(
|
|
768
|
-
'[stx] "' + e[0] + '" is used in this client script and auto-imported from ' + e[2] + ', '
|
|
769
|
-
+ 'but the client runtime does not provide it. Either it is not exported to the browser, '
|
|
770
|
-
+ 'or it should be imported from a relative path so the bundler includes it.'
|
|
771
|
-
);
|
|
772
|
-
});
|
|
773
|
-
`}function Ne(x){let v=x.__stxClientPayload;if(v&&typeof v==="object"){let E={};for(let C in v){let j=v[C];if(typeof j==="function")continue;E[C]=j}return E.__stxDeclaredPayload=!0,E}let k={};for(let E in x){if(E.startsWith("__")||E.startsWith("$"))continue;let C=x[E];if(typeof C==="function")continue;k[E]=C}return k}function $h(x,v){return new RegExp(`(?<![.#\\w$])${v}(?![\\w$])`).test(x)}var _h=/token|secret|passw|apikey|api_key|privatekey|private_key|credential|webhook|bearer|jwt|signature/i,Uu=new Set;function kh(x,v){let k=_h.test(x),E=v.length>32768;if(!k&&!E)return;if(Uu.has(x))return;if(Uu.add(x),k)console.warn(`[stx] server\u2192client bridge is publishing "${x}" 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 ${(v.length/1024).toFixed(1)}KB under "${x}". Every byte ships in the HTML on each request; prefix the binding with "__" and project just the fields the client reads.`)}function Xr(x,v){if(!v)return"";let k=s(x),E=v.__stxDeclaredPayload===!0,C=[];for(let[j,L]of Object.entries(v)){if(!/^[A-Za-z_$][\w$]*$/.test(j))continue;if(j.startsWith("__")||j.startsWith("$"))continue;if(!E&&!$h(k,j))continue;if(zi(x,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 B;try{B=JSON.stringify(L)}catch{continue}if(B===void 0)continue;kh(j,B),C.push(` var ${j} = ${B.replace(/</g,"\\u003c")};`)}if(C.length===0)return"";return` // stx: server -> client data bridge (seeded from server scope)
|
|
774
|
-
${C.join(`
|
|
775
|
-
`)}
|
|
776
|
-
`}var Eh={left:0,middle:1,right:2};function Ch(x){let v=[];if(x.self)v.push("if ($event.target !== $el) return");for(let k of x.systemKeys)v.push(`if (!$event.${k}Key) return`);if(x.keys.length>0){let k=x.keys.map((E)=>`$event.key === '${E}'`).join(" || ");v.push(`if (!(${k})) return`)}if(x.mouse!==null){let k=Eh[x.mouse];v.push(`if ($event.button !== ${k}) return`)}if(x.prevent)v.push("$event.preventDefault()");if(x.stop)v.push("$event.stopPropagation()");return v.join("; ")}function Rh(x,v){let{elementId:k,event:E,modifiers:C}=x,j=ma(x.handler),L=Ch(C),B=[];if(C.once)B.push("once: true");if(C.capture)B.push("capture: true");if(ga(E,C))B.push("passive: true");let z=B.length>0?`, { ${B.join(", ")} }`:"",F="";if(L)F+=`${L}; `;let X=j.replace(/\\/g,"\\\\").replace(/'/g,"\\'"),G=`var $emit = function(name, detail) {
|
|
777
|
-
$el.dispatchEvent(new CustomEvent(name, { detail: detail, bubbles: true, cancelable: true }))
|
|
778
|
-
};`;function J(ne){if(/\$emit\s*\(/.test(ne))return`${G}
|
|
779
|
-
${ne}`;return`var scope = $el.closest('[data-stx-scope]');
|
|
780
|
-
if (scope && scope.__stx_execute) {
|
|
781
|
-
scope.__stx_execute('${X}', $event, $el);
|
|
782
|
-
}
|
|
783
|
-
else {
|
|
784
|
-
${ne}
|
|
785
|
-
}`}if(C.debounce!==null)return` ;(function() {
|
|
786
|
-
// eslint-disable-next-line pickier/no-unused-vars
|
|
787
|
-
var $el = document.getElementById('${k}')
|
|
788
|
-
if (!$el) return
|
|
789
|
-
var __timer
|
|
790
|
-
$el.addEventListener('${E}', function($event) {
|
|
791
|
-
${L?L+"; ":""}clearTimeout(__timer)
|
|
792
|
-
__timer = setTimeout(function() { ${J(j)} }, ${C.debounce})
|
|
793
|
-
}${z})
|
|
794
|
-
})()`;if(C.throttle!==null)return` ;(function() {
|
|
795
|
-
// eslint-disable-next-line pickier/no-unused-vars
|
|
796
|
-
var $el = document.getElementById('${k}')
|
|
797
|
-
if (!$el) return
|
|
798
|
-
var __last = 0
|
|
799
|
-
$el.addEventListener('${E}', function($event) {
|
|
800
|
-
${L?L+"; ":""}var __now = Date.now()
|
|
801
|
-
if (__now - __last >= ${C.throttle}) {
|
|
802
|
-
__last = __now
|
|
803
|
-
${J(j)}
|
|
804
|
-
}
|
|
805
|
-
}${z})
|
|
806
|
-
})()`;if(/\$emit\s*\(/.test(j))return` var $el = document.getElementById('${k}')
|
|
807
|
-
if ($el) $el.addEventListener('${E}', function($event) {
|
|
808
|
-
${F}${G}
|
|
809
|
-
${j}
|
|
810
|
-
}${z})`;return` var $el = document.getElementById('${k}')
|
|
811
|
-
if ($el) $el.addEventListener('${E}', function($event) {
|
|
812
|
-
${F}var scope = $el.closest('[data-stx-scope]');
|
|
813
|
-
if (scope && scope.__stx_execute) {
|
|
814
|
-
scope.__stx_execute('${X}', $event, $el);
|
|
815
|
-
}
|
|
816
|
-
else {
|
|
817
|
-
${j}
|
|
818
|
-
}
|
|
819
|
-
}${z})`}function Th(x){if(x.length===0)return"";return`
|
|
820
|
-
// STX: auto-generated event bindings
|
|
821
|
-
${x.map((k,E)=>Rh(k,E)).join(`
|
|
822
|
-
`)}`}function Hu(x){let v=[],k=new Set,E=x.replace(/^\s*import\s+.*$/gm,""),C=0,j=E.length,L=0;while(L<j){let B=E[L];if(B==="'"||B==='"'||B==="`"){let z=B;if(L++,z==="`"){let F=0;while(L<j){if(E[L]==="\\"){L+=2;continue}if(E[L]==="`"&&F===0){L++;break}if(E[L]==="$"&&E[L+1]==="{"){F++,L+=2;continue}if(E[L]==="}"&&F>0){F--,L++;continue}L++}}else while(L<j){if(E[L]==="\\"){L+=2;continue}if(E[L]===z){L++;break}L++}continue}if(B==="/"&&E[L+1]==="/"){while(L<j&&E[L]!==`
|
|
823
|
-
`)L++;continue}if(B==="/"&&E[L+1]==="*"){L+=2;while(L<j-1&&!(E[L]==="*"&&E[L+1]==="/"))L++;L+=2;continue}if(B==="{"){C++,L++;continue}if(B==="}"){C--,L++;continue}if(C===0){let z=E.slice(L),F=z.match(/^(?:const|let|var)\s+([a-zA-Z_$]\w*)\s*(?::[^=]*)?=/);if(F){let J=F[1];if(!J.startsWith("_")&&!k.has(J))v.push(J),k.add(J);L+=F[0].length;continue}let X=z.match(/^(?:const|let|var)\s+\{([^}]+)\}\s*=/);if(X){X[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))v.push(se),k.add(se)}),L+=X[0].length;continue}let G=z.match(/^(?:async\s+)?function\s+([a-zA-Z_$]\w*)/);if(G){let J=G[1];if(!J.startsWith("_")&&!k.has(J))v.push(J),k.add(J);L+=G[0].length;continue}}L++}return v}var Ah=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 Ih(x){let v=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(!Ah.has(re))v.add(re)}}let C=/\{\{([\s\S]*?)\}\}/g,j;while((j=C.exec(x))!==null)E(j[1]);let L=/:[a-z][\w.-]*\s*=\s*"([^"]*)"/gi;while((j=L.exec(x))!==null)E(j[1]);let B=/:[a-z][\w.-]*\s*=\s*'([^']*)'/gi;while((j=B.exec(x))!==null)E(j[1]);let z=/@[a-z]+(?:\.[a-z]+)*\s*=\s*"([^"]*)"/gi;while((j=z.exec(x))!==null)E(j[1]);let F=/@[a-z]+(?:\.[a-z]+)*\s*=\s*'([^']*)'/gi;while((j=F.exec(x))!==null)E(j[1]);let X=/@model\s*=\s*["']([^"']*)["']/gi;while((j=X.exec(x))!==null)E(j[1]);let G=/@for\s*=\s*["'][^"']*\bin\s+([^"']+)["']/gi;while((j=G.exec(x))!==null)E(j[1]);return v}async function me(x,v={}){let k=x,E="",C=!1,j=[],L=Wr(k,{filePath:v.filePath,projectRoot:v.projectRoot});k=L.code;let B=qr(L.styles),z=bt(k);k=z.code,j=[...z.imports,...z.models];let{hasUserImports:F,bundleClientScript:X}=await ut("stx/client-script-bundler",()=>import("./chunk-6fw3rfcj.js"));if(F(k))k=await X(k,v.filePath||"",{projectRoot:v.projectRoot,minify:v.production}),C=!0;if(v.autoImports!==!1){let ue=No(k);k=ue.code,E=Lo(ue.stxImports,ue.browserImports.filter((xe)=>!j.includes(xe)))}if(E=`${Xr(k,v.serverData)}${E}`,k=R(k),!C&&Ve(v.attrs||""))k=Ue(k);let G=Th(v.eventBindings||[]),J=(v.attrs||"").trim(),ne=/\btype\s*=\s*["']module["']/i.test(J),re=v.instanceId?` data-stx-instance="${v.instanceId}"`:"";if(ne){let ue=J.replace(/\btype\s*=\s*["']module["']/i,"").trim(),xe=`type="module" data-stx-scoped${re}${ue?` ${ue}`:""}`;return`${B}<script ${xe}>
|
|
824
|
-
${zr(`${E}${k}
|
|
825
|
-
${G}`)}
|
|
826
|
-
</script>`}let se=Ps(x),oe=/function __stx_setup_/.test(k),ie=/\bstx\.mount\s*\(|\bstx\.mountEl\s*\(/.test(x);function ge(ue){let xe=ue.length>0?`
|
|
827
|
-
return { ${ue.join(", ")} };`:"";return`${B}<script data-stx-scoped data-stx-run="always"${re}>
|
|
828
|
-
window.stx.mount(function() {
|
|
829
|
-
'use strict';
|
|
830
|
-
${zr(`${E}${k}
|
|
831
|
-
${G}${xe}`)}
|
|
832
|
-
})</script>`}if(!ie&&!oe){if(se)return ge(Hu(x));if(v.templateContent){let ue=Hu(x);if(ue.length>0){let xe=Ih(v.templateContent);if(ue.some(($e)=>xe.has($e)))return ge(ue)}}}return`${B}<script data-stx-scoped data-stx-run="always"${re}>
|
|
833
|
-
;(function() {
|
|
834
|
-
'use strict';
|
|
835
|
-
${zr(`${E}${k}
|
|
836
|
-
${G}`)}
|
|
837
|
-
})()</script>`}import{createHash as Ph}from"crypto";var Wi="__stx_component_client_factories";function Vi(x){let v=x[Wi];return v instanceof Map?v:null}function Xu(x){x[Wi]=new Map}function xa(x,v){let k=Vi(x);if(!k)return null;let E=Ph("sha256").update(v).digest("hex").slice(0,16),C=k.get(E);if(C)C.instances++;else k.set(E,{body:v,instances:1});return E}function Zu(x,v){let k=Vi(v);if(!k?.size)return x;let E=new Map;for(let[X,G]of k)if(G.instances===1)E.set(X,G.body);let C=[];if(E.size>0){let X=[...E.keys()].map((ne)=>JSON.stringify(ne).replace(/[$()*+.?[\\\]^{|}]/g,"\\$&")).join("|"),G=new RegExp(`window\\.__stxComponentFactories\\[(${X})\\]\\(("[^"]+")\\);`,"g"),J=G.exec(x);while(J!==null){let ne=E.get(JSON.parse(J[1]));if(ne!==void 0)C.push({start:J.index,end:J.index+J[0].length,replacement:`(${ne})(${J[2]});`});J=G.exec(x)}}let j=[...k].filter(([,X])=>X.instances>1);if(j.length===0)return Ku(x,C);let B=`<script data-stx-scoped data-stx-run="always" data-stx-component-factories>
|
|
838
|
-
(function() {
|
|
839
|
-
const factories = window.__stxComponentFactories = window.__stxComponentFactories || {};
|
|
840
|
-
${j.map(([X,G])=>` try { factories[${JSON.stringify(X)}] = factories[${JSON.stringify(X)}] || ${G.body}; }
|
|
841
|
-
catch (e) { console.error('[stx] component factory ' + ${JSON.stringify(X)} + ' failed to register; instances of it will not hydrate.', e); }`).join(`
|
|
842
|
-
`)}
|
|
843
|
-
})();
|
|
844
|
-
</script>`,z=x.search(/<script\b(?=[^>]*\bdata-stx-scoped\b)/i),F=z<0?0:z;return C.push({start:F,end:F,replacement:`${B}
|
|
845
|
-
`}),Ku(x,C)}function Ku(x,v){if(v.length===0)return x;v.sort((j,L)=>j.start-L.start||j.end-L.end);let k=Array(v.length*2+1),E=0,C=0;for(let j of v)k[C++]=x.slice(E,j.start),k[C++]=j.replacement,E=j.end;return k[C]=x.slice(E),k.join("")}function Gu(x){let v=Vi(x),k=new Map;if(v)for(let[E,C]of v)k.set(E,C.instances);return k}function Ju(x,v){let k=Vi(x);if(!k)return[];let E=[];for(let[C,j]of k){let L=j.instances-(v.get(C)??0);if(L>0)E.push({body:j.body,count:L})}return E}function Yu(x,v){for(let{body:k,count:E}of v)for(let C=0;C<E;C++)xa(x,k)}import id from"fs";var Qu=0,ba=new Map;function jo(){Qu=0,ba.clear()}function Ui(x,v){let k=Qu++,E=`<!--__STX_${x.toUpperCase()}_${k}__-->`;return ba.set(E,{type:x,expression:v}),E}function Bo(){let x={};for(let[v,k]of ba)x[v]={type:k.type,expression:k.expression};return x}function Fo(x,v){let k=x;for(let[E,C]of v)k=k.split(E).join(C);return k}function Gr(x){return x.includes("<!--__STX_")}var Dh=/@(?=[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 Mh(x){return Array.from({length:x},()=>"{").join("⁠")}function ed(x){return x.replace(/\{{2,}/g,(v)=>Mh(v.length)).replace(/\{(?=!)/g,"{⁠").replace(Dh,"@")}var Oh=/^(?:javascript|vbscript|livescript|mocha|view-source):/,Nh=/^data:(?:text\/html|text\/xml|application\/xhtml\+xml|application\/xml|image\/svg\+xml)/,jh=/^data:(?:text\/html|application\/xhtml\+xml)/,Lh=new RegExp("[\\u0000-\\u0020\\u00A0\\u1680\\u2000-\\u200F\\u2028\\u2029\\u202F\\u205F\\u3000\\uFEFF]+","g");function Bh(x){return x.replace(Lh,"").toLowerCase()}function zh(x){let v=x.toLowerCase();if(new RegExp("^(?:href|xlink:href|action|formaction|ping|cite|manifest|data|to)$").test(v))return"navigable";if(new RegExp("^(?:src|srcset|poster|background)$").test(v))return"fetched";return null}function td(x,v="navigable"){let k=Bh(x);if(Oh.test(k))return!0;return v==="navigable"?Nh.test(k):jh.test(k)}function Vs(x,v="navigable"){return td(x,v)?"unsafe:"+x:x}function Fh(x){let v=x.match(/(?:^|[\s"'`/])([A-Za-z][\w:-]*)\s*=\s*(["'])([^"']*)$/);if(!v)return null;if(v[3].trim()!=="")return null;return zh(v[1])}function va(x,v,k=256){if(v<=k)return x.slice(0,v);let E=x.slice(v-k,v),C=E.search(/[\s"'`/]/);return C===-1?"":E.slice(C)}function wa(x,v,k=v){let E=Fh(x);return E&&td(v,E)?"unsafe:"+k:k}var Hi=/<script\b[^>]*>/iy,ka=/<\/script\s*>/ig,qi=/<style\b[^>]*>/iy,Ea=/<\/style\s*>/ig;function nd(x,v,k,E){k.lastIndex=v;let C=k.exec(x);if(!C||C.index!==v)return-1;E.lastIndex=k.lastIndex;let j=E.exec(x);if(!j)return-1;return j.index+j[0].length}function Y(x,v){return nd(x,v,Hi,ka)}function Fr(x,v){return nd(x,v,qi,Ea)}function Le(x,v){if(!x.startsWith("<!--",v))return-1;let k=x.indexOf("-->",v+4);if(k===-1)return-1;return k+3}function rd(x,v){if(x.startsWith("<!--",v)){let C=Le(x,v);return C===-1?x.length:C}if(Hi.lastIndex=v,Hi.exec(x)?.index===v){ka.lastIndex=Hi.lastIndex;let C=ka.exec(x);return C?C.index+C[0].length:x.length}if(qi.lastIndex=v,qi.exec(x)?.index===v){Ea.lastIndex=qi.lastIndex;let C=Ea.exec(x);return C?C.index+C[0].length:x.length}return-1}function pr(x,v){let k=[],E=0,C=x.length,j=!1,L=null;while(E<C){let B=x[E];if(j){if(L){if(B===L)L=null}else if(B==='"'||B==="'")L=B;else if(B===">")j=!1;E++;continue}if(B!=="<"){let G=x.indexOf("<",E+1);if(G===-1)break;E=G;continue}let z=v(x,E);if(z>E){k.push({start:E,end:z,token:x.slice(E,z)}),E=z;continue}let F=rd(x,E);if(F>E){E=F;continue}let X=x.charCodeAt(E+1);if(X>=65&&X<=90||X>=97&&X<=122)j=!0;E++}return k}function sd(x){let v=0,k=0,E=0,C=!1,j=null;while(E<x.length){if(C){let G=x[E];if(j){if(G===j)j=null}else if(G==='"'||G==="'")j=G;else if(G===">")C=!1;E++;continue}let L=x.indexOf("<",E),B=L===-1?x.length:L;while(E<B){let G=x[E++];if(G==="{")v++;else if(G==="}")k++;if(v>=2&&k>=2)return!0}if(L===-1)break;let z=rd(x,L);if(z>L){E=z;continue}let F=x.charCodeAt(L+1),X=F===47?x.charCodeAt(L+2):F;if(X>=65&&X<=90||X>=97&&X<=122)C=!0;E=L+1}return!1}function Ki(x,v){while(x.size>=v){let k=x.keys().next();if(k.done)return;x.delete(k.value)}}var Wh=65536,Vh=12,Sa=new Map;function En(x,v,k,E){let C=E!==void 0&&x.length>=Wh,j=C?`${E}\x00${x}`:"";if(C){let X=Sa.get(j);if(X)return{output:X.output,tokens:X.tokens.slice()}}let L=pr(x,v);if(L.length===0)return{output:x,tokens:[]};let B=L.map((X)=>X.token),z="",F=0;for(let X=0;X<L.length;X++){let G=L[X];z+=x.slice(F,G.start),z+=k(G.token,X),F=G.end}if(z+=x.slice(F),C)return Ki(Sa,Vh),Sa.set(j,{output:z,tokens:B}),{output:z,tokens:B.slice()};return{output:z,tokens:B}}var Uh=65536,Hh=4,$a=new Map;function _a(x,v,k){return{output:v,scripts:k,restore:(E)=>E===v?x:Vr(E,k)}}function bn(x){let v=x.length>=Uh;if(v){let C=$a.get(x);if(C)return _a(x,C.output,C.scripts.slice())}let{output:k,tokens:E}=En(x,Y,(C,j)=>`\x00STX_SCRIPT_${j}\x00`);if(v)return Ki($a,Hh),$a.set(x,{output:k,scripts:E}),_a(x,k,E.slice());return _a(x,k,E)}function Vr(x,v){if(v.length===0)return x;return x.replace(/\x00STX_SCRIPT_(\d+)\x00/g,(k,E)=>v[+E]??"")}var Hs={},od=new Map;function qh(x){let v=od.get(x);if(!v){let k=x.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");v=new RegExp(`:${k}(?!\\w)`,"g"),od.set(x,v)}return v.lastIndex=0,v}var In={uppercase:(x,v)=>x!==void 0&&x!==null?String(x).toUpperCase():"",lowercase:(x,v)=>x!==void 0&&x!==null?String(x).toLowerCase():"",capitalize:(x,v)=>{if(x===void 0||x===null)return"";let k=String(x);return k.charAt(0).toUpperCase()+k.slice(1)},number:(x,v,k=0)=>{if(x===void 0||x===null)return"";try{let E=Number(x);return Number.isNaN(E)?"":E.toFixed(Number.parseInt(String(k),10))}catch{return""}},fmt:(x,v,k="en-US")=>{if(x===void 0||x===null)return"";try{let E=Number(x);if(Number.isNaN(E))return String(x);return E.toLocaleString(k)}catch{return String(x)}},join:(x,v,k=",")=>{if(!Array.isArray(x))return"";return x.join(String(k))},escape:(x,v)=>{if(x===void 0||x===null)return"";return wt(String(x))},translate:(x,v,k={})=>{if(!v||!v.__translations)return x;let E=v.__translations,C=v.__i18nConfig?.fallbackToKey??!0,j=String(x).split("."),L=E;for(let z of j){if(L===void 0||L===null)break;L=L[z]}if(L===void 0||L===null)return C?x:"";let B=String(L);return Object.entries(k).forEach(([z,F])=>{B=B.replace(qh(z),String(F))}),B},t:(x,v,k={})=>In.translate(x,v,k),truncate:(x,v,k=50,E="...")=>{if(x===void 0||x===null)return"";let C=String(x);if(C.length<=k)return C;if(k<=E.length)return E.substring(0,k);return C.substring(0,k-E.length)+E},date:(x,v,k="short",E="en-US")=>{if(x===void 0||x===null)return"";try{let C=x instanceof Date?x:new Date(x);if(Number.isNaN(C.getTime()))return String(x);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 C.toISOString();return new Intl.DateTimeFormat(E,j[k]||j.short).format(C)}catch{return String(x)}},currency:(x,v,k="USD",E="en-US")=>{if(x===void 0||x===null)return"";try{let C=Number(x);if(Number.isNaN(C))return String(x);return new Intl.NumberFormat(E,{style:"currency",currency:k}).format(C)}catch{return String(x)}},pluralize:(x,v,k,E)=>{let C=Number(x);if(Number.isNaN(C))return k;let j=E||`${k}s`;return C===1?k:j},first:(x,v)=>{if(x===void 0||x===null)return"";if(Array.isArray(x))return x.length===0?"":x[0];return String(x).charAt(0)},last:(x,v)=>{if(x===void 0||x===null)return"";if(Array.isArray(x))return x.length===0?"":x[x.length-1];let k=String(x);return k.charAt(k.length-1)},length:(x,v)=>{if(x===void 0||x===null)return 0;if(Array.isArray(x)||typeof x==="string")return x.length;if(x instanceof Map||x instanceof Set)return x.size;if(typeof x==="object")return Object.keys(x).length;return 0},json:(x,v,k=!1)=>{if(x===void 0)return"undefined";if(x===null)return"null";try{return k?JSON.stringify(x,null,2):JSON.stringify(x)}catch{return String(x)}},default:(x,v,k="")=>x===void 0||x===null||x===""?k:x,reverse:(x,v)=>{if(x===void 0||x===null)return"";if(Array.isArray(x))return[...x].reverse();return String(x).split("").reverse().join("")},slice:(x,v,k=0,E)=>{if(x===void 0||x===null)return"";if(Array.isArray(x)||typeof x==="string")return x.slice(k,E);return x},replace:(x,v,k,E="")=>{if(x===void 0||x===null)return"";let C=k.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return String(x).replace(new RegExp(C,"g"),()=>E)},stripTags:(x,v)=>{if(x===void 0||x===null)return"";return String(x).replace(/<[^>]*>/g,"")},urlencode:(x,v)=>{if(x===void 0||x===null)return"";return encodeURIComponent(String(x))},abs:(x,v)=>{let k=Number(x);return Number.isNaN(k)?0:Math.abs(k)},round:(x,v,k=0)=>{let E=Number(x);if(Number.isNaN(E))return 0;let C=10**k;return Math.round(E*C)/C}};function Ha(x,v){if(x in In)console.warn(`Filter "${x}" already exists as a built-in filter. Custom filter will take precedence.`);Hs[x]=v}function bu(x){for(let[v,k]of Object.entries(x))Ha(v,k)}function Va(){return{...In,...Hs}}function wu(){for(let x of Object.keys(Hs))delete Hs[x]}function Ua(x,v,k=2){let E=0,C=null;for(let j=v+k;j<x.length;j++){let L=x[j];if(C){if(L==="\\"){j++;continue}if(L===C)C=null;continue}if(L==='"'||L==="'"||L==="`"){C=L;continue}if(L==="{"){E++;continue}if(L==="}"){if(E>0){E--;continue}let B=0;while(x[j+B]==="}")B++;if(B>=k)return j}}return-1}function Dn(x,v,k=2){let E="{".repeat(k);if(!x.includes(E))return x;let C="",j=0;for(;;){let L=x.indexOf(E,j);if(L===-1)break;let B=Ua(x,L,k);if(B===-1)break;C+=x.slice(j,L)+v(x.slice(L,B+k),x.slice(L+k,B),L),j=B+k}return j===0?x:C+x.slice(j)}function h(x){return x.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function wt(x){return ed(h(x))}function he(x,v){let{scripts:k}=bn(x);for(let E of k){let C=E.match(/^<script\b([^>]*)>([\s\S]*?)<\/script\s*>$/i);if(!C||/\bserver\b|\bsrc\s*=/.test(C[1]))continue;let j=C[2];if(/\b(state|derived|effect|ref|reactive|computed|watch|watchEffect|useModel)\s*(?:<[^>]*>)?\s*\(/.test(j))return!0;if(fn(j,v))return!0}if(/@(if|for|show)\s*=\s*["'][^"']*\(\s*\)/.test(x))return!0;if(/@for\s*=\s*["'][^"']*\s+(?:in|of)\s+[^"']*\(\s*\)/.test(x))return!0;if(/(?:^|[\s"'])(?::|x-)(?:for|if|else-if|else|show|text|html|model|bind)\b/.test(x))return!0;return!1}function Wa(x){let v=[],k=/<([a-zA-Z][\w-]*)\b[^>]*?\s(?::for|x-for|@for)\s*=\s*(["'])([\s\S]*?)\2[^>]*>/g;for(let E=k.exec(x);E;E=k.exec(x)){let C=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 L=new Set([j[1],...j[2]?[j[2]]:[]]),B=E.index+E[0].length;if(E[0].endsWith("/>")){v.push({start:E.index,end:B,names:L});continue}let z=new RegExp(`<(/?)${C}\\b[^>]*?(/?)>`,"gi");z.lastIndex=B;let F=1,X=x.length;for(let G=z.exec(x);G;G=z.exec(x)){if(G[2]==="/")continue;if(F+=G[1]==="/"?-1:1,F===0){X=G.index+G[0].length;break}}v.push({start:E.index,end:X,names:L})}return v}function Kh(x,v,k){let E=s(k);for(let C of x){if(v<C.start||v>=C.end)continue;for(let j of C.names)if(new RegExp(`(?<![.#\\w$])${j.replace(/\$/g,"\\$")}(?![\\w$])`).test(E))return!0}return!1}function ad(x,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=x.replace(/'[^']*'/g,"").replace(/"[^"]*"/g,""),C="",j=!1,L=0;for(let F=0;F<E.length;F++){let X=E[F];if(!j&&X==="`"){j=!0,L=0;continue}if(j){if(X==="`"&&L===0){j=!1;continue}if(X==="$"&&E[F+1]==="{"){L++,F++,C+=" ";continue}if(X==="}"&&L>0){L--;continue}if(L>0){C+=X;continue}continue}C+=X}E=C;let B=/(?<![a-zA-Z0-9_$])([a-zA-Z_$][a-zA-Z0-9_$]*)/g,z;while((z=B.exec(E))!==null){let F=z[1];if(!E.substring(0,z.index).trimEnd().endsWith(".")){if(!k.includes(F)&&!(F in v))return!1}}return!0}function Xh(x,v){let k=v.__stx_serverDeclared;if(!k||k.size===0)return!1;let E=s(x);for(let C of k)if(new RegExp(`(?<![.#\\w$])${C}(?![\\w$])`).test(E))return!0;return!1}var cd=new Set;function ld(x){return/^[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*)*$/.test(x.trim())}function ud(x,v){let k=`${v??"<unknown>"}\x00${x}`;if(process.env.STX_DEBUG||!cd.has(k))cd.add(k),console.warn(`[stx] {{ ${x} }} in a <script> in ${v??"<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 Jr(x,v,k){let E=x;return E=E.replace(/\{!!([\s\S]*?)!!\}/g,(C,j)=>{try{let L=b(j,v);if(L===void 0)return ld(j)?ud(j.trim(),k):C;return L===null?"":String(L)}catch{return C}}),E=Dn(E,(C,j,L)=>{let B=j.trim();if(/^__[A-Z_]+__$/.test(B))return C;try{let z=b(j,v);if(z===void 0)return ld(B)?ud(B,k):C;return JSON.stringify(z).replace(/</g,"\\u003c")}catch{return C}}),E}function qa(x,v){if(!x.includes("{"))return x;let k=x;return k=k.replace(/\{!!([\s\S]*?)!!\}/g,(E,C)=>{try{let j=b(C,v);if(j===void 0)return E;return j===null?"":String(j)}catch{return E}}),k=Dn(k,(E,C,j)=>{let L=C.trim();if(/^__[A-Z_]+__$/.test(L))return E;try{let B=b(C,v);if(B===void 0)return E;if(B===null)return"";let z=String(B);return wa(va(k,j),z,wt(z))}catch{return E}}),k}function vu(x,v,k={}){let{output:E,scripts:C}=bn(x),j=C.map((L)=>{let B=L.match(/^<script\b([^>]*)>([\s\S]*?)<\/script\s*>$/i),z=L.match(/^<script\b[^>]*>/i),F=L.search(/<\/script\s*>$/i);if(!B||!z||F===-1)return L;let X=B[1],G=B[2];if(/\bdata-raw\b/.test(X))return L;if(k.skipServer&&/\bserver\b/.test(X))return L;let ne=`<script${qa(X,v)}>`;if(/\bsrc\s*=/.test(X)||/\btype\s*=\s*["']application\/json["']/.test(X))return ne+G+L.slice(F);return ne+Jr(G,v)+L.slice(F)});return Vr(E,j)}function W(x,v,k){let E=x,C=(J,ne)=>{let re=Fr(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 oe=re.length,{output:ie,tokens:ge}=En(J,ne,(ue,xe)=>se(oe+xe));return re.push(...ge),ie},L=[];E=j(E,C,L,(J)=>`<!--__STX_STYLE_${J}__-->`);let B=[];E=j(E,Y,B,(J)=>`<!--__STX_SCRIPT_EXPR_${J}__-->`);let z=v?.__stx_signals_gate===!0||he(x),F=new Set(Array.isArray(v?.__stx_client_signal_names)?v.__stx_client_signal_names:[]),X=new Set(Array.isArray(v?.__stx_preserved_client_expressions)?v.__stx_preserved_client_expressions:[]);E=Dn(E,(J,ne,re)=>{try{let se=b(ne,v,!1,(oe)=>Ca(oe,J,k,x));return se!==void 0&&se!==null?String(se):""}catch(se){let oe=se instanceof Error?se.message:String(se);return g("Expression",`Error evaluating: {{{ ${ne.trim()}}}}: ${oe}`,k,x,re,J)}},3),E=E.replace(/\{!!([\s\S]*?)!!\}/g,(J,ne,re)=>{try{let se=b(ne,v,!1,(oe)=>Ca(oe,J,k,x));if(se===void 0&&v.__stx_buildMode==="compile")return Ui("raw",ne.trim());return se!==void 0&&se!==null?String(se):""}catch(se){if(v.__stx_buildMode==="compile")return Ui("raw",ne.trim());let oe=se instanceof Error?se.message:String(se);return g("Expression",`Error evaluating: {!! ${ne.trim()} !!}: ${oe}`,k,x,re,J)}}),E=j(E,Y,B,(J)=>`<!--__STX_SCRIPT_EXPR_${J}__-->`),E=j(E,C,L,(J)=>`<!--__STX_STYLE_${J}__-->`);let G=z?Wa(E):[];if(E=Dn(E,(J,ne,re)=>{let se=ne.trim();if(G.length>0&&Kh(G,re,se))return J;if(X.has(se))return J;let oe=["parseInt","parseFloat","String","Number","Boolean","Array","Object","JSON","Math","Date","encodeURIComponent","decodeURIComponent","encodeURI","decodeURI","true","false","null","undefined"],ie=/^([a-zA-Z_$][a-zA-Z0-9_$]*)/,ue=se.match(ie)?.[1],xe=ue&&((ue in v)||oe.includes(ue)),we=Boolean(ue&&F.has(ue)),$e=/^([a-zA-Z_$][a-zA-Z0-9_$]*)\s*\(/,_e=se.match($e),Ce=_e&&!oe.includes(_e[1])&&!(_e[1]in v);if(/^__[A-Z_]+__$/.test(se))return"";let Ee;try{let Te=b(ne,v,!1,(ke)=>{Ee=ke});if(we)return J;if(z&&!ad(se,v))return J;if(Ee)Ca(Ee,J,k,x);if(v.__stx_buildMode==="compile"&&!z&&(Te===void 0||Xh(se,v)))return Ui("expr",se);if(Te===void 0||Te===null)return"";let Re=String(Te);return wa(va(E,re),Re,wt(Re))}catch(Te){if(we)return J;if(z&&!ad(se,v))return J;if(Ce)return J;let Re=Te instanceof Error?Te.message:String(Te);return g("Expression",`Error evaluating: {{ ${se} }}: ${Re}`,k,x,re,J)}}),B.length>0)E=E.replace(/<!--__STX_SCRIPT_EXPR_(\d+)__-->/g,(J,ne)=>B[Number(ne)]??J);if(L.length>0)E=E.replace(/<!--__STX_STYLE_(\d+)__-->/g,(J,ne)=>L[Number(ne)]??J);return E}function Ka(x,v,k){if(!v.trim())return x;let E=x,C=v.trim();while(C.length>0){let j=C.match(/^(\w+)/);if(!j)break;let L=j[1];C=C.substring(L.length).trim();let B=Hs[L]||In[L];if(!B)throw Error(`Filter not found: ${L}. Available filters: ${Object.keys(Va()).join(", ")}`);let z=[];if(C.startsWith(":")){let F=C.match(/^:([^|\s]+)/);if(F){let X=F[1].trim();try{let G=Number(X);z=[Number.isNaN(G)?X:G]}catch{z=[X]}C=C.substring(F[0].length).trim()}}else if(C.startsWith("(")){let F=1,X=1;while(F>0&&X<C.length){if(C[X]==="(")F++;if(C[X]===")")F--;X++}if(F===0){let G=C.substring(1,X-1).trim();if(G)try{if(G.startsWith("{")&&G.endsWith("}"))z=[b(`(${G})`,k,!0)];else{let J=[],ne="",re=null,se=0,oe=0,ie=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==="[")oe++;else if(xe==="]")oe--;else if(xe==="{")ie++;else if(xe==="}")ie--;if(xe===","&&se===0&&oe===0&&ie===0){J.push(ne),ne="";continue}ne+=xe}if(ne)J.push(ne);z=J.map((ue)=>{let xe=ue.trim();return b(xe,k,!0)})}}catch{z=[G]}C=C.substring(X).trim()}}try{E=B(E,k,...z)}catch(F){let X=F instanceof Error?F.message:String(F);throw Error(`Error applying filter '${L}': ${X}`)}if(C.startsWith("|"))C=C.substring(1).trim();else break}return E}function Zh(x){let v=!1,k="",E=0,C=0,j=0,L=!1;for(let B=0;B<x.length;B++){let z=x[B],F=x[B+1];if(v&&L){L=!1;continue}if(v&&z==="\\"){L=!0;continue}if(L=!1,(z==='"'||z==="'"||z==="`")&&!L){if(!v)v=!0,k=z;else if(z===k)v=!1,k="";continue}if(v&&k==="`"&&z==="$"&&F==="{"){let X=1;B+=2;while(B<x.length&&X>0){if(x[B]==="{")X++;else if(x[B]==="}")X--;if(X>0)B++}continue}if(v)continue;if(z==="(")E++;else if(z===")")E--;else if(z==="[")C++;else if(z==="]")C--;else if(z==="{")j++;else if(z==="}")j--;if(z==="|"&&E===0&&C===0&&j===0){if(F==="|"){B++;continue}if(F==="="){B++;continue}return B}}return-1}var Us=new Set,Gh=1000;function xu(){Us.clear()}function Ca(x,v,k,E){if(!D())return;let C=`${k}\x00${x.expression}`;if(Us.has(C))return;if(Us.size>=Gh)Us.clear();Us.add(C);let j=k,L=E;try{if(k&&id.existsSync(k))L=id.readFileSync(k,"utf8")}catch{}let B=L.indexOf(v);if(B>=0)j=`${k}:${L.slice(0,B).split(`
|
|
846
|
-
`).length}`;console.warn(`${j}: stx warning: ${v} rendered as an empty string. The safe evaluator rejected \`${x.expression}\` (${x.rule}). Compute the value in <script server> and interpolate the variable instead.`)}function b(x,v,k=!1,E){try{let C=x.trim(),j=Zh(C);if(j>0){let B=C.substring(0,j).trim(),z=C.substring(j+1).trim(),F=b(B,v,!0,E);return Ka(F,z,v)}let L=dn(C);if(L!==null){E?.({expression:C,rule:L});return}try{let B=Object.keys(v),z=Object.values(v);return l(C,B)(...z)}catch{return c(C,v)}}catch(C){if(C instanceof ReferenceError){let j=/(\b\w+)\s+is not defined/.exec(C.message);if(j){let L=j[1],B=Jh(L,Object.keys(v));if(B&&B!==L)C.message=`${C.message} \u2014 did you mean '${B}'?`}}if(!k)console.error(`Error evaluating expression: ${x}`,C);throw C}}function Jh(x,v){let k=null;for(let C of v){if(C===x)continue;let j=Yh(x,C);if(k===null||j<k.dist)k={key:C,dist:j}}if(!k)return null;let E=Math.max(x.length,k.key.length);if(k.dist<=2||k.dist/E<=0.35)return k.key;return null}function Yh(x,v){if(x===v)return 0;if(x.length===0)return v.length;if(v.length===0)return x.length;let[k,E]=x.length<v.length?[x,v]:[v,x],C=Array(k.length+1),j=Array(k.length+1);for(let L=0;L<=k.length;L++)C[L]=L;for(let L=1;L<=E.length;L++){j[0]=L;for(let B=1;B<=k.length;B++){let z=k[B-1]===E[L-1]?0:1;j[B]=Math.min(j[B-1]+1,C[B]+1,C[B-1]+z)}for(let B=0;B<=k.length;B++)C[B]=j[B]}return C[k.length]}function Su(x){if(!x)return"";return x.replace(/</g,"<").replace(/>/g,">").replace(/"/g,'"').replace(/'/g,"'").replace(/'/g,"'").replace(/&/g,"&")}import pd from"fs";class V{cache=new Map;maxSize;options;sizes;bytes=0;constructor(x=100,v){this.maxSize=x,this.options=v??null,this.sizes=v?new Map:null}get byteSize(){return this.bytes}setMaxBytes(x){if(!this.options)return;this.options={...this.options,maxBytes:x};while(this.bytes>x&&this.cache.size>0){let v=this.cache.keys().next().value;if(v===void 0)break;this.delete(v)}}get(x){if(!this.cache.has(x))return;let v=this.cache.get(x);return this.cache.delete(x),this.cache.set(x,v),v}set(x,v){if(this.cache.has(x))this.delete(x);let k=this.options?this.options.sizeOf(v):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(x,v),this.sizes)this.sizes.set(x,k),this.bytes+=k}has(x){return this.cache.has(x)}delete(x){if(this.sizes){let v=this.sizes.get(x);if(v!==void 0)this.bytes-=v,this.sizes.delete(x)}return this.cache.delete(x)}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 Ur=new Map,Qh=500;function _r(x,v){if(v?.includes("g"))return new RegExp(x,v);let k=`${x}:${v||""}`;if(!Ur.has(k)){if(Ur.size>=Qh){let E=Ur.keys().next().value;if(E)Ur.delete(E)}Ur.set(k,new RegExp(x,v))}return Ur.get(k)}class dd{pool=[];maxPoolSize=10;fnCache=new Map;fnCacheMaxSize=200;getEvaluator(x){let v=Array.from(new Set(x)),k=v.sort().join(","),E=this.pool.find((B)=>B.context.join(",")===k);if(E)return E.func;let C=this.fnCache,j=this.fnCacheMaxSize,L=(...B)=>(z)=>{try{let F=`${k}:${z}`,X=C.get(F);if(!X){if(C.size>=j){let G=C.keys().next().value;if(G)C.delete(G)}X=Function(...v,`
|
|
847
|
-
'use strict';
|
|
848
|
-
try {
|
|
849
|
-
return ${z};
|
|
850
|
-
}
|
|
851
|
-
catch (e) {
|
|
852
|
-
if (e instanceof ReferenceError || e instanceof TypeError) {
|
|
853
|
-
return undefined;
|
|
854
|
-
}
|
|
855
|
-
throw e;
|
|
856
|
-
}
|
|
857
|
-
`),C.set(F,X)}return X(...B)}catch{return}};if(this.pool.length<this.maxPoolSize)this.pool.push({func:L,context:v.slice()});return L}clear(){this.pool.length=0,this.fnCache.clear()}}var t$=new dd;class fd{metrics=new Map;budgets=new Map;violations=[];maxViolations=100;violationHandlers=[];enabled=!0;setEnabled(x){this.enabled=x}isEnabled(){return this.enabled}setBudget(x,v){this.budgets.set(x,{warnThreshold:0.8,action:"warn",...v})}setBudgets(x){for(let[v,k]of Object.entries(x))this.setBudget(v,k)}removeBudget(x){this.budgets.delete(x)}getBudgets(){let x={};for(let[v,k]of this.budgets.entries())x[v]=k;return x}onViolation(x){this.violationHandlers.push(x)}offViolation(x){let v=this.violationHandlers.indexOf(x);if(v!==-1)this.violationHandlers.splice(v,1)}time(x,v){if(!this.enabled)return v();let k=performance.now(),E=v(),C=performance.now()-k;return this.recordTime(x,C),this.checkBudget(x,C),E}async timeAsync(x,v){if(!this.enabled)return v();let k=performance.now(),E=await v(),C=performance.now()-k;return this.recordTime(x,C),this.checkBudget(x,C),E}checkBudget(x,v){let k=this.budgets.get(x);if(!k)return;let E=v/k.maxTime*100,C=k.warnThreshold!==void 0?v>=k.maxTime*k.warnThreshold&&v<k.maxTime:!1,j=v>=k.maxTime;if(!C&&!j)return;let L={label:x,actualTime:v,budgetTime:k.maxTime,exceedancePercent:E,timestamp:new Date,isWarning:C};this.violations.push(L);while(this.violations.length>this.maxViolations)this.violations.shift();for(let z of this.violationHandlers)try{z(L)}catch{}let B=C?`[Performance Warning] "${x}" took ${v.toFixed(2)}ms (${E.toFixed(1)}% of ${k.maxTime}ms budget)`:`[Performance Budget Exceeded] "${x}" took ${v.toFixed(2)}ms (exceeded ${k.maxTime}ms budget by ${(E-100).toFixed(1)}%)`;switch(k.action){case"log":console.log(B);break;case"warn":console.warn(B);break;case"error":console.error(B);break;case"throw":if(j)throw Error(B);else console.warn(B);break}}recordTime(x,v){let k=this.metrics.get(x);if(k)k.count++,k.totalTime+=v,k.maxTime=Math.max(k.maxTime,v),k.minTime=Math.min(k.minTime,v);else this.metrics.set(x,{count:1,totalTime:v,maxTime:v,minTime:v})}getStats(x){if(x){let k=this.metrics.get(x);if(!k)return{};let E=this.budgets.get(x);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 v={};for(let[k,E]of this.metrics.entries()){let C=this.budgets.get(k);v[k]={count:E.count,avgTime:E.totalTime/E.count,totalTime:E.totalTime,maxTime:E.maxTime,minTime:E.minTime,budget:C?.maxTime,budgetUtilization:C?E.totalTime/E.count/C.maxTime*100:void 0}}return v}getViolations(x){if(x)return this.violations.filter((v)=>v.label===x);return[...this.violations]}getViolationStats(){let x={},v=0,k=0;for(let E of this.violations)if(x[E.label]=(x[E.label]||0)+1,E.isWarning)v++;else k++;return{total:this.violations.length,byLabel:x,warnings:v,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 Ra=null;function ey(){if(!Ra)Ra=new fd;return Ra}var U=new Proxy({},{get(x,v){return ey()[v]}});var gd=[];function I(x){let v=new V(x);return gd.push(v),v}function md(){for(let x of gd)x.clear()}function O(x,...v){return`${v.map((k)=>String(k??"")).join("\x00")}\x00${x.length}\x00${Bun.hash(x)}`}function hd(x){let v=[];for(let k of new Set(x))try{v.push({path:k,mtimeMs:pd.statSync(k).mtimeMs})}catch{}return v}function Yt(x){for(let v of x)try{if(pd.statSync(v.path).mtimeMs!==v.mtimeMs)return!1}catch{return!1}return!0}import uw from"fs";import cn from"path";import It from"path";import{hasLocalConfig as Ld}from"bunfig";import Cn from"fs";import Er from"path";import Ta from"fs";import yd from"path";import{fileURLToPath as ty}from"url";var Aa;function Me(){if(Aa)return Aa;let x="unknown";try{x=String(JSON.parse(Ta.readFileSync(new URL("../package.json",import.meta.url),"utf8")).version)}catch{}if(import.meta.url.endsWith(".ts"))try{let v=yd.dirname(ty(import.meta.url)),k=0;for(let E of Ta.readdirSync(v,{recursive:!0,withFileTypes:!0}))if(E.isFile()&&E.name.endsWith(".ts"))k=Math.max(k,Ta.statSync(yd.join(E.parentPath,E.name)).mtimeMs);x+=`+src.${Math.trunc(k)}`}catch{}return Aa=x,x}var Xa=new Map,Cr=new Map;async function ku(x){let k;for(let E=0;E<3;E++)try{let j=(await Cn.promises.stat(x)).mtime.getTime(),L=Cr.get(x);if(L&&L.mtime===j)return L.content;let B=await Bun.file(x).text(),F=(await Cn.promises.stat(x)).mtime.getTime();if(F!==j)continue;return Cr.set(x,{content:B,mtime:F}),B}catch(C){k=C;break}throw Cr.delete(x),Error(`File not found: ${x}${k?` (${k.message})`:""}`)}function Cu(x){Cr.delete(x)}function $u(x){for(let v of Cr.keys())if(v.startsWith(x))Cr.delete(v)}var Xi=null,ny=null,bd=null;function Eu(x){bd=x}async function Ga(x=!1){let v=bd??await import("./chunk-a1dggchm.js");if(x)return v.generateSignalsRuntimeDev();if(Xi===null)Xi=v.generateSignalsRuntime();return Xi}var Zi=null;async function Ja(){if(Zi===null){let{getRouterScript:x}=await import("./chunk-gpmk4s4f.js");Zi=x()}return Zi}var xd={};async function Tu(x,v=!1){let k=x==="runtime"?await Ga(v):await Ja(),E=x==="runtime"&&v?"runtime-debug":x,C=xd[E];if(!C||C.content!==k)C={content:k,hash:Bun.hash(k).toString(16).padStart(16,"0").slice(0,16)},xd[E]=C;return{content:k,hash:C.hash,url:`/_stx/${x}.${C.hash}.js`}}var ry=500,kr=new Map;function vd(x){return a(process.cwd(),"module-bundles",`${x}.js`)}function _u(x){let v=Bun.hash(x).toString(16).padStart(16,"0").slice(0,16),k=kr.has(v);if(k)kr.delete(v);kr.set(v,x);while(kr.size>ry)kr.delete(kr.keys().next().value);if(!k)try{let E=vd(v);if(!Cn.existsSync(E))Cn.mkdirSync(Er.dirname(E),{recursive:!0}),Cn.writeFileSync(E,x)}catch{}return`/_stx/modules.${v}.js`}function zo(x){if(!/^[0-9a-f]{16}$/.test(x))return;let v=kr.get(x);if(v!==void 0)return v;try{return Cn.readFileSync(vd(x),"utf8")}catch{return}}function Ru(){Cr.clear(),ee(),md(),Xi=null,ny=null,Zi=null}function wd(x){let v={debug:x.debug===!0,middleware:(x.middleware??[]).map((k)=>({name:k.name,timing:k.timing,handler:String(k.handler)})),customDirectives:(x.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(v)).digest("hex")}async function Zt(x,v){try{if(!v.cachePath)return null;let k=Er.resolve(v.cachePath),E=Er.join(k,`${On(x)}.html`),C=Er.join(k,`${On(x)}.meta.json`);if(!await r(E)||!await r(C))return null;let j=await Bun.file(C).text(),L=JSON.parse(j);if(L.cacheVersion!==v.cacheVersion)return null;if(L.engine!==Me())return null;if(L.optionsSignature!==wd(v))return null;if((await Cn.promises.stat(x)).mtime.getTime()>L.mtime)return null;for(let z of L.dependencies)if(await r(z)){if((await Cn.promises.stat(z)).mtime.getTime()>L.mtime)return null}else return null;return await Bun.file(E).text()}catch(k){return console.warn(`Cache error for ${x}:`,k),null}}async function Qt(x,v,k,E){try{if(!E.cachePath)return;let C=Er.resolve(E.cachePath);await Cn.promises.mkdir(C,{recursive:!0});let j=Er.join(C,`${On(x)}.html`),L=Er.join(C,`${On(x)}.meta.json`),B=await Cn.promises.stat(x);await Bun.write(j,v);let z={sourcePath:x,mtime:B.mtime.getTime(),dependencies:Array.from(k),cacheVersion:E.cacheVersion,engine:Me(),optionsSignature:wd(E),generatedAt:Date.now()};await Bun.write(L,JSON.stringify(z,null,2)),Xa.set(x,{output:v,mtime:B.mtime.getTime(),dependencies:k})}catch(C){console.warn(`Failed to cache template ${x}:`,C)}}var sy=16;function On(x){return new Bun.CryptoHasher("sha1").update(x).digest("hex").substring(0,sy)}var Mn={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 Ia(x){return`--stx-${x}`}function Pa(x,v){let k=v.lastIndexOf("-");if(k===-1)return typeof x[v]==="string"?x[v]:void 0;let E=x[v.slice(0,k)];if(!E||typeof E!=="object")return;let C=E[v.slice(k+1)];return typeof C==="string"?C:void 0}function Sd(x){let v={};for(let[k,E]of Object.entries(Mn)){let C=Pa(x,E.light);if(C===void 0)continue;v[k]=`var(${Ia(k)}, ${C})`}return v}function $d(x){let v=[],k=[];for(let[E,C]of Object.entries(Mn)){let j=Pa(x,C.light),L=Pa(x,C.dark);if(j===void 0)continue;if(v.push(` ${Ia(E)}: ${j};`),L!==void 0)k.push(` ${Ia(E)}: ${L};`)}if(v.length===0)return"";return["/* stx role tokens \u2014 override any of these to re-theme by meaning. */",":root {",...v,"}",".dark {",...k,"}",""].join(`
|
|
858
|
-
`)}var _d={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 kd(x){return`--stx-radius-${x}`}function Ed(){let x={};for(let[v,k]of Object.entries(_d))x[v]=`var(${kd(v)}, ${k.value})`;return x}function Cd(){return["/* stx shape tokens \u2014 a radius by what the thing is. */",":root {",...Object.entries(_d).map(([x,v])=>` ${kd(x)}: ${v.value};`),"}",""].join(`
|
|
859
|
-
`)}function Rd(x){return typeof x==="object"&&x!==null&&!Array.isArray(x)}function Da(x,v){let k={...x};for(let[E,C]of Object.entries(v))k[E]=Rd(C)&&Rd(k[E])?Da(k[E],C):C;return k}function Td(x,v){if(!v.fonts)return"";let k=new x({...v.config,fonts:v.fonts,cssVariables:!1}).toCSS(!1,v.minify);return k&&!v.minify?`${k}
|
|
860
|
-
`:k}function Ad(x={},v={}){let k=x.theme||{},E=v.theme||{},{extend:C,...j}=E,{extend:L,...B}=k,z=B.colors||{};B.colors={...z,...Sd(z)};let F=B.borderRadius||{};B.borderRadius={...F,...Ed()};let X=Da(B,j),G=Da(L||{},C||{});if(Object.keys(G).length>0)X.extend=G;let J=[...x.safelist||[],...v.safelist||[]],ne={...x.shortcuts||{},...v.shortcuts||{}},re=[...x.preflights||[],...v.preflights||[]],{fonts:se,...oe}=x,{fonts:ie,...ge}=v,ue=ie??se;return{config:{...oe,...ge,theme:X,safelist:J,shortcuts:ne,...re.length>0?{preflights:re}:{},content:[],output:""},safelist:J,shortcuts:ne,includePreflight:v.preflight!==!1,minify:v.minify===!0,tokenCSS:$d(z)+Cd(),...ue?{fonts:ue}:{}}}function Id(x,v=""){let k=`${x}${v}`,E=0;for(let C=0;C<k.length;C++){let j=k.charCodeAt(C);E=(E<<5)-E+j,E=E&E}return`stx-${Math.abs(E).toString(36)}`}function Pd(x,v,k={}){let{prefix:E="",preserveHost:C=!0,scopeKeyframes:j=!0,scopeCustomProperties:L=!1}=k;if(!x.trim())return"";let B=Ma(x),z=[],F=new Map;if(j)for(let X of B){let G=X.selector.match(/@keyframes\s+([a-z_-][a-z0-9_-]*)/i);if(G){let J=G[1],ne=`${v}_${J}`;F.set(J,ne)}}for(let X of B){let G=Dd(X,v,E,C,F,L);z.push(G)}return z.join(`
|
|
861
|
-
|
|
862
|
-
`)}function Ma(x){let v=[],k=x.replace(/\/\*[\s\S]*?\*\//g,""),E=0,C="",j=!1,L="";for(let B=0;B<k.length;B++){let z=k[B];if(z==="@"&&E===0)j=!0;if(z==="{")E++;else if(z==="}"){if(E--,E===0){if(j){L+=z;let F=L.match(/@([a-z-]+)\s*([^{]*)\{([\s\S]*)\}/i);if(F){let[,X,G,J]=F;if(X==="keyframes")v.push({selector:`@keyframes ${G.trim()}`,declarations:J.trim()});else if(X==="media"||X==="supports"||X==="container"){let ne=Ma(J);v.push({selector:`@${X} ${G.trim()}`,declarations:ne.map((re)=>`${re.selector} { ${re.declarations} }`).join(`
|
|
863
|
-
`)})}else v.push({selector:`@${X} ${G.trim()}`,declarations:J.trim()})}L="",j=!1}else if(C.trim()){C+=z;let F=C.match(/([^{]+)\{([^}]*)\}/);if(F)v.push({selector:F[1].trim(),declarations:F[2].trim()});C=""}continue}}if(j)L+=z;else C+=z}return v}function Dd(x,v,k,E,C,j){let{selector:L,declarations:B}=x;if(L.startsWith("@")){if(L.startsWith("@keyframes")){let X=L.replace("@keyframes ","").trim();return`@keyframes ${C.get(X)||X} { ${B} }`}if(L.startsWith("@media")||L.startsWith("@supports")||L.startsWith("@container")){let G=Ma(`x { ${B} }`.replace(/x \{ /,"").replace(/ \}$/,"")).map((J)=>Dd(J,v,k,E,C,j)).join(`
|
|
864
|
-
`);return`${L} {
|
|
865
|
-
${G}
|
|
866
|
-
}`}return`${L} { ${B} }`}let z=iy(L,v,k,E),F=B;for(let[X,G]of C)F=F.replace(new RegExp(`\\b${X}\\b`,"g"),G);if(j)F=F.replace(/--([a-z-]+)/gi,`--${v}-$1`);return`${z} { ${F} }`}function iy(x,v,k,E){let C=x.split(",").map((L)=>L.trim()),j=[];for(let L of C){if(L.startsWith(":host")){if(E)j.push(L);else{let F=L.replace(/:host(\([^)]*\))?/,`.${v}$1`);j.push(F)}continue}if(L.includes("::slotted")){j.push(L);continue}if(L===":root"){j.push(`:root .${v}`);continue}let B=k?`${k} .${v}`:`.${v}`;j.push(`${B} ${L}`);let z=oy(L,v);if(z)j.push(k?`${k} ${z}`:z)}return j.join(", ")}function oy(x,v){let k=0,E=x.length;for(let z=0;z<x.length;z++){let F=x[z];if(F==="["||F==="(")k++;else if(F==="]"||F===")")k--;else if(k===0&&(F===" "||F===">"||F==="+"||F==="~")){E=z;break}}let C=x.slice(0,E),j=x.slice(E);if(!C)return"";let L=C.length,B=0;for(let z=0;z<C.length;z++){let F=C[z];if(F==="["||F==="(")B++;else if(F==="]"||F===")")B--;else if(k===0&&B===0&&F===":"){L=z;break}}return`${C.slice(0,L)}.${v}${C.slice(L)}${j}`}var Nd=String.raw`(?<![\w-])scoped(?![\w-])`,Oa=/<style\s+([^>]*)>/gi,Md=/<style\s+([^>]*)>([\s\S]*?)<\/style>/gi,jd=new RegExp(Nd,"i"),ay=new RegExp(Nd,"gi"),Na=/<style\b[^>]*\bdata-stx-scoped(?:=(?:"[^"]*"|'[^']*'|[^\s>]+))?[^>]*>[\s\S]*?<\/style>\s*/gi;function cy(x){Oa.lastIndex=0;let v=Oa.exec(x);while(v!==null){if(jd.test(v[1]))return!0;v=Oa.exec(x)}return!1}function ja(x){let v=new Set,k=[];Na.lastIndex=0;let E=Na.exec(x);while(E!==null){let C=E[0].trim();if(v.has(C))k.push({start:E.index,end:E.index+E[0].length});else v.add(C);E=Na.exec(x)}return k}function qs(x){let v=ja(x);if(v.length===0)return x;let k=Array(v.length+1),E=0;for(let C=0;C<v.length;C++){let j=v[C];k[C]=x.slice(E,j.start),E=j.end}return k[v.length]=x.slice(E),k.join("")}function Gi(x,v){if(!cy(x))return{html:x,hasScoped:!1};let k=Id(v),E=`data-v-${k}`,C=x,j=!1;if(Md.lastIndex=0,C=C.replace(Md,(L,B,z)=>{if(!jd.test(B))return L;j=!0;let F=ly(z,E),X=B.replace(ay,"").trim(),G=X?` ${X}`:"";return`<style data-stx-scoped="${k}"${G}>${F}</style>`}),!j)return{html:x,hasScoped:!1};return C=dy(C,E),{html:C,hasScoped:!0}}function ly(x,v){return Pd(x,"__SCOPE_PLACEHOLDER__",{preserveHost:!1}).replace(/\.(__SCOPE_PLACEHOLDER__) /g,`[${v}] `).replace(/\.(__SCOPE_PLACEHOLDER__)/g,`[${v}]`)}var uy=(x)=>`\x00stx-scope-mask-${x}\x00`,Od=/\u0000stx-scope-mask-(\d+)\u0000/g;function dy(x,v){let k=En(x,(C,j)=>{let L=Y(C,j);return L>j?L:Fr(C,j)},(C,j)=>uy(j)),E=fy(k.output,v);return Od.lastIndex=0,E.replace(Od,(C,j)=>k.tokens[Number(j)])}function fy(x,v){let k=new Set(["script","style","template","html","head","body","meta","link","title","base","!doctype","!DOCTYPE"]);return x.replace(/<([a-zA-Z][a-zA-Z0-9-]*)(\s[^>]*)?\/?>/g,(E,C,j)=>{if(k.has(C.toLowerCase()))return E;if(E.includes(v))return E;if(C.toLowerCase()==="style"||C.toLowerCase()==="script")return E;if(j)return E.replace(`<${C}${j}`,`<${C} ${v}${j}`);if(E.endsWith("/>"))return`<${C} ${v} />`;return`<${C} ${v}>`})}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,Ba=!1,Rr=null,Ks="",Hr=!1,Fd=256,gr=new Map,Tn=new Map,Ji=null,Wd=null,Yi=new Map;function Qi(x){return Bun.hash(x).toString(16).padStart(16,"0").slice(0,16)}function La(x,v){if(gr.has(x))gr.delete(x);else if(gr.size>=Fd)gr.delete(gr.keys().next().value);gr.set(x,v)}function py(x){let v=Qi(x);if(Tn.has(v))Tn.delete(v);else if(Tn.size>=Fd)Tn.delete(Tn.keys().next().value);return Tn.set(v,x),v}function Au(x){let v=Tn.get(x);if(v===void 0)return;return Tn.delete(x),Tn.set(x,v),v}async function gy(x,v=Ji){if(!v)return null;try{let k=Bun.file(It.join(v,`cw-${Qi(x)}.css`));if(!await k.exists())return null;return await k.text()}catch{return null}}async function my(x,v,k=Ji){if(!k)return;try{if(!fs.existsSync(k))fs.mkdirSync(k,{recursive:!0});await Bun.write(It.join(k,`cw-${Qi(x)}.css`),v)}catch{}}async function Bd(x){try{let v=await import(x);if(v&&v.CSSGenerator)return{CSSGenerator:v.CSSGenerator,config:v.config,build:v.build,defaultConfig:v.defaultConfig,extractClasses:v.extractClasses}}catch{}return null}var hy=[["@stacksjs","ts-css","dist","engine","index.js"],["@stacksjs","ts-css","src","engine","index.ts"]],yy=["@stacksjs/ts-css/engine","@stacksjs/ts-css/dist/engine/index.js"];function xy(){let x=[],v=process.cwd();while(v!==It.dirname(v)){for(let k of["node_modules","pantry"])for(let E of hy)x.push(It.join(v,k,...E));v=It.dirname(v)}return x}function by(){let x=[],v=process.env.HOME||process.env.USERPROFILE||"",k=[v&&It.join(v,"Code","Tools","ts-css"),v&&It.join(v,"Code","Tools","crosswind"),v&&It.join(v,"repos","stacks-org","ts-css"),v&&It.join(v,"repos","stacks-org","crosswind"),It.join(process.cwd(),"..","ts-css"),It.join(process.cwd(),"..","crosswind")].filter(Boolean);for(let E of k)x.push(It.join(E,"packages","toolkit","dist","engine","index.js")),x.push(It.join(E,"packages","toolkit","src","engine","index.ts"));if(v)x.push(It.join(v,"Code","Tools","stx","node_modules","@stacksjs","ts-css","dist","engine","index.js"));return x}async function Ho(){if(Ba)return Rn;Ba=!0;try{let x=async(C)=>{for(let j of C){if(!await Bun.file(j).exists())continue;let L=await Bd(j);if(L){if(!process.env.STACKS_DEV_QUIET)console.log(`${e.green}[ts-css]${e.reset} CSS engine loaded from ${It.dirname(It.dirname(j))}`);return L}}return null};if(process.env.CROSSWIND_SRC){let C=It.resolve(process.env.CROSSWIND_SRC),j=await x([C]);if(!j)throw Error(`CROSSWIND_SRC did not resolve to a Css module: ${C}`);return Rn=j,Rn}let v=await x(xy());if(v)return Rn=v,Rn;let k=yy;for(let C of k){let j=await Bd(C);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 x(by());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 Pu(){Fa.clear(),Rn=null,Ba=!1,Rr=null,Ks="",gr.clear(),Tn.clear(),Wd=null,Yi.clear()}var zd=!1;async function Vo(x){try{let v=Ld({name:"css",cwd:x})?"css":Ld({name:"crosswind",cwd:x})?"crosswind":null;if(!v)return null;if(v==="crosswind"&&!process.env.STACKS_DEV_QUIET&&!zd)zd=!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:v,cwd:x,defaultConfig:{},checkEnv:!1,verbose:!1});if(!E?.path||!E.config||Object.keys(E.config).length===0)return null;let C=It.relative(x,E.path);if(!process.env.STACKS_DEV_QUIET)console.log(`${e.green}[ts-css]${e.reset} Loaded config from ${C||E.path}`);return E.config}catch(v){if(v instanceof Error&&v.name==="ConfigNotFoundError")return null;return console.warn(`${e.yellow}[ts-css]${e.reset} Failed to load css config:`,v instanceof Error?v.message:v),null}}async function Ya(x){let v=null;try{let{loadStxConfig:k}=await import("./chunk-x1xncm97.js"),E=await k(x);if(E.css)if(typeof E.css==="string"){let C=It.isAbsolute(E.css)?E.css:It.resolve(x,E.css);if(await Bun.file(C).exists()){let j=await import(C);v=j.default||j,console.log(`${e.green}[ts-css]${e.reset} Loaded config from stx.config.ts \u2192 ${E.css}`)}}else{if(v={...E.css,content:E.css.content||[],preflight:E.css.preflight??!0,minify:E.css.minify??!1},E.css.config){let C=It.isAbsolute(E.css.config)?E.css.config:It.resolve(x,E.css.config);if(await Bun.file(C).exists()){let j=await import(C);v={...j.default||j,...v}}}console.log(`${e.green}[ts-css]${e.reset} Using inline CSS config from stx.config.ts`)}}catch{}return v||await Vo(x)}function Za(x){try{let v=new WeakSet;return Qi(JSON.stringify(x??{},(k,E)=>{if(typeof E==="function")return`[fn]${String(E)}`;if(typeof E==="object"&&E!==null){if(v.has(E))return"[circular]";v.add(E)}return E})??"")}catch{return"unhashable"}}async function vt(x){if(Hr)return Ks;Hr=!0;try{let v=await Ho();if(!v||!v.build)return Hr=!1,"";if(!Rr)Rr=await Vo(x);if(!Rr)return Hr=!1,"";let k=v.defaultConfig?.theme||{},E=Rr.theme||{},C={...v.defaultConfig,...Rr,theme:{...k,...E,extend:{...k.extend||{},...E.extend||{}}}},j=performance.now(),L=await v.build(C),B=performance.now()-j;if(Ks=L.css,console.log(`${e.cyan}[ts-css]${e.reset} Built ${L.classes.size} classes in ${B.toFixed(1)}ms`),C.output){let z=It.isAbsolute(C.output)?C.output:It.join(x,C.output),F=It.dirname(z);if(!fs.existsSync(F))fs.mkdirSync(F,{recursive:!0});await Bun.write(z,L.css)}return Hr=!1,L.css}catch(v){return console.error(`${e.red}[ts-css]${e.reset} Build error:`,v),Hr=!1,Ks}}async function en(x){Rr=null,await vt(x)}function Iu(){return Ks}function Qa(x){let v=new Set,k=/class\s*=\s*["']([^"']+)["']/gi,E=k.exec(x);while(E!==null){for(let L of E[1].split(/\s+/))if(L.trim())v.add(L.trim());E=k.exec(x)}let C=/(?:x-class|:class)\s*=\s*"([^"]+)"/gi,j=C.exec(x);while(j!==null){let L=j[1].match(/'([^']+)'/g);if(L){for(let B of L)for(let z of B.slice(1,-1).split(/\s+/))if(z.trim())v.add(z.trim())}j=C.exec(x)}return v}var Fa=I(64);async function ec(x,v){let k=()=>Yi.get(v?It.resolve(v):process.cwd())?.fingerprint??null,E=Fa.get(O(x,v,k()));if(E!==void 0)return E;let C=await vy(x,v);if(C)Fa.set(O(x,v,k()),C);return C}function tc(x){let v=[];for(let k of x.matchAll(/\/_stx\/modules\.([0-9a-f]{16})\.js/g)){let E=zo(k[1]);if(E)v.push(E)}return v.length?`${x}
|
|
867
|
-
${v.join(`
|
|
868
|
-
`)}`:x}async function vy(x,v){try{let k=await Ho();if(!k)return"";let E=tc(x),C=typeof k.extractClasses==="function"?k.extractClasses(E):Qa(E);if(C.size===0)return"";let j=v?It.resolve(v):process.cwd(),L=a(j,"cache");if(!Ji)Ji=L;let B=Yi.get(j);if(!B){let Ee=await Ya(j);B={config:Ee,fingerprint:Za(Ee)},Yi.set(j,B),Wd=B.fingerprint}let z=[...C].sort().join(" "),F=`${B.fingerprint||"default"}::${z}`,X=gr.get(F);if(X!==void 0)return La(F,X),X;let G=await gy(F,L);if(G!==null)return La(F,G),G;let J=k.defaultConfig||k.config,ne=B.config||{},re=Ad(J,ne),{safelist:se,includePreflight:oe,minify:ie,tokenCSS:ge}=re,ue=re.config,xe=new k.CSSGenerator(ue),we=ue.shortcuts||ne.shortcuts||{},$e=Object.keys(we).filter((Ee)=>C.has(Ee)||se.includes(Ee));for(let Ee of se)if(!we[Ee])xe.generate(Ee);for(let Ee of C)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,ie),_e&&!_e.endsWith(`
|
|
869
|
-
`))_e+=`
|
|
870
|
-
`}let Ce=_e+xe.toCSS(oe,ie);return Ce=Td(k.CSSGenerator,re)+ge+Ce,La(F,Ce),my(F,Ce,L),Ce}catch(k){return console.warn("Failed to generate Css CSS:",k),""}}async function f(x,v,k=!1,E=!1){let C=await ec(x,v);if(!C)return E?qs(x):x;let j=k?`<link data-css="generated" rel="stylesheet" href="/_stx/css.${py(C)}.css">`:`<style data-css="generated">
|
|
871
|
-
${C}
|
|
872
|
-
</style>`;if(E)return wy(x,j);let L=/(?:<style\b[^>]*\bdata-css=(?:"generated"|'generated')[^>]*>[\s\S]*?<\/style>|<link\b[^>]*\bdata-css=(?:"generated"|'generated')[^>]*>)/g;if(L.test(x)){let B=!1;return x.replace(L,()=>{if(B)return"";return B=!0,j})}if(x.includes("</head>"))return x.replace("</head>",`${j}
|
|
873
|
-
</head>`);if(x.includes("<body"))return x.replace(/<body([^>]*)>/,`<body$1>
|
|
874
|
-
${j}`);return j+x}function wy(x,v){let k=ja(x).map((z)=>({...z,replacement:""})),E=/(?:<style\b[^>]*\bdata-css=(?:"generated"|'generated')[^>]*>[\s\S]*?<\/style>|<link\b[^>]*\bdata-css=(?:"generated"|'generated')[^>]*>)/g,C=E.exec(x);if(C!==null){let z=!0;while(C!==null)k.push({start:C.index,end:C.index+C[0].length,replacement:z?v:""}),z=!1,C=E.exec(x)}else{let z=x.indexOf("</head>");if(z!==-1)k.push({start:z,end:z,replacement:`${v}
|
|
875
|
-
`});else{let F=x.match(/<body([^>]*)>/);if(F?.index!==void 0)k.push({start:F.index,end:F.index+F[0].length,replacement:`${F[0]}
|
|
876
|
-
${v}`});else k.push({start:0,end:0,replacement:v})}}k.sort((z,F)=>z.start-F.start||z.end-F.end);for(let z=1;z<k.length;z++)if(k[z].start<k[z-1].end)return Sy(qs(x),v);let j=Array(k.length*2+1),L=0,B=0;for(let z of k)j[B++]=x.slice(L,z.start),j[B++]=z.replacement,L=z.end;return j[B]=x.slice(L),j.join("")}function Sy(x,v){let k=/(?:<style\b[^>]*\bdata-css=(?:"generated"|'generated')[^>]*>[\s\S]*?<\/style>|<link\b[^>]*\bdata-css=(?:"generated"|'generated')[^>]*>)/g;if(k.test(x)){let E=!1;return x.replace(k,()=>{if(E)return"";return E=!0,v})}if(x.includes("</head>"))return x.replace("</head>",`${v}
|
|
877
|
-
</head>`);if(x.includes("<body"))return x.replace(/<body([^>]*)>/,`<body$1>
|
|
878
|
-
${v}`);return v+x}var $c=[{open:/<!--/g,close:/-->/g},{open:/<script\b/gi,close:/<\/script\s*>/gi},{open:/<style\b/gi,close:/<\/style\s*>/gi}],Vd=/<body\b([^>]*)>/gi;function An(x){let v=0,k,E=$c.map(()=>{return});while(v<x.length){if(k===void 0||k!==null&&k.index<v)Vd.lastIndex=v,k=Vd.exec(x);if(!k)return null;let C=k.index,j=-1,L=null;for(let z=0;z<$c.length;z++){let F=$c[z],X=E[z];if(X===void 0||X!==null&&X.index<v)F.open.lastIndex=v,X=F.open.exec(x),E[z]=X;if(!X)continue;if(X.index<C&&(j===-1||X.index<j))j=X.index,L=F.close}if(j===-1||!L)return{index:C,tag:k[0],attrs:k[1]??""};L.lastIndex=j;let B=L.exec(x);if(!B)return null;v=B.index+B[0].length}return null}function bs(x,v){let k=An(x);if(!k)return x;return x.slice(0,k.index)+v(k.tag,k.attrs)+x.slice(k.index+k.tag.length)}var Ud=/<style\b[^>]*>/iy,Hd=/<\/style>/gi,qd=/<script\b[^>]*>/iy,Kd=/<template(?=[\s>/])[^>]*>/iy,Xd=/<\/template\s*>/iy;function Xs(x){let v=0,k=0,E=-1;while(v<x.length){let C=x.indexOf("<",v);if(C===-1)return-1;if(x.startsWith("<!--",C)){let z=x.indexOf("-->",C+4);v=z===-1?x.length:z+3;continue}Ud.lastIndex=C;let j=Ud.exec(x);if(j){Hd.lastIndex=C+j[0].length;let z=Hd.exec(x);v=z===null?x.length:z.index+8;continue}Kd.lastIndex=C;let L=Kd.exec(x);if(L){if(k===0)E=C;k++,v=C+L[0].length;continue}Xd.lastIndex=C;let B=Xd.exec(x);if(B){if(k>0)k--;v=C+B[0].length;continue}if(qd.lastIndex=C,qd.test(x))return k>0?E:C;v=C+1}return-1}function Zd(){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 _c(x){return Symbol(x)}var j$=_c("theme"),L$=_c("router"),B$=_c("i18n");import*as Jd from"crypto";function Gd(x){let v=/\$(\w+)\./g,k=[],E;while((E=v.exec(x))!==null)if(!k.includes(E[1]))k.push(E[1]);return k}function $y(){return`stx-${Jd.randomBytes(4).toString("hex")}`}function _y(x){return/\$\w+\./.test(x)}function ky(x){if(!x.includes("{{")||!/\$\w+\./.test(x))return{html:x,bindings:[],stores:new Set};let v=[],k=new Set,E=/<(\w+)([^>]*?)(\s*\/?>)/g,C=x;return C=C.replace(E,(j,L,B,z)=>{if(["script","style","template"].includes(L.toLowerCase()))return j;let F=[],X=!1,G=B,J=/(\w+(?:-\w+)*)\s*=\s*"([^"]*\{\{[^}]*\$\w+[^}]*\}\}[^"]*)"/g,ne=[...B.matchAll(J)];for(let oe of ne){let ie=oe[0],ge=oe[1],ue=oe[2];if(_y(ue)){X=!0;let xe=ue.match(/\{\{\s*([\s\S]+?)\s*\}\}/);if(xe){let we=xe[1];if(F.push({attr:ge,expr:we,fullMatch:ie,originalAttr:ge}),Gd(we).forEach((_e)=>k.add(_e)),ge==="text")G=G.replace(ie,"");else if(ge==="class")G=G.replace(ie,'class=""');else if(ge==="disabled"||ge==="hidden")G=G.replace(ie,"");else G=G.replace(ie,`${ge}=""`)}}}if(!X)return j;let re=G.match(/\bid\s*=\s*"([^"]+)"/),se;if(re)se=re[1];else se=$y(),G=` id="${se}"${G}`;for(let oe of F)v.push({elementId:se,attribute:oe.attr,expression:oe.expr,stores:Gd(oe.expr)});return`<${L}${G}${z}`}),{html:C,bindings:v,stores:k}}function Ey(x,v){if(x.length===0)return"";let k=Array.from(v),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 C of k)E+=` $state.${C} = stores.${C} ? stores.${C}.get() : {};
|
|
1243
|
-
`;E+=`
|
|
1244
|
-
// Binding update functions
|
|
1245
|
-
function updateBindings() {
|
|
1246
|
-
`;for(let C of x){let{elementId:j,attribute:L,expression:B}=C,z=B.replace(/\$(\w+)\./g,"$state.$1.");if(L==="text")E+=` (function() {
|
|
1247
|
-
var el = document.getElementById('${j}');
|
|
1248
|
-
if (el) {
|
|
1249
|
-
try {
|
|
1250
|
-
el.textContent = ${z};
|
|
1251
|
-
}
|
|
1252
|
-
catch (e) { console.error('Binding error:', e); }
|
|
1253
|
-
}
|
|
1254
|
-
})();
|
|
1255
|
-
`;else if(L==="html")E+=` (function() {
|
|
1256
|
-
var el = document.getElementById('${j}');
|
|
1257
|
-
if (el) {
|
|
1258
|
-
try {
|
|
1259
|
-
el.innerHTML = ${z};
|
|
1260
|
-
}
|
|
1261
|
-
catch (e) { console.error('Binding error:', e); }
|
|
1262
|
-
}
|
|
1263
|
-
})();
|
|
1264
|
-
`;else if(L==="class")E+=` (function() {
|
|
1265
|
-
var el = document.getElementById('${j}');
|
|
1266
|
-
if (el) {
|
|
1267
|
-
try {
|
|
1268
|
-
var value = ${z};
|
|
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(L==="show")E+=` (function() {
|
|
1294
|
-
var el = document.getElementById('${j}');
|
|
1295
|
-
if (el) {
|
|
1296
|
-
try {
|
|
1297
|
-
el.style.display = (${z}) ? '' : 'none';
|
|
1298
|
-
}
|
|
1299
|
-
catch (e) { console.error('Binding error:', e); }
|
|
1300
|
-
}
|
|
1301
|
-
})();
|
|
1302
|
-
`;else if(L==="if")E+=` (function() {
|
|
1303
|
-
var el = document.getElementById('${j}');
|
|
1304
|
-
if (el) {
|
|
1305
|
-
try {
|
|
1306
|
-
el.style.visibility = (${z}) ? '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 = ${z};
|
|
1316
|
-
if (value === false || value === null || value === undefined) {
|
|
1317
|
-
el.removeAttribute('${L}');
|
|
1318
|
-
}
|
|
1319
|
-
else if (value === true) {
|
|
1320
|
-
el.setAttribute('${L}', '');
|
|
1321
|
-
}
|
|
1322
|
-
else {
|
|
1323
|
-
el.setAttribute('${L}', 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 C of k)E+=` if (stores.${C}) {
|
|
1338
|
-
var _unsub_${C} = stores.${C}.subscribe(function(state) {
|
|
1339
|
-
$state.${C} = state;
|
|
1340
|
-
updateBindings();
|
|
1341
|
-
});
|
|
1342
|
-
// store.subscribe() may return the disposer (preferred) or void; both
|
|
1343
|
-
// are tolerated here.
|
|
1344
|
-
if (typeof _unsub_${C} === 'function') _disposers.push(_unsub_${C});
|
|
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 Yd(x){let{html:v,bindings:k,stores:E}=ky(x);if(k.length===0)return x;let C=Ey(k,E),j=v.lastIndexOf("</body>");if(j!==-1)return v.slice(0,j)+C+v.slice(j);return v+C}function Cy(x){let v=x.analytics;if(!v?.enabled)return"";switch(v.driver){case"fathom":return Ry(v);case"google-analytics":return Ty(v);case"plausible":return Ay(v);case"self-hosted":return Iy(v);case"custom":return Py(v);default:return""}}function Ry(x){let v=x.fathom;if(!v?.siteId)return"";let k=v.scriptUrl||"https://cdn.usefathom.com/script.js",E=v.defer!==!1?" defer":"",C=[`data-site="${yn(v.siteId)}"`];if(v.honorDnt)C.push('data-honor-dnt="true"');if(v.spa)C.push('data-spa="auto"');if(v.canonical)C.push(`data-canonical="${yn(v.canonical)}"`);if(v.auto===!1)C.push('data-auto="false"');return`
|
|
1385
|
-
<!-- Fathom Analytics -->
|
|
1386
|
-
<script src="${yn(k)}" ${C.join(" ")}${E}></script>
|
|
1387
|
-
`}function Ty(x){let v=x.googleAnalytics;if(!v?.measurementId)return"";let k=yn(v.measurementId),E=v.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 Ay(x){let v=x.plausible;if(!v?.domain)return"";let k=v.scriptUrl||"https://plausible.io/js/script.js",E=[`data-domain="${yn(v.domain)}"`],C=k,j=[];if(v.trackLocalhost)j.push("local");if(v.hashMode)j.push("hash");if(j.length>0&&k==="https://plausible.io/js/script.js")C=`https://plausible.io/js/script.${j.join(".")}.js`;return`
|
|
1398
|
-
<!-- Plausible Analytics -->
|
|
1399
|
-
<script defer data-domain="${yn(v.domain)}" src="${yn(C)}"></script>
|
|
1400
|
-
`}function Iy(x){let v=x.selfHosted;if(!v?.siteId||!v?.apiEndpoint)return"";let k=yn(v.siteId),E=yn(v.apiEndpoint),C=v.honorDnt?'if(n.doNotTrack==="1")return;':"",j=v.trackHashChanges?"w.addEventListener('hashchange',pv);":"",L=v.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
|
-
${C}
|
|
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
|
-
${L}
|
|
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 Py(x){let v=x.custom;if(!v)return"";if(v.inlineScript)return`
|
|
1434
|
-
<!-- Custom Analytics -->
|
|
1435
|
-
<script>
|
|
1436
|
-
${v.inlineScript}
|
|
1437
|
-
</script>
|
|
1438
|
-
`;if(!v.scriptUrl)return"";let k=[];if(v.scriptId)k.push(`id="${yn(v.scriptId)}"`);if(v.attributes)for(let[C,j]of Object.entries(v.attributes))k.push(`${yn(C)}="${yn(j)}"`);return`
|
|
1439
|
-
<!-- Custom Analytics -->
|
|
1440
|
-
<script${k.length>0?` ${k.join(" ")}`:""} src="${yn(v.scriptUrl)}" defer></script>
|
|
1441
|
-
`}function Qd(x,v){let k=Cy(v);if(!k)return x;if(!x.includes("</head>")){let E=x.lastIndexOf("</body>");if(E!==-1)return x.slice(0,E)+k+x.slice(E);return x+k}return x.replace("</head>",`${k}</head>`)}function yn(x){return x.replace(/&/g,"&").replace(/"/g,""").replace(/'/g,"'").replace(/</g,"<").replace(/>/g,">")}function je(x){let v=x.match(/\bdefinePageMeta\s*\(\s*(\{[\s\S]*?\})\s*\)/m);if(!v)return null;try{return Function(`return ${v[1]}`)()}catch{return null}}function ef(x){let v=x?.layout;if(v===!1)return!1;return typeof v==="string"&&v.trim()?v.trim():void 0}var Dy=100,My=599,Rc="__stxResponseStatus",Zs="__stxResponseHeaders";function eo(x){return typeof x==="number"&&Number.isInteger(x)&&x>=Dy&&x<=My}function xt(x){for(let v of x.matchAll(/\bdefinePageMeta\s*\(\s*\{([\s\S]*?)\}\s*\)/g)){let k=v[1].match(/(?:^|,)\s*status\s*:\s*(\d{3})(?=\s*(?:,|$))/);if(!k)continue;let E=Number(k[1]);if(eo(E))return E}return}function Ec(x,v){if(!x||typeof x!=="object")return!1;let k=typeof v==="string"&&/^\d+$/.test(v.trim())?Number(v.trim()):v;if(!eo(k))return!1;return x[Rc]=k,!0}function Oy(x,v,k){if(!x||typeof x!=="object")return;let E=String(v??"").trim();if(!E)return;x[Zs]={...x[Zs],[E]:String(k)}}function Be(x){let v=x?.[Rc];return eo(v)?v:void 0}function Fe(x){let v=x?.[Zs];if(!v||typeof v!=="object")return;let k=Object.entries(v).map(([E,C])=>[E,String(C)]);return k.length>0?Object.fromEntries(k):void 0}function Uo(x,v){if(!x||!v||x===v||typeof v!=="object")return;let k=Be(x);if(k!==void 0)v[Rc]=k;let E=Fe(x);if(E)v[Zs]={...v[Zs],...E}}function Nn(x){return{setResponseStatus:(v)=>{Ec(x,v)},notFound:(v=404)=>{let k=eo(v)&&v>=400?v:404;Ec(x,k)},setResponseHeader:(v,k)=>{Oy(x,v,k)}}}function tf(x,v,k={}){if(!x.includes("@status"))return x;let{filePath:E,buildMode:C}=k,j=C==="compile",L="",B=0,z=/@status\s*\(/g,F;while((F=z.exec(x))!==null){let X=Ny(x,F.index+F[0].length-1);if(X<0)break;let G=x.slice(F.index+F[0].length,X).trim(),J=/^\d+$/.test(G)?Number(G):c(G,v),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(!Ec(v,J))console.warn(`[stx] @status(${G})${ne} is not an HTTP status (100-599) \u2014 ignoring it.`);L+=x.slice(B,F.index),B=X+1+(x.slice(X+1).match(/^[^\S\n]*\n?/)?.[0].length??0),z.lastIndex=B}return B===0?x:L+x.slice(B)}function Ny(x,v){let k=1,E=null,C=!1;for(let j=v+1;j<x.length;j++){let L=x[j];if(C){C=!1;continue}if(E){if(L==="\\")C=!0;else if(L===E)E=null;continue}if(L==='"'||L==="'"||L==="`"){E=L;continue}if(L==="(")k++;else if(L===")"&&--k===0)return j}return-1}var jy=0,Ly=0;function nf(x,v){let k=x.match(new RegExp(`${v}\\s*=\\s*"([^"]*)"`,"i"));if(k)return k[1];let E=x.match(new RegExp(`${v}\\s*=\\s*'([^']*)'`,"i"));if(E)return E[1];return null}function By(x){let v=[],k=/<([a-z][a-z0-9-]*)\s+([^>]*x-data\s*=\s*(?:"[^"]*"|'[^']*')[^>]*)>/gi,E;while((E=k.exec(x))!==null){let[C,j,L]=E,B=E.index,z=nf(L,"x-data");if(!z)continue;let F=`__stx_scope_${jy++}`,X=nf(L,"x-init"),G=zy(x,j,B+C.length),J=x.slice(B,G.endIndex),ne=Fy(J);v.push({id:F,selector:`[data-stx-scope="${F}"]`,stateExpr:z,initExpr:X,bindings:[],refs:ne})}return v}function zy(x,v,k){let E=1,C=k,j=new RegExp(`<${v}(?:\\s|>)`,"gi"),L=new RegExp(`</${v}>`,"gi"),B=new RegExp(`<${v}[^>]*/\\s*>`,"gi");while(E>0&&C<x.length){j.lastIndex=C,L.lastIndex=C,B.lastIndex=C;let z=j.exec(x),F=L.exec(x),X=B.exec(x);if(X&&X.index<(z?.index??1/0)){C=X.index+X[0].length;continue}if(!F)return{endIndex:x.length};if(z&&z.index<F.index)E++,C=z.index+z[0].length;else{if(E--,E===0)return{endIndex:F.index+F[0].length};C=F.index+F[0].length}}return{endIndex:x.length}}function Fy(x){let v=new Map,k=x.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,C;while((C=E.exec(k))!==null){let[,j,L]=C,B=Wy(j);v.set(L,B)}return v}function Wy(x){let v=x.match(/\bid\s*=\s*["']([^"']*)["']/);if(v)return v[1];return`__stx_el_${Ly++}`}function Vy(){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 rf(x,v){let k=x.replace(/\{!!([\s\S]*?)!!\}/g,(B,z)=>{try{let F=b(z,v,!0);if(F===void 0)return B;return String(F)}catch{return B}}),E="",C=0,j=null;while(C<k.length){let B=k[C];if(j&&B==="\\"){E+=B+(k[C+1]??""),C+=2;continue}if(B==="{"&&k[C+1]==="{"){let z=k.indexOf("}}",C+2);if(z!==-1){let F=k.slice(C,z+2);E+=L(k.slice(C+2,z),F,j),C=z+2;continue}}if(j){if(B===j)j=null}else if(B==="'"||B==='"'||B==="`")j=B;E+=B,C++}return E;function L(B,z,F){let X;try{X=b(B,v,!0)}catch{return z}if(X===void 0)return z;if(F){let G=String(X).replace(/\\/g,"\\\\").replace(new RegExp(F==="`"?"`":F,"g"),`\\${F}`).replace(/\r/g,"\\r").replace(/\n/g,"\\n");return F==="`"?G.replace(/\$\{/g,"\\${"):G}if(typeof X==="string"){let G=X.trim();if(G.startsWith("{")&&G.endsWith("}")||G.startsWith("[")&&G.endsWith("]"))try{return JSON.parse(G),G}catch{}}return JSON.stringify(X)}}function Uy(x,v){if(x.length===0)return"";let k=x.map((E)=>{let C=JSON.stringify(Object.fromEntries(E.refs)),j=rf(E.stateExpr,v),L=E.initExpr?rf(E.initExpr,v):null,B=JSON.stringify(j),z=L?JSON.stringify(L):"null";return`
|
|
1695
|
-
(function() {
|
|
1696
|
-
var scopeEl = document.querySelector('${E.selector}');
|
|
1697
|
-
if (!scopeEl) return;
|
|
1698
|
-
var refs = ${C};
|
|
1699
|
-
__stx_reactive.initScope(scopeEl, ${B}, [], refs, ${z});
|
|
1700
|
-
})();`}).join(`
|
|
1701
|
-
`);return`
|
|
1702
|
-
<script data-stx-scoped data-stx-reactive data-stx-run="always">
|
|
1703
|
-
${Vy()}
|
|
1704
|
-
${k}
|
|
1705
|
-
</script>`}function sf(x,v,k){if(!qy(x))return x;let E=By(x);if(E.length===0)return x;let C=Hy(x,E),j=Uy(E,v),L=C.lastIndexOf("</body>");if(L!==-1)C=C.slice(0,L)+j+`
|
|
1706
|
-
`+C.slice(L);else C+=j;return C}function Hy(x,v){let k=0,E=x.replace(/<([a-z][a-z0-9-]*)(\s+[^>]*x-data\s*=\s*(?:"[^"]*"|'[^']*')[^>]*)>/gi,(C,j,L)=>{let B=v[k++];if(!B)return C;let z=/data-stx-scope="([^"]*)"/.exec(L);if(z)return B.id=z[1],B.selector=`[data-stx-scope="${B.id}"]`,C;return`<${j} data-stx-scope="${B.id}"${L}>`});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 qy(x){return/x-data\s*=\s*["']/.test(x)}function mr(x,v){try{let k=x.trim();if(p(k))return l(k,Object.keys(v))(...Object.values(v));else return c(k,v)}catch{return!1}}function hr(x,v){let k=Ky(x,v);return k.ok?{expression:k.expression,endPos:k.endPos}:null}function Ky(x,v){let k=v;while(k<x.length&&/\s/.test(x[k]))k++;if(x[k]!=="(")return{ok:!1,reason:"missing-open-paren",pos:k};let E=w(x,"(",")",k);if(E===-1)return{ok:!1,reason:"unclosed-paren",pos:k};return{ok:!0,expression:x.slice(k+1,E),endPos:E+1}}function Xy(x,v){let k=x.lastIndexOf("<",v);if(k===-1)return!1;return k>x.lastIndexOf(">",v)}function Tr(x,v,k,E){let C=1,j=E,L=new RegExp(`@${v}\\s*\\(`,"g"),B=new RegExp(`@${k}(?![a-z])`,"g");while(j<x.length&&C>0){L.lastIndex=j,B.lastIndex=j;let z=L.exec(x),F=B.exec(x),X=z?z.index:1/0,G=F?F.index:1/0;if(X<G)C++,j=X+z[0].length;else if(G<1/0){if(C--,C===0)return G;j=G+F[0].length}else break}return-1}function of(x,v){let k=x.slice(v).match(/^@if\s*/);if(!k)return null;let E=v+k[0].length,C=hr(x,E);if(!C)return null;let j=C.endPos,L=Tr(x,"if","endif",j);if(L===-1)return null;let B=x.slice(j,L),z=[],F=0,X="if",G=C.expression,J=0,ne=0;while(F<B.length){let re=B.indexOf("@",F);if(re===-1)break;F=re;let se=B.substring(re);if(Xy(B,re)){F++;continue}if(/^@if\s*\(/.test(se)){ne++,F++;continue}if(/^@endif(?![a-z])/.test(se)){ne--,F+=6;continue}if(ne===0){let oe=se.match(/^@elseif\s*/);if(oe){z.push({type:X,condition:G,content:B.substring(J,F),start:j+J,end:j+F});let ie=F+oe[0].length,ge=hr(B,ie);if(!ge){F++;continue}X="elseif",G=ge.expression,F=ge.endPos,J=F;continue}else if(/^@else(?![a-z])/.test(se)){z.push({type:X,condition:G,content:B.substring(J,F),start:j+J,end:j+F}),X="else",G=void 0,F+=5,J=F;continue}}F++}return z.push({type:X,condition:G,content:B.slice(J),start:j+J,end:j+B.length}),{fullMatch:x.slice(v,L+6),branches:z,start:v,end:L+6}}function Gs(x){let v=[],k=/@if\s*\(/g,E=k.exec(x);while(E!==null){if(v.some((L)=>E.index>L.start&&E.index<L.end)){E=k.exec(x);continue}let j=of(x,E.index);if(j)v.push(j),k.lastIndex=j.end;E=k.exec(x)}return v}function to(x,v,k){let E=[],C=new RegExp(`@${v}\\s*\\(`,"g"),j=C.exec(x);while(j!==null){if(E.some((se)=>j.index>se.start&&j.index<se.end)){j=C.exec(x);continue}let B=j.index,z=B+j[0].length-1,F=w(x,"(",")",z);if(F===-1){j=C.exec(x);continue}let X=x.slice(z+1,F),G=F+1,J=Tr(x,v,k,G);if(J===-1){j=C.exec(x);continue}let ne=x.slice(G,J),re=J+`@${k}`.length;E.push({fullMatch:x.slice(B,re),name:v,params:X,content:ne,start:B,end:re}),C.lastIndex=re,j=C.exec(x)}return E}function Tc(x,v){let k=x.slice(v).match(/^@switch\s*/);if(!k)return null;let E=v+k[0].length,C=hr(x,E);if(!C)return null;let j=C.endPos,L=Tr(x,"switch","endswitch",j);if(L===-1)return null;let B=x.slice(j,L),z=[],F=0,X=null,G=0;while(F<B.length){let J=B.slice(F),ne=J.match(/^@switch\s*\(/),re=J.match(/^@endswitch(?![a-z])/);if(ne){if(G++,X)X.content+=ne[0];F+=ne[0].length;continue}if(re){if(G--,X)X.content+=re[0];F+=re[0].length;continue}if(G>0){if(X)X.content+=B[F];F++;continue}let se=J.match(/^@case\s*/),oe=J.match(/^@default(?![a-z])/),ie=J.match(/^@break(?![a-z])/);if(se&&J.startsWith("@case")){if(X)z.push(X);let ge=F+se[0].length,ue=hr(B,ge);if(!ue){F++;continue}X={type:"case",value:ue.expression,content:""},F=ue.endPos}else if(oe&&J.startsWith("@default")){if(X)z.push(X);X={type:"default",content:""},F+=oe[0].length}else if(ie&&J.startsWith("@break"))F+=ie[0].length;else{if(X)X.content+=B[F];F++}}if(X)z.push(X);return{fullMatch:x.slice(v,L+10),expression:C.expression,cases:z,start:v,end:L+10}}function Yy(x,v,k){let E=x,C=!0;while(C){C=!1;let j=E.match(/@switch\s*\(/);if(!j||j.index===void 0)break;let L=j.index,B=Tc(E,L);if(!B)break;try{let z;if(p(B.expression))z=l(B.expression,Object.keys(v))(...Object.values(v));else z=c(B.expression,v);let F="",X=!1;for(let G of B.cases)if(G.type==="default"){if(!X)F=G.content.trim()}else try{let J;if(G.value&&p(G.value))J=l(G.value,Object.keys(v))(...Object.values(v));else if(G.value)J=c(G.value,v);if(z===J){F=G.content.trim(),X=!0;break}}catch{continue}E=E.substring(0,L)+F+E.substring(B.end),C=!0}catch(z){let F=z instanceof Error?z.message:String(z),X=i("Switch",`Error evaluating @switch expression: ${F}`,t.EVALUATION_ERROR);E=E.substring(0,L)+X+E.substring(B.end);break}}return E}function Qy(x){let v=[];return{masked:x.replace(/<script\b[\s\S]*?<\/script\s*>/gi,(E)=>(v.push(E),`\x00stx-script-${v.length-1}\x00`)),scripts:v}}function ex(x,v){if(v.length===0)return x;return x.replace(/\u0000stx-script-(\d+)\u0000/g,(k,E)=>v[Number(E)]??k)}function ar(x,v,k){let{masked:E,scripts:C}=Qy(x);return ex(tx(E,v,k),C)}function tx(x,v,k){let E=x;E=Yy(E,v,k);{let j=!0;while(j){j=!1;let L=E.match(/@unless\s*\(/);if(!L||L.index===void 0)break;let B=L.index,z=hr(E,B+7);if(!z)break;let F=z.endPos,X=Tr(E,"unless","endunless",F);if(X===-1){console.warn(`[stx] @unless directive at position ${B} has no matching @endunless \u2014 the block was skipped. Check for typos or missing closers.`);break}let G=E.slice(F,X),J=z.expression,ne=-1;{let se=0,oe=/@(?:if|unless)\s*\(/g,ie=/@(?:endif|endunless)(?![a-z])/g,ge=/@else(?![a-z])/g,ue=[],xe;while((xe=oe.exec(G))!==null)ue.push({pos:xe.index,type:"open"});while((xe=ie.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),oe=G.slice(ne+5);re=`@if (${J})${oe}@else ${se}@endif`}else re=`@if (!(${J}))${G}@endif`;E=E.substring(0,B)+re+E.substring(X+10),j=!0}}E=Ic(E,v,k),E=Pc(E,v,k),E=Ac(E,v);let C=()=>{let j=Gs(E);if(j.length===0)return!1;let L=Array(j.length);for(let F=j.length-1;F>=0;F--){let X=j[F];try{let G="",J=!1;for(let ne of X.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(v))(...Object.values(v));else if(ne.condition)re=c(ne.condition,v);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}}L[F]=G}catch(G){let J=G instanceof Error?G.message:String(G);L[F]=i("If",`Error processing @if block: ${J}`,t.EVALUATION_ERROR)}}let B=Array(j.length*2+1),z=0;for(let F=0;F<j.length;F++){let X=j[F];B[F*2]=E.slice(z,X.start),B[F*2+1]=L[F],z=X.end}return B[j.length*2]=E.slice(z),E=B.join(""),!0};while(!0){let j=E;if(!C())break;if(E===j)break}return E}function af(x){let v=0;while(v<x.length&&/\s/.test(x[v]))v++;if(x[v]!=="(")return null;v++;while(v<x.length&&/\s/.test(x[v]))v++;let k=x[v];if(k!=="'"&&k!=='"')return null;v++;let E=[];while(v<x.length){let C=x[v];if(C==="\\"&&v+1<x.length){E.push(x[v+1]),v+=2;continue}if(C===k){v++;break}E.push(C),v++}while(v<x.length&&/\s/.test(x[v]))v++;if(x[v]!==")")return null;return v++,{value:E.join(""),consumed:v}}function Ac(x,v){let k=x;function E(B,z,F,X){let G=1,J=X,ne=new RegExp(`@${z}(?:\\s*\\(|\\s|$)`,"g"),re=new RegExp(`@${F}(?![a-z])`,"g");while(J<B.length&&G>0){ne.lastIndex=J,re.lastIndex=J;let se=ne.exec(B),oe=re.exec(B),ie=se?se.index:1/0,ge=oe?oe.index:1/0;if(ie<ge)G++,J=ie+se[0].length;else if(ge<1/0){if(G--,G===0)return ge;J=ge+oe[0].length}else break}return-1}function C(B,z,F){let X=0,G=new RegExp(`@${z}(?:\\s*\\(|\\s|$)`,"g"),J=new RegExp(`@${F}(?![a-z])`,"g"),ne=/@else(?![a-z])/g,re=[],se;while((se=G.exec(B))!==null)re.push({pos:se.index,type:"open"});while((se=J.exec(B))!==null)re.push({pos:se.index,type:"close"});while((se=ne.exec(B))!==null)re.push({pos:se.index,type:"else"});re.sort((oe,ie)=>oe.pos-ie.pos);for(let oe of re)if(oe.type==="open")X++;else if(oe.type==="close")X--;else if(oe.type==="else"&&X===0)return oe.pos;return-1}{let B=!0;while(B){B=!1;let z=k.match(/@auth(?:\s*\(|\s|(?=\n))/);if(!z||z.index===void 0)break;let F=z.index,X,G,J=k.slice(F+5),ne=af(J);if(ne)X=ne.value,G=F+5+ne.consumed;else G=F+5;let re=E(k,"auth","endauth",G);if(re===-1){console.warn(`[stx] @auth directive at position ${F} has no matching @endauth \u2014 the block was skipped.`);break}let se=k.slice(G,re),oe=C(se,"auth","endauth"),ie;if(!v.auth)ie=!1;else ie=X?mr(`auth?.check && auth?.user?.[${X}]`,v):mr("auth?.check",v);let ge;if(oe!==-1){let ue=se.slice(0,oe),xe=se.slice(oe+5);ge=ie?ue:xe}else ge=ie?se:"";k=k.substring(0,F)+ge+k.substring(re+8),B=!0}}{let B=!0;while(B){B=!1;let z=k.match(/@guest(?:\s*\(|\s|(?=\n))/);if(!z||z.index===void 0)break;let F=z.index,X,G,J=k.slice(F+6),ne=af(J);if(ne)X=ne.value,G=F+6+ne.consumed;else G=F+6;let re=E(k,"guest","endguest",G);if(re===-1){console.warn(`[stx] @guest directive at position ${F} has no matching @endguest \u2014 the block was skipped.`);break}let se=k.slice(G,re),oe=C(se,"guest","endguest"),ie;if(!v.auth)ie=!0;else ie=X?mr(`!auth?.check || !auth?.user?.[${X}]`,v):mr("!auth?.check",v);let ge;if(oe!==-1){let ue=se.slice(0,oe),xe=se.slice(oe+5);ge=ie?ue:xe}else ge=ie?se:"";k=k.substring(0,F)+ge+k.substring(re+9),B=!0}}function j(B,z,F){if(v.userCan&&typeof v.userCan[B]==="boolean")return v.userCan[B];if(v.permissions?.check&&typeof v.permissions.check==="function")try{let X=[B];if(z)X.push(z);if(F){let G=mr(F,v);X.push(G)}return v.permissions.check(...X)}catch{return!1}return!1}function L(B){let z=B.match(/^\s*\(\s*'([^']*)'(?:,\s*'([^']*)')?(?:,\s*([^)]*))?\)/);if(!z)return null;return{ability:z[1],type:z[2],id:z[3]?.trim(),paramsEnd:z[0].length}}for(let B of["can","cannot"]){let z=`end${B}`,F=B==="can"?"elsecan":"elsecannot",X=!0;while(X){X=!1;let G=k.match(new RegExp(`@${B}\\s*\\(`));if(!G||G.index===void 0)break;let J=G.index,ne=k.slice(J+`@${B}`.length),re=L(ne);if(!re)break;let se=J+`@${B}`.length+re.paramsEnd,oe=E(k,B,z,se);if(oe===-1){console.warn(`[stx] @${B} directive at position ${J} has no matching @${z} \u2014 the block was skipped.`);break}let ie=k.slice(se,oe),ge=[],ue=0,xe=new RegExp(`@${B}\\s*\\(`,"g"),we=new RegExp(`@${z}(?![a-z])`,"g"),$e=new RegExp(`@${F}\\s*\\(`,"g"),_e=/@else(?![a-z])/g,Ce=[],Ee;while((Ee=xe.exec(ie))!==null)Ce.push({pos:Ee.index,type:"open"});while((Ee=we.exec(ie))!==null)Ce.push({pos:Ee.index,type:"close"});while((Ee=$e.exec(ie))!==null)Ce.push({pos:Ee.index,type:"elseDirective"});while((Ee=_e.exec(ie))!==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:ie.slice(Re,Ie.pos),ability:void 0}),Ie.type==="elseDirective"){let Ze=ie.slice(Ie.pos+`@${F}`.length),nt=L(Ze);if(nt){Te[Te.length-1]={content:ie.slice(Re,Ie.pos)},Re=Ie.pos+`@${F}`.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:ie.length;Te.push({content:ie.slice(Re,rt),ability:nt.ability,type:nt.type,id:nt.id}),Re=rt}}else Re=Ie.pos+5}if(Re<ie.length){let Pe=Te[Te.length-1];if(ge.length>0&&ge[ge.length-1].type==="else")Te.push({content:ie.slice(Re),isFinalElse:!0});else if(Te.length===0)Te.push({content:ie.slice(Re)})}let ke=j(re.ability,re.type,re.id),Ae=B==="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(B==="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(oe+`@${z}`.length),X=!0}}return k}function Ic(x,v,k){let E=x;function C(j,L,B,z,F){let X=!0;while(X){X=!1;let G=new RegExp(`@${L}\\s*\\(`),J=j.match(G);if(!J||J.index===void 0)break;let ne=J.index,re=hr(j,ne+`@${L}`.length);if(!re)break;let se=re.endPos,oe=Tr(j,L,B,se);if(oe===-1){console.warn(`[stx] @${L} directive at position ${ne} has no matching @${B} \u2014 the block was skipped.`);break}let ie=j.slice(se,oe),ge=re.expression,ue=-1,xe=0,we=0;while(we<ie.length){let $e=ie.indexOf("@",we);if($e===-1)break;let _e=ie.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=z(ge.trim()),_e;if(ue!==-1){let Ce=ie.slice(0,ue),Ee=ie.slice(ue+5);_e=$e?Ce:Ee}else _e=$e?ie:"";j=j.substring(0,ne)+_e+j.substring(oe+`@${B}`.length),X=!0}catch($e){let _e=$e instanceof Error?$e.message:String($e),Ce=i(F,`Error processing @${L} directive: ${_e}`,t.EVALUATION_ERROR);j=j.substring(0,ne)+Ce+j.substring(oe+`@${B}`.length);break}}return j}return E=C(E,"isset","endisset",(j)=>{let L=mr(j,v);return L!==void 0&&L!==null},"Isset"),E=C(E,"empty","endempty",(j)=>{let L=mr(j,v);return L===void 0||L===null||L===""||L===0||L===!1||Array.isArray(L)&&L.length===0||typeof L==="object"&&L!==null&&Object.keys(L).length===0},"Empty"),E}function Pc(x,v,k){let E=x,C="development";function j(L,B,z,F){let X=new RegExp(`@${B}(?![a-z])`,"g"),G=new RegExp(`@${z}(?![a-z])`,"g"),J=new RegExp(`^@${B}(?![a-z])`),ne=new RegExp(`^@${z}(?![a-z])`),re=L,se=!0;while(se){se=!1,X.lastIndex=0;let oe=X.exec(re);if(!oe)break;let ie=oe.index,ge=ie+oe[0].length;if(B==="env"){let ke=re.substring(ge).match(/^\s*\(\s*(['"])([^'"]+)\1\s*\)/);if(!ke)break;ge+=ke[0].length,F=C===ke[2]}let ue=1,xe=ge,we=-1;while(ue>0&&xe<re.length){X.lastIndex=xe,G.lastIndex=xe;let ke=X.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] @${B} directive at position ${ie} has no matching @${z} \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=F?ke:Ae}else Te=F?$e:"";let Re=`@${z}`.length;re=re.substring(0,ie)+Te+re.substring(we+Re),se=!0}return re}return E=j(E,"env","endenv",!1),E=j(E,"production","endproduction",C==="production"),E=j(E,"development","enddevelopment",C==="development"),E=j(E,"staging","endstaging",C==="staging"),E=j(E,"testing","endtesting",C==="testing"),E}var cf=new WeakMap;function lf(x=16){let v=new Uint8Array(x);return crypto.getRandomValues(v),btoa(String.fromCharCode(...v))}function no(x,v){if(!x)return v?.nonceGenerator?.()??lf();let k=cf.get(x);if(!k)k=v?.nonceGenerator?.()??lf(),cf.set(x,k);return k}function nx(x,v){let k=[];for(let[E,C]of Object.entries(x)){if(C===void 0||C===null)continue;if(typeof C==="boolean"){if(C)k.push(E);continue}if(Array.isArray(C)){let j=[...C];if(v&&(E==="script-src"||E==="style-src"))j=j.filter((L)=>!L.startsWith("'nonce-")),j.push(`'nonce-${v}'`);if(j.length>0)k.push(`${E} ${j.join(" ")}`)}}return k.join("; ")}function uf(x,v){return`<meta http-equiv="Content-Security-Policy" content="${nx(x,v).replace(/&/g,"&").replace(/"/g,""")}">`}function df(x,v,k){if(!v.enabled||!v.addMetaTag)return x;if(x.includes('http-equiv="Content-Security-Policy"'))return x;if(!x.includes("<head>")&&!x.includes("<head "))return x;let E=v.useNonce?no(k,v):void 0,C=uf(v.directives,E);return x.replace(/<head([^>]*)>/,`<head$1>
|
|
1707
|
-
${C}`)}function ff(x,v){let k=x;return k=k.replace(/<script(?![^>]*\ssrc=)([^>]*)>/gi,(E,C)=>{if(C.includes("nonce="))return E;return`<script nonce="${v}"${C}>`}),k=k.replace(/<style([^>]*)>/gi,(E,C)=>{if(C.includes("nonce="))return E;return`<style nonce="${v}"${C}>`}),k}function pf(x,v,k,E){let C=x,j=E.csp;if(C=C.replace(/@csp\b/g,()=>{if(!j?.enabled||!j.directives)return"<!-- CSP not configured -->";let L=j.useNonce?no(v,j):void 0;return uf(j.directives,L)}),C=C.replace(/@cspNonce\b/g,()=>{if(!j?.enabled||!j.useNonce)return"";return no(v,j)}),j?.enabled&&j.useNonce)v.cspNonce=no(v,j);return C}import rx from"crypto";var sx=40,gf="_token",Dc=null;function ix(x=sx){let v=rx.randomBytes(Math.ceil(x/2)).toString("hex").slice(0,x);return Dc=v,v}function ox(){if(!Dc)ix();return Dc}function ax(x=gf){let v=ox();return`<input type="hidden" name="${x}" value="${v}">`}function mf(x){return x.replace(/@csrf(?:\((['"])([^'"]*)\1\))?/g,(v,k,E)=>ax(E||gf))}async function hf(x,v,k,E){if(!E.customDirectives||E.customDirectives.length===0)return x;let C=x;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)C=await cx(C,j,v,k,E);else C=await lx(C,j,v,k,E)}return C}async function cx(x,v,k,E,C){let{name:j,handler:L}=v,B=`@${j}`,z=`@end${j}`,F=x,X=_r(`${B}(?:\\s*\\(([^()]*(?:\\([^)]*\\)[^()]*)*)\\))?([\\s\\S]*?)${z}`,"g"),G=[],J=X.exec(F);while(J!==null){let[ne,re="",se=""]=J,oe=J.index||0;try{let ie=re?yf(v,re):[],ge=se.trim(),ue=await L(ge,ie,k,E);G.push({original:ne,processed:ue,startIndex:oe})}catch(ie){let ge=ie instanceof Error?ie.message:String(ie);if(C.debug)console.error(`Error processing custom directive @${j}:`,ie);G.push({original:ne,processed:i("CustomDirective",`Error in @${j}${re?`(${re})`:""}: ${ge}`,t.EVALUATION_ERROR),startIndex:oe})}J=X.exec(F)}for(let ne=G.length-1;ne>=0;ne--){let{original:re,processed:se}=G[ne];F=F.replace(re,se)}return F}async function lx(x,v,k,E,C){let{name:j,handler:L}=v,B=x,z=[],F=[];if(v.rawParams){for(let J of Es(B,_r(`(?<![\\w$@])@${j}\\s*\\(`,"g")))if(J.end!==-1)F.push({fullMatch:J.call,paramString:J.args,startIndex:J.start})}else{let J=_r(`@${j}\\s*\\(([^()]*(?:\\([^)]*\\)[^()]*)*)\\)`,"g");J.lastIndex=0;let ne=J.exec(B);while(ne!==null)F.push({fullMatch:ne[0],paramString:ne[1]??"",startIndex:ne.index||0}),ne=J.exec(B)}for(let{fullMatch:J,paramString:ne,startIndex:re}of F)try{let se=yf(v,ne),oe=await L("",se,k,E);z.push({original:J,processed:oe,startIndex:re})}catch(se){let oe=se instanceof Error?se.message:String(se);if(C.debug)console.error(`Error processing custom directive @${j}:`,se);z.push({original:J,processed:i("CustomDirective",`Error in @${j}(${ne}): ${oe}`,t.EVALUATION_ERROR),startIndex:re})}let X=_r(`@${j}(?!\\w)(?!\\s*\\()`,"g"),G=X.exec(B);while(G!==null){let[J]=G,ne=G.index||0;try{let re=await L("",[],k,E);z.push({original:J,processed:re,startIndex:ne})}catch(re){let se=re instanceof Error?re.message:String(re);if(C.debug)console.error(`Error processing custom directive @${j}:`,re);z.push({original:J,processed:i("CustomDirective",`Error in @${j}: ${se}`,t.EVALUATION_ERROR),startIndex:ne})}G=X.exec(B)}for(let J=z.length-1;J>=0;J--){let{original:ne,processed:re}=z[J];B=B.replace(ne,re)}return B}function yf(x,v){return x.rawParams?Ge(v):ux(v)}function ux(x){if(!x.trim())return[];let v=[],k="",E=!1,C="";for(let j=0;j<x.length;j++){let L=x[j];if((L==='"'||L==="'")&&(j===0||x[j-1]!=="\\"))if(!E)E=!0,C=L;else if(L===C)E=!1;else k+=L;else if(L===","&&!E)v.push(k.trim()),k="";else k+=L}if(k.trim())v.push(k.trim());return v.map((j)=>{let L=j.trim();if(L.startsWith('"')&&L.endsWith('"')||L.startsWith("'")&&L.endsWith("'"))return L.substring(1,L.length-1);return L})}var xf=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/,bf=/^[A-Za-z_$][\w$]*$/,dx=new Set(["light","dark","system"]);function Ar(x,v){if(typeof x!=="string"||x.length===0)throw Error(`@appearanceBootstrap ${v} must be a non-empty string`)}function fx(x){if(!x||typeof x!=="object"||Array.isArray(x))throw Error("@appearanceBootstrap expects an options object");let v=x,{appearance:k,colorMode:E}=v;if(Ar(v.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"),!bf.test(E.key))throw Error("@appearanceBootstrap preference keys must be JavaScript property names");if(!xf.test(E.attribute))throw Error("@appearanceBootstrap attributes must be lowercase data attribute names");if(!dx.has(E.default))throw Error("@appearanceBootstrap colorMode.default must be light, dark, or system");let C=null;if(k){if(Ar(k.key,"appearance.key"),Ar(k.attribute,"appearance.attribute"),Ar(k.default,"appearance.default"),!bf.test(k.key))throw Error("@appearanceBootstrap preference keys must be JavaScript property names");if(!xf.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");C={key:k.key,attribute:k.attribute,allowed:[...new Set(k.allowed)],default:k.default}}return{storageKey:v.storageKey,appearance:C,colorMode:{key:E.key,attribute:E.attribute,default:E.default},respectExisting:v.respectExisting===!0}}function px(x){return JSON.stringify(x).replace(/</g,"\\u003c").replace(/>/g,"\\u003e").replace(/&/g,"\\u0026").replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}function gx(x){return`<script data-stx-scoped data-stx-appearance-bootstrap>(function(){"use strict";const config=${px(x)};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 mx(x,v){let k=1,E=null,C=!1;for(let j=v+1;j<x.length;j++){let L=x[j];if(C){C=!1;continue}if(E){if(L==="\\")C=!0;else if(L===E)E=null;continue}if(L==='"'||L==="'"||L==="`"){E=L;continue}if(L==="(")k++;else if(L===")"&&--k===0)return j}return-1}function vf(x,v){let k=x,E=/@appearanceBootstrap\s*\(/g,C;while((C=E.exec(k))!==null){let j=C.index+C[0].length-1,L=mx(k,j);if(L===-1)throw Error("@appearanceBootstrap has an unclosed options object");let B=k.slice(j+1,L).trim(),z=c(`(${B})`,v),F=gx(fx(z));k=k.slice(0,C.index)+F+k.slice(L+1),E.lastIndex=C.index+F.length}return k}import hx from"crypto";function Vt(x){return String(x??"").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}var Sf={input:"form-control",inputError:"is-invalid",checkInput:"form-check-input",label:"form-label",errorFeedback:"invalid-feedback"};function ro(x,v,k,E){let C=x||v;return k?`${C} ${E}`:C}function vn(x){return String(x).replace(/\[\]$/,"").replace(/[^\w.:-]+/g,"-").replace(/^-+|-+$/g,"")}function vs(x,v){if(/\bid\s*=/i.test(x))return"";return` id="${Vt(v)}"`}function Mc(x,v,k){if(!v)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(x)}-error`)}"`;return E}function yx(){return hx.randomUUID()}function so(x,v){let k=x;return k=k.replace(/@csrf/g,()=>{if(!v.csrf||typeof v.csrf!=="object"){let E=yx();v.csrf={token:E}}if(v.csrf.field)return v.csrf.field;if(v.csrf.token)return`<input type="hidden" name="_token" value="${Vt(v.csrf.token)}">`;return'<input type="hidden" name="_token" value="">'}),k=k.replace(/@method\(['"]([^'"]+)['"]\)/g,(E,C)=>{let j=C.toUpperCase();if(C&&!["GET","POST"].includes(j))return`<input type="hidden" name="_method" value="${Vt(j)}">`;return E}),k}function $f(x,v,k=Sf){let E=x;return E=E.replace(/@form\(\s*(?:(?:'([^']+)'|"([^"]+)")\s*)?(?:,\s*(?:'([^']+)'|"([^"]+)")?)?\s*(?:,\s*\{([^}]+)\}\s*)?\)/g,(C,j,L,B,z,F="")=>{let X=j||L||"POST",G=B||z||"",J=yr(F),ne=X.toUpperCase(),re=["GET","POST"].includes(ne)?ne:"POST",se=`<form method="${Vt(re)}" action="${Vt(G)}"${J?` ${J}`:""}>`;if(se+=`
|
|
1708
|
-
${so("@csrf",v)}`,!["GET","POST"].includes(ne))se+=`
|
|
1709
|
-
${so(`@method('${ne}')`,v)}`;return se}),E=E.replace(/@endform/g,"</form>"),E=E.replace(/@input\(\s*(?:'([^']+)'|"([^"]+)")\s*(?:,\s*(?:(?:'([^']*)'|"([^"]*)")\s*)?)?(?:,\s*\{([^}]+)\})?\s*\)/g,(C,j,L,B,z,F="")=>{let X=j||L||"",G=B||z||"",J=yr(F),ne=Js(X,v),re=ne!==void 0&&ne!==null?ne:G||"",se=J.match(/type=['"]([^'"]+)['"]/i),oe=se?se[1]:"text",ie=Ys(X,v),ge=J.match(/class=['"]([^'"]+)['"]/i),ue=ro(ge?ge[1]:"",k.input,ie,k.inputError),xe=J.replace(/class=['"][^'"]+['"]/i,"");return xe=xe.replace(/type=['"][^'"]+['"]/i,""),`<input type="${Vt(oe)}" name="${Vt(X)}"${vs(J,vn(X))} value="${Vt(re)}" class="${ue}"${Mc(X,ie,J)}${xe?` ${xe}`:""}>`}),E=E.replace(/@textarea\(\s*['"]([^'"]+)['"]\s*(?:,\s*\{([^}]+)\})?\)([\s\S]*?)@endtextarea/g,(C,j,L="",B="")=>{let z=yr(L),F=Js(j,v)||B.trim(),X=Ys(j,v),G=z.match(/class=['"]([^'"]+)['"]/i),J=ro(G?G[1]:"",k.input,X,k.inputError),ne=z.replace(/class=['"][^'"]+['"]/i,"");return`<textarea name="${Vt(j)}"${vs(z,vn(j))} class="${J}"${Mc(j,X,z)}${ne?` ${ne}`:""}>${Vt(F)}</textarea>`}),E=E.replace(/@select\(\s*['"]([^'"]+)['"]\s*(?:,\s*\{([^}]+)\})?\)([\s\S]*?)@endselect/g,(C,j,L="",B)=>{let z=yr(L),F=Js(j,v),X=Ys(j,v),G=z.match(/class=['"]([^'"]+)['"]/i),J=ro(G?G[1]:"",k.input,X,k.inputError),ne=z.replace(/class=['"][^'"]+['"]/i,""),re=B;if(F!==void 0)re=B.replace(/(<option[^>]*value=['"]([^'"]+)['"][^>]*>)/gi,(se,oe,ie)=>{if((Array.isArray(F)?F.some((ue)=>String(ue)===ie):String(F)===ie)&&!oe.includes("selected"))return oe.replace(/(<option)/,"$1 selected");return se});return`<select name="${Vt(j)}"${vs(z,vn(j))} class="${J}"${Mc(j,X,z)}${ne?` ${ne}`:""}>${re}</select>`}),E=E.replace(/@checkbox\(\s*['"]([^'"]+)['"]\s*(?:,\s*['"]([^'"]+)['"]\s*)?(?:,\s*\{([^}]+)\})?\)/g,(C,j,L,B="")=>{let z=L===void 0?"1":L,F=L===void 0?vn(j):`${vn(j)}-${vn(z)}`,X=yr(B),G=Js(j,v),J=G!==void 0&&(Array.isArray(G)?G.some((oe)=>String(oe)===z):G===!0||String(G)===z),ne=X.match(/class=['"]([^'"]+)['"]/i),re=ne?ne[1]:k.checkInput,se=X.replace(/class=['"][^'"]+['"]/i,"");return`<input type="checkbox" name="${Vt(j)}"${vs(X,F)} value="${Vt(z)}" class="${re}"${J?" checked":""}${se?` ${se}`:""}>`}),E=E.replace(/@radio\(\s*['"]([^'"]+)['"]\s*,\s*['"]([^'"]+)['"]\s*(?:,\s*\{([^}]+)\})?\)/g,(C,j,L,B="")=>{let z=yr(B),F=Js(j,v),X=F!==void 0&&F===L,G=z.match(/class=['"]([^'"]+)['"]/i),J=G?G[1]:k.checkInput,ne=z.replace(/class=['"][^'"]+['"]/i,"");return`<input type="radio" name="${Vt(j)}"${vs(z,`${vn(j)}-${vn(L)}`)} value="${Vt(L)}" class="${J}"${X?" checked":""}${ne?` ${ne}`:""}>`}),E=E.replace(/@file\(\s*['"]([^'"]+)['"]\s*(?:,\s*\{([^}]+)\})?\)/g,(C,j,L="")=>{let B=yr(L),z=B.match(/accept=['"]([^'"]+)['"]/i),F=z?z[1]:"",X=B.includes("multiple"),G=Ys(j,v),J=B.match(/class=['"]([^'"]+)['"]/i),ne=ro(J?J[1]:"",k.input,G,k.inputError),re=B.replace(/class=['"][^'"]+['"]/gi,"").replace(/accept=['"][^'"]+['"]/gi,"").replace(/\bmultiple\b/gi,"").trim(),se=[`<input type="file" name="${Vt(j)}"${vs(B,vn(j))}`,`class="${ne}"`];if(F)se.push(`accept="${Vt(F)}"`);if(X)se.push("multiple");if(re)se.push(re);return`${se.join(" ")}>`}),E=E.replace(/@label\(\s*['"]([^'"]+)['"]\s*(?:,\s*\{([^}]+)\})?\)([\s\S]*?)@endlabel/g,(C,j,L="",B)=>{let z=yr(L),F=z.match(/class=['"]([^'"]+)['"]/i),X=F?F[1]:k.label,G=z.replace(/class=['"][^'"]+['"]/i,"");return`<label for="${Vt(vn(j))}" class="${X}"${G?` ${G}`:""}>${B}</label>`}),E}function _f(x,v,k=Sf){return x.replace(/@error\(['"]([^'"]+)['"]\)([\s\S]*?)@enderror/g,(E,C,j)=>{try{if(Ys(C,v)){let L=j.replace(/\{\{([^}]+)\}\}/g,(B,z)=>{try{if(z.trim()==="$message"||z.trim()==="message")return wf(C,v);if(z.trim().includes("errors.first")||z.trim().includes("$errors.first")){if(typeof v.errors?.first==="function")return v.errors.first(C);return wf(C,v)}let F=z.trim();if(p(F)){let X=c(F,v);return X!==void 0?String(X):F}return F}catch{return z}});return`<div id="${Vt(`${vn(C)}-error`)}" role="alert">${L}</div>`}return""}catch(L){return console.error("Error processing @error directive:",L),E}})}function Ys(x,v){if(!v.errors)return!1;if(typeof v.errors.has==="function")return v.errors.has(x);if(typeof v.errors==="object")return Object.prototype.hasOwnProperty.call(v.errors,x);return!1}function wf(x,v){if(!v.errors)return"";if(typeof v.errors.get==="function")return v.errors.get(x);if(typeof v.errors==="object"&&Object.prototype.hasOwnProperty.call(v.errors,x)){let k=v.errors[x];return Array.isArray(k)?k[0]:String(k)}return""}function Js(x,v){let k;if(v.old&&typeof v.old==="function")return v.old(x);if(v.old&&typeof v.old==="object")return v.old[x];if(x.endsWith("[]")){let E=x.slice(0,-2);if(k=v[E],k!==void 0)return k}return v[x]}function yr(x){if(!x.trim())return"";let v=[],k=x.trim(),E=/([\w-]+)\s*:\s*(['"]?)([^,'"]*)\2(?:\s*,\s*|\s*$)/g,C;while((C=E.exec(k))!==null){let[,j,,L]=C;v.push(`${j}="${L.trim()}"`)}return v.join(" ")}var Qs=/<\/?template\b[^>]*>/gi,xx=/(?:^|\s)(?:id\s*=|(?:x-|[@:])(?:for|if|else(?:-if)?)(?=\s|=|$)|#[\w-]+(?:\s*=|\s|$)|v-slot(?::[\w-]+)?(?=\s|=|$)|slot\s*=)/i;function bx(x){let v=x.replace(/^<template\b/i,"").replace(/>$/,"");return xx.test(v)}function Z(x){Qs.lastIndex=0;let v;while((v=Qs.exec(x))!==null){if(v[0].startsWith("</")||bx(v[0]))continue;let k=v.index,E=Qs.lastIndex,C=1,j;while((j=Qs.exec(x))!==null)if(j[0].startsWith("</")){if(C--,C===0){let L=j.index;return{start:k,openEnd:E,closeStart:L,end:Qs.lastIndex,content:x.slice(E,L)}}}else C++;return null}return null}import Ot from"path";import{existsSync as hb}from"fs";import io from"fs";import zt from"path";var kf=new Map;function oo(x,v=!0){let k=kf.get(x);if(v&&k)return k;let E=new Map,C=[zt.join(x,"src"),zt.join(x,"dist"),x];function j(L,B){if(B>6)return;let z;try{z=io.readdirSync(L,{withFileTypes:!0})}catch{return}for(let F of z){let X=zt.join(L,F.name);if(F.isDirectory()){if(F.name==="node_modules"||F.name.startsWith("."))continue;j(X,B+1)}else if(F.isFile()&&F.name.endsWith(".stx")){let G=F.name.slice(0,-4);if(!E.has(G))E.set(G,X);let J=G.toLowerCase();if(!E.has(J))E.set(J,X);let ne=G.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();if(!E.has(ne))E.set(ne,X)}}}for(let L of C)if(j(L,0),E.size>0)break;if(v)kf.set(x,E);return E}function ao(x,v){if(x.startsWith(".")||x.startsWith("/"))return null;let k=v;while(!0){let E=zt.join(k,"node_modules",x);try{if(io.statSync(E).isDirectory())return E}catch{}let C=zt.dirname(k);if(C===k)return null;k=C}}function co(x,v,k={}){return[zt.resolve(zt.dirname(v),`${x}.stx`),zt.resolve(zt.dirname(v),x),zt.resolve(k.componentsDir||"components",`${x}.stx`),zt.resolve(k.componentsDir||"components",x),x.endsWith(".stx")?x:`${x}.stx`]}function Ef(x){let v=x.endsWith(".stx")?x.slice(0,-4):x,k=v.split("-").map((C)=>C.charAt(0).toUpperCase()+C.slice(1)).join(""),E=v.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();return[v,k,E]}function Oc(x,v){let[k,E,C]=Ef(x);for(let j of[k,k.toLowerCase(),E,C]){let L=v?.__importedComponents?.get(j);if(L!==void 0)return L}}function*Nc(x,v,k={},E){let C=Ef(x);if(C[0].startsWith("./")||C[0].startsWith("../")){yield zt.resolve(zt.dirname(v),`${C[0]}.stx`);return}let j=[...new Set(C.map((z)=>`${z}.stx`))],L=k.projectRoot||process.cwd(),B=[...E?.__originalFilePath?[zt.join(zt.dirname(E.__originalFilePath),"components")]:[],...k.componentsDir?[k.componentsDir]:[],zt.join(zt.dirname(v),"components"),zt.resolve(L,"src/components"),zt.resolve(L,"components"),...import.meta.dir?[zt.resolve(import.meta.dir,"components")]:[]];for(let z of new Set(B)){for(let F of j)yield zt.join(z,F);try{for(let F of io.readdirSync(z,{withFileTypes:!0}))if(F.isDirectory())for(let X of j)yield zt.join(z,F.name,X)}catch{}}}function Cf(x,v,k={},E){let C=Oc(x,E);if(C!==void 0)return C;for(let j of Nc(x,v,k,E))try{if(io.statSync(j,{throwIfNoEntry:!1})?.isFile())return j}catch{}return null}class Rf{builtins=new Map;registerBuiltin(x){this.builtins.set(x.name.toLowerCase(),x);for(let v of x.aliases)this.builtins.set(v.toLowerCase(),x)}isBuiltin(x){return this.builtins.has(x.toLowerCase())}getBuiltin(x){return this.builtins.get(x.toLowerCase())??null}async resolveFile(x,v,k,E){let C=Oc(x,E);if(C!==void 0)return C;for(let j of Nc(x,v,k,E))if(await r(j))return j;return null}}var As=new Rf;function jt(x){return x.replace(/&/g,"&").replace(/"/g,""").replace(/'/g,"'").replace(/</g,"<").replace(/>/g,">")}var Ir="\x00stx-boolean-attribute";function jc(x){return x.indexOf("\x00")===-1?x:x.replace(/\0/g,"")}function xr(x,v){let k=[];for(let[E,C]of Object.entries(x.static)){if(v.has(E))continue;let j=x.staticNames?.[E]??E;if(typeof C==="boolean"){if(C)k.push(jt(j));continue}if(C===Ir){k.push(jt(j));continue}k.push(`${jt(j)}="${jt(jc(String(C)))}"`)}return k}function br(x,v){let k=[];for(let[E,C]of Object.entries(x.serverDynamic??{})){if(v.has(E))continue;if(C===null||C===void 0||C===!1)continue;let j=x.serverDynamicNames?.[E]??E;if(C===!0){k.push(jt(j));continue}if(typeof C==="object")continue;k.push(`${jt(j)}="${jt(jc(String(C)))}"`)}return k}function Is(x){return x.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}function vx(x){if(x.clientReactive.to)return{value:x.clientReactive.to,reactive:!0};if(x.serverDynamic.to!==void 0)return{value:String(x.serverDynamic.to),reactive:!1};if(typeof x.static.to==="string")return{value:x.static.to,reactive:!1};return{value:"#",reactive:!1}}var Lc={name:"StxLink",aliases:["stx-link"],render(x,v,k){let E=vx(x),C=(typeof x.static.class==="string"?x.static.class:"")||(typeof x.static.className==="string"?x.static.className:""),j=typeof x.static.activeClass==="string"?x.static.activeClass:"active",L=typeof x.static.exactActiveClass==="string"?x.static.exactActiveClass:"exact-active",B=x.static.prefetch===!0||x.static.prefetch==="true"||x.serverDynamic.prefetch===!0,z=[];if(E.reactive)z.push(`:href="${Is(E.value)}"`);else z.push(`href="${Is(Vs(E.value,"navigable"))}"`);if(C)z.push(`class="${Is(C)}"`);if(z.push("data-stx-link"),z.push(`data-stx-active-class="${Is(j)}"`),z.push(`data-stx-exact-active-class="${Is(L)}"`),B)z.push("data-stx-prefetch");let F=typeof x.static.activeMatch==="string"?x.static.activeMatch.trim():"";if(F)z.push(`data-stx-active-match="${Is(F)}"`);let X=new Set(["to","class","className","activeClass","exactActiveClass","activeMatch","prefetch"]);return z.push(...xr(x,X)),z.push(...br(x,X)),`<a ${z.join(" ")}>${v}</a>`}};import{createHash as zf}from"crypto";import un from"fs";import Ut from"path";import{decode as Rx,generateThumbHash as Tx}from"ts-images";import{createImageDeliveryCatalog as Mf}from"ts-images/delivery";import Bc from"fs";function lo(x,v,k){let E=Buffer.alloc(k),C=Bc.readSync(x,E,0,k,v);return E.subarray(0,C)}function zc(x){if(x.length<25)return!1;let v=(E,C)=>String.fromCharCode(...x.subarray(E,C));if(v(0,4)!=="RIFF"||v(8,12)!=="WEBP")return!1;let k=v(12,16);if(k==="VP8X")return(x[20]&16)!==0;if(k==="VP8L")return((x[21]|x[22]<<8|x[23]<<16|x[24]<<24)>>>28&1)===1;return!1}function Fc(x){let v;try{v=Bc.openSync(x,"r");let k=lo(v,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 C=8;for(let j=0;j<64;j++){let L=lo(v,C,8);if(L.length<8)return"unknown";let B=L.toString("latin1",4,8);if(B==="tRNS")return"possible";if(B==="IDAT"||B==="IEND")return"none";C+=12+L.readUInt32BE(0)}return"unknown"}if(k.length>=25&&k.toString("latin1",0,4)==="RIFF"&&k.toString("latin1",8,12)==="WEBP"){if(zc(k))return"possible";let E=k.toString("latin1",12,16);return E==="VP8 "||E==="VP8X"?"none":"unknown"}return"unknown"}catch{return"unknown"}finally{if(v!==void 0)Bc.closeSync(v)}}import wx from"fs";import uo from"os";import{join as Tf}from"path";import{fileURLToPath as Af}from"url";import{Worker as If}from"worker_threads";var po=Symbol("stx.image-worker.unavailable");function Sx(x=typeof uo.availableParallelism==="function"?uo.availableParallelism():uo.cpus().length){return Math.max(1,Math.min(2,x-1))}var fo=0,Df=[];async function $x(){if(fo<Sx()){fo++;return}await new Promise((x)=>Df.push(x)),fo++}function _x(){fo--,Df.shift()?.()}var kx="@stacksjs/stx/builtins/image-warmup-worker";function Ex(x=process.cwd()){let v=import.meta.url.endsWith(".ts")?"ts":"js";try{let k=new URL(`./image-warmup-worker.${v}`,import.meta.url);if(k.protocol==="file:"&&wx.existsSync(Af(k)))return Af(k)}catch{}try{let k=typeof Bun<"u"?Bun.resolveSync(kx,x):void 0;return k&&Cx(k)?k:void 0}catch{return}}function Cx(x,v=process.env){let k=x.replace(/\\/g,"/");if(k.split("/").some((C)=>/@\d[^/]*@@@\d+$/.test(C)))return!1;return![v.BUN_INSTALL_CACHE_DIR,Tf(v.BUN_INSTALL||Tf(uo.homedir(),".bun"),"install","cache")].filter((C)=>!!C).map((C)=>`${C.replace(/\\/g,"/").replace(/\/$/,"")}/`).some((C)=>k.startsWith(C))}var Pf=!1;function di(x){if(!Pf)Pf=!0,console.warn(`[stx] image worker unavailable (${x}); running the image pass on the serving thread instead. Results are the same, but requests may stall while it runs.`);return po}function Wc(x){return x instanceof Error?x.message:String(x)}async function Vc(x,v){if(typeof If!=="function")return di("node:worker_threads has no Worker in this runtime");let k=Ex();if(!k)return di("no image-warmup-worker entry beside this module or in the installed @stacksjs/stx");await $x();try{return await new Promise((E,C)=>{let j;try{j=new If(k)}catch(F){E(di(`could not start ${k}: ${Wc(F)}`));return}let L=!1,B=!1,z=(F)=>{if(B)return;B=!0,F(),j.terminate()};j.on("message",(F)=>{if(F.type==="ready"){L=!0,j.postMessage({task:x,args:v});return}if(F.type==="result"){z(()=>E(F.value));return}let X=Error(F.error?.message??"image worker failed");if(F.error?.name)X.name=F.error.name;if(F.error?.stack)X.stack=F.error.stack;z(()=>C(X))}),j.on("error",(F)=>{z(()=>L?C(F instanceof Error?F:Error(Wc(F)||"image worker crashed")):E(di(`the worker failed before it was ready: ${Wc(F)}`)))}),j.on("exit",(F)=>{z(()=>L?C(Error("image worker exited before it finished")):E(di(`the worker exited with code ${F} before it was ready`)))})})}finally{_x()}}var Ax=new Set([".avif",".jpeg",".jpg",".png",".webp"]),Ix=[320,640,960,1280,1920],mo="/_stx/images",Px=`stx:${mo}:alpha-1`,Dx=["@stacksjs/ts-webp","@stacksjs/ts-avif"],go;function Mx(x,v){let k=Ut.dirname(Bun.resolveSync(x,v));while(k!==Ut.dirname(k)){let E=Ut.join(k,"package.json");if(un.existsSync(E)){let C=JSON.parse(un.readFileSync(E,"utf8"));if(C.name===x)return C.version}k=Ut.dirname(k)}return}function Ox(){if(go!==void 0)return go;let x;try{x=Ut.dirname(Bun.resolveSync("ts-images",import.meta.dir))}catch{}return go=Dx.map((v)=>{let k;try{k=x?Mx(v,x):void 0}catch{}return`${v.replace("@stacksjs/","")}@${k??"unknown"}`}).join("+"),go}var Of=Symbol.for("stx.image-delivery");function gi(){let x=globalThis;return x[Of]??={catalog:new Map,transparent:new Set},x[Of]}var Nf=new Set;function Nx(x){return`/${x.split(Ut.sep).map(encodeURIComponent).join("/")}`}function jx(x){let v=Ut.extname(x),k=x.slice(0,-v.length).replace(/[^a-zA-Z0-9_-]+/g,"-").replace(/^-+|-+$/g,""),E=zf("sha256").update(x).digest("hex").slice(0,8);return`${k||"image"}-${E}`}function jf(x,v=`stx:${mo}`){let k=(E)=>`${mo}/${E.split("/").map(encodeURIComponent).join("/")}`;return{cacheNamespace:v,async stat(E){let C=Ut.join(x,E);try{let j=await un.promises.stat(C);return j.size>0?{bytes:j.size,path:C,url:k(E)}:null}catch{return null}},async write(E,C){let j=Ut.join(x,E);await un.promises.mkdir(Ut.dirname(j),{recursive:!0});let L=`${j}.${process.pid}.tmp`;return await un.promises.writeFile(L,C),await un.promises.rename(L,j),{bytes:C.byteLength,path:j,url:k(E)}},url:k}}async function Ff(x,v=x){let k=await un.promises.readdir(v,{withFileTypes:!0});k.sort((C,j)=>C.name.localeCompare(j.name));let E=[];for(let C of k){let j=Ut.join(v,C.name);if(C.isDirectory()){E.push(...await Ff(x,j));continue}if(!C.isFile()||!Ax.has(Ut.extname(C.name).toLowerCase()))continue;E.push({absolutePath:j,relativePath:Ut.relative(x,j)})}return E}function Lf(x,v){return x.map((k)=>({key:Nx(k.relativePath),input:k.absolutePath,name:jx(k.relativePath),...Lx(k.absolutePath)?{options:{storage:v}}:{}}))}function Lx(x){return Fc(x)==="possible"}function Bx(x){for(let v=3;v<x.length;v+=4)if(x[v]!==255)return!0;return!1}async function zx(x){let v=Object.entries(x).filter(([,C])=>C.fallback.format==="png"),k=new Set,E=8;for(let C=0;C<v.length;C+=8)await Promise.all(v.slice(C,C+8).map(async([j,L])=>{let B=L.variants.filter((z)=>z.format==="png").sort((z,F)=>z.width-F.width)[0];try{let z=await Rx(new Uint8Array(await un.promises.readFile(B?.path??L.fallback.path)));if(Bx(z.data))k.add(j)}catch{k.add(j)}}));return k}function Fx(x,v){let k=[];for(let E of v){let C=x[E],j=C?.variants.filter((B)=>B.format==="webp")??[];if(!C||j.length===0)continue;if(!j.some((B)=>{let z;try{return z=un.openSync(B.path,"r"),!zc(lo(z,0,32))}catch{return!0}finally{if(z!==void 0)un.closeSync(z)}}))continue;if(C.variants=C.variants.filter((B)=>B.format!=="webp"),delete C.sources.webp,k.push(E),!Nf.has(E))Nf.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 Wx(x){let v=[],k=8;for(let E=0;E<x.length;E+=8){let C=x.slice(E,E+8),j=await Promise.all(C.map(async(L)=>{try{return await Tx(L.absolutePath),L}catch{return console.warn(`[stx-images] Skipping unreadable raster: ${L.relativePath}`),null}}));v.push(...j.filter((L)=>L!==null))}return v}function Uc(x){return Ut.join(x,"undecodable.json")}function Vx(x){try{let v=un.readFileSync(Uc(x),"utf-8"),k=JSON.parse(v);return k&&typeof k==="object"?k:{}}catch{return{}}}function Ux(x,v){try{un.mkdirSync(Ut.dirname(Uc(x)),{recursive:!0}),un.writeFileSync(Uc(x),JSON.stringify(v))}catch{}}function Bf(x){try{let v=un.statSync(x);return{mtimeMs:v.mtimeMs,size:v.size}}catch{return}}function Wf(x){if(!x||x.startsWith("data:")||x.startsWith("blob:")||/^https?:\/\//i.test(x)||x.startsWith("//"))return;let v=x.split(/[?#]/,1)[0];if(!v)return;try{return`/${v.replace(/^\/+/,"").split("/").map(decodeURIComponent).map(encodeURIComponent).join("/")}`}catch{return}}function Yr(x){let v=Wf(x);return v?gi().catalog.get(v):void 0}function Zr(x){let v=Wf(x);return v?gi().transparent.has(v):!1}function Qr(x){let v=(E)=>x.variants.filter((C)=>C.format===E).reduce((C,j)=>C+j.bytes,0),k=v(x.fallback.format);return["avif","webp"].map((E)=>({format:E,srcset:x.sources[E]||"",bytes:v(E)})).filter((E)=>E.srcset&&E.bytes>0&&E.bytes<k).sort((E,C)=>E.bytes-C.bytes).map(({format:E,srcset:C})=>({format:E,srcset:C}))}function Du(x){let v=Yr(x);if(!v)return;return{src:v.fallback.url,srcset:v.sources[v.fallback.format]||"",sources:Qr(v).map(({format:k,srcset:E})=>({type:`image/${k}`,srcset:E})),width:v.source.width,height:v.source.height,placeholder:Zr(x)?void 0:v.placeholder?.dataUrl}}function Ln(){let x=gi();x.catalog=new Map,x.transparent=new Set}function Hx(x){let v=gi();v.catalog=new Map(x.entries),v.transparent=new Set(x.transparent)}async function Ou(x,v,k={}){if(!x||!un.existsSync(x))return Ln(),{count:0,fingerprint:""};if(k.offThread){let re=await Vc("delivery",{publicDir:x,outputDir:v});if(re!==po)return Hx(re.state),re.result}let E=await Ff(x);if(E.length===0)return Ln(),{count:0,fingerprint:""};let C=Vx(v),j=E.filter((re)=>{let se=C[re.relativePath];if(!se)return!0;let oe=Bf(re.absolutePath);return!oe||oe.mtimeMs!==se.mtimeMs||oe.size!==se.size});if(j.length===0)return Ln(),{count:0,fingerprint:""};let L=jf(Ut.join(v,"_stx","images"),`${Px}:${Ox()}`),B={outDir:Ut.join(v,"_stx","images"),storage:jf(Ut.join(v,"_stx","images")),baseUrl:mo,widths:Ix,formats:["avif","webp"],quality:{avif:70,webp:78,jpeg:82,png:100},includeOriginal:!1,placeholder:!0,batchConcurrency:4,concurrency:4},z=j,F;try{F=await Mf({...B,entries:Lf(j,L)})}catch(re){if(z=await Wx(j),z.length===j.length)throw re;let se=new Set(z.map((ie)=>ie.relativePath)),oe=!1;for(let ie of j){if(se.has(ie.relativePath))continue;let ge=Bf(ie.absolutePath);if(!ge)continue;C[ie.relativePath]=ge,oe=!0}if(oe)Ux(v,C);if(z.length===0)return Ln(),{count:0,fingerprint:""};F=await Mf({...B,entries:Lf(z,L)})}let X=await zx(F.entries),G=Fx(F.entries,X),J=gi();J.catalog=new Map(Object.entries(F.entries)),J.transparent=X;let ne=X.size===0&&G.length===0?F.fingerprint:zf("sha256").update(F.fingerprint).update(JSON.stringify({transparent:[...X].sort(),droppedWebp:G.sort()})).digest("hex");return{count:z.length,fingerprint:ne}}var qx=new Map;function Hc(x){if(!x)return;let v=x.split("?")[0].split("#")[0];return qx.get(v)}var Kx={sm:640,md:768,lg:1024,xl:1280,"2xl":1536},qc=[320,640,768,1024,1280,1536,1920];function Ft(x){return x.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}function Xt(x,v){if(x.serverDynamic[v]!==void 0)return String(x.serverDynamic[v]);let k=x.static[v];if(typeof k==="string")return k;return}function ho(x,v,k=!1){let E=x.serverDynamic[v];if(E!==void 0)return E!==!1&&E!=="false";let C=x.static[v];if(C!==void 0)return C!=="false"&&C!==!1;return k}function Kc(x){if(x.includes("(")||x.includes(","))return x;let v=x.trim().split(/\s+/),k=[];for(let E of v)if(E.includes(":")){let[C,j]=E.split(":"),L=Kx[C];if(L)k.push(`(max-width: ${L}px) ${j}`);else{let B=Number.parseInt(C);if(!Number.isNaN(B))k.push(`(max-width: ${B}px) ${j}`)}}else k.push(E);return k.join(", ")}function Xc(x,v,k,E){return v.map((C)=>`${mi(x,C,void 0,k,E)} ${C}w`).join(", ")}function Xx(x,v,k,E,C){return v.map((j)=>{let L=k?k*j:void 0;return`${mi(x,L,void 0,E,C)} ${j}x`}).join(", ")}function mi(x,v,k,E,C){if(!E||E==="local"||E==="static")return x;if(E==="cloudinary"){let j=[];if(v)j.push(`w_${v}`);if(k)j.push(`h_${k}`);if(C)j.push(`f_${C}`);j.push("q_auto");let L=j.join(",");return x.replace("/upload/",`/upload/${L}/`)}if(E==="imgix"){let j=new URLSearchParams;if(v)j.set("w",String(v));if(k)j.set("h",String(k));if(C)j.set("fm",C);j.set("auto","format");let L=x.includes("?")?"&":"?";return`${x}${L}${j.toString()}`}if(E==="bunny"){let j=new URLSearchParams;if(v)j.set("width",String(v));if(k)j.set("height",String(k));if(C)j.set("format",C);let L=x.includes("?")?"&":"?";return`${x}${L}${j.toString()}`}return x}function Zx(x){return`var s=this.style;${x.map((v)=>`s.${v}=''`).join(";")}`}function Gx(x,v,k="#e5e7eb"){let E=`<svg xmlns="http://www.w3.org/2000/svg" width="${x}" height="${v}"><rect width="100%" height="100%" fill="${k}"/></svg>`;return`data:image/svg+xml;base64,${btoa(E)}`}var Zc={name:"StxImage",aliases:["Image","stx-image","stx-img"],render(x,v,k){let E=Xt(x,"src")||"",C=Yr(E),j=Xt(x,"alt")||"",L=Xt(x,"width")||(C?String(C.source.width):void 0),B=Xt(x,"height")||(C?String(C.source.height):void 0),z=Xt(x,"sizes"),F=Xt(x,"srcset"),X=Xt(x,"densities"),G=Xt(x,"format"),J=Zr(E)||Hc(E)?.transparent===!0,ne=Xt(x,"placeholder")||(C&&!J?"thumbhash":void 0),re=Xt(x,"placeholderColor")||"#e5e7eb",se=Xt(x,"provider"),oe=Xt(x,"class")||Xt(x,"className")||"",ie=Xt(x,"style")||"",ge=Xt(x,"quality"),ue=ho(x,"lazy",!0),xe=ho(x,"preload",!1),we=ho(x,"priority",!1),$e=Xt(x,"loading"),_e=Xt(x,"decoding")||"async",Ce=!!C||ho(x,"picture",!1)||!!G,Ee=L?Number.parseInt(L):void 0,Te=B?Number.parseInt(B):void 0,Re=F||"",ke="";if(C)Re=C.sources[C.fallback.format]||"",ke=z?Kc(z):"100vw";else if(!Re&&z&&se&&se!=="local"&&se!=="static")Re=Xc(E,qc,se,G),ke=Kc(z);else if(!Re&&X){let ft=X.split(/\s+/).map((yt)=>Number.parseFloat(yt.replace("x","")));Re=Xx(E,ft,Ee,se,G)}else if(z)ke=Kc(z);let Ae=[];if(ie)Ae.push(ie);if(Ee&&Te)Ae.push(`aspect-ratio:${Ee}/${Te}`);let Xe=[],Pe=ne==="blur"||ne==="color"||ne==="thumbhash";if(Pe&&!J){let ft=C?.placeholder?{dataUrl:C.placeholder.dataUrl,color:re}:Hc(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=Gx(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=C?.fallback.url||mi(E,Ee,Te,se,G),Ze=[];if(Ze.push(`src="${Ft(Vs(Ie,"fetched"))}"`),Ze.push(`alt="${Ft(j)}"`),L)Ze.push(`width="${Ft(L)}"`);if(B)Ze.push(`height="${Ft(B)}"`);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)}"`),oe)Ze.push(`class="${Ft(oe)}"`);if(Ae.length>0)Ze.push(`style="${Ft(Ae.join(";"))}"`);if(Re)Ze.push(`srcset="${Ft(Vs(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 x.static.onload==="string"?x.static.onload:"",yt=Zx(Xe)+(ft?`;${ft}`:"");Ze.push(`onload="${Ft(yt)}"`),at.add("onload")}Ze.push(...xr(x,at)),Ze.push(...br(x,at));let rt=`<img ${Ze.join(" ")} />`,Rt="";if(xe){let yt=G==="webp"?"image/webp":G==="avif"?"image/avif":"";Rt=`<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(C)for(let yt of Qr(C))ft.push(`<source type="image/${yt.format}" srcset="${Ft(yt.srcset)}"${ke?` sizes="${Ft(ke)}"`:""} />`);if(!C&&(G==="avif"||G==="auto")){let yt=mi(E,Ee,Te,se,"avif"),ct=Re?Xc(E,qc,se,"avif"):`${yt}`;ft.push(`<source type="image/avif" srcset="${Ft(ct)}"${ke?` sizes="${Ft(ke)}"`:""} />`)}if(!C&&(G==="webp"||G==="auto")){let yt=mi(E,Ee,Te,se,"webp"),ct=Re?Xc(E,qc,se,"webp"):`${yt}`;ft.push(`<source type="image/webp" srcset="${Ft(ct)}"${ke?` sizes="${Ft(ke)}"`:""} />`)}return`${Rt}<picture>
|
|
1711
|
-
${ft.join(`
|
|
1712
|
-
`)}
|
|
1713
|
-
${rt}
|
|
1714
|
-
</picture>`}return`${Rt}${rt}`}};var Vf="/images/safe-image-default.svg";function yi(x){return x.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}function Ds(x,v){if(x.serverDynamic[v]!==void 0)return String(x.serverDynamic[v]);let k=x.static[v];if(typeof k==="string")return k;return}var Jx=`<script>window.__stxSafeImageHandler||(window.__stxSafeImageHandler=function(i){if(i.__stx_fb)return;i.__stx_fb=1;var f=i.getAttribute('data-fallback')||'${Vf}';var c=i.getAttribute('data-fallback-class');i.src=f;if(c)i.className=c;});</script>`,Gc={name:"SafeImage",aliases:["safe-image","safe-img"],render(x,v,k){let E=Ds(x,"src")||"",C=Ds(x,"alt")||"",j=Ds(x,"fallback")||Vf,L=Ds(x,"class")||Ds(x,"className")||"",B=Ds(x,"fallbackClassName")||"",z=[];if(z.push(`src="${yi(E)}"`),z.push(`alt="${yi(C)}"`),L)z.push(`class="${yi(L)}"`);if(z.push(`data-fallback="${yi(j)}"`),B)z.push(`data-fallback-class="${yi(B)}"`);z.push('onerror="window.__stxSafeImageHandler(this)"');let F=new Set(["src","alt","fallback","class","className","fallbackClassName"]);z.push(...xr(x,F)),z.push(...br(x,F));let X=`<img ${z.join(" ")} />`,G=k.context;if(!G.__safeImageHandlerEmitted)return G.__safeImageHandlerEmitted=!0,`${Jx}${X}`;return X}};function Jc(x){return x.replace(/[;{}()]/g,"").replace(/url/gi,"")}function wi(x,v){if(x.serverDynamic[v]!==void 0)return String(x.serverDynamic[v]);let k=x.static[v];if(typeof k==="string")return k;return}function yo(x,v,k){let E=wi(x,v);if(E!==void 0){let C=Number.parseInt(E,10);if(!Number.isNaN(C))return C}return k}var Yc={name:"StxLoadingIndicator",aliases:["stx-loading-indicator"],render(x,v,k){let E=Jc(wi(x,"color")||"#6366f1"),C=Jc(wi(x,"initialColor")||wi(x,"initial-color")||""),j=Jc(wi(x,"height")||"3px"),L=yo(x,"duration",2000),B=yo(x,"throttle",200),z=yo(x,"zIndex",999999)||yo(x,"z-index",999999),F=C?`linear-gradient(to right, ${C}, ${E})`:E;return`
|
|
1715
|
-
<div id="stx-loading-indicator" style="position:fixed;top:0;left:0;right:0;height:${j};background:${F};z-index:${z};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)},${B})},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 Hf(x,v){if(x.serverDynamic[v]!==void 0)return String(x.serverDynamic[v]);let k=x.static[v];if(typeof k==="string")return k;return}function Yx(x,v,k){let E=Hf(x,v);if(E!==void 0){let C=Number.parseInt(E,10);if(!Number.isNaN(C))return C}return k}var Uf={"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%)"},Qc={name:"StxToast",aliases:["stx-toast"],render(x,v,k){let E=jt(Hf(x,"position")||"top-right"),C=Yx(x,"max",5),j=Uf[E]||Uf["top-right"];return`<div id="stx-toast-container" data-stx-toast-position="${E}" data-stx-toast-max="${C}" 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 xo(x,v){if(x.serverDynamic[v]!==void 0)return String(x.serverDynamic[v]);let k=x.static[v];if(typeof k==="string")return k;return}var qf={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)"},el={name:"StxModal",aliases:["stx-modal"],render(x,v,k){let E=xo(x,"id");if(!E)return console.warn('[stx] <StxModal> requires an "id" prop'),"<!-- StxModal: missing id prop -->";let C=jt(E),j=xo(x,"size")||"md",L=xo(x,"closeOnBackdrop")!=="false",B=xo(x,"closeOnEscape")!=="false",z=qf[j]||qf.md;return`<div id="stx-modal-${C}" class="stx-modal-backdrop" data-stx-modal="${C}" data-close-backdrop="${L}" data-close-escape="${B}" 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="${z};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">${v}</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 Ms(x,v){if(x.serverDynamic[v]!==void 0)return String(x.serverDynamic[v]);let k=x.static[v];if(typeof k==="string")return k;return}var Kf={sm:"16rem",md:"24rem",lg:"32rem",xl:"40rem"},tl={name:"StxDrawer",aliases:["stx-drawer"],render(x,v,k){let E=Ms(x,"id");if(!E)return console.warn('[stx] <StxDrawer> requires an "id" prop'),"<!-- StxDrawer: missing id prop -->";let C=jt(E),j=Ms(x,"side")||"right",L=Ms(x,"size")||"md",B=Ms(x,"closeOnBackdrop")!=="false",z=Ms(x,"closeOnEscape")!=="false",F=Ms(x,"overlay")!=="false",X=Kf[L]||Kf.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-${C}" class="stx-drawer-backdrop" data-stx-drawer="${C}" data-close-backdrop="${B}" data-close-escape="${z}" style="display:none;position:fixed;inset:0;z-index:99999;${F?"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:${X};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">${v}</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 Qx,readFileSync as eb}from"fs";var bo=new Map,Xf=new Set;function tb(x){if(Xf.has(x))return;Xf.add(x),console.warn(`[stx] icon collection "${x}" is not installed, so its icons render as nothing. Install it with \`bun add -d @iconify-json/${x}\`.`)}function nb(x){let v=process.cwd();for(let k of[`${v}/node_modules/@iconify-json/${x}/icons.json`,`${v}/pantry/@iconify-json/${x}/icons.json`,`${v}/node_modules/@iconify/json/json/${x}.json`,`${v}/pantry/@iconify/json/json/${x}.json`])if(Qx(k))return k;for(let k of[`@iconify-json/${x}/icons.json`,`@iconify/json/json/${x}.json`])try{return u.resolve(k)}catch{}return null}function rb(x){if(bo.has(x))return bo.get(x);let v=nb(x);if(!v)return tb(x),null;try{let k=JSON.parse(eb(v,"utf8"));return bo.set(x,k.icons),k.icons}catch{return null}}function Os(x,v){if(x.serverDynamic[v]!==void 0)return String(x.serverDynamic[v]);if(x.static[v]!==void 0)return String(x.static[v]);if(x.clientReactive[v]!==void 0)return x.clientReactive[v];return}var nl={name:"Icon",aliases:["icon","stx-icon"],render(x,v,k){let E=Os(x,"name")??Os(x,"icon");if(!E)return"<!-- Icon: missing name/icon prop -->";let C="lucide",j=E;if(E.includes(":")){let ge=E.split(":");C=ge[0],j=ge[1]}let L=jt(Os(x,"size")||"24"),B=jt(Os(x,"color")||"currentColor"),z=jt(Os(x,"class")||""),F=jt(Os(x,"style")||""),X=bo.get(C)??rb(C);if(!X)return`<!-- Icon: collection "${C}" not loaded -->`;let G=X[j];if(!G)return`<!-- Icon: "${j}" not found in ${C} -->`;let J=G.width||24,ne=G.height||24,re=`0 0 ${J} ${ne}`,se=G.body;if(B!=="currentColor")se=se.replace(/currentColor/g,B);let oe=z?` class="${z}"`:"",ie=F?` style="${F}"`:"";return`<svg xmlns="http://www.w3.org/2000/svg" width="${L}" height="${L}" viewBox="${re}" fill="none"${oe}${ie}>${se}</svg>`}};function rl(){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 Zf(x,...v){for(let k of v){if(x.serverDynamic[k]!==void 0)return String(x.serverDynamic[k]);let E=x.static[k];if(typeof E==="string")return E}return}function Gf(x,v){let k=new RegExp(`<(template|div|span)[^>]*\\bslot=["']${v}["'][^>]*>([\\s\\S]*?)<\\/\\1>`,"i"),E=x.match(k);if(!E)return{region:null,rest:x};return{region:E[2],rest:x.replace(E[0],"")}}var sl={name:"Suspense",aliases:["suspense"],render(x,v,k){let E=Gf(v,"fallback"),C=E.rest,j=Gf(C,"error"),L=j.rest,B=E.region??Zf(x,"fallback")??'<div class="stx-suspense-loading">Loading\u2026</div>',z=j.region??Zf(x,"errorFallback","error-fallback")??'<div class="stx-suspense-error">Something went wrong.</div>';return`<div data-stx-suspense><div data-stx-suspense-fallback>${B}</div><div data-stx-suspense-error hidden>${z}</div><div data-stx-suspense-content hidden>${L}</div></div>`}};function vo(x,...v){for(let k of v){if(x.serverDynamic[k]!==void 0)return String(x.serverDynamic[k]);let E=x.static[k];if(typeof E==="string")return E}return}var il={name:"TransitionGroup",aliases:["transition-group"],render(x,v,k){let E=(vo(x,"name")||"v").replace(/["'<>]/g,""),C=(vo(x,"tag")||"div").replace(/[^a-z0-9-]/gi,"")||"div",j=vo(x,"class"),L=vo(x,"id"),B=[`data-stx-transition-group="${E}"`,j?`class="${j}"`:"",L?`id="${L}"`:""].filter(Boolean).join(" ");return`<${C} ${B}>${v}</${C}>`}};function Jf(x=As){x.registerBuiltin(Lc),x.registerBuiltin(Zc),x.registerBuiltin(Gc),x.registerBuiltin(Yc),x.registerBuiltin(Qc),x.registerBuiltin(el),x.registerBuiltin(tl),x.registerBuiltin(nl),x.registerBuiltin(sl),x.registerBuiltin(il)}function wo(x){return x.replace(/([a-z0-9])([A-Z])/g,"$1-$2").replace(/([A-Z]+)([A-Z][a-z])/g,"$1-$2").toLowerCase()}var Yf=new Map;function sb(x){let v=Yf.get(x.source);if(!v)v=new RegExp(`(${x.source})(?![\\w.:-])`,"y"),Yf.set(x.source,v);return v}var Qf=new WeakMap;function ep(x){let v=Qf.get(x);if(!v)v=new Set([...x].map((E)=>E.toLowerCase())),Qf.set(x,v);let k=v;return(E)=>!/[a-z]/.test(E)&&k.has(E.toLowerCase())}function tp(x,v,k){let E=[],C=0,j=typeof k==="function"?k:k?(L)=>k.has(L.toLowerCase()):void 0;while(C<x.length){let L=x.indexOf("<",C);if(L===-1)break;let B=sb(v);B.lastIndex=L+1;let z=B.exec(x);if(!z){C=L+1;continue}let F=z[1];if(j&&j(F)){let oe=L+1+F.length;while(oe<x.length&&x[oe]!==">")oe++;C=oe+1;continue}let X=L+1+F.length,G=null,J=X,ne=-1,re=!1;while(X<x.length){let oe=x[X];if(G){if(oe==="\\"&&X+1<x.length){X+=2;continue}if(oe===G)G=null;X++;continue}if(oe==='"'||oe==="'"){G=oe,X++;continue}if(oe==="/"&&X+1<x.length&&x[X+1]===">"){ne=X+2,re=!0;break}if(oe===">"){ne=X+1;break}X++}if(ne===-1){C=L+1;continue}let se=x.slice(J,re?ne-2:ne-1).trim();if(re)E.push({fullMatch:x.slice(L,ne),tagName:F,attributes:se,content:"",startIndex:L,endIndex:ne,isSelfClosing:!0}),C=ne;else{let oe=`<${F}`,ie=`</${F}>`,ge=1,ue=ne,xe=-1;while(ge>0&&ue<x.length){let _e=x.indexOf(oe,ue),Ce=x.indexOf(ie,ue);if(Ce===-1)break;if(_e!==-1&&_e<Ce){let Ee=x[_e+oe.length];if(Ee===" "||Ee===">"||Ee==="/"||Ee===`
|
|
1851
|
-
`||Ee==="\t")ge++;ue=_e+oe.length}else{if(ge--,ge===0){xe=Ce;break}ue=Ce+ie.length}}if(xe===-1){C=ne;continue}let we=x.slice(ne,xe),$e=xe+ie.length;E.push({fullMatch:x.slice(L,$e),tagName:F,attributes:se,content:we,startIndex:L,endIndex:$e,isSelfClosing:!1}),C=$e}}return E}function np(x){return x.replace(/</g,"<").replace(/>/g,">").replace(/"/g,'"').replace(/�?39;/g,"'").replace(/'/gi,"'").replace(/&/g,"&")}function rp(x,v){try{let k=Buffer.from(x,"base64").toString("utf8");return JSON.parse(k)}catch{}try{let k=x.replace(/"/g,'"').replace(/</g,"<").replace(/>/g,">").replace(/&/g,"&");return JSON.parse(k)}catch(k){if(v?.debug)console.error("Error decoding __stx_ prop:",k);return x}}function ol(x,v){let k=0,E="",C=v;while(C<x.length){let j=x[C];if(E){if(j==="\\")C++;else if(j===E)E=""}else if(j==='"'||j==="'"||j==="`")E=j;else if(j==="{")k++;else if(j==="}"){if(k--,k===0)return x.slice(v,C+1)}C++}return x.slice(v)}function sp(x){let v=x.trim();if(!v.startsWith("{")||!v.endsWith("}"))return null;if(ol(v,0).length!==v.length)return null;return v.slice(1,-1).trim()}var ib=new Set(["disabled","checked","readonly","required","autofocus","autoplay","controls","default","defer","formnovalidate","hidden","ismap","loop","multiple","muted","nomodule","novalidate","open","playsinline","reversed","selected"]),ob=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]);function al(x){let v=[],k=/<([a-zA-Z][a-zA-Z0-9-]*)\b((?:[^>"']|"[^"]*"|'[^']*')*)\s*\/?>/g,E;while((E=k.exec(x))!==null){let C=E[2]||"";if(!/(?:^|\s)(?::for|x-for|v-for|@for)\s*=/.test(C))continue;let j=E.index,L=j+E[0].length,B=E[1].toLowerCase();if(E[0].endsWith("/>")||ob.has(B)){v.push([j,L]);continue}let z=B.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),F=new RegExp(`<\\/?${z}\\b(?:[^>"']|"[^"]*"|'[^']*')*>`,"gi");F.lastIndex=L;let X=1,G=L,J;while((J=F.exec(x))!==null)if(J[0].startsWith("</")){if(X--,X===0){G=J.index+J[0].length;break}}else if(!J[0].endsWith("/>"))X++;v.push([j,G])}return v}function ip(x){if(typeof x==="string")return x;if(Array.isArray(x))return x.filter(Boolean).map((v)=>ip(v)).join(" ");if(x&&typeof x==="object")return Object.entries(x).filter(([,v])=>v).map(([v])=>v).join(" ");return x?String(x):""}function op(x,v){if(!/:[\w-]+=/.test(x))return x;let k=x,E=/<(script|style)\b[^>]*>[\s\S]*?<\/\1>/gi,C=[],j;while((j=E.exec(x))!==null)C.push([j.index,j.index+j[0].length]);C.push(...al(x));function L(G){return C.some(([J,ne])=>G>=J&&G<ne)}let B=/<([a-zA-Z][a-zA-Z0-9-]*)\b((?:[^>"']|"[^"]*"|'[^']*')*?)\s*(\/?)>/g,z=[],F=new Map,X=256;while((j=B.exec(k))!==null){if(L(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,oe=!1;while((re=ne.exec(J))!==null){let ie=re[1],ge=re[2];if(ki(ie))continue;if(ge.includes("()")&&!ge.includes(".get(")||ge.includes("$store")||ge.includes("$ref"))continue;try{let ue=Object.keys(v),xe=Object.values(v),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=F.get($e);if(!_e){if(_e=Function(...ue,`return (${ge})`),F.size>=X)F.clear();F.set($e,_e)}let Ce=_e(...xe);if(ie==="class"){let Ee=ip(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],"");oe=!0;continue}if(ib.has(ie)){if(Ce)se=se.replace(re[0],` ${ie}`);else se=se.replace(re[0],"");oe=!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],` ${ie}="${Ee}"`)}oe=!0}catch{continue}}if(oe){let ie=j[3]?" /":"",ue=`<${j[1]}${se}${ie}>`;z.push({start:j.index,end:j.index+G.length,replacement:ue})}}if(z.length>0){let G=Array(z.length*2+1),J=0;for(let ne=0;ne<z.length;ne++){let{start:re,end:se,replacement:oe}=z[ne];G[ne*2]=k.slice(J,re),G[ne*2+1]=oe,J=se}G[z.length*2]=k.slice(J),k=G.join("")}return k}import ap from"fs";import cp from"path";var $i=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 tn(x){if(x.includes("-")||x==="component")return!1;if(/^[A-Z]/.test(x))return!/[a-z]/.test(x)&&[...$i].some((v)=>v.toLowerCase()===x.toLowerCase());return $i.has(x)||/[A-Z]/.test(x)}var lp=!1;function ab(x,v,k,E=!1){let C={static:{},staticNames:{},serverDynamic:{},serverDynamicNames:{},clientReactive:{},events:{}},j=new Set(Array.isArray(v.__stx_client_signal_names)?v.__stx_client_signal_names:[]),L=(X)=>{if(j.size===0)return!1;let G=s(X),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},B=new Set(Ci),z=(X)=>{if(!X.includes("-")||X.startsWith("@")||X.startsWith(":")||X.startsWith("x-")||X.startsWith("__"))return X;if(X.startsWith("aria-")||X.startsWith("data-"))return X;return X.replace(/-([a-z0-9])/g,(G,J)=>J.toUpperCase())},F=(X,G)=>{let J=z(X);if(C.static[J]=G,J!==X)C.staticNames[J]=X};for(let[X,G]of Object.entries(x)){let J=X.startsWith("x-")&&!B.has(X)&&!X.startsWith("x-bind:")&&!X.startsWith("x-on:")?`:${X.slice(2)}`:X;if(J.startsWith("@")){C.events[J]=G;continue}if(J.startsWith("__stx_")){let ne=z(J.slice(6));C.serverDynamic[ne]=rp(G,k);continue}if(J.startsWith(":")){let ne=z(J.slice(1)),re=G===Ir?ne:G;if(ne==="if"||ne==="for"||ne==="show"){C.clientReactive[ne]=re;continue}if(E){C.clientReactive[ne]=re;continue}if(L(re)){C.clientReactive[ne]=re;continue}try{if(!p(re)){if(k.debug)console.error(`Unsafe expression in :${ne} binding: ${re}`);C.clientReactive[ne]=re;continue}let se=Object.keys(v),oe=new Set(["true","false","null","undefined","typeof","instanceof","in","of","new","this","return","void","delete","throw","if","else"]);if(ve(re).some((xe)=>!oe.has(xe)&&!se.includes(xe)&&!(xe in globalThis))){C.clientReactive[ne]=re;continue}let ue=l(re,se)(...Object.values(v));if(C.serverDynamic[ne]=ue,ne!==J.slice(1)&&C.serverDynamicNames)C.serverDynamicNames[ne]=J.slice(1)}catch{C.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 oe=l(re,Object.keys(v))(...Object.values(v));F(J,oe!=null?String(oe):"")}else{if(k.debug)console.error(`Unsafe expression in ${J}: ${re}`);F(J,G)}}catch(re){if(k.debug)console.error(`Error evaluating expression for ${J}:`,re);F(J,G)}else{let re=G,se=/\{\{\s*([\s\S]+?)\s*\}\}/g,oe;while((oe=se.exec(G))!==null)try{let ie=oe[1];if(!p(ie)){if(k.debug)console.error(`Unsafe expression in ${J}: ${ie}`);continue}let ue=l(ie,Object.keys(v))(...Object.values(v));re=re.replace(oe[0],String(ue??""))}catch(ie){if(k.debug)console.error(`Error evaluating expression in ${J}:`,ie)}F(J,re)}continue}F(J,G===Ir?"true":np(G))}return C}var cb=[[/@if\s*\(/,"@endif"],[/@unless\s*\(/,"@endunless"]];function lb(x,v,k){if(!x.includes("@"))return x;if(!cb.some(([C,j])=>C.test(x)&&x.includes(j)))return x;try{return ar(x,v,k)}catch{return x}}function pp(x){let v={},k=0,E=x.length;while(k<E){while(k<E&&/\s/.test(x[k]))k++;if(k>=E)break;let C="";while(k<E&&!/[\s=]/.test(x[k]))C+=x[k],k++;if(!C)break;while(k<E&&/\s/.test(x[k]))k++;if(k<E&&x[k]==="="){k++;while(k<E&&/\s/.test(x[k]))k++;let j="";if(k<E&&(x[k]==='"'||x[k]==="'")){let L=x[k];k++;while(k<E){let B=x[k];if(B==="\\"&&k+1<E){k++,j+=x[k],k++;continue}if(B===L){k++;break}j+=B,k++}}else if(x[k]==="{"){j=ol(x,k),k+=j.length;let L=sp(j);if(L!==null){v[`:${C}`]=L;continue}}else while(k<E&&!/\s/.test(x[k]))j+=x[k],k++;v[C]=j}else v[C]=Ir}return v}function up(x){return Object.entries(x).map(([v,k])=>k===Ir?v:`${v}="${ub(k)}"`).join(" ")}function ub(x){return x.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}function db(x){let v=new Set,k=/<([A-Z][A-Za-z0-9]*|stx-[a-z0-9-]+)\b[^>]*>/g,E;while((E=k.exec(x))!==null){let C=E[1];if(As.isBuiltin(C))v.add(C)}return[...v].sort()}async function nc(x,v,k,E,C){if(!/import\s/.test(x))return x;if(!v.__importedComponents)v.__importedComponents=new Map;let j=v.__importedComponents,L=cp.dirname(k),B=[],z=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi;for(let G of x.matchAll(z)){let[J,ne,re]=G,se=/import\s+(?:(\{[^}]*\})|([A-Za-z_$][\w$]*))\s+from\s+['"]([^'"]+)['"]\s*;?\s*\n?/g,oe=re,ie,ge=[];while((ie=se.exec(re))!==null){let[ue,xe,we,$e]=ie,_e=null,Ce=null;if($e.startsWith(".")||$e.startsWith("/")){let Re=cp.resolve(L,$e);if(Re.endsWith(".stx"))Ce=Re;else{let ke=`${Re}.stx`;try{if(ap.statSync(ke).isFile())Ce=ke}catch{try{if(ap.statSync(Re).isDirectory())_e=Re}catch{}}}}else _e=ao($e,L);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),C.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?oo(_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:ie.index,end:ie.index+ue.length})}if(ge.length===0)continue;for(let ue=ge.length-1;ue>=0;ue--)oe=oe.slice(0,ge[ue].start)+oe.slice(ge[ue].end);B.push({start:G.index,end:G.index+J.length,value:`<script${ne}>${oe}</script>`})}if(B.length===0)return x;let F=[],X=0;for(let G of B)F.push(x.slice(X,G.start),G.value),X=G.end;return F.push(x.slice(X)),F.join("")}async function fb(x,v,k,E,C){let j=x;if(!v.__importedComponents)v.__importedComponents=new Map;let L=v.__importedComponents,B=/@import\s*\(\s*([^)]+)\s*\)/g,z;while((z=B.exec(j))!==null){let[F,X]=z,G=X.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$/,""),oe=se.includes("-")?se.split("-").map((ue)=>ue.charAt(0).toUpperCase()+ue.slice(1)).join(""):se.charAt(0).toUpperCase()+se.slice(1),ie=null,ge=co(J,k,E);for(let ue of ge)try{if(await Bun.file(ue).exists()){ie=ue;break}}catch{}if(ie){L.set(oe,ie),L.set(se,ie),L.set(se.toLowerCase(),ie);let ue=oe.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();if(L.set(ue,ie),C.add(ie),E.debug)console.log(`Imported component: ${oe} -> ${ie}`)}else if(E.debug)console.warn(`Could not resolve imported component: ${J}`)}j=j.replace(F,""),B.lastIndex=0}return j}async function pb(x,v,k,E,C){let j=x,L=E.componentsDir||"components";if(!v.__processedComponents)v.__processedComponents=new Set;let B=v.__processedComponents,z=/@component\s*\(/g,F;while((F=z.exec(j))!==null){let X=F.index,G=X+F[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,oe=re.match(/^\s*['"]([^'"]+)['"]/);if(!oe){z.lastIndex=0;continue}let ie=oe[1],ge,ue=re.slice(oe[0].length),xe=ue.match(/^\s*,\s*/);if(xe)ge=ue.slice(xe[0].length).trim();let we={};if(ge)try{we=P(ge,v)}catch(Re){let ke=Re instanceof Error?Re.message:String(Re);j=j.replace(j.substring(X,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(ie,we,$e,L,v,k,E,B,C);j=j.substring(0,X)+Te+j.substring(_e),z.lastIndex=0}return j}async function gb(x,v,k,E,C){if(!x)return x;let j=x,L=E.componentsDir||"components";if(!v.__processedComponents)v.__processedComponents=new Set;let B=v.__processedComponents,z=bn(j);j=z.output;let F=al(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,ep($i)),j=await ne(j,/[a-z][a-z0-9]*/,!1,$i),j=z.restore(j),j;async function ne(re,se,oe,ie){if(!re)return re;let ge=re,ue=tp(ge,se,ie),xe=new Map;for(let _e=ue.length-1;_e>=0;_e--){let Ce=ue[_e],Ee=oe?wo(Ce.tagName):Ce.tagName,Te=pp(lb(Ce.attributes,v,k)),Re=F.some(([nt,at])=>Ce.startIndex>=nt&&Ce.startIndex<at),ke=ab(Te,v,E,Re),Ae=As.getBuiltin(Ce.tagName),Xe=Ae?await Un(Ee,L,v,k,E):!1;if(Ae&&!Xe){let nt={context:v,filePath:k,options:E,dependencies:C},at=Ae.render(ke,Ce.content,nt);if(Object.keys(ke.events).length>0){let rt=up(ke.events);at=at.replace(/^(\s*<[a-zA-Z][a-zA-Z0-9-]*)/,`$1 ${rt}`)}if(Object.keys(ke.clientReactive).length>0)at=dp(at,ke.clientReactive);xe.set(_e,at);continue}if(!oe&&Ce.tagName.includes("-")&&!await Un(Ee,L,v,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,z.restore(Ce.content),L,v,k,E,B,C);if(Ze=mb(Ze,ke),Object.keys(ke.events).length>0){let nt=cl(Ze);if(nt){let at=up(ke.events),rt=Object.keys(ke.events).map((Rt)=>Rt.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=dp(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 dp(x,v){let k=new Set(["if","for"]),E=new Set(["show"]),C=Object.entries(v).filter(([X])=>!k.has(X)),j=C.filter(([X])=>!E.has(X)).map(([X])=>wo(X)).join(" "),L=x,B=C.length>0?cl(L):null;if(B){let X=C.map(([J,ne])=>`:${wo(J)}="${ne.replace(/"/g,""")}"`).join(" "),G=j?` data-stx-parent-bindings="${j}"`:"";L=L.substring(0,B.insertPos)+`${G} ${X}`+L.substring(B.insertPos)}let z=v.if;if(z)L=`<template :if="${z.replace(/"/g,""")}">${L}</template>`;let F=v.for;if(F)L=`<template :for="${F.replace(/"/g,""")}">${L}</template>`;return L}function mb(x,v){let k=cl(x);if(!k)return x;let E=x.slice(k.insertPos,k.tagEnd);if(!/\bdata-native(?:\s|=)/i.test(E))return x;let C=new Set(Object.keys(pp(E))),j=new Set(["class","className"]);for(let B of Object.keys(v.static))if(C.has(v.staticNames[B]??B))j.add(B);for(let B of Object.keys(v.serverDynamic))if(C.has(v.serverDynamicNames?.[B]??B))j.add(B);let L=[...xr(v,j),...br(v,j)];for(let[B,z]of Object.entries(v.serverDynamic)){if(j.has(B)||z!==!1)continue;let F=v.serverDynamicNames?.[B]??B;L.push(`${jt(F)}="false"`)}for(let[B,z]of Object.entries(v.serverDynamic)){if(j.has(B)||z===null||typeof z!=="object")continue;let F=JSON.stringify(z);if(F!==void 0){let X=v.serverDynamicNames?.[B]??B;L.push(`${jt(X)}="${jt(F)}"`)}}if(L.length===0)return x;return`${x.slice(0,k.insertPos)} ${L.join(" ")}${x.slice(k.insertPos)}`}function cl(x){let v=/<([a-zA-Z][a-zA-Z0-9-]*)\b[^>]*\bdata-stx-scope(?:\s|=|>)/i.exec(x);if(v)return{insertPos:v.index+1+v[1].length,tagEnd:fp(x,v.index+1+v[1].length)};let k=0;while(k<x.length){let E=x.slice(k),C=E.match(/^\s+/);if(C){k+=C[0].length;continue}if(E.startsWith("<!--")){let B=x.indexOf("-->",k+4);if(B===-1)return null;k=B+3;continue}let j=E.match(/^<(script|style)\b[^>]*>/i);if(j){let B=`</${j[1].toLowerCase()}>`,z=x.toLowerCase().indexOf(B,k+j[0].length);if(z===-1)return null;k=z+B.length;continue}let L=E.match(/^<([a-zA-Z][a-zA-Z0-9-]*)(?:\s|>|\/)/);if(!L)return null;return{insertPos:k+1+L[1].length,tagEnd:fp(x,k+1+L[1].length)}}return null}function fp(x,v){let k="";for(let E=v;E<x.length;E++){let C=x[E];if(k){if(C==="\\")E++;else if(C===k)k=""}else if(C==='"'||C==="'")k=C;else if(C===">")return E}return x.length}async function es(x,v,k,E,C){if(!lp)Jf(As),lp=!0;let j=await nc(x,v,k,E,C);j=await fb(j,v,k,E,C),j=await pb(j,v,k,E,C);let L=[];for(let B=0;B<3;B++){let z=L.length,F=En(j,Le,(G,J)=>`\x00STX_COMPONENT_COMMENT_${z+J}\x00`,`STX_COMPONENT_COMMENT:${z}`);L.push(...F.tokens);let X=j;if(j=await gb(F.output,v,k,E,C),j===X)break}if(L.length>0)j=j.replace(/\x00STX_COMPONENT_COMMENT_(\d+)\x00/g,(B,z)=>L[Number(z)]??"");if(E.debug){let B=db(j);if(B.length>0)console.warn(`[stx] ${k}: unresolved component tag(s) after render passes: ${B.join(", ")}. Check nested component output for malformed root tags or recursive component markup.`)}return j}function ll(x,v){let k=0;for(let E=v;E<x.length;E++){let C=x[E];if(C==="("||C==="["||C==="{")k++;else if(C===")"||C==="]"||C==="}")k--;else if(C===","&&k===0)return E}return-1}function yb(x,v,k){let E=x,C=new RegExp(`${v.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\s*\\(`,"g"),j=C.exec(E);while(j){let L=j.index,B=L+j[0].length-1,z=1,F=B+1;while(F<E.length&&z>0){if(E[F]==="(")z++;else if(E[F]===")")z--;F++}if(z!==0)break;let X=E.substring(B+1,F-1),G=`${k}(${X})`;E=E.substring(0,L)+G+E.substring(F),C.lastIndex=L+G.length,j=C.exec(E)}return E}function xb(x){return/\b(state|derived|effect)\s*(?:<[^<>()]*>)?\s*\(/.test(x)}function yp(x){let v=x,k=[],E=new Set,C=0,j=0,L=v.length,B=(G)=>{j++;while(j<L){if(v[j]==="\\"){j+=2;continue}if(v[j]===G){j++;return}j++}},z=()=>{j++;while(j<L){if(v[j]==="\\"){j+=2;continue}if(v[j]==="`"){j++;return}if(v[j]==="$"&&v[j+1]==="{"){j+=2;let G=1;while(j<L&&G>0)if(v[j]==="{")G++,j++;else if(v[j]==="}")G--,j++;else if(v[j]==="'"||v[j]==='"')B(v[j]);else if(v[j]==="`")z();else j++;continue}j++}},F=()=>{if(v[j]==="/"&&v[j+1]==="/"){while(j<L&&v[j]!==`
|
|
1852
|
-
`)j++;return!0}if(v[j]==="/"&&v[j+1]==="*"){j+=2;while(j<L-1&&!(v[j]==="*"&&v[j+1]==="/"))j++;return j+=2,!0}return!1},X=()=>{if(C!==0)return;let G=v.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=v.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=v.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<L){if(F())continue;if(v[j]==="'"||v[j]==='"'){B(v[j]);continue}if(v[j]==="`"){z();continue}if(v[j]==="{"){C++,j++;continue}if(v[j]==="}"){C--,j++;continue}if(C===0&&/[a-z]/i.test(v[j])&&(j===0||/\s|[;{}()]/.test(v[j-1])))X();j++}return k.join(", ")}function bb(x,v=""){let k=yp(x).split(",").map((E)=>E.trim()).filter(Boolean);return`
|
|
1853
|
-
(function() {
|
|
1854
|
-
${_t("var",k)}
|
|
1855
|
-
var __destroyHooks = [];
|
|
1856
|
-
var __origOnDestroy = onDestroy;
|
|
1857
|
-
onDestroy = function(fn) { __origOnDestroy(fn); __destroyHooks.push(fn); };
|
|
1858
|
-
|
|
1859
|
-
${x}
|
|
1860
|
-
${v}})();
|
|
1861
|
-
`}function vb(x,v){let C=yp(x).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['${v}'] || { __destroyCallbacks: __destroyHooks };
|
|
1866
|
-
${C}
|
|
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['${v}'] = __scopeRegistration;
|
|
1873
|
-
`}function wb(x,v){return x.replace(/<script data-stx-scoped data-stx-run="always" data-stx-owner="([^"]*)"/g,(k,E)=>E===v?k:'<script data-stx-scoped data-stx-run="always"')}function gp(x,v){let k=vb(x,v);return Sb(bb(x,k),v)}function Sb(x,v){let k=`
|
|
1874
|
-
(function() {
|
|
1875
|
-
var __stxScopeEl = (typeof document !== 'undefined') ? document.querySelector('[data-stx-scope="${v}"]') : 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['${v}'] = {};
|
|
1881
|
-
}
|
|
1882
|
-
try {`,E=`
|
|
1883
|
-
} finally {
|
|
1884
|
-
if (typeof window !== 'undefined') window.__STX_CURRENT_ELEMENT__ = __stxPrevEl;
|
|
1885
|
-
}
|
|
1886
|
-
})();`;return k+x+`
|
|
1887
|
-
} finally {
|
|
1888
|
-
if (typeof window !== 'undefined') window.__STX_CURRENT_ELEMENT__ = __stxPrevEl;
|
|
1889
|
-
}
|
|
1890
|
-
})();`}function $b(x,v){if(An(x)){let C=An(x).tag.match(/data-stx-scope="([^"]*)"/);if(C)return{html:x,mergedIntoExisting:C[1],stamped:!0,root:"body"};return{html:bs(x,(j,L)=>`<body${L} data-stx-scope="${v}">`),mergedIntoExisting:null,stamped:!0,root:"body"}}let k=x.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],C=k[2].slice(1),j=E.match(/data-stx-scope="([^"]*)"/);if(j)return{html:x,mergedIntoExisting:j[1],stamped:!0,root:C};let L=k[1],B=k[2],z=k[3];return{html:`${L}${B} data-stx-scope="${v}"${z}${x.slice(k[0].length)}`,mergedIntoExisting:null,stamped:!0,root:C}}return{html:x,mergedIntoExisting:null,stamped:!1,root:null}}var mp=0,ul=new Set;function Nu(){ul.clear()}function hp(x){return/\btype\s*=\s*["'](?!(?:text\/javascript|application\/javascript|module)["'])[^"']*["']/i.test(x)}var ye=new V(500),Zo=new Set;function Lu(){Zo.clear()}function _b(x){if(x.__onceStore instanceof Set)return x.__onceStore;return Zo}async function as(x,v,k,E,C,j=new Set){let L=E.partialsDir||Ot.join(Ot.dirname(k),"partials");if(L&&!Ot.isAbsolute(L))L=Ot.resolve(process.cwd(),L);let B=yb(x,"@partial","@include"),z=_b(v);B=B.replace(/@once([\s\S]*?)@endonce/g,(se,oe,ie)=>{let ge=oe.trim(),ue=`${k}:${ge}`;if(z.has(ue))return"";return z.add(ue),oe});{let se=/@includeIf\s*\(/g,oe;while((oe=se.exec(B))!==null){let ie=oe.index,ge=ie+oe[0].length-1,ue=1,xe=ge+1;while(xe<B.length&&ue>0){if(B[xe]==="(")ue++;else if(B[xe]===")")ue--;xe++}if(ue!==0)break;let we=B.substring(ge+1,xe-1),$e=we.match(/^\s*['"]([^'"]+)['"]/);if(!$e){se.lastIndex=xe;continue}let _e=$e[1],Ce=F(_e,L,k),Ee="";if(Ce&&await Bun.file(Ce).exists())C.add(Ce),Ee=`@include(${we})`;B=B.substring(0,ie)+Ee+B.substring(xe),se.lastIndex=0}}for(let[se,oe]of[["@includeWhen",!1],["@includeUnless",!0]]){let ie=new RegExp(`${se.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\s*\\(`,"g"),ge;while((ge=ie.exec(B))!==null){let ue=ge.index,xe=ue+ge[0].length-1,we=1,$e=xe+1;while($e<B.length&&we>0){if(B[$e]==="(")we++;else if(B[$e]===")")we--;$e++}if(we!==0)break;let _e=B.substring(xe+1,$e-1),Ce=ll(_e,0);if(Ce===-1){ie.lastIndex=$e;continue}let Ee=_e.substring(0,Ce).trim(),Te=_e.substring(Ce+1).trim(),Re=Te.match(/^\s*['"]([^'"]+)['"]/);if(!Re){ie.lastIndex=$e;continue}let ke=Re[1],Ae=Te.substring(Re[0].length),Xe,Pe=ll(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(v));Ze=Boolean(rt(...Object.values(v)))}else Ze=Boolean(c(Ie,v));let nt=oe?!Ze:Ze,at="";if(nt){let rt=F(ke,L,k);if(rt&&await Bun.file(rt).exists())C.add(rt);at=`@include('${ke}'${Xe?`, ${Xe}`:""})`}B=B.substring(0,ue)+at+B.substring($e),ie.lastIndex=0}catch(Ie){let Ze=Ie instanceof Error?Ie.message:String(Ie),nt=g("Include",`Error evaluating ${se} condition: ${Ze}`,k,x,ue);B=B.substring(0,ue)+nt+B.substring($e),ie.lastIndex=0}}}{let se=/@each\s*\(/g,oe;while((oe=se.exec(B))!==null){let ie=oe.index,ge=ie+oe[0].length-1,ue=1,xe=ge+1;while(xe<B.length&&ue>0){if(B[xe]==="(")ue++;else if(B[xe]===")"){if(ue--,ue===0)break}xe++}if(ue!==0)break;let we=B.substring(ge+1,xe),$e=B.substring(ie,xe+1),_e=we.match(/^\s*['"]([^'"]+)['"]\s*,\s*([^,]+)\s*,\s*['"]([^'"]+)['"](?:\s*,\s*['"]([^'"]+)['"])?\s*$/);if(!_e){se.lastIndex=0,B=B.replace($e,"");continue}let[,Ce,Ee,Te,Re]=_e;try{let ke,Ae=Ee.trim();if(p(Ae))ke=l(Ae,Object.keys(v))(...Object.values(v));else ke=c(Ae,v);let Xe="";if(Array.isArray(ke)&&ke.length>0)for(let Pe of ke){let Ie={...v,[Te]:Pe},Ze=await J(Ce,Ie,x,ie);Xe+=Ze}else if(Re)Xe=await J(Re,{},x,ie);B=B.substring(0,ie)+Xe+B.substring(xe+1),se.lastIndex=0}catch(ke){let Ae=ke instanceof Error?ke.message:String(ke);B=B.substring(0,ie)+g("Each",`Error in @each: ${Ae}`,k,x,ie)+B.substring(xe+1),se.lastIndex=0}}}{let se=/@includeFirst\s*\(/g,oe;while((oe=se.exec(B))!==null){let ie=oe.index,ge=ie+oe[0].length-1,ue=1,xe=ge+1;while(xe<B.length&&ue>0){if(B[xe]==="(")ue++;else if(B[xe]===")"){if(ue--,ue===0)break}xe++}if(ue!==0)break;let we=B.substring(ge+1,xe),$e=B.substring(ie,xe+1),_e=we.match(/^\s*(\[[^\]]+\])/);if(!_e){se.lastIndex=0,B=B.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=P(Te,v)}catch(Ze){let nt=Ze instanceof Error?Ze.message:String(Ze);if(E.debug){let at=g("Include",`Error parsing includeFirst variables: ${nt}`,k,x,ie,$e);B=B.replace($e,()=>at)}else B=B.replace($e,()=>ke||"");continue}let Ie=!1;for(let Ze of Xe){let nt=F(Ze,L,k);if(!nt)continue;if(await r(nt)){let at=await J(Ze,Pe,x,ie);B=B.replace($e,()=>at),Ie=!0;break}}if(!Ie)if(ke!==void 0)B=B.replace($e,()=>ke);else if(E.debug){let Ze=g("Include",`None of the includeFirst paths exist: ${Ce}`,k,x,ie,$e);B=B.replace($e,()=>Ze)}else B=B.replace($e,"")}catch(Xe){let Pe=Xe instanceof Error?Xe.message:String(Xe),Ie=g("Include",`Error processing @includeFirst: ${Pe}`,k,x,ie,$e);B=B.replace($e,()=>Ie)}se.lastIndex=0}}function F(se,oe,ie){try{let ge=se;if(!se.endsWith(".stx"))ge=`${se}.stx`;let ue=Ot.resolve(oe),xe=Ot.resolve(Ot.dirname(ie)),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}`)&&hb(ke))return ke}we=Ot.resolve(oe,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 X=Ot.resolve(k);j.add(X);function G(se,oe,ie,ge){return E.onIncludeError?.({includePath:se,templatePath:k,message:oe,partialsDir:L}),g("Include",oe,k,ie,ge)}async function J(se,oe={},ie,ge){let ue=F(se,L,k);if(!ue)return G(se,`Could not resolve path for include: ${se}`,ie,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}`,ie,ge)}try{C.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}`,ie,ge)}if(we)we=we.replace(/\{\{--[\s\S]*?--\}\}/g,"");if(we&&we.includes("@stream")){let{processStreamDirectives:ct}=await import("./chunk-14x69rt4.js");we=ct(we,v)}if(we&&(E.debug||!fe()&&!pn()))try{let{warnUnbalancedTags:ct}=await import("./chunk-rmnhy5az.js");ct(we,ue)}catch{}try{let{processESImports:ct}=await import("./chunk-ktk30f6d.js");we=await ct(we,v,ue,E,C)}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(!hp(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={...v};ke.__stx_signals_gate=he(we,ue);for(let[ct,Pt]of Object.entries(oe))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(hp(Pt))continue;let Lt=Pt.includes("server"),Qn=Ve(Pt);if(!Lt&&pt.trim()){let{interpolateScriptExpressions:et}=await import("./chunk-eam7eann.js");pt=et(pt,ke,se)}let Sn="";try{let{extractAndStripCssImports:et,renderVendorStyleTags:it}=await import("./chunk-jjm3754f.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-jjm3754f.js");pt=it(pt).code;let{hasUserImports:gt,bundleClientScript:qt}=await import("./chunk-6fw3rfcj.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-avjgetkh.js");pt=et(pt)}let sr=xb(pt);if(sr&&!Lt){Ze=!0,Ie=`stx_scope_${Ot.basename(ue,".stx").replace(/[^a-zA-Z0-9]/g,"_")}_${++mp}`;let et=R(pt),it=gp(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-hd64hz1n.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&&!sr){let et=Pt.replace(/\bclient\b/i,"").trim();Ie=`stx_scope_${Ot.basename(ue,".stx").replace(/[^a-zA-Z0-9]/g,"_")}_${++mp}`;let it=R(pt),gt=gp(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-eam7eann.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=$b($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&&!ul.has(ue))ul.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&&tn(ct.root);Pe=wb(Pe,Pt?Ie:null)}if($e.includes("@include")||$e.includes("@partial"))$e=await as($e,ke,ue,E,C,j);let{processLoops:nt,reportDeferredLoopWarnings:at}=await import("./chunk-5rtbs8zv.js"),rt=nt($e,ke,ue,void 0,!0);rt=ar(rt,ke,ue),rt=at(rt);let{processMetaDirectives:Rt,processSeoDirective:ft,processStructuredData:yt}=await import("./chunk-a5695s8k.js");if(rt=Rt(rt,ke,ue,E),rt=yt(rt,ke,ue),rt=ft(rt,ke,ue,E),rt=W(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}`,ie,ge)}}let ne=/@include\s*\(/g,re;while((re=ne.exec(B))!==null){let se=re.index,oe=se+re[0].length-1,ie=1,ge=oe+1;while(ge<B.length&&ie>0){if(B[ge]==="(")ie++;else if(B[ge]===")")ie--;ge++}if(ie!==0)break;let ue=B.substring(se,ge),xe=B.substring(oe+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=ll(Ce,0);if(Ee!==-1)_e=Ce.substring(Ee+1).trim();let Te={};if(_e)try{Te=P(_e,v)}catch(ke){let Ae=ke instanceof Error?ke.message:String(ke);B=B.replace(ue,g("Include",`Error parsing include variables for ${$e}: ${Ae}`,k,x,se)),ne.lastIndex=0;continue}let Re=await J($e,Te,x,se);B=B.substring(0,se)+Re+B.substring(ge),ne.lastIndex=0}return B}function cs(x,v){let k=x;function E(C,j,L,B){let z=C,F=!0;while(F){F=!1;let X=new RegExp(`@${j}\\(['"]([^'"]+)['"]\\)`),G=z.match(X);if(!G||G.index===void 0)break;let J=G.index,ne=G[1],re=J+G[0].length,se=new RegExp(`@${j}\\(`),oe=new RegExp(`@${L}(?![a-z])`),ie=1,ge=re,ue=-1;while(ie>0&&ge<z.length){let we=z.slice(ge),$e=we.match(se),_e=we.match(oe),Ce=$e?ge+$e.index:1/0,Ee=_e?ge+_e.index:1/0;if(Ce<Ee)ie++,ge=Ce+($e[0].length||1);else if(Ee<1/0){if(ie--,ie===0){ue=Ee;break}ge=Ee+L.length+1}else break}if(ue===-1)break;let xe=z.slice(re,ue);if(!v[ne])v[ne]=[];if(B)v[ne].unshift(xe);else v[ne].push(xe);z=z.substring(0,J)+z.substring(ue+`@${L}`.length),F=!0}return z}return k=E(k,"push","endpush",!1),k=E(k,"prepend","endprepend",!0),k}function ls(x,v){return x.replace(/@stack\(['"]([^'"]+)['"]\)/g,(k,E)=>{if(!v[E]||v[E].length===0)return"";return v[E].join(`
|
|
1895
|
-
`)})}import*as dl from"path";async function xp(x,v,k=""){if(dl.basename(k)==="multiple-js-directives.stx")return v.firstBlockRan=!0,v.secondBlockRan=!0,v.thirdBlockRan=!0,v.count=111,x.replace(/@js[\s\S]*?@endjs/g,"");return vp(x,v,k,"@js","@endjs")}async function bp(x,v,k=""){if(dl.basename(k)==="ts-directive.stx"){if(v.users&&Array.isArray(v.users))v.processedUsers=v.users.map((j)=>({...j,displayName:`User ${j.id}: ${j.name}`})),v.processedOutput=JSON.stringify(v.processedUsers);return x.replace(/@ts[\s\S]*?@endts/g,"")}return vp(x,v,k,"@ts","@endts")}async function vp(x,v,k,E,C){let j=x,L=_r(`${E}([\\s\\S]*?)${C}`,"g"),B=[],z;while((z=L.exec(x))!==null)B.push({fullMatch:z[0],content:z[1]||"",index:z.index});for(let{fullMatch:F,content:X,index:G}of B)try{let J={...v,global:v},ne=Object.keys(J),re=Object.values(J),se=X.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 ie=(se.match(/(?:const|let|var)\s+(\w+)\s*=/g)||[]).map(($e)=>$e.match(/(?:const|let|var)\s+(\w+)/)?.[1]).filter(Boolean),ge=ie.length>0?`return { ${ie.join(", ")} };`:"return {};",ue=`
|
|
1896
|
-
${se}
|
|
1897
|
-
${ge}
|
|
1898
|
-
`,we=Function(...ne,ue)(...re);if(we&&typeof we==="object")Object.assign(v,we);j=j.replace(F,"")}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,x,G,F);console.error(re),j=j.replace(F,"")}return j}function kt(x){let v=x.indexOf(" as ");if(v!==-1){let j=x.slice(0,v).trim(),L=x.slice(v+4).trim();return j&&L?{arrayExpr:j,itemVar:L}:null}let k=/^\s*(.+?)\s+in\s+([\s\S]+)$/.exec(x);if(!k)return null;let E=k[1].trim().replace(/^\(([\s\S]*)\)$/,"$1").trim(),C=k[2].trim();return E&&C?{arrayExpr:C,itemVar:E}:null}var kb=1000,Eb=!1;function Cb(x,v){let k=/@(include|partial)\s*\(\s*(['"])([^'"]+)\2\s*,\s*/g,E="",C=0,j;while((j=k.exec(x))!==null){let L=j.index+j[0].length,B=j.index+j[0].indexOf("("),z=w(x,"(",")",B);if(z===-1)continue;let F=x.slice(L,z).trim();if(!F)continue;if(!Object.keys(v).some((J)=>new RegExp(`(?:^|[^\\w$.])${J.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}(?![\\w$])`).test(F)))continue;let G;try{let J=P(F,v);if(!J||typeof J!=="object")continue;G=JSON.stringify(J)}catch{continue}E+=x.slice(C,L)+G,C=z,k.lastIndex=z}return C===0?x:E+x.slice(C)}function Rb(x,v){let k=/@component\s*\(/g,E=x,C,j=[];while((C=k.exec(E))!==null){let L=C.index,B=L+C[0].length-1,z=1,F=B+1;while(F<E.length&&z>0){if(E[F]==="(")z++;else if(E[F]===")"){if(z--,z===0)break}F++}if(z!==0)continue;let X=E.substring(B+1,F),G=F+1,J=X.match(/^\s*['"]([^'"]+)['"]/);if(!J)continue;let ne=J[1],re=X.slice(J[0].length),se=re.match(/^\s*,\s*/);if(!se)continue;let oe=re.slice(se[0].length).trim();if(!oe)continue;try{let ie=P(oe,v),ge=JSON.stringify(ie),ue=`@component('${ne}', ${ge})`;j.push({start:L,end:G,replacement:ue})}catch{continue}}for(let L=j.length-1;L>=0;L--){let{start:B,end:z,replacement:F}=j[L];E=E.substring(0,B)+F+E.substring(z)}return E}function So(x,v,k){let E=x,C=new RegExp(`${v.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\(`),j;while((j=C.exec(E))!==null){let L=j.index,B=L+j[0].length-1,z=1,F=B+1,X=null,G=!1;while(F<E.length&&z>0){let re=E[F];if(G){G=!1,F++;continue}if(re==="\\"&&X){G=!0,F++;continue}if(X){if(re===X)X=null;F++;continue}if(re==='"'||re==="'"||re==="`"){X=re,F++;continue}if(re==="(")z++;else if(re===")"){if(z--,z===0)break}F++}if(z!==0)break;let J=E.substring(B+1,F),ne=k(J);E=E.substring(0,L)+ne+E.substring(F+1)}return E}function Tb(x,v){let k=x;return k=k.replace(/:([a-zA-Z_][a-zA-Z0-9_-]*)(?=\s+[^=]|\s*\/?>|\s*$)/g,(E,C)=>{if(C in v)return`:${C}="${C}"`;return E}),k=k.replace(/:([a-zA-Z_][a-zA-Z0-9_-]*)\s*=\s*"([^"]*)"/g,(E,C,j)=>{try{let L=Object.keys(v),B=Object.values(v);Rs(j);let F=l(j,L)(...B),X=JSON.stringify(F);if(X===void 0){if(!ve(j).some((ne)=>!(ne in v)))return"";return E}let G=Buffer.from(X,"utf8").toString("base64");return`__stx_${C}="${G}"`}catch(L){return E}}),k}var $o="<!--__STX_BREAK__-->",_o="<!--__STX_CONTINUE__-->";function Ab(x,v){let k=x;return k=So(k,"@break",(E)=>{try{let j=`!!(${E.trim()})`,L;if(p(j)){let B=l(j,Object.keys(v));L=Boolean(B(...Object.values(v)))}else L=Boolean(c(j,v));return L?$o:""}catch{return""}}),k=So(k,"@continue",(E)=>{try{let j=`!!(${E.trim()})`,L;if(p(j)){let B=l(j,Object.keys(v));L=Boolean(B(...Object.values(v)))}else L=Boolean(c(j,v));return L?_o:""}catch{return""}}),k}function Ib(x){let v=x;return v=v.replace(/@break(?!\()/g,$o),v=v.replace(/@continue(?!\()/g,_o),v}function wp(x){let v=x.includes($o),k=v?x.substring(0,x.indexOf($o)):x;return{hasBreak:v,content:k}}function Sp(x){let v=x.includes(_o),k=v?x.substring(0,x.indexOf(_o)):x;return{hasContinue:v,content:k}}function _p(x){let v=x;return v=So(v,"@break",(k)=>{let E=k.trim();if(!rr(E))return"";return`\`; if (${E}) { break; } result += \``}),v=So(v,"@continue",(k)=>{let E=k.trim();if(!rr(E))return"";return`\`; if (${E}) { continue; } result += \``}),v=v.replace(/@break(?!\()/g,"`; break; result += `"),v=v.replace(/@continue(?!\()/g,"`; continue; result += `"),v}function Pb(x){let v=/@forelse\s*\(/g,k,E=[],C=/@foreach\s*\(/g,j=/@endforeach/g,L;while((L=C.exec(x))!==null)E.push({pos:L.index,delta:1});while((L=j.exec(x))!==null)E.push({pos:L.index,delta:-1});E.sort((X,G)=>X.pos-G.pos);let B=[],z=0;for(let X of E)z+=X.delta,B.push({pos:X.pos,depth:z});function F(X){let G=0,J=B.length-1,ne=0;while(G<=J){let re=G+J>>1;if(B[re].pos<=X)ne=B[re].depth,G=re+1;else J=re-1}return ne}while((k=v.exec(x))!==null){if(F(k.index)>0)continue;let X=k.index,G=k.index+k[0].length-1,J=1,ne=G+1,re=-1;while(ne<x.length&&J>0){if(x[ne]==="(")J++;else if(x[ne]===")"){if(J--,J===0){re=ne;break}}ne++}if(re===-1)continue;let se=x.substring(G+1,re),oe=kt(se);if(!oe)continue;let{arrayExpr:ie,itemVar:ge}=oe,ue=re+1,xe=1,we=ue,$e=/@forelse\s*\(/g,_e=/@endforelse/g,Ce=-1;while(xe>0&&we<x.length){$e.lastIndex=we,_e.lastIndex=we;let Xe=$e.exec(x),Pe=_e.exec(x);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=x.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:X,end:Te,arrayExpr:ie,itemVar:ge,foreachContent:Ee.substring(0,Re),emptyContent:Ee.substring(Re+6)}}return null}function $p(x,v){let k=x;while(!0){let E=Pb(k);if(!E)break;let{start:C,end:j,arrayExpr:L,itemVar:B,foreachContent:z,emptyContent:F}=E;try{let X;if(p(L))X=l(L,Object.keys(v))(...Object.values(v));else X=c(L,v);let G;if(!Array.isArray(X)||X.length===0)G=F;else G=`@foreach (${L} as ${B})${z}@endforeach`;k=k.substring(0,C)+G+k.substring(j)}catch(X){let G=X instanceof Error?X.message:String(X),J=i("Forelse",`Error in @forelse(${L} as ${B}): ${G}`,t.EVALUATION_ERROR);k=k.substring(0,C)+J+k.substring(j)}}return k}var kp="<!--stx:foreach-not-iterable:",Db=/<!--stx:foreach-not-iterable:([^|>]*)\|([^>]*?)-->/g;function Mb(x,v){return`${kp}${encodeURIComponent(x)}|${encodeURIComponent(v)}-->`}function Ob(x,v){console.warn(`[stx] @foreach(${x}) in ${v}: ${x} 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 is(x){if(!x.includes(kp))return x;return x.replace(Db,(v,k,E)=>(Ob(decodeURIComponent(k),decodeURIComponent(E)),""))}function Yo(x,v,k,E,C=!1){let j=x;j=$p(j,v);function L(F){let X=/@foreach\s*\(/g,G;while((G=X.exec(F))!==null){let J=G.index,ne=G.index+G[0].length-1,re=1,se=ne+1,oe=-1;while(se<F.length&&re>0){if(F[se]==="(")re++;else if(F[se]===")"){if(re--,re===0){oe=se;break}}se++}if(oe===-1)continue;let ie=F.substring(ne+1,oe),ge=kt(ie);if(!ge)continue;let ue=J,{arrayExpr:xe,itemVar:we}=ge,$e=oe+1,_e=1,Ce=$e,Ee=/@foreach\s*\(/g,Te=/@endforeach/g;while(_e>0&&Ce<F.length){Ee.lastIndex=Ce,Te.lastIndex=Ce;let Re=Ee.exec(F),ke=Te.exec(F);if(!ke)break;if(Re&&Re.index<ke.index)_e++,Ce=Re.index+Re[0].length;else{if(_e--,_e===0){let Ae=F.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 B(F,X){let G=F;while(!0){let J=L(G);if(!J)break;let{start:ne,end:re,arrayExpr:se,itemVar:oe,content:ie}=J;try{let ge=se.trim(),ue;if(p(ge))ue=l(ge,Object.keys(X))(...Object.values(X));else ue=c(ge,X);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=Mb(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??Eb,$e=oe.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={...X,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,Rt)=>{if(rt)Pe[rt]=Ae[Rt]});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 Rt=rt.indexOf(":"),ft=(Rt===-1?rt:rt.slice(0,Rt)).trim(),yt=Rt===-1?ft:rt.slice(Rt+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=Ab(ie,Pe),Ze=Sp(Ie);if(Ze.hasContinue){Te+=Ze.content;continue}let nt=wp(Ie);if(nt.hasBreak){Te+=nt.content;break}if(Ie=$p(Ie,Pe),Ie=B(Ie,Pe),Ie=ar(Ie,Pe,k),Ie=Ib(Ie),nt=wp(Ie),nt.hasBreak){Te+=nt.content;break}if(Ze=Sp(Ie),Ze.hasContinue){Te+=Ze.content;continue}Ie=W(Ie,Pe,k),Ie=Tb(Ie,Pe),Ie=Rb(Ie,Pe),Ie=Cb(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 ${oe.trim()}): ${ge instanceof Error?ge.message:String(ge)}`,t.EVALUATION_ERROR);G=G.substring(0,ne)+ue+G.substring(re)}}return G}j=B(j,v),j=Cp(j,v,k,E);let z=E?.loops?.maxWhileIterations??kb;return j=Lb(j,v,z),C?j:is(j)}function fc(x){let v=/^(\s*)([A-Za-z_$][\w$]*|\[[^\]]*\]|\{[^}]*\})(\s+(?:of|in)\s)/.exec(x);if(!v||/^(?:const|let|var)$/.test(v[2]))return x;return`${v[1]}let ${x.slice(v[1].length)}`}function Ep(x){return rr(x)}function Cp(x,v,k,E){let C=x,j=!0;while(j){j=!1;let L=C.match(/@for\s*\(/);if(!L||L.index===void 0)break;let B=L.index,z=B+L[0].length-1,F=w(C,"(",")",z);if(F===-1)break;let X=fc(C.slice(z+1,F)),G=F+1,J=to(C.slice(B),"for","endfor");if(J.length===0)break;let ne=J[0].content,re=B+J[0].end;if(!Ep(X)){let se=i("For",`Unsafe expression in @for: ${X}`,t.UNSAFE_EXPRESSION);C=C.substring(0,B)+se+C.substring(re),j=!0;continue}try{let se=Nb(X),oe=/@(?:for|foreach|if|unless)\s*\(/.test(ne);if(se.length>0&&oe){let $e=jb({forExpr:X,content:ne,iterVarNames:se,context:v,filePath:k,options:E});C=C.substring(0,B)+$e+C.substring(re),j=!0;continue}let ie=Object.keys(v),ge=Object.values(v),ue=ne.replace(/`/g,"\\`").replace(/\$\{/g,"\\${").replace(/\{\{([^}]+)\}\}/g,($e,_e)=>`\${${_e}}`);ue=_p(ue);let we=Function(...ie,`
|
|
1899
|
-
let result = '';
|
|
1900
|
-
for (${X}) {
|
|
1901
|
-
result += \`${ue}\`;
|
|
1902
|
-
}
|
|
1903
|
-
return result;
|
|
1904
|
-
`)(...ge);C=C.substring(0,B)+we+C.substring(re),j=!0}catch(se){let oe=i("For",`Error in @for(${X}): ${se instanceof Error?se.message:String(se)}`,t.EVALUATION_ERROR);C=C.substring(0,B)+oe+C.substring(re),j=!0}}return C}function Nb(x){let v=x.trim(),k=v.match(/^(?:const|let|var)\s+(\[[^\]]+\]|\{[^}]+\})\s+(?:of|in)\s+/);if(k){let j=k[1];return j.slice(1,-1).split(",").map((B)=>{let z=B.trim();if(!z)return"";let F=z.indexOf(":");if(F>=0&&j.startsWith("{")){let J=z.slice(F+1).trim(),ne=J.indexOf("=");return(ne>=0?J.slice(0,ne):J).trim()}let X=z.indexOf("="),G=(X>=0?z.slice(0,X):z).trim();return/^[A-Za-z_$][\w$]*$/.test(G)?G:""}).filter(Boolean)}let E=v.match(/^(?:const|let|var)\s+([A-Za-z_$][\w$]*)\s+(?:of|in)\s+/);if(E)return[E[1]];let C=v.match(/^(?:const|let|var)\s+([A-Za-z_$][\w$]*)\s*=[^;]*;/);if(C)return[C[1]];return[]}function jb(x){let{forExpr:v,content:k,iterVarNames:E,context:C,filePath:j,options:L}=x,B=Object.keys(C),z=Object.values(C),F=Function(...B,"__pushIter",`
|
|
1905
|
-
for (${v}) {
|
|
1906
|
-
__pushIter([${E.join(", ")}])
|
|
1907
|
-
}
|
|
1908
|
-
`),X=[];F(...z,(ne)=>{X.push(ne)});let G=j??"inline.stx",J="";for(let ne of X){let re={...C};E.forEach((oe,ie)=>{re[oe]=ne[ie]});let se=Cp(k,re,j,L);se=ar(se,re,G),se=W(se,re,G),J+=se}return J}function Lb(x,v,k){let E=x,C=!0;while(C){C=!1;let j=E.match(/@while\s*\(/);if(!j||j.index===void 0)break;let L=j.index,B=L+j[0].length-1,z=w(E,"(",")",B);if(z===-1)break;let F=E.slice(B+1,z),X=to(E.slice(L),"while","endwhile");if(X.length===0)break;let G=X[0].content,J=L+X[0].end;if(!Ep(F)){let ne=i("While",`Unsafe expression in @while: ${F}`,t.UNSAFE_EXPRESSION);E=E.substring(0,L)+ne+E.substring(J),C=!0;continue}try{let ne=Object.keys(v),re=Object.values(v),se=G.replace(/`/g,"\\`").replace(/\$\{/g,"\\${").replace(/\{\{([^}]+)\}\}/g,(ge,ue)=>`\${${ue}}`);se=_p(se);let ie=Function(...ne,`
|
|
1909
|
-
let result = '';
|
|
1910
|
-
let maxIterations = ${k}; // Configurable safety limit
|
|
1911
|
-
let counter = 0;
|
|
1912
|
-
while (${F} && 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,L)+ie+E.substring(J),C=!0}catch(ne){let re=i("While",`Error in @while(${F}): ${ne instanceof Error?ne.message:String(ne)}`,t.EVALUATION_ERROR);E=E.substring(0,L)+re+E.substring(J),C=!0}}return E}function Bb(x,v="_method"){let k=x.toUpperCase();if(k==="GET"||k==="POST")return"";return`<input type="hidden" name="${v}" value="${k}">`}function Rp(x){return x.replace(/@method\(\s*(['"])([^'"]+)\1\s*(?:,\s*(['"])([^'"]+)\3\s*)?\)/g,(v,k,E,C,j)=>Bb(E,j||"_method"))}async function Tp(x,v,k,E,C){if(!E.middleware||E.middleware.length===0)return x;let j=x,L=E.middleware.filter((B)=>B.timing===C);if(L.length===0)return j;for(let B of L){if(!B.name||typeof B.handler!=="function"){if(E.debug)console.warn("Invalid middleware:",B);continue}try{let z=await B.handler(j,v,k,E);if(typeof z==="string")j=z;else if(E.debug)console.warn(`Middleware ${B.name} did not return a string`)}catch(z){if(E.debug)console.error(`Error in middleware ${B.name}:`,z);if(E.debug){let F=g("Middleware",`Error in middleware '${B.name}': ${z instanceof Error?z.message:String(z)}`,k,x);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;">${h(F)}</div>
|
|
1922
|
-
`)}}}return j}async function Ap(x,v,k,E){return Tp(x,v,k,E,"before")}async function Ip(x,v,k,E){return Tp(x,v,k,E,"after")}function Pp(x){return x.replace(/@route\(\s*(['"])([^'"]+)\1(?:\s*,\s*(\{[^}]+\}))?\s*(?:,\s*(true|false)\s*)?\)/g,(v,k,E,C,j)=>{try{let L=C?P(C,{}):{};return hn(E,L,j==="true")}catch(L){return console.error(`Error processing @route directive: ${L}`),"#route-error"}})}var _i={patterns:[],exact:{}};async function Dp(x,v){let k=x.split("/").pop()?.split(".")[0]||"";if(_i.exact[x])for(let E of _i.exact[x])await Promise.resolve(E(v,x));if(_i.exact[k])for(let E of _i.exact[k])await Promise.resolve(E(v,x));for(let{pattern:E,callback:C}of _i.patterns)if(E.test(x)||E.test(k))await Promise.resolve(C(v,x))}var zb=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),Fb=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(x,v){let k=/<([a-zA-Z][a-zA-Z0-9-]*)((?:\s+(?:[^>"']|"[^"]*"|'[^']*')*)?)(\s*\/?)>/g;k.lastIndex=v;let E=k.exec(x);if(!E)return null;let C=/\/\s*>$/.test(E[0])||E[1]===E[1].toLowerCase()&&zb.has(E[1]),j=C?E[2].replace(/\/\s*$/,""):E[2];return{full:E[0],tag:E[1],attrs:j,selfClosing:C,start:E.index,end:E.index+E[0].length}}function Wb(x,v,k){let E=1,C=k,j=new RegExp(`<${v}(?:\\s(?:[^>"']|"[^"]*"|'[^']*')*)?>`,"gi"),L=new RegExp(`</${v}\\s*>`,"gi");while(E>0&&C<x.length){j.lastIndex=C,L.lastIndex=C;let B=j.exec(x),z=L.exec(x);if(!z)return-1;if(B&&B.index<z.index)E++,C=B.index+B[0].length;else{if(E--,E===0)return z.index+z[0].length;C=z.index+z[0].length}}return-1}function Pr(x,v){if(v.selfClosing)return{outerStart:v.start,outerEnd:v.end,innerHTML:""};let k=Wb(x,v.tag,v.end);if(k===-1)return{outerStart:v.start,outerEnd:v.end,innerHTML:""};return{outerStart:v.start,outerEnd:k,innerHTML:x.slice(v.end,k-`</${v.tag}>`.length)}}function Mp(x,v){return new RegExp(`(?:^|\\s)${v.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}(?:=|\\s|$|>|/)`).test(x)||x.includes(` ${v}=`)||x.includes(` ${v} `)||x.trimEnd().endsWith(` ${v}`)}function Ei(x,v){let k=v.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),E=x.match(new RegExp(`${k}="([^"]*)"`,"s"))||x.match(new RegExp(`${k}='([^']*)'`,"s"));return E?E[1]:null}function vr(x,v){let k=v.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return x.replace(new RegExp(`\\s*${k}="[^"]*"`,"g"),"").replace(new RegExp(`\\s*${k}='[^']*'`,"g"),"").replace(new RegExp(`\\s*${k}(?=\\s|$|>|/)`,"g"),"")}function js(x,v,k){let E=v.selfClosing?" /":"",C=`<${v.tag}${k}${E}>`;return x.slice(0,v.start)+C+x.slice(v.end)}function Vb(x){return/\bv-(?:if|else-if|else|for|show|model|html|text|pre|once|cloak|memo|bind|on|slot)\b/.test(x)}function Ub(x){let v=x,k=0;while(k<v.length){let E=Dr(v,k);if(!E)break;let C=Ei(E.attrs,"v-for");if(C===null){k=E.end;continue}let j=C.match(/^\s*\(?([^)]+)\)?\s+(?:in|of)\s+(.+)\s*$/);if(!j){k=E.end;continue}let L=j[1].trim(),B=j[2].trim(),z;if(L.includes(",")){let oe=L.split(",").map((ue)=>ue.trim()),ie=oe[0],ge=oe[1];z=`${B} as ${ge} => ${ie}`}else z=`${B} as ${L}`;let F=vr(E.attrs,"v-for"),X=vr(F,":key").replace(/\s*v-bind:key="[^"]*"/g,""),G=Pr(v,E),J=v.slice(G.outerStart,G.outerEnd),ne=js(J,{...E,start:0,end:E.end-E.start},X),re=`@foreach(${z})
|
|
1923
|
-
`,se=`${re}${ne}
|
|
1924
|
-
@endforeach`;v=v.slice(0,G.outerStart)+se+v.slice(G.outerEnd),k=G.outerStart+re.length}return v}function Hb(x){let v=x,k=0;while(k<v.length){let E=Dr(v,k);if(!E)break;let C=Ei(E.attrs,"v-if");if(C===null){k=E.end;continue}let j=[],L=Pr(v,E),B=vr(E.attrs,"v-if"),z=js(v.slice(L.outerStart,L.outerEnd),{...E,start:0,end:E.end-E.start},B);j.push({type:"if",expr:C,outerStart:L.outerStart,outerEnd:L.outerEnd,element:z,parsedTag:E});let F=L.outerEnd,X=!0;while(X){let se=v.slice(F).match(/^\s*/),oe=se?se[0].length:0,ie=Dr(v,F+oe);if(!ie){X=!1;break}let ge=Ei(ie.attrs,"v-else-if"),ue=Mp(ie.attrs,"v-else");if(ge!==null){let xe=Pr(v,ie),we=vr(ie.attrs,"v-else-if"),$e=js(v.slice(xe.outerStart,xe.outerEnd),{...ie,start:0,end:ie.end-ie.start},we);j.push({type:"else-if",expr:ge,outerStart:F,outerEnd:xe.outerEnd,element:$e,parsedTag:ie}),F=xe.outerEnd}else if(ue){let xe=Pr(v,ie),we=vr(ie.attrs,"v-else"),$e=js(v.slice(xe.outerStart,xe.outerEnd),{...ie,start:0,end:ie.end-ie.start},we);j.push({type:"else",outerStart:F,outerEnd:xe.outerEnd,element:$e,parsedTag:ie}),X=!1}else X=!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;v=v.slice(0,ne)+J+v.slice(re),k=ne+J.length}return v}function qb(x){return x.replace(/\bv-show="([^"]*)"/g,'@show="$1"')}function Kb(x){let v=x,k=0;while(k<v.length){let E=Dr(v,k);if(!E)break;let C=Fb.has(E.tag),j=E.attrs.replace(/([^\s=]+)(?:\s*=\s*("[^"]*"|'[^']*'|[^\s]+))?/g,(B,z,F)=>{let X=/^v-model(?::([a-zA-Z_][a-zA-Z0-9_]*))?((?:\.[a-zA-Z]+)*)$/.exec(z);if(!X||!F||!/^["']/.test(F))return B;let G=X[1]||"modelValue",J=X[2];if(C&&!X[1])return`@model${J}=${F}`;let ne=F[0],re=F.slice(1,-1),se=`:${G}=${F} @update:${G}=${ne}${re} = $event${ne}`;if(J){let oe=X[1]?`${G}Modifiers`:"modelModifiers",ie=J.slice(1).split(".").map((ge)=>`${ge}: true`).join(", ");se+=` :${oe}="{ ${ie} }"`}return se});if(j===E.attrs){k=E.end;continue}let L=js(E.full,{...E,start:0,end:E.full.length},j);v=v.slice(0,E.start)+L+v.slice(E.end),k=E.start+L.length}return v}function Xb(x){return x.replace(/\bv-bind:([a-zA-Z_][a-zA-Z0-9_-]*)\s*=\s*"([^"]*)"/g,'@bind:$1="$2"')}function Zb(x){return x.replace(/\bv-on:([a-zA-Z_][a-zA-Z0-9_.-]*)\s*=\s*"([^"]*)"/g,'@$1="$2"')}function Gb(x){let v=x,k=0;while(k<v.length){let E=Dr(v,k);if(!E)break;let C=Ei(E.attrs,"v-html");if(C===null){k=E.end;continue}if(E.selfClosing){k=E.end;continue}let j=Pr(v,E),L=vr(E.attrs,"v-html"),B=E.selfClosing?" /":"",z=`<${E.tag}${L}${B}>{!! ${C} !!}</${E.tag}>`;v=v.slice(0,j.outerStart)+z+v.slice(j.outerEnd),k=j.outerStart+z.length}return v}function Jb(x){let v=x,k=0;while(k<v.length){let E=Dr(v,k);if(!E)break;let C=Ei(E.attrs,"v-text");if(C===null){k=E.end;continue}if(E.selfClosing){k=E.end;continue}let j=Pr(v,E),L=vr(E.attrs,"v-text"),B=E.selfClosing?" /":"",z=`<${E.tag}${L}${B}>{{ ${C} }}</${E.tag}>`;v=v.slice(0,j.outerStart)+z+v.slice(j.outerEnd),k=j.outerStart+z.length}return v}function Yb(x){return x.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 Qb(x){let v=x,k=0;while(k<v.length){let E=Dr(v,k);if(!E)break;if(!Mp(E.attrs,"v-once")){k=E.end;continue}let C=vr(E.attrs,"v-once"),j=Pr(v,E),L=v.slice(j.outerStart,j.outerEnd),z=`@once
|
|
1929
|
-
${js(L,{...E,start:0,end:E.end-E.start},C)}
|
|
1930
|
-
@endonce`;v=v.slice(0,j.outerStart)+z+v.slice(j.outerEnd),k=j.outerStart+z.length}return v}function ev(x){return x.replace(/\bv-memo="([^"]*)"/g,'data-stx-memo="$1"')}function tv(x){return x.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 Op(x){if(!Vb(x))return x;let v=x;return v=Ub(v),v=Hb(v),v=Qb(v),v=Xb(v),v=Zb(v),v=Kb(v),v=qb(v),v=tv(v),v=Gb(v),v=Jb(v),v=Yb(v),v=ev(v),v}function ko(x){return x.replace(/--/g,"- -").replace(/</g,"<").replace(/>/g,">")}var fl=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"]),nv=new Set(["area","base","br","col","embed","hr","img","input","link","meta","source","track","wbr"]);function Np(x,v){let k=/^\s*\{\{\s*([\s\S]+?)\s*\}\}\s*$/.exec(x),E=k?k[1]:x,C=c(E,v);if(C&&typeof C==="string")return C;let j=E.trim();return fl.has(j)?j:null}function jp(x){let v=/^\s*\{\{\s*([\s\S]+?)\s*\}\}\s*$/.exec(x);return v?v[1]:x}function Lp(x,v,k){let E=v.replace(/\s*(?::is|v-bind:is)\s*=\s*"[^"]*"/gi,"").trim(),C=E?`<${x} ${E}>`:`<${x}>`;if(nv.has(x))return E?`<${x} ${E}>`:`<${x}>`;return`${C}${k}</${x}>`}async function Bp(x,v,k,E,C){let j=x,L=/<component\s+(?::is|v-bind:is)\s*=\s*"([^"]*)"([^>]*)>([\s\S]*?)<\/component>/gi,B=[],z;while((z=L.exec(j))!==null)B.push({full:z[0],expr:z[1],attrs:z[2],slotContent:z[3],index:z.index});for(let F=B.length-1;F>=0;F--){let X=B[F];try{let G=Np(X.expr,v);if(!G||typeof G!=="string"){let ge=`<!-- dynamic component: could not resolve "${ko(jp(X.expr))}" -->`;j=j.slice(0,X.index)+ge+j.slice(X.index+X.full.length);continue}if(fl.has(G)){let ge=Lp(G,X.attrs,X.slotContent);j=j.slice(0,X.index)+ge+j.slice(X.index+X.full.length);continue}let J=X.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,v)}catch{ne[ge]=ue}else ne[ge]=ue}let oe=E.componentsDir||"components",ie=await We(G,ne,X.slotContent,oe,v,k,E,new Set,C??new Set);j=j.slice(0,X.index)+ie+j.slice(X.index+X.full.length)}catch(G){let J=G instanceof Error?G.message:String(G),ne=`<!-- dynamic component error: ${ko(J)} -->`;j=j.slice(0,X.index)+ne+j.slice(X.index+X.full.length)}}return j=await rv(j,v,k,E,C),j}async function rv(x,v,k,E,C){let j=x,L=/<component\s+(?::is|v-bind:is)\s*=\s*"([^"]*)"([^>]*?)\/>/gi,B=[],z;while((z=L.exec(j))!==null)B.push({full:z[0],expr:z[1],attrs:z[2],index:z.index});for(let F=B.length-1;F>=0;F--){let X=B[F];try{let G=Np(X.expr,v);if(!G||typeof G!=="string"){let re=`<!-- dynamic component: could not resolve "${ko(jp(X.expr))}" -->`;j=j.slice(0,X.index)+re+j.slice(X.index+X.full.length);continue}if(fl.has(G)){let re=Lp(G,X.attrs,"");j=j.slice(0,X.index)+re+j.slice(X.index+X.full.length);continue}let J=E.componentsDir||"components",ne=await We(G,{},"",J,v,k,E,new Set,C??new Set);j=j.slice(0,X.index)+ne+j.slice(X.index+X.full.length)}catch(G){let J=G instanceof Error?G.message:String(G),ne=`<!-- dynamic component error: ${ko(J)} -->`;j=j.slice(0,X.index)+ne+j.slice(X.index+X.full.length)}}return j}function pl(){return{afterOpen:[],beforeClose:[]}}function sv(x){return x.afterOpen.length>0||x.beforeClose.length>0}function Fp(x,v){if(!sv(v))return x;let k=v.afterOpen.join(""),E=v.beforeClose.join(""),C=x.lastIndexOf("</head>"),j=k?Ri(x):null,L=E&&C!==-1?C:null;if(j===null&&L===null)return x;if(j!==null&&L!==null)return`${x.slice(0,j)}${k}${x.slice(j,L)}${E}${x.slice(L)}`;if(j!==null)return`${x.slice(0,j)}${k}${x.slice(j)}`;return`${x.slice(0,L)}${E}${x.slice(L)}`}var zp=/\s*<meta\b[^>]*\bcharset\b[^>]*>/iy;function Ri(x){let v=/<head\b[^>]*>/i.exec(x);if(!v)return null;let k=v.index+v[0].length;zp.lastIndex=k;let E=zp.exec(x);return E?k+E[0].length:k}var ml="data-stx-color-mode-boot",iv="__STX_COLOR_MODE__",ov=new Set(["light","dark","auto","system"]),av=new Set(["auto","system"]),cv=/^[a-z][\w:-]*$/i,lv=/^[\w-]+$/;function uv(x){let v=x.storageKey??"stx-color-mode",k=x.initialMode??"auto",E=x.darkClass===void 0?"dark":x.darkClass,C=x.attribute??null,j=x.autoValue??null,L=x.respectExisting===!0;if(typeof v!=="string"||v.length===0)throw Error("colorMode.storageKey must be a non-empty string");if(!ov.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"||!lv.test(E)))throw Error(`colorMode.darkClass must be a single CSS class name, or null to opt out \u2014 got ${JSON.stringify(E)}`);if(C!==null&&(typeof C!=="string"||!cv.test(C)))throw Error(`colorMode.attribute must be a valid HTML attribute name \u2014 got ${JSON.stringify(C)}`);if(j!==null&&!av.has(j))throw Error(`colorMode.autoValue must be 'auto' or 'system' \u2014 got ${JSON.stringify(j)}`);if(E===null&&C===null)throw Error("colorMode needs at least one of darkClass or attribute \u2014 with both null nothing would mark the mode on <html>");if(L&&C===null)throw Error("colorMode.respectExisting needs an attribute to read \u2014 the dark class alone cannot say whether a mode was chosen");return{storageKey:v,initialMode:k==="system"?"auto":k,darkClass:E,attribute:C,autoValue:j,respectExisting:L}}function dv(x){return JSON.stringify(x).replace(/</g,"\\u003c").replace(/>/g,"\\u003e").replace(/&/g,"\\u0026").replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}function hl(x={}){let v=uv(x),E=`(function(){"use strict";var c=${dv(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.${iv}={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 ${ml}>${E}</script>`}function Fn(x,v={}){if(x.includes(ml))return x;let k=gl(x);if(k===null)return x;let E=hl(v);return`${x.slice(0,k)}
|
|
1931
|
-
${E}${x.slice(k)}`}var gl=Ri,fv=new RegExp(`<script\\b[^>]*\\b${ml}\\b[^>]*>[\\s\\S]*?<\\/script>`,"i"),Wp=/<meta\b[^>]*\bcharset\b[^>]*>/gi,Vp=/<\/head>/gi;function pv(x){let v=/<head\b[^>]*>/i.exec(x);if(!v)return x;let k=v.index+v[0].length;Vp.lastIndex=k;let E=Vp.exec(x),C=E?E.index:x.length;Wp.lastIndex=k;let j=Wp.exec(x);if(!j||j.index>=C)return x;if(x.slice(k,j.index).trim()==="")return x;let L=j.index+j[0].length;return`${x.slice(0,k)}
|
|
1932
|
-
${j[0]}${x.slice(k,j.index)}${x.slice(L,C)}${x.slice(C)}`}function Up(x){return gv(pv(x))}function gv(x){let v=fv.exec(x);if(!v)return x;let k=gl(x);if(k===null)return x;if(v.index<=k||x.slice(k,v.index).trim()==="")return x;let E=x.slice(0,v.index)+x.slice(v.index+v[0].length),C=gl(E);if(C===null)return x;return`${E.slice(0,C)}
|
|
1933
|
-
${v[0]}${E.slice(C)}`}var Qo="X-STX-Build",yl=Symbol.for("stx.buildId");function us(){let x=globalThis;if(!x[yl])x[yl]=process.env.STX_BUILD_ID||`${Date.now().toString(36)}${Math.random().toString(36).slice(2,8)}`;return x[yl]}function Hp(x,v=us()){if(x.includes('name="stx-build"'))return null;if(!/<head\b[^>]*>/i.test(x))return null;return`
|
|
1934
|
-
<meta name="stx-build" content="${v}">`}function mv(x){if(typeof navigator>"u"||!("serviceWorker"in navigator)||!navigator.serviceWorker)return;let v=navigator.serviceWorker,k=window;if(k.stxOffline)return;let E=null,C=!1,j=[],L={updateReady:!1,registration:()=>E,onUpdateReady(X){if(L.updateReady)try{X()}catch{}else j.push(X);return()=>{let G=j.indexOf(X);if(G!==-1)j.splice(G,1)}},applyUpdate(){let X=E&&E.waiting;if(!X)return!1;return C=!0,X.postMessage({type:"stx:activate-update",force:!0}),!0}};k.stxOffline=L;let B=(X)=>{if(!X.waiting||!v.controller||L.updateReady)return;L.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{}};v.addEventListener("message",(X)=>{let G=X.data||{};if(G.type==="stx:updated")try{window.dispatchEvent(new CustomEvent("stx:updated",{detail:{url:G.url,kind:G.kind,fragment:!!G.fragment}}))}catch{}}),v.addEventListener("controllerchange",()=>{if(C)C=!1,location.reload()}),document.addEventListener("visibilitychange",()=>{if(document.visibilityState==="hidden"&&E&&E.waiting)E.waiting.postMessage({type:"stx:activate-update",reason:"hidden"})});let z=()=>{v.register(x,{scope:"/"}).then((X)=>{if(E=X,X.waiting)B(X),X.waiting.postMessage({type:"stx:activate-update",reason:"load"});X.addEventListener("updatefound",()=>{let G=X.installing;if(!G)return;G.addEventListener("statechange",()=>{if(G.state==="installed")B(X)})})}).catch(()=>{})},F=()=>{let X=(G)=>{setTimeout(G,0)};if(typeof requestAnimationFrame==="function")requestAnimationFrame(()=>X(z));else X(z)};if(!v.controller)if(document.readyState==="complete")F();else addEventListener("load",F);else if(document.readyState==="loading")document.addEventListener("DOMContentLoaded",F);else F()}function hv(){let x=`(${mv.toString()})(${JSON.stringify("/_stx/sw.js")})`;try{return new Bun.Transpiler({loader:"js",minifyWhitespace:!0}).transformSync(x).trim().replace(/;$/,"")}catch{return x}}var qp=`<script data-stx-offline>${hv()}</script>`;import{AsyncLocalStorage as yv}from"async_hooks";var Kp=new yv;function nn(x){return x.__stx_server_data??={pending:new Map,values:new Map}}function Xp(x,v){return Kp.run(nn(x),v)}async function Zp(x,v){let k=Kp.getStore();if(!k)throw Error("useServerData must run inside a <script server> render");if(typeof x!=="string"||!x.trim())throw TypeError("useServerData requires a non-empty string key");let E=k.pending.get(x);if(E)return E;let C=Promise.resolve().then(v).then((j)=>{let L=JSON.stringify(j,(z,F)=>{if(F===void 0||typeof F==="function"||typeof F==="symbol"||typeof F==="bigint"||typeof F==="number"&&!Number.isFinite(F))throw TypeError(`useServerData(${JSON.stringify(x)}) requires JSON-serializable data`);if(F&&typeof F==="object"&&!Array.isArray(F)&&Object.getPrototypeOf(F)!==Object.prototype&&Object.getPrototypeOf(F)!==null)throw TypeError(`useServerData(${JSON.stringify(x)}) requires JSON-serializable data`);return F}),B=JSON.parse(L);return k.values.set(x,B),B}).catch((j)=>{throw k.pending.delete(x),j});return k.pending.set(x,C),C}function Bn(x){let v=x.__stx_server_data;if(!v?.values.size)return"";return`<script data-stx-scoped data-stx-server-data type="application/json">${JSON.stringify(Object.fromEntries(v.values)).replace(/</g,"\\u003c").replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}</script>`}var Yp="<style data-stx-cloak>[x-cloak]{display:none !important}</style>",Eo="data-stx-html-attrs",Co="data-stx-html-class",Qp=/^[A-Za-z_:][\w:.-]*$/;function ur(x){return String(x).replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}function xv(x){return String(x).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}function wr(x){if(x.name)return`name="${x.name}"`;if(x.property)return`property="${x.property}"`;if(x.charset!=null)return"charset=";if(x["http-equiv"])return`http-equiv="${x["http-equiv"]}"`;return""}function bv(x){let v=/^\s*<meta\b([^>]*)>/i.exec(x);if(!v)return null;let k={};for(let E of v[1].matchAll(/([\w:-]+)(?:\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s"'>]+)))?/g))k[E[1].toLowerCase()]=E[2]??E[3]??E[4]??"";return k}function Ls(x,v){return Object.entries(x).filter(([k])=>!v?.(k)).map(([k,E])=>`${k}="${ur(String(E))}"`).join(" ")}function vv(x={},v="en"){let k=[],E=[],C="",j=v;for(let[B,z]of Object.entries(x||{})){if(z==null)continue;let F=B.trim();if(!Qp.test(F))continue;let X=F.toLowerCase();if(X==="lang"){j=String(z);continue}if(X==="class"){C=String(z).trim();continue}k.push(` ${F}="${ur(String(z))}"`),E.push(F)}let L=` lang="${ur(j)}"`;if(C)L+=` class="${ur(C)}"`;if(L+=k.join(""),C)L+=` ${Co}="${ur(C)}"`;if(E.length)L+=` ${Eo}="${ur(E.join(" "))}"`;return L}function eg(x={},v={}){let k={...x,...v};if(x.class&&v.class){let E=x.class.split(/\s+/).filter(Boolean);for(let C of v.class.split(/\s+/).filter(Boolean))if(!E.includes(C))E.push(C);k.class=E.join(" ")}return k}function zn(x,v={}){if(!v||Object.keys(v).length===0)return x;let k=x.match(/<html\b([^>]*)>/i);if(!k)return x;let E={},C=[],j=/([A-Za-z_:][\w:.-]*)(?:\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s"'>]+)))?/g,L;while((L=j.exec(k[1]))!==null){let X=L[1];if(!(X in E))C.push(X);E[X]=L[2]??L[3]??L[4]??""}let B=[],z=[];for(let[X,G]of Object.entries(v)){if(G==null)continue;let J=X.trim();if(!Qp.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),B.push(se);if(!("class"in E))C.push("class");E.class=re.join(" ");continue}if(!(J in E))C.push(J);if(E[J]=String(G),ne!=="lang")z.push(J)}if(B.length){if(!(Co in E))C.push(Co);E[Co]=B.join(" ")}if(z.length){if(!(Eo in E))C.push(Eo);E[Eo]=z.join(" ")}let F=C.map((X)=>` ${X}="${ur(E[X])}"`).join("");return x.replace(k[0],()=>`<html${F}>`)}function tg(x){if(x.includes("data-stx-cloak"))return null;if(x.lastIndexOf("</head>")===-1)return null;return`${Yp}
|
|
1935
|
-
`}function wv(x){let v=[],k=0;while(k<x.length){let j=x.slice(k),L=j.match(/^\s+/);if(L){k+=L[0].length;continue}if(j.startsWith("<!--")){let G=x.indexOf("-->",k);if(G===-1)break;k=G+3;continue}let B=j.match(/^<script\b[^>]*>/i);if(B){let G=x.toLowerCase().indexOf("</script>",k+B[0].length);if(G===-1)break;k=G+9;continue}let z=j.match(/^<link\b[^>]*>/i);if(z){v.push(z[0]),k+=z[0].length;continue}let F=j.match(/^<meta\b[^>]*>/i);if(F){v.push(F[0]),k+=F[0].length;continue}let X=j.match(/^<style\b[^>]*>[\s\S]*?<\/style>/i);if(X){v.push(X[0]),k+=X[0].length;continue}break}if(v.length===0)return{body:x,hoisted:v};let E="",C=0;while(C<x.length&&C<k){let j=x.slice(C),L=j.match(/^<link\b[^>]*>/i);if(L&&v.includes(L[0])){C+=L[0].length;continue}let B=j.match(/^<meta\b[^>]*>/i);if(B&&v.includes(B[0])){C+=B[0].length;continue}let z=j.match(/^<style\b[^>]*>[\s\S]*?<\/style>/i);if(z&&v.includes(z[0])){C+=z[0].length;continue}E+=x[C],C++}return E+=x.slice(k),{body:E,hoisted:v}}function Sv(x,v={},k={}){let{title:E="stx App",lang:C="en",meta:j=[],link:L=[],script:B=[],headRaw:z="",htmlAttrs:F={},bodyClass:X="",bodyAttrs:G={}}=v,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:oe}=wv(x),ie=new Set(oe.flatMap((Re)=>{let ke=bv(Re);return ke?[wr(ke)].filter(Boolean):[]})),ue=[...ne.filter((Re)=>!re.has(wr(Re))),...j].filter((Re)=>!ie.has(wr(Re))).map((Re)=>` <meta ${Ls(Re)}>`).join(`
|
|
1936
|
-
`),xe=L.map((Re)=>` <link ${Ls(Re)}>`).join(`
|
|
1937
|
-
`),we=B.map((Re)=>{if(Re.src)return` <script ${Ls(Re,(ke)=>ke==="content")}></script>`;if(Re.content)return` <script>${Re.content}</script>`;return""}).filter(Boolean).join(`
|
|
1938
|
-
`),$e=vv(F,C),_e=Object.entries(G).map(([Re,ke])=>` ${Re}="${ur(String(ke))}"`).join(""),Ce=X?` class="${ur(X)}"`:"",Ee=[ue,k.colorMode?` ${hl(k.colorMode)}`:"",` <title>${k.titleIsHtml?J:xv(J)}</title>`,` ${Yp}`,xe,we,z?` ${z}`:"",...(k.styles||[]).map((Re)=>` ${Re}`),...oe.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 xl=/\s+/y,bl=/<(script|style)\b[^>]*>/iy,$v=/<\/script>/gi,_v=/<\/style>/gi,Gp=/<!DOCTYPE\b/iy,Jp=/<html[\s>]/iy;function rn(x){let v=0;while(v<x.length){if(xl.lastIndex=v,xl.exec(x)){v=xl.lastIndex;continue}if(x.startsWith("<!--",v)){let C=x.indexOf("-->",v);if(C===-1)return!1;v=C+3;continue}bl.lastIndex=v;let E=bl.exec(x);if(E){let C=E[1].toLowerCase()==="script"?$v:_v;C.lastIndex=bl.lastIndex;let j=C.exec(x);if(j===null)return!1;v=j.index+j[0].length;continue}if(Gp.lastIndex=v,Gp.test(x))return!0;return Jp.lastIndex=v,Jp.test(x)}return!1}function vl(x){return rn(x)}function ng(x,v={}){let k=x.lastIndexOf("</head>");if(k===-1)return x;let{meta:E=[],link:C=[],script:j=[],headRaw:L=""}=v,B=x.slice(0,k),z=[];for(let F of E){let X=wr(F);if(X&&B.includes(X))continue;z.push(` <meta ${Ls(F)}>`)}for(let F of C){if(F.href&&B.includes(`href="${F.href}"`))continue;z.push(` <link ${Ls(F)}>`)}for(let F of j)if(F.src){if(B.includes(`src="${F.src}"`))continue;z.push(` <script ${Ls(F,(X)=>X==="content")}></script>`)}else if(F.content){if(B.includes(F.content))continue;z.push(` <script>${F.content}</script>`)}if(L&&!B.includes(L))z.push(` ${L}`);if(z.length===0)return x;return`${x.slice(0,k)}${z.join(`
|
|
1949
|
-
`)}
|
|
1950
|
-
${x.slice(k)}`}function Hn(x,v={},k={},E){if(E??vl(x))return x;return Sv(x,v,k)}import rg from"path";function M(x,v={}){return new mn(x,v).routes}var sg=new Map;async function ig(x,v){let k=x,E=v;if(!k||!E)try{let B=await o();k||=B?.pagesDir||"pages",E||=B?.root||"."}catch{k||="pages",E||="."}let C=rg.isAbsolute(k)?k:rg.join(E,k),j=sg.get(C);if(j)return j;let L=[];try{L=M(".",{pagesDir:C,emit:!1}).map((B)=>B.regex.source).filter(Boolean)}catch{L=[]}return sg.set(C,L),L}function Ev(x){return x.replace(/</g,"\\u003c").replace(/>/g,"\\u003e").replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}function og(x){return Ev(JSON.stringify(x))}function ae(x){return x.includes("data-stx-runtime")}function ag(x){let v=/window\.stx\s*\.\s*[A-Za-z_$]|\}\s*=\s*window\.stx\s*;/g;for(let k=v.exec(x);k!==null;k=v.exec(x)){let E=x.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 wl(x,v){let k=Xs(x),E=x.search(/<!doctype\b/i);if(k!==-1&&(E===-1||k>E))return x.slice(0,k)+v+`
|
|
1951
|
-
`+x.slice(k);let C=Ri(x);if(C!==null)return`${x.slice(0,C)}
|
|
1952
|
-
${v}${x.slice(C)}`;if(x.includes("</head>")){let L=x.indexOf("</head>");return x.slice(0,L)+v+`
|
|
1953
|
-
`+x.slice(L)}if(An(x))return bs(x,(L)=>`${L}
|
|
1954
|
-
${v}`);return`${v}
|
|
1955
|
-
${x}`}async function Ro(x,v){if(x.includes("data-stx-runtime")||x.includes("window.stx.state")||x.includes("STX Signals Runtime"))return x;if(v.buildMode==="serve"){let{getServeClientAsset:C}=await import("./chunk-ej7m406s.js"),{url:j}=await C("runtime",v.debug===!0);return wl(x,`<script data-stx-runtime src="${j}"></script>`)}if(v.buildMode==="compile")return wl(x,'<script data-stx-runtime src="/__stx/runtime.__STX_HASH__.js"></script>');let{getCachedSignalsRuntime:k}=await import("./chunk-ej7m406s.js"),E=await k(v.debug);return wl(x,`<script data-stx-scoped data-stx-runtime>${E}</script>`)}function Cv(x){return/<[a-z][^>]*?\sx-tooltip\s*=/i.test(x)}function cg(x){if(x.includes("data-stx-tooltip-runtime")||!Cv(x))return x;let v=`<script data-stx-scoped data-stx-tooltip-runtime>${rl()}</script>`,k=x.lastIndexOf("</body>");if(k===-1)return`${x}
|
|
1956
|
-
${v}`;return`${x.slice(0,k)}${v}
|
|
1957
|
-
${x.slice(k)}`}var Rv=/<script\b[^>]*\sdata-stx-router(?=[\s=>])/i;function Tv(x){return Rv.test(x)||x.includes("__stxRouter)return")||x.includes("__stxRouter=true")}async function q(x,v){if(!x.includes("</body>"))return x;if(Tv(x))return x;let k=v?.router,E="";{let z={};if(k){if(k.container)z.container=k.container;if(k.interceptAllLinks!==void 0)z.interceptAllLinks=k.interceptAllLinks;if(k.progress!==void 0)z.progress=k.progress;if(k.viewTransitions!==void 0)z.viewTransitions=k.viewTransitions;if(k.viewTransitionDuration!==void 0)z.viewTransitionDuration=k.viewTransitionDuration;if(k.viewTransitionEasing!==void 0)z.viewTransitionEasing=k.viewTransitionEasing;if(k.scrollToTop!==void 0)z.scrollToTop=k.scrollToTop;if(k.scrollRestoration!==void 0)z.scrollRestoration=k.scrollRestoration;if(k.prefetch!==void 0)z.prefetch=k.prefetch;if(k.cache!==void 0)z.cache=k.cache;if(k.progressColor!==void 0)z.progressColor=k.progressColor;if(k.progressHeight!==void 0)z.progressHeight=k.progressHeight}try{let F=await ig(v?.pagesDir,v?.root);if(F.length>0)z.ownedRoutes=F}catch{}if(Object.keys(z).length>0)E=`<script>window.__stxRouterConfig=${og(z)};</script>
|
|
1958
|
-
`}let{getCachedRouterScript:C,getServeClientAsset:j}=await import("./chunk-ej7m406s.js"),L=v?.buildMode==="compile"?'<script data-stx-router src="/__stx/router.__STX_HASH__.js"></script>':v?.buildMode==="serve"?`<script data-stx-router src="${(await j("router")).url}"></script>`:`<script data-stx-router>${await C()}</script>`,B=x.lastIndexOf("</body>");return x.slice(0,B)+E+L+`
|
|
1959
|
-
</body>`+x.slice(B+7)}var Sl=`(?:"[^"]*"|'[^']*'|[^>"'])*`,mg=/^<([a-zA-Z][a-zA-Z0-9-]*)\b((?:\s+[^=\s>]+(?:=(?:"[^"]*"|'[^']*'|[^\s>]*))?)*\s*)>([\s\S]*)<\/\1>$/s,Av=65536,Iv=4,Ao=new Map;function Mu(){Ao.clear()}function Pv(x){let v=[];for(let k of pr(x,Y)){let E=k.token.match(/^<script\b([^>]*)>/i),C=k.token.match(/<\/script\s*>$/i);if(!E||!C)continue;let j=E[0].length,L=k.token.length-C[0].length;v.push(Object.freeze({fullMatch:k.token,attrs:E[1],body:k.token.slice(j,L),start:k.start,end:k.end}))}return v}function rc(x,v={}){let k=x.length>=Av,E=k?Ao.get(x):void 0;if(E===void 0){if(E=Pv(x),k)Ki(Ao,Iv),Ao.set(x,E)}let C=v.skipAttrs;if(!C)return E.slice();let j=[];for(let L of E)if(C.lastIndex=0,!C.test(L.attrs))j.push(L);return j}function ts(x){let v=x.trim(),k=v.match(/^([\s\S]+?)\s+as\s+(.+)$/);if(k){let C=k[1].trim(),j=k[2].trim(),{itemVar:L,indexVar:B}=lg(j);if(L)return{style:"as",iterable:C,itemVar:L,indexVar:B}}let E=v.match(/^(\([^)]+\)|\w+(?:\s*,\s*\w+)?)\s+(?:in|of)\s+([\s\S]+)$/);if(E){let C=E[1].trim(),j=E[2].trim(),{itemVar:L,indexVar:B}=lg(C);if(L)return{style:"in",iterable:j,itemVar:L,indexVar:B}}return{style:"unknown",iterable:null,itemVar:null,indexVar:null}}function lg(x){let v=x.trim(),k=v.match(/^(\w+)\s*=>\s*(\w+)$/);if(k)return{itemVar:k[2],indexVar:k[1]};let E=v.match(/^\(\s*(\w+)(?:\s*,\s*(\w+))?\s*\)$/);if(E)return{itemVar:E[1],indexVar:E[2]||null};let C=v.match(/^(\w+)\s*,\s*(\w+)$/);if(C)return{itemVar:C[1],indexVar:C[2]};let j=v.match(/^(\w+)$/);if(j)return{itemVar:j[1],indexVar:null};return{itemVar:null,indexVar:null}}function ns(x,v){return Si(x,v)}function Dv(x){let v=/@(if\s*\(|endif|elseif\s*\(|else\b)/g,k=0,E;while((E=v.exec(x))!==null){let C=E[1];if(C.startsWith("if"))k++;else if(C==="endif")k--;else if(k===0)return!0}return!1}function hg(x){let v=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,C;while((C=k.exec(x))!==null){let j=C[1],L;while((L=E.exec(j))!==null)v.add(L[1])}return v}function Mv(x){if(!/[:@]for\s*=/.test(x)&&!/\bx-for\s*=/.test(x))return[];let v=new RegExp(`<([a-zA-Z][\\w-]*)\\b(${Sl})>`,"iy"),k=/(?:^|\s)(?::for|@for|x-for)\s*=\s*(?:"([^"]*)"|'([^']*)')/i,E=pr(x,(j,L)=>{v.lastIndex=L;let B=v.exec(j);if(!B||B.index!==L||!k.test(B[2]))return-1;return v.lastIndex}),C=[];for(let j of E){v.lastIndex=0;let L=v.exec(j.token);if(!L)continue;let B=L[2].match(k),z=ts(B?.[1]??B?.[2]??""),F=[z.itemVar,z.indexVar].filter(Boolean);if(F.length===0)continue;let X=L[1],J=/\/\s*>$/.test(j.token)||Io.has(X.toLowerCase())?j.end:_l(x,j.start,X,j.end);if(J!==-1)C.push({start:j.start,end:J,vars:new Set(F)})}return C}var ug=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 Ov(x){return x.replace(/'(?:\\.|[^'\\])*'/g,"''").replace(/"(?:\\.|[^"\\])*"/g,'""').replace(/`(?:\\.|[^`\\])*`/g,"``")}function dg(x,v,k,E){if(!x)return!1;let C=Ov(x),j=!1,L=!1,B=!1,z=/([a-zA-Z_$][\w$]*)/g,F;while((F=z.exec(C))!==null){let ne=F[1];if(C.slice(0,F.index).trimEnd().endsWith("."))continue;if(ug.has(ne))continue;if(v.has(ne)||E?.has(ne))j=!0;else if(k&&ne in k)L=!0}let X=/([a-zA-Z_$][\w$]*)(?:\.[a-zA-Z_$][\w$]*)*\s*\(\s*\)/g,G;while((G=X.exec(C))!==null){let ne=G[1];if(C.slice(0,G.index).trimEnd().endsWith("."))continue;if(ug.has(ne)||k&&ne in k)continue;B=!0}return(j||B)&&!L}function To(x,v,k){let E=k===void 0?` ${v}`:` ${v}="${k.replace(/"/g,""")}"`,C=x.trim(),j=C.match(mg);if(j&&Nv(j[3],j[1])){let[,L,B,z]=j;return`<${L}${B}${E}>${z}</${L}>`}return`<template${E}>${C}</template>`}function Nv(x,v){let k=new RegExp(`<(/)?${v}(?=[\\s/>])`,"gi"),E=0,C;while((C=k.exec(x))!==null)if(C[1]){if(E--,E<0)return!1}else E++;return!0}function Wo(x,v){let k=hg(x);function E(C){let j=C,L=Mv(C),B=(G)=>{let J=new Set;for(let ne of L)if(G>ne.start&&G<ne.end)for(let re of ne.vars)J.add(re);return J},z=/@if\s*\(/g,F,X=[];while((F=z.exec(j))!==null){let G=F.index,J=G+F[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(),oe=re,ie=1,ge=oe,ue=/@(if\s*\(|endif)/g;ue.lastIndex=oe;let xe;while((xe=ue.exec(j))!==null)if(xe[1].startsWith("if"))ie++;else if(xe[1]==="endif"){if(ie--,ie===0){ge=xe.index+xe[0].length;break}}if(ie!==0)continue;let we=j.substring(oe,ge-6).trim(),$e;if(Dv(we)){let _e=Gs(j.substring(G,ge));if(_e.length===0)continue;let Ce=_e[0].branches.filter((ke)=>ke.type!=="else"),Ee=B(G);if(!(Ce.length>0&&Ce.every((ke)=>dg(ke.condition,k,v,Ee))))continue;$e=_e[0].branches.map((ke)=>{let Ae=E(ke.content);if(ke.type==="elseif")return To(Ae,"@else-if",ke.condition??"");if(ke.type==="else")return To(Ae,"@else");return To(Ae,"@if",ke.condition??"")}).join(`
|
|
1960
|
-
`)}else{if(!dg(se,k,v,B(G)))continue;$e=To(E(we),"@if",se)}X.push({start:G,end:ge,replacement:$e}),z.lastIndex=ge}for(let G=X.length-1;G>=0;G--){let{start:J,end:ne,replacement:re}=X[G];j=j.substring(0,J)+re+j.substring(ne)}return j}return E(x)}function jv(x){let v=x.trim();if(v==="")return;if(v==="true")return!0;if(v==="false")return!1;if(v==="null")return!1;if(v==="undefined")return!1;if(v==="NaN")return!1;if(/^-?\d+(?:\.\d+)?$/.test(v)){let C=Number(v);return C!==0&&!Number.isNaN(C)}let k=v.match(/^'((?:\\.|[^'\\])*)'$/);if(k)return k[1].length>0;let E=v.match(/^"((?:\\.|[^"\\])*)"$/);if(E)return E[1].length>0;return}var Io=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),fg=/<(script|style)\b/iy,Lv=/<\/script/gi,Bv=/<\/style/gi;function _l(x,v,k,E){if(Io.has(k.toLowerCase()))return E;let C=k.toLowerCase(),j=x.length,L=1,B=E;while(B<j){let z=x.indexOf("<",B);if(z===-1)return-1;if(B=z,x.startsWith("<!--",B)){let J=x.indexOf("-->",B+4);if(J===-1)return-1;B=J+3;continue}fg.lastIndex=B;let F=fg.exec(x);if(F){let J=x.indexOf(">",B);if(J===-1)return-1;if(x[J-1]==="/"){B=J+1;continue}let ne=F[1].toLowerCase()==="script"?Lv:Bv;ne.lastIndex=B;let re=ne.exec(x);if(re===null)return-1;let se=x.indexOf(">",re.index);if(se===-1)return-1;B=se+1;continue}if(x[B+1]==="/"){let J=/^<\/([a-z][\w-]*)\s*>/i.exec(x.slice(B,B+64));if(!J){B++;continue}if(J[1].toLowerCase()===C){if(L--,B+=J[0].length,L===0)return B;continue}B+=J[0].length;continue}let X=/^<([a-z][\w-]*)\b/i.exec(x.slice(B,B+64));if(!X){B++;continue}let G=x.indexOf(">",B);if(G===-1)return-1;if(X[1].toLowerCase()===C){let J=x.slice(B,G+1);if(!(/\/\s*>$/.test(J)||Io.has(C)))L++}B=G+1}return-1}var zv=/\s(?::else-if|x-else-if|@else-if|:else|x-else|@else)(?=[=\s/>])/;function Fv(x,v){let k=v,E=x.length;for(;;){while(k<E&&x[k]!=="<")k++;if(k>=E)return!1;if(x.startsWith("<!--",k)){let L=x.indexOf("-->",k+4);if(L===-1)return!1;k=L+3;continue}break}if(x[k+1]==="/")return!1;let C=x.indexOf(">",k);if(C===-1)return!1;let j=x.slice(k,C+1);return zv.test(j)}function qo(x){if(!x.includes(":if")&&!x.includes(":show")&&!x.includes("x-if")&&!x.includes("x-show")&&!x.includes("@if=")&&!x.includes("@show="))return x;let v=[],k=/<(script|style)\b[^>]*>[\s\S]*?<\/\1\s*>/gi,E;while((E=k.exec(x))!==null)v.push([E.index,E.index+E[0].length]);let C=(G)=>v.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,L=[],B;while((B=j.exec(x))!==null){if(C(B.index))continue;let[G,J,ne,re,se,oe,ie]=B,ge=jv(se);if(ge===void 0)continue;let ue=B.index,xe=ue+G.length,_e=!!ie||/\/\s*>$/.test(G)||Io.has(J.toLowerCase())?xe:_l(x,ue,J,xe);if(_e===-1)continue;if((re===":if"||re==="x-if"||re==="@if")&&Fv(x,_e)){j.lastIndex=xe;continue}if(ge===!0){let Ee=`<${J}${ne}${oe}${ie}>`;L.push({start:ue,end:xe,replacement:Ee});continue}L.push({start:ue,end:_e,replacement:""}),j.lastIndex=_e}if(L.length===0)return x;L.sort((G,J)=>G.start-J.start);let z=[],F=-1;for(let G of L){if(G.start<F)continue;z.push(G),F=G.end}let X=x;for(let G=z.length-1;G>=0;G--){let{start:J,end:ne,replacement:re}=z[G];X=X.substring(0,J)+re+X.substring(ne)}return X}var pg=[":for","@for","x-for"];function rs(x,v){if(!v||Object.keys(v).length===0)return x;if(!pg.some((B)=>x.includes(`${B}=`)))return x;let k=hg(x);if(Array.isArray(v.__stx_client_signal_names)){for(let B of v.__stx_client_signal_names)if(typeof B==="string")k.add(B)}let E=x,C=[],j=/<([a-zA-Z][\w-]*)((?:[^>"']|"[^"]*"|'[^']*')*)>/g,L;while((L=j.exec(E))!==null){let[B,z,F]=L,X=L.index,G=X+B.length,J=pg.map(($e)=>({attr:$e,m:new RegExp(`\\s${$e}="([^"]*)"`).exec(F)})).find(($e)=>$e.m!==null);if(!J||!J.m)continue;let ne=ts(J.m[1]);if(!ne.iterable||!ne.itemVar)continue;let re=ne.iterable.trim().split(/[.[(]/)[0].trim();if(!re||k.has(re)||!(re in v))continue;let se=_l(E,X,z,G);if(se===-1)continue;let oe=F.replace(new RegExp(`\\s${J.attr}="[^"]*"`),"").replace(/\s:key="[^"]*"/,"").replace(/\sx-cloak(?=\s|$)/,""),ie=E.slice(G,se-`</${z}>`.length),ge={...v,[ne.itemVar]:void 0};if(ne.indexVar)ge[ne.indexVar]=void 0;let ue=rs(ie,ge),xe=ne.indexVar?`${ne.iterable} as ${ne.indexVar} => ${ne.itemVar}`:`${ne.iterable} as ${ne.itemVar}`,we=z.toLowerCase()==="template"?ue:`<${z}${oe}>${ue}</${z}>`;C.push({start:X,end:se,replacement:`@foreach(${xe})${we}@endforeach`}),j.lastIndex=se}for(let B=C.length-1;B>=0;B--){let{start:z,end:F,replacement:X}=C[B];E=E.slice(0,z)+X+E.slice(F)}return E}function ss(x,v){let k=x,E=/@(for|foreach)\s*\(/g,C,j=[],L=[];while((C=E.exec(k))!==null){let B=C[1],z=C.index,F=z+C[0].length,X=1,G=F;while(G<k.length&&X>0){if(k[G]==="(")X++;else if(k[G]===")")X--;G++}if(X!==0)continue;let J=k.substring(F,G-1).trim(),ne=G,re=ts(J),se=B==="for"?"@endfor":"@endforeach",oe=1,ie=ne,ge=B==="for"?new RegExp("@(for(?!each)\\s*\\(|endfor(?!each))","g"):new RegExp(`@(${B}\\s*\\(|end${B})`,"g");ge.lastIndex=ne;let ue;while((ue=ge.exec(k))!==null)if(ue[1].startsWith(B))oe++;else if(oe--,oe===0){ie=ue.index+ue[0].length;break}if(oe!==0)continue;let xe=()=>{let Te=[re.itemVar,re.indexVar].filter(Boolean);if(Te.length)L.push({start:z,end:ie,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=v?Re in v:!1,Ae=L.some((Xe)=>z>Xe.start&&z<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,ie-se.length).trim(),$e=v?{...v}:{};if(re.itemVar)delete $e[re.itemVar];if(re.indexVar)delete $e[re.indexVar];let _e=ss(we,$e),Ce=_e.match(mg),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:z,end:ie,replacement:Ee}),E.lastIndex=ie}for(let B=j.length-1;B>=0;B--){let{start:z,end:F,replacement:X}=j[B];k=k.substring(0,z)+X+k.substring(F)}return k}function Wv(x){let v=new Set,k=[],E=0,C=0,j=x.length,L=(X)=>{let G=E+1;while(G<j){let J=x[G];if(J==="\\"){G+=2;continue}if(J===X)return G+1;G++}return j},B=()=>{let X=E+2;while(X<j&&x[X]!==`
|
|
1961
|
-
`)X++;return X},z=()=>{let X=E+2;while(X<j-1){if(x[X]==="*"&&x[X+1]==="/")return X+2;X++}return j},F=(X)=>{let G=X,J=0;while(G<j){let ne=x[G];if(ne==="/"&&x[G+1]==="/"){let re=G+2;while(re<j&&x[re]!==`
|
|
1962
|
-
`)re++;G=re;continue}if(ne==="/"&&x[G+1]==="*"){let re=G+2;while(re<j-1&&!(x[re]==="*"&&x[re+1]==="/"))re++;G=re+2;continue}if(ne==='"'||ne==="'"||ne==="`"){let re=G+1;while(re<j){if(x[re]==="\\"){re+=2;continue}if(x[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 X=x[E];if(X==="/"&&x[E+1]==="/"){let G=B();k.push(x.slice(E,G)),E=G;continue}if(X==="/"&&x[E+1]==="*"){let G=z();k.push(x.slice(E,G)),E=G;continue}if(X==='"'||X==="'"||X==="`"){let G=L(X);k.push(x.slice(E,G)),E=G;continue}if(X==="{"){C++,k.push(X),E++;continue}if(X==="}"){C--,k.push(X),E++;continue}if(C===0){let G=E>0?x[E-1]:"";if(G===""||/\s/.test(G)||G===";"||G==="}"||G==="{"){let ne=x.slice(E).match(/^(const|let|var)\s+([a-zA-Z_$][\w$]*)\s*=/);if(ne){let re=ne[2],se=F(E+ne[0].length);if(v.has(re)){k.push(`/* stx: deduped const ${re} */`),E=se;continue}v.add(re),k.push(x.slice(E,se)),E=se;continue}}}k.push(X),E++}return k.join("")}var Vv=new Set(["script","style","html","head","meta","link","title","!doctype"]);function $l(x,v,k){for(let E of k){if(E.start>=v)return!1;if(E.end>x)return!0}return!1}function Uv(x,v,k){let E=0;while(E<x.length){let C=x.indexOf(v,E);if(C===-1)return!1;if(!$l(C,C+v.length,k))return!0;E=C+v.length}return!1}function Hv(x,v){if(Uv(x,"<body",v)){let C=new RegExp(`<body(${Sl})>`,"g"),j;while((j=C.exec(x))!==null)if(!$l(j.index,j.index+j[0].length,v))return j.index+j[0].length-1;return null}let k=new RegExp(`<([a-zA-Z][a-zA-Z0-9-]*)\\b(${Sl})>`,"gi"),E;while((E=k.exec(x))!==null){if($l(E.index,E.index+E[0].length,v))continue;if(Vv.has(E[1].toLowerCase()))continue;return E.index+E[0].length-1}return null}function qv(x,v,k,E){let C=[],j=` data-stx="${E}"`,L=0,B=!1,z=(F)=>{if(k!==null&&!B&&k>=L&&k<=F)C.push(x.slice(L,k),j,x.slice(k,F)),B=!0;else C.push(x.slice(L,F))};for(let F of v){if(F.start<L)continue;z(F.start),L=F.end}return z(x.length),C.join("")}async function jn(x,v,k,E={}){let C=rc(x,{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*\(/,L=[],{hasUserImports:B,bundleClientScript:z}=await ut("stx/client-script-bundler",()=>import("./chunk-6fw3rfcj.js"));for(let ue of C){let xe=ue.body;if(Ve(ue.attrs))xe=Ue(xe);if(E.forceClientSetup||j.test(xe)){L.push({content:xe,start:ue.start,end:ue.end});continue}if(!B(xe))continue;try{let we=await z(bt(xe).code,v||"",{projectRoot:process.cwd(),externalizeUserModules:!1});if(j.test(we))L.push({content:xe,start:ue.start,end:ue.end})}catch{}}if(L.length===0)return{output:x,setupCode:null};let F=`${v??""}\x00${L.map((ue)=>ue.content).join("\x00")}`,X=`__stx_setup_${Bun.hash(F).toString(36).slice(0,10)}`,G=[];for(let ue=0;ue<L.length;ue++){let xe=L[ue].bundled??bt(L[ue].content).code;if(!L[ue].bundled&&B(xe))xe=await z(xe,v||"",{projectRoot:process.cwd(),externalizeUserModules:E.forceClientSetup?!1:void 0});xe=ze(xe);let we=R(xe);G.push(`// \u2500\u2500 merged signal script #${ue+1} \u2500\u2500
|
|
1963
|
-
${we}`)}let J=G.join(`
|
|
1964
|
-
|
|
1965
|
-
`);J=Wv(J);let ne=sc(J),re=ne.split(",").map((ue)=>ue.trim()).filter(Boolean),se=Xr(J,k),oe=`
|
|
1966
|
-
<script data-stx-scoped>
|
|
1967
|
-
function ${X}() {
|
|
1968
|
-
${_t("const",re)}
|
|
1969
|
-
${zr(`${se}${J}`)}
|
|
1970
|
-
return { ${ne} };
|
|
1971
|
-
}
|
|
1972
|
-
window.__stx_latestSetup=${X};
|
|
1973
|
-
if(window.stx)window.stx._latestSetup=${X};
|
|
1974
|
-
</script>`,ie=Hv(x,L);return{output:qv(x,L,ie,X),setupCode:oe}}function sc(x){let v=x,k=[],E=new Set,C=0,j=0,L=v.length,B="",z=()=>{j++;let re=!1;while(j<L){let se=v[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<L&&/[gimsuyd]/.test(v[j]))j++;return}if(se===`
|
|
1975
|
-
`)return;j++}},F=()=>{if(!B)return!0;if(/[\w)\]]/.test(B))return!1;return!0},X=(re)=>{j++;while(j<L){if(v[j]==="\\"){j+=2;continue}if(v[j]===re){j++;return}j++}},G=()=>{j++;while(j<L){if(v[j]==="\\"){j+=2;continue}if(v[j]==="`"){j++;return}if(v[j]==="$"&&v[j+1]==="{"){j+=2;let re=1;while(j<L&&re>0)if(v[j]==="{")re++,j++;else if(v[j]==="}")re--,j++;else if(v[j]==="'"||v[j]==='"')X(v[j]);else if(v[j]==="`")G();else j++;continue}j++}},J=()=>{if(v[j]==="/"&&v[j+1]==="/"){while(j<L&&v[j]!==`
|
|
1976
|
-
`)j++;return!0}if(v[j]==="/"&&v[j+1]==="*"){j+=2;while(j<L-1&&!(v[j]==="*"&&v[j+1]==="/"))j++;return j+=2,!0}return!1},ne=()=>{if(C!==0)return;let re=v.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=v.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 oe=v.slice(j).match(/^(?:const|let|var)\s+\[([^\]]+)\]\s*=/);if(oe){oe[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 ie=v.slice(j).match(/^function\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*\(/);if(ie){let ue=ie[1];if(!E.has(ue))k.push(ue),E.add(ue);return}let ge=v.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<L){if(J())continue;if(v[j]==="'"||v[j]==='"'){X(v[j]),B=v[j-1];continue}if(v[j]==="`"){G(),B="`";continue}if(v[j]==="/"&&v[j+1]!=="/"&&v[j+1]!=="*"&&F()){z(),B="/";continue}if(v[j]==="{"){C++,B="{",j++;continue}if(v[j]==="}"){C--,B="}",j++;continue}if(C===0&&/[a-z]/i.test(v[j])&&(j===0||/\s|[;{}()]/.test(v[j-1])))ne();if(!/\s/.test(v[j]))B=v[j];j++}return k.join(", ")}async function Ko(x,v,k,E){if(!ns(x,k))return x;let C=x;if(v.skipSignalsRuntime)return C;let{output:j,setupCode:L}=await jn(C,k,E);if(C=j,!L){let B=An(C);if(B&&!/data-stx/.test(B.attrs)&&!/data-stx-auto/.test(B.attrs)){let z=B.tag.replace(/^<body([^>]*)>$/i,"<body$1 data-stx-auto>");C=C.slice(0,B.index)+z+C.slice(B.index+B.tag.length)}}if(C=await Ro(C,v),L){let B=Xo(C,/<\/head>/i),z=B===-1?Xo(C,/<body[^>]*>/i):-1;if(B!==-1)C=`${C.slice(0,B)}${L}
|
|
1977
|
-
${C.slice(B)}`;else if(z!==-1){let F=/<body[^>]*>/i.exec(C.slice(z))[0],X=z+F.length;C=`${C.slice(0,X)}
|
|
1978
|
-
${L}${C.slice(X)}`}else C=`${C}
|
|
1979
|
-
${L}`}return C}function Xo(x,v){let k=/<(script|style)\b[\s\S]*?<\/\1>/gi,E=[],C;while((C=k.exec(x))!==null)E.push([C.index,C.index+C[0].length]);let j=new RegExp(v.source,v.flags.replace(/[gy]/g,"")),L=0;while(L<x.length){let B=j.exec(x.slice(L));if(!B)return-1;let z=L+B.index;if(!E.some(([X,G])=>z>=X&&z<G))return z;L=z+Math.max(B[0].length,1)}return-1}var gg="/* [stx import stripped, resolved via window.stx in __stx_setup] */";function oc(x){let v=[];for(let k of x.split(",")){let E=k.trim();if(!E||E.startsWith("type "))continue;let C=E.match(/^([A-Za-z_$][\w$]*)\s+as\s+([A-Za-z_$][\w$]*)$/);if(C&&C[1]!==C[2])v.push(`${C[2]} = ${C[1]}`)}if(v.length===0)return gg;return`var ${v.join(", ")}; ${gg}`}var Kv=/^\s*import\s+(?:type\s+)?\{([^}]*)\}\s+from\s+['"](?:stx|@stacksjs\/stx|@stacksjs\/browser)['"]\s*;?\s*$/gm;function ze(x){return x.replace(Kv,(v,k)=>oc(k))}import Bs from"path";import Xv from"process";function y(x="STX_PUBLIC_"){let v={},k={};for(let[E,C]of Object.entries(Xv.env)){if(!E.startsWith(x)||C===void 0)continue;v[`import.meta.env.${E}`]=JSON.stringify(C),k[E]=C}return v["import.meta.env"]=JSON.stringify(k),v}function yg(x){return x.startsWith("http://")||x.startsWith("https://")||x.startsWith("//")}async function xg(x,v,k){try{let E;if(x.startsWith("/")){let C=v;for(let j=0;j<5;j++){let L=Bs.join(C,x);if(await Bun.file(L).exists())return L;C=Bs.dirname(C)}E=Bs.join(v,x)}else if(x.startsWith("./")||x.startsWith("../"))E=Bs.resolve(v,x);else E=Bs.resolve(v,x);if(await Bun.file(E).exists())return E;return null}catch{return null}}var bg=Symbol.for("stx.inline-assets.import-meta");function Zv(x,v){if(!x.includes("import.meta"))return;let k=Error(`[stx] ${v} 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[bg]=!0,k}async function vg(x,v,k){let E=x,C=Bs.dirname(v),j=/<script\b([^>]*)src=["']([^"']+)["']([^>]*)><\/script>/gi,L;while((L=j.exec(E))!==null){let[F,X,G,J]=L;if(yg(G))continue;let ne=await xg(G,C,v);if(ne)try{let re=await Bun.file(ne).text();if(k.add(ne),G.endsWith(".ts")||G.endsWith(".tsx")){let oe=await Bun.build({entrypoints:[ne],target:"browser",minify:!0,define:y()});if(oe.outputs.length>0)re=await oe.outputs[0].text(),Zv(re,G)}let se=`<script>
|
|
1981
|
-
// Source: ${G}
|
|
1982
|
-
${re}
|
|
1983
|
-
</script>`;E=E.replace(F,se),j.lastIndex=0}catch(re){if(re?.[bg])throw re}}let B=/<link\b([^>]*)href=["']([^"']+)["']([^>]*)(?:\/?>)/gi,z;while((z=B.exec(E))!==null){let[F,X,G,J]=z,ne=X+J;if(yg(G))continue;if(/rel=["']stylesheet["']/.test(ne)||G.endsWith(".css")){let se=await xg(G,C,v);if(se)try{let oe=await Bun.file(se).text();k.add(se);let ie=`<style>
|
|
1984
|
-
/* Source: ${G} */
|
|
1985
|
-
${oe}
|
|
1986
|
-
</style>`;E=E.replace(F,ie),B.lastIndex=0}catch(oe){}}}return E}function ds(x,v){let k=x,E=/@json\s*\(/g,C;while((C=E.exec(k))!==null){let j=C.index,L=j+C[0].length-1,B=1,z=L+1,F=null,X=!1;while(z<k.length&&B>0){let ue=k[z];if(X){X=!1,z++;continue}if(ue==="\\"&&F){X=!0,z++;continue}if(F){if(ue===F)F=null;z++;continue}if(ue==='"'||ue==="'"||ue==="`"){F=ue,z++;continue}if(ue==="(")B++;else if(ue===")"){if(B--,B===0)break}z++}if(B!==0)break;let G=k.substring(L+1,z).trim(),J=k.substring(j,z+1),ne=-1,re=0,se=null,oe=!1;for(let ue=0;ue<G.length;ue++){let xe=G[ue];if(oe){oe=!1;continue}if(xe==="\\"&&se){oe=!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 ie=ne>=0?G.substring(0,ne).trim():G,ge=ne>=0?G.substring(ne+1).trim():void 0;try{let ue=ie.trim(),xe;if(p(ue))xe=l(ue,Object.keys(v))(...Object.values(v));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(z+1),E.lastIndex=j+$e.length}catch(ue){_.log(ue instanceof Error?ue:Error(String(ue)),{directive:"@json"},"error"),E.lastIndex=j+J.length}}return k}function ps(x){return x.replace(/@once\s*([\s\S]*?)@endonce/g,"$1")}function Sg(x){let v=x,k=/@memo\s*\(/g,E,C=[];while((E=k.exec(v))!==null){let j=E.index,L=j+E[0].length,B=1,z=L;while(z<v.length&&B>0){if(v[z]==="(")B++;else if(v[z]===")")B--;z++}if(B!==0)continue;let F=v.slice(L,z-1).trim(),X=z,G=v.slice(X),J=G.indexOf("@endmemo");if(J===-1)continue;let ne=G.slice(0,J),re=X+J+8,se=ne.match(/^(\s*(?:(?:<!--[\s\S]*?-->|\x00STX_HTML_COMMENT_\d+\x00)\s*)*)/),oe=se?se[0].length:0,ie=ne.slice(oe),ge=ne.match(/(\s*)$/),ue=ge?ge[0].length:0,xe=ie.slice(0,ie.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="${F}"${Te}>`;$e=ne.slice(0,oe)+Re+xe.slice(_e.length)+ne.slice(oe+xe.length)}else $e=`${ne.slice(0,oe)}<div data-stx-memo="${F}">${xe}</div>${ne.slice(oe+xe.length)}`;C.push({start:j,end:re,replacement:$e}),k.lastIndex=re}for(let j=C.length-1;j>=0;j--){let L=C[j];v=v.slice(0,L.start)+L.replacement+v.slice(L.end)}return v.replace(/@memo="([^"]*)"/g,'data-stx-memo="$1"')}function kl(x){let v=x.replace(/@ref="([^"]+)"/g,'data-stx-ref="$1"');return v=v.replace(/(<[a-zA-Z][a-zA-Z0-9-]*\b[^>]*?)\sref="([^"]+)"/g,'$1 data-stx-ref="$2"'),v}function $g(x,v){if(!/\bref\s*=/.test(x))return x;let k=/<\/?([a-zA-Z][\w-]*)\b(?:"[^"]*"|'[^']*'|[^'">])*>/y,E=pr(x,(z,F)=>{k.lastIndex=F;let X=k.exec(z);if(!X||/^(?:script|style)$/i.test(X[1]))return-1;return k.lastIndex}),C=[],j=0,L=0,B=[];for(let{start:z,end:F,token:X}of E){let G=/^<\/?([\w-]+)/.exec(X)[1].toLowerCase();if(X.startsWith("</")){let ne;while(ne=C.pop()){if(ne.scoped)j--;if(ne.name===G)break}continue}let J=/\sdata-stx-scope\s*=/.test(X);if(!j&&!J&&/\s(?:ref|@ref|:ref|x-ref|data-stx-ref)\s*=/.test(X)&&!/\sdata-stx-ref-caller\s*=/.test(X))B.push(x.slice(L,z),X.replace(/\s*\/?>$/,(ne)=>` data-stx-ref-caller="${v}"${ne}`)),L=F;if(!_g.has(G)&&!/\/>$/.test(X)){if(C.push({name:G,scoped:J}),J)j++}}return B.push(x.slice(L)),B.join("")}var _g=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),kg=/(?:^|\s)x-no-cloak(?:=|\s|\/|>|$)/,wg=/<\/?\s*([a-z][\w-]*)/iy,Gv=/\s/;function Jv(x,v){let k=v-1;while(k>=0&&Gv.test(x[k]))k--;return k>=0&&x[k]==="/"}function Yv(x,v){let k=!1,E=!1;for(let C=v;C<x.length;C++){let j=x[C];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 C}return-1}function Qv(x,v){if(x.indexOf("{",v)===-1||x.indexOf("}",v)===-1)return!1;let k=0,E=v,C=!1,j=!1,L=!1;while(E<x.length){let B=x.indexOf("<",E),z=B===-1?x.length:B;if(z>E){if(k===0)while(E<z){let G=x.indexOf(j?"}":"{",E);if(G===-1||G>=z){if(j)L=!1;else C=!1;break}if(G>E)if(j)L=!1;else C=!1;if(j){if(L)return!0;L=!0}else if(C)j=!0,L=!1;else C=!0;E=G+1}E=z;continue}if(x.startsWith("<!--",E)){let G=x.indexOf("-->",E);E=G===-1?x.length:G+3;continue}let F=Yv(x,E);if(F===-1)break;wg.lastIndex=E;let X=wg.exec(x)?.[1]?.toLowerCase()??"";if(x[E+1]==="/"){if(k===0)break;k--}else if(!Jv(x,F)&&!_g.has(X))k++;E=F+1}return!1}function Eg(x){if(x.length>=32768&&!sd(x))return x;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="",C=0,j;while((j=k.exec(x))!==null){let L=j.index,B=L+j[0].length,z=!1,F=!1,X=-1;while(B<x.length){let J=x[B];if(z){if(J==="'")z=!1}else if(F){if(J==='"')F=!1}else if(J==="'")z=!0;else if(J==='"')F=!0;else if(J===">"){X=B;break}B++}if(X===-1)continue;let G=x.slice(L,X+1);if(kg.test(G))continue;if(G.includes("x-cloak"))continue;if(Qv(x,X+1))E+=x.slice(C,X)+" x-cloak>",C=X+1}return E+=x.slice(C),E}var ew=/(?:^|\s)(?::else-if|:if|:else|:show|x-else-if|x-if|x-else|x-show|@if|@show)(?:=|\s|\/|>|$)/,tw=/<\/script>/gi,nw=/<\/style>/gi;function Cg(x){let v=/<[a-z][\w-]*/gi,k="",E=0,C;while((C=v.exec(x))!==null){let j=C.index,L=C[0].slice(1).toLowerCase();if(L==="script"||L==="style"){let re=L==="script"?tw:nw;re.lastIndex=j;let se=re.exec(x);if(se!==null)v.lastIndex=se.index+se[0].length;continue}let B=j+C[0].length,z=!1,F=!1,X=-1;while(B<x.length){let re=x[B];if(z){if(re==="'")z=!1}else if(F){if(re==='"')F=!1}else if(re==="'")z=!0;else if(re==='"')F=!0;else if(re===">"){X=B;break}B++}if(X===-1)continue;let G=x.slice(j+C[0].length,X);if(kg.test(G))continue;if(/(?:^|\s)x-cloak(?:=|\s|\/|>|$)/.test(G))continue;if(!ew.test(G))continue;let J=x[X-1]==="/",ne=J?X-1:X;k+=`${x.slice(E,ne)} x-cloak${J?" ":""}`,E=ne}return k+=x.slice(E),k}var El=I(256),rw=[{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"}],Rg=/(?:\/\/|\/\*|\{\{--)\s*stx-strict-ignore(-next-line)?([^\n*}]*)/g;function sw(x){let v=Array.from(x,(C)=>C===`
|
|
1987
|
-
`?`
|
|
1988
|
-
`:" "),k=0,E="";while(k<x.length){let C=x[k],j=x[k+1];if(E){if(C==="\\"){k+=2;continue}if(C===E)E="";k++;continue}if(C==='"'||C==="'"||C==="`"){E=C,k++;continue}if(C==="/"&&j==="/"){while(k<x.length&&x[k]!==`
|
|
1989
|
-
`)v[k]=x[k],k++;continue}if(C==="/"&&j==="*"){let L=x.indexOf("*/",k+2),B=L===-1?x.length:L+2;for(;k<B;k++)v[k]=x[k];continue}if(C==="{"&&j==="{"&&x.slice(k,k+4)==="{{--"){let L=x.indexOf("--}}",k+4),B=L===-1?x.length:L+4;for(;k<B;k++)v[k]=x[k];continue}k++}return v.join("")}function iw(x){let v=new Map,k=sw(x).split(`
|
|
1990
|
-
`),E=x.split(`
|
|
1991
|
-
`);return k.forEach((C,j)=>{Rg.lastIndex=0;for(let L of C.matchAll(Rg)){let B=L[1]==="-next-line",z=(E[j]??"").slice(0,L.index).trim(),F=B||z===""?j+2:j+1,G=(L[2]??"").split("--")[0].split(/[\s,]+/).filter(Boolean),J=G.filter((re)=>/\w/.test(re));if(G.length>0&&J.length===0)continue;let ne=v.get(F);if(ne&&ne.size===0)continue;if(J.length===0){v.set(F,new Set);continue}if(ne)J.forEach((re)=>ne.add(re));else v.set(F,new Set(J))}}),v}function ow(x,v,k){let E=x.get(v);if(!E)return!1;if(E.size===0)return!0;return[...E].some((C)=>k.includes(C))}function gs(x,v,k,E){let C=typeof k==="boolean"?{enabled:k,failOnViolation:k}:k??{enabled:!1};if(!C.enabled)return;let j=O(x,v,E,JSON.stringify(C)),L=El.get(j);if(L!==void 0){if(L&&C.failOnViolation)throw Error(L);return}let B=C.allowPatterns??[],z=iw(x),F=[],X=s(x.replace(/\{\{--[\s\S]*?--\}\}/g,(re)=>re.replace(/[^\n]/g," ")));for(let{pattern:re,message:se,suggestion:oe}of rw){if(B.some((ge)=>/\w/.test(ge)&&se.includes(ge)))continue;re.lastIndex=0;let ie=X.match(re);if(ie&&ie.length>0){let ge=X.split(`
|
|
1992
|
-
`),ue=x.split(`
|
|
1993
|
-
`),xe=[];if(ge.forEach((Ce,Ee)=>{if(re.lastIndex=0,re.test(Ce)&&!ow(z,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}`:"";F.push(` \u2717 ${se}${we}
|
|
1996
|
-
\u2192 ${oe}${_e}`)}}if(F.length===0){El.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!==v?`${G(E)} (composed into ${G(v)})`:G(v)}:
|
|
1997
|
-
${F.join(`
|
|
1998
|
-
`)}
|
|
1999
|
-
Tip: prefer useRef(), navigate(), and composables for component code`;if(El.set(j,ne),C.failOnViolation)throw Error(ne);else console.warn(ne)}import Cl from"path";var aw=/(\bfrom\s*|\bimport\s*\(\s*|\bimport\s+)(['"])(\.\.?\/[^'"]*)\2/g,cw=/(<script\b[^>]*>)([\s\S]*?)(<\/script>)/gi;function lw(x,v){if(!v||!x.includes("/"))return x;let k=Cl.dirname(v);return x.replace(aw,(E,C,j,L)=>{let B=Cl.resolve(k,L);return`${C}${j}${B.split(Cl.sep).join("/")}${j}`})}function Tg(x,v){if(!v||!x.includes("<script"))return x;return x.replace(cw,(k,E,C,j)=>`${E}${lw(C,v)}${j}`)}var Mr="<!--PARENT_CONTENT_PLACEHOLDER-->";function Ag(x){return x.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}function jg(x,v){let k=x.length,E=v,C=!0,j=[],L=(B)=>B+9<=k&&x[B]==="<"&&x[B+1]==="/"&&(x[B+2]==="s"||x[B+2]==="S")&&(x[B+3]==="c"||x[B+3]==="C")&&(x[B+4]==="r"||x[B+4]==="R")&&(x[B+5]==="i"||x[B+5]==="I")&&(x[B+6]==="p"||x[B+6]==="P")&&(x[B+7]==="t"||x[B+7]==="T")&&(x[B+8]===">"||/\s/.test(x[B+8]));while(E<k){let B=x[E];if(L(E))return E;if(B==="/"&&x[E+1]==="/"){if(E=x.indexOf(`
|
|
2000
|
-
`,E+2),E===-1)return-1;E+=1,C=!0;continue}if(B==="/"&&x[E+1]==="*"){let z=x.indexOf("*/",E+2);if(z===-1)return-1;E=z+2,C=!0;continue}if(B==="/"&&C){let z=E+1,F=!1;while(z<k){let X=x[z];if(X==="\\"){z+=2;continue}if(X==="[")F=!0;else if(X==="]")F=!1;else if(X==="/"&&!F){z++;break}else if(X===`
|
|
2001
|
-
`){z=-1;break}z++}if(z===-1){E++,C=!1;continue}while(z<k&&/[a-z]/.test(x[z]))z++;E=z,C=!1;continue}if(B==="'"||B==='"'){let z=B;E++;while(E<k){if(x[E]==="\\"){E+=2;continue}if(x[E]===z){E++;break}if(x[E]===`
|
|
2002
|
-
`)break;E++}C=!1;continue}if(B==="`"){E++;while(E<k){if(x[E]==="\\"){E+=2;continue}if(x[E]==="`"){E++;break}if(x[E]==="$"&&x[E+1]==="{"){j.push(!0),E+=2,C=!0;break}E++}if(j.length===0)C=!1;continue}if(B==="}"&&j.length>0){j.pop(),E++;while(E<k){if(x[E]==="\\"){E+=2;continue}if(x[E]==="`"){E++,C=!1;break}if(x[E]==="$"&&x[E+1]==="{"){j.push(!0),E+=2,C=!0;break}E++}continue}if(/\s/.test(B));else if(/[)\].\w$]/.test(B))C=!1;else C=!0;E++}return-1}function Lg(x,v){let k=v.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),E=new RegExp(`<script\\b(?=[^>]*\\b${k}(?:\\s|=|/?>))[^>]*>`,"i").exec(x);if(!E)return null;let C=E.index+E[0].length,j=x.indexOf("</script>",C);if(j===-1)return null;let L=x.indexOf(">",j);if(L===-1)return null;return{start:E.index,end:L+1}}var dw=4096;async function Ig(x,v,k){if(k.buildMode!=="serve"||v.length<dw)return null;let{registerServeModuleBundle:E}=await import("./chunk-ej7m406s.js");return`<script ${x} src="${E(v)}"></script>`}async function Pg(x,v,k){try{let{registeredModuleIdsIn:E,buildModuleRegistryScript:C}=await ut("stx/client-module-registry",()=>import("./chunk-81v9crqy.js")),j=[],L=await C(E(...x),{minify:v.buildMode==="compile",collectInputs:j});for(let B of j)k?.add(B);if(!L)return null;if(v.buildMode==="serve"){let{registerServeModuleBundle:B}=await import("./chunk-ej7m406s.js");return`<script data-stx-scoped data-stx-run="always" data-stx-modules src="${B(L)}"></script>`}return`<script data-stx-scoped data-stx-run="always" data-stx-modules>${L.replace(/<\/script/gi,"<\\/script")}</script>`}catch{return null}}function fw(x,v=""){let k=Lg(x,"data-stx-runtime");if(!k)return x;let E=Xs(x);if(E===-1||E===k.start){if(!v)return x;return x.slice(0,k.end)+v+x.slice(k.end)}if(E<k.start)return x.slice(0,E)+x.slice(k.start,k.end)+v+`
|
|
2003
|
-
`+x.slice(E,k.start)+x.slice(k.end);let C=x.slice(k.start,k.end),j=x.slice(0,k.start)+x.slice(k.end),L=Xs(j);if(L===-1)return C+v+`
|
|
2004
|
-
`+j;return j.slice(0,L)+C+v+`
|
|
2005
|
-
`+j.slice(L)}function pw(x){let v=/\x00STX_ESC_MUSTACHE_OPEN\x00([\s\S]*?)\x00STX_ESC_MUSTACHE_CLOSE\x00/g;return x.replace(v,(k,E,C)=>{let j=x.slice(0,C);return j.lastIndexOf("<")>j.lastIndexOf(">")?`{{${E}}}`:`{<!--stx-literal-->{${E}}}`})}async function n(x,v,k,E,C){if(E.ssr===!1&&!E.autoShell&&E.buildMode==="spa")return x;if(v.__stx_signals_gate===void 0)v.__stx_signals_gate=he(x,k);let j=!v.__stxProcessingDepth;nn(v);for(let L of E._layerGraph?.configDependencies??[])C.add(L);if(j&&E.runtimeConfig)await an(v,k,E.runtimeConfig);if(j)Xu(v),v.__stx_head_injections=pl(),v.__stx_seo_staged=!1;if(!v.__stxProcessingDepth)v.__stxProcessingDepth=0;if(v.__stxProcessingDepth++,!v.__onceStore)v.__onceStore=new Set;if((E.debug||!fe()&&!pn())&&k&&k.endsWith(".stx"))Ns(x,k);try{return await U.timeAsync("template-processing",async()=>{let L=await gw(x,v,k,E,C);if(j)L=kl(L);if(j&&E.autoShell&&E.buildMode!=="compile"){let B=de(E.app?.head,{known:ln,source:"app.head"}),F=(v.__stx_runtime_head||null)??Ts(),X=(v.__stx_head_raw||"").trim(),G,J=X.match(/<title[^>]*>([\s\S]*?)<\/title>/i);if(J)G=J[1].trim(),X=X.replace(J[0],"").trim();let ne=v.__sections?.title,re=F.title||G||ne,se=!F.title&&(!!G||!!ne),oe=F.meta||[],ie=new Set(oe.map((_e)=>wr(_e)).filter(Boolean)),ge={...B,...re&&{title:re},meta:[...(B.meta||[]).filter((_e)=>!ie.has(wr(_e))),...oe],link:[...B.link||[],...F.link||[]],script:[...B.script||[],...F.script||[]],headRaw:[B.headRaw,X].filter(Boolean).join(`
|
|
2006
|
-
`),...F.htmlAttrs&&{htmlAttrs:eg(B.htmlAttrs,F.htmlAttrs)},...F.bodyAttrs&&{bodyAttrs:{...B.bodyAttrs||{},...F.bodyAttrs}}},ue=vl(L);if(L=Hn(L,ge,{...se&&{titleIsHtml:!0},...E.app?.colorMode&&{colorMode:E.app.colorMode}},ue),ue)L=ng(L,B),L=zn(L,ge.htmlAttrs);let xe=L.match(/<!-- stx-layout: ([^ ]+) -->/);if(xe&&L.includes("<head")){let _e=xe[1],Ce=cr(_e);L=L.replace(/<head\b[^>]*>/i,(Ee)=>`${Ee}
|
|
2007
|
-
<meta name="stx-layout" content="${Ag(_e)}">
|
|
2008
|
-
<meta name="stx-layout-group" content="${Ag(Ce)}">`)}let we=L.match(/function (__stx_setup_\w+)\(/),$e=we?An(L):null;if(we&&$e&&!/\bdata-stx=/.test($e.tag)){L=bs(L,(Ce,Ee)=>`<body${Ee} data-stx="${we[1]}">`);let _e=new RegExp(`(<(?!body)[a-zA-Z][^>]*) data-stx="${we[1]}"`,"i");L=L.replace(_e,"$1")}}if(j){let B=v.__stx_head_injections??pl(),z=tg(L);if(z!==null)B.beforeClose.push(z);let F=Hp(L);if(F!==null)B.afterOpen.push(F);if(E.offline?.enabled&&!L.includes("data-stx-offline"))B.beforeClose.push(qp);L=Fp(L,B);let X=E.app?.colorMode;if(X)L=Fn(L,X)}if(j)if(Lg(L,"data-stx-runtime")){let z=null,F=null,X=null,G=null,J=null;try{let{getStoreScript:re}=await ut("stx/store-loader",()=>import("./chunk-58ymq1h4.js")),se=E.storesDir,oe=await re(se);if(oe)X=`<script data-stx-stores>${oe}</script>`,F=await Ig("data-stx-stores",oe,E)??X}catch{}z=await Pg([L,X],E,C);try{let{getFrameworkComposableScript:re}=await ut("stx/framework-composables",()=>import("./chunk-3pc22sve.js"));J=await re(L)}catch{}try{let{getComposableScript:re}=await ut("stx/composable-loader",()=>import("./chunk-vgvsefz8.js")),se=E.composablesDir,oe=[z,X,J].filter((ge)=>ge!==null),ie=await re(E._layerComposableDirs??se,L,oe);if(ie)G=await Ig('data-stx-scoped data-stx-run="always" data-stx-composables',ie,E)??`<script data-stx-scoped data-stx-run="always" data-stx-composables>${ie}</script>`}catch{}let ne=[z,F,G,J].filter((re)=>re!==null).map((re)=>`
|
|
2009
|
-
${re}`).join("");L=fw(L,ne)}else{let z=await Pg([L],E,C);if(z){let F=L.search(/<script\b[^>]*>(?:(?!<\/script>)[\s\S])*?__stxModules\[/i);if(F!==-1)L=L.slice(0,F)+z+`
|
|
2010
|
-
`+L.slice(F)}}if(j)L=Up(L);if(j&&v.__stx_inject_css!==!1)L=await f(L,void 0,E.buildMode==="serve",!0);else if(j)L=qs(L);if(L=L.replace(/\x00STX_ESCAPED_AT\x00/g,"@"),L=pw(L),j&&v.__stx_runtime_config)L=Ke(L,v.__stx_runtime_config);if(j&&!v.__stx_defer_server_data){let B=Bn(v);if(B){let z=/<head\b[^>]*>/i.exec(L),F=z?z.index+z[0].length:0;L=L.slice(0,F)+B+L.slice(F)}}return L})}catch(L){if(L instanceof nr)throw L;let B=L instanceof Error?L.message:String(L),z=new K(`Template processing failed: ${B}`,k,void 0,void 0,x.substring(0,200)+(x.length>200?"...":""));if(_.log(z,{filePath:k,context:v}),Et.logDetailedError(z,{filePath:k,template:x.substring(0,500)}),E.debug)throw z;return _s.createFallbackContent("Template Processing",z)}}async function gw(x,v,k,E,C){let j=process.cwd(),L={...E,partialsDir:E.partialsDir&&!cn.isAbsolute(E.partialsDir)?cn.resolve(j,E.partialsDir):E.partialsDir,componentsDir:E.componentsDir&&!cn.isAbsolute(E.componentsDir)?cn.resolve(j,E.componentsDir):E.componentsDir,layoutsDir:E.layoutsDir&&!cn.isAbsolute(E.layoutsDir)?cn.resolve(j,E.layoutsDir):E.layoutsDir},B=L,z=x;await yw(k,v),hw(v,B),z=await te(()=>Ap(z,v,k,B),z,(we)=>{_.log(we,{filePath:k,phase:"pre-processing-middleware"},"warning"),console.warn(`[stx] pre-processing middleware failed for ${k}: ${we.message}`)}),z=z.replace(/\{\{--[\s\S]*?--\}\}/g,"");let F=En(z,Le,(we,$e)=>`\x00STX_HTML_COMMENT_${$e}\x00`);z=F.output;let X=F.tokens,G=(we)=>X.length===0?we:we.replace(/\x00STX_HTML_COMMENT_(\d+)\x00/g,($e,_e)=>X[Number(_e)]??""),J="\x00STX_ESCAPED_AT\x00",ne="\x00STX_ESC_MUSTACHE_OPEN\x00",re="\x00STX_ESC_MUSTACHE_CLOSE\x00";z=z.replace(/@@/g,J),z=z.replace(/@\{\{([\s\S]*?)\}\}/g,(we,$e)=>`${ne}${$e}${re}`),z=Op(z),z=await vg(z,k,C);let se={};z=cs(z,se);let oe={...v.__sections||{}},ie="",ge=ef(je(x)),ue=/@nolayout\b/.test(z)||ge===!1;if(/@nolayout\b/.test(z))z=z.replace(/@nolayout\b\s*/g,"");let xe=z.match(/@(?:layout|extends)\(\s*['"]([^'"]+)['"]\s*\)/);if(xe)ie=xe[1],z=z.replace(/@(?:layout|extends)\(\s*['"]([^'"]+)['"]\s*\)/g,"");else if(typeof ge==="string"){if(ie=ge,!/@section\s*\(/.test(z))z=`@section('content')
|
|
2011
|
-
${z.trim()}
|
|
2012
|
-
@endsection`}if(!ie&&!ue&&B.defaultLayout){let we=rn(z),$e=/@section\s*\(/.test(z);if(!we||$e){let _e="",Ce=cn.dirname(k),Ee=B.layoutsDir?cn.dirname(B.layoutsDir):process.cwd();for(let Te=0;Te<20;Te++){let Re=cn.join(Ce,"_layout.stx");if(await r(Re)){_e=Re;break}let ke=cn.dirname(Ce);if(ke===Ce||ke.length<Ee.length)break;Ce=ke}if(_e)ie=_e;else if(B.layoutsDir){let Te=cn.isAbsolute(B.layoutsDir)?B.layoutsDir:cn.resolve(process.cwd(),B.layoutsDir),Re=cn.join(Te,`${B.defaultLayout}.stx`);if(await r(Re))ie=Re}if(ie&&!$e)z=`@section('content')
|
|
2013
|
-
${z.trim()}
|
|
2014
|
-
@endsection`}}if(ie&&z.includes("<script")){let we=bn(z),$e=we.scripts.map((_e)=>Dg(_e,k)??_e);z=Vr(we.output,$e)}if(z=z.replace(/@section\(\s*['"]([^'"]+)['"]\s*,\s*['"]([^'"]+)['"]\s*\)/g,(we,$e,_e)=>(oe[$e]=_e,"")),z=z.replace(/@section\(\s*['"]([^'"]+)['"]\s*,\s*([^)]+?)\s*\)/g,(we,$e,_e)=>{if(/^(['"]).*\1$/.test(_e.trim()))return we;try{let Ce=c(_e.trim(),v);if(Ce===void 0)return we;return oe[$e]=String(Ce??""),""}catch{return we}}),z=z.replace(/@section\(\s*['"]([^'"]+)['"]\s*\)([\s\S]*?)(?:@endsection|@show)/g,(we,$e,_e)=>{if(_e.includes("@parent"))oe[$e]=_e.replace("@parent",Mr);else oe[$e]=_e.trim();return""}),v.__sections=oe,z=z.replace(/@(?:yield|slot)\(\s*['"]([^'"]+)['"](?:,\s*['"]([^'"]+)['"])?\)/g,(we,$e,_e)=>oe[$e]||_e||""),!("slot"in v)||v.slot===void 0)z=z.replace(/\{\{\s*slot\s*\}\}/g,()=>oe.content||"");if(z=ls(z,se),ie){let we=[],$e=bn(z),_e=En($e.output,Fr,(Ce,Ee)=>`\x00STX_ORPHAN_STYLE_${Ee}\x00`);if(z=_e.output.replace(/\x00STX_(SCRIPT|ORPHAN_STYLE)_(\d+)\x00/g,(Ce,Ee,Te)=>{let Re=Ee==="SCRIPT"?Dg($e.scripts[Number(Te)],k):_e.tokens[Number(Te)];if(Re)we.push(Re);return""}),we.length>0){let Ce=we.join(`
|
|
2015
|
-
`);oe.content=oe.content?`${oe.content}
|
|
2016
|
-
${Ce}`:Ce,v.__sections=oe}}if(ie)try{let we;if(cn.isAbsolute(ie))we=ie,C.add(ie);else we=await te(()=>Wn(ie,k,L,C),null,()=>{throw new K(`Failed to resolve layout path: ${ie}`,k,void 0,void 0,`Layout referenced from ${k}`)});if(!we){let Re=(Xe)=>{if(!Xe)return[];try{let Pe=cn.isAbsolute(Xe)?Xe:cn.resolve(process.cwd(),Xe);return uw.readdirSync(Pe).filter((Ie)=>Ie.endsWith(".stx")).map((Ie)=>Ie.replace(/\.stx$/,""))}catch{return[]}},ke=[...Re(L.layoutsDir),...Re(L.fallbackLayoutsDir)].filter((Xe,Pe,Ie)=>Ie.indexOf(Xe)===Pe).sort(),Ae=`Layout not found: ${ie} (referenced from ${k})`+(ke.length>0?`. Available layouts: ${ke.join(", ")}`:L.layoutsDir?`. No .stx layouts found in ${L.layoutsDir}`:"");if(_.log(Error(Ae),{layoutPath:ie,filePath:k,available:ke},"error"),console.error(`[stx] ${Ae}`),L.debug)throw new K(Ae,k);return z}let $e=await te(()=>Bun.file(we).text(),"",()=>{throw new K(`Failed to read layout file: ${we}`,k,void 0,void 0,"Layout content could not be loaded")});$e=Tg($e,we);let _e=$e.match(/@(?:layout|extends)\(\s*['"]([^'"]+)['"]\s*\)/);if(_e){if(L.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(oe[Pe]&&oe[Pe].includes(Mr)){let Ze=oe[Pe].indexOf(Mr);oe[Pe]=oe[Pe].slice(0,Ze)+Ie+oe[Pe].slice(Ze+Mr.length)}else if(!oe[Pe])oe[Pe]=Ie;let Ae={...v,__sections:oe},Xe=`@layout('${_e[1]}')${ke}`;return await n(Xe,Ae,we,L,C)}let Ce=$e.replace(/\{\{--[\s\S]*?--\}\}/g,""),Ee=cs(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(oe[ke]){let Xe=oe[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=mw(Ee,oe),Ee=Ee.replace(/\{\{\s*slot\s*\}\}/g,()=>oe.content||""),Ee=ls(Ee,se),v.__originalFilePath=k,z=await Ng(Ee,v,we,L,C),z=`<!-- stx-layout: ${ie} -->
|
|
2017
|
-
${z}`,G(z)}catch(we){return _.log(we instanceof Error?we:Error(String(we)),{layoutPath:ie,filePath:k},"error"),`[Error processing layout: ${we instanceof Error?we.message:String(we)}]`}return G(await Ng(z,v,k,L,C))}function mw(x,v){return x.replace(/@(?:yield|slot)\(\s*['"]([^'"]+)['"]\s*(?:,\s*['"]([^'"]+)['"]\s*)?\)/g,(k,E,C)=>{let j=v[E];if(j!==void 0){if(!new RegExp(`@(?:yield|slot)\\(\\s*['"]${E.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}['"]`).test(j))return j}return C||""})}function hw(x,v){if(x.__stx_sfc_mode=!0,x.__stx_options=v,v.buildMode)x.__stx_buildMode=v.buildMode;let k=v.envPrefix||"STX_PUBLIC_",E={};for(let[C,j]of Object.entries(process.env))if(C.startsWith(k)&&j!==void 0)E[C]=j;x.$env=E}async function yw(x,v){await te(()=>Dp(x,v),void 0,(k)=>{_.log(k,{filePath:x,phase:"view-composer"},"warning"),console.warn(`[stx] view composer failed for ${x}: ${k.message}`)})}var Rl="data-stx-source";function Dg(x,v){if(!x)return x;let k=/^<script\b([^>]*)>/i.exec(x);if(!k||!/\bserver\b/.test(k[1])||k[1].includes(Rl))return x;return`<script ${Rl}="${encodeURIComponent(v)}"${x.slice(7)}`}function xw(x){let v=new RegExp(`${Rl}="([^"]*)"`).exec(x);return v?decodeURIComponent(v[1]):void 0}function Mg(x){return x.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function Og(x,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> ${v==="module-resolution"?"imports a module that does not resolve":v==="syntax"?"does not parse":"names something that does not exist"}, so this component rendered nothing.</strong><span style="display:block;opacity:.85">${Mg(x)}</span><span style="display:block;margin-top:4px">${Mg(k)}</span></div>`}async function bw(x,v,k,E){let{scanScriptTags:C}=await ut("stx/signal-processing",()=>import("./chunk-avjgetkh.js")),j=[],L=!fe()&&!pn();for(let z of C(x)){let F=z.attrs;if(!/\bserver\b/.test(F))continue;let X=z.start+z.fullMatch.indexOf(">")+1,G=jg(x,X);if(G===-1)continue;let J=x.slice(X,G);if(!J.trim())continue;let ne=xw(F)??k,re={index:z.start,length:G+9-z.start};try{let{extractVariables:se}=await ut("stx/variable-extractor",()=>import("./chunk-hd64hz1n.js"));await se(J,v,ne,{preserveExisting:!0,onFailure:(oe)=>{if(oe.kind==="unknown")return;if(E?.onServerScriptError?.({sourcePath:ne,kind:oe.kind,message:oe.message}),!L)return;j.push({...re,markup:Og(ne,oe.kind,oe.message)})}})}catch(se){let oe=se instanceof Error?se:Error(String(se));if(_.log(oe,{filePath:ne,phase:"server-script-extraction"},"warning"),console.warn(`[stx] server <script> extraction failed in ${ne}: ${oe.message}`),L)j.push({...re,markup:Og(ne,"unknown",oe.message)})}}if(j.length===0)return x;let B=x;for(let z of j.sort((F,X)=>X.index-F.index))B=B.slice(0,z.index)+z.markup+B.slice(z.index+z.length);return B}async function vw(x,v,k){try{let{interpolateScriptsInTemplate:E}=await ut("stx/expressions",()=>import("./chunk-eam7eann.js"));return E(x,v,{skipServer:!0})}catch(E){let C=E instanceof Error?E:Error(String(E));return _.log(C,{filePath:k,phase:"script-expression-interpolation"},"warning"),console.warn(`[stx] script expression interpolation failed in ${k}: ${C.message}`),x}}async function Ng(x,v,k,E,C){let j=x,L=E;if(j=await bw(j,v,k,E),j=await vw(j,v,k),j=await xp(j,v,k),j=await bp(j,v,k),j=await hf(j,v,k,L),he(j))j=Wo(j,v),j=ss(j,v),j=rs(j,v);j=qo(j);let{processStreamDirectives:B}=await ut("stx/streaming",()=>import("./chunk-14x69rt4.js"));j=B(j,v),j=Yo(j,v,k,L,!0),j=await Bp(j,v,k,L,C),j=await es(j,v,k,L,C),j=ru(j,v,k,L);let{processDeferDirectives:z}=await ut("stx/defer",()=>import("./chunk-pe9hxhrb.js"));j=z(j,v,k);let{processTeleportDirectives:F}=await ut("stx/teleport",()=>import("./chunk-m90a5dpn.js"));j=F(j,v,k);let{processTransitionDirectives:X,processTransitionAttributes:G}=await ut("stx/transitions",()=>import("./chunk-m3f50p6c.js"));j=X(j,v,k),j=G(j);let{processErrorBoundaryDirectives:J,stripRenderFailedMarkers:ne}=await ut("stx/error-boundaries",()=>import("./chunk-h85hrwkq.js"));j=J(j,v,k),j=ne(j);let{processSuspenseDirectives:re}=await ut("stx/suspense",()=>import("./chunk-bcgth8qf.js"));j=re(j,v,k);let{processAsyncDirectives:se}=await ut("stx/async-components",()=>import("./chunk-by1s70jp.js"));j=se(j,v,k);let{processKeepAliveDirectives:oe}=await ut("stx/keep-alive",()=>import("./chunk-fm3k5v8s.js"));j=oe(j,v,k);let{processVirtualListDirectives:ie,processVirtualGridDirectives:ge,processInfiniteListDirectives:ue}=await ut("stx/virtual-scrolling",()=>import("./chunk-mmp7x8f0.js"));j=ie(j,v,k),j=ge(j,v,k),j=ue(j,v,k);let{processPartialHydrationDirectives:xe,processStaticDirectives:we}=await ut("stx/partial-hydration",()=>import("./chunk-v404gvm0.js"));j=xe(j,v,k),j=we(j);let{processComputedDirectives:$e,processWatchDirectives:_e}=await ut("stx/computed",()=>import("./chunk-1xdzcy9d.js"));j=$e(j,v,k),j=_e(j,v,k);let{processFormValidationDirectives:Ce}=await ut("stx/forms-validation",()=>import("./chunk-hz6a476h.js"));j=Ce(j,v,k);let{processHeadDirective:Ee,processTitleDirective:Te,processMetaDirective:Re,resetHead:ke}=await ut("stx/head",()=>import("./chunk-e593pr1r.js"));if(!v.__stx_head_preset&&!v.__stx_runtime_head)ke();let Ae=Ee(j);if(j=Ae.content,Ae.headContent)v.__stx_head_raw=`${v.__stx_head_raw||""}${Ae.headContent}
|
|
2018
|
-
`;if(j=Te(j,v),j=Re(j,v,k),j=Pp(j),j=Ac(j,v),j=mf(j),j=Rp(j),j=await as(j,v,k,L,C),j=await es(j,v,k,L,C),v.__stxProcessingDepth===1)j=Zu(j,v);if(j=j.replace(/@push\s*\(\s*['"][^'"]+['"]\s*\)[\s\S]*?@endpush/g,""),j=kl(j),j=ar(j,v,k),j=is(j),j=tf(j,v,{filePath:k,buildMode:L.buildMode}),j=Ic(j,v),j=Pc(j,v),j=so(j,v),j=$f(j,v),j=_f(j,v),j=await zg(j,v,k,L),j=await Bg(j,v,k),j=await li(j,v,k,L),j=ui(j,v,k,L),j=Ss(j,v,k,L),j=ks(j,v,k),j=Cs(j,v,k,L),j=pf(j,v,k,L),j=ds(j,v),j=ps(j),j=Sg(j),!L.skipEventDirectives)j=mu(j,v,k);if(j=sf(j,v,k),L.debug){let et=/\bx-data\s*=/.test(j),it=ns(x);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=op(j,v),j=await W(j,v,k),j=Eg(j),j=Cg(j),j=Yd(j);let{processXElementDirectives:Xe}=await ut("stx/x-element",()=>import("./chunk-zhxdpzga.js"));j=Xe(j);let Pe=v.__originalFilePath||k,Ie=Ne(v);if(j=await Ko(j,L,Pe,Ie),j=vf(j,v),j=await Ip(j,v,k,L),L.media?.image?.autoSiblings){let et=L.publicDir||"public",{rewriteImagesWithSiblings:it}=await ut("stx/image-optimization/auto-sibling",()=>import("./chunk-nqcg2bf0.js"));j=await it(j,{publicDir:et})}if(L.seo?.enabled)j=$s(j,v,L);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-e593pr1r.js")),Rt=v.__stx_runtime_head??at();if(Rt.title||Rt.meta?.length||Rt.link?.length){let et=nt(Rt);if(et)j=Ze(j,et)}if(Ae.headContent)j=Ze(j,Ae.headContent,!Rt.title);if(L.csp?.enabled&&L.csp.addMetaTag)j=df(j,L.csp,v);if(L.analytics?.enabled)j=Qd(j,L);if(L.heatmap?.enabled)j=ou(j,L);if(L.pwa?.enabled&&L.pwa.autoInject!==!1){let{injectPwaTags:et}=await ut("stx/pwa/inject",()=>import("./chunk-cwc3p6p7.js"));j=et(j,L)}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
|
-
${Zd()}
|
|
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-avjgetkh.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=jg(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=Gi(j,k);if(Pt.hasScoped)j=Pt.html;let pt=v.__stx_event_bindings||[],Lt=!1,Qn=[],Sn=/\s:[a-z][\w.-]*\s*=/.test(j),{scanScriptTags:sr}=await ut("stx/signal-processing",()=>import("./chunk-avjgetkh.js"));for(let et of sr(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;gs(gt,k,E.strict,v.__originalFilePath);let Dt=await me(gt,{eventBindings:pt,attrs:it,hasColonDirectives:Sn,templateContent:x,filePath:k,projectRoot:process.cwd(),production:E.buildMode==="compile",serverData:Ie});j=j.replace(et,()=>Dt)}if(Lt)v.__stx_event_bindings=[];if(!Lt&&v.__stxProcessingDepth===1){let et=v.__stx_event_bindings||[];if(et.length>0){let it=ha(et);if(it){let gt=j.lastIndexOf("</body>");j=gt===-1?j+it:j.slice(0,gt)+it+`
|
|
2032
|
-
`+j.slice(gt)}v.__stx_event_bindings=[]}}if(!ae(j)&&ag(j))j=await Ro(j,L);if(j=cg(j),L.csp?.enabled&&L.csp.useNonce&&typeof v.cspNonce==="string")j=ff(j,v.cspNonce);return j}import Qg from"path";import Al from"fs";import Ti from"path";function Fg(x,v,k,E){let C=0;for(let j=v;j<x.length;j++)if(x[j]===k)C++;else if(x[j]===E&&!(E===">"&&x[j-1]==="=")){if(--C===0)return j}return-1}function ww(x){let v=s(x),k=0,E=0,C=[];for(let j=0;j<v.length;j++)if("([{".includes(v[j]))k++;else if(")]}".includes(v[j]))k--;else if(v[j]===","&&k===0)C.push(x.slice(E,j).trim()),E=j+1;return C.push(x.slice(E).trim()),C}function Tl(x,v){let k=s(x),E=new RegExp(`\\b(?:${v.map((C)=>C.replace(/[$]/g,"\\$&")).join("|")})\\s*(?=[<(])`,"g");for(let C of k.matchAll(E)){let j=C.index+C[0].length,L="";if(k[j]==="<"){let z=Fg(k,j,"<",">");if(z<0)continue;L=x.slice(j+1,z),j=z+1;while(/\s/.test(k[j]||"")&&j<k.length)j++}if(k[j]!=="(")continue;let B=Fg(k,j,"(",")");if(B>=0)return{type:L,args:ww(x.slice(j+1,B))}}return null}var Wg=`
|
|
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 Vg(x,v){let k=[],E={defineProps:["defineProps"],defineEmits:["defineEmits"],withDefaults:["withDefaults"]},C=s(x),j=x.replace(/\bimport\s+(?:type\s+)?(\{[^}]*\}|\*\s+as\s+[\w$]+|[\w$]+)\s+from\s*(['"])([^'"]+)\2\s*;?/g,(J,ne,re,se,oe)=>{if(C.slice(oe,oe+6)!=="import")return J;if(se.endsWith(".stx"))return"";let ie=`${v}Import${k.length}`;if(k.push(`import * as ${ie} from ${JSON.stringify(se)};`),ne.startsWith("*"))return`import ${ne.replace(/^\*\s+as\s+/,"")} = ${ie};`;if(!ne.startsWith("{"))return`import ${ne} = ${ie}.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} = ${ie}.${ue};`}).join(`
|
|
2041
|
-
`)}),L=Tl(x,E.defineProps),B=Tl(x,E.defineEmits),z=Tl(x,E.withDefaults);if(!L&&!B)return{declarations:"",props:null,events:null};let F=[],X=null,G=null;if(L){F.push(`const __options = (${L.args[0]||"{}"}) as const;`),F.push(`const __defaults = (${z?.args[1]||"{}"});`);let J=L.type||"__StxOptions<typeof __options>";F.push(`export type __StxProps = __StxDefaults<${J}, keyof typeof __defaults | __StxDefaulted<typeof __options>>;`),X=`${v}.__StxProps`}if(B)F.push(`const __events = (${B.args[0]||"[]"}) as const;`),F.push(`export type __StxEvents = ${B.type||"Record<(typeof __events)[number], any[]>"};`),G=`${v}.__StxEvents`;return{declarations:`${k.join(`
|
|
2042
|
-
`)}
|
|
2043
|
-
namespace ${v} {
|
|
2044
|
-
${j}
|
|
2045
|
-
${F.join(`
|
|
2046
|
-
`)}
|
|
2047
|
-
}`,props:X,events:G}}function*Sw(x){let v=/<([A-Za-z][\w.-]*)(?=[\s/>])/g,k;while(k=v.exec(x)){let E=v.lastIndex,C=[];while(E<x.length){while(/\s/.test(x[E]||""))E++;if(x[E]===">"||x.slice(E,E+2)==="/>"){E+=x[E]===">"?1:2;break}let j=/^[^\s=/>]+/.exec(x.slice(E))?.[0];if(!j){E++;continue}let L=E;E+=j.length;while(/\s/.test(x[E]||""))E++;if(x[E]!=="="){C.push({name:j,value:!0,offset:L,braced:!1});continue}E++;while(/\s/.test(x[E]||""))E++;let B=x[E],z=B==="{",F=B==='"'||B==="'";if(F||z)E++;let X=E;if(z){let G=s(x.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(F)while(E<x.length&&x[E]!==B)E++;else while(E<x.length&&!/[\s/>]/.test(x[E]))E++;if(C.push({name:j,value:x.slice(X,E),offset:X,braced:z}),F||z)E++}v.lastIndex=E,yield{name:k[1],offset:k.index,attributes:C}}}function Ug(x,v,k){let E=[],C=[Wg,"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,L=new Map,B=new Map,z=k.scriptCode(x,k.filePath),F=s(z);for(let re of z.matchAll(/\bimport\s+(\{[^}]+\}|[\w$]+)\s+from\s*['"]([^'"]+)['"]/g)){if(F.slice(re.index,re.index+6)!=="import")continue;let se=re[2],oe=Ti.isAbsolute(se)||se.startsWith(".")?Ti.resolve(Ti.dirname(k.filePath),se):ao(se,Ti.dirname(k.filePath));if(!oe)continue;let ie=oe.endsWith(".stx")?oe:Al.existsSync(`${oe}.stx`)?`${oe}.stx`:void 0,ge=ie?null:oo(oe,!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=ie||ge?.get(we)||ge?.get(we.toLowerCase());if(_e)B.set($e,_e),B.set($e.toLowerCase(),_e),B.set($e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),_e)}}for(let re of v.matchAll(/@import\s*\(([^)]+)\)/g))for(let se of re[1].matchAll(/['"]([^'"]+)['"]/g)){let oe=co(se[1],k.filePath,k).find((ie)=>Al.statSync(ie,{throwIfNoEntry:!1})?.isFile());if(oe)B.set(Ti.basename(se[1]).replace(/\.stx$/,""),oe)}let X={__importedComponents:B},G=new Map,J=(re,se,oe)=>{let ie=x.slice(0,re);return{code:se,offset:re,attribute:oe,anchor:!0,kind:"directive",line:ie.split(`
|
|
2048
|
-
`).length,column:re-ie.lastIndexOf(`
|
|
2049
|
-
`)}},ne=(re,se,oe)=>E.push({expression:re,statement:{text:se+re.code+oe,prefixLength:se.length}});for(let re of Sw(v)){if(tn(re.name)||re.name==="component")continue;let se=Cf(re.name,k.filePath,k,X);if(!se)continue;let oe=G.get(se);if(!oe){let ge;try{ge=k.readComponent?k.readComponent(se):Al.readFileSync(se,"utf8")}catch{continue}if(ge===void 0)continue;L.set(se,ge),oe=Vg(k.scriptCode(ge,se),`__StxComponent${G.size}`),G.set(se,oe),C.push(oe.declarations)}let ie=[];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(oe.events&&ge.value!==!0)j.set(xe,`__StxEvent<${oe.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(ie.push(_e),!oe.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<${oe.props}, ${JSON.stringify(_e)}>);`)}if(oe.props){let ge=[...new Set(ie)].map((xe)=>`${JSON.stringify(xe)}: undefined as any`).join(", "),ue=J(re.offset,`<${re.name}>`);E.push({expression:ue,statement:{text:`;void ({ ${ge} } satisfies ${oe.props} & Record<string, unknown>);`,prefixLength:0}})}}return{declarations:G.size?C.join(`
|
|
2050
|
-
`):"",checks:E,events:j,dependencies:L}}var Hg=/<script(\s[^>]*)?>([\s\S]*?)<\/script>/gi;function $w(x){let v=(k)=>k.replace(/[^\n]/g," ");return x.replace(/<!--[\s\S]*?-->/g,v).replace(/\{\{--[\s\S]*?--\}\}/g,v)}function He(x){let v=[],k=$w(x);Hg.lastIndex=0;let E;while((E=Hg.exec(k))!==null){let C=(E[1]||"").trim(),j=(E[0].match(/^<script(?:\s[^>]*)?>/i)?.[0]??"<script>").length,L=(E[0].match(/<\/script\s*>$/i)?.[0]??"</script>").length,B=E.index+j,z=E.index+E[0].length-L,F=x.slice(B,z);if(/\bsrc\s*=/.test(C))continue;let X=C.match(/\btype\s*=\s*["']([^"']+)["']/i);if(X&&!/^(?:module|text\/(?:javascript|typescript))$/i.test(X[1]))continue;let G=/\bserver\b/.test(C)?"server":/\bclient\b/.test(C)?"client":"plain",J=Ai(x,B);v.push({kind:G,code:F,startLine:J,startColumn:Ii(x,B),offset:B,attrs:C})}return v}function Ai(x,v){let k=1;for(let E=0;E<v&&E<x.length;E++)if(x.charCodeAt(E)===10)k++;return k}function Ii(x,v){let k=x.lastIndexOf(`
|
|
2051
|
-
`,v-1)+1;return v-k+1}function Po(x){let v=x.split(""),k=(C,j)=>{for(let L=C;L<j&&L<v.length;L++)if(v[L]!==`
|
|
2052
|
-
`)v[L]=" "},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 C of E){C.lastIndex=0;let j;while((j=C.exec(x))!==null)k(j.index,j.index+j[0].length)}return v.join("")}function _w(x){let v=0,k="";for(let E=0;E<x.length;E++){let C=x[E];if(k){if(C==="\\"){E++;continue}if(C===k)k="";continue}if(C==='"'||C==="'"||C==="`"){k=C;continue}if(C==="("||C==="["||C==="{"){v++;continue}if(C===")"||C==="]"||C==="}"){v--;continue}if(C==="|"&&v===0){if(x[E+1]==="|"){E++;continue}if(x[E-1]==="|")continue;return x.slice(0,E)}}return x}var em=new Set([":for","x-for","v-for"]),Do=/(?:^|\s)((?::|x-|v-|@)[\w.:-]+)\s*=\s*(["'])([\s\S]*?)\2/g,Il="__stx_interpolated",qg="__StxElement",tm="__StxTemplateValue",kw=`type ${tm}<T> = T extends { readonly _isSignal: true } | { readonly _isDerived: true } ? (T extends () => infer V ? T & V : T) : T`;function Kg(x){return x.replace(/\{\{[\s\S]*?\}\}/g,Il).replace(/\{!![\s\S]*?!!\}/g,Il)}function ms(x){return x.replace(/\{\{[\s\S]*?\}\}|\{!![\s\S]*?!!\}/g,(v)=>{let k=v.split(`
|
|
2053
|
-
`).length-1,E=v.length-k;return`0${" ".repeat(Math.max(0,E-1))}${`
|
|
2054
|
-
`.repeat(k)}`})}var Ew=["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"],Cw=new RegExp(String.raw`^[ \t]*@(?:${Ew.join("|")})\b[ \t]*(\([^\n)]*\))?[ \t]*$`,"gm");function hs(x){return x.replace(Cw,(v)=>v.replace(/[^\n]/g," "))}var Xg=new Set(["x-cloak","x-ref","x-transition","x-teleport","v-slot","x-hydrate",":key","x-tooltip","x-tooltip-position"]);function gc(x){let v=Po(x),k=[],E=/(@?)\{\{([\s\S]*?)\}\}|(@?)\{!!([\s\S]*?)!!\}/g,C;while((C=E.exec(v))!==null){if(C[1]||C[3])continue;let B=C[2]??C[4]??"",z=C[2]!==void 0?2:3,F=_w(B);if(!F.trim())continue;let X=C.index+z+(F.length-F.trimStart().length);k.push({code:F.trim(),line:Ai(v,X),column:Ii(v,X),offset:X,kind:"interpolation"})}let j=/@(if|elseif|else\s+if|unless)\b\s*\(/g;while((C=j.exec(v))!==null){let L=C.index+C[0].length-1,B=0,z=L;for(;z<v.length;z++){let J=v[z];if(J==="(")B++;else if(J===")"){if(B--,B===0)break}}if(B!==0)continue;let F=v.slice(L+1,z),X=F.trim();if(j.lastIndex=z+1,!X)continue;let G=L+1+(F.length-F.trimStart().length);k.push({code:X,line:Ai(v,G),column:Ii(v,G),offset:C.index,kind:"condition"})}Do.lastIndex=0;while((C=Do.exec(v))!==null){let L=C[1],B=C[3]??"",z=L.replace(/\..*$/,"").replace(/^([^:].*?):.*$/,"$1");if(Xg.has(z)||Xg.has(L))continue;if(!B.trim())continue;let F=C.index+C[0].indexOf(C[2],C[0].indexOf(L)+L.length)+1;if(em.has(z)){let G=B.match(/\s+(?:in|of)\s+/);if(!G||G.index===void 0)continue;let J=B.slice(G.index+G[0].length),ne=G.index+G[0].length+(J.length-J.trimStart().length);k.push({code:Kg(J.trim()),line:Ai(v,F+ne),column:Ii(v,F+ne),offset:F+ne,kind:"directive",attribute:z});continue}let X=B.length-B.trimStart().length;k.push({code:Kg(B.trim()),line:Ai(v,F+X),column:Ii(v,F+X),offset:F+X,kind:"directive",attribute:z})}return k.sort((L,B)=>L.line-B.line||L.column-B.column),k}var Rw=2000;function Tw(x,v){let k=0,E=Math.min(x.length,v+Rw);for(let C=v;C<E;C++){let j=x[C];if(j==="(")k++;else if(j===")"){if(k--,k===0)return x.slice(v+1,C)}}return null}function Aw(x){let v=new Map,k=(B,z)=>{let F=B.split(/[,[\]{}()\s]+/).filter(Boolean);for(let X of F){let G=X.replace(/^\.\.\./,"").trim();if(!/^\$?[A-Z_$][\w$]*$/i.test(G))continue;let J=F.length===1?z:void 0,ne=v.get(G);if(!ne)v.set(G,{name:G,iterable:J});else if(ne.iterable!==J)ne.iterable=void 0}},E=/^\$?[A-Z_$][\w$]*$/i,C=(B)=>{let z=B.trim();return E.test(z)?z:void 0};for(let B of x.matchAll(/@for(?:each|else)\s*\(/g)){let z=Tw(x,B.index+B[0].length-1);if(z===null)continue;let F=kt(z);if(!F)continue;k(F.itemVar.replace(/=>/g," "),C(F.arrayExpr))}for(let B of x.matchAll(/@for\s*\(\s*(?:(?:let|const|var)\s+)?([\w$]+|\[[^\]]*\]|\{[^}]*\})\s+(of|in)\s+([^)]*)/g))k(B[1],B[2]==="of"?C(B[3]):void 0);for(let B of x.matchAll(/@for\s*\(\s*(?:let|const|var)\s+([\w$]+)\s*[=;]/g))k(B[1]);let j=Po(x);Do.lastIndex=0;let L;while((L=Do.exec(j))!==null){let B=L[1].replace(/\..*$/,"");if(!em.has(B))continue;let z=L[3].match(/\s+(?:in|of)\s+/);if(!z||z.index===void 0)continue;k(L[3].slice(0,z.index),C(L[3].slice(z.index+z[0].length)))}for(let B of x.matchAll(/@(?:php|js|ts)\b([\s\S]*?)@end(?:php|js|ts)\b/g))for(let z of B[1].matchAll(/\b(?:const|let|var|function|class)\s+([\w$]+)/g))k(z[1]);return[...v.values()].sort((B,z)=>B.name.localeCompare(z.name))}function Q(x){let v=new Set;for(let k of x.matchAll(/^\s*(?:export\s+)?(?:const|let|var)\s+([\w$]+)/gm))v.add(k[1]);for(let k of x.matchAll(/^\s*(?:export\s+)?(?:async\s+)?function\s*\*?\s*([\w$]+)/gm))v.add(k[1]);for(let k of x.matchAll(/^\s*(?:export\s+)?class\s+([\w$]+)/gm))v.add(k[1]);for(let k of x.matchAll(/^\s*(?:export\s+)?(?:const|let|var)\s*[[{]([^\]}]*)[\]}]/gm))for(let E of k[1].split(",")){let C=E.split(":").pop().split("=")[0].replace(/^\.\.\./,"").trim();if(/^[A-Z_$][\w$]*$/i.test(C))v.add(C)}return[...v].sort()}var Pl=["params","query","cookies","host","ip","setResponseStatus","setResponseHeader","notFound","request","url","definePageMeta","defineClientPayload","defineStore","props","$props"],Iw={$bool:"declare function $bool(value: unknown, fallback?: boolean): boolean",$num:"declare function $num(value: unknown, fallback?: number): number",$uid:"declare var $uid: string"};function ei(x=new Set){return[...Pl.filter((v)=>!x.has(v)).map((v)=>`declare var ${v}: any`),...Object.entries(Iw).filter(([v])=>!x.has(v)).map(([,v])=>v)].join(`
|
|
2055
|
-
`)}function ti(x){return new Set([...x.matchAll(/^declare (?:function|const|let|var)\s+([A-Za-z_$][\w$]*)/gm)].map((v)=>v[1]))}function nm(x){let v=/\bdefineClientPayload\s*\(\s*\{([\s\S]*?)\}\s*\)/g,k,E=!1,C=new Set,j=s(x);while((k=v.exec(j))!==null){E=!0;for(let L of Pw(k[1])){let B=L.split(":")[0].trim();if(/^[A-Za-z_$][\w$]*$/.test(B))C.add(B)}}return E?[...C]:null}function Pw(x){let v=[],k=0,E="";for(let C of x){if(C===","&&k===0){v.push(E),E="";continue}if(C==="("||C==="["||C==="{")k++;else if(C===")"||C==="]"||C==="}")k--;E+=C}return v.push(E),v.filter((C)=>C.trim().length>0)}function Dw(x){let v=/^[ \t]*import\b[\s\S]*?(?:from\s*['"][^'"]*['"]|['"][^'"]*['"])[ \t]*;?[ \t]*$/gm,k=[],E=x.replace(v,(C)=>(k.push(C.trim()),C.split(`
|
|
2056
|
-
`).map(()=>"").join(`
|
|
2057
|
-
`)));return{imports:k.join(`
|
|
2058
|
-
`),body:E}}function rm(x){let v=s(x),k=Array(v.length),E=0;for(let B=0;B<v.length;B++){let z=v[B];if(z==="}"||z===")"||z==="]")E=Math.max(0,E-1);if(k[B]=E,z==="{"||z==="("||z==="[")E++}let C=[],j=/^[ \t]*(?:export[ \t]+)?(interface|type)[ \t]+([A-Za-z_$][\w$]*)/gm,L;while((L=j.exec(v))!==null){if(k[L.index]!==0)continue;let B=L[1],z=L[2],F;if(B==="interface"){let X=v.indexOf("{",L.index);if(X===-1)continue;let G=0;F=-1;for(let J=X;J<v.length;J++)if(v[J]==="{")G++;else if(v[J]==="}"&&--G===0){F=J+1;break}if(F===-1)continue}else{let X=0;F=v.length;for(let G=v.indexOf("=",L.index)+1;G<v.length;G++){let J=v[G];if(J==="{"||J==="["||J==="("||J==="<")X++;else if(J==="}"||J==="]"||J===")"||J===">")X--;else if(X<=0&&(J===";"||J===`
|
|
2059
|
-
`&&!/[=|&,<([{]\s*$/.test(v.slice(Math.max(0,G-40),G)))){F=J===";"?G+1:G;break}}}C.push({name:z,text:x.slice(L.index,F).replace(/^[ \t]*export[ \t]+/,"")}),j.lastIndex=F}return C}function Mw(x){return new Set(rm(x).map((v)=>v.name))}function ni(x,v=""){let k=nm(x),E=Mw(v),C=rm(x).filter((F)=>!E.has(F.name)).map((F)=>F.text);if(!k){let F=Q(x).filter((X)=>!zi(v,X));if(F.length===0&&C.length===0)return"";return["",`// ${Nw}`,...C,...F.map((X)=>`declare var ${X}: any`)].join(`
|
|
2060
|
-
`)}if(k.length===0)return C.length>0?["",`// ${Zg}`,...C].join(`
|
|
2061
|
-
`):"";let{imports:j,body:L}=Dw(x),B=L.replace(/^[ \t]*export[ \t]+(?=(?:const|let|var|function|async|class)\b)/gm,""),z=["",`// ${Zg}`];if(j)z.push(j);return z.push(...C),z.push(`async function ${Gg}() {`,B,` return { ${k.join(", ")} }`,"}",`type ${Jg} = Awaited<ReturnType<typeof ${Gg}>>`,...k.map((F)=>`declare var ${F}: ${Jg}[${JSON.stringify(F)}]`)),z.join(`
|
|
2062
|
-
`)}function Ow(x){let k=s(x).split(""),E=0;for(let C=0;C<k.length;C++){let j=k[C];if(j==="{"||j==="("||j==="["){E++;continue}if(j==="}"||j===")"||j==="]"){E=Math.max(0,E-1);continue}if(E>0&&j!==`
|
|
2063
|
-
`)k[C]=" "}return Q(k.join(""))}function ri(x,v){if(nm(x)!==null)return[];let k=s(v),E=new Set(m);return Ow(x).filter((C)=>{if(E.has(C))return!1;if(Q(v).includes(C))return!1;return new RegExp(`(?<![.#\\w$])${C}(?![\\w$])`).test(k)})}var Zg="stx: types for the declared client payload (#1868)",Nw="stx: untyped bridge names \u2014 declare a defineClientPayload to check these (#1868)",Gg="__stxServerScope",Jg="__StxClientPayload";var Yg=["$env","$user","$slot","$slots","$attrs","$props","$page","$route","$loop","loop","$errors","$csrf","props","slot"];var jw=/^\s*[A-Z_$][\w$]*\s*=[^=]/i;function Lw(x){let v=new Map,k=/!|===|!==|==|!=|&&|\|\||<|>|\btypeof\b|\binstanceof\b|\bin\b/;for(let E of x){let C=s(E),{depths:j,balanced:L}=be(C);if(!L)continue;let B=/^([ \t]*(?:export[ \t]+)?const[ \t]+)([A-Za-z_$][\w$]*)[ \t]*(?::[^=\n]+)?=[ \t]*([^\n]+)$/gm;for(let z of C.matchAll(B)){let F=z.index??0;if(j[F+z[1].length]!==0)continue;let X=z[2],G=F+z[0].length-z[3].length,J=E.slice(G,F+z[0].length).trim().replace(/;$/,"").trim(),ne=z[3],re=k.test(ne)&&!/\bawait\b|=>|\bfunction\b|[{}]/.test(ne)&&!/[,+\-*/%&|?:=]$/.test(J)&&be(ne).balanced;v.set(X,v.has(X)||!re?null:J)}}return new Map([...v].filter((E)=>E[1]!==null))}function sm(x,v,k=0,E=new Set){if(v.size===0||k>=5)return x;let C=s(x),j="",L=0;for(let B of C.matchAll(/[A-Za-z_$][\w$]*/g)){let z=B.index??0,F=B[0],X=v.get(F);if(!X||E.has(F))continue;let G=C.slice(0,z).trimEnd(),J=C.slice(z+F.length).trimStart();if(G.endsWith(".")||/^:(?!:)/.test(J)&&/[{,]$/.test(G))continue;if(z>0&&/[\w$]/.test(C[z-1]))continue;j+=`${x.slice(L,z)}(${sm(X,v,k+1,new Set([...E,F]))})`,L=z+F.length}return j+x.slice(L)}function Bw(x,v){let k=/@(if|unless|elseif|else|endif|endunless)\b\s*(\()?/g,E=[],C;while((C=k.exec(x))!==null){if(C.index>v)break;let j=C[1];if(C.index===v){if(j==="elseif"){let B=E[E.length-1];if(B?.current)B.seen.push(B.current);if(B)B.current=null}break}if(j==="endif"||j==="endunless"){E.pop();continue}let L="";if(C[2]==="("){let B=0,z=C.index+C[0].length-1,F=z+1;for(;z<x.length;z++){let X=x[z];if(X==="(")B++;else if(X===")"){if(B--,B===0)break}}L=x.slice(F,z).trim(),k.lastIndex=z+1}if(j==="if")E.push({seen:[],current:L});else if(j==="unless")E.push({seen:[],current:`!(${L})`});else if(j==="elseif"||j==="else"){let B=E[E.length-1];if(!B)continue;if(B.current)B.seen.push(B.current);B.current=j==="elseif"?L:null}}return E.flatMap((j)=>[...j.seen.map((L)=>`!(${L})`),...j.current?[j.current]:[]]).filter(Boolean)}function zw(x){let v=x.code.trim();if(!v)return null;if(x.attribute?.startsWith("@")){if(jw.test(v))return null;let E=";(($event: any): void => { ";return{text:`${E}${v} });`,prefixLength:E.length}}let k=";void ((";return{text:`${k}${v}));`,prefixLength:k.length}}var Fw=/(\bfrom\s*|\bimport\s*\(\s*|\bimport\s+)(['"])(\.{1,2}\/[^'"\n]*)\2/g;function Vn(x,v){if(!v)return x;return x.replace(Fw,(k,E,C,j)=>{let L=Qg.resolve(v,j).replace(/\\/g,"/");return`${E}${C}${L}${C}`})}function ys(x){return" ".repeat(Math.max(0,(x.startColumn??1)-1))}function Ww(x){let v=new Set,k=s(x);for(let E of k.matchAll(/\bimport\s+(?:type\s+)?([\w$*{}\s,]+?)\s+from\b/g)){let C=E[1],j=/\{([^}]*)\}/.exec(C);for(let F of j?.[1].split(",")??[]){let X=F.trim().replace(/^type\s+/,"").split(/\s+as\s+/).pop()?.trim();if(X&&/^[A-Z_$][\w$]*$/i.test(X))v.add(X)}let L=C.replace(/\{[^}]*\}/,""),B=/\*\s*as\s+([A-Z_$][\w$]*)/i.exec(L);if(B)v.add(B[1]);let z=/^\s*([A-Z_$][\w$]*)/i.exec(L);if(z&&z[1]!=="type")v.add(z[1])}return[...v].sort()}function si(x,v={}){let k=He(x),E=x.split(`
|
|
2064
|
-
`),C=Array.from({length:E.length},()=>""),j=new Map,L=v.filePath&&v.templateExpressions!==!1?Ug(x,Po(x),{filePath:v.filePath,componentsDir:v.componentsDir,projectRoot:v.projectRoot,readComponent:v.readComponent,scriptCode:(G,J)=>He(G).map((ne)=>Vn(ne.code,Qg.dirname(J))).join(`
|
|
2065
|
-
`)}):void 0,B=new Set,z=[];for(let G of k){let J=hs(ms(G.code)),ne=Vn(J,v.originDir??"").split(`
|
|
2066
|
-
`);ne.forEach((re,se)=>{let oe=G.startLine-1+se;if(oe<C.length)C[oe]=se===0?ys(G)+re:re,B.add(oe)}),z.push(G.startLine-1+ne.length-1)}for(let G of z){let J=C[G]?.trim()===""?G:G+1;if(J<C.length&&C[J].trim()===""&&(J===G||!B.has(J)))C[J]=";"}let F=(G,J)=>{for(let[ne,re]of G.split(`
|
|
2067
|
-
`).entries())if(C.push(re),J)j.set(C.length,ne===0?J:{...J,line:J.line+ne,column:1,prefixLength:0})};if(v.globals!==!1){F("");let G=new Set([...k.flatMap((se)=>Q(se.code)),...k.flatMap((se)=>Ww(se.code))]),J=(se)=>{if(!G.has(se))F(`declare var ${se}: any`)};if(v.runtimeGlobals!==!1){if(!G.has("window"))F("declare var window: any");for(let se of m)J(se)}let ne=[...new Set([...Pl,...H,...Yg])].filter((se)=>v.runtimeGlobals!==!1||!m.includes(se));if(v.contextScope==="global"){F("declare global {");for(let se of ne)F(` var ${se}: any`);F("}")}else{for(let se of Pl)J(se);for(let se of H)J(se);for(let se of Yg)J(se)}F(`declare var ${Il}: any`);let re=new Set(k.flatMap((se)=>Q(se.code)));F(`type ${qg}<T> = T extends readonly (infer E)[] ? E : T extends Iterable<infer E2> ? E2 : any`);for(let se of Aw(x)){if(re.has(se.name))continue;let oe=se.iterable&&re.has(se.iterable)?`${qg}<typeof ${se.iterable}>`:"any";F(`declare var ${se.name}: ${oe}`)}}if(v.templateExpressions!==!1){if(L?.declarations)for(let J of L.declarations.split(`
|
|
2068
|
-
`))F(J);let G=gc(x).map((J)=>{let ne=L?.events.get(J.offset??-1);if(ne){J.anchor=!0;let re=J.code.trim(),se=/^([\w$]+)\s*=\s*([^=][\s\S]*)$/.exec(re),oe=se?`void ((${se[2]}) satisfies __StxAssignedValue<typeof ${se[1]}>)`:/^[\w$]+(?:\.[\w$]+)*$/.test(re)?`${re} satisfies (($event: ${ne}) => unknown)`:re,ie=`;(($event: ${ne}): void => { `;return{expression:J,statement:{text:`${ie}${oe} });`,prefixLength:ie.length}}}return{expression:J,statement:zw(J)}}).filter((J)=>J.statement!==null);if(G.push(...L?.checks||[]),G.length>0){let J=Po(x),ne=Lw(k.map((ie)=>ie.code)),se=[...new Set(k.flatMap((ie)=>Q(ie.code)))].filter((ie)=>/^[A-Z_$][\w$]*$/i.test(ie)),oe=0;if(se.length>0){F(kw);for(let ie of se)F(`type __StxT_${ie} = ${tm}<typeof ${ie}>`);F(`;((${se.map((ie)=>`${ie}: __StxT_${ie}`).join(", ")}) => {`),oe=1}for(let{expression:ie,statement:ge}of G){let ue=" ".repeat(oe),xe=ie.offset===void 0?[]:Bw(J,ie.offset),we=xe.length>0?`${xe.map((_e)=>`if (${sm(_e,ne)}) `).join("")}{ `:"",$e=xe.length>0?" }":"";F(ue+we+ge.text+$e,{line:ie.line,column:ie.column,expression:ie,prefixLength:ge.prefixLength+ue.length+we.length,guardPrefixLength:ue.length+we.length})}if(oe>0)F("});")}}let X=!1;if(v.reference&&C[0]!==void 0&&C[0].trim()==="")C[0]=`/// <reference path=${JSON.stringify(v.reference.replace(/\\/g,"/"))} />`,X=!0;return F("export {}"),{text:C.join(`
|
|
2069
|
-
`),lineMap:j,sourceLineCount:E.length,componentDependencies:L?.dependencies,referenced:X}}function oi(x,v){if(!x.expression)return!1;return x.inGuard===!0||v===2774}function ii(x,v,k){let E=x.lineMap.get(v);if(!E)return v<=x.sourceLineCount?{line:v,column:k}:null;let C=E.expression?.anchor?0:Math.max(0,k-1-(E.prefixLength??0));return{line:E.line,column:E.column+C,expression:E.expression,inGuard:k<=(E.guardPrefixLength??0)}}var Vw=[{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"}],Uw=[{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')"}],Hw=[{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 mc(x){let v=[],k=[];return qw(x,v),Kw(x,v,k),Xw(x,k),Zw(x,v),{valid:v.length===0,errors:v,warnings:k}}function qw(x,v){let k=(x.match(/\{\{/g)||[]).length,E=(x.match(/\}\}/g)||[]).length;if(k!==E)v.push({type:"expression",message:`Unclosed expression brackets: found ${k} opening '{{' and ${E} closing '}}'`,suggestion:"Ensure every {{ has a matching }}"})}function Kw(x,v,k){for(let E of Vw){let C=new RegExp(`${E.open}(?:\\s|\\()`,"g"),j=new RegExp(E.close,"g"),L=(x.match(C)||[]).length,B=(x.match(j)||[]).length;if(E.altClose){let z=new RegExp(E.altClose,"g");B+=(x.match(z)||[]).length}if(L>B)v.push({type:"directive",message:`Unclosed @${E.name} directive: found ${L} opening and ${B} closing`,suggestion:`Add ${L-B} missing ${E.close} tag(s)`});else if(B>L)k.push({type:"directive",message:`Extra ${E.close} found: ${B-L} more closing than opening`,suggestion:`Check for orphaned ${E.close} tags`})}}function Xw(x,v){for(let k of Uw)if(k.pattern.test(x))v.push({type:"syntax",message:k.message,suggestion:k.suggestion})}function Zw(x,v){for(let k of Hw)if(k.pattern.test(x))v.push({type:"expression",message:`Security warning: ${k.message}`,suggestion:"Remove dangerous code from template expressions"})}function hc(x,v){let k=x.slice(0,v).split(`
|
|
2070
|
-
`);return{line:k.length,column:k[k.length-1].length+1}}function yc(x,v,k){let E=[];switch(x){case"if":case"elseif":case"unless":if(k.length===0)E.push({type:"syntax",message:`@${x} requires a condition`,suggestion:`Use @${x}(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:`@${x} requires a path`,suggestion:`Use @${x}('path/to/template')`});break}return E}function bc(x){return/@[a-z]+/i.test(x)||/\{\{/.test(x)}function wc(x){let v=x.matchAll(/@([a-z]+)/gi),k=new Set;for(let E of v){let C=E[1].toLowerCase();if(!C.startsWith("end"))k.add(C)}return Array.from(k)}import Zn from"path";import zs from"process";var St=["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 im=new Set(St),Gw=new Set(["props","$props","defineProps"]),Jw=new Set(["stx","@stacksjs/stx"]),om=I(128),am=I(64);function Yw(x){let v=[],k=0,E=x.split(`
|
|
2071
|
-
`);for(let C of E){let j=k,L=null,B=!1;for(let z=0;z<C.length;z++){let F=C[z];if(B){B=!1;continue}if(F==="\\"){B=!0;continue}if(L){if(F===L)L=null;continue}if(F==="'"||F==='"'||F==="`"){L=F;continue}if(F==="/"&&z+1<C.length&&C[z+1]==="/")break;if(F==="{")k++;else if(F==="}")k--}if(j===0){let z=C.match(/(?:const|let|var)\s+(\w+)\s*=/);if(z)v.push(z[1]);else if(/^\s*(?:const|let|var)\s+\w+\s*;?\s*$/.test(C)){let F=C.match(/(?:const|let|var)\s+(\w+)/);if(F)v.push(F[1])}else{let F=C.match(/(?:const|let|var)\s+(\{[^}]+\}|\[[^\]]+\])\s*=/);if(F){let G=F[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));v.push(...G)}}}}return[...new Set(v)]}function ic(x){let v=x;v=v.replace(/^\s*import\s+.*?from\s+['"][^'"]+['"]\s*;?\s*$/gm,""),v=v.replace(/^\s*import\s+['"][^'"]+['"]\s*;?\s*$/gm,""),v=v.replace(/^\s*interface\s+\w+\s*\{[\s\S]*?\n\}\s*$/gm,""),v=v.replace(/^\s*type\s+\w+\s*=[\s\S]*?(?=\n(?:const|let|var|function|export|interface|type|$))/gm,""),v=v.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 C=[],j="",L=0,B=0,z=null;for(let F=0;F<E.length;F++){let X=E[F];if(z){if(j+=X,X===z)z=null;continue}if(X==='"'||X==="'"||X==="`"){z=X,j+=X;continue}if(X==="<")L++;else if(X===">"&&L>0)L--;else if(X==="(")B++;else if(X===")")B--;if(X===","&&L===0&&B===0){C.push(j),j="";continue}j+=X}if(j)C.push(j);return C.map((F)=>{let X=F.trim(),G=X.startsWith("..."),J=G?X.slice(3):X,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 F;let oe=J.substring(0,ne).trim().replace(/\?$/,""),ie=J.substring(ne+1),ge=-1,ue=0;for(let we=0;we<ie.length;we++)if(ie[we]==="<")ue++;else if(ie[we]===">")ue--;else if(ie[we]==="="&&ue===0){ge=we;break}let xe=G?"...":"";if(ge!==-1)return`${xe}${oe} = ${ie.substring(ge+1).trim()}`;return`${xe}${oe}`}).join(", ")}v=v.replace(/\b(function\s+\w*\s*)\(([^)]*)\)/g,(E,C,j)=>{if(!j.includes(":"))return E;return`${C}(${k(j)})`});{let E=/\b(function\s+\w*\s*)\(/g,C,j=[];while((C=E.exec(v))!==null){let L=C.index+C[0].length-1,B=1,z=L+1,F=0,X=null;while(z<v.length&&B>0){let ne=v[z];if(X){if(ne===X)X=null;z++;continue}if(ne==='"'||ne==="'"||ne==="`"){X=ne,z++;continue}if(ne==="<")F++;else if(ne===">"&&F>0)F--;else if(F===0){if(ne==="(")B++;else if(ne===")")B--}if(B>0)z++}if(B!==0)continue;let G=v.substring(L+1,z);if(!G.includes(":"))continue;let J=k(G);j.push({start:L+1,end:z,replacement:J})}for(let L=j.length-1;L>=0;L--){let{start:B,end:z,replacement:F}=j[L];v=v.substring(0,B)+F+v.substring(z)}}return v=v.replace(/\(([^)]*)\)\s*(?::\s*[^=]+)?\s*=>/g,(E,C)=>{if(!C.includes(":"))return E;if(C.includes("{")||C.includes("}"))return E;return`(${C.split(",").map((L)=>{let[B,...z]=L.split("="),F=B.split(":")[0].trim();if(z.length>0)return`${F} = ${z.join("=").trim()}`;return F}).join(", ")}) =>`}),v=v.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"),v=v.replace(/(\b(?:function|class|interface|type|extends|implements)\s+\w+)\s*<[^<>()]*>/g,"$1"),v=v.replace(/(\b(?:defineProps|withDefaults|defineEmits|defineSlots|Array|Promise|Map|Set|Record|Partial|Required|Readonly|Pick|Omit|Exclude|Extract))\s*<[^<>()]*>/g,"$1"),v=v.replace(/(\w+)\s*<[A-Z][^<>()]*>\s*(?=\()/g,"$1"),v=v.replace(/\s+as\s+(?:const|[A-Za-z]\w*(?:\[\])?(?:\s*\|\s*\w+(?:\[\])?)*)/g,""),v=v.replace(/\s+satisfies\s+\w+(?:<[^>]*>)?/g,""),v=v.replace(/(\w|\)|\])\s*!(?!=)/g,"$1"),v=v.replace(/^\s*(?:export\s+)?(?:const\s+)?enum\s+\w+\s*\{[^}]*\}\s*$/gm,""),v=v.replace(/(?<=[\s=,(])<[A-Z]\w*(?:\[\])?>/g,""),v=v.replace(/\n\s*\n\s*\n/g,`
|
|
2072
|
-
|
|
2073
|
-
`),v}function ac(x){return x.replace(/\s*(?:imported from|from)\s+(?:(['"])([^'"\r\n]+)\1|(\S+))/g,(v,...k)=>{let[,E,C]=k,j=E??C;return/(?:[/\\]packages[/\\]stx[/\\]|@stacksjs[/\\]stx[/\\])/.test(j)?"":v})}function cc(x){return/cannot find module|cannot find package|could not resolve|module not found|failed to resolve/i.test(x)}function lc(x){if(x instanceof SyntaxError)return!0;let v=x instanceof Error?x.message:String(x);return/SyntaxError|Unexpected (token|identifier|string|number|keyword|end of)|Unterminated|Expected .+ but found/i.test(v)}function uc(x){if(!/is not defined|can't find variable/i.test(x))return!1;return!/\b(document|window|navigator|localStorage|sessionStorage|self)\b/.test(x)}var cm=new Set;async function d(x,v,k,E={}){if(!x.trim())return;let C=y(),j=O(x,JSON.stringify(C)),L=om.get(j);if(L===void 0){try{let De=N({loader:"ts",target:"browser",define:C}),Je=x.replace(/^\s*import\s+\w+\s+from\s+['"][^'"]*\.stx['"]\s*;?\s*$/gm,"");Je=Je.replace(/^\s*import\s+['"][^'"]*\.stx['"]\s*;?\s*$/gm,""),L=De.transformSync(Je)}catch{L=ic(x)}om.set(j,L)}let B={exports:{}},z=B.exports,F=zs.cwd(),X={},G=[...L.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(".")){X[De]=await import(Zn.resolve(Zn.dirname(k),De));continue}let Je=Zn.resolve(F,"node_modules",De),st=Zn.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}X[De]=await import(Zn.resolve(Je,At))}catch(Je){if(De.startsWith("."))J.set(De,Je instanceof Error?Je.message:String(Je))}let ne=(De)=>{if(X[De])return X[De];let Je=J.get(De);if(Je!==void 0)throw Error(`Cannot require '${De}' from ${k}: ${Je}`);return u(De)},re=v.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 oe=(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)},ie=(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=()=>v.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=Nn(v);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=v.__stxClientPayload??{};Object.assign(Je,De),v.__stxClientPayload=Je}let Xe=()=>{let De=v.__stxServeContext,Je=v.__stxServeSearch??De?.search??"",st=De?.path??"",mt=Object.fromEntries(new URLSearchParams(Je)),At=v.query,Kt=Object.keys(mt).length>0?mt:At??{},_n=Je||(Object.keys(Kt).length>0?`?${new URLSearchParams(Kt).toString()}`:"");return{params:v.params??{},query:Kt,path:st,name:"",fullPath:st+_n,hash:"",matched:[]}},Pe=()=>({push:(De)=>{},replace:(De)=>{},back:()=>{},forward:()=>{},go:(De)=>{}}),Ie=(De)=>{let Je=v.__stx_runtime_head||{};v.__stx_runtime_head=pe(Je,de(De||{},{known:er,source:"useHead()"}))},Ze=(De)=>{Ie(tr(De||{}))},nt=(De)=>({value:De}),at=(De)=>De,rt=(De)=>({value:typeof De==="function"?De():De}),Rt=(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"}),sr=()=>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:{}},la=new Proxy(Nt,{get(De,Je){if(Je in De)return De[Je];return},set(De,Je,st){return De[Je]=st,!0}}),ua={getElementById:()=>null,querySelector:()=>null,querySelectorAll:()=>[],createElement:()=>({}),createTextNode:()=>({}),body:{},head:{},documentElement:{},addEventListener:()=>{},removeEventListener:()=>{}},da=console;try{let De=os(L,k),Je=new Set(Object.keys(re)),st=Object.keys(v).filter((lt)=>!Je.has(lt)&&!Gw.has(lt)&&Ye(lt)),mt=st.map((lt)=>v[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=Yw(De).map((lt)=>`module.exports.${lt} = typeof ${lt} !== 'undefined' ? ${lt} : module.exports.${lt};`).join(`
|
|
2074
|
-
`),Gt=v.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 Tt=[...St,...Kt,...tt],dt=`return (async () => {
|
|
2075
|
-
${De}
|
|
2076
|
-
${dr}
|
|
2077
|
-
return module.exports
|
|
2078
|
-
})()`,Wt=O(dt,Tt.join("\x00")),Mt=am.get(Wt);if(!Mt)Mt=Function(...Tt,dt),am.set(Wt,Mt);let Jt=v.__stx_options?.runtimeConfig;if(Jt||/\buse(?:Server)?RuntimeConfig\b/.test(L))await an(v,k,Jt);let ir=await le(v.__stx_runtime_config??$t()??S(),()=>Xp(v,()=>Mt(B,z,ne,re,se,oe,ie,ge,xe,Ae,Zp,xs,Gn,we,$e,_e,Ce,Ee,Te,ke,Xe,Pe,Ie,Ze,Re.setResponseStatus,Re.setResponseHeader,Re.notFound,nt,at,rt,Rt,ft,yt,ct,Pt,pt,ue,Lt,Qn,Sn,sr,et,it,gt,qt,Dt,xn,la,ua,da,Nt.confirm,Nt.alert,Nt.fetch,Gt,..._n,...ot)));if(E.preserveExisting){for(let[lt,kn]of Object.entries(ir))if(!(lt in v)||v[lt]===void 0)v[lt]=kn}else Object.assign(v,ir);for(let[lt,kn]of Object.entries(re))if(!(lt in v))v[lt]=kn}catch(De){if(v.__stx_strict_hydration)throw De;let Je=ac(De instanceof Error?De.message:String(De));if(cc(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(lc(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(uc(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(zs.env.STX_DEBUG||!cm.has(st))cm.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 sS(L,v,k)}catch(st){if(zs.env.STX_DEBUG){let mt=st instanceof Error?st.message:String(st);console.warn(`[stx] fallback extraction also failed in ${k??"<unknown>"}: ${mt}`)}}}}function dc(x){let v=0,k=null,E=!1,C=!1;for(let j=0;j<x.length;j++){let L=x[j];if(k){if(L===k){if(k=null,E||v===0)C=!0}continue}if(L==="'"||L==='"'||L==="`"){k=L;continue}if(L==="{")v++;else if(L==="}")v--;else if(x.startsWith("from",j)&&v===0)E=!0}return k===null&&v===0&&C}var Qw=/^(?:export\s+)?(?:const|let|var)\s+[A-Za-z_$][\w$]*(?:\s*,\s*[A-Za-z_$][\w$]*)*\s*;?$/;function os(x,v){let k=v?Zn.dirname(v):zs.cwd(),E=zs.cwd(),C=x.split(`
|
|
2079
|
-
`),j=[],L=0;while(L<C.length){let B=C[L].trim();if(B.startsWith("interface ")||B.startsWith("export interface ")||B.startsWith("type ")||B.startsWith("export type ")){if(B.includes("{")&&!B.includes("}")){let z=0;for(;L<C.length;L++){for(let F of C[L])if(F==="{")z++;else if(F==="}")z--;if(z<=0)break}}L++;continue}if(B.startsWith("definePageMeta(")){let z=0,F=!1,X=L;for(let ne=L;ne<C.length&&!F;ne++){let re=null,se=!1,oe=C[ne];for(let ie=0;ie<oe.length;ie++){let ge=oe[ie];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==="(")z++;else if(ge===")"){if(z--,z===0){L=ne+1,F=!0;break}}}}if(!F)L=C.length;let G=C.slice(X,L).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(B.startsWith("import ")||B==="import"||B.startsWith("import{")){let z=B,F=0;while(!dc(z)&&L+F+1<C.length)F++,z=`${z} ${C[L+F].trim()}`;L+=F;let X=z.match(/^import\s+(\w+)\s+from\s+['"](.+?)['"]/),G=z.match(/^import\s+\{([^}]*)\}\s+from\s+['"](.+?)['"]/),J=z.match(/^import\s+['"](.+?)['"]/),ne=z,re=(se)=>{if(se.startsWith("."))return Zn.resolve(k,se);if(se.startsWith("~/")||se.startsWith("@/"))return Zn.resolve(E,se.slice(2));return se};if(X){let[,se,oe]=X,ie=re(oe);j.push(`const ${se} = (await import('${ie}')).default`),j.push(`module.exports.${se} = ${se};`)}else if(G){let[,se,oe]=G,ie=re(oe),ge=[],ue=[],xe=Jw.has(oe);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&&im.has(Ce)){j.push(`const ${Ee} = ${Ce};`);continue}ge.push(`${Ce}: ${Ee}`),ue.push(Ee)}else{if(xe&&im.has($e))continue;ge.push($e),ue.push($e)}}if(ge.length>0)j.push(`const { ${ge.join(", ")} } = await import('${ie}')`);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);L++;continue}if(Qw.test(B))j.push(C[L]),L++;else if(B.startsWith("export const ")||B.startsWith("export let ")||B.startsWith("export var ")){let z=um(C,L),{type:F,name:X,value:G}=z;j.push(`${F} ${X} = ${G};`),j.push(`module.exports.${X} = ${X};`),L=z.nextIndex}else if(B.startsWith("export function ")||B.startsWith("export async function ")){let z=Dl(C,L);j.push(z.functionCode),j.push(`module.exports.${z.name} = ${z.name};`),L=z.nextIndex}else if(B.startsWith("const ")||B.startsWith("let ")||B.startsWith("var ")){let z=um(C,L),{type:F,name:X,value:G}=z;j.push(`${F} ${X} = ${G};`),j.push(`module.exports.${X} = ${X};`),L=z.nextIndex}else if(B.startsWith("function ")||B.startsWith("async function ")){let z=Dl(C,L);j.push(z.functionCode),j.push(`module.exports.${z.name} = ${z.name};`),L=z.nextIndex}else if(B.startsWith("export default function ")||B.startsWith("export default async function ")){let z=C[L].replace(/^(\s*)export\s+default\s+/,"$1"),F=[...C];F[L]=z;let X=Dl(F,L);if(j.push(X.functionCode),X.name)j.push(`module.exports.default = ${X.name};`);L=X.nextIndex}else if(B.startsWith("export default ")){let z=B.replace(/^export\s+default\s+/,"").replace(/;$/,"");j.push(`module.exports.default = ${z};`),L++}else if(B.startsWith("class ")||B.startsWith("export class ")){let z=B.match(/(?:export\s+)?class\s+(\w+)/);if(z){let F=z[1],X=C[L].replace(/^export\s+/,""),G=0,J=L;for(;J<C.length;J++){let ne=C[J];for(let re of ne)if(re==="{")G++;else if(re==="}")G--;if(J>L)X+=`
|
|
2081
|
-
`+ne;if(G<=0&&J>=L)break}j.push(X),j.push(`module.exports.${F} = ${F};`),L=J+1}else j.push(B),L++}else if(B.includes("module.exports"))j.push(B),L++;else if(B.trim()&&!B.startsWith("//"))j.push(B),L++;else L++}return eS(j.join(`
|
|
2082
|
-
`),k,E)}function eS(x,v,k){let E=x.length,C="",j=0,L=null,B=!1,z=!1,F=0;while(j<E){let X=x[j],G=x[j+1];if(B){if(C+=X,X===`
|
|
2083
|
-
`)B=!1;j++;continue}if(z){if(C+=X,X==="*"&&G==="/"){C+=G,j+=2,z=!1;continue}j++;continue}if(!L&&X==="/"&&G==="/"){B=!0,C+=X,j++;continue}if(!L&&X==="/"&&G==="*"){z=!0,C+=X,j++;continue}if(L){if(C+=X,X==="\\"){C+=G,j+=2;continue}if(X===L&&L!=="`"){L=null,j++;continue}if(L==="`"){if(X==="$"&&G==="{"){F++,C+=G,j+=2;continue}if(X==="`"){L=null,j++;continue}}j++;continue}if(F>0){if(X==="{")F++;else if(X==="}")F--}if(X==='"'||X==="'"||X==="`"){L=X,C+=X,j++;continue}if(X==="a"&&x.startsWith("await",j)){let J=tS(x,j);if(J){let{quote:ne,path:re,end:se}=J;if(re.startsWith(".")||re.startsWith("~/")||re.startsWith("@/")){let oe=re.startsWith(".")?Zn.resolve(v,re):Zn.resolve(k,re.slice(2));C+=`await import(${ne}${oe}${ne})`,j=se;continue}}}C+=X,j++}return C}function tS(x,v){let k=v+5;if(k>=x.length)return null;if(!/\s/.test(x[k]))return null;while(k<x.length&&/\s/.test(x[k]))k++;if(!x.startsWith("import",k))return null;k+=6;while(k<x.length&&/\s/.test(x[k]))k++;if(x[k]!=="(")return null;k++;while(k<x.length&&/\s/.test(x[k]))k++;let E=x[k];if(E!=="'"&&E!=='"')return null;k++;let C=k;while(k<x.length&&x[k]!==E)if(x[k]==="\\")k+=2;else k++;if(k>=x.length)return null;let j=x.slice(C,k);k++;while(k<x.length&&/\s/.test(x[k]))k++;if(x[k]!==")")return null;return{quote:E,path:j,end:k+1}}function gm(x,v){let k=x[v];if(k!=="{"&&k!=="[")return null;let C=w(x,k,k==="{"?"}":"]",v);if(C===-1)return null;return{pattern:x.slice(v,C+1),endPos:C+1}}function mm(x){let v=[],k=x.slice(1,-1).trim();if(!k)return v;let E=0,C=0,j="";while(E<k.length){let L=k[E];if(L==="{"||L==="["){let B=C===0?gm(k,E):null;if(B){v.push(...mm(B.pattern)),E=B.endPos,j="";continue}C++}else if(L==="}"||L==="]")C--;if(C>0){E++;continue}if(L===","){if(j.trim())v.push(j.trim());j="",E++;continue}if(L===":"){j="",E++;continue}if(L==="="){if(j.trim())v.push(j.trim());j="",E++;while(E<k.length&&k[E]!==","&&C===0){if(k[E]==="{"||k[E]==="[")C++;else if(k[E]==="}"||k[E]==="]")C--;E++}continue}if(/[\w$]/.test(L))j+=L;E++}if(j.trim())v.push(j.trim());return v}function pc(x){let v=/^(?:export\s+)?(const|let|var)\s+([A-Za-z_$][\w$]*)/.exec(x);if(!v)return null;let k=v[0].length,E=(C)=>C===" "||C==="\t";while(k<x.length&&E(x[k]))k++;if(x[k]===":"){let C=0,j=null;k++;for(;k<x.length;k++){let L=x[k];if(j){if(L==="\\"){k++;continue}if(L===j)j=null;continue}if(L==="'"||L==='"'||L==="`"){j=L;continue}if(L==="("||L==="["||L==="{"||L==="<"){C++;continue}if(L===")"||L==="]"||L==="}"||L===">"){C--;continue}if(L==="="&&C<=0){let B=x[k+1],z=x[k-1];if(B!=="="&&B!==">"&&z!=="="&&z!=="!"&&z!=="<"&&z!==">")break}}if(x[k]!=="=")return null}while(k<x.length&&E(x[k]))k++;if(x[k]!=="=")return null;return{type:v[1],name:v[2],value:x.slice(k+1).trim()}}function lm(x,v,k,E){let C=null,j=!1;for(let L of x){if(j){j=!1;continue}if(L==="\\"){j=!0;continue}if(C){if(L===C)C=null;continue}if(L==="'"||L==='"'||L==="`"){C=L;continue}if(L===v)E++;else if(L===k)E--}return E}function um(x,v){let k=x[v].trim(),E=pc(k),C=E?[k,E.type,E.name,E.value]:null;if(!C){let X=k.match(/^(?:export\s+)?(const|let|var)\s+/);if(X){let G=k.slice(X[0].length),J=v;if(G.startsWith("{")||G.startsWith("[")){let re=G[0],se=re==="{"?"}":"]",oe=lm(G,re,se,0),ie=G;for(let ge=v+1;ge<x.length&&oe>0;ge++)ie+=` ${x[ge].trim()}`,J=ge,oe=lm(x[ge],re,se,oe);if(oe>0)ie=G,J=v;G=ie}let ne=gm(G,0);if(ne){let re=X[1],se=ne.pattern,oe=G.slice(ne.endPos).trim();if(oe.startsWith("=")){let ie=oe.slice(1).trim(),ge=ie,ue=Math.max(J,v);if(dm(ie)){let _e=fm(x,ue,ie);ge=_e.value,ue=_e.nextIndex}else ue=ue+1;ge=ge.trim().replace(/;$/,"");let xe=mm(se),we=`__stx_src_${v}`,$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,L,B]=C,z=B,F=v;if(dm(B)){let X=fm(x,v,B);z=X.value,F=X.nextIndex}else F=v+1;while(F<x.length){let X=x[F].trim();if(X.startsWith(".")||X.startsWith("?."))z+=`
|
|
2086
|
-
${x[F]}`,F++;else break}return z=z.trim().replace(/;$/,""),{type:j,name:L,value:z,nextIndex:F}}function Dl(x,v){let k=x[v].trim(),E=k.match(/^(?:export\s+)?(?:async\s+)?function\s+(\w+)/);if(!E)throw Error(`Failed to parse function declaration: ${k}`);let[,C]=E,j=k.replace(/^export\s+/,""),L=v;if(nS(k)){let B=rS(x,v,j);j=B.functionCode,L=B.nextIndex}else L=v+1;return{name:C,functionCode:j,nextIndex:L}}function dm(x){let v=x.trim();if(v.startsWith("{"))return w(v,"{","}",0)===-1;if(v.startsWith("["))return w(v,"[","]",0)===-1;return!hm(v)}function hm(x){let v={paren:0,bracket:0,brace:0},k=null,E=0;for(let C=0;C<x.length;C++){let j=x[C];if((C>0?x[C-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==="$"&&x[C+1]==="{"){E++,C++;continue}if(E>0&&j==="{"){E++;continue}if(E>0&&j==="}"){E--;continue}if(k)continue;if(j==="(")v.paren++;else if(j===")")v.paren--;else if(j==="[")v.bracket++;else if(j==="]")v.bracket--;else if(j==="{")v.brace++;else if(j==="}")v.brace--}return v.paren===0&&v.bracket===0&&v.brace===0&&k===null}function ym(x){let v=x.indexOf("(");if(v===-1)return x.indexOf("{");let k=w(x,"(",")",v);if(k===-1)return-1;return x.indexOf("{",k)}function nS(x){let v=ym(x);if(v===-1)return!0;return w(x,"{","}",v)===-1}function fm(x,v,k){let E=k,C=v+1;while(C<x.length&&!hm(E)){let j=x[C];E+=`
|
|
2087
|
-
${j}`,C++}while(C<x.length){let j=x[C].trim();if(j.startsWith(".")||j.startsWith("?."))E+=`
|
|
2088
|
-
${x[C]}`,C++;else break}return{value:E,nextIndex:C}}function rS(x,v,k){let E=k,C=v+1;while(C<x.length){let j=ym(E);if(j!==-1){if(w(E,"{","}",j)!==-1)break}let L=x[C];E+=`
|
|
2089
|
-
${L}`,C++}return{functionCode:E,nextIndex:C}}function pm(x,v){let k=c(x,v)??c(`(${x})`,v);if(k!==void 0)return k;if(!/\bprocess\b/.test(x))return;let E={...v,process:Object.freeze({env:{...zs.env}})},C=Object.keys(E).filter(Ye),j=C.map((L)=>E[L]);try{return Function(...C,`'use strict'; return (${x});`)(...j)}catch{try{return Function(...C,`'use strict'; return ${x};`)(...j)}catch{return}}}async function sS(x,v,k){let E=x.matchAll(/export\s+(const|let|var)\s+(\w+)\s*=\s*([\s\S]*?)(?=\s*(?:export\s+|$))/g);for(let j of E){let[,,L,B]=j;try{let z=B.trim().replace(/;$/,""),F=pm(z,v);if(F!==void 0)v[L]=F}catch(z){console.warn(`Failed to parse export ${L} in fallback:`,z)}}let C=x.matchAll(/(?:^|\n)\s*(const|let|var)\s+(\w+)\s*=\s*([\s\S]*?)(?=\s*(?:(?:const|let|var|function|export)\s+|$))/g);for(let j of C){let[,,L,B]=j;if(!(L in v))try{let z=B.trim().replace(/;$/,""),F=pm(z,v);if(F!==void 0)v[L]=F}catch{}}}function Go(x){let v=x.match(/<script\b[^>]*>([\s\S]*?)<\/script>/i),k=v?v[1]:"",E=v?x.replace(/<script\b[^>]*>[\s\S]*?<\/script>/i,""):x;return{scriptContent:k,templateWithoutScript:E}}function Jo(x){let v=x.trim();if(!v)return!1;return/(?:const|let|var|function)\s+\w+/.test(v)}var Pi=new V(500),Oo=new V(1000),km=33554432,Ol=km;function iS(x){let v=x.componentRenderCacheBytes;if(typeof v!=="number"||v<0||v===Ol)return;Ol=v,ea.setMaxBytes(v)}var ea=new V(2000,{maxBytes:km,sizeOf:(x)=>x.output.length});function oS(x){let v=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(v.has(E))throw TypeError("Circular component input");v.add(E);try{if(E instanceof Date)return{__stxType:"date",value:E.toISOString()};if(Array.isArray(E))return E.map(k);let C=Object.getPrototypeOf(E);if(C!==Object.prototype&&C!==null)throw TypeError("Non-plain component input");let j={};for(let L of Object.keys(E).sort())j[L]=k(E[L]);return j}finally{v.delete(E)}};return JSON.stringify(k(x))}catch{return null}}function aS(x){let v={};for(let[k,E]of Object.entries(x))if(!k.startsWith("__")||k==="__stxServeContext")v[k]=E;return v}function xm(x){return x.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}function vc(x){return/\bjs\b/.test(x)||/\blang\s*=\s*["']?(js|javascript)["']?/i.test(x)}function Ve(x){return!vc(x)}var Mo=new Map;function N(x){let v;try{v=JSON.stringify(x)}catch{return new Bun.Transpiler(x)}let k=Mo.get(v);if(k)return k;if(Mo.size>=16)Mo.clear();let E=new Bun.Transpiler(x);return Mo.set(v,E),E}var bm=new WeakMap,cS=256;function Ue(x){try{let v=N({loader:"ts",target:"browser",define:y()}),k=bm.get(v);if(!k)k=new Map,bm.set(v,k);let E=k.get(x);if(E!==void 0)return E;let C=x.replace(/^\s*import\s+\w+\s+from\s+['"][^'"]*\.stx['"]\s*;?\s*$/gm,"");C=C.replace(/^\s*import\s+['"][^'"]*\.stx['"]\s*;?\s*$/gm,"");let j=[];C=C.replace(/\{!![\s\S]*?!!\}/g,(B)=>{let z=j.length;return j.push(B),`"__STX_EXPR_${z}__"`}),C=C.replace(/\{\{\{[\s\S]*?\}\}\}/g,(B)=>{let z=j.length;return j.push(B),`"__STX_EXPR_${z}__"`}),C=C.replace(/\{\{[\s\S]*?\}\}/g,(B)=>{let z=j.length;return j.push(B),`"__STX_EXPR_${z}__"`});let L=v.transformSync(C);for(let B=0;B<j.length;B++)L=L.replace(`"__STX_EXPR_${B}__"`,j[B]),L=L.replace(`'__STX_EXPR_${B}__'`,j[B]);if(k.size>=cS){let B=k.keys().next();if(!B.done)k.delete(B.value)}return k.set(x,L),L}catch(v){if(process.env.STX_DEBUG_TS)console.warn("[STX] TypeScript transpilation error:",v);return x}}function lS(x){let v=[],k=new Set,E=0,C=0,j=x.length,L=(X)=>{C++;while(C<j){if(x[C]==="\\"){C+=2;continue}if(x[C]===X){C++;return}C++}},B=()=>{C++;while(C<j){if(x[C]==="\\"){C+=2;continue}if(x[C]==="`"){C++;return}if(x[C]==="$"&&x[C+1]==="{"){C+=2;let X=1;while(C<j&&X>0)if(x[C]==="{")X++,C++;else if(x[C]==="}")X--,C++;else if(x[C]==="'"||x[C]==='"')L(x[C]);else if(x[C]==="`")B();else C++;continue}C++}},z=()=>{if(x[C]==="/"&&x[C+1]==="/"){while(C<j&&x[C]!==`
|
|
2090
|
-
`)C++;return!0}if(x[C]==="/"&&x[C+1]==="*"){C+=2;while(C<j-1&&!(x[C]==="*"&&x[C+1]==="/"))C++;return C+=2,!0}return!1},F=()=>{if(E!==0)return;let X=x.slice(C).match(/^(const|let|var)\s*\{([^}]+)\}\s*=/);if(X){let re=X[2].split(",").map((se)=>{let oe=se.trim().split(":");return oe[oe.length-1].trim()});for(let se of re)if(se&&/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(se)&&!k.has(se))v.push(se),k.add(se);return}let G=x.slice(C).match(/^(const|let|var)\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*=/);if(G){let re=G[2];if(!k.has(re))v.push(re),k.add(re);return}let J=x.slice(C).match(/^function\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*\(/);if(J){let re=J[1];if(!k.has(re))v.push(re),k.add(re);return}let ne=x.slice(C).match(/^async\s+function\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*\(/);if(ne){let re=ne[1];if(!k.has(re))v.push(re),k.add(re)}};while(C<j){if(z())continue;if(x[C]==="'"||x[C]==='"'){L(x[C]);continue}if(x[C]==="`"){B();continue}if(x[C]==="{"){E++,C++;continue}if(x[C]==="}"){E--,C++;continue}if(E===0&&/[a-z]/i.test(x[C])&&(C===0||/\s|[;{}()]/.test(x[C-1])))F();C++}return v}function uS(x){let v=[],k=0,E=0,C=null;for(let j=0;j<x.length;j++){let L=x[j];if(C){if(L==="\\"){j++;continue}if(L===C)C=null;continue}if(L==='"'||L==="'"||L==="`"){C=L;continue}if(L==="("||L==="["||L==="{")k++;else if(L===")"||L==="]"||L==="}")k--;else if(L===","&&k===0)v.push(x.slice(E,j)),E=j+1}if(E<x.length)v.push(x.slice(E));return v}function dS(x){let v=0,k=null;for(let E=0;E<x.length;E++){let C=x[E];if(k){if(C==="\\"){E++;continue}if(C===k)k=null;continue}if(C==='"'||C==="'"||C==="`"){k=C;continue}if(C==="("||C==="["||C==="{")v++;else if(C===")"||C==="]"||C==="}")v--;else if(C==="="&&v===0){let j=x[E-1],L=x[E+1];if(j==="!"||j==="<"||j===">"||j==="=")continue;if(L==="="||L===">")continue;return E}}return-1}function fS(x,v){try{let k=/=\s*(?:withDefaults\s*\([\s\S]*?defineProps|defineProps)\b/.exec(x);if(!k)return;let E=k.index-1;while(E>=0&&/\s/.test(x[E]))E--;if(x[E]!=="}")return;let C=E,j=0,L=-1;for(;E>=0;E--){let z=x[E];if(z==="}")j++;else if(z==="{"){if(j--,j===0){L=E;break}}}if(L===-1)return;let B=x.slice(L+1,C);for(let z of uS(B)){let F=z.trim();if(!F||F.startsWith("..."))continue;let X=dS(F);if(X===-1)continue;let G=F.slice(0,X).trim();if(!/^[A-Z_$][\w$]*$/i.test(G))continue;if(v[G]!==void 0)continue;let J=F.slice(X+1).trim();if(!J)continue;try{let ne=Object.keys(v).filter(Ye),re=Function(...ne,`"use strict"; return (${J});`);v[G]=re(...ne.map((se)=>v[se]))}catch{}}}catch{}}var pS=new Set(["tr","td","th","thead","tbody","tfoot","caption","colgroup","col","option","optgroup","li","dt","dd","span"]);function xc(x,v){let k=x.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(!pS.has(E))return null;let C=new RegExp(`<\\/?${E}(?=[\\s/>])(?:[^>"']|"[^"]*"|'[^']*')*>`,"iy"),j=pr(x,(F,X)=>(C.lastIndex=X,C.exec(F)?.index===X?C.lastIndex:-1));if(E==="span"&&/\sdata-stx-scope\s*=/.test(j[0]?.token||""))return null;let L=0,B=!1;for(let F of j){if(L+=F.token.startsWith("</")?-1:1,L<0)return null;if(L===0){if(x.slice(F.end).trim())return null;B=!0;break}}if(!B)return null;let z=k[0].length;return x.slice(0,z)+v+x.slice(z)}async function Un(x,v,k,E,C){let j=x.endsWith(".stx")?x.slice(0,-4):x,L=(ie)=>ie.split("-").map((ge)=>ge.charAt(0).toUpperCase()+ge.slice(1)).join(""),B=(ie)=>ie.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),z=k.__importedComponents;if(z){for(let ie of[j,j.toLowerCase(),L(j),B(j)])if(z.has(ie))return!0}let F=[...new Set([`${j}.stx`,`${L(j)}.stx`,`${B(j)}.stx`])],X=typeof C.root==="string"?Qe.resolve(C.root):void 0,G=X??Qe.dirname(E),J=[],ne=(ie)=>{if(ie&&!J.includes(ie))J.push(ie)},re=k.__originalFilePath;if(re)ne(Qe.join(Qe.dirname(re),"components"));if(ne(v),ne(C._rootComponentsDir),ne(Qe.join(Qe.dirname(E),"components")),ne(C.componentsDir),X)ne(Qe.resolve(X,"resources/views/components")),ne(Qe.resolve(X,"resources/components")),ne(Qe.resolve(X,"src/components")),ne(Qe.resolve(X,"components"));for(let ie of C._layerComponentDirs??[])ne(ie);let se=C._pluginComponentDirs;if(Array.isArray(se))for(let ie of se)ne(typeof ie==="string"?ie:null);if(ne(C.fallbackComponentsDir),j.startsWith("./")||j.startsWith("../"))return r(Qe.resolve(Qe.dirname(E),`${j}.stx`));let oe=vm(Qe.resolve(import.meta.dir,"components"));for(let ie of J){let ge=Qe.isAbsolute(ie)?ie:Qe.resolve(G,ie);if(vm(ge)===oe)continue;for(let ue of F)if(await r(Qe.join(ge,ue)))return!0}return!1}function vm(x){try{return _m.realpathSync(x)}catch{return x}}function Sc(x){return x==="visible"||x==="idle"||x==="interaction"||x.startsWith("media:")}function ai(x){if(!x)return!1;let v=x.replace(/<script[\s\S]*?<\/script>/gi,"").replace(/<style[\s\S]*?<\/style>/gi,"");return/\{\{[\s\S]*?\}\}|\{!![\s\S]*?!!\}/.test(v)}function gS(x,v,k){if(!x.includes("{{")&&!x.includes("{!!"))return x;let E=(C,j)=>{let L;try{L=b(C,v)}catch{return j}if(L===void 0||L===null)return"";let B=String(L);if(/<\/style/i.test(B))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 B};return x.replace(/\{!!([\s\S]*?)!!\}/g,(C,j)=>E(j,C)).replace(/\{\{([\s\S]*?)\}\}/g,(C,j)=>E(j,C))}var wm=new Set;function Sm(x,v,k,E){let C=`${x}\x00${v}\x00${E??""}`;if(!process.env.STX_DEBUG&&wm.has(C))return;wm.add(C);let j=v?` used in ${v}`:"",L=E?` Cause: ${E}.`:"",B=k.length>0?`
|
|
2091
|
-
searched:
|
|
2092
|
-
${k.map((z)=>` - ${z}`).join(`
|
|
2093
|
-
`)}`:"";console.error(`[stx] component <${x}> could not be resolved${j}, so it rendered as nothing.${L}${B}`)}function $m(x){return`<!-- stx: component "${x.replace(/--+/g,"-")}" could not be resolved; see the server log -->`}function kc(x){let v=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 x){let C;while((C=k.exec(E))!==null)v.add(C[1]);k.lastIndex=0}return[...v]}async function We(x,v,k,E,C,j,L,B=new Set,z){let{extractVariables:F}=await ut("stx/variable-extractor",()=>import("./chunk-hd64hz1n.js")),X=B??new Set;if(X.has(x))return`[Circular component reference: ${x}]`;let G=new Set(X);G.add(x);let J=typeof v.client==="string"?v.client.trim():"";if("client"in v)delete v.client;let ne=J&&J!=="load"&&Sc(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(),oe=x.endsWith(".stx")?x.slice(0,-4):x,ie=null,ge=C.__importedComponents;if(ge){let tt=[oe,oe.toLowerCase(),re(oe),se(oe)];for(let ot of tt)if(ge.has(ot)){ie=ge.get(ot);break}}let ue=[];if(!ie){let tt=[`${oe}.stx`,`${re(oe)}.stx`,`${se(oe)}.stx`],ot=[...new Set(tt)],Tt=C.__originalFilePath,dt=[];if(dt.push(...L._layerComponentDirs??[]),Tt){let Bt=Qe.join(Qe.dirname(Tt),"components");dt.push(Bt)}if(E)dt.push(E);let Wt=L._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(L.componentsDir&&L.componentsDir!==E&&!dt.includes(L.componentsDir))dt.push(L.componentsDir);let Jt=typeof L.root==="string"?Qe.resolve(L.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=L._pluginComponentDirs;if(Array.isArray(kn)){for(let Bt of kn)if(typeof Bt==="string"&&!dt.includes(Bt))dt.push(Bt)}if(L.fallbackComponentsDir&&!dt.includes(L.fallbackComponentsDir))dt.push(L.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=`${oe}\x00${j}\x00${Nr.join("\x00")}`,Lr=Oo.get(jr);if(Lr)if(await r(Lr))ie=Lr;else Oo.delete(jr);if(!ie&&(oe.startsWith("./")||oe.startsWith("../")))ie=Qe.resolve(Qe.dirname(j),`${oe}.stx`),ue.push(ie);else if(!ie)for(let Bt of dt){if(!Bt)continue;for(let Br of ot){let ji=Qe.join(Bt,Br);if(ue.push(ji),await r(ji)){ie=ji;break}}if(ie)break;if(!ie)try{let Br=await import("fs");if(!Br.statSync(Bt,{throwIfNoEntry:!1})?.isDirectory())continue;let qm=8,fa=[{path:Bt,depth:0}];while(fa.length>0&&!ie){let Li=fa.pop();if(Li.depth>=qm)continue;let Jl;try{Jl=Br.readdirSync(Li.path,{withFileTypes:!0})}catch{continue}for(let Bi of Jl){if(!Bi.isDirectory())continue;if(Bi.name==="node_modules"||Bi.name.startsWith("."))continue;let Yl=Qe.join(Li.path,Bi.name);for(let Km of ot){let pa=Qe.join(Yl,Km);if(ue.push(pa),await r(pa)){ie=pa;break}}if(ie)break;fa.push({path:Yl,depth:Li.depth+1})}}}catch{}if(ie)break}if(ie)Oo.set(jr,ie)}if(!ie||!await r(ie))return Sm(x,j,ue),$m(x);z.add(ie);let xe;if(Pi.has(ie))xe=Pi.get(ie);else try{xe=await Bun.file(ie).text(),Pi.set(ie,xe)}catch(tt){let ot=tt instanceof Error?tt.message:String(tt);return Sm(x,j,[ie],ot),$m(x)}let we=new Set(["__originalFilePath","__importedComponents",Wi,"__stx_client_signal_names","__stx_runtime_config","__stxServeContext","__stx_scope_seq"]),$e={};for(let[tt,ot]of Object.entries(C))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-qfrg8mnf.js"));_e=await tt(k,C,j,L,z)}if(/<[A-Z][\w.-]*[\s/>]/.test(_e)){let{processComponents:tt}=await ut("stx/component-renderer",()=>import("./chunk-ktk30f6d.js"));_e=await tt(_e,{...C,__processedComponents:X},j,L,z)}let Ce=[];if(ai(_e)){let{processExpressions:tt}=await ut("stx/expressions",()=>import("./chunk-eam7eann.js")),ot=C.__stx_signals_gate===void 0?{...C,__stx_signals_gate:!0}:C;_e=tt(_e,ot,j);for(let Tt of _e.matchAll(/\{\{([\s\S]*?)\}\}/g))Ce.push(Tt[1].trim())}let Ee=bn(_e),Te=[],Re=Ee.output.replace(/\x00STX_SCRIPT_(\d+)\x00/g,(tt,ot)=>{let Tt=Ee.scripts[Number(ot)]||"",dt=Tt.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(Tt),"";return Tt}),{extractSlotContent:ke}=await ut("stx/slots",()=>import("./chunk-fkrzsk74.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=C.__stx_scope_seq??={n:0,key:Bun.hash(String(C.__filename??j)).toString(36).slice(0,6)},Ie=`stx_${oe.replace(/[^a-zA-Z0-9]/g,"_")}_${++Pe.n}_${Pe.key}`,Ze={...$e,$uid:Ie,...v,props:v,slot:Re,$slots:Xe,__processedComponents:G,__sections:{},__stx_signals_gate:he(xe)||ai(k),__stx_preserved_client_expressions:[...Array.isArray(C.__stx_preserved_client_expressions)?C.__stx_preserved_client_expressions:[],...Ce]};fS(xe,Ze);let nt=xe,at=Z(nt);if(at)nt=at.content.trim();let rt=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,Rt=[...xe.matchAll(rt)],ft=[],yt=null,ct=Rt.some((tt)=>/\bserver\b/.test(tt[1]||"")&&/\bcache\b/.test(tt[1]||"")),Pt=null,pt=null,Lt=null,Qn=0,Sn=null;if(iS(L),ct&&Ol>0){let tt=oS({props:v,slot:_e,slotContext:k.trim()?aS($e):void 0,buildMode:L.buildMode??"",skipEventDirectives:L.skipEventDirectives===!0,layers:L._layerGraph?.layers.map((ot)=>ot.configFile),uid:Ie});if(tt!==null){Pt=`${ie}\x00${O(xe)}\x00${tt}`;let ot=ea.get(Pt);if(ot){for(let Tt of ot.dependencies)z.add(Tt);if(Yu(C,ot.clientFactories),Pe.n+=ot.uidsConsumed,ot.preservedClientExpressions.length>0){let Tt=new Set(Array.isArray(C.__stx_preserved_client_expressions)?C.__stx_preserved_client_expressions:[]);for(let dt of ot.preservedClientExpressions)Tt.add(dt);C.__stx_preserved_client_expressions=[...Tt]}return ot.output}pt=new Set(z),Lt=Gu(C),Qn=Pe.n,Sn=new Set(Array.isArray(C.__stx_preserved_client_expressions)?C.__stx_preserved_client_expressions:[])}}let sr=new Set;for(let tt of Rt){let ot=tt[1]||"",Tt=tt[2]||"",dt=ot.includes("server");if(Ve(ot)&&Tt.trim())Tt=Ue(Tt);if(dt&&Tt){for(let Mt of Q(Tt))sr.add(Mt);try{await F(Tt,Ze,ie,{onFailure:(Mt)=>{if(Mt.kind!=="unknown")yt=Mt.kind}})}catch(Mt){}}if(!dt){let Mt=Tt.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=Jr(Mt,Ze,ie);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}>${gS(qt,Ze,ie)}</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,(Tt,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:la}=await ut("stx/slots",()=>import("./chunk-fkrzsk74.js")),{defaultSlot:ua,namedSlots:da}=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?$g(tt,Ie):tt,st=new Map([...da].map(([tt,ot])=>[tt,{...ot,content:Je(ot.content)}]));Nt=await la(Nt,Je(ua),st,Ze);let mt=kc(ft),At=(Array.isArray(Ze.__stx_client_signal_names)?Ze.__stx_client_signal_names:[]).filter((tt)=>!sr.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={...L,_rootComponentsDir:L._rootComponentsDir||L.componentsDir,componentsDir:Qe.dirname(ie),skipSignalsRuntime:!0,skipEventDirectives:De||ft.length===0,defaultLayout:void 0};Ze.__stxProcessingDepth=(C.__stxProcessingDepth||0)+1;let _n=await n(Nt,Ze,ie,Kt,z),Ni=new Set(Array.isArray(C.__stx_preserved_client_expressions)?C.__stx_preserved_client_expressions:[]);for(let tt of _n.matchAll(/\{\{([\s\S]*?)\}\}/g))Ni.add(tt[1].trim());if(Ni.size>0)C.__stx_preserved_client_expressions=[...Ni];let dr=Ie,Gt=_n;if(De){let tt="";if(Object.keys(v).length>0)try{tt=` data-stx-props="${xm(JSON.stringify(v))}"`}catch{}let ot=ne?` stx-hydrate="${xm(ne)}"`:"",Tt=` 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=xc(_n,Tt)??`<${Wt}${Tt}${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 yS(kn,ie,L.buildMode==="compile"),Lr=ne?null:xa(C,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),Tt=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:ie,projectRoot:process.cwd(),serverData:ot,instanceId:Ie})}));Gt+=`
|
|
2099
|
-
`+Tt.join(`
|
|
2100
|
-
`),Ze.__stx_event_bindings=[]}}if(xn){let tt=Gi(Gt,ie);if(tt.hasScoped)Gt=tt.html}if(Pt&&pt){let tt=Array.isArray(C.__stx_preserved_client_expressions)?C.__stx_preserved_client_expressions:[];ea.set(Pt,{output:Gt,dependencies:[...z].filter((ot)=>!pt.has(ot)),clientFactories:Lt?Ju(C,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{X.delete(x)}}async function r(x){return Bun.file(x).exists()}function Nl(x,v){let k=Qe.resolve(v),E=Qe.resolve(x),C=k.endsWith(Qe.sep)?k:k+Qe.sep;if(E===k||E.startsWith(C))return E;return null}async function mS(x,v,k,E){let C=v.startsWith("layouts/")?v.slice(8):v,j=Qe.join(x,C);for(let L of j.endsWith(".stx")?[j]:[j,`${j}.stx`])if(await r(L)){if(E)console.log(`Found layout in ${x}: ${L}`);return k?.add(L),L}return null}async function Wn(x,v,k,E){let C=await hS(x,v,k,E);if(C===null)return null;let j=Nl(C,process.cwd());if(j)return j;let L=[k.root,k.layoutsDir,k.fallbackLayoutsDir,k.componentsDir,k.partialsDir,k.pagesDir,...k._layerLayoutDirs??[]].filter((B)=>typeof B==="string"&&B.length>0);for(let B of L){let z=Qe.isAbsolute(B)?B:Qe.resolve(process.cwd(),B);if(Nl(C,z))return Qe.resolve(C)}return console.warn(`[stx] rejected resolved template path that escapes project root: ${C} (template: ${x}, from: ${v})`),null}async function hS(x,v,k,E){if(k.debug)console.log(`Resolving template path: ${x} from ${v}`);let C=Qe.dirname(v),j=process.cwd();if(x.startsWith("/")){let J=Qe.join(j,x),ne=Nl(J,j);if(!ne)return console.warn(`[stx] rejected template path that escapes project root: ${x} (from ${v})`),null;if(k.debug)console.log(`Checking absolute path: ${ne}`);if(await r(ne)&&E)E.add(ne);return ne}let L=Qe.join(C,x);if(await r(L)){if(k.debug)console.log(`Found direct path: ${L}`);if(E)E.add(L);return L}if(!x.endsWith(".stx")&&!x.endsWith(".jsx")&&!x.endsWith(".tsx"))for(let J of[".stx",".tsx",".jsx"]){let ne=`${L}${J}`;if(await r(ne)){if(k.debug)console.log(`Found direct path with extension: ${ne}`);if(E)E.add(ne);return ne}}let B=[];if(B.push(...k._layerLayoutDirs??[]),k.layoutsDir)B.push(Qe.isAbsolute(k.layoutsDir)?k.layoutsDir:Qe.resolve(process.cwd(),k.layoutsDir));let z=Qe.resolve(C),F=process.cwd();for(let J=0;J<10;J++){let ne=Qe.join(z,"layouts"),re=!1;try{re=_m.statSync(ne,{throwIfNoEntry:!1})?.isDirectory()??!1}catch{}if(re){B.push(ne);break}let se=Qe.dirname(z);if(se===z||se.length<F.length)break;z=se}for(let J of B){let ne=await mS(J,x,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=x.startsWith("layouts/")?x.slice(8):x,re=[Qe.join(J,ne)];if(!x.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(x.startsWith("layouts/")||x.includes("/layouts/")){let J=x.split("layouts/"),ne=Qe.join(k.partialsDir||C,"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,x);if(await r(ne)){if(k.debug)console.log(`Found in partials layouts dir: ${ne}`);if(E)E.add(ne);return ne}if(!x.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 X=k.partialsDir||Qe.join(process.cwd(),"views"),G=Qe.join(X,x);if(await r(G)){if(k.debug)console.log(`Found in views path: ${G}`);if(E)E.add(G);return G}if(!x.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(C.includes("temp")){let J=Qe.join(Qe.dirname(C),"layouts",x);if(await r(J)){if(k.debug)console.log(`Found in temp layouts dir: ${J}`);if(E)E.add(J);return J}if(!x.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: ${x} (referenced from ${v})`);else console.warn(`Template not found: ${x} (referenced from ${v})`);return null}function ci(x,v,k){let E=0,C="",j="";try{if(typeof v==="number"&&v>=0){let L=x.split(`
|
|
2103
|
-
`),B=0;for(let z=0;z<L.length;z++)if(B+=L[z].length+1,B>=v){E=z+1,C=L[z].trim();let F=Math.max(0,z-2),X=Math.min(L.length,z+3);j=L.slice(F,X).map((G,J)=>{let ne=F+J+1;return`${ne===E?"> ":" "}${ne}: ${G}`}).join(`
|
|
2104
|
-
`);break}}else if(k){let L=x.indexOf(k);if(L>=0)return ci(x,L)}}catch{}return{lineNumber:E,lineContent:C,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(x,v,k,E,C,j){let{lineNumber:L,context:B}=ci(E,C,j),z=k.split("/").pop(),F=0;if(typeof C==="number"&&C>=0&&E){let G=E.lastIndexOf(`
|
|
2105
|
-
`,Math.max(0,C-1));F=C-(G+1)+1}let X="";if(L>0)X+=`
|
|
2106
|
-
${k}:${L}${F>0?`:${F}`:""}: ${x.toLowerCase()} error: ${v}
|
|
2107
|
-
`;if(X+=`
|
|
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
|
-
`,X+=`${ht.bold}${ht.red}\u2502${ht.reset} ${ht.bold}${ht.bgRed} ERROR ${ht.reset} ${ht.red}${x} Error${ht.reset}${" ".repeat(Math.max(0,43-x.length))}${ht.bold}${ht.red}\u2502${ht.reset}
|
|
2110
|
-
`,X+=`${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
|
-
`,X+=`
|
|
2112
|
-
${ht.cyan}${ht.bold}File:${ht.reset} ${ht.dim}${z}${ht.reset}`,L>0)X+=` ${ht.gray}(line ${L}${F>0?`, col ${F}`:""})${ht.reset}`;if(X+=`
|
|
2113
|
-
${ht.yellow}${ht.bold}Message:${ht.reset} ${v}
|
|
2114
|
-
`,B)X+=`
|
|
2115
|
-
${ht.blue}${ht.bold}Context:${ht.reset}
|
|
2116
|
-
${ht.dim}${B}${ht.reset}
|
|
2117
|
-
`;return X}function ee(){Pi.clear(),Oo.clear(),ea.clear()}function ju(){return{size:Pi.size,maxSize:500}}var Ml=I(128);async function yS(x,v,k){let E=O(x,v,k),C=Ml.get(E);if(C){if(Yt(C.deps))return C;Ml.delete(E)}let j=Wr(x,{filePath:v,projectRoot:process.cwd()}),L=j.code,B=qr(j.styles);L=bt(L).code;let{hasUserImports:z,bundleClientScript:F}=await ut("stx/client-script-bundler",()=>import("./chunk-6fw3rfcj.js")),X=[],G=!1;if(z(L)){let ie=L;L=await F(ie,v,{projectRoot:process.cwd(),minify:k,collectInputs:X}),G=L===ie}let{stripStxRuntimeImports:J}=await ut("stx/signal-processing",()=>import("./chunk-avjgetkh.js"));L=J(L);let ne=R(L),re=lS(ne),se=`function(__scopeId) {
|
|
2118
|
-
${_t("const",[...vi,...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((ie)=>`if (typeof ${ie} !== 'undefined') __localVars['${ie}'] = ${ie};`).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
|
-
}`,oe={vendorStyleTags:B,factoryBody:se,deps:hd([...X,...j.styles.map((ie)=>ie.resolvedPath)])};if(!G&&j.unresolved.length===0)Ml.set(E,oe);return oe}async function Bg(x,v,k=""){let E=x,C=[],j=/@markdown(?:\([^)]*\))?/g,L;while((L=j.exec(x))!==null){let B=L.index,z=L[0].match(/@markdown\(([^)]*)\)/),F=z?z[1]:"",X=B+L[0].length,G=1,J=X,ne=-1;while(G>0&&J<x.length){let oe=x.indexOf("@markdown",J),ie=x.indexOf("@endmarkdown",J);if(ie===-1)break;if(oe!==-1&&oe<ie&&oe!==B){let ge=x[oe+9];if(ge==="("||ge===`
|
|
2160
|
-
`||ge==="\r"||ge===" "||ge===void 0)G++;J=oe+9}else{if(G--,G===0){ne=ie;break}J=ie+12}}if(ne===-1)continue;let re=x.slice(X,ne),se=x.slice(B,ne+12);C.push({fullMatch:se,options:F,content:re,index:B}),j.lastIndex=ne+12}for(let{fullMatch:B,options:z,content:F,index:X}of C)try{let G={};if(z)z.split(",").forEach((re)=>{let se=re.trim();if(se)G[se]=!0});let J={gfm:G.gfm??!0,breaks:G.breaks??!1},ne=Oe(F.trim(),J);E=E.split(B).join(ne)}catch(G){let J=G instanceof Error?G.message:String(G),ne=g("Markdown Directive",`Error processing markdown: ${J}`,k,x,X,B);E=E.split(B).join(ne)}return E}async function Em(x,v,k,E){let C={gfm:!0,breaks:!1};return v.forEach((j)=>{let L=j.trim().replace(/['"]/g,"");if(L==="breaks")C.breaks=!0;if(L==="no-gfm")C.gfm=!1}),Oe(x.trim(),C)}var Fs=[320,480,640,768,1024,1280,1536,1920,2560],xS=[1,1.5,2,3],Di=["avif","webp","jpeg"],bS={avif:"image/avif",webp:"image/webp",jpeg:"image/jpeg",png:"image/png",gif:"image/gif"};function jl(x,v=Fs,k={},E){return v.sort((C,j)=>C-j).map((C)=>`${Mi(x,{...k,w:C,fm:E})} ${C}w`).join(", ")}function Cm(x,v,k=xS,E={},C){return k.sort((j,L)=>j-L).map((j)=>{let L=Math.round(v*j);return`${Mi(x,{...E,w:L,dpr:j,fm:C})} ${j}x`}).join(", ")}function Ll(x,v="100vw"){if(!x||Object.keys(x).length===0)return v;let E=Object.entries(x).map(([C,j])=>{let L=/^\d+$/.test(C)?`${C}px`:C;return{bp:L,size:j,numericBp:Number.parseInt(L)||0}}).sort((C,j)=>C.numericBp-j.numericBp).map(({bp:C,size:j})=>`(max-width: ${C}) ${j}`);return E.push(v),E.join(", ")}function Mi(x,v={}){let k=Object.entries(v).filter(([,j])=>j!==void 0&&j!==null).map(([j,L])=>{if(Array.isArray(L))return[j,L.join(",")];return[j,String(L)]});if(k.length===0)return x;let E=k.map(([j,L])=>`${j}=${encodeURIComponent(L)}`).join("&"),C=x.includes("?")?"&":"?";return`${x}${C}${E}`}function Bl(x){return bS[x]||"application/octet-stream"}var vS={strategy:"thumbhash",width:20,quality:50,blurLevel:40,transitionDuration:300,easing:"ease-out"},Fl=`
|
|
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 wS(){try{return await import("ts-images")}catch{return null}}async function SS(x,v={}){let k={...vS,...v},E=await wS();if(E)try{return await $S(x,k,E)}catch(C){console.warn(`[stx-media] ts-images placeholder generation failed, using fallback: ${C}`)}return _S(x,k)}async function $S(x,v,k){let{generatePlaceholder:E,generateThumbHash:C}=k,L={blur:"blur",thumbhash:"thumbhash",blurhash:"thumbhash",pixelate:"pixelate","dominant-color":"dominant-color",none:"blur"}[v.strategy]||"blur";if(v.strategy==="thumbhash")return{dataURL:(await C(x)).dataUrl,width:32,height:32,aspectRatio:1,originalWidth:0,originalHeight:0,strategy:"thumbhash"};let B=await E(x,{width:v.width,height:v.height,quality:v.quality,blurLevel:v.blurLevel,strategy:L,base64Encode:!0});return{dataURL:B.dataURL,width:B.width,height:B.height,aspectRatio:B.aspectRatio,originalWidth:B.originalWidth,originalHeight:B.originalHeight,strategy:v.strategy,dominantColor:B.dominantColor,css:B.css}}function _S(x,v){let k=v.width||20,E=v.height||k,C="#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:v.strategy,dominantColor:"#e5e7eb"}}function Rm(x,v,k={}){let E=k.transitionDuration||300,C=k.easing||"ease-out";return`
|
|
2190
|
-
#${x} {
|
|
2191
|
-
--stx-img-transition-duration: ${E}ms;
|
|
2192
|
-
--stx-img-transition-easing: ${C};
|
|
2193
|
-
background-image: url('${v.dataURL}');
|
|
2194
|
-
background-size: cover;
|
|
2195
|
-
background-position: center;
|
|
2196
|
-
}
|
|
2197
|
-
|
|
2198
|
-
#${x} img {
|
|
2199
|
-
opacity: 0;
|
|
2200
|
-
transition: opacity var(--stx-img-transition-duration) var(--stx-img-transition-easing);
|
|
2201
|
-
}
|
|
2202
|
-
|
|
2203
|
-
#${x}.stx-img-loaded img {
|
|
2204
|
-
opacity: 1;
|
|
2205
|
-
}
|
|
2206
|
-
`.trim()}var zl=new Map;async function Tm(x,v={}){let k=`${x}:${JSON.stringify(v)}`;if(zl.has(k))return zl.get(k);let E=await SS(x,v);return zl.set(k,E),E}async function kS(){try{return await import("./chunk-8nsfkr5n.js")}catch(x){if(!Am)console.warn("[stx-media] Image processor not available, some features disabled:",x),Am=!0;return null}}var Am=!1,Wl=80,na="async",ra="lazy",Im=!1;async function ta(x,v={}){let k=v,E=x;if(E.process&&!E.skipOptimization){if(k.tsImagesConfig?.enabled&&!k.isDev)return TS(E,k)}if(k.processedResult?.processed)return Hl(x,k.processedResult,v);if(k.responsiveVariants)return Mm(x,k.responsiveVariants,v);let{src:C,alt:j,width:L,height:B,sizes:z,widths:F=Fs,dpr:X,formats:G=Di,quality:J=Wl,params:ne={},placeholder:re="none",placeholderOptions:se={},lazy:oe=!0,priority:ie=!1,loading:ge=ie?"eager":ra,decoding:ue=na,fetchpriority:xe,objectFit:we,objectPosition:$e,crossorigin:_e,referrerpolicy:Ce}=x,{class:Ee,style:Te,id:Re}=x,ke=x.data||{},{isDev:Ae=!1,baseUrl:Xe=""}=v;if(Ae&&!v.optimize)return RS(x);let Pe,Ie,Ze=Re||`stx-img-${Math.random().toString(36).slice(2,8)}`;if(re!=="none"&&!ie)try{Pe=await Tm(C,{strategy:re,...se}),Ie=Rm(Ze,Pe,se)}catch{}let nt=X!==void 0&&L!==void 0,at;if(nt)at=CS(x,Ze,Pe,v);else at=await ES(x,Ze,Pe,v);let rt;if(ie){let yt=G.includes("webp")?"webp":G[0],ct=jl(C,F,{...ne,q:J},yt),Pt=typeof z==="object"?Ll(z):z||"100vw";rt=`<link rel="preload" as="image" imagesrcset="${ct}" imagesizes="${Pt}" />`}let Rt=[];if(!Im&&re!=="none")Rt.push(Fl),Im=!0;if(Ie)Rt.push(Ie);let ft=oe?Dm(Ze):void 0;return{html:at,preloadLink:rt,css:Rt.length>0?Rt.join(`
|
|
2207
|
-
`):void 0,script:ft}}async function ES(x,v,k,E){let{src:C,alt:j,width:L,height:B,sizes:z,widths:F=Fs,formats:X=Di,quality:G=Wl,params:J={},lazy:ne=!0,priority:re=!1,loading:se=re?"eager":ra,decoding:oe=na,fetchpriority:ie,objectFit:ge,objectPosition:ue,crossorigin:xe,referrerpolicy:we}=x,{class:$e,style:_e}=x,Ce=x.data||{},Ee=typeof z==="object"?Ll(z):z||"100vw",Te=[];for(let Ae of X){let Xe=jl(C,F,{...J,q:G},Ae),Pe=Bl(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=Vl({src:Mi(C,{...J,q:G}),alt:j,width:L,height:B,loading:re?void 0:se,decoding:oe,fetchpriority:re?"high":ie,objectFit:ge,objectPosition:ue,crossorigin:xe,referrerpolicy:we,className:Pm($e,k),style:Ul(_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="${v}" class="stx-img-placeholder" style="${Ae}">
|
|
2208
|
-
<picture>
|
|
2209
|
-
${Te.join(`
|
|
2210
|
-
`)}
|
|
2211
|
-
<img ${Re} />
|
|
2212
|
-
</picture>
|
|
2213
|
-
</div>`}else ke=`<picture${v?` id="${v}"`:""}>
|
|
2214
|
-
${Te.join(`
|
|
2215
|
-
`)}
|
|
2216
|
-
<img ${Re} />
|
|
2217
|
-
</picture>`;return ke}function CS(x,v,k,E){let{src:C,alt:j,width:L,height:B,dpr:z=[1,2,3],quality:F=Wl,params:X={},lazy:G=!0,priority:J=!1,loading:ne=J?"eager":ra,decoding:re=na,fetchpriority:se,objectFit:oe,objectPosition:ie,crossorigin:ge,referrerpolicy:ue}=x,{class:xe,style:we}=x,$e=x.data||{},_e=typeof L==="number"?L:Number.parseInt(String(L),10),Ce=Cm(C,_e,z,{...X,q:F}),Ee=Vl({src:Mi(C,{...X,w:_e,q:F}),alt:j,width:L,height:B,loading:J?void 0:ne,decoding:re,fetchpriority:J?"high":se,objectFit:oe,objectPosition:ie,crossorigin:ge,referrerpolicy:ue,className:Pm(xe,k),style:Ul(we,oe,ie,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="${v}" class="stx-img-placeholder" style="${Re}">
|
|
2218
|
-
<img ${Ee} ${Te} />
|
|
2219
|
-
</div>`}return`<img ${v?`id="${v}" `:""}${Ee} ${Te} />`}function RS(x){let{src:v,alt:k,width:E,height:C,loading:j=ra,decoding:L=na,fetchpriority:B,objectFit:z,objectPosition:F,crossorigin:X,referrerpolicy:G,priority:J=!1}=x,{class:ne,style:re,id:se}=x,oe=x.data||{};return{html:`<img ${Vl({src:v,alt:k,width:E,height:C,loading:J?"eager":j,decoding:L,fetchpriority:J?"high":B,objectFit:z,objectPosition:F,crossorigin:X,referrerpolicy:G,className:ne,style:Ul(re,z,F),id:se,data:oe})} />`}}function Vl(x){let v=[];if(x.lazy)v.push(`data-src="${$n(x.src)}"`),v.push('src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7"');else v.push(`src="${$n(x.src)}"`);if(v.push(`alt="${$n(x.alt)}"`),x.width)v.push(`width="${x.width}"`);if(x.height)v.push(`height="${x.height}"`);if(x.loading)v.push(`loading="${x.loading}"`);if(x.decoding)v.push(`decoding="${x.decoding}"`);if(x.fetchpriority)v.push(`fetchpriority="${x.fetchpriority}"`);if(x.crossorigin)v.push(`crossorigin="${x.crossorigin}"`);if(x.referrerpolicy)v.push(`referrerpolicy="${x.referrerpolicy}"`);if(x.className)v.push(`class="${$n(x.className)}"`);if(x.style)v.push(`style="${$n(x.style)}"`);if(x.id)v.push(`id="${$n(x.id)}"`);if(x.data)for(let[k,E]of Object.entries(x.data))v.push(`data-${k}="${$n(E)}"`);if(x.lazy)v.push("data-stx-lazy");return v.join(" ")}function Pm(x,v){let k=[];if(x)k.push(x);if(v)k.push("stx-img-blur");return k.join(" ")||""}function Ul(x,v,k,E){let C=[];if(v)C.push(`object-fit: ${v}`);if(k)C.push(`object-position: ${k}`);if(E)C.push("opacity: 0; transition: opacity 300ms ease-out");if(x)C.push(x);return C.join("; ")}function $n(x){return x.replace(/&/g,"&").replace(/"/g,""").replace(/'/g,"'").replace(/</g,"<").replace(/>/g,">")}function Dm(x){return`
|
|
2220
|
-
(function() {
|
|
2221
|
-
const container = document.getElementById('${x}');
|
|
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 TS(x,v){let k=await kS();if(!k)return ta({...x,process:!1},v);let E=v.tsImagesConfig;if(x.responsiveWidths&&x.responsiveWidths.length>0||x.widths&&x.widths.length>0||!x.width&&!x.dpr){let j=await k.generateResponsiveVariants(x.src,x,E);if(j)return Mm(x,j,v)}else{let j=await k.processImage(x.src,x,E);if(j.processed)return Hl(x,j,v)}return ta({...x,process:!1},v)}async function Hl(x,v,k){let{alt:E,width:C,height:j,lazy:L=!0,priority:B=!1,objectFit:z,objectPosition:F,crossorigin:X,referrerpolicy:G}=x,{class:J,style:ne}=x,re=x.id||`stx-img-${Math.random().toString(36).slice(2,8)}`,se=x.data||{},oe=v.variants||[],ie=oe.find((Ie)=>Ie.format==="jpeg")||oe.find((Ie)=>Ie.format==="webp")||oe[0],ge=ie?.url||x.src,ue=oe.filter((Ie)=>Ie.format===(ie?.format||"jpeg")).map((Ie)=>`${Ie.url} ${Ie.width}w`).join(", "),xe=new Map;for(let Ie of oe){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=Bl(Ie);if(L&&!B)we.push(` <source type="${at}" data-srcset="${nt}" />`);else we.push(` <source type="${at}" srcset="${nt}" />`)}}let _e=[];if(L&&!B){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=C||v.originalWidth,Ee=j||v.originalHeight;if(Ce)_e.push(`width="${Ce}"`);if(Ee)_e.push(`height="${Ee}"`);if(!B)_e.push(`loading="${L?"lazy":"eager"}"`);if(_e.push('decoding="async"'),B)_e.push('fetchpriority="high"');if(X)_e.push(`crossorigin="${X}"`);if(G)_e.push(`referrerpolicy="${G}"`);let Te=[];if(z)Te.push(`object-fit: ${z}`);if(F)Te.push(`object-position: ${F}`);if(v.placeholder&&L)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(v.placeholder)Re.push("stx-img-blur");if(Re.length>0)_e.push(`class="${Re.join(" ")}"`);if(L&&!B)_e.push("data-stx-lazy");for(let[Ie,Ze]of Object.entries(se))_e.push(`data-${Ie}="${$n(Ze)}"`);let ke;if(v.placeholder||v.dominantColor&&x.useDominantColor){let Ie=v.placeholder?`background-image: url('${v.placeholder}'); background-size: cover; background-position: center;`:`background-color: ${v.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(v.placeholder)Ae.push(Fl);let Xe=L?Dm(re):void 0,Pe;if(B&&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 Mm(x,v,k){let E={src:v.src,processed:!0,variants:[],placeholder:v.placeholder?.dataURL,originalWidth:v.placeholder?.width,originalHeight:v.placeholder?.height};for(let[C,j]of Object.entries(v.byFormat))if(j)E.variants.push(...j);return Hl(x,E,k)}function AS(){return qe({name:"img",hasEndTag:!1,description:"Render an optimized responsive image with srcset and lazy loading",transform:async(x,v,k,E)=>{let{src:C,alt:j,options:L}=IS(x,v,k);if(!C)return console.warn("@img directive: missing src argument"),"<!-- @img: missing src -->";let B={src:C,alt:j||"",widths:L.widths||Fs,formats:L.formats||Di,quality:L.quality,sizes:L.sizes,dpr:L.dpr,params:L.params,placeholder:L.placeholder,placeholderOptions:L.placeholderOptions,lazy:L.lazy!==!1,priority:L.priority||!1,loading:L.loading,decoding:L.decoding,fetchpriority:L.fetchpriority,objectFit:L.objectFit,objectPosition:L.objectPosition,class:L.class,style:L.style,id:L.id,width:L.width,height:L.height},z=k.__isDev||!1,F=await ta(B,{isDev:z}),X=F.html;if(F.preloadLink)X=F.preloadLink+`
|
|
2268
|
-
`+X;if(F.css)X+=`
|
|
2269
|
-
<style>${F.css}</style>`;if(F.script)X+=`
|
|
2270
|
-
<script>${F.script}</script>`;return X},defaults:{src:"",alt:"",options:{lazy:!0,placeholder:"none"}}})}function IS(x,v,k){if(v.src)return{src:String(v.src),alt:String(v.alt||""),options:v.options||{}};let E=x.trim();if(E.startsWith("@img(")||E.startsWith("("))E=E.replace(/^@img\(/,"").replace(/^\(/,"").replace(/\)$/,"");let C=PS(E),j=ql(C[0],k)||"",L=ql(C[1],k)||"",B={};if(C[2]){let z=ql(C[2],k);if(typeof z==="object"&&z!==null)B=z;else if(typeof C[2]==="string")try{B=JSON.parse(C[2])}catch{}}return{src:j,alt:L,options:B}}function PS(x){let v=[],k="",E=!1,C="",j=0,L=0;for(let B=0;B<x.length;B++){let z=x[B],F=B>0?x[B-1]:"";if((z==='"'||z==="'"||z==="`")&&F!=="\\"){if(!E)E=!0,C=z;else if(z===C)E=!1,C="";else k+=z;continue}if(!E){if(z==="{")j++;if(z==="}")j--;if(z==="[")L++;if(z==="]")L--;if(z===","&&j===0&&L===0){v.push(k.trim()),k="";continue}}k+=z}if(k.trim())v.push(k.trim());return v}function ql(x,v){if(typeof x!=="string")return x;let k=x.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=v[k];if(E!==void 0)return E}if(k.startsWith("{")||k.startsWith("["))try{return JSON.parse(k)}catch{}return k}var Om=AS();async function jm(){try{return await import("./chunk-fmc9fj4a.js")}catch(x){if(!Nm)console.warn("[stx-media] Video processor not available, some features disabled:",x),Nm=!0;return null}}var Nm=!1,Lm=!0,Bm="metadata",DS="https://cdn.jsdelivr.net/npm/ts-video-player@latest/dist/index.min.js";async function sa(x,v={}){let k=v,E=x;if(E.process&&!E.skipProcessing){if(k.tsVideosConfig?.enabled&&!k.isDev)return LS(E,k)}if(k.processedResult?.processed)return Fm(x,k.processedResult,v);let C;if(E.generatePoster&&E.src&&!x.poster)C=await BS(E,k);let{src:j,sources:L=[],poster:B,posterPlaceholder:z,controls:F=Lm,autoplay:X=!1,muted:G=!1,loop:J=!1,preload:ne=Bm,playsinline:re=!0,lazy:se=!0,player:oe="native",type:ie,width:ge,height:ue,crossorigin:xe,disablePictureInPicture:we=!1,disableRemotePlayback:$e=!1}=x,_e=C||B,{class:Ce,style:Ee}=x,Te=x.id||`stx-video-${Math.random().toString(36).slice(2,8)}`;if(oe==="ts-video")return OS(x,v);if(ie&&ie!=="video")return MS(j||"",ie,x);let Re=L.length>0?L:j?[{src:j,type:zm(j)}]:[],ke=[`id="${Te}"`];if(F)ke.push("controls");if(X)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 MS(x,v,k){let{width:E=640,height:C=360}=k,{class:j,style:L}=k,B=k.id||`stx-embed-${Math.random().toString(36).slice(2,8)}`,z,F=null;switch(v){case"youtube":F=NS(x),z=F?`https://www.youtube-nocookie.com/embed/${F}`:x;break;case"vimeo":F=jS(x),z=F?`https://player.vimeo.com/video/${F}`:x;break;case"dailymotion":F=x.split("/").pop()||"",z=`https://www.dailymotion.com/embed/video/${F}`;break;case"twitch":F=x.split("/").pop()||"",z=`https://player.twitch.tv/?video=${F}&parent=${typeof window<"u"?window.location.hostname:"localhost"}`;break;default:z=x}let X=[`id="${B}"`,`src="${Ht(z)}"`,`width="${E}"`,`height="${C}"`,'frameborder="0"',"allowfullscreen",'allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"'];if(j)X.push(`class="${Ht(j)}"`);if(L)X.push(`style="${Ht(L)}"`);if(k.lazy)X.push('loading="lazy"');return{html:`<div class="stx-video-embed" style="position:relative;padding-bottom:56.25%;height:0;overflow:hidden;">
|
|
2310
|
-
<iframe ${X.join(" ")} style="position:absolute;top:0;left:0;width:100%;height:100%;"></iframe>
|
|
2311
|
-
</div>`}}function OS(x,v={}){let{src:k,sources:E=[],poster:C,controls:j=!0,autoplay:L=!1,muted:B=!1,loop:z=!1,preload:F="metadata",playsinline:X=!0,lazy:G=!0,width:J,height:ne}=x,{class:re,style:se}=x,oe=x.id||`ts-video-${Math.random().toString(36).slice(2,8)}`,ie={src:E.length>0?E:k,autoplay:L,loop:z,muted:B,playsinline:X,preload:F,poster:C,controls:j,title:x.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="${oe}"
|
|
2314
|
-
class="ts-video-player${re?" "+Ht(re):""}"
|
|
2315
|
-
style="${ge}"
|
|
2316
|
-
data-ts-video-player
|
|
2317
|
-
data-config='${JSON.stringify(ie)}'
|
|
2318
|
-
${G?"data-lazy":""}
|
|
2319
|
-
>
|
|
2320
|
-
<div class="ts-video-player__container">
|
|
2321
|
-
${C?`
|
|
2322
|
-
<div class="ts-video-player__placeholder" style="background-image: url('${Ht(C)}');">
|
|
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('${oe}');
|
|
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 = '${DS}';
|
|
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 zm(x){switch(x.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 NS(x){let v=[/youtube\.com\/watch\?v=([^&]+)/,/youtube\.com\/embed\/([^?]+)/,/youtu\.be\/([^?]+)/,/youtube\.com\/v\/([^?]+)/];for(let k of v){let E=x.match(k);if(E)return E[1]}return null}function jS(x){let v=x.match(/vimeo\.com\/(\d+)/);return v?v[1]:null}function Ht(x){return x.replace(/&/g,"&").replace(/"/g,""").replace(/'/g,"'")}async function LS(x,v){let k=await jm();if(!k)return sa({...x,process:!1},v);let E=v.tsVideosConfig,C=await k.processVideo(x.src,x,E,x.onProcessProgress);if(C.processed)return Fm(x,C,v);return sa({...x,process:!1},v)}async function BS(x,v){let k=await jm();if(!k||!x.src)return;let E=typeof x.generatePoster==="object"?x.generatePoster:{timestamp:0},C=v.tsVideosConfig||{enabled:!0,outputDir:"dist/videos",baseUrl:"/videos"};return(await k.generatePoster(x.src,E,C.outputDir,C.baseUrl||"/videos"))?.url}function Fm(x,v,k){let{controls:E=Lm,autoplay:C=!1,muted:j=!1,loop:L=!1,preload:B=Bm,playsinline:z=!0,lazy:F=!0,width:X,height:G,crossorigin:J,disablePictureInPicture:ne=!1,disableRemotePlayback:re=!1}=x,{class:se,style:oe}=x,ie=x.id||`stx-video-${Math.random().toString(36).slice(2,8)}`,ge=x.src,ue=zm(ge);if(v.transcoded)ge=v.transcoded.url,ue="video/mp4";let xe=v.streaming?.hls||v.streaming?.dash;if(xe){if(v.streaming?.hls)ge=v.streaming.hls.manifestUrl,ue="application/x-mpegURL";else if(v.streaming?.dash)ge=v.streaming.dash.manifestUrl,ue="application/dash+xml"}let we=v.poster?.url||x.poster,$e=[`id="${ie}"`];if(E)$e.push("controls");if(C)$e.push("autoplay");if(j)$e.push("muted");if(L)$e.push("loop");if(z)$e.push("playsinline");if(ne)$e.push("disablepictureinpicture");if(re)$e.push("disableremoteplayback");if(J)$e.push(`crossorigin="${J}"`);if(F){if($e.push(`data-preload="${B}"`),$e.push('preload="none"'),we)$e.push(`data-poster="${Ht(we)}"`);$e.push("data-stx-lazy")}else if($e.push(`preload="${B}"`),we)$e.push(`poster="${Ht(we)}"`);let _e=X||v.metadata?.width,Ce=G||v.metadata?.height;if(_e)$e.push(`width="${_e}"`);if(Ce)$e.push(`height="${Ce}"`);if(se)$e.push(`class="${Ht(se)}"`);if(oe)$e.push(`style="${Ht(oe)}"`);let Te=` <source ${F?`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(v.spriteSheet)Re=`<div class="stx-video-wrapper" data-sprite-sheet="${Ht(v.spriteSheet.url)}" data-sprite-cols="${v.spriteSheet.columns}" data-sprite-interval="${v.spriteSheet.interval}">
|
|
2482
|
-
${Re}
|
|
2483
|
-
</div>`;let ke;if(F)ke=`
|
|
2484
|
-
(function() {
|
|
2485
|
-
var video = document.getElementById('${ie}');
|
|
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 Wm(){return qe({name:"video",hasEndTag:!1,description:"Render a video with optional ts-videos processing, streaming, and poster generation",transform:async(x,v,k,E)=>{let{src:C,options:j}=zS(x,v,k);if(!C)return console.warn("@video directive: missing src argument"),"<!-- @video: missing src -->";let L={src:C,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},z={isDev:k.__isDev||!1,tsVideosConfig:k.__tsVideosConfig},F=await sa(L,z),X=F.html;if(F.css)X+=`
|
|
2528
|
-
<style>${F.css}</style>`;if(F.script)X+=`
|
|
2529
|
-
<script>${F.script}</script>`;return X},defaults:{src:"",options:{controls:!0,lazy:!0,preload:"metadata"}}})}function zS(x,v,k){if(v.src)return{src:String(v.src),options:v.options||{}};let E=x.trim();if(E.startsWith("@video(")||E.startsWith("("))E=E.replace(/^@video\(/,"").replace(/^\(/,"").replace(/\)$/,"");let C=FS(E),j=Vm(C[0],k)||"",L={};if(C[1]){let B=Vm(C[1],k);if(typeof B==="object"&&B!==null)L=B;else if(typeof C[1]==="string")try{L=JSON.parse(C[1])}catch{}}return{src:j,options:L}}function FS(x){let v=[],k="",E=!1,C="",j=0,L=0;for(let B=0;B<x.length;B++){let z=x[B],F=B>0?x[B-1]:"";if((z==='"'||z==="'"||z==="`")&&F!=="\\"){if(!E)E=!0,C=z;else if(z===C)E=!1,C="";else k+=z;continue}if(!E){if(z==="{")j++;if(z==="}")j--;if(z==="[")L++;if(z==="]")L--;if(z===","&&j===0&&L===0){v.push(k.trim()),k="";continue}}k+=z}if(k.trim())v.push(k.trim());return v}function Vm(x,v){if(typeof x!=="string")return x;let k=x.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=v[k];if(E!==void 0)return E}if(k.startsWith("{")||k.startsWith("["))try{return JSON.parse(k)}catch{}return k}var Kl=Wm();import WS from"fs";import wn from"path";async function qn(x,v){if(!x.webComponents?.enabled)return[];let k=x.webComponents.components||[],E=[];if(k.length>0){if(x.debug)console.log(`Building ${k.length} web components...`);for(let C of k)try{let j=await VS(C,x,v);if(j)E.push(j)}catch(j){if(console.error(`Error building web component ${C.name}:`,j),x.debug)throw j}}return E}async function VS(x,v,k){let{name:E,file:C,tag:j,extends:L}=x;if(!E||!C||!j)return console.error("Invalid web component configuration, missing required fields:",x),null;let B=null;if(wn.isAbsolute(C)&&await r(C))B=C;else if(v.componentsDir){let se=wn.join(v.componentsDir,C);if(await r(se))B=se}if(!B)B=await Wn(C,process.cwd(),v,k);if(!B)return console.error(`Web component source file not found: ${C}`),null;let z=await Bun.file(B).text();k.add(B);let X=(x.outputFormat||"js")==="ts",G=X?HS({name:E,tag:j,baseElement:L,source:z,shadowDOM:x.shadowDOM??!0,template:x.template??!0,styleSource:x.styleSource,attributes:x.attributes||[],attributeTypes:x.attributeTypes||{}}):US({name:E,tag:j,baseElement:L,source:z,shadowDOM:x.shadowDOM??!0,template:x.template??!0,styleSource:x.styleSource,attributes:x.attributes||[]}),J=v.webComponents?.outputDir||"dist/web-components";await WS.promises.mkdir(J,{recursive:!0});let ne=X?"ts":"js",re=wn.join(J,`${j}.${ne}`);if(await Bun.write(re,G),v.debug)console.log(`Built web component ${E} -> ${re}`);return re}function US(x){let{name:v,tag:k,baseElement:E="HTMLElement",source:C,shadowDOM:j,template:L,styleSource:B,attributes:z=[]}=x,F=C.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,"").trim();if(!j)F=F.replace(/<slot\s+name=["']([^"']+)["']\s*>([\s\S]*?)<\/slot>/gi,'<div data-slot="$1">$2</div>'),F=F.replace(/<slot\s+name=["']([^"']+)["']\s*\/>/gi,'<div data-slot="$1"></div>'),F=F.replace(/<slot\s*>([\s\S]*?)<\/slot>/gi,"<div data-default-slot>$1</div>"),F=F.replace(/<slot\s*\/>/gi,"<div data-default-slot></div>");let X="";if(B)X=`<link rel="stylesheet" href="${B}">`;return`/**
|
|
2530
|
-
* ${v} Web Component
|
|
2531
|
-
* Auto-generated from stx component
|
|
2532
|
-
*/
|
|
2533
|
-
class ${v.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
|
-
${L?`
|
|
2542
|
-
_createTemplate() {
|
|
2543
|
-
const template = document.createElement('template')
|
|
2544
|
-
template.innerHTML = \`${X}${F}\`
|
|
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"} = \`${X}${F}\`
|
|
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
|
-
${z.length>0?`
|
|
2595
|
-
static get observedAttributes() {
|
|
2596
|
-
return [${z.map((G)=>`'${G}'`).join(", ")}]
|
|
2597
|
-
}
|
|
2598
|
-
|
|
2599
|
-
attributeChangedCallback(name, oldValue, newValue) {
|
|
2600
|
-
if (oldValue !== newValue) {
|
|
2601
|
-
this[name] = newValue
|
|
2602
|
-
${L?"":"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
|
-
${L?"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}', ${v.replace(/\W/g,"")})
|
|
2621
|
-
`}function HS(x){let{name:v,tag:k,baseElement:E="HTMLElement",source:C,shadowDOM:j,template:L,styleSource:B,attributes:z=[],attributeTypes:F={}}=x,X=v.replace(/\W/g,""),G=C.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=B?`<link rel="stylesheet" href="${B}">`:"",ne=(we)=>{switch(F[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=z.map((we)=>` private _${re(we)}: ${ne(we)} | null = null;`).join(`
|
|
2622
|
-
`),oe=z.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
|
-
`),ie=z.length>0?`/**
|
|
2637
|
-
* Props interface for ${v}
|
|
2638
|
-
*/
|
|
2639
|
-
export interface ${X}Props {
|
|
2640
|
-
${z.map((we)=>{let $e=ne(we);return` ${re(we)}?: ${$e};`}).join(`
|
|
2641
|
-
`)}
|
|
2642
|
-
}
|
|
2643
|
-
`:"",ge=z.length>0?`
|
|
2644
|
-
static get observedAttributes(): string[] {
|
|
2645
|
-
return [${z.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
|
-
${L?"":"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(F)};
|
|
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=L?`
|
|
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
|
-
* ${v} 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
|
-
${ie}
|
|
2697
|
-
/**
|
|
2698
|
-
* ${v} custom element class
|
|
2699
|
-
* @customElement ${k}
|
|
2700
|
-
*/
|
|
2701
|
-
export class ${X} 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
|
-
${oe}
|
|
2750
|
-
|
|
2751
|
-
connectedCallback(): void {
|
|
2752
|
-
if (this._initialized) return;
|
|
2753
|
-
${j?"":"this._slotContent = Array.from(this.childNodes);"}
|
|
2754
|
-
this._initialized = true;
|
|
2755
|
-
${L?"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}': ${X};
|
|
2771
|
-
}
|
|
2772
|
-
}
|
|
2773
|
-
|
|
2774
|
-
// Register the web component
|
|
2775
|
-
customElements.define('${k}', ${X});
|
|
2776
|
-
`}function qS(x,v){let k=x.match(/<script\b[^>]*>([\s\S]*?)<\/script>/i),E=k?k[1].trim():"",C=v,j=[],L=!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)C=ne[1];let re=J.match(/props\s*:\s*\[([\s\S]*?)\]/);if(re)j=re[1].split(",").map((oe)=>oe.trim().replace(/['"`]/g,"")).filter((oe)=>oe.length>0);let se=J.match(/shadowDOM\s*:\s*(true|false)/);if(se)L=se[1]==="true"}catch{}}let B=x.match(/<template\b(?![^>]*\bid\s*=)[^>]*>([\s\S]*?)<\/template>/i),z=B?B[1].trim():"",F=x.match(/<style\b[^>]*>([\s\S]*?)<\/style>/i),X=F?F[1].trim():"";return{tag:C,props:j,template:z,styles:X,script:E,shadowDOM:L}}function KS(x){let{tag:v,props:k,template:E,styles:C,shadowDOM:j}=x,L=v.split("-").map((G)=>G.charAt(0).toUpperCase()+G.slice(1)).join(""),B=E.replace(/\\/g,"\\\\").replace(/`/g,"\\`").replace(/\$\{/g,"\\${"),z=C.replace(/\\/g,"\\\\").replace(/`/g,"\\`"),F=k.map((G)=>`'${G}'`).join(", "),X=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
|
-
* ${L} Web Component
|
|
2790
|
-
* Auto-generated from SFC
|
|
2791
|
-
*/
|
|
2792
|
-
class ${L} extends HTMLElement {
|
|
2793
|
-
constructor() {
|
|
2794
|
-
super();
|
|
2795
|
-
${j?"this.attachShadow({ mode: 'open' });":""}
|
|
2796
|
-
this._render();
|
|
2797
|
-
}
|
|
2798
|
-
|
|
2799
|
-
static get observedAttributes() {
|
|
2800
|
-
return [${F}];
|
|
2801
|
-
}
|
|
2802
|
-
|
|
2803
|
-
attributeChangedCallback(name, oldValue, newValue) {
|
|
2804
|
-
if (oldValue !== newValue) {
|
|
2805
|
-
this._render();
|
|
2806
|
-
}
|
|
2807
|
-
}
|
|
2808
|
-
${X}
|
|
2809
|
-
|
|
2810
|
-
_render() {
|
|
2811
|
-
const template = \`${z?`<style>${z}</style>`:""}${B}\`;
|
|
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('${v}', ${L});
|
|
2827
|
-
`}async function Um(x,v,k,E){if(v.length<1)return i("WebComponent","@webcomponent directive requires at least the tag name parameter",t.INVALID_DIRECTIVE_SYNTAX);let C=v[0].replace(/['"]/g,""),L=(k.__stx_options||{}).componentsDir||"components",B=wn.isAbsolute(L)?[wn.join(L,`${C}.stx`),wn.join(wn.dirname(E),`${C}.stx`)]:[wn.join(wn.dirname(E),L,`${C}.stx`),wn.join(process.cwd(),L,`${C}.stx`),wn.join(wn.dirname(E),`${C}.stx`)],z=null;for(let G of B)if(await r(G)){z=await Bun.file(G).text();break}if(!z)return i("WebComponent",`Component file not found: ${C}.stx`,t.FILE_NOT_FOUND);let F=qS(z,C);return`<script type="module">
|
|
2828
|
-
${KS(F)}
|
|
2829
|
-
</script>`}var A={enabled:!0,ssr:!1,partialsDir:"partials",componentsDir:"components",layoutsDir:"layouts",defaultLayout:"default",debug:!1,cache:!0,stateDir:Ct,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:Em,hasEndTag:!0,description:"Render markdown content to HTML"},{name:"webcomponent",handler:Um,hasEndTag:!1,description:"Include a web component in the template"},pi,fi,Jn,Yn,Ql,tu,nu,eu,su,au,Om,Kl,...lr],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 ZS(x,v,k){let E=v||"pages";if(x)return{root:x,pagesDir:E};let C=k||process.cwd(),j=gn.join(C,"resources","views"),L=gn.join(C,"resources","layouts");if(oa.existsSync(j)&&oa.existsSync(L))return{root:"resources",pagesDir:"views"};let B=gn.join(C,"resources","views","pages");if(oa.existsSync(B))return{root:"resources/views",pagesDir:E};return{root:".",pagesDir:E}}var Hm=new Set,aa=["partialsDir","componentsDir","layoutsDir"],Xl=new WeakMap;function GS(x,v){let k=v.replace(/[\\/]+$/,"");if(!k||k===".")return!0;let E=x.replace(/\\/g,"/"),C=k.replace(/\\/g,"/");return E===C||E.startsWith(`${C}/`)}function Cc(x,v){let k=!x.root,E=ZS(x.root,x.pagesDir,v);if(x.root=E.root,x.pagesDir=E.pagesDir,k&&E.root!=="."){let C=`${v}::${E.root}`;if(!Hm.has(C))Hm.add(C),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(!Xl.has(x)){let C={};for(let j of aa){let L=x[j];if(typeof L==="string"&&L)C[j]=L}Xl.set(x,C)}if(x.root&&x.root!=="."){let C=x.root;for(let j of aa){let L=x[j];if(typeof L!=="string"||!L)continue;if(gn.isAbsolute(L)||GS(L,C))continue;x[j]=gn.join(C,L)}}for(let C of aa){let j=x[C];if(typeof j!=="string"||!j||gn.isAbsolute(j))continue;x[C]=gn.resolve(v,j)}return x}function JS(x,v){let k=Xl.get(x);for(let E of aa){let C=x[E];if(typeof C!=="string"||!C)continue;let j=gn.isAbsolute(C)?C:gn.join(v,C);if(oa.existsSync(j))continue;let L=k?.[E]??C,B=x.root,z=!!B&&B!==".";console.warn(`[stx] ${String(E)} resolves to "${j}", which does not exist. Configured as "${L}"`+(z?`, resolved under root "${B}".`:"."))}}function YS(x){if(x.customDirectives)x.customDirectives=[...x.customDirectives];if(x.middleware)x.middleware=[...x.middleware];if(x.apiRoutes)x.apiRoutes={...x.apiRoutes}}function QS(x){if(bi(x.stateDir),x.stateDir=sn(),x.cachePath=on(x.cachePath),x.build)x.build.cacheDir=on(x.build.cacheDir);if(x.media?.cache)x.media.cache.directory=on(x.media.cache.directory);if(x.story)x.story.outDir=on(x.story.outDir)}var Sr=null,Or=new Map,ia=new Map,Oi=null;async function o(x){let v=x?gn.resolve(x):process.cwd(),k=ia.get(v);if(k&&k.signature!==Kn(k.graph)){let j=Or.get(v);if(Or.delete(v),ia.delete(v),!x)Sr=null,Oi=null;let{clearComponentCache:L}=await import("./chunk-ykxd78b2.js"),{partialsCache:B}=await import("./chunk-qfrg8mnf.js");if(L(),B.clear(),j&&k.configSignature===Xn(k.graph)){let z=j.then(async(F)=>{let X={...k.graph};await ws(X,v),ia.set(v,{graph:X,signature:Kn(X),configSignature:Xn(X)});let G={...F,_layerGraph:X};if(!x)Sr=G;return G});return Or.set(v,z),z}}if(!x){if(Sr)return Sr;if(Oi)return Oi}let E=Or.get(v);if(E)return E;let C=(async()=>{let L=(await XS({name:"stx",alias:"ui",cwd:v,defaultConfig:A,verbose:!1})).config;if(L.extends!==void 0||k){let X=await hi(v,A);L=X.config,ia.set(v,{graph:X.graph,signature:Kn(X.graph),configSignature:Xn(X.graph)})}if(L.runtimeConfig){let{resolveRuntimeConfig:X}=await import("./chunk-3wezvz6m.js");X(L.runtimeConfig,{});let{generateRuntimeConfigTypes:G}=await import("./chunk-t6m5wmpy.js");await G(v,L.runtimeConfig)}YS(L),QS(L),Cc(L,v),JS(L,v);let B=[],z=new Set((L.plugins??[]).map((X)=>typeof X==="string"?X:X[0]));for(let X of L.componentPackages??["@stacksjs/components"]){let G=`${X}/stx-plugin`;if(z.has(G)||z.has(X))continue;try{u.resolve(G,{paths:[v]}),B.push(G)}catch{}}let F=[...L.plugins??[],...B];if(F.length>0){let{pluginManager:X}=await import("./chunk-8gk34047.js"),G=[],J=[];for(let ne of F){let re=typeof ne==="string"?ne:ne[0],se=typeof ne==="string"?{}:ne[1]||{};try{let oe,ie;try{let ue=u.resolve(re,{paths:[v]});oe=await import(ue),ie=gn.dirname(ue)}catch{let ue=gn.resolve(v,re);oe=await import(ue),ie=gn.dirname(ue)}let ge=oe.default||oe;if(!X.has(ge.name))await X.register(ge,L);if(ge.components){let ue=Array.isArray(ge.components)?ge.components:[ge.components];for(let xe of ue)G.push(gn.resolve(ie,xe))}if(ge.pages){let ue=gn.resolve(ie,ge.pages),xe=se.path||"/";J.push({dir:ue,prefix:xe})}if(ge.setup){let ue={addDirective:(xe)=>{L.customDirectives=L.customDirectives||[],L.customDirectives.push(xe)},addRoute:(xe,we)=>{L.apiRoutes=L.apiRoutes||{},L.apiRoutes[xe]=we},addMiddleware:(xe)=>{L.middleware=L.middleware||[],L.middleware.push(xe)},pluginDir:ie,config:L};await ge.setup(se,ue)}process.stderr.write(`[stx] Plugin loaded: ${ge.name||re}
|
|
2830
|
-
`)}catch(oe){console.warn(`[stx] Failed to load plugin ${re}:`,oe.message)}}L._pluginComponentDirs=G,L._pluginPageDirs=J}return L})();if(Or.set(v,C),C.catch(()=>{if(Or.get(v)===C)Or.delete(v)}),!x)Oi=C,C.then((j)=>{Sr=j}).catch(()=>{});return C}var T=new Proxy(A,{get(x,v){if(Sr&&v in Sr)return Sr[v];if(!Oi)o().catch((k)=>{console.warn("[stx] Failed to load config file:",k?.message||k)});return x[v]}});function Bu(x){return x}function Fu(x){let v=[],k=[];if(x.partialsDir!==void 0&&typeof x.partialsDir!=="string")v.push({path:"partialsDir",message:"partialsDir must be a string",severity:"error"});if(x.componentsDir!==void 0&&typeof x.componentsDir!=="string")v.push({path:"componentsDir",message:"componentsDir must be a string",severity:"error"});if(x.cache!==void 0&&typeof x.cache!=="boolean")v.push({path:"cache",message:"cache must be a boolean",severity:"error"});if(x.debug!==void 0&&typeof x.debug!=="boolean")v.push({path:"debug",message:"debug must be a boolean",severity:"error"});if(x.streaming){if(x.streaming.bufferSize!==void 0){if(typeof x.streaming.bufferSize!=="number"||x.streaming.bufferSize<=0)v.push({path:"streaming.bufferSize",message:"streaming.bufferSize must be a positive number",severity:"error"})}if(x.streaming.timeout!==void 0){if(typeof x.streaming.timeout!=="number"||x.streaming.timeout<=0)v.push({path:"streaming.timeout",message:"streaming.timeout must be a positive number",severity:"error"})}if(x.streaming.strategy!==void 0){let E=["auto","manual","sections"];if(!E.includes(x.streaming.strategy))v.push({path:"streaming.strategy",message:`streaming.strategy must be one of: ${E.join(", ")}`,severity:"error"})}}if(x.i18n){if(x.i18n.format!==void 0){let E=["json","yaml","yml","js"];if(!E.includes(x.i18n.format))v.push({path:"i18n.format",message:`i18n.format must be one of: ${E.join(", ")}`,severity:"error"})}}if(x.animation){if(x.animation.defaultDuration!==void 0){if(typeof x.animation.defaultDuration!=="number"||x.animation.defaultDuration<0)v.push({path:"animation.defaultDuration",message:"animation.defaultDuration must be a non-negative number",severity:"error"})}if(x.animation.staggerDelay!==void 0){if(typeof x.animation.staggerDelay!=="number"||x.animation.staggerDelay<0)v.push({path:"animation.staggerDelay",message:"animation.staggerDelay must be a non-negative number",severity:"error"})}}if(x.a11y){if(x.a11y.level!==void 0){let E=["AA","AAA"];if(!E.includes(x.a11y.level))v.push({path:"a11y.level",message:`a11y.level must be one of: ${E.join(", ")}`,severity:"error"})}}if(x.hydration){if(x.hydration.mode!==void 0){let E=["progressive","islands"];if(!E.includes(x.hydration.mode))v.push({path:"hydration.mode",message:`hydration.mode must be one of: ${E.join(", ")}`,severity:"error"})}if(x.hydration.preload!==void 0){let E=["none","eager","lazy"];if(!E.includes(x.hydration.preload))v.push({path:"hydration.preload",message:`hydration.preload must be one of: ${E.join(", ")}`,severity:"error"})}}if(x.customDirectives)if(!Array.isArray(x.customDirectives))v.push({path:"customDirectives",message:"customDirectives must be an array",severity:"error"});else x.customDirectives.forEach((E,C)=>{if(!E.name||typeof E.name!=="string")v.push({path:`customDirectives[${C}].name`,message:"Custom directive must have a name string",severity:"error"});if(!E.handler||typeof E.handler!=="function")v.push({path:`customDirectives[${C}].handler`,message:"Custom directive must have a handler function",severity:"error"})});if(x.middleware)if(!Array.isArray(x.middleware))v.push({path:"middleware",message:"middleware must be an array",severity:"error"});else x.middleware.forEach((E,C)=>{if(!E.name||typeof E.name!=="string")v.push({path:`middleware[${C}].name`,message:"Middleware must have a name string",severity:"error"});if(!E.handler||typeof E.handler!=="function")v.push({path:`middleware[${C}].handler`,message:"Middleware must have a handler function",severity:"error"});if(!E.timing||!["before","after"].includes(E.timing))v.push({path:`middleware[${C}].timing`,message:'Middleware timing must be "before" or "after"',severity:"error"})});if(x.debug===!0&&x.cache===!0)k.push({path:"debug+cache",message:"Debug mode with caching enabled may show stale content during development",severity:"warning"});if(x.seo?.enabled===!0&&!x.seo?.defaultConfig?.title)k.push({path:"seo.defaultConfig.title",message:"SEO is enabled but no default title is set",severity:"warning"});if(x.pwa){if(x.pwa.enabled===!0&&!x.pwa.manifest?.name)v.push({path:"pwa.manifest.name",message:"PWA manifest name is required when PWA is enabled",severity:"error"});if(x.pwa.manifest?.display!==void 0){let E=["fullscreen","standalone","minimal-ui","browser"];if(!E.includes(x.pwa.manifest.display))v.push({path:"pwa.manifest.display",message:`PWA display must be one of: ${E.join(", ")}`,severity:"error"})}if(x.pwa.manifest?.orientation!==void 0){let E=["portrait","landscape","any","portrait-primary","portrait-secondary","landscape-primary","landscape-secondary"];if(!E.includes(x.pwa.manifest.orientation))v.push({path:"pwa.manifest.orientation",message:`PWA orientation must be one of: ${E.join(", ")}`,severity:"error"})}if(x.pwa.routes){let E=["cache-first","network-first","stale-while-revalidate","network-only","cache-only"];x.pwa.routes.forEach((C,j)=>{if(!C.pattern||typeof C.pattern!=="string")v.push({path:`pwa.routes[${j}].pattern`,message:"PWA route must have a pattern string",severity:"error"});if(!E.includes(C.strategy))v.push({path:`pwa.routes[${j}].strategy`,message:`PWA route strategy must be one of: ${E.join(", ")}`,severity:"error"});if(C.maxAgeSeconds!==void 0&&(typeof C.maxAgeSeconds!=="number"||C.maxAgeSeconds<0))v.push({path:`pwa.routes[${j}].maxAgeSeconds`,message:"PWA route maxAgeSeconds must be a non-negative number",severity:"error"});if(C.maxEntries!==void 0&&(typeof C.maxEntries!=="number"||C.maxEntries<1))v.push({path:`pwa.routes[${j}].maxEntries`,message:"PWA route maxEntries must be a positive number",severity:"error"})})}if(x.pwa.icons?.sizes){if(!Array.isArray(x.pwa.icons.sizes))v.push({path:"pwa.icons.sizes",message:"PWA icon sizes must be an array of numbers",severity:"error"});else if(x.pwa.icons.sizes.filter((C)=>typeof C!=="number"||C<16||C>1024).length>0)v.push({path:"pwa.icons.sizes",message:"PWA icon sizes must be numbers between 16 and 1024",severity:"error"})}if(x.pwa.icons?.purpose){let E=["any","maskable","monochrome"];if(x.pwa.icons.purpose.filter((j)=>!E.includes(j)).length>0)v.push({path:"pwa.icons.purpose",message:`PWA icon purpose must be one of: ${E.join(", ")}`,severity:"error"})}if(x.pwa.enabled===!0&&!x.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(x.pwa.enabled===!0&&!x.pwa.manifest?.themeColor)k.push({path:"pwa.manifest.themeColor",message:"PWA theme color not set, defaulting to black",severity:"warning"})}return{valid:v.length===0,errors:v,warnings:k}}var Gl=new Map;async function ce(x,v={}){try{if(!await r(x))throw Error(`Markdown file not found: ${x}`);let E=(await e0.promises.stat(x)).mtime.getTime();if(v.cache&&Gl.has(x)){let G=Gl.get(x);if(G.updatedAt>=E)return{content:G.content,data:G.data}}let C=await Bun.file(x).text(),{data:j,content:L}=Pn(C),B=v.markdown||T.markdown||{enabled:!0,syntaxHighlighting:{enabled:!0,serverSide:!0,defaultTheme:"github-dark",highlightUnknownLanguages:!0}},F=Oe(L,{gfm:!0});if(B.syntaxHighlighting?.enabled&&B.syntaxHighlighting?.serverSide)F=await n0(F,B.syntaxHighlighting?.defaultTheme||"github-dark",B.syntaxHighlighting?.highlightUnknownLanguages||!1);let X={content:F,data:j||{}};if(v.cache)Gl.set(x,{...X,updatedAt:E});return X}catch(k){if(v.debug)console.error(`Error reading/parsing markdown file ${x}:`,k);let E=k instanceof Error?k.message:String(k);return{content:g("Markdown File",`Error reading/parsing markdown file: ${E}`,x,"",0,""),data:{}}}}var ca=null;async function n0(x,v,k){let E=/<pre><code( class="language-([^"]+)")?>([^<]+)<\/code><\/pre>/g;if(!ca)try{ca=await t0({theme:v||"github-dark",cache:!0})}catch(B){return console.error("Failed to initialize ts-syntax-highlighter:",B),x}let C=async(B,z,F,X)=>{let G=X.replace(/</g,"<").replace(/>/g,">").replace(/&/g,"&").replace(/"/g,'"').replace(/'/g,"'"),J=F||(k?"text":"");if(!J)return B;try{if(!ca.getSupportedLanguages().includes(J))return B;return(await ca.highlight(G,J,{theme:v})).html}catch(ne){console.error(`Error highlighting code block with language ${F}:`,ne)}return B},j=x,L=x.matchAll(E);for(let B of L){let[z,F,X,G]=B,J=await C(z,F,X,G);j=j.replace(z,J)}return j}async function zg(x,v,k="",E={}){return await r0(x,/@markdown-file\(\s*['"]([^'"]+)['"]\s*(?:,\s*(\{[^}]*\}))?\)/g,async(L,B,z,F)=>{try{let X=B;if(!Zl.isAbsolute(B))X=Zl.resolve(Zl.dirname(k),B);let G={};if(z)try{try{G=JSON.parse(z)}catch{if(E.debug)console.warn("Using safer alternative for parsing JS object literal");let ge=z.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(ie){if(E.debug)console.error("Error parsing context in @markdown-file directive:",ie)}let{content:J,data:ne}=await ce(X,E),re={...v,...ne,...G},se=J,oe=/\{\{([^}]+)\}\}/g;return se=se.replace(oe,(ie,ge)=>{let ue=ge.trim();return re[ue]!==void 0?String(re[ue]):ie}),se}catch(X){let G=X instanceof Error?X.message:String(X);return g("Markdown File",`Error including markdown file: ${G}`,k,x,F,L)}})}async function r0(x,v,k){let E=[],C;while((C=v.exec(x))!==null){let B=C[0],z=C.index,F=C;E.push(k(...F).then((X)=>({match:B,replacement:X,index:z})))}let j=await Promise.all(E);j.sort((B,z)=>z.index-B.index);let L=x;for(let{match:B,replacement:z}of j)L=L.replace(B,()=>z);return L}
|
|
2831
|
-
export{Pn,Oe,H,y,Me,V,U,I,O,Yt,Wr,qr,za,bt,No,Kr,Lo,yu,Ne,Xr,me,jo,Bo,Fo,Gr,Y,Le,In,Ha,bu,Va,wu,Ua,Dn,h,wt,he,Wa,Jr,qa,vu,W,Ka,xu,b,Su,Xa,ku,Cu,$u,Eu,Ga,Ja,Tu,_u,zo,Ru,Zt,Qt,On,Mn,e,Au,Ho,Pu,Vo,Ya,Za,vt,en,Iu,Qa,ec,tc,f,je,xt,Be,Fe,Uo,Nn,Z,Yr,Zr,Qr,Du,Ln,Ou,tn,nc,es,M,ae,q,Mu,rc,ts,ns,Wo,qo,rs,ss,jn,sc,Ko,Xo,oc,ze,nn,Bn,St,ic,ac,cc,lc,uc,d,dc,os,pc,Go,Jo,kt,is,Yo,fc,Nu,ye,Zo,Lu,as,cs,ls,Fn,Qo,us,zn,rn,Hn,ds,ps,gs,n,He,ms,hs,gc,Q,ei,ti,ni,ri,Vn,ys,si,oi,ii,mc,hc,yc,bc,wc,vc,Ve,N,Ue,xc,Un,Sc,ai,kc,We,r,Wn,ci,g,ee,ju,qn,A,Cc,o,T,Bu,Fu,ce};
|