brick-pdf 0.4.2 → 0.5.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/brick-pdf.js CHANGED
@@ -1,7 +1,7 @@
1
- import { defineComponent as _, openBlock as s, createElementBlock as c, normalizeStyle as z, toDisplayString as w, renderSlot as te, normalizeClass as ne, createElementVNode as y, Fragment as C, renderList as P, reactive as De, provide as M, inject as B, toRaw as j, ref as I, computed as E, createTextVNode as ce, createCommentVNode as $, createBlock as O, resolveDynamicComponent as oe, withCtx as G, onMounted as he, onBeforeUnmount as ve, unref as k, resolveComponent as Me, withDirectives as de, vModelSelect as ue, createVNode as A, watch as Be } from "vue";
2
- import { useMagicKeys as Oe, whenever as pe } from "@vueuse/core";
3
- import fe from "sortablejs";
4
- function re() {
1
+ import { defineComponent as S, openBlock as a, createElementBlock as u, normalizeStyle as L, toDisplayString as w, Fragment as P, createTextVNode as pe, renderSlot as me, computed as x, normalizeClass as Y, createElementVNode as y, renderList as T, createCommentVNode as R, reactive as ze, provide as F, inject as B, toRaw as oe, ref as E, createBlock as H, resolveDynamicComponent as ve, withCtx as se, onMounted as Te, onBeforeUnmount as Re, unref as g, resolveComponent as Le, withModifiers as fe, withDirectives as ne, vModelSelect as Se, vModelCheckbox as tt, watchEffect as nt, createVNode as j, watch as De, nextTick as ot, vShow as xe, withKeys as rt } from "vue";
2
+ import { useElementSize as lt, useMagicKeys as it, whenever as Ce } from "@vueuse/core";
3
+ import we from "sortablejs";
4
+ function be() {
5
5
  return {
6
6
  pageSize: "A4",
7
7
  pageOrientation: "portrait",
@@ -14,72 +14,82 @@ function re() {
14
14
  content: []
15
15
  };
16
16
  }
17
- const X = /* @__PURE__ */ new Map();
18
- function L(e) {
19
- X.set(e.type, e);
17
+ const ae = /* @__PURE__ */ new Map();
18
+ function V(e) {
19
+ ae.set(e.type, e);
20
20
  }
21
- function Y(e) {
22
- return X.get(e);
21
+ function W(e) {
22
+ return ae.get(e);
23
23
  }
24
- function Ae() {
25
- return Array.from(X.values());
24
+ function st() {
25
+ return Array.from(ae.values());
26
26
  }
27
- function sr(e) {
28
- return X.delete(e);
27
+ function Xr(e) {
28
+ return ae.delete(e);
29
29
  }
30
- function Ve() {
30
+ function at() {
31
31
  return { text: "New Text" };
32
32
  }
33
- function Fe() {
33
+ function ct() {
34
34
  return { fontSize: 12 };
35
35
  }
36
- function He(e) {
36
+ function ut(e) {
37
37
  const t = { text: e.props.text }, n = e.style;
38
38
  return n.fontSize && (t.fontSize = n.fontSize), n.bold && (t.bold = n.bold), n.italics && (t.italics = n.italics), n.color && (t.color = n.color), n.alignment && (t.alignment = n.alignment), n.margin && (t.margin = n.margin), n.font && (t.font = n.font), n.lineHeight && (t.lineHeight = n.lineHeight), n.characterSpacing && (t.characterSpacing = n.characterSpacing), n.decoration && (t.decoration = n.decoration), n.decorationStyle && (t.decorationStyle = n.decorationStyle), n.decorationColor && (t.decorationColor = n.decorationColor), n.background && (t.background = n.background), n.link && (t.link = n.link), n.opacity !== void 0 && (t.opacity = n.opacity), t;
39
39
  }
40
- const Je = /* @__PURE__ */ _({
40
+ const dt = /* @__PURE__ */ S({
41
41
  __name: "TextRenderer",
42
42
  props: {
43
43
  node: {}
44
44
  },
45
45
  setup(e) {
46
- return (t, n) => (s(), c("div", {
46
+ return (t, n) => (a(), u("div", {
47
47
  class: "brick-el-text",
48
- style: z({
49
- fontSize: (e.node.style.fontSize ?? 12) + "px",
48
+ style: L({
49
+ fontSize: e.node.style.fontSize ? "calc(" + e.node.style.fontSize + " * var(--brick-pt, 1px))" : void 0,
50
50
  fontWeight: e.node.style.bold ? "bold" : "normal",
51
51
  fontStyle: e.node.style.italics ? "italic" : "normal",
52
52
  color: e.node.style.color,
53
53
  textAlign: e.node.style.alignment,
54
54
  lineHeight: e.node.style.lineHeight,
55
- textDecoration: e.node.style.decoration === "lineThrough" ? "line-through" : e.node.style.decoration,
56
- backgroundColor: e.node.style.background,
55
+ textDecorationLine: e.node.style.decoration === "lineThrough" ? "line-through" : e.node.style.decoration,
56
+ textDecorationStyle: e.node.style.decorationStyle,
57
+ textDecorationColor: e.node.style.decorationColor,
58
+ letterSpacing: e.node.style.characterSpacing ? "calc(" + e.node.style.characterSpacing + " * var(--brick-pt, 1px))" : void 0,
57
59
  opacity: e.node.style.opacity
58
60
  })
59
- }, w(e.node.props.text), 5));
61
+ }, [
62
+ e.node.style.background ? (a(), u("span", {
63
+ key: 0,
64
+ class: "brick-el-text__bg",
65
+ style: L({ backgroundColor: e.node.style.background })
66
+ }, w(e.node.props.text), 5)) : (a(), u(P, { key: 1 }, [
67
+ pe(w(e.node.props.text), 1)
68
+ ], 64))
69
+ ], 4));
60
70
  }
61
- }), x = (e, t) => {
71
+ }), $ = (e, t) => {
62
72
  const n = e.__vccOpts || e;
63
- for (const [i, a] of t)
64
- n[i] = a;
73
+ for (const [i, f] of t)
74
+ n[i] = f;
65
75
  return n;
66
- }, Ue = /* @__PURE__ */ x(Je, [["__scopeId", "data-v-a7cd1565"]]), We = { class: "brick-text-editor" }, je = /* @__PURE__ */ _({
76
+ }, pt = /* @__PURE__ */ $(dt, [["__scopeId", "data-v-3cef04a8"]]), ft = { class: "brick-text-editor" }, yt = /* @__PURE__ */ S({
67
77
  __name: "TextPropertyEditor",
68
78
  props: {
69
79
  node: {}
70
80
  },
71
81
  setup(e) {
72
- return (t, n) => (s(), c("div", We));
82
+ return (t, n) => (a(), u("div", ft));
73
83
  }
74
- }), Ye = {
84
+ }), mt = {
75
85
  type: "text",
76
86
  label: "Text",
77
87
  icon: "T",
78
88
  isContainer: !1,
79
- defaultProps: Ve,
80
- defaultStyle: Fe,
81
- rendererComponent: Ue,
82
- propertyEditorComponent: je,
89
+ defaultProps: at,
90
+ defaultStyle: ct,
91
+ rendererComponent: pt,
92
+ propertyEditorComponent: yt,
83
93
  propertyFields: [
84
94
  { key: "props.text", label: "Text Content", section: "content", type: "textarea", defaultValue: "New Text" },
85
95
  { key: "style.fontSize", label: "Font Size", section: "style", type: "number", min: 6, max: 72, step: 1, defaultValue: 12 },
@@ -104,110 +114,110 @@ const Je = /* @__PURE__ */ _({
104
114
  { key: "style.link", label: "Link URL", section: "advanced", type: "text" },
105
115
  { key: "style.opacity", label: "Opacity", section: "advanced", type: "slider", min: 0, max: 1, step: 0.1, defaultValue: 1 }
106
116
  ],
107
- toPdfmake: He
117
+ toPdfmake: ut
108
118
  };
109
- function qe() {
119
+ function vt() {
110
120
  return {};
111
121
  }
112
- function Ke() {
122
+ function bt() {
113
123
  return {};
114
124
  }
115
- function Ge(e, t) {
125
+ function gt(e, t) {
116
126
  const n = {
117
127
  stack: t(e.children)
118
128
  };
119
129
  return e.style.margin && (n.margin = e.style.margin), e.style.fillColor && (n.fillColor = e.style.fillColor), n;
120
130
  }
121
- const Xe = /* @__PURE__ */ _({
131
+ const ht = /* @__PURE__ */ S({
122
132
  __name: "StackRenderer",
123
133
  props: {
124
134
  node: {},
125
135
  path: {}
126
136
  },
127
137
  setup(e) {
128
- return (t, n) => (s(), c("div", {
138
+ return (t, n) => (a(), u("div", {
129
139
  class: "brick-el-stack",
130
- style: z({ backgroundColor: e.node.style.fillColor })
140
+ style: L({ backgroundColor: e.node.style.fillColor })
131
141
  }, [
132
- te(t.$slots, "default", {}, void 0, !0)
142
+ me(t.$slots, "default", {}, void 0, !0)
133
143
  ], 4));
134
144
  }
135
- }), Qe = /* @__PURE__ */ x(Xe, [["__scopeId", "data-v-c59e7405"]]), Ze = { class: "brick-stack-editor" }, et = /* @__PURE__ */ _({
145
+ }), _t = /* @__PURE__ */ $(ht, [["__scopeId", "data-v-ee878376"]]), kt = { class: "brick-stack-editor" }, St = /* @__PURE__ */ S({
136
146
  __name: "StackPropertyEditor",
137
147
  props: {
138
148
  node: {}
139
149
  },
140
150
  setup(e) {
141
- return (t, n) => (s(), c("div", Ze));
151
+ return (t, n) => (a(), u("div", kt));
142
152
  }
143
- }), tt = {
153
+ }), xt = {
144
154
  type: "stack",
145
155
  label: "Stack",
146
156
  icon: "☰",
147
157
  isContainer: !0,
148
158
  acceptsChildTypes: null,
149
- defaultProps: qe,
150
- defaultStyle: Ke,
151
- rendererComponent: Qe,
152
- propertyEditorComponent: et,
159
+ defaultProps: vt,
160
+ defaultStyle: bt,
161
+ rendererComponent: _t,
162
+ propertyEditorComponent: St,
153
163
  propertyFields: [
154
164
  { key: "style.fillColor", label: "Fill Color", section: "style", type: "color" },
155
165
  { key: "style.margin", label: "Margin", section: "layout", type: "margin", defaultValue: [0, 0, 0, 0] }
156
166
  ],
157
- toPdfmake: Ge
167
+ toPdfmake: gt
158
168
  };
159
- function nt() {
169
+ function Ct() {
160
170
  return { columnGap: 10 };
161
171
  }
162
- function ot() {
172
+ function wt() {
163
173
  return {};
164
174
  }
165
- function rt(e, t) {
175
+ function Pt(e, t) {
166
176
  const n = {
167
177
  columns: t(e.children),
168
178
  columnGap: e.props.columnGap ?? 10
169
179
  };
170
180
  return e.style.margin && (n.margin = e.style.margin), n;
171
181
  }
172
- const lt = /* @__PURE__ */ _({
182
+ const Et = /* @__PURE__ */ S({
173
183
  __name: "ColumnsRenderer",
174
184
  props: {
175
185
  node: {},
176
186
  path: {}
177
187
  },
178
188
  setup(e) {
179
- return (t, n) => (s(), c("div", {
189
+ return (t, n) => (a(), u("div", {
180
190
  class: "brick-el-columns",
181
- style: z({ "--column-gap": (e.node.props.columnGap ?? 10) + "px" })
191
+ style: L({ "--column-gap": "calc(" + (e.node.props.columnGap ?? 10) + " * var(--brick-pt, 1px))" })
182
192
  }, [
183
- te(t.$slots, "default", {}, void 0, !0)
193
+ me(t.$slots, "default", {}, void 0, !0)
184
194
  ], 4));
185
195
  }
186
- }), it = /* @__PURE__ */ x(lt, [["__scopeId", "data-v-217dd721"]]), st = { class: "brick-columns-editor" }, at = /* @__PURE__ */ _({
196
+ }), $t = /* @__PURE__ */ $(Et, [["__scopeId", "data-v-1f87347b"]]), It = { class: "brick-columns-editor" }, Nt = /* @__PURE__ */ S({
187
197
  __name: "ColumnsPropertyEditor",
188
198
  props: {
189
199
  node: {}
190
200
  },
191
201
  setup(e) {
192
- return (t, n) => (s(), c("div", st));
202
+ return (t, n) => (a(), u("div", It));
193
203
  }
194
- }), ct = {
204
+ }), zt = {
195
205
  type: "columns",
196
206
  label: "Columns",
197
207
  icon: "▥",
198
208
  isContainer: !0,
199
209
  acceptsChildTypes: null,
200
- defaultProps: nt,
201
- defaultStyle: ot,
202
- rendererComponent: it,
203
- propertyEditorComponent: at,
210
+ defaultProps: Ct,
211
+ defaultStyle: wt,
212
+ rendererComponent: $t,
213
+ propertyEditorComponent: Nt,
204
214
  propertyFields: [
205
215
  { key: "props.columnGap", label: "Column Gap", section: "layout", type: "number", min: 0, max: 50, step: 1, defaultValue: 10 },
206
216
  { key: "style.margin", label: "Margin", section: "layout", type: "margin", defaultValue: [0, 0, 0, 0] }
207
217
  ],
208
- toPdfmake: rt
218
+ toPdfmake: Pt
209
219
  };
210
- function dt() {
220
+ function Tt() {
211
221
  return {
212
222
  headerRows: 1,
213
223
  widths: ["*", "*"],
@@ -218,52 +228,77 @@ function dt() {
218
228
  layout: "lightHorizontalLines"
219
229
  };
220
230
  }
221
- function ut() {
231
+ function Rt() {
222
232
  return { fontSize: 12 };
223
233
  }
224
- function pt(e) {
234
+ function Lt(e) {
225
235
  const t = e.props.body, n = {
226
236
  table: {
227
237
  headerRows: e.props.headerRows,
228
238
  widths: e.props.widths,
229
239
  body: t.map(
230
- (a) => a.map((l) => ({ text: l }))
240
+ (f) => f.map((d) => ({ text: d }))
231
241
  )
232
242
  }
233
243
  }, i = e.props.layout;
234
244
  return i && i !== "none" && (n.layout = i), e.style.fontSize && (n.fontSize = e.style.fontSize), e.style.color && (n.color = e.style.color), e.style.margin && (n.margin = e.style.margin), n;
235
245
  }
236
- const ft = /* @__PURE__ */ _({
246
+ const Dt = { key: 0 }, Bt = /* @__PURE__ */ S({
237
247
  __name: "TableRenderer",
238
248
  props: {
239
249
  node: {}
240
250
  },
241
251
  setup(e) {
242
- return (t, n) => (s(), c("div", {
243
- class: ne(["brick-el-table", "brick-el-table--" + (e.node.props.layout ?? "lightHorizontalLines")]),
244
- style: z({ fontSize: (e.node.style.fontSize ?? 12) + "px", color: e.node.style.color })
252
+ const t = e, n = ["noBorders", "headerLineOnly", "lightHorizontalLines"], i = x(() => t.node.props.body ?? []), f = x(() => t.node.props.headerRows || 0), d = x(() => t.node.props.widths), m = x(() => {
253
+ const c = t.node.props.layout;
254
+ return c && n.includes(c) ? c : "default";
255
+ }), p = x(() => d.value?.length ?? i.value[0]?.length ?? 0), s = (c) => `calc(${c} * var(--brick-pt, 1px))`, l = x(() => {
256
+ const c = d.value, v = !!c?.some((k) => k === "auto"), b = !c || c.some((k) => k === "*");
257
+ return { tableLayout: v ? "auto" : "fixed", width: b ? "100%" : void 0 };
258
+ });
259
+ function o(c) {
260
+ return typeof c == "number" ? s(c) : void 0;
261
+ }
262
+ function r(c, v) {
263
+ const b = v === p.value - 1;
264
+ let k = 4, C = 4;
265
+ m.value === "noBorders" ? (k = v === 0 ? 0 : 4, C = b ? 0 : 4) : m.value !== "default" && (k = v === 0 ? 0 : 8, C = b ? 0 : 8);
266
+ const _ = {
267
+ padding: `${s(2)} ${s(C)} ${s(2)} ${s(k)}`
268
+ };
269
+ if (c > 0 && (m.value === "lightHorizontalLines" || m.value === "headerLineOnly")) {
270
+ const I = c === f.value ? 2 : m.value === "lightHorizontalLines" ? 1 : 0, O = m.value === "lightHorizontalLines" && c !== 1 ? "#aaa" : "black";
271
+ I && (_.borderTop = `${s(I)} solid ${O}`);
272
+ }
273
+ return _;
274
+ }
275
+ return (c, v) => (a(), u("div", {
276
+ class: Y(["brick-el-table", "brick-el-table--" + m.value]),
277
+ style: L({ fontSize: e.node.style.fontSize ? s(e.node.style.fontSize) : void 0, color: e.node.style.color })
245
278
  }, [
246
- y("table", null, [
247
- y("thead", null, [
248
- (s(!0), c(C, null, P(e.node.props.body.slice(0, e.node.props.headerRows), (i, a) => (s(), c("tr", {
249
- key: "h" + a
250
- }, [
251
- (s(!0), c(C, null, P(i, (l, d) => (s(), c("th", { key: d }, w(l), 1))), 128))
252
- ]))), 128))
253
- ]),
279
+ y("table", {
280
+ style: L(l.value)
281
+ }, [
282
+ d.value ? (a(), u("colgroup", Dt, [
283
+ (a(!0), u(P, null, T(d.value, (b, k) => (a(), u("col", {
284
+ key: k,
285
+ style: L({ width: o(b) })
286
+ }, null, 4))), 128))
287
+ ])) : R("", !0),
254
288
  y("tbody", null, [
255
- (s(!0), c(C, null, P(e.node.props.body.slice(e.node.props.headerRows), (i, a) => (s(), c("tr", {
256
- key: "b" + a
257
- }, [
258
- (s(!0), c(C, null, P(i, (l, d) => (s(), c("td", { key: d }, w(l), 1))), 128))
289
+ (a(!0), u(P, null, T(i.value, (b, k) => (a(), u("tr", { key: k }, [
290
+ (a(!0), u(P, null, T(b, (C, _) => (a(), u("td", {
291
+ key: _,
292
+ style: L(r(k, _))
293
+ }, w(C), 5))), 128))
259
294
  ]))), 128))
260
295
  ])
261
- ])
296
+ ], 4)
262
297
  ], 6));
263
298
  }
264
- }), yt = /* @__PURE__ */ x(ft, [["__scopeId", "data-v-b863b05d"]]), _e = /* @__PURE__ */ Symbol("brick-pdf-document-store");
265
- function ye(e) {
266
- const t = re();
299
+ }), Mt = /* @__PURE__ */ $(Bt, [["__scopeId", "data-v-45332671"]]), Be = /* @__PURE__ */ Symbol("brick-pdf-document-store");
300
+ function Pe(e) {
301
+ const t = be();
267
302
  return {
268
303
  pageSize: e.pageSize ?? t.pageSize,
269
304
  pageOrientation: e.pageOrientation ?? t.pageOrientation,
@@ -273,184 +308,184 @@ function ye(e) {
273
308
  content: e.content ?? t.content
274
309
  };
275
310
  }
276
- function ee(e) {
311
+ function ye(e) {
277
312
  e.props = e.props ?? {}, e.style = e.style ?? {}, e.children = e.children ?? [];
278
- for (const t of e.children) ee(t);
313
+ for (const t of e.children) ye(t);
279
314
  return e;
280
315
  }
281
- function mt(e) {
282
- const t = e ? ye(e) : re();
283
- for (const u of t.content) ee(u);
284
- const n = De(t);
285
- function i(u, r) {
286
- const o = r ?? n.content;
287
- for (let p = 0; p < o.length; p++) {
288
- const g = o[p];
289
- if (g) {
290
- if (g.id === u)
291
- return { node: g, parent: o, index: p };
292
- if (g.children.length > 0) {
293
- const m = i(u, g.children);
294
- if (m) return m;
316
+ function Ot(e) {
317
+ const t = e ? Pe(e) : be();
318
+ for (const s of t.content) ye(s);
319
+ const n = ze(t);
320
+ function i(s, l) {
321
+ const o = l ?? n.content;
322
+ for (let r = 0; r < o.length; r++) {
323
+ const c = o[r];
324
+ if (c) {
325
+ if (c.id === s)
326
+ return { node: c, parent: o, index: r };
327
+ if (c.children.length > 0) {
328
+ const v = i(s, c.children);
329
+ if (v) return v;
295
330
  }
296
331
  }
297
332
  }
298
333
  return null;
299
334
  }
300
- function a(u) {
301
- n.content.splice(0, n.content.length, ...u);
335
+ function f(s) {
336
+ n.content.splice(0, n.content.length, ...s);
302
337
  }
303
- function l() {
304
- return JSON.parse(JSON.stringify(j(n.content)));
338
+ function d() {
339
+ return JSON.parse(JSON.stringify(oe(n.content)));
305
340
  }
306
- function d(u) {
307
- const r = ye(u);
308
- for (const o of r.content) ee(o);
309
- n.pageSize = r.pageSize, n.pageOrientation = r.pageOrientation, n.pageMargins = r.pageMargins, n.defaultStyle = r.defaultStyle, n.styles = r.styles, n.content.splice(0, n.content.length, ...r.content);
341
+ function m(s) {
342
+ const l = Pe(s);
343
+ for (const o of l.content) ye(o);
344
+ n.pageSize = l.pageSize, n.pageOrientation = l.pageOrientation, n.pageMargins = l.pageMargins, n.defaultStyle = l.defaultStyle, n.styles = l.styles, n.content.splice(0, n.content.length, ...l.content);
310
345
  }
311
- function f() {
312
- return JSON.parse(JSON.stringify(j(n)));
346
+ function p() {
347
+ return JSON.parse(JSON.stringify(oe(n)));
313
348
  }
314
- return { document: n, findNodeById: i, replaceContent: a, snapshotContent: l, loadDocument: d, exportDocument: f };
349
+ return { document: n, findNodeById: i, replaceContent: f, snapshotContent: d, loadDocument: m, exportDocument: p };
315
350
  }
316
- function gt(e) {
317
- M(_e, e);
351
+ function At(e) {
352
+ F(Be, e);
318
353
  }
319
- function le() {
320
- const e = B(_e);
354
+ function G() {
355
+ const e = B(Be);
321
356
  if (!e)
322
357
  throw new Error("useDocumentStore() requires a BrickPdf ancestor component");
323
358
  return e;
324
359
  }
325
- const ke = /* @__PURE__ */ Symbol("brick-pdf-selection");
326
- function bt(e) {
327
- const t = I(null), n = E(() => t.value ? e.findNodeById(t.value)?.node ?? null : null);
328
- function i(l) {
329
- t.value = l;
360
+ const Me = /* @__PURE__ */ Symbol("brick-pdf-selection");
361
+ function Vt(e) {
362
+ const t = E(null), n = x(() => t.value ? e.findNodeById(t.value)?.node ?? null : null);
363
+ function i(d) {
364
+ t.value = d;
330
365
  }
331
- function a() {
366
+ function f() {
332
367
  t.value = null;
333
368
  }
334
- return { selectedId: t, selectedNode: n, select: i, deselect: a };
369
+ return { selectedId: t, selectedNode: n, select: i, deselect: f };
335
370
  }
336
- function ht(e) {
337
- M(ke, e);
371
+ function Ht(e) {
372
+ F(Me, e);
338
373
  }
339
- function q() {
340
- const e = B(ke);
374
+ function Q() {
375
+ const e = B(Me);
341
376
  if (!e)
342
377
  throw new Error("useSelection() requires a BrickPdf ancestor component");
343
378
  return e;
344
379
  }
345
- const Se = /* @__PURE__ */ Symbol("brick-pdf-element-actions");
346
- let vt = 0;
347
- function xe() {
348
- return `el-${Date.now()}-${++vt}`;
380
+ const Oe = /* @__PURE__ */ Symbol("brick-pdf-element-actions");
381
+ let Ft = 0;
382
+ function Ae() {
383
+ return `el-${Date.now()}-${++Ft}`;
349
384
  }
350
- function Ce(e) {
385
+ function Ve(e) {
351
386
  return {
352
387
  ...e,
353
- id: xe(),
388
+ id: Ae(),
354
389
  props: structuredClone(e.props),
355
390
  style: structuredClone(e.style),
356
- children: e.children.map(Ce)
391
+ children: e.children.map(Ve)
357
392
  };
358
393
  }
359
- function _t(e, t) {
360
- function n(r, o, p) {
361
- const g = Y(r);
362
- if (!g) return null;
394
+ function Ut(e, t) {
395
+ function n(l, o, r) {
396
+ const c = W(l);
397
+ if (!c) return null;
363
398
  t.record();
364
- const m = {
365
- id: xe(),
366
- type: r,
367
- props: g.defaultProps(),
368
- style: g.defaultStyle(),
399
+ const v = {
400
+ id: Ae(),
401
+ type: l,
402
+ props: c.defaultProps(),
403
+ style: c.defaultStyle(),
369
404
  children: []
370
- }, h = o ? e.findNodeById(o)?.node.children : e.document.content;
371
- if (!h) return null;
372
- const v = p ?? h.length;
373
- return h.splice(v, 0, m), m;
405
+ }, b = o ? e.findNodeById(o)?.node.children : e.document.content;
406
+ if (!b) return null;
407
+ const k = r ?? b.length;
408
+ return b.splice(k, 0, v), v;
374
409
  }
375
- function i(r) {
376
- const o = e.findNodeById(r);
410
+ function i(l) {
411
+ const o = e.findNodeById(l);
377
412
  o && (t.record(), o.parent.splice(o.index, 1));
378
413
  }
379
- function a(r, o, p) {
380
- const g = e.findNodeById(r);
381
- if (!g) return;
414
+ function f(l, o, r) {
415
+ const c = e.findNodeById(l);
416
+ if (!c) return;
382
417
  t.record();
383
- const m = g.parent.splice(g.index, 1)[0];
384
- if (!m) return;
385
- const h = o ? e.findNodeById(o)?.node.children : e.document.content;
386
- h && h.splice(p, 0, m);
418
+ const v = c.parent.splice(c.index, 1)[0];
419
+ if (!v) return;
420
+ const b = o ? e.findNodeById(o)?.node.children : e.document.content;
421
+ b && b.splice(r, 0, v);
387
422
  }
388
- function l(r) {
389
- const o = e.findNodeById(r);
423
+ function d(l) {
424
+ const o = e.findNodeById(l);
390
425
  if (!o) return null;
391
426
  t.record();
392
- const p = Ce(o.node);
393
- return o.parent.splice(o.index + 1, 0, p), p;
427
+ const r = Ve(o.node);
428
+ return o.parent.splice(o.index + 1, 0, r), r;
394
429
  }
395
- function d(r, o) {
396
- const p = e.findNodeById(r);
397
- p && (t.record(), Object.assign(p.node.props, o));
430
+ function m(l, o) {
431
+ const r = e.findNodeById(l);
432
+ r && (t.record(), Object.assign(r.node.props, o));
398
433
  }
399
- function f(r, o) {
400
- const p = e.findNodeById(r);
401
- p && (t.record(), Object.assign(p.node.style, o));
434
+ function p(l, o) {
435
+ const r = e.findNodeById(l);
436
+ r && (t.record(), Object.assign(r.node.style, o));
402
437
  }
403
- function u(r, o) {
404
- const p = e.findNodeById(r);
405
- p && (t.record(), o ? p.node.key = o : delete p.node.key);
438
+ function s(l, o) {
439
+ const r = e.findNodeById(l);
440
+ r && (t.record(), o ? r.node.key = o : delete r.node.key);
406
441
  }
407
- return { addElement: n, removeElement: i, moveElement: a, duplicateElement: l, updateProps: d, updateStyle: f, updateKey: u };
442
+ return { addElement: n, removeElement: i, moveElement: f, duplicateElement: d, updateProps: m, updateStyle: p, updateKey: s };
408
443
  }
409
- function kt(e) {
410
- M(Se, e);
444
+ function Jt(e) {
445
+ F(Oe, e);
411
446
  }
412
- function K() {
413
- const e = B(Se);
447
+ function re() {
448
+ const e = B(Oe);
414
449
  if (!e)
415
450
  throw new Error("useElementActions() requires a BrickPdf ancestor component");
416
451
  return e;
417
452
  }
418
- const we = /* @__PURE__ */ Symbol("brick-pdf-history"), St = 50;
419
- function xt(e) {
420
- const t = I([]), n = I([]);
453
+ const He = /* @__PURE__ */ Symbol("brick-pdf-history"), Wt = 50;
454
+ function jt(e) {
455
+ const t = E([]), n = E([]);
421
456
  let i = 0;
422
- const a = E(() => t.value.length > 0), l = E(() => n.value.length > 0);
423
- function d() {
424
- const r = Date.now();
425
- if (r - i < 100) return;
426
- i = r;
457
+ const f = x(() => t.value.length > 0), d = x(() => n.value.length > 0);
458
+ function m() {
459
+ const l = Date.now();
460
+ if (l - i < 100) return;
461
+ i = l;
427
462
  const o = e.snapshotContent();
428
- t.value.push(o), t.value.length > St && t.value.shift(), n.value = [];
463
+ t.value.push(o), t.value.length > Wt && t.value.shift(), n.value = [];
429
464
  }
430
- function f() {
431
- const r = t.value.pop();
432
- r && (n.value.push(e.snapshotContent()), e.replaceContent(r));
465
+ function p() {
466
+ const l = t.value.pop();
467
+ l && (n.value.push(e.snapshotContent()), e.replaceContent(l));
433
468
  }
434
- function u() {
435
- const r = n.value.pop();
436
- r && (t.value.push(e.snapshotContent()), e.replaceContent(r));
469
+ function s() {
470
+ const l = n.value.pop();
471
+ l && (t.value.push(e.snapshotContent()), e.replaceContent(l));
437
472
  }
438
- return { canUndo: a, canRedo: l, record: d, undo: f, redo: u };
473
+ return { canUndo: f, canRedo: d, record: m, undo: p, redo: s };
439
474
  }
440
- function Ct(e) {
441
- M(we, e);
475
+ function Yt(e) {
476
+ F(He, e);
442
477
  }
443
- function wt() {
444
- const e = B(we);
478
+ function qt() {
479
+ const e = B(He);
445
480
  if (!e)
446
481
  throw new Error("useHistory() requires a BrickPdf ancestor component");
447
482
  return e;
448
483
  }
449
- const Pe = /* @__PURE__ */ Symbol("brick-pdf-drag-drop");
450
- function Pt(e, t) {
451
- const n = I(!1);
452
- function i(l) {
453
- return fe.create(l, {
484
+ const Fe = /* @__PURE__ */ Symbol("brick-pdf-drag-drop");
485
+ function Kt(e, t) {
486
+ const n = E(!1);
487
+ function i(d) {
488
+ return we.create(d, {
454
489
  group: { name: "brick-elements", pull: "clone", put: !1 },
455
490
  sort: !1,
456
491
  animation: 150,
@@ -462,8 +497,8 @@ function Pt(e, t) {
462
497
  }
463
498
  });
464
499
  }
465
- function a(l, d) {
466
- return fe.create(l, {
500
+ function f(d, m) {
501
+ return we.create(d, {
467
502
  group: { name: "brick-elements", put: !0 },
468
503
  animation: 150,
469
504
  fallbackOnBody: !0,
@@ -473,303 +508,301 @@ function Pt(e, t) {
473
508
  onStart() {
474
509
  n.value = !0;
475
510
  },
476
- onAdd(f) {
477
- const u = f.item, r = u.dataset.elementId, o = u.dataset.elementType, p = (g) => {
478
- if (!d || !g) return !1;
479
- const m = e.findNodeById(d);
480
- if (!m) return !1;
481
- const h = Y(m.node.type);
482
- return !!(h?.acceptsChildTypes && !h.acceptsChildTypes.includes(g));
511
+ onAdd(p) {
512
+ const s = p.item, l = s.dataset.elementId, o = s.dataset.elementType, r = (c) => {
513
+ if (!m || !c) return !1;
514
+ const v = e.findNodeById(m);
515
+ if (!v) return !1;
516
+ const b = W(v.node.type);
517
+ return !!(b?.acceptsChildTypes && !b.acceptsChildTypes.includes(c));
483
518
  };
484
- if (r) {
485
- if (u.parentNode?.removeChild(u), p(o)) return;
486
- t.moveElement(r, d, f.newIndex ?? 0);
519
+ if (l) {
520
+ if (r(o)) {
521
+ p.from.insertBefore(s, p.from.children[p.oldIndex ?? 0] ?? null);
522
+ return;
523
+ }
524
+ s.parentNode?.removeChild(s), t.moveElement(l, m, p.newIndex ?? 0);
487
525
  return;
488
526
  }
489
- o && (u.parentNode?.removeChild(u), !p(o) && t.addElement(o, d, f.newIndex));
527
+ o && (s.parentNode?.removeChild(s), !r(o) && t.addElement(o, m, p.newIndex));
490
528
  },
491
- onEnd(f) {
492
- if (n.value = !1, f.from === f.to && f.oldIndex !== void 0 && f.newIndex !== void 0 && f.oldIndex !== f.newIndex && f.item.dataset.elementId) {
493
- const u = d ? e.findNodeById(d)?.node.children : e.document.content;
494
- if (!u) return;
495
- const r = u.splice(f.oldIndex, 1)[0];
496
- r && u.splice(f.newIndex, 0, r);
497
- }
529
+ onEnd(p) {
530
+ n.value = !1, p.from === p.to && p.oldIndex !== void 0 && p.newIndex !== void 0 && p.oldIndex !== p.newIndex && p.item.dataset.elementId && t.moveElement(p.item.dataset.elementId, m, p.newIndex);
498
531
  }
499
532
  });
500
533
  }
501
- return { initToolbar: i, initContainer: a, isDragging: n };
534
+ return { initToolbar: i, initContainer: f, isDragging: n };
502
535
  }
503
- function Et(e) {
504
- M(Pe, e);
536
+ function Xt(e) {
537
+ F(Fe, e);
505
538
  }
506
- function ie() {
507
- const e = B(Pe);
539
+ function ge() {
540
+ const e = B(Fe);
508
541
  if (!e)
509
542
  throw new Error("useDragDrop() requires a BrickPdf ancestor component");
510
543
  return e;
511
544
  }
512
- const me = {
545
+ const Ee = {
513
546
  regular: "https://cdn.jsdelivr.net/npm/@expo-google-fonts/noto-sans-jp/NotoSansJP_400Regular.ttf",
514
547
  bold: "https://cdn.jsdelivr.net/npm/@expo-google-fonts/noto-sans-jp/NotoSansJP_700Bold.ttf"
515
- }, H = {
548
+ }, X = {
516
549
  regular: "NotoSansJP-Regular.ttf",
517
550
  bold: "NotoSansJP-Bold.ttf"
518
- }, It = "NotoSansJP";
519
- function $t(e) {
551
+ }, Gt = "NotoSansJP";
552
+ function Qt(e) {
520
553
  const t = new Uint8Array(e), n = 32768;
521
554
  let i = "";
522
- for (let a = 0; a < t.length; a += n) {
523
- const l = t.subarray(a, a + n);
524
- i += String.fromCharCode.apply(null, Array.from(l));
555
+ for (let f = 0; f < t.length; f += n) {
556
+ const d = t.subarray(f, f + n);
557
+ i += String.fromCharCode.apply(null, Array.from(d));
525
558
  }
526
559
  return btoa(i);
527
560
  }
528
- async function ge(e) {
561
+ async function $e(e) {
529
562
  const t = await fetch(e);
530
563
  if (!t.ok)
531
564
  throw new Error(`Failed to load font ${e}: HTTP ${t.status}`);
532
565
  const n = await t.arrayBuffer();
533
- return $t(n);
566
+ return Qt(n);
534
567
  }
535
- let W = null;
536
- function Rt() {
537
- return W || (W = (async () => {
568
+ let te = null;
569
+ function Zt() {
570
+ return te || (te = (async () => {
538
571
  const [e, t] = await Promise.all([
539
- ge(me.regular),
540
- ge(me.bold)
572
+ $e(Ee.regular),
573
+ $e(Ee.bold)
541
574
  ]);
542
575
  return {
543
576
  vfs: {
544
- [H.regular]: e,
545
- [H.bold]: t
577
+ [X.regular]: e,
578
+ [X.bold]: t
546
579
  },
547
580
  fonts: {
548
- [It]: {
549
- normal: H.regular,
550
- bold: H.bold,
551
- italics: H.regular,
552
- bolditalics: H.bold
581
+ [Gt]: {
582
+ normal: X.regular,
583
+ bold: X.bold,
584
+ italics: X.regular,
585
+ bolditalics: X.bold
553
586
  }
554
587
  }
555
588
  };
556
589
  })().catch((e) => {
557
- throw W = null, e;
558
- }), W);
590
+ throw te = null, e;
591
+ }), te);
559
592
  }
560
- const Ee = /* @__PURE__ */ Symbol("brick-pdf-export");
561
- function Nt(e) {
562
- return e.map(Ie);
593
+ const Ue = /* @__PURE__ */ Symbol("brick-pdf-export");
594
+ function en(e) {
595
+ return e.map(Je);
563
596
  }
564
- function Ie(e) {
565
- const t = Y(e.type);
566
- return t ? t.toPdfmake(e, Nt) : { text: `[Unknown: ${e.type}]` };
597
+ function Je(e) {
598
+ const t = W(e.type);
599
+ return t ? t.toPdfmake(e, en) : { text: `[Unknown: ${e.type}]` };
567
600
  }
568
- function zt(e) {
601
+ function tn(e) {
569
602
  function t() {
570
- const l = e.document;
603
+ const d = e.document;
571
604
  return {
572
- pageSize: l.pageSize,
573
- pageOrientation: l.pageOrientation,
574
- pageMargins: l.pageMargins,
575
- defaultStyle: JSON.parse(JSON.stringify(j(l.defaultStyle))),
576
- styles: JSON.parse(JSON.stringify(j(l.styles))),
577
- content: l.content.map(Ie)
605
+ pageSize: d.pageSize,
606
+ pageOrientation: d.pageOrientation,
607
+ pageMargins: d.pageMargins,
608
+ defaultStyle: JSON.parse(JSON.stringify(oe(d.defaultStyle))),
609
+ styles: JSON.parse(JSON.stringify(oe(d.styles))),
610
+ content: d.content.map(Je)
578
611
  };
579
612
  }
580
613
  async function n() {
581
- const l = await import("pdfmake/build/pdfmake"), d = await import("pdfmake/build/vfs_fonts"), f = l.default || l, u = d.pdfMake?.vfs ?? d.default ?? {}, r = await Rt();
582
- return f.addVirtualFileSystem({ ...u, ...r.vfs }), f.setFonts({
614
+ const d = await import("pdfmake/build/pdfmake"), m = await import("pdfmake/build/vfs_fonts"), p = d.default || d, s = m.pdfMake?.vfs ?? m.default ?? {}, l = await Zt();
615
+ return p.addVirtualFileSystem({ ...s, ...l.vfs }), p.setFonts({
583
616
  Roboto: {
584
617
  normal: "Roboto-Regular.ttf",
585
618
  bold: "Roboto-Medium.ttf",
586
619
  italics: "Roboto-Italic.ttf",
587
620
  bolditalics: "Roboto-MediumItalic.ttf"
588
621
  },
589
- ...r.fonts
590
- }), f;
622
+ ...l.fonts
623
+ }), p;
591
624
  }
592
- function i(l) {
593
- const d = t();
594
- n().then((f) => {
595
- f.createPdf(d).download(l ?? "document.pdf");
625
+ function i(d) {
626
+ const m = t();
627
+ n().then((p) => {
628
+ p.createPdf(m).download(d ?? "document.pdf");
596
629
  });
597
630
  }
598
- function a() {
599
- const l = t();
600
- n().then((d) => {
601
- d.createPdf(l).open();
631
+ function f() {
632
+ const d = t();
633
+ n().then((m) => {
634
+ m.createPdf(d).open();
602
635
  });
603
636
  }
604
- return { toDocumentDefinition: t, exportPdf: i, openPdf: a };
637
+ return { toDocumentDefinition: t, exportPdf: i, openPdf: f };
605
638
  }
606
- function Tt(e) {
607
- M(Ee, e);
639
+ function nn(e) {
640
+ F(Ue, e);
608
641
  }
609
- function Lt() {
610
- const e = B(Ee);
642
+ function on() {
643
+ const e = B(Ue);
611
644
  if (!e)
612
645
  throw new Error("usePdfExport() requires a BrickPdf ancestor component");
613
646
  return e;
614
647
  }
615
- const $e = /* @__PURE__ */ Symbol("brick-pdf-clipboard");
616
- let Dt = 0;
617
- function Mt() {
618
- return `el-${Date.now()}-${++Dt}`;
648
+ const We = /* @__PURE__ */ Symbol("brick-pdf-clipboard");
649
+ let rn = 0;
650
+ function ln() {
651
+ return `el-${Date.now()}-${++rn}`;
619
652
  }
620
- function Re(e) {
653
+ function je(e) {
621
654
  return {
622
655
  ...e,
623
- id: Mt(),
656
+ id: ln(),
624
657
  props: structuredClone(e.props),
625
658
  style: structuredClone(e.style),
626
- children: e.children.map(Re)
659
+ children: e.children.map(je)
627
660
  };
628
661
  }
629
- function Bt(e, t) {
630
- const n = I(null), i = I(!1), a = I(null), l = I(!1);
631
- function d(r) {
632
- const o = e.findNodeById(r);
633
- o && (n.value = structuredClone(o.node), i.value = !1, a.value = null, l.value = !0);
662
+ function sn(e, t) {
663
+ const n = E(null), i = E(!1), f = E(null), d = E(!1);
664
+ function m(l) {
665
+ const o = e.findNodeById(l);
666
+ o && (n.value = structuredClone(o.node), i.value = !1, f.value = null, d.value = !0);
634
667
  }
635
- function f(r) {
636
- const o = e.findNodeById(r);
637
- o && (n.value = structuredClone(o.node), i.value = !0, a.value = r, l.value = !0);
668
+ function p(l) {
669
+ const o = e.findNodeById(l);
670
+ o && (n.value = structuredClone(o.node), i.value = !0, f.value = l, d.value = !0);
638
671
  }
639
- function u(r) {
672
+ function s(l) {
640
673
  if (!n.value) return;
641
- i.value && a.value && (t.removeElement(a.value), i.value = !1, a.value = null);
642
- const o = Re(n.value), p = r ? e.findNodeById(r)?.node.children : e.document.content;
643
- p && (p.push(o), i.value && (n.value = null, l.value = !1));
674
+ i.value && f.value && (t.removeElement(f.value), i.value = !1, f.value = null);
675
+ const o = je(n.value), r = l ? e.findNodeById(l)?.node.children : e.document.content;
676
+ r && (r.push(o), i.value && (n.value = null, d.value = !1));
644
677
  }
645
- return { hasClipboard: l, copy: d, cut: f, paste: u };
678
+ return { hasClipboard: d, copy: m, cut: p, paste: s };
646
679
  }
647
- function Ot(e) {
648
- M($e, e);
680
+ function an(e) {
681
+ F(We, e);
649
682
  }
650
- function ar() {
651
- const e = B($e);
683
+ function Gr() {
684
+ const e = B(We);
652
685
  if (!e)
653
686
  throw new Error("useClipboard() requires a BrickPdf ancestor component");
654
687
  return e;
655
688
  }
656
- const Ne = /* @__PURE__ */ Symbol("brick-pdf-resize");
657
- function At(e) {
658
- const t = I(!1);
659
- function n(i, a, l, d) {
689
+ const Ye = /* @__PURE__ */ Symbol("brick-pdf-resize");
690
+ function cn(e) {
691
+ const t = E(!1);
692
+ function n(i, f, d, m) {
660
693
  t.value = !0;
661
- const f = d.clientX, u = d.clientY, r = l.width, o = l.height;
662
- function p(m) {
663
- const h = m.clientX - f, v = m.clientY - u;
664
- let b = r, S = o;
665
- a.includes("e") && (b = r + h), a.includes("w") && (b = r - h), a.includes("s") && (S = o + v), a.includes("n") && (S = o - v), b = Math.max(20, b), S = Math.max(20, S), e.updateStyle(i, {
666
- width: Math.round(b),
667
- height: Math.round(S)
694
+ const p = m.clientX, s = m.clientY, l = d.width, o = d.height;
695
+ function r(v) {
696
+ const b = v.clientX - p, k = v.clientY - s;
697
+ let C = l, _ = o;
698
+ f.includes("e") && (C = l + b), f.includes("w") && (C = l - b), f.includes("s") && (_ = o + k), f.includes("n") && (_ = o - k), C = Math.max(20, C), _ = Math.max(20, _), e.updateStyle(i, {
699
+ width: Math.round(C),
700
+ height: Math.round(_)
668
701
  });
669
702
  }
670
- function g() {
671
- t.value = !1, document.removeEventListener("pointermove", p), document.removeEventListener("pointerup", g);
703
+ function c() {
704
+ t.value = !1, document.removeEventListener("pointermove", r), document.removeEventListener("pointerup", c);
672
705
  }
673
- document.addEventListener("pointermove", p), document.addEventListener("pointerup", g);
706
+ document.addEventListener("pointermove", r), document.addEventListener("pointerup", c);
674
707
  }
675
708
  return { isResizing: t, startResize: n };
676
709
  }
677
- function Vt(e) {
678
- M(Ne, e);
710
+ function un(e) {
711
+ F(Ye, e);
679
712
  }
680
- function cr() {
681
- const e = B(Ne);
713
+ function Qr() {
714
+ const e = B(Ye);
682
715
  if (!e)
683
716
  throw new Error("useResize() requires a BrickPdf ancestor component");
684
717
  return e;
685
718
  }
686
- const Ft = { class: "brick-table-editor" }, Ht = { class: "brick-table-editor__grid" }, Jt = ["onClick"], Ut = { class: "brick-table-editor__row-header" }, Wt = ["onClick"], jt = ["value", "onInput"], Yt = /* @__PURE__ */ _({
719
+ const dn = { class: "brick-table-editor" }, pn = { class: "brick-table-editor__grid" }, fn = ["onClick"], yn = { class: "brick-table-editor__row-header" }, mn = ["onClick"], vn = ["value", "onInput"], bn = /* @__PURE__ */ S({
687
720
  __name: "TablePropertyEditor",
688
721
  props: {
689
722
  node: {}
690
723
  },
691
724
  setup(e) {
692
- const t = e, n = K();
725
+ const t = e, n = re();
693
726
  function i() {
694
727
  return t.node.props.body ?? [];
695
728
  }
696
- function a() {
729
+ function f() {
697
730
  return t.node.props.widths ?? [];
698
731
  }
699
- function l(o, p, g) {
700
- const m = i().map((h) => [...h]);
701
- m[o][p] = g, n.updateProps(t.node.id, { body: m });
732
+ function d(o, r, c) {
733
+ const v = i().map((b) => [...b]);
734
+ v[o][r] = c, n.updateProps(t.node.id, { body: v });
702
735
  }
703
- function d() {
704
- const o = i().map((g) => [...g]), p = o[0]?.length ?? 2;
705
- o.push(Array(p).fill("")), n.updateProps(t.node.id, { body: o });
736
+ function m() {
737
+ const o = i().map((c) => [...c]), r = o[0]?.length ?? 2;
738
+ o.push(Array(r).fill("")), n.updateProps(t.node.id, { body: o });
706
739
  }
707
- function f(o) {
708
- const p = i().map((m) => [...m]);
709
- if (p.length <= 1) return;
710
- p.splice(o, 1), t.node.props.headerRows > p.length ? n.updateProps(t.node.id, { body: p, headerRows: p.length }) : n.updateProps(t.node.id, { body: p });
740
+ function p(o) {
741
+ const r = i().map((v) => [...v]);
742
+ if (r.length <= 1) return;
743
+ r.splice(o, 1), t.node.props.headerRows > r.length ? n.updateProps(t.node.id, { body: r, headerRows: r.length }) : n.updateProps(t.node.id, { body: r });
711
744
  }
712
- function u() {
713
- const o = i().map((g) => [...g, ""]), p = [...a(), "*"];
714
- n.updateProps(t.node.id, { body: o, widths: p });
745
+ function s() {
746
+ const o = i().map((c) => [...c, ""]), r = [...f(), "*"];
747
+ n.updateProps(t.node.id, { body: o, widths: r });
715
748
  }
716
- function r(o) {
717
- const p = i().map((m) => {
718
- const h = [...m];
719
- return h.splice(o, 1), h;
749
+ function l(o) {
750
+ const r = i().map((v) => {
751
+ const b = [...v];
752
+ return b.splice(o, 1), b;
720
753
  });
721
- if ((p[0]?.length ?? 0) < 1) return;
722
- const g = [...a()];
723
- g.splice(o, 1), n.updateProps(t.node.id, { body: p, widths: g });
754
+ if ((r[0]?.length ?? 0) < 1) return;
755
+ const c = [...f()];
756
+ c.splice(o, 1), n.updateProps(t.node.id, { body: r, widths: c });
724
757
  }
725
- return (o, p) => (s(), c("div", Ft, [
758
+ return (o, r) => (a(), u("div", dn, [
726
759
  y("div", { class: "brick-table-editor__actions" }, [
727
760
  y("button", {
728
761
  class: "brick-table-editor__btn",
729
- onClick: d
762
+ onClick: m
730
763
  }, "+ Row"),
731
764
  y("button", {
732
765
  class: "brick-table-editor__btn",
733
- onClick: u
766
+ onClick: s
734
767
  }, "+ Column")
735
768
  ]),
736
- y("div", Ht, [
769
+ y("div", pn, [
737
770
  y("table", null, [
738
771
  y("thead", null, [
739
772
  y("tr", null, [
740
- p[0] || (p[0] = y("th", { class: "brick-table-editor__corner" }, null, -1)),
741
- (s(!0), c(C, null, P(i()[0] ?? [], (g, m) => (s(), c("th", {
742
- key: m,
773
+ r[0] || (r[0] = y("th", { class: "brick-table-editor__corner" }, null, -1)),
774
+ (a(!0), u(P, null, T(i()[0] ?? [], (c, v) => (a(), u("th", {
775
+ key: v,
743
776
  class: "brick-table-editor__col-header"
744
777
  }, [
745
- ce(" Col " + w(m + 1) + " ", 1),
746
- (i()[0]?.length ?? 0) > 1 ? (s(), c("button", {
778
+ pe(" Col " + w(v + 1) + " ", 1),
779
+ (i()[0]?.length ?? 0) > 1 ? (a(), u("button", {
747
780
  key: 0,
748
781
  class: "brick-table-editor__remove-btn",
749
782
  title: "Remove column",
750
- onClick: (h) => r(m)
751
- }, "x", 8, Jt)) : $("", !0)
783
+ onClick: (b) => l(v)
784
+ }, "x", 8, fn)) : R("", !0)
752
785
  ]))), 128))
753
786
  ])
754
787
  ]),
755
788
  y("tbody", null, [
756
- (s(!0), c(C, null, P(i(), (g, m) => (s(), c("tr", { key: m }, [
757
- y("td", Ut, [
758
- ce(w(m + 1) + " ", 1),
759
- i().length > 1 ? (s(), c("button", {
789
+ (a(!0), u(P, null, T(i(), (c, v) => (a(), u("tr", { key: v }, [
790
+ y("td", yn, [
791
+ pe(w(v + 1) + " ", 1),
792
+ i().length > 1 ? (a(), u("button", {
760
793
  key: 0,
761
794
  class: "brick-table-editor__remove-btn",
762
795
  title: "Remove row",
763
- onClick: (h) => f(m)
764
- }, "x", 8, Wt)) : $("", !0)
796
+ onClick: (b) => p(v)
797
+ }, "x", 8, mn)) : R("", !0)
765
798
  ]),
766
- (s(!0), c(C, null, P(g, (h, v) => (s(), c("td", { key: v }, [
799
+ (a(!0), u(P, null, T(c, (b, k) => (a(), u("td", { key: k }, [
767
800
  y("input", {
768
801
  class: "brick-table-editor__cell",
769
802
  type: "text",
770
- value: h,
771
- onInput: (b) => l(m, v, b.target.value)
772
- }, null, 40, jt)
803
+ value: b,
804
+ onInput: (C) => d(v, k, C.target.value)
805
+ }, null, 40, vn)
773
806
  ]))), 128))
774
807
  ]))), 128))
775
808
  ])
@@ -777,15 +810,15 @@ const Ft = { class: "brick-table-editor" }, Ht = { class: "brick-table-editor__g
777
810
  ])
778
811
  ]));
779
812
  }
780
- }), qt = /* @__PURE__ */ x(Yt, [["__scopeId", "data-v-4895020c"]]), Kt = {
813
+ }), gn = /* @__PURE__ */ $(bn, [["__scopeId", "data-v-4895020c"]]), hn = {
781
814
  type: "table",
782
815
  label: "Table",
783
816
  icon: "▦",
784
817
  isContainer: !1,
785
- defaultProps: dt,
786
- defaultStyle: ut,
787
- rendererComponent: yt,
788
- propertyEditorComponent: qt,
818
+ defaultProps: Tt,
819
+ defaultStyle: Rt,
820
+ rendererComponent: Mt,
821
+ propertyEditorComponent: gn,
789
822
  propertyFields: [
790
823
  { key: "props.headerRows", label: "Header Rows", section: "content", type: "number", min: 0, max: 10, step: 1, defaultValue: 1 },
791
824
  { key: "props.layout", label: "Border Style", section: "style", type: "select", options: [
@@ -793,67 +826,67 @@ const Ft = { class: "brick-table-editor" }, Ht = { class: "brick-table-editor__g
793
826
  { label: "Grid", value: "grid" },
794
827
  { label: "Header Only", value: "headerLineOnly" },
795
828
  { label: "No Borders", value: "noBorders" },
796
- { label: "None", value: "none" }
829
+ { label: "Default (grid)", value: "none" }
797
830
  ], defaultValue: "lightHorizontalLines" },
798
831
  { key: "style.fontSize", label: "Font Size", section: "style", type: "number", min: 6, max: 72, step: 1, defaultValue: 12 },
799
832
  { key: "style.color", label: "Text Color", section: "style", type: "color", defaultValue: "#000000" },
800
833
  { key: "style.margin", label: "Margin", section: "layout", type: "margin", defaultValue: [0, 0, 0, 0] }
801
834
  ],
802
- toPdfmake: pt
835
+ toPdfmake: Lt
803
836
  };
804
- function Gt() {
837
+ function _n() {
805
838
  return { src: "", width: 200, height: 150, fit: null };
806
839
  }
807
- function Xt() {
840
+ function kn() {
808
841
  return {};
809
842
  }
810
- function Qt(e) {
843
+ function Sn(e) {
811
844
  const t = {
812
845
  image: e.props.src
813
846
  };
814
847
  return e.props.width && (t.width = e.props.width), e.props.height && (t.height = e.props.height), e.props.fit && (t.fit = e.props.fit), e.style.margin && (t.margin = e.style.margin), e.style.alignment && (t.alignment = e.style.alignment), e.style.opacity !== void 0 && (t.opacity = e.style.opacity), t;
815
848
  }
816
- const Zt = { class: "brick-el-image" }, en = ["src"], tn = {
849
+ const xn = { class: "brick-el-image" }, Cn = ["src"], wn = {
817
850
  key: 1,
818
851
  class: "brick-el-image__placeholder"
819
- }, nn = /* @__PURE__ */ _({
852
+ }, Pn = /* @__PURE__ */ S({
820
853
  __name: "ImageRenderer",
821
854
  props: {
822
855
  node: {}
823
856
  },
824
857
  setup(e) {
825
- return (t, n) => (s(), c("div", Zt, [
826
- e.node.props.src ? (s(), c("img", {
858
+ return (t, n) => (a(), u("div", xn, [
859
+ e.node.props.src ? (a(), u("img", {
827
860
  key: 0,
828
861
  src: e.node.props.src,
829
- style: z({
830
- width: e.node.props.width + "px",
831
- height: e.node.props.height + "px",
832
- objectFit: "contain",
862
+ style: L({
863
+ width: e.node.props.width ? "calc(" + e.node.props.width + " * var(--brick-pt, 1px))" : void 0,
864
+ height: e.node.props.height ? "calc(" + e.node.props.height + " * var(--brick-pt, 1px))" : void 0,
865
+ objectFit: e.node.props.fit ? "contain" : "fill",
833
866
  opacity: e.node.style.opacity
834
867
  })
835
- }, null, 12, en)) : (s(), c("div", tn, " No image selected "))
868
+ }, null, 12, Cn)) : (a(), u("div", wn, " No image selected "))
836
869
  ]));
837
870
  }
838
- }), on = /* @__PURE__ */ x(nn, [["__scopeId", "data-v-38184258"]]), rn = { class: "brick-image-editor" }, ln = /* @__PURE__ */ _({
871
+ }), En = /* @__PURE__ */ $(Pn, [["__scopeId", "data-v-c4eec346"]]), $n = { class: "brick-image-editor" }, In = /* @__PURE__ */ S({
839
872
  __name: "ImagePropertyEditor",
840
873
  props: {
841
874
  node: {}
842
875
  },
843
876
  setup(e) {
844
- return (t, n) => (s(), c("div", rn));
877
+ return (t, n) => (a(), u("div", $n));
845
878
  }
846
- }), sn = {
879
+ }), Nn = {
847
880
  type: "image",
848
881
  label: "Image",
849
882
  icon: "🖼",
850
883
  isContainer: !1,
851
- defaultProps: Gt,
852
- defaultStyle: Xt,
853
- rendererComponent: on,
854
- propertyEditorComponent: ln,
884
+ defaultProps: _n,
885
+ defaultStyle: kn,
886
+ rendererComponent: En,
887
+ propertyEditorComponent: In,
855
888
  propertyFields: [
856
- { key: "props.src", label: "Image (Base64)", section: "content", type: "file" },
889
+ { key: "props.src", label: "Image (Base64)", section: "content", type: "file", accept: "image/png,image/jpeg" },
857
890
  { key: "props.width", label: "Width", section: "layout", type: "number", min: 10, max: 1e3, step: 10, defaultValue: 200 },
858
891
  { key: "props.height", label: "Height", section: "layout", type: "number", min: 10, max: 1e3, step: 10, defaultValue: 150 },
859
892
  { key: "style.alignment", label: "Alignment", section: "style", type: "select", options: [
@@ -864,53 +897,53 @@ const Zt = { class: "brick-el-image" }, en = ["src"], tn = {
864
897
  { key: "style.margin", label: "Margin", section: "layout", type: "margin", defaultValue: [0, 0, 0, 0] },
865
898
  { key: "style.opacity", label: "Opacity", section: "advanced", type: "slider", min: 0, max: 1, step: 0.1, defaultValue: 1 }
866
899
  ],
867
- toPdfmake: Qt
900
+ toPdfmake: Sn
868
901
  };
869
- function an() {
902
+ function zn() {
870
903
  return { ordered: !1, items: ["Item 1", "Item 2", "Item 3"] };
871
904
  }
872
- function cn() {
905
+ function Tn() {
873
906
  return { fontSize: 12 };
874
907
  }
875
- function dn(e) {
908
+ function Rn(e) {
876
909
  const t = e.props.items, i = e.props.ordered ? { ol: t } : { ul: t };
877
910
  return e.style.fontSize && (i.fontSize = e.style.fontSize), e.style.color && (i.color = e.style.color), e.style.margin && (i.margin = e.style.margin), i;
878
911
  }
879
- const un = /* @__PURE__ */ _({
912
+ const Ln = /* @__PURE__ */ S({
880
913
  __name: "ListRenderer",
881
914
  props: {
882
915
  node: {}
883
916
  },
884
917
  setup(e) {
885
- return (t, n) => (s(), c("div", {
918
+ return (t, n) => (a(), u("div", {
886
919
  class: "brick-el-list",
887
- style: z({ fontSize: (e.node.style.fontSize ?? 12) + "px", color: e.node.style.color })
920
+ style: L({ fontSize: e.node.style.fontSize ? "calc(" + e.node.style.fontSize + " * var(--brick-pt, 1px))" : void 0, color: e.node.style.color })
888
921
  }, [
889
- (s(), O(oe(e.node.props.ordered ? "ol" : "ul"), null, {
890
- default: G(() => [
891
- (s(!0), c(C, null, P(e.node.props.items, (i, a) => (s(), c("li", { key: a }, w(i), 1))), 128))
922
+ (a(), H(ve(e.node.props.ordered ? "ol" : "ul"), null, {
923
+ default: se(() => [
924
+ (a(!0), u(P, null, T(e.node.props.items, (i, f) => (a(), u("li", { key: f }, w(i), 1))), 128))
892
925
  ]),
893
926
  _: 1
894
927
  }))
895
928
  ], 4));
896
929
  }
897
- }), pn = /* @__PURE__ */ x(un, [["__scopeId", "data-v-8107f859"]]), fn = { class: "brick-list-editor" }, yn = /* @__PURE__ */ _({
930
+ }), Dn = /* @__PURE__ */ $(Ln, [["__scopeId", "data-v-ff2edb53"]]), Bn = { class: "brick-list-editor" }, Mn = /* @__PURE__ */ S({
898
931
  __name: "ListPropertyEditor",
899
932
  props: {
900
933
  node: {}
901
934
  },
902
935
  setup(e) {
903
- return (t, n) => (s(), c("div", fn));
936
+ return (t, n) => (a(), u("div", Bn));
904
937
  }
905
- }), mn = {
938
+ }), On = {
906
939
  type: "list",
907
940
  label: "List",
908
941
  icon: "☰",
909
942
  isContainer: !1,
910
- defaultProps: an,
911
- defaultStyle: cn,
912
- rendererComponent: pn,
913
- propertyEditorComponent: yn,
943
+ defaultProps: zn,
944
+ defaultStyle: Tn,
945
+ rendererComponent: Dn,
946
+ propertyEditorComponent: Mn,
914
947
  propertyFields: [
915
948
  { key: "props.ordered", label: "Ordered", section: "content", type: "toggle", defaultValue: !1 },
916
949
  { key: "props.items", label: "Items", section: "content", type: "textarea", defaultValue: `Item 1
@@ -920,54 +953,54 @@ Item 3` },
920
953
  { key: "style.color", label: "Color", section: "style", type: "color", defaultValue: "#000000" },
921
954
  { key: "style.margin", label: "Margin", section: "layout", type: "margin", defaultValue: [0, 0, 0, 0] }
922
955
  ],
923
- toPdfmake: dn
956
+ toPdfmake: Rn
924
957
  };
925
- function gn() {
958
+ function An() {
926
959
  return { data: "https://example.com", fit: 100 };
927
960
  }
928
- function bn() {
961
+ function Vn() {
929
962
  return {};
930
963
  }
931
- function hn(e) {
964
+ function Hn(e) {
932
965
  const t = {
933
966
  qr: e.props.data,
934
967
  fit: e.props.fit ?? 100
935
968
  };
936
969
  return e.style.alignment && (t.alignment = e.style.alignment), e.style.margin && (t.margin = e.style.margin), t;
937
970
  }
938
- const vn = { class: "brick-el-qr__preview" }, _n = /* @__PURE__ */ _({
971
+ const Fn = { class: "brick-el-qr__preview" }, Un = /* @__PURE__ */ S({
939
972
  __name: "QrRenderer",
940
973
  props: {
941
974
  node: {}
942
975
  },
943
976
  setup(e) {
944
- return (t, n) => (s(), c("div", {
977
+ return (t, n) => (a(), u("div", {
945
978
  class: "brick-el-qr",
946
- style: z({
947
- width: (e.node.props.fit ?? 100) + "px",
948
- height: (e.node.props.fit ?? 100) + "px"
979
+ style: L({
980
+ width: "calc(" + (e.node.props.fit ?? 100) + " * var(--brick-pt, 1px))",
981
+ height: "calc(" + (e.node.props.fit ?? 100) + " * var(--brick-pt, 1px))"
949
982
  })
950
983
  }, [
951
- y("div", vn, "QR: " + w(e.node.props.data), 1)
984
+ y("div", Fn, "QR: " + w(e.node.props.data), 1)
952
985
  ], 4));
953
986
  }
954
- }), kn = /* @__PURE__ */ x(_n, [["__scopeId", "data-v-f106ba48"]]), Sn = { class: "brick-qr-editor" }, xn = /* @__PURE__ */ _({
987
+ }), Jn = /* @__PURE__ */ $(Un, [["__scopeId", "data-v-f9071a9d"]]), Wn = { class: "brick-qr-editor" }, jn = /* @__PURE__ */ S({
955
988
  __name: "QrPropertyEditor",
956
989
  props: {
957
990
  node: {}
958
991
  },
959
992
  setup(e) {
960
- return (t, n) => (s(), c("div", Sn));
993
+ return (t, n) => (a(), u("div", Wn));
961
994
  }
962
- }), Cn = {
995
+ }), Yn = {
963
996
  type: "qr",
964
997
  label: "QR Code",
965
998
  icon: "⊞",
966
999
  isContainer: !1,
967
- defaultProps: gn,
968
- defaultStyle: bn,
969
- rendererComponent: kn,
970
- propertyEditorComponent: xn,
1000
+ defaultProps: An,
1001
+ defaultStyle: Vn,
1002
+ rendererComponent: Jn,
1003
+ propertyEditorComponent: jn,
971
1004
  propertyFields: [
972
1005
  { key: "props.data", label: "QR Data", section: "content", type: "text", defaultValue: "https://example.com" },
973
1006
  { key: "props.fit", label: "Size (px)", section: "layout", type: "number", min: 50, max: 500, step: 10, defaultValue: 100 },
@@ -978,56 +1011,56 @@ const vn = { class: "brick-el-qr__preview" }, _n = /* @__PURE__ */ _({
978
1011
  ] },
979
1012
  { key: "style.margin", label: "Margin", section: "layout", type: "margin", defaultValue: [0, 0, 0, 0] }
980
1013
  ],
981
- toPdfmake: hn
1014
+ toPdfmake: Hn
982
1015
  };
983
- function wn() {
1016
+ function qn() {
984
1017
  return {
985
1018
  svg: '<svg viewBox="0 0 100 100"><rect width="100" height="100" fill="#eee" /><text x="50" y="55" text-anchor="middle" font-size="12">SVG</text></svg>',
986
1019
  width: 200,
987
1020
  height: 200
988
1021
  };
989
1022
  }
990
- function Pn() {
1023
+ function Kn() {
991
1024
  return {};
992
1025
  }
993
- function En(e) {
1026
+ function Xn(e) {
994
1027
  const t = {
995
1028
  svg: e.props.svg
996
1029
  };
997
1030
  return e.props.width && (t.width = e.props.width), e.props.height && (t.height = e.props.height), e.style.margin && (t.margin = e.style.margin), e.style.alignment && (t.alignment = e.style.alignment), t;
998
1031
  }
999
- const In = ["innerHTML"], $n = /* @__PURE__ */ _({
1032
+ const Gn = ["innerHTML"], Qn = /* @__PURE__ */ S({
1000
1033
  __name: "SvgRenderer",
1001
1034
  props: {
1002
1035
  node: {}
1003
1036
  },
1004
1037
  setup(e) {
1005
- return (t, n) => (s(), c("div", {
1038
+ return (t, n) => (a(), u("div", {
1006
1039
  class: "brick-el-svg",
1007
- style: z({
1008
- width: e.node.props.width + "px",
1009
- height: e.node.props.height + "px"
1040
+ style: L({
1041
+ width: "calc(" + e.node.props.width + " * var(--brick-pt, 1px))",
1042
+ height: "calc(" + e.node.props.height + " * var(--brick-pt, 1px))"
1010
1043
  }),
1011
1044
  innerHTML: e.node.props.svg
1012
- }, null, 12, In));
1045
+ }, null, 12, Gn));
1013
1046
  }
1014
- }), Rn = /* @__PURE__ */ x($n, [["__scopeId", "data-v-5e9f3319"]]), Nn = { class: "brick-svg-editor" }, zn = /* @__PURE__ */ _({
1047
+ }), Zn = /* @__PURE__ */ $(Qn, [["__scopeId", "data-v-ab0b9b0b"]]), eo = { class: "brick-svg-editor" }, to = /* @__PURE__ */ S({
1015
1048
  __name: "SvgPropertyEditor",
1016
1049
  props: {
1017
1050
  node: {}
1018
1051
  },
1019
1052
  setup(e) {
1020
- return (t, n) => (s(), c("div", Nn));
1053
+ return (t, n) => (a(), u("div", eo));
1021
1054
  }
1022
- }), Tn = {
1055
+ }), no = {
1023
1056
  type: "svg",
1024
1057
  label: "SVG",
1025
1058
  icon: "◇",
1026
1059
  isContainer: !1,
1027
- defaultProps: wn,
1028
- defaultStyle: Pn,
1029
- rendererComponent: Rn,
1030
- propertyEditorComponent: zn,
1060
+ defaultProps: qn,
1061
+ defaultStyle: Kn,
1062
+ rendererComponent: Zn,
1063
+ propertyEditorComponent: to,
1031
1064
  propertyFields: [
1032
1065
  { key: "props.svg", label: "SVG Markup", section: "content", type: "textarea" },
1033
1066
  { key: "props.width", label: "Width", section: "layout", type: "number", min: 10, max: 1e3, step: 10, defaultValue: 200 },
@@ -1039,588 +1072,841 @@ const In = ["innerHTML"], $n = /* @__PURE__ */ _({
1039
1072
  ] },
1040
1073
  { key: "style.margin", label: "Margin", section: "layout", type: "margin", defaultValue: [0, 0, 0, 0] }
1041
1074
  ],
1042
- toPdfmake: En
1075
+ toPdfmake: Xn
1043
1076
  };
1044
- function Ln() {
1077
+ function oo() {
1045
1078
  return {};
1046
1079
  }
1047
- function Dn() {
1080
+ function ro() {
1048
1081
  return {};
1049
1082
  }
1050
- function Mn(e) {
1083
+ function lo(e) {
1051
1084
  return { text: "", pageBreak: "after" };
1052
1085
  }
1053
- const Bn = { class: "brick-el-pagebreak" }, On = /* @__PURE__ */ _({
1086
+ const io = { class: "brick-el-pagebreak" }, so = /* @__PURE__ */ S({
1054
1087
  __name: "PageBreakRenderer",
1055
1088
  props: {
1056
1089
  node: {}
1057
1090
  },
1058
1091
  setup(e) {
1059
- return (t, n) => (s(), c("div", Bn, [...n[0] || (n[0] = [
1092
+ return (t, n) => (a(), u("div", io, [...n[0] || (n[0] = [
1060
1093
  y("hr", null, null, -1),
1061
1094
  y("span", null, "Page Break", -1),
1062
1095
  y("hr", null, null, -1)
1063
1096
  ])]));
1064
1097
  }
1065
- }), An = /* @__PURE__ */ x(On, [["__scopeId", "data-v-60c05148"]]), Vn = { class: "brick-pagebreak-editor" }, Fn = /* @__PURE__ */ _({
1098
+ }), ao = /* @__PURE__ */ $(so, [["__scopeId", "data-v-60c05148"]]), co = { class: "brick-pagebreak-editor" }, uo = /* @__PURE__ */ S({
1066
1099
  __name: "PageBreakPropertyEditor",
1067
1100
  props: {
1068
1101
  node: {}
1069
1102
  },
1070
1103
  setup(e) {
1071
- return (t, n) => (s(), c("div", Vn, [...n[0] || (n[0] = [
1104
+ return (t, n) => (a(), u("div", co, [...n[0] || (n[0] = [
1072
1105
  y("p", { style: { color: "#999", "font-size": "12px" } }, "No configurable properties.", -1)
1073
1106
  ])]));
1074
1107
  }
1075
- }), Hn = {
1108
+ }), po = {
1076
1109
  type: "pageBreak",
1077
1110
  label: "Page Break",
1078
1111
  icon: "⏎",
1079
1112
  isContainer: !1,
1080
- defaultProps: Ln,
1081
- defaultStyle: Dn,
1082
- rendererComponent: An,
1083
- propertyEditorComponent: Fn,
1113
+ defaultProps: oo,
1114
+ defaultStyle: ro,
1115
+ rendererComponent: ao,
1116
+ propertyEditorComponent: uo,
1084
1117
  propertyFields: [],
1085
- toPdfmake: Mn
1118
+ toPdfmake: lo
1086
1119
  };
1087
- let be = !1;
1088
- function Jn() {
1089
- be || (be = !0, L(Ye), L(tt), L(ct), L(Kt), L(sn), L(mn), L(Cn), L(Tn), L(Hn));
1120
+ let Ie = !1;
1121
+ function fo() {
1122
+ Ie || (Ie = !0, V(mt), V(xt), V(zt), V(hn), V(Nn), V(On), V(Yn), V(no), V(po));
1123
+ }
1124
+ function M(e) {
1125
+ return `calc(${e} * var(--brick-pt, 1px))`;
1126
+ }
1127
+ const le = /* @__PURE__ */ Symbol("brick-pdf-canvas");
1128
+ function ce(e, t) {
1129
+ for (const n of e) {
1130
+ if (n.id === t) return [];
1131
+ const i = ce(n.children, t);
1132
+ if (i) return [n, ...i];
1133
+ }
1134
+ return null;
1090
1135
  }
1091
- const Un = {
1092
- key: 0,
1093
- class: "brick-dropzone__empty"
1094
- }, Wn = /* @__PURE__ */ _({
1136
+ const yo = /* @__PURE__ */ S({
1095
1137
  __name: "DropZone",
1096
1138
  props: {
1097
1139
  parentId: {},
1098
- layout: {}
1140
+ layout: {},
1141
+ empty: { type: Boolean }
1099
1142
  },
1100
1143
  setup(e) {
1101
- const t = e, n = I(null);
1144
+ const t = e, n = E(null);
1102
1145
  let i = null;
1103
- const a = ie(), { isDragging: l } = a;
1104
- return he(() => {
1105
- n.value && (i = a.initContainer(n.value, t.parentId));
1106
- }), ve(() => {
1146
+ const f = ge(), { isDragging: d } = f;
1147
+ return Te(() => {
1148
+ n.value && (i = f.initContainer(n.value, t.parentId));
1149
+ }), Re(() => {
1107
1150
  i?.destroy();
1108
- }), (d, f) => (s(), c("div", {
1151
+ }), (m, p) => (a(), u("div", {
1109
1152
  ref_key: "el",
1110
1153
  ref: n,
1111
- class: ne(["brick-dropzone", { "brick-dropzone--horizontal": e.layout === "horizontal", "brick-dropzone--drag-active": k(l) && e.layout === "horizontal" }])
1154
+ class: Y(["brick-dropzone", {
1155
+ "brick-dropzone--horizontal": e.layout === "horizontal",
1156
+ "brick-dropzone--drag-active": g(d) && e.layout === "horizontal",
1157
+ "brick-dropzone--empty": e.empty
1158
+ }])
1112
1159
  }, [
1113
- te(d.$slots, "default", {}, void 0, !0),
1114
- d.$slots.default ? $("", !0) : (s(), c("div", Un, " Drop elements here "))
1160
+ me(m.$slots, "default", {}, void 0, !0)
1115
1161
  ], 2));
1116
1162
  }
1117
- }), ze = /* @__PURE__ */ x(Wn, [["__scopeId", "data-v-b9596dad"]]), jn = ["data-element-id", "data-element-type"], Yn = {
1163
+ }), qe = /* @__PURE__ */ $(yo, [["__scopeId", "data-v-582e7b20"]]), mo = ["data-element-id", "data-element-type"], vo = {
1118
1164
  key: 1,
1119
1165
  class: "brick-canvas-element__unknown"
1120
- }, qn = /* @__PURE__ */ _({
1166
+ }, bo = { class: "brick-canvas-element__chip-label" }, go = /* @__PURE__ */ S({
1121
1167
  __name: "CanvasElement",
1122
1168
  props: {
1123
1169
  node: {},
1124
- path: {}
1170
+ path: {},
1171
+ inColumns: { type: Boolean }
1125
1172
  },
1126
1173
  setup(e) {
1127
- const t = e, n = q(), i = K(), { isDragging: a } = ie(), l = I(null), d = E(() => Y(t.node.type)), f = E(() => n.selectedId.value === t.node.id), u = E(() => d.value ? d.value.propertyFields.some((b) => b.key === "props.width" || b.key === "style.width") : !1), r = E(() => d.value ? d.value.propertyFields.some((b) => b.key === "props.height" || b.key === "style.height") : !1), o = E(() => typeof t.node.style.width == "number" ? t.node.style.width + "px" : t.node.props.width ? t.node.props.width + "px" : t.node.style.width), p = E(() => a.value ? {} : typeof o.value != "string" || !o.value.endsWith("px") ? {} : t.node.style.alignment === "center" ? { marginLeft: "auto", marginRight: "auto" } : t.node.style.alignment === "right" ? { marginLeft: "auto" } : {});
1128
- function g(b) {
1129
- b.stopPropagation(), n.select(t.node.id);
1174
+ const t = e, n = Q(), i = re(), f = G(), { isDragging: d } = ge(), m = B(le, null), p = E(null), s = x(() => W(t.node.type)), l = x(() => n.selectedId.value === t.node.id), o = x(() => m?.hoveredId.value === t.node.id), r = x(
1175
+ () => !!s.value?.isContainer && (!!m?.showOutlines.value || d.value)
1176
+ );
1177
+ function c() {
1178
+ m && (m.hoveredId.value = t.node.id);
1179
+ }
1180
+ function v() {
1181
+ const h = ce(f.document.content, t.node.id), N = h?.[h.length - 1];
1182
+ N && n.select(N.id);
1130
1183
  }
1131
- function m(b) {
1132
- b.stopPropagation(), b.preventDefault();
1133
- const S = b.clientX, R = l.value?.offsetWidth ?? 200;
1134
- function N(V) {
1135
- const F = V.clientX - S, D = Math.max(20, R + F);
1136
- d.value?.propertyFields.some((U) => U.key === "props.width") ? i.updateProps(t.node.id, { width: Math.round(D) }) : i.updateStyle(t.node.id, { width: Math.round(D) });
1184
+ const b = x(() => t.path.length > 1);
1185
+ function k() {
1186
+ const h = i.duplicateElement(t.node.id);
1187
+ h && n.select(h.id);
1188
+ }
1189
+ function C() {
1190
+ n.deselect(), i.removeElement(t.node.id);
1191
+ }
1192
+ const _ = x(() => {
1193
+ if (s.value)
1194
+ try {
1195
+ return s.value.toPdfmake(t.node, () => [])?.width;
1196
+ } catch {
1197
+ return;
1198
+ }
1199
+ }), I = x(
1200
+ () => !!t.inColumns && _.value !== void 0 && _.value !== "*"
1201
+ ), O = x(() => {
1202
+ const h = t.node.style.alignment, N = _.value;
1203
+ if (d.value || t.inColumns || typeof N != "number" || h !== "center" && h !== "right") return;
1204
+ const [z, , D] = t.node.style.margin ?? [0, 0, 0, 0];
1205
+ return h === "center" ? `calc(${M(z)} + (100% - ${M(N + z + D)}) / 2)` : `calc(100% - ${M(N + D)})`;
1206
+ }), ie = x(() => {
1207
+ const { style: h, props: N } = t.node, z = h.margin;
1208
+ return {
1209
+ width: typeof h.width == "number" ? M(h.width) : N.width ? M(N.width) : h.width,
1210
+ height: h.height ? M(h.height) : N.height ? M(N.height) : void 0,
1211
+ marginTop: z ? M(z[1]) : void 0,
1212
+ marginRight: z ? M(z[2]) : void 0,
1213
+ marginBottom: z ? M(z[3]) : void 0,
1214
+ marginLeft: O.value ?? (z ? M(z[0]) : void 0),
1215
+ textAlign: h.alignment
1216
+ };
1217
+ }), Z = x(() => s.value ? s.value.propertyFields.some((h) => h.key === "props.width" || h.key === "style.width") : !1), he = x(() => s.value ? s.value.propertyFields.some((h) => h.key === "props.height" || h.key === "style.height") : !1);
1218
+ function Ke(h) {
1219
+ h.stopPropagation(), n.select(t.node.id);
1220
+ }
1221
+ function U(h) {
1222
+ return Math.round(h / (m?.pxPerPt.value || 1));
1223
+ }
1224
+ function Xe(h) {
1225
+ h.stopPropagation(), h.preventDefault();
1226
+ const N = h.clientX, z = p.value?.offsetWidth ?? 200;
1227
+ function D(q) {
1228
+ const K = q.clientX - N, J = Math.max(20, z + K);
1229
+ s.value?.propertyFields.some((ee) => ee.key === "props.width") ? i.updateProps(t.node.id, { width: U(J) }) : i.updateStyle(t.node.id, { width: U(J) });
1137
1230
  }
1138
- function T() {
1139
- document.removeEventListener("pointermove", N), document.removeEventListener("pointerup", T), document.body.style.cursor = "", document.body.style.userSelect = "";
1231
+ function A() {
1232
+ document.removeEventListener("pointermove", D), document.removeEventListener("pointerup", A), document.body.style.cursor = "", document.body.style.userSelect = "";
1140
1233
  }
1141
- document.body.style.cursor = "ew-resize", document.body.style.userSelect = "none", document.addEventListener("pointermove", N), document.addEventListener("pointerup", T);
1234
+ document.body.style.cursor = "ew-resize", document.body.style.userSelect = "none", document.addEventListener("pointermove", D), document.addEventListener("pointerup", A);
1142
1235
  }
1143
- function h(b) {
1144
- b.stopPropagation(), b.preventDefault();
1145
- const S = b.clientY, R = l.value?.offsetHeight ?? 100;
1146
- function N(V) {
1147
- const F = V.clientY - S, D = Math.max(20, R + F);
1148
- d.value?.propertyFields.some((U) => U.key === "props.height") ? i.updateProps(t.node.id, { height: Math.round(D) }) : i.updateStyle(t.node.id, { height: Math.round(D) });
1236
+ function Ge(h) {
1237
+ h.stopPropagation(), h.preventDefault();
1238
+ const N = h.clientY, z = p.value?.offsetHeight ?? 100;
1239
+ function D(q) {
1240
+ const K = q.clientY - N, J = Math.max(20, z + K);
1241
+ s.value?.propertyFields.some((ee) => ee.key === "props.height") ? i.updateProps(t.node.id, { height: U(J) }) : i.updateStyle(t.node.id, { height: U(J) });
1149
1242
  }
1150
- function T() {
1151
- document.removeEventListener("pointermove", N), document.removeEventListener("pointerup", T), document.body.style.cursor = "", document.body.style.userSelect = "";
1243
+ function A() {
1244
+ document.removeEventListener("pointermove", D), document.removeEventListener("pointerup", A), document.body.style.cursor = "", document.body.style.userSelect = "";
1152
1245
  }
1153
- document.body.style.cursor = "ns-resize", document.body.style.userSelect = "none", document.addEventListener("pointermove", N), document.addEventListener("pointerup", T);
1246
+ document.body.style.cursor = "ns-resize", document.body.style.userSelect = "none", document.addEventListener("pointermove", D), document.addEventListener("pointerup", A);
1154
1247
  }
1155
- function v(b) {
1156
- b.stopPropagation(), b.preventDefault();
1157
- const S = b.clientX, R = b.clientY, N = l.value?.offsetWidth ?? 200, T = l.value?.offsetHeight ?? 100;
1158
- function V(D) {
1159
- const Q = D.clientX - S, U = D.clientY - R, se = Math.max(20, N + Q), ae = Math.max(20, T + U), Te = d.value?.propertyFields.some((Z) => Z.key === "props.width"), Le = d.value?.propertyFields.some((Z) => Z.key === "props.height");
1160
- Te ? i.updateProps(t.node.id, { width: Math.round(se) }) : i.updateStyle(t.node.id, { width: Math.round(se) }), Le ? i.updateProps(t.node.id, { height: Math.round(ae) }) : i.updateStyle(t.node.id, { height: Math.round(ae) });
1248
+ function Qe(h) {
1249
+ h.stopPropagation(), h.preventDefault();
1250
+ const N = h.clientX, z = h.clientY, D = p.value?.offsetWidth ?? 200, A = p.value?.offsetHeight ?? 100;
1251
+ function q(J) {
1252
+ const ue = J.clientX - N, ee = J.clientY - z, _e = Math.max(20, D + ue), ke = Math.max(20, A + ee), Ze = s.value?.propertyFields.some((de) => de.key === "props.width"), et = s.value?.propertyFields.some((de) => de.key === "props.height");
1253
+ Ze ? i.updateProps(t.node.id, { width: U(_e) }) : i.updateStyle(t.node.id, { width: U(_e) }), et ? i.updateProps(t.node.id, { height: U(ke) }) : i.updateStyle(t.node.id, { height: U(ke) });
1161
1254
  }
1162
- function F() {
1163
- document.removeEventListener("pointermove", V), document.removeEventListener("pointerup", F), document.body.style.cursor = "", document.body.style.userSelect = "";
1255
+ function K() {
1256
+ document.removeEventListener("pointermove", q), document.removeEventListener("pointerup", K), document.body.style.cursor = "", document.body.style.userSelect = "";
1164
1257
  }
1165
- document.body.style.cursor = "nwse-resize", document.body.style.userSelect = "none", document.addEventListener("pointermove", V), document.addEventListener("pointerup", F);
1258
+ document.body.style.cursor = "nwse-resize", document.body.style.userSelect = "none", document.addEventListener("pointermove", q), document.addEventListener("pointerup", K);
1166
1259
  }
1167
- return (b, S) => {
1168
- const R = Me("CanvasElement", !0);
1169
- return s(), c("div", {
1260
+ return (h, N) => {
1261
+ const z = Le("CanvasElement", !0);
1262
+ return a(), u("div", {
1170
1263
  ref_key: "elRef",
1171
- ref: l,
1172
- class: ne(["brick-canvas-element", { "brick-canvas-element--selected": f.value }]),
1264
+ ref: p,
1265
+ class: Y(["brick-canvas-element", {
1266
+ "brick-canvas-element--selected": l.value,
1267
+ "brick-canvas-element--hovered": o.value && !l.value && !g(d),
1268
+ "brick-canvas-element--guide": r.value,
1269
+ "brick-canvas-element--col-auto": I.value
1270
+ }]),
1173
1271
  "data-element-id": e.node.id,
1174
1272
  "data-element-type": e.node.type,
1175
- style: z({
1176
- width: o.value,
1177
- height: e.node.style.height ? e.node.style.height + "px" : e.node.props.height ? e.node.props.height + "px" : void 0,
1178
- marginTop: e.node.style.margin?.[1] + "px",
1179
- marginRight: e.node.style.margin?.[2] + "px",
1180
- marginBottom: e.node.style.margin?.[3] + "px",
1181
- marginLeft: e.node.style.margin?.[0] + "px",
1182
- textAlign: e.node.style.alignment,
1183
- ...p.value
1184
- }),
1185
- onClick: g
1273
+ style: L(ie.value),
1274
+ onClick: Ke,
1275
+ onMouseover: fe(c, ["stop"])
1186
1276
  }, [
1187
- d.value ? (s(), O(oe(d.value.rendererComponent), {
1277
+ s.value ? (a(), H(ve(s.value.rendererComponent), {
1188
1278
  key: 0,
1189
1279
  node: e.node,
1190
1280
  path: e.path
1191
1281
  }, {
1192
- default: G(() => [
1193
- d.value.isContainer ? (s(), O(ze, {
1282
+ default: se(() => [
1283
+ s.value.isContainer ? (a(), H(qe, {
1194
1284
  key: 0,
1195
1285
  "parent-id": e.node.id,
1196
- layout: e.node.type === "columns" ? "horizontal" : "vertical"
1286
+ layout: e.node.type === "columns" ? "horizontal" : "vertical",
1287
+ empty: e.node.children.length === 0
1197
1288
  }, {
1198
- default: G(() => [
1199
- (s(!0), c(C, null, P(e.node.children, (N, T) => (s(), O(R, {
1200
- key: N.id,
1201
- node: N,
1202
- path: [...e.path, T]
1203
- }, null, 8, ["node", "path"]))), 128))
1289
+ default: se(() => [
1290
+ (a(!0), u(P, null, T(e.node.children, (D, A) => (a(), H(z, {
1291
+ key: D.id,
1292
+ node: D,
1293
+ path: [...e.path, A],
1294
+ "in-columns": e.node.type === "columns"
1295
+ }, null, 8, ["node", "path", "in-columns"]))), 128))
1204
1296
  ]),
1205
1297
  _: 1
1206
- }, 8, ["parent-id", "layout"])) : $("", !0)
1298
+ }, 8, ["parent-id", "layout", "empty"])) : R("", !0)
1207
1299
  ]),
1208
1300
  _: 1
1209
- }, 8, ["node", "path"])) : (s(), c("div", Yn, " Unknown element: " + w(e.node.type), 1)),
1210
- f.value ? (s(), c(C, { key: 2 }, [
1211
- u.value ? (s(), c("div", {
1301
+ }, 8, ["node", "path"])) : (a(), u("div", vo, " Unknown element: " + w(e.node.type), 1)),
1302
+ l.value && s.value && !g(d) ? (a(), u("div", {
1303
+ key: 2,
1304
+ class: "brick-canvas-element__chip",
1305
+ onClick: N[0] || (N[0] = fe(() => {
1306
+ }, ["stop"]))
1307
+ }, [
1308
+ y("span", bo, w(s.value.icon) + " " + w(s.value.label), 1),
1309
+ b.value ? (a(), u("button", {
1310
+ key: 0,
1311
+ type: "button",
1312
+ title: "Select parent (Esc)",
1313
+ onClick: v
1314
+ }, "↑")) : R("", !0),
1315
+ y("button", {
1316
+ type: "button",
1317
+ title: "Duplicate",
1318
+ onClick: k
1319
+ }, "⧉"),
1320
+ y("button", {
1321
+ type: "button",
1322
+ title: "Delete",
1323
+ class: "brick-canvas-element__chip-danger",
1324
+ onClick: C
1325
+ }, "✕")
1326
+ ])) : R("", !0),
1327
+ l.value ? (a(), u(P, { key: 3 }, [
1328
+ Z.value ? (a(), u("div", {
1212
1329
  key: 0,
1213
1330
  class: "brick-resize-handle brick-resize-handle--e",
1214
- onPointerdown: m
1215
- }, null, 32)) : $("", !0),
1216
- r.value ? (s(), c("div", {
1331
+ onPointerdown: Xe
1332
+ }, null, 32)) : R("", !0),
1333
+ he.value ? (a(), u("div", {
1217
1334
  key: 1,
1218
1335
  class: "brick-resize-handle brick-resize-handle--s",
1219
- onPointerdown: h
1220
- }, null, 32)) : $("", !0),
1221
- u.value && r.value ? (s(), c("div", {
1336
+ onPointerdown: Ge
1337
+ }, null, 32)) : R("", !0),
1338
+ Z.value && he.value ? (a(), u("div", {
1222
1339
  key: 2,
1223
1340
  class: "brick-resize-handle brick-resize-handle--se",
1224
- onPointerdown: v
1225
- }, null, 32)) : $("", !0)
1226
- ], 64)) : $("", !0)
1227
- ], 14, jn);
1341
+ onPointerdown: Qe
1342
+ }, null, 32)) : R("", !0)
1343
+ ], 64)) : R("", !0)
1344
+ ], 46, mo);
1228
1345
  };
1229
1346
  }
1230
- }), Kn = /* @__PURE__ */ x(qn, [["__scopeId", "data-v-6e0d4942"]]), Gn = { class: "brick-doc-bar" }, Xn = { class: "brick-doc-bar__field" }, Qn = ["value"], Zn = { class: "brick-doc-bar__field" }, eo = { class: "brick-doc-bar__field brick-doc-bar__field--margins" }, to = { class: "brick-doc-bar__margins" }, no = ["placeholder", "title", "value", "onInput"], oo = { class: "brick-doc-bar__field" }, ro = ["value"], lo = /* @__PURE__ */ _({
1347
+ }), ho = /* @__PURE__ */ $(go, [["__scopeId", "data-v-462d5930"]]), _o = { class: "brick-doc-bar" }, ko = { class: "brick-doc-bar__field" }, So = ["value"], xo = { class: "brick-doc-bar__field" }, Co = { class: "brick-doc-bar__field brick-doc-bar__field--margins" }, wo = { class: "brick-doc-bar__margins" }, Po = ["placeholder", "title", "value", "onInput"], Eo = { class: "brick-doc-bar__field" }, $o = ["value"], Io = {
1348
+ key: 0,
1349
+ class: "brick-doc-bar__field brick-doc-bar__zoom"
1350
+ }, No = ["value"], zo = ["value"], To = {
1351
+ key: 1,
1352
+ class: "brick-doc-bar__field brick-doc-bar__toggle",
1353
+ title: "Show container outlines"
1354
+ }, Ro = /* @__PURE__ */ S({
1231
1355
  __name: "DocumentSettings",
1232
1356
  setup(e) {
1233
- const t = le(), n = [
1357
+ const t = G(), n = B(le, null), i = [0.5, 0.75, 1, 1.25, 1.5, 2], f = [
1234
1358
  { label: "A3", value: "A3" },
1235
1359
  { label: "A4", value: "A4" },
1236
1360
  { label: "A5", value: "A5" },
1237
1361
  { label: "Letter", value: "LETTER" },
1238
1362
  { label: "Legal", value: "LEGAL" }
1239
1363
  ];
1240
- function i(a, l) {
1241
- const d = [...t.document.pageMargins];
1242
- d[a] = l, t.document.pageMargins = d;
1364
+ function d(p) {
1365
+ p.trim() === "" || Number.isNaN(Number(p)) || (t.document.defaultStyle ??= {}, t.document.defaultStyle.fontSize = Number(p));
1366
+ }
1367
+ function m(p, s) {
1368
+ const l = [...t.document.pageMargins];
1369
+ l[p] = s, t.document.pageMargins = l;
1243
1370
  }
1244
- return (a, l) => (s(), c("div", Gn, [
1245
- y("div", Xn, [
1246
- l[3] || (l[3] = y("label", null, "Size", -1)),
1247
- de(y("select", {
1248
- "onUpdate:modelValue": l[0] || (l[0] = (d) => k(t).document.pageSize = d)
1371
+ return (p, s) => (a(), u("div", _o, [
1372
+ y("div", ko, [
1373
+ s[5] || (s[5] = y("label", null, "Size", -1)),
1374
+ ne(y("select", {
1375
+ "onUpdate:modelValue": s[0] || (s[0] = (l) => g(t).document.pageSize = l)
1249
1376
  }, [
1250
- (s(), c(C, null, P(n, (d) => y("option", {
1251
- key: d.value,
1252
- value: d.value
1253
- }, w(d.label), 9, Qn)), 64))
1377
+ (a(), u(P, null, T(f, (l) => y("option", {
1378
+ key: l.value,
1379
+ value: l.value
1380
+ }, w(l.label), 9, So)), 64))
1254
1381
  ], 512), [
1255
- [ue, k(t).document.pageSize]
1382
+ [Se, g(t).document.pageSize]
1256
1383
  ])
1257
1384
  ]),
1258
- y("div", Zn, [
1259
- l[5] || (l[5] = y("label", null, "Orientation", -1)),
1260
- de(y("select", {
1261
- "onUpdate:modelValue": l[1] || (l[1] = (d) => k(t).document.pageOrientation = d)
1262
- }, [...l[4] || (l[4] = [
1385
+ y("div", xo, [
1386
+ s[7] || (s[7] = y("label", null, "Orientation", -1)),
1387
+ ne(y("select", {
1388
+ "onUpdate:modelValue": s[1] || (s[1] = (l) => g(t).document.pageOrientation = l)
1389
+ }, [...s[6] || (s[6] = [
1263
1390
  y("option", { value: "portrait" }, "Portrait", -1),
1264
1391
  y("option", { value: "landscape" }, "Landscape", -1)
1265
1392
  ])], 512), [
1266
- [ue, k(t).document.pageOrientation]
1393
+ [Se, g(t).document.pageOrientation]
1267
1394
  ])
1268
1395
  ]),
1269
- y("div", eo, [
1270
- l[6] || (l[6] = y("label", null, "Margins", -1)),
1271
- y("div", to, [
1272
- (s(), c(C, null, P(["L", "T", "R", "B"], (d, f) => y("input", {
1273
- key: f,
1396
+ y("div", Co, [
1397
+ s[8] || (s[8] = y("label", null, "Margins", -1)),
1398
+ y("div", wo, [
1399
+ (a(), u(P, null, T(["L", "T", "R", "B"], (l, o) => y("input", {
1400
+ key: o,
1274
1401
  type: "number",
1275
- placeholder: d,
1276
- title: d,
1277
- value: k(t).document.pageMargins[f],
1278
- onInput: (u) => i(f, Number(u.target.value))
1279
- }, null, 40, no)), 64))
1402
+ placeholder: l,
1403
+ title: l,
1404
+ value: g(t).document.pageMargins[o],
1405
+ onInput: (r) => m(o, Number(r.target.value))
1406
+ }, null, 40, Po)), 64))
1280
1407
  ])
1281
1408
  ]),
1282
- y("div", oo, [
1283
- l[7] || (l[7] = y("label", null, "Font Size", -1)),
1409
+ y("div", Eo, [
1410
+ s[9] || (s[9] = y("label", null, "Font Size", -1)),
1284
1411
  y("input", {
1285
1412
  type: "number",
1286
- value: k(t).document.defaultStyle?.fontSize ?? 12,
1413
+ value: g(t).document.defaultStyle?.fontSize ?? 12,
1287
1414
  min: "6",
1288
1415
  max: "72",
1289
- onInput: l[2] || (l[2] = (d) => (k(t).document.defaultStyle ??= {}).fontSize = Number(d.target.value))
1290
- }, null, 40, ro)
1291
- ])
1416
+ onInput: s[2] || (s[2] = (l) => d(l.target.value))
1417
+ }, null, 40, $o)
1418
+ ]),
1419
+ g(n) ? (a(), u("div", Io, [
1420
+ s[11] || (s[11] = y("label", null, "Zoom", -1)),
1421
+ y("select", {
1422
+ value: g(n).zoom.value,
1423
+ onChange: s[3] || (s[3] = (l) => g(n).zoom.value = l.target.value === "fit" ? "fit" : Number(l.target.value))
1424
+ }, [
1425
+ s[10] || (s[10] = y("option", { value: "fit" }, "Fit width", -1)),
1426
+ (a(), u(P, null, T(i, (l) => y("option", {
1427
+ key: l,
1428
+ value: l
1429
+ }, w(Math.round(l * 100)) + "%", 9, zo)), 64))
1430
+ ], 40, No)
1431
+ ])) : R("", !0),
1432
+ g(n) ? (a(), u("label", To, [
1433
+ ne(y("input", {
1434
+ "onUpdate:modelValue": s[4] || (s[4] = (l) => g(n).showOutlines.value = l),
1435
+ type: "checkbox"
1436
+ }, null, 512), [
1437
+ [tt, g(n).showOutlines.value]
1438
+ ]),
1439
+ s[12] || (s[12] = y("span", null, "Outlines", -1))
1440
+ ])) : R("", !0)
1292
1441
  ]));
1293
1442
  }
1294
- }), io = /* @__PURE__ */ x(lo, [["__scopeId", "data-v-39a2b54f"]]), so = { class: "brick-canvas" }, J = 0.75, ao = /* @__PURE__ */ _({
1443
+ }), Lo = /* @__PURE__ */ $(Ro, [["__scopeId", "data-v-6def1a4b"]]), Do = { class: "brick-canvas" }, Ne = 96 / 72, Bo = 24, Mo = /* @__PURE__ */ S({
1295
1444
  __name: "DesignCanvas",
1296
1445
  setup(e) {
1297
- const t = le(), n = q(), i = {
1446
+ const t = G(), n = Q(), i = B(le, null), f = {
1298
1447
  A3: [841.89, 1190.55],
1299
1448
  A4: [595.28, 841.89],
1300
1449
  A5: [419.53, 595.28],
1301
1450
  LETTER: [612, 792],
1302
1451
  LEGAL: [612, 1008]
1303
- }, a = E(() => {
1304
- const [f, u] = i[t.document.pageSize] ?? i.A4, r = t.document.pageOrientation === "landscape" ? u : f;
1305
- return Math.round(r * J);
1306
- }), l = E(() => {
1307
- const [f, u] = i[t.document.pageSize] ?? i.A4, r = t.document.pageOrientation === "landscape" ? f : u;
1308
- return Math.round(r * J);
1452
+ }, d = x(() => {
1453
+ const [r, c] = f[t.document.pageSize] ?? f.A4;
1454
+ return t.document.pageOrientation === "landscape" ? [c, r] : [r, c];
1455
+ }), m = E(null), { width: p } = lt(m), s = x(() => {
1456
+ const r = i?.zoom.value ?? "fit";
1457
+ if (r !== "fit") return r * Ne;
1458
+ const c = p.value - Bo * 2;
1459
+ return c <= 0 ? 0.75 : Math.min(Math.max(c / d.value[0], 0.5), 2 * Ne);
1309
1460
  });
1310
- function d(f) {
1311
- (f.target === f.currentTarget || f.target.classList.contains("brick-canvas__page")) && n.deselect();
1461
+ nt(() => {
1462
+ i && (i.pxPerPt.value = s.value);
1463
+ });
1464
+ const l = x(() => {
1465
+ const r = s.value, [c, v] = d.value, [b, k, C, _] = t.document.pageMargins, I = t.document.defaultStyle?.fontSize;
1466
+ return {
1467
+ "--brick-pt": r + "px",
1468
+ width: c * r + "px",
1469
+ minHeight: v * r + "px",
1470
+ paddingTop: k * r + "px",
1471
+ paddingRight: C * r + "px",
1472
+ paddingBottom: _ * r + "px",
1473
+ paddingLeft: b * r + "px",
1474
+ fontSize: (I ?? 12) * r + "px"
1475
+ };
1476
+ });
1477
+ function o(r) {
1478
+ (r.target === r.currentTarget || r.target.classList.contains("brick-canvas__page")) && n.deselect();
1312
1479
  }
1313
- return (f, u) => (s(), c("div", so, [
1314
- A(io),
1480
+ return (r, c) => (a(), u("div", Do, [
1481
+ j(Lo),
1315
1482
  y("div", {
1483
+ ref_key: "scrollEl",
1484
+ ref: m,
1316
1485
  class: "brick-canvas__scroll",
1317
- onClick: d
1486
+ onClick: o,
1487
+ onMouseover: c[0] || (c[0] = (v) => g(i) && (g(i).hoveredId.value = null))
1318
1488
  }, [
1319
1489
  y("div", {
1320
1490
  class: "brick-canvas__page",
1321
- style: z({
1322
- width: a.value + "px",
1323
- minHeight: l.value + "px",
1324
- paddingTop: k(t).document.pageMargins[1] * J + "px",
1325
- paddingRight: k(t).document.pageMargins[2] * J + "px",
1326
- paddingBottom: k(t).document.pageMargins[3] * J + "px",
1327
- paddingLeft: k(t).document.pageMargins[0] * J + "px"
1328
- })
1491
+ style: L(l.value)
1329
1492
  }, [
1330
- A(ze, { "parent-id": null }, {
1331
- default: G(() => [
1332
- (s(!0), c(C, null, P(k(t).document.content, (r, o) => (s(), O(Kn, {
1333
- key: r.id,
1334
- node: r,
1335
- path: [o]
1493
+ j(qe, {
1494
+ "parent-id": null,
1495
+ empty: g(t).document.content.length === 0
1496
+ }, {
1497
+ default: se(() => [
1498
+ (a(!0), u(P, null, T(g(t).document.content, (v, b) => (a(), H(ho, {
1499
+ key: v.id,
1500
+ node: v,
1501
+ path: [b]
1336
1502
  }, null, 8, ["node", "path"]))), 128))
1337
1503
  ]),
1338
1504
  _: 1
1339
- })
1505
+ }, 8, ["empty"])
1340
1506
  ], 4)
1341
- ])
1507
+ ], 544)
1342
1508
  ]));
1343
1509
  }
1344
- }), co = /* @__PURE__ */ x(ao, [["__scopeId", "data-v-364329ec"]]), uo = ["data-element-type"], po = { class: "brick-element-list__icon" }, fo = { class: "brick-element-list__label" }, yo = /* @__PURE__ */ _({
1510
+ }), Oo = /* @__PURE__ */ $(Mo, [["__scopeId", "data-v-6498bac5"]]), Ao = ["data-element-type"], Vo = { class: "brick-element-list__icon" }, Ho = { class: "brick-element-list__label" }, Fo = /* @__PURE__ */ S({
1345
1511
  __name: "ToolbarElementList",
1346
1512
  setup(e) {
1347
- const t = I(null);
1513
+ const t = E(null);
1348
1514
  let n = null;
1349
- const i = ie(), a = Ae();
1350
- return he(() => {
1515
+ const i = ge(), f = st();
1516
+ return Te(() => {
1351
1517
  t.value && (n = i.initToolbar(t.value));
1352
- }), ve(() => {
1518
+ }), Re(() => {
1353
1519
  n?.destroy();
1354
- }), (l, d) => (s(), c("div", {
1520
+ }), (d, m) => (a(), u("div", {
1355
1521
  ref_key: "el",
1356
1522
  ref: t,
1357
1523
  class: "brick-element-list"
1358
1524
  }, [
1359
- (s(!0), c(C, null, P(k(a), (f) => (s(), c("div", {
1360
- key: f.type,
1525
+ (a(!0), u(P, null, T(g(f), (p) => (a(), u("div", {
1526
+ key: p.type,
1361
1527
  class: "brick-element-list__item",
1362
- "data-element-type": f.type
1528
+ "data-element-type": p.type
1363
1529
  }, [
1364
- y("span", po, w(f.icon), 1),
1365
- y("span", fo, w(f.label), 1)
1366
- ], 8, uo))), 128))
1530
+ y("span", Vo, w(p.icon), 1),
1531
+ y("span", Ho, w(p.label), 1)
1532
+ ], 8, Ao))), 128))
1367
1533
  ], 512));
1368
1534
  }
1369
- }), mo = /* @__PURE__ */ x(yo, [["__scopeId", "data-v-2d0b1dbf"]]), go = { class: "brick-field" }, bo = { class: "brick-field__label" }, ho = ["value"], vo = ["value"], _o = ["value", "min", "max", "step"], ko = ["value"], So = ["value"], xo = ["value"], Co = {
1535
+ }), Uo = /* @__PURE__ */ $(Fo, [["__scopeId", "data-v-2d0b1dbf"]]), Jo = { class: "brick-field" }, Wo = { class: "brick-field__label" }, jo = ["value"], Yo = ["value"], qo = ["value", "min", "max", "step"], Ko = ["value"], Xo = ["value"], Go = ["value"], Qo = {
1370
1536
  key: 5,
1371
1537
  class: "brick-field__toggle"
1372
- }, wo = ["checked"], Po = {
1538
+ }, Zo = ["checked"], er = {
1373
1539
  key: 6,
1374
1540
  class: "brick-field__margin"
1375
- }, Eo = ["placeholder", "value", "onInput"], Io = {
1541
+ }, tr = ["placeholder", "value", "onInput"], nr = {
1376
1542
  key: 7,
1377
1543
  class: "brick-field__slider"
1378
- }, $o = ["value", "min", "max", "step"], Ro = { class: "brick-field__slider-value" }, No = /* @__PURE__ */ _({
1544
+ }, or = ["value", "min", "max", "step"], rr = { class: "brick-field__slider-value" }, lr = ["accept"], ir = /* @__PURE__ */ S({
1379
1545
  __name: "PropertyField",
1380
1546
  props: {
1381
1547
  descriptor: {},
1382
1548
  node: {}
1383
1549
  },
1384
1550
  setup(e) {
1385
- const t = e, n = K(), i = E(() => {
1386
- const u = t.descriptor.key.split("."), r = u[0], o = u[1];
1387
- if (r === "props")
1388
- return t.node.props[o];
1389
- if (r === "style")
1390
- return t.node.style[o];
1391
- }), a = E(() => {
1392
- const u = i.value;
1393
- return t.descriptor.type === "textarea" && Array.isArray(u) ? u.join(`
1394
- `) : u;
1551
+ const t = e, n = re(), i = x(() => {
1552
+ const l = t.descriptor.key.split("."), o = l[0], r = l[1];
1553
+ if (o === "props")
1554
+ return t.node.props[r];
1555
+ if (o === "style")
1556
+ return t.node.style[r];
1557
+ }), f = x(() => {
1558
+ const l = i.value;
1559
+ return t.descriptor.type === "textarea" && Array.isArray(l) ? l.join(`
1560
+ `) : l;
1395
1561
  });
1396
- function l(u) {
1397
- const r = t.descriptor.key.split("."), o = r[0], p = r[1];
1398
- let g = u;
1399
- t.descriptor.type === "textarea" && Array.isArray(i.value) && (g = u.split(`
1400
- `)), o === "props" ? n.updateProps(t.node.id, { [p]: g }) : o === "style" && n.updateStyle(t.node.id, { [p]: g });
1562
+ function d(l) {
1563
+ const o = t.descriptor.key.split("."), r = o[0], c = o[1];
1564
+ let v = l;
1565
+ t.descriptor.type === "textarea" && Array.isArray(i.value) && (v = l.split(`
1566
+ `)), r === "props" ? n.updateProps(t.node.id, { [c]: v }) : r === "style" && n.updateStyle(t.node.id, { [c]: v });
1401
1567
  }
1402
- function d(u, r) {
1403
- const p = [...a.value ?? [0, 0, 0, 0]];
1404
- p[u] = r, l(p);
1568
+ function m(l) {
1569
+ const o = l.target.value;
1570
+ o.trim() === "" || Number.isNaN(Number(o)) || d(Number(o));
1405
1571
  }
1406
- function f(u) {
1407
- const o = u.target.files?.[0];
1408
- if (!o) return;
1409
- const p = new FileReader();
1410
- p.onload = () => {
1411
- l(p.result);
1412
- }, p.readAsDataURL(o);
1572
+ function p(l, o) {
1573
+ const c = [...f.value ?? [0, 0, 0, 0]];
1574
+ c[l] = o, d(c);
1413
1575
  }
1414
- return (u, r) => (s(), c("div", go, [
1415
- y("label", bo, w(e.descriptor.label), 1),
1416
- e.descriptor.type === "text" ? (s(), c("input", {
1576
+ function s(l) {
1577
+ const r = l.target.files?.[0];
1578
+ if (!r) return;
1579
+ const c = new FileReader();
1580
+ c.onload = () => {
1581
+ d(c.result);
1582
+ }, c.readAsDataURL(r);
1583
+ }
1584
+ return (l, o) => (a(), u("div", Jo, [
1585
+ y("label", Wo, w(e.descriptor.label), 1),
1586
+ e.descriptor.type === "text" ? (a(), u("input", {
1417
1587
  key: 0,
1418
1588
  type: "text",
1419
1589
  class: "brick-field__input",
1420
- value: a.value,
1421
- onInput: r[0] || (r[0] = (o) => l(o.target.value))
1422
- }, null, 40, ho)) : e.descriptor.type === "textarea" ? (s(), c("textarea", {
1590
+ value: f.value,
1591
+ onInput: o[0] || (o[0] = (r) => d(r.target.value))
1592
+ }, null, 40, jo)) : e.descriptor.type === "textarea" ? (a(), u("textarea", {
1423
1593
  key: 1,
1424
1594
  class: "brick-field__textarea",
1425
- value: a.value,
1595
+ value: f.value,
1426
1596
  rows: "3",
1427
- onInput: r[1] || (r[1] = (o) => l(o.target.value))
1428
- }, null, 40, vo)) : e.descriptor.type === "number" ? (s(), c("input", {
1597
+ onInput: o[1] || (o[1] = (r) => d(r.target.value))
1598
+ }, null, 40, Yo)) : e.descriptor.type === "number" ? (a(), u("input", {
1429
1599
  key: 2,
1430
1600
  type: "number",
1431
1601
  class: "brick-field__input",
1432
- value: a.value,
1602
+ value: f.value,
1433
1603
  min: e.descriptor.min,
1434
1604
  max: e.descriptor.max,
1435
1605
  step: e.descriptor.step,
1436
- onInput: r[2] || (r[2] = (o) => l(Number(o.target.value)))
1437
- }, null, 40, _o)) : e.descriptor.type === "color" ? (s(), c("input", {
1606
+ onInput: m
1607
+ }, null, 40, qo)) : e.descriptor.type === "color" ? (a(), u("input", {
1438
1608
  key: 3,
1439
1609
  type: "color",
1440
1610
  class: "brick-field__color",
1441
- value: a.value ?? "#000000",
1442
- onInput: r[3] || (r[3] = (o) => l(o.target.value))
1443
- }, null, 40, ko)) : e.descriptor.type === "select" ? (s(), c("select", {
1611
+ value: f.value ?? "#000000",
1612
+ onInput: o[2] || (o[2] = (r) => d(r.target.value))
1613
+ }, null, 40, Ko)) : e.descriptor.type === "select" ? (a(), u("select", {
1444
1614
  key: 4,
1445
1615
  class: "brick-field__select",
1446
- value: a.value,
1447
- onChange: r[4] || (r[4] = (o) => l(o.target.value || void 0))
1616
+ value: f.value,
1617
+ onChange: o[3] || (o[3] = (r) => d(r.target.value || void 0))
1448
1618
  }, [
1449
- (s(!0), c(C, null, P(e.descriptor.options, (o) => (s(), c("option", {
1450
- key: String(o.value),
1451
- value: o.value
1452
- }, w(o.label), 9, xo))), 128))
1453
- ], 40, So)) : e.descriptor.type === "toggle" ? (s(), c("label", Co, [
1619
+ (a(!0), u(P, null, T(e.descriptor.options, (r) => (a(), u("option", {
1620
+ key: String(r.value),
1621
+ value: r.value
1622
+ }, w(r.label), 9, Go))), 128))
1623
+ ], 40, Xo)) : e.descriptor.type === "toggle" ? (a(), u("label", Qo, [
1454
1624
  y("input", {
1455
1625
  type: "checkbox",
1456
- checked: a.value,
1457
- onChange: r[5] || (r[5] = (o) => l(o.target.checked))
1458
- }, null, 40, wo),
1459
- y("span", null, w(a.value ? "On" : "Off"), 1)
1460
- ])) : e.descriptor.type === "margin" ? (s(), c("div", Po, [
1461
- (s(), c(C, null, P(["L", "T", "R", "B"], (o, p) => y("input", {
1462
- key: o,
1626
+ checked: f.value,
1627
+ onChange: o[4] || (o[4] = (r) => d(r.target.checked))
1628
+ }, null, 40, Zo),
1629
+ y("span", null, w(f.value ? "On" : "Off"), 1)
1630
+ ])) : e.descriptor.type === "margin" ? (a(), u("div", er, [
1631
+ (a(), u(P, null, T(["L", "T", "R", "B"], (r, c) => y("input", {
1632
+ key: r,
1463
1633
  type: "number",
1464
1634
  class: "brick-field__margin-input",
1465
- placeholder: o,
1466
- value: (a.value ?? [0, 0, 0, 0])[p],
1467
- onInput: (g) => d(p, Number(g.target.value))
1468
- }, null, 40, Eo)), 64))
1469
- ])) : e.descriptor.type === "slider" ? (s(), c("div", Io, [
1635
+ placeholder: r,
1636
+ value: (f.value ?? [0, 0, 0, 0])[c],
1637
+ onInput: (v) => p(c, Number(v.target.value))
1638
+ }, null, 40, tr)), 64))
1639
+ ])) : e.descriptor.type === "slider" ? (a(), u("div", nr, [
1470
1640
  y("input", {
1471
1641
  type: "range",
1472
- value: a.value,
1642
+ value: f.value,
1473
1643
  min: e.descriptor.min,
1474
1644
  max: e.descriptor.max,
1475
1645
  step: e.descriptor.step,
1476
- onInput: r[6] || (r[6] = (o) => l(Number(o.target.value)))
1477
- }, null, 40, $o),
1478
- y("span", Ro, w(a.value), 1)
1479
- ])) : e.descriptor.type === "file" ? (s(), c("input", {
1646
+ onInput: o[5] || (o[5] = (r) => d(Number(r.target.value)))
1647
+ }, null, 40, or),
1648
+ y("span", rr, w(f.value), 1)
1649
+ ])) : e.descriptor.type === "file" ? (a(), u("input", {
1480
1650
  key: 8,
1481
1651
  type: "file",
1482
- accept: "image/*",
1652
+ accept: e.descriptor.accept ?? "image/*",
1483
1653
  class: "brick-field__file",
1484
- onChange: f
1485
- }, null, 32)) : $("", !0)
1654
+ onChange: s
1655
+ }, null, 40, lr)) : R("", !0)
1486
1656
  ]));
1487
1657
  }
1488
- }), zo = /* @__PURE__ */ x(No, [["__scopeId", "data-v-5a3bec1b"]]), To = {
1658
+ }), sr = /* @__PURE__ */ $(ir, [["__scopeId", "data-v-e439d522"]]), ar = {
1489
1659
  key: 0,
1490
1660
  class: "brick-property-editor"
1491
- }, Lo = { class: "brick-property-editor__type" }, Do = { class: "brick-property-editor__key" }, Mo = ["value"], Bo = {
1661
+ }, cr = {
1662
+ key: 0,
1663
+ class: "brick-property-editor__crumbs",
1664
+ "aria-label": "Element path"
1665
+ }, ur = ["onClick"], dr = { class: "brick-property-editor__type" }, pr = { class: "brick-property-editor__key" }, fr = ["value"], yr = {
1492
1666
  key: 0,
1493
1667
  class: "brick-property-editor__group"
1494
- }, Oo = { class: "brick-property-editor__group-title" }, Ao = /* @__PURE__ */ _({
1668
+ }, mr = { class: "brick-property-editor__group-title" }, vr = /* @__PURE__ */ S({
1495
1669
  __name: "PropertyEditor",
1496
1670
  setup(e) {
1497
- const t = q(), n = K();
1498
- function i(u) {
1671
+ const t = Q(), n = re(), i = G(), f = x(() => {
1672
+ const o = t.selectedId.value;
1673
+ return o ? ce(i.document.content, o) ?? [] : [];
1674
+ });
1675
+ function d(o) {
1499
1676
  const r = t.selectedNode.value;
1500
- r && n.updateKey(r.id, u.target.value);
1677
+ r && n.updateKey(r.id, o.target.value);
1501
1678
  }
1502
- const a = E(() => {
1503
- const u = t.selectedNode.value;
1504
- return u ? Y(u.type) : null;
1505
- }), l = E(() => {
1506
- if (!a.value) return {};
1507
- const u = {};
1508
- for (const r of a.value.propertyFields)
1509
- u[r.section] || (u[r.section] = []), u[r.section].push(r);
1510
- return u;
1511
- }), d = {
1679
+ const m = x(() => {
1680
+ const o = t.selectedNode.value;
1681
+ return o ? W(o.type) : null;
1682
+ }), p = x(() => {
1683
+ if (!m.value) return {};
1684
+ const o = {};
1685
+ for (const r of m.value.propertyFields)
1686
+ o[r.section] || (o[r.section] = []), o[r.section].push(r);
1687
+ return o;
1688
+ }), s = {
1512
1689
  content: "Content",
1513
1690
  style: "Style",
1514
1691
  layout: "Layout",
1515
1692
  advanced: "Advanced"
1516
- }, f = ["content", "style", "layout", "advanced"];
1517
- return (u, r) => k(t).selectedNode.value && a.value ? (s(), c("div", To, [
1518
- y("div", Lo, w(a.value.icon) + " " + w(a.value.label), 1),
1519
- y("div", Do, [
1520
- r[0] || (r[0] = y("label", { class: "brick-property-editor__key-label" }, "Key", -1)),
1693
+ }, l = ["content", "style", "layout", "advanced"];
1694
+ return (o, r) => g(t).selectedNode.value && m.value ? (a(), u("div", ar, [
1695
+ f.value.length ? (a(), u("nav", cr, [
1696
+ (a(!0), u(P, null, T(f.value, (c) => (a(), u(P, {
1697
+ key: c.id
1698
+ }, [
1699
+ y("button", {
1700
+ type: "button",
1701
+ class: "brick-property-editor__crumb",
1702
+ onClick: (v) => g(t).select(c.id)
1703
+ }, w(g(W)(c.type)?.label ?? c.type), 9, ur),
1704
+ r[0] || (r[0] = y("span", { class: "brick-property-editor__crumb-sep" }, "›", -1))
1705
+ ], 64))), 128))
1706
+ ])) : R("", !0),
1707
+ y("div", dr, w(m.value.icon) + " " + w(m.value.label), 1),
1708
+ y("div", pr, [
1709
+ r[1] || (r[1] = y("label", { class: "brick-property-editor__key-label" }, "Key", -1)),
1521
1710
  y("input", {
1522
1711
  type: "text",
1523
1712
  class: "brick-property-editor__key-input",
1524
- value: k(t).selectedNode.value.key ?? "",
1713
+ value: g(t).selectedNode.value.key ?? "",
1525
1714
  placeholder: "(optional identifier)",
1526
- onInput: i
1527
- }, null, 40, Mo)
1715
+ onInput: d
1716
+ }, null, 40, fr)
1528
1717
  ]),
1529
- (s(), c(C, null, P(f, (o) => (s(), c(C, { key: o }, [
1530
- l.value[o] ? (s(), c("div", Bo, [
1531
- y("div", Oo, w(d[o]), 1),
1532
- (s(!0), c(C, null, P(l.value[o], (p) => (s(), O(zo, {
1533
- key: p.key,
1534
- descriptor: p,
1535
- node: k(t).selectedNode.value
1718
+ (a(), u(P, null, T(l, (c) => (a(), u(P, { key: c }, [
1719
+ p.value[c] ? (a(), u("div", yr, [
1720
+ y("div", mr, w(s[c]), 1),
1721
+ (a(!0), u(P, null, T(p.value[c], (v) => (a(), H(sr, {
1722
+ key: v.key,
1723
+ descriptor: v,
1724
+ node: g(t).selectedNode.value
1536
1725
  }, null, 8, ["descriptor", "node"]))), 128))
1537
- ])) : $("", !0)
1726
+ ])) : R("", !0)
1538
1727
  ], 64))), 64)),
1539
- (s(), O(oe(a.value.propertyEditorComponent), {
1540
- node: k(t).selectedNode.value
1728
+ (a(), H(ve(m.value.propertyEditorComponent), {
1729
+ node: g(t).selectedNode.value
1541
1730
  }, null, 8, ["node"]))
1542
- ])) : $("", !0);
1731
+ ])) : R("", !0);
1543
1732
  }
1544
- }), Vo = /* @__PURE__ */ x(Ao, [["__scopeId", "data-v-e49ddc4f"]]), Fo = { class: "brick-toolbar" }, Ho = { class: "brick-toolbar__section" }, Jo = {
1733
+ }), br = /* @__PURE__ */ $(vr, [["__scopeId", "data-v-6170de2b"]]), gr = { class: "brick-layers" }, hr = ["data-layer-id", "onClick", "onMouseenter"], _r = ["onClick"], kr = {
1734
+ key: 1,
1735
+ class: "brick-layers__caret-spacer"
1736
+ }, Sr = { class: "brick-layers__icon" }, xr = { class: "brick-layers__type" }, Cr = { class: "brick-layers__summary" }, wr = /* @__PURE__ */ S({
1737
+ name: "LayerTree",
1738
+ __name: "LayerTree",
1739
+ props: {
1740
+ nodes: {},
1741
+ depth: {}
1742
+ },
1743
+ setup(e) {
1744
+ const t = Q(), n = B(le, null), i = ze(/* @__PURE__ */ new Set());
1745
+ function f(p) {
1746
+ if (p.key) return p.key;
1747
+ const s = p.props.text;
1748
+ return typeof s == "string" && s.trim() ? s.trim().split(`
1749
+ `)[0] : "";
1750
+ }
1751
+ function d(p, s) {
1752
+ t.select(p.id), s.currentTarget.closest(".brick-pdf")?.querySelector(`.brick-canvas [data-element-id="${p.id}"]`)?.scrollIntoView({ block: "nearest", behavior: "smooth" });
1753
+ }
1754
+ function m(p) {
1755
+ i.has(p) ? i.delete(p) : i.add(p);
1756
+ }
1757
+ return (p, s) => {
1758
+ const l = Le("LayerTree", !0);
1759
+ return a(), u("ul", gr, [
1760
+ (a(!0), u(P, null, T(e.nodes, (o) => (a(), u("li", {
1761
+ key: o.id
1762
+ }, [
1763
+ y("div", {
1764
+ class: Y(["brick-layers__row", {
1765
+ "brick-layers__row--selected": g(t).selectedId.value === o.id,
1766
+ "brick-layers__row--hovered": g(n)?.hoveredId.value === o.id
1767
+ }]),
1768
+ "data-layer-id": o.id,
1769
+ style: L({ paddingLeft: 4 + (e.depth ?? 0) * 14 + "px" }),
1770
+ onClick: (r) => d(o, r),
1771
+ onMouseenter: (r) => g(n) && (g(n).hoveredId.value = o.id),
1772
+ onMouseleave: s[0] || (s[0] = (r) => g(n) && (g(n).hoveredId.value = null))
1773
+ }, [
1774
+ o.children.length ? (a(), u("button", {
1775
+ key: 0,
1776
+ type: "button",
1777
+ class: Y(["brick-layers__caret", { "brick-layers__caret--collapsed": i.has(o.id) }]),
1778
+ onClick: fe((r) => m(o.id), ["stop"])
1779
+ }, "▾", 10, _r)) : (a(), u("span", kr)),
1780
+ y("span", Sr, w(g(W)(o.type)?.icon ?? "?"), 1),
1781
+ y("span", xr, w(g(W)(o.type)?.label ?? o.type), 1),
1782
+ y("span", Cr, w(f(o)), 1)
1783
+ ], 46, hr),
1784
+ o.children.length && !i.has(o.id) ? (a(), H(l, {
1785
+ key: 0,
1786
+ nodes: o.children,
1787
+ depth: (e.depth ?? 0) + 1
1788
+ }, null, 8, ["nodes", "depth"])) : R("", !0)
1789
+ ]))), 128))
1790
+ ]);
1791
+ };
1792
+ }
1793
+ }), Pr = /* @__PURE__ */ $(wr, [["__scopeId", "data-v-a3d66c12"]]), Er = { class: "brick-toolbar" }, $r = { class: "brick-toolbar__section" }, Ir = {
1794
+ class: "brick-toolbar__tabs",
1795
+ role: "tablist"
1796
+ }, Nr = ["aria-selected"], zr = ["aria-selected"], Tr = {
1797
+ key: 1,
1798
+ class: "brick-toolbar__empty"
1799
+ }, Rr = {
1545
1800
  key: 0,
1546
1801
  class: "brick-toolbar__section"
1547
- }, Uo = /* @__PURE__ */ _({
1802
+ }, Lr = /* @__PURE__ */ S({
1548
1803
  __name: "Toolbar",
1549
1804
  setup(e) {
1550
- const t = q();
1551
- return (n, i) => (s(), c("div", Fo, [
1552
- y("div", Ho, [
1553
- i[0] || (i[0] = y("h3", { class: "brick-toolbar__title" }, "Elements", -1)),
1554
- A(mo)
1805
+ const t = Q(), n = G(), i = E("elements"), f = E(null);
1806
+ return De([() => t.selectedId.value, i], async ([d]) => {
1807
+ !d || i.value !== "layers" || (await ot(), f.value?.querySelector(`[data-layer-id="${d}"]`)?.scrollIntoView({ block: "nearest" }));
1808
+ }), (d, m) => (a(), u("div", Er, [
1809
+ y("div", $r, [
1810
+ y("div", Ir, [
1811
+ y("button", {
1812
+ type: "button",
1813
+ role: "tab",
1814
+ class: Y(["brick-toolbar__tab", { "brick-toolbar__tab--active": i.value === "elements" }]),
1815
+ "aria-selected": i.value === "elements",
1816
+ onClick: m[0] || (m[0] = (p) => i.value = "elements")
1817
+ }, "Elements", 10, Nr),
1818
+ y("button", {
1819
+ type: "button",
1820
+ role: "tab",
1821
+ class: Y(["brick-toolbar__tab", { "brick-toolbar__tab--active": i.value === "layers" }]),
1822
+ "aria-selected": i.value === "layers",
1823
+ onClick: m[1] || (m[1] = (p) => i.value = "layers")
1824
+ }, "Layers", 10, zr)
1825
+ ]),
1826
+ ne(j(Uo, null, null, 512), [
1827
+ [xe, i.value === "elements"]
1828
+ ]),
1829
+ ne(y("div", {
1830
+ ref_key: "layersEl",
1831
+ ref: f,
1832
+ class: "brick-toolbar__layers"
1833
+ }, [
1834
+ g(n).document.content.length ? (a(), H(Pr, {
1835
+ key: 0,
1836
+ nodes: g(n).document.content
1837
+ }, null, 8, ["nodes"])) : (a(), u("p", Tr, "No elements yet."))
1838
+ ], 512), [
1839
+ [xe, i.value === "layers"]
1840
+ ])
1555
1841
  ]),
1556
- k(t).selectedNode.value ? (s(), c("div", Jo, [
1557
- i[1] || (i[1] = y("h3", { class: "brick-toolbar__title" }, "Properties", -1)),
1558
- A(Vo)
1559
- ])) : $("", !0)
1842
+ g(t).selectedNode.value ? (a(), u("div", Rr, [
1843
+ m[2] || (m[2] = y("h3", { class: "brick-toolbar__title" }, "Properties", -1)),
1844
+ j(br)
1845
+ ])) : R("", !0)
1560
1846
  ]));
1561
1847
  }
1562
- }), Wo = /* @__PURE__ */ x(Uo, [["__scopeId", "data-v-0174c069"]]), jo = { class: "brick-actionbar" }, Yo = { class: "brick-actionbar__group" }, qo = ["disabled"], Ko = ["disabled"], Go = ["disabled"], Xo = { class: "brick-actionbar__group" }, Qo = /* @__PURE__ */ _({
1848
+ }), Dr = /* @__PURE__ */ $(Lr, [["__scopeId", "data-v-06ce3a81"]]), Br = { class: "brick-actionbar" }, Mr = { class: "brick-actionbar__group" }, Or = ["disabled"], Ar = ["disabled"], Vr = ["disabled"], Hr = { class: "brick-actionbar__group" }, Fr = /* @__PURE__ */ S({
1563
1849
  __name: "ActionBar",
1564
1850
  setup(e) {
1565
- const t = wt(), n = Lt(), i = q(), a = K(), l = le(), d = I("document"), f = I(null);
1566
- function u() {
1567
- const m = i.selectedId.value;
1568
- m && (i.deselect(), a.removeElement(m));
1851
+ const t = qt(), n = on(), i = Q(), f = re(), d = G(), m = E("document"), p = E(null);
1852
+ function s() {
1853
+ const v = i.selectedId.value;
1854
+ v && (i.deselect(), f.removeElement(v));
1569
1855
  }
1570
- function r() {
1571
- const m = d.value.trim() || "document", h = m.endsWith(".pdf") ? m : m + ".pdf";
1572
- n.exportPdf(h);
1856
+ function l() {
1857
+ const v = m.value.trim() || "document", b = v.endsWith(".pdf") ? v : v + ".pdf";
1858
+ n.exportPdf(b);
1573
1859
  }
1574
1860
  function o() {
1575
- const m = l.exportDocument(), h = JSON.stringify(m, null, 2), v = new Blob([h], { type: "application/json" }), b = URL.createObjectURL(v), S = document.createElement("a"), R = d.value.trim() || "document";
1576
- S.href = b, S.download = R.endsWith(".json") ? R : R + ".json", S.click(), URL.revokeObjectURL(b);
1861
+ const v = d.exportDocument(), b = JSON.stringify(v, null, 2), k = new Blob([b], { type: "application/json" }), C = URL.createObjectURL(k), _ = document.createElement("a"), I = m.value.trim() || "document";
1862
+ _.href = C, _.download = I.endsWith(".json") ? I : I + ".json", _.click(), URL.revokeObjectURL(C);
1577
1863
  }
1578
- function p() {
1579
- f.value?.click();
1864
+ function r() {
1865
+ p.value?.click();
1580
1866
  }
1581
- function g(m) {
1582
- const h = m.target, v = h.files?.[0];
1583
- if (!v) return;
1584
- const b = new FileReader();
1585
- b.onload = () => {
1867
+ function c(v) {
1868
+ const b = v.target, k = b.files?.[0];
1869
+ if (!k) return;
1870
+ const C = new FileReader();
1871
+ C.onload = () => {
1586
1872
  try {
1587
- const S = JSON.parse(b.result);
1588
- if (!S.content || !S.pageSize) {
1873
+ const _ = JSON.parse(C.result);
1874
+ if (!_.content || !_.pageSize) {
1589
1875
  alert("Invalid brick-pdf JSON file.");
1590
1876
  return;
1591
1877
  }
1592
- i.deselect(), l.loadDocument(S);
1878
+ i.deselect(), d.loadDocument(_);
1593
1879
  } catch {
1594
1880
  alert("Failed to parse JSON file.");
1595
1881
  }
1596
- }, b.readAsText(v), h.value = "";
1882
+ }, C.readAsText(k), b.value = "";
1597
1883
  }
1598
- return (m, h) => (s(), c("div", jo, [
1599
- y("div", Yo, [
1884
+ return (v, b) => (a(), u("div", Br, [
1885
+ y("div", Mr, [
1600
1886
  y("button", {
1601
1887
  class: "brick-actionbar__btn",
1602
- disabled: !k(t).canUndo.value,
1888
+ disabled: !g(t).canUndo.value,
1603
1889
  title: "Undo",
1604
- onClick: h[0] || (h[0] = (v) => k(t).undo())
1605
- }, " Undo ", 8, qo),
1890
+ onClick: b[0] || (b[0] = (k) => g(t).undo())
1891
+ }, " Undo ", 8, Or),
1606
1892
  y("button", {
1607
1893
  class: "brick-actionbar__btn",
1608
- disabled: !k(t).canRedo.value,
1894
+ disabled: !g(t).canRedo.value,
1609
1895
  title: "Redo",
1610
- onClick: h[1] || (h[1] = (v) => k(t).redo())
1611
- }, " Redo ", 8, Ko),
1896
+ onClick: b[1] || (b[1] = (k) => g(t).redo())
1897
+ }, " Redo ", 8, Ar),
1612
1898
  y("button", {
1613
1899
  class: "brick-actionbar__btn brick-actionbar__btn--danger",
1614
- disabled: !k(i).selectedId.value,
1900
+ disabled: !g(i).selectedId.value,
1615
1901
  title: "Delete selected element",
1616
- onClick: u
1617
- }, " Delete ", 8, Go)
1902
+ onClick: s
1903
+ }, " Delete ", 8, Vr)
1618
1904
  ]),
1619
- y("div", Xo, [
1905
+ y("div", Hr, [
1620
1906
  y("button", {
1621
1907
  class: "brick-actionbar__btn",
1622
1908
  title: "Import JSON",
1623
- onClick: p
1909
+ onClick: r
1624
1910
  }, " Import JSON "),
1625
1911
  y("button", {
1626
1912
  class: "brick-actionbar__btn",
@@ -1629,24 +1915,24 @@ const Un = {
1629
1915
  }, " Export JSON "),
1630
1916
  y("button", {
1631
1917
  class: "brick-actionbar__btn brick-actionbar__btn--primary",
1632
- onClick: r
1918
+ onClick: l
1633
1919
  }, " Export PDF "),
1634
1920
  y("button", {
1635
1921
  class: "brick-actionbar__btn",
1636
- onClick: h[2] || (h[2] = (v) => k(n).openPdf())
1922
+ onClick: b[2] || (b[2] = (k) => g(n).openPdf())
1637
1923
  }, " Preview ")
1638
1924
  ]),
1639
1925
  y("input", {
1640
1926
  ref_key: "fileInput",
1641
- ref: f,
1927
+ ref: p,
1642
1928
  type: "file",
1643
1929
  accept: ".json",
1644
1930
  style: { display: "none" },
1645
- onChange: g
1931
+ onChange: c
1646
1932
  }, null, 544)
1647
1933
  ]));
1648
1934
  }
1649
- }), Zo = /* @__PURE__ */ x(Qo, [["__scopeId", "data-v-586445a9"]]), er = { class: "brick-pdf" }, tr = { class: "brick-pdf__workspace" }, nr = /* @__PURE__ */ _({
1935
+ }), Ur = /* @__PURE__ */ $(Fr, [["__scopeId", "data-v-586445a9"]]), Jr = { class: "brick-pdf__workspace" }, Wr = /* @__PURE__ */ S({
1650
1936
  __name: "BrickPdf",
1651
1937
  props: {
1652
1938
  modelValue: {}
@@ -1654,69 +1940,84 @@ const Un = {
1654
1940
  emits: ["update:modelValue"],
1655
1941
  setup(e, { emit: t }) {
1656
1942
  const n = e, i = t;
1657
- Jn();
1658
- const a = mt(n.modelValue ?? re());
1659
- gt(a);
1660
- const l = bt(a);
1661
- ht(l);
1662
- const d = xt(a);
1663
- Ct(d);
1664
- const f = _t(a, d);
1665
- kt(f);
1666
- const u = Pt(a, f);
1667
- Et(u);
1668
- const r = zt(a);
1669
- Tt(r);
1670
- const o = Bt(a, f);
1671
- Ot(o);
1672
- const p = At(f);
1673
- Vt(p);
1674
- const g = Oe(), m = g.Delete, h = g.Backspace;
1675
- return pe(m, () => {
1676
- if (!l.selectedId.value) return;
1677
- const v = document.activeElement;
1678
- if (v && (v.tagName === "INPUT" || v.tagName === "TEXTAREA" || v.tagName === "SELECT")) return;
1679
- const b = l.selectedId.value;
1680
- l.deselect(), f.removeElement(b);
1681
- }), pe(h, () => {
1682
- if (!l.selectedId.value) return;
1683
- const v = document.activeElement;
1684
- if (v && (v.tagName === "INPUT" || v.tagName === "TEXTAREA" || v.tagName === "SELECT")) return;
1685
- const b = l.selectedId.value;
1686
- l.deselect(), f.removeElement(b);
1687
- }), Be(
1688
- () => a.document,
1943
+ fo();
1944
+ const f = Ot(n.modelValue ?? be());
1945
+ At(f);
1946
+ const d = Vt(f);
1947
+ Ht(d);
1948
+ const m = jt(f);
1949
+ Yt(m);
1950
+ const p = Ut(f, m);
1951
+ Jt(p);
1952
+ const s = Kt(f, p);
1953
+ Xt(s);
1954
+ const l = tn(f);
1955
+ nn(l);
1956
+ const o = sn(f, p);
1957
+ an(o);
1958
+ const r = cn(p);
1959
+ un(r);
1960
+ const c = E(null);
1961
+ F(le, { hoveredId: c, showOutlines: E(!1), zoom: E("fit"), pxPerPt: E(1) });
1962
+ function v(_) {
1963
+ const I = d.selectedId.value;
1964
+ if (!I) return;
1965
+ const O = _.target;
1966
+ if (O && (O.tagName === "INPUT" || O.tagName === "TEXTAREA" || O.tagName === "SELECT")) return;
1967
+ const ie = ce(f.document.content, I), Z = ie?.[ie.length - 1];
1968
+ Z ? d.select(Z.id) : d.deselect();
1969
+ }
1970
+ const b = it(), k = b.Delete, C = b.Backspace;
1971
+ return Ce(k, () => {
1972
+ if (!d.selectedId.value) return;
1973
+ const _ = document.activeElement;
1974
+ if (_ && (_.tagName === "INPUT" || _.tagName === "TEXTAREA" || _.tagName === "SELECT" || _.isContentEditable)) return;
1975
+ const I = d.selectedId.value;
1976
+ d.deselect(), p.removeElement(I);
1977
+ }), Ce(C, () => {
1978
+ if (!d.selectedId.value) return;
1979
+ const _ = document.activeElement;
1980
+ if (_ && (_.tagName === "INPUT" || _.tagName === "TEXTAREA" || _.tagName === "SELECT" || _.isContentEditable)) return;
1981
+ const I = d.selectedId.value;
1982
+ d.deselect(), p.removeElement(I);
1983
+ }), De(
1984
+ () => f.document,
1689
1985
  () => {
1690
- i("update:modelValue", JSON.parse(JSON.stringify(j(a.document))));
1986
+ i("update:modelValue", JSON.parse(JSON.stringify(oe(f.document))));
1691
1987
  },
1692
1988
  { deep: !0 }
1693
- ), (v, b) => (s(), c("div", er, [
1694
- A(Zo),
1695
- y("div", tr, [
1696
- A(co),
1697
- A(Wo)
1989
+ ), (_, I) => (a(), u("div", {
1990
+ class: "brick-pdf",
1991
+ tabindex: "-1",
1992
+ onKeydown: rt(v, ["esc"]),
1993
+ onMouseleave: I[0] || (I[0] = (O) => c.value = null)
1994
+ }, [
1995
+ j(Ur),
1996
+ y("div", Jr, [
1997
+ j(Oo),
1998
+ j(Dr)
1698
1999
  ])
1699
- ]));
2000
+ ], 32));
1700
2001
  }
1701
- }), or = /* @__PURE__ */ x(nr, [["__scopeId", "data-v-f9b95ad8"]]), dr = {
2002
+ }), jr = /* @__PURE__ */ $(Wr, [["__scopeId", "data-v-51e3c556"]]), Zr = {
1702
2003
  install(e) {
1703
- e.component("BrickPdf", or);
2004
+ e.component("BrickPdf", jr);
1704
2005
  }
1705
2006
  };
1706
2007
  export {
1707
- or as BrickPdf,
1708
- re as createDefaultDocument,
1709
- dr as default,
1710
- Ae as getAllElementDefinitions,
1711
- Y as getElementDefinition,
1712
- L as registerElement,
1713
- sr as unregisterElement,
1714
- ar as useClipboard,
1715
- le as useDocumentStore,
1716
- ie as useDragDrop,
1717
- K as useElementActions,
1718
- wt as useHistory,
1719
- Lt as usePdfExport,
1720
- cr as useResize,
1721
- q as useSelection
2008
+ jr as BrickPdf,
2009
+ be as createDefaultDocument,
2010
+ Zr as default,
2011
+ st as getAllElementDefinitions,
2012
+ W as getElementDefinition,
2013
+ V as registerElement,
2014
+ Xr as unregisterElement,
2015
+ Gr as useClipboard,
2016
+ G as useDocumentStore,
2017
+ ge as useDragDrop,
2018
+ re as useElementActions,
2019
+ qt as useHistory,
2020
+ on as usePdfExport,
2021
+ Qr as useResize,
2022
+ Q as useSelection
1722
2023
  };