@stacksjs/stx 0.2.504 → 0.2.506

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 (131) hide show
  1. package/dist/browser-core-imports.d.ts +1 -1
  2. package/dist/browser-core-imports.js +1 -2
  3. package/dist/builtins/attrs.d.ts +2 -0
  4. package/dist/builtins/attrs.js +102 -0
  5. package/dist/{chunk-ygetbydb.js → chunk-068ank60.js} +3 -3
  6. package/dist/{chunk-81byredt.js → chunk-06v0c3fz.js} +1 -1
  7. package/dist/{chunk-x96ardq0.js → chunk-0vnr7mz7.js} +8 -8
  8. package/dist/{chunk-czmw5xsd.js → chunk-1149d93e.js} +2 -2
  9. package/dist/chunk-1b7dd8rn.js +2 -0
  10. package/dist/{chunk-49p5j9ab.js → chunk-1verz406.js} +5 -5
  11. package/dist/{chunk-78yx6xxn.js → chunk-2wr0sk42.js} +1 -1
  12. package/dist/chunk-36rwfhnb.js +2 -0
  13. package/dist/{chunk-dn9fxpwt.js → chunk-38xtsdk9.js} +2 -2
  14. package/dist/chunk-3pczp9c0.js +2 -0
  15. package/dist/{chunk-fesb4h31.js → chunk-46wre9ep.js} +3 -3
  16. package/dist/chunk-4w358hpx.js +2 -0
  17. package/dist/{chunk-gxs2p0y7.js → chunk-5dh041x0.js} +1 -1
  18. package/dist/{chunk-133ggr0t.js → chunk-5tbqdz94.js} +2 -2
  19. package/dist/{chunk-zv0vgamy.js → chunk-5tkzfw4s.js} +3 -3
  20. package/dist/{chunk-38mtn4ce.js → chunk-5zm23zrb.js} +36 -10
  21. package/dist/{chunk-azza6dcr.js → chunk-68tzytfz.js} +1 -1
  22. package/dist/chunk-76g4jw9g.js +2 -0
  23. package/dist/{chunk-a771dfsg.js → chunk-7p6y0b47.js} +1 -1
  24. package/dist/{chunk-17fan751.js → chunk-7sjmpfwy.js} +3 -3
  25. package/dist/chunk-7z28hk7r.js +2 -0
  26. package/dist/{chunk-667d6fz8.js → chunk-8nx5asjr.js} +1 -1
  27. package/dist/{chunk-d5x1t498.js → chunk-8ptefdpy.js} +1 -1
  28. package/dist/chunk-8zj1ebs5.js +2 -0
  29. package/dist/{chunk-p4gbvge6.js → chunk-91y360rc.js} +1 -1
  30. package/dist/chunk-96kr2xrt.js +2828 -0
  31. package/dist/{chunk-5cyz97t4.js → chunk-9p3rtfbv.js} +4 -4
  32. package/dist/chunk-9xw416q3.js +2 -0
  33. package/dist/chunk-9z76qhdm.js +2 -0
  34. package/dist/{chunk-jt842kx3.js → chunk-9z8mxp15.js} +1 -1
  35. package/dist/{chunk-bcgfg3x0.js → chunk-ag1j84s6.js} +1 -1
  36. package/dist/{chunk-d4k4nyj0.js → chunk-ba88n1j7.js} +2 -2
  37. package/dist/chunk-c2vwq6gr.js +2 -0
  38. package/dist/{chunk-cpj9b887.js → chunk-cb1c9mvc.js} +1 -1
  39. package/dist/{chunk-cctb8fnj.js → chunk-ces3vdjp.js} +1 -1
  40. package/dist/{chunk-szkqmwjg.js → chunk-cprcfp0j.js} +1 -1
  41. package/dist/chunk-dn4tww9q.js +2 -0
  42. package/dist/chunk-dv94gdv4.js +2 -0
  43. package/dist/chunk-e4zks32s.js +2 -0
  44. package/dist/{chunk-amd52bnv.js → chunk-ea19gveh.js} +3 -3
  45. package/dist/chunk-fkv8jmse.js +2 -0
  46. package/dist/{chunk-mfcdbqvd.js → chunk-fwvqbx49.js} +5 -5
  47. package/dist/chunk-g1r4v0mc.js +3 -0
  48. package/dist/{chunk-798epzq5.js → chunk-g495xx4v.js} +5 -5
  49. package/dist/{chunk-9836wtag.js → chunk-gw9ax7xx.js} +1 -1
  50. package/dist/{chunk-0gp4sj0v.js → chunk-h37bbgg8.js} +1 -1
  51. package/dist/chunk-h3rrsq05.js +2 -0
  52. package/dist/{chunk-ywv2838m.js → chunk-h87zhtw8.js} +1 -1
  53. package/dist/chunk-h9reptxv.js +45 -0
  54. package/dist/{chunk-2abv46yw.js → chunk-hka18tmt.js} +1 -1
  55. package/dist/chunk-j08y5n2k.js +2 -0
  56. package/dist/chunk-j7nd8zfe.js +2 -0
  57. package/dist/{chunk-bt51kf9z.js → chunk-k2331dfx.js} +1 -1
  58. package/dist/{chunk-kr5ap3qn.js → chunk-k5syze27.js} +1 -1
  59. package/dist/{chunk-5q27xq7w.js → chunk-mq6expbd.js} +1 -1
  60. package/dist/{chunk-0kj3qs23.js → chunk-mvqhf6dn.js} +1 -1
  61. package/dist/chunk-mz7snf2b.js +2 -0
  62. package/dist/chunk-n1hd2fx6.js +2 -0
  63. package/dist/{chunk-37hm4er5.js → chunk-nnrtwpvy.js} +1 -1
  64. package/dist/chunk-pecwdp57.js +2 -0
  65. package/dist/{chunk-5kq996qy.js → chunk-ph1xz7k5.js} +2 -2
  66. package/dist/{chunk-qcj12mtw.js → chunk-pj562qnx.js} +1 -1
  67. package/dist/chunk-pzcw3trh.js +2 -0
  68. package/dist/{chunk-fd6abk20.js → chunk-qt31at4s.js} +3 -3
  69. package/dist/{chunk-88xqy2b9.js → chunk-r14mvycg.js} +4 -4
  70. package/dist/chunk-r5fzxtbc.js +2 -0
  71. package/dist/{chunk-3y8ykqpx.js → chunk-rvwtyrj4.js} +1 -1
  72. package/dist/{chunk-kbhm1wqt.js → chunk-s87qrma5.js} +2 -2
  73. package/dist/chunk-spg0fzyv.js +2 -0
  74. package/dist/{chunk-xevnx24r.js → chunk-tnxprz69.js} +2 -2
  75. package/dist/{chunk-a5c75hxe.js → chunk-v74acg2k.js} +1 -1
  76. package/dist/chunk-w925gtgg.js +2 -0
  77. package/dist/{chunk-rnnead1w.js → chunk-w9kj6t7s.js} +1 -1
  78. package/dist/{chunk-2242bx8y.js → chunk-w9mxt96c.js} +35 -35
  79. package/dist/{chunk-hmyyq2hh.js → chunk-z2775k8r.js} +1 -1
  80. package/dist/{chunk-6k4f583z.js → chunk-zz5b1g50.js} +2 -2
  81. package/dist/cli.js +9 -9
  82. package/dist/component-renderer.js +84 -36
  83. package/dist/composables/index.d.ts +4 -0
  84. package/dist/composables/index.js +5 -1
  85. package/dist/composables/use-timer.d.ts +8 -0
  86. package/dist/composables/use-timer.js +4 -0
  87. package/dist/config.js +24 -7
  88. package/dist/craft-entry.js +2 -2
  89. package/dist/craft.js +2 -2
  90. package/dist/native/compiler/html-to-ir.d.ts +3 -1
  91. package/dist/native/compiler/html-to-ir.js +13 -0
  92. package/dist/native/runtime/native-host.d.ts +1 -0
  93. package/dist/native/runtime/native-host.js +1 -0
  94. package/dist/pwa.js +1 -1
  95. package/dist/runtime-globals.js +4 -0
  96. package/dist/signals.js +34 -8
  97. package/dist/ssg.js +2 -2
  98. package/dist/stx-module.d.ts +4 -0
  99. package/dist/stx.d.ts +8 -0
  100. package/dist/utils.d.ts +3 -1
  101. package/dist/utils.js +12 -2
  102. package/package.json +6 -6
  103. package/stx-module.d.ts +4 -0
  104. package/stx.d.ts +8 -0
  105. package/dist/chunk-0np4t9ka.js +0 -2828
  106. package/dist/chunk-18pxh9sv.js +0 -2
  107. package/dist/chunk-2grygc4b.js +0 -2
  108. package/dist/chunk-3kxh9rsp.js +0 -2
  109. package/dist/chunk-5c1qesrs.js +0 -2
  110. package/dist/chunk-5yrn6whx.js +0 -2
  111. package/dist/chunk-7dmrxhq7.js +0 -2
  112. package/dist/chunk-9kt6g57t.js +0 -2
  113. package/dist/chunk-b3nz1qmj.js +0 -2
  114. package/dist/chunk-d161ndyz.js +0 -2
  115. package/dist/chunk-f6n6nrdq.js +0 -2
  116. package/dist/chunk-fgvdq014.js +0 -2
  117. package/dist/chunk-hzjk2027.js +0 -2
  118. package/dist/chunk-k0zadypg.js +0 -2
  119. package/dist/chunk-kxt6xb4j.js +0 -2
  120. package/dist/chunk-mba6khev.js +0 -2
  121. package/dist/chunk-pykeaf4h.js +0 -2
  122. package/dist/chunk-qky9zfvx.js +0 -2
  123. package/dist/chunk-rrvfgmqb.js +0 -2
  124. package/dist/chunk-s4c8vf27.js +0 -2
  125. package/dist/chunk-srhgfsz3.js +0 -2
  126. package/dist/chunk-t1x0x5sw.js +0 -2
  127. package/dist/chunk-txd6fq1x.js +0 -2
  128. package/dist/chunk-w78v0xek.js +0 -45
  129. package/dist/chunk-wrghqec5.js +0 -2
  130. package/dist/chunk-wy36z6qp.js +0 -2
  131. package/dist/chunk-xsc9zbaj.js +0 -3
@@ -1,9 +1,9 @@
1
1
  // @bun
2
- import{t,i,bn,Ns,Se,l}from"./chunk-798epzq5.js";function S(e,n,r,s=0){let a=0,o=s,c=null,u=0,p=!1;while(o<e.length){let d=e[o];if(c&&p){p=!1,o++;continue}if(c&&d==="\\"){p=!0,o++;continue}if(p=!1,(d==='"'||d==="'"||d==="`")&&!c){c=d,o++;continue}if(d===c&&c!=="`"){c=null,o++;continue}if(c==="`"&&d==="$"&&e[o+1]==="{"){u++,o+=2;continue}if(u>0&&d==="}"){u--,o++;continue}if(d==="`"&&c==="`"&&u===0){c=null,o++;continue}if(c){o++;continue}if(d===n)a++;else if(d===r){if(a--,a===0)return o}o++}return-1}import U from"path";function As(e,n){let r=[];n.lastIndex=0;let s;while((s=n.exec(e))!==null){let a=s.index,o=a+s[0].length-1,c=S(e,"(",")",o);if(c===-1){r.push({start:a,end:-1,args:"",call:e.slice(a,Math.min(e.length,a+80))}),n.lastIndex=o+1;continue}r.push({start:a,end:c+1,args:e.slice(o+1,c),call:e.slice(a,c+1)}),n.lastIndex=c+1}return r}function Ge(e,n,r,s){let a="",o=0;for(let c of As(e,n)){if(a+=e.slice(o,c.start),c.end===-1){a+=s(c.call),o=c.start;continue}a+=r(c.args,c.call),o=c.end}return a+e.slice(o)}function Je(e){let n=[],r=0,s=null,a="";for(let o=0;o<e.length;o++){let c=e[o];if(s){if(a+=c,c==="\\"&&o+1<e.length){a+=e[++o];continue}if(c===s)s=null;continue}if(c==="'"||c==='"'||c==="`")s=c;else if(c==="("||c==="["||c==="{")r++;else if(c===")"||c==="]"||c==="}")r--;else if(c===","&&r===0){n.push(a.trim()),a="";continue}a+=c}if(a.trim())n.push(a.trim());return n}function O(e){let n=e.trim(),r=n[0];if(r!=="'"&&r!=='"'&&r!=="`"||n.length<2||n.at(-1)!==r)return null;let s="";for(let a=1;a<n.length-1;a++){let o=n[a];if(o==="\\"&&a+1<n.length-1){let c=n[++a];s+=c==="n"?`
2
+ import{t,i,bn,Ns,Se,l}from"./chunk-g495xx4v.js";function S(e,n,r,s=0){let a=0,o=s,c=null,u=0,p=!1;while(o<e.length){let d=e[o];if(c&&p){p=!1,o++;continue}if(c&&d==="\\"){p=!0,o++;continue}if(p=!1,(d==='"'||d==="'"||d==="`")&&!c){c=d,o++;continue}if(d===c&&c!=="`"){c=null,o++;continue}if(c==="`"&&d==="$"&&e[o+1]==="{"){u++,o+=2;continue}if(u>0&&d==="}"){u--,o++;continue}if(d==="`"&&c==="`"&&u===0){c=null,o++;continue}if(c){o++;continue}if(d===n)a++;else if(d===r){if(a--,a===0)return o}o++}return-1}import U from"path";function As(e,n){let r=[];n.lastIndex=0;let s;while((s=n.exec(e))!==null){let a=s.index,o=a+s[0].length-1,c=S(e,"(",")",o);if(c===-1){r.push({start:a,end:-1,args:"",call:e.slice(a,Math.min(e.length,a+80))}),n.lastIndex=o+1;continue}r.push({start:a,end:c+1,args:e.slice(o+1,c),call:e.slice(a,c+1)}),n.lastIndex=c+1}return r}function Ge(e,n,r,s){let a="",o=0;for(let c of As(e,n)){if(a+=e.slice(o,c.start),c.end===-1){a+=s(c.call),o=c.start;continue}a+=r(c.args,c.call),o=c.end}return a+e.slice(o)}function Je(e){let n=[],r=0,s=null,a="";for(let o=0;o<e.length;o++){let c=e[o];if(s){if(a+=c,c==="\\"&&o+1<e.length){a+=e[++o];continue}if(c===s)s=null;continue}if(c==="'"||c==='"'||c==="`")s=c;else if(c==="("||c==="["||c==="{")r++;else if(c===")"||c==="]"||c==="}")r--;else if(c===","&&r===0){n.push(a.trim()),a="";continue}a+=c}if(a.trim())n.push(a.trim());return n}function O(e){let n=e.trim(),r=n[0];if(r!=="'"&&r!=='"'&&r!=="`"||n.length<2||n.at(-1)!==r)return null;let s="";for(let a=1;a<n.length-1;a++){let o=n[a];if(o==="\\"&&a+1<n.length-1){let c=n[++a];s+=c==="n"?`
3
3
  `:c==="t"?"\t":c;continue}if(o===r)return null;if(r==="`"&&o==="$"&&n[a+1]==="{")return null;s+=o}return s}var de=new Set(["true","false","null","undefined","typeof","void","new","in","of","instanceof","this","delete","await","async","function","return","NaN","Infinity"]);function Ye(e,n){let r=e.trim();if(!r)return{ok:!1,message:"the argument is empty",code:t.INVALID_DIRECTIVE_SYNTAX};let s=bn(r);if(s)return{ok:!1,message:`the expression is not allowed (${s})`,code:t.UNSAFE_EXPRESSION};let a=Ns(n),o;try{o=l(r,Object.keys(a))(...Object.values(a))}catch(u){return{ok:!1,message:`the expression could not be evaluated: ${u instanceof Error?u.message:String(u)}`,code:t.EVALUATION_ERROR}}if(o!==void 0&&o!==null)return{ok:!0,value:o};let c=[...new Set(Se(r))].filter((u)=>!de.has(u)&&!(u in a)&&!(u in globalThis));if(c.length>0)return{ok:!1,message:`${c.map((p)=>`"${p}"`).join(", ")} ${c.length===1?"is":"are"} not defined here. Values a directive reads must come from <script server> or the render context; a plain <script> runs in the browser. To pass literal text, quote it.`,code:t.UNDEFINED_VARIABLE};if(o===void 0&&(r.startsWith("{")||r.startsWith("[")))return{ok:!1,message:"the expression threw while it was evaluated",code:t.EVALUATION_ERROR};return{ok:!0,value:o}}function ue(e){if(e===null)return"null";if(Array.isArray(e))return"an array";if(typeof e==="object")return"an object";if(typeof e==="string")return`a string ("${e.length>40?`${e.slice(0,40)}...`:e}")`;return`${/^[aeiou]/.test(typeof e)?"an":"a"} ${typeof e}`}function we(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)}function V(e){if(!e)return"";return U.isAbsolute(e)?U.relative(process.cwd(),e)||e:e}function M(e){let n=e.replace(/\s+/g," ").trim();return n.length>80?`${n.slice(0,77)}...`:n}function E(e,n,r,s,a=t.EVALUATION_ERROR){let o=s?` in ${V(s)}`:"";return console.warn(`[stx] ${M(n)}${o}: ${r}`),i(e,`${M(n)}: ${r}`,a)}function rr(e,n,r){let s=r?` in ${V(r)}`:"";console.warn(`[stx] ${M(e)}${s}: ${n}`)}function Ps(){return{afterOpen:[],beforeClose:[]}}function ge(e){return e.afterOpen.length>0||e.beforeClose.length>0}function Ei(e,n){if(!ge(n))return e;let r=n.afterOpen.join(""),s=n.beforeClose.join(""),a=e.lastIndexOf("</head>"),o=r?un(e):null,c=s&&a!==-1?a:null;if(o===null&&c===null)return e;if(o!==null&&c!==null)return`${e.slice(0,o)}${r}${e.slice(o,c)}${s}${e.slice(c)}`;if(o!==null)return`${e.slice(0,o)}${r}${e.slice(o)}`;return`${e.slice(0,c)}${s}${e.slice(c)}`}var K=/\s*<meta\b[^>]*\bcharset\b[^>]*>/iy;function un(e){let n=/<head\b[^>]*>/i.exec(e);if(!n)return null;let r=n.index+n[0].length;K.lastIndex=r;let s=K.exec(e);return s?r+s[0].length:r}var L="data-stx-color-mode-boot",F="__STX_COLOR_MODE__",he=new Set(["light","dark","auto","system"]),me=new Set(["auto","system"]),ye=/^[a-z][\w:-]*$/i,be=/^[\w-]+$/;function ke(e){let n=e.storageKey??"stx-color-mode",r=e.initialMode??"auto",s=e.darkClass===void 0?"dark":e.darkClass,a=e.attribute??null,o=e.autoValue??null,c=e.respectExisting===!0;if(typeof n!=="string"||n.length===0)throw Error("colorMode.storageKey must be a non-empty string");if(!he.has(r))throw Error(`colorMode.initialMode must be one of light, dark, auto, system \u2014 got ${JSON.stringify(r)}`);if(s!==null&&(typeof s!=="string"||!be.test(s)))throw Error(`colorMode.darkClass must be a single CSS class name, or null to opt out \u2014 got ${JSON.stringify(s)}`);if(a!==null&&(typeof a!=="string"||!ye.test(a)))throw Error(`colorMode.attribute must be a valid HTML attribute name \u2014 got ${JSON.stringify(a)}`);if(o!==null&&!me.has(o))throw Error(`colorMode.autoValue must be 'auto' or 'system' \u2014 got ${JSON.stringify(o)}`);if(s===null&&a===null)throw Error("colorMode needs at least one of darkClass or attribute \u2014 with both null nothing would mark the mode on <html>");if(c&&a===null)throw Error("colorMode.respectExisting needs an attribute to read \u2014 the dark class alone cannot say whether a mode was chosen");return{storageKey:n,initialMode:r==="system"?"auto":r,darkClass:s,attribute:a,autoValue:o,respectExisting:c}}function Te(e){return JSON.stringify(e).replace(/</g,"\\u003c").replace(/>/g,"\\u003e").replace(/&/g,"\\u0026").replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}function D(e={}){let n=ke(e),r=Te(n),s=`(function(){"use strict";var o=window.${F};if(o&&typeof o.sync==="function"){o.sync();return}var c=${r};var r=document.documentElement;function read(){var p=c.initialMode,a=c.autoValue;try{var v=localStorage.getItem(c.storageKey);if(v==="light"||v==="dark"){p=v}else if(v==="auto"||v==="system"){p="auto";if(!a)a=v}}catch(e){}return{p:p,a:a}}function sys(){try{return matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}catch(e){return"light"}}function stamp(m){if(c.attribute)r.setAttribute(c.attribute,m);if(c.darkClass){if(m==="dark")r.classList.add(c.darkClass);else r.classList.remove(c.darkClass)}}var s=read();var f=null;if(c.respectExisting&&c.attribute){var x=r.getAttribute(c.attribute);if(x==="light"||x==="dark")f=x}var m=f||(s.p==="auto"?sys():s.p);var p=s.p;stamp(m);var g=null;function sync(){var t=read(),n=f||(t.p==="auto"?sys():t.p);var moved=n!==m,chose=t.p!==p;if(moved){r.style.setProperty("transition","none","important");stamp(n);void r.offsetHeight;r.style.removeProperty("transition")}else stamp(n);m=n;p=t.p;if(g){g.mode=n;g.preference=t.p;if(t.a)g.autoValue=t.a}if(moved||chose){try{window.dispatchEvent(new CustomEvent("stx:color-mode",{detail:{mode:n,preference:t.p}}))}catch(e){}}}try{g=window.${F}={storageKey:c.storageKey,initialMode:c.initialMode,darkClass:c.darkClass,attribute:c.attribute,autoValue:s.a||"auto",respectExisting:c.respectExisting,forced:f,preference:p,mode:m,watching:true,sync:sync}}catch(e){}try{var q=matchMedia("(prefers-color-scheme: dark)");if(q.addEventListener)q.addEventListener("change",sync);else if(q.addListener)q.addListener(sync)}catch(e){}try{addEventListener("pageshow",sync);addEventListener("storage",function(e){if(e.key===null||e.key===c.storageKey)sync()});document.addEventListener("visibilitychange",function(){if(document.visibilityState==="visible")sync()})}catch(e){}}());`;return`<script ${L}>${s}</script>`}function pn(e,n={}){if(e.includes(L))return e;let r=N(e);if(r===null)return e;let s=D(n);return`${e.slice(0,r)}
4
4
  ${s}${e.slice(r)}`}var N=un,ve=new RegExp(`<script\\b[^>]*\\b${L}\\b[^>]*>[\\s\\S]*?<\\/script>`,"i"),W=/<meta\b[^>]*\bcharset\b[^>]*>/gi,q=/<\/head>/gi;function Ee(e){let n=/<head\b[^>]*>/i.exec(e);if(!n)return e;let r=n.index+n[0].length;q.lastIndex=r;let s=q.exec(e),a=s?s.index:e.length;W.lastIndex=r;let o=W.exec(e);if(!o||o.index>=a)return e;if(e.slice(r,o.index).trim()==="")return e;let c=o.index+o[0].length;return`${e.slice(0,r)}
5
5
  ${o[0]}${e.slice(r,o.index)}${e.slice(c,a)}${e.slice(a)}`}function $i(e){return Ae(Ee(e))}function Ae(e){let n=ve.exec(e);if(!n)return e;let r=N(e);if(r===null)return e;if(n.index<=r||e.slice(r,n.index).trim()==="")return e;let s=e.slice(0,n.index)+e.slice(n.index+n[0].length),a=N(s);if(a===null)return e;return`${s.slice(0,a)}
6
- ${n[0]}${s.slice(a)}`}var Y="<style data-stx-cloak>[x-cloak]{display:none !important}</style>",C="data-stx-html-attrs",R="data-stx-html-class",G=/^[A-Za-z_:][\w:.-]*$/;function y(e){return String(e).replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function Ce(e){return String(e).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function xe(e){if(e.name)return`name="${e.name}"`;if(e.property)return`property="${e.property}"`;if(e.charset!=null)return"charset=";if(e["http-equiv"])return`http-equiv="${e["http-equiv"]}"`;return""}function $e(e){let n=/^\s*<meta\b([^>]*)>/i.exec(e);if(!n)return null;let r={};for(let s of n[1].matchAll(/([\w:-]+)(?:\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s"'>]+)))?/g))r[s[1].toLowerCase()]=s[2]??s[3]??s[4]??"";return r}function k(e,n){return Object.entries(e).filter(([r])=>!n?.(r)).map(([r,s])=>`${r}="${y(String(s))}"`).join(" ")}function I(e){let n=String(e.content),r=typeof e.type==="string"?e.type.trim().toLowerCase():"";return/json$|^importmap$/.test(r)?n.replace(/<\//g,"<\\/"):n}function J(e){let n=k(e,(r)=>r==="content");return`<script${n?` ${n}`:""}>${I(e)}</script>`}function Re(e={},n="en"){let r=[],s=[],a="",o=n;for(let[u,p]of Object.entries(e||{})){if(p==null)continue;let d=u.trim();if(!G.test(d))continue;let f=d.toLowerCase();if(f==="lang"){o=String(p);continue}if(f==="class"){a=String(p).trim();continue}r.push(` ${d}="${y(String(p))}"`),s.push(d)}let c=` lang="${y(o)}"`;if(a)c+=` class="${y(a)}"`;if(c+=r.join(""),a)c+=` ${R}="${y(a)}"`;if(s.length)c+=` ${C}="${y(s.join(" "))}"`;return c}function _i(e={},n={}){let r={...e,...n};if(e.class&&n.class){let s=e.class.split(/\s+/).filter(Boolean);for(let a of n.class.split(/\s+/).filter(Boolean))if(!s.includes(a))s.push(a);r.class=s.join(" ")}return r}function fn(e,n={}){if(!n||Object.keys(n).length===0)return e;let r=e.match(/<html\b([^>]*)>/i);if(!r)return e;let s={},a=[],o=/([A-Za-z_:][\w:.-]*)(?:\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s"'>]+)))?/g,c;while((c=o.exec(r[1]))!==null){let f=c[1];if(!(f in s))a.push(f);s[f]=c[2]??c[3]??c[4]??""}let u=[],p=[];for(let[f,h]of Object.entries(n)){if(h==null)continue;let m=f.trim();if(!G.test(m))continue;let w=m.toLowerCase();if(w==="class"){let x=(s.class||"").split(/\s+/).filter(Boolean);for(let A of String(h).split(/\s+/).filter(Boolean))if(!x.includes(A))x.push(A),u.push(A);if(!("class"in s))a.push("class");s.class=x.join(" ");continue}if(!(m in s))a.push(m);if(s[m]=String(h),w!=="lang")p.push(m)}if(u.length){if(!(R in s))a.push(R);s[R]=u.join(" ")}if(p.length){if(!(C in s))a.push(C);s[C]=p.join(" ")}let d=a.map((f)=>` ${f}="${y(s[f])}"`).join("");return e.replace(r[0],()=>`<html${d}>`)}function Ti(e){if(e.includes("data-stx-cloak"))return null;if(e.lastIndexOf("</head>")===-1)return null;return`${Y}
6
+ ${n[0]}${s.slice(a)}`}var Y="<style data-stx-cloak>[x-cloak]{display:none !important}</style>",C="data-stx-html-attrs",R="data-stx-html-class",G=/^[A-Za-z_:][\w:.-]*$/;function y(e){return String(e).replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function Ce(e){return String(e).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function xe(e){if(e.name)return`name="${e.name}"`;if(e.property)return`property="${e.property}"`;if(e.charset!=null)return"charset=";if(e["http-equiv"])return`http-equiv="${e["http-equiv"]}"`;return""}function $e(e){let n=/^\s*<meta\b([^>]*)>/i.exec(e);if(!n)return null;let r={};for(let s of n[1].matchAll(/([\w:-]+)(?:\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s"'>]+)))?/g))r[s[1].toLowerCase()]=s[2]??s[3]??s[4]??"";return r}function k(e,n){return Object.entries(e).filter(([r])=>!n?.(r)).map(([r,s])=>`${r}="${y(String(s))}"`).join(" ")}function I(e){let n=String(e.content),r=typeof e.type==="string"?e.type.trim().toLowerCase():"";return/json$|^importmap$/.test(r)?n.replace(/<\//g,"<\\/"):n}function J(e){let n=k(e,(r)=>r==="content");return`<script${n?` ${n}`:""}>${I(e)}</script>`}function Re(e={},n="en"){let r=[],s=[],a="",o=n;for(let[u,p]of Object.entries(e||{})){if(p==null)continue;let d=u.trim();if(!G.test(d))continue;let f=d.toLowerCase();if(f==="lang"){o=String(p);continue}if(f==="class"){a=String(p).trim();continue}r.push(` ${d}="${y(String(p))}"`),s.push(d)}let c=` lang="${y(o)}"`;if(a)c+=` class="${y(a)}"`;if(c+=r.join(""),a)c+=` ${R}="${y(a)}"`;if(s.length)c+=` ${C}="${y(s.join(" "))}"`;return c}function Ti(e={},n={}){let r={...e,...n};if(e.class&&n.class){let s=e.class.split(/\s+/).filter(Boolean);for(let a of n.class.split(/\s+/).filter(Boolean))if(!s.includes(a))s.push(a);r.class=s.join(" ")}return r}function fn(e,n={}){if(!n||Object.keys(n).length===0)return e;let r=e.match(/<html\b([^>]*)>/i);if(!r)return e;let s={},a=[],o=/([A-Za-z_:][\w:.-]*)(?:\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s"'>]+)))?/g,c;while((c=o.exec(r[1]))!==null){let f=c[1];if(!(f in s))a.push(f);s[f]=c[2]??c[3]??c[4]??""}let u=[],p=[];for(let[f,h]of Object.entries(n)){if(h==null)continue;let m=f.trim();if(!G.test(m))continue;let w=m.toLowerCase();if(w==="class"){let x=(s.class||"").split(/\s+/).filter(Boolean);for(let A of String(h).split(/\s+/).filter(Boolean))if(!x.includes(A))x.push(A),u.push(A);if(!("class"in s))a.push("class");s.class=x.join(" ");continue}if(!(m in s))a.push(m);if(s[m]=String(h),w!=="lang")p.push(m)}if(u.length){if(!(R in s))a.push(R);s[R]=u.join(" ")}if(p.length){if(!(C in s))a.push(C);s[C]=p.join(" ")}let d=a.map((f)=>` ${f}="${y(s[f])}"`).join("");return e.replace(r[0],()=>`<html${d}>`)}function _i(e){if(e.includes("data-stx-cloak"))return null;if(e.lastIndexOf("</head>")===-1)return null;return`${Y}
7
7
  `}function Ie(e){let n=[],r=0;while(r<e.length){let o=e.slice(r),c=o.match(/^\s+/);if(c){r+=c[0].length;continue}if(o.startsWith("<!--")){let h=e.indexOf("-->",r);if(h===-1)break;r=h+3;continue}let u=o.match(/^<script\b[^>]*>/i);if(u){let h=e.toLowerCase().indexOf("</script>",r+u[0].length);if(h===-1)break;r=h+9;continue}let p=o.match(/^<link\b[^>]*>/i);if(p){n.push(p[0]),r+=p[0].length;continue}let d=o.match(/^<meta\b[^>]*>/i);if(d){n.push(d[0]),r+=d[0].length;continue}let f=o.match(/^<style\b[^>]*>[\s\S]*?<\/style>/i);if(f){n.push(f[0]),r+=f[0].length;continue}break}if(n.length===0)return{body:e,hoisted:n};let s="",a=0;while(a<e.length&&a<r){let o=e.slice(a),c=o.match(/^<link\b[^>]*>/i);if(c&&n.includes(c[0])){a+=c[0].length;continue}let u=o.match(/^<meta\b[^>]*>/i);if(u&&n.includes(u[0])){a+=u[0].length;continue}let p=o.match(/^<style\b[^>]*>[\s\S]*?<\/style>/i);if(p&&n.includes(p[0])){a+=p[0].length;continue}s+=e[a],a++}return s+=e.slice(r),{body:s,hoisted:n}}function _e(e,n={},r={}){let{title:s="stx App",lang:a="en",meta:o=[],link:c=[],script:u=[],headRaw:p="",htmlAttrs:d={},bodyClass:f="",bodyAttrs:h={}}=n,m=r.title||s,w=[{charset:"UTF-8"},{name:"viewport",content:"width=device-width, initial-scale=1.0"}],x=new Set(o.map(xe).filter(Boolean)),{body:A,hoisted:B}=Ie(e),te=new Set(B.flatMap((g)=>{let v=$e(g);return v?[xe(v)].filter(Boolean):[]})),ne=[...w.filter((g)=>!x.has(xe(g))),...o].filter((g)=>!te.has(xe(g))).map((g)=>` <meta ${k(g)}>`).join(`
8
8
  `),re=c.map((g)=>` <link ${k(g)}>`).join(`
9
9
  `),ie=u.map((g)=>{if(g.src)return` <script ${k(g,(v)=>v==="content")}></script>`;if(g.content)return` ${J(g)}`;return""}).filter(Boolean).join(`
@@ -17,8 +17,8 @@ ${le.join(`
17
17
  ${ce.join(`
18
18
  `)}
19
19
  </body>
20
- </html>`}var H=/\s+/y,j=/<(script|style)\b[^>]*>/iy,Me=/<\/script>/gi,Oe=/<\/style>/gi,z=/<!DOCTYPE\b/iy,X=/<html[\s>]/iy;function Tt(e){let n=0;while(n<e.length){if(H.lastIndex=n,H.exec(e)){n=H.lastIndex;continue}if(e.startsWith("<!--",n)){let a=e.indexOf("-->",n);if(a===-1)return!1;n=a+3;continue}j.lastIndex=n;let s=j.exec(e);if(s){let a=s[1].toLowerCase()==="script"?Me:Oe;a.lastIndex=j.lastIndex;let o=a.exec(e);if(o===null)return!1;n=o.index+o[0].length;continue}if(z.lastIndex=n,z.test(e))return!0;return X.lastIndex=n,X.test(e)}return!1}function Is(e){return Tt(e)}function Ri(e,n={}){let r=e.lastIndexOf("</head>");if(r===-1)return e;let{meta:s=[],link:a=[],script:o=[],headRaw:c=""}=n,u=e.slice(0,r),p=[];for(let d of s){let f=xe(d);if(f&&u.includes(f))continue;p.push(` <meta ${k(d)}>`)}for(let d of a){if(d.href&&u.includes(`href="${d.href}"`))continue;p.push(` <link ${k(d)}>`)}for(let d of o)if(d.src){if(u.includes(`src="${d.src}"`))continue;p.push(` <script ${k(d,(f)=>f==="content")}></script>`)}else if(d.content){if(u.includes(I(d)))continue;p.push(` ${J(d)}`)}if(c&&!u.includes(c))p.push(` ${c}`);if(p.length===0)return e;return`${e.slice(0,r)}${p.join(`
20
+ </html>`}var H=/\s+/y,j=/<(script|style)\b[^>]*>/iy,Me=/<\/script>/gi,Oe=/<\/style>/gi,z=/<!DOCTYPE\b/iy,X=/<html[\s>]/iy;function _t(e){let n=0;while(n<e.length){if(H.lastIndex=n,H.exec(e)){n=H.lastIndex;continue}if(e.startsWith("<!--",n)){let a=e.indexOf("-->",n);if(a===-1)return!1;n=a+3;continue}j.lastIndex=n;let s=j.exec(e);if(s){let a=s[1].toLowerCase()==="script"?Me:Oe;a.lastIndex=j.lastIndex;let o=a.exec(e);if(o===null)return!1;n=o.index+o[0].length;continue}if(z.lastIndex=n,z.test(e))return!0;return X.lastIndex=n,X.test(e)}return!1}function Is(e){return _t(e)}function Ri(e,n={}){let r=e.lastIndexOf("</head>");if(r===-1)return e;let{meta:s=[],link:a=[],script:o=[],headRaw:c=""}=n,u=e.slice(0,r),p=[];for(let d of s){let f=xe(d);if(f&&u.includes(f))continue;p.push(` <meta ${k(d)}>`)}for(let d of a){if(d.href&&u.includes(`href="${d.href}"`))continue;p.push(` <link ${k(d)}>`)}for(let d of o)if(d.src){if(u.includes(`src="${d.src}"`))continue;p.push(` <script ${k(d,(f)=>f==="content")}></script>`)}else if(d.content){if(u.includes(I(d)))continue;p.push(` ${J(d)}`)}if(c&&!u.includes(c))p.push(` ${c}`);if(p.length===0)return e;return`${e.slice(0,r)}${p.join(`
21
21
  `)}
22
22
  ${e.slice(r)}`}function gn(e,n={},r={},s){if(s??Is(e))return e;return _e(e,n,r)}var Ne=["og:","article:","book:","profile:","fb:","music:","video:"],Le=/^[a-z][\w-]*(?::[\w:-]+)?$/i;function mn(e,n){if(e.length<1)return{kind:"error",message:"meta directive requires at least the meta name",code:t.INVALID_DIRECTIVE_SYNTAX};if(e.length>2)return{kind:"error",message:`@meta takes a name and a value, got ${e.length} arguments`,code:t.INVALID_DIRECTIVE_SYNTAX};let r=De(e[0],n);if(typeof r!=="string")return r;let s;if(e.length===2){let o=He(e[1],n);if(typeof o!=="string")return o;s=o}else{let o=r.includes(":")?r.slice(r.indexOf(":")+1):r,c=n.openGraph,u=n[o]??(we(c)?c[o]:void 0);s=u===void 0||u===null||typeof u==="object"?"":String(u)}if(!s)return{kind:"empty"};return{kind:"tag",tag:Ne.some((o)=>r.startsWith(o))?{property:r,content:s}:{name:r,content:s}}}function De(e,n){let r=O(e);if(r!==null)return r.trim()?r:{kind:"error",message:"the meta name is empty",code:t.INVALID_DIRECTIVE_SYNTAX};if(Le.test(e.trim()))return e.trim();let s=Ye(e,n);if(!s.ok)return{kind:"error",message:`meta name: ${s.message}`,code:s.code};if(typeof s.value!=="string"||!s.value.trim())return{kind:"error",message:`the meta name must be a non-empty string, got ${ue(s.value)}`,code:t.TYPE_ERROR};return s.value}function He(e,n){let r=O(e);if(r!==null)return r;let s=Ye(e,n);if(!s.ok)return{kind:"error",message:s.message,code:s.code};let a=s.value;if(a===void 0||a===null||a===!1)return"";if(Array.isArray(a))return a.filter((o)=>o!==void 0&&o!==null&&o!=="").map(String).join(", ");if(typeof a==="object"&&!(a instanceof Date))return{kind:"error",message:`the content must be text, got ${ue(a)}`,code:t.TYPE_ERROR};return String(a)}var hn=["title","lang","meta","link","script","headRaw","htmlAttrs","bodyClass","bodyAttrs"],sr=["title","titleTemplate","base","meta","link","script","style","htmlAttrs","bodyAttrs"],ee={links:"link",metas:"meta",scripts:"script",styles:"style"},Z=new Set,Q=new WeakMap;function P(e){if(Z.has(e))return;Z.add(e),console.warn(e)}function je(e,n){let r=Array.from({length:n.length+1},(s,a)=>a);for(let s=1;s<=e.length;s++){let a=r[0];r[0]=s;for(let o=1;o<=n.length;o++){let c=r[o];r[o]=Math.min(r[o]+1,r[o-1]+1,a+(e[s-1]===n[o-1]?0:1)),a=c}}return r[n.length]}function Pe(e,n){let r=e.toLowerCase(),s=n.find((p)=>p.toLowerCase()===r);if(s)return s;let a=ee[r];if(a&&n.includes(a))return a;let o,c=1/0;for(let p of n){let d=je(r,p.toLowerCase());if(d<c)o=p,c=d}let u=Math.min(e.length,o?.length??0)<=4?1:2;return c<=u?o:void 0}function pe(e,n){if(!e||typeof e!=="object"||Array.isArray(e))return e||{};let r=Q.get(e);if(r)return r;let{known:s,source:a}=n,o=e;for(let c of Object.keys(e)){if(s.includes(c))continue;let u=ee[c];if(u&&s.includes(u)&&Array.isArray(e[c])){if(o===e)o={...e};let d=Array.isArray(o[u])?o[u]:[];o[u]=[...d,...e[c]],delete o[c],P(`[stx] ${a}.${c} is not a head key; reading it as ${a}.${u}. Rename it to \`${u}\`.`);continue}if(/^styles?$/.test(c)&&!s.includes("style")){P(`[stx] ${a}.${c} is not a head key and is ignored. Use \`link\` with rel: 'stylesheet', or \`headRaw\` for an inline <style>.`);continue}let p=Pe(c,s);P(p?`[stx] ${a}.${c} is not a head key and is ignored. Did you mean \`${p}\`?`:`[stx] ${a}.${c} is not a head key and is ignored. Known keys: ${s.join(", ")}.`)}return Q.set(e,o),o}var b={},Be=[],_={};function Ds(){return b}function su(){return _}function ou(){b={},Be.length=0,_={}}function Ai(e){b=fe(b,pe(e,{known:sr,source:"useHead()"}))}function fe(e,n){return{title:n.title??e.title,titleTemplate:n.titleTemplate??e.titleTemplate,base:n.base??e.base,meta:[...e.meta||[],...n.meta||[]],link:[...e.link||[],...n.link||[]],script:[...e.script||[],...n.script||[]],style:[...e.style||[],...n.style||[]],htmlAttrs:{...e.htmlAttrs,...n.htmlAttrs},bodyAttrs:{...e.bodyAttrs,...n.bodyAttrs}}}function jc(e){Ai(or(e))}function or(e){let n=[];if(e.description)n.push({name:"description",content:e.description});if(e.keywords){let p=Array.isArray(e.keywords)?e.keywords.join(", "):e.keywords;n.push({name:"keywords",content:p})}if(e.author)n.push({name:"author",content:e.author});if(e.robots)n.push({name:"robots",content:e.robots});let r=e.ogTitle??e.title,s=e.ogDescription??e.description;if(r)n.push({property:"og:title",content:r});if(s)n.push({property:"og:description",content:s});if(e.ogImage){if(n.push({property:"og:image",content:e.ogImage}),e.ogImageType)n.push({property:"og:image:type",content:e.ogImageType});if(e.ogImageWidth)n.push({property:"og:image:width",content:String(e.ogImageWidth)});if(e.ogImageHeight)n.push({property:"og:image:height",content:String(e.ogImageHeight)});if(e.ogImageAlt)n.push({property:"og:image:alt",content:e.ogImageAlt})}if(e.ogUrl)n.push({property:"og:url",content:e.ogUrl});if(e.ogType)n.push({property:"og:type",content:e.ogType});if(e.ogSiteName)n.push({property:"og:site_name",content:e.ogSiteName});if(e.ogLocale)n.push({property:"og:locale",content:e.ogLocale});if(e.profileFirstName)n.push({property:"profile:first_name",content:e.profileFirstName});if(e.profileLastName)n.push({property:"profile:last_name",content:e.profileLastName});if(e.profileUsername)n.push({property:"profile:username",content:e.profileUsername});let a=e.twitterTitle??e.title,o=e.twitterDescription??e.description,c=e.twitterImage??e.ogImage;if(e.twitterCard)n.push({name:"twitter:card",content:e.twitterCard});if(a)n.push({name:"twitter:title",content:a});if(o)n.push({name:"twitter:description",content:o});if(c){n.push({name:"twitter:image",content:c});let p=e.twitterImageAlt??(e.twitterImage?void 0:e.ogImageAlt);if(p)n.push({name:"twitter:image:alt",content:p})}if(e.twitterSite)n.push({name:"twitter:site",content:e.twitterSite});if(e.twitterCreator)n.push({name:"twitter:creator",content:e.twitterCreator});if(e.articleAuthor)n.push({property:"article:author",content:e.articleAuthor});if(e.articlePublishedTime)n.push({property:"article:published_time",content:e.articlePublishedTime});if(e.articleModifiedTime)n.push({property:"article:modified_time",content:e.articleModifiedTime});if(e.articleSection)n.push({property:"article:section",content:e.articleSection});if(e.articleTags)for(let p of e.articleTags)n.push({property:"article:tag",content:p});let u=[];if(e.canonical)u.push({rel:"canonical",href:e.canonical});return{title:e.title,titleTemplate:e.titleTemplate,meta:n,link:u}}function iu(e){if(_={..._,...e},e.title||e.description)jc({title:e.title,description:e.description})}function au(e){let n=typeof e==="function"?e():e;Ai({title:n})}function cu(e=b){let n=[];if(e.title){let r=e.title;if(e.titleTemplate)r=typeof e.titleTemplate==="function"?e.titleTemplate(r):e.titleTemplate.replace("%s",r);n.push(`<title>${T(r)}</title>`)}if(e.base){let r=Object.entries(e.base).map(([s,a])=>`${s}="${T(a)}"`).join(" ");n.push(`<base ${r}>`)}for(let r of e.meta||[]){let s=Object.entries(r).filter(([a,o])=>o!==void 0).map(([a,o])=>`${a==="httpEquiv"?"http-equiv":a}="${T(String(o))}"`).join(" ");n.push(`<meta ${s}>`)}for(let r of e.link||[]){let s=Object.entries(r).filter(([a,o])=>o!==void 0).map(([a,o])=>`${a}="${T(String(o))}"`).join(" ");n.push(`<link ${s}>`)}for(let r of e.script||[]){let{content:s,...a}=r,o=Object.entries(a).filter(([c,u])=>u!==void 0).map(([c,u])=>{if(typeof u==="boolean")return u?c:"";return`${c}="${T(String(u))}"`}).filter(Boolean).join(" ");if(s)n.push(`<script ${o}>${I(r)}</script>`);else n.push(`<script ${o}></script>`)}for(let r of e.style||[]){let s=r.type?` type="${r.type}"`:"";n.push(`<style${s}>${r.content}</style>`)}return n.join(`
23
23
  `)}function lu(e=b){if(!e.htmlAttrs)return"";return Object.entries(e.htmlAttrs).map(([n,r])=>`${n}="${T(r)}"`).join(" ")}function du(e=b){if(!e.bodyAttrs)return"";return Object.entries(e.bodyAttrs).map(([n,r])=>`${n}="${T(r)}"`).join(" ")}function T(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")}function uu(e=b){if(typeof document>"u")return;if(e.title){let n=e.title;if(e.titleTemplate)n=typeof e.titleTemplate==="function"?e.titleTemplate(n):e.titleTemplate.replace("%s",n);document.title=n}for(let n of e.meta||[]){let r=n.name?`meta[name="${n.name}"]`:n.property?`meta[property="${n.property}"]`:null;if(r){let s=document.querySelector(r);if(!s){if(s=document.createElement("meta"),n.name)s.setAttribute("name",n.name);if(n.property)s.setAttribute("property",n.property);document.head.appendChild(s)}s.setAttribute("content",n.content)}}for(let n of e.link||[]){let r=`link[rel="${n.rel}"]${n.href?`[href="${n.href}"]`:""}`,s=document.querySelector(r);if(!s)s=document.createElement("link"),document.head.appendChild(s);for(let[a,o]of Object.entries(n))if(o!==void 0)s.setAttribute(a,String(o))}if(e.htmlAttrs)for(let[n,r]of Object.entries(e.htmlAttrs))if(n==="class")for(let s of String(r).split(/\s+/).filter(Boolean))document.documentElement.classList.add(s);else document.documentElement.setAttribute(n,r);if(e.bodyAttrs)for(let[n,r]of Object.entries(e.bodyAttrs))document.body.setAttribute(n,r)}function pu(e){let n="";return{content:e.replace(/@head\s*([\s\S]*?)@endhead/g,(s,a)=>(n+=a.trim()+`
24
- `,"")),headContent:n.trim()}}function fu(e,n){return e.replace(/@title\s*\(\s*(?:(['"`])(.+?)\1|([^)]+))\s*\)/g,(r,s,a,o)=>{let c=s?a:n[(o||"").trim()]??o,u=n.__stx_runtime_head??{};return n.__stx_runtime_head=fe(u,{title:c}),""})}function gu(e,n,r=""){if(!e.includes("@meta"))return e;return Ge(e,/(?<![\w$@])@meta\s*\(/g,(s,a)=>{let o=mn(Je(s),n);if(o.kind==="error")return E("Meta",a,o.message,r,o.code);if(o.kind==="tag"){let c=n.__stx_runtime_head??{};n.__stx_runtime_head=fe(c,{meta:[o.tag]})}return""},(s)=>E("Meta",s,"the call has no closing parenthesis",r,t.INVALID_DIRECTIVE_SYNTAX))}export{S,As,Ge,Je,Ye,ue,we,E,rr,Ps,Ei,un,pn,$i,xe,_i,fn,Ti,Tt,Is,Ri,gn,mn,hn,sr,pe,Ds,su,ou,Ai,fe,jc,or,iu,au,cu,lu,du,uu,pu,fu,gu};
24
+ `,"")),headContent:n.trim()}}function fu(e,n){return e.replace(/@title\s*\(\s*(?:(['"`])(.+?)\1|([^)]+))\s*\)/g,(r,s,a,o)=>{let c=s?a:n[(o||"").trim()]??o,u=n.__stx_runtime_head??{};return n.__stx_runtime_head=fe(u,{title:c}),""})}function gu(e,n,r=""){if(!e.includes("@meta"))return e;return Ge(e,/(?<![\w$@])@meta\s*\(/g,(s,a)=>{let o=mn(Je(s),n);if(o.kind==="error")return E("Meta",a,o.message,r,o.code);if(o.kind==="tag"){let c=n.__stx_runtime_head??{};n.__stx_runtime_head=fe(c,{meta:[o.tag]})}return""},(s)=>E("Meta",s,"the call has no closing parenthesis",r,t.INVALID_DIRECTIVE_SYNTAX))}export{S,As,Ge,Je,Ye,ue,we,E,rr,Ps,Ei,un,pn,$i,xe,Ti,fn,_i,_t,Is,Ri,gn,mn,hn,sr,pe,Ds,su,ou,Ai,fe,jc,or,iu,au,cu,lu,du,uu,pu,fu,gu};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{K,vs,ws,xs,n}from"./chunk-96kr2xrt.js";import"./chunk-68tzytfz.js";import"./chunk-c57j92td.js";import"./chunk-kp4mzspk.js";import"./chunk-v74acg2k.js";import"./chunk-zz5b1g50.js";import"./chunk-5tbqdz94.js";import"./chunk-9p3rtfbv.js";import"./chunk-g495xx4v.js";import"./chunk-ba88n1j7.js";import"./chunk-g1r4v0mc.js";import"./chunk-xd4zvm4x.js";import"./chunk-e6y6s7q8.js";export{K as injectRouterScript,n as processDirectives,vs as processJsonDirective,ws as processOnceDirective,xs as validateClientScript};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{I,At}from"./chunk-ba88n1j7.js";export{At as stripModuleImports,I as transformStoreImports};
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{y}from"./chunk-xsc9zbaj.js";import{W,He,ss,os,Yo,Zo,Qo,ei,Wn,is,ti,ni,ri,Et,o}from"./chunk-0np4t9ka.js";import{Lr}from"./chunk-x96ardq0.js";import{a}from"./chunk-dne8n6h3.js";import{existsSync as M,readFileSync as K}from"fs";import h from"path";var me=new Set(["module","exports","require","$bool","$num","window","document","console","confirm","alert","fetch"]),te=Et.filter((e)=>!me.has(e)).sort(),ne=[...y].sort(),he=[...new Set([...te,...ne])].sort(),be=new Set(te),ye=new Set(ne),xe=new Set(he),ee=/\bimport\s+(?!type[\s{])\{([^}]*)\}\s*from\s*(['"])stx\2/g;function Se(e,t){if(t==="server")return`'${e}' is not provided by 'stx' in a <script server> block. The engine binds only its own names there (defineProps, state, useHead, ...); any other name becomes \`await import('stx')\`, which does not resolve, so the whole script fails when the page renders. Import it from '@stacksjs/stx' instead.`;return`'${e}' is not provided by 'stx' in a client <script> block. The import is replaced by the window.stx runtime, which has no '${e}', so it is undefined in the browser.`}function ie(e,t){let s=[];for(let u of t){if(u.offset===void 0)continue;let i=u.kind==="server"?be:ye;ee.lastIndex=0;for(let l of u.code.matchAll(ee)){let g=l.index+l[0].indexOf("{")+1;for(let m of l[1].matchAll(/[^,]+/g)){let S=m[0];if(/^\s*type\s/.test(S))continue;let x=/^\s*([A-Za-z_$][\w$]*)/.exec(S);if(!x)continue;let r=x[1];if(!xe.has(r)||i.has(r))continue;let f=u.offset+g+m.index+x[0].length-r.length,p=e.slice(0,f),w=p.split(`
2
+ import{y}from"./chunk-g1r4v0mc.js";import{W,He,ss,os,Yo,Zo,Qo,ei,Wn,is,ti,ni,ri,Et,o}from"./chunk-96kr2xrt.js";import{Lr}from"./chunk-0vnr7mz7.js";import{a}from"./chunk-dne8n6h3.js";import{existsSync as M,readFileSync as K}from"fs";import h from"path";var me=new Set(["module","exports","require","$bool","$num","window","document","console","confirm","alert","fetch"]),te=Et.filter((e)=>!me.has(e)).sort(),ne=[...y].sort(),he=[...new Set([...te,...ne])].sort(),be=new Set(te),ye=new Set(ne),xe=new Set(he),ee=/\bimport\s+(?!type[\s{])\{([^}]*)\}\s*from\s*(['"])stx\2/g;function Se(e,t){if(t==="server")return`'${e}' is not provided by 'stx' in a <script server> block. The engine binds only its own names there (defineProps, state, useHead, ...); any other name becomes \`await import('stx')\`, which does not resolve, so the whole script fails when the page renders. Import it from '@stacksjs/stx' instead.`;return`'${e}' is not provided by 'stx' in a client <script> block. The import is replaced by the window.stx runtime, which has no '${e}', so it is undefined in the browser.`}function ie(e,t){let s=[];for(let u of t){if(u.offset===void 0)continue;let i=u.kind==="server"?be:ye;ee.lastIndex=0;for(let l of u.code.matchAll(ee)){let g=l.index+l[0].indexOf("{")+1;for(let m of l[1].matchAll(/[^,]+/g)){let S=m[0];if(/^\s*type\s/.test(S))continue;let x=/^\s*([A-Za-z_$][\w$]*)/.exec(S);if(!x)continue;let r=x[1];if(!xe.has(r)||i.has(r))continue;let f=u.offset+g+m.index+x[0].length-r.length,p=e.slice(0,f),w=p.split(`
3
3
  `).length;s.push({line:w,column:f-(p.lastIndexOf(`
4
4
  `)+1)+1,offset:f,length:r.length,name:r,kind:u.kind,message:Se(r,u.kind)})}}}return s}import T from"path";var ke="@stacksjs/stx-typescript-plugin";function we(e,t){let s=T.resolve(e);for(;;){let u=T.join(s,"tsconfig.json");if(t(u))return u;let i=T.dirname(s);if(i===s)return;s=i}}function se(e,t,s){let u=we(e,s);if(!u)return;let i=new Set,l=(g)=>{if(i.has(g))return;i.add(g);let m=t(g);if(!m)return;let S=m.compilerOptions?.plugins;if(Array.isArray(S)){let r=S.find((p)=>p?.name===ke),f=Array.isArray(r?.libs)?r.libs.filter((p)=>typeof p==="string"):[];return r?{configPath:g,libs:f.map((p)=>T.resolve(T.dirname(g),p))}:null}let x=typeof m.extends==="string"?[m.extends]:Array.isArray(m.extends)?m.extends:[];for(let r of[...x].reverse()){if(typeof r!=="string"||!r.startsWith("."))continue;let f=T.resolve(T.dirname(g),r.endsWith(".json")?r:`${r}.json`),p=l(f);if(p!==void 0)return p}return};return l(u)??void 0}function ea(e,t="",s=""){let u=e.startLine>1?`
5
5
  `.repeat(e.startLine-1):"",i=is(e)+os(ss(e.code)),l=e.kind==="client"||e.kind==="plain"?Qo(t,e.code):"";return Wn(`${u+i}
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{W,Gr,Jr,Za,wt,Ho,Yr,Vo,Rd,Le,Zr,he}from"./chunk-0np4t9ka.js";import"./chunk-azza6dcr.js";import"./chunk-c57j92td.js";import{wi,s}from"./chunk-xemsypk7.js";import"./chunk-kp4mzspk.js";import"./chunk-a5c75hxe.js";import"./chunk-6k4f583z.js";import"./chunk-133ggr0t.js";import"./chunk-5cyz97t4.js";import"./chunk-798epzq5.js";import"./chunk-d4k4nyj0.js";import"./chunk-xsc9zbaj.js";import"./chunk-xd4zvm4x.js";import"./chunk-e6y6s7q8.js";export{W as BROWSER_CORE_IMPORTS,Za as STX_AUTO_IMPORTS,Gr as extractAndStripCssImports,Le as extractBridgeData,wi as findInterpolationEnd,Vo as generateAutoImportDestructuring,Rd as generateBrowserAutoImportDestructuring,Zr as generateServerDataBridge,wt as injectBrowserCoreAutoImports,he as processClientScript,Yr as referencesName,Jr as renderVendorStyleTags,s as stripCommentsAndLiterals,Ho as transformAutoImports};
2
+ import{W,Gr,Jr,Za,wt,Ho,Yr,Vo,Rd,Le,Zr,he}from"./chunk-96kr2xrt.js";import"./chunk-68tzytfz.js";import"./chunk-c57j92td.js";import{wi,s}from"./chunk-xemsypk7.js";import"./chunk-kp4mzspk.js";import"./chunk-v74acg2k.js";import"./chunk-zz5b1g50.js";import"./chunk-5tbqdz94.js";import"./chunk-9p3rtfbv.js";import"./chunk-g495xx4v.js";import"./chunk-ba88n1j7.js";import"./chunk-g1r4v0mc.js";import"./chunk-xd4zvm4x.js";import"./chunk-e6y6s7q8.js";export{W as BROWSER_CORE_IMPORTS,Za as STX_AUTO_IMPORTS,Gr as extractAndStripCssImports,Le as extractBridgeData,wi as findInterpolationEnd,Vo as generateAutoImportDestructuring,Rd as generateBrowserAutoImportDestructuring,Zr as generateServerDataBridge,wt as injectBrowserCoreAutoImports,he as processClientScript,Yr as referencesName,Jr as renderVendorStyleTags,s as stripCommentsAndLiterals,Ho as transformAutoImports};
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- function P(s){let o=/import\s*\{([^}]+)\}\s*from\s*['"](@stores|stx\/stores)['"]\s*;?\n?/g;s=s.replace(o,(e,t)=>`const { ${t.split(",").map((r)=>r.trim()).filter(Boolean).join(", ")} } = window.__STX_STORES__
2
+ function I(s){let o=/import\s*\{([^}]+)\}\s*from\s*['"](@stores|stx\/stores)['"]\s*;?\n?/g;s=s.replace(o,(e,t)=>`const { ${t.split(",").map((r)=>r.trim()).filter(Boolean).join(", ")} } = window.__STX_STORES__
3
3
  `);let n=/import\s*\{([^}]+)\}\s*from\s*['"]@composables['"]\s*;?\n?/g;return s=s.replace(n,(e,t)=>`const { ${t.split(",").map((r)=>r.trim()).filter(Boolean).join(", ")} } = window.__composables
4
4
  `),s}function At(s){return s.replace(/^import\s+[^'"]*?from\s*['"][^'"]+['"]\s*;?[ \t]*$/gm,"").replace(/^import\s+['"][^'"]+['"]\s*;?[ \t]*$/gm,"")}
5
- export{P,At};
5
+ export{I,At};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{Sa,ka,Ca,Ea,$a,Ta,_a,Ra,Aa,Pa,Il}from"./chunk-068ank60.js";export{Sa as createIslandRegistry,Il as default,Pa as generateIslandManifest,Ca as generatePartialHydrationCSS,Ta as hydrateAll,$a as hydrateByStrategy,Ea as hydrateIsland,_a as isHydrated,Ra as onHydrated,ka as processPartialHydrationDirectives,Aa as processStaticDirectives};
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{Bn,Qa,Ad,ec,Pd,tc,Fn,b,St,ye,nc,es,rc,Id,q,sc,Dd,x,Od}from"./chunk-0np4t9ka.js";import"./chunk-azza6dcr.js";import"./chunk-c57j92td.js";import"./chunk-kp4mzspk.js";import"./chunk-a5c75hxe.js";import"./chunk-6k4f583z.js";import"./chunk-133ggr0t.js";import"./chunk-5cyz97t4.js";import"./chunk-798epzq5.js";import"./chunk-d4k4nyj0.js";import"./chunk-xsc9zbaj.js";import"./chunk-xd4zvm4x.js";import"./chunk-e6y6s7q8.js";export{sc as applyFilters,Pd as clearCustomFilters,nc as clientLoopScopes,Bn as defaultFilters,b as escapeHtml,St as escapeHtmlValue,x as evaluateExpression,tc as findMustacheEnd,ec as getAllFilters,rc as interpolateScriptAttributes,es as interpolateScriptExpressions,Id as interpolateScriptsInTemplate,q as processExpressions,Qa as registerFilter,Ad as registerFilters,Fn as replaceInterpolations,Dd as resetRejectedExpressionWarnings,Od as unescapeHtml,ye as usesSignalsInScript};
2
+ import{Bn,Qa,Ad,ec,Pd,tc,Fn,b,St,ye,nc,es,rc,Id,q,sc,Dd,x,Od}from"./chunk-96kr2xrt.js";import"./chunk-68tzytfz.js";import"./chunk-c57j92td.js";import"./chunk-kp4mzspk.js";import"./chunk-v74acg2k.js";import"./chunk-zz5b1g50.js";import"./chunk-5tbqdz94.js";import"./chunk-9p3rtfbv.js";import"./chunk-g495xx4v.js";import"./chunk-ba88n1j7.js";import"./chunk-g1r4v0mc.js";import"./chunk-xd4zvm4x.js";import"./chunk-e6y6s7q8.js";export{sc as applyFilters,Pd as clearCustomFilters,nc as clientLoopScopes,Bn as defaultFilters,b as escapeHtml,St as escapeHtmlValue,x as evaluateExpression,tc as findMustacheEnd,ec as getAllFilters,rc as interpolateScriptAttributes,es as interpolateScriptExpressions,Id as interpolateScriptsInTemplate,q as processExpressions,Qa as registerFilter,Ad as registerFilters,Fn as replaceInterpolations,Dd as resetRejectedExpressionWarnings,Od as unescapeHtml,ye as usesSignalsInScript};
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{ie,qa,Fo,mt,ht,_d,zo,yt,Qt,Ka,Xa,Ga,Ja,bt,Ya}from"./chunk-kbhm1wqt.js";import"./chunk-fd6abk20.js";import"./chunk-2hc5mbw8.js";import"./chunk-0np4t9ka.js";import"./chunk-azza6dcr.js";import"./chunk-c57j92td.js";import"./chunk-kp4mzspk.js";import"./chunk-a5c75hxe.js";import"./chunk-6k4f583z.js";import"./chunk-133ggr0t.js";import"./chunk-5cyz97t4.js";import"./chunk-798epzq5.js";import"./chunk-d4k4nyj0.js";import"./chunk-xsc9zbaj.js";import"./chunk-xd4zvm4x.js";import"./chunk-e6y6s7q8.js";export{Qt as MODULE_SPECIFIER_PREFIX,bt as bundleClientScript,ht as clearBundleFailures,ie as clientBundleDependencies,mt as getBundleFailures,yt as hasUserImports,Xa as normalizeRegistrySpecifiers,Ja as queueClientBundleBuild,Fo as recordBundleFailure,Ka as registryIdForPath,zo as resolveBundlerFallback,Ga as rewriteRegistryImports,_d as setBundlerFallbackMode,qa as shouldLogBundlerDiagnostics,Ya as tempBuildName};
2
+ import{ie,qa,Fo,mt,ht,Td,zo,yt,Qt,Ka,Xa,Ga,Ja,bt,Ya}from"./chunk-s87qrma5.js";import"./chunk-qt31at4s.js";import"./chunk-2hc5mbw8.js";import"./chunk-96kr2xrt.js";import"./chunk-68tzytfz.js";import"./chunk-c57j92td.js";import"./chunk-kp4mzspk.js";import"./chunk-v74acg2k.js";import"./chunk-zz5b1g50.js";import"./chunk-5tbqdz94.js";import"./chunk-9p3rtfbv.js";import"./chunk-g495xx4v.js";import"./chunk-ba88n1j7.js";import"./chunk-g1r4v0mc.js";import"./chunk-xd4zvm4x.js";import"./chunk-e6y6s7q8.js";export{Qt as MODULE_SPECIFIER_PREFIX,bt as bundleClientScript,ht as clearBundleFailures,ie as clientBundleDependencies,mt as getBundleFailures,yt as hasUserImports,Xa as normalizeRegistrySpecifiers,Ja as queueClientBundleBuild,Fo as recordBundleFailure,Ka as registryIdForPath,zo as resolveBundlerFallback,Ga as rewriteRegistryImports,Td as setBundlerFallbackMode,qa as shouldLogBundlerDiagnostics,Ya as tempBuildName};
@@ -1,3 +1,3 @@
1
1
  // @bun
2
- import{o}from"./chunk-0np4t9ka.js";import{$r}from"./chunk-2etevws0.js";import p from"path";async function vl(t={}){let d=performance.now(),s=t.root||process.cwd(),e=await o(s),u=t.ssr?.routeRules??e.routeRules??{};if($r(u),!e.ssr&&Object.keys(u).length)throw Error("routeRules require ssr: true and the production server; flat SSG output cannot apply request/cache policies");if(!e.ssr&&(t.ssr?.serverApi??e.serverApi))throw Error("serverApi requires ssr: true; flat SSG output cannot execute API endpoints");let r=e.ssr?"ssr":"ssg";console.log(`[stx build] Mode: ${r.toUpperCase()}${e.ssr?" (ssr: true in stx.config.ts)":" (default \u2014 ssr is false)"}`);let n,l;if(r==="ssg"){let{generateStaticSite:i}=await import("./ssg.js");n=await i({pagesDir:p.join(e.root||".",e.pagesDir||e.build?.pagesDir||"pages"),publicDir:e.publicDir||e.build?.publicDir||"public",outputDir:e.build?.outputDir||"dist",generate404:e.build?.generate404??!0,minify:e.build?.minify??!0,cleanOutput:e.build?.cleanOutput??!0,router:e.router,...t.ssg})}else{let{buildForProduction:i}=await import("./chunk-k0zadypg.js");l=await i({root:s,outputDir:".output",debug:t.debug,...t.ssr})}let a=Math.round(performance.now()-d);return{mode:r,ssg:n,ssr:l,duration:a}}
2
+ import{o}from"./chunk-96kr2xrt.js";import{$r}from"./chunk-2etevws0.js";import p from"path";async function vl(t={}){let d=performance.now(),s=t.root||process.cwd(),e=await o(s),u=t.ssr?.routeRules??e.routeRules??{};if($r(u),!e.ssr&&Object.keys(u).length)throw Error("routeRules require ssr: true and the production server; flat SSG output cannot apply request/cache policies");if(!e.ssr&&(t.ssr?.serverApi??e.serverApi))throw Error("serverApi requires ssr: true; flat SSG output cannot execute API endpoints");let r=e.ssr?"ssr":"ssg";console.log(`[stx build] Mode: ${r.toUpperCase()}${e.ssr?" (ssr: true in stx.config.ts)":" (default \u2014 ssr is false)"}`);let n,l;if(r==="ssg"){let{generateStaticSite:i}=await import("./ssg.js");n=await i({pagesDir:p.join(e.root||".",e.pagesDir||e.build?.pagesDir||"pages"),publicDir:e.publicDir||e.build?.publicDir||"public",outputDir:e.build?.outputDir||"dist",generate404:e.build?.generate404??!0,minify:e.build?.minify??!0,cleanOutput:e.build?.cleanOutput??!0,router:e.router,...t.ssg})}else{let{buildForProduction:i}=await import("./chunk-76g4jw9g.js");l=await i({root:s,outputDir:".output",debug:t.debug,...t.ssr})}let a=Math.round(performance.now()-d);return{mode:r,ssg:n,ssr:l,duration:a}}
3
3
  export{vl};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{Tr,_r,Rr,da,ua,pa,yo,fa,ga}from"./chunk-rvwtyrj4.js";export{Tr as ImageProcessorCache,yo as applyTransformations,da as clearImageCache,fa as generateResponsiveVariants,ga as generateSrcset,_r as getCachedImageResult,pa as optimizeImage,ua as processImage,Rr as setCachedImageResult};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{R,Nc,o,A,Yd,Zd}from"./chunk-96kr2xrt.js";import"./chunk-68tzytfz.js";import"./chunk-c57j92td.js";import"./chunk-kp4mzspk.js";import"./chunk-v74acg2k.js";import"./chunk-zz5b1g50.js";import"./chunk-5tbqdz94.js";import"./chunk-9p3rtfbv.js";import"./chunk-g495xx4v.js";import"./chunk-ba88n1j7.js";import"./chunk-g1r4v0mc.js";import"./chunk-xd4zvm4x.js";import"./chunk-e6y6s7q8.js";export{A as config,R as defaultConfig,Yd as defineStxConfig,o as loadStxConfig,Nc as resolveStxDirectories,Zd as validateConfig};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{Hd,Xo,Vd,Go,cc,lc,kt,sn,Ud,dc,uc,pc,f}from"./chunk-96kr2xrt.js";import"./chunk-68tzytfz.js";import"./chunk-c57j92td.js";import"./chunk-kp4mzspk.js";import"./chunk-v74acg2k.js";import"./chunk-zz5b1g50.js";import"./chunk-5tbqdz94.js";import"./chunk-9p3rtfbv.js";import"./chunk-g495xx4v.js";import"./chunk-ba88n1j7.js";import"./chunk-g1r4v0mc.js";import"./chunk-xd4zvm4x.js";import"./chunk-e6y6s7q8.js";export{kt as buildCss,dc as extractClassNames,lc as fingerprintConfig,uc as generateCss,Ud as getCachedCSS,Hd as getCssServeAsset,f as injectCss,Xo as loadCssEngine,Go as loadCssEngineConfig,sn as rebuildCss,Vd as resetCssCache,cc as resolveUserCssConfig,pc as withLinkedModuleBundles};
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{$e,_e,Te}from"./chunk-czmw5xsd.js";import"./chunk-xsc9zbaj.js";import"./chunk-d4k4nyj0.js";import{u}from"./chunk-0np4t9ka.js";import"./chunk-798epzq5.js";import"./chunk-c57j92td.js";import"./chunk-xd4zvm4x.js";import"./chunk-5cyz97t4.js";import"./chunk-133ggr0t.js";import"./chunk-kp4mzspk.js";import"./chunk-6k4f583z.js";import"./chunk-a5c75hxe.js";import"./chunk-e6y6s7q8.js";import{it,gr,at,Vs,Ee,Us,mr,ct,qs,lt}from"./chunk-c322rrge.js";import"./chunk-azza6dcr.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()=>{Us("Config file changed, restarting...");try{await e.onChange()}catch(p){Ee(`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 nt=".stx/story/analytics.json",st=1,A=1e4;class k{storage;storagePath;currentSession=null;dirty=!1;viewStartTimes=new Map;constructor(t){this.storagePath=j.join(t,nt),this.storage=this.loadStorage(),this.startSession()}loadStorage(){try{let t=w.readFileSync(this.storagePath,"utf-8");return JSON.parse(t)}catch{return{version:st,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:dt(),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),g=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:g}}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 dt(){return`session-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}import S from"fs";import B from"path";var pt=".stx/story/bookmarks.json",mt=1;class P{storage;storagePath;dirty=!1;constructor(t){this.storagePath=B.join(t,pt),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{$e,Te,_e}from"./chunk-1149d93e.js";import"./chunk-g1r4v0mc.js";import"./chunk-ba88n1j7.js";import{u}from"./chunk-96kr2xrt.js";import"./chunk-g495xx4v.js";import"./chunk-c57j92td.js";import"./chunk-xd4zvm4x.js";import"./chunk-9p3rtfbv.js";import"./chunk-5tbqdz94.js";import"./chunk-kp4mzspk.js";import"./chunk-zz5b1g50.js";import"./chunk-v74acg2k.js";import"./chunk-e6y6s7q8.js";import{it,gr,at,Vs,Ee,Us,mr,ct,qs,lt}from"./chunk-c322rrge.js";import"./chunk-68tzytfz.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()=>{Us("Config file changed, restarting...");try{await e.onChange()}catch(p){Ee(`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 nt=".stx/story/analytics.json",st=1,A=1e4;class k{storage;storagePath;currentSession=null;dirty=!1;viewStartTimes=new Map;constructor(t){this.storagePath=j.join(t,nt),this.storage=this.loadStorage(),this.startSession()}loadStorage(){try{let t=w.readFileSync(this.storagePath,"utf-8");return JSON.parse(t)}catch{return{version:st,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:dt(),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),g=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:g}}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 dt(){return`session-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}import S from"fs";import B from"path";var pt=".stx/story/bookmarks.json",mt=1;class P{storage;storagePath;dirty=!1;constructor(t){this.storagePath=B.join(t,pt),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,9 +556,9 @@ 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-wrghqec5.js"),p={},g=h(n);if(g)try{await u(g,p,e)}catch(f){o.push(`Warning: Could not extract script variables: ${f instanceof Error?f.message:String(f)}`)}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 u(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-wrghqec5.js"),c={...r},n=h(e);if(n)try{await u(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-9xw416q3.js"),p={},g=h(n);if(g)try{await u(g,p,e)}catch(f){o.push(`Warning: Could not extract script variables: ${f instanceof Error?f.message:String(f)}`)}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 u(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-9xw416q3.js"),c={...r},n=h(e);if(n)try{await u(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
- `)}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 ct(t);_e(t,r);let s=lt(t.config,r);Te(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 f=new URL(i.url).pathname;if(f==="/__hmr"){if(l.upgrade(i,{data:{isHmr:!0}}))return;return new Response("WebSocket upgrade failed",{status:400})}if(f.startsWith("/api/"))return xt(t,f,i,{presetsManager:a,bookmarksManager:c,analyticsTracker:n});return wt(t,f,e.port)},websocket:{open(i){d.open(i)},close(i){d.close(i)},message(i,l){d.message(i,l)}}}),g=`http://${o}:${e.port}`,y=qs(t,async(i,l)=>{console.log(` [${i}] ${l.relativePath}`);let m=await ct(t);_e(t,m);let f=lt(t.config,m);if(Te(t,f),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=g;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:g,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],g=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,g,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((g)=>g.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>
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 ct(t);Te(t,r);let s=lt(t.config,r);_e(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 f=new URL(i.url).pathname;if(f==="/__hmr"){if(l.upgrade(i,{data:{isHmr:!0}}))return;return new Response("WebSocket upgrade failed",{status:400})}if(f.startsWith("/api/"))return xt(t,f,i,{presetsManager:a,bookmarksManager:c,analyticsTracker:n});return wt(t,f,e.port)},websocket:{open(i){d.open(i)},close(i){d.close(i)},message(i,l){d.message(i,l)}}}),g=`http://${o}:${e.port}`,y=qs(t,async(i,l)=>{console.log(` [${i}] ${l.relativePath}`);let m=await ct(t);Te(t,m);let f=lt(t.config,m);if(_e(t,f),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=g;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:g,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],g=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,g,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((g)=>g.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"}">
563
563
  <head>
564
564
  <meta charset="UTF-8">
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{Qc}from"./chunk-7p6y0b47.js";import"./chunk-fwvqbx49.js";import"./chunk-qt31at4s.js";import"./chunk-96kr2xrt.js";import"./chunk-68tzytfz.js";import"./chunk-c57j92td.js";import"./chunk-kp4mzspk.js";import"./chunk-v74acg2k.js";import"./chunk-zz5b1g50.js";import"./chunk-5tbqdz94.js";import"./chunk-9p3rtfbv.js";import"./chunk-g495xx4v.js";import"./chunk-ba88n1j7.js";import"./chunk-g1r4v0mc.js";import"./chunk-xd4zvm4x.js";import"./chunk-e6y6s7q8.js";export{Qc as startProductionServer};
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{Tt}from"./chunk-5cyz97t4.js";import{qo,Qr,Y,je,St,x,Fe,ze,Kn,u}from"./chunk-0np4t9ka.js";import{O}from"./chunk-vtxzaj1h.js";import v from"path";var D=/\b(?:state|derived|effect|batch|ref|reactive|computed|watch|watchEffect)\s*(?:<[^>]*>)?\s*\(/;function F(t,n,e){let r={fullTag:e,content:n,attrs:t};if(/\bserver\b/.test(t))return{...r,type:"server"};if(/\bdata-stx-scoped\b/.test(t))return{...r,type:"client"};if(D.test(n))return{...r,type:"signals"};if(/\bclient\b/.test(t)||/\btype\s*=\s*["']module["']/.test(t)||/\bsrc\s*=/.test(t))return{...r,type:"client"};return{...r,type:"server"}}var H=/^<script\b([^>]*)>([\s\S]*)<\/script\s*>$/i;function io(t){let n=[],e=[],r=[],o=0;while(o<t.length){let s=t.indexOf("<",o);if(s===-1)break;let a=je(t,s);if(a>s){o=a;continue}let i=Y(t,s);if(i>s){let c=t.slice(s,i),f=H.exec(c);if(f){let l=F(f[1],f[2],c);switch(l.type){case"signals":n.push(l);break;case"client":e.push(l);break;case"server":r.push(l);break}}o=i;continue}o=s+(t.startsWith("<!--",s)?4:1)}return{signals:n,client:e,server:r}}var L=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]);function V(t){let n=[],e=/<!--[\s\S]*?(?:-->|$)|<(script|style|textarea|title|template)\b[^>]*>[\s\S]*?<\/\1\s*>/gi,r;while((r=e.exec(t))!==null)n.push({start:r.index,end:r.index+r[0].length});return n}function P(t,n){return n.some((e)=>t>=e.start&&t<e.end)}function B(t){let n=(t||"").trim();if(!n)return null;if(/[\s>+~,:]/.test(n))return null;let e={},r=n,o=r.match(/^[a-z][\w-]*/i);if(o)e.tag=o[0].toLowerCase(),r=r.slice(o[0].length);while(r.length>0){let s=r.match(/^\[([\w-]+)(?:=(["']?)([^\]"']*)\2)?\]/);if(s){if(e.attr=s[1],s[3]!==void 0&&s[3]!=="")e.attrValue=s[3];r=r.slice(s[0].length);continue}let a=r.match(/^#([\w-]+)/);if(a){e.id=a[1],r=r.slice(a[0].length);continue}let i=r.match(/^\.([\w-]+)/);if(i){e.className=i[1],r=r.slice(i[0].length);continue}return null}if(!e.tag&&!e.attr&&!e.id&&!e.className)return null;return e}function q(t,n){if(n.attr){if(!(n.attrValue===void 0?new RegExp(`\\b${n.attr}(?=[\\s=>/]|$)`,"i"):new RegExp(`\\b${n.attr}\\s*=\\s*(["'])\\s*${n.attrValue}\\s*\\1`,"i")).test(t))return!1}if(n.id){if(!new RegExp(`\\bid\\s*=\\s*(["'])\\s*${n.id}\\s*\\1`,"i").test(t))return!1}if(n.className){let e=t.match(/\bclass\s*=\s*(["'])([\s\S]*?)\1/i);if(!e)return!1;if(!e[2].split(/\s+/).includes(n.className))return!1}return!0}function T(t,n="main"){let e=B(n);if(!e)return null;let r=/<([a-z][\w-]*)\b([^>]*)>/gi,o=V(t),s;while((s=r.exec(t))!==null){if(P(s.index,o))continue;let a=s[1].toLowerCase(),i=s[2]||"";if(i.trimEnd().endsWith("/")||L.has(a))continue;if(e.tag&&e.tag!==a)continue;if(!q(i,e))continue;let c=s[0],f=s.index+c.length,l=new RegExp(`<(/?)${a}\\b([^>]*)>`,"gi");l.lastIndex=f;let g=1,d;while((d=l.exec(t))!==null){if(P(d.index,o))continue;let h=d[1]==="/";if(!h&&(d[2]||"").trimEnd().endsWith("/"))continue;if(g+=h?-1:1,g===0)return{openTag:c,openIndex:s.index,start:f,end:d.index,tagName:a}}return null}return null}var Ae="private, no-store";function ao(t){return t.replace(/&#(\d+);/g,(n,e)=>M(Number(e),n)).replace(/&#x([0-9a-f]+);/gi,(n,e)=>M(Number.parseInt(e,16),n)).replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&quot;/g,'"').replace(/&apos;/g,"'").replace(/&amp;/g,"&")}function M(t,n){if(!Number.isInteger(t)||t<0||t>1114111)return n;try{return String.fromCodePoint(t)}catch{return n}}function ne(t){return t.headers.get("X-STX-Router")==="true"}function z(t,n){if(!t)return n;return t.split(",").some((r)=>r.trim().toLowerCase()===n.toLowerCase())?t:`${t}, ${n}`}function _(t){return{Vary:z(t,"X-STX-Router")}}var G="stx-page-head:",U=/<!--stx-page-head:([A-Za-z0-9+/=]+)-->\n?/,A={dev:null,prod:null};function W(){let t=O()?"dev":"prod",n=A[t];if(n!==null)return n;try{let e=import.meta.require("./chunk-km9g9drp.js"),r=t==="dev"&&typeof e.getRouterScriptDev==="function"?e.getRouterScriptDev:e.getRouterScript;A[t]=`<script>${r()}</script>`}catch{A[t]=""}return A[t]}async function co(t,n){if(n===!1)return null;if(n&&typeof n==="string"){let r=v.resolve(t,n);if(await Bun.file(r).exists())return r;return null}let e=v.join(t,"app.stx");if(await Bun.file(e).exists())return e;return null}async function Cr(t,n){try{let e=await Bun.file(t).text(),r=e,o=e.match(/<template\b[^>]*>([\s\S]*?)<\/template>/i);if(o)r=o[1].trim();let s=io(e),a=[...s.client.map((m)=>m.fullTag),...s.signals.map((m)=>m.fullTag)],i=[],c=/<style\b[^>]*>([\s\S]*?)<\/style>/gi,f;while((f=c.exec(e))!==null)i.push(f[0]);let l=r;for(let m of s.server)l=l.replace(m.fullTag,"");for(let m of s.client)l=l.replace(m.fullTag,"");l=l.replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,"");let g="<!--__STX_PAGE_SLOT__-->";if(l=l.replace(/<slot\s*\/>/gi,g).replace(/<slot\s*>\s*<\/slot>/gi,g),!l.includes(g))return console.warn(`[stx] Shell ${t} has no <slot /> \u2014 pages won't be injected`),null;let{processDirectives:d,extractVariables:h,defaultConfig:S,loadStxConfig:b}=await import("./chunk-pykeaf4h.js"),R=await b(),p={__filename:t,__dirname:v.dirname(t)};for(let m of a){let C=m.match(/<script\b[^>]*>([\s\S]*?)<\/script>/i);if(C&&!m.includes("client")&&!m.includes('type="module"'))await h(C[1],p,t)}let y=await d(l,p,t,{...S,...R,...n},new Set),w=y.indexOf(g);if(w===-1)return console.warn("[stx] Shell slot placeholder lost during processing"),null;return{beforeSlot:y.substring(0,w),afterSlot:y.substring(w+g.length),filePath:t,shellScripts:a,shellStyles:i}}catch(e){return console.error(`[stx] Error processing shell ${t}:`,e),null}}function An(t,n,e){let r,o="",s=n.match(U);if(s){n=n.replace(s[0],"");try{let l=Buffer.from(s[1],"base64").toString("utf8"),g=l.match(/<title[^>]*>([\s\S]*?)<\/title>/i);if(g)r=g[1].trim();o=l.replace(/<title[^>]*>[\s\S]*?<\/title>/i,"").trim()}catch{}}let a=e||r||"stx App",i=W(),c="<script>window.__stxRouterConfig={container:'[data-stx-content]'};</script>";return`<!DOCTYPE html>
2
+ import{_t}from"./chunk-9p3rtfbv.js";import{qo,Qr,Y,je,St,x,Fe,ze,Kn,u}from"./chunk-96kr2xrt.js";import{O}from"./chunk-vtxzaj1h.js";import v from"path";var D=/\b(?:state|derived|effect|batch|ref|reactive|computed|watch|watchEffect)\s*(?:<[^>]*>)?\s*\(/;function F(t,n,e){let r={fullTag:e,content:n,attrs:t};if(/\bserver\b/.test(t))return{...r,type:"server"};if(/\bdata-stx-scoped\b/.test(t))return{...r,type:"client"};if(D.test(n))return{...r,type:"signals"};if(/\bclient\b/.test(t)||/\btype\s*=\s*["']module["']/.test(t)||/\bsrc\s*=/.test(t))return{...r,type:"client"};return{...r,type:"server"}}var H=/^<script\b([^>]*)>([\s\S]*)<\/script\s*>$/i;function io(t){let n=[],e=[],r=[],o=0;while(o<t.length){let s=t.indexOf("<",o);if(s===-1)break;let a=je(t,s);if(a>s){o=a;continue}let i=Y(t,s);if(i>s){let c=t.slice(s,i),f=H.exec(c);if(f){let l=F(f[1],f[2],c);switch(l.type){case"signals":n.push(l);break;case"client":e.push(l);break;case"server":r.push(l);break}}o=i;continue}o=s+(t.startsWith("<!--",s)?4:1)}return{signals:n,client:e,server:r}}var L=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]);function V(t){let n=[],e=/<!--[\s\S]*?(?:-->|$)|<(script|style|textarea|title|template)\b[^>]*>[\s\S]*?<\/\1\s*>/gi,r;while((r=e.exec(t))!==null)n.push({start:r.index,end:r.index+r[0].length});return n}function k(t,n){return n.some((e)=>t>=e.start&&t<e.end)}function B(t){let n=(t||"").trim();if(!n)return null;if(/[\s>+~,:]/.test(n))return null;let e={},r=n,o=r.match(/^[a-z][\w-]*/i);if(o)e.tag=o[0].toLowerCase(),r=r.slice(o[0].length);while(r.length>0){let s=r.match(/^\[([\w-]+)(?:=(["']?)([^\]"']*)\2)?\]/);if(s){if(e.attr=s[1],s[3]!==void 0&&s[3]!=="")e.attrValue=s[3];r=r.slice(s[0].length);continue}let a=r.match(/^#([\w-]+)/);if(a){e.id=a[1],r=r.slice(a[0].length);continue}let i=r.match(/^\.([\w-]+)/);if(i){e.className=i[1],r=r.slice(i[0].length);continue}return null}if(!e.tag&&!e.attr&&!e.id&&!e.className)return null;return e}function q(t,n){if(n.attr){if(!(n.attrValue===void 0?new RegExp(`\\b${n.attr}(?=[\\s=>/]|$)`,"i"):new RegExp(`\\b${n.attr}\\s*=\\s*(["'])\\s*${n.attrValue}\\s*\\1`,"i")).test(t))return!1}if(n.id){if(!new RegExp(`\\bid\\s*=\\s*(["'])\\s*${n.id}\\s*\\1`,"i").test(t))return!1}if(n.className){let e=t.match(/\bclass\s*=\s*(["'])([\s\S]*?)\1/i);if(!e)return!1;if(!e[2].split(/\s+/).includes(n.className))return!1}return!0}function P(t,n="main"){let e=B(n);if(!e)return null;let r=/<([a-z][\w-]*)\b([^>]*)>/gi,o=V(t),s;while((s=r.exec(t))!==null){if(k(s.index,o))continue;let a=s[1].toLowerCase(),i=s[2]||"";if(i.trimEnd().endsWith("/")||L.has(a))continue;if(e.tag&&e.tag!==a)continue;if(!q(i,e))continue;let c=s[0],f=s.index+c.length,l=new RegExp(`<(/?)${a}\\b([^>]*)>`,"gi");l.lastIndex=f;let g=1,d;while((d=l.exec(t))!==null){if(k(d.index,o))continue;let h=d[1]==="/";if(!h&&(d[2]||"").trimEnd().endsWith("/"))continue;if(g+=h?-1:1,g===0)return{openTag:c,openIndex:s.index,start:f,end:d.index,tagName:a}}return null}return null}var Ae="private, no-store";function ao(t){return t.replace(/&#(\d+);/g,(n,e)=>M(Number(e),n)).replace(/&#x([0-9a-f]+);/gi,(n,e)=>M(Number.parseInt(e,16),n)).replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&quot;/g,'"').replace(/&apos;/g,"'").replace(/&amp;/g,"&")}function M(t,n){if(!Number.isInteger(t)||t<0||t>1114111)return n;try{return String.fromCodePoint(t)}catch{return n}}function ne(t){return t.headers.get("X-STX-Router")==="true"}function z(t,n){if(!t)return n;return t.split(",").some((r)=>r.trim().toLowerCase()===n.toLowerCase())?t:`${t}, ${n}`}function T(t){return{Vary:z(t,"X-STX-Router")}}var G="stx-page-head:",U=/<!--stx-page-head:([A-Za-z0-9+/=]+)-->\n?/,A={dev:null,prod:null};function W(){let t=O()?"dev":"prod",n=A[t];if(n!==null)return n;try{let e=import.meta.require("./chunk-km9g9drp.js"),r=t==="dev"&&typeof e.getRouterScriptDev==="function"?e.getRouterScriptDev:e.getRouterScript;A[t]=`<script>${r()}</script>`}catch{A[t]=""}return A[t]}async function co(t,n){if(n===!1)return null;if(n&&typeof n==="string"){let r=v.resolve(t,n);if(await Bun.file(r).exists())return r;return null}let e=v.join(t,"app.stx");if(await Bun.file(e).exists())return e;return null}async function Cr(t,n){try{let e=await Bun.file(t).text(),r=e,o=e.match(/<template\b[^>]*>([\s\S]*?)<\/template>/i);if(o)r=o[1].trim();let s=io(e),a=[...s.client.map((m)=>m.fullTag),...s.signals.map((m)=>m.fullTag)],i=[],c=/<style\b[^>]*>([\s\S]*?)<\/style>/gi,f;while((f=c.exec(e))!==null)i.push(f[0]);let l=r;for(let m of s.server)l=l.replace(m.fullTag,"");for(let m of s.client)l=l.replace(m.fullTag,"");l=l.replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,"");let g="<!--__STX_PAGE_SLOT__-->";if(l=l.replace(/<slot\s*\/>/gi,g).replace(/<slot\s*>\s*<\/slot>/gi,g),!l.includes(g))return console.warn(`[stx] Shell ${t} has no <slot /> \u2014 pages won't be injected`),null;let{processDirectives:d,extractVariables:h,defaultConfig:S,loadStxConfig:b}=await import("./chunk-j08y5n2k.js"),R=await b(),p={__filename:t,__dirname:v.dirname(t)};for(let m of a){let C=m.match(/<script\b[^>]*>([\s\S]*?)<\/script>/i);if(C&&!m.includes("client")&&!m.includes('type="module"'))await h(C[1],p,t)}let y=await d(l,p,t,{...S,...R,...n},new Set),w=y.indexOf(g);if(w===-1)return console.warn("[stx] Shell slot placeholder lost during processing"),null;return{beforeSlot:y.substring(0,w),afterSlot:y.substring(w+g.length),filePath:t,shellScripts:a,shellStyles:i}}catch(e){return console.error(`[stx] Error processing shell ${t}:`,e),null}}function An(t,n,e){let r,o="",s=n.match(U);if(s){n=n.replace(s[0],"");try{let l=Buffer.from(s[1],"base64").toString("utf8"),g=l.match(/<title[^>]*>([\s\S]*?)<\/title>/i);if(g)r=g[1].trim();o=l.replace(/<title[^>]*>[\s\S]*?<\/title>/i,"").trim()}catch{}}let a=e||r||"stx App",i=W(),c="<script>window.__stxRouterConfig={container:'[data-stx-content]'};</script>";return`<!DOCTYPE html>
3
3
  <html lang="en">
4
4
  <head>
5
5
  <meta charset="UTF-8">
@@ -18,13 +18,13 @@ ${t.shellScripts.filter((l)=>!l.includes("server")).join(`
18
18
  ${c}
19
19
  ${i}
20
20
  </body>
21
- </html>`}function me(t,n={}){let e=t.trim();if(!Tt(e))return t;let r=[],o=e.match(/<head\b[^>]*>([\s\S]*?)<\/head>/i);if(o){let c=o[1],f=/<style\b[^>]*>[\s\S]*?<\/style>/gi,l;while((l=f.exec(c))!==null)r.push(l[0]);let g=c.match(/<script\b[^>]*data-stx-server-data[^>]*>[\s\S]*?<\/script>/i);if(g)r.push(g[0]);let d=c.match(/<script\b[^>]*data-stx-runtime-config[^>]*>[\s\S]*?<\/script>/i);if(d)r.push(d[0])}if(n.preserveHead&&o){let c=[],f=/<title\b[^>]*>[\s\S]*?<\/title>|<meta\b[^>]*>|<link\b[^>]*>/gi,l;while((l=f.exec(o[1]))!==null){if(/<meta\b[^>]*(?:\bcharset|name="viewport")/i.test(l[0]))continue;c.push(l[0])}if(c.length>0)r.unshift(`<!--${G}${Buffer.from(c.join(`
21
+ </html>`}function me(t,n={}){let e=t.trim();if(!_t(e))return t;let r=[],o=e.match(/<head\b[^>]*>([\s\S]*?)<\/head>/i);if(o){let c=o[1],f=/<style\b[^>]*>[\s\S]*?<\/style>/gi,l;while((l=f.exec(c))!==null)r.push(l[0]);let g=c.match(/<script\b[^>]*data-stx-server-data[^>]*>[\s\S]*?<\/script>/i);if(g)r.push(g[0]);let d=c.match(/<script\b[^>]*data-stx-runtime-config[^>]*>[\s\S]*?<\/script>/i);if(d)r.push(d[0])}if(n.preserveHead&&o){let c=[],f=/<title\b[^>]*>[\s\S]*?<\/title>|<meta\b[^>]*>|<link\b[^>]*>/gi,l;while((l=f.exec(o[1]))!==null){if(/<meta\b[^>]*(?:\bcharset|name="viewport")/i.test(l[0]))continue;c.push(l[0])}if(c.length>0)r.unshift(`<!--${G}${Buffer.from(c.join(`
22
22
  `),"utf8").toString("base64")}-->`)}let s=e.match(/<body\b[^>]*>/i),a=e.lastIndexOf("</body>");if(s&&a!==-1){let c=s.index+s[0].length,f=e.slice(c,a).trim();if(r.length>0)return r.join(`
23
23
  `)+`
24
24
  `+f;return f}let i=e;if(i=i.replace(/<!DOCTYPE\b[^>]*>/i,""),i=i.replace(/<html\b[^>]*>/i,""),i=i.replace(/<\/html\s*>/i,""),o)i=i.replace(/<head\b[^>]*>[\s\S]*?<\/head>/i,r.join(`
25
- `));return i=i.replace(/<body\b[^>]*>/i,""),i=i.replace(/<\/body\s*>/i,""),i.trim()}var N=/^<script\b[^>]*\sdata-stx-(?:owner|instance)(?=[\s=/>])/i;function X(t,n,e,r){if(!N.test(n))return!1;let o=n.slice(0,n.indexOf(">")+1),s=/\sdata-stx-owner="([^"]+)"/i.exec(o)?.[1];if(!s)return!0;let a=`data-stx-scope="${s}"`;for(let i=t.indexOf(a);i!==-1;i=t.indexOf(a,i+a.length))if(i>=e&&i<r)return!1;return!0}function lo(t){return ne(t)}function re(t,n="main"){let e=t.trim(),r=[],o=[],s=e.match(/<head\b[^>]*>([\s\S]*?)<\/head>/i);if(s){let b=s[1],R=/<style\b[^>]*>[\s\S]*?<\/style>/gi,p;while((p=R.exec(b))!==null)r.push(p[0]);let y=/<script\b[^>]*data-stx-(?:route-params|server-data|scoped|component-factories)[^>]*>[\s\S]*?<\/script>/gi;while((p=y.exec(b))!==null){if(N.test(p[0])||p[0].includes("__stx_early_mounts")||/^<script\b[^>]*\bdata-stx-runtime(?=[\s=>])/i.test(p[0]))continue;o.push(p[0])}}let a=T(e,n);if(!a)return me(t);let{tagName:i,start:c,end:f}=a,l=e.slice(c,f).trim(),g=[],d=e.match(/<body\b[^>]*>/i),h=e.lastIndexOf("</body>");if(d&&d.index!==void 0&&h!==-1){let R=[[d.index+d[0].length,a.openIndex],[f+`</${i}>`.length,h]],p=/<script\b[^>]*>[\s\S]*?<\/script>/gi;for(let[y,w]of R){if(y>=w)continue;let m=e.slice(y,w),C;p.lastIndex=0;while((C=p.exec(m))!==null){if(X(e,C[0],c,f))continue;g.push(C[0])}}}let S=[];if(r.length>0)S.push(r.join(`
25
+ `));return i=i.replace(/<body\b[^>]*>/i,""),i=i.replace(/<\/body\s*>/i,""),i.trim()}var N=/^<script\b[^>]*\sdata-stx-(?:owner|instance)(?=[\s=/>])/i;function X(t,n,e,r){if(!N.test(n))return!1;let o=n.slice(0,n.indexOf(">")+1),s=/\sdata-stx-owner="([^"]+)"/i.exec(o)?.[1];if(!s)return!0;let a=`data-stx-scope="${s}"`;for(let i=t.indexOf(a);i!==-1;i=t.indexOf(a,i+a.length))if(i>=e&&i<r)return!1;return!0}function lo(t){return ne(t)}function re(t,n="main"){let e=t.trim(),r=[],o=[],s=e.match(/<head\b[^>]*>([\s\S]*?)<\/head>/i);if(s){let b=s[1],R=/<style\b[^>]*>[\s\S]*?<\/style>/gi,p;while((p=R.exec(b))!==null)r.push(p[0]);let y=/<script\b[^>]*data-stx-(?:route-params|server-data|scoped|component-factories)[^>]*>[\s\S]*?<\/script>/gi;while((p=y.exec(b))!==null){if(N.test(p[0])||p[0].includes("__stx_early_mounts")||/^<script\b[^>]*\bdata-stx-runtime(?=[\s=>])/i.test(p[0]))continue;o.push(p[0])}}let a=P(e,n);if(!a)return me(t);let{tagName:i,start:c,end:f}=a,l=e.slice(c,f).trim(),g=[],d=e.match(/<body\b[^>]*>/i),h=e.lastIndexOf("</body>");if(d&&d.index!==void 0&&h!==-1){let R=[[d.index+d[0].length,a.openIndex],[f+`</${i}>`.length,h]],p=/<script\b[^>]*>[\s\S]*?<\/script>/gi;for(let[y,w]of R){if(y>=w)continue;let m=e.slice(y,w),C;p.lastIndex=0;while((C=p.exec(m))!==null){if(X(e,C[0],c,f))continue;g.push(C[0])}}}let S=[];if(r.length>0)S.push(r.join(`
26
26
  `));if(o.length>0)S.push(o.join(`
27
27
  `));if(g.length>0)S.push(g.join(`
28
28
  `));return S.push(l),S.join(`
29
- `)}function E(t,n,e={}){let r=`${encodeURIComponent(t)}=${encodeURIComponent(n)}`;if(e.maxAge!==void 0)r+=`; Max-Age=${e.maxAge}`;if(e.expires)r+=`; Expires=${e.expires.toUTCString()}`;if(e.path)r+=`; Path=${e.path}`;if(e.domain)r+=`; Domain=${e.domain}`;if(e.secure)r+="; Secure";if(e.httpOnly)r+="; HttpOnly";if(e.sameSite)r+=`; SameSite=${e.sameSite}`;return r}async function J(t){let n=t.headers.get("content-type")||"",e={},r=(o,s)=>{let a=e[o];if(a===void 0)e[o]=s;else if(Array.isArray(a))a.push(s);else e[o]=[a,s]};if(n.includes("multipart/form-data")){let o=await t.formData();for(let[s,a]of o.entries())if(typeof a==="string")r(s,a);return e}if(n.includes("application/x-www-form-urlencoded")){for(let[o,s]of new URLSearchParams(await t.text()).entries())r(o,s);return e}return e}function Er(t){if(!t)return!1;let n=t.toUpperCase();return n!=="GET"&&n!=="HEAD"}async function I(t,n={}){let e=n.request,r=n.method??e?.method;if(!e||!Er(r))return{ran:!1};if(typeof t.action!=="function")return{ran:!1};let o={};try{o=await J(e)}catch{}let s=await t.action({request:e,form:o,params:n.params??{},query:t.query??{},cookies:n.cookies??{}});if(s&&typeof s==="object"){let a=s,i=K(a.cookies),c=a.redirect;if(typeof c==="string"&&c)return{redirect:c,ran:!0,...i.length>0?{cookies:i}:{}};let{cookies:f,redirect:l,...g}=a;if(Object.assign(t,g),i.length>0)return{ran:!0,cookies:i}}return{ran:!0}}function K(t){if(!t||typeof t!=="object"||Array.isArray(t))return[];let n=[];for(let[e,r]of Object.entries(t)){if(!e)continue;if(typeof r==="string"){n.push(E(e,r));continue}if(r&&typeof r==="object"){let o=r;if(typeof o.value!=="string")continue;n.push(E(e,o.value,o))}}return n}function go(t,n=[],e){let r=new Headers({Location:t,"Cache-Control":"no-store"});for(let o of n)r.append("Set-Cookie",o);for(let[o,s]of Object.entries(e??{}))if(o.toLowerCase()!=="location")r.set(o,s);return new Response(null,{status:303,headers:r})}import k from"fs";import j from"path";function uo(t,n,e){return{version:1,buildTime:new Date().toISOString(),routes:t,assets:n,outputDir:e}}function po(t,n){let e=j.join(n,"manifest.json");k.writeFileSync(e,JSON.stringify(t,null,2))}function fo(t){let n=j.join(t,"manifest.json");if(!k.existsSync(n))return null;try{let e=k.readFileSync(n,"utf-8"),r=JSON.parse(e);if(r.version!==1)return console.warn(`[stx] Manifest version mismatch: expected 1, got ${r.version}`),null;return r}catch(e){return console.warn("[stx] Failed to load manifest:",e),null}}async function Ot(t,n={}){let{html:e,context:r,redirect:o,cookies:s}=await Z(t,n),a=Fe(r),i=ze(r);if(o)return{html:e,redirect:o,cookies:s,status:a,headers:i};let{extractStreamBoundaries:c}=await import("./chunk-37hm4er5.js"),f=c(r),l=t.streamTemplates;if(l&&Object.keys(l).length>0){let{processDirectives:g}=await import("./chunk-wrghqec5.js"),{defaultConfig:d}=await import("./chunk-hzjk2027.js"),h=r.streamBoundaries||{},S={...d,autoShell:!1},b=Object.keys(l).map((p)=>({id:p,render:async()=>{let y=typeof h[p]==="function"?await h[p]():void 0;return g(l[p],{...r,$boundary:y},t.sourceFile,S,new Set)}})),R=new Set(b.map((p)=>p.id));f=[...(f||[]).filter((p)=>!R.has(p.id)),...b]}return{html:e,boundaries:f&&f.length>0?f:void 0,cookies:s,status:a,headers:i}}async function Z(t,n){let e={__filename:t.sourceFile,__dirname:t.sourceFile.replace(/[/\\][^/\\]+$/,""),...n};if(!t.hasServerScripts&&!Qr(t.html))return{html:t.html,context:e};for(let a of t.serverScriptContent)try{await u(a,e,t.sourceFile)}catch(i){if(n.__stx_strict_hydration)throw i;console.warn(`[stx] Server script error in ${t.sourceFile}:`,i)}let r=await I(e,{request:n.request,method:n.method,params:n.params??{},cookies:n.cookies??{}}),o=(a)=>{let i=a.replace(/<script\b[^>]*\bdata-stx-server-data\b[^>]*>[\s\S]*?<\/script>/gi,""),c=Kn(e);if(!c)return i;let f=i.indexOf("</head>");return f<0?c+i:i.slice(0,f)+c+i.slice(f)};if(r.redirect)return{html:t.html,context:e,redirect:r.redirect,cookies:r.cookies};if(!Qr(t.html))return{html:o(t.html),context:e,cookies:r.cookies};let s=new Map;for(let[a,i]of Object.entries(t.placeholders))if(i.expression)try{let c=x(i.expression,e);if(i.type==="raw")s.set(a,c!==void 0&&c!==null?String(c):"");else s.set(a,c!==void 0&&c!==null?St(String(c)):"")}catch(c){if(n.__stx_strict_hydration)throw c;s.set(a,"")}return{html:o(qo(t.html,s)),context:e,cookies:r.cookies}}
30
- export{io,Ae,ao,ne,_,co,Cr,An,me,lo,re,uo,po,fo,Er,go,Ot};
29
+ `)}function E(t,n,e={}){let r=`${encodeURIComponent(t)}=${encodeURIComponent(n)}`;if(e.maxAge!==void 0)r+=`; Max-Age=${e.maxAge}`;if(e.expires)r+=`; Expires=${e.expires.toUTCString()}`;if(e.path)r+=`; Path=${e.path}`;if(e.domain)r+=`; Domain=${e.domain}`;if(e.secure)r+="; Secure";if(e.httpOnly)r+="; HttpOnly";if(e.sameSite)r+=`; SameSite=${e.sameSite}`;return r}async function J(t){let n=t.headers.get("content-type")||"",e={},r=(o,s)=>{let a=e[o];if(a===void 0)e[o]=s;else if(Array.isArray(a))a.push(s);else e[o]=[a,s]};if(n.includes("multipart/form-data")){let o=await t.formData();for(let[s,a]of o.entries())if(typeof a==="string")r(s,a);return e}if(n.includes("application/x-www-form-urlencoded")){for(let[o,s]of new URLSearchParams(await t.text()).entries())r(o,s);return e}return e}function Er(t){if(!t)return!1;let n=t.toUpperCase();return n!=="GET"&&n!=="HEAD"}async function I(t,n={}){let e=n.request,r=n.method??e?.method;if(!e||!Er(r))return{ran:!1};if(typeof t.action!=="function")return{ran:!1};let o={};try{o=await J(e)}catch{}let s=await t.action({request:e,form:o,params:n.params??{},query:t.query??{},cookies:n.cookies??{}});if(s&&typeof s==="object"){let a=s,i=K(a.cookies),c=a.redirect;if(typeof c==="string"&&c)return{redirect:c,ran:!0,...i.length>0?{cookies:i}:{}};let{cookies:f,redirect:l,...g}=a;if(Object.assign(t,g),i.length>0)return{ran:!0,cookies:i}}return{ran:!0}}function K(t){if(!t||typeof t!=="object"||Array.isArray(t))return[];let n=[];for(let[e,r]of Object.entries(t)){if(!e)continue;if(typeof r==="string"){n.push(E(e,r));continue}if(r&&typeof r==="object"){let o=r;if(typeof o.value!=="string")continue;n.push(E(e,o.value,o))}}return n}function go(t,n=[],e){let r=new Headers({Location:t,"Cache-Control":"no-store"});for(let o of n)r.append("Set-Cookie",o);for(let[o,s]of Object.entries(e??{}))if(o.toLowerCase()!=="location")r.set(o,s);return new Response(null,{status:303,headers:r})}import _ from"fs";import j from"path";function uo(t,n,e){return{version:1,buildTime:new Date().toISOString(),routes:t,assets:n,outputDir:e}}function po(t,n){let e=j.join(n,"manifest.json");_.writeFileSync(e,JSON.stringify(t,null,2))}function fo(t){let n=j.join(t,"manifest.json");if(!_.existsSync(n))return null;try{let e=_.readFileSync(n,"utf-8"),r=JSON.parse(e);if(r.version!==1)return console.warn(`[stx] Manifest version mismatch: expected 1, got ${r.version}`),null;return r}catch(e){return console.warn("[stx] Failed to load manifest:",e),null}}async function Ot(t,n={}){let{html:e,context:r,redirect:o,cookies:s}=await Z(t,n),a=Fe(r),i=ze(r);if(o)return{html:e,redirect:o,cookies:s,status:a,headers:i};let{extractStreamBoundaries:c}=await import("./chunk-nnrtwpvy.js"),f=c(r),l=t.streamTemplates;if(l&&Object.keys(l).length>0){let{processDirectives:g}=await import("./chunk-9xw416q3.js"),{defaultConfig:d}=await import("./chunk-dv94gdv4.js"),h=r.streamBoundaries||{},S={...d,autoShell:!1},b=Object.keys(l).map((p)=>({id:p,render:async()=>{let y=typeof h[p]==="function"?await h[p]():void 0;return g(l[p],{...r,$boundary:y},t.sourceFile,S,new Set)}})),R=new Set(b.map((p)=>p.id));f=[...(f||[]).filter((p)=>!R.has(p.id)),...b]}return{html:e,boundaries:f&&f.length>0?f:void 0,cookies:s,status:a,headers:i}}async function Z(t,n){let e={__filename:t.sourceFile,__dirname:t.sourceFile.replace(/[/\\][^/\\]+$/,""),...n};if(!t.hasServerScripts&&!Qr(t.html))return{html:t.html,context:e};for(let a of t.serverScriptContent)try{await u(a,e,t.sourceFile)}catch(i){if(n.__stx_strict_hydration)throw i;console.warn(`[stx] Server script error in ${t.sourceFile}:`,i)}let r=await I(e,{request:n.request,method:n.method,params:n.params??{},cookies:n.cookies??{}}),o=(a)=>{let i=a.replace(/<script\b[^>]*\bdata-stx-server-data\b[^>]*>[\s\S]*?<\/script>/gi,""),c=Kn(e);if(!c)return i;let f=i.indexOf("</head>");return f<0?c+i:i.slice(0,f)+c+i.slice(f)};if(r.redirect)return{html:t.html,context:e,redirect:r.redirect,cookies:r.cookies};if(!Qr(t.html))return{html:o(t.html),context:e,cookies:r.cookies};let s=new Map;for(let[a,i]of Object.entries(t.placeholders))if(i.expression)try{let c=x(i.expression,e);if(i.type==="raw")s.set(a,c!==void 0&&c!==null?String(c):"");else s.set(a,c!==void 0&&c!==null?St(String(c)):"")}catch(c){if(n.__stx_strict_hydration)throw c;s.set(a,"")}return{html:o(qo(t.html,s)),context:e,cookies:r.cookies}}
30
+ export{io,Ae,ao,ne,T,co,Cr,An,me,lo,re,uo,po,fo,Er,go,Ot};
@@ -0,0 +1,3 @@
1
+ // @bun
2
+ import u from"fs";import l from"path";var m=/\b(?:state|derived|effect|ref|reactive|computed|watch|watchEffect|useModel)\s*(?:<[^<>()]*>)?\s*\(/,g=/(?:^|\n)\s*(?:import|export)\s+(?:[^'"]*?\sfrom\s+)?['"](\.[^'"]*)['"]/g,b=["",".ts",".tsx",".js",".jsx",".mts",".mjs","/index.ts","/index.js"],x=3;function h(e,t){let r=l.resolve(l.dirname(t),e);for(let o of b){let s=r+o;try{if(u.statSync(s).isFile())return s}catch{}}return null}function wn(e,t,r=0,o=new Set){if(!t||r>=x)return!1;for(let s of e.matchAll(g)){let n=h(s[1],t);if(!n||o.has(n))continue;o.add(n);let i;try{i=u.readFileSync(n,"utf8")}catch{continue}if(m.test(i))return!0;if(wn(i,n,r+1,o))return!0}return!1}var y=["batch","cachedQuery","clearServerData","computed","configureFetch","defineEmits","defineExpose","definePageMeta","defineProps","defineSlots","defineStore","derived","effect","flushKeptState","forgetKeptState","goBack","goForward","inject","invalidateRoute","isDerived","isSignal","keptState","navigate","nextTick","onBeforeMount","onBeforeUnmount","onDestroy","onMount","onMounted","onUnmounted","peek","provide","reactive","ref","refDebounced","refresh","registerStoresClient","setKeptScope","setRouteParams","state","untrack","useAsync","useClickOutside","useColorMode","useCookie","useCounter","useDark","useDebounce","useDebounceFn","useDebouncedValue","useDocumentVisibility","useEventListener","useFetch","useFocus","useHead","useId","useInterval","useLocalStorage","useMediaQuery","useModel","useMutation","useOptimistic","usePreferredContrast","usePreferredDark","usePreferredLight","usePreferredReducedMotion","useQuery","useReactiveProp","useRef","useRoute","useRouteParam","useRouteParams","useScrollLock","useSearchParams","useSeoMeta","useSessionStorage","useSlots","useStore","useThrottle","useThrottleFn","useTimeout","useTimeoutFn","useToggle","useWebSocket","watch","watchEffect","watchMultiple","withDefaults"],Pi=["onMount","onDestroy"];function Pt(e="const",t=[],r){let o=t.length?y.filter((s)=>!t.includes(s)):y;if(r!==void 0)o=o.filter((s)=>{let n=s.replace(/[$()*+.?[\\\]^{|}-]/g,"\\$&");return new RegExp(`(^|[^\\w$])${n}(?![\\w$])`).test(r)});return`${e} { ${o.join(", ")} } = window.stx;`}var E=["defineEmits","defineExpose","definePageMeta","defineProps","defineSlots","withDefaults"];var S=y.filter((e)=>!E.includes(e));function Ls(e){if(!e)return!1;return S.some((t)=>new RegExp(`\\b${t}\\s*(?:<[^>]*>)?\\s*\\(`).test(e))}var v=[/@if\s*=/,/@for\s*=/,/@show\s*=/,/@model\s*=/,/@bind:/,/@class\s*=/,/@style\s*=/,/\bx-data\s*=/,/\bstate\s*(?:<[^>]*>)?\s*\(/,/\bderived\s*(?:<[^>]*>)?\s*\(/,/\beffect\s*(?:<[^>]*>)?\s*\(/,/\bref\s*(?:<[^>]*>)?\s*\(/,/\bcomputed\s*(?:<[^>]*>)?\s*\(/,/\breactive\s*(?:<[^>]*>)?\s*\(/,/\bwatch\s*(?:<[^>]*>)?\s*\(/,/\bwatchEffect\s*(?:<[^>]*>)?\s*\(/,/\s:[a-z][\w-]*\s*=\s*["']/i,/\s:(?:if|else-if|else|for|show|text|html|model)\s*=/,/data-stx(?:-auto)?(?![-\w])/,/data-stx-scoped/],T=/\s@[a-z][\w.:-]*\s*=/i;function Ii(e,t){if(!e)return!1;let r=f(e);return d(r,t)}function d(e,t){if(v.some((r)=>r.test(e)))return!0;if(Ls(e))return!0;return R(e,t)}function R(e,t){if(!t)return!1;for(let r of e.matchAll(/<script\b(?![^>]*\bserver\b)(?![^>]*\bsrc\s*=)[^>]*>([\s\S]*?)<\/script\s*>/gi))if(wn(r[1],t))return!0;return!1}function Di(e,t){if(!e)return!1;let r=f(e);return T.test(r)||d(r,t)}var _=["if","else-if","elseif","else","for","show","key","text","html","model","ref"];function Oi(e){return _.includes(e.toLowerCase())}var cr=["x-text","x-html","x-model","x-show","x-if","x-for","x-cloak","x-ref","x-data","x-bind","x-class","x-style","x-tooltip","x-tooltip-position"],w=["x-init","x-transition","x-effect","x-on"],Mi=[...cr,...w];function Ni(){return`{${cr.map((e)=>`'${e}':1`).join(",")}}`}var js=["class","style","text","html","show","model","if","ref"];function Li(){return`{${js.map((e)=>e==="if"?"'if':1":`${e}:1`).join(",")}}`}var p=["click","dblclick","mousedown","mouseup","mousemove","mouseenter","mouseleave","keydown","keyup","keypress","input","change","submit","focus","blur","scroll","resize","touchstart","touchend","touchmove","contextmenu","wheel","pointerdown","pointerup","pointermove"];function ji(){return`/^(${p.join("|")})(?:\\.|$)/`}function Bi(e){return p.some((t)=>e===t||e.startsWith(`${t}.`))}var A=65536,N=4,c=new Map;function f(e){if(!e)return e;if(!e.includes("<!--")&&!/<(?:pre|code)\b/i.test(e))return e;let t=e.length>=A;if(t){let s=c.get(e);if(s!==void 0)return s}let r=(s)=>s.replace(/(<[^>]*>)|([^<]+)/g,(n,i,a)=>i??" ".repeat(a.length)),o=e.replace(/(<pre\b[^>]*>)([\s\S]*?)(<\/pre>)/gi,(s,n,i,a)=>n+r(i)+a).replace(/(<code\b[^>]*>)([\s\S]*?)(<\/code>)/gi,(s,n,i,a)=>n+r(i)+a).replace(/<!--[\s\S]*?-->/g,(s)=>" ".repeat(s.length));if(t){while(c.size>=N){let s=c.keys().next();if(s.done)break;c.delete(s.value)}c.set(e,o)}return o}
3
+ export{wn,y,Pi,Pt,Ls,Ii,Di,Oi,cr,Mi,Ni,js,Li,ji,Bi};
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{O}from"./chunk-vtxzaj1h.js";var t={UNCLOSED_DIRECTIVE:1001,UNCLOSED_EXPRESSION:1002,INVALID_DIRECTIVE_SYNTAX:1003,MALFORMED_EXPRESSION:1004,UNEXPECTED_TOKEN:1005,UNDEFINED_VARIABLE:1101,TYPE_ERROR:1102,EVALUATION_ERROR:1103,INFINITE_LOOP:1104,CIRCULAR_REFERENCE:1105,UNSAFE_EXPRESSION:1201,PATH_TRAVERSAL:1202,XSS_ATTEMPT:1203,CODE_INJECTION:1204,DOM_API_VIOLATION:1205,FILE_NOT_FOUND:1301,FILE_READ_ERROR:1302,INVALID_FILE_PATH:1303,PERMISSION_DENIED:1304,INVALID_CONFIG:1401,MISSING_REQUIRED_CONFIG:1402,DEPRECATED_CONFIG:1403,COMPONENT_NOT_FOUND:1501,INVALID_PROPS:1502,COMPONENT_RENDER_ERROR:1503,FILTER_NOT_FOUND:1601,INVALID_FILTER_ARGS:1602,EXPRESSION_TIMEOUT:1603};function N(e){for(let[r,n]of Object.entries(t))if(n===e)return r;return}import ee from"path";var re={showRelativePaths:!1,enableAutoRecovery:O(),logRecoveryWarnings:!0},P={...re};function R(){return{...P}}function k(e){if(!P.showRelativePaths||!e)return e;let r=P.baseDir||process.cwd();try{let n=ee.relative(r,e);return n.startsWith("..")?e:n}catch{return e}}class v extends Error{code;filePath;line;column;context;numericCode;constructor(e,r,n,o,s,a,g){super(e);this.code=r;this.filePath=n;this.line=o;this.column=s;this.context=a;if(this.name="StxError",this.numericCode=g||t.EVALUATION_ERROR,this.filePath)this.filePath=k(this.filePath)}}class X extends v{constructor(e,r,n,o,s,a){super(e,"stx_RUNTIME_ERROR",r,n,o,s,a||t.EVALUATION_ERROR);this.name="StxRuntimeError"}}class yn extends v{constructor(e,r,n,o,s,a){super(e,"stx_FILE_ERROR",r,n,o,s,a||t.FILE_NOT_FOUND);this.name="StxFileError"}}class ir extends v{isFatal=!0;constructor(e,r,n,o,s,a){super(e,"stx_VALIDATION_ERROR",r,n,o,s,a||t.DOM_API_VIOLATION);this.name="StxValidationError"}}function U(e){let{type:r,message:n,code:o,filePath:s,line:a,column:g,template:u,offset:d,snippet:f,suggestion:m,format:h="text"}=e,E=a,x=g;if(!E&&u&&d!==void 0){let z=ce(u,d);E=z.line,x=z.column}let y=s?k(s):void 0,K=o?N(o):void 0,w={type:r,code:o,codeName:K,message:n,filePath:y,line:E,column:x,snippet:f,suggestion:m,timestamp:new Date().toISOString()},S;switch(h){case"html":S=oe(w);break;case"json":S=JSON.stringify(w,null,2);break;case"console":S=ie(w,u,d);break;case"text":default:S=ne(w,u,d);break}return{formatted:S,data:w}}function ne(e,r,n){let o=[],s=e.code?` [${e.codeName||e.code}]`:"";if(o.push(`[${e.type} Error${s}]`),e.filePath){let a=e.filePath;if(e.line){if(a+=`:${e.line}`,e.column)a+=`:${e.column}`}o.push(`at ${a}`)}if(o.push(`
2
+ import{O}from"./chunk-vtxzaj1h.js";var t={UNCLOSED_DIRECTIVE:1001,UNCLOSED_EXPRESSION:1002,INVALID_DIRECTIVE_SYNTAX:1003,MALFORMED_EXPRESSION:1004,UNEXPECTED_TOKEN:1005,UNDEFINED_VARIABLE:1101,TYPE_ERROR:1102,EVALUATION_ERROR:1103,INFINITE_LOOP:1104,CIRCULAR_REFERENCE:1105,UNSAFE_EXPRESSION:1201,PATH_TRAVERSAL:1202,XSS_ATTEMPT:1203,CODE_INJECTION:1204,DOM_API_VIOLATION:1205,FILE_NOT_FOUND:1301,FILE_READ_ERROR:1302,INVALID_FILE_PATH:1303,PERMISSION_DENIED:1304,INVALID_CONFIG:1401,MISSING_REQUIRED_CONFIG:1402,DEPRECATED_CONFIG:1403,COMPONENT_NOT_FOUND:1501,INVALID_PROPS:1502,COMPONENT_RENDER_ERROR:1503,FILTER_NOT_FOUND:1601,INVALID_FILTER_ARGS:1602,EXPRESSION_TIMEOUT:1603};function N(e){for(let[r,n]of Object.entries(t))if(n===e)return r;return}import ee from"path";var re={showRelativePaths:!1,enableAutoRecovery:O(),logRecoveryWarnings:!0},L={...re};function R(){return{...L}}function k(e){if(!L.showRelativePaths||!e)return e;let r=L.baseDir||process.cwd();try{let n=ee.relative(r,e);return n.startsWith("..")?e:n}catch{return e}}class v extends Error{code;filePath;line;column;context;numericCode;constructor(e,r,n,o,s,a,g){super(e);this.code=r;this.filePath=n;this.line=o;this.column=s;this.context=a;if(this.name="StxError",this.numericCode=g||t.EVALUATION_ERROR,this.filePath)this.filePath=k(this.filePath)}}class X extends v{constructor(e,r,n,o,s,a){super(e,"stx_RUNTIME_ERROR",r,n,o,s,a||t.EVALUATION_ERROR);this.name="StxRuntimeError"}}class yn extends v{constructor(e,r,n,o,s,a){super(e,"stx_FILE_ERROR",r,n,o,s,a||t.FILE_NOT_FOUND);this.name="StxFileError"}}class ir extends v{isFatal=!0;constructor(e,r,n,o,s,a){super(e,"stx_VALIDATION_ERROR",r,n,o,s,a||t.DOM_API_VIOLATION);this.name="StxValidationError"}}function U(e){let{type:r,message:n,code:o,filePath:s,line:a,column:g,template:u,offset:d,snippet:f,suggestion:m,format:h="text"}=e,E=a,x=g;if(!E&&u&&d!==void 0){let z=ce(u,d);E=z.line,x=z.column}let y=s?k(s):void 0,K=o?N(o):void 0,w={type:r,code:o,codeName:K,message:n,filePath:y,line:E,column:x,snippet:f,suggestion:m,timestamp:new Date().toISOString()},S;switch(h){case"html":S=oe(w);break;case"json":S=JSON.stringify(w,null,2);break;case"console":S=ie(w,u,d);break;case"text":default:S=ne(w,u,d);break}return{formatted:S,data:w}}function ne(e,r,n){let o=[],s=e.code?` [${e.codeName||e.code}]`:"";if(o.push(`[${e.type} Error${s}]`),e.filePath){let a=e.filePath;if(e.line){if(a+=`:${e.line}`,e.column)a+=`:${e.column}`}o.push(`at ${a}`)}if(o.push(`
3
3
  ${e.message}`),r&&e.line){let a=se(r,e.line,2);if(a)o.push(`
4
4
  ${a}`)}if(e.snippet)o.push(`
5
5
  Snippet: ${e.snippet}`);if(e.suggestion)o.push(`
@@ -18,14 +18,14 @@ ${"\x1B[31m"}\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\
18
18
  `),s=Math.max(0,r-n-1),a=Math.min(o.length-1,r+n-1),g="\x1B[90m",u="\x1B[31m",d="\x1B[0m",f=[];for(let m=s;m<=a;m++){let h=(m+1).toString().padStart(4),E=m===r-1,x=E?"\x1B[31m>\x1B[0m":" ",y=E?`\x1B[31m${o[m]}\x1B[0m`:`\x1B[90m${o[m]}\x1B[0m`;f.push(`${x}\x1B[90m${h}\x1B[0m | ${y}`)}return f.join(`
19
19
  `)}function M(e){return e.replace(/--/g,"- -").replace(/>/g,"&gt;")}function ce(e,r){let o=e.substring(0,r).split(`
20
20
  `);return{line:o.length,column:o[o.length-1].length}}function i(e,r,n){return U({type:e,message:r,code:n,format:"html"}).formatted}async function te(e,r,n){try{return await e()}catch(o){if(n&&o instanceof Error)n(o);return r}}var Os={isEnabled(){return R().enableAutoRecovery},fixCommonSyntaxErrors(e){let r=R();if(!r.enableAutoRecovery)return{fixed:e,fixes:[]};let n=e,o=[],s=(n.match(/\{\{/g)||[]).length,a=(n.match(/\}\}/g)||[]).length;if(s>a){let u=s-a;n+="}}".repeat(u),o.push(`Added ${u} missing closing braces '}}'`)}let g=["if","foreach","for","switch","section"];for(let u of g){let d=(n.match(new RegExp(`@${u}\\b`,"g"))||[]).length,f=(n.match(new RegExp(`@end${u}\\b`,"g"))||[]).length;if(d>f){let m=d-f;for(let h=0;h<m;h++)n+=`
21
- @end${u}`;o.push(`Added ${m} missing @end${u}`)}}if(o.length>0&&r.logRecoveryWarnings)console.warn("[stx] Auto-recovery applied fixes:"),o.forEach((u)=>console.warn(` - ${u}`)),console.warn(" Consider fixing these issues in your template.");return{fixed:n,fixes:o}},createFallbackContent(e,r){if(O())return`<!-- ${e} failed: ${r.message} -->`;return"<!-- stx rendering error -->"}};class L{errors=[];maxErrors;enableFileLogging;logFilePath;logFormat;maxFileSize;maxLogFiles;minLevel;writeQueue=Promise.resolve();constructor(e={}){this.maxErrors=e.maxErrors??1000,this.enableFileLogging=e.enableFileLogging??!1,this.logFilePath=e.logFilePath??".stx/errors.log",this.logFormat=e.logFormat??"json",this.maxFileSize=e.maxFileSize??10485760,this.maxLogFiles=e.maxLogFiles??5,this.minLevel=e.minLevel??"all"}configure(e){if(e.maxErrors!==void 0)this.maxErrors=e.maxErrors;if(e.enableFileLogging!==void 0)this.enableFileLogging=e.enableFileLogging;if(e.logFilePath!==void 0)this.logFilePath=e.logFilePath;if(e.logFormat!==void 0)this.logFormat=e.logFormat;if(e.maxFileSize!==void 0)this.maxFileSize=e.maxFileSize;if(e.maxLogFiles!==void 0)this.maxLogFiles=e.maxLogFiles;if(e.minLevel!==void 0)this.minLevel=e.minLevel}log(e,r,n="error"){let o={timestamp:new Date,error:e,context:r,level:n};if(this.errors.push(o),this.errors.length>this.maxErrors)this.errors=this.errors.slice(-this.maxErrors);if(this.enableFileLogging&&this.shouldLog(n))this.writeToFile(o)}shouldLog(e){if(this.minLevel==="all")return!0;if(this.minLevel==="warning")return e==="error"||e==="warning";if(this.minLevel==="error")return e==="error";return!0}formatEntry(e){if(this.logFormat==="json")return JSON.stringify({timestamp:e.timestamp.toISOString(),level:e.level||"error",type:e.error.constructor.name,message:e.error.message,stack:e.error.stack,context:e.context});let r=[`[${e.timestamp.toISOString()}] [${(e.level||"error").toUpperCase()}] ${e.error.constructor.name}: ${e.error.message}`];if(e.error.stack)r.push(` Stack: ${e.error.stack.split(`
21
+ @end${u}`;o.push(`Added ${m} missing @end${u}`)}}if(o.length>0&&r.logRecoveryWarnings)console.warn("[stx] Auto-recovery applied fixes:"),o.forEach((u)=>console.warn(` - ${u}`)),console.warn(" Consider fixing these issues in your template.");return{fixed:n,fixes:o}},createFallbackContent(e,r){if(O())return`<!-- ${e} failed: ${r.message} -->`;return"<!-- stx rendering error -->"}};class I{errors=[];maxErrors;enableFileLogging;logFilePath;logFormat;maxFileSize;maxLogFiles;minLevel;writeQueue=Promise.resolve();constructor(e={}){this.maxErrors=e.maxErrors??1000,this.enableFileLogging=e.enableFileLogging??!1,this.logFilePath=e.logFilePath??".stx/errors.log",this.logFormat=e.logFormat??"json",this.maxFileSize=e.maxFileSize??10485760,this.maxLogFiles=e.maxLogFiles??5,this.minLevel=e.minLevel??"all"}configure(e){if(e.maxErrors!==void 0)this.maxErrors=e.maxErrors;if(e.enableFileLogging!==void 0)this.enableFileLogging=e.enableFileLogging;if(e.logFilePath!==void 0)this.logFilePath=e.logFilePath;if(e.logFormat!==void 0)this.logFormat=e.logFormat;if(e.maxFileSize!==void 0)this.maxFileSize=e.maxFileSize;if(e.maxLogFiles!==void 0)this.maxLogFiles=e.maxLogFiles;if(e.minLevel!==void 0)this.minLevel=e.minLevel}log(e,r,n="error"){let o={timestamp:new Date,error:e,context:r,level:n};if(this.errors.push(o),this.errors.length>this.maxErrors)this.errors=this.errors.slice(-this.maxErrors);if(this.enableFileLogging&&this.shouldLog(n))this.writeToFile(o)}shouldLog(e){if(this.minLevel==="all")return!0;if(this.minLevel==="warning")return e==="error"||e==="warning";if(this.minLevel==="error")return e==="error";return!0}formatEntry(e){if(this.logFormat==="json")return JSON.stringify({timestamp:e.timestamp.toISOString(),level:e.level||"error",type:e.error.constructor.name,message:e.error.message,stack:e.error.stack,context:e.context});let r=[`[${e.timestamp.toISOString()}] [${(e.level||"error").toUpperCase()}] ${e.error.constructor.name}: ${e.error.message}`];if(e.error.stack)r.push(` Stack: ${e.error.stack.split(`
22
22
  `).slice(1).join(`
23
23
  `)}`);if(e.context)r.push(` Context: ${JSON.stringify(e.context)}`);return r.join(`
24
24
  `)}writeToFile(e){this.writeQueue=this.writeQueue.then(async()=>{try{let r=await import("fs"),n=await import("path"),o=n.dirname(this.logFilePath);if(!r.existsSync(o))r.mkdirSync(o,{recursive:!0});await this.rotateIfNeeded(r);let s=`${this.formatEntry(e)}
25
25
  `;r.appendFileSync(this.logFilePath,s,"utf-8")}catch(r){if(process.env.STX_DEBUG==="true")console.error("Failed to write to error log:",r)}})}async rotateIfNeeded(e){try{if(!e.existsSync(this.logFilePath))return;if(e.statSync(this.logFilePath).size<this.maxFileSize)return;for(let n=this.maxLogFiles-1;n>=1;n--){let o=`${this.logFilePath}.${n}`,s=`${this.logFilePath}.${n+1}`;if(e.existsSync(o))if(n>=this.maxLogFiles-1)e.unlinkSync(o);else e.renameSync(o,s)}if(this.maxLogFiles<=1)e.writeFileSync(this.logFilePath,"");else e.renameSync(this.logFilePath,`${this.logFilePath}.1`)}catch(r){if(process.env.STX_DEBUG==="true")console.error("Failed to rotate error logs:",r)}}getRecentErrors(e=10){return this.errors.slice(-e)}getErrorsByType(e){return this.errors.filter((r)=>r.error.constructor.name===e)}getErrorsByLevel(e){return this.errors.filter((r)=>r.level===e)}clear(){this.errors.length=0}async clearLogFile(){try{let e=await import("fs");if(e.existsSync(this.logFilePath))e.writeFileSync(this.logFilePath,"","utf-8")}catch(e){if(process.env.STX_DEBUG==="true")console.error("Failed to clear error log:",e)}}getStats(){let e={},r={error:0,warning:0,info:0};for(let n of this.errors){let o=n.error.constructor.name;e[o]=(e[o]||0)+1;let s=n.level||"error";r[s]=(r[s]||0)+1}return{total:this.errors.length,byType:e,byLevel:r}}async exportToFile(e,r="json"){let n=await import("fs"),o=await import("path"),s=o.dirname(e);if(!n.existsSync(s))n.mkdirSync(s,{recursive:!0});if(r==="json"){let a=this.errors.map((g)=>({timestamp:g.timestamp.toISOString(),level:g.level||"error",type:g.error.constructor.name,message:g.error.message,stack:g.error.stack,context:g.context}));n.writeFileSync(e,JSON.stringify(a,null,2),"utf-8")}else{let a=this.errors.map((g)=>this.formatEntry(g));n.writeFileSync(e,a.join(`
26
26
 
27
- `),"utf-8")}}async flush(){await this.writeQueue}}var A=new L,Rt={isDevelopment(){return O()},logDetailedError(e,r){if(!this.isDevelopment())return;if(console.error("=== stx Detailed Error ==="),console.error("Error:",e.message),console.error("Stack:",e.stack),r)console.error("Context:",r);console.error("========================")},createErrorReport(e,r){let n=["=== stx Error Report ===",`Time: ${new Date().toISOString()}`,`Error: ${e.message}`,`Type: ${e.constructor.name}`,`Stack: ${e.stack}`];if(r)n.push(`Context: ${JSON.stringify(r,null,2)}`);return n.push("========================"),n.join(`
28
- `)}};var le={maxSanitizeDepth:10,allowBracketNotation:!1},G={...le};var C=/\bnew\s+/,F="__stx_safe_ctors",H=[/\b(eval|Function|setTimeout|setInterval|setImmediate)\b/,/\b(process|require|import|exports|module)\b/,/\b(window|document|global|globalThis)\b/,/\b(constructor|prototype|__proto__)\b/,/\b(Reflect|Proxy)\b/,/\bSymbol\b/,/\b(WeakMap|WeakSet|WeakRef|FinalizationRegistry)\b/,/\b(Generator|AsyncGenerator)\b/,/__\w+__/,/\.(bind|call|apply)\s*\(/,C,/\bdelete\s+/,/\bthis\b/],ue=new Set(["eval","Function","setTimeout","setInterval","setImmediate","process","require","import","exports","module","window","document","global","globalThis","constructor","prototype","Reflect","Proxy","Symbol","WeakMap","WeakSet","WeakRef","FinalizationRegistry","Generator","AsyncGenerator","delete","this",F]),q=new Set(["__proto__","constructor","prototype"]),ge=/[\w)\]]\s*\[\s*['"]/;function J(e){let r="",n=[],o=null,s=!1;for(let a=0;a<e.length;a++){let g=e[a];if(s){s=!1;continue}if(g==="\\"&&o){s=!0;continue}if(o){if(o==="`"&&g==="$"&&a+1<e.length&&e[a+1]==="{"){let u=1;a+=2;while(a<e.length&&u>0){if(e[a]==="{")u++;else if(e[a]==="}")u--;if(u>0)r+=e[a],n.push(a),a++}continue}if(g===o)o=null;continue}if(g==='"'||g==="'"||g==="`"){o=g;continue}r+=g,n.push(a)}return{text:r,map:n}}function fe(e){return J(e).text}var Y=["Collator","DateTimeFormat","DisplayNames","ListFormat","Locale","NumberFormat","PluralRules","RelativeTimeFormat","Segmenter"],Z=(()=>{let e={Date,URL,URLSearchParams},r=Intl;for(let n of Y)if(typeof r[n]==="function")e[`Intl_${n}`]=r[n];return Object.freeze(Object.assign(Object.create(null),e))})(),me=/^new(\s+)(Date|URLSearchParams|URL|Intl\s*\.\s*([A-Z_a-z]\w*))\s*\(/,j=/(?<![\w$])new(?![\w$])/g,B=`only new Date(), new URL(), new URLSearchParams() and new Intl.{${Y.join(",")}}() are allowed`;function pe(e){let{text:r,map:n}=J(e),o=[];j.lastIndex=0;let s;while((s=j.exec(r))!==null){let g=s.index;if(/(?<!\.)\.\s*$/.test(r.slice(0,g)))continue;let u=me.exec(r.slice(g)),d=u?.[3],f=!u?null:d?`Intl_${d}`:u[2];if(!u||!f||!(f in Z))throw new b(`matched /${C.source}/; ${B}`,e);let m=g+u[0].length,h=n[g],E=n[m-1]+1;if(e.slice(h,E)!==r.slice(g,m))throw new b(`matched /${C.source}/; ${B}`,e);let x=h+3+u[1].length;o.push({start:x,end:x+u[2].length,key:f})}let a=e;for(let g=o.length-1;g>=0;g--){let u=o[g];a=`${a.slice(0,u.start)}${F}.${u.key}${a.slice(u.end)}`}return{source:a,usesSafeConstructors:o.length>0}}class b extends Error{rule;expression;constructor(e,r,n){super(n??`Potentially unsafe expression (${e}): ${r}`);this.name="UnsafeExpressionError",this.rule=e,this.expression=r}}function bn(e){try{return T(e),null}catch(r){return r instanceof b?r.rule:r instanceof Error?r.message:String(r)}}function de(e,r){let n=/[$A-Z_a-z][$\w]*/g,o;while((o=n.exec(e))!==null){let s=o[0],a=e[o.index-1];if(ue.has(s))throw new b(`matched /\\b${s}\\b/; identifier ${s}`,r);if(a==="."&&q.has(s))throw new b(`matched /.${s}/; property ${s}`,r)}}function he(e){let r=/\[\s*(['"])(.*?)\1\s*\]/g,n;while((n=r.exec(e))!==null){let o=n[2];if(!q.has(o))continue;let s=e.slice(0,n.index).match(/\S(?=\s*$)/)?.[0],a=e.slice(n.index+n[0].length).match(/^\s*(\S)/)?.[1];if(!((s==="{"||s===",")&&a===":"))throw new b(`bracket key ${n[2]}`,e)}}function T(e){let r=e.trim(),n=fe(r);de(n,r),he(r);for(let o of H){if(o===C)continue;if(o.test(n))throw new b(`matched /${o.source}/`,r)}if(!G.allowBracketNotation&&ge.test(r))throw new b("bracket notation with a string key; enable with configureSafeEvaluator({ allowBracketNotation: true })",r,`Bracket notation with strings not allowed: ${r}. Enable with configureSafeEvaluator({ allowBracketNotation: true })`);return pe(r)}function Ms(e){return T(e),e.trim()}function Ns(e){let r={};r.Math=Math,r.JSON=JSON,r.Date=Date,r.String=String,r.Number=Number,r.Boolean=Boolean,r.Array=Array,r.parseInt=Number.parseInt,r.parseFloat=Number.parseFloat,r.isNaN=Number.isNaN,r.isFinite=Number.isFinite,r.encodeURIComponent=encodeURIComponent,r.decodeURIComponent=decodeURIComponent;for(let[n,o]of Object.entries(e)){if(n.startsWith("__")||H.some((s)=>s.test(n)))continue;if(o&&typeof o==="object"&&!Array.isArray(o))r[n]=I(o);else r[n]=o}return r}function I(e,r=0){if(r>=G.maxSanitizeDepth)return"[Object too deep]";if(e===null||typeof e!=="object")return e;if(Array.isArray(e))return e.map((o)=>I(o,r+1));if(e instanceof Date||e instanceof RegExp||e instanceof Map||e instanceof Set||e instanceof Error)return e;let n={};for(let[o,s]of Object.entries(e)){if(o.startsWith("__")||o==="constructor"||o==="prototype")continue;if(s&&typeof s==="object")n[o]=I(s,r+1);else n[o]=s}return n}function c(e,r){try{let n=Ns(r),o=Object.keys(n),s=Object.values(n);return l(e,o)(...s)}catch{return}}function p(e){try{return Ms(e),!0}catch{return!1}}function D(e,r){try{let n=c(e,r);if(n&&typeof n==="object"&&!Array.isArray(n))return n;return{}}catch{return{}}}var Q=new Set(["break","case","catch","class","const","continue","debugger","default","delete","do","else","enum","export","extends","false","finally","for","function","if","import","in","instanceof","new","null","return","super","switch","this","throw","true","try","typeof","var","void","while","with","yield","let","static","implements","interface","package","private","protected","public","arguments","eval","await"]),Ee=2000,_=new Map;function V(e,r){let n=`${e.join(",")}\x00${r}`,o=_.get(n);if(o)return o;let s=Function(...e,r);if(_.size>=Ee)_.clear();return _.set(n,s),s}function Se(e){return e.replace(/'(?:[^'\\]|\\.)*'|"(?:[^"\\]|\\.)*"|`(?:[^`\\]|\\.)*`/g," ").replace(/\??\.\s*[a-zA-Z_$][\w$]*/g," ").replace(/([{,]\s*)[a-zA-Z_$][\w$]*(\s*:)/g,"$1$2").match(/\b[a-zA-Z_$][\w$]*\b/g)||[]}var xe=/^[A-Za-z_$][\w$]*$/;function Ze(e){return xe.test(e)&&!Q.has(e)}function l(e,r){let{source:n,usesSafeConstructors:o}=T(e),s=[];for(let f=0;f<r.length;f++){if(!Ze(r[f]))continue;if(r[f]===F)continue;s.push({key:r[f],index:f})}s.sort((f,m)=>f.key.localeCompare(m.key));let a=s.map((f)=>f.key),g=s.map((f)=>f.index),u=`
27
+ `),"utf-8")}}async flush(){await this.writeQueue}}var P=new I,Rt={isDevelopment(){return O()},logDetailedError(e,r){if(!this.isDevelopment())return;if(console.error("=== stx Detailed Error ==="),console.error("Error:",e.message),console.error("Stack:",e.stack),r)console.error("Context:",r);console.error("========================")},createErrorReport(e,r){let n=["=== stx Error Report ===",`Time: ${new Date().toISOString()}`,`Error: ${e.message}`,`Type: ${e.constructor.name}`,`Stack: ${e.stack}`];if(r)n.push(`Context: ${JSON.stringify(r,null,2)}`);return n.push("========================"),n.join(`
28
+ `)}};var le={maxSanitizeDepth:10,allowBracketNotation:!1},G={...le};var C=/\bnew\s+/,F="__stx_safe_ctors",H=[/\b(eval|Function|setTimeout|setInterval|setImmediate)\b/,/\b(process|require|import|exports|module)\b/,/\b(window|document|global|globalThis)\b/,/\b(constructor|prototype|__proto__)\b/,/\b(Reflect|Proxy)\b/,/\bSymbol\b/,/\b(WeakMap|WeakSet|WeakRef|FinalizationRegistry)\b/,/\b(Generator|AsyncGenerator)\b/,/__\w+__/,/\.(bind|call|apply)\s*\(/,C,/\bdelete\s+/,/\bthis\b/],ue=new Set(["eval","Function","setTimeout","setInterval","setImmediate","process","require","import","exports","module","window","document","global","globalThis","constructor","prototype","Reflect","Proxy","Symbol","WeakMap","WeakSet","WeakRef","FinalizationRegistry","Generator","AsyncGenerator","delete","this",F]),q=new Set(["__proto__","constructor","prototype"]),ge=/[\w)\]]\s*\[\s*['"]/;function J(e){let r="",n=[],o=null,s=!1;for(let a=0;a<e.length;a++){let g=e[a];if(s){s=!1;continue}if(g==="\\"&&o){s=!0;continue}if(o){if(o==="`"&&g==="$"&&a+1<e.length&&e[a+1]==="{"){let u=1;a+=2;while(a<e.length&&u>0){if(e[a]==="{")u++;else if(e[a]==="}")u--;if(u>0)r+=e[a],n.push(a),a++}continue}if(g===o)o=null;continue}if(g==='"'||g==="'"||g==="`"){o=g;continue}r+=g,n.push(a)}return{text:r,map:n}}function fe(e){return J(e).text}var Y=["Collator","DateTimeFormat","DisplayNames","ListFormat","Locale","NumberFormat","PluralRules","RelativeTimeFormat","Segmenter"],Z=(()=>{let e={Date,URL,URLSearchParams},r=Intl;for(let n of Y)if(typeof r[n]==="function")e[`Intl_${n}`]=r[n];return Object.freeze(Object.assign(Object.create(null),e))})(),me=/^new(\s+)(Date|URLSearchParams|URL|Intl\s*\.\s*([A-Z_a-z]\w*))\s*\(/,j=/(?<![\w$])new(?![\w$])/g,B=`only new Date(), new URL(), new URLSearchParams() and new Intl.{${Y.join(",")}}() are allowed`;function pe(e){let{text:r,map:n}=J(e),o=[];j.lastIndex=0;let s;while((s=j.exec(r))!==null){let g=s.index;if(/(?<!\.)\.\s*$/.test(r.slice(0,g)))continue;let u=me.exec(r.slice(g)),d=u?.[3],f=!u?null:d?`Intl_${d}`:u[2];if(!u||!f||!(f in Z))throw new b(`matched /${C.source}/; ${B}`,e);let m=g+u[0].length,h=n[g],E=n[m-1]+1;if(e.slice(h,E)!==r.slice(g,m))throw new b(`matched /${C.source}/; ${B}`,e);let x=h+3+u[1].length;o.push({start:x,end:x+u[2].length,key:f})}let a=e;for(let g=o.length-1;g>=0;g--){let u=o[g];a=`${a.slice(0,u.start)}${F}.${u.key}${a.slice(u.end)}`}return{source:a,usesSafeConstructors:o.length>0}}class b extends Error{rule;expression;constructor(e,r,n){super(n??`Potentially unsafe expression (${e}): ${r}`);this.name="UnsafeExpressionError",this.rule=e,this.expression=r}}function bn(e){try{return T(e),null}catch(r){return r instanceof b?r.rule:r instanceof Error?r.message:String(r)}}function de(e,r){let n=/[$A-Z_a-z][$\w]*/g,o;while((o=n.exec(e))!==null){let s=o[0],a=e[o.index-1];if(ue.has(s))throw new b(`matched /\\b${s}\\b/; identifier ${s}`,r);if(a==="."&&q.has(s))throw new b(`matched /.${s}/; property ${s}`,r)}}function he(e){let r=/\[\s*(['"])(.*?)\1\s*\]/g,n;while((n=r.exec(e))!==null){let o=n[2];if(!q.has(o))continue;let s=e.slice(0,n.index).match(/\S(?=\s*$)/)?.[0],a=e.slice(n.index+n[0].length).match(/^\s*(\S)/)?.[1];if(!((s==="{"||s===",")&&a===":"))throw new b(`bracket key ${n[2]}`,e)}}function T(e){let r=e.trim(),n=fe(r);de(n,r),he(r);for(let o of H){if(o===C)continue;if(o.test(n))throw new b(`matched /${o.source}/`,r)}if(!G.allowBracketNotation&&ge.test(r))throw new b("bracket notation with a string key; enable with configureSafeEvaluator({ allowBracketNotation: true })",r,`Bracket notation with strings not allowed: ${r}. Enable with configureSafeEvaluator({ allowBracketNotation: true })`);return pe(r)}function Ms(e){return T(e),e.trim()}function Ns(e){let r={};r.Math=Math,r.JSON=JSON,r.Date=Date,r.String=String,r.Number=Number,r.Boolean=Boolean,r.Array=Array,r.parseInt=Number.parseInt,r.parseFloat=Number.parseFloat,r.isNaN=Number.isNaN,r.isFinite=Number.isFinite,r.encodeURIComponent=encodeURIComponent,r.decodeURIComponent=decodeURIComponent;for(let[n,o]of Object.entries(e)){if(n.startsWith("__")||H.some((s)=>s.test(n)))continue;if(o&&typeof o==="object"&&!Array.isArray(o))r[n]=A(o);else r[n]=o}return r}function A(e,r=0){if(r>=G.maxSanitizeDepth)return"[Object too deep]";if(e===null||typeof e!=="object")return e;if(Array.isArray(e))return e.map((o)=>A(o,r+1));if(e instanceof Date||e instanceof RegExp||e instanceof Map||e instanceof Set||e instanceof Error)return e;let n={};for(let[o,s]of Object.entries(e)){if(o.startsWith("__")||o==="constructor"||o==="prototype")continue;if(s&&typeof s==="object")n[o]=A(s,r+1);else n[o]=s}return n}function c(e,r){try{let n=Ns(r),o=Object.keys(n),s=Object.values(n);return l(e,o)(...s)}catch{return}}function p(e){try{return Ms(e),!0}catch{return!1}}function D(e,r){try{let n=c(e,r);if(n&&typeof n==="object"&&!Array.isArray(n))return n;return{}}catch{return{}}}var Q=new Set(["break","case","catch","class","const","continue","debugger","default","delete","do","else","enum","export","extends","false","finally","for","function","if","import","in","instanceof","new","null","return","super","switch","this","throw","true","try","typeof","var","void","while","with","yield","let","static","implements","interface","package","private","protected","public","arguments","eval","await"]),Ee=2000,_=new Map;function V(e,r){let n=`${e.join(",")}\x00${r}`,o=_.get(n);if(o)return o;let s=Function(...e,r);if(_.size>=Ee)_.clear();return _.set(n,s),s}function Se(e){return e.replace(/'(?:[^'\\]|\\.)*'|"(?:[^"\\]|\\.)*"|`(?:[^`\\]|\\.)*`/g," ").replace(/\??\.\s*[a-zA-Z_$][\w$]*/g," ").replace(/([{,]\s*)[a-zA-Z_$][\w$]*(\s*:)/g,"$1$2").match(/\b[a-zA-Z_$][\w$]*\b/g)||[]}var xe=/^[A-Za-z_$][\w$]*$/;function Ze(e){return xe.test(e)&&!Q.has(e)}function l(e,r){let{source:n,usesSafeConstructors:o}=T(e),s=[];for(let f=0;f<r.length;f++){if(!Ze(r[f]))continue;if(r[f]===F)continue;s.push({key:r[f],index:f})}s.sort((f,m)=>f.key.localeCompare(m.key));let a=s.map((f)=>f.key),g=s.map((f)=>f.index),u=`
29
29
  'use strict';
30
30
  try {
31
31
  return ${n};
@@ -37,4 +37,4 @@ catch (e) {
37
37
  throw e;
38
38
  }
39
39
  `;return be(o?(f)=>{let m=V([F,...a,...f],u);return(...h)=>m(Z,...h)}:(f)=>V([...a,...f],u),a,r,s,g)}function be(e,r,n,o,s){let a=e([]),g=o.every((d,f)=>d.index===f);if(r.length===n.length&&g)return W(a,r,e);return W((...d)=>{let f=Array(s.length);for(let m=0;m<s.length;m++)f[m]=d[s[m]];return a(...f)},r,e,(d)=>{a=e(d)})}function W(e,r,n,o){let a=/^(\w+) is not defined$/,g=e,u=[],d=new Set(r);return(...f)=>{for(let m=0;m<=8;m++)try{return g(...f)}catch(h){let E=h instanceof Error?h.message:"",x=a.exec(E);if(!(h instanceof ReferenceError)||!x)return;let y=x[1];if(d.has(y)||Q.has(y))return;if(d.add(y),u.push(y),o)o(u);else g=n(u)}return}}function ar(e){let r=e.trim(),n=[/\beval\s*\(/i,/\bFunction\s*\(/i,/\bimport\s*\(/i,/\brequire\s*\(/i,/\bprocess\b/i,/\b__proto__\b/i,/\bconstructor\s*[.(]/i,/\bglobalThis\b/i,/\bwindow\b/i,/\bdocument\b/i,/\bfetch\s*\(/i,/\bBun\b/i,/\bDeno\b/i,/\bconsole\b/i,/\bthis\b/i,/\bReflect\b/i,/\bProxy\b/i,/\bprototype\b/i,/\.(bind|call|apply)\s*\(/i];for(let o of n)if(o.test(r))return!1;return!0}
40
- export{t,X,yn,ir,i,te,Os,A,Rt,bn,Ms,Ns,c,p,D,Se,Ze,l,ar};
40
+ export{t,X,yn,ir,i,te,Os,P,Rt,bn,Ms,Ns,c,p,D,Se,Ze,l,ar};
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{De,Kt,sd}from"./chunk-38mtn4ce.js";import{V,Dn,Xt,jr,Br,On,od,id,ad,Gt,Jt,Fr,Mn,cd}from"./chunk-x81vcxzs.js";import"./chunk-xsc9zbaj.js";export{jr as batch,sd as default,Dn as derived,Xt as effect,De as generateSignalsRuntime,Kt as generateSignalsRuntimeDev,Jt as isDerived,Gt as isSignal,On as onDestroy,Br as onMount,Mn as peek,ad as pendingLifecycleCounts,id as runDestroyCallbacks,od as runMountCallbacks,V as state,Fr as untrack,cd as useOptimistic};
2
+ import{De,Kt,sd}from"./chunk-5zm23zrb.js";import{V,Dn,Xt,jr,Br,On,od,id,ad,Gt,Jt,Fr,Mn,cd}from"./chunk-x81vcxzs.js";import"./chunk-g1r4v0mc.js";export{jr as batch,sd as default,Dn as derived,Xt as effect,De as generateSignalsRuntime,Kt as generateSignalsRuntimeDev,Jt as isDerived,Gt as isSignal,On as onDestroy,Br as onMount,Mn as peek,ad as pendingLifecycleCounts,id as runDestroyCallbacks,od as runMountCallbacks,V as state,Fr as untrack,cd as useOptimistic};
@@ -1,3 +1,3 @@
1
1
  // @bun
2
- import{p,l}from"./chunk-798epzq5.js";import{b}from"./chunk-0np4t9ka.js";function y(t,o){let i=1,r=o,e="<template",n="</template";while(r<t.length&&i>0){let s=t.indexOf("<",r);if(s===-1)break;if(r=s,t.startsWith(e,r)&&(r+e.length>=t.length||/[\s>\/]/.test(t[r+e.length]))){i++,r+=e.length;continue}if(t.startsWith(n,r)){let a=t.indexOf(">",r+n.length);if(a!==-1){if(i--,i===0)return a+1;r=a+1;continue}}r++}return i===0?r:-1}var w=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]);function x(t,o){let i=null;for(let r=o;r<t.length;r++){let e=t[r];if(i){if(e==="\\"){r++;continue}if(e===i)i=null;continue}if(e==='"'||e==="'"){i=e;continue}if(e===">")return r+1}return-1}function N(t,o,i){let r=o.toLowerCase(),e=1,n=i;while(n<t.length){let s=t.indexOf("<",n);if(s===-1)return-1;if(t.startsWith("<!--",s)){let g=t.indexOf("-->",s+4);n=g===-1?t.length:g+3;continue}let a=x(t,s+1);if(a===-1)return-1;let f=t.slice(s,a),u=f.match(/^<\s*(\/?)\s*([a-zA-Z][\w-]*)/);if(u&&u[2].toLowerCase()===r){if(u[1]==="/"){if(e--,e===0)return a}else if(!/\/\s*>$/.test(f))e++}n=a}return-1}function A(t){let o=[],i=[],r=/\bslot\s*=\s*(?:"([^"]+)"|'([^']+)')/i,e=0;while(e<t.length){let n=t.indexOf("<",e);if(n===-1)break;if(t.startsWith("<!--",n)){let c=t.indexOf("-->",n+4);e=c===-1?t.length:c+3;continue}let s=x(t,n+1);if(s===-1)break;let a=t.slice(n,s),f=a.match(/^<\s*(\/?)\s*([a-zA-Z][\w-]*)/);if(!f){e=s;continue}let u=f[2].toLowerCase();if(f[1]==="/"){let c=i.lastIndexOf(u);if(c!==-1)i.splice(c);e=s;continue}let g=/\/\s*>$/.test(a),d=i.length===0?a.match(r):null;if(d){let c=d[1]||d[2],m=a.replace(r,"").replace(/\s+(?=\/?>$)/,"").replace(/\s{2,}/g," "),h=g||w.has(u)?-1:N(t,u,s);if(h===-1)o.push({start:n,end:s,slotName:c,element:m}),e=s;else o.push({start:n,end:h,slotName:c,element:m+t.slice(s,h)}),e=h;continue}if(!g&&!w.has(u)){if(i.push(u),u==="script"||u==="style"){let c=t.toLowerCase().indexOf(`</${u}>`,s);if(c!==-1){e=c;continue}}}e=s}return o}function O(t){let o=[],i=[],r=/^<template\s+(?:#([a-zA-Z][\w-]*)|v-slot:([a-zA-Z][\w-]*)|slot="([a-zA-Z][\w-]*)")(?:\s*=\s*"([^"]*)")?[^>]*>$/i,e=0;while(e<t.length){let n=t.indexOf("<",e);if(n===-1)break;if(t.startsWith("<!--",n)){let c=t.indexOf("-->",n+4);e=c===-1?t.length:c+3;continue}let s=x(t,n+1);if(s===-1)break;let a=t.slice(n,s),f=a.match(/^<\s*(\/?)\s*([a-zA-Z][\w-]*)/);if(!f){e=s;continue}let u=f[1]==="/",g=f[2].toLowerCase();if(u){let c=i.lastIndexOf(g);if(c!==-1)i.splice(c);e=s;continue}if(g==="template"&&i.length===0){let c=a.match(r);if(c){let m=y(t,s);if(m!==-1){let h=c[1]||c[2]||c[3];o.push({start:n,end:m,slotName:h,content:t.slice(s,m-11).trim(),propsBinding:c[4]||void 0}),e=m;continue}}}if(!/\/\s*>$/.test(a)&&!w.has(g)){if(i.push(g),g==="script"||g==="style"){let c=t.toLowerCase().indexOf(`</${g}>`,s);if(c!==-1){e=c;continue}}}e=s}return o}function aa(t){let o={default:"",named:new Map},i=t,r=O(t);for(let n of r)o.named.set(n.slotName,{name:n.slotName,content:n.content,propsBinding:n.propsBinding});r.sort((n,s)=>s.start-n.start);for(let n of r)i=i.slice(0,n.start)+i.slice(n.end);let e=A(i);for(let n of e){let s=o.named.get(n.slotName);if(s)s.content+=n.element;else o.named.set(n.slotName,{name:n.slotName,content:n.element})}for(let n=e.length-1;n>=0;n--){let s=e[n];i=i.slice(0,s.start)+i.slice(s.end)}return o.default=i.trim(),o}function xl(t){let o=t.match(/name\s*=\s*["']([^"']+)["']/),i=o?o[1]:"",r={},e=/:([a-zA-Z][\w-]*)\s*=\s*["']([^"']+)["']/g,n;while((n=e.exec(t))!==null)r[n[1]]=n[2];let s=t.match(/<slot[^>]*>([\s\S]*?)<\/slot>/i),a=s?s[1].trim():"";return{name:i,props:r,defaultContent:a}}async function ca(t,o,i,r){if(!t)return i;let e=t.content;if(t.propsBinding&&Object.keys(o).length>0){let n=t.propsBinding.trim(),s={...r};if(n.startsWith("{")&&n.endsWith("}")){let a=n.slice(1,-1).split(",").map((f)=>f.trim()).filter(Boolean);for(let f of a){let[u,g]=f.split(":").map((c)=>c.trim()),d=g||u;if(o[u]!==void 0)s[d]=o[u]}}else s[n]=o;e=C(e,s)}return e}function C(t,o){return t.replace(/\{\{\s*([^}]+)\s*\}\}/g,(i,r)=>{try{let e=r.trim(),n=k(e,o);return b(String(n??""))}catch{return`{{ ${r} }}`}})}function k(t,o){if(/^[a-zA-Z_$][\w$]*(\.[a-zA-Z_$][\w$]*)*$/.test(t)){let r=t.split("."),e=o;for(let n of r)if(e&&typeof e==="object"&&n in e)e=e[n];else return;return e}let i=t.match(/^([a-zA-Z_$][\w$]*)\s*([+\-*/])\s*(\d+)$/);if(i){let[,r,e,n]=i,s=o[r],a=parseInt(n,10);if(typeof s==="number")switch(e){case"+":return s+a;case"-":return s-a;case"*":return s*a;case"/":return s/a}}try{if(!p(t))return;return l(t,Object.keys(o))(...Object.values(o))}catch{return}}async function la(t,o,i){let r=t;r=await M(r,/<slot\s+name\s*=\s*["']([^"']+)["']([^>]*?)(?:\/>|>([\s\S]*?)<\/slot>)/gi,async(s,a,f,u)=>{let g=o.named.get(a),d=u?.trim()||"",c=f||"",m={},h=/:([a-zA-Z_$][\w$-]*)\s*=\s*["']([^"']+)["']/g,S;while((S=h.exec(c))!==null){let E=S[1],R=S[2];m[E]=k(R,i)}return await ca(g,m,d,i)});let n=/<slot\b((?:"[^"]*"|'[^']*'|[^>"'])*?)\s*(?:\/>|>([\s\S]*?)<\/slot>)/gi;return r=r.replace(n,(s,a,f)=>{if(/\bname\s*=/.test(a||""))return s;let u=f?.trim()||"";return o.default||u}),r}async function M(t,o,i){let r=[],e=[];t.replace(o,(a,...f)=>{let u=f[f.length-2];return e.push({match:a,index:u}),r.push(i(a,...f.slice(0,-2))),a});let n=await Promise.all(r),s=t;for(let a=e.length-1;a>=0;a--){let{match:f,index:u}=e[a];s=s.slice(0,u)+n[a]+s.slice(u+f.length)}return s}function Sl(t){let o=aa(t);return{defaultSlot:o.default,namedSlots:o.named}}async function kl(t,o,i,r){return await la(t,{default:o,named:i},r)}
2
+ import{p,l}from"./chunk-g495xx4v.js";import{b}from"./chunk-96kr2xrt.js";function y(t,o){let i=1,r=o,e="<template",n="</template";while(r<t.length&&i>0){let s=t.indexOf("<",r);if(s===-1)break;if(r=s,t.startsWith(e,r)&&(r+e.length>=t.length||/[\s>\/]/.test(t[r+e.length]))){i++,r+=e.length;continue}if(t.startsWith(n,r)){let a=t.indexOf(">",r+n.length);if(a!==-1){if(i--,i===0)return a+1;r=a+1;continue}}r++}return i===0?r:-1}var w=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]);function x(t,o){let i=null;for(let r=o;r<t.length;r++){let e=t[r];if(i){if(e==="\\"){r++;continue}if(e===i)i=null;continue}if(e==='"'||e==="'"){i=e;continue}if(e===">")return r+1}return-1}function N(t,o,i){let r=o.toLowerCase(),e=1,n=i;while(n<t.length){let s=t.indexOf("<",n);if(s===-1)return-1;if(t.startsWith("<!--",s)){let g=t.indexOf("-->",s+4);n=g===-1?t.length:g+3;continue}let a=x(t,s+1);if(a===-1)return-1;let f=t.slice(s,a),u=f.match(/^<\s*(\/?)\s*([a-zA-Z][\w-]*)/);if(u&&u[2].toLowerCase()===r){if(u[1]==="/"){if(e--,e===0)return a}else if(!/\/\s*>$/.test(f))e++}n=a}return-1}function A(t){let o=[],i=[],r=/\bslot\s*=\s*(?:"([^"]+)"|'([^']+)')/i,e=0;while(e<t.length){let n=t.indexOf("<",e);if(n===-1)break;if(t.startsWith("<!--",n)){let c=t.indexOf("-->",n+4);e=c===-1?t.length:c+3;continue}let s=x(t,n+1);if(s===-1)break;let a=t.slice(n,s),f=a.match(/^<\s*(\/?)\s*([a-zA-Z][\w-]*)/);if(!f){e=s;continue}let u=f[2].toLowerCase();if(f[1]==="/"){let c=i.lastIndexOf(u);if(c!==-1)i.splice(c);e=s;continue}let g=/\/\s*>$/.test(a),d=i.length===0?a.match(r):null;if(d){let c=d[1]||d[2],m=a.replace(r,"").replace(/\s+(?=\/?>$)/,"").replace(/\s{2,}/g," "),h=g||w.has(u)?-1:N(t,u,s);if(h===-1)o.push({start:n,end:s,slotName:c,element:m}),e=s;else o.push({start:n,end:h,slotName:c,element:m+t.slice(s,h)}),e=h;continue}if(!g&&!w.has(u)){if(i.push(u),u==="script"||u==="style"){let c=t.toLowerCase().indexOf(`</${u}>`,s);if(c!==-1){e=c;continue}}}e=s}return o}function O(t){let o=[],i=[],r=/^<template\s+(?:#([a-zA-Z][\w-]*)|v-slot:([a-zA-Z][\w-]*)|slot="([a-zA-Z][\w-]*)")(?:\s*=\s*"([^"]*)")?[^>]*>$/i,e=0;while(e<t.length){let n=t.indexOf("<",e);if(n===-1)break;if(t.startsWith("<!--",n)){let c=t.indexOf("-->",n+4);e=c===-1?t.length:c+3;continue}let s=x(t,n+1);if(s===-1)break;let a=t.slice(n,s),f=a.match(/^<\s*(\/?)\s*([a-zA-Z][\w-]*)/);if(!f){e=s;continue}let u=f[1]==="/",g=f[2].toLowerCase();if(u){let c=i.lastIndexOf(g);if(c!==-1)i.splice(c);e=s;continue}if(g==="template"&&i.length===0){let c=a.match(r);if(c){let m=y(t,s);if(m!==-1){let h=c[1]||c[2]||c[3];o.push({start:n,end:m,slotName:h,content:t.slice(s,m-11).trim(),propsBinding:c[4]||void 0}),e=m;continue}}}if(!/\/\s*>$/.test(a)&&!w.has(g)){if(i.push(g),g==="script"||g==="style"){let c=t.toLowerCase().indexOf(`</${g}>`,s);if(c!==-1){e=c;continue}}}e=s}return o}function aa(t){let o={default:"",named:new Map},i=t,r=O(t);for(let n of r)o.named.set(n.slotName,{name:n.slotName,content:n.content,propsBinding:n.propsBinding});r.sort((n,s)=>s.start-n.start);for(let n of r)i=i.slice(0,n.start)+i.slice(n.end);let e=A(i);for(let n of e){let s=o.named.get(n.slotName);if(s)s.content+=n.element;else o.named.set(n.slotName,{name:n.slotName,content:n.element})}for(let n=e.length-1;n>=0;n--){let s=e[n];i=i.slice(0,s.start)+i.slice(s.end)}return o.default=i.trim(),o}function xl(t){let o=t.match(/name\s*=\s*["']([^"']+)["']/),i=o?o[1]:"",r={},e=/:([a-zA-Z][\w-]*)\s*=\s*["']([^"']+)["']/g,n;while((n=e.exec(t))!==null)r[n[1]]=n[2];let s=t.match(/<slot[^>]*>([\s\S]*?)<\/slot>/i),a=s?s[1].trim():"";return{name:i,props:r,defaultContent:a}}async function ca(t,o,i,r){if(!t)return i;let e=t.content;if(t.propsBinding&&Object.keys(o).length>0){let n=t.propsBinding.trim(),s={...r};if(n.startsWith("{")&&n.endsWith("}")){let a=n.slice(1,-1).split(",").map((f)=>f.trim()).filter(Boolean);for(let f of a){let[u,g]=f.split(":").map((c)=>c.trim()),d=g||u;if(o[u]!==void 0)s[d]=o[u]}}else s[n]=o;e=C(e,s)}return e}function C(t,o){return t.replace(/\{\{\s*([^}]+)\s*\}\}/g,(i,r)=>{try{let e=r.trim(),n=k(e,o);return b(String(n??""))}catch{return`{{ ${r} }}`}})}function k(t,o){if(/^[a-zA-Z_$][\w$]*(\.[a-zA-Z_$][\w$]*)*$/.test(t)){let r=t.split("."),e=o;for(let n of r)if(e&&typeof e==="object"&&n in e)e=e[n];else return;return e}let i=t.match(/^([a-zA-Z_$][\w$]*)\s*([+\-*/])\s*(\d+)$/);if(i){let[,r,e,n]=i,s=o[r],a=parseInt(n,10);if(typeof s==="number")switch(e){case"+":return s+a;case"-":return s-a;case"*":return s*a;case"/":return s/a}}try{if(!p(t))return;return l(t,Object.keys(o))(...Object.values(o))}catch{return}}async function la(t,o,i){let r=t;r=await M(r,/<slot\s+name\s*=\s*["']([^"']+)["']([^>]*?)(?:\/>|>([\s\S]*?)<\/slot>)/gi,async(s,a,f,u)=>{let g=o.named.get(a),d=u?.trim()||"",c=f||"",m={},h=/:([a-zA-Z_$][\w$-]*)\s*=\s*["']([^"']+)["']/g,S;while((S=h.exec(c))!==null){let E=S[1],R=S[2];m[E]=k(R,i)}return await ca(g,m,d,i)});let n=/<slot\b((?:"[^"]*"|'[^']*'|[^>"'])*?)\s*(?:\/>|>([\s\S]*?)<\/slot>)/gi;return r=r.replace(n,(s,a,f)=>{if(/\bname\s*=/.test(a||""))return s;let u=f?.trim()||"";return o.default||u}),r}async function M(t,o,i){let r=[],e=[];t.replace(o,(a,...f)=>{let u=f[f.length-2];return e.push({match:a,index:u}),r.push(i(a,...f.slice(0,-2))),a});let n=await Promise.all(r),s=t;for(let a=e.length-1;a>=0;a--){let{match:f,index:u}=e[a];s=s.slice(0,u)+n[a]+s.slice(u+f.length)}return s}function Sl(t){let o=aa(t);return{defaultSlot:o.default,namedSlots:o.named}}async function kl(t,o,i,r){return await la(t,{default:o,named:i},r)}
3
3
  export{aa,xl,ca,la,Sl,kl};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{on,gc,as}from"./chunk-96kr2xrt.js";import"./chunk-68tzytfz.js";import"./chunk-c57j92td.js";import"./chunk-kp4mzspk.js";import"./chunk-v74acg2k.js";import"./chunk-zz5b1g50.js";import"./chunk-5tbqdz94.js";import"./chunk-9p3rtfbv.js";import{Se}from"./chunk-g495xx4v.js";import"./chunk-ba88n1j7.js";import"./chunk-g1r4v0mc.js";import"./chunk-xd4zvm4x.js";import"./chunk-e6y6s7q8.js";export{Se as freeIdentifiers,as as processComponents,gc as processESImports,on as rendersAsElement};