@stacksjs/stx 0.2.847 → 0.2.850
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-rqjskxpw.js → chunk-0dnetjh8.js} +31 -31
- package/dist/{chunk-09412heg.js → chunk-0rszcb0m.js} +13 -13
- package/dist/chunk-1qdhwjs4.js +2 -0
- package/dist/{chunk-z57xq46m.js → chunk-2d7e5g92.js} +4 -4
- package/dist/{chunk-wp14sf2j.js → chunk-2j2qzv8g.js} +1 -1
- package/dist/{chunk-nws4zm4k.js → chunk-2rg9pqmh.js} +4 -4
- package/dist/chunk-3gyq9rjx.js +2 -0
- package/dist/chunk-3w9xhs7k.js +2 -0
- package/dist/chunk-3wt0nh3p.js +2 -0
- package/dist/{chunk-jh36gqcq.js → chunk-422r7zkx.js} +2 -2
- package/dist/chunk-4e6wkjtx.js +2 -0
- package/dist/chunk-4pbrszgz.js +2 -0
- package/dist/chunk-5be6p256.js +2 -0
- package/dist/{chunk-6peq9s4s.js → chunk-5jqz5qff.js} +7 -7
- package/dist/chunk-5m4txcry.js +2 -0
- package/dist/chunk-5p6vpvmz.js +2 -0
- package/dist/chunk-5wk40kjd.js +2 -0
- package/dist/{chunk-q61r0m6r.js → chunk-62k66qj9.js} +1 -1
- package/dist/chunk-660g9vjn.js +2 -0
- package/dist/chunk-67bn31a3.js +2 -0
- package/dist/{chunk-y1cneng3.js → chunk-6p62jjzm.js} +2 -2
- package/dist/{chunk-cv0rmntr.js → chunk-6q6atv4g.js} +5 -5
- package/dist/chunk-6rd4phe3.js +2 -0
- package/dist/chunk-7hnt9a2e.js +2 -0
- package/dist/{chunk-ysqzz2h3.js → chunk-7zxce1yw.js} +3 -3
- package/dist/chunk-80bb89fh.js +2 -0
- package/dist/{chunk-he9dzchk.js → chunk-833y1ndd.js} +1 -1
- package/dist/{chunk-93c08def.js → chunk-88392kaj.js} +5 -5
- package/dist/{chunk-t4dkcf28.js → chunk-8cvgm13s.js} +2 -2
- package/dist/{chunk-jj5fz0fq.js → chunk-8hkgycpm.js} +1 -1
- package/dist/chunk-8k6cd1e0.js +2 -0
- package/dist/{chunk-2ts9pb6s.js → chunk-8vjr3atq.js} +2 -2
- package/dist/{chunk-rsa9ssz7.js → chunk-918ws1g7.js} +6 -6
- package/dist/{chunk-h9778nxm.js → chunk-98qgcmxr.js} +2 -2
- package/dist/chunk-9bkgbyrs.js +2 -0
- package/dist/{chunk-5njk2ba0.js → chunk-9mryv01z.js} +52 -52
- package/dist/{chunk-8586a2hh.js → chunk-9yp0t7zc.js} +2 -2
- package/dist/{chunk-yrmppd8r.js → chunk-a2fngjfx.js} +1 -1
- package/dist/chunk-a2shk93y.js +3 -0
- package/dist/chunk-a7v1j7td.js +2 -0
- package/dist/{chunk-zfb2wnha.js → chunk-aas25pac.js} +3 -3
- package/dist/{chunk-eqbx4yj1.js → chunk-ab1vk7jv.js} +4 -4
- package/dist/chunk-acbx3jn5.js +2 -0
- package/dist/{chunk-0wms5teg.js → chunk-agbkv9ab.js} +2 -2
- package/dist/{chunk-wdwx2aa6.js → chunk-amerebya.js} +2 -2
- package/dist/{chunk-b1q40vq4.js → chunk-anva219c.js} +2 -2
- package/dist/chunk-apq33h4w.js +2 -0
- package/dist/{chunk-fxk08je0.js → chunk-ar1prdev.js} +7 -7
- package/dist/{chunk-trgbdydw.js → chunk-axga9ebe.js} +2 -2
- package/dist/{chunk-5aqvfnvy.js → chunk-brheng7x.js} +8 -8
- package/dist/{chunk-fhyvdxhw.js → chunk-btkazgdb.js} +3 -3
- package/dist/chunk-c90qz5w0.js +2 -0
- package/dist/{chunk-4fc8zs15.js → chunk-caehra7e.js} +5 -5
- package/dist/chunk-cwt26rvt.js +3 -0
- package/dist/chunk-d4kystzh.js +2 -0
- package/dist/chunk-dx31vsyf.js +2 -0
- package/dist/{chunk-jaf44web.js → chunk-e105xsee.js} +1 -1
- package/dist/{chunk-xn0ebqgw.js → chunk-e46n406k.js} +13 -13
- package/dist/{chunk-2j3gttzf.js → chunk-e85wsz8y.js} +1 -1
- package/dist/{chunk-5x8q6e1q.js → chunk-eh8g8kr1.js} +5 -5
- package/dist/chunk-f4x21pqx.js +2 -0
- package/dist/{chunk-6xcmeev9.js → chunk-f5n871gp.js} +5 -5
- package/dist/{chunk-81ysx0tc.js → chunk-fffjjgnt.js} +2 -2
- package/dist/{chunk-wzyc9da7.js → chunk-frhdk0p9.js} +2 -2
- package/dist/chunk-frhh6jd3.js +2 -0
- package/dist/{chunk-b3n1m4m5.js → chunk-g046t3hb.js} +1 -1
- package/dist/chunk-g1gqysb4.js +2 -0
- package/dist/{chunk-110s34yg.js → chunk-gr8q8xqz.js} +3 -3
- package/dist/{chunk-emf6ee94.js → chunk-gsrdjmw9.js} +2 -2
- package/dist/{chunk-r96ahk8s.js → chunk-gwdffrz6.js} +9 -9
- package/dist/chunk-h7rcb74n.js +2 -0
- package/dist/{chunk-jcwtw3hd.js → chunk-h9gjt73q.js} +2 -2
- package/dist/chunk-hg9354gt.js +2 -0
- package/dist/{chunk-s6td2c1k.js → chunk-hhk46fzp.js} +2 -2
- package/dist/chunk-j3x3e353.js +2 -0
- package/dist/chunk-j6r964wk.js +2 -0
- package/dist/chunk-je8ma636.js +2 -0
- package/dist/chunk-jpyk0gtr.js +3 -0
- package/dist/{chunk-v5tzcd49.js → chunk-jqjw00qm.js} +12 -12
- package/dist/{chunk-vm68yvgf.js → chunk-jqsn4sgv.js} +6 -6
- package/dist/{chunk-5m0nyt8d.js → chunk-jt5cqq09.js} +3 -3
- package/dist/chunk-k0pm7p0f.js +2 -0
- package/dist/chunk-k1pyzf9e.js +2 -0
- package/dist/{chunk-eg2p1cyw.js → chunk-k47addf7.js} +29 -29
- package/dist/{chunk-qpz9jrvw.js → chunk-k7dvn2r8.js} +2 -2
- package/dist/{chunk-fa3ygt8c.js → chunk-kd06c90f.js} +4 -4
- package/dist/{chunk-9sjtph54.js → chunk-krtkxnz6.js} +2 -2
- package/dist/chunk-kybes29w.js +2 -0
- package/dist/{chunk-25m74mh1.js → chunk-m05pqmcj.js} +5 -5
- package/dist/chunk-m276y4f3.js +2 -0
- package/dist/{chunk-907zya76.js → chunk-m6nhh5xf.js} +9 -9
- package/dist/{chunk-cww1zk8y.js → chunk-m710wkr4.js} +1 -1
- package/dist/chunk-nnbr1q94.js +2 -0
- package/dist/chunk-nq2z2yrz.js +2 -0
- package/dist/chunk-p2chmq36.js +2 -0
- package/dist/chunk-p9sbpbhg.js +2 -0
- package/dist/{chunk-3qyz80d6.js → chunk-pkq96sqk.js} +6 -6
- package/dist/chunk-q2d8x7p1.js +2 -0
- package/dist/{chunk-cz2s176s.js → chunk-qa1pcm7n.js} +5 -5
- package/dist/{chunk-tm5t3hh3.js → chunk-qa4vs1qg.js} +3 -3
- package/dist/{chunk-5ghw26vq.js → chunk-qahz3n8z.js} +2 -2
- package/dist/{chunk-jm0qsr3s.js → chunk-qev14f76.js} +6 -6
- package/dist/{chunk-tb5h85ag.js → chunk-qjc3qjyf.js} +2 -2
- package/dist/chunk-r0btg48x.js +2 -0
- package/dist/{chunk-qay7pgnq.js → chunk-r0k5jbvk.js} +1 -1
- package/dist/{chunk-ks0dwtp0.js → chunk-r2p2nyyq.js} +3 -3
- package/dist/chunk-ryb4jesm.js +2 -0
- package/dist/{chunk-bttvkzxh.js → chunk-s0pnyd2f.js} +6 -6
- package/dist/{chunk-dv9q56r7.js → chunk-s37af6rd.js} +2 -2
- package/dist/chunk-sa18tper.js +20 -0
- package/dist/{chunk-2xf323h9.js → chunk-scaawv2r.js} +3 -3
- package/dist/chunk-sjpya8wm.js +2 -0
- package/dist/chunk-sy0jtgmv.js +42 -0
- package/dist/chunk-sznk5c66.js +2 -0
- package/dist/{chunk-c541s99z.js → chunk-t23jn83r.js} +4 -4
- package/dist/{chunk-fez9828r.js → chunk-t74qb5ej.js} +3 -3
- package/dist/chunk-t7ws9sth.js +2 -0
- package/dist/{chunk-fr658fhd.js → chunk-tbs24vx1.js} +2 -2
- package/dist/{chunk-acwdf0cf.js → chunk-td6b41vj.js} +4 -4
- package/dist/chunk-tdtwqydq.js +2 -0
- package/dist/{chunk-ga650crj.js → chunk-tm1ec751.js} +9 -9
- package/dist/{chunk-prnebmz1.js → chunk-tmftv8na.js} +102 -102
- package/dist/chunk-tpax2gpz.js +2 -0
- package/dist/chunk-ts6sm467.js +2 -0
- package/dist/{chunk-46t924aw.js → chunk-v4bqmzj9.js} +2 -2
- package/dist/chunk-w005b56n.js +2 -0
- package/dist/{chunk-ema1c29k.js → chunk-w032x0zm.js} +2 -2
- package/dist/chunk-w8aj3f9v.js +2 -0
- package/dist/{chunk-ma9yq04p.js → chunk-wzv7k91a.js} +2 -2
- package/dist/chunk-x4077p94.js +2 -0
- package/dist/{chunk-3c2hgvag.js → chunk-x80b12gr.js} +3 -3
- package/dist/{chunk-sz2nax5v.js → chunk-xa1f13nk.js} +56 -56
- package/dist/{chunk-ybgzr6wn.js → chunk-xe8m66a3.js} +104 -102
- package/dist/{chunk-9qxx2teq.js → chunk-xndr2dx9.js} +6 -6
- package/dist/chunk-xrdh4at4.js +2 -0
- package/dist/chunk-y8qdpb0p.js +2 -0
- package/dist/chunk-ydjy26ch.js +2 -0
- package/dist/{chunk-k44qj40k.js → chunk-ym5qgw03.js} +2 -2
- package/dist/chunk-yx37mvy7.js +2 -0
- package/dist/{chunk-na1x46xm.js → chunk-z0qfspzg.js} +3 -3
- package/dist/chunk-z278w3cb.js +2 -0
- package/dist/chunk-z33esms3.js +3 -0
- package/dist/{chunk-hpaj7zjv.js → chunk-z46mk8ym.js} +4 -4
- package/dist/chunk-znfzh6fm.js +2 -0
- package/dist/chunk-zteccxj9.js +2 -0
- package/dist/cli.js +20 -20
- package/dist/component-renderer.d.ts +1 -0
- package/dist/component-renderer.js +28 -4
- package/dist/craft-entry.js +2 -2
- package/dist/craft.js +2 -2
- package/dist/native/floating-actions.d.ts +43 -0
- package/dist/native/floating-actions.js +50 -0
- package/dist/native/index.d.ts +1 -0
- package/dist/native/index.js +1 -0
- package/dist/native/primitives/FloatingActions.stx +42 -0
- package/dist/native/runtime/browser-screen.js +3 -8
- package/dist/pwa.js +3 -3
- package/dist/safe-evaluator.d.ts +10 -0
- package/dist/safe-evaluator.js +24 -5
- package/dist/server-bindings.d.ts +11 -0
- package/dist/server-bindings.js +27 -0
- package/dist/ssg.js +15 -15
- package/dist/stx-virtual-ts.d.ts +31 -0
- package/dist/stx-virtual-ts.js +49 -2
- package/dist/typecheck.d.ts +1 -1
- package/dist/typecheck.js +5 -4
- package/package.json +5 -5
- package/dist/chunk-0d4zhbjz.js +0 -2
- package/dist/chunk-0vbt87cv.js +0 -2
- package/dist/chunk-11snc6n0.js +0 -2
- package/dist/chunk-1menbxwb.js +0 -2
- package/dist/chunk-1na30z8t.js +0 -2
- package/dist/chunk-1pf4y2yr.js +0 -2
- package/dist/chunk-1rban2td.js +0 -2
- package/dist/chunk-31rtwv90.js +0 -2
- package/dist/chunk-341c732h.js +0 -2
- package/dist/chunk-343hxxq1.js +0 -2
- package/dist/chunk-37bzsnr7.js +0 -2
- package/dist/chunk-3m6n90sk.js +0 -2
- package/dist/chunk-5bm8hmwd.js +0 -2
- package/dist/chunk-6bemqsdj.js +0 -2
- package/dist/chunk-6hd83cj4.js +0 -2
- package/dist/chunk-77fs8281.js +0 -2
- package/dist/chunk-79pgjds2.js +0 -2
- package/dist/chunk-86z8zrn9.js +0 -3
- package/dist/chunk-8xb9ecb9.js +0 -2
- package/dist/chunk-9c6yvh3p.js +0 -2
- package/dist/chunk-9fxeqf0e.js +0 -2
- package/dist/chunk-9m96yv69.js +0 -2
- package/dist/chunk-atsjexk0.js +0 -2
- package/dist/chunk-bcefawtc.js +0 -2
- package/dist/chunk-byjjz7h8.js +0 -2
- package/dist/chunk-c0azgkss.js +0 -2
- package/dist/chunk-cbz7jtzf.js +0 -2
- package/dist/chunk-cq06hsm4.js +0 -2
- package/dist/chunk-dsh91n7n.js +0 -2
- package/dist/chunk-evdskc25.js +0 -2
- package/dist/chunk-f8akfzzn.js +0 -2
- package/dist/chunk-f8wmxwa3.js +0 -2
- package/dist/chunk-fseqwysr.js +0 -2
- package/dist/chunk-g891ftgz.js +0 -2
- package/dist/chunk-gc7gh0g0.js +0 -2
- package/dist/chunk-gg48cgx3.js +0 -2
- package/dist/chunk-gzx1f8ay.js +0 -2
- package/dist/chunk-h526qmg2.js +0 -2
- package/dist/chunk-hazd1sh8.js +0 -2
- package/dist/chunk-j08r18x1.js +0 -2
- package/dist/chunk-j1sm889p.js +0 -2
- package/dist/chunk-j539dz72.js +0 -2
- package/dist/chunk-jmqwpnpd.js +0 -2
- package/dist/chunk-jqngvqby.js +0 -2
- package/dist/chunk-k33kgf8a.js +0 -2
- package/dist/chunk-ke8rxpp9.js +0 -2
- package/dist/chunk-kvttzk86.js +0 -2
- package/dist/chunk-mbcqpcyt.js +0 -20
- package/dist/chunk-mfbqjkgp.js +0 -3
- package/dist/chunk-my8257pf.js +0 -2
- package/dist/chunk-nm04926f.js +0 -2
- package/dist/chunk-nnnf8cjv.js +0 -2
- package/dist/chunk-p2fkggw4.js +0 -3
- package/dist/chunk-q18508s2.js +0 -2
- package/dist/chunk-r6085mp4.js +0 -2
- package/dist/chunk-rke4q3jk.js +0 -2
- package/dist/chunk-s4wcksaw.js +0 -3
- package/dist/chunk-se79v0pe.js +0 -2
- package/dist/chunk-twfx2scr.js +0 -2
- package/dist/chunk-txs1vxas.js +0 -42
- package/dist/chunk-v7d7m4k1.js +0 -2
- package/dist/chunk-vdb3p2v3.js +0 -2
- package/dist/chunk-vm2y05sr.js +0 -2
- package/dist/chunk-xc1k2zza.js +0 -2
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{
|
|
3
|
-
`),y=[
|
|
4
|
-
`],m=c.start;for(let x of
|
|
2
|
+
import{Bt,ae,_,u,f,P,t,ce,K,l,_e,Ai,z,En,Pi,Ht,Ii,dl,Ir,pl,ct,fl,Or,gl,Tn,Oi,ml,Nr,Dr,Ce,Ni}from"./chunk-k47addf7.js";import{pi,Mc,o,C,Ne,Ot,mn,Me,fe,J,kr,hn,Vs,Wc,qc,bn,$r,Ws,qs,Kc,wi,Gc,Xc,Jc,Yc,Le,je,Ks,ze,s,xn,h,p,W,Q,ke,E,Ei}from"./chunk-xe8m66a3.js";import{jt}from"./chunk-v4bqmzj9.js";import{_n}from"./chunk-qahz3n8z.js";import{b}from"./chunk-ar1prdev.js";import{br,Ns}from"./chunk-8cvgm13s.js";import{wc,vc,mr,et,xc,O}from"./chunk-9mryv01z.js";import{ri,si,oi,ii}from"./chunk-0rszcb0m.js";import{gc,ms}from"./chunk-sy0jtgmv.js";import{us,ds,ps}from"./chunk-jqjw00qm.js";import{bs,Xo,Jo,ws,vs,Yo}from"./chunk-m6nhh5xf.js";import{hs,Uo}from"./chunk-7zxce1yw.js";import{Fo}from"./chunk-t5q31st4.js";import{oe,Wo,qo,Ko}from"./chunk-m710wkr4.js";import{dr,we,hc,pr,yc}from"./chunk-eh8g8kr1.js";import{B,Ze}from"./chunk-ybq56wam.js";import{Sc,kc}from"./chunk-r2p2nyyq.js";import{T,$n,Mi}from"./chunk-ym5qgw03.js";import Kn from"fs";import ie from"path";function dt(n){let e=Ot(n),c=e.find((x)=>x.closing&&x.name.toLowerCase()==="head");if(!c)return n;let a=new Set(["template","svg","noscript","math","textarea","title","xmp","iframe","noembed","noframes","plaintext"]),g=0,r=[];for(let x=0;x<e.length;x++){let w=e[x];if(w.start<c.end)continue;let v=w.name.toLowerCase();if(a.has(v)){g=Math.max(0,g+(w.closing?-1:w.selfClosing?0:1));continue}if(v!=="style"||w.closing||g>0)continue;let k=e[x+1];if(k?.name.toLowerCase()==="style"&&k.closing){if(/@scope\s*\{/.test(n.slice(w.end,k.start)))continue;r.push({start:w.start,end:k.end}),x++}}if(!r.length)return n;let d=r.map((x)=>n.slice(x.start,x.end)).join(`
|
|
3
|
+
`),y=[n.slice(0,c.start),d,`
|
|
4
|
+
`],m=c.start;for(let x of r)y.push(n.slice(m,x.start)),m=x.end;return y.push(n.slice(m)),y.join("")}function pt(){return`
|
|
5
5
|
// STX Lifecycle Runtime
|
|
6
6
|
(function() {
|
|
7
7
|
if (typeof window === 'undefined') return;
|
|
@@ -349,7 +349,7 @@ else {
|
|
|
349
349
|
|
|
350
350
|
console.log('[stx] Lifecycle runtime initialized');
|
|
351
351
|
})();
|
|
352
|
-
`}function Ge(
|
|
352
|
+
`}function Ge(n){return Symbol(n)}var xs=Ge("theme"),ks=Ge("router"),Ss=Ge("i18n");import*as gt from"crypto";function ft(n){let e=/\$(\w+)\./g,c=[],a;while((a=e.exec(n))!==null)if(!c.includes(a[1]))c.push(a[1]);return c}function Lr(){return`stx-${gt.randomBytes(4).toString("hex")}`}function Pr(n){return/\$\w+\./.test(n)}function jr(n){if(!/\{\{[^}]*\$\w/.test(n)||!/\$\w+\./.test(n))return{html:n,bindings:[],stores:new Set};let e=[],c=new Set,a=/<(\w+)([^>]*?)(\s*\/?>)/g,g=n;return g=g.replace(a,(r,d,y,m)=>{if(["script","style","template"].includes(d.toLowerCase()))return r;if(!y.includes("{{"))return r;let x=[],w=!1,v=y,k=/(\w+(?:-\w+)*)\s*=\s*"([^"]*\{\{[^}]*\$\w+[^}]*\}\}[^"]*)"/g,S=[...y.matchAll(k)];for(let R of S){let D=R[0],j=R[1],N=R[2];if(Pr(N)){w=!0;let F=N.match(/\{\{\s*([\s\S]+?)\s*\}\}/);if(F){let I=F[1];if(x.push({attr:j,expr:I,fullMatch:D,originalAttr:j}),ft(I).forEach((H)=>c.add(H)),j==="text")v=v.replace(D,"");else if(j==="class")v=v.replace(D,'class=""');else if(j==="disabled"||j==="hidden")v=v.replace(D,"");else v=v.replace(D,`${j}=""`)}}}if(!w)return r;let M=v.match(/\bid\s*=\s*"([^"]+)"/),A;if(M)A=M[1];else A=Lr(),v=` id="${A}"${v}`;for(let R of x)e.push({elementId:A,attribute:R.attr,expression:R.expr,stores:ft(R.expr)});return`<${d}${v}${m}`}),{html:g,bindings:e,stores:c}}function Hr(n,e){if(n.length===0)return"";let c=Array.from(e),a=`
|
|
353
353
|
<script>
|
|
354
354
|
(function() {
|
|
355
355
|
'use strict';
|
|
@@ -369,8 +369,8 @@ else {
|
|
|
369
369
|
`;a+=`
|
|
370
370
|
// Binding update functions
|
|
371
371
|
function updateBindings() {
|
|
372
|
-
`;for(let g of
|
|
373
|
-
var el = document.getElementById('${
|
|
372
|
+
`;for(let g of n){let{elementId:r,attribute:d,expression:y}=g,m=y.replace(/\$(\w+)\./g,"$state.$1.");if(d==="text")a+=` (function() {
|
|
373
|
+
var el = document.getElementById('${r}');
|
|
374
374
|
if (el) {
|
|
375
375
|
try {
|
|
376
376
|
el.textContent = ${m};
|
|
@@ -379,7 +379,7 @@ catch (e) { console.error('Binding error:', e); }
|
|
|
379
379
|
}
|
|
380
380
|
})();
|
|
381
381
|
`;else if(d==="html")a+=` (function() {
|
|
382
|
-
var el = document.getElementById('${
|
|
382
|
+
var el = document.getElementById('${r}');
|
|
383
383
|
if (el) {
|
|
384
384
|
try {
|
|
385
385
|
el.innerHTML = ${m};
|
|
@@ -388,7 +388,7 @@ catch (e) { console.error('Binding error:', e); }
|
|
|
388
388
|
}
|
|
389
389
|
})();
|
|
390
390
|
`;else if(d==="class")a+=` (function() {
|
|
391
|
-
var el = document.getElementById('${
|
|
391
|
+
var el = document.getElementById('${r}');
|
|
392
392
|
if (el) {
|
|
393
393
|
try {
|
|
394
394
|
var value = ${m};
|
|
@@ -417,7 +417,7 @@ catch (e) { console.error('Binding error:', e); }
|
|
|
417
417
|
}
|
|
418
418
|
})();
|
|
419
419
|
`;else if(d==="show")a+=` (function() {
|
|
420
|
-
var el = document.getElementById('${
|
|
420
|
+
var el = document.getElementById('${r}');
|
|
421
421
|
if (el) {
|
|
422
422
|
try {
|
|
423
423
|
el.style.display = (${m}) ? '' : 'none';
|
|
@@ -426,7 +426,7 @@ catch (e) { console.error('Binding error:', e); }
|
|
|
426
426
|
}
|
|
427
427
|
})();
|
|
428
428
|
`;else if(d==="if")a+=` (function() {
|
|
429
|
-
var el = document.getElementById('${
|
|
429
|
+
var el = document.getElementById('${r}');
|
|
430
430
|
if (el) {
|
|
431
431
|
try {
|
|
432
432
|
el.style.visibility = (${m}) ? 'visible' : 'hidden';
|
|
@@ -435,7 +435,7 @@ catch (e) { console.error('Binding error:', e); }
|
|
|
435
435
|
}
|
|
436
436
|
})();
|
|
437
437
|
`;else a+=` (function() {
|
|
438
|
-
var el = document.getElementById('${
|
|
438
|
+
var el = document.getElementById('${r}');
|
|
439
439
|
if (el) {
|
|
440
440
|
try {
|
|
441
441
|
var value = ${m};
|
|
@@ -507,10 +507,10 @@ else {
|
|
|
507
507
|
}
|
|
508
508
|
})();
|
|
509
509
|
</script>
|
|
510
|
-
`,a}function mt(
|
|
510
|
+
`,a}function mt(n){let{html:e,bindings:c,stores:a}=jr(n);if(c.length===0)return n;let g=Hr(c,a),r=e.lastIndexOf("</body>");if(r!==-1)return e.slice(0,r)+g+e.slice(r);return e+g}function Br(n){let e=n.analytics;if(!e?.enabled)return"";switch(e.driver){case"fathom":return Fr(e);case"google-analytics":return Ur(e);case"plausible":return qr(e);case"self-hosted":return Vr(e);case"custom":return Wr(e);default:return""}}function Fr(n){let e=n.fathom;if(!e?.siteId)return"";let c=e.scriptUrl||"https://cdn.usefathom.com/script.js",a=e.defer!==!1?" defer":"",g=[`data-site="${ue(e.siteId)}"`];if(e.honorDnt)g.push('data-honor-dnt="true"');if(e.spa)g.push('data-spa="auto"');if(e.canonical)g.push(`data-canonical="${ue(e.canonical)}"`);if(e.auto===!1)g.push('data-auto="false"');return`
|
|
511
511
|
<!-- Fathom Analytics -->
|
|
512
512
|
<script src="${ue(c)}" ${g.join(" ")}${a}></script>
|
|
513
|
-
`}function
|
|
513
|
+
`}function Ur(n){let e=n.googleAnalytics;if(!e?.measurementId)return"";let c=ue(e.measurementId),a=e.debug?`gtag('config', '${c}', { 'debug_mode': true });`:"";return`
|
|
514
514
|
<!-- Google Analytics -->
|
|
515
515
|
<script async src="https://www.googletagmanager.com/gtag/js?id=${c}"></script>
|
|
516
516
|
<script>
|
|
@@ -520,10 +520,10 @@ else {
|
|
|
520
520
|
gtag('config', '${c}');
|
|
521
521
|
${a}
|
|
522
522
|
</script>
|
|
523
|
-
`}function
|
|
523
|
+
`}function qr(n){let e=n.plausible;if(!e?.domain)return"";let c=e.scriptUrl||"https://plausible.io/js/script.js",a=[`data-domain="${ue(e.domain)}"`],g=c,r=[];if(e.trackLocalhost)r.push("local");if(e.hashMode)r.push("hash");if(r.length>0&&c==="https://plausible.io/js/script.js")g=`https://plausible.io/js/script.${r.join(".")}.js`;return`
|
|
524
524
|
<!-- Plausible Analytics -->
|
|
525
525
|
<script defer data-domain="${ue(e.domain)}" src="${ue(g)}"></script>
|
|
526
|
-
`}function
|
|
526
|
+
`}function Vr(n){let e=n.selfHosted;if(!e?.siteId||!e?.apiEndpoint)return"";let c=ue(e.siteId),a=ue(e.apiEndpoint),g=e.honorDnt?'if(n.doNotTrack==="1")return;':"",r=e.trackHashChanges?"w.addEventListener('hashchange',pv);":"",d=e.trackOutboundLinks?`
|
|
527
527
|
d.addEventListener('click',function(e){
|
|
528
528
|
var a=e.target.closest('a');
|
|
529
529
|
if(a&&a.hostname!==location.hostname){
|
|
@@ -549,39 +549,39 @@ else {
|
|
|
549
549
|
}));
|
|
550
550
|
}
|
|
551
551
|
function pv(){t('pageview');}
|
|
552
|
-
${
|
|
552
|
+
${r}
|
|
553
553
|
${d}
|
|
554
554
|
if(d.readyState==='complete')pv();
|
|
555
555
|
else w.addEventListener('load',pv);
|
|
556
556
|
w.stxAnalytics={track:function(n,v){t('event',{name:n,value:v});}};
|
|
557
557
|
})();
|
|
558
558
|
</script>
|
|
559
|
-
`}function
|
|
559
|
+
`}function Wr(n){let e=n.custom;if(!e)return"";if(e.inlineScript)return`
|
|
560
560
|
<!-- Custom Analytics -->
|
|
561
561
|
<script>
|
|
562
562
|
${e.inlineScript}
|
|
563
563
|
</script>
|
|
564
|
-
`;if(!e.scriptUrl)return"";let c=[];if(e.scriptId)c.push(`id="${ue(e.scriptId)}"`);if(e.attributes)for(let[g,
|
|
564
|
+
`;if(!e.scriptUrl)return"";let c=[];if(e.scriptId)c.push(`id="${ue(e.scriptId)}"`);if(e.attributes)for(let[g,r]of Object.entries(e.attributes))c.push(`${ue(g)}="${ue(r)}"`);return`
|
|
565
565
|
<!-- Custom Analytics -->
|
|
566
566
|
<script${c.length>0?` ${c.join(" ")}`:""} src="${ue(e.scriptUrl)}" defer></script>
|
|
567
|
-
`}function ht(
|
|
568
|
-
${g}`)}function $t(s,e){let c=s;return c=c.replace(/<script(?![^>]*\ssrc=)([^>]*)>/gi,(a,g)=>{if(g.includes("nonce="))return a;return`<script nonce="${e}"${g}>`}),c=c.replace(/<style([^>]*)>/gi,(a,g)=>{if(g.includes("nonce="))return a;return`<style nonce="${e}"${g}>`}),c}function Et(s,e,c,a){let g=s,n=a.csp;if(g=g.replace(/@csp\b/g,()=>{if(!n?.enabled||!n.directives)return"<!-- CSP not configured -->";let d=n.useNonce?qe(e,n):void 0;return kt(n.directives,d)}),g=g.replace(/@cspNonce\b/g,()=>{if(!n?.enabled||!n.useNonce)return"";return qe(e,n)}),n?.enabled&&n.useNonce)e.cspNonce=qe(e,n);return g}import Zr from"crypto";var Jr=40,Tt="_token",Ye=null;function Qr(s=Jr){let e=Zr.randomBytes(Math.ceil(s/2)).toString("hex").slice(0,s);return Ye=e,e}function Yr(){if(!Ye)Qr();return Ye}function en(s=Tt){let e=Yr();return`<input type="hidden" name="${s}" value="${e}">`}function _t(s){return s.replace(/@csrf(?:\((['"])([^'"]*)\1\))?/g,(e,c,a)=>en(a||Tt))}async function Ct(s,e,c,a){if(!a.customDirectives||a.customDirectives.length===0)return s;let g=s;for(let n of a.customDirectives){if(!n.name||typeof n.handler!=="function"){if(a.debug)console.warn("Invalid custom directive:",n);continue}if(n.hasEndTag)g=await tn(g,n,e,c,a);else g=await rn(g,n,e,c,a)}return g}async function tn(s,e,c,a,g){let{name:n,handler:d}=e,y=`@${n}`,m=`@end${n}`,x=s,w=jt(`${y}(?:\\s*\\(([^()]*(?:\\([^)]*\\)[^()]*)*)\\))?([\\s\\S]*?)${m}`,"g"),v=[],k=w.exec(x);while(k!==null){let[S,M="",A=""]=k,R=k.index||0;try{let D=M?At(e,M):[],j=A.trim(),N=await d(j,D,c,a);v.push({original:S,processed:N,startIndex:R})}catch(D){let j=D instanceof Error?D.message:String(D);if(g.debug)console.error(`Error processing custom directive @${n}:`,D);v.push({original:S,processed:l("CustomDirective",`Error in @${n}${M?`(${M})`:""}: ${j}`,t.EVALUATION_ERROR),startIndex:R})}k=w.exec(x)}for(let S=v.length-1;S>=0;S--){let{original:M,processed:A}=v[S];x=x.replace(M,A)}return x}async function rn(s,e,c,a,g){let{name:n,handler:d}=e,y=s,m=[],x=[];if(e.rawParams){for(let k of Ai(y,jt(`(?<![\\w$@])@${n}\\s*\\(`,"g")))if(k.end!==-1)x.push({fullMatch:k.call,paramString:k.args,startIndex:k.start})}else{let k=jt(`@${n}\\s*\\(([^()]*(?:\\([^)]*\\)[^()]*)*)\\)`,"g");k.lastIndex=0;let S=k.exec(y);while(S!==null)x.push({fullMatch:S[0],paramString:S[1]??"",startIndex:S.index||0}),S=k.exec(y)}for(let{fullMatch:k,paramString:S,startIndex:M}of x)try{let A=At(e,S),R=await d("",A,c,a);m.push({original:k,processed:R,startIndex:M})}catch(A){let R=A instanceof Error?A.message:String(A);if(g.debug)console.error(`Error processing custom directive @${n}:`,A);m.push({original:k,processed:l("CustomDirective",`Error in @${n}(${S}): ${R}`,t.EVALUATION_ERROR),startIndex:M})}let w=jt(`@${n}(?!\\w)(?!\\s*\\()`,"g"),v=w.exec(y);while(v!==null){let[k]=v,S=v.index||0;try{let M=await d("",[],c,a);m.push({original:k,processed:M,startIndex:S})}catch(M){let A=M instanceof Error?M.message:String(M);if(g.debug)console.error(`Error processing custom directive @${n}:`,M);m.push({original:k,processed:l("CustomDirective",`Error in @${n}: ${A}`,t.EVALUATION_ERROR),startIndex:S})}v=w.exec(y)}for(let k=m.length-1;k>=0;k--){let{original:S,processed:M}=m[k];y=y.replace(S,M)}return y}function At(s,e){return s.rawParams?zt(e):nn(e)}function nn(s){if(!s.trim())return[];let e=[],c="",a=!1,g="";for(let n=0;n<s.length;n++){let d=s[n];if((d==='"'||d==="'")&&(n===0||s[n-1]!=="\\"))if(!a)a=!0,g=d;else if(d===g)a=!1;else c+=d;else if(d===","&&!a)e.push(c.trim()),c="";else c+=d}if(c.trim())e.push(c.trim());return e.map((n)=>{let d=n.trim();if(d.startsWith('"')&&d.endsWith('"')||d.startsWith("'")&&d.endsWith("'"))return d.substring(1,d.length-1);return d})}var Rt=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/,Mt=/^[A-Za-z_$][\w$]*$/,sn=new Set(["light","dark","system"]);function xe(s,e){if(typeof s!=="string"||s.length===0)throw Error(`@appearanceBootstrap ${e} must be a non-empty string`)}function on(s){if(!s||typeof s!=="object"||Array.isArray(s))throw Error("@appearanceBootstrap expects an options object");let e=s,{appearance:c,colorMode:a}=e;if(xe(e.storageKey,"storageKey"),c!==void 0&&(!c||typeof c!=="object"||Array.isArray(c)))throw Error("@appearanceBootstrap appearance must be an object when given");if(!a||typeof a!=="object"||Array.isArray(a))throw Error("@appearanceBootstrap colorMode must be an object");if(xe(a.key,"colorMode.key"),xe(a.attribute,"colorMode.attribute"),xe(a.default,"colorMode.default"),!Mt.test(a.key))throw Error("@appearanceBootstrap preference keys must be JavaScript property names");if(!Rt.test(a.attribute))throw Error("@appearanceBootstrap attributes must be lowercase data attribute names");if(!sn.has(a.default))throw Error("@appearanceBootstrap colorMode.default must be light, dark, or system");let g=null;if(c){if(xe(c.key,"appearance.key"),xe(c.attribute,"appearance.attribute"),xe(c.default,"appearance.default"),!Mt.test(c.key))throw Error("@appearanceBootstrap preference keys must be JavaScript property names");if(!Rt.test(c.attribute))throw Error("@appearanceBootstrap attributes must be lowercase data attribute names");if(!Array.isArray(c.allowed)||c.allowed.length===0||c.allowed.some((n)=>typeof n!=="string"||n.length===0))throw Error("@appearanceBootstrap appearance.allowed must contain one or more strings");if(!c.allowed.includes(c.default))throw Error("@appearanceBootstrap appearance.default must be in appearance.allowed");g={key:c.key,attribute:c.attribute,allowed:[...new Set(c.allowed)],default:c.default}}return{storageKey:e.storageKey,appearance:g,colorMode:{key:a.key,attribute:a.attribute,default:a.default},respectExisting:e.respectExisting===!0}}function an(s){return JSON.stringify(s).replace(/</g,"\\u003c").replace(/>/g,"\\u003e").replace(/&/g,"\\u0026").replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}function cn(s){return`<script data-stx-scoped data-stx-appearance-bootstrap>(function(){"use strict";const config=${an(s)};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 ln(s,e){let c=1,a=null,g=!1;for(let n=e+1;n<s.length;n++){let d=s[n];if(g){g=!1;continue}if(a){if(d==="\\")g=!0;else if(d===a)a=null;continue}if(d==='"'||d==="'"||d==="`"){a=d;continue}if(d==="(")c++;else if(d===")"&&--c===0)return n}return-1}function Dt(s,e){let c=s,a=/@appearanceBootstrap\s*\(/g,g;while((g=a.exec(c))!==null){let n=g.index+g[0].length-1,d=ln(c,n);if(d===-1)throw Error("@appearanceBootstrap has an unclosed options object");let y=c.slice(n+1,d).trim(),m=u(`(${y})`,e),x=cn(on(m));c=c.slice(0,g.index)+x+c.slice(d+1),a.lastIndex=g.index+x.length}return c}import un from"crypto";function Y(s){return W(String(s??""))}var Ot={input:"form-control",inputError:"is-invalid",checkInput:"form-check-input",label:"form-label",errorFeedback:"invalid-feedback"};function Ve(s,e,c,a){let g=s||e;return c?`${g} ${a}`:g}function ge(s){return String(s).replace(/\[\]$/,"").replace(/[^\w.:-]+/g,"-").replace(/^-+|-+$/g,"")}function Re(s,e){if(/\bid\s*=/i.test(s))return"";return` id="${Y(e)}"`}function tt(s,e,c){if(!e)return"";let a="";if(!/\baria-invalid\s*=/i.test(c))a+=' aria-invalid="true"';if(!/\baria-describedby\s*=/i.test(c))a+=` aria-describedby="${Y(`${ge(s)}-error`)}"`;return a}function dn(){return un.randomUUID()}function We(s,e){let c=s;return c=c.replace(/@csrf/g,()=>{if(!e.csrf||typeof e.csrf!=="object"){let a=dn();e.csrf={token:a}}if(e.csrf.field)return e.csrf.field;if(e.csrf.token)return`<input type="hidden" name="_token" value="${Y(e.csrf.token)}">`;return'<input type="hidden" name="_token" value="">'}),c=c.replace(/@method\(['"]([^'"]+)['"]\)/g,(a,g)=>{let n=g.toUpperCase();if(g&&!["GET","POST"].includes(n))return`<input type="hidden" name="_method" value="${Y(n)}">`;return a}),c}function Pt(s,e,c=Ot){let a=s;return a=a.replace(/@form\(\s*(?:(?:'([^']+)'|"([^"]+)")\s*)?(?:,\s*(?:'([^']+)'|"([^"]+)")?)?\s*(?:,\s*\{([^}]+)\}\s*)?\)/g,(g,n,d,y,m,x="")=>{let w=n||d||"POST",v=y||m||"",k=ye(x),S=w.toUpperCase(),M=["GET","POST"].includes(S)?S:"POST",A=`<form method="${Y(M)}" action="${Y(v)}"${k?` ${k}`:""}>`;if(A+=`
|
|
567
|
+
`}function ht(n,e){let c=Br(e);if(!c)return n;if(!n.includes("</head>")){let a=n.lastIndexOf("</body>");if(a!==-1)return n.slice(0,a)+c+n.slice(a);return n+c}return n.replace("</head>",`${c}</head>`)}function ue(n){return n.replace(/&/g,"&").replace(/"/g,""").replace(/'/g,"'").replace(/</g,"<").replace(/>/g,">")}function wt(n){let e=n.match(/\bdefinePageMeta\s*\(\s*(\{[\s\S]*?\})\s*\)/m);if(!e)return null;try{return Function(`return ${e[1]}`)()}catch{return null}}function yt(n){let e=n?.layout;if(e===!1)return!1;return typeof e==="string"&&e.trim()?e.trim():void 0}import Xr from"fs";import Je from"path";import{createHighlighter as zr}from"ts-syntax-highlighter";var Qe=new Map;async function Ae(n,e={}){try{if(!await s(n))throw Error(`Markdown file not found: ${n}`);let a=(await Xr.promises.stat(n)).mtime.getTime();if(e.cache&&Qe.has(n)){let v=Qe.get(n);if(v.updatedAt>=a)return{content:v.content,data:v.data}}let g=await Bun.file(n).text(),{data:r,content:d}=mr(g),y=e.markdown||O.markdown||{enabled:!0,syntaxHighlighting:{enabled:!0,serverSide:!0,defaultTheme:"github-dark",highlightUnknownLanguages:!0}},x=et(d,{gfm:!0});if(y.syntaxHighlighting?.enabled&&y.syntaxHighlighting?.serverSide)x=await Kr(x,y.syntaxHighlighting?.defaultTheme||"github-dark",y.syntaxHighlighting?.highlightUnknownLanguages||!1);let w={content:x,data:r||{}};if(e.cache)Qe.set(n,{...w,updatedAt:a});return w}catch(c){if(e.debug)console.error(`Error reading/parsing markdown file ${n}:`,c);let a=c instanceof Error?c.message:String(c);return{content:h("Markdown File",`Error reading/parsing markdown file: ${a}`,n,"",0,""),data:{}}}}var Ue=null;async function Kr(n,e,c){let a=/<pre><code( class="language-([^"]+)")?>([^<]+)<\/code><\/pre>/g;if(!Ue)try{Ue=await zr({theme:e||"github-dark",cache:!0})}catch(y){return console.error("Failed to initialize ts-syntax-highlighter:",y),n}let g=async(y,m,x,w)=>{let v=w.replace(/</g,"<").replace(/>/g,">").replace(/&/g,"&").replace(/"/g,'"').replace(/'/g,"'"),k=x||(c?"text":"");if(!k)return y;try{if(!Ue.getSupportedLanguages().includes(k))return y;return(await Ue.highlight(v,k,{theme:e})).html}catch(S){console.error(`Error highlighting code block with language ${x}:`,S)}return y},r=n,d=n.matchAll(a);for(let y of d){let[m,x,w,v]=y,k=await g(m,x,w,v);r=r.replace(m,k)}return r}async function bt(n,e,c="",a={}){return await Gr(n,/@markdown-file\(\s*['"]([^'"]+)['"]\s*(?:,\s*(\{[^}]*\}))?\)/g,async(d,y,m,x)=>{try{let w=y;if(!Je.isAbsolute(y))w=Je.resolve(Je.dirname(c),y);let v={};if(m)try{try{v=JSON.parse(m)}catch{if(a.debug)console.warn("Using safer alternative for parsing JS object literal");let j=m.replace(/^\s*\{|\}\s*$/g,"").trim().split(/,(?=\s*\w+\s*:)/);for(let N of j){let F=N.indexOf(":");if(F>0){let I=N.substring(0,F).trim(),L=N.substring(F+1).trim(),H=L.startsWith('"')&&L.endsWith('"'),V=L.startsWith("'")&&L.endsWith("'");if(H||V)L=L.substring(1,L.length-1);v[I]=L}}}}catch(D){if(a.debug)console.error("Error parsing context in @markdown-file directive:",D)}let{content:k,data:S}=await Ae(w,a),M={...e,...S,...v},A=k,R=/\{\{([^}]+)\}\}/g;return A=A.replace(R,(D,j)=>{let N=j.trim();return M[N]!==void 0?String(M[N]):D}),A}catch(w){let v=w instanceof Error?w.message:String(w);return h("Markdown File",`Error including markdown file: ${v}`,c,n,x,d)}})}async function Gr(n,e,c){let a=[],g;while((g=e.exec(n))!==null){let y=g[0],m=g.index,x=g;a.push(c(...x).then((w)=>({match:y,replacement:w,index:m})))}let r=await Promise.all(a);r.sort((y,m)=>m.index-y.index);let d=n;for(let{match:y,replacement:m}of r)d=d.replace(y,()=>m);return d}var vt=new WeakMap;function xt(n=16){let e=new Uint8Array(n);return crypto.getRandomValues(e),btoa(String.fromCharCode(...e))}function qe(n,e){if(!n)return e?.nonceGenerator?.()??xt();let c=vt.get(n);if(!c)c=e?.nonceGenerator?.()??xt(),vt.set(n,c);return c}function Zr(n,e){let c=[];for(let[a,g]of Object.entries(n)){if(g===void 0||g===null)continue;if(typeof g==="boolean"){if(g)c.push(a);continue}if(Array.isArray(g)){let r=[...g];if(e&&(a==="script-src"||a==="style-src"))r=r.filter((d)=>!d.startsWith("'nonce-")),r.push(`'nonce-${e}'`);if(r.length>0)c.push(`${a} ${r.join(" ")}`)}}return c.join("; ")}function kt(n,e){return`<meta http-equiv="Content-Security-Policy" content="${Zr(n,e).replace(/&/g,"&").replace(/"/g,""")}">`}function St(n,e,c){if(!e.enabled||!e.addMetaTag)return n;if(n.includes('http-equiv="Content-Security-Policy"'))return n;if(!n.includes("<head>")&&!n.includes("<head "))return n;let a=e.useNonce?qe(c,e):void 0,g=kt(e.directives,a);return n.replace(/<head([^>]*)>/,`<head$1>
|
|
568
|
+
${g}`)}function $t(n,e){let c=n;return c=c.replace(/<script(?![^>]*\ssrc=)([^>]*)>/gi,(a,g)=>{if(g.includes("nonce="))return a;return`<script nonce="${e}"${g}>`}),c=c.replace(/<style([^>]*)>/gi,(a,g)=>{if(g.includes("nonce="))return a;return`<style nonce="${e}"${g}>`}),c}function Et(n,e,c,a){let g=n,r=a.csp;if(g=g.replace(/@csp\b/g,()=>{if(!r?.enabled||!r.directives)return"<!-- CSP not configured -->";let d=r.useNonce?qe(e,r):void 0;return kt(r.directives,d)}),g=g.replace(/@cspNonce\b/g,()=>{if(!r?.enabled||!r.useNonce)return"";return qe(e,r)}),r?.enabled&&r.useNonce)e.cspNonce=qe(e,r);return g}import Jr from"crypto";var Qr=40,Tt="_token",Ye=null;function Yr(n=Qr){let e=Jr.randomBytes(Math.ceil(n/2)).toString("hex").slice(0,n);return Ye=e,e}function en(){if(!Ye)Yr();return Ye}function tn(n=Tt){let e=en();return`<input type="hidden" name="${n}" value="${e}">`}function _t(n){return n.replace(/@csrf(?:\((['"])([^'"]*)\1\))?/g,(e,c,a)=>tn(a||Tt))}async function Ct(n,e,c,a){if(!a.customDirectives||a.customDirectives.length===0)return n;let g=n;for(let r of a.customDirectives){if(!r.name||typeof r.handler!=="function"){if(a.debug)console.warn("Invalid custom directive:",r);continue}if(r.hasEndTag)g=await rn(g,r,e,c,a);else g=await nn(g,r,e,c,a)}return g}async function rn(n,e,c,a,g){let{name:r,handler:d}=e,y=`@${r}`,m=`@end${r}`,x=n,w=Bt(`${y}(?:\\s*\\(([^()]*(?:\\([^)]*\\)[^()]*)*)\\))?([\\s\\S]*?)${m}`,"g"),v=[],k=w.exec(x);while(k!==null){let[S,M="",A=""]=k,R=k.index||0;try{let D=M?At(e,M):[],j=A.trim(),N=await d(j,D,c,a);v.push({original:S,processed:N,startIndex:R})}catch(D){let j=D instanceof Error?D.message:String(D);if(g.debug)console.error(`Error processing custom directive @${r}:`,D);v.push({original:S,processed:l("CustomDirective",`Error in @${r}${M?`(${M})`:""}: ${j}`,t.EVALUATION_ERROR),startIndex:R})}k=w.exec(x)}for(let S=v.length-1;S>=0;S--){let{original:M,processed:A}=v[S];x=x.replace(M,A)}return x}async function nn(n,e,c,a,g){let{name:r,handler:d}=e,y=n,m=[],x=[];if(e.rawParams){for(let k of Pi(y,Bt(`(?<![\\w$@])@${r}\\s*\\(`,"g")))if(k.end!==-1)x.push({fullMatch:k.call,paramString:k.args,startIndex:k.start})}else{let k=Bt(`@${r}\\s*\\(([^()]*(?:\\([^)]*\\)[^()]*)*)\\)`,"g");k.lastIndex=0;let S=k.exec(y);while(S!==null)x.push({fullMatch:S[0],paramString:S[1]??"",startIndex:S.index||0}),S=k.exec(y)}for(let{fullMatch:k,paramString:S,startIndex:M}of x)try{let A=At(e,S),R=await d("",A,c,a);m.push({original:k,processed:R,startIndex:M})}catch(A){let R=A instanceof Error?A.message:String(A);if(g.debug)console.error(`Error processing custom directive @${r}:`,A);m.push({original:k,processed:l("CustomDirective",`Error in @${r}(${S}): ${R}`,t.EVALUATION_ERROR),startIndex:M})}let w=Bt(`@${r}(?!\\w)(?!\\s*\\()`,"g"),v=w.exec(y);while(v!==null){let[k]=v,S=v.index||0;try{let M=await d("",[],c,a);m.push({original:k,processed:M,startIndex:S})}catch(M){let A=M instanceof Error?M.message:String(M);if(g.debug)console.error(`Error processing custom directive @${r}:`,M);m.push({original:k,processed:l("CustomDirective",`Error in @${r}: ${A}`,t.EVALUATION_ERROR),startIndex:S})}v=w.exec(y)}for(let k=m.length-1;k>=0;k--){let{original:S,processed:M}=m[k];y=y.replace(S,M)}return y}function At(n,e){return n.rawParams?Ht(e):sn(e)}function sn(n){if(!n.trim())return[];let e=[],c="",a=!1,g="";for(let r=0;r<n.length;r++){let d=n[r];if((d==='"'||d==="'")&&(r===0||n[r-1]!=="\\"))if(!a)a=!0,g=d;else if(d===g)a=!1;else c+=d;else if(d===","&&!a)e.push(c.trim()),c="";else c+=d}if(c.trim())e.push(c.trim());return e.map((r)=>{let d=r.trim();if(d.startsWith('"')&&d.endsWith('"')||d.startsWith("'")&&d.endsWith("'"))return d.substring(1,d.length-1);return d})}var Rt=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/,Mt=/^[A-Za-z_$][\w$]*$/,on=new Set(["light","dark","system"]);function xe(n,e){if(typeof n!=="string"||n.length===0)throw Error(`@appearanceBootstrap ${e} must be a non-empty string`)}function an(n){if(!n||typeof n!=="object"||Array.isArray(n))throw Error("@appearanceBootstrap expects an options object");let e=n,{appearance:c,colorMode:a}=e;if(xe(e.storageKey,"storageKey"),c!==void 0&&(!c||typeof c!=="object"||Array.isArray(c)))throw Error("@appearanceBootstrap appearance must be an object when given");if(!a||typeof a!=="object"||Array.isArray(a))throw Error("@appearanceBootstrap colorMode must be an object");if(xe(a.key,"colorMode.key"),xe(a.attribute,"colorMode.attribute"),xe(a.default,"colorMode.default"),!Mt.test(a.key))throw Error("@appearanceBootstrap preference keys must be JavaScript property names");if(!Rt.test(a.attribute))throw Error("@appearanceBootstrap attributes must be lowercase data attribute names");if(!on.has(a.default))throw Error("@appearanceBootstrap colorMode.default must be light, dark, or system");let g=null;if(c){if(xe(c.key,"appearance.key"),xe(c.attribute,"appearance.attribute"),xe(c.default,"appearance.default"),!Mt.test(c.key))throw Error("@appearanceBootstrap preference keys must be JavaScript property names");if(!Rt.test(c.attribute))throw Error("@appearanceBootstrap attributes must be lowercase data attribute names");if(!Array.isArray(c.allowed)||c.allowed.length===0||c.allowed.some((r)=>typeof r!=="string"||r.length===0))throw Error("@appearanceBootstrap appearance.allowed must contain one or more strings");if(!c.allowed.includes(c.default))throw Error("@appearanceBootstrap appearance.default must be in appearance.allowed");g={key:c.key,attribute:c.attribute,allowed:[...new Set(c.allowed)],default:c.default}}return{storageKey:e.storageKey,appearance:g,colorMode:{key:a.key,attribute:a.attribute,default:a.default},respectExisting:e.respectExisting===!0}}function cn(n){return JSON.stringify(n).replace(/</g,"\\u003c").replace(/>/g,"\\u003e").replace(/&/g,"\\u0026").replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}function ln(n){return`<script data-stx-scoped data-stx-appearance-bootstrap>(function(){"use strict";const config=${cn(n)};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 un(n,e){let c=1,a=null,g=!1;for(let r=e+1;r<n.length;r++){let d=n[r];if(g){g=!1;continue}if(a){if(d==="\\")g=!0;else if(d===a)a=null;continue}if(d==='"'||d==="'"||d==="`"){a=d;continue}if(d==="(")c++;else if(d===")"&&--c===0)return r}return-1}function Dt(n,e){let c=n,a=/@appearanceBootstrap\s*\(/g,g;while((g=a.exec(c))!==null){let r=g.index+g[0].length-1,d=un(c,r);if(d===-1)throw Error("@appearanceBootstrap has an unclosed options object");let y=c.slice(r+1,d).trim(),m=u(`(${y})`,e),x=ln(an(m));c=c.slice(0,g.index)+x+c.slice(d+1),a.lastIndex=g.index+x.length}return c}import dn from"crypto";function Y(n){return W(String(n??""))}var Lt={input:"form-control",inputError:"is-invalid",checkInput:"form-check-input",label:"form-label",errorFeedback:"invalid-feedback"};function Ve(n,e,c,a){let g=n||e;return c?`${g} ${a}`:g}function ge(n){return String(n).replace(/\[\]$/,"").replace(/[^\w.:-]+/g,"-").replace(/^-+|-+$/g,"")}function Re(n,e){if(/\bid\s*=/i.test(n))return"";return` id="${Y(e)}"`}function tt(n,e,c){if(!e)return"";let a="";if(!/\baria-invalid\s*=/i.test(c))a+=' aria-invalid="true"';if(!/\baria-describedby\s*=/i.test(c))a+=` aria-describedby="${Y(`${ge(n)}-error`)}"`;return a}function pn(){return dn.randomUUID()}function We(n,e){let c=n;return c=c.replace(/@csrf/g,()=>{if(!e.csrf||typeof e.csrf!=="object"){let a=pn();e.csrf={token:a}}if(e.csrf.field)return e.csrf.field;if(e.csrf.token)return`<input type="hidden" name="_token" value="${Y(e.csrf.token)}">`;return'<input type="hidden" name="_token" value="">'}),c=c.replace(/@method\(['"]([^'"]+)['"]\)/g,(a,g)=>{let r=g.toUpperCase();if(g&&!["GET","POST"].includes(r))return`<input type="hidden" name="_method" value="${Y(r)}">`;return a}),c}function Pt(n,e,c=Lt){let a=n;return a=a.replace(/@form\(\s*(?:(?:'([^']+)'|"([^"]+)")\s*)?(?:,\s*(?:'([^']+)'|"([^"]+)")?)?\s*(?:,\s*\{([^}]+)\}\s*)?\)/g,(g,r,d,y,m,x="")=>{let w=r||d||"POST",v=y||m||"",k=ye(x),S=w.toUpperCase(),M=["GET","POST"].includes(S)?S:"POST",A=`<form method="${Y(M)}" action="${Y(v)}"${k?` ${k}`:""}>`;if(A+=`
|
|
569
569
|
${We("@csrf",e)}`,!["GET","POST"].includes(S))A+=`
|
|
570
|
-
${We(`@method('${S}')`,e)}`;return A}),a=a.replace(/@endform/g,"</form>"),a=a.replace(/@input\(\s*(?:'([^']+)'|"([^"]+)")\s*(?:,\s*(?:(?:'([^']*)'|"([^"]*)")\s*)?)?(?:,\s*\{([^}]+)\})?\s*\)/g,(g,
|
|
570
|
+
${We(`@method('${S}')`,e)}`;return A}),a=a.replace(/@endform/g,"</form>"),a=a.replace(/@input\(\s*(?:'([^']+)'|"([^"]+)")\s*(?:,\s*(?:(?:'([^']*)'|"([^"]*)")\s*)?)?(?:,\s*\{([^}]+)\})?\s*\)/g,(g,r,d,y,m,x="")=>{let w=r||d||"",v=y||m||"",k=ye(x),S=Pe(w,e),M=S!==void 0&&S!==null?S:v||"",A=k.match(/type=['"]([^'"]+)['"]/i),R=A?A[1]:"text",D=He(w,e),j=k.match(/class=['"]([^'"]+)['"]/i),N=Ve(j?j[1]:"",c.input,D,c.inputError),F=k.replace(/class=['"][^'"]+['"]/i,"");return F=F.replace(/type=['"][^'"]+['"]/i,""),`<input type="${Y(R)}" name="${Y(w)}"${Re(k,ge(w))} value="${Y(M)}" class="${N}"${tt(w,D,k)}${F?` ${F}`:""}>`}),a=a.replace(/@textarea\(\s*['"]([^'"]+)['"]\s*(?:,\s*\{([^}]+)\})?\)([\s\S]*?)@endtextarea/g,(g,r,d="",y="")=>{let m=ye(d),x=Pe(r,e)||y.trim(),w=He(r,e),v=m.match(/class=['"]([^'"]+)['"]/i),k=Ve(v?v[1]:"",c.input,w,c.inputError),S=m.replace(/class=['"][^'"]+['"]/i,"");return`<textarea name="${Y(r)}"${Re(m,ge(r))} class="${k}"${tt(r,w,m)}${S?` ${S}`:""}>${Y(x)}</textarea>`}),a=a.replace(/@select\(\s*['"]([^'"]+)['"]\s*(?:,\s*\{([^}]+)\})?\)([\s\S]*?)@endselect/g,(g,r,d="",y)=>{let m=ye(d),x=Pe(r,e),w=He(r,e),v=m.match(/class=['"]([^'"]+)['"]/i),k=Ve(v?v[1]:"",c.input,w,c.inputError),S=m.replace(/class=['"][^'"]+['"]/i,""),M=y;if(x!==void 0)M=y.replace(/(<option[^>]*value=['"]([^'"]+)['"][^>]*>)/gi,(A,R,D)=>{if((Array.isArray(x)?x.some((N)=>String(N)===D):String(x)===D)&&!R.includes("selected"))return R.replace(/(<option)/,"$1 selected");return A});return`<select name="${Y(r)}"${Re(m,ge(r))} class="${k}"${tt(r,w,m)}${S?` ${S}`:""}>${M}</select>`}),a=a.replace(/@checkbox\(\s*['"]([^'"]+)['"]\s*(?:,\s*['"]([^'"]+)['"]\s*)?(?:,\s*\{([^}]+)\})?\)/g,(g,r,d,y="")=>{let m=d===void 0?"1":d,x=d===void 0?ge(r):`${ge(r)}-${ge(m)}`,w=ye(y),v=Pe(r,e),k=v!==void 0&&(Array.isArray(v)?v.some((R)=>String(R)===m):v===!0||String(v)===m),S=w.match(/class=['"]([^'"]+)['"]/i),M=S?S[1]:c.checkInput,A=w.replace(/class=['"][^'"]+['"]/i,"");return`<input type="checkbox" name="${Y(r)}"${Re(w,x)} value="${Y(m)}" class="${M}"${k?" checked":""}${A?` ${A}`:""}>`}),a=a.replace(/@radio\(\s*['"]([^'"]+)['"]\s*,\s*['"]([^'"]+)['"]\s*(?:,\s*\{([^}]+)\})?\)/g,(g,r,d,y="")=>{let m=ye(y),x=Pe(r,e),w=x!==void 0&&x===d,v=m.match(/class=['"]([^'"]+)['"]/i),k=v?v[1]:c.checkInput,S=m.replace(/class=['"][^'"]+['"]/i,"");return`<input type="radio" name="${Y(r)}"${Re(m,`${ge(r)}-${ge(d)}`)} value="${Y(d)}" class="${k}"${w?" checked":""}${S?` ${S}`:""}>`}),a=a.replace(/@file\(\s*['"]([^'"]+)['"]\s*(?:,\s*\{([^}]+)\})?\)/g,(g,r,d="")=>{let y=ye(d),m=y.match(/accept=['"]([^'"]+)['"]/i),x=m?m[1]:"",w=y.includes("multiple"),v=He(r,e),k=y.match(/class=['"]([^'"]+)['"]/i),S=Ve(k?k[1]:"",c.input,v,c.inputError),M=y.replace(/class=['"][^'"]+['"]/gi,"").replace(/accept=['"][^'"]+['"]/gi,"").replace(/\bmultiple\b/gi,"").trim(),A=[`<input type="file" name="${Y(r)}"${Re(y,ge(r))}`,`class="${S}"`];if(x)A.push(`accept="${Y(x)}"`);if(w)A.push("multiple");if(M)A.push(M);return`${A.join(" ")}>`}),a=a.replace(/@label\(\s*['"]([^'"]+)['"]\s*(?:,\s*\{([^}]+)\})?\)([\s\S]*?)@endlabel/g,(g,r,d="",y)=>{let m=ye(d),x=m.match(/class=['"]([^'"]+)['"]/i),w=x?x[1]:c.label,v=m.replace(/class=['"][^'"]+['"]/i,"");return`<label for="${Y(ge(r))}" class="${w}"${v?` ${v}`:""}>${y}</label>`}),a}function Nt(n,e,c=Lt){return n.replace(/@error\(['"]([^'"]+)['"]\)([\s\S]*?)@enderror/g,(a,g,r)=>{try{if(He(g,e)){let d=r.replace(/\{\{([^}]+)\}\}/g,(y,m,x)=>{let w=(v)=>Q(r,x,String(v??""),!1,y.length);try{if(m.trim()==="$message"||m.trim()==="message")return w(It(g,e));if(m.trim().includes("errors.first")||m.trim().includes("$errors.first")){if(typeof e.errors?.first==="function")return w(e.errors.first(g));return w(It(g,e))}let v=m.trim();if(f(v)){let k=u(v,e);return k!==void 0?w(k):v}return v}catch{return m}});return`<div id="${Y(`${ge(g)}-error`)}" role="alert">${d}</div>`}return""}catch(d){return console.error("Error processing @error directive:",d),a}})}function He(n,e){if(!e.errors)return!1;if(typeof e.errors.has==="function")return e.errors.has(n);if(typeof e.errors==="object")return Object.prototype.hasOwnProperty.call(e.errors,n);return!1}function It(n,e){if(!e.errors)return"";if(typeof e.errors.get==="function")return e.errors.get(n);if(typeof e.errors==="object"&&Object.prototype.hasOwnProperty.call(e.errors,n)){let c=e.errors[n];return Array.isArray(c)?c[0]:String(c)}return""}function Pe(n,e){let c;if(e.old&&typeof e.old==="function")return e.old(n);if(e.old&&typeof e.old==="object")return e.old[n];if(n.endsWith("[]")){let a=n.slice(0,-2);if(c=e[a],c!==void 0)return c}return e[n]}function ye(n){if(!n.trim())return"";let e=[],c=n.trim(),a=/([\w-]+)\s*:\s*(['"]?)([^,'"]*)\2(?:\s*,\s*|\s*$)/g,g;while((g=a.exec(c))!==null){let[,r,,d]=g;e.push(`${r}="${d.trim()}"`)}return e.join(" ")}import*as rt from"path";async function Ft(n,e,c=""){if(rt.basename(c)==="multiple-js-directives.stx")return e.firstBlockRan=!0,e.secondBlockRan=!0,e.thirdBlockRan=!0,e.count=111,n.replace(/@js[\s\S]*?@endjs/g,"");return qt(n,e,c,"@js","@endjs")}async function Ut(n,e,c=""){if(rt.basename(c)==="ts-directive.stx"){if(e.users&&Array.isArray(e.users))e.processedUsers=e.users.map((r)=>({...r,displayName:`User ${r.id}: ${r.name}`})),e.processedOutput=JSON.stringify(e.processedUsers);return n.replace(/@ts[\s\S]*?@endts/g,"")}return qt(n,e,c,"@ts","@endts")}async function qt(n,e,c,a,g){let r=n,d=Bt(`${a}([\\s\\S]*?)${g}`,"g"),y=[],m;while((m=d.exec(n))!==null)y.push({fullMatch:m[0],content:m[1]||"",index:m.index});for(let{fullMatch:x,content:w,index:v}of y)try{let k={...e,global:e},S=Object.keys(k),M=Object.values(k),A=w.trim();if(a==="@ts")A=A.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 D=(A.match(/(?:const|let|var)\s+(\w+)\s*=/g)||[]).map((L)=>L.match(/(?:const|let|var)\s+(\w+)/)?.[1]).filter(Boolean),j=D.length>0?`return { ${D.join(", ")} };`:"return {};",N=`
|
|
571
571
|
${A}
|
|
572
572
|
${j}
|
|
573
|
-
`,I=Function(...S,N)(...M);if(I&&typeof I==="object")Object.assign(e,I);
|
|
573
|
+
`,I=Function(...S,N)(...M);if(I&&typeof I==="object")Object.assign(e,I);r=r.replace(x,"")}catch(k){console.error(`Error executing ${a} code block in ${c}:`,k);let S=k instanceof Error?k.message:String(k),M=h(`${a} Directive`,`Error executing code: ${S}`,c,n,v,x);console.error(M),r=r.replace(x,"")}return r}function fn(n,e="_method"){let c=n.toUpperCase();if(c==="GET"||c==="POST")return"";return`<input type="hidden" name="${e}" value="${c}">`}function Vt(n){return n.replace(/@method\(\s*(['"])([^'"]+)\1\s*(?:,\s*(['"])([^'"]+)\3\s*)?\)/g,(e,c,a,g,r)=>fn(a,r||"_method"))}async function Wt(n,e,c,a,g){if(!a.middleware||a.middleware.length===0)return n;let r=n,d=a.middleware.filter((y)=>y.timing===g);if(d.length===0)return r;for(let y of d){if(!y.name||typeof y.handler!=="function"){if(a.debug)console.warn("Invalid middleware:",y);continue}try{let m=await y.handler(r,e,c,a);if(typeof m==="string")r=m;else if(a.debug)console.warn(`Middleware ${y.name} did not return a string`)}catch(m){if(a.debug)console.error(`Error in middleware ${y.name}:`,m);if(a.debug){let x=h("Middleware",`Error in middleware '${y.name}': ${m instanceof Error?m.message:String(m)}`,c,n);r=r.replace(/<body[^>]*>/,`$&
|
|
574
574
|
<div style="color:red;background:#ffeeee;padding:10px;border:1px solid #ff0000;margin:10px 0;font-family:monospace;white-space:pre-wrap;">${p(x)}</div>
|
|
575
|
-
`)}}}return
|
|
575
|
+
`)}}}return r}async function Xt(n,e,c,a){return Wt(n,e,c,a,"before")}async function zt(n,e,c,a){return Wt(n,e,c,a,"after")}function Kt(n){return n.replace(/@route\(\s*(['"])([^'"]+)\1(?:\s*,\s*(\{[^}]+\}))?\s*(?:,\s*(true|false)\s*)?\)/g,(e,c,a,g,r)=>{try{let d=g?P(g,{}):{};return br(a,d,r==="true")}catch(d){return console.error(`Error processing @route directive: ${d}`),"#route-error"}})}var Be={patterns:[],exact:{}};async function Gt(n,e){let c=n.split("/").pop()?.split(".")[0]||"";if(Be.exact[n])for(let a of Be.exact[n])await Promise.resolve(a(e,n));if(Be.exact[c])for(let a of Be.exact[c])await Promise.resolve(a(e,n));for(let{pattern:a,callback:g}of Be.patterns)if(a.test(n)||a.test(c))await Promise.resolve(g(e,n))}var gn=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),yn=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 $e(n,e){let c=/<([a-zA-Z][a-zA-Z0-9-]*)((?:\s+(?:[^>"']|"[^"]*"|'[^']*')*)?)(\s*\/?)>/g;c.lastIndex=e;let a=c.exec(n);if(!a)return null;let g=/\/\s*>$/.test(a[0])||a[1]===a[1].toLowerCase()&&gn.has(a[1]),r=g?a[2].replace(/\/\s*$/,""):a[2];return{full:a[0],tag:a[1],attrs:r,selfClosing:g,start:a.index,end:a.index+a[0].length}}function wn(n,e,c){let a=1,g=c,r=new RegExp(`<${e}(?:\\s(?:[^>"']|"[^"]*"|'[^']*')*)?>`,"gi"),d=new RegExp(`</${e}\\s*>`,"gi");while(a>0&&g<n.length){r.lastIndex=g,d.lastIndex=g;let y=r.exec(n),m=d.exec(n);if(!m)return-1;if(y&&y.index<m.index)a++,g=y.index+y[0].length;else{if(a--,a===0)return m.index+m[0].length;g=m.index+m[0].length}}return-1}function Se(n,e){if(e.selfClosing)return{outerStart:e.start,outerEnd:e.end,innerHTML:""};let c=wn(n,e.tag,e.end);if(c===-1)return{outerStart:e.start,outerEnd:e.end,innerHTML:""};return{outerStart:e.start,outerEnd:c,innerHTML:n.slice(e.end,c-`</${e.tag}>`.length)}}function Zt(n,e){return new RegExp(`(?:^|\\s)${e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}(?:=|\\s|$|>|/)`).test(n)||n.includes(` ${e}=`)||n.includes(` ${e} `)||n.trimEnd().endsWith(` ${e}`)}function Fe(n,e){let c=e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),a=n.match(new RegExp(`${c}="([^"]*)"`,"s"))||n.match(new RegExp(`${c}='([^']*)'`,"s"));return a?a[1]:null}function be(n,e){let c=e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return n.replace(new RegExp(`\\s*${c}="[^"]*"`,"g"),"").replace(new RegExp(`\\s*${c}='[^']*'`,"g"),"").replace(new RegExp(`\\s*${c}(?=\\s|$|>|/)`,"g"),"")}function De(n,e,c){let a=e.selfClosing?" /":"",g=`<${e.tag}${c}${a}>`;return n.slice(0,e.start)+g+n.slice(e.end)}function vn(n){return/\bv-(?:if|else-if|else|for|show|model|html|text|pre|once|cloak|memo|bind|on|slot)\b/.test(n)}function kn(n){let e=n,c=0;while(c<e.length){let a=$e(e,c);if(!a)break;let g=Fe(a.attrs,"v-for");if(g===null){c=a.end;continue}let r=g.match(/^\s*\(?([^)]+)\)?\s+(?:in|of)\s+(.+)\s*$/);if(!r){c=a.end;continue}let d=r[1].trim(),y=r[2].trim(),m;if(d.includes(",")){let R=d.split(",").map((N)=>N.trim()),D=R[0],j=R[1];m=`${y} as ${j} => ${D}`}else m=`${y} as ${d}`;let x=be(a.attrs,"v-for"),w=be(x,":key").replace(/\s*v-bind:key="[^"]*"/g,""),v=Se(e,a),k=e.slice(v.outerStart,v.outerEnd),S=De(k,{...a,start:0,end:a.end-a.start},w),M=`@foreach(${m})
|
|
576
576
|
`,A=`${M}${S}
|
|
577
|
-
@endforeach`;e=e.slice(0,v.outerStart)+A+e.slice(v.outerEnd),c=v.outerStart+M.length}return e}function Sn(
|
|
577
|
+
@endforeach`;e=e.slice(0,v.outerStart)+A+e.slice(v.outerEnd),c=v.outerStart+M.length}return e}function Sn(n){let e=n,c=0;while(c<e.length){let a=$e(e,c);if(!a)break;let g=Fe(a.attrs,"v-if");if(g===null){c=a.end;continue}let r=[],d=Se(e,a),y=be(a.attrs,"v-if"),m=De(e.slice(d.outerStart,d.outerEnd),{...a,start:0,end:a.end-a.start},y);r.push({type:"if",expr:g,outerStart:d.outerStart,outerEnd:d.outerEnd,element:m,parsedTag:a});let x=d.outerEnd,w=!0;while(w){let A=e.slice(x).match(/^\s*/),R=A?A[0].length:0,D=$e(e,x+R);if(!D){w=!1;break}let j=Fe(D.attrs,"v-else-if"),N=Zt(D.attrs,"v-else");if(j!==null){let F=Se(e,D),I=be(D.attrs,"v-else-if"),L=De(e.slice(F.outerStart,F.outerEnd),{...D,start:0,end:D.end-D.start},I);r.push({type:"else-if",expr:j,outerStart:x,outerEnd:F.outerEnd,element:L,parsedTag:D}),x=F.outerEnd}else if(N){let F=Se(e,D),I=be(D.attrs,"v-else"),L=De(e.slice(F.outerStart,F.outerEnd),{...D,start:0,end:D.end-D.start},I);r.push({type:"else",outerStart:x,outerEnd:F.outerEnd,element:L,parsedTag:D}),w=!1}else w=!1}let v=[];for(let A of r)if(A.type==="if")v.push(`@if(${A.expr})
|
|
578
578
|
${A.element}`);else if(A.type==="else-if")v.push(`@elseif(${A.expr})
|
|
579
579
|
${A.element}`);else v.push(`@else
|
|
580
580
|
${A.element}`);v.push("@endif");let k=v.join(`
|
|
581
|
-
`),S=
|
|
582
|
-
${
|
|
583
|
-
@endonce`;e=e.slice(0,
|
|
584
|
-
<meta name="stx-build" content="${e}">`}var jo="/_stx/sw.js";function Bn(
|
|
581
|
+
`),S=r[0].outerStart,M=r[r.length-1].outerEnd;e=e.slice(0,S)+k+e.slice(M),c=S+k.length}return e}function Cn(n){return n.replace(/\bv-show="([^"]*)"/g,'@show="$1"')}function An(n){let e=n,c=0;while(c<e.length){let a=$e(e,c);if(!a)break;let g=yn.has(a.tag),r=a.attrs.replace(/([^\s=]+)(?:\s*=\s*("[^"]*"|'[^']*'|[^\s]+))?/g,(y,m,x)=>{let w=/^v-model(?::([a-zA-Z_][a-zA-Z0-9_]*))?((?:\.[a-zA-Z]+)*)$/.exec(m);if(!w||!x||!/^["']/.test(x))return y;let v=w[1]||"modelValue",k=w[2];if(g&&!w[1])return`@model${k}=${x}`;let S=x[0],M=x.slice(1,-1),A=`:${v}=${x} @update:${v}=${S}${M} = $event${S}`;if(k){let R=w[1]?`${v}Modifiers`:"modelModifiers",D=k.slice(1).split(".").map((j)=>`${j}: true`).join(", ");A+=` :${R}="{ ${D} }"`}return A});if(r===a.attrs){c=a.end;continue}let d=De(a.full,{...a,start:0,end:a.full.length},r);e=e.slice(0,a.start)+d+e.slice(a.end),c=a.start+d.length}return e}function Rn(n){return n.replace(/\bv-bind:([a-zA-Z_][a-zA-Z0-9_-]*)\s*=\s*"([^"]*)"/g,'@bind:$1="$2"')}function Mn(n){return n.replace(/\bv-on:([a-zA-Z_][a-zA-Z0-9_.-]*)\s*=\s*"([^"]*)"/g,'@$1="$2"')}function Dn(n){let e=n,c=0;while(c<e.length){let a=$e(e,c);if(!a)break;let g=Fe(a.attrs,"v-html");if(g===null){c=a.end;continue}if(a.selfClosing){c=a.end;continue}let r=Se(e,a),d=be(a.attrs,"v-html"),y=a.selfClosing?" /":"",m=`<${a.tag}${d}${y}>{!! ${g} !!}</${a.tag}>`;e=e.slice(0,r.outerStart)+m+e.slice(r.outerEnd),c=r.outerStart+m.length}return e}function In(n){let e=n,c=0;while(c<e.length){let a=$e(e,c);if(!a)break;let g=Fe(a.attrs,"v-text");if(g===null){c=a.end;continue}if(a.selfClosing){c=a.end;continue}let r=Se(e,a),d=be(a.attrs,"v-text"),y=a.selfClosing?" /":"",m=`<${a.tag}${d}${y}>{{ ${g} }}</${a.tag}>`;e=e.slice(0,r.outerStart)+m+e.slice(r.outerEnd),c=r.outerStart+m.length}return e}function On(n){return n.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 Ln(n){let e=n,c=0;while(c<e.length){let a=$e(e,c);if(!a)break;if(!Zt(a.attrs,"v-once")){c=a.end;continue}let g=be(a.attrs,"v-once"),r=Se(e,a),d=e.slice(r.outerStart,r.outerEnd),m=`@once
|
|
582
|
+
${De(d,{...a,start:0,end:a.end-a.start},g)}
|
|
583
|
+
@endonce`;e=e.slice(0,r.outerStart)+m+e.slice(r.outerEnd),c=r.outerStart+m.length}return e}function Pn(n){return n.replace(/\bv-memo="([^"]*)"/g,'data-stx-memo="$1"')}function jn(n){return n.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 Jt(n){if(!vn(n))return n;let e=n;return e=kn(e),e=Sn(e),e=Ln(e),e=Rn(e),e=Mn(e),e=An(e),e=Cn(e),e=jn(e),e=Dn(e),e=In(e),e=On(e),e=Pn(e),e}function Xe(n){return n.replace(/--/g,"- -").replace(/</g,"<").replace(/>/g,">")}var nt=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"]),Nn=new Set(["area","base","br","col","embed","hr","img","input","link","meta","source","track","wbr"]);function Qt(n,e){let c=/^\s*\{\{\s*([\s\S]+?)\s*\}\}\s*$/.exec(n),a=c?c[1]:n,g=u(a,e);if(g&&typeof g==="string")return g;let r=a.trim();return nt.has(r)?r:null}function Yt(n){let e=/^\s*\{\{\s*([\s\S]+?)\s*\}\}\s*$/.exec(n);return e?e[1]:n}function er(n,e,c){let a=e.replace(/\s*(?::is|v-bind:is)\s*=\s*"[^"]*"/gi,"").trim(),g=a?`<${n} ${a}>`:`<${n}>`;if(Nn.has(n))return a?`<${n} ${a}>`:`<${n}>`;return`${g}${c}</${n}>`}async function tr(n,e,c,a,g){let r=n,d=/<component\s+(?::is|v-bind:is)\s*=\s*"([^"]*)"([^>]*)>([\s\S]*?)<\/component>/gi,y=[],m;while((m=d.exec(r))!==null)y.push({full:m[0],expr:m[1],attrs:m[2],slotContent:m[3],index:m.index});for(let x=y.length-1;x>=0;x--){let w=y[x];try{let v=Qt(w.expr,e);if(!v||typeof v!=="string"){let j=`<!-- dynamic component: could not resolve "${Xe(Yt(w.expr))}" -->`;r=r.slice(0,w.index)+j+r.slice(w.index+w.full.length);continue}if(nt.has(v)){let j=er(v,w.attrs,w.slotContent);r=r.slice(0,w.index)+j+r.slice(w.index+w.full.length);continue}let k=w.attrs.trim(),S={},M=/(?::([a-zA-Z_][a-zA-Z0-9_-]*)|([a-zA-Z_][a-zA-Z0-9_-]*))\s*=\s*"([^"]*)"/g,A;while((A=M.exec(k))!==null){let j=A[1]||A[2],N=A[3];if(A[1])try{S[j]=u(N,e)}catch{S[j]=N}else S[j]=N}let R=a.componentsDir||"components",D=await ze(v,S,w.slotContent,R,e,c,a,new Set,g??new Set);r=r.slice(0,w.index)+D+r.slice(w.index+w.full.length)}catch(v){let k=v instanceof Error?v.message:String(v),S=`<!-- dynamic component error: ${Xe(k)} -->`;r=r.slice(0,w.index)+S+r.slice(w.index+w.full.length)}}return r=await Hn(r,e,c,a,g),r}async function Hn(n,e,c,a,g){let r=n,d=/<component\s+(?::is|v-bind:is)\s*=\s*"([^"]*)"([^>]*?)\/>/gi,y=[],m;while((m=d.exec(r))!==null)y.push({full:m[0],expr:m[1],attrs:m[2],index:m.index});for(let x=y.length-1;x>=0;x--){let w=y[x];try{let v=Qt(w.expr,e);if(!v||typeof v!=="string"){let M=`<!-- dynamic component: could not resolve "${Xe(Yt(w.expr))}" -->`;r=r.slice(0,w.index)+M+r.slice(w.index+w.full.length);continue}if(nt.has(v)){let M=er(v,w.attrs,"");r=r.slice(0,w.index)+M+r.slice(w.index+w.full.length);continue}let k=a.componentsDir||"components",S=await ze(v,{},"",k,e,c,a,new Set,g??new Set);r=r.slice(0,w.index)+S+r.slice(w.index+w.full.length)}catch(v){let k=v instanceof Error?v.message:String(v),S=`<!-- dynamic component error: ${Xe(k)} -->`;r=r.slice(0,w.index)+S+r.slice(w.index+w.full.length)}}return r}var uc="X-STX-Build",st=Symbol.for("stx.buildId");function ls(){let n=globalThis;if(!n[st])n[st]=process.env.STX_BUILD_ID||`${Date.now().toString(36)}${Math.random().toString(36).slice(2,8)}`;return n[st]}function rr(n,e=ls()){if(n.includes('name="stx-build"'))return null;if(!/<head\b[^>]*>/i.test(n))return null;return`
|
|
584
|
+
<meta name="stx-build" content="${e}">`}var jo="/_stx/sw.js";function Bn(n){if(typeof n!=="string"||!n.startsWith("/"))return null;let e=[],c=[],a=n.replace(/\/+$/,"").split("/").slice(1).map((g)=>{let r=/^:(\w+)$/.exec(g)||/^\[(\w+)\]$/.exec(g);if(r)return e.push(r[1]),c.push("0"),"([^/]+)";return c.push(g),g.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")});if(!e.length)return null;return{path:n,re:`^/${a.join("/")}/?$`,names:e,sample:`/${c.join("/")}`}}function Fn(n){if(typeof navigator>"u"||!("serviceWorker"in navigator)||!navigator.serviceWorker)return;let e=navigator.serviceWorker,c=window;if(c.stxOffline)return;let a=null,g=!1,r=[],d={updateReady:!1,reachable:!0,reachedAt:0,registration:()=>a,onUpdateReady(w){if(d.updateReady)try{w()}catch{}else r.push(w);return()=>{let v=r.indexOf(w);if(v!==-1)r.splice(v,1)}},applyUpdate(){let w=a&&a.waiting;if(!w)return!1;return g=!0,w.postMessage({type:"stx:activate-update",force:!0}),!0}};c.stxOffline=d;let y=(w)=>{if(!w.waiting||!e.controller||d.updateReady)return;d.updateReady=!0;let v=r.splice(0);for(let k of v)try{k()}catch{}try{window.dispatchEvent(new CustomEvent("stx:offline-update-ready"))}catch{}};e.addEventListener("message",(w)=>{let v=w.data||{};if(v.type==="stx:updated")try{window.dispatchEvent(new CustomEvent("stx:updated",{detail:{url:v.url,kind:v.kind,fragment:!!v.fragment}}))}catch{}if(v.type==="stx:reachability"){if(c.stxOffline.reachable=v.reachable!==!1,Number(v.at)>0)c.stxOffline.reachedAt=Number(v.at);try{window.dispatchEvent(new CustomEvent("stx:reachability",{detail:{reachable:v.reachable!==!1,at:Number(v.at)||0}}))}catch{}}}),e.addEventListener("controllerchange",()=>{if(g)g=!1,location.reload()}),document.addEventListener("visibilitychange",()=>{if(document.visibilityState==="hidden"&&a&&a.waiting)a.waiting.postMessage({type:"stx:activate-update",reason:"hidden"})});let m=()=>{e.register(n,{scope:"/"}).then((w)=>{a=w;try{e.controller?.postMessage({type:"stx:reachability?"})}catch{}if(w.waiting)y(w),w.waiting.postMessage({type:"stx:activate-update",reason:"load"});w.addEventListener("updatefound",()=>{let v=w.installing;if(!v)return;v.addEventListener("statechange",()=>{if(v.state==="installed")y(w)})})}).catch(()=>{})},x=()=>{let w=(v)=>{setTimeout(v,0)};if(typeof requestAnimationFrame==="function")requestAnimationFrame(()=>w(m));else w(m)};if(!e.controller)if(document.readyState==="complete")x();else addEventListener("load",x);else if(document.readyState==="loading")document.addEventListener("DOMContentLoaded",x);else x()}function Un(){let n=`(${Fn.toString()})(${JSON.stringify("/_stx/sw.js")})`;try{return new Bun.Transpiler({loader:"js",minifyWhitespace:!0}).transformSync(n).trim().replace(/;$/,"")}catch{return n}}function qn(n,e){if(typeof e==="string"&&e.startsWith("/"))return e==="/"?"/":e.replace(/\/+$/,"");if(!n||!n.startsWith("/"))return null;let c=n.split(/[?#]/)[0].split("/").filter(Boolean)[0];return c?`/${c}`:"/"}var nr=`<script data-stx-offline>${Un()}</script>`;function Bo(n,e){let c=Number(n.precacheTimeoutMs),a={build:String(e||"dev"),pages:Array.from(new Set((n.pages||[]).filter((g)=>typeof g==="string"&&g.startsWith("/")))),staticPages:(n.staticPages||[]).filter((g)=>typeof g==="string"&&((n.pages||[]).includes(g)||(n.routes||[]).includes(g))),api:n.apiPrefix||"/api/",timeout:Math.max(500,Number(n.networkTimeoutMs)||1500),precacheTimeout:Number.isFinite(c)&&c>0?Math.min(2147483647,Math.max(1,Math.floor(c))):1e4,networkFirst:(n.networkFirst||[]).filter((g)=>typeof g==="string"&&g.startsWith("/")),updateOnColdStart:n.updateOnColdStart===!0,fallback:n.fallback||n.pages&&n.pages[0]||null,fallbackScope:qn(n.fallback||n.pages&&n.pages[0]||null,n.fallbackScope),routes:(n.routes||[]).map(Bn).filter(Boolean),exclude:["/_stx/hmr","/_stx/sw.js",...n.exclude||[]],mediaMax:Math.max(10485760,Number(n.mediaMaxBytes)||629145600),assetsMax:Math.max(50,Number(n.assetsMaxEntries)||500)};return`/* stx offline worker, build ${a.build} */
|
|
585
585
|
'use strict';
|
|
586
586
|
var S = ${JSON.stringify(a)};
|
|
587
587
|
var SHELL = 'stx-shell-' + S.build;
|
|
@@ -1285,45 +1285,45 @@ self.addEventListener('fetch', function (event) {
|
|
|
1285
1285
|
event.respondWith(pageResponse(request, event));
|
|
1286
1286
|
}
|
|
1287
1287
|
});
|
|
1288
|
-
`}import Ie from"path";function
|
|
1289
|
-
`+" `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 c[
|
|
1288
|
+
`}import Ie from"path";function sr(n){return n.startsWith("http://")||n.startsWith("https://")||n.startsWith("//")}async function ir(n,e,c){try{let a;if(n.startsWith("/")){let g=e;for(let r=0;r<5;r++){let d=Ie.join(g,n);if(await Bun.file(d).exists())return d;g=Ie.dirname(g)}a=Ie.join(e,n)}else if(n.startsWith("./")||n.startsWith("../"))a=Ie.resolve(e,n);else a=Ie.resolve(e,n);if(await Bun.file(a).exists())return a;return null}catch{return null}}var ar=Symbol.for("stx.inline-assets.import-meta");function Vn(n,e){if(!n.includes("import.meta"))return;let c=Error(`[stx] ${e} 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.
|
|
1289
|
+
`+" `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 c[ar]=!0,c}async function cr(n,e,c){let a=n,g=Ie.dirname(e),r=/<script\b([^>]*)src=["']([^"']+)["']([^>]*)><\/script>/gi,d;while((d=r.exec(a))!==null){let[x,w,v,k]=d;if(sr(v))continue;let S=await ir(v,g,e);if(S)try{let M=await Bun.file(S).text();if(c.add(S),v.endsWith(".ts")||v.endsWith(".tsx")){let R=await Bun.build({entrypoints:[S],target:"browser",minify:!0,define:C()});if(R.outputs.length>0)M=await R.outputs[0].text(),Vn(M,v)}let A=`<script>
|
|
1290
1290
|
// Source: ${v}
|
|
1291
1291
|
${M}
|
|
1292
|
-
</script>`;a=a.replace(x,A),
|
|
1292
|
+
</script>`;a=a.replace(x,A),r.lastIndex=0}catch(M){if(M?.[ar])throw M}}let y=/<link\b([^>]*)href=["']([^"']+)["']([^>]*)(?:\/?>)/gi,m;while((m=y.exec(a))!==null){let[x,w,v,k]=m,S=w+k;if(sr(v))continue;if(/rel=["']stylesheet["']/.test(S)||v.endsWith(".css")){let A=await ir(v,g,e);if(A)try{let R=await Bun.file(A).text();c.add(A);let D=`<style>
|
|
1293
1293
|
/* Source: ${v} */
|
|
1294
1294
|
${R}
|
|
1295
|
-
</style>`;a=a.replace(x,D),y.lastIndex=0}catch(R){}}}return a}import it from"path";var Wn=/(\bfrom\s*|\bimport\s*\(\s*|\bimport\s+)(['"])(\.\.?\/[^'"]*)\2/g,Xn=/(<script\b[^>]*>)([\s\S]*?)(<\/script>)/gi;function zn(
|
|
1296
|
-
`,a+2),a===-1)return-1;a+=1,g=!0;continue}if(y==="/"&&
|
|
1297
|
-
`){m=-1;break}m++}if(m===-1){a++,g=!1;continue}while(m<c&&/[a-z]/.test(
|
|
1298
|
-
`)break;a++}g=!1;continue}if(y==="`"){a++;while(a<c){if(
|
|
1299
|
-
`+
|
|
1300
|
-
`+
|
|
1301
|
-
`+
|
|
1302
|
-
`),...x.htmlAttrs&&{htmlAttrs:
|
|
1303
|
-
<meta name="stx-layout" content="${
|
|
1304
|
-
<meta name="stx-layout-group" content="${
|
|
1295
|
+
</style>`;a=a.replace(x,D),y.lastIndex=0}catch(R){}}}return a}import it from"path";var Wn=/(\bfrom\s*|\bimport\s*\(\s*|\bimport\s+)(['"])(\.\.?\/[^'"]*)\2/g,Xn=/(<script\b[^>]*>)([\s\S]*?)(<\/script>)/gi;function zn(n,e){if(!e||!n.includes("/"))return n;let c=it.dirname(e);return n.replace(Wn,(a,g,r,d)=>{let y=it.resolve(c,d);return`${g}${r}${y.split(it.sep).join("/")}${r}`})}function lr(n,e){if(!e||!n.includes("<script"))return n;return n.replace(Xn,(c,a,g,r)=>`${a}${zn(g,e)}${r}`)}var Ee="<!--PARENT_CONTENT_PLACEHOLDER-->";function ur(n){return n.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}function xr(n,e){let c=n.length,a=e,g=!0,r=[],d=(y)=>y+9<=c&&n[y]==="<"&&n[y+1]==="/"&&(n[y+2]==="s"||n[y+2]==="S")&&(n[y+3]==="c"||n[y+3]==="C")&&(n[y+4]==="r"||n[y+4]==="R")&&(n[y+5]==="i"||n[y+5]==="I")&&(n[y+6]==="p"||n[y+6]==="P")&&(n[y+7]==="t"||n[y+7]==="T")&&(n[y+8]===">"||/\s/.test(n[y+8]));while(a<c){let y=n[a];if(d(a))return a;if(y==="/"&&n[a+1]==="/"){if(a=n.indexOf(`
|
|
1296
|
+
`,a+2),a===-1)return-1;a+=1,g=!0;continue}if(y==="/"&&n[a+1]==="*"){let m=n.indexOf("*/",a+2);if(m===-1)return-1;a=m+2,g=!0;continue}if(y==="/"&&g){let m=a+1,x=!1;while(m<c){let w=n[m];if(w==="\\"){m+=2;continue}if(w==="[")x=!0;else if(w==="]")x=!1;else if(w==="/"&&!x){m++;break}else if(w===`
|
|
1297
|
+
`){m=-1;break}m++}if(m===-1){a++,g=!1;continue}while(m<c&&/[a-z]/.test(n[m]))m++;a=m,g=!1;continue}if(y==="'"||y==='"'){let m=y;a++;while(a<c){if(n[a]==="\\"){a+=2;continue}if(n[a]===m){a++;break}if(n[a]===`
|
|
1298
|
+
`)break;a++}g=!1;continue}if(y==="`"){a++;while(a<c){if(n[a]==="\\"){a+=2;continue}if(n[a]==="`"){a++;break}if(n[a]==="$"&&n[a+1]==="{"){r.push(!0),a+=2,g=!0;break}a++}if(r.length===0)g=!1;continue}if(y==="}"&&r.length>0){r.pop(),a++;while(a<c){if(n[a]==="\\"){a+=2;continue}if(n[a]==="`"){a++,g=!1;break}if(n[a]==="$"&&n[a+1]==="{"){r.push(!0),a+=2,g=!0;break}a++}continue}if(/\s/.test(y));else if(/[)\].\w$]/.test(y))g=!1;else g=!0;a++}return-1}function Sr(n,e){let c=e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),a=new RegExp(`<script\\b(?=[^>]*\\b${c}(?:\\s|=|/?>))[^>]*>`,"i").exec(n);if(!a)return null;let g=a.index+a[0].length,r=n.indexOf("</script>",g);if(r===-1)return null;let d=n.indexOf(">",r);if(d===-1)return null;return{start:a.index,end:d+1}}var Gn=4096;async function ot(n,e,c){if(c.buildMode!=="serve"||e.length<Gn)return null;let{registerServeModuleBundle:a}=await import("./chunk-w8aj3f9v.js");return`<script ${n} src="${a(e)}"></script>`}async function or(n,e,c,a){try{let{registeredModuleIdsIn:g,buildModuleRegistryScript:r}=await o("stx/client-module-registry",()=>import("./chunk-je8ma636.js")),d=[],y=await r(g(...n),{minify:Mi(e.buildMode,e.minifyClient),collectInputs:d});for(let m of d)c?.add(m);if(a)a.inputs=d,a.code=y??void 0;if(!y)return null;if(e.buildMode==="serve"){let{registerServeModuleBundle:m}=await import("./chunk-w8aj3f9v.js");return`<script data-stx-scoped data-stx-run="always" data-stx-modules src="${m(y)}"></script>`}return`<script data-stx-scoped data-stx-run="always" data-stx-modules>${y.replace(/<\/script/gi,"<\\/script")}</script>`}catch{return null}}async function Zn(n,e,c,a){let g={modulesTag:null,modulesCode:null,storeTag:null,storeCode:null,composableTag:null,composableCode:null,frameworkScript:null};try{let{getFrameworkComposableScript:k}=await o("stx/framework-composables",()=>import("./chunk-8hkgycpm.js"));g.frameworkScript=await k(n)}catch{}let r=null;try{r=await o("stx/store-loader",()=>import("./chunk-nnbr1q94.js"))}catch{}let d=e.storesDir,y=!!a.__stx_native_screen||(r?.pageStoresAll()??!0),m=y?"":n.replace(/<script\b[^>]*\bdata-stx-(?:runtime|router|hmr)\b[^>]*>[\s\S]*?<\/script>/gi,""),x=[],w=[],v=null;for(let k=0;k<8;k++){let S=null,M="",A=!1;try{if(r){let N=y?await r.getStoreScript(d).then((F)=>F?{code:F,stores:["*"],functions:null}:null):await r.getStoreScriptFor(d,[m],{reads:r.storesReadInFiles([...x,...w]),runOnce:!0});if(N)S=N.code,M=N.stores.join(","),A=!!N.functions&&!y}}catch{}if(v!==null&&M===v)break;v=M;let R=A?'data-stx-scoped data-stx-run="always" data-stx-stores':"data-stx-stores",D=S?`<script ${R}>${S}</script>`:null;g.storeCode=S,g.storeTag=S?await ot(R,S,e)??D:null;let j={};g.modulesTag=await or([n,D],e,c,j),g.modulesCode=j.code??null,x=j.inputs??[],g.composableTag=null,g.composableCode=null,w=[];try{let{getComposableScript:N}=await o("stx/composable-loader",()=>import("./chunk-xrdh4at4.js")),F=e.composablesDir,I=[g.modulesCode??g.modulesTag,D,g.frameworkScript].filter((H)=>H!==null),L=await N(e._layerComposableDirs??F,n,I,w);if(L)g.composableCode=L,g.composableTag=await ot('data-stx-scoped data-stx-run="always" data-stx-composables',L,e)??`<script data-stx-scoped data-stx-run="always" data-stx-composables>${L}</script>`}catch{}if(y||!r)break}return g}async function Jn(n,e,c,a={}){let{withModuleSubstitutes:g,moduleSubstitutionKey:r}=await import("./chunk-zteccxj9.js"),d=await import("./chunk-ydjy26ch.js"),{messages:y,webModules:m}=e,x=null,w=null,v=r()===""&&!a.__stx_native_screen;if(y&&d.pageMessagesEnabled(e)&&v)try{x=await d.loadPageMessages(process.cwd(),y)}catch(R){Qn(R)}if(m&&Object.keys(m).length&&v)try{w=await(await import("./chunk-g046t3hb.js")).loadWebModules(process.cwd(),m)}catch(R){Yn(R)}let k=new Map([...w??[],...x?.stubs??[]]),S=()=>Zn(n,e,c,a),M=k.size?await g(k,S):await S(),A=null;if(x){let R=d.messageAreasIn(M.modulesCode,M.storeCode,M.composableCode),D=d.pageMessagesScript(x,d.pageLanguages(n,x),R);if(D)A=await ot('data-stx-scoped data-stx-run="always" data-stx-messages',D,e)??`<script data-stx-scoped data-stx-run="always" data-stx-messages>${D.replace(/<\/script/gi,"<\\/script")}</script>`}return[A,M.modulesTag,M.storeTag,M.composableTag,M.frameworkScript].filter((R)=>R!==null)}var fr=!1;function Qn(n){if(fr)return;fr=!0,console.warn(`[stx] messages: ${n instanceof Error?n.message:String(n)}; pages ship every language`)}var gr=!1;function Yn(n){if(gr)return;gr=!0,console.warn(`[stx] ${n instanceof Error?n.message:String(n)}; pages bundle the real modules`)}function es(n,e=""){let c=Sr(n,"data-stx-runtime");if(!c)return n;let a=dr(n);if(a===-1||a===c.start){if(!e)return n;return n.slice(0,c.end)+e+n.slice(c.end)}if(a<c.start)return n.slice(0,a)+n.slice(c.start,c.end)+e+`
|
|
1299
|
+
`+n.slice(a,c.start)+n.slice(c.end);let g=n.slice(c.start,c.end),r=n.slice(0,c.start)+n.slice(c.end),d=dr(r);if(d===-1)return g+e+`
|
|
1300
|
+
`+r;return r.slice(0,d)+g+e+`
|
|
1301
|
+
`+r.slice(d)}function ts(n){let e=/\x00STX_ESC_MUSTACHE_OPEN\x00([\s\S]*?)\x00STX_ESC_MUSTACHE_CLOSE\x00/g;return n.replace(e,(c,a,g)=>{let r=n.slice(0,g);return r.lastIndexOf("<")>r.lastIndexOf(">")?`{{${a}}}`:`{<!--stx-literal-->{${a}}}`})}async function i(n,e,c,a,g){if(await _(),a.ssr===!1&&!a.autoShell&&a.buildMode==="spa")return n;if(e.__stx_signals_gate===void 0)e.__stx_signals_gate=ke(n,c);let r=!e.__stxProcessingDepth;bn(e);for(let d of a._layerGraph?.configDependencies??[])g.add(d);if(r&&a.runtimeConfig)await _n(e,c,a.runtimeConfig);if(r)Jc(e),e.__stx_scope_seq??={n:0,key:Ks(String(e.__filename??c))},e.__stx_head_injections=Ii(),e.__stx_seo_staged=!1;if(!e.__stxProcessingDepth)e.__stxProcessingDepth=0;if(e.__stxProcessingDepth++,!e.__onceStore)e.__onceStore=new Set;if((a.debug||!T()&&!$n())&&c&&c.endsWith(".stx"))Fo(n,c);try{return await ae.timeAsync("template-processing",async()=>{let d=await rs(n,e,c,a,g);if(r)d=wi(d);if(r&&a.autoShell&&a.buildMode!=="compile"){let y=Ce(a.app?.head,{known:Dr,source:"app.head"}),x=(e.__stx_runtime_head||null)??Ni(),w=(e.__stx_head_raw||"").trim(),v,k=w.match(/<title[^>]*>([\s\S]*?)<\/title>/i);if(k)v=k[1].trim(),w=w.replace(k[0],"").trim();let S=e.__sections?.title,M=S?E(S,e,c):void 0,A=x.title||v||M,R=!x.title&&(!!v||!!M),D=x.meta||[],j=new Set(D.map((V)=>ct(V)).filter(Boolean)),N={...y,...A&&{title:A},meta:[...(y.meta||[]).filter((V)=>!j.has(ct(V))),...D],link:[...y.link||[],...x.link||[]],script:[...y.script||[],...x.script||[]],headRaw:[y.headRaw,w].filter(Boolean).join(`
|
|
1302
|
+
`),...x.htmlAttrs&&{htmlAttrs:fl(y.htmlAttrs,x.htmlAttrs)},...x.bodyAttrs&&{bodyAttrs:{...y.bodyAttrs||{},...x.bodyAttrs}}},F=Oi(d);if(d=Nr(d,N,{...R&&{titleIsHtml:!0},...a.app?.colorMode&&{colorMode:a.app.colorMode}},F),F)d=ml(d,y),d=Or(d,N.htmlAttrs);let I=d.match(/<!-- stx-layout: ([^ ]+) -->/);if(I&&d.includes("<head")){let V=I[1],X=Ns(V);d=d.replace(/<head\b[^>]*>/i,(ee)=>`${ee}
|
|
1303
|
+
<meta name="stx-layout" content="${ur(V)}">
|
|
1304
|
+
<meta name="stx-layout-group" content="${ur(X)}">`)}let L=d.match(/function (__stx_setup_\w+)\(/),H=L?B(d):null;if(L&&H&&!/\bdata-stx=/.test(H.tag)){d=Ze(d,(X,ee)=>`<body${ee} data-stx="${L[1]}">`);let V=new RegExp(`(<(?!body)[a-zA-Z][^>]*) data-stx="${L[1]}"`,"i");d=d.replace(V,"$1")}}if(r){let y=e.__stx_head_injections??Ii(),m=gl(d);if(m!==null)y.beforeClose.push(m);let x=rr(d);if(x!==null)y.afterOpen.push(x);if(a.offline?.enabled&&!d.includes("data-stx-offline"))y.beforeClose.push(nr);d=dl(d,y);let w=a.app?.colorMode;if(w)d=Ir(d,w)}if(r)if(Sr(d,"data-stx-runtime")){let m=await Jn(d,a,g,e);d=es(d,m.map((x)=>`
|
|
1305
1305
|
${x}`).join(""))}else{let m=await or([d],a,g);if(m){let x=d.search(/<script\b[^>]*>(?:(?!<\/script>)[\s\S])*?__stxModules\[/i);if(x!==-1)d=d.slice(0,x)+m+`
|
|
1306
|
-
`+d.slice(x)}}if(
|
|
1306
|
+
`+d.slice(x)}}if(r)d=pl(d);if(r&&e.__stx_inject_css!==!1)d=await b(d,void 0,a.buildMode==="serve",!0);else if(r)d=hn(d);if(r)d=dt(d);if(d=d.replace(/\x00STX_ESCAPED_AT\x00/g,"@"),d=ts(d),r&&e.__stx_runtime_config)d=jt(d,e.__stx_runtime_config);if(r&&!e.__stx_defer_server_data){let y=$r(e);if(y){let m=/<head\b[^>]*>/i.exec(d),x=m?m.index+m[0].length:0;d=d.slice(0,x)+y+d.slice(x)}}return d})}catch(d){if(d instanceof K)throw d;let y=d instanceof Error?d.message:String(d),m=new ce(`Template processing failed: ${y}`,c,void 0,void 0,n.substring(0,200)+(n.length>200?"...":""));if(z.log(m,{filePath:c,context:e}),En.logDetailedError(m,{filePath:c,template:n.substring(0,500)}),T()&&!a.debug)console.error(`[stx] ${ie.relative(process.cwd(),c)||c}: ${m.message}`);if(a.debug)throw m;return Ai.createFallbackContent("Template Processing",m)}}async function rs(n,e,c,a,g){let r=process.cwd(),d={...a,partialsDir:a.partialsDir&&!ie.isAbsolute(a.partialsDir)?ie.resolve(r,a.partialsDir):a.partialsDir,componentsDir:a.componentsDir&&!ie.isAbsolute(a.componentsDir)?ie.resolve(r,a.componentsDir):a.componentsDir,layoutsDir:a.layoutsDir&&!ie.isAbsolute(a.layoutsDir)?ie.resolve(r,a.layoutsDir):a.layoutsDir},y=d,m=n;await is(c,e),ss(e,y),m=await _e(()=>Xt(m,e,c,y),m,(I)=>{z.log(I,{filePath:c,phase:"pre-processing-middleware"},"warning"),console.warn(`[stx] pre-processing middleware failed for ${c}: ${I.message}`)}),m=m.replace(/\{\{--[\s\S]*?--\}\}/g,"");let x=fe(m,Me,(I,L)=>`\x00STX_HTML_COMMENT_${L}\x00`);m=x.output;let w=x.tokens,v=(I)=>w.length===0?I:I.replace(/\x00STX_HTML_COMMENT_(\d+)\x00/g,(L,H)=>w[Number(H)]??""),k="\x00STX_ESCAPED_AT\x00",S="\x00STX_ESC_MUSTACHE_OPEN\x00",M="\x00STX_ESC_MUSTACHE_CLOSE\x00";m=m.replace(/@@/g,k),m=m.replace(/@\{\{([\s\S]*?)\}\}/g,(I,L)=>`${S}${L}${M}`),m=Jt(m),m=await cr(m,c,g);let A={};m=ds(m,A);let R={...e.__sections||{}},D="",j=yt(wt(n)),N=/@nolayout\b/.test(m)||j===!1;if(/@nolayout\b/.test(m))m=m.replace(/@nolayout\b\s*/g,"");let F=m.match(/@(?:layout|extends)\(\s*['"]([^'"]+)['"]\s*\)/);if(F)D=F[1],m=m.replace(/@(?:layout|extends)\(\s*['"]([^'"]+)['"]\s*\)/g,"");else if(typeof j==="string"){if(D=j,!/@section\s*\(/.test(m))m=`@section('content')
|
|
1307
1307
|
${m.trim()}
|
|
1308
|
-
@endsection`}if(!D&&!N&&y.defaultLayout){let I=Tn(m),L=/@section\s*\(/.test(m);if(!I||L){let H="",V=ie.dirname(c),X=y.layoutsDir?ie.dirname(y.layoutsDir):process.cwd();for(let ee=0;ee<20;ee++){let te=ie.join(V,"_layout.stx");if(await
|
|
1308
|
+
@endsection`}if(!D&&!N&&y.defaultLayout){let I=Tn(m),L=/@section\s*\(/.test(m);if(!I||L){let H="",V=ie.dirname(c),X=y.layoutsDir?ie.dirname(y.layoutsDir):process.cwd();for(let ee=0;ee<20;ee++){let te=ie.join(V,"_layout.stx");if(await s(te)){H=te;break}let re=ie.dirname(V);if(re===V||re.length<X.length)break;V=re}if(H)D=H;else if(y.layoutsDir){let ee=ie.isAbsolute(y.layoutsDir)?y.layoutsDir:ie.resolve(process.cwd(),y.layoutsDir),te=ie.join(ee,`${y.defaultLayout}.stx`);if(await s(te))D=te}if(D&&!L)m=`@section('content')
|
|
1309
1309
|
${m.trim()}
|
|
1310
|
-
@endsection`}}if(D&&m.includes("<script")){let I=J(m),L=I.scripts.map((H)=>
|
|
1310
|
+
@endsection`}}if(D&&m.includes("<script")){let I=J(m),L=I.scripts.map((H)=>hr(H,c)??H);m=kr(I.output,L)}if(m=m.replace(/@section\(\s*['"]([^'"]+)['"]\s*,\s*['"]([^'"]+)['"]\s*\)/g,(I,L,H)=>(R[L]=H,"")),m=m.replace(/@section\(\s*['"]([^'"]+)['"]\s*,\s*([^)]+?)\s*\)/g,(I,L,H)=>{if(/^(['"]).*\1$/.test(H.trim()))return I;try{let V=u(H.trim(),e);if(V===void 0)return I;let ee=(e.__stx_inline_section_values??=[]).push(V)-1;return R[L]=`{{ __stx_inline_section_values[${ee}] }}`,""}catch{return I}}),m=m.replace(/@section\(\s*['"]([^'"]+)['"]\s*\)([\s\S]*?)(?:@endsection|@show)/g,(I,L,H)=>{if(H.includes("@parent"))R[L]=H.replace("@parent",Ee);else R[L]=H.trim();return""}),e.__sections=R,m=m.replace(/@(?:yield|slot)\(\s*['"]([^'"]+)['"](?:,\s*['"]([^'"]+)['"])?\)/g,(I,L,H)=>R[L]||H||""),!("slot"in e)||e.slot===void 0)m=m.replace(/\{\{\s*slot\s*\}\}/g,()=>R.content||"");if(m=ps(m,A),D){let I=[],L=J(m),H=fe(L.output,mn,(V,X)=>`\x00STX_ORPHAN_STYLE_${X}\x00`);if(m=H.output.replace(/\x00STX_(SCRIPT|ORPHAN_STYLE)_(\d+)\x00/g,(V,X,ee)=>{let te=X==="SCRIPT"?hr(L.scripts[Number(ee)],c):H.tokens[Number(ee)];if(te)I.push(te);return""}),I.length>0){let V=I.join(`
|
|
1311
1311
|
`);R.content=R.content?`${R.content}
|
|
1312
|
-
${V}`:V,e.__sections=R}}if(D)try{let I;if(ie.isAbsolute(D))I=D,g.add(D);else I=await _e(()=>xn(D,c,d,g),null,()=>{throw new ce(`Failed to resolve layout path: ${D}`,c,void 0,void 0,`Layout referenced from ${c}`)});if(!I){let te=(G)=>{if(!G)return[];try{let me=ie.isAbsolute(G)?G:ie.resolve(process.cwd(),G);return Kn.readdirSync(me).filter((ve)=>ve.endsWith(".stx")).map((ve)=>ve.replace(/\.stx$/,""))}catch{return[]}},re=[...te(d.layoutsDir),...te(d.fallbackLayoutsDir)].filter((G,me,ve)=>ve.indexOf(G)===me).sort(),le=[d.layoutsDir,d.fallbackLayoutsDir].filter((G)=>typeof G==="string"&&G.length>0),de=le.length>0?` Searched: ${le.join(", ")} (set \`layoutsDir\` to look elsewhere).`:"",se=`Layout not found: ${D} (referenced from ${c})`+(re.length>0?`. Available layouts: ${re.join(", ")}`:d.layoutsDir?`. No .stx layouts found in ${d.layoutsDir}`:"")+de;if(z.log(Error(se),{layoutPath:D,filePath:c,available:re},"error"),console.error(`[stx] ${se}`),d.debug)throw new ce(se,c);return m}let L=await _e(()=>Bun.file(I).text(),"",()=>{throw new ce(`Failed to read layout file: ${I}`,c,void 0,void 0,"Layout content could not be loaded")});L=
|
|
1313
|
-
${m}`,v(m)}catch(I){if(I instanceof K)throw I;throw new ce(`Error processing layout ${D}: ${I instanceof Error?I.message:String(I)}`,c)}return v(await
|
|
1314
|
-
`;if(
|
|
1312
|
+
${V}`:V,e.__sections=R}}if(D)try{let I;if(ie.isAbsolute(D))I=D,g.add(D);else I=await _e(()=>xn(D,c,d,g),null,()=>{throw new ce(`Failed to resolve layout path: ${D}`,c,void 0,void 0,`Layout referenced from ${c}`)});if(!I){let te=(G)=>{if(!G)return[];try{let me=ie.isAbsolute(G)?G:ie.resolve(process.cwd(),G);return Kn.readdirSync(me).filter((ve)=>ve.endsWith(".stx")).map((ve)=>ve.replace(/\.stx$/,""))}catch{return[]}},re=[...te(d.layoutsDir),...te(d.fallbackLayoutsDir)].filter((G,me,ve)=>ve.indexOf(G)===me).sort(),le=[d.layoutsDir,d.fallbackLayoutsDir].filter((G)=>typeof G==="string"&&G.length>0),de=le.length>0?` Searched: ${le.join(", ")} (set \`layoutsDir\` to look elsewhere).`:"",se=`Layout not found: ${D} (referenced from ${c})`+(re.length>0?`. Available layouts: ${re.join(", ")}`:d.layoutsDir?`. No .stx layouts found in ${d.layoutsDir}`:"")+de;if(z.log(Error(se),{layoutPath:D,filePath:c,available:re},"error"),console.error(`[stx] ${se}`),d.debug)throw new ce(se,c);return m}let L=await _e(()=>Bun.file(I).text(),"",()=>{throw new ce(`Failed to read layout file: ${I}`,c,void 0,void 0,"Layout content could not be loaded")});L=lr(L,I);let H=L.match(/@(?:layout|extends)\(\s*['"]([^'"]+)['"]\s*\)/);if(H){if(d.debug)console.log(`Found nested layout: ${H[1]} in ${I}`);let te={},re=L.replace(/@section\(\s*['"]([^'"]+)['"]\s*\)([\s\S]*?)(?:@show|@endsection)/g,(se,G,me)=>(te[G]=me.trim(),""));for(let[se,G]of Object.entries(te))if(R[se]&&R[se].includes(Ee)){let me=R[se].indexOf(Ee);R[se]=R[se].slice(0,me)+G+R[se].slice(me+Ee.length)}else if(!R[se])R[se]=G;let le={...e,__sections:R},de=`@layout('${H[1]}')${re}`;return await i(de,le,I,d,g)}let V=L.replace(/\{\{--[\s\S]*?--\}\}/g,""),X=ds(V,A),ee={};return X=X.replace(/@section\(\s*['"]([^'"]+)['"]\s*\)([\s\S]*?)(?:@show|@endsection)/g,(te,re,le)=>(ee[re]=le.trim(),`@slot('${re}')`)),X=X.replace(/@(?:yield|slot)\(\s*['"]([^'"]+)['"]\s*(?:,\s*['"]([^'"]+)['"]\s*)?\)/g,(te,re,le)=>{if(R[re]){let de=R[re];if(de.includes(Ee)){let se=ee[re]||"",G=de.indexOf(Ee);de=de.slice(0,G)+se+de.slice(G+Ee.length)}return de}return le||""}),X=ns(X,R),X=X.replace(/\{\{\s*slot\s*\}\}/g,()=>R.content||""),X=ps(X,A),e.__originalFilePath=c,m=await vr(X,e,I,d,g),m=`<!-- stx-layout: ${D} -->
|
|
1313
|
+
${m}`,v(m)}catch(I){if(I instanceof K)throw I;throw new ce(`Error processing layout ${D}: ${I instanceof Error?I.message:String(I)}`,c)}return v(await vr(m,e,c,d,g))}function ns(n,e){return n.replace(/@(?:yield|slot)\(\s*['"]([^'"]+)['"]\s*(?:,\s*['"]([^'"]+)['"]\s*)?\)/g,(c,a,g)=>{let r=e[a];if(r!==void 0){if(!new RegExp(`@(?:yield|slot)\\(\\s*['"]${a.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}['"]`).test(r))return r}return g||""})}function ss(n,e){if(n.__stx_sfc_mode=!0,n.__stx_options=e,e.buildMode)n.__stx_buildMode=e.buildMode;let c=e.envPrefix||"STX_PUBLIC_",a={};for(let[g,r]of Object.entries(process.env))if(g.startsWith(c)&&r!==void 0)a[g]=r;n.$env=a}async function is(n,e){await _e(()=>Gt(n,e),void 0,(c)=>{z.log(c,{filePath:n,phase:"view-composer"},"warning"),console.warn(`[stx] view composer failed for ${n}: ${c.message}`)})}var at="data-stx-source";function hr(n,e){if(!n)return n;let c=/^<script\b([^>]*)>/i.exec(n);if(!c||!/\bserver\b/.test(c[1])||c[1].includes(at))return n;return`<script ${at}="${encodeURIComponent(e)}"${n.slice(7)}`}function os(n){let e=new RegExp(`${at}="([^"]*)"`).exec(n);return e?decodeURIComponent(e[1]):void 0}function yr(n){return n.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function wr(n,e,c){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> ${e==="module-resolution"?"imports a module that does not resolve":e==="syntax"?"does not parse":"names something that does not exist"}, so this component rendered nothing.</strong><span style="display:block;opacity:.85">${yr(n)}</span><span style="display:block;margin-top:4px">${yr(c)}</span></div>`}async function as(n,e,c,a){let{scanScriptTags:g}=await o("stx/signal-processing",()=>import("./chunk-5m4txcry.js")),r=[],d=!T()&&!$n();for(let m of g(n)){let x=m.attrs;if(!/\bserver\b/.test(x))continue;let w=m.start+m.fullMatch.indexOf(">")+1,v=xr(n,w);if(v===-1)continue;let k=n.slice(w,v);if(!k.trim())continue;let S=os(x)??c,M={index:m.start,length:v+9-m.start};try{let{extractVariables:A}=await o("stx/variable-extractor",()=>import("./chunk-nq2z2yrz.js"));await A(k,e,S,{preserveExisting:!0,onFailure:(R)=>{if(R.kind==="unknown")return;if(a?.onServerScriptError?.({sourcePath:S,kind:R.kind,message:R.message}),!d)return;r.push({...M,markup:wr(S,R.kind,R.message)})}})}catch(A){let R=A instanceof Error?A:Error(String(A));if(z.log(R,{filePath:S,phase:"server-script-extraction"},"warning"),console.warn(`[stx] server <script> extraction failed in ${S}: ${R.message}`),d)r.push({...M,markup:wr(S,"unknown",R.message)})}}if(r.length===0)return n;let y=n;for(let m of r.sort((x,w)=>w.index-x.index))y=y.slice(0,m.index)+m.markup+y.slice(m.index+m.length);return y}async function cs(n,e,c){try{let{interpolateScriptsInTemplate:a}=await o("stx/expressions",()=>import("./chunk-d4kystzh.js"));return a(n,e,{skipServer:!0})}catch(a){let g=a instanceof Error?a:Error(String(a));return z.log(g,{filePath:c,phase:"script-expression-interpolation"},"warning"),console.warn(`[stx] script expression interpolation failed in ${c}: ${g.message}`),n}}async function vr(n,e,c,a,g){let r=n;await _();let d=a;if(r=await as(r,e,c,a),r=await Ft(r,e,c),r=await Ut(r,e,c),r=await cs(r,e,c),await _(),r=await Ct(r,e,c,d),ke(r))r=Xo(r,e),r=vs(r,e),r=ws(r,e);r=Jo(r),await _();let{processStreamDirectives:y}=await o("stx/streaming",()=>import("./chunk-sznk5c66.js"));r=y(r,e),r=await Uo(r,e,c,d,!0),await _(),r=await tr(r,e,c,d,g),r=await ms(r,e,c,d,g),await _(),r=wc(r,e,c,d);let{processDeferDirectives:m}=await o("stx/defer",()=>import("./chunk-h7rcb74n.js"));r=m(r,e,c);let{processTeleportDirectives:x}=await o("stx/teleport",()=>import("./chunk-acbx3jn5.js"));r=x(r,e,c);let{processTransitionDirectives:w,processTransitionAttributes:v}=await o("stx/transitions",()=>import("./chunk-1qdhwjs4.js"));r=w(r,e,c),r=v(r);let{processErrorBoundaryDirectives:k,stripRenderFailedMarkers:S}=await o("stx/error-boundaries",()=>import("./chunk-h85hrwkq.js"));r=k(r,e,c),r=S(r);let{processSuspenseDirectives:M}=await o("stx/suspense",()=>import("./chunk-3w9xhs7k.js"));r=M(r,e,c);let{processAsyncDirectives:A}=await o("stx/async-components",()=>import("./chunk-yx37mvy7.js"));r=A(r,e,c);let{processKeepAliveDirectives:R}=await o("stx/keep-alive",()=>import("./chunk-4e6wkjtx.js"));r=R(r,e,c);let{processVirtualListDirectives:D,processVirtualGridDirectives:j,processInfiniteListDirectives:N}=await o("stx/virtual-scrolling",()=>import("./chunk-znfzh6fm.js"));r=D(r,e,c),r=j(r,e,c),r=N(r,e,c),await _();let{processPartialHydrationDirectives:F,processStaticDirectives:I}=await o("stx/partial-hydration",()=>import("./chunk-67bn31a3.js"));r=F(r,e,c),r=I(r);let{processComputedDirectives:L,processWatchDirectives:H}=await o("stx/computed",()=>import("./chunk-1xdzcy9d.js"));r=L(r,e,c),r=H(r,e,c);let{processFormValidationDirectives:V}=await o("stx/forms-validation",()=>import("./chunk-5p6vpvmz.js"));r=V(r,e,c);let{processHeadDirective:X,processTitleDirective:ee,processMetaDirective:te,resetHead:re}=await o("stx/head",()=>import("./chunk-3gyq9rjx.js"));if(!e.__stx_head_preset&&!e.__stx_runtime_head)re();let le=X(r);if(r=le.content,le.headContent)e.__stx_head_raw=`${e.__stx_head_raw||""}${le.headContent}
|
|
1314
|
+
`;if(r=ee(r,e),r=te(r,e,c),r=Kt(r),r=Wo(r,e),r=_t(r),r=Vt(r),r=await us(r,e,c,d,g),r=await ms(r,e,c,d,g),await _(),r=r.replace(/@push\s*\(\s*['"][^'"]+['"]\s*\)[\s\S]*?@endpush/g,""),r=wi(r),r=oe(r,e,c),r=hs(r),await _(),e.__stxProcessingDepth===1)r=Yc(r,e);if(r=Wc(r,e,{filePath:c,buildMode:d.buildMode}),r=qo(r,e),r=Ko(r,e),r=We(r,e),r=Pt(r,e),r=Nt(r,e),r=await bt(r,e,c,d),r=await xc(r,e,c),r=await Sc(r,e,c,d),await _(),r=kc(r,e,c,d),r=ri(r,e,c,d),r=si(r,e,c),r=oi(r,e,c,d),r=Et(r,e,c,d),r=Ws(r,e),r=qs(r),r=Kc(r),!d.skipEventDirectives)r=Mc(r,e,c);if(r=qc(r,e,c,a.skipSignalsRuntime===!0&&Number(e.__stxProcessingDepth)>0),await _(),d.debug){let U=/\bx-data\s*=/.test(r),q=bs(n);if(U&&q)console.warn(`[stx] ${c}: Template mixes Alpine-style (x-data) and signals (state/derived/effect) reactivity.
|
|
1315
1315
|
Both work on the same page, but they manage separate scopes.
|
|
1316
|
-
Prefer signals (state/derived/effect) for new components.`)}
|
|
1316
|
+
Prefer signals (state/derived/effect) for new components.`)}r=gc(r,e),r=await Ei(r,e,c),await _(),r=Gc(r),r=Xc(r),r=mt(r);let{processXElementDirectives:de}=await o("stx/x-element",()=>import("./chunk-zhxdpzga.js"));r=de(r);let se=e.__originalFilePath||c,G=Le(e);if(r=await Yo(r,d,se,G),await _(),r=Dt(r,e),r=await zt(r,e,c,d),await _(),d.media?.image?.autoSiblings){let U=d.publicDir||"public",{rewriteImagesWithSiblings:q}=await o("stx/image-optimization/auto-sibling",()=>import("./chunk-j3x3e353.js"));r=await q(r,{publicDir:U})}if(d.seo?.enabled)r=ii(r,e,d);let me=(U,q,Z=!0)=>{if(!q)return U;let he=q.match(/<title\b[^>]*>[\s\S]*?<\/title>/i),ne=/<head\b[^>]*>[\s\S]*?(?:<\/head\s*>|<body\b|$)/i.exec(U),pe=ne?/<title\b[^>]*>[\s\S]*?<\/title>/i.exec(ne[0]):null;if(he&&ne&&pe){if(Z){let Te=ne.index+pe.index;U=U.slice(0,Te)+he[0]+U.slice(Te+pe[0].length)}if(q=q.replace(he[0],"").trim(),!q)return U}if(/<\/head>/i.test(U))return U.replace(/<\/head>/i,`${q}
|
|
1317
1317
|
</head>`);if(/<head\b[^>]*>/i.test(U))return U.replace(/(<head\b[^>]*>)/i,`$1
|
|
1318
1318
|
${q}`);if(/<html\b[^>]*>/i.test(U))return U.replace(/(<html\b[^>]*>)/i,`$1
|
|
1319
1319
|
<head>
|
|
1320
1320
|
${q}
|
|
1321
|
-
</head>`);return U},{renderHead:ve,getHead:
|
|
1321
|
+
</head>`);return U},{renderHead:ve,getHead:Er}=await o("stx/head",()=>import("./chunk-3gyq9rjx.js")),Oe=e.__stx_runtime_head??Er();if(Oe.title||Oe.meta?.length||Oe.link?.length){let U=ve(Oe);if(U)r=me(r,U)}if(le.headContent)r=me(r,le.headContent,!Oe.title);if(d.csp?.enabled&&d.csp.addMetaTag)r=St(r,d.csp,e);if(d.analytics?.enabled)r=ht(r,d);if(d.heatmap?.enabled)r=vc(r,d);if(d.pwa?.enabled&&d.pwa.autoInject!==!1){let{injectPwaTags:U}=await o("stx/pwa/inject",()=>import("./chunk-c90qz5w0.js"));r=U(r,d)}let Tr=/<script\b(?![^>]*\bserver\b)[^>]*>[\s\S]*?<\/script>/i.test(r),_r=/\bSTX\.\w+/.test(r),Cr=/window\.STX\s*=/.test(r);if(Tr&&_r&&!Cr){let q=`<script data-stx-scoped data-stx-run="once">
|
|
1322
1322
|
${pt()}
|
|
1323
|
-
</script>`;if(
|
|
1324
|
-
`+Te}else
|
|
1325
|
-
</head>`)}else if(
|
|
1326
|
-
${q}`);else
|
|
1327
|
-
`+
|
|
1328
|
-
`+
|
|
1329
|
-
export{
|
|
1323
|
+
</script>`;if(r.includes("</head>")){let Z=r.indexOf("</head>"),ne=r.slice(0,Z).indexOf("<script");if(ne!==-1){let pe=r.slice(0,ne),Te=r.slice(ne);r=pe+q+`
|
|
1324
|
+
`+Te}else r=r.replace("</head>",`${q}
|
|
1325
|
+
</head>`)}else if(r.includes("<body"))r=r.replace(/<body([^>]*)>/,`<body$1>
|
|
1326
|
+
${q}`);else r=q+`
|
|
1327
|
+
`+r}{let{scanScriptTags:U}=await o("stx/signal-processing",()=>import("./chunk-5m4txcry.js")),q=[];for(let Z of U(r)){if(!/\bserver\b/i.test(Z.attrs))continue;let he=Z.start+Z.fullMatch.indexOf(">")+1,ne=xr(r,he);if(ne===-1)continue;let pe=ne+9;while(pe<r.length&&/\s/.test(r[pe]))pe++;q.push({start:Z.start,end:pe})}if(q.length>0){let Z=Array(q.length+1),he=0;for(let ne=0;ne<q.length;ne++){let{start:pe,end:Te}=q[ne];Z[ne]=r.slice(he,pe),he=Te}Z[q.length]=r.slice(he),r=Z.join("")}}let lt=Vs(r,c);if(lt.hasScoped)r=lt.html;let Ar=e.__stx_event_bindings||[],Ke=!1,ut=[],Rr=/\s:[a-z][\w.-]*\s*=/.test(r),{scanScriptTags:Mr}=await o("stx/signal-processing",()=>import("./chunk-5m4txcry.js"));for(let U of Mr(r,{skipAttrs:/\bserver\b|\bsrc\s*=|\bdata-stx-scoped\b|\bdata-stx-router\b|\btype\s*=\s*["'](?!(?:text\/javascript|application\/javascript|module)["'])[^"']*["']/}))ut.push({match:U.fullMatch,attrs:U.attrs,content:U.body});for(let{match:U,attrs:q,content:Z}of ut){Ke=!0;let he=Z;Ne(Z,c,a.strict,e.__originalFilePath);let ne=await je(Z,{eventBindings:Ar,attrs:q,hasColonDirectives:Rr,templateContent:n,filePath:c,projectRoot:process.cwd(),production:Mi(a.buildMode,a.minifyClient),serverData:G});r=r.replace(U,()=>ne)}if(Ke)e.__stx_event_bindings=[];if(!Ke&&e.__stxProcessingDepth===1){let U=e.__stx_event_bindings||[];if(U.length>0){let q=pi(U);if(q){let Z=r.lastIndexOf("</body>");r=Z===-1?r+q:r.slice(0,Z)+q+`
|
|
1328
|
+
`+r.slice(Z)}e.__stx_event_bindings=[]}}if(!d.skipSignalsRuntime&&!we(r)&&hc(r))r=await pr(r,d);if(r=yc(r),d.csp?.enabled&&d.csp.useNonce&&typeof e.cspNonce==="string")r=$t(r,e.cspNonce);return r}
|
|
1329
|
+
export{wt,Ae,uc,ls,jo,Bo,or,i};
|