@lit-pigeon/core 0.1.1

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,1382 @@
1
+ import { produce as T } from "immer";
2
+ import { nanoid as W } from "nanoid";
3
+ class V {
4
+ constructor(t) {
5
+ this._steps = [], this._selection = null, this._selectionSet = !1, this._meta = /* @__PURE__ */ new Map(), this._doc = t;
6
+ }
7
+ get steps() {
8
+ return this._steps;
9
+ }
10
+ get selection() {
11
+ return this._selection;
12
+ }
13
+ get selectionSet() {
14
+ return this._selectionSet;
15
+ }
16
+ get meta() {
17
+ return this._meta;
18
+ }
19
+ get doc() {
20
+ return this._doc;
21
+ }
22
+ addStep(t) {
23
+ return this._doc = t.apply(this._doc), this._steps.push(t), this;
24
+ }
25
+ setSelection(t) {
26
+ return this._selection = t, this._selectionSet = !0, this;
27
+ }
28
+ setMeta(t, e) {
29
+ return this._meta.set(t, e), this;
30
+ }
31
+ getMeta(t) {
32
+ return this._meta.get(t);
33
+ }
34
+ }
35
+ function m(o, t, e, n) {
36
+ return {
37
+ type: o,
38
+ path: t,
39
+ apply(r) {
40
+ return T(r, e);
41
+ },
42
+ invert(r) {
43
+ return m(`${o}:invert`, t, n, e);
44
+ }
45
+ };
46
+ }
47
+ function w() {
48
+ return W(10);
49
+ }
50
+ function b(o = 0) {
51
+ return { top: o, right: o, bottom: o, left: o };
52
+ }
53
+ function P() {
54
+ return {
55
+ content: "<p>Enter your text here</p>",
56
+ padding: b(10),
57
+ lineHeight: "1.5",
58
+ textAlign: "left"
59
+ };
60
+ }
61
+ function D() {
62
+ return {
63
+ src: "",
64
+ alt: "",
65
+ width: "auto",
66
+ padding: b(10),
67
+ alignment: "center"
68
+ };
69
+ }
70
+ function E() {
71
+ return {
72
+ content: "<p>Click me</p>",
73
+ href: "#",
74
+ backgroundColor: "#3b82f6",
75
+ textColor: "#ffffff",
76
+ borderRadius: 4,
77
+ padding: b(10),
78
+ innerPadding: { top: 12, right: 24, bottom: 12, left: 24 },
79
+ fontSize: 16,
80
+ fontWeight: "600",
81
+ alignment: "center",
82
+ fullWidth: !1
83
+ };
84
+ }
85
+ function L() {
86
+ return {
87
+ borderColor: "#e2e8f0",
88
+ borderWidth: 1,
89
+ borderStyle: "solid",
90
+ padding: b(10),
91
+ width: "100%"
92
+ };
93
+ }
94
+ function O() {
95
+ return { height: 20 };
96
+ }
97
+ function j() {
98
+ return {
99
+ icons: [],
100
+ iconSize: 32,
101
+ spacing: 8,
102
+ alignment: "center",
103
+ padding: b(10)
104
+ };
105
+ }
106
+ function z() {
107
+ return {
108
+ content: "",
109
+ padding: b(0)
110
+ };
111
+ }
112
+ function N() {
113
+ return {
114
+ backgroundUrl: "",
115
+ backgroundPosition: "center center",
116
+ mode: "fluid-height",
117
+ width: 600,
118
+ height: 400,
119
+ verticalAlign: "middle",
120
+ padding: b(0),
121
+ innerPadding: b(20),
122
+ backgroundColor: "#ffffff",
123
+ content: '<p style="color:#ffffff;font-size:24px;">Hero Title</p>'
124
+ };
125
+ }
126
+ function q() {
127
+ return {
128
+ links: [
129
+ { href: "#", text: "Home" },
130
+ { href: "#", text: "About" },
131
+ { href: "#", text: "Contact" }
132
+ ],
133
+ hamburger: "hamburger",
134
+ alignment: "center",
135
+ padding: b(10),
136
+ linkColor: "#000000",
137
+ linkFontSize: 14,
138
+ linkPadding: "10px 15px"
139
+ };
140
+ }
141
+ const $ = {
142
+ text: P,
143
+ image: D,
144
+ button: E,
145
+ divider: L,
146
+ spacer: O,
147
+ social: j,
148
+ html: z,
149
+ hero: N,
150
+ navbar: q
151
+ };
152
+ function y(o) {
153
+ const t = $[o];
154
+ if (!t)
155
+ throw new Error(`Unknown block type: ${o}`);
156
+ return t();
157
+ }
158
+ let I = null;
159
+ function U(o) {
160
+ I = o;
161
+ }
162
+ function bt(o, t) {
163
+ const e = $[o];
164
+ if (e)
165
+ return {
166
+ id: w(),
167
+ type: o,
168
+ values: { ...e(), ...t }
169
+ };
170
+ const n = I == null ? void 0 : I(o);
171
+ if (n)
172
+ return {
173
+ id: w(),
174
+ type: o,
175
+ values: { ...structuredClone(n), ...t }
176
+ };
177
+ throw new Error(`Unknown block type: ${o}`);
178
+ }
179
+ function B(o = []) {
180
+ return {
181
+ id: w(),
182
+ type: "column",
183
+ attributes: {
184
+ padding: b(0),
185
+ verticalAlign: "top"
186
+ },
187
+ blocks: o
188
+ };
189
+ }
190
+ function ht(o, t) {
191
+ const e = o ?? [B()], n = t ?? e.map(() => Math.floor(12 / e.length));
192
+ return {
193
+ id: w(),
194
+ type: "row",
195
+ attributes: {
196
+ padding: b(0),
197
+ fullWidth: !1
198
+ },
199
+ columns: e,
200
+ columnRatios: n,
201
+ locked: !1
202
+ };
203
+ }
204
+ function F(o = "Untitled") {
205
+ const t = (/* @__PURE__ */ new Date()).toISOString();
206
+ return {
207
+ version: "1.0",
208
+ metadata: {
209
+ name: o,
210
+ createdAt: t,
211
+ updatedAt: t
212
+ },
213
+ body: {
214
+ attributes: {
215
+ width: 600,
216
+ backgroundColor: "#f4f4f5",
217
+ fontFamily: "Arial, Helvetica, sans-serif",
218
+ contentAlignment: "center"
219
+ },
220
+ rows: []
221
+ }
222
+ };
223
+ }
224
+ class A {
225
+ constructor(t, e, n, r) {
226
+ this.doc = t, this.selection = e, this.plugins = n, this._pluginList = r;
227
+ }
228
+ static create(t = {}) {
229
+ const e = t.doc ?? F(), n = t.plugins ?? [], r = /* @__PURE__ */ new Map(), s = new A(e, null, r, n);
230
+ for (const i of n)
231
+ i.init && r.set(i.name, i.init(s));
232
+ return s;
233
+ }
234
+ createTransaction() {
235
+ return new V(this.doc);
236
+ }
237
+ apply(t) {
238
+ let e = t.doc;
239
+ const n = t.selectionSet ? t.selection : this.selection, r = new Map(this.plugins);
240
+ for (const i of this._pluginList)
241
+ if (i.apply) {
242
+ const l = r.get(i.name);
243
+ r.set(i.name, i.apply(t, l));
244
+ }
245
+ t.steps.length > 0 && !t.getMeta("skipTimestamp") && (e = T(e, (i) => {
246
+ i.metadata.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
247
+ }));
248
+ const s = new A(e, n, r, this._pluginList);
249
+ for (const i of this._pluginList)
250
+ i.onStateChange && i.onStateChange(s, this);
251
+ return s;
252
+ }
253
+ getPluginState(t) {
254
+ return this.plugins.get(t);
255
+ }
256
+ }
257
+ function S(o, t, e) {
258
+ return { type: "block", rowId: o, columnId: t, blockId: e };
259
+ }
260
+ function C(o) {
261
+ return { type: "row", rowId: o };
262
+ }
263
+ function yt(o, t) {
264
+ return { type: "column", rowId: o, columnId: t };
265
+ }
266
+ function wt() {
267
+ return { type: "body" };
268
+ }
269
+ function kt(o, t) {
270
+ return o === t ? !0 : !o || !t ? !1 : o.type === t.type && o.rowId === t.rowId && o.columnId === t.columnId && o.blockId === t.blockId;
271
+ }
272
+ function k(o, t, e) {
273
+ const n = o.body.rows.findIndex((s) => s.id === t);
274
+ if (n === -1) return null;
275
+ const r = o.body.rows[n].columns.findIndex((s) => s.id === e);
276
+ return r === -1 ? null : { rowIndex: n, columnIndex: r };
277
+ }
278
+ function xt(o, t, e, n) {
279
+ return (r, s) => {
280
+ const i = k(r.doc, o, t);
281
+ if (!i) return !1;
282
+ const l = r.doc.body.rows[i.rowIndex].columns[i.columnIndex], c = n ?? l.blocks.length;
283
+ if (s) {
284
+ const a = r.createTransaction(), u = m(
285
+ "insertBlock",
286
+ `body.rows[${i.rowIndex}].columns[${i.columnIndex}].blocks`,
287
+ (d) => {
288
+ d.body.rows[i.rowIndex].columns[i.columnIndex].blocks.splice(c, 0, e);
289
+ },
290
+ (d) => {
291
+ d.body.rows[i.rowIndex].columns[i.columnIndex].blocks.splice(c, 1);
292
+ }
293
+ );
294
+ a.addStep(u), a.setSelection(S(o, t, e.id)), s(a);
295
+ }
296
+ return !0;
297
+ };
298
+ }
299
+ function It(o, t, e) {
300
+ return (n, r) => {
301
+ const s = k(n.doc, o, t);
302
+ if (!s) return !1;
303
+ const i = n.doc.body.rows[s.rowIndex].columns[s.columnIndex], l = i.blocks.findIndex((c) => c.id === e);
304
+ if (l === -1) return !1;
305
+ if (r) {
306
+ const c = i.blocks[l], a = n.createTransaction(), u = m(
307
+ "deleteBlock",
308
+ `body.rows[${s.rowIndex}].columns[${s.columnIndex}].blocks`,
309
+ (d) => {
310
+ d.body.rows[s.rowIndex].columns[s.columnIndex].blocks.splice(l, 1);
311
+ },
312
+ (d) => {
313
+ d.body.rows[s.rowIndex].columns[s.columnIndex].blocks.splice(
314
+ l,
315
+ 0,
316
+ c
317
+ );
318
+ }
319
+ );
320
+ a.addStep(u), a.setSelection(null), r(a);
321
+ }
322
+ return !0;
323
+ };
324
+ }
325
+ function vt(o, t, e, n) {
326
+ return (r, s) => {
327
+ const i = k(r.doc, o, t);
328
+ if (!i) return !1;
329
+ const l = r.doc.body.rows[i.rowIndex].columns[i.columnIndex], c = l.blocks.findIndex((a) => a.id === e);
330
+ if (c === -1) return !1;
331
+ if (s) {
332
+ const a = l.blocks[c], u = r.createTransaction(), d = m(
333
+ "updateBlock",
334
+ `body.rows[${i.rowIndex}].columns[${i.columnIndex}].blocks[${c}]`,
335
+ (p) => {
336
+ const g = p.body.rows[i.rowIndex].columns[i.columnIndex].blocks[c];
337
+ Object.assign(g.values, n);
338
+ },
339
+ (p) => {
340
+ p.body.rows[i.rowIndex].columns[i.columnIndex].blocks[c] = a;
341
+ }
342
+ );
343
+ u.addStep(d), s(u);
344
+ }
345
+ return !0;
346
+ };
347
+ }
348
+ function At(o, t, e, n, r, s) {
349
+ return (i, l) => {
350
+ const c = k(i.doc, o, t);
351
+ if (!c) return !1;
352
+ const u = i.doc.body.rows[c.rowIndex].columns[c.columnIndex].blocks.findIndex((p) => p.id === e);
353
+ if (u === -1) return !1;
354
+ const d = k(i.doc, n, r);
355
+ if (!d) return !1;
356
+ if (l) {
357
+ const p = i.createTransaction(), g = m(
358
+ "moveBlock",
359
+ "body.rows",
360
+ (h) => {
361
+ const [v] = h.body.rows[c.rowIndex].columns[c.columnIndex].blocks.splice(u, 1);
362
+ h.body.rows[d.rowIndex].columns[d.columnIndex].blocks.splice(s, 0, v);
363
+ },
364
+ (h) => {
365
+ const [v] = h.body.rows[d.rowIndex].columns[d.columnIndex].blocks.splice(s, 1);
366
+ h.body.rows[c.rowIndex].columns[c.columnIndex].blocks.splice(u, 0, v);
367
+ }
368
+ );
369
+ p.addStep(g), p.setSelection(S(n, r, e)), l(p);
370
+ }
371
+ return !0;
372
+ };
373
+ }
374
+ function St(o, t, e) {
375
+ return (n, r) => {
376
+ const s = k(n.doc, o, t);
377
+ if (!s) return !1;
378
+ const i = n.doc.body.rows[s.rowIndex].columns[s.columnIndex], l = i.blocks.findIndex((c) => c.id === e);
379
+ if (l === -1) return !1;
380
+ if (r) {
381
+ const c = i.blocks[l], a = w(), u = structuredClone(c);
382
+ u.id = a;
383
+ const d = l + 1, p = n.createTransaction(), g = m(
384
+ "duplicateBlock",
385
+ `body.rows[${s.rowIndex}].columns[${s.columnIndex}].blocks`,
386
+ (h) => {
387
+ h.body.rows[s.rowIndex].columns[s.columnIndex].blocks.splice(d, 0, u);
388
+ },
389
+ (h) => {
390
+ h.body.rows[s.rowIndex].columns[s.columnIndex].blocks.splice(d, 1);
391
+ }
392
+ );
393
+ p.addStep(g), p.setSelection(S(o, t, a)), r(p);
394
+ }
395
+ return !0;
396
+ };
397
+ }
398
+ function Ct(o, t) {
399
+ return (e, n) => {
400
+ const r = t ?? e.doc.body.rows.length;
401
+ if (n) {
402
+ const s = e.createTransaction(), i = m(
403
+ "insertRow",
404
+ "body.rows",
405
+ (l) => {
406
+ l.body.rows.splice(r, 0, o);
407
+ },
408
+ (l) => {
409
+ l.body.rows.splice(r, 1);
410
+ }
411
+ );
412
+ s.addStep(i), s.setSelection(C(o.id)), n(s);
413
+ }
414
+ return !0;
415
+ };
416
+ }
417
+ function Rt(o) {
418
+ return (t, e) => {
419
+ const n = t.doc.body.rows.findIndex((r) => r.id === o);
420
+ if (n === -1) return !1;
421
+ if (e) {
422
+ const r = structuredClone(t.doc.body.rows[n]), s = t.createTransaction(), i = m(
423
+ "deleteRow",
424
+ "body.rows",
425
+ (l) => {
426
+ l.body.rows.splice(n, 1);
427
+ },
428
+ (l) => {
429
+ l.body.rows.splice(n, 0, r);
430
+ }
431
+ );
432
+ s.addStep(i), s.setSelection(null), e(s);
433
+ }
434
+ return !0;
435
+ };
436
+ }
437
+ function _t(o, t) {
438
+ return (e, n) => {
439
+ const r = e.doc.body.rows.findIndex((s) => s.id === o);
440
+ if (r === -1 || r === t) return !1;
441
+ if (n) {
442
+ const s = e.createTransaction(), i = m(
443
+ "moveRow",
444
+ "body.rows",
445
+ (l) => {
446
+ const [c] = l.body.rows.splice(r, 1);
447
+ l.body.rows.splice(t, 0, c);
448
+ },
449
+ (l) => {
450
+ const [c] = l.body.rows.splice(t, 1);
451
+ l.body.rows.splice(r, 0, c);
452
+ }
453
+ );
454
+ s.addStep(i), s.setSelection(C(o)), n(s);
455
+ }
456
+ return !0;
457
+ };
458
+ }
459
+ function Tt(o) {
460
+ return (t, e) => {
461
+ const n = t.doc.body.rows.findIndex((r) => r.id === o);
462
+ if (n === -1) return !1;
463
+ if (e) {
464
+ const r = t.doc.body.rows[n], s = structuredClone(r);
465
+ s.id = w(), s.columns.forEach((a) => {
466
+ a.id = w(), a.blocks.forEach((u) => {
467
+ u.id = w();
468
+ });
469
+ });
470
+ const i = n + 1, l = t.createTransaction(), c = m(
471
+ "duplicateRow",
472
+ "body.rows",
473
+ (a) => {
474
+ a.body.rows.splice(i, 0, s);
475
+ },
476
+ (a) => {
477
+ a.body.rows.splice(i, 1);
478
+ }
479
+ );
480
+ l.addStep(c), l.setSelection(C(s.id)), e(l);
481
+ }
482
+ return !0;
483
+ };
484
+ }
485
+ function $t(o, t) {
486
+ return (e, n) => {
487
+ const r = e.doc.body.rows.findIndex((s) => s.id === o);
488
+ if (r === -1) return !1;
489
+ if (n) {
490
+ const s = { ...e.doc.body.rows[r].attributes }, i = e.createTransaction(), l = m(
491
+ "updateRowAttributes",
492
+ `body.rows[${r}].attributes`,
493
+ (c) => {
494
+ Object.assign(c.body.rows[r].attributes, t);
495
+ },
496
+ (c) => {
497
+ c.body.rows[r].attributes = s;
498
+ }
499
+ );
500
+ i.addStep(l), n(i);
501
+ }
502
+ return !0;
503
+ };
504
+ }
505
+ function Bt(o) {
506
+ return (t, e) => {
507
+ const n = t.doc.body.rows.findIndex((s) => s.id === o);
508
+ if (n === -1) return !1;
509
+ const r = t.doc.body.rows[n];
510
+ if (r.locked || r.columns.length >= 4) return !1;
511
+ if (e) {
512
+ const s = B(), i = r.columns.length + 1, l = H(i), c = [...r.columnRatios], a = t.createTransaction(), u = m(
513
+ "addColumn",
514
+ `body.rows[${n}]`,
515
+ (d) => {
516
+ d.body.rows[n].columns.push(s), d.body.rows[n].columnRatios = l;
517
+ },
518
+ (d) => {
519
+ d.body.rows[n].columns.pop(), d.body.rows[n].columnRatios = c;
520
+ }
521
+ );
522
+ a.addStep(u), e(a);
523
+ }
524
+ return !0;
525
+ };
526
+ }
527
+ function Ht(o, t) {
528
+ return (e, n) => {
529
+ const r = e.doc.body.rows.findIndex((l) => l.id === o);
530
+ if (r === -1) return !1;
531
+ const s = e.doc.body.rows[r];
532
+ if (s.locked || s.columns.length <= 1) return !1;
533
+ const i = s.columns.findIndex((l) => l.id === t);
534
+ if (i === -1) return !1;
535
+ if (n) {
536
+ const l = structuredClone(s.columns[i]), c = [...s.columnRatios], a = s.columns.length - 1, u = H(a), d = e.createTransaction(), p = m(
537
+ "removeColumn",
538
+ `body.rows[${r}]`,
539
+ (g) => {
540
+ g.body.rows[r].columns.splice(i, 1), g.body.rows[r].columnRatios = u;
541
+ },
542
+ (g) => {
543
+ g.body.rows[r].columns.splice(i, 0, l), g.body.rows[r].columnRatios = c;
544
+ }
545
+ );
546
+ d.addStep(p), n(d);
547
+ }
548
+ return !0;
549
+ };
550
+ }
551
+ function Mt(o, t) {
552
+ return (e, n) => {
553
+ const r = e.doc.body.rows.findIndex((l) => l.id === o);
554
+ if (r === -1) return !1;
555
+ const s = e.doc.body.rows[r];
556
+ if (t.length !== s.columns.length || t.reduce((l, c) => l + c, 0) !== 12) return !1;
557
+ if (n) {
558
+ const l = [...s.columnRatios], c = e.createTransaction(), a = m(
559
+ "resizeColumns",
560
+ `body.rows[${r}].columnRatios`,
561
+ (u) => {
562
+ u.body.rows[r].columnRatios = t;
563
+ },
564
+ (u) => {
565
+ u.body.rows[r].columnRatios = l;
566
+ }
567
+ );
568
+ c.addStep(a), n(c);
569
+ }
570
+ return !0;
571
+ };
572
+ }
573
+ function H(o) {
574
+ const t = Math.floor(12 / o), e = 12 - t * o, n = new Array(o).fill(t);
575
+ for (let r = 0; r < e; r++)
576
+ n[r] += 1;
577
+ return n;
578
+ }
579
+ const K = ["text", "image", "button", "divider", "spacer", "social", "html", "hero", "navbar"];
580
+ function G(o) {
581
+ const t = [];
582
+ if (!o || typeof o != "object")
583
+ return t.push({ path: "", message: "Document must be an object" }), t;
584
+ const e = o;
585
+ if (e.version !== "1.0" && t.push({ path: "version", message: 'Version must be "1.0"' }), !e.metadata || typeof e.metadata != "object" ? t.push({ path: "metadata", message: "Metadata is required" }) : typeof e.metadata.name != "string" && t.push({ path: "metadata.name", message: "Name must be a string" }), !e.body || typeof e.body != "object")
586
+ return t.push({ path: "body", message: "Body is required" }), t;
587
+ const n = e.body;
588
+ return (!n.attributes || typeof n.attributes != "object") && t.push({ path: "body.attributes", message: "Body attributes are required" }), Array.isArray(n.rows) ? (n.rows.forEach((r, s) => {
589
+ t.push(...Y(r, `body.rows[${s}]`));
590
+ }), t) : (t.push({ path: "body.rows", message: "Rows must be an array" }), t);
591
+ }
592
+ function Y(o, t) {
593
+ const e = [];
594
+ return o.id || e.push({ path: `${t}.id`, message: "Row must have an id" }), o.type !== "row" && e.push({ path: `${t}.type`, message: 'Row type must be "row"' }), Array.isArray(o.columns) ? (Array.isArray(o.columnRatios) ? o.columnRatios.length !== o.columns.length && e.push({
595
+ path: `${t}.columnRatios`,
596
+ message: "Column ratios length must match columns length"
597
+ }) : e.push({ path: `${t}.columnRatios`, message: "Column ratios must be an array" }), o.columns.forEach((n, r) => {
598
+ e.push(...X(n, `${t}.columns[${r}]`));
599
+ }), e) : (e.push({ path: `${t}.columns`, message: "Columns must be an array" }), e);
600
+ }
601
+ function X(o, t) {
602
+ const e = [];
603
+ return o.id || e.push({ path: `${t}.id`, message: "Column must have an id" }), Array.isArray(o.blocks) ? (o.blocks.forEach((n, r) => {
604
+ e.push(...Z(n, `${t}.blocks[${r}]`));
605
+ }), e) : (e.push({ path: `${t}.blocks`, message: "Blocks must be an array" }), e);
606
+ }
607
+ function Z(o, t) {
608
+ const e = [];
609
+ return o.id || e.push({ path: `${t}.id`, message: "Block must have an id" }), K.includes(o.type) || e.push({ path: `${t}.type`, message: `Invalid block type: ${o.type}` }), (!o.values || typeof o.values != "object") && e.push({ path: `${t}.values`, message: "Block must have values" }), e;
610
+ }
611
+ function Wt(o) {
612
+ return G(o).length === 0;
613
+ }
614
+ const x = /* @__PURE__ */ new Map(), J = [
615
+ {
616
+ type: "text",
617
+ label: "Text",
618
+ icon: "text",
619
+ defaultValues: y("text")
620
+ },
621
+ {
622
+ type: "image",
623
+ label: "Image",
624
+ icon: "image",
625
+ defaultValues: y("image")
626
+ },
627
+ {
628
+ type: "button",
629
+ label: "Button",
630
+ icon: "button",
631
+ defaultValues: y("button")
632
+ },
633
+ {
634
+ type: "divider",
635
+ label: "Divider",
636
+ icon: "divider",
637
+ defaultValues: y("divider")
638
+ },
639
+ {
640
+ type: "spacer",
641
+ label: "Spacer",
642
+ icon: "spacer",
643
+ defaultValues: y("spacer")
644
+ },
645
+ {
646
+ type: "social",
647
+ label: "Social",
648
+ icon: "social",
649
+ defaultValues: y("social")
650
+ },
651
+ {
652
+ type: "html",
653
+ label: "HTML",
654
+ icon: "html",
655
+ defaultValues: y("html")
656
+ },
657
+ {
658
+ type: "hero",
659
+ label: "Hero",
660
+ icon: "hero",
661
+ defaultValues: y("hero")
662
+ },
663
+ {
664
+ type: "navbar",
665
+ label: "Navbar",
666
+ icon: "navbar",
667
+ defaultValues: y("navbar")
668
+ }
669
+ ];
670
+ function Q() {
671
+ for (const o of J)
672
+ x.set(o.type, o);
673
+ U((o) => {
674
+ var t;
675
+ return (t = x.get(o)) == null ? void 0 : t.defaultValues;
676
+ });
677
+ }
678
+ function tt(o) {
679
+ x.set(o.type, o);
680
+ }
681
+ function Vt(o) {
682
+ return x.get(o);
683
+ }
684
+ function Pt() {
685
+ return Array.from(x.values());
686
+ }
687
+ function Dt(o) {
688
+ return x.has(o);
689
+ }
690
+ Q();
691
+ const et = 100;
692
+ function ot() {
693
+ return {
694
+ undoStack: [],
695
+ redoStack: []
696
+ };
697
+ }
698
+ function nt(o, t) {
699
+ const e = [...o.undoStack, t];
700
+ return e.length > et && e.shift(), {
701
+ undoStack: e,
702
+ redoStack: []
703
+ // Clear redo stack on new change
704
+ };
705
+ }
706
+ function rt(o) {
707
+ if (o.undoStack.length === 0)
708
+ return { history: o, entry: null };
709
+ const t = [...o.undoStack], e = t.pop(), n = [...o.redoStack, e];
710
+ return {
711
+ history: { undoStack: t, redoStack: n },
712
+ entry: e
713
+ };
714
+ }
715
+ function st(o) {
716
+ if (o.redoStack.length === 0)
717
+ return { history: o, entry: null };
718
+ const t = [...o.redoStack], e = t.pop();
719
+ return {
720
+ history: { undoStack: [...o.undoStack, e], redoStack: t },
721
+ entry: e
722
+ };
723
+ }
724
+ function it(o) {
725
+ return o.undoStack.length > 0;
726
+ }
727
+ function lt(o) {
728
+ return o.redoStack.length > 0;
729
+ }
730
+ const R = "history";
731
+ function Et() {
732
+ return {
733
+ name: R,
734
+ init() {
735
+ return ot();
736
+ },
737
+ apply(o, t) {
738
+ const e = t;
739
+ if (o.meta.get("isUndo") || o.meta.get("isRedo"))
740
+ return o.meta.get("newHistory") ?? e;
741
+ if (o.steps.length === 0 || o.meta.get("skipHistory"))
742
+ return e;
743
+ const n = {
744
+ steps: [...o.steps],
745
+ doc: o.doc,
746
+ timestamp: Date.now()
747
+ };
748
+ return nt(e, n);
749
+ }
750
+ };
751
+ }
752
+ function Lt(o, t) {
753
+ const e = o.plugins.get(R);
754
+ if (!e || !it(e)) return !1;
755
+ if (t) {
756
+ const { history: n, entry: r } = rt(e);
757
+ if (!r) return !1;
758
+ const s = o.createTransaction();
759
+ for (let i = r.steps.length - 1; i >= 0; i--) {
760
+ const l = r.steps[i].invert(s.doc);
761
+ s.addStep(l);
762
+ }
763
+ s.setMeta("isUndo", !0), s.setMeta("newHistory", n), s.setMeta("skipTimestamp", !0), t(s);
764
+ }
765
+ return !0;
766
+ }
767
+ function Ot(o, t) {
768
+ const e = o.plugins.get(R);
769
+ if (!e || !lt(e)) return !1;
770
+ if (t) {
771
+ const { history: n, entry: r } = st(e);
772
+ if (!r) return !1;
773
+ const s = o.createTransaction();
774
+ for (const i of r.steps)
775
+ s.addStep(i);
776
+ s.setMeta("isRedo", !0), s.setMeta("newHistory", n), s.setMeta("skipTimestamp", !0), t(s);
777
+ }
778
+ return !0;
779
+ }
780
+ class jt {
781
+ constructor() {
782
+ this._plugins = /* @__PURE__ */ new Map();
783
+ }
784
+ register(t) {
785
+ if (this._plugins.has(t.name))
786
+ throw new Error(`Plugin "${t.name}" is already registered`);
787
+ if (this._plugins.set(t.name, t), t.blocks)
788
+ for (const e of t.blocks)
789
+ tt(e);
790
+ }
791
+ unregister(t) {
792
+ this._plugins.delete(t);
793
+ }
794
+ get(t) {
795
+ return this._plugins.get(t);
796
+ }
797
+ getAll() {
798
+ return Array.from(this._plugins.values());
799
+ }
800
+ getCommands() {
801
+ const t = {};
802
+ for (const e of this._plugins.values())
803
+ e.commands && Object.assign(t, e.commands);
804
+ return t;
805
+ }
806
+ has(t) {
807
+ return this._plugins.has(t);
808
+ }
809
+ }
810
+ function _(o, t) {
811
+ if (o === t) return !0;
812
+ if (o == null || t == null || typeof o != typeof t) return !1;
813
+ if (Array.isArray(o))
814
+ return !Array.isArray(t) || o.length !== t.length ? !1 : o.every((e, n) => _(e, t[n]));
815
+ if (typeof o == "object") {
816
+ const e = Object.keys(o), n = Object.keys(t);
817
+ return e.length !== n.length ? !1 : e.every(
818
+ (r) => _(
819
+ o[r],
820
+ t[r]
821
+ )
822
+ );
823
+ }
824
+ return !1;
825
+ }
826
+ const f = "2026-05-26T10:00:00.000Z", ct = {
827
+ id: "starter-welcome",
828
+ name: "Welcome",
829
+ description: "A clean welcome email with a hero, intro paragraph, and call-to-action.",
830
+ category: "welcome",
831
+ createdAt: f,
832
+ updatedAt: f,
833
+ document: {
834
+ version: "1.0",
835
+ metadata: {
836
+ name: "Welcome",
837
+ previewText: "We're glad you're here.",
838
+ createdAt: f,
839
+ updatedAt: f
840
+ },
841
+ body: {
842
+ attributes: { width: 600, backgroundColor: "#f5f7fb", fontFamily: "Inter, sans-serif", contentAlignment: "center" },
843
+ rows: [
844
+ {
845
+ id: "r-hero",
846
+ type: "row",
847
+ locked: !1,
848
+ attributes: { padding: { top: 0, right: 0, bottom: 0, left: 0 }, fullWidth: !0 },
849
+ columnRatios: [12],
850
+ columns: [{
851
+ id: "c-hero",
852
+ type: "column",
853
+ attributes: { padding: { top: 0, right: 0, bottom: 0, left: 0 }, verticalAlign: "top" },
854
+ blocks: [{
855
+ id: "b-hero",
856
+ type: "hero",
857
+ values: {
858
+ backgroundUrl: "https://placehold.co/600x280/0f172a/ffffff?text=Welcome",
859
+ backgroundPosition: "center center",
860
+ mode: "fixed-height",
861
+ width: 600,
862
+ height: 280,
863
+ verticalAlign: "middle",
864
+ padding: { top: 0, right: 0, bottom: 0, left: 0 },
865
+ innerPadding: { top: 40, right: 40, bottom: 40, left: 40 },
866
+ backgroundColor: "#0f172a",
867
+ content: '<h1 style="color:#ffffff;font-size:32px;margin:0;">Welcome, {{firstName}}</h1>'
868
+ }
869
+ }]
870
+ }]
871
+ },
872
+ {
873
+ id: "r-intro",
874
+ type: "row",
875
+ locked: !1,
876
+ attributes: { backgroundColor: "#ffffff", padding: { top: 32, right: 24, bottom: 8, left: 24 }, fullWidth: !1 },
877
+ columnRatios: [12],
878
+ columns: [{
879
+ id: "c-intro",
880
+ type: "column",
881
+ attributes: { padding: { top: 0, right: 0, bottom: 0, left: 0 }, verticalAlign: "top" },
882
+ blocks: [{
883
+ id: "b-intro",
884
+ type: "text",
885
+ values: {
886
+ content: "<p>Thanks for joining — we've put together a quick guide to help you get the most out of your account.</p>",
887
+ padding: { top: 0, right: 0, bottom: 0, left: 0 },
888
+ lineHeight: "1.6",
889
+ textAlign: "left"
890
+ }
891
+ }]
892
+ }]
893
+ },
894
+ {
895
+ id: "r-cta",
896
+ type: "row",
897
+ locked: !1,
898
+ attributes: { backgroundColor: "#ffffff", padding: { top: 16, right: 24, bottom: 32, left: 24 }, fullWidth: !1 },
899
+ columnRatios: [12],
900
+ columns: [{
901
+ id: "c-cta",
902
+ type: "column",
903
+ attributes: { padding: { top: 0, right: 0, bottom: 0, left: 0 }, verticalAlign: "top" },
904
+ blocks: [{
905
+ id: "b-cta",
906
+ type: "button",
907
+ values: {
908
+ content: "<p>Get started</p>",
909
+ href: "https://example.com/start",
910
+ backgroundColor: "#3b82f6",
911
+ textColor: "#ffffff",
912
+ borderRadius: 6,
913
+ padding: { top: 8, right: 8, bottom: 8, left: 8 },
914
+ innerPadding: { top: 12, right: 24, bottom: 12, left: 24 },
915
+ fontSize: 16,
916
+ fontWeight: "600",
917
+ alignment: "center",
918
+ fullWidth: !1
919
+ }
920
+ }]
921
+ }]
922
+ }
923
+ ]
924
+ }
925
+ }
926
+ }, at = {
927
+ id: "starter-newsletter",
928
+ name: "Newsletter",
929
+ description: "A simple 3-section newsletter — headline + body + footer.",
930
+ category: "newsletter",
931
+ createdAt: f,
932
+ updatedAt: f,
933
+ document: {
934
+ version: "1.0",
935
+ metadata: { name: "Newsletter", previewText: "This month's updates", createdAt: f, updatedAt: f },
936
+ body: {
937
+ attributes: { width: 600, backgroundColor: "#ffffff", fontFamily: "Inter, sans-serif", contentAlignment: "center" },
938
+ rows: [
939
+ {
940
+ id: "r-head",
941
+ type: "row",
942
+ locked: !1,
943
+ attributes: { padding: { top: 24, right: 24, bottom: 8, left: 24 }, fullWidth: !1 },
944
+ columnRatios: [12],
945
+ columns: [{
946
+ id: "c-head",
947
+ type: "column",
948
+ attributes: { padding: { top: 0, right: 0, bottom: 0, left: 0 }, verticalAlign: "top" },
949
+ blocks: [{
950
+ id: "b-head",
951
+ type: "text",
952
+ values: {
953
+ content: '<h1 style="font-size:24px;margin:0;">This month at Acme</h1>',
954
+ padding: { top: 0, right: 0, bottom: 0, left: 0 },
955
+ lineHeight: "1.3",
956
+ textAlign: "left"
957
+ }
958
+ }]
959
+ }]
960
+ },
961
+ {
962
+ id: "r-body",
963
+ type: "row",
964
+ locked: !1,
965
+ attributes: { padding: { top: 8, right: 24, bottom: 24, left: 24 }, fullWidth: !1 },
966
+ columnRatios: [12],
967
+ columns: [{
968
+ id: "c-body",
969
+ type: "column",
970
+ attributes: { padding: { top: 0, right: 0, bottom: 0, left: 0 }, verticalAlign: "top" },
971
+ blocks: [{
972
+ id: "b-body",
973
+ type: "text",
974
+ values: {
975
+ content: "<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur sodales, mauris vel rhoncus sodales, eros lectus rutrum lectus.</p><p>Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.</p>",
976
+ padding: { top: 0, right: 0, bottom: 0, left: 0 },
977
+ lineHeight: "1.6",
978
+ textAlign: "left"
979
+ }
980
+ }]
981
+ }]
982
+ },
983
+ {
984
+ id: "r-foot",
985
+ type: "row",
986
+ locked: !1,
987
+ attributes: { backgroundColor: "#f5f7fb", padding: { top: 16, right: 24, bottom: 16, left: 24 }, fullWidth: !1 },
988
+ columnRatios: [12],
989
+ columns: [{
990
+ id: "c-foot",
991
+ type: "column",
992
+ attributes: { padding: { top: 0, right: 0, bottom: 0, left: 0 }, verticalAlign: "top" },
993
+ blocks: [{
994
+ id: "b-foot",
995
+ type: "text",
996
+ values: {
997
+ content: '<p style="color:#64748b;font-size:12px;">© Acme · <a href="https://example.com/unsubscribe">Unsubscribe</a></p>',
998
+ padding: { top: 0, right: 0, bottom: 0, left: 0 },
999
+ lineHeight: "1.5",
1000
+ textAlign: "center"
1001
+ }
1002
+ }]
1003
+ }]
1004
+ }
1005
+ ]
1006
+ }
1007
+ }
1008
+ }, dt = {
1009
+ id: "starter-transactional",
1010
+ name: "Transactional (order confirmation)",
1011
+ description: "Order confirmation pattern with summary and a primary button.",
1012
+ category: "transactional",
1013
+ createdAt: f,
1014
+ updatedAt: f,
1015
+ document: {
1016
+ version: "1.0",
1017
+ metadata: { name: "Order confirmation", previewText: "Order {{orderNumber}} is on its way.", createdAt: f, updatedAt: f },
1018
+ body: {
1019
+ attributes: { width: 600, backgroundColor: "#ffffff", fontFamily: "Inter, sans-serif", contentAlignment: "center" },
1020
+ rows: [
1021
+ {
1022
+ id: "r-h",
1023
+ type: "row",
1024
+ locked: !1,
1025
+ attributes: { padding: { top: 32, right: 24, bottom: 8, left: 24 }, fullWidth: !1 },
1026
+ columnRatios: [12],
1027
+ columns: [{
1028
+ id: "c-h",
1029
+ type: "column",
1030
+ attributes: { padding: { top: 0, right: 0, bottom: 0, left: 0 }, verticalAlign: "top" },
1031
+ blocks: [{
1032
+ id: "b-h",
1033
+ type: "text",
1034
+ values: {
1035
+ content: '<h1 style="font-size:24px;margin:0 0 8px;">Thanks for your order, {{firstName}}</h1><p style="margin:0;">Order <strong>{{orderNumber}}</strong> is on its way.</p>',
1036
+ padding: { top: 0, right: 0, bottom: 0, left: 0 },
1037
+ lineHeight: "1.5",
1038
+ textAlign: "left"
1039
+ }
1040
+ }]
1041
+ }]
1042
+ },
1043
+ {
1044
+ id: "r-summary",
1045
+ type: "row",
1046
+ locked: !1,
1047
+ attributes: { backgroundColor: "#f8fafc", padding: { top: 16, right: 24, bottom: 16, left: 24 }, fullWidth: !1 },
1048
+ columnRatios: [12],
1049
+ columns: [{
1050
+ id: "c-summary",
1051
+ type: "column",
1052
+ attributes: { padding: { top: 0, right: 0, bottom: 0, left: 0 }, verticalAlign: "top" },
1053
+ blocks: [{
1054
+ id: "b-summary",
1055
+ type: "text",
1056
+ values: {
1057
+ content: '<p style="margin:0 0 8px;"><strong>Summary</strong></p><p style="margin:0;">{{itemCount}} item(s) · {{total}}</p><p style="margin:8px 0 0;color:#64748b;font-size:12px;">Estimated delivery: {{deliveryDate}}</p>',
1058
+ padding: { top: 0, right: 0, bottom: 0, left: 0 },
1059
+ lineHeight: "1.5",
1060
+ textAlign: "left"
1061
+ }
1062
+ }]
1063
+ }]
1064
+ },
1065
+ {
1066
+ id: "r-cta",
1067
+ type: "row",
1068
+ locked: !1,
1069
+ attributes: { padding: { top: 24, right: 24, bottom: 24, left: 24 }, fullWidth: !1 },
1070
+ columnRatios: [12],
1071
+ columns: [{
1072
+ id: "c-cta",
1073
+ type: "column",
1074
+ attributes: { padding: { top: 0, right: 0, bottom: 0, left: 0 }, verticalAlign: "top" },
1075
+ blocks: [{
1076
+ id: "b-cta",
1077
+ type: "button",
1078
+ values: {
1079
+ content: "<p>View order</p>",
1080
+ href: "https://example.com/orders/{{orderNumber}}",
1081
+ backgroundColor: "#0f172a",
1082
+ textColor: "#ffffff",
1083
+ borderRadius: 6,
1084
+ padding: { top: 0, right: 0, bottom: 0, left: 0 },
1085
+ innerPadding: { top: 12, right: 24, bottom: 12, left: 24 },
1086
+ fontSize: 16,
1087
+ fontWeight: "600",
1088
+ alignment: "left",
1089
+ fullWidth: !1
1090
+ }
1091
+ }]
1092
+ }]
1093
+ }
1094
+ ]
1095
+ }
1096
+ }
1097
+ }, ut = {
1098
+ id: "starter-promo",
1099
+ name: "Promo / Sale",
1100
+ description: "Two-column product grid with a primary CTA and a social-link footer.",
1101
+ category: "promo",
1102
+ createdAt: f,
1103
+ updatedAt: f,
1104
+ document: {
1105
+ version: "1.0",
1106
+ metadata: { name: "Spring sale", previewText: "Two days only — 30% off.", createdAt: f, updatedAt: f },
1107
+ body: {
1108
+ attributes: { width: 600, backgroundColor: "#fdf6ee", fontFamily: "Inter, sans-serif", contentAlignment: "center" },
1109
+ rows: [
1110
+ {
1111
+ id: "r-hero",
1112
+ type: "row",
1113
+ locked: !1,
1114
+ attributes: { padding: { top: 0, right: 0, bottom: 0, left: 0 }, fullWidth: !0 },
1115
+ columnRatios: [12],
1116
+ columns: [{
1117
+ id: "c-hero",
1118
+ type: "column",
1119
+ attributes: { padding: { top: 0, right: 0, bottom: 0, left: 0 }, verticalAlign: "middle" },
1120
+ blocks: [{
1121
+ id: "b-hero",
1122
+ type: "hero",
1123
+ values: {
1124
+ backgroundUrl: "https://placehold.co/600x240/e76f51/ffffff?text=30%25+off",
1125
+ backgroundPosition: "center center",
1126
+ mode: "fluid-height",
1127
+ width: 600,
1128
+ height: 240,
1129
+ verticalAlign: "middle",
1130
+ padding: { top: 0, right: 0, bottom: 0, left: 0 },
1131
+ innerPadding: { top: 32, right: 32, bottom: 32, left: 32 },
1132
+ backgroundColor: "#e76f51",
1133
+ content: '<h1 style="color:#ffffff;font-size:36px;margin:0 0 8px;">30% off, this weekend only</h1><p style="color:#ffffff;font-size:16px;margin:0;">Code <strong>SPRING30</strong> at checkout.</p>'
1134
+ }
1135
+ }]
1136
+ }]
1137
+ },
1138
+ {
1139
+ id: "r-grid",
1140
+ type: "row",
1141
+ locked: !1,
1142
+ attributes: { backgroundColor: "#ffffff", padding: { top: 24, right: 16, bottom: 24, left: 16 }, fullWidth: !1 },
1143
+ columnRatios: [6, 6],
1144
+ columns: [
1145
+ {
1146
+ id: "c-l",
1147
+ type: "column",
1148
+ attributes: { padding: { top: 0, right: 8, bottom: 0, left: 0 }, verticalAlign: "top" },
1149
+ blocks: [
1150
+ {
1151
+ id: "b-l-img",
1152
+ type: "image",
1153
+ values: {
1154
+ src: "https://placehold.co/280x200",
1155
+ alt: "Linen shirt",
1156
+ width: "auto",
1157
+ href: "https://example.com/p/shirt",
1158
+ padding: { top: 0, right: 0, bottom: 8, left: 0 },
1159
+ alignment: "center",
1160
+ borderRadius: 6
1161
+ }
1162
+ },
1163
+ {
1164
+ id: "b-l-txt",
1165
+ type: "text",
1166
+ values: {
1167
+ content: '<p style="text-align:center;margin:0;"><strong>Linen shirt</strong><br><span style="color:#64748b;">$48 · was $69</span></p>',
1168
+ padding: { top: 0, right: 0, bottom: 0, left: 0 },
1169
+ lineHeight: "1.5",
1170
+ textAlign: "center"
1171
+ }
1172
+ }
1173
+ ]
1174
+ },
1175
+ {
1176
+ id: "c-r",
1177
+ type: "column",
1178
+ attributes: { padding: { top: 0, right: 0, bottom: 0, left: 8 }, verticalAlign: "top" },
1179
+ blocks: [
1180
+ {
1181
+ id: "b-r-img",
1182
+ type: "image",
1183
+ values: {
1184
+ src: "https://placehold.co/280x200",
1185
+ alt: "Wool jumper",
1186
+ width: "auto",
1187
+ href: "https://example.com/p/jumper",
1188
+ padding: { top: 0, right: 0, bottom: 8, left: 0 },
1189
+ alignment: "center",
1190
+ borderRadius: 6
1191
+ }
1192
+ },
1193
+ {
1194
+ id: "b-r-txt",
1195
+ type: "text",
1196
+ values: {
1197
+ content: '<p style="text-align:center;margin:0;"><strong>Wool jumper</strong><br><span style="color:#64748b;">$84 · was $120</span></p>',
1198
+ padding: { top: 0, right: 0, bottom: 0, left: 0 },
1199
+ lineHeight: "1.5",
1200
+ textAlign: "center"
1201
+ }
1202
+ }
1203
+ ]
1204
+ }
1205
+ ]
1206
+ },
1207
+ {
1208
+ id: "r-cta",
1209
+ type: "row",
1210
+ locked: !1,
1211
+ attributes: { backgroundColor: "#ffffff", padding: { top: 8, right: 16, bottom: 24, left: 16 }, fullWidth: !1 },
1212
+ columnRatios: [12],
1213
+ columns: [{
1214
+ id: "c-cta",
1215
+ type: "column",
1216
+ attributes: { padding: { top: 0, right: 0, bottom: 0, left: 0 }, verticalAlign: "top" },
1217
+ blocks: [{
1218
+ id: "b-cta",
1219
+ type: "button",
1220
+ values: {
1221
+ content: "<p>Shop the sale</p>",
1222
+ href: "https://example.com/sale",
1223
+ backgroundColor: "#0f172a",
1224
+ textColor: "#ffffff",
1225
+ borderRadius: 6,
1226
+ padding: { top: 8, right: 0, bottom: 8, left: 0 },
1227
+ innerPadding: { top: 14, right: 28, bottom: 14, left: 28 },
1228
+ fontSize: 16,
1229
+ fontWeight: "600",
1230
+ alignment: "center",
1231
+ fullWidth: !0
1232
+ }
1233
+ }]
1234
+ }]
1235
+ }
1236
+ ]
1237
+ }
1238
+ }
1239
+ }, M = Object.freeze([ct, at, dt, ut]);
1240
+ function ft() {
1241
+ return M.map((o) => structuredClone(o));
1242
+ }
1243
+ function zt(o) {
1244
+ const t = M.find((e) => e.id === o);
1245
+ return t ? structuredClone(t) : null;
1246
+ }
1247
+ class Nt {
1248
+ constructor(t = {}) {
1249
+ if (this._byId = /* @__PURE__ */ new Map(), t.includeStarters !== !1)
1250
+ for (const e of ft()) this._byId.set(e.id, e);
1251
+ if (t.seed)
1252
+ for (const e of t.seed) this._byId.set(e.id, e);
1253
+ }
1254
+ async list() {
1255
+ return Array.from(this._byId.values()).map((t) => structuredClone(t));
1256
+ }
1257
+ async get(t) {
1258
+ const e = this._byId.get(t);
1259
+ return e ? structuredClone(e) : null;
1260
+ }
1261
+ async save(t) {
1262
+ if (!t.id) throw new Error("Template.id is required");
1263
+ const e = structuredClone(t);
1264
+ e.updatedAt = (/* @__PURE__ */ new Date()).toISOString(), this._byId.has(e.id) || (e.createdAt = e.updatedAt), this._byId.set(e.id, e);
1265
+ }
1266
+ async delete(t) {
1267
+ this._byId.delete(t);
1268
+ }
1269
+ }
1270
+ class qt {
1271
+ constructor(t = {}) {
1272
+ if (this._byId = /* @__PURE__ */ new Map(), t.seed)
1273
+ for (const e of t.seed) this._byId.set(e.id, e);
1274
+ }
1275
+ async list() {
1276
+ return Array.from(this._byId.values()).map((t) => structuredClone(t));
1277
+ }
1278
+ async get(t) {
1279
+ const e = this._byId.get(t);
1280
+ return e ? structuredClone(e) : null;
1281
+ }
1282
+ async save(t) {
1283
+ if (!t.id) throw new Error("BrandKit.id is required");
1284
+ const e = structuredClone(t);
1285
+ e.updatedAt = (/* @__PURE__ */ new Date()).toISOString(), this._byId.has(e.id) || (e.createdAt = e.updatedAt), this._byId.set(e.id, e);
1286
+ }
1287
+ async delete(t) {
1288
+ this._byId.delete(t);
1289
+ }
1290
+ }
1291
+ class Ut {
1292
+ constructor(t = {}) {
1293
+ if (this._byId = /* @__PURE__ */ new Map(), t.seed)
1294
+ for (const e of t.seed) this._byId.set(e.id, e);
1295
+ }
1296
+ async list(t = {}) {
1297
+ let n = Array.from(this._byId.values()).map((i) => structuredClone(i)).filter((i) => pt(i, t));
1298
+ n.sort((i, l) => i.updatedAt < l.updatedAt ? 1 : i.updatedAt > l.updatedAt ? -1 : 0);
1299
+ const r = t.offset ?? 0, s = t.limit;
1300
+ return n = n.slice(r, s !== void 0 ? r + s : void 0), n;
1301
+ }
1302
+ async get(t) {
1303
+ const e = this._byId.get(t);
1304
+ return e ? structuredClone(e) : null;
1305
+ }
1306
+ async save(t) {
1307
+ if (!t.id) throw new Error("Asset.id is required");
1308
+ if (!t.src) throw new Error("Asset.src is required");
1309
+ const e = structuredClone(t);
1310
+ e.updatedAt = (/* @__PURE__ */ new Date()).toISOString(), this._byId.has(e.id) || (e.createdAt = e.updatedAt), e.folder || (e.folder = "/"), this._byId.set(e.id, e);
1311
+ }
1312
+ async delete(t) {
1313
+ this._byId.delete(t);
1314
+ }
1315
+ async listFolders() {
1316
+ const t = /* @__PURE__ */ new Set();
1317
+ for (const e of this._byId.values()) t.add(e.folder || "/");
1318
+ return Array.from(t).sort();
1319
+ }
1320
+ }
1321
+ function pt(o, t) {
1322
+ if (t.folder && (o.folder || "/") !== t.folder)
1323
+ return !1;
1324
+ if (t.tags && t.tags.length > 0) {
1325
+ const e = new Set(o.tags ?? []);
1326
+ if (!t.tags.every((n) => e.has(n))) return !1;
1327
+ }
1328
+ if (t.search) {
1329
+ const e = t.search.toLowerCase();
1330
+ if (![o.name, o.alt ?? "", ...o.tags ?? []].join(" ").toLowerCase().includes(e)) return !1;
1331
+ }
1332
+ return !0;
1333
+ }
1334
+ export {
1335
+ A as EditorState,
1336
+ R as HISTORY_PLUGIN_NAME,
1337
+ Ut as InMemoryAssetStorage,
1338
+ qt as InMemoryBrandKitStorage,
1339
+ Nt as InMemoryTemplateStorage,
1340
+ jt as PluginRegistry,
1341
+ V as Transaction,
1342
+ Bt as addColumn,
1343
+ lt as canRedo,
1344
+ it as canUndo,
1345
+ bt as createBlock,
1346
+ S as createBlockSelection,
1347
+ wt as createBodySelection,
1348
+ B as createColumn,
1349
+ yt as createColumnSelection,
1350
+ F as createDefaultDocument,
1351
+ m as createDocStep,
1352
+ Et as createHistoryPlugin,
1353
+ ht as createRow,
1354
+ C as createRowSelection,
1355
+ _ as deepEqual,
1356
+ b as defaultSpacing,
1357
+ It as deleteBlock,
1358
+ Rt as deleteRow,
1359
+ St as duplicateBlock,
1360
+ Tt as duplicateRow,
1361
+ w as generateId,
1362
+ Pt as getAllBlockDefinitions,
1363
+ Vt as getBlockDefinition,
1364
+ y as getDefaultValues,
1365
+ zt as getStarterTemplate,
1366
+ ft as getStarterTemplates,
1367
+ xt as insertBlock,
1368
+ Ct as insertRow,
1369
+ Dt as isKnownBlockType,
1370
+ Wt as isValidDocument,
1371
+ At as moveBlock,
1372
+ _t as moveRow,
1373
+ Ot as redo,
1374
+ tt as registerBlock,
1375
+ Ht as removeColumn,
1376
+ Mt as resizeColumns,
1377
+ kt as selectionsEqual,
1378
+ Lt as undo,
1379
+ vt as updateBlock,
1380
+ $t as updateRowAttributes,
1381
+ G as validateDocument
1382
+ };