@stacksjs/stx 0.2.870 → 0.2.872

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.
Files changed (143) hide show
  1. package/dist/{chunk-6mjd3pqd.js → chunk-18a3vdnq.js} +3 -3
  2. package/dist/{chunk-cwmfxbhz.js → chunk-1c8j9zdp.js} +1 -1
  3. package/dist/{chunk-nkwj7eq3.js → chunk-1p9rb7rt.js} +1 -1
  4. package/dist/{chunk-9ffvh6cr.js → chunk-2jccw1km.js} +2 -2
  5. package/dist/chunk-2nd3h37q.js +2 -0
  6. package/dist/{chunk-81n2s24z.js → chunk-2yrd286h.js} +1 -1
  7. package/dist/chunk-3k5g4tbn.js +2 -0
  8. package/dist/chunk-3qewdhvh.js +2 -0
  9. package/dist/{chunk-tjwzy9xq.js → chunk-40h07m5w.js} +1 -1
  10. package/dist/{chunk-tv61s6fc.js → chunk-4ay62hs9.js} +1 -1
  11. package/dist/chunk-4es07dwb.js +2 -0
  12. package/dist/{chunk-zbvfjm4a.js → chunk-4nb7egk0.js} +2 -2
  13. package/dist/{chunk-q58f5wk2.js → chunk-4p51hk75.js} +5 -5
  14. package/dist/{chunk-m4k6ndf5.js → chunk-4v70bs2q.js} +1 -1
  15. package/dist/{chunk-6ggme8xx.js → chunk-5nj2k8zf.js} +1 -1
  16. package/dist/{chunk-sbvkk4cn.js → chunk-6mkn81pd.js} +2 -2
  17. package/dist/{chunk-sb3dx4dd.js → chunk-6s7q8kw3.js} +2 -2
  18. package/dist/chunk-71hjqg16.js +177 -0
  19. package/dist/{chunk-3ryp43f3.js → chunk-73k579v7.js} +1 -1
  20. package/dist/{chunk-3f51tn2b.js → chunk-7cvbz4eq.js} +2 -2
  21. package/dist/{chunk-4vtw6f0c.js → chunk-7j0qkye5.js} +2 -2
  22. package/dist/chunk-7mqnbn1x.js +2 -0
  23. package/dist/chunk-7q3ar8ay.js +2 -0
  24. package/dist/chunk-808fbm83.js +2 -0
  25. package/dist/chunk-832m6nwr.js +2051 -0
  26. package/dist/{chunk-1mqcttg3.js → chunk-8tk8yf91.js} +2 -2
  27. package/dist/{chunk-wb7s2cnb.js → chunk-9bnggqhj.js} +8 -8
  28. package/dist/{chunk-t5ekex4s.js → chunk-9c07p1vq.js} +4 -4
  29. package/dist/{chunk-rpep1ve3.js → chunk-9fyw1xkh.js} +2 -2
  30. package/dist/{chunk-311mrz2n.js → chunk-a8164hnf.js} +1 -1
  31. package/dist/chunk-asrzmw7w.js +2 -0
  32. package/dist/{chunk-pfr3cazq.js → chunk-av2vknrs.js} +2 -2
  33. package/dist/chunk-b2kkezey.js +2 -0
  34. package/dist/{chunk-dg4zxpbq.js → chunk-b8vs32dw.js} +3 -3
  35. package/dist/{chunk-y1cvab1b.js → chunk-ba86dkhs.js} +1 -1
  36. package/dist/{chunk-d9k8j44b.js → chunk-bbq79tap.js} +6 -6
  37. package/dist/chunk-bfvr4byj.js +21 -0
  38. package/dist/{chunk-gesktj4m.js → chunk-bmbqr2br.js} +1 -1
  39. package/dist/chunk-bqs9wyje.js +2 -0
  40. package/dist/chunk-c63027nw.js +2 -0
  41. package/dist/{chunk-0tyyad6q.js → chunk-csymxc5a.js} +8 -8
  42. package/dist/chunk-cv9vmz5x.js +2 -0
  43. package/dist/{chunk-6ksyrmpp.js → chunk-d0h18m2r.js} +1 -1
  44. package/dist/{chunk-sb8n32rn.js → chunk-dhbpbjt3.js} +1 -1
  45. package/dist/{chunk-3v7xht2q.js → chunk-dv1edvz8.js} +1 -1
  46. package/dist/{chunk-1dt8e7ew.js → chunk-e2t7mk29.js} +2 -2
  47. package/dist/{chunk-4t5t33yj.js → chunk-e549f7a9.js} +2 -2
  48. package/dist/{chunk-adqh1gp1.js → chunk-e7s109j6.js} +1 -1
  49. package/dist/chunk-eczy00w6.js +2 -0
  50. package/dist/{chunk-h0nxd9xg.js → chunk-f5gg0pxj.js} +1 -1
  51. package/dist/chunk-gc4bgven.js +2 -0
  52. package/dist/{chunk-7chzhef2.js → chunk-gvz0kqkz.js} +1 -1
  53. package/dist/{chunk-5d0csn7w.js → chunk-hcaedzck.js} +1 -1
  54. package/dist/{chunk-drdr0a53.js → chunk-hd4vn78w.js} +1 -1
  55. package/dist/{chunk-dy7vqv1x.js → chunk-hhbt8grm.js} +2 -2
  56. package/dist/{chunk-gcsy3z1e.js → chunk-j89p53vx.js} +3 -3
  57. package/dist/{chunk-y0msz738.js → chunk-jcr69v95.js} +4 -4
  58. package/dist/{chunk-rt55f47q.js → chunk-jf3n1f32.js} +3 -3
  59. package/dist/chunk-jkevn2jy.js +2 -0
  60. package/dist/{chunk-xr3x6wk6.js → chunk-jnj9s2yw.js} +1 -1
  61. package/dist/{chunk-dwqjrbse.js → chunk-jpgc0j8x.js} +2 -2
  62. package/dist/{chunk-mwxehpse.js → chunk-kkevjppm.js} +2 -2
  63. package/dist/{chunk-z8x86cr7.js → chunk-kx6y1cqw.js} +5 -5
  64. package/dist/{chunk-cbpxd3qa.js → chunk-kzhget9h.js} +1 -1
  65. package/dist/{chunk-mnx6njd4.js → chunk-m131znxe.js} +6 -6
  66. package/dist/chunk-me7cxs0e.js +2 -0
  67. package/dist/{chunk-w1rrfj39.js → chunk-mm00bb1p.js} +1 -1
  68. package/dist/{chunk-fcvgf88g.js → chunk-my6tp8rn.js} +1 -1
  69. package/dist/chunk-p2kqsb5k.js +2 -0
  70. package/dist/chunk-pc8jnkb3.js +2 -0
  71. package/dist/{chunk-zpgj4asv.js → chunk-pj1znb6y.js} +1 -1
  72. package/dist/{chunk-hze3158c.js → chunk-pnqdwqw9.js} +56 -56
  73. package/dist/{chunk-79y9amt1.js → chunk-pywz8q4k.js} +5 -5
  74. package/dist/{chunk-k7m8659h.js → chunk-q50x1gfd.js} +2 -2
  75. package/dist/{chunk-1637r8fg.js → chunk-q8d0wf0w.js} +1 -1
  76. package/dist/{chunk-qmr5xsjj.js → chunk-qk1fkfvj.js} +1 -1
  77. package/dist/{chunk-7wae4311.js → chunk-qt4dha3g.js} +4 -4
  78. package/dist/{chunk-n7w8n327.js → chunk-qvxtq5vb.js} +1 -1
  79. package/dist/{chunk-7d6jq5j8.js → chunk-rvbw12e1.js} +2 -2
  80. package/dist/{chunk-vrcr4b13.js → chunk-s584xnzx.js} +1 -1
  81. package/dist/{chunk-pdpmtmfj.js → chunk-s70e5jbq.js} +10 -10
  82. package/dist/chunk-tahw02kf.js +2 -0
  83. package/dist/{chunk-zfq2vvex.js → chunk-tc36b3r4.js} +24 -24
  84. package/dist/{chunk-d4zcwtna.js → chunk-teahvty8.js} +1 -1
  85. package/dist/chunk-tfsf9pes.js +2 -0
  86. package/dist/chunk-thyxsg54.js +2 -0
  87. package/dist/chunk-txjtd4gj.js +2 -0
  88. package/dist/{chunk-mrh08821.js → chunk-tyvm49be.js} +2 -2
  89. package/dist/{chunk-m1a3a32y.js → chunk-v4ab2jzz.js} +1 -1
  90. package/dist/{chunk-12sk3dtm.js → chunk-v99hgmsx.js} +1 -1
  91. package/dist/chunk-vf91b9b9.js +20 -0
  92. package/dist/chunk-vmq773pb.js +2 -0
  93. package/dist/{chunk-3asy7ev5.js → chunk-vv9anbw1.js} +1 -1
  94. package/dist/{chunk-hvx6j4a2.js → chunk-vvxcebpn.js} +2 -2
  95. package/dist/{chunk-5h9d6jew.js → chunk-wk2rge05.js} +3 -3
  96. package/dist/{chunk-wk188ph7.js → chunk-y48ykf1n.js} +4 -4
  97. package/dist/chunk-y69hhxn8.js +2 -0
  98. package/dist/{chunk-ca9x39p1.js → chunk-ycb07ppz.js} +1 -1
  99. package/dist/chunk-z0qxrx9r.js +3 -0
  100. package/dist/chunk-z2wfgva6.js +2 -0
  101. package/dist/{chunk-x7redxyd.js → chunk-z9xe3xkg.js} +2 -2
  102. package/dist/{chunk-stdddhk9.js → chunk-zfrzdje6.js} +2 -2
  103. package/dist/cli.js +14 -14
  104. package/dist/component-library.js +140 -36
  105. package/dist/craft-entry.js +1 -1
  106. package/dist/craft.js +1 -1
  107. package/dist/native/accessibility.d.ts +15 -0
  108. package/dist/native/accessibility.js +14 -4
  109. package/dist/native/compiler/html-to-ir.js +56 -1
  110. package/dist/pwa.js +3 -3
  111. package/dist/signal-processing.js +4 -1
  112. package/dist/ssg.js +5 -5
  113. package/package.json +5 -5
  114. package/dist/chunk-04f6r2kh.js +0 -2
  115. package/dist/chunk-0jchm9gg.js +0 -2
  116. package/dist/chunk-5sbtbfj3.js +0 -2
  117. package/dist/chunk-79sr2kxg.js +0 -2
  118. package/dist/chunk-8cf6995c.js +0 -2
  119. package/dist/chunk-8cgn4re9.js +0 -2
  120. package/dist/chunk-94e6kmjm.js +0 -2
  121. package/dist/chunk-aa6ztwdq.js +0 -2
  122. package/dist/chunk-bz1jgrx8.js +0 -2
  123. package/dist/chunk-eh1rdapx.js +0 -2
  124. package/dist/chunk-hb6r4pxp.js +0 -2
  125. package/dist/chunk-jksjr12b.js +0 -2
  126. package/dist/chunk-khe30jmk.js +0 -3
  127. package/dist/chunk-ndrgek64.js +0 -2
  128. package/dist/chunk-nxecjev1.js +0 -2
  129. package/dist/chunk-ps6m8n9n.js +0 -2
  130. package/dist/chunk-pxce4aag.js +0 -2
  131. package/dist/chunk-qm0qn2xa.js +0 -177
  132. package/dist/chunk-qxxvaxee.js +0 -2
  133. package/dist/chunk-rhhq8k9f.js +0 -2
  134. package/dist/chunk-s2a9vfdg.js +0 -2
  135. package/dist/chunk-sew1z7cv.js +0 -21
  136. package/dist/chunk-swzxhkh2.js +0 -2042
  137. package/dist/chunk-tg7kt56m.js +0 -2
  138. package/dist/chunk-ttr8ay8h.js +0 -2
  139. package/dist/chunk-w2hqjv5e.js +0 -2
  140. package/dist/chunk-xb34eyne.js +0 -2
  141. package/dist/chunk-y0dee635.js +0 -2
  142. package/dist/chunk-yx3vghee.js +0 -2
  143. package/dist/chunk-zf9n3esr.js +0 -20
@@ -1,6 +1,6 @@
1
1
  // @bun
2
- import o from"fs";import u from"path";var h={".html":"includeHtml",".htm":"includeHtml",".js":"includeJs",".mjs":"includeJs",".css":"includeCss",".png":"includeImages",".jpg":"includeImages",".jpeg":"includeImages",".gif":"includeImages",".webp":"includeImages",".svg":"includeImages",".ico":"includeImages",".woff":"includeFonts",".woff2":"includeFonts",".ttf":"includeFonts",".eot":"includeFonts",".otf":"includeFonts"};function p(e){let r=0;for(let t=0;t<e.length;t++){let n=e[t];r=(r<<5)-r+n,r=r&r}return Math.abs(r).toString(16).padStart(8,"0")}function x(e,r){let t=u.basename(e);for(let n of r)if(n.startsWith("*.")){let i=n.slice(1);if(t.endsWith(i))return!0}else if(n.includes("*")){let i=new RegExp(`^${n.replace(/\*/g,".*")}$`);if(i.test(t)||i.test(e))return!0}else if(t===n||e.includes(n))return!0;return!1}function S(e,r,t){let n=u.extname(e).toLowerCase(),i=h[n],c=(t.maxFileSizeKB||500)*1024;if(r>c)return!1;if(t.exclude&&x(e,t.exclude))return!1;if(t.include&&t.include.length>0){for(let s of t.include)if(s.startsWith("*.")){if(e.endsWith(s.slice(1)))return!0}else if(e.includes(s))return!0}if(i&&t[i]===!0)return!0;if(!i)return!1;return!1}function f(e,r,t,n){let i=o.readdirSync(e,{withFileTypes:!0});for(let c of i){let s=u.join(e,c.name);if(c.isDirectory()){if(["node_modules",".git",".stx"].includes(c.name))continue;f(s,r,t,n)}else if(c.isFile()){let a=o.statSync(s),l=u.relative(r,s);if(S(l,a.size,t)){let d=o.readFileSync(s),g=p(d),m=`/${l.replace(/\\/g,"/")}`;n.push({url:m,revision:g,size:a.size})}}}}function Xe(e,r){let t=r.pwa?.precache,n=[];if(!t?.enabled)return{entries:[],totalSize:0,fileCount:0};if(!o.existsSync(e))return{entries:[],totalSize:0,fileCount:0};f(e,e,t,n),n.sort((c,s)=>c.url.localeCompare(s.url));let i=n.reduce((c,s)=>c+s.size,0);return{entries:n,totalSize:i,fileCount:n.length}}function Nn(e){if(e.entries.length===0)return"[]";return`[
2
+ import o from"fs";import u from"path";var h={".html":"includeHtml",".htm":"includeHtml",".js":"includeJs",".mjs":"includeJs",".css":"includeCss",".png":"includeImages",".jpg":"includeImages",".jpeg":"includeImages",".gif":"includeImages",".webp":"includeImages",".svg":"includeImages",".ico":"includeImages",".woff":"includeFonts",".woff2":"includeFonts",".ttf":"includeFonts",".eot":"includeFonts",".otf":"includeFonts"};function p(e){let r=0;for(let t=0;t<e.length;t++){let n=e[t];r=(r<<5)-r+n,r=r&r}return Math.abs(r).toString(16).padStart(8,"0")}function x(e,r){let t=u.basename(e);for(let n of r)if(n.startsWith("*.")){let i=n.slice(1);if(t.endsWith(i))return!0}else if(n.includes("*")){let i=new RegExp(`^${n.replace(/\*/g,".*")}$`);if(i.test(t)||i.test(e))return!0}else if(t===n||e.includes(n))return!0;return!1}function S(e,r,t){let n=u.extname(e).toLowerCase(),i=h[n],c=(t.maxFileSizeKB||500)*1024;if(r>c)return!1;if(t.exclude&&x(e,t.exclude))return!1;if(t.include&&t.include.length>0){for(let s of t.include)if(s.startsWith("*.")){if(e.endsWith(s.slice(1)))return!0}else if(e.includes(s))return!0}if(i&&t[i]===!0)return!0;if(!i)return!1;return!1}function f(e,r,t,n){let i=o.readdirSync(e,{withFileTypes:!0});for(let c of i){let s=u.join(e,c.name);if(c.isDirectory()){if(["node_modules",".git",".stx"].includes(c.name))continue;f(s,r,t,n)}else if(c.isFile()){let a=o.statSync(s),l=u.relative(r,s);if(S(l,a.size,t)){let d=o.readFileSync(s),g=p(d),m=`/${l.replace(/\\/g,"/")}`;n.push({url:m,revision:g,size:a.size})}}}}function Ge(e,r){let t=r.pwa?.precache,n=[];if(!t?.enabled)return{entries:[],totalSize:0,fileCount:0};if(!o.existsSync(e))return{entries:[],totalSize:0,fileCount:0};f(e,e,t,n),n.sort((c,s)=>c.url.localeCompare(s.url));let i=n.reduce((c,s)=>c+s.size,0);return{entries:n,totalSize:i,fileCount:n.length}}function Nn(e){if(e.entries.length===0)return"[]";return`[
3
3
  ${e.entries.map((t)=>` { url: '${t.url}', revision: '${t.revision}' }`).join(`,
4
4
  `)}
5
5
  ]`}function Vi(e){if(e<1024)return`${e} B`;if(e<1048576)return`${(e/1024).toFixed(1)} KB`;return`${(e/1048576).toFixed(2)} MB`}
6
- export{Xe,Nn,Vi};
6
+ export{Ge,Nn,Vi};
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{eg,Qh,ey,ty,ny,tg,ng,ry,sy,ni,oy,hr,yr,Es}from"./chunk-nkwj7eq3.js";import{at}from"./chunk-n3jw3xpj.js";import"./chunk-hze3158c.js";import"./chunk-w1rrfj39.js";import"./chunk-60yppcbb.js";import"./chunk-0tyyad6q.js";import"./chunk-farh4p7f.js";import"./chunk-qjey0jk6.js";export{ny as __setSignalsGeneratorsForTest,at as cacheEngineFingerprint,yr as cacheTemplate,hr as checkCache,oy as clearDevCaches,ng as getCachedRouterScript,tg as getCachedSignalsRuntime,ry as getServeClientAsset,ni as getServeModuleBundle,Es as hashFilePath,ey as invalidateFileCache,ty as invalidateFileCacheByDir,Qh as readFileCached,sy as registerServeModuleBundle,eg as templateCache};
2
+ import{eg,Qh,ey,ty,ny,tg,ng,ry,sy,ni,oy,hr,yr,Es}from"./chunk-1p9rb7rt.js";import{at}from"./chunk-n3jw3xpj.js";import"./chunk-pnqdwqw9.js";import"./chunk-mm00bb1p.js";import"./chunk-60yppcbb.js";import"./chunk-csymxc5a.js";import"./chunk-farh4p7f.js";import"./chunk-qjey0jk6.js";export{ny as __setSignalsGeneratorsForTest,at as cacheEngineFingerprint,yr as cacheTemplate,hr as checkCache,oy as clearDevCaches,ng as getCachedRouterScript,tg as getCachedSignalsRuntime,ry as getServeClientAsset,ni as getServeModuleBundle,Es as hashFilePath,ey as invalidateFileCache,ty as invalidateFileCacheByDir,Qh as readFileCached,sy as registerServeModuleBundle,eg as templateCache};
@@ -1,3 +1,3 @@
1
1
  // @bun
2
- import{J,Be}from"./chunk-hze3158c.js";var o=/\b(?:state|derived|effect|batch|ref|reactive|computed|watch|watchEffect)\s*(?:<[^>]*>)?\s*\(/;function u(t,e,r){let i={fullTag:r,content:e,attrs:t};if(/\bserver\b/.test(t))return{...i,type:"server"};if(/\bdata-stx-scoped\b/.test(t))return{...i,type:"client"};if(o.test(e))return{...i,type:"signals"};if(/\bclient\b/.test(t)||/\btype\s*=\s*["']module["']/.test(t)||/\bsrc\s*=/.test(t))return{...i,type:"client"};return{...i,type:"server"}}var S=/^<script\b([^>]*)>([\s\S]*)<\/script\s*>$/i;function an(t){let e=[],r=[],i=[],c=0;while(c<t.length){let s=t.indexOf("<",c);if(s===-1)break;let p=Be(t,s);if(p>s){c=p;continue}let a=J(t,s);if(a>s){let f=t.slice(s,a),l=S.exec(f);if(l){let n=u(l[1],l[2],f);switch(n.type){case"signals":e.push(n);break;case"client":r.push(n);break;case"server":i.push(n);break}}c=a;continue}c=s+(t.startsWith("<!--",s)?4:1)}return{signals:e,client:r,server:i}}
2
+ import{J,Be}from"./chunk-pnqdwqw9.js";var o=/\b(?:state|derived|effect|batch|ref|reactive|computed|watch|watchEffect)\s*(?:<[^>]*>)?\s*\(/;function u(t,e,r){let i={fullTag:r,content:e,attrs:t};if(/\bserver\b/.test(t))return{...i,type:"server"};if(/\bdata-stx-scoped\b/.test(t))return{...i,type:"client"};if(o.test(e))return{...i,type:"signals"};if(/\bclient\b/.test(t)||/\btype\s*=\s*["']module["']/.test(t)||/\bsrc\s*=/.test(t))return{...i,type:"client"};return{...i,type:"server"}}var S=/^<script\b([^>]*)>([\s\S]*)<\/script\s*>$/i;function an(t){let e=[],r=[],i=[],c=0;while(c<t.length){let s=t.indexOf("<",c);if(s===-1)break;let p=Be(t,s);if(p>s){c=p;continue}let a=J(t,s);if(a>s){let f=t.slice(s,a),l=S.exec(f);if(l){let n=u(l[1],l[2],f);switch(n.type){case"signals":e.push(n);break;case"client":r.push(n);break;case"server":i.push(n);break}}c=a;continue}c=s+(t.startsWith("<!--",s)?4:1)}return{signals:e,client:r,server:i}}
3
3
  export{an};
@@ -0,0 +1,20 @@
1
+ // @bun
2
+ import{ar,Oe}from"./chunk-9zrvh3pz.js";import{K,S,Cr,Vs,T}from"./chunk-pnqdwqw9.js";import{a,M}from"./chunk-jcr69v95.js";import{Fo}from"./chunk-kkevjppm.js";import{at}from"./chunk-n3jw3xpj.js";import{l}from"./chunk-46pxmpeb.js";import{r,Y}from"./chunk-z9xe3xkg.js";import d from"path";import j from"fs";import{AsyncLocalStorage as lt}from"async_hooks";import{randomUUID as $t}from"crypto";var wt=11;function J(t,e,n){return/^(?:(?:stx|ui)\.config\.[cm]?[jt]s|runtime-config-(?:server|loader)\.[cm]?[jt]s)$/.test(d.basename(t))||Fo(t,e,n)}var ct=2;function Nf(t){let e=process.env.STX_BUNDLE_CACHE_DIR?.trim();return e?d.resolve(e):l(t,"bundle-cache")}function st(t,e){let n=t;for(let i of St(e))if(i!==d.sep)n=n.split(i).join("\x00root");return n}var rt=new Map;function St(t){let e=d.resolve(t),n=rt.get(e);if(!n){let i=e;try{i=j.realpathSync(e)}catch{}n=[...new Set([e,i])].sort((c,p)=>p.length-c.length),rt.set(e,n)}return n}function vt(t,e){try{let n=j.statSync(t),i=d.resolve(e),c=t.startsWith(`${i}${d.sep}`);return{path:c?d.relative(i,t):t,...c?{inRoot:!0}:{},mtimeMs:n.mtimeMs,size:n.size,hash:Bun.hash(j.readFileSync(t)).toString(36)}}catch{return null}}function ut(t,e){return t.inRoot?d.join(d.resolve(e),t.path):t.path}function Bt(t,e){for(let n of t){let i=ut(n,e);try{let c=j.statSync(i);if(c.size!==n.size)return!1;if(c.mtimeMs!==n.mtimeMs&&Bun.hash(j.readFileSync(i)).toString(36)!==n.hash)return!1}catch{return!1}}return!0}var dt=new Map,jt=100;function Df(t=process.env){let e=Number(t.STX_BUNDLE_CACHE_LIMIT);return Number.isFinite(e)&&e>=1?Math.floor(e):2000}var G=new Map;async function Et(t){let e=G.get(t)??0;if(e>0&&e<jt){G.set(t,e+1);return}G.set(t,1);try{let n=(await j.promises.readdir(t)).filter((o)=>o.endsWith(".js")),i=Df();if(n.length<=i)return;let p=(await Promise.all(n.map(async(o)=>{try{return{name:o,at:(await j.promises.stat(d.join(t,o))).mtimeMs}}catch{return null}}))).filter((o)=>o!==null);p.sort((o,b)=>b.at-o.at);for(let o of p.slice(i)){let b=o.name.slice(0,-3);await j.promises.rm(d.join(t,`${b}.js`),{force:!0}),await j.promises.rm(d.join(t,`${b}.deps.json`),{force:!0})}N("pruned bundle cache to",i,"entries")}catch{}}function xe(t){return dt.get(t)??[]}function q(t,e){if(t)dt.set(t,e)}function Mf(t=process.env){return t.STX_DEBUG==="true"||t.STX_DEBUG==="1"}function N(...t){if(Mf())console.log("[stx:bundler]",...t)}var tt=[];function pc(t,e,n){tt.push({filePath:t||"<inline>",message:e,details:n})}function cn(){return tt.slice()}function ln(){tt.length=0}var Z;function Fh(t){Z=t}function fc(){if(Z)return Z;try{let t=M.strict;return typeof t==="object"&&t!==null?t.bundlerFallback??"warn":"warn"}catch{return"warn"}}var Q=[/^stx$/,/^@stacksjs\/stx$/,/^@stores$/,/^stx\/stores$/,/^@composables$/];function un(t){let e=/^[ \t]*import[ \t]+(?!type(?:[ \t]|{))[\s\S]*?\s+from\s+['"]([^'"]+)['"][ \t]*;?/gm,n;while((n=e.exec(t))!==null){let c=n[1];if(!Q.some((o)=>o.test(c)))return N("detected user import:",c),!0}let i=/^[ \t]*import[ \t]*['"]([^'"]+)['"]/gm;while((n=i.exec(t))!==null){let c=n[1];if(/\.css(?:\?.*)?$/.test(c))continue;if(!Q.some((o)=>o.test(c)))return N("detected side-effect import:",c),!0}return!1}var ir="stx-module:",_t=/\.(?:[cm]?[jt]sx?|json)$/i;function Lf(t,e){return d.relative(t,e).split(d.sep).join("/")}function jf(t,e){if(e.size===0)return t;return t.replace(/^([ \t]*import(?:(?:\s+|(?=[{*]))[^;"']*?\s*from\s*|\s*))(["'])([^"']+)\2/gm,(n,i,c,p)=>{let o=e.get(p);return o&&!p.startsWith(ir)?`${i}${c}${o}${c}`:n})}function Bf(t,e){let n=0,i=(p)=>{let o=`__stxMod${n++}`,b=JSON.stringify(p);return e.push(`var ${o} = globalThis.__stxModules && globalThis.__stxModules[${b}];`,`if (${o} === undefined) throw new Error("[stx] module " + ${JSON.stringify(b)} + " is not registered on this page (#1957)");`),o},c=(p,o)=>{for(let b of p.split(",")){let C=b.trim();if(!C)continue;let R=C.match(/^("(?:[^"\\]|\\.)*"|[\w$]+)(?:\s+as\s+([\w$]+))?$/);if(!R)continue;let w=R[1].startsWith('"')?JSON.parse(R[1]):R[1],f=R[2]??w;e.push(`var ${f} = ${o}[${JSON.stringify(w)}];`)}};return t=t.replace(/^[ \t]*import(?:\s+|(?=[{*]))([^;"']+?)\s*from\s*["'](stx-module:[^"']+)["'];?[ \t]*$/gm,(p,o,b)=>{let C=b.slice(ir.length),R=i(C),w=o.trim(),f=w.match(/^([\w$]+)\s*(?:,\s*|$)/);if(f&&!w.startsWith("{")&&!w.startsWith("*"))e.push(`var ${f[1]} = ${R}.default;`),w=w.slice(f[0].length).trim();let v=w.match(/^\*\s*as\s+([\w$]+)$/);if(v)e.push(`var ${v[1]} = ${R};`);else if(w.startsWith("{"))c(w.replace(/^\{|\}$/g,""),R);return""}),t=t.replace(/^[ \t]*import\s*["'](stx-module:[^"']+)["'];?[ \t]*$/gm,(p,o)=>(i(o.slice(ir.length)),"")),t}function it(t){let e=[t,`${t}.ts`,`${t}.tsx`,`${t}.js`,`${t}.mjs`,`${t}.jsx`,d.join(t,"index.ts"),d.join(t,"index.tsx"),d.join(t,"index.js"),d.join(t,"index.mjs")];for(let n of e)try{if(j.existsSync(n)&&j.statSync(n,{throwIfNoEntry:!1})?.isFile())return n}catch{}return}var X=new lt;function ds(t,e){let n=new Bun.CryptoHasher("md5");for(let[i,c]of[...t].sort(([p],[o])=>p<o?-1:p>o?1:0))n.update(`${i}\x00${c}\x00`);return X.run({modules:t,key:n.digest("hex").slice(0,12)},e)}var pt=new lt;function Ff(t){return pt.run(!0,t)}function zf(){return pt.getStore()===!0}function gc(t){if(!zf())return;throw Error(`The client script of ${t} needs bundling, and it is being rendered inside a Bun.build loader, where Bun never finishes a second build. Make the page an entrypoint of the build (bun-plugin-stx renders entrypoints before the bundler starts), or render it once outside the build so its bundle is cached.`)}function dn(){return X.getStore()?.key??""}function ft(t,e,n,i,c,p,o=new Map,b,C,R){let w=new Map([[n,i],...R??[]]),f=(B)=>B!==void 0&&w.has(B),v=(B,s,u)=>{if(J(s,t,b))return null;if(!p||!f(B)||!_t.test(s))return null;try{if(!j.statSync(s,{throwIfNoEntry:!1})?.isFile())return null}catch{return null}c.add(s);let E=`${ir}${Lf(process.cwd(),s)}`;return o.set(u,E),{path:E,external:!0}},y=(B,s)=>{let u=f(B)?e:d.dirname(B),E=d.resolve(u,s);return it(E)??E};return{name:"stx-client-bundle",setup(B){if(B.onResolve({filter:/^(stx|@stacksjs\/stx)$/},(s)=>({path:s.path,external:!0})),B.onResolve({filter:/^(@stores|@composables|stx\/stores)$/},(s)=>({path:s.path,external:!0})),B.onResolve({filter:/^\//},(s)=>{if(f(s.path))return{path:s.path};let u=it(s.path);if(u){let E=v(s.importer,u,s.path);if(E)return E;if(!f(u))c.add(u);return{path:u}}return{path:s.path,external:!0}}),B.onResolve({filter:/^\.\.?\//},(s)=>{let u=y(s.importer,s.path),E=v(s.importer,u,s.path);if(E)return E;return c.add(u),{path:u}}),B.onResolve({filter:/^[@~]\//},(s)=>{let u=d.resolve(t,s.path.slice(2)),E=[u,`${u}.ts`,`${u}.tsx`,`${u}.js`,`${u}.mjs`,`${u}.jsx`,d.join(u,"index.ts"),d.join(u,"index.tsx"),d.join(u,"index.js"),d.join(u,"index.mjs")];for(let h of E)if(j.existsSync(h)&&j.statSync(h,{throwIfNoEntry:!1})?.isFile()){let D=v(s.importer,h,s.path);if(D)return D;return N(`resolved ${s.path[0]}/ import:`,s.path,"\u2192",h),c.add(h),{path:h}}return console.warn(`[stx:bundler] could not resolve ${s.path[0]}/ import:`,s.path),{path:u}}),p)B.onResolve({filter:/^(?!node:|bun:)(?:@[\w.-]+\/)?[\w.-]/},(s)=>{if(!f(s.importer))return;let u=`${ir}npm:${s.path}`;return o.set(s.path,u),{path:u,external:!0}});B.onLoad({filter:/\.(?:[cm]?[jt]sx?|json)$/},(s)=>{if(w.has(s.path))return{contents:w.get(s.path),loader:"ts"};if(J(s.path,t,b))throw Error(`Server-only API source cannot be imported by a client script: ${s.path}`);let u=d.extname(s.path).toLowerCase(),E=u===".json"?"json":u===".tsx"?"tsx":u===".jsx"?"jsx":u===".ts"||u===".mts"||u===".cts"?"ts":"js";if(!f(s.path))c.add(s.path);let h=C?.get(s.path);if(h!==void 0)return{contents:h,loader:"js"};return{contents:j.readFileSync(s.path,"utf8"),loader:E}})}}}var H=new Map,z=S(64),ot=Symbol.for("stx.client-bundle-build-queue");function Hf(t){let e=globalThis,i=(e[ot]??Promise.resolve()).then(t,t);return e[ot]=i.then(()=>{return},()=>{return}),i}async function pn(t,e,n={}){let i=n.projectRoot||process.cwd(),c=(await a(i)).serverApi,p=n.minify??!1,o=n.externalizeUserModules??!0,b=n.expose?.length?[...new Set(n.expose)].sort():void 0,C=n.cacheDir||Nf(i),R=X.getStore(),w=new Bun.CryptoHasher("md5");w.update(`${wt}\x00${at()}\x00${JSON.stringify(c??!1)}\x00${o?"registry":"inline"}\x00${b?b.join(","):"*"}\x00${p?"minified":"readable"}\x00${R?.key??""}\x00${st(t,i)}\x00${st(e,i)}`);let f=w.digest("hex").slice(0,12),v=d.join(C,`${f}.js`),y=z.get(v);if(y){if(Vs(y.files)&&y.files.every((h)=>!J(h.path,i,c))){N("memo hit:",f);let h=y.files.map((D)=>D.path);return q(e,h),n.collectInputs?.push(...h),y.code}z.delete(v),N("memo invalidated by dep change:",f)}let B=d.join(C,`${f}.deps.json`),s=Bun.file(v);if(await s.exists()){let h=Bun.file(B),D=!1,k=null;if(await h.exists())try{let O=JSON.parse(await h.text());if(O.metadataVersion===ct&&Array.isArray(O.files)&&Bt(O.files,i))k=Cr(O.files.map((g)=>ut(g,i))),D=k.length===O.files.length&&!k.some((g)=>J(g.path,i,c))}catch{D=!1}if(D){if(N("cache hit:",f),k)q(e,k.map((U)=>U.path)),n.collectInputs?.push(...k.map((U)=>U.path));let O=await s.text(),g=new Date;if(j.promises.utimes(v,g,g).catch(()=>{}),k)z.set(v,{code:O,files:k});return O}N("cache invalidated by dep change:",f)}let u=H.get(f);if(u){let h=await u;if(n.collectInputs)n.collectInputs.push(...(z.get(v)?.files??[]).map((D)=>D.path));return h}gc(e);let E=Hf(()=>Mt(t,e,{projectRoot:i,minify:p,cacheDir:C,hash:f,cachePath:v,depsPath:B,collectInputs:n.collectInputs,externalizeUserModules:o,serverApi:c,expose:b,throwOnFailure:n.throwOnFailure,substitutes:R?.modules}));H.set(f,E);try{return await E}finally{H.delete(f)}}function mc(t){return`${t}-${process.pid}-${$t()}`}async function zh(t,e){let{projectRoot:n}=e,i=mc(new Bun.CryptoHasher("md5").update([...t.keys()].join("\x00")).digest("hex").slice(0,12)),c=d.join(l(n,"bundle-tmp"),"out",i);j.mkdirSync(c,{recursive:!0});let p=new Map,o=new Map,b=0;for(let[f,v]of t){let y=d.join(n,`.stx-split-${i}-${b++}.ts`);p.set(y,v),o.set(d.basename(y).replace(/\.ts$/,""),f)}let[C,R]=[...p][0],w=new Set;gc(e.filePath);try{let f=await Bun.build({entrypoints:[...p.keys()],outdir:c,target:"browser",format:"esm",splitting:!0,minify:!1,naming:{entry:"[name].js",chunk:"chunk-[hash].js"},plugins:[ft(n,d.dirname(e.filePath),C,R,w,!1,new Map,void 0,X.getStore()?.modules,p)],define:{"process.env.NODE_ENV":'"development"',...T()},root:n});if(!f.success)throw Error(f.logs.filter((y)=>y.level==="error").map((y)=>y.message).join(", ")||"Unable to bundle the entries");let v={entries:new Map,chunks:new Map};for(let y of f.outputs){let B=d.basename(y.path);if(y.kind==="entry-point"){let s=o.get(B.replace(/\.js$/,""));if(s!==void 0)v.entries.set(s,await y.text())}else if(y.kind==="chunk")v.chunks.set(B.replace(/\.js$/,""),await y.text())}return e.collectInputs?.push(...w),v}finally{try{j.rmSync(c,{recursive:!0,force:!0})}catch{}}}async function Mt(t,e,n){let{projectRoot:i,minify:c,cacheDir:p,hash:o,cachePath:b,depsPath:C,externalizeUserModules:R}=n,w=l(i,"bundle-tmp"),f=mc(o),v=d.join(i,`.stx-client-${f}.ts`),y=d.join(w,"out",f);j.mkdirSync(y,{recursive:!0});let B=d.dirname(e),s=new Set,u=/^[ \t]*(export\s+)?(?:const|let|var)\s+(?:\{([^}]+)\}|(\w+))/gm,E=/^[ \t]*(export\s+)?(?:async\s+)?function\s+(\w+)/gm,h=r(t),{depths:D,balanced:k}=Y(h),O=(F)=>!k||D[F]===0,g;while((g=u.exec(h))!==null){if(g[1])continue;if(!O(g.index))continue;if(g[2])g[2].split(",").forEach((F)=>{let m=Rt(F);if(m)s.add(m)});else if(g[3])s.add(g[3])}while((g=E.exec(h))!==null){if(g[1])continue;if(!O(g.index))continue;s.add(g[2])}let U=/^[ \t]*import[ \t]+(?!type\b)(?:(\w+)\s*(?:,\s*)?)?(?:\*\s+as\s+(\w+)|\{([^}]+)\})?\s+from\b/gm;while((g=U.exec(h))!==null){if(!O(g.index))continue;let F=/^\s*['"]([^'"]+)['"]/.exec(t.slice(g.index+g[0].length))?.[1];if(F&&Q.some((m)=>m.test(F)))continue;if(g[1])s.add(g[1]);if(g[2])s.add(g[2]);for(let m of(g[3]??"").split(",")){let _=m.trim();if(!_||/^type\s/.test(_))continue;let L=/\bas\s+(\w+)\s*$/.exec(_)?.[1]??/^\w+$/.exec(_)?.[0];if(L)s.add(L)}}for(let F of h.matchAll(/\bexport\s*\{([^}]+)\}/g))for(let m of F[1].split(",")){let _=/\bas\s+(\w+)\s*$/.exec(m)?.[1]??/^\s*(\w+)\s*$/.exec(m)?.[1];if(_)s.delete(_)}let mt=s.size>0?`
3
+ export { ${[...s].join(", ")} }`:"";N("bundling:",o,"from:",d.basename(e));let et=new Set,nt=new Map;try{let F=await Bun.build({entrypoints:[v],outdir:y,target:"browser",format:"esm",minify:c?{whitespace:!1,identifiers:!0,syntax:!0}:!1,plugins:[ft(i,B,v,t+mt,et,R,nt,n.serverApi,n.substitutes)],define:{"process.env.NODE_ENV":c?'"production"':'"development"',...T()},root:i});if(!F.success){let I=F.logs.filter((A)=>A.level==="error").map((A)=>A.message).join(", ")||`Unable to bundle ${d.basename(e)}`,P=ar(F.logs,e||void 0);if(console.warn("[stx:bundler] build failed:",I),pc(e||"",I,P),n.throwOnFailure||fc()==="error")throw Error(I);return t}let m="";for(let x of F.outputs){m=await x.text();break}let _=[];for(let x of m.matchAll(/^\s*export\s*\{([^}]*)\}\s*;?\s*$/gm))for(let I of x[1].split(",")){let P=I.trim().match(/^([A-Za-z_$][\w$]*)\s+as\s+([A-Za-z_$][\w$]*)$/);if(P){_.push([P[2],P[1]]);continue}let A=I.trim();if(/^[A-Za-z_$][\w$]*$/.test(A))_.push([A,A])}if(n.expose){let x=new Set(n.expose);for(let I=_.length-1;I>=0;I--)if(!x.has(_[I][0]))_.splice(I,1)}let L=[];m=Bf(jf(m,nt),L);let gt=m.match(/^\s*import(?:\s+|(?=["'{*]))[^;]+;?\s*$/gm)||[];if(m=m.replace(/^\s*import(?:\s+|(?=["'{*]))[^;]+;?\s*$/gm,"").replace(/^\s*export\s*\{[^}]*\}\s*;?\s*$/gm,"").replace(/^\s*export\s+default\s+.*$/gm,"").trim(),c&&m)try{m=new Bun.Transpiler({loader:"js",minifyWhitespace:!0}).transformSync(m)}catch{}let V=`__stxBundle_${o}`,ht=new Set(K(t,!0).split(",").map((x)=>x.trim())),xt=_.map(([x,I])=>`get ${JSON.stringify(x)}() { return ${I} }${ht.has(x)?`, set ${JSON.stringify(x)}(__stxValue_${I}) { ${I} = __stxValue_${I} }`:""}`).join(", "),yt=_.map(([x])=>`var ${x} = undefined;`).join(`
4
+ `),bt=_.map(([x])=>`${x} = ${V}[${JSON.stringify(x)}];`).join(`
5
+ `);if(m=`${gt.join(`
6
+ `)}
7
+ ${yt}
8
+ var ${V} = (function() {
9
+ ${L.join(`
10
+ `)}
11
+ ${m}
12
+ return { ${xt} };
13
+ })();
14
+ ${bt}
15
+ var __stxLiveBindings = typeof __stxLiveBindings === 'undefined' ? {} : __stxLiveBindings;
16
+ Object.keys(${V}).forEach(function(name) {
17
+ if (!Object.prototype.hasOwnProperty.call(__stxLiveBindings, name))
18
+ Object.defineProperty(__stxLiveBindings, name, Object.getOwnPropertyDescriptor(${V}, name));
19
+ });`.trim(),N("bundled:",o,"output:",m.length,"bytes"),s.size>0&&_.length===0)return console.warn(`[stx:bundler] dropped every binding for ${d.basename(e)} (${o}); serving the unbundled source and not caching this result`),t;j.mkdirSync(p,{recursive:!0}),await Bun.write(b,m);let W=Cr(et);return await Bun.write(C,JSON.stringify({metadataVersion:ct,files:W.map((x)=>vt(x.path,i)).filter((x)=>x!==null)})),q(e,W.map((x)=>x.path)),n.collectInputs?.push(...W.map((x)=>x.path)),z.set(b,{code:m,files:W}),await Et(p),m}catch(F){let m=ar(F,e||void 0),_=Oe(F,e||void 0);if(console.warn(`[stx:bundler] error: ${_}`),pc(e||"",_,m),n.throwOnFailure||fc()==="error")throw F;return t}finally{try{j.rmSync(y,{recursive:!0,force:!0})}catch{}}}function Rt(t){let e=t.trim();if(!e)return null;let n=e.indexOf("=");if(n!==-1)e=e.slice(0,n).trim();let i=e.indexOf(":");if(i!==-1)e=e.slice(i+1).trim();if(e.startsWith("..."))e=e.slice(3).trim();return/^[A-Za-z_$][\w$]*$/.test(e)?e:null}
20
+ export{Nf,Df,xe,Mf,pc,cn,ln,Fh,fc,un,ir,Lf,jf,Bf,ds,Ff,zf,gc,dn,Hf,pn,mc,zh};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{St,Gn,$h}from"./chunk-m131znxe.js";import{he,Jn,Rh,Yn,To,ns,rs,Ah,Ph,Ih,Zn,Qn,$o,ss,Oh}from"./chunk-e2t7mk29.js";import"./chunk-qjey0jk6.js";export{To as batch,$h as default,Jn as derived,Yn as effect,St as generateSignalsRuntime,Gn as generateSignalsRuntimeDev,Qn as isDerived,Zn as isSignal,Rh as memo,rs as onDestroy,ns as onMount,ss as peek,Ih as pendingLifecycleCounts,Ph as runDestroyCallbacks,Ah as runMountCallbacks,he as state,$o as untrack,Oh as useOptimistic};
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{fn,Lo,jo,Bo,Hh,Fo}from"./chunk-mwxehpse.js";import"./chunk-rw5492e2.js";import"./chunk-dy7vqv1x.js";import"./chunk-60yppcbb.js";export{jo as buildServerApi,Hh as createServerApi,fn as discoverServerApi,Lo as generateApiTypes,Fo as isServerApiSource,Bo as productionApiDispatcher};
2
+ import{fn,Lo,jo,Bo,Hh,Fo}from"./chunk-kkevjppm.js";import"./chunk-rw5492e2.js";import"./chunk-hhbt8grm.js";import"./chunk-60yppcbb.js";export{jo as buildServerApi,Hh as createServerApi,fn as discoverServerApi,Lo as generateApiTypes,Fo as isServerApiSource,Bo as productionApiDispatcher};
@@ -1,3 +1,3 @@
1
1
  // @bun
2
- import{d,m,hl,p,t,u}from"./chunk-0tyyad6q.js";import{rt,Et,hn,ti}from"./chunk-311mrz2n.js";function L(w,e){try{let g=w.trim();if(m(g))return p(g,Object.keys(e))(...Object.values(e));else return d(g,e)}catch{return!1}}function Q(w,e,g){let n=w,v=!0;while(v){v=!1;let a=n.match(/@switch\s*\(/);if(!a||a.index===void 0)break;let f=a.index,s=ti(n,f);if(!s)break;try{let o;if(m(s.expression))o=p(s.expression,Object.keys(e))(...Object.values(e));else o=d(s.expression,e);let r="",c=!1;for(let i of s.cases)if(i.type==="default"){if(!c)r=i.content.trim()}else try{let b;if(i.value&&m(i.value))b=p(i.value,Object.keys(e))(...Object.values(e));else if(i.value)b=d(i.value,e);if(o===b){r=i.content.trim(),c=!0;break}}catch{continue}n=n.substring(0,f)+r+n.substring(s.end),v=!0}catch(o){let r=o instanceof Error?o.message:String(o),c=u("Switch",`Error evaluating @switch expression: ${r}`,t.EVALUATION_ERROR);n=n.substring(0,f)+c+n.substring(s.end);break}}return n}function H(w){let e=[];return{masked:w.replace(/<script\b[\s\S]*?<\/script\s*>/gi,(n)=>(e.push(n),`\x00stx-script-${e.length-1}\x00`)),scripts:e}}function J(w,e){if(e.length===0)return w;return w.replace(/\u0000stx-script-(\d+)\u0000/g,(g,n)=>e[Number(n)]??g)}function ue(w,e,g){let{masked:n,scripts:v}=H(w);return J(K(n,e,g),v)}function K(w,e,g){let n=w;n=Q(n,e,g);{let a=!0;while(a){a=!1;let f=n.match(/@unless\s*\(/);if(!f||f.index===void 0)break;let s=f.index,o=rt(n,s+7);if(!o)break;let r=o.endPos,c=Et(n,"unless","endunless",r);if(c===-1){console.warn(`[stx] @unless directive at position ${s} has no matching @endunless \u2014 the block was skipped. Check for typos or missing closers.`);break}let i=n.slice(r,c),b=o.expression,y=-1;{let x=0,k=/@(?:if|unless)\s*\(/g,h=/@(?:endif|endunless)(?![a-z])/g,E=/@else(?![a-z])/g,S=[],C;while((C=k.exec(i))!==null)S.push({pos:C.index,type:"open"});while((C=h.exec(i))!==null)S.push({pos:C.index,type:"close"});while((C=E.exec(i))!==null)S.push({pos:C.index,type:"else"});S.sort((P,R)=>P.pos-R.pos);for(let P of S)if(P.type==="open")x++;else if(P.type==="close")x--;else if(P.type==="else"&&x===0){y=P.pos;break}}let l;if(y!==-1){let x=i.slice(0,y),k=i.slice(y+5);l=`@if (${b})${k}@else ${x}@endif`}else l=`@if (!(${b}))${i}@endif`;n=n.substring(0,s)+l+n.substring(c+10),a=!0}}n=Xo(n,e,g),n=Jo(n,e,g),n=Go(n,e);let v=()=>{let a=hn(n);if(a.length===0)return!1;let f=Array(a.length);for(let r=a.length-1;r>=0;r--){let c=a[r];try{let i="",b=!1;for(let y of c.branches){if(b)break;if(y.type==="else")i=y.content,b=!0;else try{if(y.condition?hl(y.condition,e):!1)i=y.content,b=!0}catch(l){i=u(y.type==="if"?"If":"Elseif",`Error in @${y.type}(${y.condition}): ${l instanceof Error?l.message:String(l)}`,t.EVALUATION_ERROR),b=!0}}f[r]=i}catch(i){let b=i instanceof Error?i.message:String(i);f[r]=u("If",`Error processing @if block: ${b}`,t.EVALUATION_ERROR)}}let s=Array(a.length*2+1),o=0;for(let r=0;r<a.length;r++){let c=a[r];s[r*2]=n.slice(o,c.start),s[r*2+1]=f[r],o=c.end}return s[a.length*2]=n.slice(o),n=s.join(""),!0};while(!0){let a=n;if(!v())break;if(n===a)break}return n}function q(w){let e=0;while(e<w.length&&/\s/.test(w[e]))e++;if(w[e]!=="(")return null;e++;while(e<w.length&&/\s/.test(w[e]))e++;let g=w[e];if(g!=="'"&&g!=='"')return null;e++;let n=[];while(e<w.length){let v=w[e];if(v==="\\"&&e+1<w.length){n.push(w[e+1]),e+=2;continue}if(v===g){e++;break}n.push(v),e++}while(e<w.length&&/\s/.test(w[e]))e++;if(w[e]!==")")return null;return e++,{value:n.join(""),consumed:e}}function Go(w,e){let g=w;function n(s,o,r,c){let i=1,b=c,y=new RegExp(`@${o}(?:\\s*\\(|\\s|$)`,"g"),l=new RegExp(`@${r}(?![a-z])`,"g");while(b<s.length&&i>0){y.lastIndex=b,l.lastIndex=b;let x=y.exec(s),k=l.exec(s),h=x?x.index:1/0,E=k?k.index:1/0;if(h<E)i++,b=h+x[0].length;else if(E<1/0){if(i--,i===0)return E;b=E+k[0].length}else break}return-1}function v(s,o,r){let c=0,i=new RegExp(`@${o}(?:\\s*\\(|\\s|$)`,"g"),b=new RegExp(`@${r}(?![a-z])`,"g"),y=/@else(?![a-z])/g,l=[],x;while((x=i.exec(s))!==null)l.push({pos:x.index,type:"open"});while((x=b.exec(s))!==null)l.push({pos:x.index,type:"close"});while((x=y.exec(s))!==null)l.push({pos:x.index,type:"else"});l.sort((k,h)=>k.pos-h.pos);for(let k of l)if(k.type==="open")c++;else if(k.type==="close")c--;else if(k.type==="else"&&c===0)return k.pos;return-1}{let s=!0;while(s){s=!1;let o=g.match(/@auth(?:\s*\(|\s|(?=\n))/);if(!o||o.index===void 0)break;let r=o.index,c,i,b=g.slice(r+5),y=q(b);if(y)c=y.value,i=r+5+y.consumed;else i=r+5;let l=n(g,"auth","endauth",i);if(l===-1){console.warn(`[stx] @auth directive at position ${r} has no matching @endauth \u2014 the block was skipped.`);break}let x=g.slice(i,l),k=v(x,"auth","endauth"),h;if(!e.auth)h=!1;else h=c?L(`auth?.check && auth?.user?.[${c}]`,e):L("auth?.check",e);let E;if(k!==-1){let S=x.slice(0,k),C=x.slice(k+5);E=h?S:C}else E=h?x:"";g=g.substring(0,r)+E+g.substring(l+8),s=!0}}{let s=!0;while(s){s=!1;let o=g.match(/@guest(?:\s*\(|\s|(?=\n))/);if(!o||o.index===void 0)break;let r=o.index,c,i,b=g.slice(r+6),y=q(b);if(y)c=y.value,i=r+6+y.consumed;else i=r+6;let l=n(g,"guest","endguest",i);if(l===-1){console.warn(`[stx] @guest directive at position ${r} has no matching @endguest \u2014 the block was skipped.`);break}let x=g.slice(i,l),k=v(x,"guest","endguest"),h;if(!e.auth)h=!0;else h=c?L(`!auth?.check || !auth?.user?.[${c}]`,e):L("!auth?.check",e);let E;if(k!==-1){let S=x.slice(0,k),C=x.slice(k+5);E=h?S:C}else E=h?x:"";g=g.substring(0,r)+E+g.substring(l+9),s=!0}}function a(s,o,r){if(e.userCan&&typeof e.userCan[s]==="boolean")return e.userCan[s];if(e.permissions?.check&&typeof e.permissions.check==="function")try{let c=[s];if(o)c.push(o);if(r){let i=L(r,e);c.push(i)}return e.permissions.check(...c)}catch{return!1}return!1}function f(s){let o=s.match(/^\s*\(\s*'([^']*)'(?:,\s*'([^']*)')?(?:,\s*([^)]*))?\)/);if(!o)return null;return{ability:o[1],type:o[2],id:o[3]?.trim(),paramsEnd:o[0].length}}for(let s of["can","cannot"]){let o=`end${s}`,r=s==="can"?"elsecan":"elsecannot",c=!0;while(c){c=!1;let i=g.match(new RegExp(`@${s}\\s*\\(`));if(!i||i.index===void 0)break;let b=i.index,y=g.slice(b+`@${s}`.length),l=f(y);if(!l)break;let x=b+`@${s}`.length+l.paramsEnd,k=n(g,s,o,x);if(k===-1){console.warn(`[stx] @${s} directive at position ${b} has no matching @${o} \u2014 the block was skipped.`);break}let h=g.slice(x,k),E=[],S=0,C=new RegExp(`@${s}\\s*\\(`,"g"),P=new RegExp(`@${o}(?![a-z])`,"g"),R=new RegExp(`@${r}\\s*\\(`,"g"),T=/@else(?![a-z])/g,_=[],M;while((M=C.exec(h))!==null)_.push({pos:M.index,type:"open"});while((M=P.exec(h))!==null)_.push({pos:M.index,type:"close"});while((M=R.exec(h))!==null)_.push({pos:M.index,type:"elseDirective"});while((M=T.exec(h))!==null)_.push({pos:M.index,type:"else"});_.sort((A,z)=>A.pos-z.pos);for(let A of _){if(A.type==="open"){S++;continue}if(A.type==="close"){S--;continue}if(S===0)E.push(A)}let I=[],F=0;for(let A=0;A<E.length;A++){let z=E[A];if(I.push({content:h.slice(F,z.pos),ability:void 0}),z.type==="elseDirective"){let D=h.slice(z.pos+`@${r}`.length),B=f(D);if(B){I[I.length-1]={content:h.slice(F,z.pos)},F=z.pos+`@${r}`.length+B.paramsEnd,I.push({content:"",ability:B.ability,type:B.type,id:B.id}),I.pop();let G=E[A+1],U=G?G.pos:h.length;I.push({content:h.slice(F,U),ability:B.ability,type:B.type,id:B.id}),F=U}}else F=z.pos+5}if(F<h.length){let A=I[I.length-1];if(E.length>0&&E[E.length-1].type==="else")I.push({content:h.slice(F),isFinalElse:!0});else if(I.length===0)I.push({content:h.slice(F)})}let O=a(l.ability,l.type,l.id),j=s==="can"?O:!O,V="";if(j)V=I[0]?.content||"";else{let A=!1;for(let z=1;z<I.length;z++){let D=I[z];if(D.isFinalElse){V=D.content,A=!0;break}if(D.ability){let B=a(D.ability,D.type,D.id);if(s==="can"?B:!B){V=D.content,A=!0;break}}}if(!A&&I.length>0){let z=I[I.length-1];if(z.isFinalElse)V=z.content}}g=g.substring(0,b)+V+g.substring(k+`@${o}`.length),c=!0}}return g}function Xo(w,e,g){let n=w;function v(a,f,s,o,r){let c=!0;while(c){c=!1;let i=new RegExp(`@${f}\\s*\\(`),b=a.match(i);if(!b||b.index===void 0)break;let y=b.index,l=rt(a,y+`@${f}`.length);if(!l)break;let x=l.endPos,k=Et(a,f,s,x);if(k===-1){console.warn(`[stx] @${f} directive at position ${y} has no matching @${s} \u2014 the block was skipped.`);break}let h=a.slice(x,k),E=l.expression,S=-1,C=0,P=0;while(P<h.length){let R=h.indexOf("@",P);if(R===-1)break;let T=h.substring(R);if(/^@(?:if|unless|isset|empty)\s*\(/.test(T)){C++,P=R+1;continue}if(/^@(?:endif|endunless|endisset|endempty)(?![a-z])/.test(T)){C--,P=R+1;continue}if(C===0&&/^@else(?![a-z])/.test(T)){S=R;break}P=R+1}try{let R=o(E.trim()),T;if(S!==-1){let _=h.slice(0,S),M=h.slice(S+5);T=R?_:M}else T=R?h:"";a=a.substring(0,y)+T+a.substring(k+`@${s}`.length),c=!0}catch(R){let T=R instanceof Error?R.message:String(R),_=u(r,`Error processing @${f} directive: ${T}`,t.EVALUATION_ERROR);a=a.substring(0,y)+_+a.substring(k+`@${s}`.length);break}}return a}return n=v(n,"isset","endisset",(a)=>{let f=L(a,e);return f!==void 0&&f!==null},"Isset"),n=v(n,"empty","endempty",(a)=>{let f=L(a,e);return f===void 0||f===null||f===""||f===0||f===!1||Array.isArray(f)&&f.length===0||typeof f==="object"&&f!==null&&Object.keys(f).length===0},"Empty"),n}function Jo(w,e,g){let n=w,v="development";function a(f,s,o,r){let c=new RegExp(`@${s}(?![a-z])`,"g"),i=new RegExp(`@${o}(?![a-z])`,"g"),b=new RegExp(`^@${s}(?![a-z])`),y=new RegExp(`^@${o}(?![a-z])`),l=f,x=!0;while(x){x=!1,c.lastIndex=0;let k=c.exec(l);if(!k)break;let h=k.index,E=h+k[0].length;if(s==="env"){let O=l.substring(E).match(/^\s*\(\s*(['"])([^'"]+)\1\s*\)/);if(!O)break;E+=O[0].length,r=v===O[2]}let S=1,C=E,P=-1;while(S>0&&C<l.length){c.lastIndex=C,i.lastIndex=C;let O=c.exec(l),j=i.exec(l),V=O?O.index:1/0,A=j?j.index:1/0;if(V<A)S++,C=V+O[0].length;else if(A<1/0){if(S--,S===0){P=A;break}C=A+j[0].length}else break}if(P===-1){console.warn(`[stx] @${s} directive at position ${h} has no matching @${o} \u2014 the block was skipped.`);break}let R=l.substring(E,P),T=-1,_=0,M=0;while(M<R.length){let O=R.indexOf("@",M);if(O===-1)break;let j=R.substring(O);if(b.test(j)){_++,M=O+1;continue}if(y.test(j)){_--,M=O+1;continue}if(_===0&&/^@else(?![a-z])/.test(j)){T=O;break}M=O+1}let I;if(T!==-1){let O=R.slice(0,T),j=R.slice(T+5);I=r?O:j}else I=r?R:"";let F=`@${o}`.length;l=l.substring(0,h)+I+l.substring(P+F),x=!0}return l}return n=a(n,"env","endenv",!1),n=a(n,"production","endproduction",v==="production"),n=a(n,"development","enddevelopment",v==="development"),n=a(n,"staging","endstaging",v==="staging"),n=a(n,"testing","endtesting",v==="testing"),n}
3
- export{ue,Go,Xo,Jo};
2
+ import{d,m,hl,p,t,u}from"./chunk-csymxc5a.js";import{rt,Et,hn,ti}from"./chunk-a8164hnf.js";function L(w,e){try{let g=w.trim();if(m(g))return p(g,Object.keys(e))(...Object.values(e));else return d(g,e)}catch{return!1}}function Q(w,e,g){let n=w,v=!0;while(v){v=!1;let a=n.match(/@switch\s*\(/);if(!a||a.index===void 0)break;let f=a.index,s=ti(n,f);if(!s)break;try{let o;if(m(s.expression))o=p(s.expression,Object.keys(e))(...Object.values(e));else o=d(s.expression,e);let r="",c=!1;for(let i of s.cases)if(i.type==="default"){if(!c)r=i.content.trim()}else try{let b;if(i.value&&m(i.value))b=p(i.value,Object.keys(e))(...Object.values(e));else if(i.value)b=d(i.value,e);if(o===b){r=i.content.trim(),c=!0;break}}catch{continue}n=n.substring(0,f)+r+n.substring(s.end),v=!0}catch(o){let r=o instanceof Error?o.message:String(o),c=u("Switch",`Error evaluating @switch expression: ${r}`,t.EVALUATION_ERROR);n=n.substring(0,f)+c+n.substring(s.end);break}}return n}function H(w){let e=[];return{masked:w.replace(/<script\b[\s\S]*?<\/script\s*>/gi,(n)=>(e.push(n),`\x00stx-script-${e.length-1}\x00`)),scripts:e}}function J(w,e){if(e.length===0)return w;return w.replace(/\u0000stx-script-(\d+)\u0000/g,(g,n)=>e[Number(n)]??g)}function de(w,e,g){let{masked:n,scripts:v}=H(w);return J(K(n,e,g),v)}function K(w,e,g){let n=w;n=Q(n,e,g);{let a=!0;while(a){a=!1;let f=n.match(/@unless\s*\(/);if(!f||f.index===void 0)break;let s=f.index,o=rt(n,s+7);if(!o)break;let r=o.endPos,c=Et(n,"unless","endunless",r);if(c===-1){console.warn(`[stx] @unless directive at position ${s} has no matching @endunless \u2014 the block was skipped. Check for typos or missing closers.`);break}let i=n.slice(r,c),b=o.expression,y=-1;{let x=0,k=/@(?:if|unless)\s*\(/g,h=/@(?:endif|endunless)(?![a-z])/g,E=/@else(?![a-z])/g,S=[],C;while((C=k.exec(i))!==null)S.push({pos:C.index,type:"open"});while((C=h.exec(i))!==null)S.push({pos:C.index,type:"close"});while((C=E.exec(i))!==null)S.push({pos:C.index,type:"else"});S.sort((P,R)=>P.pos-R.pos);for(let P of S)if(P.type==="open")x++;else if(P.type==="close")x--;else if(P.type==="else"&&x===0){y=P.pos;break}}let l;if(y!==-1){let x=i.slice(0,y),k=i.slice(y+5);l=`@if (${b})${k}@else ${x}@endif`}else l=`@if (!(${b}))${i}@endif`;n=n.substring(0,s)+l+n.substring(c+10),a=!0}}n=Go(n,e,g),n=Jo(n,e,g),n=Xo(n,e);let v=()=>{let a=hn(n);if(a.length===0)return!1;let f=Array(a.length);for(let r=a.length-1;r>=0;r--){let c=a[r];try{let i="",b=!1;for(let y of c.branches){if(b)break;if(y.type==="else")i=y.content,b=!0;else try{if(y.condition?hl(y.condition,e):!1)i=y.content,b=!0}catch(l){i=u(y.type==="if"?"If":"Elseif",`Error in @${y.type}(${y.condition}): ${l instanceof Error?l.message:String(l)}`,t.EVALUATION_ERROR),b=!0}}f[r]=i}catch(i){let b=i instanceof Error?i.message:String(i);f[r]=u("If",`Error processing @if block: ${b}`,t.EVALUATION_ERROR)}}let s=Array(a.length*2+1),o=0;for(let r=0;r<a.length;r++){let c=a[r];s[r*2]=n.slice(o,c.start),s[r*2+1]=f[r],o=c.end}return s[a.length*2]=n.slice(o),n=s.join(""),!0};while(!0){let a=n;if(!v())break;if(n===a)break}return n}function q(w){let e=0;while(e<w.length&&/\s/.test(w[e]))e++;if(w[e]!=="(")return null;e++;while(e<w.length&&/\s/.test(w[e]))e++;let g=w[e];if(g!=="'"&&g!=='"')return null;e++;let n=[];while(e<w.length){let v=w[e];if(v==="\\"&&e+1<w.length){n.push(w[e+1]),e+=2;continue}if(v===g){e++;break}n.push(v),e++}while(e<w.length&&/\s/.test(w[e]))e++;if(w[e]!==")")return null;return e++,{value:n.join(""),consumed:e}}function Xo(w,e){let g=w;function n(s,o,r,c){let i=1,b=c,y=new RegExp(`@${o}(?:\\s*\\(|\\s|$)`,"g"),l=new RegExp(`@${r}(?![a-z])`,"g");while(b<s.length&&i>0){y.lastIndex=b,l.lastIndex=b;let x=y.exec(s),k=l.exec(s),h=x?x.index:1/0,E=k?k.index:1/0;if(h<E)i++,b=h+x[0].length;else if(E<1/0){if(i--,i===0)return E;b=E+k[0].length}else break}return-1}function v(s,o,r){let c=0,i=new RegExp(`@${o}(?:\\s*\\(|\\s|$)`,"g"),b=new RegExp(`@${r}(?![a-z])`,"g"),y=/@else(?![a-z])/g,l=[],x;while((x=i.exec(s))!==null)l.push({pos:x.index,type:"open"});while((x=b.exec(s))!==null)l.push({pos:x.index,type:"close"});while((x=y.exec(s))!==null)l.push({pos:x.index,type:"else"});l.sort((k,h)=>k.pos-h.pos);for(let k of l)if(k.type==="open")c++;else if(k.type==="close")c--;else if(k.type==="else"&&c===0)return k.pos;return-1}{let s=!0;while(s){s=!1;let o=g.match(/@auth(?:\s*\(|\s|(?=\n))/);if(!o||o.index===void 0)break;let r=o.index,c,i,b=g.slice(r+5),y=q(b);if(y)c=y.value,i=r+5+y.consumed;else i=r+5;let l=n(g,"auth","endauth",i);if(l===-1){console.warn(`[stx] @auth directive at position ${r} has no matching @endauth \u2014 the block was skipped.`);break}let x=g.slice(i,l),k=v(x,"auth","endauth"),h;if(!e.auth)h=!1;else h=c?L(`auth?.check && auth?.user?.[${c}]`,e):L("auth?.check",e);let E;if(k!==-1){let S=x.slice(0,k),C=x.slice(k+5);E=h?S:C}else E=h?x:"";g=g.substring(0,r)+E+g.substring(l+8),s=!0}}{let s=!0;while(s){s=!1;let o=g.match(/@guest(?:\s*\(|\s|(?=\n))/);if(!o||o.index===void 0)break;let r=o.index,c,i,b=g.slice(r+6),y=q(b);if(y)c=y.value,i=r+6+y.consumed;else i=r+6;let l=n(g,"guest","endguest",i);if(l===-1){console.warn(`[stx] @guest directive at position ${r} has no matching @endguest \u2014 the block was skipped.`);break}let x=g.slice(i,l),k=v(x,"guest","endguest"),h;if(!e.auth)h=!0;else h=c?L(`!auth?.check || !auth?.user?.[${c}]`,e):L("!auth?.check",e);let E;if(k!==-1){let S=x.slice(0,k),C=x.slice(k+5);E=h?S:C}else E=h?x:"";g=g.substring(0,r)+E+g.substring(l+9),s=!0}}function a(s,o,r){if(e.userCan&&typeof e.userCan[s]==="boolean")return e.userCan[s];if(e.permissions?.check&&typeof e.permissions.check==="function")try{let c=[s];if(o)c.push(o);if(r){let i=L(r,e);c.push(i)}return e.permissions.check(...c)}catch{return!1}return!1}function f(s){let o=s.match(/^\s*\(\s*'([^']*)'(?:,\s*'([^']*)')?(?:,\s*([^)]*))?\)/);if(!o)return null;return{ability:o[1],type:o[2],id:o[3]?.trim(),paramsEnd:o[0].length}}for(let s of["can","cannot"]){let o=`end${s}`,r=s==="can"?"elsecan":"elsecannot",c=!0;while(c){c=!1;let i=g.match(new RegExp(`@${s}\\s*\\(`));if(!i||i.index===void 0)break;let b=i.index,y=g.slice(b+`@${s}`.length),l=f(y);if(!l)break;let x=b+`@${s}`.length+l.paramsEnd,k=n(g,s,o,x);if(k===-1){console.warn(`[stx] @${s} directive at position ${b} has no matching @${o} \u2014 the block was skipped.`);break}let h=g.slice(x,k),E=[],S=0,C=new RegExp(`@${s}\\s*\\(`,"g"),P=new RegExp(`@${o}(?![a-z])`,"g"),R=new RegExp(`@${r}\\s*\\(`,"g"),T=/@else(?![a-z])/g,_=[],M;while((M=C.exec(h))!==null)_.push({pos:M.index,type:"open"});while((M=P.exec(h))!==null)_.push({pos:M.index,type:"close"});while((M=R.exec(h))!==null)_.push({pos:M.index,type:"elseDirective"});while((M=T.exec(h))!==null)_.push({pos:M.index,type:"else"});_.sort((A,z)=>A.pos-z.pos);for(let A of _){if(A.type==="open"){S++;continue}if(A.type==="close"){S--;continue}if(S===0)E.push(A)}let I=[],F=0;for(let A=0;A<E.length;A++){let z=E[A];if(I.push({content:h.slice(F,z.pos),ability:void 0}),z.type==="elseDirective"){let D=h.slice(z.pos+`@${r}`.length),B=f(D);if(B){I[I.length-1]={content:h.slice(F,z.pos)},F=z.pos+`@${r}`.length+B.paramsEnd,I.push({content:"",ability:B.ability,type:B.type,id:B.id}),I.pop();let G=E[A+1],U=G?G.pos:h.length;I.push({content:h.slice(F,U),ability:B.ability,type:B.type,id:B.id}),F=U}}else F=z.pos+5}if(F<h.length){let A=I[I.length-1];if(E.length>0&&E[E.length-1].type==="else")I.push({content:h.slice(F),isFinalElse:!0});else if(I.length===0)I.push({content:h.slice(F)})}let O=a(l.ability,l.type,l.id),j=s==="can"?O:!O,V="";if(j)V=I[0]?.content||"";else{let A=!1;for(let z=1;z<I.length;z++){let D=I[z];if(D.isFinalElse){V=D.content,A=!0;break}if(D.ability){let B=a(D.ability,D.type,D.id);if(s==="can"?B:!B){V=D.content,A=!0;break}}}if(!A&&I.length>0){let z=I[I.length-1];if(z.isFinalElse)V=z.content}}g=g.substring(0,b)+V+g.substring(k+`@${o}`.length),c=!0}}return g}function Go(w,e,g){let n=w;function v(a,f,s,o,r){let c=!0;while(c){c=!1;let i=new RegExp(`@${f}\\s*\\(`),b=a.match(i);if(!b||b.index===void 0)break;let y=b.index,l=rt(a,y+`@${f}`.length);if(!l)break;let x=l.endPos,k=Et(a,f,s,x);if(k===-1){console.warn(`[stx] @${f} directive at position ${y} has no matching @${s} \u2014 the block was skipped.`);break}let h=a.slice(x,k),E=l.expression,S=-1,C=0,P=0;while(P<h.length){let R=h.indexOf("@",P);if(R===-1)break;let T=h.substring(R);if(/^@(?:if|unless|isset|empty)\s*\(/.test(T)){C++,P=R+1;continue}if(/^@(?:endif|endunless|endisset|endempty)(?![a-z])/.test(T)){C--,P=R+1;continue}if(C===0&&/^@else(?![a-z])/.test(T)){S=R;break}P=R+1}try{let R=o(E.trim()),T;if(S!==-1){let _=h.slice(0,S),M=h.slice(S+5);T=R?_:M}else T=R?h:"";a=a.substring(0,y)+T+a.substring(k+`@${s}`.length),c=!0}catch(R){let T=R instanceof Error?R.message:String(R),_=u(r,`Error processing @${f} directive: ${T}`,t.EVALUATION_ERROR);a=a.substring(0,y)+_+a.substring(k+`@${s}`.length);break}}return a}return n=v(n,"isset","endisset",(a)=>{let f=L(a,e);return f!==void 0&&f!==null},"Isset"),n=v(n,"empty","endempty",(a)=>{let f=L(a,e);return f===void 0||f===null||f===""||f===0||f===!1||Array.isArray(f)&&f.length===0||typeof f==="object"&&f!==null&&Object.keys(f).length===0},"Empty"),n}function Jo(w,e,g){let n=w,v="development";function a(f,s,o,r){let c=new RegExp(`@${s}(?![a-z])`,"g"),i=new RegExp(`@${o}(?![a-z])`,"g"),b=new RegExp(`^@${s}(?![a-z])`),y=new RegExp(`^@${o}(?![a-z])`),l=f,x=!0;while(x){x=!1,c.lastIndex=0;let k=c.exec(l);if(!k)break;let h=k.index,E=h+k[0].length;if(s==="env"){let O=l.substring(E).match(/^\s*\(\s*(['"])([^'"]+)\1\s*\)/);if(!O)break;E+=O[0].length,r=v===O[2]}let S=1,C=E,P=-1;while(S>0&&C<l.length){c.lastIndex=C,i.lastIndex=C;let O=c.exec(l),j=i.exec(l),V=O?O.index:1/0,A=j?j.index:1/0;if(V<A)S++,C=V+O[0].length;else if(A<1/0){if(S--,S===0){P=A;break}C=A+j[0].length}else break}if(P===-1){console.warn(`[stx] @${s} directive at position ${h} has no matching @${o} \u2014 the block was skipped.`);break}let R=l.substring(E,P),T=-1,_=0,M=0;while(M<R.length){let O=R.indexOf("@",M);if(O===-1)break;let j=R.substring(O);if(b.test(j)){_++,M=O+1;continue}if(y.test(j)){_--,M=O+1;continue}if(_===0&&/^@else(?![a-z])/.test(j)){T=O;break}M=O+1}let I;if(T!==-1){let O=R.slice(0,T),j=R.slice(T+5);I=r?O:j}else I=r?R:"";let F=`@${o}`.length;l=l.substring(0,h)+I+l.substring(P+F),x=!0}return l}return n=a(n,"env","endenv",!1),n=a(n,"production","endproduction",v==="production"),n=a(n,"development","enddevelopment",v==="development"),n=a(n,"staging","endstaging",v==="staging"),n=a(n,"testing","endtesting",v==="testing"),n}
3
+ export{de,Xo,Go,Jo};
@@ -1,4 +1,4 @@
1
1
  // @bun
2
- import{existsSync as A,mkdtempSync as D,readdirSync as M,rmSync as b,statSync as g,writeFileSync as k}from"fs";import{constants as P,tmpdir as x}from"os";import{join as s}from"path";import t from"process";var _=/^stx-(?:.+-)?p(\d+)-\w{6}$/,v=".stx-keep",I=60000,N=["SIGINT","SIGTERM","SIGHUP"],i=new Set,y=new Set,c=!1,S=new Set;function p(e){try{b(e,{recursive:!0,force:!0})}catch{}}function R(){for(let e of i)p(e);i.clear(),f()}function E(){for(let e of i)p(e);i.clear()}function C(e){if(R(),t.listenerCount(e)===0)t.exit(128+(P.signals[e]??1))}var h=new Map(N.map((e)=>[e,()=>C(e)]));function G(){if(c)return;c=!0,t.on("exit",E);for(let[e,n]of h)try{t.on(e,n)}catch{}}function f(){if(!c)return;c=!1,t.off("exit",E);for(let[e,n]of h)t.off(e,n)}function K(e){try{return t.kill(e,0),!0}catch(n){return n.code==="EPERM"}}function O(e={}){let n=e.root??x(),r=e.isAlive??K,w=e.minAgeMs??I,T=e.now??Date.now(),a=[],u;try{u=M(n)}catch{return a}for(let d of u){let l=_.exec(d);if(!l)continue;let m=Number(l[1]);if(m===t.pid||r(m))continue;let o=s(n,d);try{if(!g(o).isDirectory())continue;if(T-g(o).mtimeMs<w)continue;if(A(s(o,v)))continue}catch{continue}p(o),a.push(o)}return a}function L(e){let n=e.replace(/^stx-/,"").replace(/-+$/,"");return n?`stx-${n}-p${t.pid}-`:`stx-p${t.pid}-`}function z(e=t.env){let n=e.STX_KEEP_TEMP?.trim().toLowerCase();return!!n&&n!=="0"&&n!=="false"}function Ze(e="stx",n=x()){if(!S.has(n))S.add(n),O({root:n});let r=D(s(n,L(e)));if(z())return H(r),console.warn(`[stx] STX_KEEP_TEMP: keeping ${r}`),r;return G(),i.add(r),r}function le(e){if(y.has(e))return;if(p(e),i.delete(e),i.size===0)f()}function H(e){try{k(s(e,v),`kept by pid ${t.pid}
3
- `)}catch{}if(y.add(e),i.delete(e),i.size===0)f()}async function cc(e,n){let r=Ze(e);try{return await n(r)}finally{le(r)}}
4
- export{Ze,le,cc};
2
+ import{existsSync as A,mkdtempSync as D,readdirSync as M,rmSync as b,statSync as g,writeFileSync as k}from"fs";import{constants as P,tmpdir as x}from"os";import{join as s}from"path";import t from"process";var _=/^stx-(?:.+-)?p(\d+)-\w{6}$/,v=".stx-keep",I=60000,N=["SIGINT","SIGTERM","SIGHUP"],i=new Set,y=new Set,c=!1,S=new Set;function p(e){try{b(e,{recursive:!0,force:!0})}catch{}}function R(){for(let e of i)p(e);i.clear(),f()}function E(){for(let e of i)p(e);i.clear()}function C(e){if(R(),t.listenerCount(e)===0)t.exit(128+(P.signals[e]??1))}var h=new Map(N.map((e)=>[e,()=>C(e)]));function G(){if(c)return;c=!0,t.on("exit",E);for(let[e,n]of h)try{t.on(e,n)}catch{}}function f(){if(!c)return;c=!1,t.off("exit",E);for(let[e,n]of h)t.off(e,n)}function K(e){try{return t.kill(e,0),!0}catch(n){return n.code==="EPERM"}}function O(e={}){let n=e.root??x(),r=e.isAlive??K,w=e.minAgeMs??I,T=e.now??Date.now(),a=[],u;try{u=M(n)}catch{return a}for(let d of u){let l=_.exec(d);if(!l)continue;let m=Number(l[1]);if(m===t.pid||r(m))continue;let o=s(n,d);try{if(!g(o).isDirectory())continue;if(T-g(o).mtimeMs<w)continue;if(A(s(o,v)))continue}catch{continue}p(o),a.push(o)}return a}function L(e){let n=e.replace(/^stx-/,"").replace(/-+$/,"");return n?`stx-${n}-p${t.pid}-`:`stx-p${t.pid}-`}function z(e=t.env){let n=e.STX_KEEP_TEMP?.trim().toLowerCase();return!!n&&n!=="0"&&n!=="false"}function Ze(e="stx",n=x()){if(!S.has(n))S.add(n),O({root:n});let r=D(s(n,L(e)));if(z())return H(r),console.warn(`[stx] STX_KEEP_TEMP: keeping ${r}`),r;return G(),i.add(r),r}function ue(e){if(y.has(e))return;if(p(e),i.delete(e),i.size===0)f()}function H(e){try{k(s(e,v),`kept by pid ${t.pid}
3
+ `)}catch{}if(y.add(e),i.delete(e),i.size===0)f()}async function cc(e,n){let r=Ze(e);try{return await n(r)}finally{ue(r)}}
4
+ export{Ze,ue,cc};
@@ -1,15 +1,15 @@
1
1
  // @bun
2
- import{E,Oi,eo,d,m,O,ut,p,to,t,u,k}from"./chunk-0tyyad6q.js";import{Ce,jt,te,j,Cn,re,R}from"./chunk-hze3158c.js";import{fr}from"./chunk-sew1z7cv.js";import{ue}from"./chunk-hvx6j4a2.js";import{Cs}from"./chunk-311mrz2n.js";var he=1000,me=!1;function xe(n,r){let i=/@(include|partial)\s*\(\s*(['"])([^'"]+)\2\s*,\s*/g,e="",o=0,s;while((s=i.exec(n))!==null){let l=s.index+s[0].length,b=s.index+s[0].indexOf("("),x=k(n,"(",")",b);if(x===-1)continue;let f=n.slice(l,x).trim();if(!f)continue;if(!Object.keys(r).some((a)=>new RegExp(`(?:^|[^\\w$.])${a.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}(?![\\w$])`).test(f)))continue;let h;try{let a=O(f,r);if(!a||typeof a!=="object")continue;h=JSON.stringify(a)}catch{continue}e+=n.slice(o,l)+h,o=x,i.lastIndex=x}return o===0?n:e+n.slice(o)}function be(n,r){let i=/@component\s*\(/g,e=n,o,s=[];while((o=i.exec(e))!==null){let l=o.index,b=l+o[0].length-1,x=1,f=b+1;while(f<e.length&&x>0){if(e[f]==="(")x++;else if(e[f]===")"){if(x--,x===0)break}f++}if(x!==0)continue;let c=e.substring(b+1,f),h=f+1,a=c.match(/^\s*['"]([^'"]+)['"]/);if(!a)continue;let y=a[1],g=c.slice(a[0].length),w=g.match(/^\s*,\s*/);if(!w)continue;let S=g.slice(w[0].length).trim();if(!S)continue;try{let F=O(S,r),B=JSON.stringify(F),v=`@component('${y}', ${B})`;s.push({start:l,end:h,replacement:v})}catch{continue}}for(let l=s.length-1;l>=0;l--){let{start:b,end:x,replacement:f}=s[l];e=e.substring(0,b)+f+e.substring(x)}return e}function ie(n,r,i){let e=n,o=new RegExp(`${r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\(`),s;while((s=o.exec(e))!==null){let l=s.index,b=l+s[0].length-1,x=1,f=b+1,c=null,h=!1;while(f<e.length&&x>0){let g=e[f];if(h){h=!1,f++;continue}if(g==="\\"&&c){h=!0,f++;continue}if(c){if(g===c)c=null;f++;continue}if(g==='"'||g==="'"||g==="`"){c=g,f++;continue}if(g==="(")x++;else if(g===")"){if(x--,x===0)break}f++}if(x!==0)break;let a=e.substring(b+1,f),y=i(a);e=e.substring(0,l)+y+e.substring(f+1)}return e}function ye(n,r){let i=n;return i=i.replace(/:([a-zA-Z_][a-zA-Z0-9_-]*)(?=\s+[^=]|\s*\/?>|\s*$)/g,(e,o)=>{if(o in r)return`:${o}="${o}"`;return e}),i=i.replace(/:([a-zA-Z_][a-zA-Z0-9_-]*)\s*=\s*"([^"]*)"/g,(e,o,s)=>{try{if(j(s,r.__stx_client_signal_names||[]))return e;let l=Object.keys(r),b=Object.values(r);Oi(s);let x=!1,c=p(s,l,()=>{x=!0})(...b);if(x)return e;let h=JSON.stringify(c);if(h===void 0){if(!ut(s).some((g)=>!(g in r)))return"";return e}let a=Buffer.from(h,"utf8").toString("base64");return`__stx_${o}="${a}"`}catch(l){return e}}),i}var Q="<!--__STX_BREAK__-->",ee="<!--__STX_CONTINUE__-->";function ae(n,r){let i=/\{\{\{?|\{!!|@(break|continue)(?![\w$])/g,e="",o=0;for(let s=i.exec(n);s;s=i.exec(n)){if(!s[1]){let f=s[0].length===3&&s[0]==="{{{"?3:2,c=s[0]==="{!!"?n.indexOf("!!}",i.lastIndex):Ce(n,s.index,f);if(c<0)break;i.lastIndex=c+(s[0]==="{!!"?3:f);continue}let l=i.lastIndex,b=!0,x=/^\s*\(/.exec(n.slice(l));if(x){let f=l+x[0].length-1,c=k(n,"(",")",f);if(c<0)break;l=c+1;try{let h=`!!(${n.slice(f+1,c).trim()})`;b=m(h)?Boolean(p(h,Object.keys(r))(...Object.values(r))):Boolean(d(h,r))}catch{b=!1}}if(e+=n.slice(o,s.index),b)return e+(s[1]==="break"?Q:ee);o=l,i.lastIndex=l}return e+n.slice(o)}function fe(n){let r=(o)=>o.replace(/\\/g,"\\\\").replace(/`/g,"\\`").replace(/\$\{/g,"\\${"),i="",e=0;return Cn(n,(o,s,l)=>(i+=ce(r(n.slice(e,l))),i+=`\${__stxRenderLoopValue(${l}, (${s}), ${o.length})}`,e=l+o.length,o)),i+ce(r(n.slice(e)))}function ge(n,r,i,e){return re(n,r,i==null?"":String(i),!1,e)}function ce(n){let r=n;return r=ie(r,"@break",(i)=>{let e=i.trim();if(!to(e))return"";return`\`; if (${e}) { break; } result += \``}),r=ie(r,"@continue",(i)=>{let e=i.trim();if(!to(e))return"";return`\`; if (${e}) { continue; } result += \``}),r=r.replace(/@break(?!\()/g,"`; break; result += `"),r=r.replace(/@continue(?!\()/g,"`; continue; result += `"),r}function Ee(n){let r=/@forelse\s*\(/g,i,e=[],o=/@foreach\s*\(/g,s=/@endforeach/g,l;while((l=o.exec(n))!==null)e.push({pos:l.index,delta:1});while((l=s.exec(n))!==null)e.push({pos:l.index,delta:-1});e.sort((c,h)=>c.pos-h.pos);let b=[],x=0;for(let c of e)x+=c.delta,b.push({pos:c.pos,depth:x});function f(c){let h=0,a=b.length-1,y=0;while(h<=a){let g=h+a>>1;if(b[g].pos<=c)y=b[g].depth,h=g+1;else a=g-1}return y}while((i=r.exec(n))!==null){if(f(i.index)>0)continue;let c=i.index,h=i.index+i[0].length-1,a=1,y=h+1,g=-1;while(y<n.length&&a>0){if(n[y]==="(")a++;else if(n[y]===")"){if(a--,a===0){g=y;break}}y++}if(g===-1)continue;let w=n.substring(h+1,g),S=jt(w);if(!S)continue;let{arrayExpr:F,itemVar:B}=S,v=g+1,A=1,T=v,K=/@forelse\s*\(/g,L=/@endforelse/g,V=-1;while(A>0&&T<n.length){K.lastIndex=T,L.lastIndex=T;let P=K.exec(n),_=L.exec(n);if(!_)break;if(P&&P.index<_.index)A++,T=P.index+P[0].length;else{if(A--,A===0){V=_.index;break}T=_.index+11}}if(V===-1)continue;let I=n.substring(v,V),Z=V+11,z=-1,D=0,N=0;while(N<I.length){let P=I.indexOf("@",N);if(P===-1)break;let _=I.substring(P);if(/^@forelse\s*\(/.test(_))D++,N=P+1;else if(_.startsWith("@endforelse"))D--,N=P+11;else if(D===0&&_.startsWith("@empty")){if(I.length<=P+6||!/[a-z]/i.test(I[P+6])){z=P;break}N=P+1}else N=P+1}if(z===-1)continue;return{start:c,end:Z,arrayExpr:F,itemVar:B,foreachContent:I.substring(0,z),emptyContent:I.substring(z+6)}}return null}function le(n,r){let i=n;while(!0){let e=Ee(i);if(!e)break;let{start:o,end:s,arrayExpr:l,itemVar:b,foreachContent:x,emptyContent:f}=e;try{let c;if(m(l))c=p(l,Object.keys(r))(...Object.values(r));else c=d(l,r);let h;if(!Array.isArray(c)||c.length===0)h=f;else h=`@foreach (${l} as ${b})${x}@endforeach`;i=i.substring(0,o)+h+i.substring(s)}catch(c){let h=c instanceof Error?c.message:String(c),a=u("Forelse",`Error in @forelse(${l} as ${b}): ${h}`,t.EVALUATION_ERROR);i=i.substring(0,o)+a+i.substring(s)}}return i}var de="<!--stx:foreach-not-iterable:",_e=/<!--stx:foreach-not-iterable:([^|>]*)\|([^>]*?)-->/g;function $e(n,r){return`${de}${encodeURIComponent(n)}|${encodeURIComponent(r)}-->`}function Re(n,r){console.warn(`[stx] @foreach(${n}) in ${r}: ${n} is not iterable server-side, so the loop rendered nothing. `+"Values a server loop reads must come from <script server> or the page context \u2014 "+"a plain <script> runs in the browser.")}function ws(n){if(!n.includes(de))return n;return n.replace(_e,(r,i,e)=>(Re(decodeURIComponent(i),decodeURIComponent(e)),""))}function Jf(n,r,i,e,o=!1){let s=ne(n,r,i,e,o),l=s.next();while(!l.done)l=s.next();return l.value}async function Ko(n,r,i,e,o=!1){let s=ne(n,r,i,e,o),l=s.next();while(!l.done)await E(),l=s.next();return l.value}function*ne(n,r,i,e,o=!1){let s=n,l=new Set(r.__stx_client_signal_names||[]);for(let c of fr(n))l.add(c);if(l.size)r={...r,__stx_client_signal_names:[...l]};s=le(s,r);function b(c){let h=/@foreach\s*\(/g,a;while((a=h.exec(c))!==null){let y=a.index,g=a.index+a[0].length-1,w=1,S=g+1,F=-1;while(S<c.length&&w>0){if(c[S]==="(")w++;else if(c[S]===")"){if(w--,w===0){F=S;break}}S++}if(F===-1)continue;let B=c.substring(g+1,F),v=jt(B);if(!v)continue;let A=y,{arrayExpr:T,itemVar:K}=v,L=F+1,V=1,I=L,Z=/@foreach\s*\(/g,z=/@endforeach/g;while(V>0&&I<c.length){Z.lastIndex=I,z.lastIndex=I;let D=Z.exec(c),N=z.exec(c);if(!N)break;if(D&&D.index<N.index)V++,I=D.index+D[0].length;else{if(V--,V===0){let P=c.substring(L,N.index),_=N.index+11;return{start:A,end:_,arrayExpr:T,itemVar:K,content:P}}I=N.index+11}}}return null}function*x(c,h){let a=c;while(!0){let y=b(a);if(!y)break;let{start:g,end:w,arrayExpr:S,itemVar:F,content:B}=y;try{let v=S.trim(),A;if(m(v))A=p(v,Object.keys(h))(...Object.values(h));else A=d(v,h);let T=!1;if(!Array.isArray(A))if(A instanceof Map)A=Array.from(A),T=!0;else if(A instanceof Set)A=Array.from(A);else if(typeof A==="string")A=Array.from(A);else if(A&&typeof A==="object"&&!(A instanceof Date)&&!(A instanceof RegExp))A=Object.entries(A),T=!0;else{let _=$e(v,i)+u("Foreach",`Error in @foreach: ${v} is not iterable`,t.TYPE_ERROR);a=a.substring(0,g)+_+a.substring(w);continue}let K=e?.loops?.useAltLoopVariable??me,L=F.trim(),V=null,I,Z=!1;if(L.includes("=>")){let _=L.split("=>").map((W)=>W.trim());if(_.length===2&&_[0]&&_[1])V=_[0],I=_[1];else I=L}else if(!L.startsWith("[")&&!L.startsWith("{")&&L.includes(",")){let _=L.split(",").map((W)=>W.trim());if(_.length===2&&_[0]&&_[1])I=_[0],V=_[1],Z=!0;else I=L}else I=L;let z="",D=new Set(te(`${S} as ${F}`)),N=A,P=h[eo]??new WeakMap;for(let _=0;_<N.length;_++){if(_%16===0)yield;let W=N[_],se={index:_,iteration:_+1,first:_===0,last:_===N.length-1,count:N.length},M={...h,loop:se,$loop:se,[eo]:P};if(Array.isArray(h.__stx_client_signal_names))M.__stx_client_signal_names=h.__stx_client_signal_names.filter((H)=>!D.has(H));if(I.startsWith("[")&&I.endsWith("]")){let H=I.slice(1,-1).split(",").map((U)=>U.trim());if(Array.isArray(W))H.forEach((U,X)=>{if(U)M[U]=W[X]});else M[I]=W}else if(I.startsWith("{")&&I.endsWith("}")){let H=I.slice(1,-1).split(",").map((U)=>U.trim()).filter(Boolean);if(W!==null&&typeof W==="object")H.forEach((U)=>{let X=U.indexOf(":"),Y=(X===-1?U:U.slice(0,X)).trim(),oe=X===-1?Y:U.slice(X+1).trim();if(Y&&oe)M[oe]=W[Y]});else M[I]=W}else M[I]=W;if(V)if(!Z&&T&&Array.isArray(W)&&W.length===2)M[V]=W[0],M[I]=W[1];else M[V]=_;let C=le(B,M);C=yield*ne(C,M,i,e,!0),C=ue(C,M,i),C=ae(C,M);let J=C.indexOf(Q),G=C.indexOf(ee),q=J<0?G:G<0?J:Math.min(J,G);if(q>=0)C=C.slice(0,q);if(C=R(C,M,i),C=ye(C,M),C=be(C,M),C=xe(C,M),z+=C,q>=0&&q===J)break}a=a.substring(0,g)+z+a.substring(w)}catch(v){let A=u("Foreach",`Error in @foreach(${S.trim()} as ${F.trim()}): ${v instanceof Error?v.message:String(v)}`,t.EVALUATION_ERROR);a=a.substring(0,g)+A+a.substring(w)}}return a}s=yield*x(s,r),s=Ae(s,r,i,e);let f=e?.loops?.maxWhileIterations??he;return s=ke(s,r,f),o?s:ws(s)}function Yf(n){let r=/^(\s*)([A-Za-z_$][\w$]*|\[[^\]]*\]|\{[^}]*\})(\s+(?:of|in)\s)/.exec(n);if(!r||/^(?:const|let|var)$/.test(r[2]))return n;return`${r[1]}let ${n.slice(r[1].length)}`}function pe(n){return to(n)}function Ae(n,r,i,e){let o=n,s=!0;while(s){s=!1;let l=o.match(/@for\s*\(/);if(!l||l.index===void 0)break;let b=l.index,x=b+l[0].length-1,f=k(o,"(",")",x);if(f===-1)break;let c=Yf(o.slice(x+1,f)),h=f+1,a=Cs(o.slice(b),"for","endfor");if(a.length===0)break;let y=a[0].content,g=b+a[0].end;if(!pe(c)){let w=u("For",`Unsafe expression in @for: ${c}`,t.UNSAFE_EXPRESSION);o=o.substring(0,b)+w+o.substring(g),s=!0;continue}try{let w=we(c),S=/@(?:for|foreach|if|unless)\s*\(/.test(y);if(w.length>0&&S){let K=Oe({forExpr:c,content:y,iterVarNames:w,context:r,filePath:i,options:e});o=o.substring(0,b)+K+o.substring(g),s=!0;continue}let F=Object.keys(r),B=Object.values(r),v=fe(y),T=Function(...F,"__stxRenderLoopValue",`
2
+ import{E,Oi,eo,d,m,O,ut,p,to,t,u,k}from"./chunk-csymxc5a.js";import{Ce,jt,ne,j,Cn,se,R}from"./chunk-pnqdwqw9.js";import{fr}from"./chunk-bfvr4byj.js";import{de}from"./chunk-vvxcebpn.js";import{Cs}from"./chunk-a8164hnf.js";var he=1000,me=!1;function xe(n,r){let i=/@(include|partial)\s*\(\s*(['"])([^'"]+)\2\s*,\s*/g,e="",o=0,s;while((s=i.exec(n))!==null){let l=s.index+s[0].length,b=s.index+s[0].indexOf("("),x=k(n,"(",")",b);if(x===-1)continue;let f=n.slice(l,x).trim();if(!f)continue;if(!Object.keys(r).some((a)=>new RegExp(`(?:^|[^\\w$.])${a.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}(?![\\w$])`).test(f)))continue;let h;try{let a=O(f,r);if(!a||typeof a!=="object")continue;h=JSON.stringify(a)}catch{continue}e+=n.slice(o,l)+h,o=x,i.lastIndex=x}return o===0?n:e+n.slice(o)}function be(n,r){let i=/@component\s*\(/g,e=n,o,s=[];while((o=i.exec(e))!==null){let l=o.index,b=l+o[0].length-1,x=1,f=b+1;while(f<e.length&&x>0){if(e[f]==="(")x++;else if(e[f]===")"){if(x--,x===0)break}f++}if(x!==0)continue;let c=e.substring(b+1,f),h=f+1,a=c.match(/^\s*['"]([^'"]+)['"]/);if(!a)continue;let y=a[1],g=c.slice(a[0].length),w=g.match(/^\s*,\s*/);if(!w)continue;let S=g.slice(w[0].length).trim();if(!S)continue;try{let F=O(S,r),B=JSON.stringify(F),v=`@component('${y}', ${B})`;s.push({start:l,end:h,replacement:v})}catch{continue}}for(let l=s.length-1;l>=0;l--){let{start:b,end:x,replacement:f}=s[l];e=e.substring(0,b)+f+e.substring(x)}return e}function ie(n,r,i){let e=n,o=new RegExp(`${r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\(`),s;while((s=o.exec(e))!==null){let l=s.index,b=l+s[0].length-1,x=1,f=b+1,c=null,h=!1;while(f<e.length&&x>0){let g=e[f];if(h){h=!1,f++;continue}if(g==="\\"&&c){h=!0,f++;continue}if(c){if(g===c)c=null;f++;continue}if(g==='"'||g==="'"||g==="`"){c=g,f++;continue}if(g==="(")x++;else if(g===")"){if(x--,x===0)break}f++}if(x!==0)break;let a=e.substring(b+1,f),y=i(a);e=e.substring(0,l)+y+e.substring(f+1)}return e}function ye(n,r){let i=n;return i=i.replace(/:([a-zA-Z_][a-zA-Z0-9_-]*)(?=\s+[^=]|\s*\/?>|\s*$)/g,(e,o)=>{if(o in r)return`:${o}="${o}"`;return e}),i=i.replace(/:([a-zA-Z_][a-zA-Z0-9_-]*)\s*=\s*"([^"]*)"/g,(e,o,s)=>{try{if(j(s,r.__stx_client_signal_names||[]))return e;let l=Object.keys(r),b=Object.values(r);Oi(s);let x=!1,c=p(s,l,()=>{x=!0})(...b);if(x)return e;let h=JSON.stringify(c);if(h===void 0){if(!ut(s).some((g)=>!(g in r)))return"";return e}let a=Buffer.from(h,"utf8").toString("base64");return`__stx_${o}="${a}"`}catch(l){return e}}),i}var Q="<!--__STX_BREAK__-->",ee="<!--__STX_CONTINUE__-->";function ae(n,r){let i=/\{\{\{?|\{!!|@(break|continue)(?![\w$])/g,e="",o=0;for(let s=i.exec(n);s;s=i.exec(n)){if(!s[1]){let f=s[0].length===3&&s[0]==="{{{"?3:2,c=s[0]==="{!!"?n.indexOf("!!}",i.lastIndex):Ce(n,s.index,f);if(c<0)break;i.lastIndex=c+(s[0]==="{!!"?3:f);continue}let l=i.lastIndex,b=!0,x=/^\s*\(/.exec(n.slice(l));if(x){let f=l+x[0].length-1,c=k(n,"(",")",f);if(c<0)break;l=c+1;try{let h=`!!(${n.slice(f+1,c).trim()})`;b=m(h)?Boolean(p(h,Object.keys(r))(...Object.values(r))):Boolean(d(h,r))}catch{b=!1}}if(e+=n.slice(o,s.index),b)return e+(s[1]==="break"?Q:ee);o=l,i.lastIndex=l}return e+n.slice(o)}function ue(n){let r=(o)=>o.replace(/\\/g,"\\\\").replace(/`/g,"\\`").replace(/\$\{/g,"\\${"),i="",e=0;return Cn(n,(o,s,l)=>(i+=ce(r(n.slice(e,l))),i+=`\${__stxRenderLoopValue(${l}, (${s}), ${o.length})}`,e=l+o.length,o)),i+ce(r(n.slice(e)))}function fe(n,r,i,e){return se(n,r,i==null?"":String(i),!1,e)}function ce(n){let r=n;return r=ie(r,"@break",(i)=>{let e=i.trim();if(!to(e))return"";return`\`; if (${e}) { break; } result += \``}),r=ie(r,"@continue",(i)=>{let e=i.trim();if(!to(e))return"";return`\`; if (${e}) { continue; } result += \``}),r=r.replace(/@break(?!\()/g,"`; break; result += `"),r=r.replace(/@continue(?!\()/g,"`; continue; result += `"),r}function Ee(n){let r=/@forelse\s*\(/g,i,e=[],o=/@foreach\s*\(/g,s=/@endforeach/g,l;while((l=o.exec(n))!==null)e.push({pos:l.index,delta:1});while((l=s.exec(n))!==null)e.push({pos:l.index,delta:-1});e.sort((c,h)=>c.pos-h.pos);let b=[],x=0;for(let c of e)x+=c.delta,b.push({pos:c.pos,depth:x});function f(c){let h=0,a=b.length-1,y=0;while(h<=a){let g=h+a>>1;if(b[g].pos<=c)y=b[g].depth,h=g+1;else a=g-1}return y}while((i=r.exec(n))!==null){if(f(i.index)>0)continue;let c=i.index,h=i.index+i[0].length-1,a=1,y=h+1,g=-1;while(y<n.length&&a>0){if(n[y]==="(")a++;else if(n[y]===")"){if(a--,a===0){g=y;break}}y++}if(g===-1)continue;let w=n.substring(h+1,g),S=jt(w);if(!S)continue;let{arrayExpr:F,itemVar:B}=S,v=g+1,A=1,T=v,K=/@forelse\s*\(/g,L=/@endforelse/g,V=-1;while(A>0&&T<n.length){K.lastIndex=T,L.lastIndex=T;let P=K.exec(n),_=L.exec(n);if(!_)break;if(P&&P.index<_.index)A++,T=P.index+P[0].length;else{if(A--,A===0){V=_.index;break}T=_.index+11}}if(V===-1)continue;let I=n.substring(v,V),Z=V+11,z=-1,D=0,N=0;while(N<I.length){let P=I.indexOf("@",N);if(P===-1)break;let _=I.substring(P);if(/^@forelse\s*\(/.test(_))D++,N=P+1;else if(_.startsWith("@endforelse"))D--,N=P+11;else if(D===0&&_.startsWith("@empty")){if(I.length<=P+6||!/[a-z]/i.test(I[P+6])){z=P;break}N=P+1}else N=P+1}if(z===-1)continue;return{start:c,end:Z,arrayExpr:F,itemVar:B,foreachContent:I.substring(0,z),emptyContent:I.substring(z+6)}}return null}function le(n,r){let i=n;while(!0){let e=Ee(i);if(!e)break;let{start:o,end:s,arrayExpr:l,itemVar:b,foreachContent:x,emptyContent:f}=e;try{let c;if(m(l))c=p(l,Object.keys(r))(...Object.values(r));else c=d(l,r);let h;if(!Array.isArray(c)||c.length===0)h=f;else h=`@foreach (${l} as ${b})${x}@endforeach`;i=i.substring(0,o)+h+i.substring(s)}catch(c){let h=c instanceof Error?c.message:String(c),a=u("Forelse",`Error in @forelse(${l} as ${b}): ${h}`,t.EVALUATION_ERROR);i=i.substring(0,o)+a+i.substring(s)}}return i}var ge="<!--stx:foreach-not-iterable:",_e=/<!--stx:foreach-not-iterable:([^|>]*)\|([^>]*?)-->/g;function $e(n,r){return`${ge}${encodeURIComponent(n)}|${encodeURIComponent(r)}-->`}function Re(n,r){console.warn(`[stx] @foreach(${n}) in ${r}: ${n} is not iterable server-side, so the loop rendered nothing. `+"Values a server loop reads must come from <script server> or the page context \u2014 "+"a plain <script> runs in the browser.")}function ws(n){if(!n.includes(ge))return n;return n.replace(_e,(r,i,e)=>(Re(decodeURIComponent(i),decodeURIComponent(e)),""))}function Jf(n,r,i,e,o=!1){let s=te(n,r,i,e,o),l=s.next();while(!l.done)l=s.next();return l.value}async function Ko(n,r,i,e,o=!1){let s=te(n,r,i,e,o),l=s.next();while(!l.done)await E(),l=s.next();return l.value}function*te(n,r,i,e,o=!1){let s=n,l=new Set(r.__stx_client_signal_names||[]);for(let c of fr(n))l.add(c);if(l.size)r={...r,__stx_client_signal_names:[...l]};s=le(s,r);function b(c){let h=/@foreach\s*\(/g,a;while((a=h.exec(c))!==null){let y=a.index,g=a.index+a[0].length-1,w=1,S=g+1,F=-1;while(S<c.length&&w>0){if(c[S]==="(")w++;else if(c[S]===")"){if(w--,w===0){F=S;break}}S++}if(F===-1)continue;let B=c.substring(g+1,F),v=jt(B);if(!v)continue;let A=y,{arrayExpr:T,itemVar:K}=v,L=F+1,V=1,I=L,Z=/@foreach\s*\(/g,z=/@endforeach/g;while(V>0&&I<c.length){Z.lastIndex=I,z.lastIndex=I;let D=Z.exec(c),N=z.exec(c);if(!N)break;if(D&&D.index<N.index)V++,I=D.index+D[0].length;else{if(V--,V===0){let P=c.substring(L,N.index),_=N.index+11;return{start:A,end:_,arrayExpr:T,itemVar:K,content:P}}I=N.index+11}}}return null}function*x(c,h){let a=c;while(!0){let y=b(a);if(!y)break;let{start:g,end:w,arrayExpr:S,itemVar:F,content:B}=y;try{let v=S.trim(),A;if(m(v))A=p(v,Object.keys(h))(...Object.values(h));else A=d(v,h);let T=!1;if(!Array.isArray(A))if(A instanceof Map)A=Array.from(A),T=!0;else if(A instanceof Set)A=Array.from(A);else if(typeof A==="string")A=Array.from(A);else if(A&&typeof A==="object"&&!(A instanceof Date)&&!(A instanceof RegExp))A=Object.entries(A),T=!0;else{let _=$e(v,i)+u("Foreach",`Error in @foreach: ${v} is not iterable`,t.TYPE_ERROR);a=a.substring(0,g)+_+a.substring(w);continue}let K=e?.loops?.useAltLoopVariable??me,L=F.trim(),V=null,I,Z=!1;if(L.includes("=>")){let _=L.split("=>").map((W)=>W.trim());if(_.length===2&&_[0]&&_[1])V=_[0],I=_[1];else I=L}else if(!L.startsWith("[")&&!L.startsWith("{")&&L.includes(",")){let _=L.split(",").map((W)=>W.trim());if(_.length===2&&_[0]&&_[1])I=_[0],V=_[1],Z=!0;else I=L}else I=L;let z="",D=new Set(ne(`${S} as ${F}`)),N=A,P=h[eo]??new WeakMap;for(let _=0;_<N.length;_++){if(_%16===0)yield;let W=N[_],re={index:_,iteration:_+1,first:_===0,last:_===N.length-1,count:N.length},M={...h,loop:re,$loop:re,[eo]:P};if(Array.isArray(h.__stx_client_signal_names))M.__stx_client_signal_names=h.__stx_client_signal_names.filter((H)=>!D.has(H));if(I.startsWith("[")&&I.endsWith("]")){let H=I.slice(1,-1).split(",").map((U)=>U.trim());if(Array.isArray(W))H.forEach((U,X)=>{if(U)M[U]=W[X]});else M[I]=W}else if(I.startsWith("{")&&I.endsWith("}")){let H=I.slice(1,-1).split(",").map((U)=>U.trim()).filter(Boolean);if(W!==null&&typeof W==="object")H.forEach((U)=>{let X=U.indexOf(":"),Y=(X===-1?U:U.slice(0,X)).trim(),oe=X===-1?Y:U.slice(X+1).trim();if(Y&&oe)M[oe]=W[Y]});else M[I]=W}else M[I]=W;if(V)if(!Z&&T&&Array.isArray(W)&&W.length===2)M[V]=W[0],M[I]=W[1];else M[V]=_;let C=le(B,M);C=yield*te(C,M,i,e,!0),C=de(C,M,i),C=ae(C,M);let J=C.indexOf(Q),G=C.indexOf(ee),q=J<0?G:G<0?J:Math.min(J,G);if(q>=0)C=C.slice(0,q);if(C=R(C,M,i),C=ye(C,M),C=be(C,M),C=xe(C,M),z+=C,q>=0&&q===J)break}a=a.substring(0,g)+z+a.substring(w)}catch(v){let A=u("Foreach",`Error in @foreach(${S.trim()} as ${F.trim()}): ${v instanceof Error?v.message:String(v)}`,t.EVALUATION_ERROR);a=a.substring(0,g)+A+a.substring(w)}}return a}s=yield*x(s,r),s=Ae(s,r,i,e);let f=e?.loops?.maxWhileIterations??he;return s=ke(s,r,f),o?s:ws(s)}function Yf(n){let r=/^(\s*)([A-Za-z_$][\w$]*|\[[^\]]*\]|\{[^}]*\})(\s+(?:of|in)\s)/.exec(n);if(!r||/^(?:const|let|var)$/.test(r[2]))return n;return`${r[1]}let ${n.slice(r[1].length)}`}function pe(n){return to(n)}function Ae(n,r,i,e){let o=n,s=!0;while(s){s=!1;let l=o.match(/@for\s*\(/);if(!l||l.index===void 0)break;let b=l.index,x=b+l[0].length-1,f=k(o,"(",")",x);if(f===-1)break;let c=Yf(o.slice(x+1,f)),h=f+1,a=Cs(o.slice(b),"for","endfor");if(a.length===0)break;let y=a[0].content,g=b+a[0].end;if(!pe(c)){let w=u("For",`Unsafe expression in @for: ${c}`,t.UNSAFE_EXPRESSION);o=o.substring(0,b)+w+o.substring(g),s=!0;continue}try{let w=we(c),S=/@(?:for|foreach|if|unless)\s*\(/.test(y);if(w.length>0&&S){let K=Oe({forExpr:c,content:y,iterVarNames:w,context:r,filePath:i,options:e});o=o.substring(0,b)+K+o.substring(g),s=!0;continue}let F=Object.keys(r),B=Object.values(r),v=ue(y),T=Function(...F,"__stxRenderLoopValue",`
3
3
  let result = '';
4
4
  for (${c}) {
5
5
  result += \`${v}\`;
6
6
  }
7
7
  return result;
8
- `)(...B,(K,L,V)=>ge(y,K,L,V));o=o.substring(0,b)+T+o.substring(g),s=!0}catch(w){let S=u("For",`Error in @for(${c}): ${w instanceof Error?w.message:String(w)}`,t.EVALUATION_ERROR);o=o.substring(0,b)+S+o.substring(g),s=!0}}return o}function we(n){let r=n.trim(),i=r.match(/^(?:const|let|var)\s+(\[[^\]]+\]|\{[^}]+\})\s+(?:of|in)\s+/);if(i){let s=i[1];return s.slice(1,-1).split(",").map((b)=>{let x=b.trim();if(!x)return"";let f=x.indexOf(":");if(f>=0&&s.startsWith("{")){let a=x.slice(f+1).trim(),y=a.indexOf("=");return(y>=0?a.slice(0,y):a).trim()}let c=x.indexOf("="),h=(c>=0?x.slice(0,c):x).trim();return/^[A-Za-z_$][\w$]*$/.test(h)?h:""}).filter(Boolean)}let e=r.match(/^(?:const|let|var)\s+([A-Za-z_$][\w$]*)\s+(?:of|in)\s+/);if(e)return[e[1]];let o=r.match(/^(?:const|let|var)\s+([A-Za-z_$][\w$]*)\s*=[^;]*;/);if(o)return[o[1]];return[]}function Oe(n){let{forExpr:r,content:i,iterVarNames:e,context:o,filePath:s,options:l}=n,b=Object.keys(o),x=Object.values(o),f=s??"inline.stx",c="";return Function(...b,"__renderIteration",`
8
+ `)(...B,(K,L,V)=>fe(y,K,L,V));o=o.substring(0,b)+T+o.substring(g),s=!0}catch(w){let S=u("For",`Error in @for(${c}): ${w instanceof Error?w.message:String(w)}`,t.EVALUATION_ERROR);o=o.substring(0,b)+S+o.substring(g),s=!0}}return o}function we(n){let r=n.trim(),i=r.match(/^(?:const|let|var)\s+(\[[^\]]+\]|\{[^}]+\})\s+(?:of|in)\s+/);if(i){let s=i[1];return s.slice(1,-1).split(",").map((b)=>{let x=b.trim();if(!x)return"";let f=x.indexOf(":");if(f>=0&&s.startsWith("{")){let a=x.slice(f+1).trim(),y=a.indexOf("=");return(y>=0?a.slice(0,y):a).trim()}let c=x.indexOf("="),h=(c>=0?x.slice(0,c):x).trim();return/^[A-Za-z_$][\w$]*$/.test(h)?h:""}).filter(Boolean)}let e=r.match(/^(?:const|let|var)\s+([A-Za-z_$][\w$]*)\s+(?:of|in)\s+/);if(e)return[e[1]];let o=r.match(/^(?:const|let|var)\s+([A-Za-z_$][\w$]*)\s*=[^;]*;/);if(o)return[o[1]];return[]}function Oe(n){let{forExpr:r,content:i,iterVarNames:e,context:o,filePath:s,options:l}=n,b=Object.keys(o),x=Object.values(o),f=s??"inline.stx",c="";return Function(...b,"__renderIteration",`
9
9
  for (${r}) {
10
10
  if (!__renderIteration([${e.join(", ")}])) break;
11
11
  }
12
- `)(...x,(a)=>{let y={...o};e.forEach((B,v)=>{y[B]=a[v]});let g=Jf(i,y,f,l,!0);g=ue(g,y,f),g=ae(g,y);let w=g.indexOf(Q),S=g.indexOf(ee),F=w<0?S:S<0?w:Math.min(w,S);if(F>=0)g=g.slice(0,F);return c+=R(g,y,f),F<0||F!==w}),c}function ke(n,r,i){let e=n,o=!0;while(o){o=!1;let s=e.match(/@while\s*\(/);if(!s||s.index===void 0)break;let l=s.index,b=l+s[0].length-1,x=k(e,"(",")",b);if(x===-1)break;let f=e.slice(b+1,x),c=Cs(e.slice(l),"while","endwhile");if(c.length===0)break;let h=c[0].content,a=l+c[0].end;if(!pe(f)){let y=u("While",`Unsafe expression in @while: ${f}`,t.UNSAFE_EXPRESSION);e=e.substring(0,l)+y+e.substring(a),o=!0;continue}try{let y=Object.keys(r),g=Object.values(r),w=fe(h),F=Function(...y,"__stxRenderLoopValue",`
12
+ `)(...x,(a)=>{let y={...o};e.forEach((B,v)=>{y[B]=a[v]});let g=Jf(i,y,f,l,!0);g=de(g,y,f),g=ae(g,y);let w=g.indexOf(Q),S=g.indexOf(ee),F=w<0?S:S<0?w:Math.min(w,S);if(F>=0)g=g.slice(0,F);return c+=R(g,y,f),F<0||F!==w}),c}function ke(n,r,i){let e=n,o=!0;while(o){o=!1;let s=e.match(/@while\s*\(/);if(!s||s.index===void 0)break;let l=s.index,b=l+s[0].length-1,x=k(e,"(",")",b);if(x===-1)break;let f=e.slice(b+1,x),c=Cs(e.slice(l),"while","endwhile");if(c.length===0)break;let h=c[0].content,a=l+c[0].end;if(!pe(f)){let y=u("While",`Unsafe expression in @while: ${f}`,t.UNSAFE_EXPRESSION);e=e.substring(0,l)+y+e.substring(a),o=!0;continue}try{let y=Object.keys(r),g=Object.values(r),w=ue(h),F=Function(...y,"__stxRenderLoopValue",`
13
13
  let result = '';
14
14
  let maxIterations = ${i}; // Configurable safety limit
15
15
  let counter = 0;
@@ -21,5 +21,5 @@ import{E,Oi,eo,d,m,O,ut,p,to,t,u,k}from"./chunk-0tyyad6q.js";import{Ce,jt,te,j,C
21
21
  result += '<!-- [While Error [1104]]: Maximum iterations (${i}) exceeded in while loop. Configure via options.loops.maxWhileIterations -->';
22
22
  }
23
23
  return result;
24
- `)(...g,(B,v,A)=>ge(h,B,v,A));e=e.substring(0,l)+F+e.substring(a),o=!0}catch(y){let g=u("While",`Error in @while(${f}): ${y instanceof Error?y.message:String(y)}`,t.EVALUATION_ERROR);e=e.substring(0,l)+g+e.substring(a),o=!0}}return e}
24
+ `)(...g,(B,v,A)=>fe(h,B,v,A));e=e.substring(0,l)+F+e.substring(a),o=!0}catch(y){let g=u("While",`Error in @while(${f}): ${y instanceof Error?y.message:String(y)}`,t.EVALUATION_ERROR);e=e.substring(0,l)+g+e.substring(a),o=!0}}return e}
25
25
  export{ws,Jf,Ko,Yf};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{qh,Xf,tt,wc,Kh,gs,ms,hs}from"./chunk-s70e5jbq.js";import"./chunk-kx6y1cqw.js";import"./chunk-z0qxrx9r.js";import"./chunk-vvxcebpn.js";import"./chunk-a8164hnf.js";import"./chunk-pnqdwqw9.js";import"./chunk-mm00bb1p.js";import"./chunk-60yppcbb.js";import"./chunk-csymxc5a.js";import"./chunk-farh4p7f.js";import"./chunk-qjey0jk6.js";export{Kh as clearOnceStore,wc as onceStore,tt as partialsCache,gs as processIncludes,ms as processStackPushDirectives,hs as processStackReplacements,qh as resetUnscopedSignalWarnings,Xf as topLevelElements};
@@ -1,4 +1,4 @@
1
1
  // @bun
2
- import{it}from"./chunk-dy7vqv1x.js";import{St,Xn}from"./chunk-mnx6njd4.js";import{Dr,Mr,Lr,Br,Re}from"./chunk-0tyyad6q.js";import{Fe,vn,pl,fl}from"./chunk-hze3158c.js";import{B}from"./chunk-60yppcbb.js";import{Pi}from"./chunk-w1rrfj39.js";import{x}from"./chunk-pfr3cazq.js";import{i}from"./chunk-zfq2vvex.js";import{U,a}from"./chunk-y0msz738.js";import{Mc}from"./chunk-rw5492e2.js";import{Ln,jn,Je,Pe,xa,Sa,Bn}from"./chunk-7wae4311.js";import{fn,jo}from"./chunk-mwxehpse.js";import{Fn}from"./chunk-3z1mmar2.js";import{on,sr,or}from"./chunk-ymdw4fhd.js";import{Q}from"./chunk-q58f5wk2.js";import m from"fs";import c from"path";import{createHash as Y}from"crypto";function I(n){return Y("sha256").update(n).digest("hex").slice(0,8)}function W(n=!1){let l=n?Xn():St(),o=I(l);return{content:l,filename:`runtime.${o}.js`,hash:o}}function J(){let n=it(),l=I(n);return{content:n,filename:`router.${l}.js`,hash:l}}import V from"path";import{createHash as ee}from"crypto";function te(n={}){let l=new Set;return{context:new Proxy(n,{get(r,e){if(e in r)return r[e];if(typeof e==="string"&&!e.startsWith("__"))l.add(e);return},has(r,e){if(e in r)return!0;if(typeof e==="string"&&!e.startsWith("__"))l.add(e);return!1}}),accessedKeys:l}}async function q(n,l,o={}){let r=V.resolve(n),e=await Bun.file(r).text(),S=ee("sha256").update(e).digest("hex").slice(0,16);pl();let _={};try{_=await a(o.configDir)}catch{}let y=[],d=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,g;while((g=d.exec(e))!==null){let R=g[1];if(/\bserver\b/.test(R))y.push(g[2])}let u=new Set(y.flatMap((R)=>Fe(R))),{context:D}=te({__filename:r,__dirname:V.dirname(r),__stx_serverDeclared:u}),A=new Set,T={...U,..._,...o,buildMode:"compile",strict:!1},f=await i(e,D,r,T,A),w=Ln(f)+jn(f)+Je(f),j=fl();return{route:l,sourceFile:n,html:f,fragment:w,placeholders:j,hasServerScripts:y.length>0,serverScriptContent:y,dependencies:Array.from(A),contentHash:S,status:vn(e),streamTemplates:D.__streamTemplates}}var re=new Set([".DS_Store","Thumbs.db","desktop.ini",".gitkeep",".gitignore"]);function X(n,l){let o=0,r=0;if(!m.existsSync(n))return{copied:o,bytes:r};m.mkdirSync(l,{recursive:!0});function e(S,_){let y=m.readdirSync(S,{withFileTypes:!0});for(let d of y){if(re.has(d.name))continue;let g=c.join(S,d.name),u=c.join(_,d.name);if(d.isDirectory())m.mkdirSync(u,{recursive:!0}),e(g,u);else if(d.isFile()){if(m.existsSync(u))continue;m.copyFileSync(g,u),o++,r+=m.statSync(u).size}}}return e(n,l),{copied:o,bytes:r}}async function wm(n={}){let l=Date.now(),o=c.resolve(n.root||process.cwd()),r=c.resolve(o,n.outputDir||".output");console.log("[stx build] Starting production build...");let e=await a(o),S=c.resolve(o,n.componentsDir??e.componentsDir??"components"),_=c.resolve(o,n.partialsDir??e.partialsDir??"partials"),y=c.resolve(o,n.layoutsDir??e.layoutsDir??"layouts"),d=n.publicDir??e.publicDir??"public",g=Re(e.app?.head,{known:Br,source:"app.head"}),u=e.app?.colorMode,D=e.router?.container||"main",A=n.routeRules??e.routeRules??{},T=Fn(A),f=n.serverApi??e.serverApi,w=typeof f==="object"?f:{};if(f)fn(o,w);if(e.runtimeConfig)B(e.runtimeConfig,{});if(m.existsSync(r))m.rmSync(r,{recursive:!0});let j=[c.join(r,"public","__stx"),c.join(r,"public","assets"),c.join(r,"server","pages"),c.join(r,"server","fragments")];for(let s of j)m.mkdirSync(s,{recursive:!0});console.log("[stx build] Discovering routes...");let R=Q(o,{pagesDirs:e._layerPageDirs}),Z=["components","layouts","partials"],P=R.filter((s)=>!Z.some((h)=>s.pattern.startsWith(`/${h}/`)||s.pattern===`/${h}`));console.log(`[stx build] Found ${P.length} page routes (${R.length-P.length} non-page files excluded)`),console.log("[stx build] Generating shared assets...");let v=W(n.debug),b=J();await Bun.write(c.join(r,"public","__stx",v.filename),v.content),await Bun.write(c.join(r,"public","__stx",b.filename),b.content),console.log(`[stx build] Runtime: ${v.filename} (${(v.content.length/1024).toFixed(1)}KB)`),console.log(`[stx build] Router: ${b.filename} (${(b.content.length/1024).toFixed(1)}KB)`),console.log("[stx build] Compiling templates...");let M=[],H=[];for(let s of P){let h=T(s.pattern),O=h.rendering==="prerender";if(O&&(s.pattern.includes(":")||s.pattern.includes("[")))throw Error(`Cannot prerender parameter route ${s.pattern}; use dynamic rendering (explicit path enumeration is not supported here)`);try{let t=await q(s.filePath,s.pattern,{configDir:o,componentsDir:S,partialsDir:_,layoutsDir:y,debug:n.debug});if(M.push(t),t.html=t.html.replace(/runtime\.__STX_HASH__\.js/g,v.filename).replace(/router\.__STX_HASH__\.js/g,b.filename),t.html=Lr(t.html,g,{bodyScripts:[`<script src="/__stx/${b.filename}"></script>`],...u&&{colorMode:u}}),u)t.html=Dr(t.html,u);if(g.htmlAttrs)t.html=Mr(t.html,g.htmlAttrs);if(!/<body[^>]*\bdata-stx=/.test(t.html)){let p=t.html.match(/<(?!body\b)[a-zA-Z][a-zA-Z0-9-]*\b[^>]*?\s(data-stx="[^"]+")[^>]*>/);if(p&&p[1]){let G=p[1];t.html=t.html.replace(" "+G,""),t.html=t.html.replace(/<body([^>]*)>/,`<body$1 ${G}>`)}}if(t.html=t.html.replace(/<style data-css="generated">[\s\S]*?<\/style>\s*/g,""),t.html=await x(t.html),O){let p=await Bn(t,{params:{},request:new Request(`http://stx.build${s.pattern}`),method:"GET",__stx_strict_hydration:!0});if(p.redirect||p.cookies?.length||p.boundaries?.length||p.headers&&Object.keys(p.headers).length)throw Error(`Prerendered route ${s.pattern} cannot set response headers/cookies, redirect or stream`);t.html=p.html,t.status=p.status??t.status,t.hasServerScripts=!1,t.serverScriptContent=[],t.placeholders={}}t.fragment=Pe(t.html,D,!0);let K=s.pattern==="/"?"index":s.pattern.slice(1).replace(/\//g,"-").replace(/[[\]]/g,"_"),L=c.join("server","pages",`${K}.compiled.json`),z=c.join("server","fragments",`${K}.html`);await Bun.write(c.join(r,L),JSON.stringify(t,null,2)),await Bun.write(c.join(r,z),t.fragment),H.push({pattern:s.pattern,compiledPath:L,fragmentPath:z,isDynamic:t.hasServerScripts,hasParams:s.pattern.includes(":")||s.pattern.includes("["),prerendered:O}),console.log(`[stx build] \u2713 ${s.pattern}`)}catch(t){if(Object.keys(h).length)throw t;console.error(`[stx build] \u2717 ${s.pattern}:`,t instanceof Error?t.message:t)}}let k=c.resolve(o,d);if(m.existsSync(k)){let{copied:s,bytes:h}=X(k,c.join(r,"public"));if(s>0)console.log(`[stx build] Copied ${s} public asset${s===1?"":"s"} (${(h/1024).toFixed(1)}KB) from ${d}/`)}let E=or(o);if(E){let{copied:s,bytes:h}=X(E,c.join(r,"public",sr));if(s>0)console.log(`[stx build] Copied ${s} asset${s===1?"":"s"} (${(h/1024).toFixed(1)}KB) from ${on}/`)}let F={runtime:v.filename,router:b.filename},C=xa(H,F,r);if(C.routeRules=A,C.routerContainer=D,f)C.apiRoutes=await jo(o,r,w);if(e.runtimeConfig)await Bun.write(c.join(r,"server/runtime-config.json"),JSON.stringify(e.runtimeConfig)),await Pi(o,e.runtimeConfig);if(e._layerGraph)await Bun.write(c.join(r,"server/layers.json"),JSON.stringify(Mc(e._layerGraph),null,2));Sa(C,r);let N=Date.now()-l;return console.log(`
2
+ import{it}from"./chunk-hhbt8grm.js";import{St,Gn}from"./chunk-m131znxe.js";import{Dr,Mr,Lr,Br,Re}from"./chunk-csymxc5a.js";import{Fe,vn,pl,fl}from"./chunk-pnqdwqw9.js";import{B}from"./chunk-60yppcbb.js";import{Pi}from"./chunk-mm00bb1p.js";import{x}from"./chunk-av2vknrs.js";import{i}from"./chunk-tc36b3r4.js";import{U,a}from"./chunk-jcr69v95.js";import{Mc}from"./chunk-rw5492e2.js";import{Ln,jn,Je,Pe,xa,Sa,Bn}from"./chunk-qt4dha3g.js";import{fn,jo}from"./chunk-kkevjppm.js";import{Fn}from"./chunk-3z1mmar2.js";import{on,sr,or}from"./chunk-ymdw4fhd.js";import{ee}from"./chunk-4p51hk75.js";import m from"fs";import c from"path";import{createHash as Y}from"crypto";function I(n){return Y("sha256").update(n).digest("hex").slice(0,8)}function W(n=!1){let l=n?Gn():St(),o=I(l);return{content:l,filename:`runtime.${o}.js`,hash:o}}function J(){let n=it(),l=I(n);return{content:n,filename:`router.${l}.js`,hash:l}}import V from"path";import{createHash as Q}from"crypto";function te(n={}){let l=new Set;return{context:new Proxy(n,{get(r,e){if(e in r)return r[e];if(typeof e==="string"&&!e.startsWith("__"))l.add(e);return},has(r,e){if(e in r)return!0;if(typeof e==="string"&&!e.startsWith("__"))l.add(e);return!1}}),accessedKeys:l}}async function q(n,l,o={}){let r=V.resolve(n),e=await Bun.file(r).text(),S=Q("sha256").update(e).digest("hex").slice(0,16);pl();let _={};try{_=await a(o.configDir)}catch{}let y=[],d=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,g;while((g=d.exec(e))!==null){let R=g[1];if(/\bserver\b/.test(R))y.push(g[2])}let u=new Set(y.flatMap((R)=>Fe(R))),{context:D}=te({__filename:r,__dirname:V.dirname(r),__stx_serverDeclared:u}),A=new Set,T={...U,..._,...o,buildMode:"compile",strict:!1},f=await i(e,D,r,T,A),w=Ln(f)+jn(f)+Je(f),j=fl();return{route:l,sourceFile:n,html:f,fragment:w,placeholders:j,hasServerScripts:y.length>0,serverScriptContent:y,dependencies:Array.from(A),contentHash:S,status:vn(e),streamTemplates:D.__streamTemplates}}var re=new Set([".DS_Store","Thumbs.db","desktop.ini",".gitkeep",".gitignore"]);function X(n,l){let o=0,r=0;if(!m.existsSync(n))return{copied:o,bytes:r};m.mkdirSync(l,{recursive:!0});function e(S,_){let y=m.readdirSync(S,{withFileTypes:!0});for(let d of y){if(re.has(d.name))continue;let g=c.join(S,d.name),u=c.join(_,d.name);if(d.isDirectory())m.mkdirSync(u,{recursive:!0}),e(g,u);else if(d.isFile()){if(m.existsSync(u))continue;m.copyFileSync(g,u),o++,r+=m.statSync(u).size}}}return e(n,l),{copied:o,bytes:r}}async function wm(n={}){let l=Date.now(),o=c.resolve(n.root||process.cwd()),r=c.resolve(o,n.outputDir||".output");console.log("[stx build] Starting production build...");let e=await a(o),S=c.resolve(o,n.componentsDir??e.componentsDir??"components"),_=c.resolve(o,n.partialsDir??e.partialsDir??"partials"),y=c.resolve(o,n.layoutsDir??e.layoutsDir??"layouts"),d=n.publicDir??e.publicDir??"public",g=Re(e.app?.head,{known:Br,source:"app.head"}),u=e.app?.colorMode,D=e.router?.container||"main",A=n.routeRules??e.routeRules??{},T=Fn(A),f=n.serverApi??e.serverApi,w=typeof f==="object"?f:{};if(f)fn(o,w);if(e.runtimeConfig)B(e.runtimeConfig,{});if(m.existsSync(r))m.rmSync(r,{recursive:!0});let j=[c.join(r,"public","__stx"),c.join(r,"public","assets"),c.join(r,"server","pages"),c.join(r,"server","fragments")];for(let s of j)m.mkdirSync(s,{recursive:!0});console.log("[stx build] Discovering routes...");let R=ee(o,{pagesDirs:e._layerPageDirs}),Z=["components","layouts","partials"],P=R.filter((s)=>!Z.some((h)=>s.pattern.startsWith(`/${h}/`)||s.pattern===`/${h}`));console.log(`[stx build] Found ${P.length} page routes (${R.length-P.length} non-page files excluded)`),console.log("[stx build] Generating shared assets...");let v=W(n.debug),b=J();await Bun.write(c.join(r,"public","__stx",v.filename),v.content),await Bun.write(c.join(r,"public","__stx",b.filename),b.content),console.log(`[stx build] Runtime: ${v.filename} (${(v.content.length/1024).toFixed(1)}KB)`),console.log(`[stx build] Router: ${b.filename} (${(b.content.length/1024).toFixed(1)}KB)`),console.log("[stx build] Compiling templates...");let M=[],H=[];for(let s of P){let h=T(s.pattern),O=h.rendering==="prerender";if(O&&(s.pattern.includes(":")||s.pattern.includes("[")))throw Error(`Cannot prerender parameter route ${s.pattern}; use dynamic rendering (explicit path enumeration is not supported here)`);try{let t=await q(s.filePath,s.pattern,{configDir:o,componentsDir:S,partialsDir:_,layoutsDir:y,debug:n.debug});if(M.push(t),t.html=t.html.replace(/runtime\.__STX_HASH__\.js/g,v.filename).replace(/router\.__STX_HASH__\.js/g,b.filename),t.html=Lr(t.html,g,{bodyScripts:[`<script src="/__stx/${b.filename}"></script>`],...u&&{colorMode:u}}),u)t.html=Dr(t.html,u);if(g.htmlAttrs)t.html=Mr(t.html,g.htmlAttrs);if(!/<body[^>]*\bdata-stx=/.test(t.html)){let p=t.html.match(/<(?!body\b)[a-zA-Z][a-zA-Z0-9-]*\b[^>]*?\s(data-stx="[^"]+")[^>]*>/);if(p&&p[1]){let G=p[1];t.html=t.html.replace(" "+G,""),t.html=t.html.replace(/<body([^>]*)>/,`<body$1 ${G}>`)}}if(t.html=t.html.replace(/<style data-css="generated">[\s\S]*?<\/style>\s*/g,""),t.html=await x(t.html),O){let p=await Bn(t,{params:{},request:new Request(`http://stx.build${s.pattern}`),method:"GET",__stx_strict_hydration:!0});if(p.redirect||p.cookies?.length||p.boundaries?.length||p.headers&&Object.keys(p.headers).length)throw Error(`Prerendered route ${s.pattern} cannot set response headers/cookies, redirect or stream`);t.html=p.html,t.status=p.status??t.status,t.hasServerScripts=!1,t.serverScriptContent=[],t.placeholders={}}t.fragment=Pe(t.html,D,!0);let K=s.pattern==="/"?"index":s.pattern.slice(1).replace(/\//g,"-").replace(/[[\]]/g,"_"),L=c.join("server","pages",`${K}.compiled.json`),z=c.join("server","fragments",`${K}.html`);await Bun.write(c.join(r,L),JSON.stringify(t,null,2)),await Bun.write(c.join(r,z),t.fragment),H.push({pattern:s.pattern,compiledPath:L,fragmentPath:z,isDynamic:t.hasServerScripts,hasParams:s.pattern.includes(":")||s.pattern.includes("["),prerendered:O}),console.log(`[stx build] \u2713 ${s.pattern}`)}catch(t){if(Object.keys(h).length)throw t;console.error(`[stx build] \u2717 ${s.pattern}:`,t instanceof Error?t.message:t)}}let k=c.resolve(o,d);if(m.existsSync(k)){let{copied:s,bytes:h}=X(k,c.join(r,"public"));if(s>0)console.log(`[stx build] Copied ${s} public asset${s===1?"":"s"} (${(h/1024).toFixed(1)}KB) from ${d}/`)}let E=or(o);if(E){let{copied:s,bytes:h}=X(E,c.join(r,"public",sr));if(s>0)console.log(`[stx build] Copied ${s} asset${s===1?"":"s"} (${(h/1024).toFixed(1)}KB) from ${on}/`)}let F={runtime:v.filename,router:b.filename},C=xa(H,F,r);if(C.routeRules=A,C.routerContainer=D,f)C.apiRoutes=await jo(o,r,w);if(e.runtimeConfig)await Bun.write(c.join(r,"server/runtime-config.json"),JSON.stringify(e.runtimeConfig)),await Pi(o,e.runtimeConfig);if(e._layerGraph)await Bun.write(c.join(r,"server/layers.json"),JSON.stringify(Mc(e._layerGraph),null,2));Sa(C,r);let N=Date.now()-l;return console.log(`
3
3
  [stx build] Done in ${N}ms \u2014 ${M.length} pages compiled`),{pageCount:M.length,assets:F,outputDir:r,duration:N}}
4
4
  export{wm};
@@ -0,0 +1,3 @@
1
+ // @bun
2
+ import{G}from"./chunk-pnqdwqw9.js";function n(t){return G(t)}
3
+ export{n};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{ws,Jf,Ko,Yf}from"./chunk-y48ykf1n.js";import"./chunk-vvxcebpn.js";import"./chunk-bfvr4byj.js";import"./chunk-4p51hk75.js";import"./chunk-a8164hnf.js";import"./chunk-jcr69v95.js";import"./chunk-6s7q8kw3.js";import"./chunk-tnp2ta5q.js";import"./chunk-rw5492e2.js";import"./chunk-6mkn81pd.js";import"./chunk-hhbt8grm.js";import{jt}from"./chunk-pnqdwqw9.js";import"./chunk-mm00bb1p.js";import"./chunk-60yppcbb.js";import"./chunk-csymxc5a.js";import"./chunk-farh4p7f.js";import"./chunk-qjey0jk6.js";export{Yf as declareBareLoopHead,jt as parseLoopBinding,Jf as processLoops,Ko as processLoopsAsync,ws as reportDeferredLoopWarnings};
@@ -8,5 +8,5 @@ function o(t,i){let n=t[i],e=i+1;while(e<t.length){if(t[e]==="\\"){e+=2;continue
8
8
  `?`
9
9
  `:" ",n++}i+=" ",n++,e=h,s="";continue}if(l==="/"&&a(e,s)){let u=w(t,n);if(u!==-1){i+=`/${" ".repeat(u-n-2)}/`,n=u,e=h,s="";continue}}if(l==="`"){i+=" ",n++;while(n<t.length&&t[n]!=="`"){if(t[n]==="\\"){i+=" ",n+=2;continue}if(t[n]==="$"&&t[n+1]==="{"){let u=n+2,g=ml(t,u);if(i+=" ",i+=r(t.slice(u,g)),g<t.length)i+=" ";n=g+1;continue}i+=t[n]===`
10
10
  `?`
11
- `:" ",n++}i+=" ",n++,e=h,s="";continue}if(i+=l,n++,/[\w$]/.test(l))s=/[\w$]/.test(e)?s+l:l,e=l;else if(!/\s/.test(l))e=l,s=""}return i}function we(t){let i=new Uint16Array(t.length),n=0,e=!0;for(let s=0;s<t.length;s++){let f=t[s];if(f===")"||f==="]"||f==="}")if(n===0)e=!1;else n--;if(i[s]=n,f==="("||f==="["||f==="{")n++}return{depths:i,balanced:e&&n===0}}
12
- export{ml,r,we};
11
+ `:" ",n++}i+=" ",n++,e=h,s="";continue}if(i+=l,n++,/[\w$]/.test(l))s=/[\w$]/.test(e)?s+l:l,e=l;else if(!/\s/.test(l))e=l,s=""}return i}function Y(t){let i=new Uint16Array(t.length),n=0,e=!0;for(let s=0;s<t.length;s++){let f=t[s];if(f===")"||f==="]"||f==="}")if(n===0)e=!1;else n--;if(i[s]=n,f==="("||f==="["||f==="{")n++}return{depths:i,balanced:e&&n===0}}
12
+ export{ml,r,Y};
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{Gt}from"./chunk-6mjd3pqd.js";import{c,f}from"./chunk-fd1bpv35.js";function io(e){let n=e.pwa;if(!n?.enabled)return"";let r=n.manifest,t=n.icons?.outputDir?`/${n.icons.outputDir}`:"/pwa-icons",o=Gt(e),i=`
2
+ import{Xt}from"./chunk-18a3vdnq.js";import{c,f}from"./chunk-fd1bpv35.js";function io(e){let n=e.pwa;if(!n?.enabled)return"";let r=n.manifest,t=n.icons?.outputDir?`/${n.icons.outputDir}`:"/pwa-icons",o=Xt(e),i=`
3
3
  <!-- stx PWA Meta Tags -->
4
4
  <link rel="manifest" href="/manifest.json">
5
5
  <meta name="theme-color" content="${a(r?.themeColor||"#000000")}">
@@ -47,7 +47,7 @@ if ('serviceWorker' in navigator) {
47
47
  `+e.slice(o)}return e+io(n)}let t=io(n);return f(e,t)}function Fg(e){if(!e.pwa?.enabled)return"";return`<script>
48
48
  if ('serviceWorker' in navigator) {
49
49
  window.addEventListener('load', function() {
50
- navigator.serviceWorker.register('/${Gt(e)}')
50
+ navigator.serviceWorker.register('/${Xt(e)}')
51
51
  .then(function(registration) {
52
52
  console.log('[PWA] Service Worker registered:', registration.scope);
53
53
  })