@stacksjs/stx 0.2.345 → 0.2.347

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 (77) hide show
  1. package/dist/binding-manifest.js +2 -0
  2. package/dist/{chunk-kqzpmwx2.js → chunk-0573wv97.js} +183 -171
  3. package/dist/{chunk-223makqc.js → chunk-0vdng9sh.js} +1 -1
  4. package/dist/{chunk-ybx8n794.js → chunk-16kfapt5.js} +1 -1
  5. package/dist/{chunk-e7gs18rc.js → chunk-1kwtdq06.js} +1 -1
  6. package/dist/{chunk-qkdcbeaw.js → chunk-1vtd57x6.js} +6 -6
  7. package/dist/{chunk-fp868yhg.js → chunk-1zjh3d0f.js} +1 -1
  8. package/dist/{chunk-8rhjt6fh.js → chunk-24rhp7ye.js} +1 -1
  9. package/dist/{chunk-1qyg1q6d.js → chunk-3phs970s.js} +1 -1
  10. package/dist/{chunk-nqz501eq.js → chunk-4fcvaazx.js} +2 -2
  11. package/dist/{chunk-zmazqcb8.js → chunk-4k8rebtb.js} +1 -1
  12. package/dist/{chunk-6fwp7gee.js → chunk-5d3f7rth.js} +1 -1
  13. package/dist/{chunk-1t4ece3v.js → chunk-632jxm61.js} +1 -1
  14. package/dist/{chunk-1vv9g6cj.js → chunk-6be9r0tz.js} +1 -1
  15. package/dist/{chunk-cypg8qwn.js → chunk-6h8t40zg.js} +1 -1
  16. package/dist/{chunk-7g5vk4c3.js → chunk-8753m7f0.js} +1 -1
  17. package/dist/{chunk-esjcyxa9.js → chunk-8b8jwbne.js} +2 -2
  18. package/dist/{chunk-qr3zcm87.js → chunk-8cd3ws01.js} +1 -1
  19. package/dist/{chunk-9jbssgem.js → chunk-8m0g0h4x.js} +146 -10
  20. package/dist/{chunk-77p1kjg2.js → chunk-9rc9gshn.js} +2 -2
  21. package/dist/{chunk-1vtdege3.js → chunk-adevnpdw.js} +1 -1
  22. package/dist/{chunk-aapqf6bj.js → chunk-dmpexr7d.js} +1 -1
  23. package/dist/{chunk-vhg91hnw.js → chunk-e6zk6ntt.js} +1 -1
  24. package/dist/{chunk-3zm4hgcf.js → chunk-e9sk8fqy.js} +1 -1
  25. package/dist/{chunk-kfkf9v2d.js → chunk-f5veee11.js} +1 -1
  26. package/dist/{chunk-6wmjwbq9.js → chunk-fbs0x8r3.js} +1 -1
  27. package/dist/{chunk-gvemapw4.js → chunk-fqp4b8k4.js} +1 -1
  28. package/dist/{chunk-9qtf2b1p.js → chunk-gkr35yjh.js} +1 -1
  29. package/dist/chunk-gnb15a8d.js +32 -0
  30. package/dist/{chunk-4spaszfn.js → chunk-h2sbvyr4.js} +190 -190
  31. package/dist/chunk-h8apy0k1.js +2 -0
  32. package/dist/chunk-hpr2sdfc.js +2 -0
  33. package/dist/{chunk-xq0e2y4x.js → chunk-jxg9vnsy.js} +1 -1
  34. package/dist/{chunk-pajk5680.js → chunk-nqqknczy.js} +2 -2
  35. package/dist/{chunk-2fhk4e68.js → chunk-ns38fhve.js} +1 -1
  36. package/dist/{chunk-v7aa7v85.js → chunk-p3p4d6g1.js} +1 -1
  37. package/dist/{chunk-1yh6pq6b.js → chunk-pwh8pbks.js} +1 -1
  38. package/dist/{chunk-eqzc88et.js → chunk-q018c92j.js} +1 -1
  39. package/dist/{chunk-z8wb7kbj.js → chunk-qrhbqzz0.js} +1 -1
  40. package/dist/{chunk-jnbg3e4r.js → chunk-rd02ysw3.js} +1 -1
  41. package/dist/{chunk-zwr4bn6a.js → chunk-rv28743b.js} +1 -1
  42. package/dist/{chunk-b5mnam29.js → chunk-s2rc73vk.js} +1 -1
  43. package/dist/{chunk-yca761bm.js → chunk-st8wkk98.js} +1 -1
  44. package/dist/{chunk-yg5r7bnm.js → chunk-swvm1wgn.js} +27 -3
  45. package/dist/{chunk-rzda6bd6.js → chunk-tg56j4ka.js} +1 -1
  46. package/dist/{chunk-nrt99ptw.js → chunk-tshyy2br.js} +1 -1
  47. package/dist/{chunk-c8e2deyp.js → chunk-vxk12k35.js} +1 -1
  48. package/dist/{chunk-ek2m0kkw.js → chunk-w7vyd0n0.js} +1 -1
  49. package/dist/{chunk-xrjx7b2v.js → chunk-wjaqhspq.js} +1 -1
  50. package/dist/{chunk-mr8ccsnm.js → chunk-xvr9enmb.js} +1 -1
  51. package/dist/{chunk-72yrrggn.js → chunk-xy99vzs2.js} +1 -1
  52. package/dist/chunk-y8g8neeh.js +2 -0
  53. package/dist/{chunk-h1vax4wg.js → chunk-yr634wtd.js} +1 -1
  54. package/dist/{chunk-7m9qk7da.js → chunk-zrbhpfda.js} +1 -1
  55. package/dist/cli.js +8 -8
  56. package/dist/component-library.d.ts +0 -31
  57. package/dist/component-library.js +279 -17
  58. package/dist/config.js +16 -4
  59. package/dist/craft-entry.js +1 -1
  60. package/dist/craft.js +1 -1
  61. package/dist/dev-server/ts-css.js +16 -47
  62. package/dist/process.js +34 -8
  63. package/dist/pwa.js +1 -1
  64. package/dist/signals.js +146 -10
  65. package/dist/ssg.js +2 -2
  66. package/dist/stx-virtual-ts.d.ts +16 -1
  67. package/dist/stx-virtual-ts.js +33 -2
  68. package/dist/theme-tokens.js +9 -5
  69. package/dist/typecheck.js +2 -0
  70. package/dist/types/config-types.d.ts +10 -0
  71. package/dist/variable-extractor.d.ts +31 -0
  72. package/dist/variable-extractor.js +9 -5
  73. package/package.json +5 -5
  74. package/dist/chunk-57t402mn.js +0 -2
  75. package/dist/chunk-66tgkvqw.js +0 -2
  76. package/dist/chunk-c4tf1vpy.js +0 -2
  77. package/dist/chunk-r38xq7fp.js +0 -33
@@ -33,6 +33,18 @@ export declare function stripTypeScript(scriptContent: string): string;
33
33
  * Matched on the message because the failure arrives as a plain Error from the
34
34
  * runtime's loader rather than a typed one, and the wording differs between
35
35
  * Bun and Node.
36
+ *
37
+ * `cannot find package` is the important one and was missing. An ESM import
38
+ * that does not resolve says
39
+ *
40
+ * Cannot find package 'bunfig' imported from /…/dist/index.js
41
+ *
42
+ * and only a `require()` says "module". So the case stacksjs/stx#1991 was
43
+ * filed for - a dependency importing a package it had not declared, which
44
+ * threw wherever that package was unreachable - was classified as an unknown
45
+ * failure and got the generic warning instead of the one naming the cause.
46
+ * That one is also deduplicated per cause, so the clearest failure in the set
47
+ * was getting the quietest treatment.
36
48
  */
37
49
  export declare function isModuleResolutionFailure(message: string): boolean;
38
50
  /**
@@ -76,6 +88,25 @@ export interface ExtractVariablesOptions {
76
88
  * passes this flag on.
77
89
  */
78
90
  preserveExisting?: boolean;
91
+ /**
92
+ * Called when the script failed, so every variable it declared is undefined
93
+ * and anything reading one renders empty (stacksjs/stx#1991).
94
+ *
95
+ * `kind` says how certain that is a bug. The first three always are.
96
+ * `unknown` is not: a server script reaching for `window` or constructing a
97
+ * Chart lands there, which is the case the quiet fallback exists for, so a
98
+ * caller showing the developer something should leave that one alone.
99
+ *
100
+ * Reported rather than thrown, because one failed script must not take the
101
+ * page down with it. Before this a caller could not find out at all: the
102
+ * extractor warned and returned normally, which is why the component became
103
+ * a hole that nothing could put a boundary around.
104
+ */
105
+ onFailure?: (failure: {
106
+ kind: 'module-resolution' | 'syntax' | 'missing-binding' | 'unknown';
107
+ message: string;
108
+ error: unknown;
109
+ }) => void;
79
110
  }
80
111
  export declare function extractVariables(scriptContent: string, context: Record<string, unknown>, filePath: string, options?: ExtractVariablesOptions): Promise<void>;
81
112
  /**
@@ -274,7 +274,7 @@ export function stripTypeScript(scriptContent) {
274
274
  return result;
275
275
  }
276
276
  export function isModuleResolutionFailure(message) {
277
- return /cannot find module|could not resolve|module not found|failed to resolve/i.test(message);
277
+ return /cannot find module|cannot find package|could not resolve|module not found|failed to resolve/i.test(message);
278
278
  }
279
279
  export function isSyntaxFailure(error) {
280
280
  if (error instanceof SyntaxError)
@@ -569,18 +569,22 @@ export async function extractVariables(scriptContent, context, filePath, options
569
569
  if (context.__stx_strict_hydration)
570
570
  throw primaryError;
571
571
  const msg = primaryError instanceof Error ? primaryError.message : String(primaryError);
572
- if (isModuleResolutionFailure(msg))
572
+ if (isModuleResolutionFailure(msg)) {
573
573
  console.warn(`[stx] server <script> in ${filePath ?? "<unknown>"} imports a module that does not resolve, so every variable in that script is undefined. Cause: ${msg}`);
574
- else if (isSyntaxFailure(primaryError))
574
+ options.onFailure?.({ kind: "module-resolution", message: msg, error: primaryError });
575
+ } else if (isSyntaxFailure(primaryError)) {
575
576
  console.warn(`[stx] server <script> in ${filePath ?? "<unknown>"} does not parse, so every variable in that script is undefined. Cause: ${msg}`);
576
- else if (isMissingBindingFailure(msg))
577
+ options.onFailure?.({ kind: "syntax", message: msg, error: primaryError });
578
+ } else if (isMissingBindingFailure(msg)) {
577
579
  console.warn(`[stx] server <script> in ${filePath ?? "<unknown>"} names something that does not exist, so every variable in that script is undefined. Optional chaining does not help here: an undefined identifier throws before the chain is reached. Cause: ${msg}`);
578
- else {
580
+ options.onFailure?.({ kind: "missing-binding", message: msg, error: primaryError });
581
+ } else {
579
582
  const seenKey = `${filePath ?? "<unknown>"}\x00${msg}`;
580
583
  if (process.env.STX_DEBUG || !reportedServerScriptFailures.has(seenKey)) {
581
584
  reportedServerScriptFailures.add(seenKey);
582
585
  console.warn(`[stx] server <script> in ${filePath ?? "<unknown>"} threw, so every variable in that script is undefined and anything that reads one renders empty. Cause: ${msg}`);
583
586
  }
587
+ options.onFailure?.({ kind: "unknown", message: msg, error: primaryError });
584
588
  }
585
589
  try {
586
590
  await fallbackVariableExtraction(jsContent, context, filePath);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@stacksjs/stx",
3
3
  "type": "module",
4
- "version": "0.2.345",
4
+ "version": "0.2.347",
5
5
  "description": "A performant UI Framework. Powered by Bun.",
6
6
  "author": "Chris Breuer <chris@stacksjs.org>",
7
7
  "license": "MIT",
@@ -117,12 +117,12 @@
117
117
  "dependencies": {
118
118
  "@stacksjs/ts-css": "^0.3.2",
119
119
  "@stacksjs/clapp": "^0.2.16",
120
- "@stacksjs/desktop": "0.2.345",
121
- "@stacksjs/sanitizer": "0.2.345",
120
+ "@stacksjs/desktop": "0.2.347",
121
+ "@stacksjs/sanitizer": "0.2.347",
122
122
  "@stacksjs/ts-i18n": "^0.1.11",
123
- "bun-plugin-stx": "0.2.345",
123
+ "bun-plugin-stx": "0.2.347",
124
124
  "bunfig": "^0.15.19",
125
- "stx-router": "0.2.345",
125
+ "stx-router": "0.2.347",
126
126
  "ts-broadcasting": "^0.0.10",
127
127
  "ts-images": "^0.2.22",
128
128
  "ts-syntax-highlighter": "^0.2.1"
@@ -1,2 +0,0 @@
1
- // @bun
2
- import{Ye as a}from"./chunk-zmazqcb8.js";import"./chunk-esjcyxa9.js";import"./chunk-57atgbyq.js";import"./chunk-77p1kjg2.js";import"./chunk-4spaszfn.js";import"./chunk-8y1ve8tc.js";import"./chunk-njx93b4z.js";import"./chunk-bqdfbwdf.js";import"./chunk-89mqnh67.js";import"./chunk-xvh1k1a4.js";import"./chunk-r38xq7fp.js";import"./chunk-y2f41kaq.js";import"./chunk-xj6bcwqa.js";import"./chunk-z8wb7kbj.js";import"./chunk-vhta1be7.js";import"./chunk-tc4pj651.js";import"./chunk-san1eq0r.js";import"./chunk-avwywzsj.js";import"./chunk-wj21f1e0.js";import"./chunk-d86q27j8.js";import"./chunk-72x62kch.js";import"./chunk-yg5r7bnm.js";import"./chunk-9nrgjtah.js";import"./chunk-ejqpq0wc.js";export{a as startProductionServer};
@@ -1,2 +0,0 @@
1
- // @bun
2
- import{Wf as a}from"./chunk-7m9qk7da.js";import"./chunk-esjcyxa9.js";import"./chunk-57atgbyq.js";import"./chunk-9jbssgem.js";import"./chunk-e4g8wz6t.js";import"./chunk-c0n802j1.js";import"./chunk-77p1kjg2.js";import"./chunk-4spaszfn.js";import"./chunk-8y1ve8tc.js";import"./chunk-njx93b4z.js";import"./chunk-bqdfbwdf.js";import"./chunk-89mqnh67.js";import"./chunk-xvh1k1a4.js";import"./chunk-r38xq7fp.js";import"./chunk-y2f41kaq.js";import"./chunk-xj6bcwqa.js";import"./chunk-z8wb7kbj.js";import"./chunk-vhta1be7.js";import"./chunk-tc4pj651.js";import"./chunk-san1eq0r.js";import"./chunk-avwywzsj.js";import"./chunk-wj21f1e0.js";import"./chunk-d86q27j8.js";import"./chunk-72x62kch.js";import"./chunk-yg5r7bnm.js";import"./chunk-9nrgjtah.js";import"./chunk-ejqpq0wc.js";export{a as buildForProduction};
@@ -1,2 +0,0 @@
1
- // @bun
2
- import{Ue as a}from"./chunk-vhg91hnw.js";import"./chunk-57atgbyq.js";import"./chunk-4spaszfn.js";import"./chunk-8y1ve8tc.js";import"./chunk-njx93b4z.js";import"./chunk-bqdfbwdf.js";import"./chunk-89mqnh67.js";import"./chunk-xvh1k1a4.js";import"./chunk-r38xq7fp.js";import"./chunk-y2f41kaq.js";import"./chunk-xj6bcwqa.js";import"./chunk-z8wb7kbj.js";import"./chunk-vhta1be7.js";import"./chunk-tc4pj651.js";import"./chunk-san1eq0r.js";import"./chunk-avwywzsj.js";import"./chunk-wj21f1e0.js";import"./chunk-d86q27j8.js";import"./chunk-72x62kch.js";import"./chunk-yg5r7bnm.js";import"./chunk-9nrgjtah.js";import"./chunk-ejqpq0wc.js";export{a as buildApp};
@@ -1,33 +0,0 @@
1
- // @bun
2
- import{nt as iJ}from"./chunk-y2f41kaq.js";import{Nw as hJ}from"./chunk-ejqpq0wc.js";import z from"path";import{hasLocalConfig as dJ}from"bunfig";var BJ={fg:{light:"neutral-900",dark:"neutral-100",description:"Primary text"},"fg-strong":{light:"neutral-700",dark:"neutral-300",description:"Labels, secondary headings"},"fg-muted":{light:"neutral-600",dark:"neutral-400",description:"Supporting text"},"fg-soft":{light:"neutral-500",dark:"neutral-400",description:"De-emphasised text"},"fg-subtle":{light:"neutral-400",dark:"neutral-500",description:"Placeholders, disabled text"},surface:{light:"neutral-50",dark:"neutral-800",description:"Page and panel background"},"surface-raised":{light:"neutral-100",dark:"neutral-700",description:"Cards, popovers"},"surface-sunken":{light:"neutral-200",dark:"neutral-700",description:"Wells, track backgrounds"},panel:{light:"white",dark:"neutral-800",description:"Card, menu, dialog surface"},field:{light:"white",dark:"neutral-700",description:"Form control surface"},"surface-hover":{light:"neutral-100",dark:"neutral-700",description:"Row or item highlight on a page or panel"},"surface-raised-hover":{light:"neutral-200",dark:"neutral-600",description:"Raised surface, hovered"},"surface-sunken-hover":{light:"neutral-300",dark:"neutral-600",description:"Sunken surface, hovered"},"field-hover":{light:"neutral-50",dark:"neutral-600",description:"Form control surface, hovered"},inverse:{light:"neutral-900",dark:"neutral-700",description:"Tooltip bubble, inverted surface"},"inverse-ink":{light:"white",dark:"white",description:"Text on an inverted surface"},line:{light:"neutral-200",dark:"neutral-700",description:"Default border, divider"},"line-strong":{light:"neutral-300",dark:"neutral-600",description:"Input border, focus ring track"},accent:{light:"blue-600",dark:"blue-400",description:"Primary action, selected state"},info:{light:"cyan-600",dark:"cyan-400",description:"Informational emphasis, links"},danger:{light:"red-600",dark:"red-400",description:"Errors, destructive actions"},success:{light:"green-600",dark:"green-400",description:"Confirmation"},warning:{light:"yellow-600",dark:"yellow-400",description:"Caution"},"accent-solid":{light:"blue-500",dark:"blue-600",description:"Primary button fill"},"info-solid":{light:"cyan-500",dark:"cyan-600",description:"Informational fill"},"danger-solid":{light:"red-500",dark:"red-600",description:"Destructive button fill"},"success-solid":{light:"green-500",dark:"green-600",description:"Confirmation fill"},"warning-solid":{light:"yellow-500",dark:"yellow-600",description:"Caution fill"},"accent-solid-hover":{light:"blue-600",dark:"blue-700",description:"Primary button fill, hovered"},"info-solid-hover":{light:"cyan-600",dark:"cyan-700",description:"Informational fill, hovered"},"danger-solid-hover":{light:"red-600",dark:"red-700",description:"Destructive fill, hovered"},"success-solid-hover":{light:"green-600",dark:"green-700",description:"Confirmation fill, hovered"},"warning-solid-hover":{light:"yellow-600",dark:"yellow-700",description:"Caution fill, hovered"},"accent-ink":{light:"white",dark:"white",description:"Text on a primary fill"},"info-ink":{light:"white",dark:"white",description:"Text on an informational fill"},"danger-ink":{light:"white",dark:"white",description:"Text on a destructive fill"},"success-ink":{light:"white",dark:"white",description:"Text on a confirmation fill"},"warning-ink":{light:"neutral-900",dark:"neutral-900",description:"Text on a caution fill"},"accent-soft":{light:"blue-100",dark:"blue-900",description:"Tinted primary fill"},"accent-soft-ink":{light:"blue-800",dark:"blue-200",description:"Text on a tinted primary fill"},"info-soft":{light:"cyan-100",dark:"cyan-900",description:"Tinted informational fill"},"info-soft-ink":{light:"cyan-800",dark:"cyan-200",description:"Text on a tinted informational fill"},"danger-soft":{light:"red-100",dark:"red-900",description:"Tinted destructive fill"},"danger-soft-ink":{light:"red-800",dark:"red-200",description:"Text on a tinted destructive fill"},"success-soft":{light:"green-100",dark:"green-900",description:"Tinted confirmation fill"},"success-soft-ink":{light:"green-800",dark:"green-200",description:"Text on a tinted confirmation fill"},"warning-soft":{light:"yellow-100",dark:"yellow-900",description:"Tinted caution fill"},"warning-soft-ink":{light:"yellow-800",dark:"yellow-200",description:"Text on a tinted caution fill"},secondary:{light:"purple-600",dark:"purple-400",description:"Secondary emphasis"},"secondary-solid":{light:"purple-500",dark:"purple-600",description:"Secondary fill"},"secondary-solid-hover":{light:"purple-600",dark:"purple-700",description:"Secondary fill, hovered"},"secondary-ink":{light:"white",dark:"white",description:"Text on a secondary fill"},"secondary-soft":{light:"purple-100",dark:"purple-900",description:"Tinted secondary fill"},"secondary-soft-ink":{light:"purple-800",dark:"purple-200",description:"Text on a tinted secondary fill"},"danger-fg":{light:"red-900",dark:"red-300",description:"Text in a field with an error"},"danger-fg-subtle":{light:"red-300",dark:"red-500",description:"Placeholder in a field with an error"},"danger-line":{light:"red-300",dark:"red-600",description:"Border of a field with an error"},"danger-focus":{light:"red-500",dark:"red-400",description:"Focus ring of a field with an error"}};function p(J){return`--stx-${J}`}function m(J,Q){let Z=Q.lastIndexOf("-");if(Z===-1)return typeof J[Q]==="string"?J[Q]:void 0;let $=J[Q.slice(0,Z)];if(!$||typeof $!=="object")return;let U=$[Q.slice(Z+1)];return typeof U==="string"?U:void 0}function LJ(J){let Q={};for(let[Z,$]of Object.entries(BJ)){let U=m(J,$.light);if(U===void 0)continue;Q[Z]=`var(${p(Z)}, ${U})`}return Q}function HJ(J){let Q=[],Z=[];for(let[$,U]of Object.entries(BJ)){let F=m(J,U.light),W=m(J,U.dark);if(F===void 0)continue;if(Q.push(` ${p($)}: ${F};`),W!==void 0)Z.push(` ${p($)}: ${W};`)}if(Q.length===0)return"";return["/* stx role tokens \u2014 override any of these to re-theme by meaning. */",":root {",...Q,"}",".dark {",...Z,"}",""].join(`
3
- `)}var OJ={control:{value:"0.375rem",description:"Buttons, inputs, selects \u2014 rounded-md"},panel:{value:"0.5rem",description:"Cards, dialogs, menus \u2014 rounded-lg"},pill:{value:"9999px",description:"Chips and badges, which are pill-shaped by intent"}};function KJ(J){return`--stx-radius-${J}`}function IJ(){let J={};for(let[Q,Z]of Object.entries(OJ))J[Q]=`var(${KJ(Q)}, ${Z.value})`;return J}function DJ(){return["/* stx shape tokens \u2014 a radius by what the thing is. */",":root {",...Object.entries(OJ).map(([J,Q])=>` ${KJ(J)}: ${Q.value};`),"}",""].join(`
4
- `)}function NJ(J){return typeof J==="object"&&J!==null&&!Array.isArray(J)}function h(J,Q){let Z={...J};for(let[$,U]of Object.entries(Q))Z[$]=NJ(U)&&NJ(Z[$])?h(Z[$],U):U;return Z}function MJ(J={},Q={}){let Z=J.theme||{},$=Q.theme||{},{extend:U,...F}=$,{extend:W,...j}=Z,X=j.colors||{};j.colors={...X,...LJ(X)};let V=j.borderRadius||{};j.borderRadius={...V,...IJ()};let q=h(j,F),G=h(W||{},U||{});if(Object.keys(G).length>0)q.extend=G;let w=[...J.safelist||[],...Q.safelist||[]],K={...J.shortcuts||{},...Q.shortcuts||{}},D=[...J.preflights||[],...Q.preflights||[]];return{config:{...J,...Q,theme:q,safelist:w,shortcuts:K,...D.length>0?{preflights:D}:{},content:[],output:""},safelist:w,shortcuts:K,includePreflight:Q.preflight!==!1,minify:Q.minify===!0,tokenCSS:HJ(X)+DJ()}}var E=/<script\b[^>]*>/iy,c=/<\/script\s*>/ig,S=/<style\b[^>]*>/iy,l=/<\/style\s*>/ig;function PJ(J,Q,Z,$){Z.lastIndex=Q;let U=Z.exec(J);if(!U||U.index!==Q)return-1;$.lastIndex=Z.lastIndex;let F=$.exec(J);if(!F)return-1;return F.index+F[0].length}function o(J,Q){return PJ(J,Q,E,c)}function AJ(J,Q){return PJ(J,Q,S,l)}function lJ(J,Q){if(!J.startsWith("<!--",Q))return-1;let Z=J.indexOf("-->",Q+4);if(Z===-1)return-1;return Z+3}function _J(J,Q){if(J.startsWith("<!--",Q)){let U=lJ(J,Q);return U===-1?J.length:U}if(E.lastIndex=Q,E.exec(J)?.index===Q){c.lastIndex=E.lastIndex;let U=c.exec(J);return U?U.index+U[0].length:J.length}if(S.lastIndex=Q,S.exec(J)?.index===Q){l.lastIndex=S.lastIndex;let U=l.exec(J);return U?U.index+U[0].length:J.length}return-1}function oJ(J,Q){let Z=[],$=0,U=J.length,F=!1,W=null;while($<U){let j=J[$];if(F){if(W){if(j===W)W=null}else if(j==='"'||j==="'")W=j;else if(j===">")F=!1;$++;continue}if(j!=="<"){let G=J.indexOf("<",$+1);if(G===-1)break;$=G;continue}let X=Q(J,$);if(X>$){Z.push({start:$,end:X,token:J.slice($,X)}),$=X;continue}let V=_J(J,$);if(V>$){$=V;continue}let q=J.charCodeAt($+1);if(q>=65&&q<=90||q>=97&&q<=122)F=!0;$++}return Z}function kQ(J){let Q=0,Z=0,$=0,U=!1,F=null;while($<J.length){if(U){let G=J[$];if(F){if(G===F)F=null}else if(G==='"'||G==="'")F=G;else if(G===">")U=!1;$++;continue}let W=J.indexOf("<",$),j=W===-1?J.length:W;while($<j){let G=J[$++];if(G==="{")Q++;else if(G==="}")Z++;if(Q>=2&&Z>=2)return!0}if(W===-1)break;let X=_J(J,W);if(X>W){$=X;continue}let V=J.charCodeAt(W+1),q=V===47?J.charCodeAt(W+2):V;if(q>=65&&q<=90||q>=97&&q<=122)U=!0;$=W+1}return!1}function vJ(J,Q){while(J.size>=Q){let Z=J.keys().next();if(Z.done)return;J.delete(Z.value)}}var aJ=65536,sJ=12,i=new Map;function a(J,Q,Z,$){let U=$!==void 0&&J.length>=aJ,F=U?`${$}\x00${J}`:"";if(U){let q=i.get(F);if(q)return{output:q.output,tokens:q.tokens.slice()}}let W=oJ(J,Q);if(W.length===0)return{output:J,tokens:[]};let j=W.map((q)=>q.token),X="",V=0;for(let q=0;q<W.length;q++){let G=W[q];X+=J.slice(V,G.start),X+=Z(G.token,q),V=G.end}if(X+=J.slice(V),U)return vJ(i,sJ),i.set(F,{output:X,tokens:j}),{output:X,tokens:j.slice()};return{output:X,tokens:j}}var tJ=65536,eJ=4,r=new Map;function n(J,Q,Z){return{output:Q,scripts:Z,restore:($)=>$===Q?J:JQ($,Z)}}function xQ(J){let Q=J.length>=tJ;if(Q){let U=r.get(J);if(U)return n(J,U.output,U.scripts.slice())}let{output:Z,tokens:$}=a(J,o,(U,F)=>`\x00STX_SCRIPT_${F}\x00`);if(Q)return vJ(r,eJ),r.set(J,{output:Z,scripts:$}),n(J,Z,$.slice());return n(J,Z,$)}function JQ(J,Q){if(Q.length===0)return J;return J.replace(/\x00STX_SCRIPT_(\d+)\x00/g,(Z,$)=>Q[+$]??"")}function RJ(J,Q=""){let Z=`${J}${Q}`,$=0;for(let U=0;U<Z.length;U++){let F=Z.charCodeAt(U);$=($<<5)-$+F,$=$&$}return`stx-${Math.abs($).toString(36)}`}function TJ(J,Q,Z={}){let{prefix:$="",preserveHost:U=!0,scopeKeyframes:F=!0,scopeCustomProperties:W=!1}=Z;if(!J.trim())return"";let j=s(J),X=[],V=new Map;if(F)for(let q of j){let G=q.selector.match(/@keyframes\s+([a-z_-][a-z0-9_-]*)/i);if(G){let w=G[1],K=`${Q}_${w}`;V.set(w,K)}}for(let q of j){let G=bJ(q,Q,$,U,V,W);X.push(G)}return X.join(`
5
-
6
- `)}function s(J){let Q=[],Z=J.replace(/\/\*[\s\S]*?\*\//g,""),$=0,U="",F=!1,W="";for(let j=0;j<Z.length;j++){let X=Z[j];if(X==="@"&&$===0)F=!0;if(X==="{")$++;else if(X==="}"){if($--,$===0){if(F){W+=X;let V=W.match(/@([a-z-]+)\s*([^{]*)\{([\s\S]*)\}/i);if(V){let[,q,G,w]=V;if(q==="keyframes")Q.push({selector:`@keyframes ${G.trim()}`,declarations:w.trim()});else if(q==="media"||q==="supports"||q==="container"){let K=s(w);Q.push({selector:`@${q} ${G.trim()}`,declarations:K.map((D)=>`${D.selector} { ${D.declarations} }`).join(`
7
- `)})}else Q.push({selector:`@${q} ${G.trim()}`,declarations:w.trim()})}W="",F=!1}else if(U.trim()){U+=X;let V=U.match(/([^{]+)\{([^}]*)\}/);if(V)Q.push({selector:V[1].trim(),declarations:V[2].trim()});U=""}continue}}if(F)W+=X;else U+=X}return Q}function bJ(J,Q,Z,$,U,F){let{selector:W,declarations:j}=J;if(W.startsWith("@")){if(W.startsWith("@keyframes")){let q=W.replace("@keyframes ","").trim();return`@keyframes ${U.get(q)||q} { ${j} }`}if(W.startsWith("@media")||W.startsWith("@supports")||W.startsWith("@container")){let G=s(`x { ${j} }`.replace(/x \{ /,"").replace(/ \}$/,"")).map((w)=>bJ(w,Q,Z,$,U,F)).join(`
8
- `);return`${W} {
9
- ${G}
10
- }`}return`${W} { ${j} }`}let X=QQ(W,Q,Z,$),V=j;for(let[q,G]of U)V=V.replace(new RegExp(`\\b${q}\\b`,"g"),G);if(F)V=V.replace(/--([a-z-]+)/gi,`--${Q}-$1`);return`${X} { ${V} }`}function QQ(J,Q,Z,$){let U=J.split(",").map((W)=>W.trim()),F=[];for(let W of U){if(W.startsWith(":host")){if($)F.push(W);else{let V=W.replace(/:host(\([^)]*\))?/,`.${Q}$1`);F.push(V)}continue}if(W.includes("::slotted")){F.push(W);continue}if(W===":root"){F.push(`:root .${Q}`);continue}let j=Z?`${Z} .${Q}`:`.${Q}`;F.push(`${j} ${W}`);let X=$Q(W,Q);if(X)F.push(Z?`${Z} ${X}`:X)}return F.join(", ")}function $Q(J,Q){let Z=0,$=J.length;for(let X=0;X<J.length;X++){let V=J[X];if(V==="["||V==="(")Z++;else if(V==="]"||V===")")Z--;else if(Z===0&&(V===" "||V===">"||V==="+"||V==="~")){$=X;break}}let U=J.slice(0,$),F=J.slice($);if(!U)return"";let W=U.length,j=0;for(let X=0;X<U.length;X++){let V=U[X];if(V==="["||V==="(")j++;else if(V==="]"||V===")")j--;else if(Z===0&&j===0&&V===":"){W=X;break}}return`${U.slice(0,W)}.${Q}${U.slice(W)}${F}`}var EJ=String.raw`(?<![\w-])scoped(?![\w-])`,t=/<style\s+([^>]*)>/gi,kJ=/<style\s+([^>]*)>([\s\S]*?)<\/style>/gi,SJ=new RegExp(EJ,"i"),ZQ=new RegExp(EJ,"gi"),e=/<style\b[^>]*\bdata-stx-scoped(?:=(?:"[^"]*"|'[^']*'|[^\s>]+))?[^>]*>[\s\S]*?<\/style>\s*/gi;function UQ(J){t.lastIndex=0;let Q=t.exec(J);while(Q!==null){if(SJ.test(Q[1]))return!0;Q=t.exec(J)}return!1}function JJ(J){let Q=new Set,Z=[];e.lastIndex=0;let $=e.exec(J);while($!==null){let U=$[0].trim();if(Q.has(U))Z.push({start:$.index,end:$.index+$[0].length});else Q.add(U);$=e.exec(J)}return Z}function QJ(J){let Q=JJ(J);if(Q.length===0)return J;let Z=Array(Q.length+1),$=0;for(let U=0;U<Q.length;U++){let F=Q[U];Z[U]=J.slice($,F.start),$=F.end}return Z[Q.length]=J.slice($),Z.join("")}function CQ(J,Q){if(!UQ(J))return{html:J,hasScoped:!1};let Z=RJ(Q),$=`data-v-${Z}`,U=J,F=!1;if(kJ.lastIndex=0,U=U.replace(kJ,(W,j,X)=>{if(!SJ.test(j))return W;F=!0;let V=FQ(X,$),q=j.replace(ZQ,"").trim(),G=q?` ${q}`:"";return`<style data-stx-scoped="${Z}"${G}>${V}</style>`}),!F)return{html:J,hasScoped:!1};return U=XQ(U,$),{html:U,hasScoped:!0}}function FQ(J,Q){return TJ(J,"__SCOPE_PLACEHOLDER__",{preserveHost:!1}).replace(/\.(__SCOPE_PLACEHOLDER__) /g,`[${Q}] `).replace(/\.(__SCOPE_PLACEHOLDER__)/g,`[${Q}]`)}var WQ=(J)=>`\x00stx-scope-mask-${J}\x00`,xJ=/\u0000stx-scope-mask-(\d+)\u0000/g;function XQ(J,Q){let Z=a(J,(U,F)=>{let W=o(U,F);return W>F?W:AJ(U,F)},(U,F)=>WQ(F)),$=jQ(Z.output,Q);return xJ.lastIndex=0,$.replace(xJ,(U,F)=>Z.tokens[Number(F)])}function jQ(J,Q){let Z=new Set(["script","style","template","html","head","body","meta","link","title","base","!doctype","!DOCTYPE"]);return J.replace(/<([a-zA-Z][a-zA-Z0-9-]*)(\s[^>]*)?\/?>/g,($,U,F)=>{if(Z.has(U.toLowerCase()))return $;if($.includes(Q))return $;if(U.toLowerCase()==="style"||U.toLowerCase()==="script")return $;if(F)return $.replace(`<${U}${F}`,`<${U} ${Q}${F}`);if($.endsWith("/>"))return`<${U} ${Q} />`;return`<${U} ${Q}>`})}var Y={reset:"\x1B[0m",bright:"\x1B[1m",dim:"\x1B[2m",underscore:"\x1B[4m",blink:"\x1B[5m",reverse:"\x1B[7m",hidden:"\x1B[8m",black:"\x1B[30m",red:"\x1B[31m",green:"\x1B[32m",yellow:"\x1B[33m",blue:"\x1B[34m",magenta:"\x1B[35m",cyan:"\x1B[36m",white:"\x1B[37m",gray:"\x1B[90m",bgBlack:"\x1B[40m",bgRed:"\x1B[41m",bgGreen:"\x1B[42m",bgYellow:"\x1B[43m",bgBlue:"\x1B[44m",bgMagenta:"\x1B[45m",bgCyan:"\x1B[46m",bgWhite:"\x1B[47m",bgGray:"\x1B[100m"};import CJ from"fs";class ZJ{cache=new Map;maxSize;options;sizes;bytes=0;constructor(J=100,Q){this.maxSize=J,this.options=Q??null,this.sizes=Q?new Map:null}get byteSize(){return this.bytes}setMaxBytes(J){if(!this.options)return;this.options={...this.options,maxBytes:J};while(this.bytes>J&&this.cache.size>0){let Q=this.cache.keys().next().value;if(Q===void 0)break;this.delete(Q)}}get(J){if(!this.cache.has(J))return;let Q=this.cache.get(J);return this.cache.delete(J),this.cache.set(J,Q),Q}set(J,Q){if(this.cache.has(J))this.delete(J);let Z=this.options?this.options.sizeOf(Q):0;if(this.options&&Z>this.options.maxBytes)return;while(this.cache.size>0&&(this.cache.size>=this.maxSize||this.options!==null&&this.bytes+Z>this.options.maxBytes)){let $=this.cache.keys().next().value;if($===void 0)break;this.delete($)}if(this.cache.set(J,Q),this.sizes)this.sizes.set(J,Z),this.bytes+=Z}has(J){return this.cache.has(J)}delete(J){if(this.sizes){let Q=this.sizes.get(J);if(Q!==void 0)this.bytes-=Q,this.sizes.delete(J)}return this.cache.delete(J)}clear(){this.cache.clear(),this.sizes?.clear(),this.bytes=0}get size(){return this.cache.size}keys(){return this.cache.keys()}values(){return this.cache.values()}}var P=new Map,VQ=500;function dQ(J,Q){if(Q?.includes("g"))return new RegExp(J,Q);let Z=`${J}:${Q||""}`;if(!P.has(Z)){if(P.size>=VQ){let $=P.keys().next().value;if($)P.delete($)}P.set(Z,new RegExp(J,Q))}return P.get(Z)}class yJ{pool=[];maxPoolSize=10;fnCache=new Map;fnCacheMaxSize=200;getEvaluator(J){let Q=Array.from(new Set(J)),Z=Q.sort().join(","),$=this.pool.find((j)=>j.context.join(",")===Z);if($)return $.func;let U=this.fnCache,F=this.fnCacheMaxSize,W=(...j)=>{return(X)=>{try{let V=`${Z}:${X}`,q=U.get(V);if(!q){if(U.size>=F){let G=U.keys().next().value;if(G)U.delete(G)}q=Function(...Q,`
11
- 'use strict';
12
- try {
13
- return ${X};
14
- }
15
- catch (e) {
16
- if (e instanceof ReferenceError || e instanceof TypeError) {
17
- return undefined;
18
- }
19
- throw e;
20
- }
21
- `),U.set(V,q)}return q(...j)}catch{return}}};if(this.pool.length<this.maxPoolSize)this.pool.push({func:W,context:Q.slice()});return W}clear(){this.pool.length=0,this.fnCache.clear()}}var pQ=new yJ;class fJ{metrics=new Map;budgets=new Map;violations=[];maxViolations=100;violationHandlers=[];enabled=!0;setEnabled(J){this.enabled=J}isEnabled(){return this.enabled}setBudget(J,Q){this.budgets.set(J,{warnThreshold:0.8,action:"warn",...Q})}setBudgets(J){for(let[Q,Z]of Object.entries(J))this.setBudget(Q,Z)}removeBudget(J){this.budgets.delete(J)}getBudgets(){let J={};for(let[Q,Z]of this.budgets.entries())J[Q]=Z;return J}onViolation(J){this.violationHandlers.push(J)}offViolation(J){let Q=this.violationHandlers.indexOf(J);if(Q!==-1)this.violationHandlers.splice(Q,1)}time(J,Q){if(!this.enabled)return Q();let Z=performance.now(),$=Q(),U=performance.now()-Z;return this.recordTime(J,U),this.checkBudget(J,U),$}async timeAsync(J,Q){if(!this.enabled)return Q();let Z=performance.now(),$=await Q(),U=performance.now()-Z;return this.recordTime(J,U),this.checkBudget(J,U),$}checkBudget(J,Q){let Z=this.budgets.get(J);if(!Z)return;let $=Q/Z.maxTime*100,U=Z.warnThreshold!==void 0?Q>=Z.maxTime*Z.warnThreshold&&Q<Z.maxTime:!1,F=Q>=Z.maxTime;if(!U&&!F)return;let W={label:J,actualTime:Q,budgetTime:Z.maxTime,exceedancePercent:$,timestamp:new Date,isWarning:U};this.violations.push(W);while(this.violations.length>this.maxViolations)this.violations.shift();for(let X of this.violationHandlers)try{X(W)}catch{}let j=U?`[Performance Warning] "${J}" took ${Q.toFixed(2)}ms (${$.toFixed(1)}% of ${Z.maxTime}ms budget)`:`[Performance Budget Exceeded] "${J}" took ${Q.toFixed(2)}ms (exceeded ${Z.maxTime}ms budget by ${($-100).toFixed(1)}%)`;switch(Z.action){case"log":console.log(j);break;case"warn":console.warn(j);break;case"error":console.error(j);break;case"throw":if(F)throw Error(j);else console.warn(j);break}}recordTime(J,Q){let Z=this.metrics.get(J);if(Z)Z.count++,Z.totalTime+=Q,Z.maxTime=Math.max(Z.maxTime,Q),Z.minTime=Math.min(Z.minTime,Q);else this.metrics.set(J,{count:1,totalTime:Q,maxTime:Q,minTime:Q})}getStats(J){if(J){let Z=this.metrics.get(J);if(!Z)return{};let $=this.budgets.get(J);return{count:Z.count,avgTime:Z.totalTime/Z.count,totalTime:Z.totalTime,maxTime:Z.maxTime,minTime:Z.minTime,budget:$?.maxTime,budgetUtilization:$?Z.totalTime/Z.count/$.maxTime*100:void 0}}let Q={};for(let[Z,$]of this.metrics.entries()){let U=this.budgets.get(Z);Q[Z]={count:$.count,avgTime:$.totalTime/$.count,totalTime:$.totalTime,maxTime:$.maxTime,minTime:$.minTime,budget:U?.maxTime,budgetUtilization:U?$.totalTime/$.count/U.maxTime*100:void 0}}return Q}getViolations(J){if(J)return this.violations.filter((Q)=>Q.label===J);return[...this.violations]}getViolationStats(){let J={},Q=0,Z=0;for(let $ of this.violations)if(J[$.label]=(J[$.label]||0)+1,$.isWarning)Q++;else Z++;return{total:this.violations.length,byLabel:J,warnings:Q,errors:Z}}clear(){this.metrics.clear()}clearViolations(){this.violations.length=0}clearBudgets(){this.budgets.clear()}reset(){this.clear(),this.clearViolations(),this.clearBudgets(),this.violationHandlers.length=0}}var $J=null;function qQ(){if(!$J)$J=new fJ;return $J}var mQ=new Proxy({},{get(J,Q){return qQ()[Q]}});var gJ=[];function uJ(J){let Q=new ZJ(J);return gJ.push(Q),Q}function nQ(){for(let J of gJ)J.clear()}function UJ(J,...Q){return`${Q.map((Z)=>String(Z??"")).join("\x00")}\x00${J.length}\x00${Bun.hash(J)}`}function cQ(J){let Q=[];for(let Z of new Set(J))try{Q.push({path:Z,mtimeMs:CJ.statSync(Z).mtimeMs})}catch{}return Q}function lQ(J){for(let Q of J)try{if(CJ.statSync(Q.path).mtimeMs!==Q.mtimeMs)return!1}catch{return!1}return!0}var H=null,WJ=!1,L=null,T="",A=!1,rJ=256,N=new Map,O=new Map,M=null,b=null;function y(J){return Bun.hash(J).toString(16).padStart(16,"0").slice(0,16)}function FJ(J,Q){if(N.has(J))N.delete(J);else if(N.size>=rJ)N.delete(N.keys().next().value);N.set(J,Q)}function GQ(J){let Q=y(J);if(O.has(Q))O.delete(Q);else if(O.size>=rJ)O.delete(O.keys().next().value);return O.set(Q,J),Q}function Z0(J){let Q=O.get(J);if(Q===void 0)return;return O.delete(J),O.set(J,Q),Q}async function zQ(J){if(!M)return null;try{let Q=Bun.file(z.join(M,`cw-${y(J)}.css`));if(!await Q.exists())return null;return await Q.text()}catch{return null}}async function YQ(J,Q){if(!M)return;try{if(!fs.existsSync(M))fs.mkdirSync(M,{recursive:!0});await Bun.write(z.join(M,`cw-${y(J)}.css`),Q)}catch{}}async function pJ(J){try{let Q=await import(J);if(Q&&Q.CSSGenerator)return{CSSGenerator:Q.CSSGenerator,config:Q.config,build:Q.build,defaultConfig:Q.defaultConfig,extractClasses:Q.extractClasses}}catch{}return null}var wQ=[["@stacksjs","ts-css","dist","engine","index.js"],["@stacksjs","ts-css","src","engine","index.ts"]],BQ=["@stacksjs/ts-css/engine","@stacksjs/ts-css/dist/engine/index.js"];function LQ(){let J=[],Q=process.cwd();while(Q!==z.dirname(Q)){for(let Z of["node_modules","pantry"])for(let $ of wQ)J.push(z.join(Q,Z,...$));Q=z.dirname(Q)}return J}function HQ(){let J=[],Q=process.env.HOME||process.env.USERPROFILE||"",Z=[Q&&z.join(Q,"Code","Tools","ts-css"),Q&&z.join(Q,"Code","Tools","crosswind"),Q&&z.join(Q,"repos","stacks-org","ts-css"),Q&&z.join(Q,"repos","stacks-org","crosswind"),z.join(process.cwd(),"..","ts-css"),z.join(process.cwd(),"..","crosswind")].filter(Boolean);for(let $ of Z)J.push(z.join($,"packages","toolkit","dist","engine","index.js")),J.push(z.join($,"packages","toolkit","src","engine","index.ts"));if(Q)J.push(z.join(Q,"Code","Tools","stx","node_modules","@stacksjs","ts-css","dist","engine","index.js"));return J}async function nJ(){if(WJ)return H;WJ=!0;try{let J=async(U)=>{for(let F of U){if(!await Bun.file(F).exists())continue;let W=await pJ(F);if(W){if(!process.env.STACKS_DEV_QUIET)console.log(`${Y.green}[ts-css]${Y.reset} CSS engine loaded from ${z.dirname(z.dirname(F))}`);return W}}return null};if(process.env.CROSSWIND_SRC){let U=z.resolve(process.env.CROSSWIND_SRC),F=await J([U]);if(!F)throw Error(`CROSSWIND_SRC did not resolve to a Css module: ${U}`);return H=F,H}let Q=await J(LQ());if(Q)return H=Q,H;let Z=BQ;for(let U of Z){let F=await pJ(U);if(F){if(H=F,!process.env.STACKS_DEV_QUIET)console.log(`${Y.green}[ts-css]${Y.reset} CSS engine loaded`);return H}}let $=await J(HQ());if($)return H=$,H;throw Error("Css CSSGenerator not found in any location")}catch{return console.warn(`${Y.yellow}[ts-css] CSS engine not available, Tailwind styles will not be generated${Y.reset}`),console.warn(`${Y.yellow}Run 'bun add @stacksjs/ts-css' to enable CSS generation${Y.reset}`),null}}function U0(){XJ.clear(),H=null,WJ=!1,L=null,T="",N.clear(),O.clear(),b=null}var mJ=!1;async function cJ(J){try{let Q=dJ({name:"css",cwd:J})?"css":dJ({name:"crosswind",cwd:J})?"crosswind":null;if(!Q)return null;if(Q==="crosswind"&&!process.env.STACKS_DEV_QUIET&&!mJ)mJ=!0,console.warn(`${Y.yellow}[ts-css]${Y.reset} Reading the CSS config from a \`crosswind\` file. Rename it to \`css\` (e.g. config/css.ts) \u2014 the old name is deprecated.`);let{loadConfigWithResult:Z}=await import("bunfig"),$=await Z({name:Q,cwd:J,defaultConfig:{},checkEnv:!1,verbose:!1});if(!$?.path||!$.config||Object.keys($.config).length===0)return null;let U=z.relative(J,$.path);if(!process.env.STACKS_DEV_QUIET)console.log(`${Y.green}[ts-css]${Y.reset} Loaded config from ${U||$.path}`);return $.config}catch(Q){if(Q instanceof Error&&Q.name==="ConfigNotFoundError")return null;return console.warn(`${Y.yellow}[ts-css]${Y.reset} Failed to load css config:`,Q instanceof Error?Q.message:Q),null}}async function OQ(J){let Q=null;try{let{loadStxConfig:Z}=await import("./chunk-8rhjt6fh.js"),$=await Z(J);if($.css)if(typeof $.css==="string"){let U=z.isAbsolute($.css)?$.css:z.resolve(J,$.css);if(await Bun.file(U).exists()){let F=await import(U);Q=F.default||F,console.log(`${Y.green}[ts-css]${Y.reset} Loaded config from stx.config.ts \u2192 ${$.css}`)}}else{if(Q={...$.css,content:$.css.content||[],preflight:$.css.preflight??!0,minify:$.css.minify??!1},$.css.config){let U=z.isAbsolute($.css.config)?$.css.config:z.resolve(J,$.css.config);if(await Bun.file(U).exists()){let F=await import(U);Q={...F.default||F,...Q}}}console.log(`${Y.green}[ts-css]${Y.reset} Using inline CSS config from stx.config.ts`)}}catch{}return Q||await cJ(J)}function KQ(J){try{let Q=new WeakSet;return y(JSON.stringify(J??{},(Z,$)=>{if(typeof $==="function")return`[fn]${String($)}`;if(typeof $==="object"&&$!==null){if(Q.has($))return"[circular]";Q.add($)}return $})??"")}catch{return"unhashable"}}async function IQ(J){if(A)return T;A=!0;try{let Q=await nJ();if(!Q||!Q.build)return A=!1,"";if(!L)L=await cJ(J);if(!L)return A=!1,"";let Z=Q.defaultConfig?.theme||{},$=L.theme||{},U={...Q.defaultConfig,...L,theme:{...Z,...$,extend:{...Z.extend||{},...$.extend||{}}}},F=performance.now(),W=await Q.build(U),j=performance.now()-F;if(T=W.css,console.log(`${Y.cyan}[ts-css]${Y.reset} Built ${W.classes.size} classes in ${j.toFixed(1)}ms`),U.output){let X=z.isAbsolute(U.output)?U.output:z.join(J,U.output),V=z.dirname(X);if(!fs.existsSync(V))fs.mkdirSync(V,{recursive:!0});await Bun.write(X,W.css)}return A=!1,W.css}catch(Q){return console.error(`${Y.red}[ts-css]${Y.reset} Build error:`,Q),A=!1,T}}async function F0(J){L=null,await IQ(J)}function W0(){return T}function DQ(J){let Q=new Set,Z=/class\s*=\s*["']([^"']+)["']/gi,$=Z.exec(J);while($!==null){for(let W of $[1].split(/\s+/))if(W.trim())Q.add(W.trim());$=Z.exec(J)}let U=/(?:x-class|:class)\s*=\s*"([^"]+)"/gi,F=U.exec(J);while(F!==null){let W=F[1].match(/'([^']+)'/g);if(W){for(let j of W)for(let X of j.slice(1,-1).split(/\s+/))if(X.trim())Q.add(X.trim())}F=U.exec(J)}return Q}var XJ=uJ(64);async function NQ(J,Q){let Z=XJ.get(UJ(J,Q,b));if(Z!==void 0)return Z;let $=await MQ(J,Q);if($)XJ.set(UJ(J,Q,b),$);return $}async function MQ(J,Q){try{let Z=await nJ();if(!Z)return"";let $=typeof Z.extractClasses==="function"?Z.extractClasses(J):DQ(J);if($.size===0)return"";let U=Q?z.resolve(Q):process.cwd();if(!M)M=iJ(U,"cache");let F=[...$].sort().join(" "),W=`${b||"default"}::${F}`,j=N.get(W);if(j!==void 0)return FJ(W,j),j;let X=await zQ(W);if(X!==null)return FJ(W,X),X;if(!L)L=await OQ(U),b=KQ(L);let V=Z.defaultConfig||Z.config,q=L||{},G=MJ(V,q),{safelist:w,includePreflight:K,minify:D,tokenCSS:jJ}=G,VJ=G.config,_=new Z.CSSGenerator(VJ);for(let B of w)_.generate(B);for(let B of $)_.generate(B);let I=_.toCSS(K,D),qJ=VJ.shortcuts||q.shortcuts||{};for(let[B,f]of Object.entries(qJ)){if(!$.has(B)&&!w.includes(B))continue;let C=f.split(/\s+/).filter(Boolean);for(let R of C)_.generate(R)}I=_.toCSS(K,D);let v=I.split(`
22
- `);for(let[B,f]of Object.entries(qJ)){if(!$.has(B)&&!w.includes(B))continue;let C=f.split(/\s+/).filter(Boolean),R=[],g=[];for(let u of C){let GJ=u.startsWith("dark:"),zJ=`.${(GJ?u.slice(5):u).replace(/\//g,"\\/").replace(/:/g,"\\:").replace(/\./g,"\\.").replace(/\[/g,"\\[").replace(/\]/g,"\\]").replace(/%/g,"\\%")}`;for(let k=0;k<v.length;k++){let YJ=v[k].trim();if(YJ===`${zJ} {`||YJ.startsWith(`${zJ} {`)){let x=k,wJ="";while(x<v.length){if(wJ+=v[x],v[x].includes("}"))break;x++}let d=wJ.match(/\{([^}]+)\}/);if(d)if(GJ)g.push(d[1].trim());else R.push(d[1].trim());break}}}if(R.length)I+=`
23
- .${B} { ${R.join(" ")} }`;if(g.length)I+=`
24
- @media (prefers-color-scheme: dark) { .dark .${B} { ${g.join(" ")} } }`}return I=jJ+I,FJ(W,I),YQ(W,I),I}catch(Z){return console.warn("Failed to generate Css CSS:",Z),""}}async function X0(J,Q,Z=!1,$=!1){let U=await NQ(J,Q);if(!U)return $?QJ(J):J;let F=Z?`<link data-css="generated" rel="stylesheet" href="/_stx/css.${GQ(U)}.css">`:`<style data-css="generated">
25
- ${U}
26
- </style>`;if($)return PQ(J,F);let W=/(?:<style\b[^>]*\bdata-css=(?:"generated"|'generated')[^>]*>[\s\S]*?<\/style>|<link\b[^>]*\bdata-css=(?:"generated"|'generated')[^>]*>)/g;if(W.test(J)){let j=!1;return J.replace(W,()=>{if(j)return"";return j=!0,F})}if(J.includes("</head>"))return J.replace("</head>",`${F}
27
- </head>`);if(J.includes("<body"))return J.replace(/<body([^>]*)>/,`<body$1>
28
- ${F}`);return F+J}function PQ(J,Q){let Z=JJ(J).map((X)=>({...X,replacement:""})),$=/(?:<style\b[^>]*\bdata-css=(?:"generated"|'generated')[^>]*>[\s\S]*?<\/style>|<link\b[^>]*\bdata-css=(?:"generated"|'generated')[^>]*>)/g,U=$.exec(J);if(U!==null){let X=!0;while(U!==null)Z.push({start:U.index,end:U.index+U[0].length,replacement:X?Q:""}),X=!1,U=$.exec(J)}else{let X=J.indexOf("</head>");if(X!==-1)Z.push({start:X,end:X,replacement:`${Q}
29
- `});else{let V=J.match(/<body([^>]*)>/);if(V?.index!==void 0)Z.push({start:V.index,end:V.index+V[0].length,replacement:`${V[0]}
30
- ${Q}`});else Z.push({start:0,end:0,replacement:Q})}}Z.sort((X,V)=>X.start-V.start||X.end-V.end);for(let X=1;X<Z.length;X++)if(Z[X].start<Z[X-1].end)return AQ(QJ(J),Q);let F=Array(Z.length*2+1),W=0,j=0;for(let X of Z)F[j++]=J.slice(W,X.start),F[j++]=X.replacement,W=X.end;return F[j]=J.slice(W),F.join("")}function AQ(J,Q){let Z=/(?:<style\b[^>]*\bdata-css=(?:"generated"|'generated')[^>]*>[\s\S]*?<\/style>|<link\b[^>]*\bdata-css=(?:"generated"|'generated')[^>]*>)/g;if(Z.test(J)){let $=!1;return J.replace(Z,()=>{if($)return"";return $=!0,Q})}if(J.includes("</head>"))return J.replace("</head>",`${Q}
31
- </head>`);if(J.includes("<body"))return J.replace(/<body([^>]*)>/,`<body$1>
32
- ${Q}`);return Q+J}
33
- export{ZJ as Cs,dQ as Ds,mQ as Es,uJ as Fs,nQ as Gs,UJ as Hs,cQ as Is,lQ as Js,o as Ks,AJ as Ls,lJ as Ms,oJ as Ns,kQ as Os,vJ as Ps,a as Qs,xQ as Rs,JQ as Ss,h as Ts,MJ as Us,JJ as Vs,QJ as Ws,CQ as Xs,Y as Ys,Z0 as Zs,nJ as _s,U0 as $s,cJ as at,OQ as bt,KQ as ct,IQ as dt,F0 as et,W0 as ft,DQ as gt,NQ as ht,X0 as it};