@stacksjs/stx 0.2.817 → 0.2.818

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 (201) hide show
  1. package/dist/{chunk-pyytr30r.js → chunk-035m9ada.js} +3 -3
  2. package/dist/chunk-03mtfndv.js +2 -0
  3. package/dist/chunk-18qxd18d.js +2 -0
  4. package/dist/{chunk-d47m4qat.js → chunk-1a8qtvs1.js} +2 -2
  5. package/dist/{chunk-s9xs2ff4.js → chunk-1ae3megp.js} +5 -5
  6. package/dist/chunk-1cd0w20k.js +2 -0
  7. package/dist/{chunk-549end3k.js → chunk-1hg0zb3p.js} +2 -2
  8. package/dist/{chunk-p8wq37hd.js → chunk-1rvgv1fr.js} +5 -5
  9. package/dist/{chunk-n761hp6d.js → chunk-1tzqqr0p.js} +2 -2
  10. package/dist/{chunk-rc424p1c.js → chunk-2bnbcr22.js} +24 -24
  11. package/dist/{chunk-b5ckg7zq.js → chunk-2jn0x4sh.js} +5 -5
  12. package/dist/chunk-2kt1gqtq.js +2 -0
  13. package/dist/chunk-2vaap97d.js +2 -0
  14. package/dist/chunk-33ewq978.js +2 -0
  15. package/dist/chunk-3m342maz.js +2 -0
  16. package/dist/chunk-46sej67y.js +2 -0
  17. package/dist/{chunk-5efv1fhk.js → chunk-4fbg7gq8.js} +2 -2
  18. package/dist/{chunk-cj1p3qdh.js → chunk-4h78zypb.js} +1 -1
  19. package/dist/chunk-5zf566bv.js +2 -0
  20. package/dist/chunk-67k5q95t.js +2 -0
  21. package/dist/chunk-6e76tz09.js +2 -0
  22. package/dist/{chunk-bphwhfbd.js → chunk-6n11z33h.js} +5 -5
  23. package/dist/{chunk-7rk7wfm6.js → chunk-72jt897s.js} +13 -13
  24. package/dist/chunk-72w08sh9.js +2 -0
  25. package/dist/{chunk-agxjwnz0.js → chunk-7ac98ja7.js} +8 -8
  26. package/dist/chunk-7q79h0j4.js +2 -0
  27. package/dist/chunk-88mhhbqj.js +2 -0
  28. package/dist/{chunk-a0r4dpzs.js → chunk-8dmey36n.js} +2 -2
  29. package/dist/chunk-8gcg9maj.js +1327 -0
  30. package/dist/{chunk-gtfs96f2.js → chunk-8hfgvs0x.js} +2 -2
  31. package/dist/{chunk-cm5cp3m0.js → chunk-8wdy7kdq.js} +4 -4
  32. package/dist/{chunk-kjjvs3sc.js → chunk-9487tyfa.js} +2 -2
  33. package/dist/chunk-9736003n.js +2 -0
  34. package/dist/chunk-99zwpazg.js +2 -0
  35. package/dist/chunk-9e5gamvs.js +2 -0
  36. package/dist/{chunk-17wb2x3z.js → chunk-9egd7tx3.js} +2 -2
  37. package/dist/{chunk-5hxvhmg3.js → chunk-9gj702tw.js} +4 -4
  38. package/dist/{chunk-2ws2qe1k.js → chunk-9gwhs0gk.js} +2 -2
  39. package/dist/{chunk-rxt4jj9b.js → chunk-9tzcvsv0.js} +6 -6
  40. package/dist/{chunk-133vw0ae.js → chunk-9xd85mvm.js} +4 -4
  41. package/dist/chunk-9y1dm510.js +2 -0
  42. package/dist/{chunk-yvqe0pzk.js → chunk-a1cy78h3.js} +2 -2
  43. package/dist/{chunk-sa0nkpx9.js → chunk-a67c2xrp.js} +2 -2
  44. package/dist/chunk-abzrvxct.js +2 -0
  45. package/dist/chunk-avbvedyx.js +2 -0
  46. package/dist/{chunk-3vpgr6nk.js → chunk-b9d70mgr.js} +3 -3
  47. package/dist/chunk-bbxzkcsk.js +2 -0
  48. package/dist/chunk-c179xpsq.js +2 -0
  49. package/dist/{chunk-n9av365c.js → chunk-casvvt3k.js} +1 -1
  50. package/dist/{chunk-p5ez40kf.js → chunk-cf196sv5.js} +2 -2
  51. package/dist/chunk-cvq4bz8y.js +2 -0
  52. package/dist/{chunk-1wdv3zj2.js → chunk-d4pmddb9.js} +1 -1
  53. package/dist/chunk-dh1f8ga0.js +2 -0
  54. package/dist/{chunk-1fc6rax4.js → chunk-dpn314z2.js} +2 -2
  55. package/dist/{chunk-6cw072n5.js → chunk-dq9djbgq.js} +4 -4
  56. package/dist/{chunk-tb4wmzzd.js → chunk-e3t2bqyf.js} +5 -5
  57. package/dist/{chunk-y3p6w1e0.js → chunk-e9w8qav3.js} +5 -5
  58. package/dist/{chunk-jg9f5nqf.js → chunk-em2yy1te.js} +6 -6
  59. package/dist/chunk-em7kntfc.js +2 -0
  60. package/dist/chunk-enm79dwe.js +2 -0
  61. package/dist/{chunk-m0x96g8e.js → chunk-f6nk205v.js} +1 -1
  62. package/dist/{chunk-f54t0qar.js → chunk-fmawgk87.js} +1 -1
  63. package/dist/chunk-fvs15n0s.js +2 -0
  64. package/dist/{chunk-gqjb1y7c.js → chunk-g7mjv276.js} +2 -2
  65. package/dist/{chunk-r6dtrd7y.js → chunk-gcje06er.js} +30 -30
  66. package/dist/{chunk-1bgv727x.js → chunk-gtd6qs1r.js} +2 -2
  67. package/dist/chunk-gvthmy3a.js +2 -0
  68. package/dist/chunk-h8kbcz9t.js +2 -0
  69. package/dist/chunk-h8x56dq5.js +2 -0
  70. package/dist/{chunk-hg67a15h.js → chunk-hntm02x0.js} +3 -3
  71. package/dist/chunk-hx575xy8.js +2 -0
  72. package/dist/{chunk-dy7yccxm.js → chunk-j24psz0z.js} +7 -7
  73. package/dist/chunk-j58z3y2g.js +2 -0
  74. package/dist/chunk-j5t40n2g.js +2 -0
  75. package/dist/{chunk-nmkkfpmh.js → chunk-j65nf7mt.js} +6 -6
  76. package/dist/{chunk-kvhsdyfg.js → chunk-j8r0am39.js} +1 -1
  77. package/dist/{chunk-jtx9x3as.js → chunk-k01aftw0.js} +6 -6
  78. package/dist/{chunk-0h99mrb0.js → chunk-k3t72x38.js} +2 -2
  79. package/dist/{chunk-0svj1nfa.js → chunk-k3zcadcc.js} +2 -2
  80. package/dist/chunk-kgwdxx75.js +2 -0
  81. package/dist/{chunk-r5nt1bcx.js → chunk-mbhvf0sv.js} +2 -2
  82. package/dist/{chunk-fn3q1gtr.js → chunk-mjg9cx5a.js} +3 -3
  83. package/dist/{chunk-ccxphr19.js → chunk-mm8ak4w2.js} +2 -2
  84. package/dist/{chunk-xrd1md4j.js → chunk-mr2ke5km.js} +6 -6
  85. package/dist/chunk-n1tbc7da.js +2 -0
  86. package/dist/{chunk-4ws3yz5q.js → chunk-n4s0se11.js} +8 -8
  87. package/dist/chunk-n7dm6prj.js +2 -0
  88. package/dist/chunk-nknpr8cy.js +2 -0
  89. package/dist/{chunk-jham85mf.js → chunk-nqdh7z2d.js} +1 -1
  90. package/dist/{chunk-vbrn4w81.js → chunk-p13wg97w.js} +3 -3
  91. package/dist/chunk-pe9npaby.js +2 -0
  92. package/dist/chunk-pyz2jqph.js +2 -0
  93. package/dist/chunk-q51w24br.js +2 -0
  94. package/dist/chunk-qek9bcjt.js +2 -0
  95. package/dist/chunk-qkxx34vt.js +2 -0
  96. package/dist/{chunk-0jcady6w.js → chunk-qr14xvwb.js} +1 -1
  97. package/dist/chunk-r2v042ym.js +2 -0
  98. package/dist/{chunk-df60fpgx.js → chunk-r8ydxe4z.js} +3 -3
  99. package/dist/chunk-rjzp7za8.js +2 -0
  100. package/dist/{chunk-yts2b9d8.js → chunk-s6mte5vy.js} +11 -6
  101. package/dist/chunk-s9b49v74.js +3 -0
  102. package/dist/{chunk-vkn133cs.js → chunk-s9b6abkb.js} +2 -2
  103. package/dist/chunk-sata7rh2.js +2 -0
  104. package/dist/{chunk-pdnyhs63.js → chunk-sf4rntqj.js} +1 -1
  105. package/dist/{chunk-8h3jv8dd.js → chunk-sh1hbhhb.js} +2 -2
  106. package/dist/{chunk-ntn6bnjv.js → chunk-skht06a2.js} +1 -1
  107. package/dist/{chunk-gc7pykfq.js → chunk-swbrvrgr.js} +2 -2
  108. package/dist/{chunk-s90m43sm.js → chunk-sxad7x2s.js} +4 -4
  109. package/dist/{chunk-w6n4y2xg.js → chunk-tj6zvs8f.js} +2 -2
  110. package/dist/chunk-tmcgpf68.js +2 -0
  111. package/dist/chunk-tsb5h4e2.js +2 -0
  112. package/dist/chunk-v8h2kns0.js +2 -0
  113. package/dist/{chunk-ncyjaxyz.js → chunk-vmxzktdr.js} +1 -1
  114. package/dist/chunk-vpazz8ca.js +2 -0
  115. package/dist/{chunk-5gxneecs.js → chunk-vtt2dec3.js} +3 -3
  116. package/dist/chunk-vyw40ym7.js +2 -0
  117. package/dist/chunk-whq40bdm.js +2 -0
  118. package/dist/chunk-x15hrtmt.js +2 -0
  119. package/dist/{chunk-fcvyk047.js → chunk-x34me5ar.js} +7 -7
  120. package/dist/{chunk-0ekdbagy.js → chunk-xc7nynb9.js} +2 -2
  121. package/dist/chunk-xha2gt0n.js +2 -0
  122. package/dist/{chunk-hhazm0cs.js → chunk-y3zjmv9e.js} +3 -3
  123. package/dist/chunk-ydt1pbhx.js +2 -0
  124. package/dist/chunk-ymypc1rp.js +709 -0
  125. package/dist/chunk-z8ywxqqg.js +2 -0
  126. package/dist/{chunk-crmxg1c0.js → chunk-zgq8bfaw.js} +4 -4
  127. package/dist/{chunk-e39nkbt4.js → chunk-zhvmcj78.js} +4 -4
  128. package/dist/{chunk-2p3eaj16.js → chunk-zme16hcr.js} +3 -3
  129. package/dist/{chunk-sphc7xzx.js → chunk-znx5m1jv.js} +1 -1
  130. package/dist/chunk-zwp7n01x.js +2 -0
  131. package/dist/cli.js +12 -12
  132. package/dist/client/signals-expression-runtime.js +6 -2
  133. package/dist/client/signals-public-api-runtime.js +1 -0
  134. package/dist/craft-entry.js +2 -2
  135. package/dist/craft.js +2 -2
  136. package/dist/process.js +2 -2
  137. package/dist/pwa.js +3 -3
  138. package/dist/reactive.d.ts +12 -2
  139. package/dist/reactive.js +69 -32
  140. package/dist/ssg.js +10 -10
  141. package/dist/utils.js +6 -1
  142. package/package.json +5 -5
  143. package/dist/chunk-0yjm4j26.js +0 -2
  144. package/dist/chunk-1kz70290.js +0 -2
  145. package/dist/chunk-1rwfgmmk.js +0 -2
  146. package/dist/chunk-2k3qtmn8.js +0 -2
  147. package/dist/chunk-2vget8rh.js +0 -2
  148. package/dist/chunk-3e85etrf.js +0 -2
  149. package/dist/chunk-3eqs0rpv.js +0 -2
  150. package/dist/chunk-3ftaegqg.js +0 -2
  151. package/dist/chunk-3jd5ak8h.js +0 -2
  152. package/dist/chunk-4ypwqrj2.js +0 -2
  153. package/dist/chunk-5eqna31h.js +0 -2
  154. package/dist/chunk-6a97a9wk.js +0 -2
  155. package/dist/chunk-7agp0wj2.js +0 -2
  156. package/dist/chunk-7hch54b2.js +0 -2
  157. package/dist/chunk-7pb9fepg.js +0 -2
  158. package/dist/chunk-8g8h2xwz.js +0 -2
  159. package/dist/chunk-9mtw71xy.js +0 -2
  160. package/dist/chunk-9ttf7k5e.js +0 -2
  161. package/dist/chunk-9wmjmas8.js +0 -2
  162. package/dist/chunk-a350jjd3.js +0 -2
  163. package/dist/chunk-aqydav9y.js +0 -2
  164. package/dist/chunk-ar7w1kx0.js +0 -2
  165. package/dist/chunk-aya8nv31.js +0 -2
  166. package/dist/chunk-b9ntt41z.js +0 -2
  167. package/dist/chunk-bj6ax0he.js +0 -2
  168. package/dist/chunk-cxpnkgvw.js +0 -2
  169. package/dist/chunk-d3gncxq1.js +0 -2
  170. package/dist/chunk-da886asf.js +0 -2
  171. package/dist/chunk-dnemxdvy.js +0 -2
  172. package/dist/chunk-dnqt6y8v.js +0 -3
  173. package/dist/chunk-f0bwetnx.js +0 -421
  174. package/dist/chunk-gzhrtymg.js +0 -1592
  175. package/dist/chunk-h9yvb9qn.js +0 -2
  176. package/dist/chunk-hsmwzzy2.js +0 -2
  177. package/dist/chunk-jsvc264s.js +0 -2
  178. package/dist/chunk-k98nt4pk.js +0 -2
  179. package/dist/chunk-ka1hrt56.js +0 -2
  180. package/dist/chunk-m477m5dp.js +0 -2
  181. package/dist/chunk-mkr46mzz.js +0 -2
  182. package/dist/chunk-mmyrdbxx.js +0 -2
  183. package/dist/chunk-p4f1hrvn.js +0 -2
  184. package/dist/chunk-py244ymg.js +0 -2
  185. package/dist/chunk-rp6b7awz.js +0 -2
  186. package/dist/chunk-rqfg21xk.js +0 -2
  187. package/dist/chunk-rxc1076r.js +0 -2
  188. package/dist/chunk-rzwyaqgg.js +0 -2
  189. package/dist/chunk-s5pegavh.js +0 -2
  190. package/dist/chunk-sj4vw93g.js +0 -2
  191. package/dist/chunk-snfjvd94.js +0 -2
  192. package/dist/chunk-syvsj91a.js +0 -2
  193. package/dist/chunk-tzb0n60s.js +0 -2
  194. package/dist/chunk-w8xvkbt9.js +0 -2
  195. package/dist/chunk-x5rt4kpx.js +0 -2
  196. package/dist/chunk-xbknqp19.js +0 -2
  197. package/dist/chunk-xgqyzkt2.js +0 -2
  198. package/dist/chunk-yd0074ks.js +0 -2
  199. package/dist/chunk-yd1zsy7t.js +0 -2
  200. package/dist/chunk-yjezsy4p.js +0 -2
  201. package/dist/chunk-yjvwp1s6.js +0 -2
@@ -1,1592 +0,0 @@
1
- // @bun
2
- import{Lt,ie,u,f,A,t,ae,q,l,ke,ki,F,Sn,_i,Ft,Ci,rl,$r,sl,it,ol,Rr,il,kn,Ei,al,Ar,Ir,_e,Ti}from"./chunk-7rk7wfm6.js";import{ai,$c,o,C,Oe,pn,Ne,pe,G,vr,fn,Bs,jc,mn,_r,zs,Hs,Bc,fi,Fc,zc,Hc,Vc,De,Le,Vs,Fe,s,bn,h,p,U,Z,Se,_,T}from"./chunk-f0bwetnx.js";import{Dt}from"./chunk-m7hfcxt3.js";import{vn}from"./chunk-pdnyhs63.js";import{y}from"./chunk-rxt4jj9b.js";import{gr,As}from"./chunk-1bgv727x.js";import{pc,fc,dr,Qe,gc,I}from"./chunk-nmkkfpmh.js";import{Zo,Qo,ei,ti}from"./chunk-jg9f5nqf.js";import{ac,us}from"./chunk-df60fpgx.js";import{is,as,cs}from"./chunk-agxjwnz0.js";import{gs,Uo,Wo,ms,hs,qo}from"./chunk-fcvyk047.js";import{ds,or}from"./chunk-y3p6w1e0.js";import{Do}from"./chunk-c84pxd2k.js";import{se,Fo,zo,Ho}from"./chunk-m0x96g8e.js";import{ar,be,lc,cr,uc}from"./chunk-133vw0ae.js";import{j,Ye}from"./chunk-cmnze7at.js";import{mc,hc}from"./chunk-n9av365c.js";import{E,_n,$i}from"./chunk-c5vzr1va.js";import ps from"fs";import ce from"path";function dt(){return`
3
- // STX Lifecycle Runtime
4
- (function() {
5
- if (typeof window === 'undefined') return;
6
-
7
- const instances = new Map();
8
- let currentInstance = null;
9
- let idCounter = 0;
10
-
11
- function generateId() {
12
- return 'stx-' + (++idCounter) + '-' + Date.now().toString(36);
13
- }
14
-
15
- function createInstance(element) {
16
- const instance = {
17
- id: generateId(),
18
- element: element,
19
- mountHooks: [],
20
- destroyHooks: [],
21
- updateHooks: [],
22
- refs: new Map(),
23
- watchers: [],
24
- isMounted: false
25
- };
26
- instances.set(instance.id, instance);
27
- return instance;
28
- }
29
-
30
- window.STX = window.STX || {};
31
-
32
- // Lifecycle hooks
33
- window.STX.onMount = function(hook) {
34
- if (currentInstance) currentInstance.mountHooks.push(hook);
35
- };
36
-
37
- window.STX.onDestroy = function(hook) {
38
- if (currentInstance) currentInstance.destroyHooks.push(hook);
39
- };
40
-
41
- window.STX.onUpdate = function(hook) {
42
- if (currentInstance) currentInstance.updateHooks.push(hook);
43
- };
44
-
45
- // Aliases
46
- window.STX.onMounted = window.STX.onMount;
47
- window.STX.onUnmounted = window.STX.onDestroy;
48
- window.STX.onUpdated = window.STX.onUpdate;
49
-
50
- // Refs
51
- window.STX.ref = function(initialValue) {
52
- const r = { value: initialValue || null };
53
- Object.defineProperty(r, 'current', {
54
- get: function() { return this.value; }
55
- });
56
- if (currentInstance) {
57
- currentInstance.refs.set('ref-' + currentInstance.refs.size, r);
58
- }
59
- return r;
60
- };
61
-
62
- // Watch
63
- window.STX.watch = function(source, callback, options) {
64
- options = options || {};
65
- let oldValue;
66
- let cleanup;
67
- let isActive = true;
68
-
69
- function run() {
70
- if (!isActive) return;
71
- const newValue = source();
72
- if (oldValue !== newValue || options.immediate) {
73
- if (cleanup) cleanup();
74
- cleanup = callback(newValue, oldValue);
75
- oldValue = newValue;
76
- }
77
- }
78
-
79
- if (options.immediate) {
80
- run();
81
- }
82
- else {
83
- oldValue = source();
84
- }
85
-
86
- const intervalId = setInterval(run, 16);
87
-
88
- function stop() {
89
- isActive = false;
90
- clearInterval(intervalId);
91
- if (cleanup) cleanup();
92
- }
93
-
94
- if (currentInstance) {
95
- currentInstance.watchers.push({ stop: stop });
96
- currentInstance.destroyHooks.push(stop);
97
- }
98
-
99
- return stop;
100
- };
101
-
102
- // Computed
103
- window.STX.computed = function(getter) {
104
- let cached;
105
- let dirty = true;
106
- return {
107
- get value() {
108
- if (dirty) {
109
- cached = getter();
110
- dirty = false;
111
- queueMicrotask(function() { dirty = true; });
112
- }
113
- return cached;
114
- }
115
- };
116
- };
117
-
118
- // Component management
119
- window.STX.setupComponent = function(element, setup) {
120
- const instance = createInstance(element);
121
- currentInstance = instance;
122
- try {
123
- setup();
124
- }
125
- finally {
126
- currentInstance = null;
127
- }
128
- return instance;
129
- };
130
-
131
- window.STX.mountComponent = function(instance) {
132
- if (instance.isMounted) return;
133
- instance.isMounted = true;
134
- instance.mountHooks.forEach(function(hook) {
135
- try {
136
- const cleanup = hook();
137
- if (typeof cleanup === 'function') {
138
- instance.destroyHooks.push(cleanup);
139
- }
140
- else if (cleanup && typeof cleanup.then === 'function') {
141
- cleanup.catch(function(e) { console.error('[stx] onMount error:', e); });
142
- }
143
- }
144
- catch (e) {
145
- console.error('[stx] onMount error:', e);
146
- }
147
- });
148
- };
149
-
150
- window.STX.destroyComponent = function(instance) {
151
- if (!instance.isMounted) return;
152
- instance.watchers.forEach(function(w) { w.stop(); });
153
- instance.destroyHooks.forEach(function(hook) {
154
- try { hook(); }
155
- catch (e) { console.error('[stx] onDestroy error:', e); }
156
- });
157
- instance.refs.forEach(function(ref) { ref.value = null; });
158
- instance.isMounted = false;
159
- instances.delete(instance.id);
160
- };
161
-
162
- // ==========================================================================
163
- // Vue-Style Refs System - No document.** required!
164
- // ==========================================================================
165
-
166
- // Internal: Query for ref elements without exposing document API
167
- function queryRef(name, root) {
168
- return (root || document).querySelector('[data-stx-ref="' + name + '"], [data-ref="' + name + '"]');
169
- }
170
-
171
- function queryAllRefs(root) {
172
- return (root || document).querySelectorAll('[data-stx-ref], [data-ref]');
173
- }
174
-
175
- // Auto-bind refs from ref attributes (Vue-style)
176
- window.STX.bindRefs = function(root, refs) {
177
- if (!root) return;
178
- queryAllRefs(root).forEach(function(el) {
179
- var refName = el.getAttribute('data-stx-ref') || el.getAttribute('data-ref');
180
- if (refs[refName]) {
181
- refs[refName].value = el;
182
- }
183
- });
184
- };
185
-
186
- // Vue-style useRefs() - returns object with all refs as direct elements
187
- // Usage: const { input, button, container } = STX.useRefs()
188
- window.STX.useRefs = function(root) {
189
- var refs = {};
190
- queryAllRefs(root).forEach(function(el) {
191
- var refName = el.getAttribute('data-stx-ref') || el.getAttribute('data-ref');
192
- if (refName) {
193
- refs[refName] = el;
194
- }
195
- });
196
- return refs;
197
- };
198
-
199
- // Get a single ref by name - Vue's useTemplateRef equivalent
200
- // Usage: const input = STX.useRef('input')
201
- window.STX.useRef = function(name, root) {
202
- return queryRef(name, root);
203
- };
204
-
205
- // Two-way binding helper for form elements
206
- // Usage: STX.model(inputEl, state, 'username')
207
- window.STX.model = function(el, state, key) {
208
- if (!el || !state) return;
209
-
210
- var isCheckbox = el.type === 'checkbox';
211
- var isRadio = el.type === 'radio';
212
- var isSelect = el.tagName === 'SELECT';
213
-
214
- // Set initial value
215
- if (isCheckbox) {
216
- el.checked = !!state[key];
217
- }
218
- else if (isRadio) {
219
- el.checked = el.value === state[key];
220
- }
221
- else {
222
- el.value = state[key] || '';
223
- }
224
-
225
- // Listen for changes
226
- var eventType = isCheckbox || isRadio ? 'change' : 'input';
227
- el.addEventListener(eventType, function() {
228
- if (isCheckbox) {
229
- state[key] = el.checked;
230
- }
231
- else if (isRadio) {
232
- if (el.checked) state[key] = el.value;
233
- }
234
- else {
235
- state[key] = el.value;
236
- }
237
- });
238
-
239
- // Return cleanup function
240
- return function() {
241
- el.removeEventListener(eventType, arguments.callee);
242
- };
243
- };
244
-
245
- // Batch event binding helper - cleaner than manual addEventListener
246
- // Usage: STX.on({ click: [btn1, btn2], input: [textField] }, handler)
247
- window.STX.on = function(el, event, handler) {
248
- if (!el) return function() {};
249
- el.addEventListener(event, handler);
250
- return function() { el.removeEventListener(event, handler); };
251
- };
252
-
253
- // Bind multiple events at once
254
- // Usage: STX.events(refs.btn, { click: handleClick, mouseenter: handleHover })
255
- window.STX.events = function(el, eventMap) {
256
- if (!el) return function() {};
257
- var cleanups = [];
258
- Object.keys(eventMap).forEach(function(event) {
259
- el.addEventListener(event, eventMap[event]);
260
- cleanups.push(function() { el.removeEventListener(event, eventMap[event]); });
261
- });
262
- return function() { cleanups.forEach(function(c) { c(); }); };
263
- };
264
-
265
- // ==========================================================================
266
- // DOM Helpers - Eliminate document.* usage
267
- // ==========================================================================
268
-
269
- // Global keyboard event listener
270
- // Usage: STX.onKey('Escape', () => closeModal())
271
- window.STX.onKey = function(key, handler, options) {
272
- var listener = function(e) {
273
- if (e.key === key) {
274
- handler(e);
275
- }
276
- };
277
- document.addEventListener('keydown', listener, options);
278
- return function() { document.removeEventListener('keydown', listener, options); };
279
- };
280
-
281
- // Create element helper
282
- // Usage: STX.el('div', { class: 'foo' }, 'text content')
283
- window.STX.el = function(tag, attrs, content) {
284
- var el = document.createElement(tag);
285
- if (attrs) {
286
- Object.keys(attrs).forEach(function(key) {
287
- if (key === 'class') {
288
- el.className = attrs[key];
289
- }
290
- else if (key.startsWith('on')) {
291
- el.addEventListener(key.slice(2).toLowerCase(), attrs[key]);
292
- }
293
- else {
294
- el.setAttribute(key, attrs[key]);
295
- }
296
- });
297
- }
298
- if (content) {
299
- if (typeof content === 'string') {
300
- el.textContent = content;
301
- }
302
- else if (Array.isArray(content)) {
303
- content.forEach(function(child) { el.appendChild(child); });
304
- }
305
- else {
306
- el.appendChild(content);
307
- }
308
- }
309
- return el;
310
- };
311
-
312
- // Get currently focused element
313
- // Usage: const focused = STX.activeElement()
314
- window.STX.activeElement = function() {
315
- return document.activeElement;
316
- };
317
-
318
- // Escape HTML helper
319
- // Usage: const safe = STX.escapeHtml(userInput)
320
- window.STX.escapeHtml = function(text) {
321
- var div = document.createElement('div');
322
- div.textContent = text;
323
- return div.innerHTML;
324
- };
325
-
326
- // MutationObserver for automatic lifecycle management
327
- const observer = new MutationObserver(function(mutations) {
328
- mutations.forEach(function(mutation) {
329
- // Handle removed nodes
330
- mutation.removedNodes.forEach(function(node) {
331
- if (node.nodeType === 1 && node.__stx_instance__) {
332
- window.STX.destroyComponent(node.__stx_instance__);
333
- }
334
- });
335
- });
336
- });
337
-
338
- // Start observing when DOM is ready
339
- if (document.readyState === 'loading') {
340
- document.addEventListener('DOMContentLoaded', function() {
341
- observer.observe(document.body, { childList: true, subtree: true });
342
- });
343
- }
344
- else {
345
- observer.observe(document.body, { childList: true, subtree: true });
346
- }
347
-
348
- console.log('[stx] Lifecycle runtime initialized');
349
- })();
350
- `}function Ge(r){return Symbol(r)}var Ds=Ge("theme"),Is=Ge("router"),Os=Ge("i18n");import*as ft from"crypto";function pt(r){let e=/\$(\w+)\./g,c=[],a;while((a=e.exec(r))!==null)if(!c.includes(a[1]))c.push(a[1]);return c}function Pn(){return`stx-${ft.randomBytes(4).toString("hex")}`}function Ln(r){return/\$\w+\./.test(r)}function jn(r){if(!/\{\{[^}]*\$\w/.test(r)||!/\$\w+\./.test(r))return{html:r,bindings:[],stores:new Set};let e=[],c=new Set,a=/<(\w+)([^>]*?)(\s*\/?>)/g,d=r;return d=d.replace(a,(n,g,v,m)=>{if(["script","style","template"].includes(g.toLowerCase()))return n;if(!v.includes("{{"))return n;let x=[],b=!1,w=v,S=/(\w+(?:-\w+)*)\s*=\s*"([^"]*\{\{[^}]*\$\w+[^}]*\}\}[^"]*)"/g,k=[...v.matchAll(S)];for(let M of k){let O=M[0],N=M[1],H=M[2];if(Ln(H)){b=!0;let V=H.match(/\{\{\s*([\s\S]+?)\s*\}\}/);if(V){let P=V[1];if(x.push({attr:N,expr:P,fullMatch:O,originalAttr:N}),pt(P).forEach((B)=>c.add(B)),N==="text")w=w.replace(O,"");else if(N==="class")w=w.replace(O,'class=""');else if(N==="disabled"||N==="hidden")w=w.replace(O,"");else w=w.replace(O,`${N}=""`)}}}if(!b)return n;let D=w.match(/\bid\s*=\s*"([^"]+)"/),R;if(D)R=D[1];else R=Pn(),w=` id="${R}"${w}`;for(let M of x)e.push({elementId:R,attribute:M.attr,expression:M.expr,stores:pt(M.expr)});return`<${g}${w}${m}`}),{html:d,bindings:e,stores:c}}function Nn(r,e){if(r.length===0)return"";let c=Array.from(e),a=`
351
- <script>
352
- (function() {
353
- 'use strict';
354
-
355
- // Wait for stores to be available
356
- function initBindings() {
357
- var stores = window.VoideStores;
358
- if (!stores) {
359
- setTimeout(initBindings, 10);
360
- return;
361
- }
362
-
363
- // Store references for expressions
364
- // eslint-disable-next-line pickier/no-unused-vars
365
- var $state = {};
366
- `;for(let d of c)a+=` $state.${d} = stores.${d} ? stores.${d}.get() : {};
367
- `;a+=`
368
- // Binding update functions
369
- function updateBindings() {
370
- `;for(let d of r){let{elementId:n,attribute:g,expression:v}=d,m=v.replace(/\$(\w+)\./g,"$state.$1.");if(g==="text")a+=` (function() {
371
- var el = document.getElementById('${n}');
372
- if (el) {
373
- try {
374
- el.textContent = ${m};
375
- }
376
- catch (e) { console.error('Binding error:', e); }
377
- }
378
- })();
379
- `;else if(g==="html")a+=` (function() {
380
- var el = document.getElementById('${n}');
381
- if (el) {
382
- try {
383
- el.innerHTML = ${m};
384
- }
385
- catch (e) { console.error('Binding error:', e); }
386
- }
387
- })();
388
- `;else if(g==="class")a+=` (function() {
389
- var el = document.getElementById('${n}');
390
- if (el) {
391
- try {
392
- var value = ${m};
393
- if (typeof value === 'string') {
394
- // Dynamic class string - merge with existing static classes
395
- // eslint-disable-next-line pickier/no-unused-vars
396
- var staticClasses = el.getAttribute('data-static-class') || el.className;
397
- if (!el.hasAttribute('data-static-class')) {
398
- el.setAttribute('data-static-class', el.className);
399
- }
400
- el.className = (el.getAttribute('data-static-class') + ' ' + value).trim();
401
- }
402
- else if (typeof value === 'object') {
403
- // Object syntax: { 'class-name': condition }
404
- for (var cls in value) {
405
- if (value[cls]) {
406
- el.classList.add(cls);
407
- }
408
- else {
409
- el.classList.remove(cls);
410
- }
411
- }
412
- }
413
- }
414
- catch (e) { console.error('Binding error:', e); }
415
- }
416
- })();
417
- `;else if(g==="show")a+=` (function() {
418
- var el = document.getElementById('${n}');
419
- if (el) {
420
- try {
421
- el.style.display = (${m}) ? '' : 'none';
422
- }
423
- catch (e) { console.error('Binding error:', e); }
424
- }
425
- })();
426
- `;else if(g==="if")a+=` (function() {
427
- var el = document.getElementById('${n}');
428
- if (el) {
429
- try {
430
- el.style.visibility = (${m}) ? 'visible' : 'hidden';
431
- }
432
- catch (e) { console.error('Binding error:', e); }
433
- }
434
- })();
435
- `;else a+=` (function() {
436
- var el = document.getElementById('${n}');
437
- if (el) {
438
- try {
439
- var value = ${m};
440
- if (value === false || value === null || value === undefined) {
441
- el.removeAttribute('${g}');
442
- }
443
- else if (value === true) {
444
- el.setAttribute('${g}', '');
445
- }
446
- else {
447
- el.setAttribute('${g}', value);
448
- }
449
- }
450
- catch (e) { console.error('Binding error:', e); }
451
- }
452
- })();
453
- `}a+=` }
454
-
455
- // Subscribe to stores and update on changes. Capture the disposers so
456
- // SPA fragment swaps can tear down old bindings before the next page's
457
- // runtime takes over \u2014 without this, every navigation between pages
458
- // using reactive-bindings stacked another subscription on every store,
459
- // walking detached DOM forever. See stacksjs/stx#1709.
460
- var _disposers = [];
461
- `;for(let d of c)a+=` if (stores.${d}) {
462
- var _unsub_${d} = stores.${d}.subscribe(function(state) {
463
- $state.${d} = state;
464
- updateBindings();
465
- });
466
- // store.subscribe() may return the disposer (preferred) or void; both
467
- // are tolerated here.
468
- if (typeof _unsub_${d} === 'function') _disposers.push(_unsub_${d});
469
- }
470
- `;return a+=`
471
- // Initial update
472
- updateBindings();
473
-
474
- // Register this runtime's cleanup so SPA navigation can run it before
475
- // swapping pages. The router (and any code) can call
476
- // window.__stxCleanupBindings() to dispose subscriptions; we also wire
477
- // 'popstate' and 'beforeunload' as a safety net for browser-driven nav.
478
- function _cleanup() {
479
- for (var i = 0; i < _disposers.length; i++) {
480
- try { _disposers[i](); } catch (e) { /* swallow */ }
481
- }
482
- _disposers.length = 0;
483
- }
484
- if (!window.__stxBindingsCleanups) window.__stxBindingsCleanups = [];
485
- window.__stxBindingsCleanups.push(_cleanup);
486
- if (!window.__stxCleanupBindings) {
487
- window.__stxCleanupBindings = function() {
488
- var fns = window.__stxBindingsCleanups || [];
489
- for (var i = 0; i < fns.length; i++) {
490
- try { fns[i](); } catch (e) { /* swallow */ }
491
- }
492
- window.__stxBindingsCleanups = [];
493
- };
494
- window.addEventListener('popstate', window.__stxCleanupBindings);
495
- window.addEventListener('beforeunload', window.__stxCleanupBindings);
496
- }
497
- }
498
-
499
- // Start when DOM is ready
500
- if (document.readyState === 'loading') {
501
- document.addEventListener('DOMContentLoaded', initBindings);
502
- }
503
- else {
504
- initBindings();
505
- }
506
- })();
507
- </script>
508
- `,a}function gt(r){let{html:e,bindings:c,stores:a}=jn(r);if(c.length===0)return r;let d=Nn(c,a),n=e.lastIndexOf("</body>");if(n!==-1)return e.slice(0,n)+d+e.slice(n);return e+d}function Hn(r){let e=r.analytics;if(!e?.enabled)return"";switch(e.driver){case"fathom":return Bn(e);case"google-analytics":return Fn(e);case"plausible":return qn(e);case"self-hosted":return Un(e);case"custom":return Vn(e);default:return""}}function Bn(r){let e=r.fathom;if(!e?.siteId)return"";let c=e.scriptUrl||"https://cdn.usefathom.com/script.js",a=e.defer!==!1?" defer":"",d=[`data-site="${ue(e.siteId)}"`];if(e.honorDnt)d.push('data-honor-dnt="true"');if(e.spa)d.push('data-spa="auto"');if(e.canonical)d.push(`data-canonical="${ue(e.canonical)}"`);if(e.auto===!1)d.push('data-auto="false"');return`
509
- <!-- Fathom Analytics -->
510
- <script src="${ue(c)}" ${d.join(" ")}${a}></script>
511
- `}function Fn(r){let e=r.googleAnalytics;if(!e?.measurementId)return"";let c=ue(e.measurementId),a=e.debug?`gtag('config', '${c}', { 'debug_mode': true });`:"";return`
512
- <!-- Google Analytics -->
513
- <script async src="https://www.googletagmanager.com/gtag/js?id=${c}"></script>
514
- <script>
515
- window.dataLayer = window.dataLayer || [];
516
- function gtag(){dataLayer.push(arguments);}
517
- gtag('js', new Date());
518
- gtag('config', '${c}');
519
- ${a}
520
- </script>
521
- `}function qn(r){let e=r.plausible;if(!e?.domain)return"";let c=e.scriptUrl||"https://plausible.io/js/script.js",a=[`data-domain="${ue(e.domain)}"`],d=c,n=[];if(e.trackLocalhost)n.push("local");if(e.hashMode)n.push("hash");if(n.length>0&&c==="https://plausible.io/js/script.js")d=`https://plausible.io/js/script.${n.join(".")}.js`;return`
522
- <!-- Plausible Analytics -->
523
- <script defer data-domain="${ue(e.domain)}" src="${ue(d)}"></script>
524
- `}function Un(r){let e=r.selfHosted;if(!e?.siteId||!e?.apiEndpoint)return"";let c=ue(e.siteId),a=ue(e.apiEndpoint),d=e.honorDnt?'if(n.doNotTrack==="1")return;':"",n=e.trackHashChanges?"w.addEventListener('hashchange',pv);":"",g=e.trackOutboundLinks?`
525
- d.addEventListener('click',function(e){
526
- var a=e.target.closest('a');
527
- if(a&&a.hostname!==location.hostname){
528
- t('outbound',{url:a.href});
529
- }
530
- });`:"";return`
531
- <!-- Self-Hosted Analytics -->
532
- <script data-site="${c}" data-api="${a}" defer>
533
- (function(){
534
- 'use strict';
535
- var d=document,w=window,n=navigator,s=d.currentScript;
536
- var site=s.dataset.site,api=s.dataset.api;
537
- ${d}
538
- var q=[],sid=Math.random().toString(36).slice(2);
539
- function t(e,p){
540
- var x=new XMLHttpRequest();
541
- x.open('POST',api+'/collect',true);
542
- x.setRequestHeader('Content-Type','application/json');
543
- x.send(JSON.stringify({
544
- s:site,sid:sid,e:e,p:p||{},
545
- u:location.href,r:d.referrer,t:d.title,
546
- sw:screen.width,sh:screen.height
547
- }));
548
- }
549
- function pv(){t('pageview');}
550
- ${n}
551
- ${g}
552
- if(d.readyState==='complete')pv();
553
- else w.addEventListener('load',pv);
554
- w.stxAnalytics={track:function(n,v){t('event',{name:n,value:v});}};
555
- })();
556
- </script>
557
- `}function Vn(r){let e=r.custom;if(!e)return"";if(e.inlineScript)return`
558
- <!-- Custom Analytics -->
559
- <script>
560
- ${e.inlineScript}
561
- </script>
562
- `;if(!e.scriptUrl)return"";let c=[];if(e.scriptId)c.push(`id="${ue(e.scriptId)}"`);if(e.attributes)for(let[d,n]of Object.entries(e.attributes))c.push(`${ue(d)}="${ue(n)}"`);return`
563
- <!-- Custom Analytics -->
564
- <script${c.length>0?` ${c.join(" ")}`:""} src="${ue(e.scriptUrl)}" defer></script>
565
- `}function mt(r,e){let c=Hn(e);if(!c)return r;if(!r.includes("</head>")){let a=r.lastIndexOf("</body>");if(a!==-1)return r.slice(0,a)+c+r.slice(a);return r+c}return r.replace("</head>",`${c}</head>`)}function ue(r){return r.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/'/g,"&#39;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function yt(r){let e=r.match(/\bdefinePageMeta\s*\(\s*(\{[\s\S]*?\})\s*\)/m);if(!e)return null;try{return Function(`return ${e[1]}`)()}catch{return null}}function ht(r){let e=r?.layout;if(e===!1)return!1;return typeof e==="string"&&e.trim()?e.trim():void 0}var zn=0,Wn=0;function vt(r,e){let c=r.match(new RegExp(`${e}\\s*=\\s*"([^"]*)"`,"i"));if(c)return c[1];let a=r.match(new RegExp(`${e}\\s*=\\s*'([^']*)'`,"i"));if(a)return a[1];return null}function Xn(r){let e=[],c=/<([a-z][a-z0-9-]*)\s+([^>]*x-data\s*=\s*(?:"[^"]*"|'[^']*')[^>]*)>/gi,a;while((a=c.exec(r))!==null){let[d,n,g]=a,v=a.index,m=vt(g,"x-data");if(!m)continue;let x=`__stx_scope_${zn++}`,b=vt(g,"x-init"),w=Kn(r,n,v+d.length),S=r.slice(v,w.endIndex),k=Gn(S);e.push({id:x,selector:`[data-stx-scope="${x}"]`,stateExpr:m,initExpr:b,bindings:[],refs:k})}return e}function Kn(r,e,c){let a=1,d=c,n=new RegExp(`<${e}(?:\\s|>)`,"gi"),g=new RegExp(`</${e}>`,"gi"),v=new RegExp(`<${e}[^>]*/\\s*>`,"gi");while(a>0&&d<r.length){n.lastIndex=d,g.lastIndex=d,v.lastIndex=d;let m=n.exec(r),x=g.exec(r),b=v.exec(r);if(b&&b.index<(m?.index??1/0)){d=b.index+b[0].length;continue}if(!x)return{endIndex:r.length};if(m&&m.index<x.index)a++,d=m.index+m[0].length;else{if(a--,a===0)return{endIndex:x.index+x[0].length};d=x.index+x[0].length}}return{endIndex:r.length}}function Gn(r){let e=new Map,c=r.replace(/x-data\s*=\s*"[^"]*"/gi,'x-data="__stripped__"').replace(/x-data\s*=\s*'[^']*'/gi,"x-data='__stripped__'"),a=/<[a-z][a-z0-9-]*\s+([^>]*x-ref\s*=\s*["']([^"']*)["'][^>]*)>/gi,d;while((d=a.exec(c))!==null){let[,n,g]=d,v=Jn(n);e.set(g,v)}return e}function Jn(r){let e=r.match(/\bid\s*=\s*["']([^"']*)["']/);if(e)return e[1];return`__stx_el_${Wn++}`}function Zn(){return`
566
- // STX Reactive Runtime - x-cloak and transition CSS
567
- (function() {
568
- var style = document.createElement('style');
569
- style.textContent = [
570
- '[x-cloak] { display: none !important; }',
571
- // Default transition classes
572
- '.stx-enter { opacity: 0; transform: scale(0.95); }',
573
- '.stx-enter-start { opacity: 0; transform: scale(0.95); }',
574
- '.stx-enter-active { transition: opacity 150ms ease-out, transform 150ms ease-out; }',
575
- '.stx-enter-to { opacity: 1; transform: scale(1); }',
576
- '.stx-leave { opacity: 1; transform: scale(1); }',
577
- '.stx-leave-start { opacity: 1; transform: scale(1); }',
578
- '.stx-leave-active { transition: opacity 100ms ease-in, transform 100ms ease-in; }',
579
- '.stx-leave-to { opacity: 0; transform: scale(0.95); }'
580
- ].join('\\n');
581
- document.head.appendChild(style);
582
- })();
583
-
584
- // STX Reactive Runtime
585
- /* eslint-disable pickier/no-unused-vars, no-console, prefer-const */
586
- window.__stx_reactive = (function() {
587
- 'use strict';
588
-
589
- // Deep reactive proxy that triggers onChange for any mutation
590
- function reactive(obj, onChange) {
591
- if (!obj || typeof obj !== 'object') return obj;
592
- return new Proxy(obj, {
593
- get(target, prop) {
594
- const value = target[prop];
595
- if (value && typeof value === 'object' && !Array.isArray(value) && !(value instanceof Promise)) {
596
- return reactive(value, onChange);
597
- }
598
- return value;
599
- },
600
- set(target, prop, value) {
601
- target[prop] = value;
602
- onChange(prop, value);
603
- return true;
604
- }
605
- });
606
- }
607
-
608
- // Initialize an x-data scope: parse state, run init(), register into window.stx._scopes,
609
- // then let the signals runtime handle all directive processing (x-for, x-text, :bind, etc.)
610
- function initScope(scopeEl, initialState, bindings, refs, initExpr) {
611
- // Parse initial state (may contain methods including async init())
612
- var state;
613
- try {
614
- state = new Function('return (' + initialState + ')')();
615
- } catch (e) {
616
- console.error('[stx-reactive] Invalid x-data:', initialState, e);
617
- return;
618
- }
619
-
620
- // Build $refs object
621
- var $refs = {};
622
- for (var name in refs) {
623
- if (Object.prototype.hasOwnProperty.call(refs, name)) {
624
- (function(refName, refId) {
625
- Object.defineProperty($refs, refName, {
626
- get: function() { return document.getElementById(refId); }
627
- });
628
- })(name, refs[name]);
629
- }
630
- }
631
-
632
- // Extract init method from state if present (Alpine.js convention)
633
- var initMethod = state.init;
634
- if (typeof initMethod === 'function') {
635
- delete state.init;
636
- }
637
-
638
- // Make state reactive \u2014 mutations trigger re-render via signals
639
- var scopeId = scopeEl.getAttribute('data-stx-scope');
640
- var stx = window.stx;
641
-
642
- // Create signals for each state property so the signals runtime can track dependencies
643
- var signalState = {};
644
- var rawState = {};
645
- var derivedState = {};
646
- var accessors = {};
647
- // A getter must NOT be read here. Reading one calls it, and the old loop did
648
- // exactly that: the returned value is not a function, so it was wrapped as a
649
- // plain state() -- a snapshot of the answer at construction time, frozen
650
- // forever while plain properties beside it updated (#2053). A getter is a
651
- // derived value, so it is registered as one below, once ctxProxy exists for
652
- // it to read through.
653
- var ownDescriptors = Object.getOwnPropertyDescriptors ? Object.getOwnPropertyDescriptors(state) : {};
654
- for (var key in state) {
655
- if (Object.prototype.hasOwnProperty.call(state, key)) {
656
- var descriptor = ownDescriptors[key];
657
- if (descriptor && typeof descriptor.get === 'function') {
658
- accessors[key] = descriptor;
659
- continue;
660
- }
661
- if (typeof state[key] === 'function') {
662
- // Methods \u2014 bind to a proxy so 'this.prop = val' triggers signal updates
663
- signalState[key] = state[key];
664
- } else {
665
- // Data properties \u2014 wrap in signals for reactivity
666
- signalState[key] = stx.state(state[key]);
667
- rawState[key] = true;
668
- }
669
- }
670
- }
671
-
672
- // Create a proxy context that auto-unwraps signals and writes back through them.
673
- // Methods get 'this' bound to this proxy so this.foo = bar triggers reactivity.
674
- var ctx = {};
675
- var ctxProxy = new Proxy(ctx, {
676
- get: function(target, prop) {
677
- if (prop === '$refs') return $refs;
678
- if (prop === '$el') return scopeEl;
679
- if (prop === '$nextTick') return function(fn) { requestAnimationFrame(fn); };
680
- var s = signalState[prop];
681
- if (!s) return undefined;
682
- if (rawState[prop] && s && typeof s === 'function' && typeof s.value !== 'undefined') {
683
- return s.value; // unwrap signal
684
- }
685
- if (typeof s === 'function' && !rawState[prop]) {
686
- return s.bind(ctxProxy); // bind methods to proxy
687
- }
688
- return s;
689
- },
690
- set: function(target, prop, value) {
691
- var accessor = derivedState[prop];
692
- if (accessor) {
693
- // A getter/setter pair writes through its setter. A getter alone has
694
- // nowhere to put the value: a derived has no .value setter, so the
695
- // assignment would be a silent no-op, which is the same class of
696
- // failure as the stale read this replaces.
697
- if (typeof accessor.set === 'function') {
698
- accessor.set.call(ctxProxy, value);
699
- return true;
700
- }
701
- console.warn('[stx-reactive] cannot assign to ' + String(prop) + ': it is a getter in x-data, so its value comes from what it reads. Give it a setter, or make it a plain property.');
702
- return true;
703
- }
704
- var s = signalState[prop];
705
- if (rawState[prop] && s && typeof s === 'function') {
706
- s.value = value; // write through signal \u2014 triggers effects
707
- } else {
708
- signalState[prop] = value;
709
- }
710
- return true;
711
- },
712
- has: function(target, prop) {
713
- return prop in signalState || prop === '$refs' || prop === '$el' || prop === '$nextTick';
714
- },
715
- ownKeys: function() {
716
- return Object.keys(signalState).concat(['$refs', '$el', '$nextTick']);
717
- },
718
- getOwnPropertyDescriptor: function(target, prop) {
719
- if (prop in signalState || prop === '$refs' || prop === '$el' || prop === '$nextTick') {
720
- return { configurable: true, enumerable: true, writable: true, value: ctxProxy[prop] };
721
- }
722
- return undefined;
723
- }
724
- });
725
-
726
- // Now that ctxProxy exists, a getter becomes a derived that reads through it,
727
- // so it tracks whatever it touches and recomputes when that changes. derived()
728
- // is lazy, so nothing is evaluated until a binding actually reads it.
729
- //
730
- // Marked rawState as well: that is what makes the proxy unwrap it and what
731
- // exposes the signal itself to the runtime below, which is where dependency
732
- // tracking comes from. A getter needs both, exactly like a data property.
733
- for (var accessorKey in accessors) {
734
- if (Object.prototype.hasOwnProperty.call(accessors, accessorKey)) {
735
- (function(name, descriptor) {
736
- signalState[name] = stx.derived(function() {
737
- return descriptor.get.call(ctxProxy);
738
- });
739
- rawState[name] = true;
740
- derivedState[name] = descriptor;
741
- })(accessorKey, accessors[accessorKey]);
742
- }
743
- }
744
-
745
- // Build scope vars for the signals runtime \u2014 it reads these for expression evaluation.
746
- // We need to provide getter/setter descriptors so signals track properly.
747
- var scopeVars = {};
748
- for (var k in signalState) {
749
- if (Object.prototype.hasOwnProperty.call(signalState, k)) {
750
- if (rawState[k]) {
751
- // Data: expose the signal directly so expressions trigger dependency tracking
752
- scopeVars[k] = signalState[k];
753
- } else {
754
- // Method: bind to ctxProxy so 'this' works
755
- scopeVars[k] = (typeof signalState[k] === 'function') ? signalState[k].bind(ctxProxy) : signalState[k];
756
- }
757
- }
758
- }
759
- scopeVars.$refs = $refs;
760
- scopeVars.$el = scopeEl;
761
- scopeVars.$nextTick = function(fn) { requestAnimationFrame(fn); };
762
-
763
- // Register scope \u2014 merge with any existing vars from partial signal scripts
764
- if (!stx._scopes) stx._scopes = {};
765
- stx._scopes[scopeId] = Object.assign(stx._scopes[scopeId] || {}, scopeVars);
766
-
767
- // Store on element for findElementScope
768
- scopeEl.__stx_scope = scopeVars;
769
-
770
- // Run init() if present (supports async)
771
- function runInit() {
772
- var maybePromise;
773
- if (initMethod) {
774
- maybePromise = initMethod.call(ctxProxy);
775
- }
776
- if (initExpr) {
777
- try {
778
- var keys = Object.keys(scopeVars);
779
- var vals = keys.map(function(k) { return scopeVars[k]; });
780
- var fn = new Function(keys.join(','), initExpr);
781
- var result = fn.apply(ctxProxy, vals);
782
- if (result && typeof result.then === 'function') maybePromise = result;
783
- } catch (e) {
784
- console.warn('[stx-reactive] init expression error:', e);
785
- }
786
- }
787
- // If init is async, signal updates will trigger effects automatically
788
- // when init() resolves and sets this.prop = value (writes through signal)
789
- if (maybePromise && typeof maybePromise.then === 'function') {
790
- maybePromise.catch(function(e) {
791
- console.error('[stx-reactive] async init() error:', e);
792
- });
793
- }
794
- }
795
-
796
- // Run init before the signals runtime processes this scope
797
- runInit();
798
-
799
- // Expose for debugging
800
- scopeEl.__stx_state = ctxProxy;
801
- scopeEl.__stx_execute = function(stmt, $event, $el) {
802
- try {
803
- // Run the statement with the reactive proxy as the lexical scope.
804
- // Wrapping in a with-block on the proxy makes bare reads/writes go
805
- // through it (so foo = bar triggers signal.set()) instead of treating
806
- // each state key as a local function parameter \u2014 bare assignments
807
- // would otherwise just rebind the local and never reach the signal.
808
- var fn = new Function('$event', '$el', 'with(this){' + stmt + ';}');
809
- fn.call(ctxProxy, $event, $el);
810
- } catch (e) {
811
- console.warn('[stx-reactive] execute error:', e);
812
- }
813
- };
814
- }
815
-
816
- return { initScope: initScope, reactive: reactive };
817
- })();
818
- `}function bt(r,e){let c=r.replace(/\{!!([\s\S]*?)!!\}/g,(v,m)=>{try{let x=T(m,e,!0);if(x===void 0)return v;return String(x)}catch{return v}}),a="",d=0,n=null;while(d<c.length){let v=c[d];if(n&&v==="\\"){a+=v+(c[d+1]??""),d+=2;continue}if(v==="{"&&c[d+1]==="{"){let m=c.indexOf("}}",d+2);if(m!==-1){let x=c.slice(d,m+2);a+=g(c.slice(d+2,m),x,n),d=m+2;continue}}if(n){if(v===n)n=null}else if(v==="'"||v==='"'||v==="`")n=v;a+=v,d++}return a;function g(v,m,x){let b;try{b=T(v,e,!0)}catch{return m}if(b===void 0)return m;if(x){let w=String(b).replace(/\\/g,"\\\\").replace(new RegExp(x==="`"?"`":x,"g"),`\\${x}`).replace(/\r/g,"\\r").replace(/\n/g,"\\n");return x==="`"?w.replace(/\$\{/g,"\\${"):w}if(typeof b==="string"){let w=b.trim();if(w.startsWith("{")&&w.endsWith("}")||w.startsWith("[")&&w.endsWith("]"))try{return JSON.parse(w),w}catch{}}return JSON.stringify(b)}}function Qn(r,e){if(r.length===0)return"";let c=r.map((a)=>{let d=JSON.stringify(Object.fromEntries(a.refs)),n=bt(a.stateExpr,e),g=a.initExpr?bt(a.initExpr,e):null,v=JSON.stringify(n),m=g?JSON.stringify(g):"null";return`
819
- (function() {
820
- var scopeEl = document.querySelector('${a.selector}');
821
- if (!scopeEl) return;
822
- var refs = ${d};
823
- __stx_reactive.initScope(scopeEl, ${v}, [], refs, ${m});
824
- })();`}).join(`
825
- `);return`
826
- <script data-stx-scoped data-stx-reactive data-stx-run="always">
827
- ${Zn()}
828
- ${c}
829
- </script>`}function wt(r,e,c){if(!er(r))return r;let a=Xn(r);if(a.length===0)return r;let d=Yn(r,a),n=Qn(a,e),g=d.lastIndexOf("</body>");if(g!==-1)d=d.slice(0,g)+n+`
830
- `+d.slice(g);else d+=n;return d}function Yn(r,e){let c=0,a=r.replace(/<([a-z][a-z0-9-]*)(\s+[^>]*x-data\s*=\s*(?:"[^"]*"|'[^']*')[^>]*)>/gi,(d,n,g)=>{let v=e[c++];if(!v)return d;let m=/data-stx-scope="([^"]*)"/.exec(g);if(m)return v.id=m[1],v.selector=`[data-stx-scope="${v.id}"]`,d;return`<${n} data-stx-scope="${v.id}"${g}>`});return a=a.replace(/\s*x-data\s*=\s*"([^"]*)"/g,' data-stx-xdata="$1"'),a=a.replace(/\s*x-data\s*=\s*'([^']*)'/g," data-stx-xdata='$1'"),a=a.replace(/\s*x-init\s*=\s*"([^"]*)"/g,' data-stx-xinit="$1"'),a=a.replace(/\s*x-init\s*=\s*'([^']*)'/g," data-stx-xinit='$1'"),a}function er(r){return/x-data\s*=\s*["']/.test(r)}import nr from"fs";import Je from"path";import{createHighlighter as rr}from"ts-syntax-highlighter";var Ze=new Map;async function Re(r,e={}){try{if(!await s(r))throw Error(`Markdown file not found: ${r}`);let a=(await nr.promises.stat(r)).mtime.getTime();if(e.cache&&Ze.has(r)){let w=Ze.get(r);if(w.updatedAt>=a)return{content:w.content,data:w.data}}let d=await Bun.file(r).text(),{data:n,content:g}=dr(d),v=e.markdown||I.markdown||{enabled:!0,syntaxHighlighting:{enabled:!0,serverSide:!0,defaultTheme:"github-dark",highlightUnknownLanguages:!0}},x=Qe(g,{gfm:!0});if(v.syntaxHighlighting?.enabled&&v.syntaxHighlighting?.serverSide)x=await sr(x,v.syntaxHighlighting?.defaultTheme||"github-dark",v.syntaxHighlighting?.highlightUnknownLanguages||!1);let b={content:x,data:n||{}};if(e.cache)Ze.set(r,{...b,updatedAt:a});return b}catch(c){if(e.debug)console.error(`Error reading/parsing markdown file ${r}:`,c);let a=c instanceof Error?c.message:String(c);return{content:h("Markdown File",`Error reading/parsing markdown file: ${a}`,r,"",0,""),data:{}}}}var Ue=null;async function sr(r,e,c){let a=/<pre><code( class="language-([^"]+)")?>([^<]+)<\/code><\/pre>/g;if(!Ue)try{Ue=await rr({theme:e||"github-dark",cache:!0})}catch(v){return console.error("Failed to initialize ts-syntax-highlighter:",v),r}let d=async(v,m,x,b)=>{let w=b.replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&amp;/g,"&").replace(/&quot;/g,'"').replace(/&#39;/g,"'"),S=x||(c?"text":"");if(!S)return v;try{if(!Ue.getSupportedLanguages().includes(S))return v;return(await Ue.highlight(w,S,{theme:e})).html}catch(k){console.error(`Error highlighting code block with language ${x}:`,k)}return v},n=r,g=r.matchAll(a);for(let v of g){let[m,x,b,w]=v,S=await d(m,x,b,w);n=n.replace(m,S)}return n}async function xt(r,e,c="",a={}){return await ir(r,/@markdown-file\(\s*['"]([^'"]+)['"]\s*(?:,\s*(\{[^}]*\}))?\)/g,async(g,v,m,x)=>{try{let b=v;if(!Je.isAbsolute(v))b=Je.resolve(Je.dirname(c),v);let w={};if(m)try{try{w=JSON.parse(m)}catch{if(a.debug)console.warn("Using safer alternative for parsing JS object literal");let N=m.replace(/^\s*\{|\}\s*$/g,"").trim().split(/,(?=\s*\w+\s*:)/);for(let H of N){let V=H.indexOf(":");if(V>0){let P=H.substring(0,V).trim(),L=H.substring(V+1).trim(),B=L.startsWith('"')&&L.endsWith('"'),X=L.startsWith("'")&&L.endsWith("'");if(B||X)L=L.substring(1,L.length-1);w[P]=L}}}}catch(O){if(a.debug)console.error("Error parsing context in @markdown-file directive:",O)}let{content:S,data:k}=await Re(b,a),D={...e,...k,...w},R=S,M=/\{\{([^}]+)\}\}/g;return R=R.replace(M,(O,N)=>{let H=N.trim();return D[H]!==void 0?String(D[H]):O}),R}catch(b){let w=b instanceof Error?b.message:String(b);return h("Markdown File",`Error including markdown file: ${w}`,c,r,x,g)}})}async function ir(r,e,c){let a=[],d;while((d=e.exec(r))!==null){let v=d[0],m=d.index,x=d;a.push(c(...x).then((b)=>({match:v,replacement:b,index:m})))}let n=await Promise.all(a);n.sort((v,m)=>m.index-v.index);let g=r;for(let{match:v,replacement:m}of n)g=g.replace(v,()=>m);return g}var St=new WeakMap;function kt(r=16){let e=new Uint8Array(r);return crypto.getRandomValues(e),btoa(String.fromCharCode(...e))}function Ve(r,e){if(!r)return e?.nonceGenerator?.()??kt();let c=St.get(r);if(!c)c=e?.nonceGenerator?.()??kt(),St.set(r,c);return c}function lr(r,e){let c=[];for(let[a,d]of Object.entries(r)){if(d===void 0||d===null)continue;if(typeof d==="boolean"){if(d)c.push(a);continue}if(Array.isArray(d)){let n=[...d];if(e&&(a==="script-src"||a==="style-src"))n=n.filter((g)=>!g.startsWith("'nonce-")),n.push(`'nonce-${e}'`);if(n.length>0)c.push(`${a} ${n.join(" ")}`)}}return c.join("; ")}function $t(r,e){return`<meta http-equiv="Content-Security-Policy" content="${lr(r,e).replace(/&/g,"&amp;").replace(/"/g,"&quot;")}">`}function Et(r,e,c){if(!e.enabled||!e.addMetaTag)return r;if(r.includes('http-equiv="Content-Security-Policy"'))return r;if(!r.includes("<head>")&&!r.includes("<head "))return r;let a=e.useNonce?Ve(c,e):void 0,d=$t(e.directives,a);return r.replace(/<head([^>]*)>/,`<head$1>
831
- ${d}`)}function _t(r,e){let c=r;return c=c.replace(/<script(?![^>]*\ssrc=)([^>]*)>/gi,(a,d)=>{if(d.includes("nonce="))return a;return`<script nonce="${e}"${d}>`}),c=c.replace(/<style([^>]*)>/gi,(a,d)=>{if(d.includes("nonce="))return a;return`<style nonce="${e}"${d}>`}),c}function Tt(r,e,c,a){let d=r,n=a.csp;if(d=d.replace(/@csp\b/g,()=>{if(!n?.enabled||!n.directives)return"<!-- CSP not configured -->";let g=n.useNonce?Ve(e,n):void 0;return $t(n.directives,g)}),d=d.replace(/@cspNonce\b/g,()=>{if(!n?.enabled||!n.useNonce)return"";return Ve(e,n)}),n?.enabled&&n.useNonce)e.cspNonce=Ve(e,n);return d}import ur from"crypto";var pr=40,Ct="_token",et=null;function fr(r=pr){let e=ur.randomBytes(Math.ceil(r/2)).toString("hex").slice(0,r);return et=e,e}function mr(){if(!et)fr();return et}function hr(r=Ct){let e=mr();return`<input type="hidden" name="${r}" value="${e}">`}function At(r){return r.replace(/@csrf(?:\((['"])([^'"]*)\1\))?/g,(e,c,a)=>hr(a||Ct))}async function Rt(r,e,c,a){if(!a.customDirectives||a.customDirectives.length===0)return r;let d=r;for(let n of a.customDirectives){if(!n.name||typeof n.handler!=="function"){if(a.debug)console.warn("Invalid custom directive:",n);continue}if(n.hasEndTag)d=await yr(d,n,e,c,a);else d=await br(d,n,e,c,a)}return d}async function yr(r,e,c,a,d){let{name:n,handler:g}=e,v=`@${n}`,m=`@end${n}`,x=r,b=Lt(`${v}(?:\\s*\\(([^()]*(?:\\([^)]*\\)[^()]*)*)\\))?([\\s\\S]*?)${m}`,"g"),w=[],S=b.exec(x);while(S!==null){let[k,D="",R=""]=S,M=S.index||0;try{let O=D?Mt(e,D):[],N=R.trim(),H=await g(N,O,c,a);w.push({original:k,processed:H,startIndex:M})}catch(O){let N=O instanceof Error?O.message:String(O);if(d.debug)console.error(`Error processing custom directive @${n}:`,O);w.push({original:k,processed:l("CustomDirective",`Error in @${n}${D?`(${D})`:""}: ${N}`,t.EVALUATION_ERROR),startIndex:M})}S=b.exec(x)}for(let k=w.length-1;k>=0;k--){let{original:D,processed:R}=w[k];x=x.replace(D,R)}return x}async function br(r,e,c,a,d){let{name:n,handler:g}=e,v=r,m=[],x=[];if(e.rawParams){for(let S of _i(v,Lt(`(?<![\\w$@])@${n}\\s*\\(`,"g")))if(S.end!==-1)x.push({fullMatch:S.call,paramString:S.args,startIndex:S.start})}else{let S=Lt(`@${n}\\s*\\(([^()]*(?:\\([^)]*\\)[^()]*)*)\\)`,"g");S.lastIndex=0;let k=S.exec(v);while(k!==null)x.push({fullMatch:k[0],paramString:k[1]??"",startIndex:k.index||0}),k=S.exec(v)}for(let{fullMatch:S,paramString:k,startIndex:D}of x)try{let R=Mt(e,k),M=await g("",R,c,a);m.push({original:S,processed:M,startIndex:D})}catch(R){let M=R instanceof Error?R.message:String(R);if(d.debug)console.error(`Error processing custom directive @${n}:`,R);m.push({original:S,processed:l("CustomDirective",`Error in @${n}(${k}): ${M}`,t.EVALUATION_ERROR),startIndex:D})}let b=Lt(`@${n}(?!\\w)(?!\\s*\\()`,"g"),w=b.exec(v);while(w!==null){let[S]=w,k=w.index||0;try{let D=await g("",[],c,a);m.push({original:S,processed:D,startIndex:k})}catch(D){let R=D instanceof Error?D.message:String(D);if(d.debug)console.error(`Error processing custom directive @${n}:`,D);m.push({original:S,processed:l("CustomDirective",`Error in @${n}: ${R}`,t.EVALUATION_ERROR),startIndex:k})}w=b.exec(v)}for(let S=m.length-1;S>=0;S--){let{original:k,processed:D}=m[S];v=v.replace(k,D)}return v}function Mt(r,e){return r.rawParams?Ft(e):wr(e)}function wr(r){if(!r.trim())return[];let e=[],c="",a=!1,d="";for(let n=0;n<r.length;n++){let g=r[n];if((g==='"'||g==="'")&&(n===0||r[n-1]!=="\\"))if(!a)a=!0,d=g;else if(g===d)a=!1;else c+=g;else if(g===","&&!a)e.push(c.trim()),c="";else c+=g}if(c.trim())e.push(c.trim());return e.map((n)=>{let g=n.trim();if(g.startsWith('"')&&g.endsWith('"')||g.startsWith("'")&&g.endsWith("'"))return g.substring(1,g.length-1);return g})}var It=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/,Ot=/^[A-Za-z_$][\w$]*$/,xr=new Set(["light","dark","system"]);function xe(r,e){if(typeof r!=="string"||r.length===0)throw Error(`@appearanceBootstrap ${e} must be a non-empty string`)}function Sr(r){if(!r||typeof r!=="object"||Array.isArray(r))throw Error("@appearanceBootstrap expects an options object");let e=r,{appearance:c,colorMode:a}=e;if(xe(e.storageKey,"storageKey"),c!==void 0&&(!c||typeof c!=="object"||Array.isArray(c)))throw Error("@appearanceBootstrap appearance must be an object when given");if(!a||typeof a!=="object"||Array.isArray(a))throw Error("@appearanceBootstrap colorMode must be an object");if(xe(a.key,"colorMode.key"),xe(a.attribute,"colorMode.attribute"),xe(a.default,"colorMode.default"),!Ot.test(a.key))throw Error("@appearanceBootstrap preference keys must be JavaScript property names");if(!It.test(a.attribute))throw Error("@appearanceBootstrap attributes must be lowercase data attribute names");if(!xr.has(a.default))throw Error("@appearanceBootstrap colorMode.default must be light, dark, or system");let d=null;if(c){if(xe(c.key,"appearance.key"),xe(c.attribute,"appearance.attribute"),xe(c.default,"appearance.default"),!Ot.test(c.key))throw Error("@appearanceBootstrap preference keys must be JavaScript property names");if(!It.test(c.attribute))throw Error("@appearanceBootstrap attributes must be lowercase data attribute names");if(!Array.isArray(c.allowed)||c.allowed.length===0||c.allowed.some((n)=>typeof n!=="string"||n.length===0))throw Error("@appearanceBootstrap appearance.allowed must contain one or more strings");if(!c.allowed.includes(c.default))throw Error("@appearanceBootstrap appearance.default must be in appearance.allowed");d={key:c.key,attribute:c.attribute,allowed:[...new Set(c.allowed)],default:c.default}}return{storageKey:e.storageKey,appearance:d,colorMode:{key:a.key,attribute:a.attribute,default:a.default},respectExisting:e.respectExisting===!0}}function kr(r){return JSON.stringify(r).replace(/</g,"\\u003c").replace(/>/g,"\\u003e").replace(/&/g,"\\u0026").replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}function Er(r){return`<script data-stx-scoped data-stx-appearance-bootstrap>(function(){"use strict";const config=${kr(r)};const root=document.documentElement;const MODES=["light","dark","system"];let format="json";const forced=(function(){const found={colorMode:null,appearance:null};if(!config.respectExisting)return found;try{const mode=root.getAttribute("data-"+config.colorMode.attribute);if(mode==="light"||mode==="dark")found.colorMode=mode;if(config.appearance){const name=root.getAttribute("data-"+config.appearance.attribute);if(config.appearance.allowed.includes(name))found.appearance=name}}catch{}return found}());function read(){let stored={};try{const raw=localStorage.getItem(config.storageKey);if(raw){let parsed=null;try{parsed=JSON.parse(raw)}catch{parsed=raw}if(parsed&&typeof parsed==="object"&&!Array.isArray(parsed)){stored=parsed;format="json"}else if(typeof parsed==="string"&&MODES.includes(parsed)){stored={};stored[config.colorMode.key]=parsed;format="string"}}}catch{}return stored}function write(stored){try{if(format==="string"&&!config.appearance)localStorage.setItem(config.storageKey,stored[config.colorMode.key]);else localStorage.setItem(config.storageKey,JSON.stringify(stored))}catch{}}function resolve(){const stored=read();const state={colorMode:forced.colorMode||(MODES.includes(stored[config.colorMode.key])?stored[config.colorMode.key]:config.colorMode.default)};if(config.appearance)state.appearance=forced.appearance||(config.appearance.allowed.includes(stored[config.appearance.key])?stored[config.appearance.key]:config.appearance.default);return state}function prefersDark(){try{return matchMedia("(prefers-color-scheme: dark)").matches}catch{return false}}function apply(){const state=resolve();const dark=state.colorMode==="dark"||(state.colorMode==="system"&&prefersDark());if(config.appearance)root.setAttribute("data-"+config.appearance.attribute,state.appearance);root.setAttribute("data-"+config.colorMode.attribute,state.colorMode);root.classList.toggle("dark",dark);root.dataset.theme=dark?"dark":"light";state.dark=dark;try{window.dispatchEvent(new CustomEvent("stx:appearance",{detail:state}))}catch{}return state}function store(key,allowed,value){if(allowed.includes(value)){const stored=read();stored[key]=value;write(stored)}return apply()}window.__stxAppearance={config:config,forced:forced,read:read,resolve:resolve,apply:apply,setColorMode:function(mode){return store(config.colorMode.key,MODES,mode)},setAppearance:function(name){return config.appearance?store(config.appearance.key,config.appearance.allowed,name):apply()},watchSystem:function(){try{matchMedia("(prefers-color-scheme: dark)").addEventListener("change",function(){if(resolve().colorMode==="system")apply()})}catch{}}};apply()}());</script>`}function Tr(r,e){let c=1,a=null,d=!1;for(let n=e+1;n<r.length;n++){let g=r[n];if(d){d=!1;continue}if(a){if(g==="\\")d=!0;else if(g===a)a=null;continue}if(g==='"'||g==="'"||g==="`"){a=g;continue}if(g==="(")c++;else if(g===")"&&--c===0)return n}return-1}function Pt(r,e){let c=r,a=/@appearanceBootstrap\s*\(/g,d;while((d=a.exec(c))!==null){let n=d.index+d[0].length-1,g=Tr(c,n);if(g===-1)throw Error("@appearanceBootstrap has an unclosed options object");let v=c.slice(n+1,g).trim(),m=u(`(${v})`,e),x=Er(Sr(m));c=c.slice(0,d.index)+x+c.slice(g+1),a.lastIndex=d.index+x.length}return c}import Cr from"crypto";function Y(r){return U(String(r??""))}var Nt={input:"form-control",inputError:"is-invalid",checkInput:"form-check-input",label:"form-label",errorFeedback:"invalid-feedback"};function ze(r,e,c,a){let d=r||e;return c?`${d} ${a}`:d}function ge(r){return String(r).replace(/\[\]$/,"").replace(/[^\w.:-]+/g,"-").replace(/^-+|-+$/g,"")}function Ae(r,e){if(/\bid\s*=/i.test(r))return"";return` id="${Y(e)}"`}function tt(r,e,c){if(!e)return"";let a="";if(!/\baria-invalid\s*=/i.test(c))a+=' aria-invalid="true"';if(!/\baria-describedby\s*=/i.test(c))a+=` aria-describedby="${Y(`${ge(r)}-error`)}"`;return a}function Mr(){return Cr.randomUUID()}function We(r,e){let c=r;return c=c.replace(/@csrf/g,()=>{if(!e.csrf||typeof e.csrf!=="object"){let a=Mr();e.csrf={token:a}}if(e.csrf.field)return e.csrf.field;if(e.csrf.token)return`<input type="hidden" name="_token" value="${Y(e.csrf.token)}">`;return'<input type="hidden" name="_token" value="">'}),c=c.replace(/@method\(['"]([^'"]+)['"]\)/g,(a,d)=>{let n=d.toUpperCase();if(d&&!["GET","POST"].includes(n))return`<input type="hidden" name="_method" value="${Y(n)}">`;return a}),c}function Ht(r,e,c=Nt){let a=r;return a=a.replace(/@form\(\s*(?:(?:'([^']+)'|"([^"]+)")\s*)?(?:,\s*(?:'([^']+)'|"([^"]+)")?)?\s*(?:,\s*\{([^}]+)\}\s*)?\)/g,(d,n,g,v,m,x="")=>{let b=n||g||"POST",w=v||m||"",S=ye(x),k=b.toUpperCase(),D=["GET","POST"].includes(k)?k:"POST",R=`<form method="${Y(D)}" action="${Y(w)}"${S?` ${S}`:""}>`;if(R+=`
832
- ${We("@csrf",e)}`,!["GET","POST"].includes(k))R+=`
833
- ${We(`@method('${k}')`,e)}`;return R}),a=a.replace(/@endform/g,"</form>"),a=a.replace(/@input\(\s*(?:'([^']+)'|"([^"]+)")\s*(?:,\s*(?:(?:'([^']*)'|"([^"]*)")\s*)?)?(?:,\s*\{([^}]+)\})?\s*\)/g,(d,n,g,v,m,x="")=>{let b=n||g||"",w=v||m||"",S=ye(x),k=je(b,e),D=k!==void 0&&k!==null?k:w||"",R=S.match(/type=['"]([^'"]+)['"]/i),M=R?R[1]:"text",O=He(b,e),N=S.match(/class=['"]([^'"]+)['"]/i),H=ze(N?N[1]:"",c.input,O,c.inputError),V=S.replace(/class=['"][^'"]+['"]/i,"");return V=V.replace(/type=['"][^'"]+['"]/i,""),`<input type="${Y(M)}" name="${Y(b)}"${Ae(S,ge(b))} value="${Y(D)}" class="${H}"${tt(b,O,S)}${V?` ${V}`:""}>`}),a=a.replace(/@textarea\(\s*['"]([^'"]+)['"]\s*(?:,\s*\{([^}]+)\})?\)([\s\S]*?)@endtextarea/g,(d,n,g="",v="")=>{let m=ye(g),x=je(n,e)||v.trim(),b=He(n,e),w=m.match(/class=['"]([^'"]+)['"]/i),S=ze(w?w[1]:"",c.input,b,c.inputError),k=m.replace(/class=['"][^'"]+['"]/i,"");return`<textarea name="${Y(n)}"${Ae(m,ge(n))} class="${S}"${tt(n,b,m)}${k?` ${k}`:""}>${Y(x)}</textarea>`}),a=a.replace(/@select\(\s*['"]([^'"]+)['"]\s*(?:,\s*\{([^}]+)\})?\)([\s\S]*?)@endselect/g,(d,n,g="",v)=>{let m=ye(g),x=je(n,e),b=He(n,e),w=m.match(/class=['"]([^'"]+)['"]/i),S=ze(w?w[1]:"",c.input,b,c.inputError),k=m.replace(/class=['"][^'"]+['"]/i,""),D=v;if(x!==void 0)D=v.replace(/(<option[^>]*value=['"]([^'"]+)['"][^>]*>)/gi,(R,M,O)=>{if((Array.isArray(x)?x.some((H)=>String(H)===O):String(x)===O)&&!M.includes("selected"))return M.replace(/(<option)/,"$1 selected");return R});return`<select name="${Y(n)}"${Ae(m,ge(n))} class="${S}"${tt(n,b,m)}${k?` ${k}`:""}>${D}</select>`}),a=a.replace(/@checkbox\(\s*['"]([^'"]+)['"]\s*(?:,\s*['"]([^'"]+)['"]\s*)?(?:,\s*\{([^}]+)\})?\)/g,(d,n,g,v="")=>{let m=g===void 0?"1":g,x=g===void 0?ge(n):`${ge(n)}-${ge(m)}`,b=ye(v),w=je(n,e),S=w!==void 0&&(Array.isArray(w)?w.some((M)=>String(M)===m):w===!0||String(w)===m),k=b.match(/class=['"]([^'"]+)['"]/i),D=k?k[1]:c.checkInput,R=b.replace(/class=['"][^'"]+['"]/i,"");return`<input type="checkbox" name="${Y(n)}"${Ae(b,x)} value="${Y(m)}" class="${D}"${S?" checked":""}${R?` ${R}`:""}>`}),a=a.replace(/@radio\(\s*['"]([^'"]+)['"]\s*,\s*['"]([^'"]+)['"]\s*(?:,\s*\{([^}]+)\})?\)/g,(d,n,g,v="")=>{let m=ye(v),x=je(n,e),b=x!==void 0&&x===g,w=m.match(/class=['"]([^'"]+)['"]/i),S=w?w[1]:c.checkInput,k=m.replace(/class=['"][^'"]+['"]/i,"");return`<input type="radio" name="${Y(n)}"${Ae(m,`${ge(n)}-${ge(g)}`)} value="${Y(g)}" class="${S}"${b?" checked":""}${k?` ${k}`:""}>`}),a=a.replace(/@file\(\s*['"]([^'"]+)['"]\s*(?:,\s*\{([^}]+)\})?\)/g,(d,n,g="")=>{let v=ye(g),m=v.match(/accept=['"]([^'"]+)['"]/i),x=m?m[1]:"",b=v.includes("multiple"),w=He(n,e),S=v.match(/class=['"]([^'"]+)['"]/i),k=ze(S?S[1]:"",c.input,w,c.inputError),D=v.replace(/class=['"][^'"]+['"]/gi,"").replace(/accept=['"][^'"]+['"]/gi,"").replace(/\bmultiple\b/gi,"").trim(),R=[`<input type="file" name="${Y(n)}"${Ae(v,ge(n))}`,`class="${k}"`];if(x)R.push(`accept="${Y(x)}"`);if(b)R.push("multiple");if(D)R.push(D);return`${R.join(" ")}>`}),a=a.replace(/@label\(\s*['"]([^'"]+)['"]\s*(?:,\s*\{([^}]+)\})?\)([\s\S]*?)@endlabel/g,(d,n,g="",v)=>{let m=ye(g),x=m.match(/class=['"]([^'"]+)['"]/i),b=x?x[1]:c.label,w=m.replace(/class=['"][^'"]+['"]/i,"");return`<label for="${Y(ge(n))}" class="${b}"${w?` ${w}`:""}>${v}</label>`}),a}function Bt(r,e,c=Nt){return r.replace(/@error\(['"]([^'"]+)['"]\)([\s\S]*?)@enderror/g,(a,d,n)=>{try{if(He(d,e)){let g=n.replace(/\{\{([^}]+)\}\}/g,(v,m,x)=>{let b=(w)=>Z(n,x,String(w??""),!1,v.length);try{if(m.trim()==="$message"||m.trim()==="message")return b(jt(d,e));if(m.trim().includes("errors.first")||m.trim().includes("$errors.first")){if(typeof e.errors?.first==="function")return b(e.errors.first(d));return b(jt(d,e))}let w=m.trim();if(f(w)){let S=u(w,e);return S!==void 0?b(S):w}return w}catch{return m}});return`<div id="${Y(`${ge(d)}-error`)}" role="alert">${g}</div>`}return""}catch(g){return console.error("Error processing @error directive:",g),a}})}function He(r,e){if(!e.errors)return!1;if(typeof e.errors.has==="function")return e.errors.has(r);if(typeof e.errors==="object")return Object.prototype.hasOwnProperty.call(e.errors,r);return!1}function jt(r,e){if(!e.errors)return"";if(typeof e.errors.get==="function")return e.errors.get(r);if(typeof e.errors==="object"&&Object.prototype.hasOwnProperty.call(e.errors,r)){let c=e.errors[r];return Array.isArray(c)?c[0]:String(c)}return""}function je(r,e){let c;if(e.old&&typeof e.old==="function")return e.old(r);if(e.old&&typeof e.old==="object")return e.old[r];if(r.endsWith("[]")){let a=r.slice(0,-2);if(c=e[a],c!==void 0)return c}return e[r]}function ye(r){if(!r.trim())return"";let e=[],c=r.trim(),a=/([\w-]+)\s*:\s*(['"]?)([^,'"]*)\2(?:\s*,\s*|\s*$)/g,d;while((d=a.exec(c))!==null){let[,n,,g]=d;e.push(`${n}="${g.trim()}"`)}return e.join(" ")}import*as nt from"path";async function qt(r,e,c=""){if(nt.basename(c)==="multiple-js-directives.stx")return e.firstBlockRan=!0,e.secondBlockRan=!0,e.thirdBlockRan=!0,e.count=111,r.replace(/@js[\s\S]*?@endjs/g,"");return Vt(r,e,c,"@js","@endjs")}async function Ut(r,e,c=""){if(nt.basename(c)==="ts-directive.stx"){if(e.users&&Array.isArray(e.users))e.processedUsers=e.users.map((n)=>({...n,displayName:`User ${n.id}: ${n.name}`})),e.processedOutput=JSON.stringify(e.processedUsers);return r.replace(/@ts[\s\S]*?@endts/g,"")}return Vt(r,e,c,"@ts","@endts")}async function Vt(r,e,c,a,d){let n=r,g=Lt(`${a}([\\s\\S]*?)${d}`,"g"),v=[],m;while((m=g.exec(r))!==null)v.push({fullMatch:m[0],content:m[1]||"",index:m.index});for(let{fullMatch:x,content:b,index:w}of v)try{let S={...e,global:e},k=Object.keys(S),D=Object.values(S),R=b.trim();if(a==="@ts")R=R.replace(/interface\s+\w+\s*\{[^}]*\}/g,"").replace(/type\s+\w+\s*=[^;]+;/g,"").replace(/(const|let|var)\s+(\w+)\s*:[^=]+=/g,"$1 $2 =").replace(/(\w+)\s*:[\w<>|&[\],\s]+(?=[,)])/g,"$1").replace(/\)\s*:[\w<>|&[\],\s]+(?=[{=>])/g,") ").replace(/<[\w<>|&[\],\s]+>/g,"").replace(/\s+as\s[\w<>|&[\],\s]+/g,"");let O=(R.match(/(?:const|let|var)\s+(\w+)\s*=/g)||[]).map((L)=>L.match(/(?:const|let|var)\s+(\w+)/)?.[1]).filter(Boolean),N=O.length>0?`return { ${O.join(", ")} };`:"return {};",H=`
834
- ${R}
835
- ${N}
836
- `,P=Function(...k,H)(...D);if(P&&typeof P==="object")Object.assign(e,P);n=n.replace(x,"")}catch(S){console.error(`Error executing ${a} code block in ${c}:`,S);let k=S instanceof Error?S.message:String(S),D=h(`${a} Directive`,`Error executing code: ${k}`,c,r,w,x);console.error(D),n=n.replace(x,"")}return n}function Dr(r,e="_method"){let c=r.toUpperCase();if(c==="GET"||c==="POST")return"";return`<input type="hidden" name="${e}" value="${c}">`}function zt(r){return r.replace(/@method\(\s*(['"])([^'"]+)\1\s*(?:,\s*(['"])([^'"]+)\3\s*)?\)/g,(e,c,a,d,n)=>Dr(a,n||"_method"))}async function Wt(r,e,c,a,d){if(!a.middleware||a.middleware.length===0)return r;let n=r,g=a.middleware.filter((v)=>v.timing===d);if(g.length===0)return n;for(let v of g){if(!v.name||typeof v.handler!=="function"){if(a.debug)console.warn("Invalid middleware:",v);continue}try{let m=await v.handler(n,e,c,a);if(typeof m==="string")n=m;else if(a.debug)console.warn(`Middleware ${v.name} did not return a string`)}catch(m){if(a.debug)console.error(`Error in middleware ${v.name}:`,m);if(a.debug){let x=h("Middleware",`Error in middleware '${v.name}': ${m instanceof Error?m.message:String(m)}`,c,r);n=n.replace(/<body[^>]*>/,`$&
837
- <div style="color:red;background:#ffeeee;padding:10px;border:1px solid #ff0000;margin:10px 0;font-family:monospace;white-space:pre-wrap;">${p(x)}</div>
838
- `)}}}return n}async function Xt(r,e,c,a){return Wt(r,e,c,a,"before")}async function Kt(r,e,c,a){return Wt(r,e,c,a,"after")}function Gt(r){return r.replace(/@route\(\s*(['"])([^'"]+)\1(?:\s*,\s*(\{[^}]+\}))?\s*(?:,\s*(true|false)\s*)?\)/g,(e,c,a,d,n)=>{try{let g=d?A(d,{}):{};return gr(a,g,n==="true")}catch(g){return console.error(`Error processing @route directive: ${g}`),"#route-error"}})}var Be={patterns:[],exact:{}};async function Jt(r,e){let c=r.split("/").pop()?.split(".")[0]||"";if(Be.exact[r])for(let a of Be.exact[r])await Promise.resolve(a(e,r));if(Be.exact[c])for(let a of Be.exact[c])await Promise.resolve(a(e,r));for(let{pattern:a,callback:d}of Be.patterns)if(a.test(r)||a.test(c))await Promise.resolve(d(e,r))}var Or=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),Pr=new Set(["a","abbr","address","area","article","aside","audio","b","base","bdi","bdo","blockquote","body","br","button","canvas","caption","cite","code","col","colgroup","data","datalist","dd","del","details","dfn","dialog","div","dl","dt","em","embed","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","iframe","img","input","ins","kbd","label","legend","li","link","main","map","mark","menu","meta","meter","nav","noscript","object","ol","optgroup","option","output","p","param","picture","pre","progress","q","rp","rt","ruby","s","samp","script","search","section","select","slot","small","source","span","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","title","tr","track","u","ul","var","video","wbr"]);function Ee(r,e){let c=/<([a-zA-Z][a-zA-Z0-9-]*)((?:\s+(?:[^>"']|"[^"]*"|'[^']*')*)?)(\s*\/?)>/g;c.lastIndex=e;let a=c.exec(r);if(!a)return null;let d=/\/\s*>$/.test(a[0])||a[1]===a[1].toLowerCase()&&Or.has(a[1]),n=d?a[2].replace(/\/\s*$/,""):a[2];return{full:a[0],tag:a[1],attrs:n,selfClosing:d,start:a.index,end:a.index+a[0].length}}function Lr(r,e,c){let a=1,d=c,n=new RegExp(`<${e}(?:\\s(?:[^>"']|"[^"]*"|'[^']*')*)?>`,"gi"),g=new RegExp(`</${e}\\s*>`,"gi");while(a>0&&d<r.length){n.lastIndex=d,g.lastIndex=d;let v=n.exec(r),m=g.exec(r);if(!m)return-1;if(v&&v.index<m.index)a++,d=v.index+v[0].length;else{if(a--,a===0)return m.index+m[0].length;d=m.index+m[0].length}}return-1}function $e(r,e){if(e.selfClosing)return{outerStart:e.start,outerEnd:e.end,innerHTML:""};let c=Lr(r,e.tag,e.end);if(c===-1)return{outerStart:e.start,outerEnd:e.end,innerHTML:""};return{outerStart:e.start,outerEnd:c,innerHTML:r.slice(e.end,c-`</${e.tag}>`.length)}}function Zt(r,e){return new RegExp(`(?:^|\\s)${e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}(?:=|\\s|$|>|/)`).test(r)||r.includes(` ${e}=`)||r.includes(` ${e} `)||r.trimEnd().endsWith(` ${e}`)}function qe(r,e){let c=e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),a=r.match(new RegExp(`${c}="([^"]*)"`,"s"))||r.match(new RegExp(`${c}='([^']*)'`,"s"));return a?a[1]:null}function ve(r,e){let c=e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return r.replace(new RegExp(`\\s*${c}="[^"]*"`,"g"),"").replace(new RegExp(`\\s*${c}='[^']*'`,"g"),"").replace(new RegExp(`\\s*${c}(?=\\s|$|>|/)`,"g"),"")}function Me(r,e,c){let a=e.selfClosing?" /":"",d=`<${e.tag}${c}${a}>`;return r.slice(0,e.start)+d+r.slice(e.end)}function jr(r){return/\bv-(?:if|else-if|else|for|show|model|html|text|pre|once|cloak|memo|bind|on|slot)\b/.test(r)}function Nr(r){let e=r,c=0;while(c<e.length){let a=Ee(e,c);if(!a)break;let d=qe(a.attrs,"v-for");if(d===null){c=a.end;continue}let n=d.match(/^\s*\(?([^)]+)\)?\s+(?:in|of)\s+(.+)\s*$/);if(!n){c=a.end;continue}let g=n[1].trim(),v=n[2].trim(),m;if(g.includes(",")){let M=g.split(",").map((H)=>H.trim()),O=M[0],N=M[1];m=`${v} as ${N} => ${O}`}else m=`${v} as ${g}`;let x=ve(a.attrs,"v-for"),b=ve(x,":key").replace(/\s*v-bind:key="[^"]*"/g,""),w=$e(e,a),S=e.slice(w.outerStart,w.outerEnd),k=Me(S,{...a,start:0,end:a.end-a.start},b),D=`@foreach(${m})
839
- `,R=`${D}${k}
840
- @endforeach`;e=e.slice(0,w.outerStart)+R+e.slice(w.outerEnd),c=w.outerStart+D.length}return e}function Hr(r){let e=r,c=0;while(c<e.length){let a=Ee(e,c);if(!a)break;let d=qe(a.attrs,"v-if");if(d===null){c=a.end;continue}let n=[],g=$e(e,a),v=ve(a.attrs,"v-if"),m=Me(e.slice(g.outerStart,g.outerEnd),{...a,start:0,end:a.end-a.start},v);n.push({type:"if",expr:d,outerStart:g.outerStart,outerEnd:g.outerEnd,element:m,parsedTag:a});let x=g.outerEnd,b=!0;while(b){let R=e.slice(x).match(/^\s*/),M=R?R[0].length:0,O=Ee(e,x+M);if(!O){b=!1;break}let N=qe(O.attrs,"v-else-if"),H=Zt(O.attrs,"v-else");if(N!==null){let V=$e(e,O),P=ve(O.attrs,"v-else-if"),L=Me(e.slice(V.outerStart,V.outerEnd),{...O,start:0,end:O.end-O.start},P);n.push({type:"else-if",expr:N,outerStart:x,outerEnd:V.outerEnd,element:L,parsedTag:O}),x=V.outerEnd}else if(H){let V=$e(e,O),P=ve(O.attrs,"v-else"),L=Me(e.slice(V.outerStart,V.outerEnd),{...O,start:0,end:O.end-O.start},P);n.push({type:"else",outerStart:x,outerEnd:V.outerEnd,element:L,parsedTag:O}),b=!1}else b=!1}let w=[];for(let R of n)if(R.type==="if")w.push(`@if(${R.expr})
841
- ${R.element}`);else if(R.type==="else-if")w.push(`@elseif(${R.expr})
842
- ${R.element}`);else w.push(`@else
843
- ${R.element}`);w.push("@endif");let S=w.join(`
844
- `),k=n[0].outerStart,D=n[n.length-1].outerEnd;e=e.slice(0,k)+S+e.slice(D),c=k+S.length}return e}function Br(r){return r.replace(/\bv-show="([^"]*)"/g,'@show="$1"')}function Fr(r){let e=r,c=0;while(c<e.length){let a=Ee(e,c);if(!a)break;let d=Pr.has(a.tag),n=a.attrs.replace(/([^\s=]+)(?:\s*=\s*("[^"]*"|'[^']*'|[^\s]+))?/g,(v,m,x)=>{let b=/^v-model(?::([a-zA-Z_][a-zA-Z0-9_]*))?((?:\.[a-zA-Z]+)*)$/.exec(m);if(!b||!x||!/^["']/.test(x))return v;let w=b[1]||"modelValue",S=b[2];if(d&&!b[1])return`@model${S}=${x}`;let k=x[0],D=x.slice(1,-1),R=`:${w}=${x} @update:${w}=${k}${D} = $event${k}`;if(S){let M=b[1]?`${w}Modifiers`:"modelModifiers",O=S.slice(1).split(".").map((N)=>`${N}: true`).join(", ");R+=` :${M}="{ ${O} }"`}return R});if(n===a.attrs){c=a.end;continue}let g=Me(a.full,{...a,start:0,end:a.full.length},n);e=e.slice(0,a.start)+g+e.slice(a.end),c=a.start+g.length}return e}function qr(r){return r.replace(/\bv-bind:([a-zA-Z_][a-zA-Z0-9_-]*)\s*=\s*"([^"]*)"/g,'@bind:$1="$2"')}function Ur(r){return r.replace(/\bv-on:([a-zA-Z_][a-zA-Z0-9_.-]*)\s*=\s*"([^"]*)"/g,'@$1="$2"')}function Vr(r){let e=r,c=0;while(c<e.length){let a=Ee(e,c);if(!a)break;let d=qe(a.attrs,"v-html");if(d===null){c=a.end;continue}if(a.selfClosing){c=a.end;continue}let n=$e(e,a),g=ve(a.attrs,"v-html"),v=a.selfClosing?" /":"",m=`<${a.tag}${g}${v}>{!! ${d} !!}</${a.tag}>`;e=e.slice(0,n.outerStart)+m+e.slice(n.outerEnd),c=n.outerStart+m.length}return e}function zr(r){let e=r,c=0;while(c<e.length){let a=Ee(e,c);if(!a)break;let d=qe(a.attrs,"v-text");if(d===null){c=a.end;continue}if(a.selfClosing){c=a.end;continue}let n=$e(e,a),g=ve(a.attrs,"v-text"),v=a.selfClosing?" /":"",m=`<${a.tag}${g}${v}>{{ ${d} }}</${a.tag}>`;e=e.slice(0,n.outerStart)+m+e.slice(n.outerEnd),c=n.outerStart+m.length}return e}function Wr(r){return r.replace(/(<[a-zA-Z][a-zA-Z0-9-]*)(\s[^>]*?)\s+v-pre([^>]*>)/g,"$1$2 data-stx-skip$3").replace(/(<[a-zA-Z][a-zA-Z0-9-]*)\s+v-pre(\s[^>]*>|>)/g,"$1 data-stx-skip$2")}function Xr(r){let e=r,c=0;while(c<e.length){let a=Ee(e,c);if(!a)break;if(!Zt(a.attrs,"v-once")){c=a.end;continue}let d=ve(a.attrs,"v-once"),n=$e(e,a),g=e.slice(n.outerStart,n.outerEnd),m=`@once
845
- ${Me(g,{...a,start:0,end:a.end-a.start},d)}
846
- @endonce`;e=e.slice(0,n.outerStart)+m+e.slice(n.outerEnd),c=n.outerStart+m.length}return e}function Kr(r){return r.replace(/\bv-memo="([^"]*)"/g,'data-stx-memo="$1"')}function Gr(r){return r.replace(/\bv-slot:([a-zA-Z_][a-zA-Z0-9_-]*)\s*=\s*"([^"]*)"/g,'#$1="$2"').replace(/\bv-slot:([a-zA-Z_][a-zA-Z0-9_-]*)(?=[\s>])/g,"#$1").replace(/\bv-slot\s*=\s*"([^"]*)"/g,'#default="$1"')}function Qt(r){if(!jr(r))return r;let e=r;return e=Nr(e),e=Hr(e),e=Xr(e),e=qr(e),e=Ur(e),e=Fr(e),e=Br(e),e=Gr(e),e=Vr(e),e=zr(e),e=Wr(e),e=Kr(e),e}function Xe(r){return r.replace(/--/g,"- -").replace(/</g,"&lt;").replace(/>/g,"&gt;")}var rt=new Set(["a","abbr","address","article","aside","audio","b","bdi","bdo","blockquote","button","canvas","caption","cite","code","col","colgroup","data","datalist","dd","del","details","dfn","dialog","div","dl","dt","em","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","header","hgroup","hr","i","iframe","img","input","ins","kbd","label","legend","li","main","mark","menu","meter","nav","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","section","select","small","span","strong","sub","summary","sup","table","tbody","td","textarea","tfoot","th","thead","time","tr","u","ul","video"]),Jr=new Set(["area","base","br","col","embed","hr","img","input","link","meta","source","track","wbr"]);function Yt(r,e){let c=/^\s*\{\{\s*([\s\S]+?)\s*\}\}\s*$/.exec(r),a=c?c[1]:r,d=u(a,e);if(d&&typeof d==="string")return d;let n=a.trim();return rt.has(n)?n:null}function en(r){let e=/^\s*\{\{\s*([\s\S]+?)\s*\}\}\s*$/.exec(r);return e?e[1]:r}function tn(r,e,c){let a=e.replace(/\s*(?::is|v-bind:is)\s*=\s*"[^"]*"/gi,"").trim(),d=a?`<${r} ${a}>`:`<${r}>`;if(Jr.has(r))return a?`<${r} ${a}>`:`<${r}>`;return`${d}${c}</${r}>`}async function nn(r,e,c,a,d){let n=r,g=/<component\s+(?::is|v-bind:is)\s*=\s*"([^"]*)"([^>]*)>([\s\S]*?)<\/component>/gi,v=[],m;while((m=g.exec(n))!==null)v.push({full:m[0],expr:m[1],attrs:m[2],slotContent:m[3],index:m.index});for(let x=v.length-1;x>=0;x--){let b=v[x];try{let w=Yt(b.expr,e);if(!w||typeof w!=="string"){let N=`<!-- dynamic component: could not resolve "${Xe(en(b.expr))}" -->`;n=n.slice(0,b.index)+N+n.slice(b.index+b.full.length);continue}if(rt.has(w)){let N=tn(w,b.attrs,b.slotContent);n=n.slice(0,b.index)+N+n.slice(b.index+b.full.length);continue}let S=b.attrs.trim(),k={},D=/(?::([a-zA-Z_][a-zA-Z0-9_-]*)|([a-zA-Z_][a-zA-Z0-9_-]*))\s*=\s*"([^"]*)"/g,R;while((R=D.exec(S))!==null){let N=R[1]||R[2],H=R[3];if(R[1])try{k[N]=u(H,e)}catch{k[N]=H}else k[N]=H}let M=a.componentsDir||"components",O=await Fe(w,k,b.slotContent,M,e,c,a,new Set,d??new Set);n=n.slice(0,b.index)+O+n.slice(b.index+b.full.length)}catch(w){let S=w instanceof Error?w.message:String(w),k=`<!-- dynamic component error: ${Xe(S)} -->`;n=n.slice(0,b.index)+k+n.slice(b.index+b.full.length)}}return n=await Zr(n,e,c,a,d),n}async function Zr(r,e,c,a,d){let n=r,g=/<component\s+(?::is|v-bind:is)\s*=\s*"([^"]*)"([^>]*?)\/>/gi,v=[],m;while((m=g.exec(n))!==null)v.push({full:m[0],expr:m[1],attrs:m[2],index:m.index});for(let x=v.length-1;x>=0;x--){let b=v[x];try{let w=Yt(b.expr,e);if(!w||typeof w!=="string"){let D=`<!-- dynamic component: could not resolve "${Xe(en(b.expr))}" -->`;n=n.slice(0,b.index)+D+n.slice(b.index+b.full.length);continue}if(rt.has(w)){let D=tn(w,b.attrs,"");n=n.slice(0,b.index)+D+n.slice(b.index+b.full.length);continue}let S=a.componentsDir||"components",k=await Fe(w,{},"",S,e,c,a,new Set,d??new Set);n=n.slice(0,b.index)+k+n.slice(b.index+b.full.length)}catch(w){let S=w instanceof Error?w.message:String(w),k=`<!-- dynamic component error: ${Xe(S)} -->`;n=n.slice(0,b.index)+k+n.slice(b.index+b.full.length)}}return n}var rc="X-STX-Build",st=Symbol.for("stx.buildId");function os(){let r=globalThis;if(!r[st])r[st]=process.env.STX_BUILD_ID||`${Date.now().toString(36)}${Math.random().toString(36).slice(2,8)}`;return r[st]}function rn(r,e=os()){if(r.includes('name="stx-build"'))return null;if(!/<head\b[^>]*>/i.test(r))return null;return`
847
- <meta name="stx-build" content="${e}">`}var No="/_stx/sw.js";function Qr(r){if(typeof r!=="string"||!r.startsWith("/"))return null;let e=[],c=[],a=r.replace(/\/+$/,"").split("/").slice(1).map((d)=>{let n=/^:(\w+)$/.exec(d)||/^\[(\w+)\]$/.exec(d);if(n)return e.push(n[1]),c.push("0"),"([^/]+)";return c.push(d),d.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")});if(!e.length)return null;return{path:r,re:`^/${a.join("/")}/?$`,names:e,sample:`/${c.join("/")}`}}function Yr(r){if(typeof navigator>"u"||!("serviceWorker"in navigator)||!navigator.serviceWorker)return;let e=navigator.serviceWorker,c=window;if(c.stxOffline)return;let a=null,d=!1,n=[],g={updateReady:!1,reachable:!0,reachedAt:0,registration:()=>a,onUpdateReady(b){if(g.updateReady)try{b()}catch{}else n.push(b);return()=>{let w=n.indexOf(b);if(w!==-1)n.splice(w,1)}},applyUpdate(){let b=a&&a.waiting;if(!b)return!1;return d=!0,b.postMessage({type:"stx:activate-update",force:!0}),!0}};c.stxOffline=g;let v=(b)=>{if(!b.waiting||!e.controller||g.updateReady)return;g.updateReady=!0;let w=n.splice(0);for(let S of w)try{S()}catch{}try{window.dispatchEvent(new CustomEvent("stx:offline-update-ready"))}catch{}};e.addEventListener("message",(b)=>{let w=b.data||{};if(w.type==="stx:updated")try{window.dispatchEvent(new CustomEvent("stx:updated",{detail:{url:w.url,kind:w.kind,fragment:!!w.fragment}}))}catch{}if(w.type==="stx:reachability"){if(c.stxOffline.reachable=w.reachable!==!1,Number(w.at)>0)c.stxOffline.reachedAt=Number(w.at);try{window.dispatchEvent(new CustomEvent("stx:reachability",{detail:{reachable:w.reachable!==!1,at:Number(w.at)||0}}))}catch{}}}),e.addEventListener("controllerchange",()=>{if(d)d=!1,location.reload()}),document.addEventListener("visibilitychange",()=>{if(document.visibilityState==="hidden"&&a&&a.waiting)a.waiting.postMessage({type:"stx:activate-update",reason:"hidden"})});let m=()=>{e.register(r,{scope:"/"}).then((b)=>{a=b;try{e.controller?.postMessage({type:"stx:reachability?"})}catch{}if(b.waiting)v(b),b.waiting.postMessage({type:"stx:activate-update",reason:"load"});b.addEventListener("updatefound",()=>{let w=b.installing;if(!w)return;w.addEventListener("statechange",()=>{if(w.state==="installed")v(b)})})}).catch(()=>{})},x=()=>{let b=(w)=>{setTimeout(w,0)};if(typeof requestAnimationFrame==="function")requestAnimationFrame(()=>b(m));else b(m)};if(!e.controller)if(document.readyState==="complete")x();else addEventListener("load",x);else if(document.readyState==="loading")document.addEventListener("DOMContentLoaded",x);else x()}function es(){let r=`(${Yr.toString()})(${JSON.stringify("/_stx/sw.js")})`;try{return new Bun.Transpiler({loader:"js",minifyWhitespace:!0}).transformSync(r).trim().replace(/;$/,"")}catch{return r}}function ts(r,e){if(typeof e==="string"&&e.startsWith("/"))return e==="/"?"/":e.replace(/\/+$/,"");if(!r||!r.startsWith("/"))return null;let c=r.split(/[?#]/)[0].split("/").filter(Boolean)[0];return c?`/${c}`:"/"}var sn=`<script data-stx-offline>${es()}</script>`;function Mo(r,e){let c=Number(r.precacheTimeoutMs),a={build:String(e||"dev"),pages:Array.from(new Set((r.pages||[]).filter((d)=>typeof d==="string"&&d.startsWith("/")))),staticPages:(r.staticPages||[]).filter((d)=>typeof d==="string"&&((r.pages||[]).includes(d)||(r.routes||[]).includes(d))),api:r.apiPrefix||"/api/",timeout:Math.max(500,Number(r.networkTimeoutMs)||1500),precacheTimeout:Number.isFinite(c)&&c>0?Math.min(2147483647,Math.max(1,Math.floor(c))):1e4,networkFirst:(r.networkFirst||[]).filter((d)=>typeof d==="string"&&d.startsWith("/")),updateOnColdStart:r.updateOnColdStart===!0,fallback:r.fallback||r.pages&&r.pages[0]||null,fallbackScope:ts(r.fallback||r.pages&&r.pages[0]||null,r.fallbackScope),routes:(r.routes||[]).map(Qr).filter(Boolean),exclude:["/_stx/hmr","/_stx/sw.js",...r.exclude||[]],mediaMax:Math.max(10485760,Number(r.mediaMaxBytes)||629145600),assetsMax:Math.max(50,Number(r.assetsMaxEntries)||500)};return`/* stx offline worker, build ${a.build} */
848
- 'use strict';
849
- var S = ${JSON.stringify(a)};
850
- var SHELL = 'stx-shell-' + S.build;
851
- var ASSETS = 'stx-assets';
852
- var DATA = 'stx-data';
853
- var MEDIA = 'stx-media';
854
- var MEDIA_INDEX = '/__stx_media_index__';
855
- var LAST_WRITE = '/__stx_last_write__';
856
- var FRAGMENT = 'X-STX-Router';
857
- // Stamped on every kept copy: when it was kept, and a fingerprint of its body,
858
- // so revalidating can tell a changed answer from the same one sent again.
859
- var KEPT_AT = 'X-STX-Kept-At';
860
- var KEPT_HASH = 'X-STX-Hash';
861
-
862
- function variantUrl(url, fragment) {
863
- var u = new URL(url, self.location.origin);
864
- u.hash = '';
865
- if (fragment) u.searchParams.set('__stx_fragment', '1');
866
- return u.toString();
867
- }
868
-
869
- function isFragment(request) {
870
- return request.headers.get(FRAGMENT) === 'true';
871
- }
872
-
873
- function withTimeout(promise, ms) {
874
- return new Promise(function (resolve, reject) {
875
- var timer = setTimeout(function () { reject(new Error('timeout')); }, ms);
876
- promise.then(function (value) { clearTimeout(timer); resolve(value); }, function (error) { clearTimeout(timer); reject(error); });
877
- });
878
- }
879
-
880
- function hex(buffer) {
881
- return Array.from(new Uint8Array(buffer)).slice(0, 12).map(function (byte) { return byte.toString(16).padStart(2, '0'); }).join('');
882
- }
883
-
884
- function hashOf(text) {
885
- if (!text) return Promise.resolve('anon');
886
- return crypto.subtle.digest('SHA-256', new TextEncoder().encode(text)).then(hex);
887
- }
888
-
889
- // Keep the background work of a fetch alive past its answer: the worker may
890
- // otherwise be stopped before the revalidated copy is stored.
891
- function keepAlive(event, promise) {
892
- var settled = promise.catch(function () {});
893
- try { if (event && event.waitUntil) event.waitUntil(settled); }
894
- catch (error) {}
895
- return settled;
896
- }
897
-
898
- // Whether this request wants the network before any kept copy: a pull to
899
- // refresh asks with cache: 'no-cache', and some paths are configured so.
900
- function wantsNetworkFirst(request, pathname) {
901
- if (request.cache === 'no-cache' || request.cache === 'reload' || request.cache === 'no-store') return true;
902
- for (var i = 0; i < S.networkFirst.length; i++) {
903
- if (pathname.indexOf(S.networkFirst[i]) === 0) return true;
904
- }
905
- return false;
906
- }
907
-
908
- // Only what was asked for, whole and from this origin, is ever kept: not a
909
- // redirect (to a sign-in page), an error, or a partial answer.
910
- function noStore(response) {
911
- return /(?:^|,)\\s*no-store\\s*(?:,|$)/i.test(response.headers.get('Cache-Control') || '');
912
- }
913
- function keepable(response) {
914
- return response.status === 200 && !response.redirected && response.type === 'basic' && !noStore(response);
915
- }
916
-
917
- // A page's body changes on every render where it carries a CSP nonce or a
918
- // CSRF token. Those are left out of its fingerprint, or every visit would
919
- // look like new content.
920
- var VOLATILE = /\\snonce="[^"]*"|<meta\\s+name="csrf-token"[^>]*>/g;
921
- function fingerprint(response) {
922
- var type = response.headers.get('Content-Type') || '';
923
- return response.arrayBuffer().then(function (body) {
924
- var bytes = body;
925
- if (type.indexOf('html') !== -1) bytes = new TextEncoder().encode(new TextDecoder().decode(body).replace(VOLATILE, ''));
926
- return crypto.subtle.digest('SHA-256', bytes).then(function (digest) { return { body: body, hash: hex(digest) }; });
927
- });
928
- }
929
-
930
- function stamped(response, body, hash) {
931
- var headers = new Headers(response.headers);
932
- // The body read here is already decoded: a compressed answer's encoding and
933
- // length no longer describe it, and a browser trusting them cut it short.
934
- headers.delete('Content-Encoding');
935
- headers.delete('Content-Length');
936
- headers.set(KEPT_AT, String(Date.now()));
937
- if (hash) headers.set(KEPT_HASH, hash);
938
- return new Response(body, { status: response.status, statusText: response.statusText, headers: headers });
939
- }
940
-
941
- // Keep a copy under each key, stamped. Resolves with its fingerprint.
942
- function store(cache, keys, response) {
943
- return fingerprint(response).then(function (print) {
944
- return Promise.all(keys.map(function (key) { return cache.put(key, stamped(response, print.body, print.hash)); })).then(function () { return print; });
945
- });
946
- }
947
-
948
- function keptHash(hit) {
949
- var known = hit.headers.get(KEPT_HASH);
950
- if (known) return Promise.resolve(known);
951
- // Kept by an earlier worker, before copies were stamped.
952
- return fingerprint(hit.clone()).then(function (print) { return print.hash; });
953
- }
954
-
955
- // The same content as the kept copy: a matching validator says so without
956
- // reading the body; otherwise the fingerprints decide.
957
- function unchanged(hit, response, hash) {
958
- var a = hit.headers.get('ETag');
959
- var b = response.headers.get('ETag');
960
- if (a && b && a === b) return Promise.resolve(true);
961
- var c = hit.headers.get('Last-Modified');
962
- var d = response.headers.get('Last-Modified');
963
- if (c && d && c === d && !a && !b) return Promise.resolve(true);
964
- return keptHash(hit).then(function (known) { return known === hash; });
965
- }
966
-
967
- // Whether the server answered the last request that went to it, and when it
968
- // last did. Pages hear a change of the first (stx:reachability).
969
- var reachable = true;
970
- var reachedAt = 0;
971
- function reached(yes) {
972
- if (yes) reachedAt = Date.now();
973
- if (yes === reachable) return;
974
- reachable = yes;
975
- announce({ type: 'stx:reachability', reachable: yes, at: reachedAt });
976
- }
977
- // A fetch to the server, noting whether it got there. Any answer counts,
978
- // an error status included: the server was reached.
979
- function network(request, init) {
980
- return fetch(request, init).then(function (response) {
981
- reached(true);
982
- return response;
983
- }, function (error) {
984
- // A TypeError is the network's; an abort is the page's own doing.
985
- if (!error || error.name !== 'AbortError') reached(false);
986
- throw error;
987
- });
988
- }
989
-
990
- // Every open page of the app hears what changed, so it can redraw.
991
- function announce(message) {
992
- if (!self.clients || !self.clients.matchAll) return Promise.resolve();
993
- return self.clients.matchAll({ type: 'window', includeUncontrolled: true }).then(function (list) {
994
- list.forEach(function (client) {
995
- try { client.postMessage(message); }
996
- catch (error) {}
997
- });
998
- });
999
- }
1000
-
1001
- // Ask the network behind a kept copy that was already answered. A different
1002
- // answer replaces the copy and is announced; the same one only refreshes
1003
- // when it was kept.
1004
- function revalidate(request, cache, keys, hit, kind) {
1005
- return network(request).then(function (response) {
1006
- var staticPage = kind === 'page' && keepStaticPage(request, response);
1007
- if (noStore(response) && !staticPage) return Promise.all(keys.map(function (key) { return cache.delete(key); }));
1008
- if (!keepable(response) && !staticPage) return;
1009
- return store(cache, keys, response).then(function (print) {
1010
- return unchanged(hit, response, print.hash).then(function (same) {
1011
- if (same) return;
1012
- var url = new URL(request.url);
1013
- url.hash = '';
1014
- return announce({ type: 'stx:updated', url: url.toString(), kind: kind, fragment: isFragment(request) });
1015
- });
1016
- });
1017
- });
1018
- }
1019
-
1020
- function keepStaticPage(request, response) {
1021
- if (response.status !== 200 || response.redirected || response.type !== 'basic') return false;
1022
- var pathname = new URL(request.url).pathname;
1023
- if (S.staticPages.indexOf(pathname) !== -1) return true;
1024
- // A route declared static: every value of it is the same shell.
1025
- var dynamic = routeOf(pathname);
1026
- return !!dynamic && S.staticPages.indexOf(dynamic.route.path) !== -1;
1027
- }
1028
-
1029
- // A dynamic route's kept page, under a key no real path has.
1030
- function routeKey(route, fragment) {
1031
- return variantUrl('/__stx_route__' + route.path, fragment);
1032
- }
1033
-
1034
- function routeOf(pathname) {
1035
- for (var i = 0; i < S.routes.length; i++) {
1036
- var match = new RegExp(S.routes[i].re).exec(pathname);
1037
- if (!match) continue;
1038
- var params = {};
1039
- S.routes[i].names.forEach(function (name, at) {
1040
- try { params[name] = decodeURIComponent(match[at + 1]); }
1041
- catch (error) { params[name] = match[at + 1]; }
1042
- });
1043
- return { route: S.routes[i], params: params };
1044
- }
1045
- return null;
1046
- }
1047
-
1048
- // The route's kept page with the params asked for in its params script, so
1049
- // useRoute().params reads the value that was opened, not the one kept.
1050
- var PARAMS_SCRIPT = /(<script\\b[^>]*data-stx-route-params[^>]*>\\(function\\(\\)\\{var p=)[\\s\\S]*?(;window\\.__stx_rp)/;
1051
- function withParams(response, params) {
1052
- return response.text().then(function (html) {
1053
- var json = JSON.stringify(params).replace(/</g, '\\\\u003C').replace(/\\u2028/g, '\\\\u2028').replace(/\\u2029/g, '\\\\u2029');
1054
- var body = html.replace(PARAMS_SCRIPT, function (all, open, close) { return open + json + close; });
1055
- var headers = new Headers(response.headers);
1056
- headers.delete('Content-Length');
1057
- return new Response(body, { status: 200, headers: headers });
1058
- });
1059
- }
1060
-
1061
- // The stylesheets and scripts a kept page links to. Each page has its own
1062
- // generated CSS, fetched only when the page is shown: a screen kept at
1063
- // install but never opened online came up offline without its styles.
1064
- // Background installation must leave connections available for the page the
1065
- // person opens. Bound the whole response body, not just its response headers.
1066
- var backgroundQueue = [];
1067
- var backgroundActive = 0;
1068
- function startBackground(job) {
1069
- var controller = new AbortController();
1070
- var timer = setTimeout(function () { controller.abort(); }, S.precacheTimeout);
1071
- function finish() {
1072
- clearTimeout(timer);
1073
- backgroundActive--;
1074
- drainBackground();
1075
- }
1076
- Promise.resolve().then(function () { return job.work(controller.signal); }).then(function (value) {
1077
- finish();
1078
- job.resolve(value);
1079
- }, function (error) {
1080
- finish();
1081
- job.reject(error);
1082
- });
1083
- }
1084
- function drainBackground() {
1085
- while (backgroundActive < 2 && backgroundQueue.length) {
1086
- backgroundActive++;
1087
- startBackground(backgroundQueue.shift());
1088
- }
1089
- }
1090
- function background(work) {
1091
- return new Promise(function (resolve, reject) {
1092
- backgroundQueue.push({ work: work, resolve: resolve, reject: reject });
1093
- drainBackground();
1094
- });
1095
- }
1096
-
1097
- var keepingAssets = {};
1098
- var ASSET_REF = /<(?:link|script)\\b[^>]*?\\s(?:href|src)="(\\/[^"]+\\.(?:css|js))"/g;
1099
- function assetRefs(html) {
1100
- var urls = [];
1101
- var match;
1102
- ASSET_REF.lastIndex = 0;
1103
- while ((match = ASSET_REF.exec(html))) {
1104
- if (urls.indexOf(match[1]) === -1) urls.push(match[1]);
1105
- }
1106
- return urls;
1107
- }
1108
-
1109
- function keepAsset(cache, request, response) {
1110
- return response.blob().then(function (body) { return cache.put(request, stamped(response, body, null)); });
1111
- }
1112
-
1113
- function keepAssets(html) {
1114
- var urls = assetRefs(html);
1115
- return caches.open(ASSETS).then(function (cache) {
1116
- return Promise.all(urls.map(function (url) {
1117
- // A page and its fragment link the same files: one fetch each.
1118
- if (!keepingAssets[url]) {
1119
- keepingAssets[url] = cache.match(url).then(function (hit) {
1120
- if (hit) return;
1121
- return background(function (signal) {
1122
- return fetch(url, { credentials: 'same-origin', signal: signal, priority: 'low' }).then(function (asset) {
1123
- if (asset.status === 200) return keepAsset(cache, url, asset);
1124
- delete keepingAssets[url];
1125
- });
1126
- });
1127
- }).catch(function () { delete keepingAssets[url]; });
1128
- }
1129
- return keepingAssets[url];
1130
- }));
1131
- }).catch(function () {});
1132
- }
1133
-
1134
- function precache() {
1135
- var wanted = S.pages.map(function (page) { return { url: page, key: function (fragment) { return variantUrl(page, fragment); } }; })
1136
- .concat(S.routes.map(function (route) { return { url: route.sample, key: function (fragment) { return routeKey(route, fragment); } }; }));
1137
- return caches.open(SHELL).then(function (cache) {
1138
- return Promise.all(wanted.map(function (page) {
1139
- return Promise.all([false, true].map(function (fragment) {
1140
- var headers = fragment ? { 'X-STX-Router': 'true', 'Accept': 'text/html' } : { 'Accept': 'text/html' };
1141
- return background(function (signal) {
1142
- return fetch(page.url, { headers: headers, credentials: 'same-origin', signal: signal, priority: 'low' }).then(function (response) {
1143
- if (response.status !== 200 || response.redirected) return null;
1144
- var copy = response.clone();
1145
- return Promise.all([store(cache, [page.key(fragment)], response), copy.text()]).then(function (parts) { return parts[1]; });
1146
- });
1147
- }).then(function (html) {
1148
- // Queue linked assets after releasing the page's slot. Waiting for
1149
- // child jobs inside a bounded parent job would deadlock installation.
1150
- if (html !== null) return keepAssets(html);
1151
- }).catch(function () {});
1152
- }));
1153
- }));
1154
- });
1155
- }
1156
-
1157
- // Stylesheets and scripts no kept screen of this build links to, and that
1158
- // nothing fetched lately, are an earlier build's: dropped when this build
1159
- // takes over. Other files (images, fonts) are capped, least recently fetched
1160
- // first. Fetching refreshes a file's stamp, so one in use is never the oldest.
1161
- var ASSET_GRACE_MS = 24 * 60 * 60 * 1000;
1162
- function pruneAssets() {
1163
- return Promise.all([caches.open(SHELL), caches.open(ASSETS)]).then(function (opened) {
1164
- var shell = opened[0];
1165
- var assets = opened[1];
1166
- return shell.keys().then(function (pages) {
1167
- return Promise.all(pages.map(function (page) {
1168
- return shell.match(page).then(function (hit) { return hit ? hit.text() : ''; }).catch(function () { return ''; });
1169
- }));
1170
- }).then(function (htmls) {
1171
- var linked = {};
1172
- htmls.forEach(function (html) {
1173
- assetRefs(html).forEach(function (url) { linked[new URL(url, self.location.origin).toString()] = true; });
1174
- });
1175
- return assets.keys().then(function (requests) {
1176
- return Promise.all(requests.map(function (request) {
1177
- return assets.match(request).then(function (hit) { return { request: request, at: hit ? Number(hit.headers.get(KEPT_AT) || 0) : 0 }; });
1178
- }));
1179
- }).then(function (entries) {
1180
- var now = Date.now();
1181
- var drops = [];
1182
- var others = [];
1183
- entries.forEach(function (entry) {
1184
- var url = entry.request.url;
1185
- if (/\\.(?:css|js)$/.test(new URL(url).pathname)) {
1186
- // With no screen kept there is nothing to judge by: keep them.
1187
- if (htmls.length && !linked[url] && now - entry.at > ASSET_GRACE_MS) drops.push(entry.request);
1188
- }
1189
- else others.push(entry);
1190
- });
1191
- if (others.length > S.assetsMax) {
1192
- others.sort(function (a, b) { return a.at - b.at; });
1193
- others.slice(0, others.length - S.assetsMax).forEach(function (entry) { drops.push(entry.request); });
1194
- }
1195
- return Promise.all(drops.map(function (request) { return assets.delete(request); }));
1196
- });
1197
- });
1198
- }).catch(function () {});
1199
- }
1200
-
1201
- // A new build waits for the one running to be let go (see 'message'), rather
1202
- // than taking over under a page that is on screen: its fragments would not
1203
- // match the page's build, and the router would reload under the person.
1204
- self.addEventListener('install', function (event) {
1205
- event.waitUntil(precache());
1206
- });
1207
-
1208
- self.addEventListener('activate', function (event) {
1209
- event.waitUntil(caches.keys().then(function (keys) {
1210
- return Promise.all(keys.filter(function (key) { return key.indexOf('stx-shell-') === 0 && key !== SHELL; }).map(function (key) { return caches.delete(key); }));
1211
- }).then(pruneAssets).then(function () { return self.clients.claim(); }));
1212
- });
1213
-
1214
- // When a page may let this build take over: asked outright (an "Update"
1215
- // button), the app starting cold, or no page of the app on screen.
1216
- function mayTakeOver(data) {
1217
- if (data.force || data.reason === 'cold-start') return Promise.resolve(true);
1218
- if (!self.clients || !self.clients.matchAll) return Promise.resolve(false);
1219
- return self.clients.matchAll({ type: 'window', includeUncontrolled: true }).then(function (list) {
1220
- if (data.reason === 'load' && list.length <= 1) return true;
1221
- return !list.some(function (client) { return client.visibilityState === 'visible'; });
1222
- });
1223
- }
1224
-
1225
- // --- Media kept for offline: videos a page asked for (cacheMedia()) ---
1226
- // Stored whole and answered here, ranges included: a player seeks with Range
1227
- // requests, and the network may not be there to answer them. The index (url
1228
- // -> bytes, when) lives in the same cache, so eviction can go oldest first.
1229
- function mediaKey(url) {
1230
- var u = new URL(url, self.location.origin);
1231
- u.hash = '';
1232
- return u.toString();
1233
- }
1234
-
1235
- function readMediaIndex(cache) {
1236
- return cache.match(MEDIA_INDEX).then(function (hit) { return hit ? hit.json() : {}; }).catch(function () { return {}; });
1237
- }
1238
-
1239
- function writeMediaIndex(cache, index) {
1240
- return cache.put(MEDIA_INDEX, new Response(JSON.stringify(index), { headers: { 'Content-Type': 'application/json' } }));
1241
- }
1242
-
1243
- function keepMedia(urls) {
1244
- return caches.open(MEDIA).then(function (cache) {
1245
- return readMediaIndex(cache).then(function (index) {
1246
- var wanted = urls.map(mediaKey);
1247
- var chain = Promise.resolve();
1248
- wanted.forEach(function (key) {
1249
- chain = chain.then(function () {
1250
- if (index[key]) { index[key].at = Date.now(); return; }
1251
- // Already stored by the page (cacheMedia downloads while the app is
1252
- // open), so only its size is wanted. Otherwise fetched here.
1253
- return cache.match(key).then(function (stored) {
1254
- if (stored) return stored;
1255
- return fetch(key, { credentials: 'same-origin' }).then(function (response) {
1256
- if (response.status !== 200 || !response.body) return null;
1257
- var type = response.headers.get('Content-Type') || 'application/octet-stream';
1258
- // Streamed into the cache, never held whole: a coach's 300 MB
1259
- // upload read into one blob was enough for iOS to end the worker
1260
- // part way, and nothing was kept.
1261
- return cache.put(key, new Response(response.body, { headers: { 'Content-Type': type, 'Accept-Ranges': 'bytes' } })).then(function () {
1262
- return cache.match(key);
1263
- });
1264
- });
1265
- }).then(function (kept) {
1266
- if (!kept) return;
1267
- return kept.blob().then(function (blob) { index[key] = { bytes: blob.size, at: Date.now() }; });
1268
- }).catch(function () {});
1269
- });
1270
- });
1271
- return chain.then(function () {
1272
- // Oldest first, until what is kept fits.
1273
- var total = 0;
1274
- var keys = Object.keys(index).sort(function (a, b) { return index[b].at - index[a].at; });
1275
- var drops = [];
1276
- keys.forEach(function (key) {
1277
- total += index[key].bytes;
1278
- if (total > S.mediaMax && wanted.indexOf(key) === -1) drops.push(key);
1279
- });
1280
- return Promise.all(drops.map(function (key) { delete index[key]; return cache.delete(key); }));
1281
- }).then(function () { return writeMediaIndex(cache, index); }).then(function () { return Object.keys(index); });
1282
- });
1283
- });
1284
- }
1285
-
1286
- function mediaResponse(request) {
1287
- return caches.open(MEDIA).then(function (cache) {
1288
- return cache.match(mediaKey(request.url)).then(function (hit) {
1289
- if (!hit) return null;
1290
- var range = request.headers.get('Range');
1291
- if (!range) return hit;
1292
- return hit.blob().then(function (blob) {
1293
- var match = /bytes=(\\d*)-(\\d*)/.exec(range);
1294
- var size = blob.size;
1295
- var start = match && match[1] ? Number(match[1]) : 0;
1296
- var end = match && match[2] ? Math.min(Number(match[2]), size - 1) : size - 1;
1297
- if (match && !match[1] && match[2]) { start = Math.max(0, size - Number(match[2])); end = size - 1; }
1298
- if (start >= size || start > end) return new Response(null, { status: 416, headers: { 'Content-Range': 'bytes */' + size } });
1299
- return new Response(blob.slice(start, end + 1), {
1300
- status: 206,
1301
- headers: {
1302
- 'Content-Type': hit.headers.get('Content-Type') || 'application/octet-stream',
1303
- 'Content-Range': 'bytes ' + start + '-' + end + '/' + size,
1304
- 'Content-Length': String(end - start + 1),
1305
- 'Accept-Ranges': 'bytes',
1306
- },
1307
- });
1308
- });
1309
- });
1310
- });
1311
- }
1312
-
1313
- self.addEventListener('message', function (event) {
1314
- var data = event.data || {};
1315
- if (data.type === 'stx:reachability?') {
1316
- // A page just opened: what this worker last saw of the server.
1317
- event.waitUntil(announce({ type: 'stx:reachability', reachable: reachable, at: reachedAt }));
1318
- }
1319
- if (data.type === 'stx:clear-offline-data') {
1320
- lastWrite = null;
1321
- event.waitUntil(Promise.all([caches.delete(DATA), caches.delete(MEDIA)]));
1322
- }
1323
- if (data.type === 'stx:activate-update') {
1324
- // Sent to the waiting worker. One already running ignores it: skipWaiting
1325
- // does nothing once active.
1326
- event.waitUntil(mayTakeOver(data).then(function (yes) { if (yes) return self.skipWaiting(); }));
1327
- }
1328
- if (data.type === 'stx:cache-media' && Array.isArray(data.urls)) {
1329
- var reply = event.ports && event.ports[0];
1330
- event.waitUntil(keepMedia(data.urls.filter(function (url) { return typeof url === 'string'; })).then(function (kept) {
1331
- if (reply) reply.postMessage({ ok: true, kept: kept });
1332
- }, function () {
1333
- if (reply) reply.postMessage({ ok: false, kept: [] });
1334
- }));
1335
- }
1336
- });
1337
-
1338
- // Whether the fallback screen may stand in for this path (S.fallbackScope).
1339
- function inFallbackScope(pathname) {
1340
- var scope = S.fallbackScope;
1341
- if (!scope || scope === '/') return true;
1342
- return pathname === scope || pathname.indexOf(scope + '/') === 0;
1343
- }
1344
-
1345
- // The fallback screen stands in for one this device has not kept whole. It
1346
- // says so, and the router then asks for the screen that was wanted as a
1347
- // fragment: one reached inside the app was kept that way.
1348
- function markFallback(response) {
1349
- return response.text().then(function (html) {
1350
- var head = html.indexOf('<head');
1351
- var at = head === -1 ? -1 : html.indexOf('>', head) + 1;
1352
- var mark = '<meta name="stx-offline-fallback" content="1">';
1353
- var body = at > 0 ? html.slice(0, at) + mark + html.slice(at) : mark + html;
1354
- var headers = new Headers(response.headers);
1355
- headers.delete('Content-Length');
1356
- return new Response(body, { status: 200, headers: headers });
1357
- });
1358
- }
1359
-
1360
- // The app starting cold (a navigation with no other page of it open) while a
1361
- // new build waits, with updateOnColdStart on: the new build takes over now, and
1362
- // this navigation goes to the network so it opens on the new build rather than
1363
- // the kept old one. Off, it opens at once on the kept build.
1364
- function coldStartUpdate(request) {
1365
- var registration = self.registration;
1366
- if (!S.updateOnColdStart || request.mode !== 'navigate' || !registration || !registration.waiting || !self.clients || !self.clients.matchAll) return Promise.resolve(false);
1367
- return self.clients.matchAll({ type: 'window' }).then(function (list) {
1368
- if (list.length > 1 || !registration.waiting) return false;
1369
- registration.waiting.postMessage({ type: 'stx:activate-update', reason: 'cold-start' });
1370
- return true;
1371
- }).catch(function () { return false; });
1372
- }
1373
-
1374
- // Whether every module bundle a kept page links to is kept too.
1375
- //
1376
- // A page's registry, stores and composables are /_stx/modules.<hash>.js,
1377
- // answered by the server process that rendered the page, and only by it: a
1378
- // deploy starts a process that has never heard of the old hashes and answers
1379
- // them 404. A kept page whose bundles are not kept beside it is therefore one
1380
- // that may never bind -- opened cold, it showed its markup with every {{ }}
1381
- // empty and no button working, until a revalidation happened to replace it.
1382
- // Such a copy is not answered first: the network is, and the copy only stands
1383
- // in when there is no network at all, where it is the best there is.
1384
- // ignoreVary: a script was kept under the browser's own request, whose
1385
- // Accept-Encoding a lookup by URL does not carry.
1386
- var MODULE_BUNDLE = /\\/_stx\\/modules\\.[0-9a-f]{16}\\.js/g;
1387
- function bundlesKept(response) {
1388
- return response.clone().text().then(function (html) {
1389
- var urls = [];
1390
- var match;
1391
- MODULE_BUNDLE.lastIndex = 0;
1392
- while ((match = MODULE_BUNDLE.exec(html))) {
1393
- if (urls.indexOf(match[0]) === -1) urls.push(match[0]);
1394
- }
1395
- if (!urls.length) return true;
1396
- return caches.open(ASSETS).then(function (assets) {
1397
- return Promise.all(urls.map(function (url) { return assets.match(url, { ignoreVary: true }); }));
1398
- }).then(function (kept) {
1399
- return kept.every(Boolean);
1400
- });
1401
- }).catch(function () { return true; });
1402
- }
1403
-
1404
- function pageResponse(request, event) {
1405
- var fragment = isFragment(request);
1406
- var key = variantUrl(request.url, fragment);
1407
- var dynamic = routeOf(new URL(request.url).pathname);
1408
- var keys = dynamic ? [key, routeKey(dynamic.route, fragment)] : [key];
1409
- return Promise.all([caches.open(SHELL), coldStartUpdate(request)]).then(function (opened) {
1410
- var cache = opened[0];
1411
- var networkFirst = opened[1] || wantsNetworkFirst(request, new URL(request.url).pathname);
1412
- return cache.match(key).then(function (hit) {
1413
- return (hit && !networkFirst ? bundlesKept(hit) : Promise.resolve(false)).then(function (whole) {
1414
- if (whole) {
1415
- keepAlive(event, revalidate(request, cache, keys, hit, 'page'));
1416
- return hit;
1417
- }
1418
- // Kept, but without its module bundles: not shown while the network
1419
- // might answer (bundlesKept).
1420
- var partial = hit && !networkFirst;
1421
- var asked = network(request).then(function (response) {
1422
- if (keepable(response) || keepStaticPage(request, response)) keepAlive(event, store(cache, keys, response.clone()));
1423
- return response;
1424
- });
1425
- // What stands in when the network is not there, or slow: the kept copy,
1426
- // then a dynamic route's kept page, then the fallback screen.
1427
- var standIn = function (offline) {
1428
- if (hit && (!partial || offline)) return Promise.resolve(hit);
1429
- var route = dynamic ? cache.match(routeKey(dynamic.route, fragment)) : Promise.resolve(null);
1430
- return route.then(function (kept) {
1431
- if (kept) return withParams(kept, dynamic.params);
1432
- if (!offline) return null;
1433
- if (!S.fallback || fragment || !inFallbackScope(new URL(request.url).pathname)) return Response.error();
1434
- return cache.match(variantUrl(S.fallback, false)).then(function (fallback) { return fallback ? markFallback(fallback) : Response.error(); });
1435
- });
1436
- };
1437
- return withTimeout(asked, S.timeout).catch(function () {
1438
- return standIn(false).then(function (kept) {
1439
- if (kept) {
1440
- keepAlive(event, asked);
1441
- return kept;
1442
- }
1443
- // Slower than the timeout, nothing kept to show: wait for it rather than fail.
1444
- return asked.catch(function () { return standIn(true); });
1445
- });
1446
- });
1447
- });
1448
- });
1449
- });
1450
- }
1451
-
1452
- function assetResponse(request, event) {
1453
- return caches.open(ASSETS).then(function (cache) {
1454
- return cache.match(request).then(function (hit) {
1455
- var network = fetch(request).then(function (response) {
1456
- if (keepable(response)) keepAlive(event, keepAsset(cache, request, response.clone()));
1457
- return response;
1458
- });
1459
- if (hit) {
1460
- keepAlive(event, network);
1461
- return hit;
1462
- }
1463
- return network;
1464
- });
1465
- });
1466
- }
1467
-
1468
- // When the app last wrote to its API (any request but a GET). A copy kept
1469
- // before it is not answered at once: it would show the screen as if the
1470
- // write had not happened. Kept in the data cache so a restarted worker knows.
1471
- var lastWrite = null;
1472
- function lastWriteAt() {
1473
- if (!lastWrite) {
1474
- lastWrite = caches.open(DATA).then(function (cache) { return cache.match(LAST_WRITE); })
1475
- .then(function (hit) { return hit ? hit.text() : '0'; })
1476
- .then(function (text) { return Number(text) || 0; })
1477
- .catch(function () { return 0; });
1478
- }
1479
- return lastWrite;
1480
- }
1481
- function noteWrite() {
1482
- var at = Date.now();
1483
- lastWrite = Promise.resolve(at);
1484
- return caches.open(DATA).then(function (cache) { return cache.put(LAST_WRITE, new Response(String(at))); }).catch(function () {});
1485
- }
1486
-
1487
- function apiResponse(request, event) {
1488
- return hashOf(request.headers.get('Authorization') || '').then(function (who) {
1489
- var u = new URL(request.url);
1490
- u.searchParams.set('__stx_who', who);
1491
- var key = u.toString();
1492
- return Promise.all([caches.open(DATA), lastWriteAt()]).then(function (opened) {
1493
- var cache = opened[0];
1494
- return cache.match(key).then(function (hit) {
1495
- var stale = hit && opened[1] > 0 && Number(hit.headers.get(KEPT_AT) || 0) <= opened[1];
1496
- if (hit && !stale && !wantsNetworkFirst(request, u.pathname)) {
1497
- keepAlive(event, revalidate(request, cache, [key], hit, 'api'));
1498
- return hit;
1499
- }
1500
- var asked = network(request).then(function (response) {
1501
- if (noStore(response)) keepAlive(event, cache.delete(key));
1502
- if (keepable(response)) keepAlive(event, store(cache, [key], response.clone()));
1503
- return response;
1504
- });
1505
- return withTimeout(asked, S.timeout).catch(function () {
1506
- return hit || asked;
1507
- });
1508
- });
1509
- });
1510
- });
1511
- }
1512
-
1513
- self.addEventListener('fetch', function (event) {
1514
- var request = event.request;
1515
- var url = new URL(request.url);
1516
- if (url.origin !== self.location.origin) return;
1517
- if (request.method !== 'GET') {
1518
- // Writes go straight to the network; only when they happened is noted.
1519
- if (url.pathname.indexOf(S.api) === 0) keepAlive(event, noteWrite());
1520
- return;
1521
- }
1522
- // Live status and other explicitly uncached reads must never be answered
1523
- // from offline storage, including when the network fails.
1524
- if (request.cache === 'no-store') {
1525
- event.respondWith(network(request));
1526
- return;
1527
- }
1528
- // Media kept for offline is answered from the device, a range included;
1529
- // anything else asking for a range is the browser's to answer, since a
1530
- // cache cannot hold a partial response.
1531
- if (request.headers.has('Range') || /\\.(?:mp4|m4v|mov|webm|m3u8|mp3|m4a)$/i.test(url.pathname)) {
1532
- event.respondWith(mediaResponse(request).then(function (kept) { return kept || fetch(request); }));
1533
- return;
1534
- }
1535
- for (var i = 0; i < S.exclude.length; i++) {
1536
- if (url.pathname.indexOf(S.exclude[i]) === 0) return;
1537
- }
1538
- if (url.pathname.indexOf(S.api) === 0) {
1539
- event.respondWith(apiResponse(request, event));
1540
- return;
1541
- }
1542
- if (url.pathname.indexOf('/_stx/') === 0 || url.pathname.indexOf('/assets/') === 0 || /\\.(?:js|css|woff2?|png|jpe?g|webp|avif|svg|ico)$/.test(url.pathname)) {
1543
- event.respondWith(assetResponse(request, event));
1544
- return;
1545
- }
1546
- var accept = request.headers.get('Accept') || '';
1547
- if (request.mode === 'navigate' || isFragment(request) || accept.indexOf('text/html') !== -1) {
1548
- event.respondWith(pageResponse(request, event));
1549
- }
1550
- });
1551
- `}import Ie from"path";function on(r){return r.startsWith("http://")||r.startsWith("https://")||r.startsWith("//")}async function an(r,e,c){try{let a;if(r.startsWith("/")){let d=e;for(let n=0;n<5;n++){let g=Ie.join(d,r);if(await Bun.file(g).exists())return g;d=Ie.dirname(d)}a=Ie.join(e,r)}else if(r.startsWith("./")||r.startsWith("../"))a=Ie.resolve(e,r);else a=Ie.resolve(e,r);if(await Bun.file(a).exists())return a;return null}catch{return null}}var cn=Symbol.for("stx.inline-assets.import-meta");function ns(r,e){if(!r.includes("import.meta"))return;let c=Error(`[stx] ${e} still references \`import.meta\` after bundling, and it is being inlined as a classic <script> where that is a SyntaxError \u2014 the whole script fails to parse, taking every other script on the page with it.
1552
- `+" `import.meta.env.STX_PUBLIC_*` is substituted at build time and is safe; anything else is not.\n Fix it by moving the module-only code (`import.meta.glob`, `import.meta.url`) into its own module, or by resolving the value without `import.meta`.");throw c[cn]=!0,c}async function ln(r,e,c){let a=r,d=Ie.dirname(e),n=/<script\b([^>]*)src=["']([^"']+)["']([^>]*)><\/script>/gi,g;while((g=n.exec(a))!==null){let[x,b,w,S]=g;if(on(w))continue;let k=await an(w,d,e);if(k)try{let D=await Bun.file(k).text();if(c.add(k),w.endsWith(".ts")||w.endsWith(".tsx")){let M=await Bun.build({entrypoints:[k],target:"browser",minify:!0,define:C()});if(M.outputs.length>0)D=await M.outputs[0].text(),ns(D,w)}let R=`<script>
1553
- // Source: ${w}
1554
- ${D}
1555
- </script>`;a=a.replace(x,R),n.lastIndex=0}catch(D){if(D?.[cn])throw D}}let v=/<link\b([^>]*)href=["']([^"']+)["']([^>]*)(?:\/?>)/gi,m;while((m=v.exec(a))!==null){let[x,b,w,S]=m,k=b+S;if(on(w))continue;if(/rel=["']stylesheet["']/.test(k)||w.endsWith(".css")){let R=await an(w,d,e);if(R)try{let M=await Bun.file(R).text();c.add(R);let O=`<style>
1556
- /* Source: ${w} */
1557
- ${M}
1558
- </style>`;a=a.replace(x,O),v.lastIndex=0}catch(M){}}}return a}import ot from"path";var rs=/(\bfrom\s*|\bimport\s*\(\s*|\bimport\s+)(['"])(\.\.?\/[^'"]*)\2/g,ss=/(<script\b[^>]*>)([\s\S]*?)(<\/script>)/gi;function ls(r,e){if(!e||!r.includes("/"))return r;let c=ot.dirname(e);return r.replace(rs,(a,d,n,g)=>{let v=ot.resolve(c,g);return`${d}${n}${v.split(ot.sep).join("/")}${n}`})}function un(r,e){if(!e||!r.includes("<script"))return r;return r.replace(ss,(c,a,d,n)=>`${a}${ls(d,e)}${n}`)}var Te="<!--PARENT_CONTENT_PLACEHOLDER-->";function dn(r){return r.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function En(r,e){let c=r.length,a=e,d=!0,n=[],g=(v)=>v+9<=c&&r[v]==="<"&&r[v+1]==="/"&&(r[v+2]==="s"||r[v+2]==="S")&&(r[v+3]==="c"||r[v+3]==="C")&&(r[v+4]==="r"||r[v+4]==="R")&&(r[v+5]==="i"||r[v+5]==="I")&&(r[v+6]==="p"||r[v+6]==="P")&&(r[v+7]==="t"||r[v+7]==="T")&&(r[v+8]===">"||/\s/.test(r[v+8]));while(a<c){let v=r[a];if(g(a))return a;if(v==="/"&&r[a+1]==="/"){if(a=r.indexOf(`
1559
- `,a+2),a===-1)return-1;a+=1,d=!0;continue}if(v==="/"&&r[a+1]==="*"){let m=r.indexOf("*/",a+2);if(m===-1)return-1;a=m+2,d=!0;continue}if(v==="/"&&d){let m=a+1,x=!1;while(m<c){let b=r[m];if(b==="\\"){m+=2;continue}if(b==="[")x=!0;else if(b==="]")x=!1;else if(b==="/"&&!x){m++;break}else if(b===`
1560
- `){m=-1;break}m++}if(m===-1){a++,d=!1;continue}while(m<c&&/[a-z]/.test(r[m]))m++;a=m,d=!1;continue}if(v==="'"||v==='"'){let m=v;a++;while(a<c){if(r[a]==="\\"){a+=2;continue}if(r[a]===m){a++;break}if(r[a]===`
1561
- `)break;a++}d=!1;continue}if(v==="`"){a++;while(a<c){if(r[a]==="\\"){a+=2;continue}if(r[a]==="`"){a++;break}if(r[a]==="$"&&r[a+1]==="{"){n.push(!0),a+=2,d=!0;break}a++}if(n.length===0)d=!1;continue}if(v==="}"&&n.length>0){n.pop(),a++;while(a<c){if(r[a]==="\\"){a+=2;continue}if(r[a]==="`"){a++,d=!1;break}if(r[a]==="$"&&r[a+1]==="{"){n.push(!0),a+=2,d=!0;break}a++}continue}if(/\s/.test(v));else if(/[)\].\w$]/.test(v))d=!1;else d=!0;a++}return-1}function Tn(r,e){let c=e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),a=new RegExp(`<script\\b(?=[^>]*\\b${c}(?:\\s|=|/?>))[^>]*>`,"i").exec(r);if(!a)return null;let d=a.index+a[0].length,n=r.indexOf("</script>",d);if(n===-1)return null;let g=r.indexOf(">",n);if(g===-1)return null;return{start:a.index,end:g+1}}var fs=4096;async function at(r,e,c){if(c.buildMode!=="serve"||e.length<fs)return null;let{registerServeModuleBundle:a}=await import("./chunk-1kz70290.js");return`<script ${r} src="${a(e)}"></script>`}async function tr(r,e,c,a){try{let{registeredModuleIdsIn:d,buildModuleRegistryScript:n}=await o("stx/client-module-registry",()=>import("./chunk-aya8nv31.js")),g=[],v=await n(d(...r),{minify:$i(e.buildMode,e.minifyClient),collectInputs:g});for(let m of g)c?.add(m);if(a)a.inputs=g,a.code=v??void 0;if(!v)return null;if(e.buildMode==="serve"){let{registerServeModuleBundle:m}=await import("./chunk-1kz70290.js");return`<script data-stx-scoped data-stx-run="always" data-stx-modules src="${m(v)}"></script>`}return`<script data-stx-scoped data-stx-run="always" data-stx-modules>${v.replace(/<\/script/gi,"<\\/script")}</script>`}catch{return null}}async function ys(r,e,c,a){let d={modulesTag:null,modulesCode:null,storeTag:null,storeCode:null,composableTag:null,composableCode:null,frameworkScript:null};try{let{getFrameworkComposableScript:S}=await o("stx/framework-composables",()=>import("./chunk-1fc6rax4.js"));d.frameworkScript=await S(r)}catch{}let n=null;try{n=await o("stx/store-loader",()=>import("./chunk-7pb9fepg.js"))}catch{}let g=e.storesDir,v=!!a.__stx_native_screen||(n?.pageStoresAll()??!0),m=v?"":r.replace(/<script\b[^>]*\bdata-stx-(?:runtime|router|hmr)\b[^>]*>[\s\S]*?<\/script>/gi,""),x=[],b=[],w=null;for(let S=0;S<8;S++){let k=null,D="",R=!1;try{if(n){let H=v?await n.getStoreScript(g).then((V)=>V?{code:V,stores:["*"],functions:null}:null):await n.getStoreScriptFor(g,[m],{reads:n.storesReadInFiles([...x,...b]),runOnce:!0});if(H)k=H.code,D=H.stores.join(","),R=!!H.functions&&!v}}catch{}if(w!==null&&D===w)break;w=D;let M=R?'data-stx-scoped data-stx-run="always" data-stx-stores':"data-stx-stores",O=k?`<script ${M}>${k}</script>`:null;d.storeCode=k,d.storeTag=k?await at(M,k,e)??O:null;let N={};d.modulesTag=await tr([r,O],e,c,N),d.modulesCode=N.code??null,x=N.inputs??[],d.composableTag=null,d.composableCode=null,b=[];try{let{getComposableScript:H}=await o("stx/composable-loader",()=>import("./chunk-k98nt4pk.js")),V=e.composablesDir,P=[d.modulesCode??d.modulesTag,O,d.frameworkScript].filter((B)=>B!==null),L=await H(e._layerComposableDirs??V,r,P,b);if(L)d.composableCode=L,d.composableTag=await at('data-stx-scoped data-stx-run="always" data-stx-composables',L,e)??`<script data-stx-scoped data-stx-run="always" data-stx-composables>${L}</script>`}catch{}if(v||!n)break}return d}async function vs(r,e,c,a={}){let{withModuleSubstitutes:d,moduleSubstitutionKey:n}=await import("./chunk-yjvwp1s6.js"),g=await import("./chunk-mkr46mzz.js"),{messages:v,webModules:m}=e,x=null,b=null,w=n()===""&&!a.__stx_native_screen;if(v&&g.pageMessagesEnabled(e)&&w)try{x=await g.loadPageMessages(process.cwd(),v)}catch(M){bs(M)}if(m&&Object.keys(m).length&&w)try{b=await(await import("./chunk-ntn6bnjv.js")).loadWebModules(process.cwd(),m)}catch(M){ws(M)}let S=new Map([...b??[],...x?.stubs??[]]),k=()=>ys(r,e,c,a),D=S.size?await d(S,k):await k(),R=null;if(x){let M=g.messageAreasIn(D.modulesCode,D.storeCode,D.composableCode),O=g.pageMessagesScript(x,g.pageLanguages(r,x),M);if(O)R=await at('data-stx-scoped data-stx-run="always" data-stx-messages',O,e)??`<script data-stx-scoped data-stx-run="always" data-stx-messages>${O.replace(/<\/script/gi,"<\\/script")}</script>`}return[R,D.modulesTag,D.storeTag,D.composableTag,D.frameworkScript].filter((M)=>M!==null)}var gn=!1;function bs(r){if(gn)return;gn=!0,console.warn(`[stx] messages: ${r instanceof Error?r.message:String(r)}; pages ship every language`)}var hn=!1;function ws(r){if(hn)return;hn=!0,console.warn(`[stx] ${r instanceof Error?r.message:String(r)}; pages bundle the real modules`)}function xs(r,e=""){let c=Tn(r,"data-stx-runtime");if(!c)return r;let a=ar(r);if(a===-1||a===c.start){if(!e)return r;return r.slice(0,c.end)+e+r.slice(c.end)}if(a<c.start)return r.slice(0,a)+r.slice(c.start,c.end)+e+`
1562
- `+r.slice(a,c.start)+r.slice(c.end);let d=r.slice(c.start,c.end),n=r.slice(0,c.start)+r.slice(c.end),g=ar(n);if(g===-1)return d+e+`
1563
- `+n;return n.slice(0,g)+d+e+`
1564
- `+n.slice(g)}function Ss(r){let e=/\x00STX_ESC_MUSTACHE_OPEN\x00([\s\S]*?)\x00STX_ESC_MUSTACHE_CLOSE\x00/g;return r.replace(e,(c,a,d)=>{let n=r.slice(0,d);return n.lastIndexOf("<")>n.lastIndexOf(">")?`{{${a}}}`:`{<!--stx-literal-->{${a}}}`})}async function i(r,e,c,a,d){if(a.ssr===!1&&!a.autoShell&&a.buildMode==="spa")return r;if(e.__stx_signals_gate===void 0)e.__stx_signals_gate=Se(r,c);let n=!e.__stxProcessingDepth;mn(e);for(let g of a._layerGraph?.configDependencies??[])d.add(g);if(n&&a.runtimeConfig)await vn(e,c,a.runtimeConfig);if(n)Hc(e),e.__stx_scope_seq??={n:0,key:Vs(String(e.__filename??c))},e.__stx_head_injections=Ci(),e.__stx_seo_staged=!1;if(!e.__stxProcessingDepth)e.__stxProcessingDepth=0;if(e.__stxProcessingDepth++,!e.__onceStore)e.__onceStore=new Set;if((a.debug||!E()&&!_n())&&c&&c.endsWith(".stx"))Do(r,c);try{return await ie.timeAsync("template-processing",async()=>{let g=await ks(r,e,c,a,d);if(n)g=fi(g);if(n&&a.autoShell&&a.buildMode!=="compile"){let v=_e(a.app?.head,{known:Ir,source:"app.head"}),x=(e.__stx_runtime_head||null)??Ti(),b=(e.__stx_head_raw||"").trim(),w,S=b.match(/<title[^>]*>([\s\S]*?)<\/title>/i);if(S)w=S[1].trim(),b=b.replace(S[0],"").trim();let k=e.__sections?.title,D=k?_(k,e,c):void 0,R=x.title||w||D,M=!x.title&&(!!w||!!D),O=x.meta||[],N=new Set(O.map((X)=>it(X)).filter(Boolean)),H={...v,...R&&{title:R},meta:[...(v.meta||[]).filter((X)=>!N.has(it(X))),...O],link:[...v.link||[],...x.link||[]],script:[...v.script||[],...x.script||[]],headRaw:[v.headRaw,b].filter(Boolean).join(`
1565
- `),...x.htmlAttrs&&{htmlAttrs:ol(v.htmlAttrs,x.htmlAttrs)},...x.bodyAttrs&&{bodyAttrs:{...v.bodyAttrs||{},...x.bodyAttrs}}},V=Ei(g);if(g=Ar(g,H,{...M&&{titleIsHtml:!0},...a.app?.colorMode&&{colorMode:a.app.colorMode}},V),V)g=al(g,v),g=Rr(g,H.htmlAttrs);let P=g.match(/<!-- stx-layout: ([^ ]+) -->/);if(P&&g.includes("<head")){let X=P[1],K=As(X);g=g.replace(/<head\b[^>]*>/i,(ee)=>`${ee}
1566
- <meta name="stx-layout" content="${dn(X)}">
1567
- <meta name="stx-layout-group" content="${dn(K)}">`)}let L=g.match(/function (__stx_setup_\w+)\(/),B=L?j(g):null;if(L&&B&&!/\bdata-stx=/.test(B.tag)){g=Ye(g,(K,ee)=>`<body${ee} data-stx="${L[1]}">`);let X=new RegExp(`(<(?!body)[a-zA-Z][^>]*) data-stx="${L[1]}"`,"i");g=g.replace(X,"$1")}}if(n){let v=e.__stx_head_injections??Ci(),m=il(g);if(m!==null)v.beforeClose.push(m);let x=rn(g);if(x!==null)v.afterOpen.push(x);if(a.offline?.enabled&&!g.includes("data-stx-offline"))v.beforeClose.push(sn);g=rl(g,v);let b=a.app?.colorMode;if(b)g=$r(g,b)}if(n)if(Tn(g,"data-stx-runtime")){let m=await vs(g,a,d,e);g=xs(g,m.map((x)=>`
1568
- ${x}`).join(""))}else{let m=await tr([g],a,d);if(m){let x=g.search(/<script\b[^>]*>(?:(?!<\/script>)[\s\S])*?__stxModules\[/i);if(x!==-1)g=g.slice(0,x)+m+`
1569
- `+g.slice(x)}}if(n)g=sl(g);if(n&&e.__stx_inject_css!==!1)g=await y(g,void 0,a.buildMode==="serve",!0);else if(n)g=fn(g);if(g=g.replace(/\x00STX_ESCAPED_AT\x00/g,"@"),g=Ss(g),n&&e.__stx_runtime_config)g=Dt(g,e.__stx_runtime_config);if(n&&!e.__stx_defer_server_data){let v=_r(e);if(v){let m=/<head\b[^>]*>/i.exec(g),x=m?m.index+m[0].length:0;g=g.slice(0,x)+v+g.slice(x)}}return g})}catch(g){if(g instanceof q)throw g;let v=g instanceof Error?g.message:String(g),m=new ae(`Template processing failed: ${v}`,c,void 0,void 0,r.substring(0,200)+(r.length>200?"...":""));if(F.log(m,{filePath:c,context:e}),Sn.logDetailedError(m,{filePath:c,template:r.substring(0,500)}),E()&&!a.debug)console.error(`[stx] ${ce.relative(process.cwd(),c)||c}: ${m.message}`);if(a.debug)throw m;return ki.createFallbackContent("Template Processing",m)}}async function ks(r,e,c,a,d){let n=process.cwd(),g={...a,partialsDir:a.partialsDir&&!ce.isAbsolute(a.partialsDir)?ce.resolve(n,a.partialsDir):a.partialsDir,componentsDir:a.componentsDir&&!ce.isAbsolute(a.componentsDir)?ce.resolve(n,a.componentsDir):a.componentsDir,layoutsDir:a.layoutsDir&&!ce.isAbsolute(a.layoutsDir)?ce.resolve(n,a.layoutsDir):a.layoutsDir},v=g,m=r;await _s(c,e),Es(e,v),m=await ke(()=>Xt(m,e,c,v),m,(P)=>{F.log(P,{filePath:c,phase:"pre-processing-middleware"},"warning"),console.warn(`[stx] pre-processing middleware failed for ${c}: ${P.message}`)}),m=m.replace(/\{\{--[\s\S]*?--\}\}/g,"");let x=pe(m,Ne,(P,L)=>`\x00STX_HTML_COMMENT_${L}\x00`);m=x.output;let b=x.tokens,w=(P)=>b.length===0?P:P.replace(/\x00STX_HTML_COMMENT_(\d+)\x00/g,(L,B)=>b[Number(B)]??""),S="\x00STX_ESCAPED_AT\x00",k="\x00STX_ESC_MUSTACHE_OPEN\x00",D="\x00STX_ESC_MUSTACHE_CLOSE\x00";m=m.replace(/@@/g,S),m=m.replace(/@\{\{([\s\S]*?)\}\}/g,(P,L)=>`${k}${L}${D}`),m=Qt(m),m=await ln(m,c,d);let R={};m=as(m,R);let M={...e.__sections||{}},O="",N=ht(yt(r)),H=/@nolayout\b/.test(m)||N===!1;if(/@nolayout\b/.test(m))m=m.replace(/@nolayout\b\s*/g,"");let V=m.match(/@(?:layout|extends)\(\s*['"]([^'"]+)['"]\s*\)/);if(V)O=V[1],m=m.replace(/@(?:layout|extends)\(\s*['"]([^'"]+)['"]\s*\)/g,"");else if(typeof N==="string"){if(O=N,!/@section\s*\(/.test(m))m=`@section('content')
1570
- ${m.trim()}
1571
- @endsection`}if(!O&&!H&&v.defaultLayout){let P=kn(m),L=/@section\s*\(/.test(m);if(!P||L){let B="",X=ce.dirname(c),K=v.layoutsDir?ce.dirname(v.layoutsDir):process.cwd();for(let ee=0;ee<20;ee++){let te=ce.join(X,"_layout.stx");if(await s(te)){B=te;break}let ne=ce.dirname(X);if(ne===X||ne.length<K.length)break;X=ne}if(B)O=B;else if(v.layoutsDir){let ee=ce.isAbsolute(v.layoutsDir)?v.layoutsDir:ce.resolve(process.cwd(),v.layoutsDir),te=ce.join(ee,`${v.defaultLayout}.stx`);if(await s(te))O=te}if(O&&!L)m=`@section('content')
1572
- ${m.trim()}
1573
- @endsection`}}if(O&&m.includes("<script")){let P=G(m),L=P.scripts.map((B)=>yn(B,c)??B);m=vr(P.output,L)}if(m=m.replace(/@section\(\s*['"]([^'"]+)['"]\s*,\s*['"]([^'"]+)['"]\s*\)/g,(P,L,B)=>(M[L]=B,"")),m=m.replace(/@section\(\s*['"]([^'"]+)['"]\s*,\s*([^)]+?)\s*\)/g,(P,L,B)=>{if(/^(['"]).*\1$/.test(B.trim()))return P;try{let X=u(B.trim(),e);if(X===void 0)return P;let ee=(e.__stx_inline_section_values??=[]).push(X)-1;return M[L]=`{{ __stx_inline_section_values[${ee}] }}`,""}catch{return P}}),m=m.replace(/@section\(\s*['"]([^'"]+)['"]\s*\)([\s\S]*?)(?:@endsection|@show)/g,(P,L,B)=>{if(B.includes("@parent"))M[L]=B.replace("@parent",Te);else M[L]=B.trim();return""}),e.__sections=M,m=m.replace(/@(?:yield|slot)\(\s*['"]([^'"]+)['"](?:,\s*['"]([^'"]+)['"])?\)/g,(P,L,B)=>M[L]||B||""),!("slot"in e)||e.slot===void 0)m=m.replace(/\{\{\s*slot\s*\}\}/g,()=>M.content||"");if(m=cs(m,R),O){let P=[],L=G(m),B=pe(L.output,pn,(X,K)=>`\x00STX_ORPHAN_STYLE_${K}\x00`);if(m=B.output.replace(/\x00STX_(SCRIPT|ORPHAN_STYLE)_(\d+)\x00/g,(X,K,ee)=>{let te=K==="SCRIPT"?yn(L.scripts[Number(ee)],c):B.tokens[Number(ee)];if(te)P.push(te);return""}),P.length>0){let X=P.join(`
1574
- `);M.content=M.content?`${M.content}
1575
- ${X}`:X,e.__sections=M}}if(O)try{let P;if(ce.isAbsolute(O))P=O,d.add(O);else P=await ke(()=>bn(O,c,g,d),null,()=>{throw new ae(`Failed to resolve layout path: ${O}`,c,void 0,void 0,`Layout referenced from ${c}`)});if(!P){let te=(J)=>{if(!J)return[];try{let me=ce.isAbsolute(J)?J:ce.resolve(process.cwd(),J);return ps.readdirSync(me).filter((we)=>we.endsWith(".stx")).map((we)=>we.replace(/\.stx$/,""))}catch{return[]}},ne=[...te(g.layoutsDir),...te(g.fallbackLayoutsDir)].filter((J,me,we)=>we.indexOf(J)===me).sort(),le=[g.layoutsDir,g.fallbackLayoutsDir].filter((J)=>typeof J==="string"&&J.length>0),de=le.length>0?` Searched: ${le.join(", ")} (set \`layoutsDir\` to look elsewhere).`:"",oe=`Layout not found: ${O} (referenced from ${c})`+(ne.length>0?`. Available layouts: ${ne.join(", ")}`:g.layoutsDir?`. No .stx layouts found in ${g.layoutsDir}`:"")+de;if(F.log(Error(oe),{layoutPath:O,filePath:c,available:ne},"error"),console.error(`[stx] ${oe}`),g.debug)throw new ae(oe,c);return m}let L=await ke(()=>Bun.file(P).text(),"",()=>{throw new ae(`Failed to read layout file: ${P}`,c,void 0,void 0,"Layout content could not be loaded")});L=un(L,P);let B=L.match(/@(?:layout|extends)\(\s*['"]([^'"]+)['"]\s*\)/);if(B){if(g.debug)console.log(`Found nested layout: ${B[1]} in ${P}`);let te={},ne=L.replace(/@section\(\s*['"]([^'"]+)['"]\s*\)([\s\S]*?)(?:@show|@endsection)/g,(oe,J,me)=>(te[J]=me.trim(),""));for(let[oe,J]of Object.entries(te))if(M[oe]&&M[oe].includes(Te)){let me=M[oe].indexOf(Te);M[oe]=M[oe].slice(0,me)+J+M[oe].slice(me+Te.length)}else if(!M[oe])M[oe]=J;let le={...e,__sections:M},de=`@layout('${B[1]}')${ne}`;return await i(de,le,P,g,d)}let X=L.replace(/\{\{--[\s\S]*?--\}\}/g,""),K=as(X,R),ee={};return K=K.replace(/@section\(\s*['"]([^'"]+)['"]\s*\)([\s\S]*?)(?:@show|@endsection)/g,(te,ne,le)=>(ee[ne]=le.trim(),`@slot('${ne}')`)),K=K.replace(/@(?:yield|slot)\(\s*['"]([^'"]+)['"]\s*(?:,\s*['"]([^'"]+)['"]\s*)?\)/g,(te,ne,le)=>{if(M[ne]){let de=M[ne];if(de.includes(Te)){let oe=ee[ne]||"",J=de.indexOf(Te);de=de.slice(0,J)+oe+de.slice(J+Te.length)}return de}return le||""}),K=$s(K,M),K=K.replace(/\{\{\s*slot\s*\}\}/g,()=>M.content||""),K=cs(K,R),e.__originalFilePath=c,m=await $n(K,e,P,g,d),m=`<!-- stx-layout: ${O} -->
1576
- ${m}`,w(m)}catch(P){if(P instanceof q)throw P;throw new ae(`Error processing layout ${O}: ${P instanceof Error?P.message:String(P)}`,c)}return w(await $n(m,e,c,g,d))}function $s(r,e){return r.replace(/@(?:yield|slot)\(\s*['"]([^'"]+)['"]\s*(?:,\s*['"]([^'"]+)['"]\s*)?\)/g,(c,a,d)=>{let n=e[a];if(n!==void 0){if(!new RegExp(`@(?:yield|slot)\\(\\s*['"]${a.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}['"]`).test(n))return n}return d||""})}function Es(r,e){if(r.__stx_sfc_mode=!0,r.__stx_options=e,e.buildMode)r.__stx_buildMode=e.buildMode;let c=e.envPrefix||"STX_PUBLIC_",a={};for(let[d,n]of Object.entries(process.env))if(d.startsWith(c)&&n!==void 0)a[d]=n;r.$env=a}async function _s(r,e){await ke(()=>Jt(r,e),void 0,(c)=>{F.log(c,{filePath:r,phase:"view-composer"},"warning"),console.warn(`[stx] view composer failed for ${r}: ${c.message}`)})}var ct="data-stx-source";function yn(r,e){if(!r)return r;let c=/^<script\b([^>]*)>/i.exec(r);if(!c||!/\bserver\b/.test(c[1])||c[1].includes(ct))return r;return`<script ${ct}="${encodeURIComponent(e)}"${r.slice(7)}`}function Ts(r){let e=new RegExp(`${ct}="([^"]*)"`).exec(r);return e?decodeURIComponent(e[1]):void 0}function wn(r){return r.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function xn(r,e,c){return`<div data-stx-server-script-error role="alert" style="padding:12px 14px;border:1px solid #f0b4b4;border-left-width:4px;background:#fff5f5;color:#7a1f1f;font:13px/1.5 ui-monospace,SFMono-Regular,Menlo,monospace"><strong style="display:block;margin-bottom:4px">stx: a &lt;script server&gt; ${e==="module-resolution"?"imports a module that does not resolve":e==="syntax"?"does not parse":"names something that does not exist"}, so this component rendered nothing.</strong><span style="display:block;opacity:.85">${wn(r)}</span><span style="display:block;margin-top:4px">${wn(c)}</span></div>`}async function Cs(r,e,c,a){let{scanScriptTags:d}=await o("stx/signal-processing",()=>import("./chunk-rqfg21xk.js")),n=[],g=!E()&&!_n();for(let m of d(r)){let x=m.attrs;if(!/\bserver\b/.test(x))continue;let b=m.start+m.fullMatch.indexOf(">")+1,w=En(r,b);if(w===-1)continue;let S=r.slice(b,w);if(!S.trim())continue;let k=Ts(x)??c,D={index:m.start,length:w+9-m.start};try{let{extractVariables:R}=await o("stx/variable-extractor",()=>import("./chunk-x5rt4kpx.js"));await R(S,e,k,{preserveExisting:!0,onFailure:(M)=>{if(M.kind==="unknown")return;if(a?.onServerScriptError?.({sourcePath:k,kind:M.kind,message:M.message}),!g)return;n.push({...D,markup:xn(k,M.kind,M.message)})}})}catch(R){let M=R instanceof Error?R:Error(String(R));if(F.log(M,{filePath:k,phase:"server-script-extraction"},"warning"),console.warn(`[stx] server <script> extraction failed in ${k}: ${M.message}`),g)n.push({...D,markup:xn(k,"unknown",M.message)})}}if(n.length===0)return r;let v=r;for(let m of n.sort((x,b)=>b.index-x.index))v=v.slice(0,m.index)+m.markup+v.slice(m.index+m.length);return v}async function Rs(r,e,c){try{let{interpolateScriptsInTemplate:a}=await o("stx/expressions",()=>import("./chunk-yd0074ks.js"));return a(r,e,{skipServer:!0})}catch(a){let d=a instanceof Error?a:Error(String(a));return F.log(d,{filePath:c,phase:"script-expression-interpolation"},"warning"),console.warn(`[stx] script expression interpolation failed in ${c}: ${d.message}`),r}}async function $n(r,e,c,a,d){let n=r,g=a;if(n=await Cs(n,e,c,a),n=await qt(n,e,c),n=await Ut(n,e,c),n=await Rs(n,e,c),n=await Rt(n,e,c,g),Se(n))n=Uo(n,e),n=hs(n,e),n=ms(n,e);n=Wo(n);let{processStreamDirectives:v}=await o("stx/streaming",()=>import("./chunk-9ttf7k5e.js"));n=v(n,e),n=or(n,e,c,g,!0),n=await nn(n,e,c,g,d),n=await us(n,e,c,g,d),n=pc(n,e,c,g);let{processDeferDirectives:m}=await o("stx/defer",()=>import("./chunk-bj6ax0he.js"));n=m(n,e,c);let{processTeleportDirectives:x}=await o("stx/teleport",()=>import("./chunk-rxc1076r.js"));n=x(n,e,c);let{processTransitionDirectives:b,processTransitionAttributes:w}=await o("stx/transitions",()=>import("./chunk-d3gncxq1.js"));n=b(n,e,c),n=w(n);let{processErrorBoundaryDirectives:S,stripRenderFailedMarkers:k}=await o("stx/error-boundaries",()=>import("./chunk-h85hrwkq.js"));n=S(n,e,c),n=k(n);let{processSuspenseDirectives:D}=await o("stx/suspense",()=>import("./chunk-1rwfgmmk.js"));n=D(n,e,c);let{processAsyncDirectives:R}=await o("stx/async-components",()=>import("./chunk-xgqyzkt2.js"));n=R(n,e,c);let{processKeepAliveDirectives:M}=await o("stx/keep-alive",()=>import("./chunk-cxpnkgvw.js"));n=M(n,e,c);let{processVirtualListDirectives:O,processVirtualGridDirectives:N,processInfiniteListDirectives:H}=await o("stx/virtual-scrolling",()=>import("./chunk-tzb0n60s.js"));n=O(n,e,c),n=N(n,e,c),n=H(n,e,c);let{processPartialHydrationDirectives:V,processStaticDirectives:P}=await o("stx/partial-hydration",()=>import("./chunk-da886asf.js"));n=V(n,e,c),n=P(n);let{processComputedDirectives:L,processWatchDirectives:B}=await o("stx/computed",()=>import("./chunk-1xdzcy9d.js"));n=L(n,e,c),n=B(n,e,c);let{processFormValidationDirectives:X}=await o("stx/forms-validation",()=>import("./chunk-snfjvd94.js"));n=X(n,e,c);let{processHeadDirective:K,processTitleDirective:ee,processMetaDirective:te,resetHead:ne}=await o("stx/head",()=>import("./chunk-mmyrdbxx.js"));if(!e.__stx_head_preset&&!e.__stx_runtime_head)ne();let le=K(n);if(n=le.content,le.headContent)e.__stx_head_raw=`${e.__stx_head_raw||""}${le.headContent}
1577
- `;if(n=ee(n,e),n=te(n,e,c),n=Gt(n),n=Fo(n,e),n=At(n),n=zt(n),n=await is(n,e,c,g,d),n=await us(n,e,c,g,d),n=n.replace(/@push\s*\(\s*['"][^'"]+['"]\s*\)[\s\S]*?@endpush/g,""),n=fi(n),n=se(n,e,c),n=ds(n),e.__stxProcessingDepth===1)n=Vc(n,e);if(n=jc(n,e,{filePath:c,buildMode:g.buildMode}),n=zo(n,e),n=Ho(n,e),n=We(n,e),n=Ht(n,e),n=Bt(n,e),n=await xt(n,e,c,g),n=await gc(n,e,c),n=await mc(n,e,c,g),n=hc(n,e,c,g),n=Zo(n,e,c,g),n=Qo(n,e,c),n=ei(n,e,c,g),n=Tt(n,e,c,g),n=zs(n,e),n=Hs(n),n=Bc(n),!g.skipEventDirectives)n=$c(n,e,c);if(n=wt(n,e,c),g.debug){let z=/\bx-data\s*=/.test(n),W=gs(r);if(z&&W)console.warn(`[stx] ${c}: Template mixes Alpine-style (x-data) and signals (state/derived/effect) reactivity.
1578
- Both work on the same page, but they manage separate scopes.
1579
- Prefer signals (state/derived/effect) for new components.`)}n=ac(n,e),n=await _(n,e,c),n=Fc(n),n=zc(n),n=gt(n);let{processXElementDirectives:de}=await o("stx/x-element",()=>import("./chunk-zhxdpzga.js"));n=de(n);let oe=e.__originalFilePath||c,J=De(e);if(n=await qo(n,g,oe,J),n=Pt(n,e),n=await Kt(n,e,c,g),g.media?.image?.autoSiblings){let z=g.publicDir||"public",{rewriteImagesWithSiblings:W}=await o("stx/image-optimization/auto-sibling",()=>import("./chunk-9wmjmas8.js"));n=await W(n,{publicDir:z})}if(g.seo?.enabled)n=ti(n,e,g);let me=(z,W,Q=!0)=>{if(!W)return z;let he=W.match(/<title\b[^>]*>[\s\S]*?<\/title>/i),re=/<head\b[^>]*>[\s\S]*?(?:<\/head\s*>|<body\b|$)/i.exec(z),fe=re?/<title\b[^>]*>[\s\S]*?<\/title>/i.exec(re[0]):null;if(he&&re&&fe){if(Q){let Ce=re.index+fe.index;z=z.slice(0,Ce)+he[0]+z.slice(Ce+fe[0].length)}if(W=W.replace(he[0],"").trim(),!W)return z}if(/<\/head>/i.test(z))return z.replace(/<\/head>/i,`${W}
1580
- </head>`);if(/<head\b[^>]*>/i.test(z))return z.replace(/(<head\b[^>]*>)/i,`$1
1581
- ${W}`);if(/<html\b[^>]*>/i.test(z))return z.replace(/(<html\b[^>]*>)/i,`$1
1582
- <head>
1583
- ${W}
1584
- </head>`);return z},{renderHead:we,getHead:Cn}=await o("stx/head",()=>import("./chunk-mmyrdbxx.js")),Pe=e.__stx_runtime_head??Cn();if(Pe.title||Pe.meta?.length||Pe.link?.length){let z=we(Pe);if(z)n=me(n,z)}if(le.headContent)n=me(n,le.headContent,!Pe.title);if(g.csp?.enabled&&g.csp.addMetaTag)n=Et(n,g.csp,e);if(g.analytics?.enabled)n=mt(n,g);if(g.heatmap?.enabled)n=fc(n,g);if(g.pwa?.enabled&&g.pwa.autoInject!==!1){let{injectPwaTags:z}=await o("stx/pwa/inject",()=>import("./chunk-aqydav9y.js"));n=z(n,g)}let An=/<script\b(?![^>]*\bserver\b)[^>]*>[\s\S]*?<\/script>/i.test(n),Rn=/\bSTX\.\w+/.test(n),Mn=/window\.STX\s*=/.test(n);if(An&&Rn&&!Mn){let W=`<script data-stx-scoped data-stx-run="once">
1585
- ${dt()}
1586
- </script>`;if(n.includes("</head>")){let Q=n.indexOf("</head>"),re=n.slice(0,Q).indexOf("<script");if(re!==-1){let fe=n.slice(0,re),Ce=n.slice(re);n=fe+W+`
1587
- `+Ce}else n=n.replace("</head>",`${W}
1588
- </head>`)}else if(n.includes("<body"))n=n.replace(/<body([^>]*)>/,`<body$1>
1589
- ${W}`);else n=W+`
1590
- `+n}{let{scanScriptTags:z}=await o("stx/signal-processing",()=>import("./chunk-rqfg21xk.js")),W=[];for(let Q of z(n)){if(!/\bserver\b/i.test(Q.attrs))continue;let he=Q.start+Q.fullMatch.indexOf(">")+1,re=En(n,he);if(re===-1)continue;let fe=re+9;while(fe<n.length&&/\s/.test(n[fe]))fe++;W.push({start:Q.start,end:fe})}if(W.length>0){let Q=Array(W.length+1),he=0;for(let re=0;re<W.length;re++){let{start:fe,end:Ce}=W[re];Q[re]=n.slice(he,fe),he=Ce}Q[W.length]=n.slice(he),n=Q.join("")}}let lt=Bs(n,c);if(lt.hasScoped)n=lt.html;let Dn=e.__stx_event_bindings||[],Ke=!1,ut=[],In=/\s:[a-z][\w.-]*\s*=/.test(n),{scanScriptTags:On}=await o("stx/signal-processing",()=>import("./chunk-rqfg21xk.js"));for(let z of On(n,{skipAttrs:/\bserver\b|\bsrc\s*=|\bdata-stx-scoped\b|\bdata-stx-router\b|\btype\s*=\s*["'](?!(?:text\/javascript|application\/javascript|module)["'])[^"']*["']/}))ut.push({match:z.fullMatch,attrs:z.attrs,content:z.body});for(let{match:z,attrs:W,content:Q}of ut){Ke=!0;let he=Q;Oe(Q,c,a.strict,e.__originalFilePath);let re=await Le(Q,{eventBindings:Dn,attrs:W,hasColonDirectives:In,templateContent:r,filePath:c,projectRoot:process.cwd(),production:$i(a.buildMode,a.minifyClient),serverData:J});n=n.replace(z,()=>re)}if(Ke)e.__stx_event_bindings=[];if(!Ke&&e.__stxProcessingDepth===1){let z=e.__stx_event_bindings||[];if(z.length>0){let W=ai(z);if(W){let Q=n.lastIndexOf("</body>");n=Q===-1?n+W:n.slice(0,Q)+W+`
1591
- `+n.slice(Q)}e.__stx_event_bindings=[]}}if(!be(n)&&lc(n))n=await cr(n,g);if(n=uc(n),g.csp?.enabled&&g.csp.useNonce&&typeof e.cspNonce==="string")n=_t(n,e.cspNonce);return n}
1592
- export{yt,Re,rc,os,No,Mo,tr,i};