@ptengine/lp-editor-core 1.0.0-alpha.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,1426 @@
1
+ import { compile, __unstable__loadDesignSystem } from 'tailwindcss';
2
+ import { extendTailwindMerge } from 'tailwind-merge';
3
+
4
+ var __defProp = Object.defineProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+
10
+ // src/dom/parse.ts
11
+ function createParse(DOMParser) {
12
+ const parser = new DOMParser();
13
+ return function parse(html) {
14
+ if (typeof html !== "string") {
15
+ throw new TypeError("parse(): html \u5FC5\u987B\u662F\u5B57\u7B26\u4E32");
16
+ }
17
+ return parser.parseFromString(html, "text/html");
18
+ };
19
+ }
20
+
21
+ // src/dom/parseFragment.ts
22
+ function parseFragment(doc, html) {
23
+ if (typeof html !== "string") {
24
+ throw new TypeError("parseFragment(): html \u5FC5\u987B\u662F\u5B57\u7B26\u4E32");
25
+ }
26
+ const tpl = doc.createElement("template");
27
+ tpl.innerHTML = html;
28
+ return tpl.content;
29
+ }
30
+ function fragmentElementRoots(fragment) {
31
+ const roots = [];
32
+ let child = fragment.firstChild;
33
+ while (child) {
34
+ if (child.nodeType === 1) roots.push(child);
35
+ child = child.nextSibling;
36
+ }
37
+ return roots;
38
+ }
39
+
40
+ // src/serialize/canonical.ts
41
+ var HTML_NS = "http://www.w3.org/1999/xhtml";
42
+ var VOID_ELEMENTS = /* @__PURE__ */ new Set([
43
+ "area",
44
+ "base",
45
+ "basefont",
46
+ "bgsound",
47
+ "br",
48
+ "col",
49
+ "embed",
50
+ "frame",
51
+ "hr",
52
+ "img",
53
+ "input",
54
+ "keygen",
55
+ "link",
56
+ "meta",
57
+ "param",
58
+ "source",
59
+ "track",
60
+ "wbr"
61
+ ]);
62
+ var RAW_TEXT_ELEMENTS = /* @__PURE__ */ new Set([
63
+ "script",
64
+ "style",
65
+ "xmp",
66
+ "iframe",
67
+ "noembed",
68
+ "noframes",
69
+ "plaintext"
70
+ ]);
71
+ var NEWLINE_EATING_ELEMENTS = /* @__PURE__ */ new Set(["pre", "textarea", "listing"]);
72
+ var ELEMENT_NODE = 1;
73
+ var TEXT_NODE = 3;
74
+ var CDATA_SECTION_NODE = 4;
75
+ var PROCESSING_INSTRUCTION_NODE = 7;
76
+ var COMMENT_NODE = 8;
77
+ var DOCUMENT_NODE = 9;
78
+ var DOCUMENT_TYPE_NODE = 10;
79
+ var DOCUMENT_FRAGMENT_NODE = 11;
80
+ function escapeText(value) {
81
+ let out = "";
82
+ for (let i = 0; i < value.length; i++) {
83
+ const ch = value[i];
84
+ if (ch === "&") out += "&amp;";
85
+ else if (ch === "<") out += "&lt;";
86
+ else if (ch === ">") out += "&gt;";
87
+ else if (ch === "\r") out += "&#13;";
88
+ else out += ch;
89
+ }
90
+ return out;
91
+ }
92
+ function escapeAttribute(value) {
93
+ let out = "";
94
+ for (let i = 0; i < value.length; i++) {
95
+ const ch = value[i];
96
+ if (ch === "&") out += "&amp;";
97
+ else if (ch === "<") out += "&lt;";
98
+ else if (ch === ">") out += "&gt;";
99
+ else if (ch === '"') out += "&quot;";
100
+ else if (ch === "\r") out += "&#13;";
101
+ else out += ch;
102
+ }
103
+ return out;
104
+ }
105
+ function normalizeClassValue(value) {
106
+ const seen = /* @__PURE__ */ new Set();
107
+ const out = [];
108
+ for (const token of value.split(/[\t\n\f\r ]+/)) {
109
+ if (token === "" || seen.has(token)) continue;
110
+ seen.add(token);
111
+ out.push(token);
112
+ }
113
+ return out.join(" ");
114
+ }
115
+ function canonicalTagName(el) {
116
+ const local = el.localName;
117
+ if (el.namespaceURI === HTML_NS || el.namespaceURI == null) {
118
+ return local.toLowerCase();
119
+ }
120
+ return local;
121
+ }
122
+ function sortedAttributes(el) {
123
+ const attrs = [];
124
+ const list = el.attributes;
125
+ for (let i = 0; i < list.length; i++) {
126
+ const a = list[i];
127
+ const raw = a.value === null || a.value === void 0 ? "" : a.value;
128
+ attrs.push([a.name, a.name === "class" ? normalizeClassValue(raw) : raw]);
129
+ }
130
+ attrs.sort((x, y) => x[0] < y[0] ? -1 : x[0] > y[0] ? 1 : 0);
131
+ return attrs;
132
+ }
133
+ function serializeAttributes(el) {
134
+ let out = "";
135
+ for (const [name, value] of sortedAttributes(el)) {
136
+ out += " " + name + '="' + escapeAttribute(value) + '"';
137
+ }
138
+ return out;
139
+ }
140
+ function serializeDoctype(dt) {
141
+ const name = (dt.name || "").toLowerCase();
142
+ const publicId = dt.publicId || "";
143
+ const systemId = dt.systemId || "";
144
+ if (name === "html" && publicId === "" && systemId === "") {
145
+ return "<!DOCTYPE html>";
146
+ }
147
+ let out = "<!DOCTYPE " + name;
148
+ if (publicId !== "") {
149
+ out += ' PUBLIC "' + publicId + '"';
150
+ if (systemId !== "") out += ' "' + systemId + '"';
151
+ } else if (systemId !== "") {
152
+ out += ' SYSTEM "' + systemId + '"';
153
+ }
154
+ return out + ">";
155
+ }
156
+ function isRawTextElement(el) {
157
+ return (el.namespaceURI === HTML_NS || el.namespaceURI == null) && RAW_TEXT_ELEMENTS.has(canonicalTagName(el));
158
+ }
159
+ function isVoidElement(el) {
160
+ return (el.namespaceURI === HTML_NS || el.namespaceURI == null) && VOID_ELEMENTS.has(canonicalTagName(el));
161
+ }
162
+ function serializeChildren(node, sink) {
163
+ let child = node.firstChild;
164
+ while (child) {
165
+ serializeNode(child, sink);
166
+ child = child.nextSibling;
167
+ }
168
+ }
169
+ function serializeElement(el, sink) {
170
+ const tag2 = canonicalTagName(el);
171
+ sink.push("<" + tag2 + serializeAttributes(el) + ">");
172
+ if (isVoidElement(el)) {
173
+ return;
174
+ }
175
+ const isTemplate = tag2 === "template" && (el.namespaceURI === HTML_NS || el.namespaceURI == null);
176
+ const tplContent = el.content;
177
+ const contentRoot = isTemplate && tplContent ? tplContent : el;
178
+ if (NEWLINE_EATING_ELEMENTS.has(tag2) && !isTemplate) {
179
+ const first = contentRoot.firstChild;
180
+ if (first && first.nodeType === TEXT_NODE && first.data.charCodeAt(0) === 10) {
181
+ sink.push("\n");
182
+ }
183
+ }
184
+ if (isRawTextElement(el)) {
185
+ let child = contentRoot.firstChild;
186
+ while (child) {
187
+ if (child.nodeType === TEXT_NODE || child.nodeType === CDATA_SECTION_NODE) {
188
+ sink.push(child.data);
189
+ } else {
190
+ serializeNode(child, sink);
191
+ }
192
+ child = child.nextSibling;
193
+ }
194
+ } else {
195
+ serializeChildren(contentRoot, sink);
196
+ }
197
+ sink.push("</" + tag2 + ">");
198
+ }
199
+ function serializeNode(node, sink) {
200
+ switch (node.nodeType) {
201
+ case ELEMENT_NODE:
202
+ serializeElement(node, sink);
203
+ break;
204
+ case TEXT_NODE: {
205
+ const parent = node.parentNode;
206
+ if (parent && parent.nodeType === ELEMENT_NODE && isRawTextElement(parent)) {
207
+ sink.push(node.data);
208
+ } else {
209
+ sink.push(escapeText(node.data));
210
+ }
211
+ break;
212
+ }
213
+ case CDATA_SECTION_NODE:
214
+ sink.push("<![CDATA[" + node.data + "]]>");
215
+ break;
216
+ case PROCESSING_INSTRUCTION_NODE:
217
+ sink.push(
218
+ "<?" + node.target + " " + node.data + ">"
219
+ );
220
+ break;
221
+ case COMMENT_NODE:
222
+ sink.push("<!--" + node.data + "-->");
223
+ break;
224
+ case DOCUMENT_TYPE_NODE:
225
+ sink.push(serializeDoctype(node));
226
+ break;
227
+ case DOCUMENT_NODE:
228
+ case DOCUMENT_FRAGMENT_NODE:
229
+ serializeChildren(node, sink);
230
+ break;
231
+ }
232
+ }
233
+ function serialize(node) {
234
+ if (node === null || node === void 0) {
235
+ throw new TypeError("serialize(): node \u4E0D\u80FD\u4E3A\u7A7A");
236
+ }
237
+ const sink = [];
238
+ serializeNode(node, sink);
239
+ return sink.join("");
240
+ }
241
+
242
+ // src/rules/index.ts
243
+ var DEVICE_VARIANTS = ["md", "max-md"];
244
+ var STATE_VARIANTS = ["hover", "focus-visible", "active", "disabled"];
245
+ var PROPERTY_SLOTS = ["base", "md", "max-md"];
246
+ var LAYER_NAMES = ["section", "container", "leaf"];
247
+ var LEAF_TYPES = ["text", "media", "button", "shape"];
248
+ var ID_PATTERN = /^[a-z][a-z0-9_-]{1,31}$/;
249
+ var ID_PATTERN_SOURCE = "[a-z][a-z0-9_-]{1,31}";
250
+ var THEME_PT_ID = "theme";
251
+ var ROOT_PT_ID = "root";
252
+ var FORMAT_META_NAME = "lpx-format";
253
+ var FORMAT_VERSION = "4";
254
+ var SWITCHES = [
255
+ {
256
+ key: "hide",
257
+ attr: "data-pt-hide",
258
+ values: ["mobile", "pc"],
259
+ summary: "\u4E00\u7AEF\u9690\u85CF"
260
+ },
261
+ {
262
+ key: "layout-mobile",
263
+ attr: "data-pt-layout-mobile",
264
+ values: ["stack", "scroll"],
265
+ summary: "PC \u8F6E\u64AD\u2192\u624B\u673A\u7EB5\u5411\u5E73\u94FA / PC \u7F51\u683C\u2192\u624B\u673A\u6A2A\u6ED1"
266
+ },
267
+ {
268
+ key: "swap-image",
269
+ attr: null,
270
+ values: [],
271
+ summary: "<picture> \u53CC source\uFF0C(min-width:768px) \u5206\u754C"
272
+ },
273
+ {
274
+ key: "direction",
275
+ attr: null,
276
+ values: [],
277
+ summary: "flex-col md:flex-row"
278
+ },
279
+ {
280
+ key: "columns",
281
+ attr: null,
282
+ values: [],
283
+ summary: "grid-cols-1 md:grid-cols-{n}"
284
+ },
285
+ {
286
+ key: "placeholder",
287
+ attr: "data-pt-placeholder",
288
+ values: [],
289
+ summary: "\u672A\u843D\u56FE\u5360\u4F4D\uFF1B\u5FC5\u5E26 aspect-*\uFF0Csrc \u4E3A\u7A7A"
290
+ }
291
+ ];
292
+ var CROSS_DEVICE_CONSISTENT_PROPERTIES = [
293
+ "color",
294
+ "font-weight",
295
+ "border",
296
+ "box-shadow",
297
+ "font-family"
298
+ ];
299
+ var OPAQUE_MODES = ["strict", "text"];
300
+ var OPAQUE_ATTR = "data-pt-opaque";
301
+ var OPAQUE_DEFAULT_MODE = "strict";
302
+ var OPAQUE_TEXT_EDITABLE_TAGS = ["td", "th"];
303
+ var INLINE_NO_ID_TAGS = [
304
+ "a",
305
+ "abbr",
306
+ "b",
307
+ "bdi",
308
+ "bdo",
309
+ "br",
310
+ "cite",
311
+ "code",
312
+ "data",
313
+ "dfn",
314
+ "em",
315
+ "i",
316
+ "kbd",
317
+ "mark",
318
+ "q",
319
+ "rp",
320
+ "rt",
321
+ "ruby",
322
+ "s",
323
+ "samp",
324
+ "small",
325
+ "span",
326
+ "strong",
327
+ "sub",
328
+ "sup",
329
+ "time",
330
+ "u",
331
+ "var",
332
+ "wbr"
333
+ ];
334
+ var INLINE_STYLE_ALLOWED_PREFIX = "--pt-";
335
+ var EDIT_OP_KINDS = ["set", "insert", "delete", "move", "replace"];
336
+ var ARBITRARY_VALUE_ALLOWED_PROPERTIES = [
337
+ "width",
338
+ "height",
339
+ "aspect-ratio",
340
+ "background-image",
341
+ "max-width",
342
+ "min-height"
343
+ ];
344
+ var rules = {
345
+ deviceVariants: DEVICE_VARIANTS,
346
+ stateVariants: STATE_VARIANTS,
347
+ propertySlots: PROPERTY_SLOTS,
348
+ layers: LAYER_NAMES,
349
+ leafTypes: LEAF_TYPES,
350
+ idPattern: ID_PATTERN_SOURCE,
351
+ themePtId: THEME_PT_ID,
352
+ rootPtId: ROOT_PT_ID,
353
+ formatMetaName: FORMAT_META_NAME,
354
+ formatVersion: FORMAT_VERSION,
355
+ switches: SWITCHES,
356
+ crossDeviceConsistentProperties: CROSS_DEVICE_CONSISTENT_PROPERTIES,
357
+ opaqueModes: OPAQUE_MODES,
358
+ opaqueTextEditableTags: OPAQUE_TEXT_EDITABLE_TAGS,
359
+ inlineNoIdTags: INLINE_NO_ID_TAGS,
360
+ inlineStyleAllowedPrefix: INLINE_STYLE_ALLOWED_PREFIX,
361
+ editOpKinds: EDIT_OP_KINDS,
362
+ arbitraryValueAllowedProperties: ARBITRARY_VALUE_ALLOWED_PROPERTIES
363
+ };
364
+
365
+ // src/kinds.ts
366
+ var KIND_PROFILES = {
367
+ page: {
368
+ root: "document",
369
+ layers: ["section", "container", "leaf"],
370
+ compile: "document",
371
+ leafTypes: ["text", "media", "button", "shape"],
372
+ components: {
373
+ carousel: "self",
374
+ faq: "self",
375
+ tabs: "self",
376
+ "sticky-cta": "self",
377
+ form: "self"
378
+ },
379
+ units: { vh: true },
380
+ customCode: true
381
+ },
382
+ popup: {
383
+ root: "fragment",
384
+ // 弹窗无 section 层:root › children。
385
+ layers: ["container", "leaf"],
386
+ compile: "shadow-px",
387
+ leafTypes: ["text", "media", "button", "shape"],
388
+ components: {
389
+ form: "engage-sdk",
390
+ countdown: "engage-sdk",
391
+ carousel: "self",
392
+ faq: "self",
393
+ tabs: "self"
394
+ },
395
+ units: { vh: false },
396
+ customCode: false
397
+ }
398
+ };
399
+
400
+ // src/version.ts
401
+ var VERSION = "1.0.0-alpha.0";
402
+ var COMPILER_VERSION = "1";
403
+
404
+ // src/validate/tree.ts
405
+ var INLINE_SET = new Set(INLINE_NO_ID_TAGS);
406
+ var OPAQUE_TEXT_TAGS = new Set(OPAQUE_TEXT_EDITABLE_TAGS);
407
+ function tag(el) {
408
+ return el.localName.toLowerCase();
409
+ }
410
+ function isInlineTag(el) {
411
+ return INLINE_SET.has(tag(el));
412
+ }
413
+ function opaqueMode(el) {
414
+ if (!el.hasAttribute(OPAQUE_ATTR)) return null;
415
+ const raw = (el.getAttribute(OPAQUE_ATTR) ?? "").trim();
416
+ if (raw === "") return OPAQUE_DEFAULT_MODE;
417
+ return OPAQUE_MODES.includes(raw) ? raw : OPAQUE_DEFAULT_MODE;
418
+ }
419
+ function closestOpaque(el) {
420
+ let cur = el;
421
+ while (cur) {
422
+ const mode = opaqueMode(cur);
423
+ if (mode) return { host: cur, mode };
424
+ cur = cur.parentElement;
425
+ }
426
+ return null;
427
+ }
428
+ var SCAFFOLD_TAGS = /* @__PURE__ */ new Set([
429
+ "html",
430
+ "head",
431
+ "meta",
432
+ "title",
433
+ "link",
434
+ "base",
435
+ "style",
436
+ "script",
437
+ "noscript",
438
+ "template"
439
+ ]);
440
+ function isThemeStyle(el) {
441
+ return tag(el) === "style" && el.getAttribute("type") === "text/tailwindcss";
442
+ }
443
+ function leafAncestor(el) {
444
+ let cur = el.parentElement;
445
+ while (cur) {
446
+ if (cur.hasAttribute("data-pt-type") || cur.hasAttribute("data-pt-component")) return cur;
447
+ cur = cur.parentElement;
448
+ }
449
+ return null;
450
+ }
451
+ function shouldHaveId(el) {
452
+ if (el.hasAttribute("data-pt-type") || el.hasAttribute("data-pt-component")) return true;
453
+ if (isThemeStyle(el)) return true;
454
+ if (tag(el) === "body") return true;
455
+ if (SCAFFOLD_TAGS.has(tag(el))) return false;
456
+ if (leafAncestor(el)) return false;
457
+ const opaque = closestOpaque(el);
458
+ if (opaque) {
459
+ if (opaque.host === el) return true;
460
+ return opaque.mode === "text" && OPAQUE_TEXT_TAGS.has(tag(el));
461
+ }
462
+ if (isInlineTag(el)) return false;
463
+ return true;
464
+ }
465
+ function collectIds(root) {
466
+ const out = /* @__PURE__ */ new Set();
467
+ const nodes = root.querySelectorAll("[data-pt-id]");
468
+ for (let i = 0; i < nodes.length; i++) {
469
+ const v = nodes[i].getAttribute("data-pt-id");
470
+ if (v) out.add(v);
471
+ }
472
+ if (root instanceof Object && "getAttribute" in root) {
473
+ const self = root.getAttribute?.("data-pt-id");
474
+ if (self) out.add(self);
475
+ }
476
+ return out;
477
+ }
478
+
479
+ // src/normalize.ts
480
+ var LEGACY_PROMPT_COMMENT = /^\s*lpx-image-prompt:\s*([\s\S]*?)\s*$/;
481
+ function normalize(root, options = {}) {
482
+ const prefix = options.prefix ?? "e";
483
+ if (!ID_PATTERN.test(`${prefix}1`)) {
484
+ throw new TypeError(`normalize(): \u524D\u7F00 ${prefix} \u4E0E id \u683C\u5F0F\u4E0D\u517C\u5BB9`);
485
+ }
486
+ let changed = 0;
487
+ changed += legacyPlaceholderCommentsToAttributes(root);
488
+ const used = collectIds(root);
489
+ let counter = 0;
490
+ const nextId = () => {
491
+ let candidate;
492
+ do {
493
+ counter += 1;
494
+ candidate = `${prefix}${counter}`;
495
+ } while (used.has(candidate));
496
+ used.add(candidate);
497
+ return candidate;
498
+ };
499
+ for (const el of walkElements(root)) {
500
+ if (!shouldHaveId(el)) continue;
501
+ if (el.hasAttribute("data-pt-id")) continue;
502
+ if (tag(el) === "body" && !used.has(ROOT_PT_ID)) {
503
+ el.setAttribute("data-pt-id", ROOT_PT_ID);
504
+ used.add(ROOT_PT_ID);
505
+ changed += 1;
506
+ continue;
507
+ }
508
+ if (tag(el) === "style" && el.getAttribute("type") === "text/tailwindcss") {
509
+ if (!used.has(THEME_PT_ID)) {
510
+ el.setAttribute("data-pt-id", THEME_PT_ID);
511
+ used.add(THEME_PT_ID);
512
+ changed += 1;
513
+ continue;
514
+ }
515
+ }
516
+ el.setAttribute("data-pt-id", nextId());
517
+ changed += 1;
518
+ }
519
+ return changed;
520
+ }
521
+ function legacyPlaceholderCommentsToAttributes(root) {
522
+ let changed = 0;
523
+ const comments = [];
524
+ collectComments(root, comments);
525
+ for (const comment of comments) {
526
+ const match = LEGACY_PROMPT_COMMENT.exec(comment.data);
527
+ if (!match) continue;
528
+ const img = nextImageSibling(comment);
529
+ if (!img) continue;
530
+ if (!img.hasAttribute("data-pt-image-prompt")) {
531
+ img.setAttribute("data-pt-image-prompt", match[1]);
532
+ }
533
+ if (!img.hasAttribute("data-pt-placeholder")) {
534
+ img.setAttribute("data-pt-placeholder", "");
535
+ }
536
+ comment.parentNode?.removeChild(comment);
537
+ changed += 1;
538
+ }
539
+ return changed;
540
+ }
541
+ function collectComments(node, out) {
542
+ let child = node.firstChild;
543
+ while (child) {
544
+ if (child.nodeType === 8) out.push(child);
545
+ else if (child.nodeType === 1 || child.nodeType === 11) collectComments(child, out);
546
+ child = child.nextSibling;
547
+ }
548
+ }
549
+ function nextImageSibling(from) {
550
+ let sib = from.nextSibling;
551
+ while (sib) {
552
+ if (sib.nodeType === 1) {
553
+ const el = sib;
554
+ return el.localName.toLowerCase() === "img" ? el : null;
555
+ }
556
+ if (sib.nodeType === 3 && sib.data.trim() !== "") return null;
557
+ sib = sib.nextSibling;
558
+ }
559
+ return null;
560
+ }
561
+ function* walkElements(root) {
562
+ if ("tagName" in root) yield root;
563
+ const list = root.querySelectorAll("*");
564
+ for (let i = 0; i < list.length; i++) yield list[i];
565
+ }
566
+
567
+ // src/validate/variants.ts
568
+ var DEVICE = new Set(DEVICE_VARIANTS);
569
+ var STATE = new Set(STATE_VARIANTS);
570
+ function checkVariants(className) {
571
+ const bracket = className.indexOf("[");
572
+ const head = bracket === -1 ? className : className.slice(0, bracket);
573
+ const parts = head.split(":");
574
+ if (parts.length <= 1) return { ok: true };
575
+ const prefixes = parts.slice(0, -1);
576
+ let seenState = false;
577
+ for (const p of prefixes) {
578
+ if (DEVICE.has(p)) {
579
+ if (seenState) {
580
+ return { ok: false, offending: p, reason: "order" };
581
+ }
582
+ continue;
583
+ }
584
+ if (STATE.has(p)) {
585
+ seenState = true;
586
+ continue;
587
+ }
588
+ return { ok: false, offending: p, reason: "not-allowed" };
589
+ }
590
+ return { ok: true };
591
+ }
592
+
593
+ // src/validate/palette.ts
594
+ var NATIVE_PALETTE_PREFIXES = [
595
+ "red",
596
+ "orange",
597
+ "amber",
598
+ "yellow",
599
+ "lime",
600
+ "green",
601
+ "emerald",
602
+ "teal",
603
+ "cyan",
604
+ "sky",
605
+ "blue",
606
+ "indigo",
607
+ "violet",
608
+ "purple",
609
+ "fuchsia",
610
+ "pink",
611
+ "rose",
612
+ "slate",
613
+ "gray",
614
+ "zinc",
615
+ "neutral",
616
+ "stone"
617
+ ];
618
+ var PALETTE = new Set(NATIVE_PALETTE_PREFIXES);
619
+ var SHADE = /^(50|950|[1-9]00)$/;
620
+ function isNativePaletteClass(className) {
621
+ const bracket = className.indexOf("[");
622
+ if (bracket !== -1) return false;
623
+ const lastColon = className.lastIndexOf(":");
624
+ const base = lastColon === -1 ? className : className.slice(lastColon + 1);
625
+ const parts = base.split("-");
626
+ if (parts.length < 3) return false;
627
+ const shade = parts[parts.length - 1];
628
+ const name = parts[parts.length - 2];
629
+ return SHADE.test(shade) && PALETTE.has(name);
630
+ }
631
+
632
+ // src/validate/index.ts
633
+ var EVENT_ATTR = /^on[a-z]/i;
634
+ function validate(root, options) {
635
+ const issues = [];
636
+ const isDocument = options.profile.root === "document" && isDoc(root);
637
+ if (isDocument) checkFormatMeta(root, issues);
638
+ checkIds(root, issues);
639
+ checkElements(root, options, issues);
640
+ return { ok: issues.length === 0, issues };
641
+ }
642
+ function isDoc(root) {
643
+ return root.nodeType === 9;
644
+ }
645
+ function checkFormatMeta(doc, issues) {
646
+ const meta = doc.querySelector(`meta[name="${FORMAT_META_NAME}"]`);
647
+ if (!meta || meta.getAttribute("content") !== FORMAT_VERSION) {
648
+ issues.push({ rule: "FORMAT_MISSING" });
649
+ }
650
+ }
651
+ function checkIds(root, issues) {
652
+ const seen = /* @__PURE__ */ new Set();
653
+ const nodes = root.querySelectorAll("[data-pt-id]");
654
+ for (let i = 0; i < nodes.length; i++) {
655
+ const el = nodes[i];
656
+ const id = el.getAttribute("data-pt-id") ?? "";
657
+ if (!ID_PATTERN.test(id)) {
658
+ issues.push({ ptId: id, rule: "ID_FORMAT", params: { id } });
659
+ continue;
660
+ }
661
+ if (seen.has(id)) {
662
+ issues.push({ ptId: id, rule: "ID_DUPLICATE", params: { id } });
663
+ continue;
664
+ }
665
+ seen.add(id);
666
+ }
667
+ }
668
+ function checkElements(root, options, issues) {
669
+ const all = root.querySelectorAll("*");
670
+ for (let i = 0; i < all.length; i++) {
671
+ const el = all[i];
672
+ const name = tag(el);
673
+ const ptId = el.getAttribute("data-pt-id") ?? void 0;
674
+ if (shouldHaveId(el) && !el.hasAttribute("data-pt-id")) {
675
+ issues.push({ rule: "ID_FORMAT", params: { tag: name, reason: "missing" } });
676
+ }
677
+ if (!shouldHaveId(el) && el.hasAttribute("data-pt-id")) {
678
+ issues.push({
679
+ ptId,
680
+ rule: "ID_FORMAT",
681
+ params: { tag: name, reason: "unexpected" }
682
+ });
683
+ }
684
+ if (name === "script") {
685
+ issues.push({ ptId, rule: "SCRIPT_FORBIDDEN", params: { tag: name } });
686
+ }
687
+ checkAttributes(el, ptId, issues);
688
+ checkClasses(el, ptId, options, issues);
689
+ checkPlaceholder(el, ptId, issues);
690
+ }
691
+ }
692
+ function checkAttributes(el, ptId, issues) {
693
+ const attrs = el.attributes;
694
+ for (let i = 0; i < attrs.length; i++) {
695
+ const a = attrs[i];
696
+ if (EVENT_ATTR.test(a.name)) {
697
+ issues.push({ ptId, rule: "SCRIPT_FORBIDDEN", params: { attr: a.name } });
698
+ continue;
699
+ }
700
+ if (a.name !== "style") continue;
701
+ const declarations = a.value.split(";").map((s) => s.trim()).filter(Boolean);
702
+ const offending = declarations.find((d) => !d.startsWith(INLINE_STYLE_ALLOWED_PREFIX));
703
+ if (offending) {
704
+ issues.push({ ptId, rule: "INLINE_STYLE", params: { declaration: offending } });
705
+ }
706
+ }
707
+ }
708
+ function checkClasses(el, ptId, options, issues) {
709
+ const raw = el.getAttribute("class");
710
+ if (!raw) return;
711
+ for (const cls of raw.split(/[\t\n\f\r ]+/)) {
712
+ if (cls === "") continue;
713
+ const variant = checkVariants(cls);
714
+ if (!variant.ok) {
715
+ issues.push({
716
+ ptId,
717
+ rule: "VARIANT_FORBIDDEN",
718
+ params: { className: cls, prefix: variant.offending ?? "", reason: variant.reason ?? "" }
719
+ });
720
+ continue;
721
+ }
722
+ if (isNativePaletteClass(cls)) {
723
+ issues.push({ ptId, rule: "NATIVE_PALETTE", params: { className: cls } });
724
+ continue;
725
+ }
726
+ if (options.canCompileClass && !options.canCompileClass(cls)) {
727
+ issues.push({ ptId, rule: "CLASS_UNCOMPILABLE", params: { className: cls } });
728
+ }
729
+ }
730
+ }
731
+ function checkPlaceholder(el, ptId, issues) {
732
+ if (!el.hasAttribute("data-pt-placeholder")) return;
733
+ const cls = el.getAttribute("class") ?? "";
734
+ const hasAspect = cls.split(/\s+/).some((c) => /(^|:)aspect-/.test(c));
735
+ if (!hasAspect) {
736
+ issues.push({ ptId, rule: "PLACEHOLDER_UNRESOLVED", params: { reason: "missing-aspect" } });
737
+ return;
738
+ }
739
+ const src = el.getAttribute("src") ?? "";
740
+ if (src !== "") {
741
+ issues.push({ ptId, rule: "PLACEHOLDER_UNRESOLVED", params: { reason: "src-not-empty" } });
742
+ return;
743
+ }
744
+ issues.push({ ptId, rule: "PLACEHOLDER_UNRESOLVED", params: { reason: "unresolved" } });
745
+ }
746
+
747
+ // src/errors.ts
748
+ var ERROR_CODES = [
749
+ /** 源 HTML 缺 <meta name="lpx-format" content="4">,不是 v4 源。 */
750
+ "FORMAT_MISSING",
751
+ /** 文档内出现重复的 data-pt-id。 */
752
+ "ID_DUPLICATE",
753
+ /** 片段携带的 id 与目标文档中已有的 id 冲突。 */
754
+ "ID_CONFLICT",
755
+ /** id 不符合 [a-z][a-z0-9_-]{1,31},或结构节点缺 id。 */
756
+ "ID_FORMAT",
757
+ /** 操作引用了文档中不存在的 id(requireIdHit,用得最多的一条)。 */
758
+ "ID_NOT_FOUND",
759
+ /** 出现 <script> 或 on* 事件属性。 */
760
+ "SCRIPT_FORBIDDEN",
761
+ /** 出现内联 style(动效变量除外)。 */
762
+ "INLINE_STYLE",
763
+ /** 使用了 Tailwind 内置色板。它本身可编译,所以必须由独立规则拦。 */
764
+ "NATIVE_PALETTE",
765
+ /** class 在当前 @theme 下编译不出 CSS。 */
766
+ "CLASS_UNCOMPILABLE",
767
+ /** 变体前缀不在允许集内,或组合顺序不是「设备在前、状态在后」。 */
768
+ "VARIANT_FORBIDDEN",
769
+ /** 违反 section › container › leaf 三层结构,或往不透明子树里做结构编辑。 */
770
+ "STRUCTURE",
771
+ /** insert / replace 的片段不是单根元素。 */
772
+ "MULTI_ROOT",
773
+ /** replace 换掉了被替换元素的根 id(埋点锚点会静默断链)。 */
774
+ "REPLACE_ID_CHANGED",
775
+ /** AI 基于过期文档产出的操作块,baseVersion 对不上。 */
776
+ "STALE_BASE_VERSION",
777
+ /** 片段 canonical 往返不一致,说明 HTML 畸形。 */
778
+ "FRAGMENT_NOT_CANONICAL",
779
+ /** 存在未落图的图片占位 —— 阻塞发布,不阻塞预览。 */
780
+ "PLACEHOLDER_UNRESOLVED"
781
+ ];
782
+ var ERROR_CODE_SET = new Set(ERROR_CODES);
783
+ function isErrorCode(value) {
784
+ return typeof value === "string" && ERROR_CODE_SET.has(value);
785
+ }
786
+ var PUBLISH_BLOCKING_RULES = /* @__PURE__ */ new Set([
787
+ "PLACEHOLDER_UNRESOLVED"
788
+ ]);
789
+ function isPublishBlocking(issue) {
790
+ return PUBLISH_BLOCKING_RULES.has(issue.rule);
791
+ }
792
+ function editorError(code, extra) {
793
+ return { code, ...extra };
794
+ }
795
+
796
+ // src/validate/structure.ts
797
+ var NOT_A_LAYER = /* @__PURE__ */ new Set(["html", "head", "body"]);
798
+ function layerOf(el, profile) {
799
+ const name = tag(el);
800
+ if (NOT_A_LAYER.has(name)) return null;
801
+ const hasSectionLayer = profile.layers.includes("section");
802
+ if (hasSectionLayer && name === "section") return "section";
803
+ const ptType = el.getAttribute("data-pt-type");
804
+ if (ptType && profile.leafTypes.includes(ptType)) return "leaf";
805
+ if (el.hasAttribute("data-pt-component")) return "leaf";
806
+ const opaque = closestOpaque(el);
807
+ if (opaque && opaque.host === el) return "leaf";
808
+ if (el.hasAttribute("data-pt-id")) return "container";
809
+ return null;
810
+ }
811
+ var MAX_CONTAINER_DEPTH = 2;
812
+ function containerDepth(el, profile) {
813
+ let depth = 0;
814
+ let cur = el;
815
+ while (cur) {
816
+ if (layerOf(cur, profile) === "container") depth += 1;
817
+ cur = cur.parentElement;
818
+ }
819
+ return depth;
820
+ }
821
+ function canContain(parent, childLayer, profile) {
822
+ const opaque = closestOpaque(parent);
823
+ if (opaque) return "opaque-subtree";
824
+ const parentLayer = layerOf(parent, profile);
825
+ if (childLayer === "section") {
826
+ const isBody = tag(parent) === "body";
827
+ return isBody ? null : "section-not-body-child";
828
+ }
829
+ if (childLayer === "container") {
830
+ if (parentLayer === "section") return null;
831
+ if (parentLayer === "container") {
832
+ return containerDepth(parent, profile) + 1 > MAX_CONTAINER_DEPTH ? "container-too-deep" : null;
833
+ }
834
+ if (!profile.layers.includes("section") && parentLayer === null) return null;
835
+ return parentLayer === "leaf" ? "leaf-cannot-contain" : "unknown-layer";
836
+ }
837
+ if (parentLayer === "container") return null;
838
+ if (parentLayer === "leaf") return "leaf-cannot-contain";
839
+ if (!profile.layers.includes("section") && parentLayer === null) return null;
840
+ return "unknown-layer";
841
+ }
842
+ function deleteTarget(el, profile) {
843
+ const layer = layerOf(el, profile);
844
+ if (layer !== "container") return el;
845
+ const parent = el.parentElement;
846
+ if (!parent || layerOf(parent, profile) !== "section") return el;
847
+ const siblingContainers = Array.from(parent.children).filter(
848
+ (c) => c !== el && layerOf(c, profile) === "container"
849
+ );
850
+ return siblingContainers.length === 0 ? parent : el;
851
+ }
852
+
853
+ // src/ops/guards.ts
854
+ var guards_exports = {};
855
+ __export(guards_exports, {
856
+ findById: () => findById,
857
+ rejectScriptsAndHandlers: () => rejectScriptsAndHandlers,
858
+ requireCanonicalFragment: () => requireCanonicalFragment,
859
+ requireFragmentIds: () => requireFragmentIds,
860
+ requireIdHit: () => requireIdHit,
861
+ requireSingleRoot: () => requireSingleRoot
862
+ });
863
+ var EVENT_ATTR2 = /^on[a-z]/i;
864
+ function requireIdHit(doc, id) {
865
+ if (!id || !ID_PATTERN.test(id)) {
866
+ return editorError("ID_FORMAT", { ptId: id, params: { id } });
867
+ }
868
+ return findById(doc, id) ? null : editorError("ID_NOT_FOUND", { ptId: id, params: { id } });
869
+ }
870
+ function findById(root, id) {
871
+ if (!ID_PATTERN.test(id)) return null;
872
+ return root.querySelector(`[data-pt-id="${id}"]`);
873
+ }
874
+ function rejectScriptsAndHandlers(node) {
875
+ if (node.nodeType === 1) {
876
+ const el = node;
877
+ if (el.localName.toLowerCase() === "script") {
878
+ return editorError("SCRIPT_FORBIDDEN", { params: { tag: "script" } });
879
+ }
880
+ const attrs = el.attributes;
881
+ for (let i = 0; i < attrs.length; i++) {
882
+ if (EVENT_ATTR2.test(attrs[i].name)) {
883
+ return editorError("SCRIPT_FORBIDDEN", { params: { attr: attrs[i].name } });
884
+ }
885
+ }
886
+ }
887
+ let child = node.firstChild;
888
+ while (child) {
889
+ const err = rejectScriptsAndHandlers(child);
890
+ if (err) return err;
891
+ child = child.nextSibling;
892
+ }
893
+ return null;
894
+ }
895
+ function requireFragmentIds(fragment, existing) {
896
+ const seen = /* @__PURE__ */ new Set();
897
+ const all = fragment.querySelectorAll("*");
898
+ const check = (el) => {
899
+ if (!shouldHaveId(el)) return null;
900
+ const id = el.getAttribute("data-pt-id");
901
+ if (!id) {
902
+ return editorError("ID_FORMAT", {
903
+ params: { tag: el.localName, reason: "missing" }
904
+ });
905
+ }
906
+ if (!ID_PATTERN.test(id)) {
907
+ return editorError("ID_FORMAT", { ptId: id, params: { id } });
908
+ }
909
+ if (existing.has(id) || seen.has(id)) {
910
+ return editorError("ID_CONFLICT", { ptId: id, params: { id } });
911
+ }
912
+ seen.add(id);
913
+ return null;
914
+ };
915
+ for (let i = 0; i < all.length; i++) {
916
+ const err = check(all[i]);
917
+ if (err) return err;
918
+ }
919
+ return null;
920
+ }
921
+ function requireSingleRoot(fragment) {
922
+ const roots = fragmentElementRoots(fragment);
923
+ if (roots.length === 1) return null;
924
+ return editorError("MULTI_ROOT", { params: { count: roots.length } });
925
+ }
926
+ function requireCanonicalFragment(doc, html) {
927
+ const once = serialize(parseFragment(doc, html));
928
+ const twice = serialize(parseFragment(doc, once));
929
+ return once === twice ? null : editorError("FRAGMENT_NOT_CANONICAL");
930
+ }
931
+
932
+ // src/ops/apply.ts
933
+ var RAW_TEXT = /* @__PURE__ */ new Set(["style", "script", "xmp", "iframe", "noembed", "noframes", "plaintext"]);
934
+ function apply(doc, ops, options) {
935
+ if (!Array.isArray(ops)) throw new TypeError("apply(): ops \u5FC5\u987B\u662F\u6570\u7EC4");
936
+ if (ops.length === 0) return { ok: true, inverse: [] };
937
+ const rehearsal = doc.cloneNode(true);
938
+ const dry = run(rehearsal, ops, options);
939
+ if (!dry.ok) return dry;
940
+ return run(doc, ops, options);
941
+ }
942
+ function run(doc, ops, options) {
943
+ const inverse = [];
944
+ for (let i = 0; i < ops.length; i++) {
945
+ const result = applyOne(doc, ops[i], options);
946
+ if (!result.ok) return { ok: false, error: result.error, failedIndex: i };
947
+ inverse.unshift(result.inverse);
948
+ }
949
+ return { ok: true, inverse };
950
+ }
951
+ function applyOne(doc, op, options) {
952
+ switch (op.op) {
953
+ case "set":
954
+ return applySet(doc, op);
955
+ case "insert":
956
+ return applyInsert(doc, op, options);
957
+ case "delete":
958
+ return applyDelete(doc, op, options);
959
+ case "move":
960
+ return applyMove(doc, op, options);
961
+ case "replace":
962
+ return applyReplace(doc, op);
963
+ default:
964
+ return {
965
+ ok: false,
966
+ error: editorError("STRUCTURE", {
967
+ params: { reason: `\u672A\u77E5\u7684 op: ${String(op.op)}` }
968
+ })
969
+ };
970
+ }
971
+ }
972
+ function applySet(doc, op) {
973
+ const miss = requireIdHit(doc, op.id);
974
+ if (miss) return { ok: false, error: miss };
975
+ const el = findById(doc, op.id);
976
+ const opaque = closestOpaque(el);
977
+ if (opaque && opaque.host !== el && opaque.mode !== "text") {
978
+ return { ok: false, error: editorError("STRUCTURE", { ptId: op.id, params: { reason: "opaque-subtree" } }) };
979
+ }
980
+ const invAttrs = {};
981
+ if (op.attrs) {
982
+ for (const name of Object.keys(op.attrs)) {
983
+ if (/^on[a-z]/i.test(name)) {
984
+ return { ok: false, error: editorError("SCRIPT_FORBIDDEN", { ptId: op.id, params: { attr: name } }) };
985
+ }
986
+ invAttrs[name] = el.hasAttribute(name) ? el.getAttribute(name) : null;
987
+ }
988
+ }
989
+ let invClasses;
990
+ if (op.classes) {
991
+ const before = new Set(
992
+ normalizeClassValue(el.getAttribute("class") ?? "").split(" ").filter(Boolean)
993
+ );
994
+ const actuallyAdded = (op.classes.add ?? []).filter((c) => !before.has(c));
995
+ const actuallyRemoved = (op.classes.remove ?? []).filter((c) => before.has(c));
996
+ if (actuallyAdded.length || actuallyRemoved.length) {
997
+ invClasses = { add: actuallyRemoved, remove: actuallyAdded };
998
+ }
999
+ }
1000
+ let invText;
1001
+ if (op.text !== void 0) {
1002
+ const err = checkTextPayload(doc, el, op.text);
1003
+ if (err) return { ok: false, error: { ...err, ptId: op.id } };
1004
+ invText = serializeChildren2(el);
1005
+ }
1006
+ if (op.attrs) {
1007
+ for (const [name, value] of Object.entries(op.attrs)) {
1008
+ if (value === null) el.removeAttribute(name);
1009
+ else el.setAttribute(name, value);
1010
+ }
1011
+ }
1012
+ if (op.classes) applyClasses(el, op.classes);
1013
+ if (op.text !== void 0) setChildren(doc, el, op.text);
1014
+ const inv = { op: "set", id: op.id };
1015
+ if (op.attrs) inv.attrs = invAttrs;
1016
+ if (invClasses) inv.classes = invClasses;
1017
+ if (invText !== void 0) inv.text = invText;
1018
+ return { ok: true, inverse: inv };
1019
+ }
1020
+ function applyClasses(el, spec) {
1021
+ const list = normalizeClassValue(el.getAttribute("class") ?? "").split(" ").filter(Boolean);
1022
+ const set = new Set(list);
1023
+ for (const c of spec.remove ?? []) set.delete(c);
1024
+ const out = list.filter((c) => set.has(c));
1025
+ for (const c of spec.add ?? []) {
1026
+ if (!set.has(c)) {
1027
+ set.add(c);
1028
+ out.push(c);
1029
+ }
1030
+ }
1031
+ if (out.length === 0) el.removeAttribute("class");
1032
+ else el.setAttribute("class", out.join(" "));
1033
+ }
1034
+ function isRawText(el) {
1035
+ return RAW_TEXT.has(el.localName.toLowerCase());
1036
+ }
1037
+ function serializeChildren2(el) {
1038
+ if (isRawText(el)) {
1039
+ let out2 = "";
1040
+ let child2 = el.firstChild;
1041
+ while (child2) {
1042
+ if (child2.nodeType === 3) out2 += child2.data;
1043
+ child2 = child2.nextSibling;
1044
+ }
1045
+ return out2;
1046
+ }
1047
+ let out = "";
1048
+ let child = el.firstChild;
1049
+ while (child) {
1050
+ out += serialize(child);
1051
+ child = child.nextSibling;
1052
+ }
1053
+ return out;
1054
+ }
1055
+ function checkTextPayload(doc, el, text) {
1056
+ if (isRawText(el)) return null;
1057
+ const frag = parseFragment(doc, text);
1058
+ return rejectScriptsAndHandlers(frag);
1059
+ }
1060
+ function setChildren(doc, el, text) {
1061
+ while (el.firstChild) el.removeChild(el.firstChild);
1062
+ if (isRawText(el)) {
1063
+ el.appendChild(doc.createTextNode(text));
1064
+ return;
1065
+ }
1066
+ el.appendChild(parseFragment(doc, text));
1067
+ }
1068
+ function applyInsert(doc, op, options) {
1069
+ const miss = requireIdHit(doc, op.parentId);
1070
+ if (miss) return { ok: false, error: miss };
1071
+ const parent = findById(doc, op.parentId);
1072
+ const canonical = requireCanonicalFragment(doc, op.html);
1073
+ if (canonical) return { ok: false, error: canonical };
1074
+ const frag = parseFragment(doc, op.html);
1075
+ const single = requireSingleRoot(frag);
1076
+ if (single) return { ok: false, error: single };
1077
+ const scripts = rejectScriptsAndHandlers(frag);
1078
+ if (scripts) return { ok: false, error: scripts };
1079
+ const idErr = requireFragmentIds(frag, collectDocIds(doc));
1080
+ if (idErr) return { ok: false, error: idErr };
1081
+ const root = fragmentElementRoots(frag)[0];
1082
+ const childLayer = layerOf(root, options.profile);
1083
+ if (!childLayer) {
1084
+ return { ok: false, error: editorError("STRUCTURE", { params: { reason: "unknown-layer" } }) };
1085
+ }
1086
+ const rejection = canContain(parent, childLayer, options.profile);
1087
+ if (rejection) {
1088
+ return { ok: false, error: editorError("STRUCTURE", { ptId: op.parentId, params: { reason: rejection } }) };
1089
+ }
1090
+ const newId = root.getAttribute("data-pt-id");
1091
+ const at = resolveOffset(parent, op.index, op.nodeIndex);
1092
+ parent.insertBefore(frag, parent.childNodes[at] ?? null);
1093
+ return { ok: true, inverse: { op: "delete", id: newId } };
1094
+ }
1095
+ function applyDelete(doc, op, options) {
1096
+ const miss = requireIdHit(doc, op.id);
1097
+ if (miss) return { ok: false, error: miss };
1098
+ const el = findById(doc, op.id);
1099
+ const opaque = closestOpaque(el);
1100
+ if (opaque && opaque.host !== el) {
1101
+ return { ok: false, error: editorError("STRUCTURE", { ptId: op.id, params: { reason: "opaque-subtree" } }) };
1102
+ }
1103
+ const target = deleteTarget(el, options.profile);
1104
+ const parent = target.parentElement;
1105
+ if (!parent) {
1106
+ return { ok: false, error: editorError("STRUCTURE", { ptId: op.id, params: { reason: "no-parent" } }) };
1107
+ }
1108
+ const parentId = parent.getAttribute("data-pt-id");
1109
+ if (!parentId) {
1110
+ return { ok: false, error: editorError("STRUCTURE", { ptId: op.id, params: { reason: "parent-has-no-id" } }) };
1111
+ }
1112
+ const nodeIndex = nodeOffset(parent, target);
1113
+ const html = serialize(target);
1114
+ parent.removeChild(target);
1115
+ return {
1116
+ ok: true,
1117
+ // 逆操作带上精确的 childNodes 偏移,空白节点才回得到原位。
1118
+ inverse: { op: "insert", parentId, index: 0, html, nodeIndex }
1119
+ };
1120
+ }
1121
+ function applyMove(doc, op, options) {
1122
+ const missSelf = requireIdHit(doc, op.id);
1123
+ if (missSelf) return { ok: false, error: missSelf };
1124
+ const missParent = requireIdHit(doc, op.parentId);
1125
+ if (missParent) return { ok: false, error: missParent };
1126
+ const el = findById(doc, op.id);
1127
+ const parent = findById(doc, op.parentId);
1128
+ if (el === parent || el.contains(parent)) {
1129
+ return { ok: false, error: editorError("STRUCTURE", { ptId: op.id, params: { reason: "move-into-self" } }) };
1130
+ }
1131
+ const layer = layerOf(el, options.profile);
1132
+ if (!layer) {
1133
+ return { ok: false, error: editorError("STRUCTURE", { ptId: op.id, params: { reason: "unknown-layer" } }) };
1134
+ }
1135
+ const rejection = canContain(parent, layer, options.profile);
1136
+ if (rejection) {
1137
+ return { ok: false, error: editorError("STRUCTURE", { ptId: op.parentId, params: { reason: rejection } }) };
1138
+ }
1139
+ const oldParent = el.parentElement;
1140
+ const oldParentId = oldParent?.getAttribute("data-pt-id");
1141
+ if (!oldParent || !oldParentId) {
1142
+ return { ok: false, error: editorError("STRUCTURE", { ptId: op.id, params: { reason: "parent-has-no-id" } }) };
1143
+ }
1144
+ const oldNodeIndex = nodeOffset(oldParent, el);
1145
+ const at = resolveOffset(parent, op.index, op.nodeIndex, el);
1146
+ parent.insertBefore(el, parent.childNodes[at] ?? null);
1147
+ return {
1148
+ ok: true,
1149
+ inverse: { op: "move", id: op.id, parentId: oldParentId, index: 0, nodeIndex: oldNodeIndex }
1150
+ };
1151
+ }
1152
+ function applyReplace(doc, op) {
1153
+ const miss = requireIdHit(doc, op.id);
1154
+ if (miss) return { ok: false, error: miss };
1155
+ const el = findById(doc, op.id);
1156
+ const canonical = requireCanonicalFragment(doc, op.html);
1157
+ if (canonical) return { ok: false, error: canonical };
1158
+ const frag = parseFragment(doc, op.html);
1159
+ const single = requireSingleRoot(frag);
1160
+ if (single) return { ok: false, error: single };
1161
+ const scripts = rejectScriptsAndHandlers(frag);
1162
+ if (scripts) return { ok: false, error: scripts };
1163
+ const root = fragmentElementRoots(frag)[0];
1164
+ const rootId = root.getAttribute("data-pt-id");
1165
+ if (rootId !== op.id) {
1166
+ return {
1167
+ ok: false,
1168
+ error: editorError("REPLACE_ID_CHANGED", { ptId: op.id, params: { got: rootId ?? "" } })
1169
+ };
1170
+ }
1171
+ const existing = collectDocIds(doc);
1172
+ for (const id of collectIdsIn(el)) existing.delete(id);
1173
+ const idErr = requireFragmentIds(frag, existing);
1174
+ if (idErr) return { ok: false, error: idErr };
1175
+ const before = serialize(el);
1176
+ el.parentNode.replaceChild(frag, el);
1177
+ return { ok: true, inverse: { op: "replace", id: op.id, html: before } };
1178
+ }
1179
+ function resolveOffset(parent, elementIndex, nodeIndex, moving) {
1180
+ if (typeof nodeIndex === "number") {
1181
+ let target = nodeIndex;
1182
+ if (moving && moving.parentElement === parent) {
1183
+ const cur = nodeOffset(parent, moving);
1184
+ if (cur < nodeIndex) target = nodeIndex + 1;
1185
+ }
1186
+ return Math.max(0, Math.min(target, parent.childNodes.length));
1187
+ }
1188
+ const children = parent.childNodes;
1189
+ let seen = 0;
1190
+ for (let i = 0; i < children.length; i++) {
1191
+ const node = children[i];
1192
+ if (node.nodeType !== 1) continue;
1193
+ if (node === moving) continue;
1194
+ if (seen === elementIndex) return i;
1195
+ seen += 1;
1196
+ }
1197
+ return children.length;
1198
+ }
1199
+ function nodeOffset(parent, node) {
1200
+ const children = parent.childNodes;
1201
+ for (let i = 0; i < children.length; i++) {
1202
+ if (children[i] === node) return i;
1203
+ }
1204
+ return children.length;
1205
+ }
1206
+ function collectDocIds(doc) {
1207
+ const out = /* @__PURE__ */ new Set();
1208
+ const nodes = doc.querySelectorAll("[data-pt-id]");
1209
+ for (let i = 0; i < nodes.length; i++) {
1210
+ const v = nodes[i].getAttribute("data-pt-id");
1211
+ if (v) out.add(v);
1212
+ }
1213
+ return out;
1214
+ }
1215
+ function collectIdsIn(el) {
1216
+ const out = /* @__PURE__ */ new Set();
1217
+ const self = el.getAttribute("data-pt-id");
1218
+ if (self) out.add(self);
1219
+ const nodes = el.querySelectorAll("[data-pt-id]");
1220
+ for (let i = 0; i < nodes.length; i++) {
1221
+ const v = nodes[i].getAttribute("data-pt-id");
1222
+ if (v) out.add(v);
1223
+ }
1224
+ return out;
1225
+ }
1226
+
1227
+ // src/compile/index.ts
1228
+ var compile_exports = {};
1229
+ __export(compile_exports, {
1230
+ EMPTY_THEME: () => EMPTY_THEME,
1231
+ canCompile: () => canCompile,
1232
+ clearCompileCache: () => clearCompileCache,
1233
+ fresh: () => fresh,
1234
+ incremental: () => incremental,
1235
+ mergeClasses: () => mergeClasses,
1236
+ themeFromSource: () => themeFromSource,
1237
+ themeOf: () => themeOf,
1238
+ themeTokens: () => themeTokens,
1239
+ warm: () => warm
1240
+ });
1241
+
1242
+ // src/generated/tw-css.ts
1243
+ var THEME_CSS = "@theme default {\n --font-sans:\n -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', 'Noto Sans', Arial,\n sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji';\n --font-serif: ui-serif, Georgia, Cambria, 'Times New Roman', Times, serif;\n --font-mono:\n ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', 'Courier New',\n monospace;\n\n --color-red-50: oklch(97.1% 0.013 17.38);\n --color-red-100: oklch(93.6% 0.032 17.717);\n --color-red-200: oklch(88.5% 0.062 18.334);\n --color-red-300: oklch(80.8% 0.114 19.571);\n --color-red-400: oklch(70.4% 0.191 22.216);\n --color-red-500: oklch(63.7% 0.237 25.331);\n --color-red-600: oklch(57.7% 0.245 27.325);\n --color-red-700: oklch(50.5% 0.213 27.518);\n --color-red-800: oklch(44.4% 0.177 26.899);\n --color-red-900: oklch(39.6% 0.141 25.723);\n --color-red-950: oklch(25.8% 0.092 26.042);\n\n --color-orange-50: oklch(98% 0.016 73.684);\n --color-orange-100: oklch(95.4% 0.038 75.164);\n --color-orange-200: oklch(90.1% 0.076 70.697);\n --color-orange-300: oklch(83.7% 0.128 66.29);\n --color-orange-400: oklch(75% 0.183 55.934);\n --color-orange-500: oklch(70.5% 0.213 47.604);\n --color-orange-600: oklch(64.6% 0.222 41.116);\n --color-orange-700: oklch(55.3% 0.195 38.402);\n --color-orange-800: oklch(47% 0.157 37.304);\n --color-orange-900: oklch(40.8% 0.123 38.172);\n --color-orange-950: oklch(26.6% 0.079 36.259);\n\n --color-amber-50: oklch(98.7% 0.022 95.277);\n --color-amber-100: oklch(96.2% 0.059 95.617);\n --color-amber-200: oklch(92.4% 0.12 95.746);\n --color-amber-300: oklch(87.9% 0.169 91.605);\n --color-amber-400: oklch(82.8% 0.189 84.429);\n --color-amber-500: oklch(76.9% 0.188 70.08);\n --color-amber-600: oklch(66.6% 0.179 58.318);\n --color-amber-700: oklch(55.5% 0.163 48.998);\n --color-amber-800: oklch(47.3% 0.137 46.201);\n --color-amber-900: oklch(41.4% 0.112 45.904);\n --color-amber-950: oklch(27.9% 0.077 45.635);\n\n --color-yellow-50: oklch(98.7% 0.026 102.212);\n --color-yellow-100: oklch(97.3% 0.071 103.193);\n --color-yellow-200: oklch(94.5% 0.129 101.54);\n --color-yellow-300: oklch(90.5% 0.182 98.111);\n --color-yellow-400: oklch(85.2% 0.199 91.936);\n --color-yellow-500: oklch(79.5% 0.184 86.047);\n --color-yellow-600: oklch(68.1% 0.162 75.834);\n --color-yellow-700: oklch(55.4% 0.135 66.442);\n --color-yellow-800: oklch(47.6% 0.114 61.907);\n --color-yellow-900: oklch(42.1% 0.095 57.708);\n --color-yellow-950: oklch(28.6% 0.066 53.813);\n\n --color-lime-50: oklch(98.6% 0.031 120.757);\n --color-lime-100: oklch(96.7% 0.067 122.328);\n --color-lime-200: oklch(93.8% 0.127 124.321);\n --color-lime-300: oklch(89.7% 0.196 126.665);\n --color-lime-400: oklch(84.1% 0.238 128.85);\n --color-lime-500: oklch(76.8% 0.233 130.85);\n --color-lime-600: oklch(64.8% 0.2 131.684);\n --color-lime-700: oklch(53.2% 0.157 131.589);\n --color-lime-800: oklch(45.3% 0.124 130.933);\n --color-lime-900: oklch(40.5% 0.101 131.063);\n --color-lime-950: oklch(27.4% 0.072 132.109);\n\n --color-green-50: oklch(98.2% 0.018 155.826);\n --color-green-100: oklch(96.2% 0.044 156.743);\n --color-green-200: oklch(92.5% 0.084 155.995);\n --color-green-300: oklch(87.1% 0.15 154.449);\n --color-green-400: oklch(79.2% 0.209 151.711);\n --color-green-500: oklch(72.3% 0.219 149.579);\n --color-green-600: oklch(62.7% 0.194 149.214);\n --color-green-700: oklch(52.7% 0.154 150.069);\n --color-green-800: oklch(44.8% 0.119 151.328);\n --color-green-900: oklch(39.3% 0.095 152.535);\n --color-green-950: oklch(26.6% 0.065 152.934);\n\n --color-emerald-50: oklch(97.9% 0.021 166.113);\n --color-emerald-100: oklch(95% 0.052 163.051);\n --color-emerald-200: oklch(90.5% 0.093 164.15);\n --color-emerald-300: oklch(84.5% 0.143 164.978);\n --color-emerald-400: oklch(76.5% 0.177 163.223);\n --color-emerald-500: oklch(69.6% 0.17 162.48);\n --color-emerald-600: oklch(59.6% 0.145 163.225);\n --color-emerald-700: oklch(50.8% 0.118 165.612);\n --color-emerald-800: oklch(43.2% 0.095 166.913);\n --color-emerald-900: oklch(37.8% 0.077 168.94);\n --color-emerald-950: oklch(26.2% 0.051 172.552);\n\n --color-teal-50: oklch(98.4% 0.014 180.72);\n --color-teal-100: oklch(95.3% 0.051 180.801);\n --color-teal-200: oklch(91% 0.096 180.426);\n --color-teal-300: oklch(85.5% 0.138 181.071);\n --color-teal-400: oklch(77.7% 0.152 181.912);\n --color-teal-500: oklch(70.4% 0.14 182.503);\n --color-teal-600: oklch(60% 0.118 184.704);\n --color-teal-700: oklch(51.1% 0.096 186.391);\n --color-teal-800: oklch(43.7% 0.078 188.216);\n --color-teal-900: oklch(38.6% 0.063 188.416);\n --color-teal-950: oklch(27.7% 0.046 192.524);\n\n --color-cyan-50: oklch(98.4% 0.019 200.873);\n --color-cyan-100: oklch(95.6% 0.045 203.388);\n --color-cyan-200: oklch(91.7% 0.08 205.041);\n --color-cyan-300: oklch(86.5% 0.127 207.078);\n --color-cyan-400: oklch(78.9% 0.154 211.53);\n --color-cyan-500: oklch(71.5% 0.143 215.221);\n --color-cyan-600: oklch(60.9% 0.126 221.723);\n --color-cyan-700: oklch(52% 0.105 223.128);\n --color-cyan-800: oklch(45% 0.085 224.283);\n --color-cyan-900: oklch(39.8% 0.07 227.392);\n --color-cyan-950: oklch(30.2% 0.056 229.695);\n\n --color-sky-50: oklch(97.7% 0.013 236.62);\n --color-sky-100: oklch(95.1% 0.026 236.824);\n --color-sky-200: oklch(90.1% 0.058 230.902);\n --color-sky-300: oklch(82.8% 0.111 230.318);\n --color-sky-400: oklch(74.6% 0.16 232.661);\n --color-sky-500: oklch(68.5% 0.169 237.323);\n --color-sky-600: oklch(58.8% 0.158 241.966);\n --color-sky-700: oklch(50% 0.134 242.749);\n --color-sky-800: oklch(44.3% 0.11 240.79);\n --color-sky-900: oklch(39.1% 0.09 240.876);\n --color-sky-950: oklch(29.3% 0.066 243.157);\n\n --color-blue-50: oklch(97% 0.014 254.604);\n --color-blue-100: oklch(93.2% 0.032 255.585);\n --color-blue-200: oklch(88.2% 0.059 254.128);\n --color-blue-300: oklch(80.9% 0.105 251.813);\n --color-blue-400: oklch(70.7% 0.165 254.624);\n --color-blue-500: oklch(62.3% 0.214 259.815);\n --color-blue-600: oklch(54.6% 0.245 262.881);\n --color-blue-700: oklch(48.8% 0.243 264.376);\n --color-blue-800: oklch(42.4% 0.199 265.638);\n --color-blue-900: oklch(37.9% 0.146 265.522);\n --color-blue-950: oklch(28.2% 0.091 267.935);\n\n --color-indigo-50: oklch(96.2% 0.018 272.314);\n --color-indigo-100: oklch(93% 0.034 272.788);\n --color-indigo-200: oklch(87% 0.065 274.039);\n --color-indigo-300: oklch(78.5% 0.115 274.713);\n --color-indigo-400: oklch(67.3% 0.182 276.935);\n --color-indigo-500: oklch(58.5% 0.233 277.117);\n --color-indigo-600: oklch(51.1% 0.262 276.966);\n --color-indigo-700: oklch(45.7% 0.24 277.023);\n --color-indigo-800: oklch(39.8% 0.195 277.366);\n --color-indigo-900: oklch(35.9% 0.144 278.697);\n --color-indigo-950: oklch(25.7% 0.09 281.288);\n\n --color-violet-50: oklch(96.9% 0.016 293.756);\n --color-violet-100: oklch(94.3% 0.029 294.588);\n --color-violet-200: oklch(89.4% 0.057 293.283);\n --color-violet-300: oklch(81.1% 0.111 293.571);\n --color-violet-400: oklch(70.2% 0.183 293.541);\n --color-violet-500: oklch(60.6% 0.25 292.717);\n --color-violet-600: oklch(54.1% 0.281 293.009);\n --color-violet-700: oklch(49.1% 0.27 292.581);\n --color-violet-800: oklch(43.2% 0.232 292.759);\n --color-violet-900: oklch(38% 0.189 293.745);\n --color-violet-950: oklch(28.3% 0.141 291.089);\n\n --color-purple-50: oklch(97.7% 0.014 308.299);\n --color-purple-100: oklch(94.6% 0.033 307.174);\n --color-purple-200: oklch(90.2% 0.063 306.703);\n --color-purple-300: oklch(82.7% 0.119 306.383);\n --color-purple-400: oklch(71.4% 0.203 305.504);\n --color-purple-500: oklch(62.7% 0.265 303.9);\n --color-purple-600: oklch(55.8% 0.288 302.321);\n --color-purple-700: oklch(49.6% 0.265 301.924);\n --color-purple-800: oklch(43.8% 0.218 303.724);\n --color-purple-900: oklch(38.1% 0.176 304.987);\n --color-purple-950: oklch(29.1% 0.149 302.717);\n\n --color-fuchsia-50: oklch(97.7% 0.017 320.058);\n --color-fuchsia-100: oklch(95.2% 0.037 318.852);\n --color-fuchsia-200: oklch(90.3% 0.076 319.62);\n --color-fuchsia-300: oklch(83.3% 0.145 321.434);\n --color-fuchsia-400: oklch(74% 0.238 322.16);\n --color-fuchsia-500: oklch(66.7% 0.295 322.15);\n --color-fuchsia-600: oklch(59.1% 0.293 322.896);\n --color-fuchsia-700: oklch(51.8% 0.253 323.949);\n --color-fuchsia-800: oklch(45.2% 0.211 324.591);\n --color-fuchsia-900: oklch(40.1% 0.17 325.612);\n --color-fuchsia-950: oklch(29.3% 0.136 325.661);\n\n --color-pink-50: oklch(97.1% 0.014 343.198);\n --color-pink-100: oklch(94.8% 0.028 342.258);\n --color-pink-200: oklch(89.9% 0.061 343.231);\n --color-pink-300: oklch(82.3% 0.12 346.018);\n --color-pink-400: oklch(71.8% 0.202 349.761);\n --color-pink-500: oklch(65.6% 0.241 354.308);\n --color-pink-600: oklch(59.2% 0.249 0.584);\n --color-pink-700: oklch(52.5% 0.223 3.958);\n --color-pink-800: oklch(45.9% 0.187 3.815);\n --color-pink-900: oklch(40.8% 0.153 2.432);\n --color-pink-950: oklch(28.4% 0.109 3.907);\n\n --color-rose-50: oklch(96.9% 0.015 12.422);\n --color-rose-100: oklch(94.1% 0.03 12.58);\n --color-rose-200: oklch(89.2% 0.058 10.001);\n --color-rose-300: oklch(81% 0.117 11.638);\n --color-rose-400: oklch(71.2% 0.194 13.428);\n --color-rose-500: oklch(64.5% 0.246 16.439);\n --color-rose-600: oklch(58.6% 0.253 17.585);\n --color-rose-700: oklch(51.4% 0.222 16.935);\n --color-rose-800: oklch(45.5% 0.188 13.697);\n --color-rose-900: oklch(41% 0.159 10.272);\n --color-rose-950: oklch(27.1% 0.105 12.094);\n\n --color-slate-50: oklch(98.4% 0.003 247.858);\n --color-slate-100: oklch(96.8% 0.007 247.896);\n --color-slate-200: oklch(92.9% 0.013 255.508);\n --color-slate-300: oklch(86.9% 0.022 252.894);\n --color-slate-400: oklch(70.4% 0.04 256.788);\n --color-slate-500: oklch(55.4% 0.046 257.417);\n --color-slate-600: oklch(44.6% 0.043 257.281);\n --color-slate-700: oklch(37.2% 0.044 257.287);\n --color-slate-800: oklch(27.9% 0.041 260.031);\n --color-slate-900: oklch(20.8% 0.042 265.755);\n --color-slate-950: oklch(12.9% 0.042 264.695);\n\n --color-gray-50: oklch(98.5% 0.002 247.839);\n --color-gray-100: oklch(96.7% 0.003 264.542);\n --color-gray-200: oklch(92.8% 0.006 264.531);\n --color-gray-300: oklch(87.2% 0.01 258.338);\n --color-gray-400: oklch(70.7% 0.022 261.325);\n --color-gray-500: oklch(55.1% 0.027 264.364);\n --color-gray-600: oklch(44.6% 0.03 256.802);\n --color-gray-700: oklch(37.3% 0.034 259.733);\n --color-gray-800: oklch(27.8% 0.033 256.848);\n --color-gray-900: oklch(21% 0.034 264.665);\n --color-gray-950: oklch(13% 0.028 261.692);\n\n --color-zinc-50: oklch(98.5% 0 none);\n --color-zinc-100: oklch(96.7% 0.001 286.375);\n --color-zinc-200: oklch(92% 0.004 286.32);\n --color-zinc-300: oklch(87.1% 0.006 286.286);\n --color-zinc-400: oklch(70.5% 0.015 286.067);\n --color-zinc-500: oklch(55.2% 0.016 285.938);\n --color-zinc-600: oklch(44.2% 0.017 285.786);\n --color-zinc-700: oklch(37% 0.013 285.805);\n --color-zinc-800: oklch(27.4% 0.006 286.033);\n --color-zinc-900: oklch(21% 0.006 285.885);\n --color-zinc-950: oklch(14.1% 0.005 285.823);\n\n --color-neutral-50: oklch(98.5% 0 none);\n --color-neutral-100: oklch(97% 0 none);\n --color-neutral-200: oklch(92.2% 0 none);\n --color-neutral-300: oklch(87% 0 none);\n --color-neutral-400: oklch(70.8% 0 none);\n --color-neutral-500: oklch(55.6% 0 none);\n --color-neutral-600: oklch(43.9% 0 none);\n --color-neutral-700: oklch(37.1% 0 none);\n --color-neutral-800: oklch(26.9% 0 none);\n --color-neutral-900: oklch(20.5% 0 none);\n --color-neutral-950: oklch(14.5% 0 none);\n\n --color-stone-50: oklch(98.5% 0.001 106.423);\n --color-stone-100: oklch(97% 0.001 106.424);\n --color-stone-200: oklch(92.3% 0.003 48.717);\n --color-stone-300: oklch(86.9% 0.005 56.366);\n --color-stone-400: oklch(70.9% 0.01 56.259);\n --color-stone-500: oklch(55.3% 0.013 58.071);\n --color-stone-600: oklch(44.4% 0.011 73.639);\n --color-stone-700: oklch(37.4% 0.01 67.558);\n --color-stone-800: oklch(26.8% 0.007 34.298);\n --color-stone-900: oklch(21.6% 0.006 56.043);\n --color-stone-950: oklch(14.7% 0.004 49.25);\n\n --color-mauve-50: oklch(98.5% 0 none);\n --color-mauve-100: oklch(96% 0.003 325.6);\n --color-mauve-200: oklch(92.2% 0.005 325.62);\n --color-mauve-300: oklch(86.5% 0.012 325.68);\n --color-mauve-400: oklch(71.1% 0.019 323.02);\n --color-mauve-500: oklch(54.2% 0.034 322.5);\n --color-mauve-600: oklch(43.5% 0.029 321.78);\n --color-mauve-700: oklch(36.4% 0.029 323.89);\n --color-mauve-800: oklch(26.3% 0.024 320.12);\n --color-mauve-900: oklch(21.2% 0.019 322.12);\n --color-mauve-950: oklch(14.5% 0.008 326);\n\n --color-olive-50: oklch(98.8% 0.003 106.5);\n --color-olive-100: oklch(96.6% 0.005 106.5);\n --color-olive-200: oklch(93% 0.007 106.5);\n --color-olive-300: oklch(88% 0.011 106.6);\n --color-olive-400: oklch(73.7% 0.021 106.9);\n --color-olive-500: oklch(58% 0.031 107.3);\n --color-olive-600: oklch(46.6% 0.025 107.3);\n --color-olive-700: oklch(39.4% 0.023 107.4);\n --color-olive-800: oklch(28.6% 0.016 107.4);\n --color-olive-900: oklch(22.8% 0.013 107.4);\n --color-olive-950: oklch(15.3% 0.006 107.1);\n\n --color-mist-50: oklch(98.7% 0.002 197.1);\n --color-mist-100: oklch(96.3% 0.002 197.1);\n --color-mist-200: oklch(92.5% 0.005 214.3);\n --color-mist-300: oklch(87.2% 0.007 219.6);\n --color-mist-400: oklch(72.3% 0.014 214.4);\n --color-mist-500: oklch(56% 0.021 213.5);\n --color-mist-600: oklch(45% 0.017 213.2);\n --color-mist-700: oklch(37.8% 0.015 216);\n --color-mist-800: oklch(27.5% 0.011 216.9);\n --color-mist-900: oklch(21.8% 0.008 223.9);\n --color-mist-950: oklch(14.8% 0.004 228.8);\n\n --color-taupe-50: oklch(98.6% 0.002 67.8);\n --color-taupe-100: oklch(96% 0.002 17.2);\n --color-taupe-200: oklch(92.2% 0.005 34.3);\n --color-taupe-300: oklch(86.8% 0.007 39.5);\n --color-taupe-400: oklch(71.4% 0.014 41.2);\n --color-taupe-500: oklch(54.7% 0.021 43.1);\n --color-taupe-600: oklch(43.8% 0.017 39.3);\n --color-taupe-700: oklch(36.7% 0.016 35.7);\n --color-taupe-800: oklch(26.8% 0.011 36.5);\n --color-taupe-900: oklch(21.4% 0.009 43.1);\n --color-taupe-950: oklch(14.7% 0.004 49.3);\n\n --color-black: #000;\n --color-white: #fff;\n\n --spacing: 0.25rem;\n\n --breakpoint-sm: 40rem;\n --breakpoint-md: 48rem;\n --breakpoint-lg: 64rem;\n --breakpoint-xl: 80rem;\n --breakpoint-2xl: 96rem;\n\n --container-3xs: 16rem;\n --container-2xs: 18rem;\n --container-xs: 20rem;\n --container-sm: 24rem;\n --container-md: 28rem;\n --container-lg: 32rem;\n --container-xl: 36rem;\n --container-2xl: 42rem;\n --container-3xl: 48rem;\n --container-4xl: 56rem;\n --container-5xl: 64rem;\n --container-6xl: 72rem;\n --container-7xl: 80rem;\n\n --text-xs: 0.75rem;\n --text-xs--line-height: calc(1 / 0.75);\n --text-sm: 0.875rem;\n --text-sm--line-height: calc(1.25 / 0.875);\n --text-base: 1rem;\n --text-base--line-height: calc(1.5 / 1);\n --text-lg: 1.125rem;\n --text-lg--line-height: calc(1.75 / 1.125);\n --text-xl: 1.25rem;\n --text-xl--line-height: calc(1.75 / 1.25);\n --text-2xl: 1.5rem;\n --text-2xl--line-height: calc(2 / 1.5);\n --text-3xl: 1.875rem;\n --text-3xl--line-height: calc(2.25 / 1.875);\n --text-4xl: 2.25rem;\n --text-4xl--line-height: calc(2.5 / 2.25);\n --text-5xl: 3rem;\n --text-5xl--line-height: 1;\n --text-6xl: 3.75rem;\n --text-6xl--line-height: 1;\n --text-7xl: 4.5rem;\n --text-7xl--line-height: 1;\n --text-8xl: 6rem;\n --text-8xl--line-height: 1;\n --text-9xl: 8rem;\n --text-9xl--line-height: 1;\n\n --font-weight-thin: 100;\n --font-weight-extralight: 200;\n --font-weight-light: 300;\n --font-weight-normal: 400;\n --font-weight-medium: 500;\n --font-weight-semibold: 600;\n --font-weight-bold: 700;\n --font-weight-extrabold: 800;\n --font-weight-black: 900;\n\n --tracking-tighter: -0.05em;\n --tracking-tight: -0.025em;\n --tracking-normal: 0em;\n --tracking-wide: 0.025em;\n --tracking-wider: 0.05em;\n --tracking-widest: 0.1em;\n\n --leading-tight: 1.25;\n --leading-snug: 1.375;\n --leading-normal: 1.5;\n --leading-relaxed: 1.625;\n --leading-loose: 2;\n\n --radius-xs: 0.125rem;\n --radius-sm: 0.25rem;\n --radius-md: 0.375rem;\n --radius-lg: 0.5rem;\n --radius-xl: 0.75rem;\n --radius-2xl: 1rem;\n --radius-3xl: 1.5rem;\n --radius-4xl: 2rem;\n\n --shadow-2xs: 0 1px rgb(0 0 0 / 0.05);\n --shadow-xs: 0 1px 2px 0 rgb(0 0 0 / 0.05);\n --shadow-sm: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);\n --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);\n --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);\n --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);\n --shadow-2xl: 0 25px 50px -12px rgb(0 0 0 / 0.25);\n\n --inset-shadow-2xs: inset 0 1px rgb(0 0 0 / 0.05);\n --inset-shadow-xs: inset 0 1px 1px rgb(0 0 0 / 0.05);\n --inset-shadow-sm: inset 0 2px 4px rgb(0 0 0 / 0.05);\n\n --drop-shadow-xs: 0 1px 1px rgb(0 0 0 / 0.05);\n --drop-shadow-sm: 0 1px 2px rgb(0 0 0 / 0.15);\n --drop-shadow-md: 0 3px 3px rgb(0 0 0 / 0.12);\n --drop-shadow-lg: 0 4px 4px rgb(0 0 0 / 0.15);\n --drop-shadow-xl: 0 9px 7px rgb(0 0 0 / 0.1);\n --drop-shadow-2xl: 0 25px 25px rgb(0 0 0 / 0.15);\n\n --text-shadow-2xs: 0px 1px 0px rgb(0 0 0 / 0.15);\n --text-shadow-xs: 0px 1px 1px rgb(0 0 0 / 0.2);\n --text-shadow-sm:\n 0px 1px 0px rgb(0 0 0 / 0.075), 0px 1px 1px rgb(0 0 0 / 0.075), 0px 2px 2px rgb(0 0 0 / 0.075);\n --text-shadow-md:\n 0px 1px 1px rgb(0 0 0 / 0.1), 0px 1px 2px rgb(0 0 0 / 0.1), 0px 2px 4px rgb(0 0 0 / 0.1);\n --text-shadow-lg:\n 0px 1px 2px rgb(0 0 0 / 0.1), 0px 3px 2px rgb(0 0 0 / 0.1), 0px 4px 8px rgb(0 0 0 / 0.1);\n\n --ease-in: cubic-bezier(0.4, 0, 1, 1);\n --ease-out: cubic-bezier(0, 0, 0.2, 1);\n --ease-in-out: cubic-bezier(0.4, 0, 0.2, 1);\n\n --animate-spin: spin 1s linear infinite;\n --animate-ping: ping 1s cubic-bezier(0, 0, 0.2, 1) infinite;\n --animate-pulse: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;\n --animate-bounce: bounce 1s infinite;\n\n @keyframes spin {\n to {\n transform: rotate(360deg);\n }\n }\n\n @keyframes ping {\n 75%,\n 100% {\n transform: scale(2);\n opacity: 0;\n }\n }\n\n @keyframes pulse {\n 50% {\n opacity: 0.5;\n }\n }\n\n @keyframes bounce {\n 0%,\n 100% {\n transform: translateY(-25%);\n animation-timing-function: cubic-bezier(0.8, 0, 1, 1);\n }\n\n 50% {\n transform: none;\n animation-timing-function: cubic-bezier(0, 0, 0.2, 1);\n }\n }\n\n --blur-xs: 4px;\n --blur-sm: 8px;\n --blur-md: 12px;\n --blur-lg: 16px;\n --blur-xl: 24px;\n --blur-2xl: 40px;\n --blur-3xl: 64px;\n\n --perspective-dramatic: 100px;\n --perspective-near: 300px;\n --perspective-normal: 500px;\n --perspective-midrange: 800px;\n --perspective-distant: 1200px;\n\n --aspect-video: 16 / 9;\n\n --default-transition-duration: 150ms;\n --default-transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);\n --default-font-family: --theme(--font-sans, initial);\n --default-font-feature-settings: --theme(--font-sans--font-feature-settings, initial);\n --default-font-variation-settings: --theme(--font-sans--font-variation-settings, initial);\n --default-mono-font-family: --theme(--font-mono, initial);\n --default-mono-font-feature-settings: --theme(--font-mono--font-feature-settings, initial);\n --default-mono-font-variation-settings: --theme(--font-mono--font-variation-settings, initial);\n}\n\n/* Deprecated */\n@theme default inline reference {\n --blur: 8px;\n --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);\n --shadow-inner: inset 0 2px 4px 0 rgb(0 0 0 / 0.05);\n --drop-shadow: 0 1px 2px rgb(0 0 0 / 0.1), 0 1px 1px rgb(0 0 0 / 0.06);\n --radius: 0.25rem;\n --max-width-prose: 65ch;\n}\n";
1244
+ var PREFLIGHT_CSS = "/*\n 1. Prevent padding and border from affecting element width. (https://github.com/mozdevs/cssremedy/issues/4)\n 2. Remove default margins and padding\n 3. Reset all borders.\n*/\n\n*,\n::after,\n::before,\n::backdrop,\n::file-selector-button {\n box-sizing: border-box; /* 1 */\n margin: 0; /* 2 */\n padding: 0; /* 2 */\n border: 0 solid; /* 3 */\n}\n\n/*\n 1. Use a consistent sensible line-height in all browsers.\n 2. Prevent adjustments of font size after orientation changes in iOS.\n 3. Use a more readable tab size.\n 4. Use the user's configured `sans` font-family by default.\n 5. Use the user's configured `sans` font-feature-settings by default.\n 6. Use the user's configured `sans` font-variation-settings by default.\n 7. Disable tap highlights on iOS.\n*/\n\nhtml,\n:host {\n line-height: 1.5; /* 1 */\n -webkit-text-size-adjust: 100%; /* 2 */\n tab-size: 4; /* 3 */\n font-family: --theme(\n --default-font-family,\n -apple-system,\n BlinkMacSystemFont,\n 'Segoe UI',\n Roboto,\n 'Helvetica Neue',\n 'Noto Sans',\n Arial,\n sans-serif,\n 'Apple Color Emoji',\n 'Segoe UI Emoji',\n 'Segoe UI Symbol',\n 'Noto Color Emoji'\n ); /* 4 */\n font-feature-settings: --theme(--default-font-feature-settings, normal); /* 5 */\n font-variation-settings: --theme(--default-font-variation-settings, normal); /* 6 */\n -webkit-tap-highlight-color: transparent; /* 7 */\n}\n\n/*\n 1. Add the correct height in Firefox.\n 2. Correct the inheritance of border color in Firefox. (https://bugzilla.mozilla.org/show_bug.cgi?id=190655)\n 3. Reset the default border style to a 1px solid border.\n*/\n\nhr {\n height: 0; /* 1 */\n color: inherit; /* 2 */\n border-top-width: 1px; /* 3 */\n}\n\n/*\n Add the correct text decoration in Chrome, Edge, and Safari.\n*/\n\nabbr:where([title]) {\n -webkit-text-decoration: underline dotted;\n text-decoration: underline dotted;\n}\n\n/*\n Remove the default font size and weight for headings.\n*/\n\nh1,\nh2,\nh3,\nh4,\nh5,\nh6 {\n font-size: inherit;\n font-weight: inherit;\n}\n\n/*\n Reset links to optimize for opt-in styling instead of opt-out.\n*/\n\na {\n color: inherit;\n -webkit-text-decoration: inherit;\n text-decoration: inherit;\n}\n\n/*\n Add the correct font weight in Edge and Safari.\n*/\n\nb,\nstrong {\n font-weight: bolder;\n}\n\n/*\n 1. Use the user's configured `mono` font-family by default.\n 2. Use the user's configured `mono` font-feature-settings by default.\n 3. Use the user's configured `mono` font-variation-settings by default.\n 4. Correct the odd `em` font sizing in all browsers.\n*/\n\ncode,\nkbd,\nsamp,\npre {\n font-family: --theme(\n --default-mono-font-family,\n ui-monospace,\n SFMono-Regular,\n Menlo,\n Monaco,\n Consolas,\n 'Liberation Mono',\n 'Courier New',\n monospace\n ); /* 1 */\n font-feature-settings: --theme(--default-mono-font-feature-settings, normal); /* 2 */\n font-variation-settings: --theme(--default-mono-font-variation-settings, normal); /* 3 */\n font-size: 1em; /* 4 */\n}\n\n/*\n Add the correct font size in all browsers.\n*/\n\nsmall {\n font-size: 80%;\n}\n\n/*\n Prevent `sub` and `sup` elements from affecting the line height in all browsers.\n*/\n\nsub,\nsup {\n font-size: 75%;\n line-height: 0;\n position: relative;\n vertical-align: baseline;\n}\n\nsub {\n bottom: -0.25em;\n}\n\nsup {\n top: -0.5em;\n}\n\n/*\n 1. Remove text indentation from table contents in Chrome and Safari. (https://bugs.chromium.org/p/chromium/issues/detail?id=999088, https://bugs.webkit.org/show_bug.cgi?id=201297)\n 2. Correct table border color inheritance in all Chrome and Safari. (https://bugs.chromium.org/p/chromium/issues/detail?id=935729, https://bugs.webkit.org/show_bug.cgi?id=195016)\n 3. Remove gaps between table borders by default.\n*/\n\ntable {\n text-indent: 0; /* 1 */\n border-color: inherit; /* 2 */\n border-collapse: collapse; /* 3 */\n}\n\n/*\n Use the modern Firefox focus style for all focusable elements.\n*/\n\n:-moz-focusring:where(:not(iframe)) {\n outline: auto;\n}\n\n/*\n Add the correct vertical alignment in Chrome and Firefox.\n*/\n\nprogress {\n vertical-align: baseline;\n}\n\n/*\n Add the correct display in Chrome and Safari.\n*/\n\nsummary {\n display: list-item;\n}\n\n/*\n Make lists unstyled by default.\n*/\n\nol,\nul,\nmenu {\n list-style: none;\n}\n\n/*\n 1. Make replaced elements `display: block` by default. (https://github.com/mozdevs/cssremedy/issues/14)\n 2. Add `vertical-align: middle` to align replaced elements more sensibly by default. (https://github.com/jensimmons/cssremedy/issues/14#issuecomment-634934210)\n This can trigger a poorly considered lint error in some tools but is included by design.\n*/\n\nimg,\nsvg,\nvideo,\ncanvas,\naudio,\niframe,\nembed,\nobject {\n display: block; /* 1 */\n vertical-align: middle; /* 2 */\n}\n\n/*\n Constrain images and videos to the parent width and preserve their intrinsic aspect ratio. (https://github.com/mozdevs/cssremedy/issues/14)\n*/\n\nimg,\nvideo {\n max-width: 100%;\n height: auto;\n}\n\n/*\n 1. Inherit font styles in all browsers.\n 2. Remove border radius in all browsers.\n 3. Remove background color in all browsers.\n 4. Ensure consistent opacity for disabled states in all browsers.\n*/\n\nbutton,\ninput,\nselect,\noptgroup,\ntextarea,\n::file-selector-button {\n font: inherit; /* 1 */\n font-feature-settings: inherit; /* 1 */\n font-variation-settings: inherit; /* 1 */\n letter-spacing: inherit; /* 1 */\n color: inherit; /* 1 */\n border-radius: 0; /* 2 */\n background-color: transparent; /* 3 */\n opacity: 1; /* 4 */\n}\n\n/*\n Restore default font weight.\n*/\n\n:where(select:is([multiple], [size])) optgroup {\n font-weight: bolder;\n}\n\n/*\n Restore indentation.\n*/\n\n:where(select:is([multiple], [size])) optgroup option {\n padding-inline-start: 20px;\n}\n\n/*\n Restore space after button.\n*/\n\n::file-selector-button {\n margin-inline-end: 4px;\n}\n\n/*\n Reset the default placeholder opacity in Firefox. (https://github.com/tailwindlabs/tailwindcss/issues/3300)\n*/\n\n::placeholder {\n opacity: 1;\n}\n\n/*\n Set the default placeholder color to a semi-transparent version of the current text color in browsers that do not\n crash when using `color-mix(\u2026)` with `currentcolor`. (https://github.com/tailwindlabs/tailwindcss/issues/17194)\n*/\n\n@supports (not (-webkit-appearance: -apple-pay-button)) /* Not Safari */ or\n (contain-intrinsic-size: 1px) /* Safari 17+ */ {\n ::placeholder {\n color: color-mix(in oklab, currentcolor 50%, transparent);\n }\n}\n\n/*\n Prevent resizing textareas horizontally by default.\n*/\n\ntextarea {\n resize: vertical;\n}\n\n/*\n Remove the inner padding in Chrome and Safari on macOS.\n*/\n\n::-webkit-search-decoration {\n -webkit-appearance: none;\n}\n\n/*\n 1. Ensure date/time inputs have the same height when empty in iOS Safari.\n 2. Ensure text alignment can be changed on date/time inputs in iOS Safari.\n*/\n\n::-webkit-date-and-time-value {\n min-height: 1lh; /* 1 */\n text-align: inherit; /* 2 */\n}\n\n/*\n Prevent height from changing on date/time inputs in macOS Safari when the input is set to `display: block`.\n*/\n\n::-webkit-datetime-edit {\n display: inline-flex;\n}\n\n/*\n Remove excess padding from pseudo-elements in date/time inputs to ensure consistent height across browsers.\n*/\n\n::-webkit-datetime-edit-fields-wrapper {\n padding: 0;\n}\n\n::-webkit-datetime-edit,\n::-webkit-datetime-edit-year-field,\n::-webkit-datetime-edit-month-field,\n::-webkit-datetime-edit-day-field,\n::-webkit-datetime-edit-hour-field,\n::-webkit-datetime-edit-minute-field,\n::-webkit-datetime-edit-second-field,\n::-webkit-datetime-edit-millisecond-field,\n::-webkit-datetime-edit-meridiem-field {\n padding-block: 0;\n}\n\n/*\n Center dropdown marker shown on inputs with paired `<datalist>`s in Chrome. (https://github.com/tailwindlabs/tailwindcss/issues/18499)\n*/\n\n::-webkit-calendar-picker-indicator {\n line-height: 1;\n}\n\n/*\n Remove the additional `:invalid` styles in Firefox. (https://github.com/mozilla/gecko-dev/blob/2f9eacd9d3d995c937b4251a5557d95d494c9be1/layout/style/res/forms.css#L728-L737)\n*/\n\n:-moz-ui-invalid {\n box-shadow: none;\n}\n\n/*\n Correct the inability to style the border radius in iOS Safari.\n*/\n\nbutton,\ninput:where([type='button'], [type='reset'], [type='submit']),\n::file-selector-button {\n appearance: button;\n}\n\n/*\n Correct the cursor style of increment and decrement buttons in Safari.\n*/\n\n::-webkit-inner-spin-button,\n::-webkit-outer-spin-button {\n height: auto;\n}\n\n/*\n Make elements with the HTML hidden attribute stay hidden by default.\n*/\n\n[hidden]:where(:not([hidden='until-found'])) {\n display: none !important;\n}\n";
1245
+ var UTILITIES_CSS = "@tailwind utilities;\n";
1246
+ var TW_SHEETS = {
1247
+ "tailwindcss/theme.css": THEME_CSS,
1248
+ "tailwindcss/preflight.css": PREFLIGHT_CSS,
1249
+ "tailwindcss/utilities.css": UTILITIES_CSS
1250
+ };
1251
+
1252
+ // src/compile/theme.ts
1253
+ var EMPTY_THEME = { source: "", hash: "0" };
1254
+ function themeOf(root) {
1255
+ const el = root.querySelector(`style[data-pt-id="${THEME_PT_ID}"]`) ?? root.querySelector('style[type="text/tailwindcss"]');
1256
+ if (!el) return EMPTY_THEME;
1257
+ return themeFromSource(el.textContent ?? "");
1258
+ }
1259
+ function themeFromSource(source) {
1260
+ return { source, hash: hashString(source) };
1261
+ }
1262
+ function hashString(input) {
1263
+ let h = 2166136261;
1264
+ for (let i = 0; i < input.length; i++) {
1265
+ h ^= input.charCodeAt(i);
1266
+ h = Math.imul(h, 16777619);
1267
+ }
1268
+ return (h >>> 0).toString(36);
1269
+ }
1270
+ var NAMESPACES = [
1271
+ ["color", "--color-"],
1272
+ ["text", "--text-"],
1273
+ ["spacing", "--spacing-"],
1274
+ ["radius", "--radius-"],
1275
+ ["shadow", "--shadow-"],
1276
+ ["font", "--font-"]
1277
+ ];
1278
+ function themeTokens(theme) {
1279
+ const out = { color: [], text: [], spacing: [], radius: [], shadow: [], font: [] };
1280
+ const re = /--[a-z0-9-]+(?=\s*:)/gi;
1281
+ const seen = /* @__PURE__ */ new Set();
1282
+ for (const match of theme.source.matchAll(re)) {
1283
+ const name = match[0];
1284
+ if (seen.has(name)) continue;
1285
+ seen.add(name);
1286
+ for (const [key, prefix] of NAMESPACES) {
1287
+ if (name.startsWith(prefix)) {
1288
+ const token = name.slice(prefix.length);
1289
+ if (token && !token.includes("--")) out[key].push(token);
1290
+ break;
1291
+ }
1292
+ }
1293
+ }
1294
+ return out;
1295
+ }
1296
+
1297
+ // src/compile/index.ts
1298
+ var BASE_IMPORTS = '@import "tailwindcss/theme.css"; @import "tailwindcss/preflight.css"; @import "tailwindcss/utilities.css";';
1299
+ function inputFor(theme) {
1300
+ return theme.source ? `${BASE_IMPORTS}
1301
+ ${theme.source}` : BASE_IMPORTS;
1302
+ }
1303
+ var loadStylesheet = async (id, base) => {
1304
+ const content = TW_SHEETS[id];
1305
+ if (content === void 0) throw new Error(`lp-editor-core: \u672A\u77E5\u6837\u5F0F\u8868 ${id}`);
1306
+ return { path: `virtual:${id}`, base, content };
1307
+ };
1308
+ var compileOptions = { base: "/", loadStylesheet };
1309
+ var cache = /* @__PURE__ */ new Map();
1310
+ function entryOf(theme) {
1311
+ let e = cache.get(theme.hash);
1312
+ if (!e) {
1313
+ e = { theme, compilable: /* @__PURE__ */ new Map() };
1314
+ cache.set(theme.hash, e);
1315
+ }
1316
+ return e;
1317
+ }
1318
+ async function designSystemOf(theme) {
1319
+ const e = entryOf(theme);
1320
+ if (!e.designSystem) {
1321
+ e.designSystem = await __unstable__loadDesignSystem(
1322
+ inputFor(theme),
1323
+ compileOptions
1324
+ );
1325
+ }
1326
+ return e.designSystem;
1327
+ }
1328
+ async function incrementalOf(theme) {
1329
+ const e = entryOf(theme);
1330
+ if (!e.incremental) {
1331
+ e.incremental = await compile(inputFor(theme), compileOptions);
1332
+ }
1333
+ return e.incremental;
1334
+ }
1335
+ function twMergeOf(theme) {
1336
+ const e = entryOf(theme);
1337
+ if (!e.twMerge) {
1338
+ const t = themeTokens(theme);
1339
+ e.twMerge = extendTailwindMerge({
1340
+ extend: {
1341
+ theme: {
1342
+ color: t.color,
1343
+ text: t.text,
1344
+ spacing: t.spacing,
1345
+ radius: t.radius,
1346
+ shadow: t.shadow,
1347
+ font: t.font
1348
+ }
1349
+ }
1350
+ });
1351
+ }
1352
+ return e.twMerge;
1353
+ }
1354
+ async function incremental(candidates, theme = EMPTY_THEME) {
1355
+ const engine = await incrementalOf(theme);
1356
+ return engine.build([...candidates]);
1357
+ }
1358
+ async function fresh(candidates, theme = EMPTY_THEME) {
1359
+ const engine = await compile(inputFor(theme), compileOptions);
1360
+ return engine.build([...new Set(candidates)].sort());
1361
+ }
1362
+ async function warm(theme = EMPTY_THEME) {
1363
+ await Promise.all([designSystemOf(theme), incrementalOf(theme)]);
1364
+ twMergeOf(theme);
1365
+ }
1366
+ async function canCompile(classes, theme = EMPTY_THEME) {
1367
+ const e = entryOf(theme);
1368
+ const unknown = [...new Set(classes)].filter((c) => !e.compilable.has(c));
1369
+ if (unknown.length > 0) {
1370
+ const ds = await designSystemOf(theme);
1371
+ const css = ds.candidatesToCss(unknown);
1372
+ unknown.forEach((c, i) => e.compilable.set(c, css[i] != null));
1373
+ }
1374
+ const out = /* @__PURE__ */ new Map();
1375
+ for (const c of classes) out.set(c, e.compilable.get(c) ?? false);
1376
+ return out;
1377
+ }
1378
+ function mergeClasses(classes, theme = EMPTY_THEME) {
1379
+ return twMergeOf(theme)(...classes);
1380
+ }
1381
+ function clearCompileCache() {
1382
+ cache.clear();
1383
+ }
1384
+
1385
+ // src/collectClasses.ts
1386
+ function collectClasses(root) {
1387
+ const out = /* @__PURE__ */ new Set();
1388
+ const add = (el) => {
1389
+ const raw = el.getAttribute("class");
1390
+ if (!raw) return;
1391
+ for (const c of raw.split(/[\t\n\f\r ]+/)) if (c) out.add(c);
1392
+ };
1393
+ if ("getAttribute" in root && typeof root.getAttribute === "function") {
1394
+ add(root);
1395
+ }
1396
+ const nodes = root.querySelectorAll("[class]");
1397
+ for (let i = 0; i < nodes.length; i++) add(nodes[i]);
1398
+ return out;
1399
+ }
1400
+
1401
+ // src/index.ts
1402
+ function createCore(options) {
1403
+ if (!options || typeof options.DOMParser !== "function") {
1404
+ throw new TypeError("createCore(): \u5FC5\u987B\u6CE8\u5165 DOMParser \u6784\u9020\u5668");
1405
+ }
1406
+ const parse = createParse(options.DOMParser);
1407
+ return {
1408
+ parse,
1409
+ parseFragment,
1410
+ serialize,
1411
+ normalize,
1412
+ validate,
1413
+ apply,
1414
+ guards: guards_exports,
1415
+ compile: compile_exports,
1416
+ collectClasses,
1417
+ rules,
1418
+ KIND_PROFILES,
1419
+ VERSION,
1420
+ COMPILER_VERSION
1421
+ };
1422
+ }
1423
+
1424
+ export { COMPILER_VERSION, EMPTY_THEME, ERROR_CODES, KIND_PROFILES, PUBLISH_BLOCKING_RULES, VERSION, apply, canContain, checkVariants, collectClasses, compile_exports as compile, createCore, deleteTarget, editorError, fragmentElementRoots, guards_exports as guards, isErrorCode, isNativePaletteClass, isPublishBlocking, layerOf, normalize, normalizeClassValue, parseFragment, rules, serialize, themeFromSource, themeOf, themeTokens, validate };
1425
+ //# sourceMappingURL=index.js.map
1426
+ //# sourceMappingURL=index.js.map