@stacksjs/stx 0.2.647 → 0.2.648

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 (120) hide show
  1. package/dist/{chunk-ma7d95f0.js → chunk-06w0z1cm.js} +5 -5
  2. package/dist/chunk-0en5jwjy.js +2 -0
  3. package/dist/{chunk-3ghbxena.js → chunk-0h8tg21j.js} +1 -1
  4. package/dist/{chunk-x8k64g1e.js → chunk-0jhdrgpr.js} +2 -2
  5. package/dist/{chunk-xnjf1zbn.js → chunk-0vkawews.js} +2 -2
  6. package/dist/{chunk-5t4qtxgr.js → chunk-2h8ea0we.js} +2 -2
  7. package/dist/{chunk-jsb4pvj1.js → chunk-2jh21f1n.js} +1 -1
  8. package/dist/chunk-2n3pa5gm.js +2 -0
  9. package/dist/chunk-3b5bphcn.js +2 -0
  10. package/dist/{chunk-h5zr710w.js → chunk-3p7mk3mw.js} +1 -1
  11. package/dist/{chunk-yfrvbnc6.js → chunk-3q163st5.js} +10 -10
  12. package/dist/{chunk-nph4d1ff.js → chunk-3zyjqvsq.js} +2 -2
  13. package/dist/{chunk-aah6csjm.js → chunk-481d4kr9.js} +1 -1
  14. package/dist/{chunk-0m08316b.js → chunk-4q2dtxdk.js} +1 -1
  15. package/dist/{chunk-bk96wjaz.js → chunk-55zaxb4s.js} +8 -8
  16. package/dist/chunk-57md41g9.js +2 -0
  17. package/dist/{chunk-42rghbqe.js → chunk-67xhsacd.js} +1 -1
  18. package/dist/{chunk-b0vhe6d4.js → chunk-6ea6az61.js} +1 -1
  19. package/dist/chunk-6vh8s0pg.js +2 -0
  20. package/dist/{chunk-myq3hrww.js → chunk-88z4wkrj.js} +2 -2
  21. package/dist/{chunk-e7sg0fa0.js → chunk-89yj6tcd.js} +1 -1
  22. package/dist/{chunk-y3vget29.js → chunk-8d2f2e42.js} +1 -1
  23. package/dist/chunk-8fsq2ynj.js +2 -0
  24. package/dist/{chunk-c7fs96n6.js → chunk-8p9kpfk8.js} +1 -1
  25. package/dist/chunk-8tpmz4as.js +2 -0
  26. package/dist/{chunk-hgy4c6mm.js → chunk-9121nkpj.js} +1 -1
  27. package/dist/{chunk-zevx9866.js → chunk-9txn4rvb.js} +1 -1
  28. package/dist/chunk-9x0zt65f.js +2 -0
  29. package/dist/chunk-a2bw46t9.js +2 -0
  30. package/dist/chunk-a4sggwcz.js +2 -0
  31. package/dist/{chunk-7s32fe6k.js → chunk-ab7zqtax.js} +1 -1
  32. package/dist/chunk-b0hpshvk.js +2 -0
  33. package/dist/chunk-c1479y92.js +2 -0
  34. package/dist/{chunk-gc9ftf7r.js → chunk-c1dkh0es.js} +3 -3
  35. package/dist/{chunk-pw9bhdaz.js → chunk-e87xa4r3.js} +1 -1
  36. package/dist/chunk-embejqx4.js +2 -0
  37. package/dist/chunk-er60h3j3.js +2 -0
  38. package/dist/chunk-eyfxw7ds.js +2 -0
  39. package/dist/chunk-f3y4fnaa.js +2 -0
  40. package/dist/{chunk-wzgn9fv7.js → chunk-f46ht5kq.js} +3 -3
  41. package/dist/chunk-f7930sce.js +2 -0
  42. package/dist/{chunk-emaexvgz.js → chunk-fsbjat59.js} +1 -1
  43. package/dist/{chunk-vgt9f7ac.js → chunk-gv793yqq.js} +2 -2
  44. package/dist/chunk-gz90fqn8.js +2 -0
  45. package/dist/chunk-h15xb2vd.js +2 -0
  46. package/dist/{chunk-31714f76.js → chunk-h5nmf98w.js} +1 -1
  47. package/dist/{chunk-da7x7y7j.js → chunk-hfpv56cp.js} +1 -1
  48. package/dist/chunk-hhmj9gpk.js +2 -0
  49. package/dist/{chunk-5yg3tkth.js → chunk-hjm69qnj.js} +1 -1
  50. package/dist/{chunk-shkysa02.js → chunk-j393gsfd.js} +2 -2
  51. package/dist/{chunk-p22w6mwr.js → chunk-j5gd0e53.js} +1 -1
  52. package/dist/{chunk-msr25dhc.js → chunk-jkaszw24.js} +2 -2
  53. package/dist/{chunk-rwrbdpdk.js → chunk-m6qfqkbh.js} +1 -1
  54. package/dist/{chunk-ztbzktzg.js → chunk-mnp8ecj9.js} +1 -1
  55. package/dist/chunk-ncqh5qe5.js +2 -0
  56. package/dist/{chunk-rb5xdcen.js → chunk-nj1t4g3a.js} +3 -3
  57. package/dist/{chunk-p08x0z86.js → chunk-np4zm2ph.js} +1 -1
  58. package/dist/{chunk-0z5cc7qn.js → chunk-nt0n0vjm.js} +2 -2
  59. package/dist/{chunk-0jq3w712.js → chunk-p44kmbdg.js} +3 -3
  60. package/dist/{chunk-dpjnjs09.js → chunk-pbtkbe48.js} +23 -23
  61. package/dist/{chunk-jx3wpgv0.js → chunk-pg0xzsss.js} +2 -2
  62. package/dist/{chunk-xyjn0rvj.js → chunk-pxs7sgnp.js} +1 -1
  63. package/dist/{chunk-74pej67a.js → chunk-qfe7ps3v.js} +7 -7
  64. package/dist/{chunk-b07djygp.js → chunk-qm4672dj.js} +3 -3
  65. package/dist/chunk-r1r6311d.js +14 -0
  66. package/dist/{chunk-55x799st.js → chunk-radggg3p.js} +5 -5
  67. package/dist/{chunk-ar22s1e1.js → chunk-sgptbhrc.js} +1 -1
  68. package/dist/{chunk-fygp3cs9.js → chunk-sszhz1zh.js} +1 -1
  69. package/dist/{chunk-mmm6mm16.js → chunk-szyqxcfj.js} +2 -2
  70. package/dist/{chunk-cj2xj1v6.js → chunk-t1k9160w.js} +4 -4
  71. package/dist/{chunk-tkkvvt26.js → chunk-t82be9yf.js} +1 -1
  72. package/dist/{chunk-9y2ncrnq.js → chunk-v2x9vzgw.js} +2 -2
  73. package/dist/{chunk-w2q32x72.js → chunk-w2zceynt.js} +1 -1
  74. package/dist/{chunk-pfk9ffbz.js → chunk-wjt0kej9.js} +1 -1
  75. package/dist/{chunk-9am6dsb1.js → chunk-wpm58d6p.js} +2 -2
  76. package/dist/{chunk-9z9jtwct.js → chunk-wq6j2h32.js} +1 -1
  77. package/dist/{chunk-20f1veqy.js → chunk-x34scshq.js} +2 -2
  78. package/dist/{chunk-pdc9s7bg.js → chunk-x5tjb4y4.js} +1 -1
  79. package/dist/chunk-xfzcv0jc.js +2 -0
  80. package/dist/{chunk-ajv5xmjx.js → chunk-xm2mee4a.js} +14 -14
  81. package/dist/{chunk-ggwm8w5m.js → chunk-xvs04cnp.js} +1 -1
  82. package/dist/{chunk-3e7haxwt.js → chunk-ye8tgmd3.js} +1 -1
  83. package/dist/{chunk-asqnaddf.js → chunk-ymymwzt5.js} +1 -1
  84. package/dist/{chunk-a8j91pqz.js → chunk-yq021b3r.js} +3 -3
  85. package/dist/{chunk-jyth1zjy.js → chunk-zdnc7a4t.js} +3 -3
  86. package/dist/{chunk-5gtpswnm.js → chunk-zmh9p9aa.js} +1 -1
  87. package/dist/{chunk-w1v1d7rq.js → chunk-zsgcsqat.js} +94 -94
  88. package/dist/chunk-zyqs6a3p.js +2 -0
  89. package/dist/cli.js +12 -12
  90. package/dist/craft-entry.js +1 -1
  91. package/dist/craft.js +1 -1
  92. package/dist/interpolation-context.js +111 -8
  93. package/dist/pwa.js +3 -3
  94. package/dist/runtime-injection.js +9 -3
  95. package/dist/ssg.js +3 -3
  96. package/package.json +5 -5
  97. package/dist/chunk-0ky1j84b.js +0 -2
  98. package/dist/chunk-1c5p7ede.js +0 -2
  99. package/dist/chunk-1q6yvbdx.js +0 -2
  100. package/dist/chunk-1x4qn6fy.js +0 -2
  101. package/dist/chunk-2c3w367n.js +0 -2
  102. package/dist/chunk-2cxav9xe.js +0 -2
  103. package/dist/chunk-2v4s7xtx.js +0 -2
  104. package/dist/chunk-40y6mb8t.js +0 -2
  105. package/dist/chunk-4fz2eq7g.js +0 -2
  106. package/dist/chunk-5e20mvke.js +0 -2
  107. package/dist/chunk-5fzh8n52.js +0 -2
  108. package/dist/chunk-70pmthc3.js +0 -2
  109. package/dist/chunk-8ttg2d3m.js +0 -2
  110. package/dist/chunk-9qeg5trh.js +0 -2
  111. package/dist/chunk-apgb7r22.js +0 -2
  112. package/dist/chunk-aze7k3a5.js +0 -2
  113. package/dist/chunk-cs0dd5w8.js +0 -2
  114. package/dist/chunk-cwd65649.js +0 -2
  115. package/dist/chunk-edz1h5f9.js +0 -2
  116. package/dist/chunk-ek2adv0n.js +0 -2
  117. package/dist/chunk-n4cvg2sw.js +0 -2
  118. package/dist/chunk-qn63btbf.js +0 -2
  119. package/dist/chunk-vac56rgd.js +0 -12
  120. package/dist/chunk-vn3yx05b.js +0 -2
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{Be,wn,Jo}from"./chunk-9am6dsb1.js";function Es(e,a){let t=e.pwa;if(!t?.enabled)return"";let c=t.serviceWorker||{},d=t.routes||[],i=c.cacheVersion||"1.0.0",o=t.offline,l=o?.page?"/offline.html":"/offline.html",{push:r,backgroundSync:s,cacheStorage:n}=t,u=a?Be(a,e):null,h=u?wn(u):"[]",f=["/","/manifest.json",...o?.enabled?[l]:[],...o?.precacheAssets||[]];return`/**
2
+ import{Fe,wn,Jo}from"./chunk-wpm58d6p.js";function Es(e,a){let t=e.pwa;if(!t?.enabled)return"";let c=t.serviceWorker||{},d=t.routes||[],i=c.cacheVersion||"1.0.0",o=t.offline,l=o?.page?"/offline.html":"/offline.html",{push:r,backgroundSync:s,cacheStorage:n}=t,u=a?Fe(a,e):null,h=u?wn(u):"[]",f=["/","/manifest.json",...o?.enabled?[l]:[],...o?.precacheAssets||[]];return`/**
3
3
  * Service Worker - Auto-generated by stx
4
4
  * Cache Version: ${i}
5
5
  *
@@ -825,5 +825,5 @@ self.addEventListener('message', (event) => {
825
825
  event.waitUntil(registerFormSync(event.data.payload));
826
826
  }
827
827
  });
828
- `}function jt(e){return e.pwa?.serviceWorker?.fileName||"sw.js"}function bc(e){return e.pwa?.enabled===!0&&e.pwa?.serviceWorker?.useWorkbox===!0}function gu(e,a){if(!e.pwa?.enabled)return"";if(bc(e)){let{generateWorkboxServiceWorker:t}=import.meta.require("./chunk-jx3wpgv0.js");return t(e,a)}return Es(e,a)}
828
+ `}function jt(e){return e.pwa?.serviceWorker?.fileName||"sw.js"}function bc(e){return e.pwa?.enabled===!0&&e.pwa?.serviceWorker?.useWorkbox===!0}function gu(e,a){if(!e.pwa?.enabled)return"";if(bc(e)){let{generateWorkboxServiceWorker:t}=import.meta.require("./chunk-pg0xzsss.js");return t(e,a)}return Es(e,a)}
829
829
  export{Es,jt,bc,gu};
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{Mi,tl,Pn,td,nl,rl,sl,nd}from"./chunk-b0vhe6d4.js";import"./chunk-w1v1d7rq.js";import"./chunk-pdc9s7bg.js";import"./chunk-5t4qtxgr.js";import"./chunk-bk96wjaz.js";import"./chunk-ce6zddpf.js";import"./chunk-7rta163c.js";export{Pn as Validator,tl as defineForm,nl as processErrorDirective,rl as processErrorsDirective,nd as processFormValidationDirectives,sl as processHasErrorsDirective,Mi as useForm,td as v};
2
+ import{Mi,tl,Pn,td,nl,rl,sl,nd}from"./chunk-6ea6az61.js";import"./chunk-zsgcsqat.js";import"./chunk-x5tjb4y4.js";import"./chunk-2h8ea0we.js";import"./chunk-55zaxb4s.js";import"./chunk-ce6zddpf.js";import"./chunk-7rta163c.js";export{Pn as Validator,tl as defineForm,nl as processErrorDirective,rl as processErrorsDirective,nd as processFormValidationDirectives,sl as processHasErrorsDirective,Mi as useForm,td as v};
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{Es,jt,bc,gu}from"./chunk-msr25dhc.js";export{Es as generateServiceWorker,gu as generateServiceWorkerAuto,jt as getServiceWorkerFileName,bc as isWorkboxEnabled};
2
+ import{Es,jt,bc,gu}from"./chunk-jkaszw24.js";export{Es as generateServiceWorker,gu as generateServiceWorkerAuto,jt as getServiceWorkerFileName,bc as isWorkboxEnabled};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{xc,Sc}from"./chunk-xm2mee4a.js";import"./chunk-0h8tg21j.js";import"./chunk-wjt0kej9.js";import"./chunk-rjh2jwxx.js";import"./chunk-yq021b3r.js";import"./chunk-j393gsfd.js";import"./chunk-zqtbtqbq.js";import"./chunk-8p9kpfk8.js";import{_i}from"./chunk-06w0z1cm.js";import"./chunk-jxda11cg.js";import"./chunk-2jh21f1n.js";import"./chunk-9txn4rvb.js";import"./chunk-rcadtv3x.js";import"./chunk-sgptbhrc.js";import"./chunk-0jhdrgpr.js";import"./chunk-ym41ybz2.js";import"./chunk-n38yb274.js";import"./chunk-6ea6az61.js";import"./chunk-tre98h62.js";import"./chunk-481d4kr9.js";import"./chunk-dgb4z4kw.js";import"./chunk-r3e6x87d.js";import"./chunk-mmwedr93.js";import"./chunk-aprhqxky.js";import"./chunk-kgfgb971.js";import"./chunk-nrvwejdw.js";import"./chunk-9121nkpj.js";import"./chunk-wq6j2h32.js";import"./chunk-fg3jw17w.js";import"./chunk-qm4672dj.js";import"./chunk-c1dkh0es.js";import"./chunk-6ajahb2x.js";import"./chunk-f46ht5kq.js";import"./chunk-88z4wkrj.js";import"./chunk-v2x9vzgw.js";import{Ee,s}from"./chunk-pbtkbe48.js";import"./chunk-qfe7ps3v.js";import"./chunk-prf164ct.js";import"./chunk-nj1t4g3a.js";import"./chunk-radggg3p.js";import"./chunk-3zyjqvsq.js";import"./chunk-ymymwzt5.js";import"./chunk-0vkawews.js";import{me}from"./chunk-r1r6311d.js";import"./chunk-ye8tgmd3.js";import{Xn,Jn}from"./chunk-pxs7sgnp.js";import{qr,N,i}from"./chunk-3q163st5.js";import"./chunk-e87xa4r3.js";import"./chunk-a3d0g4mr.js";import"./chunk-04kg16qs.js";import"./chunk-p44kmbdg.js";import"./chunk-gv793yqq.js";import{f,Oe}from"./chunk-zsgcsqat.js";import"./chunk-x5tjb4y4.js";import"./chunk-2h8ea0we.js";import"./chunk-55zaxb4s.js";import"./chunk-ce6zddpf.js";import"./chunk-7rta163c.js";import"./chunk-9p6efb17.js";import"./chunk-t2pzy3x1.js";export{qr as buildWebComponents,Jn as cacheTemplate,Xn as checkCache,_i as classifyAllScripts,xc as createMiddleware,Sc as createRoute,N as defaultConfig,f as extractVariables,me as injectRouterScript,i as loadStxConfig,Oe as processClientScript,s as processDirectives,Ee as readMarkdownFile};
@@ -1,15 +1,15 @@
1
1
  // @bun
2
- import{Fo,vs,l,d,C,et,u,ws,t,a,w}from"./chunk-bk96wjaz.js";import{Ye,Et,It,K,k}from"./chunk-w1v1d7rq.js";import{ee}from"./chunk-asqnaddf.js";import{Ur}from"./chunk-3e7haxwt.js";var ae=1000,ue=!1;function fe(n,r){let o=/@(include|partial)\s*\(\s*(['"])([^'"]+)\2\s*,\s*/g,e="",s=0,i;while((i=o.exec(n))!==null){let p=i.index+i[0].length,y=i.index+i[0].indexOf("("),m=w(n,"(",")",y);if(m===-1)continue;let c=n.slice(p,m).trim();if(!c)continue;if(!Object.keys(r).some((b)=>new RegExp(`(?:^|[^\\w$.])${b.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}(?![\\w$])`).test(c)))continue;let g;try{let b=C(c,r);if(!b||typeof b!=="object")continue;g=JSON.stringify(b)}catch{continue}e+=n.slice(s,p)+g,s=m,o.lastIndex=m}return s===0?n:e+n.slice(s)}function ge(n,r){let o=/@component\s*\(/g,e=n,s,i=[];while((s=o.exec(e))!==null){let p=s.index,y=p+s[0].length-1,m=1,c=y+1;while(c<e.length&&m>0){if(e[c]==="(")m++;else if(e[c]===")"){if(m--,m===0)break}c++}if(m!==0)continue;let f=e.substring(y+1,c),g=c+1,b=f.match(/^\s*['"]([^'"]+)['"]/);if(!b)continue;let x=b[1],h=f.slice(b[0].length),O=h.match(/^\s*,\s*/);if(!O)continue;let I=h.slice(O[0].length).trim();if(!I)continue;try{let P=C(I,r),S=JSON.stringify(P),E=`@component('${x}', ${S})`;i.push({start:p,end:g,replacement:E})}catch{continue}}for(let p=i.length-1;p>=0;p--){let{start:y,end:m,replacement:c}=i[p];e=e.substring(0,y)+c+e.substring(m)}return e}function te(n,r,o){let e=n,s=new RegExp(`${r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\(`),i;while((i=s.exec(e))!==null){let p=i.index,y=p+i[0].length-1,m=1,c=y+1,f=null,g=!1;while(c<e.length&&m>0){let h=e[c];if(g){g=!1,c++;continue}if(h==="\\"&&f){g=!0,c++;continue}if(f){if(h===f)f=null;c++;continue}if(h==='"'||h==="'"||h==="`"){f=h,c++;continue}if(h==="(")m++;else if(h===")"){if(m--,m===0)break}c++}if(m!==0)break;let b=e.substring(y+1,c),x=o(b);e=e.substring(0,p)+x+e.substring(c+1)}return e}function pe(n,r){let o=n;return o=o.replace(/:([a-zA-Z_][a-zA-Z0-9_-]*)(?=\s+[^=]|\s*\/?>|\s*$)/g,(e,s)=>{if(s in r)return`:${s}="${s}"`;return e}),o=o.replace(/:([a-zA-Z_][a-zA-Z0-9_-]*)\s*=\s*"([^"]*)"/g,(e,s,i)=>{try{let p=Object.keys(r),y=Object.values(r);Fo(i);let c=u(i,p)(...y),f=JSON.stringify(c);if(f===void 0){if(!et(i).some((x)=>!(x in r)))return"";return e}let g=Buffer.from(f,"utf8").toString("base64");return`__stx_${s}="${g}"`}catch(p){return e}}),o}var Y="<!--__STX_BREAK__-->",G="<!--__STX_CONTINUE__-->";function se(n,r){let o=/\{\{\{?|\{!!|@(break|continue)(?![\w$])/g,e="",s=0;for(let i=o.exec(n);i;i=o.exec(n)){if(!i[1]){let c=i[0].length===3&&i[0]==="{{{"?3:2,f=i[0]==="{!!"?n.indexOf("!!}",o.lastIndex):Ye(n,i.index,c);if(f<0)break;o.lastIndex=f+(i[0]==="{!!"?3:c);continue}let p=o.lastIndex,y=!0,m=/^\s*\(/.exec(n.slice(p));if(m){let c=p+m[0].length-1,f=w(n,"(",")",c);if(f<0)break;p=f+1;try{let g=`!!(${n.slice(c+1,f).trim()})`;y=d(g)?Boolean(u(g,Object.keys(r))(...Object.values(r))):Boolean(l(g,r))}catch{y=!1}}if(e+=n.slice(s,i.index),y)return e+(i[1]==="break"?Y:G);s=p,o.lastIndex=p}return e+n.slice(s)}function oe(n){let r=(s)=>s.replace(/\\/g,"\\\\").replace(/`/g,"\\`").replace(/\$\{/g,"\\${"),o="",e=0;return It(n,(s,i,p)=>(o+=ne(r(n.slice(e,p))),o+=`\${__stxRenderLoopValue(${p}, (${i}), ${s.length})}`,e=p+s.length,s)),o+ne(r(n.slice(e)))}function ie(n,r,o,e){return K(n,r,o==null?"":String(o),!1,e)}function ne(n){let r=n;return r=te(r,"@break",(o)=>{let e=o.trim();if(!ws(e))return"";return`\`; if (${e}) { break; } result += \``}),r=te(r,"@continue",(o)=>{let e=o.trim();if(!ws(e))return"";return`\`; if (${e}) { continue; } result += \``}),r=r.replace(/@break(?!\()/g,"`; break; result += `"),r=r.replace(/@continue(?!\()/g,"`; continue; result += `"),r}function de(n){let r=/@forelse\s*\(/g,o,e=[],s=/@foreach\s*\(/g,i=/@endforeach/g,p;while((p=s.exec(n))!==null)e.push({pos:p.index,delta:1});while((p=i.exec(n))!==null)e.push({pos:p.index,delta:-1});e.sort((f,g)=>f.pos-g.pos);let y=[],m=0;for(let f of e)m+=f.delta,y.push({pos:f.pos,depth:m});function c(f){let g=0,b=y.length-1,x=0;while(g<=b){let h=g+b>>1;if(y[h].pos<=f)x=y[h].depth,g=h+1;else b=h-1}return x}while((o=r.exec(n))!==null){if(c(o.index)>0)continue;let f=o.index,g=o.index+o[0].length-1,b=1,x=g+1,h=-1;while(x<n.length&&b>0){if(n[x]==="(")b++;else if(n[x]===")"){if(b--,b===0){h=x;break}}x++}if(h===-1)continue;let O=n.substring(g+1,h),I=Et(O);if(!I)continue;let{arrayExpr:P,itemVar:S}=I,E=h+1,N=1,U=E,F=/@forelse\s*\(/g,V=/@endforelse/g,_=-1;while(N>0&&U<n.length){F.lastIndex=U,V.lastIndex=U;let R=F.exec(n),T=V.exec(n);if(!T)break;if(R&&R.index<T.index)N++,U=R.index+R[0].length;else{if(N--,N===0){_=T.index;break}U=T.index+11}}if(_===-1)continue;let j=n.substring(E,_),z=_+11,M=-1,W=0,A=0;while(A<j.length){let R=j.indexOf("@",A);if(R===-1)break;let T=j.substring(R);if(/^@forelse\s*\(/.test(T))W++,A=R+1;else if(T.startsWith("@endforelse"))W--,A=R+11;else if(W===0&&T.startsWith("@empty")){if(j.length<=R+6||!/[a-z]/i.test(j[R+6])){M=R;break}A=R+1}else A=R+1}if(M===-1)continue;return{start:f,end:z,arrayExpr:P,itemVar:S,foreachContent:j.substring(0,M),emptyContent:j.substring(M+6)}}return null}function re(n,r){let o=n;while(!0){let e=de(o);if(!e)break;let{start:s,end:i,arrayExpr:p,itemVar:y,foreachContent:m,emptyContent:c}=e;try{let f;if(d(p))f=u(p,Object.keys(r))(...Object.values(r));else f=l(p,r);let g;if(!Array.isArray(f)||f.length===0)g=c;else g=`@foreach (${p} as ${y})${m}@endforeach`;o=o.substring(0,s)+g+o.substring(i)}catch(f){let g=f instanceof Error?f.message:String(f),b=a("Forelse",`Error in @forelse(${p} as ${y}): ${g}`,t.EVALUATION_ERROR);o=o.substring(0,s)+b+o.substring(i)}}return o}var ce="<!--stx:foreach-not-iterable:",he=/<!--stx:foreach-not-iterable:([^|>]*)\|([^>]*?)-->/g;function me(n,r){return`${ce}${encodeURIComponent(n)}|${encodeURIComponent(r)}-->`}function be(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 Nr(n){if(!n.includes(ce))return n;return n.replace(he,(r,o,e)=>(be(decodeURIComponent(o),decodeURIComponent(e)),""))}function qn(n,r,o,e,s=!1){let i=n;i=re(i,r);function p(c){let f=/@foreach\s*\(/g,g;while((g=f.exec(c))!==null){let b=g.index,x=g.index+g[0].length-1,h=1,O=x+1,I=-1;while(O<c.length&&h>0){if(c[O]==="(")h++;else if(c[O]===")"){if(h--,h===0){I=O;break}}O++}if(I===-1)continue;let P=c.substring(x+1,I),S=Et(P);if(!S)continue;let E=b,{arrayExpr:N,itemVar:U}=S,F=I+1,V=1,_=F,j=/@foreach\s*\(/g,z=/@endforeach/g;while(V>0&&_<c.length){j.lastIndex=_,z.lastIndex=_;let M=j.exec(c),W=z.exec(c);if(!W)break;if(M&&M.index<W.index)V++,_=M.index+M[0].length;else{if(V--,V===0){let A=c.substring(F,W.index),R=W.index+11;return{start:E,end:R,arrayExpr:N,itemVar:U,content:A}}_=W.index+11}}}return null}function y(c,f){let g=c;while(!0){let b=p(g);if(!b)break;let{start:x,end:h,arrayExpr:O,itemVar:I,content:P}=b;try{let S=O.trim(),E;if(d(S))E=u(S,Object.keys(f))(...Object.values(f));else E=l(S,f);let N=!1;if(!Array.isArray(E))if(E instanceof Map)E=Array.from(E),N=!0;else if(E instanceof Set)E=Array.from(E);else if(typeof E==="string")E=Array.from(E);else if(E&&typeof E==="object"&&!(E instanceof Date)&&!(E instanceof RegExp))E=Object.entries(E),N=!0;else{let A=me(S,o)+a("Foreach",`Error in @foreach: ${S} is not iterable`,t.TYPE_ERROR);g=g.substring(0,x)+A+g.substring(h);continue}let U=e?.loops?.useAltLoopVariable??ue,F=I.trim(),V=null,_,j=!1;if(F.includes("=>")){let A=F.split("=>").map((R)=>R.trim());if(A.length===2&&A[0]&&A[1])V=A[0],_=A[1];else _=F}else if(!F.startsWith("[")&&!F.startsWith("{")&&F.includes(",")){let A=F.split(",").map((R)=>R.trim());if(A.length===2&&A[0]&&A[1])_=A[0],V=A[1],j=!0;else _=F}else _=F;let z="",M=E,W=f[vs]??new WeakMap;for(let A=0;A<M.length;A++){let R=M[A],T={index:A,iteration:A+1,first:A===0,last:A===M.length-1,count:M.length},L={...f,loop:T,$loop:T,[vs]:W};if(_.startsWith("[")&&_.endsWith("]")){let J=_.slice(1,-1).split(",").map((B)=>B.trim());if(Array.isArray(R))J.forEach((B,D)=>{if(B)L[B]=R[D]});else L[_]=R}else if(_.startsWith("{")&&_.endsWith("}")){let J=_.slice(1,-1).split(",").map((B)=>B.trim()).filter(Boolean);if(R!==null&&typeof R==="object")J.forEach((B)=>{let D=B.indexOf(":"),q=(D===-1?B:B.slice(0,D)).trim(),Q=D===-1?q:B.slice(D+1).trim();if(q&&Q)L[Q]=R[q]});else L[_]=R}else L[_]=R;if(V)if(!j&&N&&Array.isArray(R)&&R.length===2)L[V]=R[0],L[_]=R[1];else L[V]=A;let v=re(P,L);v=qn(v,L,o,e,!0),v=ee(v,L,o),v=se(v,L);let Z=v.indexOf(Y),H=v.indexOf(G),X=Z<0?H:H<0?Z:Math.min(Z,H);if(X>=0)v=v.slice(0,X);if(v=k(v,L,o),v=pe(v,L),v=ge(v,L),v=fe(v,L),z+=v,X>=0&&X===Z)break}g=g.substring(0,x)+z+g.substring(h)}catch(S){let E=a("Foreach",`Error in @foreach(${O.trim()} as ${I.trim()}): ${S instanceof Error?S.message:String(S)}`,t.EVALUATION_ERROR);g=g.substring(0,x)+E+g.substring(h)}}return g}i=y(i,r),i=xe(i,r,o,e);let m=e?.loops?.maxWhileIterations??ae;return i=$e(i,r,m),s?i:Nr(i)}function xl(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 le(n){return ws(n)}function xe(n,r,o,e){let s=n,i=!0;while(i){i=!1;let p=s.match(/@for\s*\(/);if(!p||p.index===void 0)break;let y=p.index,m=y+p[0].length-1,c=w(s,"(",")",m);if(c===-1)break;let f=xl(s.slice(m+1,c)),g=c+1,b=Ur(s.slice(y),"for","endfor");if(b.length===0)break;let x=b[0].content,h=y+b[0].end;if(!le(f)){let O=a("For",`Unsafe expression in @for: ${f}`,t.UNSAFE_EXPRESSION);s=s.substring(0,y)+O+s.substring(h),i=!0;continue}try{let O=ye(f),I=/@(?:for|foreach|if|unless)\s*\(/.test(x);if(O.length>0&&I){let F=Ee({forExpr:f,content:x,iterVarNames:O,context:r,filePath:o,options:e});s=s.substring(0,y)+F+s.substring(h),i=!0;continue}let P=Object.keys(r),S=Object.values(r),E=oe(x),U=Function(...P,"__stxRenderLoopValue",`
2
+ import{Fo,vs,l,d,C,et,u,ws,t,a,w}from"./chunk-55zaxb4s.js";import{he,Et,It,K,k}from"./chunk-zsgcsqat.js";import{ee}from"./chunk-ymymwzt5.js";import{Ur}from"./chunk-ye8tgmd3.js";var ae=1000,ue=!1;function fe(n,r){let o=/@(include|partial)\s*\(\s*(['"])([^'"]+)\2\s*,\s*/g,e="",s=0,i;while((i=o.exec(n))!==null){let p=i.index+i[0].length,y=i.index+i[0].indexOf("("),m=w(n,"(",")",y);if(m===-1)continue;let c=n.slice(p,m).trim();if(!c)continue;if(!Object.keys(r).some((b)=>new RegExp(`(?:^|[^\\w$.])${b.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}(?![\\w$])`).test(c)))continue;let g;try{let b=C(c,r);if(!b||typeof b!=="object")continue;g=JSON.stringify(b)}catch{continue}e+=n.slice(s,p)+g,s=m,o.lastIndex=m}return s===0?n:e+n.slice(s)}function ge(n,r){let o=/@component\s*\(/g,e=n,s,i=[];while((s=o.exec(e))!==null){let p=s.index,y=p+s[0].length-1,m=1,c=y+1;while(c<e.length&&m>0){if(e[c]==="(")m++;else if(e[c]===")"){if(m--,m===0)break}c++}if(m!==0)continue;let f=e.substring(y+1,c),g=c+1,b=f.match(/^\s*['"]([^'"]+)['"]/);if(!b)continue;let x=b[1],h=f.slice(b[0].length),O=h.match(/^\s*,\s*/);if(!O)continue;let I=h.slice(O[0].length).trim();if(!I)continue;try{let P=C(I,r),S=JSON.stringify(P),E=`@component('${x}', ${S})`;i.push({start:p,end:g,replacement:E})}catch{continue}}for(let p=i.length-1;p>=0;p--){let{start:y,end:m,replacement:c}=i[p];e=e.substring(0,y)+c+e.substring(m)}return e}function te(n,r,o){let e=n,s=new RegExp(`${r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\(`),i;while((i=s.exec(e))!==null){let p=i.index,y=p+i[0].length-1,m=1,c=y+1,f=null,g=!1;while(c<e.length&&m>0){let h=e[c];if(g){g=!1,c++;continue}if(h==="\\"&&f){g=!0,c++;continue}if(f){if(h===f)f=null;c++;continue}if(h==='"'||h==="'"||h==="`"){f=h,c++;continue}if(h==="(")m++;else if(h===")"){if(m--,m===0)break}c++}if(m!==0)break;let b=e.substring(y+1,c),x=o(b);e=e.substring(0,p)+x+e.substring(c+1)}return e}function pe(n,r){let o=n;return o=o.replace(/:([a-zA-Z_][a-zA-Z0-9_-]*)(?=\s+[^=]|\s*\/?>|\s*$)/g,(e,s)=>{if(s in r)return`:${s}="${s}"`;return e}),o=o.replace(/:([a-zA-Z_][a-zA-Z0-9_-]*)\s*=\s*"([^"]*)"/g,(e,s,i)=>{try{let p=Object.keys(r),y=Object.values(r);Fo(i);let c=u(i,p)(...y),f=JSON.stringify(c);if(f===void 0){if(!et(i).some((x)=>!(x in r)))return"";return e}let g=Buffer.from(f,"utf8").toString("base64");return`__stx_${s}="${g}"`}catch(p){return e}}),o}var Y="<!--__STX_BREAK__-->",G="<!--__STX_CONTINUE__-->";function se(n,r){let o=/\{\{\{?|\{!!|@(break|continue)(?![\w$])/g,e="",s=0;for(let i=o.exec(n);i;i=o.exec(n)){if(!i[1]){let c=i[0].length===3&&i[0]==="{{{"?3:2,f=i[0]==="{!!"?n.indexOf("!!}",o.lastIndex):he(n,i.index,c);if(f<0)break;o.lastIndex=f+(i[0]==="{!!"?3:c);continue}let p=o.lastIndex,y=!0,m=/^\s*\(/.exec(n.slice(p));if(m){let c=p+m[0].length-1,f=w(n,"(",")",c);if(f<0)break;p=f+1;try{let g=`!!(${n.slice(c+1,f).trim()})`;y=d(g)?Boolean(u(g,Object.keys(r))(...Object.values(r))):Boolean(l(g,r))}catch{y=!1}}if(e+=n.slice(s,i.index),y)return e+(i[1]==="break"?Y:G);s=p,o.lastIndex=p}return e+n.slice(s)}function oe(n){let r=(s)=>s.replace(/\\/g,"\\\\").replace(/`/g,"\\`").replace(/\$\{/g,"\\${"),o="",e=0;return It(n,(s,i,p)=>(o+=ne(r(n.slice(e,p))),o+=`\${__stxRenderLoopValue(${p}, (${i}), ${s.length})}`,e=p+s.length,s)),o+ne(r(n.slice(e)))}function ie(n,r,o,e){return K(n,r,o==null?"":String(o),!1,e)}function ne(n){let r=n;return r=te(r,"@break",(o)=>{let e=o.trim();if(!ws(e))return"";return`\`; if (${e}) { break; } result += \``}),r=te(r,"@continue",(o)=>{let e=o.trim();if(!ws(e))return"";return`\`; if (${e}) { continue; } result += \``}),r=r.replace(/@break(?!\()/g,"`; break; result += `"),r=r.replace(/@continue(?!\()/g,"`; continue; result += `"),r}function de(n){let r=/@forelse\s*\(/g,o,e=[],s=/@foreach\s*\(/g,i=/@endforeach/g,p;while((p=s.exec(n))!==null)e.push({pos:p.index,delta:1});while((p=i.exec(n))!==null)e.push({pos:p.index,delta:-1});e.sort((f,g)=>f.pos-g.pos);let y=[],m=0;for(let f of e)m+=f.delta,y.push({pos:f.pos,depth:m});function c(f){let g=0,b=y.length-1,x=0;while(g<=b){let h=g+b>>1;if(y[h].pos<=f)x=y[h].depth,g=h+1;else b=h-1}return x}while((o=r.exec(n))!==null){if(c(o.index)>0)continue;let f=o.index,g=o.index+o[0].length-1,b=1,x=g+1,h=-1;while(x<n.length&&b>0){if(n[x]==="(")b++;else if(n[x]===")"){if(b--,b===0){h=x;break}}x++}if(h===-1)continue;let O=n.substring(g+1,h),I=Et(O);if(!I)continue;let{arrayExpr:P,itemVar:S}=I,E=h+1,N=1,U=E,F=/@forelse\s*\(/g,V=/@endforelse/g,_=-1;while(N>0&&U<n.length){F.lastIndex=U,V.lastIndex=U;let R=F.exec(n),T=V.exec(n);if(!T)break;if(R&&R.index<T.index)N++,U=R.index+R[0].length;else{if(N--,N===0){_=T.index;break}U=T.index+11}}if(_===-1)continue;let j=n.substring(E,_),z=_+11,M=-1,W=0,A=0;while(A<j.length){let R=j.indexOf("@",A);if(R===-1)break;let T=j.substring(R);if(/^@forelse\s*\(/.test(T))W++,A=R+1;else if(T.startsWith("@endforelse"))W--,A=R+11;else if(W===0&&T.startsWith("@empty")){if(j.length<=R+6||!/[a-z]/i.test(j[R+6])){M=R;break}A=R+1}else A=R+1}if(M===-1)continue;return{start:f,end:z,arrayExpr:P,itemVar:S,foreachContent:j.substring(0,M),emptyContent:j.substring(M+6)}}return null}function re(n,r){let o=n;while(!0){let e=de(o);if(!e)break;let{start:s,end:i,arrayExpr:p,itemVar:y,foreachContent:m,emptyContent:c}=e;try{let f;if(d(p))f=u(p,Object.keys(r))(...Object.values(r));else f=l(p,r);let g;if(!Array.isArray(f)||f.length===0)g=c;else g=`@foreach (${p} as ${y})${m}@endforeach`;o=o.substring(0,s)+g+o.substring(i)}catch(f){let g=f instanceof Error?f.message:String(f),b=a("Forelse",`Error in @forelse(${p} as ${y}): ${g}`,t.EVALUATION_ERROR);o=o.substring(0,s)+b+o.substring(i)}}return o}var ce="<!--stx:foreach-not-iterable:",me=/<!--stx:foreach-not-iterable:([^|>]*)\|([^>]*?)-->/g;function be(n,r){return`${ce}${encodeURIComponent(n)}|${encodeURIComponent(r)}-->`}function xe(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 Nr(n){if(!n.includes(ce))return n;return n.replace(me,(r,o,e)=>(xe(decodeURIComponent(o),decodeURIComponent(e)),""))}function qn(n,r,o,e,s=!1){let i=n;i=re(i,r);function p(c){let f=/@foreach\s*\(/g,g;while((g=f.exec(c))!==null){let b=g.index,x=g.index+g[0].length-1,h=1,O=x+1,I=-1;while(O<c.length&&h>0){if(c[O]==="(")h++;else if(c[O]===")"){if(h--,h===0){I=O;break}}O++}if(I===-1)continue;let P=c.substring(x+1,I),S=Et(P);if(!S)continue;let E=b,{arrayExpr:N,itemVar:U}=S,F=I+1,V=1,_=F,j=/@foreach\s*\(/g,z=/@endforeach/g;while(V>0&&_<c.length){j.lastIndex=_,z.lastIndex=_;let M=j.exec(c),W=z.exec(c);if(!W)break;if(M&&M.index<W.index)V++,_=M.index+M[0].length;else{if(V--,V===0){let A=c.substring(F,W.index),R=W.index+11;return{start:E,end:R,arrayExpr:N,itemVar:U,content:A}}_=W.index+11}}}return null}function y(c,f){let g=c;while(!0){let b=p(g);if(!b)break;let{start:x,end:h,arrayExpr:O,itemVar:I,content:P}=b;try{let S=O.trim(),E;if(d(S))E=u(S,Object.keys(f))(...Object.values(f));else E=l(S,f);let N=!1;if(!Array.isArray(E))if(E instanceof Map)E=Array.from(E),N=!0;else if(E instanceof Set)E=Array.from(E);else if(typeof E==="string")E=Array.from(E);else if(E&&typeof E==="object"&&!(E instanceof Date)&&!(E instanceof RegExp))E=Object.entries(E),N=!0;else{let A=be(S,o)+a("Foreach",`Error in @foreach: ${S} is not iterable`,t.TYPE_ERROR);g=g.substring(0,x)+A+g.substring(h);continue}let U=e?.loops?.useAltLoopVariable??ue,F=I.trim(),V=null,_,j=!1;if(F.includes("=>")){let A=F.split("=>").map((R)=>R.trim());if(A.length===2&&A[0]&&A[1])V=A[0],_=A[1];else _=F}else if(!F.startsWith("[")&&!F.startsWith("{")&&F.includes(",")){let A=F.split(",").map((R)=>R.trim());if(A.length===2&&A[0]&&A[1])_=A[0],V=A[1],j=!0;else _=F}else _=F;let z="",M=E,W=f[vs]??new WeakMap;for(let A=0;A<M.length;A++){let R=M[A],T={index:A,iteration:A+1,first:A===0,last:A===M.length-1,count:M.length},L={...f,loop:T,$loop:T,[vs]:W};if(_.startsWith("[")&&_.endsWith("]")){let J=_.slice(1,-1).split(",").map((B)=>B.trim());if(Array.isArray(R))J.forEach((B,D)=>{if(B)L[B]=R[D]});else L[_]=R}else if(_.startsWith("{")&&_.endsWith("}")){let J=_.slice(1,-1).split(",").map((B)=>B.trim()).filter(Boolean);if(R!==null&&typeof R==="object")J.forEach((B)=>{let D=B.indexOf(":"),q=(D===-1?B:B.slice(0,D)).trim(),Q=D===-1?q:B.slice(D+1).trim();if(q&&Q)L[Q]=R[q]});else L[_]=R}else L[_]=R;if(V)if(!j&&N&&Array.isArray(R)&&R.length===2)L[V]=R[0],L[_]=R[1];else L[V]=A;let v=re(P,L);v=qn(v,L,o,e,!0),v=ee(v,L,o),v=se(v,L);let Z=v.indexOf(Y),H=v.indexOf(G),X=Z<0?H:H<0?Z:Math.min(Z,H);if(X>=0)v=v.slice(0,X);if(v=k(v,L,o),v=pe(v,L),v=ge(v,L),v=fe(v,L),z+=v,X>=0&&X===Z)break}g=g.substring(0,x)+z+g.substring(h)}catch(S){let E=a("Foreach",`Error in @foreach(${O.trim()} as ${I.trim()}): ${S instanceof Error?S.message:String(S)}`,t.EVALUATION_ERROR);g=g.substring(0,x)+E+g.substring(h)}}return g}i=y(i,r),i=ye(i,r,o,e);let m=e?.loops?.maxWhileIterations??ae;return i=Re(i,r,m),s?i:Nr(i)}function xl(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 le(n){return ws(n)}function ye(n,r,o,e){let s=n,i=!0;while(i){i=!1;let p=s.match(/@for\s*\(/);if(!p||p.index===void 0)break;let y=p.index,m=y+p[0].length-1,c=w(s,"(",")",m);if(c===-1)break;let f=xl(s.slice(m+1,c)),g=c+1,b=Ur(s.slice(y),"for","endfor");if(b.length===0)break;let x=b[0].content,h=y+b[0].end;if(!le(f)){let O=a("For",`Unsafe expression in @for: ${f}`,t.UNSAFE_EXPRESSION);s=s.substring(0,y)+O+s.substring(h),i=!0;continue}try{let O=Ee(f),I=/@(?:for|foreach|if|unless)\s*\(/.test(x);if(O.length>0&&I){let F=$e({forExpr:f,content:x,iterVarNames:O,context:r,filePath:o,options:e});s=s.substring(0,y)+F+s.substring(h),i=!0;continue}let P=Object.keys(r),S=Object.values(r),E=oe(x),U=Function(...P,"__stxRenderLoopValue",`
3
3
  let result = '';
4
4
  for (${f}) {
5
5
  result += \`${E}\`;
6
6
  }
7
7
  return result;
8
- `)(...S,(F,V,_)=>ie(x,F,V,_));s=s.substring(0,y)+U+s.substring(h),i=!0}catch(O){let I=a("For",`Error in @for(${f}): ${O instanceof Error?O.message:String(O)}`,t.EVALUATION_ERROR);s=s.substring(0,y)+I+s.substring(h),i=!0}}return s}function ye(n){let r=n.trim(),o=r.match(/^(?:const|let|var)\s+(\[[^\]]+\]|\{[^}]+\})\s+(?:of|in)\s+/);if(o){let i=o[1];return i.slice(1,-1).split(",").map((y)=>{let m=y.trim();if(!m)return"";let c=m.indexOf(":");if(c>=0&&i.startsWith("{")){let b=m.slice(c+1).trim(),x=b.indexOf("=");return(x>=0?b.slice(0,x):b).trim()}let f=m.indexOf("="),g=(f>=0?m.slice(0,f):m).trim();return/^[A-Za-z_$][\w$]*$/.test(g)?g:""}).filter(Boolean)}let e=r.match(/^(?:const|let|var)\s+([A-Za-z_$][\w$]*)\s+(?:of|in)\s+/);if(e)return[e[1]];let s=r.match(/^(?:const|let|var)\s+([A-Za-z_$][\w$]*)\s*=[^;]*;/);if(s)return[s[1]];return[]}function Ee(n){let{forExpr:r,content:o,iterVarNames:e,context:s,filePath:i,options:p}=n,y=Object.keys(s),m=Object.values(s),c=i??"inline.stx",f="";return Function(...y,"__renderIteration",`
8
+ `)(...S,(F,V,_)=>ie(x,F,V,_));s=s.substring(0,y)+U+s.substring(h),i=!0}catch(O){let I=a("For",`Error in @for(${f}): ${O instanceof Error?O.message:String(O)}`,t.EVALUATION_ERROR);s=s.substring(0,y)+I+s.substring(h),i=!0}}return s}function Ee(n){let r=n.trim(),o=r.match(/^(?:const|let|var)\s+(\[[^\]]+\]|\{[^}]+\})\s+(?:of|in)\s+/);if(o){let i=o[1];return i.slice(1,-1).split(",").map((y)=>{let m=y.trim();if(!m)return"";let c=m.indexOf(":");if(c>=0&&i.startsWith("{")){let b=m.slice(c+1).trim(),x=b.indexOf("=");return(x>=0?b.slice(0,x):b).trim()}let f=m.indexOf("="),g=(f>=0?m.slice(0,f):m).trim();return/^[A-Za-z_$][\w$]*$/.test(g)?g:""}).filter(Boolean)}let e=r.match(/^(?:const|let|var)\s+([A-Za-z_$][\w$]*)\s+(?:of|in)\s+/);if(e)return[e[1]];let s=r.match(/^(?:const|let|var)\s+([A-Za-z_$][\w$]*)\s*=[^;]*;/);if(s)return[s[1]];return[]}function $e(n){let{forExpr:r,content:o,iterVarNames:e,context:s,filePath:i,options:p}=n,y=Object.keys(s),m=Object.values(s),c=i??"inline.stx",f="";return Function(...y,"__renderIteration",`
9
9
  for (${r}) {
10
10
  if (!__renderIteration([${e.join(", ")}])) break;
11
11
  }
12
- `)(...m,(b)=>{let x={...s};e.forEach((S,E)=>{x[S]=b[E]});let h=qn(o,x,c,p,!0);h=ee(h,x,c),h=se(h,x);let O=h.indexOf(Y),I=h.indexOf(G),P=O<0?I:I<0?O:Math.min(O,I);if(P>=0)h=h.slice(0,P);return f+=k(h,x,c),P<0||P!==O}),f}function $e(n,r,o){let e=n,s=!0;while(s){s=!1;let i=e.match(/@while\s*\(/);if(!i||i.index===void 0)break;let p=i.index,y=p+i[0].length-1,m=w(e,"(",")",y);if(m===-1)break;let c=e.slice(y+1,m),f=Ur(e.slice(p),"while","endwhile");if(f.length===0)break;let g=f[0].content,b=p+f[0].end;if(!le(c)){let x=a("While",`Unsafe expression in @while: ${c}`,t.UNSAFE_EXPRESSION);e=e.substring(0,p)+x+e.substring(b),s=!0;continue}try{let x=Object.keys(r),h=Object.values(r),O=oe(g),P=Function(...x,"__stxRenderLoopValue",`
12
+ `)(...m,(b)=>{let x={...s};e.forEach((S,E)=>{x[S]=b[E]});let h=qn(o,x,c,p,!0);h=ee(h,x,c),h=se(h,x);let O=h.indexOf(Y),I=h.indexOf(G),P=O<0?I:I<0?O:Math.min(O,I);if(P>=0)h=h.slice(0,P);return f+=k(h,x,c),P<0||P!==O}),f}function Re(n,r,o){let e=n,s=!0;while(s){s=!1;let i=e.match(/@while\s*\(/);if(!i||i.index===void 0)break;let p=i.index,y=p+i[0].length-1,m=w(e,"(",")",y);if(m===-1)break;let c=e.slice(y+1,m),f=Ur(e.slice(p),"while","endwhile");if(f.length===0)break;let g=f[0].content,b=p+f[0].end;if(!le(c)){let x=a("While",`Unsafe expression in @while: ${c}`,t.UNSAFE_EXPRESSION);e=e.substring(0,p)+x+e.substring(b),s=!0;continue}try{let x=Object.keys(r),h=Object.values(r),O=oe(g),P=Function(...x,"__stxRenderLoopValue",`
13
13
  let result = '';
14
14
  let maxIterations = ${o}; // Configurable safety limit
15
15
  let counter = 0;
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{jt}from"./chunk-msr25dhc.js";function Cs(e){let n=e.pwa;if(!n?.enabled)return"";let r=n.manifest,t=n.icons?.outputDir?`/${n.icons.outputDir}`:"/pwa-icons",o=jt(e),i=`
2
+ import{jt}from"./chunk-jkaszw24.js";function Cs(e){let n=e.pwa;if(!n?.enabled)return"";let r=n.manifest,t=n.icons?.outputDir?`/${n.icons.outputDir}`:"/pwa-icons",o=jt(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")}">
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{ot,it,at}from"./chunk-jkvr7e91.js";import"./chunk-7rta163c.js";import"./chunk-ce6zddpf.js";import{f}from"./chunk-w1v1d7rq.js";import"./chunk-bk96wjaz.js";import"./chunk-5t4qtxgr.js";import"./chunk-pdc9s7bg.js";import{Bt,$s,Ft,ai,st,ci,Rs,zt,ui,Ht}from"./chunk-4yf1w261.js";import M from"fs";import x from"path";function E(t,e){let r=[x.join(t.root,"stx.config.ts"),x.join(t.root,"stx.config.js"),x.join(t.root,"stx.config.mjs")],s=e.debounceMs??300,o=null,a=[];for(let c of r)try{if(!M.existsSync(c))continue;let n=M.watch(c,(d)=>{if(d==="change"){if(o)clearTimeout(o);o=setTimeout(async()=>{ci("Config file changed, restarting...");try{await e.onChange()}catch(p){st(`Failed to restart: ${p}`)}},s)}});a.push(n)}catch{}return{stop(){if(o)clearTimeout(o);for(let c of a)c.close()}}}import w from"fs";import j from"path";var ct=".stx/story/analytics.json",dt=1,A=1e4;class k{storage;storagePath;currentSession=null;dirty=!1;viewStartTimes=new Map;constructor(t){this.storagePath=j.join(t,ct),this.storage=this.loadStorage(),this.startSession()}loadStorage(){try{let t=w.readFileSync(this.storagePath,"utf-8");return JSON.parse(t)}catch{return{version:dt,events:[],sessions:[]}}}async save(){if(!this.dirty)return;let t=j.dirname(this.storagePath);if(await w.promises.mkdir(t,{recursive:!0}),this.storage.events.length>A)this.storage.events=this.storage.events.slice(-A);await w.promises.writeFile(this.storagePath,JSON.stringify(this.storage,null,2)),this.dirty=!1}startSession(){this.endSession(),this.currentSession={id:pt(),startTime:Date.now(),componentViews:[]},this.storage.sessions.push(this.currentSession),this.dirty=!0}endSession(){if(this.currentSession)this.currentSession.endTime=Date.now(),this.currentSession=null}track(t){this.storage.events.push({...t,timestamp:Date.now()}),this.dirty=!0}trackView(t,e){if(this.endViewTiming(t),this.viewStartTimes.set(t,Date.now()),this.track({type:"view",componentId:t,variantId:e}),this.currentSession&&!this.currentSession.componentViews.includes(t))this.currentSession.componentViews.push(t)}endViewTiming(t){let e=this.viewStartTimes.get(t);if(e){let r=Date.now()-e;this.track({type:"view",componentId:t,metadata:{duration:r,endView:!0}}),this.viewStartTimes.delete(t)}}trackPropChange(t,e,r){this.track({type:"prop_change",componentId:t,propName:e,metadata:{value:r}})}trackVariantSwitch(t,e){this.track({type:"variant_switch",componentId:t,variantId:e})}trackSearch(t,e){this.track({type:"search",query:t,metadata:{resultCount:e}})}getComponentAnalytics(t,e){let r=this.storage.events.filter((i)=>i.componentId===t),s=r.filter((i)=>i.type==="view"&&!i.metadata?.endView),o=r.filter((i)=>i.type==="prop_change"),a=r.filter((i)=>i.type==="variant_switch"),c={};for(let i of o)if(i.propName)c[i.propName]=(c[i.propName]||0)+1;let n={};for(let i of a)if(i.variantId)n[i.variantId]=(n[i.variantId]||0)+1;let d=new Set(this.storage.sessions.filter((i)=>i.componentViews.includes(t)).map((i)=>i.id)),p=r.filter((i)=>i.metadata?.duration).map((i)=>i.metadata.duration),u=p.length>0?p.reduce((i,l)=>i+l,0)/p.length:0,y=Object.entries(c).sort((i,l)=>l[1]-i[1]).slice(0,5).map(([i])=>i);return{componentId:t,componentName:e,viewCount:s.length,uniqueViews:d.size,lastViewed:s[s.length-1]?.timestamp,propChanges:c,topChangedProps:y,variantViews:n,avgTimeSpent:u}}getMostViewedComponents(t=10){let e=new Map;for(let r of this.storage.events)if(r.type==="view"&&r.componentId&&!r.metadata?.endView)e.set(r.componentId,(e.get(r.componentId)||0)+1);return Array.from(e.entries()).map(([r,s])=>({componentId:r,viewCount:s})).sort((r,s)=>s.viewCount-r.viewCount).slice(0,t)}getMostChangedProps(t=10){let e=new Map;for(let r of this.storage.events)if(r.type==="prop_change"&&r.propName)e.set(r.propName,(e.get(r.propName)||0)+1);return Array.from(e.entries()).map(([r,s])=>({propName:r,changeCount:s})).sort((r,s)=>s.changeCount-r.changeCount).slice(0,t)}getSearchAnalytics(){let t=this.storage.events.filter((o)=>o.type==="search"),e=new Map,r=0;for(let o of t){if(o.query)e.set(o.query,(e.get(o.query)||0)+1);if(o.metadata?.resultCount!==void 0)r+=o.metadata.resultCount}let s=Array.from(e.entries()).map(([o,a])=>({query:o,count:a})).sort((o,a)=>a.count-o.count).slice(0,10);return{totalSearches:t.length,topQueries:s,avgResultCount:t.length>0?r/t.length:0}}clear(){this.storage.events=[],this.storage.sessions=[],this.dirty=!0,this.startSession()}exportAnalytics(){return JSON.stringify({exportedAt:Date.now(),...this.storage},null,2)}}function pt(){return`session-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}import S from"fs";import B from"path";var lt=".stx/story/bookmarks.json",mt=1;class P{storage;storagePath;dirty=!1;constructor(t){this.storagePath=B.join(t,lt),this.storage=this.loadStorage()}loadStorage(){try{let t=S.readFileSync(this.storagePath,"utf-8");return JSON.parse(t)}catch{return{version:mt,bookmarks:[]}}}async save(){if(!this.dirty)return;let t=B.dirname(this.storagePath);await S.promises.mkdir(t,{recursive:!0}),await S.promises.writeFile(this.storagePath,JSON.stringify(this.storage,null,2)),this.dirty=!1}addBookmark(t,e,r,s={}){let o={id:ut(),name:s.name||`${t}/${e}`,storyId:t,variantId:e,props:r,created:Date.now(),notes:s.notes,color:s.color};return this.storage.bookmarks.push(o),this.dirty=!0,o}getAllBookmarks(){return[...this.storage.bookmarks]}getBookmarksForStory(t){return this.storage.bookmarks.filter((e)=>e.storyId===t)}getBookmark(t){return this.storage.bookmarks.find((e)=>e.id===t)}isBookmarked(t,e){return this.storage.bookmarks.some((r)=>r.storyId===t&&r.variantId===e)}updateBookmark(t,e){let r=this.getBookmark(t);if(!r)return;return Object.assign(r,e),this.dirty=!0,r}deleteBookmark(t){let e=this.storage.bookmarks.findIndex((r)=>r.id===t);if(e===-1)return!1;return this.storage.bookmarks.splice(e,1),this.dirty=!0,!0}toggleBookmark(t,e,r){let s=this.storage.bookmarks.find((a)=>a.storyId===t&&a.variantId===e);if(s)return this.deleteBookmark(s.id),{added:!1};return{added:!0,bookmark:this.addBookmark(t,e,r)}}exportBookmarks(){return JSON.stringify(this.storage,null,2)}importBookmarks(t,e=!0){let r=JSON.parse(t),s=0;for(let o of r.bookmarks){if(e){let a=this.storage.bookmarks.find((c)=>c.id===o.id);if(a)Object.assign(a,o);else this.storage.bookmarks.push(o)}else this.storage.bookmarks.push(o);s++}if(s>0)this.dirty=!0;return s}}function ut(){return`bm-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}var v=new Set;function N(){return{open(t){v.add(t),t.send(JSON.stringify({type:"connected",timestamp:Date.now()}))},close(t){v.delete(t)},message(t,e){}}}function C(t){let e=JSON.stringify({...t,timestamp:t.timestamp||Date.now()});for(let r of v)try{r.send(e)}catch{v.delete(r)}}function V(t,e){C({type:"story-update",data:{storyId:t,...e}})}function H(t,e){C({type:"story-add",data:{storyId:t,...e}})}function O(t){C({type:"story-remove",data:{storyId:t}})}function F(t){return`
2
+ import{ot,it,at}from"./chunk-jkvr7e91.js";import"./chunk-7rta163c.js";import"./chunk-ce6zddpf.js";import{f}from"./chunk-zsgcsqat.js";import"./chunk-55zaxb4s.js";import"./chunk-2h8ea0we.js";import"./chunk-x5tjb4y4.js";import{Bt,$s,Ft,ai,st,ci,Rs,zt,ui,Ht}from"./chunk-4yf1w261.js";import M from"fs";import x from"path";function E(t,e){let r=[x.join(t.root,"stx.config.ts"),x.join(t.root,"stx.config.js"),x.join(t.root,"stx.config.mjs")],s=e.debounceMs??300,o=null,a=[];for(let c of r)try{if(!M.existsSync(c))continue;let n=M.watch(c,(d)=>{if(d==="change"){if(o)clearTimeout(o);o=setTimeout(async()=>{ci("Config file changed, restarting...");try{await e.onChange()}catch(p){st(`Failed to restart: ${p}`)}},s)}});a.push(n)}catch{}return{stop(){if(o)clearTimeout(o);for(let c of a)c.close()}}}import w from"fs";import j from"path";var ct=".stx/story/analytics.json",dt=1,A=1e4;class k{storage;storagePath;currentSession=null;dirty=!1;viewStartTimes=new Map;constructor(t){this.storagePath=j.join(t,ct),this.storage=this.loadStorage(),this.startSession()}loadStorage(){try{let t=w.readFileSync(this.storagePath,"utf-8");return JSON.parse(t)}catch{return{version:dt,events:[],sessions:[]}}}async save(){if(!this.dirty)return;let t=j.dirname(this.storagePath);if(await w.promises.mkdir(t,{recursive:!0}),this.storage.events.length>A)this.storage.events=this.storage.events.slice(-A);await w.promises.writeFile(this.storagePath,JSON.stringify(this.storage,null,2)),this.dirty=!1}startSession(){this.endSession(),this.currentSession={id:pt(),startTime:Date.now(),componentViews:[]},this.storage.sessions.push(this.currentSession),this.dirty=!0}endSession(){if(this.currentSession)this.currentSession.endTime=Date.now(),this.currentSession=null}track(t){this.storage.events.push({...t,timestamp:Date.now()}),this.dirty=!0}trackView(t,e){if(this.endViewTiming(t),this.viewStartTimes.set(t,Date.now()),this.track({type:"view",componentId:t,variantId:e}),this.currentSession&&!this.currentSession.componentViews.includes(t))this.currentSession.componentViews.push(t)}endViewTiming(t){let e=this.viewStartTimes.get(t);if(e){let r=Date.now()-e;this.track({type:"view",componentId:t,metadata:{duration:r,endView:!0}}),this.viewStartTimes.delete(t)}}trackPropChange(t,e,r){this.track({type:"prop_change",componentId:t,propName:e,metadata:{value:r}})}trackVariantSwitch(t,e){this.track({type:"variant_switch",componentId:t,variantId:e})}trackSearch(t,e){this.track({type:"search",query:t,metadata:{resultCount:e}})}getComponentAnalytics(t,e){let r=this.storage.events.filter((i)=>i.componentId===t),s=r.filter((i)=>i.type==="view"&&!i.metadata?.endView),o=r.filter((i)=>i.type==="prop_change"),a=r.filter((i)=>i.type==="variant_switch"),c={};for(let i of o)if(i.propName)c[i.propName]=(c[i.propName]||0)+1;let n={};for(let i of a)if(i.variantId)n[i.variantId]=(n[i.variantId]||0)+1;let d=new Set(this.storage.sessions.filter((i)=>i.componentViews.includes(t)).map((i)=>i.id)),p=r.filter((i)=>i.metadata?.duration).map((i)=>i.metadata.duration),u=p.length>0?p.reduce((i,l)=>i+l,0)/p.length:0,y=Object.entries(c).sort((i,l)=>l[1]-i[1]).slice(0,5).map(([i])=>i);return{componentId:t,componentName:e,viewCount:s.length,uniqueViews:d.size,lastViewed:s[s.length-1]?.timestamp,propChanges:c,topChangedProps:y,variantViews:n,avgTimeSpent:u}}getMostViewedComponents(t=10){let e=new Map;for(let r of this.storage.events)if(r.type==="view"&&r.componentId&&!r.metadata?.endView)e.set(r.componentId,(e.get(r.componentId)||0)+1);return Array.from(e.entries()).map(([r,s])=>({componentId:r,viewCount:s})).sort((r,s)=>s.viewCount-r.viewCount).slice(0,t)}getMostChangedProps(t=10){let e=new Map;for(let r of this.storage.events)if(r.type==="prop_change"&&r.propName)e.set(r.propName,(e.get(r.propName)||0)+1);return Array.from(e.entries()).map(([r,s])=>({propName:r,changeCount:s})).sort((r,s)=>s.changeCount-r.changeCount).slice(0,t)}getSearchAnalytics(){let t=this.storage.events.filter((o)=>o.type==="search"),e=new Map,r=0;for(let o of t){if(o.query)e.set(o.query,(e.get(o.query)||0)+1);if(o.metadata?.resultCount!==void 0)r+=o.metadata.resultCount}let s=Array.from(e.entries()).map(([o,a])=>({query:o,count:a})).sort((o,a)=>a.count-o.count).slice(0,10);return{totalSearches:t.length,topQueries:s,avgResultCount:t.length>0?r/t.length:0}}clear(){this.storage.events=[],this.storage.sessions=[],this.dirty=!0,this.startSession()}exportAnalytics(){return JSON.stringify({exportedAt:Date.now(),...this.storage},null,2)}}function pt(){return`session-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}import S from"fs";import B from"path";var lt=".stx/story/bookmarks.json",mt=1;class P{storage;storagePath;dirty=!1;constructor(t){this.storagePath=B.join(t,lt),this.storage=this.loadStorage()}loadStorage(){try{let t=S.readFileSync(this.storagePath,"utf-8");return JSON.parse(t)}catch{return{version:mt,bookmarks:[]}}}async save(){if(!this.dirty)return;let t=B.dirname(this.storagePath);await S.promises.mkdir(t,{recursive:!0}),await S.promises.writeFile(this.storagePath,JSON.stringify(this.storage,null,2)),this.dirty=!1}addBookmark(t,e,r,s={}){let o={id:ut(),name:s.name||`${t}/${e}`,storyId:t,variantId:e,props:r,created:Date.now(),notes:s.notes,color:s.color};return this.storage.bookmarks.push(o),this.dirty=!0,o}getAllBookmarks(){return[...this.storage.bookmarks]}getBookmarksForStory(t){return this.storage.bookmarks.filter((e)=>e.storyId===t)}getBookmark(t){return this.storage.bookmarks.find((e)=>e.id===t)}isBookmarked(t,e){return this.storage.bookmarks.some((r)=>r.storyId===t&&r.variantId===e)}updateBookmark(t,e){let r=this.getBookmark(t);if(!r)return;return Object.assign(r,e),this.dirty=!0,r}deleteBookmark(t){let e=this.storage.bookmarks.findIndex((r)=>r.id===t);if(e===-1)return!1;return this.storage.bookmarks.splice(e,1),this.dirty=!0,!0}toggleBookmark(t,e,r){let s=this.storage.bookmarks.find((a)=>a.storyId===t&&a.variantId===e);if(s)return this.deleteBookmark(s.id),{added:!1};return{added:!0,bookmark:this.addBookmark(t,e,r)}}exportBookmarks(){return JSON.stringify(this.storage,null,2)}importBookmarks(t,e=!0){let r=JSON.parse(t),s=0;for(let o of r.bookmarks){if(e){let a=this.storage.bookmarks.find((c)=>c.id===o.id);if(a)Object.assign(a,o);else this.storage.bookmarks.push(o)}else this.storage.bookmarks.push(o);s++}if(s>0)this.dirty=!0;return s}}function ut(){return`bm-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}var v=new Set;function N(){return{open(t){v.add(t),t.send(JSON.stringify({type:"connected",timestamp:Date.now()}))},close(t){v.delete(t)},message(t,e){}}}function C(t){let e=JSON.stringify({...t,timestamp:t.timestamp||Date.now()});for(let r of v)try{r.send(e)}catch{v.delete(r)}}function V(t,e){C({type:"story-update",data:{storyId:t,...e}})}function H(t,e){C({type:"story-add",data:{storyId:t,...e}})}function O(t){C({type:"story-remove",data:{storyId:t}})}function F(t){return`
3
3
  <script>
4
4
  (function() {
5
5
  const ws = new WebSocket('${t}');
@@ -556,7 +556,7 @@ window.__stxPerformance = {
556
556
 
557
557
  window.clearPerformanceMetrics = () => window.__stxPerformance.clear();
558
558
  </script>
559
- `}import T from"fs";import K from"path";var ft=".stx/story/presets.json",R=1,yt=10;class I{storage;storagePath;dirty=!1;constructor(t){this.storagePath=K.join(t,ft),this.storage=this.loadStorage()}loadStorage(){try{let t=T.readFileSync(this.storagePath,"utf-8"),e=JSON.parse(t);if(e.version!==R)return this.migrateStorage(e);return e}catch{return{version:R,presets:[],recentIds:[]}}}migrateStorage(t){return{version:R,presets:t.presets||[],recentIds:t.recentIds||[]}}async save(){if(!this.dirty)return;let t=K.dirname(this.storagePath);await T.promises.mkdir(t,{recursive:!0}),await T.promises.writeFile(this.storagePath,JSON.stringify(this.storage,null,2)),this.dirty=!1}createPreset(t,e,r={}){let s={id:ht(),name:t,description:r.description,props:e,componentId:r.componentId,created:Date.now(),usageCount:0,tags:r.tags};return this.storage.presets.push(s),this.dirty=!0,s}getPreset(t){return this.storage.presets.find((e)=>e.id===t)}getAllPresets(){return[...this.storage.presets]}getPresetsForComponent(t){return this.storage.presets.filter((e)=>!e.componentId||e.componentId===t)}getRecentPresets(){return this.storage.recentIds.map((t)=>this.getPreset(t)).filter((t)=>t!==void 0)}usePreset(t){let e=this.getPreset(t);if(!e)return;return e.lastUsed=Date.now(),e.usageCount++,this.storage.recentIds=[t,...this.storage.recentIds.filter((r)=>r!==t)].slice(0,yt),this.dirty=!0,e}updatePreset(t,e){let r=this.getPreset(t);if(!r)return;return Object.assign(r,e),this.dirty=!0,r}deletePreset(t){let e=this.storage.presets.findIndex((r)=>r.id===t);if(e===-1)return!1;return this.storage.presets.splice(e,1),this.storage.recentIds=this.storage.recentIds.filter((r)=>r!==t),this.dirty=!0,!0}searchPresets(t){let e=t.toLowerCase();return this.storage.presets.filter((r)=>{if(r.name.toLowerCase().includes(e))return!0;if(r.description?.toLowerCase().includes(e))return!0;if(r.tags?.some((s)=>s.toLowerCase().includes(e)))return!0;return!1})}getMostUsedPresets(t=5){return[...this.storage.presets].sort((e,r)=>r.usageCount-e.usageCount).slice(0,t)}exportPresets(t){let e=t?this.storage.presets.filter((r)=>t.includes(r.id)):this.storage.presets;return JSON.stringify({presets:e},null,2)}importPresets(t,e=!1){let r=JSON.parse(t),s=0;for(let o of r.presets){let a=this.storage.presets.find((c)=>c.id===o.id);if(a&&!e)continue;if(a)Object.assign(a,o);else this.storage.presets.push(o);s++}if(s>0)this.dirty=!0;return s}}function ht(){return`preset-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}import _ from"fs";var q=new Map;async function b(t,e,r={}){let s=performance.now(),o=[];try{let a=await _.promises.stat(e),c=q.get(e),n;if(c&&c.mtime===a.mtimeMs)n=c.content;else n=await _.promises.readFile(e,"utf-8"),q.set(e,{content:n,mtime:a.mtimeMs,analyzed:null});let{processDirectives:d}=await import("./chunk-cs0dd5w8.js"),p={},u=h(n);if(u)try{await f(u,p,e)}catch(g){o.push(`Warning: Could not extract script variables: ${g instanceof Error?g.message:String(g)}`)}if(r.props)Object.assign(p,r.props);let i=await d(n,p,e,{},new Set),l=Z(n),m=h(n);return i=Q(i),i=tt(i,p),{html:i,css:l,js:m,errors:o,duration:performance.now()-s}}catch(a){return o.push(a instanceof Error?a.message:String(a)),{html:`<div class="stx-render-error">${et(o[0])}</div>`,css:"",js:"",errors:o,duration:performance.now()-s}}}async function vt(t){try{let e=await _.promises.readFile(t,"utf-8"),r=h(e);if(!r)return null;let s={};if(await f(r,s,t),Array.isArray(s.variants))return s.variants;return null}catch{return null}}async function Y(t,e,r,s){let o=e.story?.variants;if(!o){let n=await vt(e.path);if(n)o=n}if(!o&&r==="default")return b(t,e.path,{props:s||{}});if(!o)return b(t,e.path,{props:s||{}});let a=o.find((n)=>n.id===r);if(!a&&r==="default")return b(t,e.path,{props:s||{}});if(!a)return{html:'<div class="stx-render-error">Variant not found</div>',css:"",js:"",errors:[`Variant '${r}' not found`],duration:0};let c={...a.state,...s};if(a.source)return bt(t,a.source,c);return b(t,e.path,{props:c})}async function bt(t,e,r={}){let s=performance.now(),o=[];try{let{processDirectives:a}=await import("./chunk-cs0dd5w8.js"),c={...r},n=h(e);if(n)try{await f(n,c,"inline-template.stx")}catch{}let p=await a(e,c,"inline-template.stx",{},new Set);return p=Q(p),p=tt(p,c),{html:p,css:Z(e),js:h(e),errors:o,duration:performance.now()-s}}catch(a){return o.push(a instanceof Error?a.message:String(a)),{html:`<div class="stx-render-error">${et(o[0])}</div>`,css:"",js:"",errors:o,duration:performance.now()-s}}}function Z(t){let e=[],r=/<style\b[^>]*>([\s\S]*?)<\/style>/gi,s=r.exec(t);while(s!==null)e.push(s[1].trim()),s=r.exec(t);return e.join(`
559
+ `}import T from"fs";import K from"path";var ft=".stx/story/presets.json",R=1,yt=10;class I{storage;storagePath;dirty=!1;constructor(t){this.storagePath=K.join(t,ft),this.storage=this.loadStorage()}loadStorage(){try{let t=T.readFileSync(this.storagePath,"utf-8"),e=JSON.parse(t);if(e.version!==R)return this.migrateStorage(e);return e}catch{return{version:R,presets:[],recentIds:[]}}}migrateStorage(t){return{version:R,presets:t.presets||[],recentIds:t.recentIds||[]}}async save(){if(!this.dirty)return;let t=K.dirname(this.storagePath);await T.promises.mkdir(t,{recursive:!0}),await T.promises.writeFile(this.storagePath,JSON.stringify(this.storage,null,2)),this.dirty=!1}createPreset(t,e,r={}){let s={id:ht(),name:t,description:r.description,props:e,componentId:r.componentId,created:Date.now(),usageCount:0,tags:r.tags};return this.storage.presets.push(s),this.dirty=!0,s}getPreset(t){return this.storage.presets.find((e)=>e.id===t)}getAllPresets(){return[...this.storage.presets]}getPresetsForComponent(t){return this.storage.presets.filter((e)=>!e.componentId||e.componentId===t)}getRecentPresets(){return this.storage.recentIds.map((t)=>this.getPreset(t)).filter((t)=>t!==void 0)}usePreset(t){let e=this.getPreset(t);if(!e)return;return e.lastUsed=Date.now(),e.usageCount++,this.storage.recentIds=[t,...this.storage.recentIds.filter((r)=>r!==t)].slice(0,yt),this.dirty=!0,e}updatePreset(t,e){let r=this.getPreset(t);if(!r)return;return Object.assign(r,e),this.dirty=!0,r}deletePreset(t){let e=this.storage.presets.findIndex((r)=>r.id===t);if(e===-1)return!1;return this.storage.presets.splice(e,1),this.storage.recentIds=this.storage.recentIds.filter((r)=>r!==t),this.dirty=!0,!0}searchPresets(t){let e=t.toLowerCase();return this.storage.presets.filter((r)=>{if(r.name.toLowerCase().includes(e))return!0;if(r.description?.toLowerCase().includes(e))return!0;if(r.tags?.some((s)=>s.toLowerCase().includes(e)))return!0;return!1})}getMostUsedPresets(t=5){return[...this.storage.presets].sort((e,r)=>r.usageCount-e.usageCount).slice(0,t)}exportPresets(t){let e=t?this.storage.presets.filter((r)=>t.includes(r.id)):this.storage.presets;return JSON.stringify({presets:e},null,2)}importPresets(t,e=!1){let r=JSON.parse(t),s=0;for(let o of r.presets){let a=this.storage.presets.find((c)=>c.id===o.id);if(a&&!e)continue;if(a)Object.assign(a,o);else this.storage.presets.push(o);s++}if(s>0)this.dirty=!0;return s}}function ht(){return`preset-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}import _ from"fs";var q=new Map;async function b(t,e,r={}){let s=performance.now(),o=[];try{let a=await _.promises.stat(e),c=q.get(e),n;if(c&&c.mtime===a.mtimeMs)n=c.content;else n=await _.promises.readFile(e,"utf-8"),q.set(e,{content:n,mtime:a.mtimeMs,analyzed:null});let{processDirectives:d}=await import("./chunk-zyqs6a3p.js"),p={},u=h(n);if(u)try{await f(u,p,e)}catch(g){o.push(`Warning: Could not extract script variables: ${g instanceof Error?g.message:String(g)}`)}if(r.props)Object.assign(p,r.props);let i=await d(n,p,e,{},new Set),l=Z(n),m=h(n);return i=Q(i),i=tt(i,p),{html:i,css:l,js:m,errors:o,duration:performance.now()-s}}catch(a){return o.push(a instanceof Error?a.message:String(a)),{html:`<div class="stx-render-error">${et(o[0])}</div>`,css:"",js:"",errors:o,duration:performance.now()-s}}}async function vt(t){try{let e=await _.promises.readFile(t,"utf-8"),r=h(e);if(!r)return null;let s={};if(await f(r,s,t),Array.isArray(s.variants))return s.variants;return null}catch{return null}}async function Y(t,e,r,s){let o=e.story?.variants;if(!o){let n=await vt(e.path);if(n)o=n}if(!o&&r==="default")return b(t,e.path,{props:s||{}});if(!o)return b(t,e.path,{props:s||{}});let a=o.find((n)=>n.id===r);if(!a&&r==="default")return b(t,e.path,{props:s||{}});if(!a)return{html:'<div class="stx-render-error">Variant not found</div>',css:"",js:"",errors:[`Variant '${r}' not found`],duration:0};let c={...a.state,...s};if(a.source)return bt(t,a.source,c);return b(t,e.path,{props:c})}async function bt(t,e,r={}){let s=performance.now(),o=[];try{let{processDirectives:a}=await import("./chunk-zyqs6a3p.js"),c={...r},n=h(e);if(n)try{await f(n,c,"inline-template.stx")}catch{}let p=await a(e,c,"inline-template.stx",{},new Set);return p=Q(p),p=tt(p,c),{html:p,css:Z(e),js:h(e),errors:o,duration:performance.now()-s}}catch(a){return o.push(a instanceof Error?a.message:String(a)),{html:`<div class="stx-render-error">${et(o[0])}</div>`,css:"",js:"",errors:o,duration:performance.now()-s}}}function Z(t){let e=[],r=/<style\b[^>]*>([\s\S]*?)<\/style>/gi,s=r.exec(t);while(s!==null)e.push(s[1].trim()),s=r.exec(t);return e.join(`
560
560
  `)}function Q(t){return t.replace(/<!--[\s\S]*?-->/g,"").replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,"").replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,"").replace(/^\s*\n/gm,"").trim()}function h(t){let e=[],r=/<script\b[^>]*>([\s\S]*?)<\/script>/gi,s=r.exec(t);while(s!==null)e.push(s[1].trim()),s=r.exec(t);return e.join(`
561
561
  `)}function tt(t,e){let r=`<script>window.__stxProps = ${JSON.stringify(e)};</script>`;return t+r}function et(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}async function rt(t,e){let r=await zt(t);it(t,r);let s=Ht(t.config,r);at(t,s),console.log(` Found ${r.length} story files`);let o=typeof e.host==="string"?e.host:e.host===!0?"0.0.0.0":"localhost",a=new I(t.root),c=new P(t.root),n=new k(t.root),d=N(),p=Bun.serve({port:e.port,hostname:o,fetch:async(i,l)=>{let g=new URL(i.url).pathname;if(g==="/__hmr"){if(l.upgrade(i,{data:{isHmr:!0}}))return;return new Response("WebSocket upgrade failed",{status:400})}if(g.startsWith("/api/"))return xt(t,g,i,{presetsManager:a,bookmarksManager:c,analyticsTracker:n});return wt(t,g,e.port)},websocket:{open(i){d.open(i)},close(i){d.close(i)},message(i,l){d.message(i,l)}}}),u=`http://${o}:${e.port}`,y=ui(t,async(i,l)=>{console.log(` [${i}] ${l.relativePath}`);let m=await zt(t);it(t,m);let g=Ht(t.config,m);if(at(t,g),i==="add")H(l.id,{fileName:l.fileName});else if(i==="unlink")O(l.id);else V(l.id,{fileName:l.fileName})});if(e.open){let i=u;try{let{exec:l}=await import("child_process"),m=process.platform;l(`${m==="darwin"?"open":m==="win32"?"start":"xdg-open"} ${i}`)}catch{}}return{server:p,url:u,close:async()=>{y(),p.stop()}}}async function xt(t,e,r,s){let{presetsManager:o,bookmarksManager:a,analyticsTracker:c}=s;if(e==="/api/stories")return Response.json({files:t.storyFiles.map((n)=>({id:n.id,fileName:n.fileName,relativePath:n.relativePath,treePath:n.treePath})),tree:t.tree});if(e.startsWith("/api/story/")){let n=e.slice(11),d=t.storyFiles.find((p)=>p.id===n);if(!d)return new Response("Story not found",{status:404});try{let p=await Bun.file(d.path).text();return Response.json({id:d.id,fileName:d.fileName,relativePath:d.relativePath,content:p})}catch{return new Response("Error reading story",{status:500})}}if(e==="/api/config")return Response.json({theme:t.config.theme,responsivePresets:t.config.responsivePresets,backgroundPresets:t.config.backgroundPresets});if(e.startsWith("/api/render/")){let n=new URL(r.url),d=e.slice(12).split("/"),p=d[0],u=d[1]||"default",y,i=n.searchParams.get("props");if(i)try{y=JSON.parse(i)}catch{}let l=t.storyFiles.find((m)=>m.id===p);if(!l)return new Response("Story not found",{status:404});try{let m=await Y(t,l,u,y);return Response.json({html:m.html,css:m.css,js:m.js,errors:m.errors,duration:m.duration})}catch(m){return Response.json({html:"",css:"",js:"",errors:[m instanceof Error?m.message:String(m)],duration:0},{status:500})}}if(e==="/api/presets"&&r.method==="GET")return Response.json({presets:o.getAllPresets()});if(e==="/api/presets"&&r.method==="POST")try{let n=await r.json(),d=o.createPreset(n.name,n.props,{componentId:n.componentId,description:n.description});return await o.save(),Response.json(d)}catch(n){return Response.json({error:String(n)},{status:400})}if(e.startsWith("/api/presets/")&&!e.includes("/use")&&r.method==="GET"){let n=e.slice(13),d=o.getPreset(n);if(!d)return new Response("Preset not found",{status:404});return Response.json(d)}if(e.endsWith("/use")&&r.method==="POST"){let n=e.slice(13,-4),d=o.usePreset(n);if(!d)return new Response("Preset not found",{status:404});return await o.save(),Response.json(d)}if(e.startsWith("/api/presets/")&&r.method==="DELETE"){let n=e.slice(13);if(!o.deletePreset(n))return new Response("Preset not found",{status:404});return await o.save(),Response.json({success:!0})}if(e==="/api/bookmarks"&&r.method==="GET")return Response.json({bookmarks:a.getAllBookmarks()});if(e==="/api/bookmarks"&&r.method==="POST")try{let n=await r.json(),d=a.addBookmark(n.storyId,n.variantId,n.props,{name:n.name,notes:n.notes,color:n.color});return await a.save(),Response.json(d)}catch(n){return Response.json({error:String(n)},{status:400})}if(e==="/api/bookmarks/toggle"&&r.method==="POST")try{let n=await r.json(),d=a.toggleBookmark(n.storyId,n.variantId,n.props);return await a.save(),Response.json(d)}catch(n){return Response.json({error:String(n)},{status:400})}if(e.startsWith("/api/bookmarks/")&&e!=="/api/bookmarks/toggle"&&r.method==="GET"){let n=e.slice(15),d=a.getBookmark(n);if(!d)return new Response("Bookmark not found",{status:404});return Response.json(d)}if(e.startsWith("/api/bookmarks/")&&r.method==="DELETE"){let n=e.slice(15);if(!a.deleteBookmark(n))return new Response("Bookmark not found",{status:404});return await a.save(),Response.json({success:!0})}if(e==="/api/analytics/track"&&r.method==="POST")try{let n=await r.json();if(n.type==="view"&&n.componentId)c.trackView(n.componentId,n.variantId);else if(n.type==="prop_change"&&n.componentId&&n.propName)c.trackPropChange(n.componentId,n.propName,null);else if(n.type==="variant_switch"&&n.componentId&&n.variantId)c.trackVariantSwitch(n.componentId,n.variantId);else if(n.type==="search"&&n.query)c.trackSearch(n.query,0);return await c.save(),Response.json({success:!0})}catch(n){return Response.json({error:String(n)},{status:400})}if(e==="/api/analytics/summary"&&r.method==="GET")return Response.json({mostViewed:c.getMostViewedComponents(10),mostChangedProps:c.getMostChangedProps(10),searchAnalytics:c.getSearchAnalytics()});if(e.startsWith("/api/analytics/component/")&&r.method==="GET"){let n=e.slice(25),d=t.storyFiles.find((u)=>u.id===n),p=c.getComponentAnalytics(n,d?.fileName||n);return Response.json(p)}return new Response("Not found",{status:404})}function wt(t,e,r){let s=kt(t,r);return new Response(s,{headers:{"Content-Type":"text/html; charset=utf-8"}})}function kt(t,e){let{theme:r}=t.config,s=r.title||"STX Story",o=`ws://localhost:${e}/__hmr`,a=F(o);return`<!DOCTYPE html>
562
562
  <html lang="en" class="${r.darkClass||"dark"}">
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{t,a,Dt,Mt,Lt,Le,tt,P,xs,mr,je}from"./chunk-bk96wjaz.js";var O=/(?<![\w$@])@meta\s*\(/g,I=/(?<![\w$@])@metaTag\s*\(/g,C=/(?<![\w$@])@structuredData\s*\(/g,k=/(?<![\w$@])@seo\s*\(/g;function _(e,r){return(n)=>P(e,n,"the call has no closing parenthesis",r,t.INVALID_DIRECTIVE_SYNTAX)}function N(e){return"property"in e?`<meta property="${l(e.property)}" content="${l(e.content)}">`:`<meta name="${l(e.name)}" content="${l(e.content)}">`}function mo(e,r,n,g){if(!e.includes("@meta"))return e;let i=Dt(e,O,(s,c)=>{let o=mr(Mt(s),r);if(o.kind==="tag")return N(o.tag);if(o.kind==="empty")return"";return P("Meta",c,o.message,n,o.code)},_("Meta",n));return i=Dt(i,I,(s,c)=>{let o=Lt(s,r);if(!o.ok)return P("MetaTag",c,o.message,n,o.code);if(o.value===void 0||o.value===null)return"";if(!tt(o.value))return P("MetaTag",c,`expected an object such as { name, content }, got ${Le(o.value)}`,n,t.TYPE_ERROR);let u=o.value;if(!u.name&&!u.property&&!u.httpEquiv)return P("MetaTag",c,"the tag needs a name, property or httpEquiv",n,t.INVALID_DIRECTIVE_SYNTAX);if(u.content===void 0||u.content===null||u.content===""||u.content===!1)return"";let p="<meta";if(u.name)p+=` name="${l(u.name)}"`;if(u.property)p+=` property="${l(u.property)}"`;if(u.httpEquiv)p+=` http-equiv="${l(u.httpEquiv)}"`;return p+=` content="${l(u.content)}">`,p},_("MetaTag",n)),i}function b(e){let r=(n)=>n["@context"]?{...n}:{...n,"@context":"https://schema.org"};if(tt(e))return r(e);if(Array.isArray(e)&&e.length>0&&e.every(tt))return e.map(r);return null}function E(e){return`<script type="application/ld+json">${JSON.stringify(e).replace(/<\//g,"<\\/")}</script>`}function ho(e,r,n){if(!e.includes("@structuredData"))return e;return Dt(e,C,(g,i)=>{let s=Lt(g,r);if(!s.ok)return P("StructuredData",i,s.message,n,s.code);if(s.value===void 0||s.value===null)return"";let c=b(s.value);if(!c)return P("StructuredData",i,`expected an object or an array of objects, got ${Le(s.value)}`,n,t.TYPE_ERROR);try{return E(c)}catch(o){let u=o instanceof Error?o.message:String(o);return P("StructuredData",i,`the data cannot be written as JSON: ${u}`,n,t.EVALUATION_ERROR)}},_("StructuredData",n))}var j=new Set(["title","description","keywords","robots","canonical","openGraph","twitter","structuredData"]),A={image:"openGraph.image",url:"canonical or openGraph.url",type:"openGraph.type",siteName:"openGraph.siteName",locale:"openGraph.locale",og:"openGraph",author:"@meta('author', ...)"};function yo(e,r,n,g){if(!e.includes("@seo"))return e;return Dt(e,k,(i,s)=>{if(!i.trim())return P("SEO",s,"expected an object: @seo({ title, description }) or @seo(seoVariable)",n,t.INVALID_DIRECTIVE_SYNTAX);let c=Lt(i,r);if(!c.ok)return P("SEO",s,c.message,n,c.code);if(c.value===void 0||c.value===null)return"";if(!tt(c.value))return P("SEO",s,`expected an object such as { title, description }, got ${Le(c.value)}`,n,t.TYPE_ERROR);try{return L(c.value,s,n)}catch(o){let u=o instanceof Error?o.message:String(o);return P("SEO",s,`Error processing @seo directive: ${u}`,n,t.EVALUATION_ERROR)}},_("SEO",n))}function R(e,r,n,g){let i=e[r];if(i===void 0||i===null||i===!1)return;if(tt(i))return i;xs(n,`${r} must be an object, got ${Le(i)}; its tags were left out`,g);return}function L(e,r,n){let g=Object.keys(e).filter((o)=>!j.has(o));if(g.length>0){let o=g.map((u)=>A[u]?`${u} (use ${A[u]})`:u).join(", ");xs(r,`@seo does not read ${o}; ${g.length===1?"it was":"they were"} ignored`,n)}let i="";if(e.title)i+=`<title>${l(e.title)}</title>
2
+ import{t,a,Dt,Mt,Lt,je,tt,P,xs,mr,Be}from"./chunk-55zaxb4s.js";var O=/(?<![\w$@])@meta\s*\(/g,I=/(?<![\w$@])@metaTag\s*\(/g,C=/(?<![\w$@])@structuredData\s*\(/g,k=/(?<![\w$@])@seo\s*\(/g;function _(e,r){return(n)=>P(e,n,"the call has no closing parenthesis",r,t.INVALID_DIRECTIVE_SYNTAX)}function N(e){return"property"in e?`<meta property="${l(e.property)}" content="${l(e.content)}">`:`<meta name="${l(e.name)}" content="${l(e.content)}">`}function mo(e,r,n,g){if(!e.includes("@meta"))return e;let i=Dt(e,O,(s,c)=>{let o=mr(Mt(s),r);if(o.kind==="tag")return N(o.tag);if(o.kind==="empty")return"";return P("Meta",c,o.message,n,o.code)},_("Meta",n));return i=Dt(i,I,(s,c)=>{let o=Lt(s,r);if(!o.ok)return P("MetaTag",c,o.message,n,o.code);if(o.value===void 0||o.value===null)return"";if(!tt(o.value))return P("MetaTag",c,`expected an object such as { name, content }, got ${je(o.value)}`,n,t.TYPE_ERROR);let u=o.value;if(!u.name&&!u.property&&!u.httpEquiv)return P("MetaTag",c,"the tag needs a name, property or httpEquiv",n,t.INVALID_DIRECTIVE_SYNTAX);if(u.content===void 0||u.content===null||u.content===""||u.content===!1)return"";let p="<meta";if(u.name)p+=` name="${l(u.name)}"`;if(u.property)p+=` property="${l(u.property)}"`;if(u.httpEquiv)p+=` http-equiv="${l(u.httpEquiv)}"`;return p+=` content="${l(u.content)}">`,p},_("MetaTag",n)),i}function b(e){let r=(n)=>n["@context"]?{...n}:{...n,"@context":"https://schema.org"};if(tt(e))return r(e);if(Array.isArray(e)&&e.length>0&&e.every(tt))return e.map(r);return null}function E(e){return`<script type="application/ld+json">${JSON.stringify(e).replace(/<\//g,"<\\/")}</script>`}function ho(e,r,n){if(!e.includes("@structuredData"))return e;return Dt(e,C,(g,i)=>{let s=Lt(g,r);if(!s.ok)return P("StructuredData",i,s.message,n,s.code);if(s.value===void 0||s.value===null)return"";let c=b(s.value);if(!c)return P("StructuredData",i,`expected an object or an array of objects, got ${je(s.value)}`,n,t.TYPE_ERROR);try{return E(c)}catch(o){let u=o instanceof Error?o.message:String(o);return P("StructuredData",i,`the data cannot be written as JSON: ${u}`,n,t.EVALUATION_ERROR)}},_("StructuredData",n))}var j=new Set(["title","description","keywords","robots","canonical","openGraph","twitter","structuredData"]),A={image:"openGraph.image",url:"canonical or openGraph.url",type:"openGraph.type",siteName:"openGraph.siteName",locale:"openGraph.locale",og:"openGraph",author:"@meta('author', ...)"};function yo(e,r,n,g){if(!e.includes("@seo"))return e;return Dt(e,k,(i,s)=>{if(!i.trim())return P("SEO",s,"expected an object: @seo({ title, description }) or @seo(seoVariable)",n,t.INVALID_DIRECTIVE_SYNTAX);let c=Lt(i,r);if(!c.ok)return P("SEO",s,c.message,n,c.code);if(c.value===void 0||c.value===null)return"";if(!tt(c.value))return P("SEO",s,`expected an object such as { title, description }, got ${je(c.value)}`,n,t.TYPE_ERROR);try{return L(c.value,s,n)}catch(o){let u=o instanceof Error?o.message:String(o);return P("SEO",s,`Error processing @seo directive: ${u}`,n,t.EVALUATION_ERROR)}},_("SEO",n))}function R(e,r,n,g){let i=e[r];if(i===void 0||i===null||i===!1)return;if(tt(i))return i;xs(n,`${r} must be an object, got ${je(i)}; its tags were left out`,g);return}function L(e,r,n){let g=Object.keys(e).filter((o)=>!j.has(o));if(g.length>0){let o=g.map((u)=>A[u]?`${u} (use ${A[u]})`:u).join(", ");xs(r,`@seo does not read ${o}; ${g.length===1?"it was":"they were"} ignored`,n)}let i="";if(e.title)i+=`<title>${l(e.title)}</title>
3
3
  `,i+=`<meta name="title" content="${l(e.title)}">
4
4
  `;if(e.description)i+=`<meta name="description" content="${l(e.description)}">
5
5
  `;if(e.keywords){let o=Array.isArray(e.keywords)?e.keywords.join(", "):e.keywords;i+=`<meta name="keywords" content="${l(o)}">
@@ -25,7 +25,7 @@ import{t,a,Dt,Mt,Lt,Le,tt,P,xs,mr,je}from"./chunk-bk96wjaz.js";var O=/(?<![\w$@]
25
25
  `}if(c.site)i+=`<meta name="twitter:site" content="${l(c.site)}">
26
26
  `;if(c.creator)i+=`<meta name="twitter:creator" content="${l(c.creator)}">
27
27
  `}if(e.structuredData!==void 0&&e.structuredData!==null){let o=b(e.structuredData);if(o)i+=`${E(o)}
28
- `;else xs(r,`structuredData must be an object or an array of objects, got ${Le(e.structuredData)}; it was left out`,n)}return i.trim()}function bo(e,r,n){if(n.seo?.enabled===!1)return e;if(e.includes("<!-- stx SEO Tags -->")||r.__stx_seo_staged===!0||n.skipDefaultSeoTags===!0)return e;let g=r.__stx_runtime_head;if(!!(g?.title||g?.meta?.some((S)=>S.property==="og:title"||S.name==="og:title"||S.name==="twitter:title"||S.name==="description")))return e;if(/<meta\s+(?:[^>]*\s)?property=["']og:title["']/i.test(e)||/<meta\s+(?:[^>]*\s)?name=["']og:title["']/i.test(e)||/<meta\s+(?:[^>]*\s)?name=["']twitter:title["']/i.test(e))return e;if(!e.includes("<head>")&&!e.includes("<head "))return e;let s=e.includes("<title>")||e.includes("</title>"),c=q(e),o=M(c),u=G(c),p="";if(r.title)p=r.title;else if(r.meta&&r.meta.title)p=r.meta.title;else if(o)p=o;else if(n.seo?.defaultConfig?.title)p=n.seo.defaultConfig.title;else p=n.defaultTitle||"stx Project";let m="";if(r.description)m=r.description;else if(r.meta&&r.meta.description)m=r.meta.description;else if(u)m=u;else if(n.seo?.defaultConfig?.description)m=n.seo.defaultConfig.description;else m=n.defaultDescription||"A website built with stx templating engine";let d="";if(r.image)d=r.image;else if(r.meta&&r.meta.image)d=r.meta.image;else if(r.openGraph&&r.openGraph.image)d=r.openGraph.image;else if(n.seo?.defaultImage)d=n.seo.defaultImage;else if(n.defaultImage)d=n.defaultImage;let f=s?"":`
28
+ `;else xs(r,`structuredData must be an object or an array of objects, got ${je(e.structuredData)}; it was left out`,n)}return i.trim()}function bo(e,r,n){if(n.seo?.enabled===!1)return e;if(e.includes("<!-- stx SEO Tags -->")||r.__stx_seo_staged===!0||n.skipDefaultSeoTags===!0)return e;let g=r.__stx_runtime_head;if(!!(g?.title||g?.meta?.some((S)=>S.property==="og:title"||S.name==="og:title"||S.name==="twitter:title"||S.name==="description")))return e;if(/<meta\s+(?:[^>]*\s)?property=["']og:title["']/i.test(e)||/<meta\s+(?:[^>]*\s)?name=["']og:title["']/i.test(e)||/<meta\s+(?:[^>]*\s)?name=["']twitter:title["']/i.test(e))return e;if(!e.includes("<head>")&&!e.includes("<head "))return e;let s=e.includes("<title>")||e.includes("</title>"),c=q(e),o=M(c),u=G(c),p="";if(r.title)p=r.title;else if(r.meta&&r.meta.title)p=r.meta.title;else if(o)p=o;else if(n.seo?.defaultConfig?.title)p=n.seo.defaultConfig.title;else p=n.defaultTitle||"stx Project";let m="";if(r.description)m=r.description;else if(r.meta&&r.meta.description)m=r.meta.description;else if(u)m=u;else if(n.seo?.defaultConfig?.description)m=n.seo.defaultConfig.description;else m=n.defaultDescription||"A website built with stx templating engine";let d="";if(r.image)d=r.image;else if(r.meta&&r.meta.image)d=r.meta.image;else if(r.openGraph&&r.openGraph.image)d=r.openGraph.image;else if(n.seo?.defaultImage)d=n.seo.defaultImage;else if(n.defaultImage)d=n.defaultImage;let f=s?"":`
29
29
  <meta name="title" content="${l(p)}">`,D=V(c)?"":`
30
30
  <meta name="description" content="${l(m)}">`,y=`
31
31
  <!-- stx SEO Tags -->${f}${D}
@@ -43,7 +43,7 @@ import{t,a,Dt,Mt,Lt,Le,tt,P,xs,mr,je}from"./chunk-bk96wjaz.js";var O=/(?<![\w$@]
43
43
  ${y}
44
44
  `),h;return h.replace(/<head[^>]*>/,`$&
45
45
  ${y}
46
- `)}function q(e){let r=e.search(/<\/head\s*>/i);return r===-1?e:e.slice(0,r)}function v(e){return e.replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&quot;/g,'"').replace(/&#0*39;|&apos;/g,"'").replace(/&amp;/g,"&")}function M(e){let r=e.match(/<title(?:\s[^>]*)?>([\s\S]*?)<\/title\s*>/i);return r?v(r[1].trim()):""}function x(e){return(e.match(/<meta\s[^>]*>/gi)||[]).filter((r)=>/\sname\s*=\s*["']description["']/i.test(r))}function V(e){return x(e).length>0}function G(e){for(let r of x(e)){let n=r.match(/\scontent\s*=\s*(?:"([^"]*)"|'([^']*)')/i),g=(n?.[1]??n?.[2]??"").trim();if(g)return v(g)}return""}function l(e){return String(e).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}var Xr={name:"meta",rawParams:!0,handler:(e,r,n,g)=>{let i=mr(r,n??{});if(i.kind==="error")return P("Meta",`@meta(${r.join(", ")})`,i.message,g,i.code);if(i.kind==="empty")return"";if(n)n.__stx_runtime_head=je(n.__stx_runtime_head??{},{meta:[i.tag]});return""},hasEndTag:!1},Jr={name:"structuredData",handler:(e,r,n,g)=>{if(e.trim()==="")return a("StructuredData","structuredData directive requires JSON-LD content",t.INVALID_DIRECTIVE_SYNTAX);try{let i=JSON.parse(e);if(!i["@context"])i["@context"]="https://schema.org";if(!i["@type"])return a("StructuredData","structuredData requires @type property",t.INVALID_DIRECTIVE_SYNTAX);return E(i)}catch(i){let s=i instanceof Error?i.message:String(i);return a("StructuredData",s,t.EVALUATION_ERROR)}},hasEndTag:!0};function kp(){return[Xr,Jr]}function _p(e,r){let{baseUrl:n,defaultChangefreq:g="weekly",defaultPriority:i=0.5,includeLastmod:s=!0}=r,c=n.replace(/\/$/,""),o=(m)=>m.startsWith("http")?m:`${c}${m.startsWith("/")?"":"/"}${m}`,u=e.map((m)=>{let d=o(m.loc),f=m.lastmod||(s?new Date().toISOString().split("T")[0]:void 0),D=m.changefreq||g,y=m.priority??i,h=` <url>
46
+ `)}function q(e){let r=e.search(/<\/head\s*>/i);return r===-1?e:e.slice(0,r)}function v(e){return e.replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&quot;/g,'"').replace(/&#0*39;|&apos;/g,"'").replace(/&amp;/g,"&")}function M(e){let r=e.match(/<title(?:\s[^>]*)?>([\s\S]*?)<\/title\s*>/i);return r?v(r[1].trim()):""}function x(e){return(e.match(/<meta\s[^>]*>/gi)||[]).filter((r)=>/\sname\s*=\s*["']description["']/i.test(r))}function V(e){return x(e).length>0}function G(e){for(let r of x(e)){let n=r.match(/\scontent\s*=\s*(?:"([^"]*)"|'([^']*)')/i),g=(n?.[1]??n?.[2]??"").trim();if(g)return v(g)}return""}function l(e){return String(e).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}var Xr={name:"meta",rawParams:!0,handler:(e,r,n,g)=>{let i=mr(r,n??{});if(i.kind==="error")return P("Meta",`@meta(${r.join(", ")})`,i.message,g,i.code);if(i.kind==="empty")return"";if(n)n.__stx_runtime_head=Be(n.__stx_runtime_head??{},{meta:[i.tag]});return""},hasEndTag:!1},Jr={name:"structuredData",handler:(e,r,n,g)=>{if(e.trim()==="")return a("StructuredData","structuredData directive requires JSON-LD content",t.INVALID_DIRECTIVE_SYNTAX);try{let i=JSON.parse(e);if(!i["@context"])i["@context"]="https://schema.org";if(!i["@type"])return a("StructuredData","structuredData requires @type property",t.INVALID_DIRECTIVE_SYNTAX);return E(i)}catch(i){let s=i instanceof Error?i.message:String(i);return a("StructuredData",s,t.EVALUATION_ERROR)}},hasEndTag:!0};function kp(){return[Xr,Jr]}function _p(e,r){let{baseUrl:n,defaultChangefreq:g="weekly",defaultPriority:i=0.5,includeLastmod:s=!0}=r,c=n.replace(/\/$/,""),o=(m)=>m.startsWith("http")?m:`${c}${m.startsWith("/")?"":"/"}${m}`,u=e.map((m)=>{let d=o(m.loc),f=m.lastmod||(s?new Date().toISOString().split("T")[0]:void 0),D=m.changefreq||g,y=m.priority??i,h=` <url>
47
47
  <loc>${T(d)}</loc>`;for(let w of m.alternates??[])h+=`
48
48
  <xhtml:link rel="alternate" hreflang="${T(w.hreflang)}" href="${T(o(w.href))}"/>`;if(f)h+=`
49
49
  <lastmod>${f}</lastmod>`;return h+=`