@stacksjs/actions 0.70.23 → 0.70.26

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 (384) hide show
  1. package/dist/chunk-2gh7kgpc.js +3 -0
  2. package/dist/chunk-2kaj93p5.js +3 -0
  3. package/dist/chunk-2qchdrf9.js +3 -0
  4. package/dist/chunk-3086k7zk.js +184 -0
  5. package/dist/chunk-3beht8ja.js +130 -0
  6. package/dist/chunk-60qjz7zb.js +3 -0
  7. package/dist/chunk-67y94dzt.js +658 -0
  8. package/dist/chunk-6x1m5rkr.js +17 -0
  9. package/dist/chunk-7bpdkc40.js +714 -0
  10. package/dist/chunk-96b7fcmd.js +3 -0
  11. package/dist/chunk-aw6d8zr3.js +7 -0
  12. package/dist/chunk-c8qt2xst.js +3 -0
  13. package/dist/chunk-d4srk6ma.js +3 -0
  14. package/dist/chunk-e9tcbk71.js +1 -0
  15. package/dist/chunk-gt77jmb5.js +46 -0
  16. package/dist/chunk-h93n2j40.js +95 -0
  17. package/dist/chunk-jd1yzkq5.js +3 -0
  18. package/dist/chunk-kzhgexj4.js +3 -0
  19. package/dist/chunk-n1y0gpv6.js +3 -0
  20. package/dist/chunk-n2fd1d0m.js +3 -0
  21. package/dist/chunk-n2x7v39b.js +5 -0
  22. package/dist/chunk-rdajkt2s.js +88 -0
  23. package/dist/chunk-s735m9mg.js +1 -0
  24. package/dist/chunk-schcaf73.js +3 -0
  25. package/dist/chunk-tc935b45.js +93 -0
  26. package/dist/chunk-v0wnrnaa.js +7 -0
  27. package/dist/chunk-w418anbq.js +5 -0
  28. package/dist/chunk-wnrgcx3d.js +114 -0
  29. package/dist/chunk-wv5yb5wb.js +101 -0
  30. package/dist/chunk-x471rxrn.js +7 -0
  31. package/dist/chunk-xg9xscqz.js +1 -0
  32. package/dist/src/action.d.ts +60 -0
  33. package/dist/src/action.js +2 -0
  34. package/dist/src/actions.d.ts +2 -0
  35. package/dist/src/actions.js +2 -0
  36. package/dist/src/add.d.ts +6 -0
  37. package/dist/src/add.js +2 -0
  38. package/dist/src/ai/request-model-access.d.ts +1 -0
  39. package/dist/src/ai/request-model-access.js +2 -0
  40. package/dist/src/auth/client.d.ts +1 -0
  41. package/dist/src/auth/client.js +3 -0
  42. package/dist/src/auth/prune.d.ts +1 -0
  43. package/dist/src/auth/prune.js +2 -0
  44. package/dist/src/auth/setup.d.ts +1 -0
  45. package/dist/src/auth/setup.js +148 -0
  46. package/dist/src/auth/token.d.ts +1 -0
  47. package/dist/src/auth/token.js +2 -0
  48. package/dist/src/build/cli.d.ts +1 -0
  49. package/dist/src/build/cli.js +2 -0
  50. package/dist/src/build/component-libs.d.ts +1 -0
  51. package/dist/src/build/component-libs.js +2 -0
  52. package/dist/src/build/core.d.ts +1 -0
  53. package/dist/src/build/core.js +2 -0
  54. package/dist/src/build/desktop.d.ts +1 -0
  55. package/dist/src/build/desktop.js +2 -0
  56. package/dist/src/build/docs.d.ts +1 -0
  57. package/dist/src/build/docs.js +2 -0
  58. package/dist/src/build/server.d.ts +1 -0
  59. package/dist/src/build/server.js +2 -0
  60. package/dist/src/build/stacks.d.ts +1 -0
  61. package/dist/src/build/stacks.js +2 -0
  62. package/dist/src/build/views.d.ts +1 -0
  63. package/dist/src/build/views.js +2 -0
  64. package/dist/{build.d.ts → src/build.d.ts} +1 -2
  65. package/dist/src/build.js +2 -0
  66. package/dist/src/bump.d.ts +1 -0
  67. package/dist/src/bump.js +2 -0
  68. package/dist/src/cdn/invalidate-cache.d.ts +1 -0
  69. package/dist/src/cdn/invalidate-cache.js +1 -0
  70. package/dist/src/changelog.d.ts +1 -0
  71. package/dist/src/changelog.js +2 -0
  72. package/dist/src/check/ports.d.ts +1 -0
  73. package/dist/src/check/ports.js +2 -0
  74. package/dist/src/clean.d.ts +1 -0
  75. package/dist/src/clean.js +2 -0
  76. package/dist/{commit.d.ts → src/commit.d.ts} +1 -2
  77. package/dist/src/commit.js +2 -0
  78. package/dist/src/copy-types.d.ts +1 -0
  79. package/dist/src/copy-types.js +3 -0
  80. package/dist/src/database/seed.d.ts +1 -0
  81. package/dist/src/database/seed.js +2 -0
  82. package/dist/src/deploy/create-receipt-rule.d.ts +1 -0
  83. package/dist/src/deploy/create-receipt-rule.js +2 -0
  84. package/dist/src/deploy/index.d.ts +1 -0
  85. package/dist/src/deploy/index.js +307 -0
  86. package/dist/src/dev/api.d.ts +1 -0
  87. package/dist/src/dev/api.js +6 -0
  88. package/dist/src/dev/components.d.ts +1 -0
  89. package/dist/src/dev/components.js +2 -0
  90. package/dist/src/dev/dashboard-globals.d.ts +4 -0
  91. package/dist/src/dev/dashboard-globals.js +3 -0
  92. package/dist/src/dev/dashboard-utils.d.ts +126 -0
  93. package/dist/src/dev/dashboard-utils.js +2 -0
  94. package/dist/src/dev/dashboard.d.ts +12 -0
  95. package/dist/src/dev/dashboard.js +8 -0
  96. package/dist/src/dev/desktop.d.ts +1 -0
  97. package/dist/src/dev/desktop.js +2 -0
  98. package/dist/src/dev/docs.d.ts +1 -0
  99. package/dist/src/dev/docs.js +2 -0
  100. package/dist/src/dev/index.d.ts +10 -0
  101. package/dist/src/dev/index.js +2 -0
  102. package/dist/src/dev/system-tray.d.ts +1 -0
  103. package/dist/src/dev/system-tray.js +2 -0
  104. package/dist/src/dev/views.d.ts +1 -0
  105. package/dist/src/dev/views.js +2 -0
  106. package/dist/src/discover-packages.d.ts +18 -0
  107. package/dist/src/discover-packages.js +2 -0
  108. package/dist/src/domains/add.d.ts +1 -0
  109. package/dist/src/domains/add.js +2 -0
  110. package/dist/src/domains/purchase.d.ts +1 -0
  111. package/dist/src/domains/purchase.js +2 -0
  112. package/dist/src/domains/remove.d.ts +1 -0
  113. package/dist/src/domains/remove.js +2 -0
  114. package/dist/{examples.d.ts → src/examples.d.ts} +1 -2
  115. package/dist/src/examples.js +2 -0
  116. package/dist/src/find-projects.d.ts +1 -0
  117. package/dist/src/find-projects.js +2 -0
  118. package/dist/src/fresh.d.ts +1 -0
  119. package/dist/src/fresh.js +2 -0
  120. package/dist/src/generate/action-types.d.ts +1 -0
  121. package/dist/src/generate/action-types.js +8 -0
  122. package/dist/src/generate/component-meta.d.ts +1 -0
  123. package/dist/src/generate/component-meta.js +3 -0
  124. package/dist/src/generate/custom-cli-file.d.ts +1 -0
  125. package/dist/src/generate/custom-cli-file.js +4 -0
  126. package/dist/src/generate/env-files.d.ts +1 -0
  127. package/dist/src/generate/env-files.js +26 -0
  128. package/dist/src/generate/ide-helpers.d.ts +1 -0
  129. package/dist/src/generate/ide-helpers.js +3 -0
  130. package/dist/src/generate/index.d.ts +36 -0
  131. package/dist/src/generate/index.js +2 -0
  132. package/dist/src/generate/lib-entries.d.ts +1 -0
  133. package/dist/src/generate/lib-entries.js +3 -0
  134. package/dist/src/generate/pantry-file.d.ts +1 -0
  135. package/dist/src/generate/pantry-file.js +2 -0
  136. package/dist/src/generate/symlink-core.d.ts +1 -0
  137. package/dist/src/generate/symlink-core.js +2 -0
  138. package/dist/src/generate/types.d.ts +1 -0
  139. package/dist/src/generate/types.js +2 -0
  140. package/dist/src/generate/vscode-custom-data.d.ts +1 -0
  141. package/dist/src/generate/vscode-custom-data.js +3 -0
  142. package/dist/src/generate/web-types.d.ts +1 -0
  143. package/dist/src/generate/web-types.js +1 -0
  144. package/dist/src/helpers/component-meta.d.ts +26 -0
  145. package/dist/src/helpers/component-meta.js +2 -0
  146. package/dist/src/helpers/index.d.ts +4 -0
  147. package/dist/src/helpers/index.js +2 -0
  148. package/dist/{lib-entries.d.ts → src/helpers/lib-entries.d.ts} +9 -5
  149. package/dist/src/helpers/lib-entries.js +2 -0
  150. package/dist/src/helpers/package-json.d.ts +2 -0
  151. package/dist/src/helpers/package-json.js +43 -0
  152. package/dist/src/helpers/utils.d.ts +23 -0
  153. package/dist/src/helpers/utils.js +2 -0
  154. package/dist/{vscode-custom-data.d.ts → src/helpers/vscode-custom-data.d.ts} +1 -1
  155. package/dist/src/helpers/vscode-custom-data.js +2 -0
  156. package/dist/src/index.d.ts +42 -0
  157. package/dist/src/index.js +2 -0
  158. package/dist/src/key-generate.d.ts +1 -0
  159. package/dist/src/key-generate.js +2 -0
  160. package/dist/src/lint/fix.d.ts +1 -0
  161. package/dist/src/lint/fix.js +4 -0
  162. package/dist/src/lint/index.d.ts +1 -0
  163. package/dist/src/lint/index.js +3 -0
  164. package/dist/src/make-command.d.ts +10 -0
  165. package/dist/src/make-command.js +2 -0
  166. package/dist/src/make-job.d.ts +5 -0
  167. package/dist/src/make-job.js +2 -0
  168. package/dist/src/make-policy.d.ts +10 -0
  169. package/dist/src/make-policy.js +2 -0
  170. package/dist/src/make-resource.d.ts +10 -0
  171. package/dist/src/make-resource.js +2 -0
  172. package/dist/{make.d.ts → src/make.d.ts} +11 -9
  173. package/dist/src/make.js +2 -0
  174. package/dist/src/migrate/database.d.ts +1 -0
  175. package/dist/src/migrate/database.js +2 -0
  176. package/dist/src/migrate/fresh.d.ts +1 -0
  177. package/dist/src/migrate/fresh.js +2 -0
  178. package/dist/src/orm/base.d.ts +1 -0
  179. package/dist/src/orm/base.js +2 -0
  180. package/dist/src/orm/test.d.ts +1 -0
  181. package/dist/src/orm/test.js +1 -0
  182. package/dist/src/prepublish.d.ts +1 -0
  183. package/dist/src/prepublish.js +2 -0
  184. package/dist/src/queue/clear.d.ts +1 -0
  185. package/dist/src/queue/clear.js +2 -0
  186. package/dist/src/queue/failed.d.ts +1 -0
  187. package/dist/src/queue/failed.js +5 -0
  188. package/dist/src/queue/flush.d.ts +1 -0
  189. package/dist/src/queue/flush.js +3 -0
  190. package/dist/src/queue/inspect.d.ts +1 -0
  191. package/dist/src/queue/inspect.js +8 -0
  192. package/dist/src/queue/monitor.d.ts +1 -0
  193. package/dist/src/queue/monitor.js +7 -0
  194. package/dist/src/queue/retry.d.ts +1 -0
  195. package/dist/src/queue/retry.js +2 -0
  196. package/dist/src/queue/schedule-list.d.ts +1 -0
  197. package/dist/src/queue/schedule-list.js +5 -0
  198. package/dist/src/queue/schedule.d.ts +1 -0
  199. package/dist/src/queue/schedule.js +2 -0
  200. package/dist/src/queue/status.d.ts +1 -0
  201. package/dist/src/queue/status.js +5 -0
  202. package/dist/src/queue/table.d.ts +1 -0
  203. package/dist/src/queue/table.js +2 -0
  204. package/dist/src/queue/work.d.ts +1 -0
  205. package/dist/src/queue/work.js +2 -0
  206. package/dist/src/release.d.ts +1 -0
  207. package/dist/src/release.js +3 -0
  208. package/dist/src/route/list.d.ts +1 -0
  209. package/dist/src/route/list.js +3 -0
  210. package/dist/src/run-action.d.ts +2 -0
  211. package/dist/src/run-action.js +2 -0
  212. package/dist/src/saas/setup.d.ts +1 -0
  213. package/dist/src/saas/setup.js +2 -0
  214. package/dist/src/scaffold-crud.d.ts +25 -0
  215. package/dist/src/scaffold-crud.js +2 -0
  216. package/dist/src/schedule/run.d.ts +1 -0
  217. package/dist/src/schedule/run.js +2 -0
  218. package/dist/src/search/flush.d.ts +1 -0
  219. package/dist/src/search/flush.js +2 -0
  220. package/dist/src/search/import.d.ts +1 -0
  221. package/dist/src/search/import.js +2 -0
  222. package/dist/src/search/settings-list.d.ts +1 -0
  223. package/dist/src/search/settings-list.js +2 -0
  224. package/dist/src/search/settings.d.ts +1 -0
  225. package/dist/src/search/settings.js +2 -0
  226. package/dist/src/serve/api.d.ts +1 -0
  227. package/dist/src/serve/api.js +2 -0
  228. package/dist/src/setup/index.d.ts +1 -0
  229. package/dist/src/setup/index.js +2 -0
  230. package/dist/src/setup/ssl.d.ts +38 -0
  231. package/dist/src/setup/ssl.js +2 -0
  232. package/dist/src/stacks.d.ts +4 -0
  233. package/dist/src/stacks.js +2 -0
  234. package/dist/src/templates.d.ts +8 -0
  235. package/dist/src/templates.js +2 -0
  236. package/dist/src/test/feature.d.ts +1 -0
  237. package/dist/src/test/feature.js +2 -0
  238. package/dist/src/test/index.d.ts +1 -0
  239. package/dist/src/test/index.js +2 -0
  240. package/dist/src/test/ui.d.ts +1 -0
  241. package/dist/src/test/ui.js +2 -0
  242. package/dist/src/test/unit.d.ts +1 -0
  243. package/dist/src/test/unit.js +2 -0
  244. package/dist/src/typecheck.d.ts +1 -0
  245. package/dist/src/typecheck.js +2 -0
  246. package/dist/{types.d.ts → src/types.d.ts} +1 -2
  247. package/dist/src/types.js +2 -0
  248. package/dist/src/upgrade/binary.d.ts +1 -0
  249. package/dist/src/upgrade/binary.js +2 -0
  250. package/dist/src/upgrade/bun.d.ts +1 -0
  251. package/dist/src/upgrade/bun.js +1 -0
  252. package/dist/src/upgrade/dependencies.d.ts +1 -0
  253. package/dist/src/upgrade/dependencies.js +2 -0
  254. package/dist/src/upgrade/framework-utils.d.ts +102 -0
  255. package/dist/src/upgrade/framework-utils.js +2 -0
  256. package/dist/src/upgrade/framework.d.ts +1 -0
  257. package/dist/src/upgrade/framework.js +7 -0
  258. package/dist/src/upgrade/index.d.ts +1 -0
  259. package/dist/src/upgrade/index.js +2 -0
  260. package/dist/src/upgrade/shell.d.ts +1 -0
  261. package/dist/src/upgrade/shell.js +5 -0
  262. package/dist/src/upgrade.d.ts +7 -0
  263. package/dist/src/upgrade.js +2 -0
  264. package/package.json +39 -23
  265. package/dist/action-types.d.ts +0 -9
  266. package/dist/action.d.ts +0 -64
  267. package/dist/actions.d.ts +0 -2
  268. package/dist/add.d.ts +0 -5
  269. package/dist/add.js +0 -33
  270. package/dist/api.d.ts +0 -1
  271. package/dist/binary.d.ts +0 -2
  272. package/dist/build/component-libs.js +0 -9
  273. package/dist/build/core.js +0 -23
  274. package/dist/build/stacks.js +0 -8
  275. package/dist/build.js +0 -108
  276. package/dist/bump.d.ts +0 -2
  277. package/dist/bump.js +0 -17
  278. package/dist/changelog.d.ts +0 -2
  279. package/dist/changelog.js +0 -17
  280. package/dist/chunk-2dvnt46s.js +0 -7657
  281. package/dist/chunk-494jp8d5.js +0 -54
  282. package/dist/chunk-4axj3j8y.js +0 -34
  283. package/dist/chunk-56ar3gp7.js +0 -3823
  284. package/dist/chunk-76zhb40c.js +0 -92
  285. package/dist/chunk-7s5qcjkt.js +0 -105
  286. package/dist/chunk-9v6qtbez.js +0 -45
  287. package/dist/chunk-a13x0e43.js +0 -1180
  288. package/dist/chunk-a7k3cdby.js +0 -2266
  289. package/dist/chunk-b5g5w1hh.js +0 -1482
  290. package/dist/chunk-bf8bq8pc.js +0 -205
  291. package/dist/chunk-ccnf3w1b.js +0 -2228
  292. package/dist/chunk-dvkgakrr.js +0 -1283
  293. package/dist/chunk-frw3va9v.js +0 -69
  294. package/dist/chunk-hvfeg6n6.js +0 -179248
  295. package/dist/chunk-mdj7x1vs.js +0 -790
  296. package/dist/chunk-mdqphqep.js +0 -438
  297. package/dist/chunk-mmskr8ar.js +0 -212
  298. package/dist/chunk-nrr524a7.js +0 -658
  299. package/dist/chunk-p0c688mg.js +0 -729
  300. package/dist/chunk-pacq2bz6.js +0 -902
  301. package/dist/chunk-psa9yf21.js +0 -72
  302. package/dist/chunk-q81mf99q.js +0 -169
  303. package/dist/chunk-q9dmga3k.js +0 -11
  304. package/dist/chunk-qhh0v93n.js +0 -73
  305. package/dist/chunk-qkm8e752.js +0 -51
  306. package/dist/chunk-saqpg5nd.js +0 -118
  307. package/dist/chunk-t5em30ak.js +0 -379
  308. package/dist/chunk-veja9rez.js +0 -5764
  309. package/dist/chunk-w4bfpxhm.js +0 -311
  310. package/dist/chunk-w6fdq4hk.js +0 -14425
  311. package/dist/chunk-wkwtsvym.js +0 -477
  312. package/dist/chunk-xgsmf4cy.js +0 -410
  313. package/dist/chunk-ykb33tkv.js +0 -177
  314. package/dist/chunk-ze46550n.js +0 -0
  315. package/dist/chunk-zzerxbrm.js +0 -107
  316. package/dist/clean.js +0 -6
  317. package/dist/commit.js +0 -22
  318. package/dist/component-meta.d.ts +0 -15
  319. package/dist/components.d.ts +0 -3
  320. package/dist/copy-types.d.ts +0 -1
  321. package/dist/copy-types.js +0 -14
  322. package/dist/core.d.ts +0 -1
  323. package/dist/create-receipt-rule.d.ts +0 -4
  324. package/dist/database/seed.js +0 -30
  325. package/dist/database.d.ts +0 -2
  326. package/dist/deploy/index.js +0 -48
  327. package/dist/dev/components.js +0 -11
  328. package/dist/dev/docs.js +0 -7
  329. package/dist/dev/index.js +0 -58
  330. package/dist/env-files.d.ts +0 -9
  331. package/dist/examples.js +0 -46
  332. package/dist/feature.d.ts +0 -2
  333. package/dist/find-projects.d.ts +0 -1
  334. package/dist/fix.d.ts +0 -1
  335. package/dist/flush.d.ts +0 -2
  336. package/dist/fresh.d.ts +0 -1
  337. package/dist/fresh.js +0 -21
  338. package/dist/generate/component-meta.js +0 -17
  339. package/dist/generate/ide-helpers.js +0 -18
  340. package/dist/generate/index.js +0 -216
  341. package/dist/generate/lib-entries.js +0 -30
  342. package/dist/generate/vscode-custom-data.js +0 -17
  343. package/dist/helpers/component-meta.js +0 -204227
  344. package/dist/helpers/lib-entries.js +0 -122
  345. package/dist/helpers/package-json.js +0 -96
  346. package/dist/helpers/utils.js +0 -76
  347. package/dist/helpers/vscode-custom-data.js +0 -43
  348. package/dist/import.d.ts +0 -2
  349. package/dist/index.d.ts +0 -2
  350. package/dist/index.js +0 -172
  351. package/dist/key-generate.js +0 -15
  352. package/dist/lint/fix.js +0 -18
  353. package/dist/lint/index.js +0 -5
  354. package/dist/list.d.ts +0 -1
  355. package/dist/make.js +0 -349
  356. package/dist/package-json.d.ts +0 -92
  357. package/dist/pkgx-file.d.ts +0 -8
  358. package/dist/ports.d.ts +0 -2
  359. package/dist/prepublish.d.ts +0 -1
  360. package/dist/prepublish.js +0 -17
  361. package/dist/purchase.d.ts +0 -6
  362. package/dist/release.js +0 -49
  363. package/dist/remove.d.ts +0 -6
  364. package/dist/request-model-access.d.ts +0 -1
  365. package/dist/run.d.ts +0 -1
  366. package/dist/settings-list.d.ts +0 -2
  367. package/dist/settings.d.ts +0 -1
  368. package/dist/setup.d.ts +0 -1
  369. package/dist/shell.d.ts +0 -2
  370. package/dist/table.d.ts +0 -1
  371. package/dist/test/feature.js +0 -14
  372. package/dist/test/index.js +0 -14
  373. package/dist/test/ui.js +0 -6
  374. package/dist/test/unit.js +0 -14
  375. package/dist/typecheck.js +0 -6
  376. package/dist/types.js +0 -23
  377. package/dist/unit.d.ts +0 -2
  378. package/dist/upgrade/dependencies.js +0 -8
  379. package/dist/upgrade/index.js +0 -22
  380. package/dist/upgrade.d.ts +0 -5
  381. package/dist/upgrade.js +0 -50
  382. package/dist/utils.d.ts +0 -75
  383. package/dist/work.d.ts +0 -3
  384. /package/dist/{upgrade/framework.js → chunk-cdk2r2jd.js} +0 -0
@@ -0,0 +1,714 @@
1
+ // @bun
2
+ import"./chunk-xg9xscqz.js";import"./chunk-96b7fcmd.js";import U from"fs";import Z from"path";import Q from"fs";import j from"path";import F from"path";import D from"fs";import L from"path";import T from"fs";import H from"path";function S(G,B){let I=["// Auto-generated by STX - do not edit",'declare module "stx/routes" {'," interface RouteMap {"];for(let J of G){let K=[];for(let V of J.params){let X=J.pattern.includes(`:${V}*`)?"string[]":"string";K.push(`${V}: ${X}`)}let O=K.join("; ");I.push(` '${J.pattern}': { ${O} }`)}I.push(" }","}",""),Q.mkdirSync(B,{recursive:!0}),Q.writeFileSync(j.join(B,"route-types.d.ts"),I.join(`
3
+ `))}function b(G,B,I){let J=process.cwd(),K=j.relative(J,I),O=["components","layouts","partials"],V=G.filter((W)=>!O.some((Y)=>W.pattern.startsWith(`/${Y}/`)||W.pattern===`/${Y}`)),X=["// Auto-generated by stx \u2014 do not edit",`// Source: ${K||"pages"}/`,"","export const routes = ["];for(let W of V){let Y=j.relative(J,W.filePath).replace(/\\/g,"/"),M=JSON.stringify(W.params),R=W.layout?`, layout: '${j.relative(J,W.layout).replace(/\\/g,"/")}'`:"";X.push(` { pattern: '${W.pattern}', filePath: '${Y}', isDynamic: ${W.isDynamic}, params: ${M}${R} },`)}X.push("] as const",""),X.push("export type RouteName = typeof routes[number]['pattern']",""),Q.mkdirSync(B,{recursive:!0}),Q.writeFileSync(j.join(B,"routes.ts"),X.join(`
4
+ `))}function v(G,B){let J=F.relative(B,G).replace(/\.(stx|md)$/,"");if(J=J.split(F.sep).join("/"),J==="index")return"/";if(J.endsWith("/index"))J=J.slice(0,-6);return J=J.replace(/\[\[([^\]]+)\]\]/g,":$1?"),J=J.replace(/\[([^\]]+)\]/g,":$1"),J=J.replace(/:\.\.\.([^/]+)/g,":$1*"),`/${J}`}function w(G){let B=[],I=G.replace(/[.+^${}()|[\]\\]/g,"\\$&");return I=I.replace(/\/:([^/]+)\?/g,(J,K)=>{return B.push(K),"(?:/([^/]+))?"}),I=I.replace(/:([^/]+)\*/g,(J,K)=>{return B.push(K),"(.+)"}),I=I.replace(/:([^/]+)/g,(J,K)=>{return B.push(K),"([^/]+)"}),I=`^${I}$`,{regex:new RegExp(I),params:B}}function m(G,B){let I=G===""?"/":G;for(let J of B){let K=I.match(J.regex);if(K){let O={};return J.params.forEach((V,X)=>{O[V]=K[X+1]}),{route:J,params:O}}}return null}function P(G,B){let I=[],J=L.dirname(G);while(J.startsWith(B)||J===B){let K=L.join(J,"_layout.stx");if(D.existsSync(K))I.unshift(K);if(J===B)break;J=L.dirname(J)}return I}function N(G,B){let I=[];if(!U.existsSync(G))return I;let J=U.readdirSync(G,{withFileTypes:!0});for(let K of J){let O=Z.join(G,K.name);if(K.isDirectory()){if(K.name.startsWith("."))continue;I.push(...N(O,B))}else if(K.isFile()){let V=Z.extname(K.name);if(B.includes(V)){if(K.name.startsWith("_")&&K.name!=="_layout.stx")continue;if(K.name==="_layout.stx")continue;I.push(O)}}}return I}class C{routes;pagesDir;config;constructor(G,B={}){this.config=B,this.pagesDir=Z.resolve(G,B.pagesDir||"pages");let I=B.extensions||[".stx"],J=N(this.pagesDir,I);this.routes=J.map((O)=>{let V=v(O,this.pagesDir),{regex:X,params:W}=w(V),Y=B.layouts!==!1?P(O,this.pagesDir):[];return{pattern:V,regex:X,params:W,filePath:O,isDynamic:W.length>0,layout:Y.length>0?Y[Y.length-1]:void 0}}),this.routes.sort((O,V)=>{if(!O.isDynamic&&V.isDynamic)return-1;if(O.isDynamic&&!V.isDynamic)return 1;let X=O.pattern.split("/").length,W=V.pattern.split("/").length;if(X!==W)return W-X;return O.pattern.localeCompare(V.pattern)});let K=Z.join(G,".stx");S(this.routes,K),b(this.routes,K,this.pagesDir)}match(G){let B=G===""?"/":G;for(let I of this.routes){let J=B.match(I.regex);if(J){let K={};return I.params.forEach((O,V)=>{K[O]=J[V+1]}),{route:I,params:K}}}return null}resolve(G,B){let I=this.routes.find((K)=>K.pattern===G||K.filePath.includes(G));if(!I)return"#not-found";let J=I.pattern;if(B)for(let[K,O]of Object.entries(B))J=J.replace(`:${K}`,encodeURIComponent(O));return J}addRoute(G){this.routes.push(G),this.routes.sort((B,I)=>{if(!B.isDynamic&&I.isDynamic)return-1;if(B.isDynamic&&!I.isDynamic)return 1;return B.pattern.localeCompare(I.pattern)})}getLayout(G){return G.layout??null}}function i(G,B){return new C(G,B)}function o(G,B){let I=[`${B}.stx`,"error.stx"];for(let J of I){let K=Z.join(G,J);if(U.existsSync(K))return K}return null}function t(G,B){return G.map((I)=>{let J=Z.relative(B,I.filePath),K=I.isDynamic?" (dynamic)":"";return`${I.pattern} \u2192 ${J}${K}`})}var $={},_="";function r(G){_=G.replace(/\/$/,"")}function a(G,B,I={}){$[G]={path:B,name:G,params:I}}function e(G){for(let[B,I]of Object.entries(G))if(typeof I==="string")$[B]={path:I,name:B};else $[B]={...I,name:B}}function BB(G,B={},I=!1){let J=$[G];if(!J)return console.warn(`Route [${G}] not defined.`),"#undefined-route";let K={...J.params,...B},O=J.path;O=O.replace(/:(\w+)/g,(X,W)=>{let Y=K[W];if(Y===void 0)return console.warn(`Missing parameter [${W}] for route [${G}].`),`:${W}`;return delete K[W],encodeURIComponent(String(Y))});let V=Object.entries(K);if(V.length>0){let X=V.map(([W,Y])=>`${encodeURIComponent(W)}=${encodeURIComponent(String(Y))}`).join("&");O+=(O.includes("?")?"&":"?")+X}return I&&_?`${_}${O}`:O}function GB(){for(let G of Object.keys($))delete $[G];_=""}function KB(G,B={}){return{type:"redirect",path:G,options:{replace:B.replace??!1,external:B.external??!1,redirectCode:B.redirectCode??302}}}function OB(G){return{type:"abort",error:typeof G==="string"?{statusCode:500,message:G}:G}}function VB(G,B={}){return{handler:G,mode:B.mode??"universal"}}function z(G){let B={};if(!G)return B;let I=G.split(";");for(let J of I){let[K,...O]=J.split("=");if(K){let V=K.trim(),X=O.join("=").trim();if(V)B[V]=decodeURIComponent(X)}}return B}function E(G,B,I={}){let J=`${encodeURIComponent(G)}=${encodeURIComponent(B)}`;if(I.expires){let K=typeof I.expires==="number"?new Date(Date.now()+I.expires*1000):I.expires;J+=`; Expires=${K.toUTCString()}`}if(I.path)J+=`; Path=${I.path}`;if(I.domain)J+=`; Domain=${I.domain}`;if(I.secure)J+="; Secure";if(I.httpOnly)J+="; HttpOnly";if(I.sameSite)J+=`; SameSite=${I.sameSite}`;return J}function k(G,B){let I=G.headers.get("cookie")||"",J=z(I);return{get(K){return J[K]},set(K,O,V={}){J[K]=O,B.append("Set-Cookie",E(K,O,V))},delete(K){delete J[K],B.append("Set-Cookie",E(K,"",{expires:new Date(0),path:"/"}))},getAll(){return{...J}}}}function x(){return{get(G){if(typeof document>"u")return;return z(document.cookie)[G]},set(G,B,I={}){if(typeof document>"u")return;document.cookie=E(G,B,I)},delete(G){if(typeof document>"u")return;document.cookie=E(G,"",{expires:new Date(0),path:"/"})},getAll(){if(typeof document>"u")return{};return z(document.cookie)}}}function y(){let G=typeof window<"u"&&typeof window.localStorage<"u";return{get(B){if(!G)return null;try{return window.localStorage.getItem(B)}catch{return null}},set(B,I){if(!G)return;try{window.localStorage.setItem(B,I)}catch{}},remove(B){if(!G)return;try{window.localStorage.removeItem(B)}catch{}},isAvailable(){return G}}}var A=new Map;function q(G,B){A.set(G,B)}function f(G){return A.get(G)}function WB(G){return A.has(G)}function XB(){A.clear()}function YB(){return Array.from(A.keys())}async function ZB(G,B="middleware"){let I=H.resolve(G,B);if(!T.existsSync(I))return;let J=T.readdirSync(I);for(let K of J){if(!K.endsWith(".ts")&&!K.endsWith(".js"))continue;if(K.includes(".test.")||K.includes(".spec."))continue;let O=K.replace(/\.(ts|js)$/,""),V=H.join(I,K);try{let W=(await import(V)).default;if(W&&typeof W.handler==="function")q(O,W);else if(typeof W==="function")q(O,{handler:W,mode:"universal"})}catch(X){console.warn(`Failed to load middleware '${O}' from ${V}:`,X)}}}function g(G){let B={};if(!G)return B;let I=new URLSearchParams(G);for(let[J,K]of I)B[J]=K;return B}function $B(G,B,I,J=""){return{path:G,params:B,query:g(J),fullPath:J?`${G}?${J}`:G,meta:I}}function jB(G,B,I){let J=typeof window>"u",K=!J,O=new Headers;return{to:G,from:B,isClient:K,isServer:J,cookies:J&&I?k(I,O):x(),storage:y(),state:{},request:I,responseHeaders:O}}async function AB(G,B){let I=Array.isArray(G)?G:[G],J=B.isServer;for(let K of I){let O=f(K);if(!O){console.warn(`Middleware '${K}' not found`);continue}if(O.mode==="server"&&!J)continue;if(O.mode==="client"&&J)continue;try{let V=await O.handler(B);if(V){if(V.type==="redirect")return{passed:!1,redirect:V,state:B.state,responseHeaders:B.responseHeaders};if(V.type==="abort")return{passed:!1,abort:V,state:B.state,responseHeaders:B.responseHeaders}}}catch(V){return console.error(`Error in middleware '${K}':`,V),{passed:!1,abort:{type:"abort",error:{statusCode:500,message:V instanceof Error?V.message:"Middleware error"}},state:B.state,responseHeaders:B.responseHeaders}}}return{passed:!0,state:B.state,responseHeaders:B.responseHeaders}}function QB(){return`
5
+ ;(function(){
6
+ 'use strict';
7
+ if(window.__stxRouter)return;
8
+
9
+ // \u2500\u2500 Configuration \u2500\u2500
10
+ var defaults={container:'main',loadingClass:'stx-navigating',viewTransitions:true,cache:true,scrollToTop:true,prefetch:true,progress:true,progressColor:'#78dce8',progressHeight:'2px',interceptAllLinks:false};
11
+ var o=Object.assign({},defaults,window.__stxRouterConfig||{},window.STX_ROUTER_OPTIONS||{});
12
+ var containerSel=o.container;
13
+
14
+ // \u2500\u2500 Progress bar (0\u2192100% at top of viewport) \u2500\u2500
15
+ // Native loading indicator baked into the router. Starts when navigation
16
+ // begins, trickles up to ~90% during fetch, snaps to 100% + fades on
17
+ // completion. Opt-out via window.__stxRouterConfig={progress:false}.
18
+ var progEl=null;
19
+ var progVal=0;
20
+ var progTimer=null;
21
+ function setProgress(v){
22
+ progVal=v<0?0:(v>100?100:v);
23
+ if(!progEl)return;
24
+ progEl.style.opacity=progVal>0?'1':'0';
25
+ progEl.style.transform='scaleX('+(progVal/100)+')';
26
+ }
27
+ function startProgress(){
28
+ if(!o.progress||!progEl)return;
29
+ if(progTimer){clearInterval(progTimer);progTimer=null}
30
+ setProgress(8);
31
+ progTimer=setInterval(function(){
32
+ if(progVal>=90)return;
33
+ // Asymptotic trickle \u2014 fast at first, slower near 90%
34
+ var inc=Math.max(0.4,(90-progVal)*0.08);
35
+ setProgress(progVal+inc);
36
+ },160);
37
+ }
38
+ function finishProgress(){
39
+ if(!o.progress||!progEl)return;
40
+ if(progTimer){clearInterval(progTimer);progTimer=null}
41
+ setProgress(100);
42
+ // Fade out, then reset. Delays chosen so the "full" state is briefly
43
+ // visible before the bar disappears.
44
+ setTimeout(function(){
45
+ if(!progEl)return;
46
+ progEl.style.opacity='0';
47
+ setTimeout(function(){progVal=0;if(progEl)progEl.style.transform='scaleX(0)'},260);
48
+ },180);
49
+ }
50
+
51
+ var cache={};
52
+ var prefetching={};
53
+ var isNavigating=false;
54
+
55
+ // Extract top-level CSS blocks (rules AND @media blocks with nested braces).
56
+ // The old regex ([^{}]+{[^{}]*}) silently dropped @media blocks because
57
+ // it couldn't handle nested braces \u2014 causing responsive classes (lg:, md:)
58
+ // to vanish after SPA navigation.
59
+ function extractCssBlocks(css){
60
+ var blocks=[];
61
+ var i=0;
62
+ var len=css.length;
63
+ while(i<len){
64
+ // Skip whitespace
65
+ while(i<len&&(css[i]===' '||css[i]==='\\n'||css[i]==='\\r'||css[i]==='\\t'))i++;
66
+ if(i>=len)break;
67
+ // Find the start of a block (first {)
68
+ var blockStart=i;
69
+ var bracePos=css.indexOf('{',i);
70
+ if(bracePos===-1)break;
71
+ // Walk forward tracking brace depth to find the matching close
72
+ var depth=0;
73
+ var j=bracePos;
74
+ while(j<len){
75
+ if(css[j]==='{')depth++;
76
+ else if(css[j]==='}'){depth--;if(depth===0){j++;break}}
77
+ j++;
78
+ }
79
+ if(depth!==0)break;
80
+ blocks.push(css.slice(blockStart,j).trim());
81
+ i=j;
82
+ }
83
+ return blocks;
84
+ }
85
+
86
+ function mergeCrosswindCSS(existing,incoming){
87
+ var blocks=extractCssBlocks(incoming);
88
+ var newBlocks=[];
89
+ for(var bi=0;bi<blocks.length;bi++){
90
+ if(existing.indexOf(blocks[bi])===-1)newBlocks.push(blocks[bi]);
91
+ }
92
+ if(newBlocks.length>0)return existing+'\\n'+newBlocks.join('\\n');
93
+ return null;
94
+ }
95
+
96
+ function getContainer(){
97
+ return document.querySelector(containerSel)||document.querySelector('[data-stx-content]')||document.querySelector('main');
98
+ }
99
+
100
+ // \u2500\u2500 Navigation \u2500\u2500
101
+ // Layout group detection \u2014 layouts in the same group share a <main> container.
102
+ // Only truly different layout groups trigger a full page reload.
103
+ var layoutCache={};
104
+ // Track executed script hashes to prevent redeclaration errors on navigation.
105
+ // Layout-level scripts (theme, nav setup) execute on initial page load and
106
+ // should NOT re-execute when navigating to another page with the same layout.
107
+ var executedScriptHashes={};
108
+ function hashScript(code){
109
+ var h=0;for(var i=0;i<code.length;i++){h=((h<<5)-h)+code.charCodeAt(i);h|=0}
110
+ return h;
111
+ }
112
+ // Record scripts from the initial page load
113
+ document.querySelectorAll('script').forEach(function(s){
114
+ var text=s.textContent||'';
115
+ if(text.trim()&&!s.hasAttribute('src'))executedScriptHashes[hashScript(text)]=1;
116
+ });
117
+ function getLayoutGroup(layout){
118
+ if(!layout)return 'app';
119
+ if(layout.indexOf('auth')!==-1||layout.indexOf('guest')!==-1)return 'auth';
120
+ return 'app';
121
+ }
122
+ function checkLayoutChange(newLayout,targetUrl){
123
+ var currentLayout=document.querySelector('meta[name="stx-layout"]');
124
+ var curLayoutName=currentLayout?currentLayout.getAttribute('content'):'';
125
+ var curGroup=getLayoutGroup(curLayoutName);
126
+ var newGroup=getLayoutGroup(newLayout);
127
+ console.log('[router] layout check: current='+curLayoutName+'('+curGroup+') new='+(newLayout||'')+'('+newGroup+')');
128
+ // Different layout GROUP (e.g. app \u2192 auth): full reload
129
+ if(curGroup!==newGroup){
130
+ console.log('[router] layout group change:',curGroup,'\u2192',newGroup,'\u2014 full reload to:',targetUrl);
131
+ return true;
132
+ }
133
+ // Same group but different SPECIFIC layout (e.g. layouts/app \u2192 layouts/coach):
134
+ // full body swap so nav, sidebar, and other layout-level elements update
135
+ if(curLayoutName && newLayout && curLayoutName!==newLayout){
136
+ console.log('[router] layout name change:',curLayoutName,'\u2192',newLayout,'\u2014 full body swap');
137
+ return true;
138
+ }
139
+ return false;
140
+ }
141
+
142
+ function navigate(url,pushState,force){
143
+ console.log('[router] navigate() called:',url,'isNavigating:',isNavigating);
144
+ if(isNavigating)return;
145
+ var t=new URL(url,location.origin);
146
+
147
+ if(t.origin!==location.origin){location.href=url;return}
148
+
149
+ if(t.pathname===location.pathname&&t.hash){
150
+ if(pushState!==false)history.pushState({},'',t.href);
151
+ var el=document.querySelector(t.hash);
152
+ if(el)el.scrollIntoView({behavior:'smooth'});
153
+ return;
154
+ }
155
+
156
+ if(t.href===location.href&&!t.hash&&!force)return;
157
+
158
+ isNavigating=true;
159
+ document.body.classList.add(o.loadingClass);
160
+ startProgress();
161
+
162
+ var targetHref=t.href;
163
+ var targetPath=t.pathname;
164
+ var targetHash=t.hash;
165
+
166
+ function done(){isNavigating=false;document.body.classList.remove(o.loadingClass);finishProgress()}
167
+
168
+ if(o.cache&&cache[targetPath]&&!force){
169
+ if(checkLayoutChange(layoutCache[targetPath],url)){
170
+ // Layout changed \u2014 fetch full page and do full document swap
171
+ console.log('[router] cache hit but layout changed \u2014 fetching full page');
172
+ fetch(url,{headers:{'Accept':'text/html'}}).then(function(r){
173
+ if(!r.ok)throw new Error(r.status);
174
+ return r.text();
175
+ }).then(function(html){
176
+ console.log('[router] full page fetched from cache path, len:',html.length);
177
+ swap(html,targetPath,pushState,targetHash);
178
+ }).catch(function(err){
179
+ console.error('[router] full page fetch error:',err);
180
+ location.href=url;
181
+ }).finally(done);
182
+ return;
183
+ }
184
+ swap(cache[targetPath],targetPath,pushState,targetHash);
185
+ done();
186
+ }
187
+ else {
188
+ if(force&&cache[targetPath])delete cache[targetPath];
189
+ // First fetch as fragment (SPA mode)
190
+ fetch(url,{headers:{'X-STX-Router':'true','Accept':'text/html'}}).then(function(r){
191
+ if(!r.ok)throw new Error(r.status);
192
+ var isFragment=r.headers.get('X-STX-Fragment')==='true';
193
+ var newLayout=r.headers.get('X-STX-Layout')||'';
194
+ // Layout change? Fetch the FULL page (no X-STX-Router header) and do full document swap
195
+ if(isFragment&&checkLayoutChange(newLayout,url)){
196
+ console.log('[router] layout change \u2014 fetching full page for document swap');
197
+ return fetch(url,{headers:{'Accept':'text/html'}}).then(function(fullRes){
198
+ console.log('[router] full page fetched:',fullRes.status,'ok:',fullRes.ok);
199
+ if(!fullRes.ok)throw new Error(fullRes.status);
200
+ return fullRes.text().then(function(html){
201
+ console.log('[router] full page html length:',html.length);
202
+ return{html:html,isFragment:false,layout:newLayout};
203
+ });
204
+ });
205
+ }
206
+ return r.text().then(function(html){return{html:html,isFragment:isFragment,layout:newLayout}});
207
+ }).then(function(result){
208
+ if(!result)return;
209
+ if(result.isFragment)result.html='<!--stx-fragment-->'+result.html;
210
+ if(o.cache){cache[targetPath]=result.html;layoutCache[targetPath]=result.layout}
211
+ swap(result.html,targetPath,pushState,targetHash);
212
+ }).catch(function(err){
213
+ console.error('[router] fetch error:',err);
214
+ location.href=url;
215
+ }).finally(done);
216
+ }
217
+ }
218
+
219
+ function swap(html,url,pushState,hash){
220
+ var isFragment=html.indexOf('<!--stx-fragment-->')===0;
221
+ if(isFragment)html=html.slice('<!--stx-fragment-->'.length);
222
+ var currentContent=getContainer();
223
+ console.log('[router] swap: isFragment='+isFragment+' container='+!!currentContent+' htmlLen='+html.length);
224
+ if(!currentContent){console.log('[router] no container \u2014 falling back');location.href=url;return}
225
+
226
+ // Fragment mode: server returned just the page content (no document wrapper)
227
+ if(isFragment){
228
+ if(window.stx&&window.stx._cleanupContainer)window.stx._cleanupContainer(currentContent);
229
+ function doFragSwap(){
230
+ // Extract scripts from fragment before injecting HTML
231
+ var fragScripts=[];
232
+ var fragStyles=[];
233
+ var fragCrosswindCSS=null;
234
+ var cleanFrag=html.replace(new RegExp('<scr'+'ipt\\\\b[^>]*>([\\\\s\\\\S]*?)<\\\\/scr'+'ipt>','gi'),function(m,code){
235
+ if(code&&code.trim())fragScripts.push(code);
236
+ return '';
237
+ });
238
+ cleanFrag=cleanFrag.replace(new RegExp('<sty'+'le\\\\b([^>]*)>([\\\\s\\\\S]*?)<\\\\/sty'+'le>','gi'),function(m,attrs,css){
239
+ if(attrs.indexOf('data-crosswind')!==-1){
240
+ fragCrosswindCSS=css;
241
+ }else{
242
+ fragStyles.push({attrs:attrs,css:css});
243
+ }
244
+ return '';
245
+ });
246
+ // Remove old page styles (not crosswind \u2014 that gets merged)
247
+ document.querySelectorAll('style[data-stx-page]').forEach(function(s){s.remove()});
248
+ // Merge crosswind CSS from fragment into existing crosswind style
249
+ if(fragCrosswindCSS){
250
+ var curCrosswind=document.querySelector('head style[data-crosswind]');
251
+ if(curCrosswind){
252
+ var merged=mergeCrosswindCSS(curCrosswind.textContent||'',fragCrosswindCSS);
253
+ if(merged)curCrosswind.textContent=merged;
254
+ }else{
255
+ var cw=document.createElement('style');
256
+ cw.setAttribute('data-crosswind','generated');
257
+ cw.textContent=fragCrosswindCSS;
258
+ document.head.appendChild(cw);
259
+ }
260
+ }
261
+ // Add new page styles
262
+ fragStyles.forEach(function(s){
263
+ var el=document.createElement('style');
264
+ el.textContent=s.css;
265
+ el.setAttribute('data-stx-page','');
266
+ document.head.appendChild(el);
267
+ });
268
+ // Swap content
269
+ currentContent.innerHTML=cleanFrag;
270
+ // Remove old page scripts
271
+ document.querySelectorAll('script[data-stx-page]').forEach(function(s){s.remove()});
272
+ if(pushState!==false)history.pushState({},'',url+(hash||''));
273
+ updateNav(url);
274
+ updateActiveLinks();
275
+ if(o.scrollToTop&&!hash)window.scrollTo({top:0,behavior:'instant'});
276
+ else if(hash){var el=document.querySelector(hash);if(el)el.scrollIntoView({behavior:'smooth'})}
277
+ window.dispatchEvent(new CustomEvent('stx:navigate',{detail:{url:url}}));
278
+ // Execute page scripts FIRST \u2014 they define setup functions and set _latestSetup
279
+ console.log('[router] frag scripts:', fragScripts.length);
280
+ document.querySelectorAll('script[data-stx-page]').forEach(function(s){s.remove()});
281
+ fragScripts.forEach(function(code){
282
+ console.log('[router] exec script len:', code.length, 'has __stx_setup:', code.indexOf('__stx_setup')>-1);
283
+ var ns=document.createElement('script');
284
+ // Wrap in block scope to prevent const/let collisions on re-navigation.
285
+ // Without this, navigating away and back throws "Identifier has already
286
+ // been declared" because the previous page's top-level const/let are
287
+ // still in the global scope.
288
+ var isAlreadyScoped=code.trimStart().charAt(0)==='('||code.trimStart().charAt(0)===';'||code.indexOf('window.stx.mount')>-1;
289
+ ns.textContent=isAlreadyScoped?code:'{'+code+'}';
290
+ ns.setAttribute('data-stx-page','');
291
+ document.body.appendChild(ns);
292
+ });
293
+ console.log('[router] scripts done. _latestSetup:', !!window.stx._latestSetup);
294
+ // THEN fire stx:load \u2014 now _latestSetup is set and processElement has the right scope
295
+ window.dispatchEvent(new Event('stx:load'));
296
+ }
297
+ if(o.viewTransitions&&document.startViewTransition){document.startViewTransition(doFragSwap)}
298
+ else{currentContent.style.transition='opacity 0.12s ease-out';currentContent.style.opacity='0';setTimeout(function(){doFragSwap();currentContent.style.opacity='1';setTimeout(function(){currentContent.style.transition=''},150)},120)}
299
+ return;
300
+ }
301
+
302
+ // Full document mode: parse with DOMParser and extract container content
303
+ var parser=new DOMParser();
304
+ var doc=parser.parseFromString(html,'text/html');
305
+ var newContent=doc.querySelector(containerSel)||doc.querySelector('[data-stx-content]')||doc.querySelector('main');
306
+ if(!newContent){location.href=url;return}
307
+
308
+ // Clean up existing signals/effects
309
+ if(window.stx&&window.stx._cleanupContainer){
310
+ window.stx._cleanupContainer(currentContent);
311
+ }
312
+
313
+ function doSwap(){
314
+ // \u2500\u2500 Swap <head> styles \u2500\u2500
315
+ // Inject new styles FIRST, then remove old to prevent unstyled flash
316
+ var keepIds={'stx-view-transitions':1,'stx-r-css':1};
317
+ var curStyles=document.querySelectorAll('head style');
318
+ var newStyles=doc.querySelectorAll('head style');
319
+
320
+ // Merge crosswind styles instead of replacing \u2014 persistent elements
321
+ // (nav, footer) outside <main> still need their utility classes
322
+ var curCrosswind=document.querySelector('head style[data-crosswind]');
323
+ var newCrosswind=null;
324
+ newStyles.forEach(function(s){if(s.getAttribute('data-crosswind'))newCrosswind=s});
325
+
326
+ if(curCrosswind&&newCrosswind){
327
+ var merged=mergeCrosswindCSS(curCrosswind.textContent||'',newCrosswind.textContent||'');
328
+ if(merged)curCrosswind.textContent=merged;
329
+ }
330
+
331
+ var incoming=[];
332
+ newStyles.forEach(function(s){
333
+ if(!keepIds[s.id]&&!s.getAttribute('data-crosswind')){
334
+ var ns=document.createElement('style');
335
+ ns.textContent=s.textContent;
336
+ ns.setAttribute('data-stx-incoming','');
337
+ document.head.appendChild(ns);
338
+ incoming.push(ns);
339
+ }
340
+ });
341
+
342
+ // If no existing crosswind but new page has one, add it
343
+ if(!curCrosswind&&newCrosswind){
344
+ var ns=document.createElement('style');
345
+ ns.textContent=newCrosswind.textContent;
346
+ ns.setAttribute('data-crosswind',newCrosswind.getAttribute('data-crosswind'));
347
+ document.head.appendChild(ns);
348
+ }
349
+
350
+ // Remove old styles (except persistent ones, crosswind, and incoming)
351
+ curStyles.forEach(function(s){
352
+ if(!keepIds[s.id]&&!s.hasAttribute('data-stx-incoming')&&!s.hasAttribute('data-crosswind'))s.remove();
353
+ });
354
+
355
+ incoming.forEach(function(s){s.removeAttribute('data-stx-incoming')});
356
+
357
+ // \u2500\u2500 Swap content \u2500\u2500
358
+ // For layout changes: swap the entire <body> to replace layout chrome (nav, footer, etc.)
359
+ // For same-layout: swap only the container (<main>)
360
+ var newBody=doc.querySelector('body');
361
+ var isLayoutChange=false;
362
+ if(newBody){
363
+ var newMeta=doc.querySelector('meta[name="stx-layout"]');
364
+ var curMeta=document.querySelector('meta[name="stx-layout"]');
365
+ var curGroup=getLayoutGroup(curMeta?curMeta.getAttribute('content'):'');
366
+ var newGroup=getLayoutGroup(newMeta?newMeta.getAttribute('content'):'');
367
+ isLayoutChange=curGroup!==newGroup;
368
+ }
369
+ if(isLayoutChange&&newBody){
370
+ console.log('[router] full body swap for layout change');
371
+ // Replace entire body content \u2014 layout chrome and all
372
+ var bodyHTML=newBody.innerHTML.replace(new RegExp('<scr'+'ipt\\\\b[^>]*>[\\\\s\\\\S]*?<\\\\/scr'+'ipt\\\\s*>','gi'),'');
373
+ document.body.innerHTML=bodyHTML;
374
+ // Copy body attributes (class, data-stx, etc.)
375
+ Array.from(newBody.attributes).forEach(function(attr){document.body.setAttribute(attr.name,attr.value)});
376
+ // Update layout meta tag
377
+ var oldMeta=document.querySelector('meta[name="stx-layout"]');
378
+ var freshMeta=doc.querySelector('meta[name="stx-layout"]');
379
+ if(oldMeta&&freshMeta)oldMeta.setAttribute('content',freshMeta.getAttribute('content')||'');
380
+ else if(freshMeta){var m=document.createElement('meta');m.name='stx-layout';m.content=freshMeta.getAttribute('content')||'';document.head.appendChild(m)}
381
+ // Update container reference for script execution below
382
+ currentContent=document.querySelector(containerSel)||document.querySelector('main')||document.body;
383
+ } else {
384
+ // Same layout \u2014 swap only container content
385
+ var cleanHTML=newContent.innerHTML.replace(new RegExp('<scr'+'ipt\\\\b[^>]*>[\\\\s\\\\S]*?<\\\\/scr'+'ipt\\\\s*>','gi'),'');
386
+ currentContent.innerHTML=cleanHTML;
387
+ }
388
+
389
+ // \u2500\u2500 Load new external <head> scripts \u2500\u2500
390
+ var loadedSrcs={};
391
+ document.querySelectorAll('head script[src]').forEach(function(s){loadedSrcs[s.src]=1});
392
+ var extPromises=[];
393
+ doc.querySelectorAll('head script[src]').forEach(function(s){
394
+ var src=new URL(s.getAttribute('src'),location.origin).href;
395
+ if(loadedSrcs[src])return;
396
+ loadedSrcs[src]=1;
397
+ extPromises.push(new Promise(function(resolve,reject){
398
+ var ns=document.createElement('script');
399
+ ns.src=src;
400
+ ns.onload=resolve;
401
+ ns.onerror=reject;
402
+ document.head.appendChild(ns);
403
+ }));
404
+ });
405
+
406
+ // \u2500\u2500 Script re-execution \u2500\u2500
407
+ // Remove previously injected page scripts
408
+ document.querySelectorAll('script[data-stx-page]').forEach(function(s){s.remove()});
409
+
410
+ var scripts=[];
411
+ if(isLayoutChange){
412
+ // Layout change: collect ALL scripts from the new document body
413
+ // (layout scripts, component mounts, setup functions \u2014 everything)
414
+ var newBodyEl=doc.querySelector('body');
415
+ if(newBodyEl){
416
+ newBodyEl.querySelectorAll('script').forEach(function(s){
417
+ var text=s.textContent||'';
418
+ if(s.hasAttribute('src'))return;
419
+ if(!text.trim())return;
420
+ // Skip the signals runtime IIFE \u2014 it's already loaded
421
+ if(text.indexOf("'use strict';var cloakStyle")!==-1)return;
422
+ if(text.indexOf('__stxRouter')!==-1)return;
423
+ scripts.push(text);
424
+ });
425
+ }
426
+ // Also collect setup functions from <head>
427
+ doc.querySelectorAll('head script').forEach(function(s){
428
+ var text=s.textContent||'';
429
+ if(s.hasAttribute('src'))return;
430
+ if(!text.trim())return;
431
+ if(text.indexOf('__stx_setup_')!==-1)scripts.push(text);
432
+ });
433
+ } else {
434
+ // Same layout: collect scripts from the container
435
+ newContent.querySelectorAll('script').forEach(function(s){
436
+ var text=s.textContent||'';
437
+ if(s.hasAttribute('src'))return;
438
+ if(!text.trim())return;
439
+ scripts.push(text);
440
+ });
441
+ // Collect setup scripts from <head> AND <body> (outside container).
442
+ // SSG builds place the setup function in <body> before <main>, not
443
+ // in <head>. Without this, SPA navigation on static sites never
444
+ // runs the setup and reactive data stays empty.
445
+ var seenSetups={};
446
+ scripts.forEach(function(t){if(t.indexOf('__stx_setup_')!==-1)seenSetups[t.substring(0,80)]=1});
447
+ doc.querySelectorAll('script').forEach(function(s){
448
+ var text=s.textContent||'';
449
+ if(s.hasAttribute('src'))return;
450
+ if(!text.trim())return;
451
+ if(text.indexOf('__stx_setup_')===-1)return;
452
+ // Skip signals runtime and router (they contain __stx_setup references but aren't setup functions)
453
+ if(text.indexOf("'use strict';var cloakStyle")!==-1)return;
454
+ if(text.indexOf('__stxRouter')!==-1)return;
455
+ var key=text.substring(0,80);
456
+ if(seenSetups[key])return;
457
+ seenSetups[key]=1;
458
+ scripts.push(text);
459
+ });
460
+ }
461
+
462
+ // Push history state (before active link updates so location.pathname is current)
463
+ if(pushState!==false)history.pushState({},'',url+(hash||''));
464
+
465
+ // Update active nav links
466
+ updateNav(url);
467
+ updateActiveLinks();
468
+
469
+ // Scroll
470
+ if(o.scrollToTop&&!hash)window.scrollTo({top:0,behavior:'instant'});
471
+ else if(hash){var el=document.querySelector(hash);if(el)el.scrollIntoView({behavior:'smooth'})}
472
+
473
+ // Update title
474
+ var newTitle=doc.querySelector('title');
475
+ if(newTitle)document.title=newTitle.textContent;
476
+
477
+ // Update <html lang> from the destination doc so screen readers,
478
+ // CSS :lang() selectors, and any i18n picker that mirrors
479
+ // document.documentElement.lang stay accurate after SPA hops.
480
+ if(doc.documentElement&&doc.documentElement.lang){
481
+ document.documentElement.lang=doc.documentElement.lang;
482
+ }
483
+
484
+ window.dispatchEvent(new CustomEvent('stx:navigate',{detail:{url:url}}));
485
+
486
+ // Execute page scripts FIRST \u2014 they define setup functions and set _latestSetup
487
+ function execScripts(){
488
+ scripts.forEach(function(text){
489
+ // Skip scripts that were already executed (layout-level partials
490
+ // like theme.stx). Their top-level const/function declarations
491
+ // would throw "Identifier has already been declared" on re-execution.
492
+ // Exception: setup functions (__stx_setup_) must always re-execute
493
+ // because each page has its own setup, and import statements
494
+ // need special handling.
495
+ var h=hashScript(text);
496
+ var isSetup=text.indexOf('__stx_setup_')!==-1;
497
+ var hasImport=text.indexOf('import ')!==-1;
498
+ if(!isSetup&&executedScriptHashes[h])return;
499
+ executedScriptHashes[h]=1;
500
+ // Wrap scripts with import statements as modules (Bug 3 fix)
501
+ var ns=document.createElement('script');
502
+ if(hasImport){
503
+ ns.type='module';
504
+ }
505
+ // Wrap in block scope to prevent const/let collisions on re-navigation.
506
+ // Top-level const/let in <script> tags are global-scoped in browsers
507
+ // and throw "Identifier has already been declared" on re-execution.
508
+ var alreadyScoped=text.trimStart().charAt(0)==='('||text.trimStart().charAt(0)===';'||text.indexOf('window.stx.mount')>-1;
509
+ ns.textContent=alreadyScoped?text:'{'+text+'}';
510
+ ns.setAttribute('data-stx-page','');
511
+ document.body.appendChild(ns);
512
+ });
513
+ // THEN fire stx:load \u2014 now _latestSetup is set and processElement has the right scope
514
+ window.dispatchEvent(new Event('stx:load'));
515
+ }
516
+
517
+ if(extPromises.length>0){
518
+ Promise.all(extPromises).then(execScripts).catch(execScripts);
519
+ }
520
+ else {
521
+ execScripts();
522
+ }
523
+ }
524
+
525
+ if(o.viewTransitions&&document.startViewTransition){
526
+ document.startViewTransition(doSwap);
527
+ }
528
+ else {
529
+ // Fallback fade for browsers without View Transitions API
530
+ currentContent.style.transition='opacity 0.12s ease-out';
531
+ currentContent.style.opacity='0';
532
+ setTimeout(function(){
533
+ doSwap();
534
+ currentContent.style.opacity='1';
535
+ setTimeout(function(){currentContent.style.transition=''},150);
536
+ },120);
537
+ }
538
+ }
539
+
540
+ // \u2500\u2500 Link interception \u2500\u2500
541
+ function shouldIntercept(link){
542
+ if(!link)return false;
543
+ var href=link.getAttribute('href');
544
+ if(!href)return false;
545
+ if(href.startsWith('http')||href.startsWith('#')||href.startsWith('mailto:')||href.startsWith('tel:')||href.startsWith('javascript:'))return false;
546
+ if(link.target==='_blank')return false;
547
+ if(link.hasAttribute('data-stx-no-router')||link.hasAttribute('data-no-router')||link.hasAttribute('download'))return false;
548
+ if(href===location.pathname)return false;
549
+ if(!getContainer())return false;
550
+ return true;
551
+ }
552
+
553
+ // SPA click handling. By default only [data-stx-link] elements get
554
+ // SPA navigation; regular <a href> does native full page reload. Set
555
+ // interceptAllLinks:true (window.__stxRouterConfig or build-time
556
+ // config) to intercept any same-origin anchor \u2014 used by static-site
557
+ // mode where every page is part of the same SPA shell.
558
+ document.addEventListener('click',function(e){
559
+ if(e.metaKey||e.ctrlKey||e.shiftKey||e.altKey||e.button!==0)return;
560
+ if(!e.target||!e.target.closest)return;
561
+ var link=e.target.closest('[data-stx-link]');
562
+ if(!link&&o.interceptAllLinks){
563
+ var anchor=e.target.closest('a[href]');
564
+ if(anchor&&shouldIntercept(anchor))link=anchor;
565
+ }
566
+ if(!link){return}
567
+ var href=link.getAttribute('href');
568
+ console.log('[router] click intercepted:',href,'container:',!!getContainer(),'defaultPrevented:',e.defaultPrevented);
569
+ if(!href||href.startsWith('http')||href.startsWith('#')||href.startsWith('mailto:')||href.startsWith('tel:')){console.log('[router] skipped:',href);return}
570
+ if(link.target==='_blank'||link.hasAttribute('download'))return;
571
+ e.preventDefault();
572
+ e.stopPropagation();
573
+ console.log('[router] navigating to:',href);
574
+ navigate(href);
575
+ },true);
576
+
577
+ // \u2500\u2500 Back/forward \u2500\u2500
578
+ window.addEventListener('popstate',function(){
579
+ navigate(location.pathname+location.search+location.hash,false);
580
+ });
581
+
582
+ // \u2500\u2500 Prefetch on hover \u2500\u2500
583
+ if(o.prefetch){
584
+ document.addEventListener('mouseover',function(e){
585
+ if(!e.target||!e.target.closest)return;
586
+ var link=e.target.closest('[data-stx-link]');
587
+ if(!link)return;
588
+ var href=link.getAttribute('href');
589
+ if(cache[href]||prefetching[href])return;
590
+ prefetching[href]=true;
591
+ fetch(href,{headers:{'X-STX-Router':'true','Accept':'text/html'}}).then(function(r){
592
+ var isFrag=r.headers.get('X-STX-Fragment')==='true';
593
+ var pLayout=r.headers.get('X-STX-Layout')||'';
594
+ return r.text().then(function(html){return{html:isFrag?'<!--stx-fragment-->'+html:html,layout:pLayout}});
595
+ }).then(function(result){
596
+ if(o.cache){cache[href]=result.html;layoutCache[href]=result.layout}
597
+ }).catch(function(){}).finally(function(){delete prefetching[href]});
598
+ },true);
599
+ }
600
+
601
+ // \u2500\u2500 Active link management \u2500\u2500
602
+ function updateNav(url){
603
+ document.querySelectorAll('nav a[href], #mobileNav a[href], [data-stx-nav] a[href]').forEach(function(a){
604
+ var href=a.getAttribute('href');
605
+ if(!href||href.startsWith('#')||href.startsWith('http'))return;
606
+ var isActive=(href===url)||(href==='/'&&url==='/');
607
+ if(a.hasAttribute('data-stx-link')){
608
+ var ac=a.getAttribute('data-stx-active-class')||'active';
609
+ if(isActive)ac.split(' ').forEach(function(cls){if(cls)a.classList.add(cls)});else ac.split(' ').forEach(function(cls){if(cls)a.classList.remove(cls)});
610
+ }
611
+ });
612
+ }
613
+
614
+ function updateActiveLinks(){
615
+ // Update active classes on <stx-link> elements (and legacy data-stx-link)
616
+ var links=document.querySelectorAll('[data-stx-link]');
617
+ var cur=location.pathname;
618
+ links.forEach(function(link){
619
+ var href=link.getAttribute('to')||link.getAttribute('href')||'';
620
+ var ac=link.getAttribute('active-class')||link.getAttribute('data-stx-active-class')||'active';
621
+ var eac=link.getAttribute('exact-active-class')||link.getAttribute('data-stx-exact-active-class')||'exact-active';
622
+ ac.split(' ').forEach(function(cls){if(cls)link.classList.remove(cls)});
623
+ eac.split(' ').forEach(function(cls){if(cls)link.classList.remove(cls)});
624
+ var isExact=cur===href;
625
+ var isActive=href!=='/'?cur.startsWith(href):cur==='/';
626
+ if(isExact)eac.split(' ').forEach(function(cls){if(cls)link.classList.add(cls)});
627
+ if(isActive)ac.split(' ').forEach(function(cls){if(cls)link.classList.add(cls)});
628
+ });
629
+ }
630
+
631
+ // \u2500\u2500 Progress bar DOM + style \u2500\u2500
632
+ // Injects a fixed-position element at the top of the viewport plus the
633
+ // minimal CSS for its transform/opacity transitions. Kept idempotent so
634
+ // repeated init() calls (e.g. after full-body swaps) don't duplicate.
635
+ // Also ships the default View Transitions fade+slide CSS when
636
+ // viewTransitions is enabled and the browser supports it. Apps can
637
+ // override by defining more specific ::view-transition-* rules later in
638
+ // the cascade, or opt out entirely with viewTransitions:false.
639
+ function injectStyles(){
640
+ if(!document.getElementById('stx-r-css')){
641
+ var s=document.createElement('style');s.id='stx-r-css';
642
+ // Strip characters that could escape our CSS block and inject new
643
+ // declarations: ; { } ( ) " ' \\ < > plus whitespace control chars.
644
+ // This keeps the value safe to concat into a stylesheet even if a
645
+ // caller wires the config from an untrusted source.
646
+ var sanitize=function(v){return String(v).replace(/[;{}()"'\\\\<>\\n\\r\\t]/g,'')};
647
+ var pc=sanitize(o.progressColor);
648
+ var ph=sanitize(o.progressHeight);
649
+ var css='.stx-navigating{cursor:wait}.stx-navigating a,.stx-navigating button{pointer-events:none}#stx-router-progress{position:fixed;top:0;left:0;right:0;height:'+ph+';background:'+pc+';box-shadow:0 0 8px '+pc+',0 0 4px '+pc+';transform:scaleX(0);transform-origin:left;transition:transform .18s ease-out,opacity .26s ease;opacity:0;pointer-events:none;z-index:999999}';
650
+ if(o.viewTransitions&&'startViewTransition' in document){
651
+ var dur=(o.viewTransitionDuration||220)+'ms';
652
+ var ease=o.viewTransitionEasing||'cubic-bezier(0.16, 1, 0.3, 1)';
653
+ css+='::view-transition-old(root),::view-transition-new(root){animation-duration:'+dur+';animation-timing-function:'+ease+'}';
654
+ css+='::view-transition-old(root){animation-name:stx-r-fade-out}::view-transition-new(root){animation-name:stx-r-fade-in}';
655
+ css+='@keyframes stx-r-fade-out{from{opacity:1;transform:translateY(0)}to{opacity:0;transform:translateY(-4px)}}';
656
+ css+='@keyframes stx-r-fade-in{from{opacity:0;transform:translateY(6px)}to{opacity:1;transform:translateY(0)}}';
657
+ css+='@media (prefers-reduced-motion: reduce){::view-transition-old(root),::view-transition-new(root){animation-duration:0s;animation-name:none}}';
658
+ }
659
+ s.textContent=css;
660
+ document.head.appendChild(s);
661
+ }
662
+ if(o.progress&&!document.getElementById('stx-router-progress')){
663
+ var el=document.createElement('div');
664
+ el.id='stx-router-progress';
665
+ el.setAttribute('role','progressbar');
666
+ el.setAttribute('aria-hidden','true');
667
+ // Append to <html>, not <body>: when the router swaps the body
668
+ // (container:'body' for full-page static-site SPAs) the progress
669
+ // element gets wiped along with it. <html> stays put across
670
+ // swaps, so the bar survives multi-hop navigation.
671
+ document.documentElement.appendChild(el);
672
+ progEl=el;
673
+ } else if(o.progress){
674
+ progEl=document.getElementById('stx-router-progress');
675
+ }
676
+ }
677
+
678
+ function injectViewTransitionCSS(){
679
+ if(document.getElementById('stx-view-transitions'))return;
680
+ var s=document.createElement('style');s.id='stx-view-transitions';
681
+ s.textContent='::view-transition-group(root){animation:none}::view-transition-old(root){animation:none}::view-transition-new(root){animation:none}main,#app-content,[data-stx-content]{view-transition-name:stx-content}::view-transition-old(stx-content){animation:stx-fade-out .15s ease-out both}::view-transition-new(stx-content){animation:stx-fade-in .15s ease-in .1s both}@keyframes stx-fade-out{from{opacity:1}to{opacity:0}}@keyframes stx-fade-in{from{opacity:0}to{opacity:1}}::view-transition{background:transparent}::view-transition-group(stx-content){background:inherit;overflow:hidden}';
682
+ (document.head||document.documentElement).appendChild(s);
683
+ }
684
+
685
+ // \u2500\u2500 Public API \u2500\u2500
686
+ var router={
687
+ navigate:navigate,
688
+ navigateTo:navigate,
689
+ prefetch:function(url){
690
+ if(!cache[url]){
691
+ fetch(url,{headers:{'X-STX-Router':'true'}}).then(function(r){var isFrag=r.headers.get('X-STX-Fragment')==='true';return r.text().then(function(html){return isFrag?'<!--stx-fragment-->'+html:html})}).then(function(html){cache[url]=html}).catch(function(){});
692
+ }
693
+ },
694
+ clearCache:function(){for(var k in cache)delete cache[k]},
695
+ cache:cache,
696
+ swap:swap,
697
+ updateNav:updateNav
698
+ };
699
+
700
+ window.__stxRouter=router;
701
+ window.stxRouter=router;
702
+ if(window.stx)window.stx.router=router;
703
+
704
+ // \u2500\u2500 Initialize \u2500\u2500
705
+ function init(){
706
+ injectStyles();
707
+ injectViewTransitionCSS();
708
+ updateActiveLinks();
709
+ updateNav(location.pathname);
710
+ }
711
+
712
+ if(document.readyState==='loading')document.addEventListener('DOMContentLoaded',init);else init();
713
+ })();
714
+ `}export{r as setAppUrl,AB as runMiddleware,BB as route,P as resolveLayoutChain,GB as resetRoutes,q as registerMiddleware,w as patternToRegex,KB as navigateTo,m as matchRoute,ZB as loadMiddlewareFromDirectory,WB as hasMiddleware,QB as getRouterScript,YB as getMiddlewareNames,f as getMiddleware,S as generateRouteTypes,b as generateRouteManifest,t as formatRoutes,o as findErrorPage,v as filePathToPattern,e as defineRoutes,a as defineRoute,VB as defineMiddleware,y as createStorageManager,k as createServerCookieManager,i as createRouter,$B as createRouteLocation,jB as createMiddlewareContext,x as createClientCookieManager,XB as clearMiddleware,OB as abortNavigation,C as Router};