@hankchen/canvas-editor-vue 0.1.1 → 0.1.3

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.
@@ -0,0 +1,1650 @@
1
+ import { t as e } from "./createLucideIcon-SCvtEGVf.js";
2
+ import { c as t, d as n, f as r, l as i, o as a, p as o, s, u as c } from "./dist-DGtNmLwo.js";
3
+ import { i as l, n as u, o as d } from "./layerPath-uy2ywyld.js";
4
+ import { i as f, r as p } from "./completionAnchor-CDR5YZhu.js";
5
+ import { l as m, n as h, o as g, s as _, t as v } from "./useTransientFeedback-Cnp6aNB7.js";
6
+ import { i as y, n as b, r as x, t as S } from "./uploadFile-BOfv8aLG.js";
7
+ import { n as C, t as w } from "./useViewport-D9Ipevzs.js";
8
+ import { Fragment as T, computed as E, createBlock as D, createCommentVNode as O, createElementBlock as k, createElementVNode as A, createVNode as j, defineComponent as M, mergeProps as N, nextTick as P, normalizeClass as F, normalizeStyle as I, onBeforeUnmount as L, onMounted as R, onScopeDispose as z, openBlock as B, ref as V, renderList as H, shallowRef as U, toDisplayString as W, unref as G, vModelText as ee, vShow as K, watch as q, withDirectives as J, withKeys as Y, withModifiers as X } from "vue";
9
+ var Z = e({
10
+ name: "arrow-down-left",
11
+ size: 24,
12
+ node: [["path", {
13
+ d: "M17 7 7 17",
14
+ key: "15tmo1"
15
+ }], ["path", {
16
+ d: "M17 17H7V7",
17
+ key: "1org7z"
18
+ }]]
19
+ }), te = e({
20
+ name: "arrow-down-right",
21
+ size: 24,
22
+ node: [["path", {
23
+ d: "m7 7 10 10",
24
+ key: "1fmybs"
25
+ }], ["path", {
26
+ d: "M17 7v10H7",
27
+ key: "6fjiku"
28
+ }]]
29
+ }), ne = e({
30
+ name: "arrow-up-left",
31
+ size: 24,
32
+ node: [["path", {
33
+ d: "M7 17V7h10",
34
+ key: "11bw93"
35
+ }], ["path", {
36
+ d: "M17 17 7 7",
37
+ key: "2786uv"
38
+ }]]
39
+ }), re = e({
40
+ name: "arrow-up-right",
41
+ size: 24,
42
+ node: [["path", {
43
+ d: "M7 7h10v10",
44
+ key: "1tivn9"
45
+ }], ["path", {
46
+ d: "M7 17 17 7",
47
+ key: "1vkiza"
48
+ }]]
49
+ }), ie = e({
50
+ name: "chevron-up",
51
+ size: 24,
52
+ node: [["path", {
53
+ d: "m18 15-6-6-6 6",
54
+ key: "153udz"
55
+ }]]
56
+ });
57
+ //#endregion
58
+ //#region ../canvas-editor/src/spatial/camera.ts
59
+ function ae(e, t) {
60
+ if (!(t > 0)) return e;
61
+ let n = e.zoom * t;
62
+ return {
63
+ x: Math.round(e.x * n) / n,
64
+ y: Math.round(e.y * n) / n,
65
+ zoom: e.zoom
66
+ };
67
+ }
68
+ function oe(e) {
69
+ return 6 / e;
70
+ }
71
+ function se(e, t, n) {
72
+ let r = [];
73
+ for (let i = 0; i < e.layers.length; i += 1) {
74
+ if (t !== null && i === t) continue;
75
+ let o = e.layers[i];
76
+ o.visible !== !1 && r.push(a(o, 0, 0, e.width, e.height, n));
77
+ }
78
+ return r;
79
+ }
80
+ function ce(e, t, n, r) {
81
+ let i = [];
82
+ for (let e of n) i.push({
83
+ orientation: "vertical",
84
+ position: e.x,
85
+ source: "layer"
86
+ }, {
87
+ orientation: "vertical",
88
+ position: e.x + e.width / 2,
89
+ source: "layer"
90
+ }, {
91
+ orientation: "vertical",
92
+ position: e.x + e.width,
93
+ source: "layer"
94
+ }, {
95
+ orientation: "horizontal",
96
+ position: e.y,
97
+ source: "layer"
98
+ }, {
99
+ orientation: "horizontal",
100
+ position: e.y + e.height / 2,
101
+ source: "layer"
102
+ }, {
103
+ orientation: "horizontal",
104
+ position: e.y + e.height,
105
+ source: "layer"
106
+ });
107
+ i.push({
108
+ orientation: "vertical",
109
+ position: e / 2,
110
+ source: "canvas-center"
111
+ }, {
112
+ orientation: "horizontal",
113
+ position: t / 2,
114
+ source: "canvas-center"
115
+ });
116
+ for (let e of r) i.push({
117
+ orientation: e.orientation,
118
+ position: e.position,
119
+ source: "guide"
120
+ });
121
+ return i;
122
+ }
123
+ function Q(e, t, n, r) {
124
+ let i = null;
125
+ for (let a of t) if (a.orientation === n) for (let t of e) {
126
+ let e = a.position - t, n = Math.abs(e);
127
+ n > r || (i === null || n < Math.abs(i.delta)) && (i = {
128
+ delta: e,
129
+ axis: a
130
+ });
131
+ }
132
+ return i;
133
+ }
134
+ function le(e, t, n) {
135
+ let r = Q(e.vertical, t, "vertical", n), i = Q(e.horizontal, t, "horizontal", n);
136
+ return {
137
+ dx: r ? r.delta : 0,
138
+ dy: i ? i.delta : 0,
139
+ axes: [...r ? [r.axis] : [], ...i ? [i.axis] : []]
140
+ };
141
+ }
142
+ function ue(e, t, n) {
143
+ return le({
144
+ vertical: [
145
+ e.x,
146
+ e.x + e.width / 2,
147
+ e.x + e.width
148
+ ],
149
+ horizontal: [
150
+ e.y,
151
+ e.y + e.height / 2,
152
+ e.y + e.height
153
+ ]
154
+ }, t, n);
155
+ }
156
+ //#endregion
157
+ //#region ../canvas-editor/src/spatial/resize.ts
158
+ function de(e, t) {
159
+ let n = e.x + e.width, r = e.y + e.height;
160
+ switch (t) {
161
+ case "nw": return {
162
+ x: e.x,
163
+ y: e.y
164
+ };
165
+ case "n": return {
166
+ x: e.x + e.width / 2,
167
+ y: e.y
168
+ };
169
+ case "ne": return {
170
+ x: n,
171
+ y: e.y
172
+ };
173
+ case "e": return {
174
+ x: n,
175
+ y: e.y + e.height / 2
176
+ };
177
+ case "se": return {
178
+ x: n,
179
+ y: r
180
+ };
181
+ case "s": return {
182
+ x: e.x + e.width / 2,
183
+ y: r
184
+ };
185
+ case "sw": return {
186
+ x: e.x,
187
+ y: r
188
+ };
189
+ case "w": return {
190
+ x: e.x,
191
+ y: e.y + e.height / 2
192
+ };
193
+ }
194
+ }
195
+ //#endregion
196
+ //#region ../canvas-editor/src/spatial/wheel.ts
197
+ function fe(e) {
198
+ return e.ctrlKey || e.metaKey ? "zoom" : e.shiftKey ? "pan-x" : "pan";
199
+ }
200
+ //#endregion
201
+ //#region ../canvas-browser-renderer/src/fonts.ts
202
+ function pe(e) {
203
+ return e === "" || /^[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?$/.test(e.trim());
204
+ }
205
+ function me(e) {
206
+ return pe(e) ? "sans-serif" : `${he(e)}, sans-serif`;
207
+ }
208
+ function he(e) {
209
+ let t = 2166136261;
210
+ for (let n = 0; n < e.length; n++) t ^= e.charCodeAt(n), t = Math.imul(t, 16777619);
211
+ return `canvas-font-${(t >>> 0).toString(36)}`;
212
+ }
213
+ //#endregion
214
+ //#region src/canvas/AlignFloatBar.vue?vue&type=script&setup=true&lang.ts
215
+ var ge = ["aria-disabled"], _e = {
216
+ key: 0,
217
+ class: "cn-align-float__divider",
218
+ "aria-hidden": "true"
219
+ }, ve = { class: "cn-align-float__group" }, ye = [
220
+ "disabled",
221
+ "title",
222
+ "aria-label",
223
+ "onClick"
224
+ ], be = /*#__PURE__*/ m(/* @__PURE__ */ M({
225
+ __name: "AlignFloatBar",
226
+ props: { editor: {} },
227
+ setup(e) {
228
+ let a = e, s = C(a.editor), l = E(() => s.value !== null), u = (e) => `贴${e}角(边距 40px)`, d = [
229
+ { keys: [{
230
+ mode: "h-center",
231
+ icon: r,
232
+ title: "水平居中"
233
+ }, {
234
+ mode: "v-center",
235
+ icon: o,
236
+ title: "垂直居中"
237
+ }] },
238
+ { keys: [
239
+ {
240
+ mode: "left",
241
+ icon: t,
242
+ title: "贴左"
243
+ },
244
+ {
245
+ mode: "right",
246
+ icon: c,
247
+ title: "贴右"
248
+ },
249
+ {
250
+ mode: "top",
251
+ icon: i,
252
+ title: "贴顶"
253
+ },
254
+ {
255
+ mode: "bottom",
256
+ icon: n,
257
+ title: "贴底"
258
+ }
259
+ ] },
260
+ { keys: [
261
+ {
262
+ mode: "corner-tl",
263
+ icon: ne,
264
+ title: u("左上")
265
+ },
266
+ {
267
+ mode: "corner-tr",
268
+ icon: re,
269
+ title: u("右上")
270
+ },
271
+ {
272
+ mode: "corner-bl",
273
+ icon: Z,
274
+ title: u("左下")
275
+ },
276
+ {
277
+ mode: "corner-br",
278
+ icon: te,
279
+ title: u("右下")
280
+ }
281
+ ] }
282
+ ];
283
+ function p(e) {
284
+ return { [`data-align-${e}`]: "" };
285
+ }
286
+ function m(e) {
287
+ let t = s.value;
288
+ t && (e.startsWith("corner-") ? a.editor.alignToCanvas(t, e, { margin: 40 }) : a.editor.alignToCanvas(t, e));
289
+ }
290
+ return (e, t) => (B(), k("div", {
291
+ class: F(["cn-align-float", { "cn-align-float--disabled": !l.value }]),
292
+ role: "toolbar",
293
+ "aria-label": "对齐画布",
294
+ "data-align-float": "",
295
+ "aria-disabled": l.value ? void 0 : "true"
296
+ }, [(B(), k(T, null, H(d, (e, t) => (B(), k(T, { key: t }, [t > 0 ? (B(), k("span", _e)) : O("", !0), A("span", ve, [(B(!0), k(T, null, H(e.keys, (e) => (B(), k("button", N({
297
+ key: e.mode,
298
+ type: "button",
299
+ class: "cn-align-float__key",
300
+ disabled: !l.value,
301
+ title: e.title,
302
+ "aria-label": e.title
303
+ }, { ref_for: !0 }, p(e.mode), { onClick: (t) => m(e.mode) }), [j(f, { icon: e.icon }, null, 8, ["icon"])], 16, ye))), 128))])], 64))), 64))], 10, ge));
304
+ }
305
+ }), [["__scopeId", "data-v-9a761d37"]]), xe = {
306
+ key: 0,
307
+ class: "cn-context-menu__form"
308
+ }, Se = { class: "cn-context-menu__hint" }, Ce = ["onKeydown"], we = {
309
+ key: 0,
310
+ class: "cn-context-menu__hint cn-context-menu__hint--error"
311
+ }, Te = [
312
+ "disabled",
313
+ "title",
314
+ "onClick"
315
+ ], Ee = /*#__PURE__*/ m(/* @__PURE__ */ M({
316
+ __name: "ContextMenu",
317
+ props: { editor: {} },
318
+ setup(e, { expose: t }) {
319
+ let n = e, r = V(null), i = V(!1), a = V({
320
+ x: 0,
321
+ y: 0
322
+ }), o = g(), s = `先 ${_("copyStyle", o)} 复制样式`, c = `图层已锁定(${_("toggleLayerLock", o)} 解锁后可删除)`, l = C(n.editor), f = E(() => l.value !== null && u(l.value)), p = E(() => l.value !== null && n.editor.canCopySelection), m = E(() => (i.value, l.value !== null && n.editor.canCopyStyle)), h = E(() => (i.value, l.value !== null && n.editor.canPasteStyle)), v = E(() => {
323
+ let e = l.value, t = n.editor.store.doc;
324
+ return !e || !t || !u(e) ? !0 : d(t, e)?.visible ?? !0;
325
+ }), y = E(() => {
326
+ let e = l.value, t = n.editor.store.doc;
327
+ return !e || !t ? null : d(t, e);
328
+ });
329
+ function b() {
330
+ let e = l.value;
331
+ return !e || typeof e[1] != "number" ? null : ["layers", e[1]];
332
+ }
333
+ let x = E(() => y.value?.type === "TableLayer" && y.value.template !== null), S = E(() => l.value?.[l.value.length - 1] === "template"), w = E(() => l.value !== null && n.editor.isLocked(l.value)), D = E(() => {
334
+ let e = y.value;
335
+ if (!e || e.type !== "TableLayer" || e.template !== null) return !1;
336
+ let t = e.rows[e.rows.length - 1];
337
+ return t !== void 0 && t.cells.length > 0;
338
+ }), j = E(() => {
339
+ let e = y.value;
340
+ return !e || e.type !== "TableLayer" ? "" : `模板取自末行,其余 ${Math.max(e.rows.length - 1, 0)} 行将移除(可撤销)`;
341
+ }), M = V(!1), N = V(""), L = V(!1);
342
+ function R() {
343
+ M.value = !0, N.value = "", L.value = !1;
344
+ }
345
+ function z() {
346
+ let e = b(), t = N.value.trim();
347
+ if (!e || t === "") {
348
+ L.value = !0;
349
+ return;
350
+ }
351
+ n.editor.convertTableToTemplate(e, t), K();
352
+ }
353
+ let U = E(() => [
354
+ {
355
+ key: "visibility",
356
+ label: v.value ? "隐藏" : "显示",
357
+ enabled: f.value,
358
+ title: f.value ? void 0 : "显示/隐藏仅作用于根图层",
359
+ run: () => {
360
+ let e = l.value;
361
+ e && n.editor.toggleLayerVisibility(e);
362
+ }
363
+ },
364
+ {
365
+ key: "duplicate",
366
+ label: "创建副本",
367
+ enabled: p.value,
368
+ title: p.value ? void 0 : "行/格/行模板是容器内结构,不可复制",
369
+ run: () => n.editor.duplicateSelection()
370
+ },
371
+ {
372
+ key: "copy-style",
373
+ label: "复制样式",
374
+ enabled: m.value,
375
+ title: !m.value && S.value ? "行模板替身无样式可复制" : void 0,
376
+ run: () => {
377
+ let e = l.value;
378
+ e && n.editor.copyStyle(e);
379
+ }
380
+ },
381
+ {
382
+ key: "paste-style",
383
+ label: "粘贴样式",
384
+ enabled: h.value,
385
+ title: h.value ? void 0 : s,
386
+ run: () => {
387
+ let e = l.value;
388
+ e && n.editor.pasteStyle(e);
389
+ }
390
+ },
391
+ {
392
+ key: "forward",
393
+ label: "前移一层",
394
+ enabled: f.value,
395
+ title: f.value ? void 0 : "前移/后移仅对根图层生效",
396
+ run: () => n.editor.bringForward()
397
+ },
398
+ {
399
+ key: "backward",
400
+ label: "后移一层",
401
+ enabled: f.value,
402
+ title: f.value ? void 0 : "前移/后移仅对根图层生效",
403
+ run: () => n.editor.sendBackward()
404
+ },
405
+ {
406
+ key: "front",
407
+ label: "置顶",
408
+ enabled: f.value,
409
+ title: f.value ? void 0 : "置顶/置底仅对根图层生效",
410
+ run: () => n.editor.bringToFront()
411
+ },
412
+ {
413
+ key: "back",
414
+ label: "置底",
415
+ enabled: f.value,
416
+ title: f.value ? void 0 : "置顶/置底仅对根图层生效",
417
+ run: () => n.editor.sendToBack()
418
+ },
419
+ ...x.value ? [{
420
+ key: "to-rows",
421
+ label: "转回普通表",
422
+ enabled: !0,
423
+ title: "行模板实例化为单行,恢复普通表格编辑",
424
+ run: () => {
425
+ let e = b();
426
+ e && n.editor.convertTableToRows(e);
427
+ }
428
+ }] : y.value?.type === "TableLayer" ? [{
429
+ key: "to-template",
430
+ label: "转为模板表…",
431
+ enabled: D.value,
432
+ title: D.value ? j.value : y.value.rows.length === 0 ? "空表无可转换行" : "末行为空——先为末行加格",
433
+ keepsOpen: !0,
434
+ run: () => R()
435
+ }] : [],
436
+ {
437
+ key: "delete",
438
+ label: "删除",
439
+ enabled: l.value !== null && !S.value && !w.value,
440
+ title: S.value ? "行模板由表持有——转换回普通表请用 V2 转换入口" : w.value ? c : void 0,
441
+ run: () => {
442
+ let e = l.value;
443
+ e && n.editor.deleteLayer(e);
444
+ }
445
+ }
446
+ ]);
447
+ async function G(e, t) {
448
+ a.value = {
449
+ x: e,
450
+ y: t
451
+ }, i.value = !0, await P();
452
+ let n = r.value, o = n?.parentElement;
453
+ if (!n || !o) return;
454
+ let s = n.getBoundingClientRect(), c = o.clientWidth - s.width - 2, l = o.clientHeight - s.height - 2;
455
+ a.value = {
456
+ x: Math.max(2, Math.min(a.value.x, c)),
457
+ y: Math.max(2, Math.min(a.value.y, l))
458
+ };
459
+ }
460
+ function K() {
461
+ i.value = !1, M.value = !1, N.value = "", L.value = !1;
462
+ }
463
+ function q(e) {
464
+ e.run(), e.keepsOpen !== !0 && K();
465
+ }
466
+ return t({
467
+ openAt: G,
468
+ close: K
469
+ }), (e, t) => i.value ? (B(), k("div", {
470
+ key: 0,
471
+ ref_key: "rootRef",
472
+ ref: r,
473
+ class: "cn-context-menu",
474
+ role: "menu",
475
+ "aria-label": "图层操作菜单",
476
+ style: I({
477
+ left: `${a.value.x}px`,
478
+ top: `${a.value.y}px`
479
+ }),
480
+ onPointerdown: t[1] ||= X(() => {}, ["stop"]),
481
+ onContextmenu: t[2] ||= X(() => {}, ["prevent"])
482
+ }, [M.value ? (B(), k("div", xe, [
483
+ A("p", Se, W(j.value), 1),
484
+ J(A("input", {
485
+ "onUpdate:modelValue": t[0] ||= (e) => N.value = e,
486
+ "data-convert-rows-path": "",
487
+ type: "text",
488
+ placeholder: "数据行路径,如 order.items",
489
+ class: F(["cn-context-menu__input", { "cn-context-menu__input--invalid": L.value }]),
490
+ onKeydown: Y(X(z, ["prevent"]), ["enter"])
491
+ }, null, 42, Ce), [[ee, N.value]]),
492
+ L.value ? (B(), k("p", we, " rowsPath 必填 ")) : O("", !0),
493
+ A("div", { class: "cn-context-menu__form-actions" }, [A("button", {
494
+ type: "button",
495
+ class: "cn-context-menu__item cn-context-menu__item--confirm",
496
+ onClick: z
497
+ }, " 确认转换 "), A("button", {
498
+ type: "button",
499
+ class: "cn-context-menu__item",
500
+ onClick: K
501
+ }, "取消")])
502
+ ])) : (B(!0), k(T, { key: 1 }, H(U.value, (e) => (B(), k("button", {
503
+ key: e.key,
504
+ type: "button",
505
+ role: "menuitem",
506
+ class: F(["cn-context-menu__item", [`cn-context-menu__item--${e.key}`]]),
507
+ disabled: !e.enabled,
508
+ title: e.title,
509
+ onClick: (t) => q(e)
510
+ }, W(e.label), 11, Te))), 128))], 36)) : O("", !0);
511
+ }
512
+ }), [["__scopeId", "data-v-e554ef38"]]);
513
+ //#endregion
514
+ //#region src/canvas/useFindSession.ts
515
+ function De(e) {
516
+ let t = U(e.store.ui.find.open), n = U(e.store.ui.find.query), r = U(e.store.ui.find.replacement), i = U(e.listFindMatches()), a = U(e.findCursor), o = () => {
517
+ let o = e.store.ui.find;
518
+ t.value = o.open, n.value = o.query, r.value = o.replacement, i.value = e.listFindMatches(), a.value = e.findCursor;
519
+ }, s = e.subscribe((e) => {
520
+ (e.scope === "doc" || e.scope === "ui" && e.branch === "find") && o();
521
+ });
522
+ return z(s, !0), {
523
+ open: t,
524
+ query: n,
525
+ replacement: r,
526
+ matches: i,
527
+ cursor: a
528
+ };
529
+ }
530
+ //#endregion
531
+ //#region src/canvas/FindBar.vue?vue&type=script&setup=true&lang.ts
532
+ var Oe = ["value"], ke = ["value"], Ae = {
533
+ class: "cn-find-bar__count",
534
+ "data-find-count": ""
535
+ }, je = {
536
+ key: 0,
537
+ class: "cn-find-bar__note",
538
+ "data-find-note": ""
539
+ }, Me = ["disabled"], Ne = ["disabled"], Pe = ["disabled"], Fe = ["disabled"], Ie = /*#__PURE__*/ m(/* @__PURE__ */ M({
540
+ __name: "FindBar",
541
+ props: { editor: {} },
542
+ setup(e, { expose: t }) {
543
+ let n = e, { open: r, query: i, replacement: a, matches: o, cursor: c } = De(n.editor), l = V(null), u = V(null), d = E(() => {
544
+ let e = o.value.length;
545
+ return e === 0 ? i.value === "" ? "" : "无结果" : `第 ${c.value + 1}/${e} 处`;
546
+ }), p = E(() => o.value.length > 0), m = E(() => p.value && c.value > 0), g = E(() => p.value && c.value < o.value.length - 1);
547
+ function _(e) {
548
+ let t = o.value[e];
549
+ if (!t) return;
550
+ n.editor.setSelection(t.path);
551
+ let r = n.editor.layerBoxAt(t.path);
552
+ r && n.editor.panToBox(r);
553
+ }
554
+ function v(e) {
555
+ let t = o.value.length;
556
+ if (t === 0) return;
557
+ let r = Math.min(Math.max(c.value + e, 0), t - 1);
558
+ n.editor.setFindCursor(r), _(r);
559
+ }
560
+ function y() {
561
+ n.editor.replaceOne() && _(c.value);
562
+ }
563
+ function b() {
564
+ let e = n.editor.replaceAll();
565
+ e !== 0 && (u.value = `已替换 ${e} 处`, _(c.value));
566
+ }
567
+ function x() {
568
+ n.editor.closeFind(), u.value = null;
569
+ }
570
+ function S(e) {
571
+ if (!(e.isComposing || e.keyCode === 229)) {
572
+ if (e.key === "Escape") {
573
+ e.preventDefault(), x();
574
+ return;
575
+ }
576
+ e.key === "Enter" && (e.preventDefault(), v(e.shiftKey ? -1 : 1));
577
+ }
578
+ }
579
+ function C(e) {
580
+ n.editor.setFindQuery(e.target.value);
581
+ }
582
+ function w(e) {
583
+ n.editor.setFindReplacement(e.target.value);
584
+ }
585
+ q(r, (e) => {
586
+ e && l.value?.focus({ preventScroll: !0 });
587
+ }, {
588
+ immediate: !0,
589
+ flush: "post"
590
+ });
591
+ function T(e) {
592
+ r.value && (e.key.toLowerCase() !== "f" || !(e.metaKey || e.ctrlKey) || e.shiftKey || e.altKey || h(e.target) || l.value?.focus({ preventScroll: !0 }));
593
+ }
594
+ return window.addEventListener("keydown", T), L(() => window.removeEventListener("keydown", T)), q(i, () => {
595
+ u.value = null;
596
+ }), t({ close: x }), (e, t) => G(r) ? (B(), k("div", {
597
+ key: 0,
598
+ class: "cn-find-bar",
599
+ "data-find-bar": "",
600
+ role: "search",
601
+ "aria-label": "查找替换",
602
+ onPointerdown: t[2] ||= X(() => {}, ["stop"])
603
+ }, [
604
+ A("input", {
605
+ ref_key: "queryInput",
606
+ ref: l,
607
+ class: "cn-find-bar__input",
608
+ "data-find-query": "",
609
+ type: "text",
610
+ value: G(i),
611
+ placeholder: "查找",
612
+ "aria-label": "查找",
613
+ spellcheck: "false",
614
+ autocomplete: "off",
615
+ onInput: C,
616
+ onKeydown: S
617
+ }, null, 40, Oe),
618
+ A("input", {
619
+ class: "cn-find-bar__input",
620
+ "data-find-replace": "",
621
+ type: "text",
622
+ value: G(a),
623
+ placeholder: "替换",
624
+ "aria-label": "替换",
625
+ spellcheck: "false",
626
+ autocomplete: "off",
627
+ onInput: w,
628
+ onKeydown: S
629
+ }, null, 40, ke),
630
+ A("span", Ae, W(d.value), 1),
631
+ u.value ? (B(), k("span", je, W(u.value), 1)) : O("", !0),
632
+ A("button", {
633
+ type: "button",
634
+ class: "cn-find-bar__key",
635
+ "data-find-prev": "",
636
+ disabled: !m.value,
637
+ title: "上一处(Shift+Enter)",
638
+ "aria-label": "上一处",
639
+ onClick: t[0] ||= (e) => v(-1)
640
+ }, [j(f, { icon: G(ie) }, null, 8, ["icon"])], 8, Me),
641
+ A("button", {
642
+ type: "button",
643
+ class: "cn-find-bar__key",
644
+ "data-find-next": "",
645
+ disabled: !g.value,
646
+ title: "下一处(Enter)",
647
+ "aria-label": "下一处",
648
+ onClick: t[1] ||= (e) => v(1)
649
+ }, [j(f, { icon: G(s) }, null, 8, ["icon"])], 8, Ne),
650
+ A("button", {
651
+ type: "button",
652
+ class: "cn-find-bar__action",
653
+ "data-find-replace-one": "",
654
+ disabled: !p.value,
655
+ title: "替换当前处",
656
+ onClick: y
657
+ }, " 替换 ", 8, Pe),
658
+ A("button", {
659
+ type: "button",
660
+ class: "cn-find-bar__action",
661
+ "data-find-replace-all": "",
662
+ disabled: !p.value,
663
+ title: "全部替换",
664
+ onClick: b
665
+ }, " 全部替换 ", 8, Fe)
666
+ ], 32)) : O("", !0);
667
+ }
668
+ }), [["__scopeId", "data-v-e9f0e575"]]), Le = {
669
+ nw: "nwse-resize",
670
+ se: "nwse-resize",
671
+ ne: "nesw-resize",
672
+ sw: "nesw-resize",
673
+ n: "ns-resize",
674
+ s: "ns-resize",
675
+ e: "ew-resize",
676
+ w: "ew-resize"
677
+ }, Re = [
678
+ "aria-pressed",
679
+ "data-pill-static",
680
+ "data-pill-expression",
681
+ "onClick"
682
+ ], ze = /*#__PURE__*/ m(/* @__PURE__ */ M({
683
+ __name: "ContentTypePill",
684
+ props: { mode: {} },
685
+ emits: ["change"],
686
+ setup(e, { expose: t, emit: n }) {
687
+ let r = e, i = n, a = V(null);
688
+ t({ rootEl: a });
689
+ let o = [{
690
+ value: "static",
691
+ label: "静态"
692
+ }, {
693
+ value: "expression",
694
+ label: "表达式"
695
+ }];
696
+ function s(e) {
697
+ e !== r.mode && i("change", e);
698
+ }
699
+ return (t, n) => (B(), k("div", {
700
+ ref_key: "rootRef",
701
+ ref: a,
702
+ class: "cn-content-pill",
703
+ role: "group",
704
+ "aria-label": "内容类型",
705
+ "data-content-pill": "",
706
+ onPointerdown: n[0] ||= X(() => {}, ["prevent"])
707
+ }, [(B(), k(T, null, H(o, (t) => A("button", {
708
+ key: t.value,
709
+ type: "button",
710
+ class: F(["cn-content-pill__item", { "cn-content-pill__item--active": t.value === e.mode }]),
711
+ "aria-pressed": t.value === e.mode,
712
+ "data-pill-static": t.value === "static" || void 0,
713
+ "data-pill-expression": t.value === "expression" || void 0,
714
+ onClick: (e) => s(t.value)
715
+ }, W(t.label), 11, Re)), 64))], 544));
716
+ }
717
+ }), [["__scopeId", "data-v-d99d2c13"]]);
718
+ //#endregion
719
+ //#region src/canvas/useDpr.ts
720
+ function $(e) {
721
+ let t = null, n = () => {
722
+ t?.removeEventListener("change", n), e(window.devicePixelRatio || 1), t = window.matchMedia(`(resolution: ${window.devicePixelRatio}dppx)`), t.addEventListener("change", n);
723
+ };
724
+ return n(), () => t?.removeEventListener("change", n);
725
+ }
726
+ function Be() {
727
+ let e = U(window.devicePixelRatio || 1), t = $((t) => {
728
+ e.value = t;
729
+ });
730
+ return z(t, !0), e;
731
+ }
732
+ //#endregion
733
+ //#region src/canvas/useTextEditing.ts
734
+ var Ve = /* @__PURE__ */ new Map();
735
+ function He(e, t) {
736
+ let n = `${e}|${t}`, r = Ve.get(n);
737
+ if (r !== void 0) return r;
738
+ let i = t * 1.2;
739
+ try {
740
+ let n = document.createElement("canvas").getContext("2d");
741
+ if (n) {
742
+ n.font = `${t}px ${me(e)}`;
743
+ let r = n.measureText("字"), a = (r.fontBoundingBoxAscent ?? r.actualBoundingBoxAscent) + (r.fontBoundingBoxDescent ?? r.actualBoundingBoxDescent);
744
+ a > 0 && (i = a);
745
+ }
746
+ } catch {}
747
+ return Ve.set(n, i), i;
748
+ }
749
+ function Ue(e, t) {
750
+ let n = U(e.store.ui.editing), r = e.subscribe((t) => {
751
+ (t.scope === "doc" || t.scope === "ui" && t.branch === "editing") && (n.value = e.store.ui.editing);
752
+ });
753
+ z(r, !0);
754
+ let i = E(() => n.value?.path ?? null), a = Be(), o = w(e), s = E(() => {
755
+ let t = n.value;
756
+ return t ? e.textEditLayout(t.path) : null;
757
+ }), c = E(() => ae(o.value, a.value));
758
+ function l(e, t) {
759
+ let { x: n, y: r, zoom: i } = c.value;
760
+ return {
761
+ left: (e - n) * i,
762
+ top: (t - r) * i,
763
+ zoom: i
764
+ };
765
+ }
766
+ let u = E(() => {
767
+ let e = s.value;
768
+ if (!e) return null;
769
+ let { left: t, top: n, zoom: r } = l(e.box.x, e.box.y);
770
+ return {
771
+ transform: `translate(${t}px, ${n}px) scale(${r})`,
772
+ transformOrigin: "0 0",
773
+ width: `${e.box.width}px`,
774
+ height: `${e.box.height}px`,
775
+ color: e.fontColor,
776
+ fontFamily: me(e.font),
777
+ fontSize: `${e.fontSize}px`,
778
+ lineHeight: `${e.lineHeightPx}px`,
779
+ ...f(e),
780
+ textAlign: e.horizontalAlign,
781
+ whiteSpace: e.autowrap ? "pre-wrap" : "pre"
782
+ };
783
+ }), d = E(() => {
784
+ let e = s.value;
785
+ if (!e) return null;
786
+ let { left: t, top: n, zoom: r } = l(e.box.x + e.box.width / 2, e.box.y);
787
+ return {
788
+ transform: `translate(${t}px, ${n}px) scale(${r}) translate(-50%, -100%)`,
789
+ transformOrigin: "0 0"
790
+ };
791
+ });
792
+ function f(e) {
793
+ let t = e.padding.top + e.verticalAnchorY, n = e.lineHeightPx, r = He(e.font, e.fontSize), i;
794
+ return i = e.verticalAlign === "center" ? t - n / 2 : e.verticalAlign === "bottom" ? t - (n + r) / 2 : t - (n - r) / 2, {
795
+ paddingTop: `${Math.max(0, i)}px`,
796
+ paddingRight: `${e.padding.right}px`,
797
+ paddingBottom: `${e.padding.bottom}px`,
798
+ paddingLeft: `${e.padding.left}px`
799
+ };
800
+ }
801
+ let p = (t, n) => {
802
+ let r = e.hitTest(t, n);
803
+ return r !== null && e.beginTextEdit(r);
804
+ }, m = (t) => e.beginTextEdit(t), h = (t) => {
805
+ let n = e.store.ui.editing;
806
+ n && n.expression !== t && e.store.setEditing({
807
+ path: n.path,
808
+ expression: t
809
+ });
810
+ }, g = null, _ = !1, v = !1, y = () => {
811
+ e.commitTextEdit(t.getTextarea()?.value ?? "");
812
+ }, b = () => {
813
+ g !== null && clearTimeout(g), g = null;
814
+ }, x = () => {
815
+ if (b(), S.value) {
816
+ v = !0;
817
+ return;
818
+ }
819
+ y();
820
+ }, S = U(!1), C = (e) => {
821
+ S.value = e, !e && v && (v = !1, i.value !== null && y());
822
+ }, T = () => {
823
+ if (i.value !== null) {
824
+ if (b(), _) {
825
+ _ = !1;
826
+ return;
827
+ }
828
+ g = setTimeout(() => {
829
+ g = null;
830
+ let e = t.getTextarea();
831
+ if (e === null || document.activeElement !== e) {
832
+ if (S.value) {
833
+ v = !0;
834
+ return;
835
+ }
836
+ y();
837
+ }
838
+ }, 0);
839
+ }
840
+ }, D = (e) => {
841
+ if (!(e instanceof Node)) return !1;
842
+ let n = t.getPill?.() ?? null;
843
+ if (n !== null && n.contains(e)) return !0;
844
+ let r = t.getTextarea();
845
+ return r !== null && r.contains(e);
846
+ }, O = (e) => {
847
+ if (i.value === null || D(e.target)) return;
848
+ let n = t.getHost();
849
+ n !== null && n.contains(e.target) || (_ = !0);
850
+ }, k = () => {
851
+ _ = !1;
852
+ };
853
+ return window.addEventListener("pointerdown", O, !0), window.addEventListener("pointerup", k, !0), z(() => {
854
+ window.removeEventListener("pointerdown", O, !0), window.removeEventListener("pointerup", k, !0), b();
855
+ }, !0), {
856
+ editing: i,
857
+ layout: s,
858
+ style: u,
859
+ pillStyle: d,
860
+ scale: E(() => c.value.zoom),
861
+ composing: E(() => S.value),
862
+ setComposing: C,
863
+ beginAt: p,
864
+ beginTextEdit: m,
865
+ commitNow: x,
866
+ setExpressionMode: h,
867
+ armBlurCommit: T,
868
+ ownsEventTarget: D
869
+ };
870
+ }
871
+ //#endregion
872
+ //#region src/canvas/TextEditingOverlay.vue?vue&type=script&setup=true&lang.ts
873
+ var We = ["wrap"], Ge = /*#__PURE__*/ m(/* @__PURE__ */ M({
874
+ __name: "TextEditingOverlay",
875
+ props: { editor: {} },
876
+ setup(e, { expose: t }) {
877
+ let n = e, r = V(null), i = V(null), a = V(null), o = V(null), s = Ue(n.editor, {
878
+ getTextarea: () => i.value,
879
+ getHost: () => r.value?.parentElement ?? null,
880
+ getPill: () => a.value?.rootEl ?? null
881
+ }), { editing: c, style: l, composing: u, pillStyle: d } = s, f = s.layout, m = E(() => f.value?.expressionMode === !0), { popup: h, accept: g } = b({
882
+ target: i,
883
+ enabled: m,
884
+ resolve: (e) => {
885
+ let t = n.editor.store.ui.dataSourceSchema, r = c.value;
886
+ if (t === null || r === null) return null;
887
+ let i = x(t, y(t, n.editor.store.doc, r));
888
+ return i === null ? null : i(e);
889
+ },
890
+ popupEl: () => o.value?.rootEl ?? null,
891
+ scale: s.scale
892
+ });
893
+ q(c, async (e) => {
894
+ if (!e) return;
895
+ await P();
896
+ let t = i.value, n = s.layout.value;
897
+ t && n && (t.value = n.text, t.focus({ preventScroll: !0 }), t.select());
898
+ }), q(l, async (e, t) => {
899
+ if (!t || !e) return;
900
+ let n = i.value;
901
+ if (!n || u.value) return;
902
+ let r = n.selectionStart, a = n.selectionEnd;
903
+ await P(), i.value === n && (n.selectionStart !== r || n.selectionEnd !== a) && n.setSelectionRange(r, a);
904
+ }, { flush: "post" });
905
+ let _ = (e) => {
906
+ e.isComposing || e.keyCode === 229 || (e.key === "Escape" || e.key === "Enter" && (e.ctrlKey || e.metaKey)) && (e.key === "Escape" && h.open || (e.preventDefault(), s.commitNow()));
907
+ }, v = () => s.armBlurCommit();
908
+ return t({
909
+ beginAt: s.beginAt,
910
+ beginTextEdit: s.beginTextEdit,
911
+ commitEditing: () => s.commitNow(),
912
+ isEditing: () => c.value !== null,
913
+ ownsEventTarget: (e) => s.ownsEventTarget(e)
914
+ }), (e, t) => (B(), k("div", {
915
+ ref_key: "rootRef",
916
+ ref: r,
917
+ class: "cn-text-overlay"
918
+ }, [
919
+ G(c) && G(l) ? (B(), k("textarea", {
920
+ key: G(c).join(""),
921
+ ref_key: "textareaRef",
922
+ ref: i,
923
+ class: "cn-text-overlay__textarea",
924
+ style: I(G(l)),
925
+ wrap: G(l).whiteSpace === "pre" ? "off" : "soft",
926
+ spellcheck: "false",
927
+ autocomplete: "off",
928
+ onKeydown: _,
929
+ onBlur: v,
930
+ onCompositionstart: t[0] ||= (e) => G(s).setComposing(!0),
931
+ onCompositionend: t[1] ||= (e) => G(s).setComposing(!1)
932
+ }, null, 44, We)) : O("", !0),
933
+ G(c) && G(d) ? (B(), D(ze, {
934
+ key: 1,
935
+ ref_key: "pillRef",
936
+ ref: a,
937
+ style: I(G(d)),
938
+ mode: m.value ? "expression" : "static",
939
+ onChange: t[2] ||= (e) => G(s).setExpressionMode(e === "expression")
940
+ }, null, 8, ["style", "mode"])) : O("", !0),
941
+ j(p, {
942
+ ref_key: "popupRef",
943
+ ref: o,
944
+ state: G(h),
945
+ onSelect: G(g)
946
+ }, null, 8, ["state", "onSelect"])
947
+ ], 512));
948
+ }
949
+ }), [["__scopeId", "data-v-bc9281f8"]]), Ke = {
950
+ key: 0,
951
+ class: "cn-surface__drop-hint",
952
+ "data-drop-hint": ""
953
+ }, qe = 16, Je = /*#__PURE__*/ m(/* @__PURE__ */ M({
954
+ __name: "CanvasSurface",
955
+ props: { editor: {} },
956
+ emits: ["ready"],
957
+ setup(e, { emit: t }) {
958
+ let n = e, r = t, i = V(null), a = V(null), o = V(null), s = V(null), c = V(null), l = V(null), u = V(!1), d = V(!1), f = V(null), p = V(null), m = V(n.editor.store.ui.armedCreate), g = V(!1), _ = E(() => d.value ? "cn-surface--panning" : u.value ? "cn-surface--pannable" : ""), y = E(() => {
959
+ if (d.value) return;
960
+ if (m.value !== null || g.value) return u.value ? void 0 : { cursor: "crosshair" };
961
+ let e = p.value ?? f.value;
962
+ return e === null ? void 0 : { cursor: Le[e] };
963
+ }), b = V(!1), x = v();
964
+ function C(e) {
965
+ return new Promise((t, n) => {
966
+ let r = URL.createObjectURL(e), i = new Image();
967
+ i.onload = () => {
968
+ URL.revokeObjectURL(r), t({
969
+ width: i.naturalWidth,
970
+ height: i.naturalHeight
971
+ });
972
+ }, i.onerror = () => {
973
+ URL.revokeObjectURL(r), n(/* @__PURE__ */ Error(`无法解码图片:${e.name}`));
974
+ }, i.src = r;
975
+ });
976
+ }
977
+ let w = [];
978
+ return R(() => {
979
+ let e = i.value, t = a.value, _ = o.value;
980
+ if (!e || !t || !_) return;
981
+ let v = n.editor, y = () => {
982
+ let n = window.devicePixelRatio, r = Math.max(1, Math.round(e.clientWidth * n)), i = Math.max(1, Math.round(e.clientHeight * n));
983
+ for (let e of [t, _]) e.width !== r && (e.width = r), e.height !== i && (e.height = i);
984
+ v.flushPendingFrames();
985
+ }, T = () => {
986
+ v.setSurfaceSize(e.clientWidth, e.clientHeight), y();
987
+ };
988
+ v.setDevicePixelRatio(window.devicePixelRatio), T();
989
+ let E = v.subscribe((e) => {
990
+ (e.scope === "doc" || e.scope === "ui" && e.branch === "armedCreate") && (m.value = v.store.ui.armedCreate);
991
+ });
992
+ w.push(E);
993
+ let D = new ResizeObserver(T);
994
+ D.observe(e), w.push(() => D.disconnect());
995
+ let O = $(() => {
996
+ v.setDevicePixelRatio(window.devicePixelRatio), y();
997
+ });
998
+ w.push(O);
999
+ let k = (t) => {
1000
+ let n = e.getBoundingClientRect();
1001
+ return {
1002
+ x: t.clientX - n.left,
1003
+ y: t.clientY - n.top
1004
+ };
1005
+ }, A = (e) => e.deltaMode === 1 ? 16 : e.deltaMode === 2 ? 100 : 1, j = (e) => {
1006
+ e.preventDefault();
1007
+ let t = A(e), n = k(e), r = fe(e);
1008
+ r === "zoom" ? v.zoomByWheel(n.x, n.y, e.deltaY * t) : r === "pan-x" ? v.panBy(-(e.deltaY || e.deltaX) * t, 0) : v.panBy(-e.deltaX * t, -e.deltaY * t);
1009
+ };
1010
+ e.addEventListener("wheel", j, { passive: !1 }), w.push(() => e.removeEventListener("wheel", j));
1011
+ let M = null, N = {
1012
+ x: 0,
1013
+ y: 0
1014
+ }, P = (e) => {
1015
+ let t = k(e);
1016
+ return v.toScenePoint(t.x, t.y);
1017
+ }, F = (t) => {
1018
+ if (c.value?.close(), M !== null) return;
1019
+ if (t.button === 1 || t.button === 0 && u.value) {
1020
+ t.preventDefault(), M = {
1021
+ id: t.pointerId,
1022
+ mode: "pan"
1023
+ }, N = {
1024
+ x: t.clientX,
1025
+ y: t.clientY
1026
+ }, d.value = !0, e.setPointerCapture(t.pointerId);
1027
+ return;
1028
+ }
1029
+ if (t.button !== 0) return;
1030
+ if (s.value?.isEditing()) {
1031
+ if (s.value.ownsEventTarget(t.target)) return;
1032
+ s.value.commitEditing();
1033
+ }
1034
+ t.preventDefault();
1035
+ let n = P(t);
1036
+ if (v.beginLayerCreate(n.x, n.y)) {
1037
+ M = {
1038
+ id: t.pointerId,
1039
+ mode: "create"
1040
+ }, g.value = !0, f.value = null, e.setPointerCapture(t.pointerId);
1041
+ return;
1042
+ }
1043
+ let r = v.resizeHandleAt(n.x, n.y);
1044
+ if (r !== null && v.beginResize(v.store.ui.selection, r, n.x, n.y)) {
1045
+ M = {
1046
+ id: t.pointerId,
1047
+ mode: "resize"
1048
+ }, p.value = r, f.value = null, e.setPointerCapture(t.pointerId);
1049
+ return;
1050
+ }
1051
+ let i = P(t), a = v.selectAt(i.x, i.y);
1052
+ if (a && v.beginDrag(a, i.x, i.y, { copy: t.altKey && v.canCopyLayerAt(a) })) {
1053
+ M = {
1054
+ id: t.pointerId,
1055
+ mode: "drag"
1056
+ }, e.setPointerCapture(t.pointerId);
1057
+ return;
1058
+ }
1059
+ a === null && (M = {
1060
+ id: t.pointerId,
1061
+ mode: "pan"
1062
+ }, N = {
1063
+ x: t.clientX,
1064
+ y: t.clientY
1065
+ }, d.value = !0, e.setPointerCapture(t.pointerId));
1066
+ }, I = (e) => {
1067
+ if (M !== null) {
1068
+ if (e.pointerId !== M.id) return;
1069
+ if (M.mode === "pan") v.panBy(e.clientX - N.x, e.clientY - N.y), N = {
1070
+ x: e.clientX,
1071
+ y: e.clientY
1072
+ };
1073
+ else if (M.mode === "resize") {
1074
+ let t = P(e);
1075
+ v.resizeTo(t.x, t.y);
1076
+ } else if (M.mode === "create") {
1077
+ let t = P(e);
1078
+ v.createTo(t.x, t.y);
1079
+ } else {
1080
+ let t = P(e);
1081
+ v.dragTo(t.x, t.y);
1082
+ }
1083
+ return;
1084
+ }
1085
+ let t = P(e), n = v.resizeHandleAt(t.x, t.y);
1086
+ if (f.value = n, n !== null) {
1087
+ v.setHovered(null);
1088
+ return;
1089
+ }
1090
+ v.hoverAt(t.x, t.y);
1091
+ }, L = (t) => {
1092
+ if (M !== null && t.pointerId === M.id) {
1093
+ if (M.mode === "drag") v.endDrag();
1094
+ else if (M.mode === "resize") v.endResize(), p.value = null;
1095
+ else if (M.mode === "create") {
1096
+ g.value = !1;
1097
+ let e = v.endCreate();
1098
+ e !== null && s.value?.beginTextEdit(e);
1099
+ } else d.value = !1;
1100
+ M = null, e.hasPointerCapture(t.pointerId) && e.releasePointerCapture(t.pointerId);
1101
+ }
1102
+ }, R = (e) => {
1103
+ e.button === 1 && e.preventDefault();
1104
+ }, z = (e) => {
1105
+ let t = k(e), n = v.toScenePoint(t.x, t.y);
1106
+ s.value?.beginAt(n.x, n.y);
1107
+ }, B = (e) => {
1108
+ if (s.value?.isEditing()) {
1109
+ if (s.value.ownsEventTarget(e.target)) return;
1110
+ s.value.commitEditing();
1111
+ }
1112
+ e.preventDefault();
1113
+ let t = k(e), n = v.toScenePoint(t.x, t.y);
1114
+ if (v.selectAt(n.x, n.y) === null) {
1115
+ c.value?.close();
1116
+ return;
1117
+ }
1118
+ c.value?.openAt(t.x, t.y);
1119
+ }, V = () => {
1120
+ M === null && (v.setHovered(null), f.value = null);
1121
+ };
1122
+ e.addEventListener("pointerdown", F), e.addEventListener("pointermove", I), e.addEventListener("pointerup", L), e.addEventListener("pointercancel", L), e.addEventListener("pointerleave", V), e.addEventListener("mousedown", R), e.addEventListener("dblclick", z), w.push(() => {
1123
+ e.removeEventListener("pointerdown", F), e.removeEventListener("pointermove", I), e.removeEventListener("pointerup", L), e.removeEventListener("pointercancel", L), e.removeEventListener("pointerleave", V), e.removeEventListener("mousedown", R), e.removeEventListener("dblclick", z);
1124
+ });
1125
+ let H = h, U = (e) => {
1126
+ e.code !== "Space" || e.repeat || H(e.target) || (e.preventDefault(), u.value = !0);
1127
+ }, W = (e) => {
1128
+ e.code === "Space" && (u.value = !1);
1129
+ }, G = (e) => {
1130
+ if (!(e.key !== "Escape" || h(e.target))) {
1131
+ if (v.store.ui.armedCreate !== null || v.store.ui.create !== null) {
1132
+ v.cancelCreate();
1133
+ return;
1134
+ }
1135
+ c.value?.close(), l.value?.close(), v.escapeSelection();
1136
+ }
1137
+ };
1138
+ window.addEventListener("keydown", U), window.addEventListener("keyup", W), window.addEventListener("keydown", G), w.push(() => {
1139
+ window.removeEventListener("keydown", U), window.removeEventListener("keyup", W), window.removeEventListener("keydown", G);
1140
+ }), e.addEventListener("contextmenu", B), w.push(() => e.removeEventListener("contextmenu", B));
1141
+ let ee = (e) => {
1142
+ let t = e.dataTransfer?.items;
1143
+ if (!t) return !1;
1144
+ for (let e = 0; e < t.length; e += 1) {
1145
+ let n = t[e];
1146
+ if (n !== void 0 && n.kind === "file" && n.type.startsWith("image/")) return !0;
1147
+ }
1148
+ return !1;
1149
+ }, K = (e) => {
1150
+ ee(e) && (e.preventDefault(), e.dataTransfer && (e.dataTransfer.dropEffect = "copy"), b.value = !0);
1151
+ }, q = (t) => {
1152
+ t.relatedTarget !== null && e.contains(t.relatedTarget) || (b.value = !1);
1153
+ }, J = (e) => {
1154
+ e.preventDefault(), b.value = !1;
1155
+ let t = [], n = e.dataTransfer?.files;
1156
+ for (let e = 0; n !== void 0 && e < n.length; e += 1) {
1157
+ let r = n[e];
1158
+ r !== void 0 && r.type.startsWith("image/") && t.push(r);
1159
+ }
1160
+ if (t.length !== 0) {
1161
+ if (!v.canUpload) {
1162
+ x.show("上传不可用:未接入上传实现,图片未添加");
1163
+ return;
1164
+ }
1165
+ s.value?.isEditing() && s.value.commitEditing(), Y(t, k(e));
1166
+ }
1167
+ }, Y = async (e, t) => {
1168
+ let n = v.toScenePoint(t.x, t.y);
1169
+ for (let t = 0; t < e.length; t += 1) {
1170
+ let r = e[t];
1171
+ if (r) try {
1172
+ let e = await C(r);
1173
+ await v.uploadImageAsLayer(await S(r), {
1174
+ at: {
1175
+ x: n.x + t * qe,
1176
+ y: n.y + t * qe
1177
+ },
1178
+ size: e
1179
+ });
1180
+ } catch (e) {
1181
+ x.show(`上传失败:${e instanceof Error ? e.message : String(e)}`);
1182
+ return;
1183
+ }
1184
+ }
1185
+ };
1186
+ e.addEventListener("dragover", K), e.addEventListener("dragleave", q), e.addEventListener("drop", J), w.push(() => {
1187
+ e.removeEventListener("dragover", K), e.removeEventListener("dragleave", q), e.removeEventListener("drop", J);
1188
+ });
1189
+ let X = () => v.invalidate("both"), Z = (e) => e.preventDefault();
1190
+ t.addEventListener("contextlost", Z), t.addEventListener("contextrestored", X), _.addEventListener("contextlost", Z), _.addEventListener("contextrestored", X), w.push(() => {
1191
+ t.removeEventListener("contextlost", Z), t.removeEventListener("contextrestored", X), _.removeEventListener("contextlost", Z), _.removeEventListener("contextrestored", X);
1192
+ }), r("ready", {
1193
+ contentCanvas: t,
1194
+ overlayCanvas: _
1195
+ });
1196
+ }), L(() => {
1197
+ w.forEach((e) => e()), w.length = 0, n.editor.detachSurfaces();
1198
+ }), (t, n) => (B(), k("div", {
1199
+ ref_key: "hostRef",
1200
+ ref: i,
1201
+ class: F(["cn-surface", _.value]),
1202
+ style: I(y.value)
1203
+ }, [
1204
+ A("canvas", {
1205
+ ref_key: "contentRef",
1206
+ ref: a,
1207
+ class: "cn-surface__canvas"
1208
+ }, null, 512),
1209
+ A("canvas", {
1210
+ ref_key: "overlayRef",
1211
+ ref: o,
1212
+ class: "cn-surface__canvas cn-surface__canvas--overlay"
1213
+ }, null, 512),
1214
+ j(Ge, {
1215
+ ref_key: "textEditRef",
1216
+ ref: s,
1217
+ editor: e.editor
1218
+ }, null, 8, ["editor"]),
1219
+ j(Ee, {
1220
+ ref_key: "contextMenuRef",
1221
+ ref: c,
1222
+ editor: e.editor
1223
+ }, null, 8, ["editor"]),
1224
+ j(Ie, {
1225
+ ref_key: "findBarRef",
1226
+ ref: l,
1227
+ editor: e.editor
1228
+ }, null, 8, ["editor"]),
1229
+ b.value ? (B(), k("div", Ke, [...n[0] ||= [A("span", { class: "cn-surface__drop-hint-text" }, "松开以上传图片", -1)]])) : O("", !0)
1230
+ ], 6));
1231
+ }
1232
+ }), [["__scopeId", "data-v-6e21095e"]]);
1233
+ //#endregion
1234
+ //#region src/canvas/guideSnap.ts
1235
+ function Ye(e, t, n) {
1236
+ let r = e.store.doc;
1237
+ if (!r) return n;
1238
+ let i = ue({
1239
+ x: n,
1240
+ y: n,
1241
+ width: 0,
1242
+ height: 0
1243
+ }, ce(r.width, r.height, se(r, -1, e.textPolicies), e.listGuides()), oe(e.store.ui.viewport.zoom));
1244
+ return t === "vertical" ? n + i.dx : n + i.dy;
1245
+ }
1246
+ //#endregion
1247
+ //#region src/canvas/GuidesOverlay.vue?vue&type=script&setup=true&lang.ts
1248
+ var Xe = [
1249
+ "data-snap-orientation",
1250
+ "data-snap-position",
1251
+ "data-snap-source"
1252
+ ], Ze = [
1253
+ "data-guide-line",
1254
+ "data-guide-orientation",
1255
+ "data-guide-position",
1256
+ "data-guide-dragging",
1257
+ "onPointerdown"
1258
+ ], Qe = ["data-guide-orientation", "data-guide-position"], $e = /*#__PURE__*/ m(/* @__PURE__ */ M({
1259
+ __name: "GuidesOverlay",
1260
+ props: { editor: {} },
1261
+ setup(e, { expose: t }) {
1262
+ let n = e, r = w(n.editor), i = U(n.editor.store.doc), a = U(n.editor.listGuides()), o = U(n.editor.listSnapAxes()), s = n.editor.subscribe((e) => {
1263
+ if (e.scope === "doc") {
1264
+ i.value = n.editor.store.doc, a.value = n.editor.listGuides(), o.value = n.editor.listSnapAxes();
1265
+ return;
1266
+ }
1267
+ e.branch === "guides" ? a.value = n.editor.listGuides() : e.branch === "snapAxes" && (o.value = n.editor.listSnapAxes());
1268
+ });
1269
+ z(s, !0);
1270
+ function c(e, t) {
1271
+ let n = i.value, a = r.value;
1272
+ return n ? e === "vertical" ? {
1273
+ left: `${(t - a.x) * a.zoom}px`,
1274
+ top: "0px",
1275
+ height: "100%"
1276
+ } : {
1277
+ top: `${(t - a.y) * a.zoom}px`,
1278
+ left: "0px",
1279
+ width: "100%"
1280
+ } : { display: "none" };
1281
+ }
1282
+ function l(e) {
1283
+ return String(Math.round(e * 100) / 100);
1284
+ }
1285
+ let u = V(null);
1286
+ function d(e) {
1287
+ return {
1288
+ orientation: e.orientation,
1289
+ position: Ye(n.editor, e.orientation, e.position)
1290
+ };
1291
+ }
1292
+ function f(e) {
1293
+ u.value = d(e);
1294
+ }
1295
+ function p(e) {
1296
+ u.value !== null && u.value.orientation === e.orientation && (u.value = d(e));
1297
+ }
1298
+ function m(e) {
1299
+ if (u.value === null) return;
1300
+ u.value = null;
1301
+ let { orientation: t, position: r } = d(e);
1302
+ n.editor.listGuides().some((e) => e.orientation === t && Math.abs(e.position - r) < 1e-6) || n.editor.addGuide({
1303
+ orientation: t,
1304
+ position: r
1305
+ });
1306
+ }
1307
+ function h() {
1308
+ u.value = null;
1309
+ }
1310
+ t({
1311
+ beginGuideDrag: f,
1312
+ moveGuideDrag: p,
1313
+ endGuideDrag: m,
1314
+ cancelGuideDrag: h
1315
+ });
1316
+ let g = V(null), _ = E(() => a.value.map((e) => {
1317
+ let t = g.value;
1318
+ return t !== null && t.id === e.id ? {
1319
+ id: e.id,
1320
+ orientation: e.orientation,
1321
+ position: t.current,
1322
+ dragging: !0,
1323
+ overRuler: t.overRuler
1324
+ } : {
1325
+ id: e.id,
1326
+ orientation: e.orientation,
1327
+ position: e.position,
1328
+ dragging: !1,
1329
+ overRuler: !1
1330
+ };
1331
+ })), v = V(null);
1332
+ function y(e, t) {
1333
+ let n = v.value?.getBoundingClientRect(), i = r.value, a = n?.left ?? 0, o = n?.top ?? 0;
1334
+ return t === "vertical" ? i.x + (e.clientX - a) / i.zoom : i.y + (e.clientY - o) / i.zoom;
1335
+ }
1336
+ function b(e, t) {
1337
+ let n = document.elementFromPoint(e, t);
1338
+ return n !== null && n.closest("[data-ruler-top], [data-ruler-left]") !== null;
1339
+ }
1340
+ function x(e) {
1341
+ try {
1342
+ e.currentTarget.setPointerCapture(e.pointerId);
1343
+ } catch {}
1344
+ }
1345
+ function S(e) {
1346
+ try {
1347
+ e.currentTarget.releasePointerCapture(e.pointerId);
1348
+ } catch {}
1349
+ }
1350
+ function C(e, t) {
1351
+ e.button === 0 && g.value === null && (e.preventDefault(), g.value = {
1352
+ id: t.id,
1353
+ orientation: t.orientation,
1354
+ pointerId: e.pointerId,
1355
+ current: t.position,
1356
+ overRuler: !1
1357
+ }, x(e));
1358
+ }
1359
+ function D(e) {
1360
+ let t = g.value;
1361
+ t !== null && e.pointerId === t.pointerId && (g.value = {
1362
+ ...t,
1363
+ current: y(e, t.orientation),
1364
+ overRuler: b(e.clientX, e.clientY)
1365
+ });
1366
+ }
1367
+ function A(e) {
1368
+ let t = g.value;
1369
+ t !== null && e.pointerId === t.pointerId && (g.value = null, S(e), b(e.clientX, e.clientY) && n.editor.removeGuide(t.id));
1370
+ }
1371
+ function j(e) {
1372
+ let t = g.value;
1373
+ t !== null && e.pointerId === t.pointerId && (g.value = null, S(e));
1374
+ }
1375
+ return (e, t) => (B(), k("div", {
1376
+ ref_key: "rootRef",
1377
+ ref: v,
1378
+ class: "cn-guides",
1379
+ "data-guide-overlay": ""
1380
+ }, [
1381
+ (B(!0), k(T, null, H(o.value, (e, t) => (B(), k("div", {
1382
+ key: `${e.orientation}-${e.position}-${t}`,
1383
+ class: F(["cn-guides__snap", `cn-guides__snap--${e.orientation}`]),
1384
+ "data-snap-line": "",
1385
+ "data-snap-orientation": e.orientation,
1386
+ "data-snap-position": l(e.position),
1387
+ "data-snap-source": e.source,
1388
+ style: I(c(e.orientation, e.position))
1389
+ }, null, 14, Xe))), 128)),
1390
+ (B(!0), k(T, null, H(_.value, (e) => (B(), k("div", {
1391
+ key: e.id,
1392
+ class: F(["cn-guides__guide", [`cn-guides__guide--${e.orientation}`, {
1393
+ "cn-guides__guide--grabbed": e.dragging,
1394
+ "cn-guides__guide--will-delete": e.overRuler
1395
+ }]]),
1396
+ "data-guide-line": e.id,
1397
+ "data-guide-orientation": e.orientation,
1398
+ "data-guide-position": l(e.position),
1399
+ "data-guide-dragging": e.dragging ? "" : void 0,
1400
+ style: I(c(e.orientation, e.position)),
1401
+ onPointerdown: (t) => C(t, e),
1402
+ onPointermove: D,
1403
+ onPointerup: A,
1404
+ onPointercancel: j
1405
+ }, null, 46, Ze))), 128)),
1406
+ u.value ? (B(), k("div", {
1407
+ key: 0,
1408
+ class: F(["cn-guides__guide cn-guides__guide--preview", `cn-guides__guide--${u.value.orientation}`]),
1409
+ "data-guide-preview": "",
1410
+ "data-guide-orientation": u.value.orientation,
1411
+ "data-guide-position": l(u.value.position),
1412
+ style: I(c(u.value.orientation, u.value.position))
1413
+ }, null, 14, Qe)) : O("", !0)
1414
+ ], 512));
1415
+ }
1416
+ }), [["__scopeId", "data-v-51fd929c"]]), et = {
1417
+ class: "cn-ruler",
1418
+ "data-ruler": ""
1419
+ }, tt = {
1420
+ key: 0,
1421
+ class: "cn-ruler__label"
1422
+ }, nt = {
1423
+ key: 0,
1424
+ class: "cn-ruler__label"
1425
+ }, rt = 10, it = 5, at = /*#__PURE__*/ m(/* @__PURE__ */ M({
1426
+ __name: "Ruler",
1427
+ props: { editor: {} },
1428
+ emits: [
1429
+ "guide-drag-start",
1430
+ "guide-drag-move",
1431
+ "guide-drag-end",
1432
+ "guide-drag-cancel"
1433
+ ],
1434
+ setup(e, { emit: t }) {
1435
+ let n = e, r = t, i = w(n.editor), a = U(n.editor.store.ui.rulersVisible), o = n.editor.subscribe((e) => {
1436
+ e.scope === "ui" && e.branch === "rulersVisible" && (a.value = n.editor.store.ui.rulersVisible);
1437
+ });
1438
+ z(o, !0);
1439
+ let s = [
1440
+ 1,
1441
+ 2,
1442
+ 5,
1443
+ 10,
1444
+ 20,
1445
+ 50,
1446
+ 100,
1447
+ 200,
1448
+ 500,
1449
+ 1e3,
1450
+ 2e3,
1451
+ 5e3,
1452
+ 1e4
1453
+ ];
1454
+ function c(e, t, n) {
1455
+ if (!(t > 0) || !(n > 0) || !Number.isFinite(e)) return [];
1456
+ let r = s[s.length - 1];
1457
+ for (let e of s) if (e * n >= rt) {
1458
+ r = e;
1459
+ break;
1460
+ }
1461
+ let i = r * it, a = Math.floor(e / r) * r, o = [];
1462
+ for (let s = 0;; s++) {
1463
+ let c = a + s * r, l = (c - e) * n;
1464
+ if (l > t) break;
1465
+ if (l >= 0) {
1466
+ let e = c / i, t = Math.abs(e - Math.round(e)) < 1e-6;
1467
+ o.push({
1468
+ scene: c,
1469
+ position: l,
1470
+ label: t ? String(Math.round(c)) : null
1471
+ });
1472
+ }
1473
+ }
1474
+ return o;
1475
+ }
1476
+ let l = V(null), u = V(null), d = V(0), f = V(0), p = () => {
1477
+ d.value = l.value?.clientWidth ?? 0, f.value = u.value?.clientHeight ?? 0;
1478
+ }, m = null;
1479
+ R(() => {
1480
+ p(), m = new ResizeObserver(() => p()), l.value && m.observe(l.value), u.value && m.observe(u.value);
1481
+ }), L(() => m?.disconnect());
1482
+ let h = E(() => c(i.value.x, d.value, i.value.zoom)), g = E(() => c(i.value.y, f.value, i.value.zoom)), _ = V(null);
1483
+ function v(e, t, n) {
1484
+ let r = e.getBoundingClientRect(), a = i.value;
1485
+ return {
1486
+ orientation: t,
1487
+ position: t === "vertical" ? a.x + (n.clientX - r.left) / a.zoom : a.y + (n.clientY - r.top) / a.zoom
1488
+ };
1489
+ }
1490
+ function y(e, t) {
1491
+ let n = e.currentTarget;
1492
+ if (n instanceof HTMLElement && e.button === 0 && _.value === null) {
1493
+ e.preventDefault(), _.value = {
1494
+ pointerId: e.pointerId,
1495
+ orientation: t
1496
+ };
1497
+ try {
1498
+ n.setPointerCapture(e.pointerId);
1499
+ } catch {}
1500
+ r("guide-drag-start", v(n, t, e));
1501
+ }
1502
+ }
1503
+ function b(e) {
1504
+ let t = e.currentTarget, n = _.value;
1505
+ t instanceof HTMLElement && n !== null && e.pointerId === n.pointerId && r("guide-drag-move", v(t, n.orientation, e));
1506
+ }
1507
+ function x(e, t) {
1508
+ let n = e.currentTarget, i = _.value;
1509
+ if (!(n instanceof HTMLElement) || i === null || e.pointerId !== i.pointerId) return;
1510
+ _.value = null;
1511
+ try {
1512
+ n.releasePointerCapture(e.pointerId);
1513
+ } catch {}
1514
+ let a = v(n, i.orientation, e);
1515
+ r(t === "guide-drag-end" ? "guide-drag-end" : "guide-drag-cancel", a);
1516
+ }
1517
+ return (e, t) => J((B(), k("div", et, [
1518
+ A("div", {
1519
+ ref_key: "topRef",
1520
+ ref: l,
1521
+ class: "cn-ruler__bar cn-ruler__bar--top",
1522
+ "data-ruler-top": "",
1523
+ role: "img",
1524
+ "aria-label": "水平标尺",
1525
+ title: "水平标尺(拖出垂直参考线)",
1526
+ onPointerdown: t[0] ||= (e) => y(e, "vertical"),
1527
+ onPointermove: t[1] ||= (e) => b(e),
1528
+ onPointerup: t[2] ||= (e) => x(e, "guide-drag-end"),
1529
+ onPointercancel: t[3] ||= (e) => x(e, "guide-drag-cancel")
1530
+ }, [(B(!0), k(T, null, H(h.value, (e) => (B(), k("span", {
1531
+ key: e.scene,
1532
+ class: F(["cn-ruler__tick", { "cn-ruler__tick--major": e.label !== null }]),
1533
+ style: I({ left: `${e.position}px` })
1534
+ }, [e.label === null ? O("", !0) : (B(), k("span", tt, W(e.label), 1))], 6))), 128))], 544),
1535
+ A("div", {
1536
+ ref_key: "leftRef",
1537
+ ref: u,
1538
+ class: "cn-ruler__bar cn-ruler__bar--left",
1539
+ "data-ruler-left": "",
1540
+ role: "img",
1541
+ "aria-label": "垂直标尺",
1542
+ title: "垂直标尺(拖出水平参考线)",
1543
+ onPointerdown: t[4] ||= (e) => y(e, "horizontal"),
1544
+ onPointermove: t[5] ||= (e) => b(e),
1545
+ onPointerup: t[6] ||= (e) => x(e, "guide-drag-end"),
1546
+ onPointercancel: t[7] ||= (e) => x(e, "guide-drag-cancel")
1547
+ }, [(B(!0), k(T, null, H(g.value, (e) => (B(), k("span", {
1548
+ key: e.scene,
1549
+ class: F(["cn-ruler__tick", { "cn-ruler__tick--major": e.label !== null }]),
1550
+ style: I({ top: `${e.position}px` })
1551
+ }, [e.label === null ? O("", !0) : (B(), k("span", nt, W(e.label), 1))], 6))), 128))], 544),
1552
+ t[8] ||= A("div", {
1553
+ class: "cn-ruler__corner",
1554
+ "data-ruler-corner": "",
1555
+ "aria-hidden": "true"
1556
+ }, null, -1)
1557
+ ], 512)), [[K, a.value]]);
1558
+ }
1559
+ }), [["__scopeId", "data-v-5bd7248c"]]), ot = "#2563eb", st = "rgba(37, 99, 235, 0.08)", ct = [4, 3], lt = 1, ut = "rgba(11, 18, 32, 0.9)", dt = "#ffffff", ft = 11, pt = 6, mt = 3, ht = 3, gt = 6;
1560
+ function _t(e, t, n) {
1561
+ let r = t.store.ui.create;
1562
+ if (!r) return;
1563
+ let { x: i, y: a, width: o, height: s } = r.rect;
1564
+ if (o === 0 && s === 0) return;
1565
+ let c = n.viewport.zoom;
1566
+ e.fillStyle = st, e.fillRect(i, a, o, s), e.strokeStyle = ot, e.lineWidth = lt / c, e.setLineDash(ct.map((e) => e / c)), e.strokeRect(i, a, o, s), e.setLineDash([]);
1567
+ let l = ft / c, u = pt / c, d = mt / c;
1568
+ e.font = `${l}px system-ui, sans-serif`;
1569
+ let f = `${Math.round(o)} × ${Math.round(s)}`, p = e.measureText(f).width + u * 2, m = l + d * 2, h = i + o + gt / c, g = a + s + gt / c;
1570
+ e.fillStyle = ut, e.beginPath(), e.roundRect(h, g, p, m, ht / c), e.fill(), e.fillStyle = dt, e.textBaseline = "middle", e.fillText(f, h + u, g + m / 2);
1571
+ }
1572
+ //#endregion
1573
+ //#region src/canvas/findHighlight.ts
1574
+ var vt = {
1575
+ matchColor: "#f59e0b",
1576
+ currentColor: "#38bdf8",
1577
+ currentFill: "rgba(56, 189, 248, 0.12)",
1578
+ lineWidth: 2
1579
+ };
1580
+ function yt(e, t, n, r) {
1581
+ if (!n.doc || !t.store.ui.find.open) return;
1582
+ let i = {
1583
+ ...vt,
1584
+ ...r
1585
+ }, a = t.listFindMatches();
1586
+ if (a.length === 0) return;
1587
+ let o = t.findCursor;
1588
+ for (let r = 0; r < a.length; r += 1) {
1589
+ let s = t.layerBoxAt(a[r].path);
1590
+ if (!s) continue;
1591
+ let c = r === o;
1592
+ c && i.currentFill && (e.fillStyle = i.currentFill, e.fillRect(s.x, s.y, s.width, s.height)), e.strokeStyle = c ? i.currentColor : i.matchColor, e.lineWidth = (c ? i.lineWidth * 1.5 : i.lineWidth) / n.viewport.zoom, e.strokeRect(s.x, s.y, s.width, s.height);
1593
+ }
1594
+ }
1595
+ //#endregion
1596
+ //#region src/canvas/gizmo.ts
1597
+ var bt = {
1598
+ selectionColor: "#2563eb",
1599
+ hoverColor: "rgba(37, 99, 235, 0.55)",
1600
+ selectionWidth: 2,
1601
+ handleSize: 8,
1602
+ handleFill: "#ffffff"
1603
+ };
1604
+ function xt(e, t) {
1605
+ return d(e, t)?.visible === !1;
1606
+ }
1607
+ function St(e, t, n, r) {
1608
+ let i = {
1609
+ ...bt,
1610
+ ...r
1611
+ }, { selection: a, hovered: o } = t.store.ui, s = n.doc;
1612
+ if (s) {
1613
+ if (o && !l(o, a) && !xt(s, o) && !t.isLocked(o)) {
1614
+ let r = t.layerBoxAt(o);
1615
+ r && (e.strokeStyle = i.hoverColor, e.lineWidth = i.selectionWidth / 2 / n.viewport.zoom, e.strokeRect(r.x, r.y, r.width, r.height));
1616
+ }
1617
+ if (a && !xt(s, a)) {
1618
+ let r = t.layerBoxAt(a);
1619
+ r && (e.strokeStyle = i.selectionColor, e.lineWidth = i.selectionWidth / n.viewport.zoom, e.strokeRect(r.x, r.y, r.width, r.height), Ct(e, t, a, r, n.viewport.zoom, i));
1620
+ }
1621
+ }
1622
+ }
1623
+ function Ct(e, t, n, r, i, a) {
1624
+ let o = t.resizeHandlesAt(n);
1625
+ if (o.length === 0) return;
1626
+ let s = a.handleSize / i, c = s / 2;
1627
+ e.fillStyle = a.handleFill, e.strokeStyle = a.selectionColor, e.lineWidth = a.selectionWidth / i;
1628
+ for (let t of o) {
1629
+ let n = de(r, t);
1630
+ e.fillRect(n.x - c, n.y - c, s, s), e.strokeRect(n.x - c, n.y - c, s, s);
1631
+ }
1632
+ }
1633
+ function wt(e, t, n) {
1634
+ return (r) => {
1635
+ if (!t) return;
1636
+ t.setTransform(1, 0, 0, 1, 0, 0), t.clearRect(0, 0, t.canvas.width, t.canvas.height);
1637
+ let i = r.dpr * r.viewport.zoom;
1638
+ t.setTransform(i, 0, 0, i, -r.viewport.x * i, -r.viewport.y * i), St(t, e, r, n);
1639
+ };
1640
+ }
1641
+ //#endregion
1642
+ //#region src/canvas/scheduler.ts
1643
+ function Tt() {
1644
+ return (e) => {
1645
+ let t = window.requestAnimationFrame(() => e());
1646
+ return () => window.cancelAnimationFrame(t);
1647
+ };
1648
+ }
1649
+ //#endregion
1650
+ export { be as _, _t as a, Je as c, Be as d, $ as f, Ee as g, De as h, yt as i, Ge as l, Ie as m, wt as n, at as o, ze as p, St as r, $e as s, Tt as t, Ue as u };