@serimo/player 0.0.0-stage → 0.1.0

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.
package/dist/index.js ADDED
@@ -0,0 +1,1714 @@
1
+ "use client";
2
+ import { validateComposition } from "@serimo/core/composition";
3
+ import { createTimelineRegistry } from "@serimo/core/timeline-registry";
4
+ import { createContext, createElement, forwardRef, isValidElement, useContext, useImperativeHandle, useLayoutEffect, useMemo, useRef, useState } from "react";
5
+ import { getFrameState } from "@serimo/core/clock";
6
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
7
+ //#region src/player-session.ts
8
+ function createPlayerSession(composition, registry) {
9
+ let current;
10
+ const handle = {
11
+ whenReady() {
12
+ return current?.ready ?? Promise.reject(/* @__PURE__ */ new Error("Player is not mounted"));
13
+ },
14
+ async seek(frame) {
15
+ getFrameState(composition, frame);
16
+ await handle.whenReady();
17
+ if (!current) throw new Error("Player is not mounted");
18
+ registry.seek(frame);
19
+ },
20
+ getComposition() {
21
+ const { id, width, height, fps, durationInFrames } = composition;
22
+ return {
23
+ id,
24
+ width,
25
+ height,
26
+ fps,
27
+ durationInFrames
28
+ };
29
+ }
30
+ };
31
+ return {
32
+ ...handle,
33
+ start() {
34
+ const controller = new AbortController();
35
+ const timeout = setTimeout(() => {
36
+ controller.abort(/* @__PURE__ */ new Error("Player timelines were not ready within 10000ms"));
37
+ }, 1e4);
38
+ const ready = registry.whenReady({ signal: controller.signal }).then(() => {
39
+ controller.signal.throwIfAborted();
40
+ registry.seek(0);
41
+ }).finally(() => clearTimeout(timeout));
42
+ current = {
43
+ controller,
44
+ ready
45
+ };
46
+ return ready;
47
+ },
48
+ stop() {
49
+ current?.controller.abort(new DOMException("Player unmounted", "AbortError"));
50
+ current = void 0;
51
+ }
52
+ };
53
+ }
54
+ //#endregion
55
+ //#region ../../node_modules/clsx/dist/clsx.mjs
56
+ function r(e) {
57
+ var t, f, n = "";
58
+ if ("string" == typeof e || "number" == typeof e) n += e;
59
+ else if ("object" == typeof e) if (Array.isArray(e)) {
60
+ var o = e.length;
61
+ for (t = 0; t < o; t++) e[t] && (f = r(e[t])) && (n && (n += " "), n += f);
62
+ } else for (f in e) e[f] && (n && (n += " "), n += f);
63
+ return n;
64
+ }
65
+ function clsx() {
66
+ for (var e, t, f = 0, n = "", o = arguments.length; f < o; f++) (e = arguments[f]) && (t = r(e)) && (n && (n += " "), n += t);
67
+ return n;
68
+ }
69
+ //#endregion
70
+ //#region ../../node_modules/class-variance-authority/dist/index.mjs
71
+ /**
72
+ * Copyright 2022 Joe Bell. All rights reserved.
73
+ *
74
+ * This file is licensed to you under the Apache License, Version 2.0
75
+ * (the "License"); you may not use this file except in compliance with the
76
+ * License. You may obtain a copy of the License at
77
+ *
78
+ * http://www.apache.org/licenses/LICENSE-2.0
79
+ *
80
+ * Unless required by applicable law or agreed to in writing, software
81
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
82
+ * WARRANTIES OR REPRESENTATIONS OF ANY KIND, either express or implied. See the
83
+ * License for the specific language governing permissions and limitations under
84
+ * the License.
85
+ */ const falsyToString = (value) => typeof value === "boolean" ? `${value}` : value === 0 ? "0" : value;
86
+ const cx = clsx;
87
+ const cva = (base, config) => (props) => {
88
+ var _config_compoundVariants;
89
+ if ((config === null || config === void 0 ? void 0 : config.variants) == null) return cx(base, props === null || props === void 0 ? void 0 : props.class, props === null || props === void 0 ? void 0 : props.className);
90
+ const { variants, defaultVariants } = config;
91
+ const getVariantClassNames = Object.keys(variants).map((variant) => {
92
+ const variantProp = props === null || props === void 0 ? void 0 : props[variant];
93
+ const defaultVariantProp = defaultVariants === null || defaultVariants === void 0 ? void 0 : defaultVariants[variant];
94
+ if (variantProp === null) return null;
95
+ const variantKey = falsyToString(variantProp) || falsyToString(defaultVariantProp);
96
+ return variants[variant][variantKey];
97
+ });
98
+ const propsWithoutUndefined = props && Object.entries(props).reduce((acc, param) => {
99
+ let [key, value] = param;
100
+ if (value === void 0) return acc;
101
+ acc[key] = value;
102
+ return acc;
103
+ }, {});
104
+ const getCompoundVariantClassNames = config === null || config === void 0 ? void 0 : (_config_compoundVariants = config.compoundVariants) === null || _config_compoundVariants === void 0 ? void 0 : _config_compoundVariants.reduce((acc, param) => {
105
+ let { class: cvClass, className: cvClassName, ...compoundVariantOptions } = param;
106
+ return Object.entries(compoundVariantOptions).every((param) => {
107
+ let [key, value] = param;
108
+ return Array.isArray(value) ? value.includes({
109
+ ...defaultVariants,
110
+ ...propsWithoutUndefined
111
+ }[key]) : {
112
+ ...defaultVariants,
113
+ ...propsWithoutUndefined
114
+ }[key] === value;
115
+ }) ? [
116
+ ...acc,
117
+ cvClass,
118
+ cvClassName
119
+ ] : acc;
120
+ }, []);
121
+ return cx(base, getVariantClassNames, getCompoundVariantClassNames, props === null || props === void 0 ? void 0 : props.class, props === null || props === void 0 ? void 0 : props.className);
122
+ };
123
+ //#endregion
124
+ //#region ../../node_modules/cn/dist/tables.js
125
+ const P = 48;
126
+ const U = (s, o = 0) => {
127
+ const out = new Int32Array(s.length);
128
+ for (let i = 0; i < s.length; i++) out[i] = s.charCodeAt(i) - P - o;
129
+ return out;
130
+ };
131
+ const PS = (counts) => {
132
+ const out = new Int32Array(counts.length + 1);
133
+ for (let i = 0; i < counts.length; i++) out[i + 1] = out[i] + counts[i];
134
+ return out;
135
+ };
136
+ const DZ = (s) => {
137
+ const out = new Int32Array(s.length);
138
+ let a = 0;
139
+ for (let i = 0; i < s.length; i++) {
140
+ const z = s.charCodeAt(i) - P;
141
+ a += z >>> 1 ^ -(z & 1);
142
+ out[i] = a;
143
+ }
144
+ return out;
145
+ };
146
+ const GROUP_COUNT = 384;
147
+ const customValidatorNames = [];
148
+ const edgeStart = PS(U("E0500002005282000000002000150000020021820000011200000003022202000300004200120000200420001200021200301200010400162000010000220021010:2192001200220012000220012000200200200400010200040000000000400200108200110100000022010313000162002000020020012020080213000228200000000082000000000120002000120020020040101020300130001001010"));
149
+ const labelStart = PS(U(":11111111211111119311546544411119731869:671397415686432441111111111161114151214313433415:78311132233313187211117221449443411141111151152226611131111112212518142224214215421421542142424242516171151615616347111111111197911327451111111111111111111113134714133513411111311111111111111111111112444411111342312715245411117:3"));
150
+ const labelText = "@containerabcdefghinlmoprstunderlineviawzccentlignnimatespectuto-colsrowsaglorightnessckdrop-sisbcontrastfiltergrayscalehue-rotateinvertopacityslurrightnessaturateepia-coniclinearpositionradialsizeockurrderttom-belrstxyespacing-xyaretoursorlnt-umnsendspantartainentrasteividerop-shadowurationcorationlay-xyasendillexontromlter-featuresstretchapr-xyayscaleidow-colsrowsue-rotatedentlinesetvert-beringsxyeshadoweiadingftnest-clamp-imageabein-lrstxyskx--b-coniclpositionrsizet-x-y-fromto-fromto-inearfromto-fromto-adialfromto-fromtofromtofromtofromtoblockhinlinew-screenesblockhinlinewbjectpacityrutlinederigin-offsetbelrstxyesrspective-originaceholderioghtng-offsettateundedw-xyz-belrstlreseslr-endspantartaturatecepiahizekewpace-taleroll-xyz-barmpbelrstxyesbelrstxyes-thumbrackadowrink-xyxyartrokeabextora-shadowpckingnsformitionlate-xyz-offsetill-changeoom";
151
+ const edgeTarget = (() => {
152
+ const N = edgeStart.length - 1;
153
+ const sizes = new Int32Array(N);
154
+ for (let i = N - 1; i >= 0; i--) {
155
+ let s = 1;
156
+ let c = i + 1;
157
+ for (let k = edgeStart[i]; k < edgeStart[i + 1]; k++) {
158
+ s += sizes[c];
159
+ c += sizes[c];
160
+ }
161
+ sizes[i] = s;
162
+ }
163
+ const out = new Int32Array(edgeStart[N]);
164
+ let e = 0;
165
+ for (let i = 0; i < N; i++) {
166
+ let c = i + 1;
167
+ for (let k = edgeStart[i]; k < edgeStart[i + 1]; k++) {
168
+ out[e++] = c;
169
+ c += sizes[c];
170
+ }
171
+ }
172
+ return out;
173
+ })();
174
+ const nodeGroup = U("02000000000000900<=0?000B000F00F00ŏI0J0LNPRTVX0000]_a00000000000000000000000rst0000000zŏ00000000000…ŏ000ˆ0000ŏ0000000000—0000000000000000000000000000000000000000000000000000Ë000000000000000000000Þ000000000000000000ð0000000ø0ùúûüýþÿĀāĂ㥹Ć000000000000000000000000000000000000000000ħ0ĨĪ00000000000000000000ļĽ00000Ŭ000000", 1);
175
+ const vlistPat = PS(U("123333359346463635126536711576"));
176
+ const vlistOps = U("93203242332583253248325D>E?F@03263243255B:032523853:0325B:8GA032542H<C=12727B:0328432553;D>E?3257D>032585:0325B:;0328B:032");
177
+ const vlistRef = U("012113445661666666789111:5;;;;;;;;444;;;:62999<1161=62>>?61:21@ABCD4446996:64E:::;:?::64:F114GHHIHHHHIHH1HH1HH1HHHHHH::EEJ4444::EE4444441691;644444114244444:;K6666555555555555555999666664444444444444444444444226?6:66644L9M?D:111::::6DE199");
178
+ const vlistGroup = DZ("020200202020020020020020020020200200200200200200200002020202001003040106000200200200200200200200200200200200200200200200200200200200200200200200200200200200020020020020020020002020200202002002002002002002002002002020002002020020200220200200200200200200200200200200020020020000200020002000200200200020020020002000200200200020020202002020202000200200020022000200200020020002002000200220002002000200W0Z00020020002002020002002000200g0j0002002000200200020020002002000200200020020002000200002000002002002002002000200020000200002002002002002002002020020020200200200200200200200200202020020020020020020020020002002002020020020020020020020020020020020020020020020020020020020020020020020020020020020020020020020020020020020020020020020020020020020020020020020020020020020020020020020020020002002002002002002000200200200200200200200200200020202020002000200020002002002002000020200200");
179
+ const nodeVlist = (() => {
180
+ const out = (/* @__PURE__ */ new Int32Array(319)).fill(-1);
181
+ const A = DZ("02422242:222222242224222242442222222422222244442242226224222426222422442462222422622222222626222462242622422622422424242422222222422222222242422222222222222222622442224222222222222224424442262222222222222222222226224222424242422224422422422222");
182
+ const V = DZ("02222222222222222222202222222222222222222222221422222222222222222222222222222222222Y\\222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222221422222222222222222222222222222222222222Ŀł222222222222222222");
183
+ for (let i = 0; i < A.length; i++) out[A[i]] = V[i];
184
+ return out;
185
+ })();
186
+ const SETS = "container |break-after- all auto avoid avoid-page column left page right|break-before- all auto avoid avoid-page column left page right|break-inside-a uto void void-column void-page|box-decoration- clone slice|box- border content| contents flow-root hidden table table-caption table-cell table-column table-column-group table-footer-group table-header-group table-row table-row-group| not-sr-only sr-only|float- end left none right start|clear- both end left none right start|isolat e ion-auto|overflow- auto clip hidden scroll visible|overflow-x- auto clip hidden scroll visible|overflow-y- auto clip hidden scroll visible|overscroll- auto contain none|overscroll-x- auto contain none|overscroll-y- auto contain none| absolute fixed relative static sticky| collapse invisible visible|justify- around baseline between center center-safe end end-safe evenly normal start stretch|justify-items- center center-safe end end-safe normal start stretch|justify-self- auto center center-safe end end-safe start stretch|items- baseline baseline-last center center-safe end end-safe start stretch|self- auto baseline baseline-last center center-safe end end-safe start stretch|place-content- around baseline between center center-safe end end-safe evenly start stretch|place-items- baseline center center-safe end end-safe start stretch|place-self- auto center center-safe end end-safe start stretch| antialiased subpixel-antialiased| italic not-italic|normal-nums |ordinal |slashed-zero | lining-nums oldstyle-nums| proportional-nums tabular-nums| diagonal-fractions stacked-fractions| no-underline overline| capitalize lowercase normal-case uppercase|truncate |whitespace- break-spaces normal nowrap pre pre-line pre-wrap|break- all keep normal words|wrap- anywhere break-word normal|hyphens- auto manual none|mix-blend- color color-burn color-dodge darken difference exclusion hard-light hue lighten luminosity multiply normal overlay plus-darker plus-lighter saturation screen soft-light|table- auto fixed|caption- bottom top|backface- hidden visible|appearance- auto none|scheme- dark light light-dark normal only-dark only-light|field-sizing- content fixed|pointer-events- auto none|resize -none -x -y|snap- align-none center end start|snap- always normal|snap- both none x y|snap- mandatory proximity|touch- auto manipulation none|touch-pan- left right x|touch-pan- down up y|touch-pinch-zoom |select- all auto none text|forced-color-adjust- auto none| normal size| baseline bottom middle sub super text-bottom text-top top| bounce none ping pulse spin| auto square video| auto fr max min px|none | auto full px| fixed local scroll|clip- border content padding text|origin- border content padding| bottom bottom-left bottom-right center left left-bottom left-top right right-bottom right-top top top-left top-right| no-repeat repeat repeat-round repeat-space repeat-x repeat-y| auto contain cover| gradient-to-b gradient-to-bl gradient-to-br gradient-to-l gradient-to-r gradient-to-t gradient-to-tl gradient-to-tr none|blend- color color-burn color-dodge darken difference exclusion hard-light hue lighten luminosity multiply normal overlay saturation screen soft-light|to- b bl br l r t tl tr| auto dvh fit full lh lvh max min px screen svh| dashed dotted double hidden none solid| collapse separate|px |auto |full | content none strict| inline-size size|layout |paint |style | around baseline between center center-safe end end-safe evenly normal start stretch| alias all-scroll auto cell col-resize context-menu copy crosshair default e-resize ew-resize grab grabbing help move n-resize ne-resize nesw-resize no-drop none not-allowed ns-resize nw-resize nwse-resize pointer progress row-resize s-resize se-resize sw-resize text vertical-text w-resize wait zoom-in zoom-out| dashed dotted double solid wavy| auto from-font|reverse |initial | in in-out initial linear out| col col-reverse row row-reverse| nowrap wrap wrap-reverse| auto initial none| black bold extrabold extralight light medium normal semibold thin| condensed expanded extra-condensed extra-expanded normal semi-condensed semi-expanded ultra-condensed ultra-expanded|flow- col col-dense dense row row-dense| none subgrid| auto dvh dvw fit full lh lvh lvw max min px screen svh svw| block flex grid table| auto dvw fit full lvw max min px screen svw| loose none normal px relaxed snug tight|through |item | inside outside| decimal disc none| auto px| clip-border clip-content clip-fill clip-padding clip-stroke clip-view no-clip| add exclude intersect subtract| alpha luminance match|origin- border content fill padding stroke view|type- alpha luminance| circle ellipse| closest-corner closest-side farthest-corner farthest-side|at- bottom bottom-left bottom-right center left left-bottom left-top right right-bottom right-top top top-left top-right| dvh fit full lh lvh max min none px screen svh| auto dvh dvw fit full lh lvh lvw max min none px screen svh svw| dvw fit full lvw max min none px screen svw| auto dvh dvw fit full lvh lvw max min none prose px svh svw| auto dvh dvw fit full lvh lvw max min none px screen svh svw| contain cover fill none scale-down| first last none| distant dramatic midrange near none normal|inset | full none|3d | auto smooth|gutter- auto both stable| auto none thin| inner none| auto dvh dvw fit full lvh lvw max min px svh svw|base | center end justify left right start| clip ellipsis| balance nowrap pretty wrap| normal tight tighter wide wider widest| cpu gpu none| 3d flat| all colors none opacity shadow transform| discrete normal| full px| auto dvh dvw fit full lvh lvw max min px screen svh svw| auto contents scroll transform".split("|").map((s) => {
187
+ const tails = s.split(" ");
188
+ const prefix = tails.shift();
189
+ for (let i = 0; i < tails.length; i++) tails[i] = prefix + tails[i];
190
+ return tails;
191
+ });
192
+ const AA = DZ("0000000000000000000000000000000000000000000000000000000000000262242:6@200000006:240B428:4422400002046044222426220026642642462026224222824220022400000000\\00N222422242222222224062242222222422226264222422222222222222442804222422222222222222222222220<4<0204260002444020204224422");
193
+ const AG = DZ("ɠ222222222222222222222222222222222222222222222222222222222222˕4222226>ʶ22ʷʺʷ2ʸʷ42ʴ2ʓ22>621422ɶ222ɹɼɷɺɷɺ22ɱ42222ɨ2ɧ26622ɘɓ244ƸƵ222]d24242ǖǓƚÄȫ2263ȨȥȨ2222222ǣ222222222222222222ǂƽ2ƾƵ2222222422222ƜƑ22222222222222222222144Ŧţ22Ţş222222222222222222222ĸ2ı68ĦģĦɡŰ4Ġ«®ĝ822ĔđĔ2ē2222622");
194
+ const AS = DZ("02222222222222222222222222222222222222222222222222222222222222222202022222222222EH2200IL021042222Y\\222IL0cf2e10j2222U00X202[^2y0000120|{~‚22…ˆ‡:22|22222222222G000q†OVI00000}š2›>40000ŒB00000I¨©000¬00000000000000021M®­00°“000000000000000000000–222›HGHa1º222¿2À2222ÉÌ000­°2±");
195
+ const litAnchor = /* @__PURE__ */ new Int32Array(995);
196
+ const litGroup = /* @__PURE__ */ new Int32Array(995);
197
+ const litPool = /* @__PURE__ */ new Int32Array(995);
198
+ let poolText = "";
199
+ const poolOffsets = /* @__PURE__ */ new Int32Array(1038);
200
+ {
201
+ const tailRef = /* @__PURE__ */ new Map();
202
+ let nextRef = 0;
203
+ let e = 0;
204
+ for (let i = 0; i < AA.length; i++) for (const tail of SETS[AS[i]]) {
205
+ let r = tailRef.get(tail);
206
+ if (r === void 0) {
207
+ r = nextRef++;
208
+ tailRef.set(tail, r);
209
+ poolOffsets[r * 2] = poolText.length;
210
+ poolOffsets[r * 2 + 1] = tail.length;
211
+ poolText += tail;
212
+ }
213
+ litAnchor[e] = AA[i];
214
+ litGroup[e] = AG[i];
215
+ litPool[e] = r;
216
+ e++;
217
+ }
218
+ }
219
+ const adjGid = DZ("0b2N:222@R>F@286¦2@H2D266226FB22B2>BD\\6N22222Z222D222p");
220
+ const adjStart = PS(U("1::24444432:442:44:44>222222:44:4421322511111311111114"));
221
+ const adjTgt = DZ("2Š4A;33N=C@H4A;33N=C@<27;83:;8393NQ:3NQʰ222ˉºŴŽ2R2=18cƴÅҜ=cĞÛC1ƈǝȈ:ħ25=11D3A@4=<1;1DEr25;11B3?<6;:371BCn9@7=<8192>2E121@9@EHE@9>2T25511<398454131<=V25511<398454131<=„ƧNž2Đå242L222290000f22500ɛ000ǘ222");
222
+ const patGid = U("ij");
223
+ const patTgt = U("—");
224
+ const postfixLookupGroups = U("1");
225
+ var tables_generated_default = {
226
+ GROUP_COUNT,
227
+ customValidatorNames,
228
+ edgeStart,
229
+ labelStart,
230
+ labelText,
231
+ edgeTarget,
232
+ nodeGroup,
233
+ nodeVlist,
234
+ vlistPat,
235
+ vlistOps,
236
+ vlistRef,
237
+ vlistGroup,
238
+ litAnchor,
239
+ litGroup,
240
+ litPool,
241
+ poolOffsets,
242
+ poolText,
243
+ adjGid,
244
+ adjStart,
245
+ adjTgt,
246
+ patGid,
247
+ patTgt,
248
+ postfixLookupGroups,
249
+ orderSensitiveModifiers: "* ** after backdrop before details-content file first-letter first-line marker placeholder selection"
250
+ };
251
+ //#endregion
252
+ //#region ../../node_modules/cn/dist/engine.js
253
+ const IS_JSC = "line" in /* @__PURE__ */ new Error();
254
+ const EXTERNAL = -1;
255
+ const DEAD = -1;
256
+ const fnv = (str, s, e) => {
257
+ let h = 2166136261;
258
+ for (let p = s; p < e; p++) h = Math.imul(h ^ str.charCodeAt(p), 16777619);
259
+ return h;
260
+ };
261
+ const spanHash = (str, s, e) => {
262
+ const len = e - s;
263
+ let h = Math.imul(len, 2654435761) ^ str.charCodeAt(s);
264
+ if (len > 3) {
265
+ const q = len >> 2;
266
+ const m = len >> 1;
267
+ h = Math.imul(h ^ str.charCodeAt(s + 1) << 8 ^ str.charCodeAt(s + 2) << 16 ^ str.charCodeAt(s + q), 2246822507);
268
+ h = Math.imul(h ^ str.charCodeAt(s + m) << 8 ^ str.charCodeAt(s + m + q) << 16 ^ str.charCodeAt(e - 3), 3266489909);
269
+ h ^= str.charCodeAt(e - 2) << 8 ^ str.charCodeAt(e - 1) << 16;
270
+ for (let p = s + 3, q = e - 4; p < s + 8 && p < q; p++, q--) h = Math.imul(h ^ str.charCodeAt(p) ^ str.charCodeAt(q) << 8, 16777619);
271
+ }
272
+ return h ^ h >>> 15 | 0;
273
+ };
274
+ const createEngine = (T, validatorImpls, options = {}) => {
275
+ const { GROUP_COUNT, edgeStart, labelStart, labelText, edgeTarget, nodeGroup, nodeVlist, vlistPat, vlistOps, vlistRef, vlistGroup, litAnchor, litGroup, litPool, poolOffsets, poolText, adjGid, adjStart, adjTgt, patGid, patTgt, postfixLookupGroups, customValidatorNames, orderSensitiveModifiers } = T;
276
+ const adjRow = new Int32Array(GROUP_COUNT).fill(-1);
277
+ for (let i = 0; i < adjGid.length; i++) adjRow[adjGid[i]] = i;
278
+ let maxAdj = 0;
279
+ for (let r = 0; r + 1 < adjStart.length; r++) {
280
+ const n = adjStart[r + 1] - adjStart[r];
281
+ if (n > maxAdj) maxAdj = n;
282
+ }
283
+ let CLAIM_PER_TOKEN = 32;
284
+ while (CLAIM_PER_TOKEN < 2 * (1 + maxAdj + patGid.length)) CLAIM_PER_TOKEN <<= 1;
285
+ const vgStart = new Int32Array(vlistRef.length + 1);
286
+ for (let l = 0; l < vlistRef.length; l++) vgStart[l + 1] = vgStart[l] + vlistPat[vlistRef[l] + 1] - vlistPat[vlistRef[l]];
287
+ const postfixLookupSet = new Uint8Array(GROUP_COUNT);
288
+ for (let i = 0; i < postfixLookupGroups.length; i++) postfixLookupSet[postfixLookupGroups[i]] = 1;
289
+ const nodeCount = edgeStart.length - 1;
290
+ const nodeHasLit = new Uint8Array(nodeCount);
291
+ let litMaxLen = 0;
292
+ let litNoArb = true;
293
+ for (let i = 0; i < litAnchor.length; i++) {
294
+ nodeHasLit[litAnchor[i]] = 1;
295
+ const len = poolOffsets[litPool[i] * 2 + 1];
296
+ if (len > litMaxLen) litMaxLen = len;
297
+ const c0 = poolText.charCodeAt(poolOffsets[litPool[i] * 2]);
298
+ if (c0 === 91 || c0 === 40) litNoArb = false;
299
+ }
300
+ let LIT_SIZE = 1;
301
+ while (LIT_SIZE < litAnchor.length * 2) LIT_SIZE <<= 1;
302
+ const litTable = new Int32Array(LIT_SIZE).fill(-1);
303
+ for (let i = 0; i < litAnchor.length; i++) {
304
+ const off = poolOffsets[litPool[i] * 2];
305
+ let idx = (fnv(poolText, off, off + poolOffsets[litPool[i] * 2 + 1]) ^ Math.imul(litAnchor[i], 2654435761) | 0) & LIT_SIZE - 1;
306
+ while (litTable[idx] !== -1) idx = idx + 1 & LIT_SIZE - 1;
307
+ litTable[idx] = i;
308
+ }
309
+ const litProbe = (anchor, input, s, e) => {
310
+ let idx = (fnv(input, s, e) ^ Math.imul(anchor, 2654435761) | 0) & LIT_SIZE - 1;
311
+ const len = e - s;
312
+ for (;;) {
313
+ const entry = litTable[idx];
314
+ if (entry === -1) return -1;
315
+ if (litAnchor[entry] === anchor && poolOffsets[litPool[entry] * 2 + 1] === len) {
316
+ const off = poolOffsets[litPool[entry] * 2];
317
+ let ok = true;
318
+ for (let k = 0; k < len; k++) if (poolText.charCodeAt(off + k) !== input.charCodeAt(s + k)) {
319
+ ok = false;
320
+ break;
321
+ }
322
+ if (ok) return litGroup[entry];
323
+ }
324
+ idx = idx + 1 & LIT_SIZE - 1;
325
+ }
326
+ };
327
+ const cacheSize = options.cacheSize ?? 8192;
328
+ const RAW_PREFIX = options.prefix ?? T.prefix ?? "";
329
+ const FULL_PREFIX = RAW_PREFIX === "" ? "" : RAW_PREFIX + ":";
330
+ const FPL = FULL_PREFIX.length;
331
+ const vCustom = (customValidatorNames ?? []).map((name) => {
332
+ const fn = validatorImpls && validatorImpls[name];
333
+ if (!fn) throw new Error("cn: missing validator " + name);
334
+ return fn;
335
+ });
336
+ const lengthUnitRegex = /\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/;
337
+ const colorFunctionRegex = /^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/;
338
+ const shadowRegex = /^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/;
339
+ const imageRegex = /^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/;
340
+ let aKind = 0;
341
+ let aLabelS = -1;
342
+ let aLabelE = -1;
343
+ let aValS = -1;
344
+ let aValE = -1;
345
+ const isWordCode = (c) => c >= 97 && c <= 122 || c >= 65 && c <= 90 || c >= 48 && c <= 57 || c === 95;
346
+ const isUniWS = (c) => /\s/.test(String.fromCharCode(c));
347
+ const analyzeArb = (input, s, e) => {
348
+ aKind = 0;
349
+ aLabelS = -1;
350
+ if (e - s < 3) return;
351
+ const c0 = input.charCodeAt(s);
352
+ const cl = input.charCodeAt(e - 1);
353
+ if (c0 === 91 && cl === 93) aKind = 1;
354
+ else if (c0 === 40 && cl === 41) aKind = 2;
355
+ else return;
356
+ aValS = s + 1;
357
+ aValE = e - 1;
358
+ let p = s + 1;
359
+ if (isWordCode(input.charCodeAt(p))) {
360
+ p++;
361
+ while (p < e - 1) {
362
+ const c = input.charCodeAt(p);
363
+ if (!isWordCode(c) && c !== 45) break;
364
+ p++;
365
+ }
366
+ if (p < e - 2 && input.charCodeAt(p) === 58) {
367
+ aLabelS = s + 1;
368
+ aLabelE = p;
369
+ aValS = p + 1;
370
+ }
371
+ }
372
+ };
373
+ const spanEq = (input, s, e, str) => {
374
+ if (e - s !== str.length) return false;
375
+ for (let i = 0; i < str.length; i++) if (input.charCodeAt(s + i) !== str.charCodeAt(i)) return false;
376
+ return true;
377
+ };
378
+ const fractionRegex = /^\d+(?:\.\d+)?\/\d+(?:\.\d+)?$/;
379
+ const tshirtRegex = /^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/;
380
+ const isNumStr = (v) => !!v && !Number.isNaN(Number(v));
381
+ const spanIsNamedContainerQuery = (input, s, e) => {
382
+ if (e - s < 11 || !spanEq(input, s, s + 10, "@container")) return false;
383
+ if (input.charCodeAt(s + 10) === 47) return e - s >= 12;
384
+ const c11 = input.charCodeAt(s + 11);
385
+ return c11 === 115 && e - s >= 17 && spanEq(input, s + 10, s + 16, "-size/") || c11 === 110 && e - s >= 19 && spanEq(input, s + 10, s + 18, "-normal/");
386
+ };
387
+ const VKIND = [
388
+ 1,
389
+ 1,
390
+ 1,
391
+ 1,
392
+ 1,
393
+ 1,
394
+ 1,
395
+ 1,
396
+ 2,
397
+ 2,
398
+ 2,
399
+ 2,
400
+ 2,
401
+ 2,
402
+ 2
403
+ ];
404
+ const VLABELS = "length|number|number weight|family-name|position percentage|length size bg-size|image url|shadow|length|family-name|position percentage|length size bg-size|image url|shadow|number weight".split("|").map((s) => s.split(" "));
405
+ const VFALL = [
406
+ 2,
407
+ 3,
408
+ 1,
409
+ 0,
410
+ 0,
411
+ 0,
412
+ 4,
413
+ 5,
414
+ 0,
415
+ 0,
416
+ 0,
417
+ 0,
418
+ 0,
419
+ 1,
420
+ 1
421
+ ];
422
+ const runValidator = (op, input, s, e) => {
423
+ if (op >= 10) {
424
+ if (op >= 25) return vCustom[op - 25](input.slice(s, e));
425
+ const i = op - 10;
426
+ if (aKind !== VKIND[i]) return false;
427
+ if (aLabelS >= 0) {
428
+ for (const L of VLABELS[i]) if (spanEq(input, aLabelS, aLabelE, L)) return true;
429
+ return false;
430
+ }
431
+ switch (VFALL[i]) {
432
+ case 0: return false;
433
+ case 1: return true;
434
+ case 2: {
435
+ const v = input.slice(aValS, aValE);
436
+ return lengthUnitRegex.test(v) && !colorFunctionRegex.test(v);
437
+ }
438
+ case 3: return isNumStr(input.slice(aValS, aValE));
439
+ case 4: return imageRegex.test(input.slice(aValS, aValE));
440
+ default: return shadowRegex.test(input.slice(aValS, aValE));
441
+ }
442
+ }
443
+ switch (op) {
444
+ case 0: return true;
445
+ case 1: return aKind === 0;
446
+ case 2: return aKind === 1;
447
+ case 3: return aKind === 2;
448
+ case 4: return fractionRegex.test(input.slice(s, e));
449
+ case 5: return isNumStr(input.slice(s, e));
450
+ case 6: {
451
+ const v = input.slice(s, e);
452
+ return !!v && Number.isInteger(Number(v));
453
+ }
454
+ case 7: return e > s && input.charCodeAt(e - 1) === 37 && isNumStr(input.slice(s, e - 1));
455
+ case 8: return tshirtRegex.test(input.slice(s, e));
456
+ default: return spanIsNamedContainerQuery(input, s, e);
457
+ }
458
+ };
459
+ const orderSensitive = new Set(typeof orderSensitiveModifiers === "string" ? orderSensitiveModifiers.split(" ") : orderSensitiveModifiers);
460
+ const internSpan = (map, input, s, e, imp, make) => {
461
+ const h = fnv(input, s, e) ^ (imp ? 2654435769 : 0) | 0;
462
+ let bucket = map.get(h);
463
+ if (bucket !== void 0) outer: for (let b = 0; b < bucket.length; b++) {
464
+ const en = bucket[b];
465
+ if (en.imp !== imp || en.k.length !== e - s) continue;
466
+ for (let i = 0; i < en.k.length; i++) if (en.k.charCodeAt(i) !== input.charCodeAt(s + i)) continue outer;
467
+ return en.id;
468
+ }
469
+ else map.set(h, bucket = []);
470
+ const k = input.slice(s, e);
471
+ const id = make(k);
472
+ bucket.push({
473
+ k,
474
+ imp,
475
+ id
476
+ });
477
+ return id;
478
+ };
479
+ let ctxByHash = /* @__PURE__ */ new Map();
480
+ let ctxByCanon = /* @__PURE__ */ new Map();
481
+ let nextCtxId = 2;
482
+ const MAX_CTX = 4096;
483
+ const canonicalizeContext = (raw, important) => {
484
+ const mods = [];
485
+ let dB = 0, dP = 0, start = 0;
486
+ for (let i = 0; i < raw.length; i++) {
487
+ const c = raw.charCodeAt(i);
488
+ if (dB === 0 && dP === 0 && c === 58) {
489
+ mods.push(raw.slice(start, i));
490
+ start = i + 1;
491
+ } else if (c === 91) dB++;
492
+ else if (c === 93) dB--;
493
+ else if (c === 40) dP++;
494
+ else if (c === 41) dP--;
495
+ }
496
+ mods.push(raw.slice(start));
497
+ let canonical = mods[0];
498
+ if (mods.length > 1) {
499
+ const result = [];
500
+ let segment = [];
501
+ for (const mod of mods) if (mod.charCodeAt(0) === 91 || orderSensitive.has(mod)) {
502
+ if (segment.length) {
503
+ result.push(...segment.sort());
504
+ segment = [];
505
+ }
506
+ result.push(mod);
507
+ } else segment.push(mod);
508
+ if (segment.length) result.push(...segment.sort());
509
+ canonical = result.join(":");
510
+ }
511
+ const key = important ? canonical + " !" : canonical;
512
+ let id = ctxByCanon.get(key);
513
+ if (id === void 0) ctxByCanon.set(key, id = nextCtxId++);
514
+ return id;
515
+ };
516
+ let dynByHash = /* @__PURE__ */ new Map();
517
+ let nextDynId = GROUP_COUNT;
518
+ const MAX_DYN = GROUP_COUNT + 4096;
519
+ const newDynId = () => nextDynId++;
520
+ const ID_LIMIT = 2097152;
521
+ const TOKEN_TABLE = 8192;
522
+ const memoHash = new Int32Array(TOKEN_TABLE);
523
+ const memoStr = new Array(TOKEN_TABLE).fill(null);
524
+ const memoGid = new Int32Array(TOKEN_TABLE);
525
+ const memoCtx = new Int32Array(TOKEN_TABLE);
526
+ const memoFlags = new Uint8Array(TOKEN_TABLE);
527
+ let memoTick = 0;
528
+ const memoPut = (way0, input, ts, te, h, gid, ctxId, flags) => {
529
+ let slot = way0;
530
+ if (memoStr[way0] !== null) {
531
+ if (memoStr[way0 | 1] === null) slot = way0 | 1;
532
+ else if ((memoTick++ & 3) === 0) slot = way0 | memoTick >> 2 & 1;
533
+ else return;
534
+ }
535
+ memoStr[slot] = input.slice(ts, te);
536
+ memoHash[slot] = h;
537
+ memoGid[slot] = gid;
538
+ memoCtx[slot] = ctxId;
539
+ memoFlags[slot] = flags;
540
+ };
541
+ const memoReset = () => memoStr.fill(null);
542
+ let cap = 256;
543
+ let tokI32 = [
544
+ new Int32Array(cap),
545
+ new Int32Array(cap),
546
+ new Int32Array(cap),
547
+ new Int32Array(cap)
548
+ ];
549
+ let [tokStart, tokEnd, tokGid, tokCtx] = tokI32;
550
+ let tokFlags = new Uint8Array(cap);
551
+ let keep = new Uint8Array(cap);
552
+ const growTokens = () => {
553
+ cap *= 2;
554
+ tokI32 = tokI32.map((a) => {
555
+ const n = new Int32Array(cap);
556
+ n.set(a);
557
+ return n;
558
+ });
559
+ [tokStart, tokEnd, tokGid, tokCtx] = tokI32;
560
+ const nf = new Uint8Array(cap);
561
+ nf.set(tokFlags);
562
+ tokFlags = nf;
563
+ keep = new Uint8Array(cap);
564
+ };
565
+ let ckptCap = 64;
566
+ let ckptNode = new Int32Array(ckptCap);
567
+ let ckptTail = new Int32Array(ckptCap);
568
+ const claim0 = new Int32Array(GROUP_COUNT);
569
+ let CLAIM_TABLE = 2048;
570
+ let claimShift = 21;
571
+ let claimKeys = new Float64Array(CLAIM_TABLE);
572
+ let claimEpochs = new Int32Array(CLAIM_TABLE);
573
+ let epoch = 0;
574
+ const claimTest = (ctx, gid) => {
575
+ if (ctx === 0 && gid < GROUP_COUNT) {
576
+ if (claim0[gid] === epoch) return 1;
577
+ claim0[gid] = epoch;
578
+ return 0;
579
+ }
580
+ const key = ctx * 2097152 + gid + 1;
581
+ let idx = Math.imul(key, 2654435761) >>> claimShift;
582
+ for (;;) {
583
+ if (claimEpochs[idx] !== epoch) break;
584
+ if (claimKeys[idx] === key) return 1;
585
+ idx = idx + 1 & CLAIM_TABLE - 1;
586
+ }
587
+ claimKeys[idx] = key;
588
+ claimEpochs[idx] = epoch;
589
+ return 0;
590
+ };
591
+ const resolveAt = (input, bs, endPos, nodeAt, ckptAt) => {
592
+ if (endPos - bs >= 2 && input.charCodeAt(bs) === 91 && input.charCodeAt(endPos - 1) === 93) {
593
+ let colon = -1;
594
+ for (let p = bs + 1; p < endPos - 1; p++) if (input.charCodeAt(p) === 58) {
595
+ colon = p;
596
+ break;
597
+ }
598
+ if (colon === -1 || colon === bs + 1) return EXTERNAL;
599
+ return internSpan(dynByHash, input, bs + 1, colon, 0, newDynId);
600
+ }
601
+ if (nodeAt >= 0 && nodeGroup[nodeAt] >= 0) return nodeGroup[nodeAt];
602
+ for (let k = ckptAt - 1; k >= 0; k--) {
603
+ const tailStart = ckptTail[k];
604
+ if (tailStart > endPos) continue;
605
+ const nodeId = ckptNode[k];
606
+ const tlen = endPos - tailStart;
607
+ if (nodeHasLit[nodeId] === 1 && tlen > 0 && tlen <= litMaxLen) {
608
+ const c0 = input.charCodeAt(tailStart);
609
+ if (litNoArb === false || c0 !== 91 && c0 !== 40) {
610
+ const g = litProbe(nodeId, input, tailStart, endPos);
611
+ if (g >= 0) return g;
612
+ }
613
+ }
614
+ const vl = nodeVlist[nodeId];
615
+ if (vl < 0) continue;
616
+ const pat = vlistRef[vl];
617
+ const vs = vlistPat[pat];
618
+ const ve = vlistPat[pat + 1];
619
+ if (vs === ve) continue;
620
+ analyzeArb(input, tailStart, endPos);
621
+ const g0 = vgStart[vl] - vs;
622
+ for (let v = vs; v < ve; v++) if (runValidator(vlistOps[v], input, tailStart, endPos)) return vlistGroup[g0 + v];
623
+ }
624
+ return EXTERNAL;
625
+ };
626
+ const mergeClassList = (input) => {
627
+ const n = input.length;
628
+ let tokenCount = 0;
629
+ let totalTokenChars = 0;
630
+ let sawNonSpaceWS = false;
631
+ if (nextCtxId > MAX_CTX || ctxByHash.size > MAX_CTX) {
632
+ ctxByHash = /* @__PURE__ */ new Map();
633
+ ctxByCanon = /* @__PURE__ */ new Map();
634
+ nextCtxId = 2;
635
+ memoReset();
636
+ }
637
+ if (nextDynId > MAX_DYN) {
638
+ dynByHash = /* @__PURE__ */ new Map();
639
+ nextDynId = GROUP_COUNT;
640
+ memoReset();
641
+ }
642
+ let i = 0;
643
+ while (i < n) {
644
+ let c = input.charCodeAt(i);
645
+ if (c === 32 || c >= 9 && c <= 13 || c >= 160 && isUniWS(c)) {
646
+ if (c !== 32) sawNonSpaceWS = true;
647
+ i++;
648
+ continue;
649
+ }
650
+ const ts = i;
651
+ let th = 0;
652
+ while (i < n) {
653
+ c = input.charCodeAt(i);
654
+ if (c <= 32) {
655
+ if (c === 32) break;
656
+ if (c >= 9 && c <= 13) {
657
+ sawNonSpaceWS = true;
658
+ break;
659
+ }
660
+ } else if (c >= 160 && isUniWS(c)) {
661
+ sawNonSpaceWS = true;
662
+ break;
663
+ }
664
+ th = Math.imul(th ^ c, 16777619);
665
+ i++;
666
+ }
667
+ const te = i;
668
+ const len = te - ts;
669
+ if (tokenCount === cap) growTokens();
670
+ const t = tokenCount++;
671
+ tokStart[t] = ts;
672
+ tokEnd[t] = te;
673
+ totalTokenChars += len;
674
+ th ^= Math.imul(len, 2654435761);
675
+ const h = th ^ th >>> 15 | 0;
676
+ const way0 = h & 8190;
677
+ {
678
+ let hitAt = -1;
679
+ if (memoHash[way0] === h && memoStr[way0] !== null && memoStr[way0].length === len) hitAt = way0;
680
+ else if (memoHash[way0 | 1] === h && memoStr[way0 | 1] !== null && memoStr[way0 | 1].length === len) hitAt = way0 | 1;
681
+ if (hitAt >= 0) {
682
+ const s = memoStr[hitAt];
683
+ let ok = true;
684
+ for (let k = 0; k < len; k++) if (s.charCodeAt(k) !== input.charCodeAt(ts + k)) {
685
+ ok = false;
686
+ break;
687
+ }
688
+ if (ok) {
689
+ tokGid[t] = memoGid[hitAt];
690
+ tokCtx[t] = memoCtx[hitAt];
691
+ tokFlags[t] = memoFlags[hitAt];
692
+ continue;
693
+ }
694
+ }
695
+ }
696
+ let pts = ts;
697
+ if (FPL !== 0) {
698
+ if (te - ts <= FPL || !input.startsWith(FULL_PREFIX, ts)) {
699
+ tokGid[t] = EXTERNAL;
700
+ memoPut(way0, input, ts, te, h, EXTERNAL, 0, 0);
701
+ continue;
702
+ }
703
+ pts = ts + FPL;
704
+ }
705
+ let depthB = 0, depthP = 0;
706
+ let lastColon = -1, lastSlash = -1;
707
+ for (let p = pts; p < te; p++) {
708
+ const pc = input.charCodeAt(p);
709
+ if (depthB === 0 && depthP === 0) {
710
+ if (pc === 58) {
711
+ lastColon = p;
712
+ continue;
713
+ }
714
+ if (pc === 47) {
715
+ lastSlash = p;
716
+ continue;
717
+ }
718
+ }
719
+ if (pc === 91) depthB++;
720
+ else if (pc === 93) depthB--;
721
+ else if (pc === 40) depthP++;
722
+ else if (pc === 41) depthP--;
723
+ }
724
+ const modStart = lastColon >= pts ? lastColon + 1 : pts;
725
+ let bs = modStart;
726
+ let be = te;
727
+ let important = false;
728
+ let prefixShift = 0;
729
+ if (be > bs && input.charCodeAt(be - 1) === 33) {
730
+ important = true;
731
+ be--;
732
+ } else if (be > bs && input.charCodeAt(bs) === 33) {
733
+ important = true;
734
+ bs++;
735
+ prefixShift = 1;
736
+ }
737
+ let postfixEnd = -1;
738
+ if (lastSlash > modStart) {
739
+ postfixEnd = lastSlash + prefixShift;
740
+ if (postfixEnd >= be) postfixEnd = -1;
741
+ }
742
+ let feedStart = bs;
743
+ if (be - bs > 1 && input.charCodeAt(bs) === 45) feedStart = bs + 1;
744
+ let node = 0;
745
+ let lp = 0;
746
+ let le = 0;
747
+ let pending = -1;
748
+ let ckptTop = 0;
749
+ if (nodeVlist[0] >= 0 || nodeHasLit[0] === 1) {
750
+ ckptNode[0] = 0;
751
+ ckptTail[0] = feedStart;
752
+ ckptTop = 1;
753
+ }
754
+ let slashNode = DEAD;
755
+ let slashCkpt = 0;
756
+ for (let p = feedStart; p < be; p++) {
757
+ if (p === postfixEnd) {
758
+ slashNode = lp < le ? DEAD : node;
759
+ slashCkpt = ckptTop;
760
+ }
761
+ if (node !== DEAD) {
762
+ const cc = input.charCodeAt(p);
763
+ let arrived = -1;
764
+ if (lp < le) {
765
+ if (labelText.charCodeAt(lp) === cc) {
766
+ lp++;
767
+ if (lp === le) arrived = node = pending;
768
+ } else node = DEAD;
769
+ } else {
770
+ const es = edgeStart[node];
771
+ const ee = edgeStart[node + 1];
772
+ let next = DEAD;
773
+ for (let e = es; e < ee; e++) {
774
+ const ls = labelStart[e];
775
+ if (labelText.charCodeAt(ls) === cc) {
776
+ if (labelStart[e + 1] - ls === 1) arrived = next = edgeTarget[e];
777
+ else {
778
+ lp = ls + 1;
779
+ le = labelStart[e + 1];
780
+ pending = edgeTarget[e];
781
+ next = node;
782
+ }
783
+ break;
784
+ }
785
+ }
786
+ node = next;
787
+ }
788
+ if (arrived >= 0 && (nodeVlist[arrived] >= 0 || nodeHasLit[arrived] === 1) && p + 1 < be && input.charCodeAt(p + 1) === 45) {
789
+ if (ckptTop === ckptCap) {
790
+ ckptCap *= 2;
791
+ const nv = new Int32Array(ckptCap);
792
+ nv.set(ckptNode);
793
+ ckptNode = nv;
794
+ const nt = new Int32Array(ckptCap);
795
+ nt.set(ckptTail);
796
+ ckptTail = nt;
797
+ }
798
+ ckptNode[ckptTop] = arrived;
799
+ ckptTail[ckptTop] = p + 2;
800
+ ckptTop++;
801
+ }
802
+ }
803
+ }
804
+ if (postfixEnd === be) {
805
+ slashNode = lp < le ? DEAD : node;
806
+ slashCkpt = ckptTop;
807
+ }
808
+ const endNode = lp < le ? DEAD : node;
809
+ let gid;
810
+ let hasPostfix = false;
811
+ if (postfixEnd >= 0) {
812
+ hasPostfix = true;
813
+ gid = resolveAt(input, bs, postfixEnd, slashNode, slashCkpt);
814
+ if (gid !== EXTERNAL && gid < GROUP_COUNT && postfixLookupSet[gid]) {
815
+ const gidFull = resolveAt(input, bs, be, endNode, ckptTop);
816
+ if (gidFull !== EXTERNAL && gidFull !== gid) {
817
+ gid = gidFull;
818
+ hasPostfix = false;
819
+ }
820
+ } else if (gid === EXTERNAL) {
821
+ gid = resolveAt(input, bs, be, endNode, ckptTop);
822
+ hasPostfix = false;
823
+ }
824
+ } else gid = resolveAt(input, bs, be, endNode, ckptTop);
825
+ let ctxId = 0;
826
+ let flags = 0;
827
+ if (gid === EXTERNAL) tokGid[t] = EXTERNAL;
828
+ else {
829
+ flags = hasPostfix ? 1 : 0;
830
+ ctxId = pts >= lastColon ? important ? 1 : 0 : internSpan(ctxByHash, input, pts, lastColon, important ? 1 : 0, (k) => canonicalizeContext(k, important));
831
+ tokGid[t] = gid;
832
+ tokFlags[t] = flags;
833
+ tokCtx[t] = ctxId;
834
+ }
835
+ memoPut(way0, input, ts, te, h, gid, ctxId, flags);
836
+ }
837
+ if (tokenCount === 0) return "";
838
+ if (tokenCount === 1) return tokStart[0] === 0 && tokEnd[0] === n ? input : input.slice(tokStart[0], tokEnd[0]);
839
+ if (tokenCount * CLAIM_PER_TOKEN > CLAIM_TABLE) {
840
+ while (tokenCount * CLAIM_PER_TOKEN > CLAIM_TABLE) {
841
+ CLAIM_TABLE <<= 1;
842
+ claimShift--;
843
+ }
844
+ claimKeys = new Float64Array(CLAIM_TABLE);
845
+ claimEpochs = new Int32Array(CLAIM_TABLE);
846
+ }
847
+ if (nextCtxId >= ID_LIMIT || nextDynId >= ID_LIMIT) throw new Error("cn: too many distinct classes in one merge");
848
+ epoch = epoch + 1 | 0;
849
+ if (epoch === 0) {
850
+ claim0.fill(0);
851
+ claimEpochs.fill(0);
852
+ epoch = 1;
853
+ }
854
+ let didDrop = false;
855
+ for (let t = tokenCount - 1; t >= 0; t--) {
856
+ const gid = tokGid[t];
857
+ if (gid === EXTERNAL) {
858
+ keep[t] = 1;
859
+ continue;
860
+ }
861
+ const ctxId = tokCtx[t];
862
+ if (claimTest(ctxId, gid) === 1) {
863
+ keep[t] = 0;
864
+ didDrop = true;
865
+ continue;
866
+ }
867
+ keep[t] = 1;
868
+ if (gid < GROUP_COUNT) {
869
+ const r = adjRow[gid];
870
+ if (r >= 0) for (let k = adjStart[r]; k < adjStart[r + 1]; k++) claimTest(ctxId, adjTgt[k]);
871
+ if (tokFlags[t] & 1) {
872
+ for (let k = 0; k < patGid.length; k++) if (patGid[k] === gid) claimTest(ctxId, patTgt[k]);
873
+ }
874
+ }
875
+ }
876
+ if (!didDrop && !sawNonSpaceWS && n === totalTokenChars + tokenCount - 1) return input;
877
+ let out = "";
878
+ let t = 0;
879
+ while (t < tokenCount) {
880
+ if (!keep[t]) {
881
+ t++;
882
+ continue;
883
+ }
884
+ const runStart = tokStart[t];
885
+ let runEnd = tokEnd[t];
886
+ let u = t + 1;
887
+ while (u < tokenCount && keep[u] && tokStart[u] === runEnd + 1 && input.charCodeAt(runEnd) === 32) {
888
+ runEnd = tokEnd[u];
889
+ u++;
890
+ }
891
+ if (out.length > 0) out += " ";
892
+ out += input.slice(runStart, runEnd);
893
+ t = u;
894
+ }
895
+ return out;
896
+ };
897
+ const DOOR_SIZE = 16384;
898
+ const door = new Int32Array(DOOR_SIZE * 2);
899
+ let doorBase = 0;
900
+ let doorEpoch = 1;
901
+ let cache = Object.create(null);
902
+ let prevCache = Object.create(null);
903
+ let cacheMap = /* @__PURE__ */ new Map();
904
+ let prevCacheMap = /* @__PURE__ */ new Map();
905
+ let cacheCount = 0;
906
+ let doorMarks = 0;
907
+ const rotateDoor = () => {
908
+ doorBase ^= DOOR_SIZE;
909
+ doorEpoch = doorEpoch + 1 | 0;
910
+ doorMarks = 0;
911
+ };
912
+ const mergeCached = (input) => {
913
+ let merged = cache[input];
914
+ if (merged !== void 0) return merged;
915
+ const hash = spanHash(input, 0, input.length);
916
+ const slot = (hash & 16383) + doorBase;
917
+ const wasSeen = door[slot] === (hash ^ doorEpoch) || door[slot ^ DOOR_SIZE] === (hash ^ doorEpoch - 1);
918
+ if (wasSeen) {
919
+ merged = prevCache[input];
920
+ if (merged !== void 0) {
921
+ cache[input] = merged;
922
+ return merged;
923
+ }
924
+ }
925
+ merged = mergeClassList(input);
926
+ if (wasSeen) {
927
+ cache[input] = merged;
928
+ if (++cacheCount > cacheSize) {
929
+ cacheCount = 0;
930
+ prevCache = cache;
931
+ cache = Object.create(null);
932
+ rotateDoor();
933
+ }
934
+ } else {
935
+ door[slot] = hash ^ doorEpoch;
936
+ if (++doorMarks > DOOR_SIZE) rotateDoor();
937
+ }
938
+ return merged;
939
+ };
940
+ const mergeCachedMap = (input) => {
941
+ let merged = cacheMap.get(input);
942
+ if (merged !== void 0) return merged;
943
+ const hash = spanHash(input, 0, input.length);
944
+ const slot = (hash & 16383) + doorBase;
945
+ const wasSeen = door[slot] === (hash ^ doorEpoch) || door[slot ^ DOOR_SIZE] === (hash ^ doorEpoch - 1);
946
+ if (wasSeen) {
947
+ merged = prevCacheMap.get(input);
948
+ if (merged !== void 0) {
949
+ cacheMap.set(input, merged);
950
+ return merged;
951
+ }
952
+ }
953
+ merged = mergeClassList(input);
954
+ if (wasSeen) {
955
+ cacheMap.set(input, merged);
956
+ if (++cacheCount > cacheSize) {
957
+ cacheCount = 0;
958
+ prevCacheMap = cacheMap;
959
+ cacheMap = /* @__PURE__ */ new Map();
960
+ rotateDoor();
961
+ }
962
+ } else {
963
+ door[slot] = hash ^ doorEpoch;
964
+ if (++doorMarks > DOOR_SIZE) rotateDoor();
965
+ }
966
+ return merged;
967
+ };
968
+ const seenBefore = (input) => {
969
+ const hash = spanHash(input, 0, input.length);
970
+ const slot = (hash & 16383) + doorBase;
971
+ if (door[slot] === (hash ^ doorEpoch) || door[slot ^ DOOR_SIZE] === (hash ^ doorEpoch - 1)) return true;
972
+ door[slot] = hash ^ doorEpoch;
973
+ if (++doorMarks > DOOR_SIZE) rotateDoor();
974
+ return false;
975
+ };
976
+ const mergeString = cacheSize === 0 ? mergeClassList : IS_JSC ? (input) => {
977
+ const merged = cacheMap.get(input);
978
+ return merged !== void 0 ? merged : mergeCachedMap(input);
979
+ } : mergeCached;
980
+ const merge = function() {
981
+ return arguments.length === 1 && typeof arguments[0] === "string" ? mergeString(arguments[0]) : mergeString(twJoin.apply(null, arguments));
982
+ };
983
+ return {
984
+ merge,
985
+ mergeString,
986
+ seenBefore: cacheSize === 0 ? () => false : seenBefore,
987
+ mergeUncached: mergeClassList
988
+ };
989
+ };
990
+ const resolveValue = (v, clsxMode) => {
991
+ if (!v) return "";
992
+ if (typeof v === "string") return v;
993
+ let out = "";
994
+ if (typeof v.length === "number" && (clsxMode ? Array.isArray(v) : true)) {
995
+ const arr = v;
996
+ for (let i = 0; i < arr.length; i++) {
997
+ const item = arr[i];
998
+ if (!item) continue;
999
+ const r = typeof item === "string" ? item : resolveValue(item, clsxMode);
1000
+ if (r) {
1001
+ if (out) out += " ";
1002
+ out += r;
1003
+ }
1004
+ }
1005
+ return out;
1006
+ }
1007
+ if (clsxMode) {
1008
+ if (typeof v === "number") return "" + v;
1009
+ if (typeof v === "object") {
1010
+ for (const k in v) if (v[k]) {
1011
+ if (out) out += " ";
1012
+ out += k;
1013
+ }
1014
+ }
1015
+ }
1016
+ return out;
1017
+ };
1018
+ const joinArgs = (args, clsxMode) => {
1019
+ let s = "";
1020
+ for (let i = 0; i < args.length; i++) {
1021
+ const a = args[i];
1022
+ if (!a) continue;
1023
+ const r = typeof a === "string" ? a : resolveValue(a, clsxMode);
1024
+ if (r) {
1025
+ if (s) s += " ";
1026
+ s += r;
1027
+ }
1028
+ }
1029
+ return s;
1030
+ };
1031
+ /** join-only, `twJoin`-compatible (strings + nested arrays, falsy skipped) */
1032
+ const twJoin = function() {
1033
+ return joinArgs(arguments, false);
1034
+ };
1035
+ const BUCKET_CAP = 256;
1036
+ const BUCKET_MISS_CAP = 16;
1037
+ const BUCKET_SKIP = 1024;
1038
+ const CHURN_SIZE = 4096;
1039
+ const wrapClsx = (mergeString, fresh) => {
1040
+ const seenBefore = fresh === void 0 ? () => true : fresh.seenBefore;
1041
+ const mergeUncached = fresh === void 0 ? mergeString : fresh.mergeUncached;
1042
+ let argCache = /* @__PURE__ */ new Map();
1043
+ let prevArgCache = /* @__PURE__ */ new Map();
1044
+ let argCount = 0;
1045
+ let lastHit = null;
1046
+ let churnKey = null;
1047
+ let churnOwn = [];
1048
+ let churnVal = [];
1049
+ let churnTick = 0;
1050
+ const churnLookup = (key, own, join) => {
1051
+ if (churnKey === null) {
1052
+ churnKey = new Array(CHURN_SIZE).fill("");
1053
+ churnOwn = new Array(CHURN_SIZE).fill("");
1054
+ churnVal = new Array(CHURN_SIZE).fill("");
1055
+ }
1056
+ const way0 = spanHash(key, 0, key.length) & 4094;
1057
+ if (churnKey[way0] === key && churnOwn[way0] === own) return churnVal[way0];
1058
+ if (churnKey[way0 | 1] === key && churnOwn[way0 | 1] === own) return churnVal[way0 | 1];
1059
+ const merged = mergeString(join ? own + " " + key : key);
1060
+ const slot = churnKey[way0] === "" ? way0 : way0 | (churnKey[way0 | 1] === "" ? 1 : churnTick++ & 1);
1061
+ churnKey[slot] = key;
1062
+ churnOwn[slot] = own;
1063
+ churnVal[slot] = merged;
1064
+ return merged;
1065
+ };
1066
+ const match3 = (e, v0, v1, v2) => {
1067
+ let k = 0;
1068
+ if (v0) {
1069
+ if (v0 !== e.a0) return false;
1070
+ k = 1;
1071
+ }
1072
+ if (v1) {
1073
+ if (v1 !== (k === 0 ? e.a0 : e.a1)) return false;
1074
+ k++;
1075
+ }
1076
+ if (v2) {
1077
+ if (v2 !== (k === 0 ? e.a0 : k === 1 ? e.a1 : e.a2)) return false;
1078
+ k++;
1079
+ }
1080
+ return k === e.t;
1081
+ };
1082
+ const matchN = (e, vals) => {
1083
+ const ea = e.a;
1084
+ let k = 0;
1085
+ for (let i = 0; i < vals.length; i++) {
1086
+ const v = vals[i];
1087
+ if (!v) continue;
1088
+ if (v !== ea[k]) return false;
1089
+ k++;
1090
+ }
1091
+ return k === e.t;
1092
+ };
1093
+ const resolveArgs = (vals, probed) => {
1094
+ const nArgs = vals.length;
1095
+ const pred = lastHit === null ? null : lastHit.n;
1096
+ if (!probed) {
1097
+ if (pred !== null && matchN(pred, vals)) {
1098
+ lastHit = pred;
1099
+ return pred.r;
1100
+ }
1101
+ if (lastHit !== null && lastHit !== pred && matchN(lastHit, vals)) return lastHit.r;
1102
+ }
1103
+ let first = "";
1104
+ let firstIdx = -1;
1105
+ let truthy = 0;
1106
+ let hasResolvedValue = false;
1107
+ for (let i = 0; i < nArgs; i++) {
1108
+ let v = vals[i];
1109
+ if (!v) continue;
1110
+ if (typeof v !== "string") {
1111
+ v = vals[i] = resolveValue(v, true);
1112
+ if (!v) continue;
1113
+ hasResolvedValue = true;
1114
+ }
1115
+ if (firstIdx < 0) {
1116
+ first = v;
1117
+ firstIdx = i;
1118
+ }
1119
+ truthy++;
1120
+ }
1121
+ if (truthy === 0) return "";
1122
+ if (truthy === 1) return mergeString(first);
1123
+ if (hasResolvedValue) {
1124
+ if (pred !== null && matchN(pred, vals)) {
1125
+ lastHit = pred;
1126
+ return pred.r;
1127
+ }
1128
+ if (lastHit !== null && lastHit !== pred && matchN(lastHit, vals)) return lastHit.r;
1129
+ }
1130
+ let bucket = argCache.get(first);
1131
+ if (bucket === void 0) {
1132
+ bucket = prevArgCache.get(first);
1133
+ if (bucket !== void 0) argCache.set(first, bucket);
1134
+ }
1135
+ let hit = null;
1136
+ if (bucket !== void 0) {
1137
+ if (bucket.skip > 0) {
1138
+ bucket.skip--;
1139
+ lastHit = null;
1140
+ let joined = first;
1141
+ for (let i = firstIdx + 1; i < nArgs; i++) {
1142
+ const v = vals[i];
1143
+ if (v) joined += " " + v;
1144
+ }
1145
+ return churnLookup(joined, "", false);
1146
+ }
1147
+ const entries = bucket.e;
1148
+ outer: for (let b = 0; b < entries.length; b++) {
1149
+ const e = entries[b];
1150
+ if (e.t !== truthy) continue;
1151
+ const ea = e.a;
1152
+ let k = 1;
1153
+ for (let i = firstIdx + 1; i < nArgs; i++) {
1154
+ const v = vals[i];
1155
+ if (v && v !== ea[k++]) continue outer;
1156
+ }
1157
+ hit = e;
1158
+ break;
1159
+ }
1160
+ if (hit !== null) bucket.miss = 0;
1161
+ }
1162
+ if (hit === null) {
1163
+ let joined = first;
1164
+ const a = [first];
1165
+ for (let i = firstIdx + 1; i < nArgs; i++) {
1166
+ const v = vals[i];
1167
+ if (!v) continue;
1168
+ joined += " " + v;
1169
+ a.push(v);
1170
+ }
1171
+ if (!seenBefore(joined)) return mergeUncached(joined);
1172
+ hit = {
1173
+ r: mergeString(joined),
1174
+ t: a.length,
1175
+ a0: a[0],
1176
+ a1: a[1],
1177
+ a2: a[2] ?? "",
1178
+ a,
1179
+ n: null
1180
+ };
1181
+ if (bucket === void 0) argCache.set(first, bucket = {
1182
+ e: [],
1183
+ miss: 0,
1184
+ skip: 0,
1185
+ at: 0
1186
+ });
1187
+ else if (++bucket.miss > BUCKET_MISS_CAP) {
1188
+ bucket.miss = BUCKET_MISS_CAP;
1189
+ bucket.skip = BUCKET_SKIP;
1190
+ bucket.e.length = 0;
1191
+ bucket.at = 0;
1192
+ }
1193
+ const entries = bucket.e;
1194
+ if (entries.length < BUCKET_CAP) entries.push(hit);
1195
+ else {
1196
+ entries[bucket.at] = hit;
1197
+ bucket.at = bucket.at + 1 & 255;
1198
+ }
1199
+ if (++argCount > 1e3) {
1200
+ argCount = 0;
1201
+ prevArgCache = argCache;
1202
+ argCache = /* @__PURE__ */ new Map();
1203
+ }
1204
+ }
1205
+ if (lastHit !== null && lastHit !== hit) lastHit.n = hit;
1206
+ lastHit = hit;
1207
+ return hit.r;
1208
+ };
1209
+ const mergeSingleValue = (value) => Array.isArray(value) ? resolveArgs(value.slice(), false) : mergeString(resolveValue(value, true));
1210
+ return function(v0, v1, v2) {
1211
+ const nArgs = arguments.length;
1212
+ if ((nArgs | 1) === 3) {
1213
+ const lh = lastHit;
1214
+ if (lh !== null) {
1215
+ const pred = lh.n;
1216
+ if (pred !== null && match3(pred, v0, v1, v2)) {
1217
+ lastHit = pred;
1218
+ return pred.r;
1219
+ }
1220
+ if (lh !== pred && match3(lh, v0, v1, v2)) return lh.r;
1221
+ }
1222
+ if (nArgs === 2 && typeof v1 === "string" && v1 !== "") {
1223
+ const bucket = argCache.get(v0);
1224
+ if (bucket !== void 0 && bucket.skip > 0) {
1225
+ bucket.skip--;
1226
+ lastHit = null;
1227
+ return churnLookup(v1, v0, true);
1228
+ }
1229
+ }
1230
+ return resolveArgs([
1231
+ v0,
1232
+ v1,
1233
+ v2
1234
+ ], true);
1235
+ }
1236
+ if (nArgs === 1) return typeof v0 === "string" ? mergeString(v0) : mergeSingleValue(v0);
1237
+ const lh = lastHit;
1238
+ if (lh !== null) {
1239
+ const pred = lh.n;
1240
+ if (pred !== null) {
1241
+ const pa = pred.a;
1242
+ let k = 0;
1243
+ let ok = true;
1244
+ for (let i = 0; i < nArgs; i++) {
1245
+ const v = arguments[i];
1246
+ if (!v) continue;
1247
+ if (v !== pa[k]) {
1248
+ ok = false;
1249
+ break;
1250
+ }
1251
+ k++;
1252
+ }
1253
+ if (ok && k === pred.t) {
1254
+ lastHit = pred;
1255
+ return pred.r;
1256
+ }
1257
+ }
1258
+ if (lh !== pred) {
1259
+ const la = lh.a;
1260
+ let k = 0;
1261
+ let ok = true;
1262
+ for (let i = 0; i < nArgs; i++) {
1263
+ const v = arguments[i];
1264
+ if (!v) continue;
1265
+ if (v !== la[k]) {
1266
+ ok = false;
1267
+ break;
1268
+ }
1269
+ k++;
1270
+ }
1271
+ if (ok && k === lh.t) return lh.r;
1272
+ }
1273
+ }
1274
+ const vals = [];
1275
+ for (let i = 0; i < nArgs; i++) vals.push(arguments[i]);
1276
+ return resolveArgs(vals, true);
1277
+ };
1278
+ };
1279
+ //#endregion
1280
+ //#region ../../node_modules/cn/dist/index.js
1281
+ const instance = /* @__PURE__ */ createEngine(tables_generated_default);
1282
+ /**
1283
+ * Merge Tailwind CSS classes with clsx-style arguments (strings, arrays,
1284
+ * objects, conditionals). Drop-in replacement for `twMerge(clsx(...))`.
1285
+ */
1286
+ const cn = /* @__PURE__ */ wrapClsx(instance.mergeString, instance);
1287
+ instance.merge;
1288
+ //#endregion
1289
+ //#region ../ui/src/components/alert.tsx
1290
+ const alertVariants = cva("group/alert relative grid w-full gap-0.5 rounded-lg border px-2.5 py-2 text-start text-sm has-data-[slot=alert-action]:relative has-data-[slot=alert-action]:pe-18 has-[>svg]:grid-cols-[auto_1fr] has-[>svg]:gap-x-2 *:[svg]:row-span-2 *:[svg]:translate-y-0.5 *:[svg]:text-current *:[svg:not([class*='size-'])]:size-4", {
1291
+ variants: { variant: {
1292
+ default: "bg-card text-card-foreground",
1293
+ destructive: "bg-card text-destructive *:data-[slot=alert-description]:text-destructive/90 *:[svg]:text-current"
1294
+ } },
1295
+ defaultVariants: { variant: "default" }
1296
+ });
1297
+ function Alert({ className, variant, ...props }) {
1298
+ return /* @__PURE__ */ jsx("div", {
1299
+ "data-slot": "alert",
1300
+ role: "alert",
1301
+ className: cn(alertVariants({ variant }), className),
1302
+ ...props
1303
+ });
1304
+ }
1305
+ function AlertTitle({ className, ...props }) {
1306
+ return /* @__PURE__ */ jsx("div", {
1307
+ "data-slot": "alert-title",
1308
+ className: cn("font-medium group-has-[>svg]/alert:col-start-2 [&_a]:underline [&_a]:underline-offset-3 [&_a]:hover:text-foreground", className),
1309
+ ...props
1310
+ });
1311
+ }
1312
+ function AlertDescription({ className, ...props }) {
1313
+ return /* @__PURE__ */ jsx("div", {
1314
+ "data-slot": "alert-description",
1315
+ className: cn("text-sm text-balance text-muted-foreground md:text-pretty [&_a]:underline [&_a]:underline-offset-3 [&_a]:hover:text-foreground [&_p:not(:last-child)]:mb-4", className),
1316
+ ...props
1317
+ });
1318
+ }
1319
+ //#endregion
1320
+ //#region ../../node_modules/lucide-react/dist/esm/shared/src/utils/toKebabCase.mjs
1321
+ /**
1322
+ * @license lucide-react v1.61.0 - ISC
1323
+ *
1324
+ * This source code is licensed under the ISC license.
1325
+ * See the LICENSE file in the root directory of this source tree.
1326
+ */
1327
+ const toKebabCase = (string) => string?.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase();
1328
+ //#endregion
1329
+ //#region ../../node_modules/lucide-react/dist/esm/shared/src/utils/toLucideIconData.mjs
1330
+ /**
1331
+ * @license lucide-react v1.61.0 - ISC
1332
+ *
1333
+ * This source code is licensed under the ISC license.
1334
+ * See the LICENSE file in the root directory of this source tree.
1335
+ */
1336
+ function toLucideIconData(iconName, iconNode, aliases = []) {
1337
+ if (iconNode == null) throw new Error("[lucide]: iconNode is required when icon name is used");
1338
+ return {
1339
+ name: toKebabCase(iconName),
1340
+ size: 24,
1341
+ node: iconNode,
1342
+ ...aliases.length > 0 ? { aliases } : {}
1343
+ };
1344
+ }
1345
+ //#endregion
1346
+ //#region ../../node_modules/lucide-react/dist/esm/shared/src/utils/toCamelCase.mjs
1347
+ /**
1348
+ * @license lucide-react v1.61.0 - ISC
1349
+ *
1350
+ * This source code is licensed under the ISC license.
1351
+ * See the LICENSE file in the root directory of this source tree.
1352
+ */
1353
+ const toCamelCase = (string) => {
1354
+ let out = "";
1355
+ let upperNext = false;
1356
+ for (const ch of string) {
1357
+ if (ch === "-" || ch === "_" || ch <= " ") {
1358
+ upperNext = out.length > 0;
1359
+ continue;
1360
+ }
1361
+ if (out.length === 0) out += ch.toLowerCase();
1362
+ else out += upperNext ? ch.toUpperCase() : ch;
1363
+ upperNext = false;
1364
+ }
1365
+ return out;
1366
+ };
1367
+ //#endregion
1368
+ //#region ../../node_modules/lucide-react/dist/esm/shared/src/utils/toPascalCase.mjs
1369
+ /**
1370
+ * @license lucide-react v1.61.0 - ISC
1371
+ *
1372
+ * This source code is licensed under the ISC license.
1373
+ * See the LICENSE file in the root directory of this source tree.
1374
+ */
1375
+ const toPascalCase = (string) => {
1376
+ const camelCase = toCamelCase(string);
1377
+ return camelCase.charAt(0).toUpperCase() + camelCase.slice(1);
1378
+ };
1379
+ //#endregion
1380
+ //#region ../../node_modules/lucide-react/dist/esm/shared/src/utils/mergeClasses.mjs
1381
+ /**
1382
+ * @license lucide-react v1.61.0 - ISC
1383
+ *
1384
+ * This source code is licensed under the ISC license.
1385
+ * See the LICENSE file in the root directory of this source tree.
1386
+ */
1387
+ const mergeClasses = (...classes) => classes.filter((className, index, array) => {
1388
+ return Boolean(className) && className.trim() !== "" && array.indexOf(className) === index;
1389
+ }).join(" ").trim();
1390
+ //#endregion
1391
+ //#region ../../node_modules/lucide-react/dist/esm/shared/src/build/defaultAttributes.mjs
1392
+ /**
1393
+ * @license lucide-react v1.61.0 - ISC
1394
+ *
1395
+ * This source code is licensed under the ISC license.
1396
+ * See the LICENSE file in the root directory of this source tree.
1397
+ */
1398
+ const defaultAttributes = {
1399
+ xmlns: "http://www.w3.org/2000/svg",
1400
+ width: 24,
1401
+ height: 24,
1402
+ viewBox: "0 0 24 24",
1403
+ fill: "none",
1404
+ stroke: "currentColor",
1405
+ "stroke-width": 2,
1406
+ "stroke-linecap": "round",
1407
+ "stroke-linejoin": "round"
1408
+ };
1409
+ //#endregion
1410
+ //#region ../../node_modules/lucide-react/dist/esm/shared/src/build/buildLucideIconNode.mjs
1411
+ /**
1412
+ * @license lucide-react v1.61.0 - ISC
1413
+ *
1414
+ * This source code is licensed under the ISC license.
1415
+ * See the LICENSE file in the root directory of this source tree.
1416
+ */
1417
+ function isDefined(value) {
1418
+ return value !== null && value !== void 0;
1419
+ }
1420
+ function buildLucideIconNode(icon, params = {}) {
1421
+ const attributeNames = params.attributeNames ?? {};
1422
+ const getAttributeName = (attributeName) => attributeNames[attributeName] ?? attributeName;
1423
+ const viewBoxWidth = icon.size ?? icon.width ?? defaultAttributes["width"];
1424
+ const viewBoxHeight = icon.size ?? icon.height ?? defaultAttributes["height"];
1425
+ const aliasClassNames = icon.aliases?.filter((alias) => typeof alias === "string" && alias.trim() !== "").map((alias) => `lucide-${alias}`) ?? [];
1426
+ const iconClassNames = [...icon.name ? [`lucide-${icon.name}`] : [], ...aliasClassNames];
1427
+ const classNamesFromClassName = params.className?.split(" ").filter(Boolean) ?? [];
1428
+ const className = params.includeDefaultClasses === false ? mergeClasses(...classNamesFromClassName) : mergeClasses("lucide", ...iconClassNames, ...classNamesFromClassName);
1429
+ const calculatedStrokeWidth = params.absoluteStrokeWidth ? Number(params.strokeWidth ?? defaultAttributes["stroke-width"]) * Number(icon.size ?? icon.width ?? defaultAttributes["width"]) / Number(params.size ?? params.width ?? defaultAttributes["width"]) : params.strokeWidth ?? defaultAttributes["stroke-width"];
1430
+ return [
1431
+ "svg",
1432
+ {
1433
+ ...Object.entries(defaultAttributes).reduce((attrs, [attrName, value]) => {
1434
+ attrs[getAttributeName(attrName)] = value;
1435
+ return attrs;
1436
+ }, {}),
1437
+ ..."color" in params && params.color && { [getAttributeName("stroke")]: params.color },
1438
+ ..."size" in params && isDefined(params.size) && {
1439
+ [getAttributeName("width")]: params.size,
1440
+ [getAttributeName("height")]: params.size
1441
+ },
1442
+ ..."width" in params && isDefined(params.width) && { [getAttributeName("width")]: params.width },
1443
+ ..."height" in params && isDefined(params.height) && { [getAttributeName("height")]: params.height },
1444
+ [getAttributeName("stroke-width")]: calculatedStrokeWidth,
1445
+ ...className && { [getAttributeName("class")]: className },
1446
+ [getAttributeName("viewBox")]: `0 0 ${viewBoxWidth} ${viewBoxHeight}`,
1447
+ ...params.hasA11yProp === false ? { [getAttributeName("aria-hidden")]: "true" } : {},
1448
+ ..."attributes" in params && params.attributes
1449
+ },
1450
+ icon.node.map((child) => {
1451
+ const [name, attrs, children] = child;
1452
+ const nextAttrs = params.nonScalingStroke ? {
1453
+ [getAttributeName("vector-effect")]: "non-scaling-stroke",
1454
+ ...attrs
1455
+ } : attrs;
1456
+ return children ? [
1457
+ name,
1458
+ nextAttrs,
1459
+ children
1460
+ ] : [name, nextAttrs];
1461
+ })
1462
+ ];
1463
+ }
1464
+ //#endregion
1465
+ //#region ../../node_modules/lucide-react/dist/esm/shared/src/build/buildLucideIconForReact.mjs
1466
+ /**
1467
+ * @license lucide-react v1.61.0 - ISC
1468
+ *
1469
+ * This source code is licensed under the ISC license.
1470
+ * See the LICENSE file in the root directory of this source tree.
1471
+ */
1472
+ function buildLucideIconForReact(icon, params = {}) {
1473
+ return buildLucideIconNode(icon, {
1474
+ ...params,
1475
+ attributeNames: {
1476
+ ...params.attributeNames,
1477
+ class: "className",
1478
+ "stroke-width": "strokeWidth",
1479
+ "stroke-linecap": "strokeLinecap",
1480
+ "stroke-linejoin": "strokeLinejoin",
1481
+ "vector-effect": "vectorEffect"
1482
+ }
1483
+ });
1484
+ }
1485
+ //#endregion
1486
+ //#region ../../node_modules/lucide-react/dist/esm/shared/src/utils/hasA11yProp.mjs
1487
+ /**
1488
+ * @license lucide-react v1.61.0 - ISC
1489
+ *
1490
+ * This source code is licensed under the ISC license.
1491
+ * See the LICENSE file in the root directory of this source tree.
1492
+ */
1493
+ const hasA11yProp = (props) => {
1494
+ for (const prop in props) if (prop.startsWith("aria-") || prop === "role" || prop === "title") return true;
1495
+ return false;
1496
+ };
1497
+ //#endregion
1498
+ //#region ../../node_modules/lucide-react/dist/esm/context.mjs
1499
+ /**
1500
+ * @license lucide-react v1.61.0 - ISC
1501
+ *
1502
+ * This source code is licensed under the ISC license.
1503
+ * See the LICENSE file in the root directory of this source tree.
1504
+ */
1505
+ const LucideContext = createContext({});
1506
+ const useLucideContext = () => useContext(LucideContext);
1507
+ //#endregion
1508
+ //#region ../../node_modules/lucide-react/dist/esm/Icon.mjs
1509
+ /**
1510
+ * @license lucide-react v1.61.0 - ISC
1511
+ *
1512
+ * This source code is licensed under the ISC license.
1513
+ * See the LICENSE file in the root directory of this source tree.
1514
+ */
1515
+ const Icon = forwardRef(({ color, size, width, height, strokeWidth, absoluteStrokeWidth, nonScalingStroke, className = "", children, iconNode = [], icon = {
1516
+ node: iconNode,
1517
+ aliases: [],
1518
+ size: 24
1519
+ }, ...rest }, ref) => {
1520
+ const { size: contextSize = 24, strokeWidth: contextStrokeWidth = 2, absoluteStrokeWidth: contextAbsoluteStrokeWidth = false, nonScalingStroke: contextNonScalingStroke = false, color: contextColor = "currentColor", className: contextClass = "" } = useLucideContext() ?? {};
1521
+ const hasAccessibleProp = Boolean(children) || hasA11yProp(rest);
1522
+ const [name, svgAttributes, builtIconNode = []] = buildLucideIconForReact(icon, {
1523
+ color: color ?? contextColor,
1524
+ width: width ?? size ?? contextSize,
1525
+ height: height ?? size ?? contextSize,
1526
+ strokeWidth: strokeWidth ?? contextStrokeWidth,
1527
+ absoluteStrokeWidth: absoluteStrokeWidth ?? contextAbsoluteStrokeWidth,
1528
+ nonScalingStroke: nonScalingStroke ?? contextNonScalingStroke,
1529
+ className: mergeClasses(contextClass, className),
1530
+ hasA11yProp: hasAccessibleProp,
1531
+ attributes: rest
1532
+ });
1533
+ return createElement(name, {
1534
+ ref,
1535
+ ...svgAttributes
1536
+ }, [...builtIconNode.map(([tag, attrs]) => createElement(tag, attrs)), ...Array.isArray(children) ? children : [children]]);
1537
+ });
1538
+ //#endregion
1539
+ //#region ../../node_modules/lucide-react/dist/esm/createLucideIcon.mjs
1540
+ /**
1541
+ * @license lucide-react v1.61.0 - ISC
1542
+ *
1543
+ * This source code is licensed under the ISC license.
1544
+ * See the LICENSE file in the root directory of this source tree.
1545
+ */
1546
+ function createLucideIcon(iconDataOrName, iconNode = [], aliases = []) {
1547
+ const iconData = typeof iconDataOrName === "string" ? toLucideIconData(iconDataOrName, iconNode, aliases) : iconDataOrName;
1548
+ const Component = forwardRef(({ className, ...props }, ref) => createElement(Icon, {
1549
+ ref,
1550
+ icon: iconData,
1551
+ className,
1552
+ ...props
1553
+ }));
1554
+ if (iconData.name) Component.displayName = toPascalCase(iconData.name);
1555
+ return Component;
1556
+ }
1557
+ //#endregion
1558
+ //#region ../../node_modules/lucide-react/dist/esm/icons/loader-circle.mjs
1559
+ /**
1560
+ * @license lucide-react v1.61.0 - ISC
1561
+ *
1562
+ * This source code is licensed under the ISC license.
1563
+ * See the LICENSE file in the root directory of this source tree.
1564
+ */
1565
+ const __iconData = {
1566
+ name: "loader-circle",
1567
+ size: 24,
1568
+ node: [["path", {
1569
+ d: "M21 12a9 9 0 1 1-6.219-8.56",
1570
+ key: "13zald"
1571
+ }]],
1572
+ aliases: ["loader-2"]
1573
+ };
1574
+ __iconData.node;
1575
+ const LoaderCircle = createLucideIcon(__iconData);
1576
+ //#endregion
1577
+ //#region ../ui/src/components/spinner.tsx
1578
+ function Spinner({ className, ...props }) {
1579
+ return /* @__PURE__ */ jsx(LoaderCircle, {
1580
+ "data-slot": "spinner",
1581
+ role: "status",
1582
+ "aria-label": "Loading",
1583
+ className: cn("size-4 animate-spin", className),
1584
+ ...props
1585
+ });
1586
+ }
1587
+ //#endregion
1588
+ //#region src/player-status.tsx
1589
+ function PlayerStatus({ state, error }) {
1590
+ if (state === "loading") return /* @__PURE__ */ jsx(Spinner, { "aria-label": "Composition loading" });
1591
+ if (state === "error") return /* @__PURE__ */ jsxs(Alert, {
1592
+ variant: "destructive",
1593
+ children: [/* @__PURE__ */ jsx(AlertTitle, { children: "Composition failed" }), /* @__PURE__ */ jsx(AlertDescription, { children: error })]
1594
+ });
1595
+ return null;
1596
+ }
1597
+ //#endregion
1598
+ //#region src/composition-player.tsx
1599
+ function CompositionPlayer({ composition, components, ref }) {
1600
+ const { validated, registry, clips } = useMemo(() => {
1601
+ const validated = validateComposition(composition);
1602
+ const registry = createTimelineRegistry(validated);
1603
+ return {
1604
+ validated,
1605
+ registry,
1606
+ clips: validated.clips.map((clip, declarationIndex) => ({
1607
+ clip,
1608
+ declarationIndex
1609
+ })).sort((left, right) => {
1610
+ if (left.clip.layer < right.clip.layer) return -1;
1611
+ if (left.clip.layer > right.clip.layer) return 1;
1612
+ return left.declarationIndex - right.declarationIndex;
1613
+ }).map(({ clip }) => {
1614
+ const renderComponent = Object.hasOwn(components, clip.component) ? components[clip.component] : void 0;
1615
+ if (typeof renderComponent !== "function") throw new RangeError(`Unknown player component: ${clip.component}`);
1616
+ const element = renderComponent({
1617
+ clip,
1618
+ registry,
1619
+ durationSeconds: clip.durationInFrames / validated.fps
1620
+ });
1621
+ if (!isValidElement(element)) throw new TypeError(`Component ${clip.component} must return a React element`);
1622
+ return /* @__PURE__ */ jsx("div", {
1623
+ "data-clip-id": clip.id,
1624
+ style: {
1625
+ position: "absolute",
1626
+ inset: 0
1627
+ },
1628
+ children: element
1629
+ }, clip.id);
1630
+ })
1631
+ };
1632
+ }, [composition, components]);
1633
+ const session = useMemo(() => createPlayerSession(validated, registry), [validated, registry]);
1634
+ const [status, setStatus] = useState({
1635
+ session,
1636
+ state: "loading"
1637
+ });
1638
+ useImperativeHandle(ref, () => ({
1639
+ whenReady: session.whenReady,
1640
+ seek: session.seek,
1641
+ getComposition: session.getComposition
1642
+ }), [session]);
1643
+ useLayoutEffect(() => {
1644
+ let active = true;
1645
+ session.start().then(() => {
1646
+ if (active) setStatus({
1647
+ session,
1648
+ state: "ready"
1649
+ });
1650
+ }, (error) => {
1651
+ if (active) setStatus({
1652
+ session,
1653
+ state: "error",
1654
+ error: error instanceof Error ? error.message : String(error)
1655
+ });
1656
+ });
1657
+ return () => {
1658
+ active = false;
1659
+ session.stop();
1660
+ };
1661
+ }, [session]);
1662
+ const currentStatus = status.session === session ? status : {
1663
+ state: "loading",
1664
+ error: void 0
1665
+ };
1666
+ return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("div", {
1667
+ "data-composition-id": validated.id,
1668
+ style: {
1669
+ position: "relative",
1670
+ width: validated.width,
1671
+ height: validated.height,
1672
+ overflow: "hidden"
1673
+ },
1674
+ children: clips
1675
+ }), /* @__PURE__ */ jsx(PlayerStatus, {
1676
+ state: currentStatus.state,
1677
+ error: currentStatus.error
1678
+ })] });
1679
+ }
1680
+ //#endregion
1681
+ //#region src/renderer-bridge.tsx
1682
+ function CompositionPlayerBridge(props) {
1683
+ const playerRef = useRef(null);
1684
+ useLayoutEffect(() => {
1685
+ const browserWindow = window;
1686
+ if (browserWindow.__serimoRenderer) throw new Error("Renderer bridge already installed");
1687
+ const currentPlayer = () => {
1688
+ const player = playerRef.current;
1689
+ if (!player) throw new Error("Player is not mounted");
1690
+ return player;
1691
+ };
1692
+ const bridge = {
1693
+ async whenReady() {
1694
+ await currentPlayer().whenReady();
1695
+ },
1696
+ async seek(frame) {
1697
+ await currentPlayer().seek(frame);
1698
+ },
1699
+ getComposition() {
1700
+ return currentPlayer().getComposition();
1701
+ }
1702
+ };
1703
+ browserWindow.__serimoRenderer = bridge;
1704
+ return () => {
1705
+ if (browserWindow.__serimoRenderer === bridge) delete browserWindow.__serimoRenderer;
1706
+ };
1707
+ }, []);
1708
+ return /* @__PURE__ */ jsx(CompositionPlayer, {
1709
+ ...props,
1710
+ ref: playerRef
1711
+ });
1712
+ }
1713
+ //#endregion
1714
+ export { CompositionPlayer, CompositionPlayerBridge };