@stll/folio-vue 0.24.0 → 0.26.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.
Files changed (112) hide show
  1. package/dist/{ListButtons-DjLPhg8p.js → ListButtons-1YJNViXB.js} +416 -398
  2. package/dist/ListButtons-Cw5RTKNt.cjs +4 -0
  3. package/dist/{SplitCellDialog-Id6nLwrR.js → SplitCellDialog-CWvjxbog.js} +1207 -1185
  4. package/dist/SplitCellDialog-Dpp-FPQ6.cjs +15 -0
  5. package/dist/components/AnonymizationRectsOverlay.vue.d.ts +20 -0
  6. package/dist/components/AutocompleteCaretOverlay.vue.d.ts +4 -0
  7. package/dist/components/AutocompleteSuggestionOverlay.vue.d.ts +11 -0
  8. package/dist/components/CommentMarginMarkers.vue.d.ts +16 -0
  9. package/dist/components/ContentControlWidgetsOverlay.vue.d.ts +8 -0
  10. package/dist/components/DecorationLayer.vue.d.ts +12 -0
  11. package/dist/components/DocumentName.vue.d.ts +13 -0
  12. package/dist/components/DocumentOutline.vue.d.ts +28 -0
  13. package/dist/components/DocxEditor/DocxEditorDialogs.vue.d.ts +67 -0
  14. package/dist/components/DocxEditor/DocxEditorMenuBar.vue.d.ts +39 -0
  15. package/dist/components/DocxEditor/DocxEditorOverlays.vue.d.ts +42 -0
  16. package/dist/components/DocxEditor/types.d.ts +18 -2
  17. package/dist/components/DocxEditor.vue.d.ts +61 -0
  18. package/dist/components/EditingModeDropdown.vue.d.ts +11 -0
  19. package/dist/components/EditorToolbar.vue.d.ts +30 -0
  20. package/dist/components/FormattingBar.vue.d.ts +20 -0
  21. package/dist/components/HeaderFooterSelectionOverlay.vue.d.ts +12 -0
  22. package/dist/components/ImageContextMenu.vue.d.ts +24 -0
  23. package/dist/components/ImageSelectionOverlay.vue.d.ts +21 -0
  24. package/dist/components/InlineHeaderFooterEditor.vue.d.ts +15 -0
  25. package/dist/components/MenuBar.vue.d.ts +18 -0
  26. package/dist/components/PageIndicator.vue.d.ts +8 -0
  27. package/dist/components/PassageHighlightOverlay.vue.d.ts +16 -0
  28. package/dist/components/PrintButton.vue.d.ts +16 -0
  29. package/dist/components/ReviewControls.vue.d.ts +17 -0
  30. package/dist/components/TemplateDirectivesOverlay.vue.d.ts +15 -0
  31. package/dist/components/TextContextMenu.vue.d.ts +46 -0
  32. package/dist/components/TitleBar.vue.d.ts +17 -0
  33. package/dist/components/Toolbar.vue.d.ts +139 -0
  34. package/dist/components/UnifiedSidebar.vue.d.ts +55 -0
  35. package/dist/components/dialogs/FindReplaceDialog.vue.d.ts +12 -0
  36. package/dist/components/dialogs/FootnotePropertiesDialog.vue.d.ts +15 -0
  37. package/dist/components/dialogs/HyperlinkDialog.vue.d.ts +30 -0
  38. package/dist/components/dialogs/ImagePositionDialog.vue.d.ts +29 -0
  39. package/dist/components/dialogs/ImagePropertiesDialog.vue.d.ts +13 -0
  40. package/dist/components/dialogs/InsertImageDialog.vue.d.ts +21 -0
  41. package/dist/components/dialogs/InsertSymbolDialog.vue.d.ts +12 -0
  42. package/dist/components/dialogs/InsertTableDialog.vue.d.ts +22 -0
  43. package/dist/components/dialogs/PageSetupDialog.vue.d.ts +14 -0
  44. package/dist/components/dialogs/PasteSpecialDialog.vue.d.ts +16 -0
  45. package/dist/components/dialogs/SetNumberingValueDialog.vue.d.ts +12 -0
  46. package/dist/components/dialogs/SplitCellDialog.vue.d.ts +22 -0
  47. package/dist/components/dialogs/TablePropertiesDialog.vue.d.ts +15 -0
  48. package/dist/components/dialogs/WatermarkDialog.vue.d.ts +14 -0
  49. package/dist/components/dialogs/index.d.ts +13 -13
  50. package/dist/components/sidebar/AddCommentCard.vue.d.ts +9 -0
  51. package/dist/components/sidebar/Avatar.vue.d.ts +10 -0
  52. package/dist/components/sidebar/CommentCard.vue.d.ts +21 -0
  53. package/dist/components/sidebar/ReplyInput.vue.d.ts +7 -0
  54. package/dist/components/sidebar/ReplyThread.vue.d.ts +8 -0
  55. package/dist/components/sidebar/ResolvedCommentMarker.vue.d.ts +11 -0
  56. package/dist/components/sidebar/TrackedChangeCard.vue.d.ts +20 -0
  57. package/dist/components/ui/AlignmentButtons.vue.d.ts +15 -0
  58. package/dist/components/ui/Button.vue.d.ts +30 -0
  59. package/dist/components/ui/Checkbox.vue.d.ts +11 -0
  60. package/dist/components/ui/ColorPicker.vue.d.ts +30 -0
  61. package/dist/components/ui/DatePickerPopover.vue.d.ts +13 -0
  62. package/dist/components/ui/Dialog.vue.d.ts +28 -0
  63. package/dist/components/ui/FontPicker.vue.d.ts +21 -0
  64. package/dist/components/ui/FontSizePicker.vue.d.ts +27 -0
  65. package/dist/components/ui/HorizontalRuler.vue.d.ts +39 -0
  66. package/dist/components/ui/HyperlinkPopup.vue.d.ts +21 -0
  67. package/dist/components/ui/IconGridDropdown.vue.d.ts +32 -0
  68. package/dist/components/ui/ImageTransformDropdown.vue.d.ts +11 -0
  69. package/dist/components/ui/ImageWrapDropdown.vue.d.ts +15 -0
  70. package/dist/components/ui/Input.vue.d.ts +17 -0
  71. package/dist/components/ui/LineSpacingPicker.vue.d.ts +20 -0
  72. package/dist/components/ui/ListButtons.vue.d.ts +30 -0
  73. package/dist/components/ui/MaterialSymbol.vue.d.ts +13 -0
  74. package/dist/components/ui/MenuDropdown.vue.d.ts +42 -0
  75. package/dist/components/ui/OutlineRail.vue.d.ts +19 -0
  76. package/dist/components/ui/Popover.vue.d.ts +40 -0
  77. package/dist/components/ui/Select.vue.d.ts +15 -0
  78. package/dist/components/ui/StylePicker.vue.d.ts +16 -0
  79. package/dist/components/ui/TableBorderColorPicker.vue.d.ts +14 -0
  80. package/dist/components/ui/TableBorderPicker.vue.d.ts +11 -0
  81. package/dist/components/ui/TableBorderWidthPicker.vue.d.ts +10 -0
  82. package/dist/components/ui/TableCellFillPicker.vue.d.ts +14 -0
  83. package/dist/components/ui/TableGridInline.vue.d.ts +14 -0
  84. package/dist/components/ui/TableGridPicker.vue.d.ts +18 -0
  85. package/dist/components/ui/TableMoreDropdown.vue.d.ts +51 -0
  86. package/dist/components/ui/TableStyleGallery.vue.d.ts +10 -0
  87. package/dist/components/ui/TableToolbar.vue.d.ts +61 -0
  88. package/dist/components/ui/VerticalRuler.vue.d.ts +20 -0
  89. package/dist/components/ui/ZoomControl.vue.d.ts +12 -0
  90. package/dist/components/ui/icon-paths.json.d.ts +276 -0
  91. package/dist/composables/useDocxEditor.d.ts +2 -0
  92. package/dist/composables/useDocxEditorRefApi.d.ts +5 -0
  93. package/dist/composables/useFindReplace.d.ts +38 -16
  94. package/dist/composables.cjs +2 -2
  95. package/dist/composables.js +44 -44
  96. package/dist/dialogs.cjs +1 -1
  97. package/dist/dialogs.js +2 -5
  98. package/dist/folio-vue.css +1 -1
  99. package/dist/index.cjs +1 -1
  100. package/dist/index.d.ts +3 -0
  101. package/dist/index.js +1584 -1518
  102. package/dist/ui.cjs +1 -1
  103. package/dist/ui.js +2 -2
  104. package/dist/useZoom-C_sQUu4b.js +1010 -0
  105. package/dist/useZoom-CbH76z8x.cjs +1 -0
  106. package/package.json +13 -2
  107. package/dist/ListButtons-DIWR-Q8d.cjs +0 -4
  108. package/dist/SplitCellDialog-B_z6ynxm.cjs +0 -15
  109. package/dist/useFindReplace-CL8Rbc3y.js +0 -59
  110. package/dist/useFindReplace-ZCrdvwEk.cjs +0 -1
  111. package/dist/useZoom-BA92aWwm.js +0 -884
  112. package/dist/useZoom-Bv8t7dYu.cjs +0 -1
@@ -0,0 +1,1010 @@
1
+ import { computed as e, inject as t, onBeforeUnmount as n, onMounted as r, onScopeDispose as i, provide as a, reactive as o, ref as s, shallowRef as c, toValue as l, watch as u, watchEffect as d } from "vue";
2
+ import { CANONICAL_GAP as f, canonicalRefusalMessage as p, usesCanonicalSession as m } from "@stll/folio-core/types/canonicalCapabilities";
3
+ import { TRANSACTION_LAYOUT_TIMING as h, browserClock as g, createLayoutScheduler as _ } from "@stll/folio-core/controller/layoutScheduler";
4
+ import { CanonicalSessionRefusalError as v, collectRemoteSelections as ee, createHiddenEditorManager as y, createHiddenEditorState as b } from "@stll/folio-core/controller/hiddenEditorManager";
5
+ import { cloneDocumentWithParagraphPropertySources as te } from "@stll/folio-core/docx/document-clone";
6
+ import { getMargins as ne, getPageSize as re, twipsToPixels as ie } from "@stll/folio-core/paged-layout/sectionGeometry";
7
+ import { getEditorScrollRoot as x, scrollEditorBy as S } from "@stll/folio-core/paged-layout/editorScrollRoot";
8
+ import { createAnonymizationDecorationsPlugin as ae } from "@stll/folio-core/prosemirror/plugins/anonymizationDecorations";
9
+ import { autocompleteSuggestionPlugin as oe } from "@stll/folio-core/prosemirror/plugins/autocompleteSuggestion";
10
+ import { getEditorReadOnlyReason as se } from "@stll/folio-core/managers/EditorModeManager";
11
+ import { createTemplateDirectivesPlugin as ce } from "@stll/folio-core/prosemirror/plugins/templateDirectives";
12
+ import { createDefaultFindOptions as le, replaceEligibility as ue } from "@stll/folio-core/utils/findReplace";
13
+ import { createSuggestionModePlugin as de, setSuggestionMode as fe } from "@stll/folio-core/prosemirror/plugins/suggestionMode";
14
+ import { getFootnoteText as C } from "@stll/folio-core/docx/storyPlainText";
15
+ import { FOLIO_DOCX_SERIALIZATION_MODE as pe, createFolioEditor as me } from "@stll/folio-core/controller/folioEditor";
16
+ import { createFolioEditorEmitter as he } from "@stll/folio-core/controller/folioEditorEvents";
17
+ import { prepareCanonicalDocxInput as w } from "@stll/folio-core/docx/canonicalSessionInput";
18
+ import { CanonicalSaveDiagnosticError as ge, serializeCanonicalSave as _e } from "@stll/folio-core/docx/canonicalSave";
19
+ import { loadCollaborationModules as ve } from "@stll/folio-core/controller/collaborationModules";
20
+ import { createHeaderFooterEditorManager as ye } from "@stll/folio-core/controller/headerFooterEditorManager";
21
+ import { createNoteEditorManager as be } from "@stll/folio-core/controller/noteEditorManager";
22
+ import { runLayoutPipeline as xe } from "@stll/folio-core/controller/layoutPipeline";
23
+ import { createHyphenationReadiness as Se } from "@stll/folio-core/controller/hyphenationReadiness";
24
+ import { readFontSetSignature as Ce, waitForInitialLayoutFonts as we, watchLayoutFontLoads as Te } from "@stll/folio-core/controller/fontReadiness";
25
+ import { createLayoutSession as Ee } from "@stll/folio-core/controller/layoutSession";
26
+ import { parseDocx as De } from "@stll/folio-core/docx/parser";
27
+ import { convertHeaderFooterPmDocToContent as T, convertHeaderFooterToContent as Oe } from "@stll/folio-core/layout-bridge/convert/headerFooterLayout";
28
+ import { resolveSectionHeaderFooterRefs as ke } from "@stll/folio-core/layout-engine";
29
+ import { LayoutPainter as Ae } from "@stll/folio-core/layout-painter";
30
+ import { LayoutSelectionGate as je } from "@stll/folio-core/paged-layout/LayoutSelectionGate";
31
+ import { fromProseDoc as Me } from "@stll/folio-core/prosemirror/conversion/fromProseDoc";
32
+ import { createNoteReferenceFollower as Ne, withoutUnreferencedNotes as Pe } from "@stll/folio-core/prosemirror/noteReferenceReview";
33
+ import { ExtensionManager as Fe } from "@stll/folio-core/prosemirror/extensions/ExtensionManager";
34
+ import { getChangedParagraphIds as Ie, hasStructuralChanges as Le, hasUntrackedChanges as Re, repackWithEditorSectionRemovals as ze } from "@stll/folio-core/prosemirror/extensions/features/ParagraphChangeTrackerExtension";
35
+ import { createStarterKit as Be } from "@stll/folio-core/prosemirror/extensions/StarterKit";
36
+ import { createTemplatePreviewValuesPlugin as Ve } from "@stll/folio-core/prosemirror/plugins/templatePreviewValues";
37
+ import { templateSlashMenuPlugin as He } from "@stll/folio-core/prosemirror/plugins/templateSlashMenu";
38
+ import { resolveHeaderFooterContent as Ue } from "@stll/folio-core/utils/headerFooter";
39
+ import { FindReplaceManager as We } from "@stll/folio-core/managers/FindReplaceManager";
40
+ import { findInDisplayedDocument as Ge, resolveFindMatchRange as E } from "@stll/folio-core/prosemirror/findReplaceSelection";
41
+ import { createFindSearchKey as Ke, sameFindSearchKey as qe } from "@stll/folio-core/utils/findSearchKey";
42
+ import { createFindMatchView as Je, getRenderedSearchStories as Ye } from "@stll/folio-core/utils/findMatchView";
43
+ import { MIN_CELL_WIDTH_TWIPS as Xe, MIN_ROW_HEIGHT_TWIPS as D, TWIPS_PER_PIXEL as O, commitColumnResize as Ze, commitRightEdgeResize as Qe, commitRowResize as $e, readColumnWidthAt as et, readColumnWidths as tt, readRowHeight as nt } from "@stll/folio-core/prosemirror/tableResize";
44
+ import { extractTrackedChanges as rt } from "@stll/folio-core/prosemirror/utils/extractTrackedChanges";
45
+ import { ZOOM_MAX as it, ZOOM_MIN as at, ZOOM_STEP as k } from "@stll/folio-core/utils/zoom";
46
+ //#region src/utils/colorMode.ts
47
+ var A = "(prefers-color-scheme: dark)";
48
+ function ot() {
49
+ return typeof window < "u" && typeof window.matchMedia == "function";
50
+ }
51
+ function j(e, t) {
52
+ return e === "dark" || e === "system" && t;
53
+ }
54
+ function M(e) {
55
+ if (!ot()) return () => {};
56
+ let t = window.matchMedia(A);
57
+ e(t.matches);
58
+ let n = (t) => e(t.matches);
59
+ return t.addEventListener("change", n), () => t.removeEventListener("change", n);
60
+ }
61
+ //#endregion
62
+ //#region src/composables/useColorMode.ts
63
+ var N = "light", P = Symbol("folioColorMode"), F = (t = N) => {
64
+ a(P, e(() => l(t)));
65
+ }, I = { install(t, n = N) {
66
+ t.provide(P, e(() => l(n)));
67
+ } };
68
+ function st() {
69
+ let n = t(P, e(() => N)), i = s(!1), a = s(!1);
70
+ return r(() => {
71
+ i.value = !0;
72
+ }), d((e) => {
73
+ !i.value || n.value !== "system" || e(M((e) => {
74
+ a.value = e;
75
+ }));
76
+ }), e(() => j(n.value, i.value && a.value));
77
+ }
78
+ //#endregion
79
+ //#region src/composables/useDocxEditor.ts
80
+ var ct = 24, lt = "User", ut = 250, dt = [], ft = [];
81
+ function pt(e) {
82
+ let t = e?.columnCount ?? 1;
83
+ if (t <= 1) return;
84
+ let n = {
85
+ count: t,
86
+ gap: ie(e?.columnSpace ?? 720),
87
+ equalWidth: e?.equalWidth ?? !0
88
+ };
89
+ return e?.separator !== void 0 && (n.separator = e.separator), n;
90
+ }
91
+ function mt(e, t, n, r, i, a) {
92
+ if (!e) return;
93
+ let o = t ? {
94
+ ...a,
95
+ rId: t
96
+ } : a, s = t ? n?.getView(t) : null;
97
+ return s ? T(s.state.doc, r, i, o) : Oe(e, r, i, o);
98
+ }
99
+ function ht(e, t, n, r, i) {
100
+ if (!e || e.size === 0) return;
101
+ let a = /* @__PURE__ */ new Map();
102
+ for (let [o, s] of e) {
103
+ let e = mt(s, o, t, n, r, i);
104
+ e && a.set(o, e);
105
+ }
106
+ return a.size > 0 ? a : void 0;
107
+ }
108
+ function gt(e, t, n) {
109
+ let r = /* @__PURE__ */ new Map();
110
+ if (!n || !n.package.footnotes) return r;
111
+ let i = /* @__PURE__ */ new Map();
112
+ for (let e of n.package.footnotes) e.noteType && e.noteType !== "normal" || i.set(e.id, e);
113
+ for (let [n, a] of e) {
114
+ let e = [];
115
+ for (let n of a) {
116
+ let r = i.get(n);
117
+ if (!r) continue;
118
+ let a = t.get(n), o = a?.displayNumber ?? 0;
119
+ e.push({
120
+ displayNumber: String(o),
121
+ noteId: n,
122
+ text: C(r),
123
+ ...a ? { content: {
124
+ blocks: a.blocks,
125
+ measures: a.measures,
126
+ height: a.height
127
+ } } : {}
128
+ });
129
+ }
130
+ e.length > 0 && r.set(n, e);
131
+ }
132
+ return r;
133
+ }
134
+ var L = /* @__PURE__ */ new Set([
135
+ "black",
136
+ "blue",
137
+ "cyan",
138
+ "darkBlue",
139
+ "darkCyan",
140
+ "darkGray",
141
+ "darkGreen",
142
+ "darkMagenta",
143
+ "darkRed",
144
+ "darkYellow",
145
+ "green",
146
+ "lightGray",
147
+ "magenta",
148
+ "none",
149
+ "red",
150
+ "white",
151
+ "yellow"
152
+ ]);
153
+ function _t(e) {
154
+ let t = [], n = (e, r) => {
155
+ for (let [n, i] of e.marks.entries()) i.type.name === "highlight" && !L.has(String(i.attrs.color)) && t.push(`${r}.marks[${n}]=${JSON.stringify(i.attrs)}`);
156
+ e.forEach((e, t, i) => {
157
+ n(e, `${r}.content[${i}]`);
158
+ });
159
+ };
160
+ return n(e, "doc"), t.join("; ");
161
+ }
162
+ function R(e) {
163
+ let { hiddenContainer: t, hiddenHeaderFooterContainer: n, noteEditorContainer: r, pagesContainer: a, readOnly: o = !1, experimentalSession: d, pageGap: ie = ct, pageRenderer: x, markupView: S = "all-markup", showCommentHighlights: se = !0, showMarginGuides: le, marginGuideColor: ue, password: C, editorMode: T, author: Oe, externalPlugins: We = [], historyShortcuts: Ge = "editor", collaboration: E, onAnonymizationMatchesChange: Ke, showTemplateDirectives: qe, onSlashMenuChange: Je, onSlashMenuKeyAction: Ye, onChange: Xe, onError: D, onSelectionUpdate: O, onEditorViewReady: Ze, onCopy: Qe, onCut: $e, onPaste: et, onReadOnlyEditAttempt: tt, featureFlags: nt, onSelectiveSaveTripwire: rt } = e, it = n ?? t, at = () => l(Oe) ?? lt, k = c(null), A = 0, ot = !1, j = 0, M = !1, N = c(null), P = c(null), F = c(null), I = c([]), st = c(null), L = c(null), R = c(null), vt = c([]), yt = c([]), z = s(!1), B = s(null), V = s(!1), H = () => m(l(d), f.authorityRouting), U = (e) => H() ? te(e) : e, bt = (e, t) => {
164
+ if (!H()) return !1;
165
+ let n = new v({
166
+ gap: e,
167
+ message: p(e, t)
168
+ });
169
+ return D?.(n), !0;
170
+ }, W = new Fe(Be({ historyShortcuts: Ge }));
171
+ W.buildSchema(), W.initializeRuntime();
172
+ let xt = de(!1), St = [xt], Ct = oe({ keymap: !0 }), wt = ae({ onMatchesChange: (e) => Ke?.(e) }), Tt = ce(), Et = He({
173
+ onChange: (e) => Je?.(e),
174
+ onKeyAction: (e) => Ye?.(e) ?? !1
175
+ }), Dt = Ve(), Ot = () => l(qe) === !0;
176
+ function kt() {
177
+ return [
178
+ Ct,
179
+ xt,
180
+ ...We,
181
+ ...l(E)?.plugins ?? [],
182
+ wt,
183
+ ...Ot() ? [Tt, Et] : [],
184
+ Dt
185
+ ];
186
+ }
187
+ let G = he(), K = new je(), q = Ee(), At = Se({
188
+ relayout: () => {
189
+ let e = N.value?.state ?? q.lastEditorState;
190
+ e && Z(e, { reason: "hyphenation-ready" });
191
+ },
192
+ onError: (e) => D?.(e)
193
+ });
194
+ i(At.cancel), i(Te({
195
+ measuredFontSet: () => q.lastMeasureInputs?.fontSet ?? null,
196
+ relayout: () => {
197
+ if (M) return;
198
+ let e = N.value?.state ?? q.lastEditorState;
199
+ e && Z(e, { reason: "font-ready" });
200
+ }
201
+ }));
202
+ let jt = new Ae({
203
+ pageGap: ie,
204
+ showShadow: !0
205
+ }), J = ye({
206
+ getHost: () => it.value,
207
+ getReadOnly: () => l(o),
208
+ getDocument: () => $.api.getCanonicalDocument() ?? k.value,
209
+ getCanonicalApi: () => $.api,
210
+ getExperimentalSession: () => l(d),
211
+ onSessionRefusal: (e, t, n) => {
212
+ B.value = e, D?.(n ?? new v({
213
+ gap: t,
214
+ message: e
215
+ }));
216
+ },
217
+ getStyles: () => k.value?.package.styles ?? null,
218
+ getTheme: () => k.value?.package.theme ?? null,
219
+ onTransaction: ({ rId: e, kind: t, view: n, docChanged: r, selectionChanged: i }) => {
220
+ if (r && (V.value = !0, Pt.schedule()), r || i) {
221
+ let { from: r, to: i } = n.state.selection;
222
+ st.value = {
223
+ from: r,
224
+ kind: t,
225
+ rId: e,
226
+ to: i
227
+ }, O?.(n.state), G.emit("selectionChange", {
228
+ from: r,
229
+ to: i
230
+ });
231
+ }
232
+ K.requestRender();
233
+ }
234
+ }), Mt = { current: null }, Y = be({
235
+ getHost: () => r?.value ?? null,
236
+ getPlugins: () => St,
237
+ getDocument: () => $.api.getCanonicalDocument() ?? k.value,
238
+ getCanonicalApi: () => $.api,
239
+ getExperimentalSession: () => l(d),
240
+ onSessionRefusal: (e, t, n) => {
241
+ B.value = e, D?.(n ?? new v({
242
+ gap: t,
243
+ message: e
244
+ }));
245
+ },
246
+ getStyles: () => k.value?.package.styles ?? null,
247
+ getTheme: () => k.value?.package.theme ?? null,
248
+ onTransaction: ({ docChanged: e, selectionChanged: t, view: n }) => {
249
+ if (e) {
250
+ V.value = !0;
251
+ let e = k.value;
252
+ if (e) {
253
+ let t = $.api.getCanonicalDocument() ?? Mt.current?.snapshotDocument(e) ?? e;
254
+ k.value = t, Xe?.(U(t)), G.emit("docChange", U(t));
255
+ }
256
+ Pt.schedule();
257
+ }
258
+ if (e || t) {
259
+ O?.(n.state);
260
+ let { from: e, to: t } = n.state.selection;
261
+ G.emit("selectionChange", {
262
+ from: e,
263
+ to: t
264
+ });
265
+ }
266
+ }
267
+ });
268
+ Mt.current = Y;
269
+ let X = () => {
270
+ J.sync(), Y.sync();
271
+ };
272
+ u(() => l(d), X);
273
+ function Nt(e) {
274
+ e.layout && (R.value = e.layout), e.blocks && (vt.value = e.blocks), e.measures && (yt.value = e.measures), e.blockLookup && jt.setBlockLookup(e.blockLookup), e.layout && G.emit("layoutComplete", e.layout);
275
+ }
276
+ function Z(e, t = {}) {
277
+ if (M) return;
278
+ let n = a.value, r = n instanceof HTMLDivElement ? n : null, i = k.value, o = i?.package.document, s = o?.sections?.[0]?.properties ?? o?.finalSectionProperties ?? null, c = re(s), u = ne(s), d = pt(s), f = c.w - u.left - u.right, p = i?.package.styles ?? null, m = i?.package.theme ?? null, h = i?.package.settings?.defaultTabStop, g = i?.package.settings?.mirrorMargins === !0, _ = Ue(i?.package);
279
+ try {
280
+ Nt(xe({
281
+ contentWidth: f,
282
+ columns: d,
283
+ pageSize: c,
284
+ margins: u,
285
+ pageGap: ie,
286
+ showMarginGuides: l(le) === !0,
287
+ marginGuideColor: l(ue),
288
+ ...(() => {
289
+ let e = l(x);
290
+ return e === void 0 ? {} : { pageRenderer: e };
291
+ })(),
292
+ syncCoordinator: K,
293
+ headerContent: _.headerContent,
294
+ footerContent: _.footerContent,
295
+ firstPageHeaderContent: _.firstPageHeaderContent,
296
+ firstPageFooterContent: _.firstPageFooterContent,
297
+ headerContentRId: _.activeHeaderRId,
298
+ footerContentRId: _.activeFooterRId,
299
+ firstPageHeaderContentRId: _.activeFirstHeaderRId,
300
+ firstPageFooterContentRId: _.activeFirstFooterRId,
301
+ sectionHeaderFooterRefs: ke(i),
302
+ theme: m,
303
+ sectionProperties: s,
304
+ document: i,
305
+ defaultTabStop: h,
306
+ mirrorMargins: g,
307
+ styles: p,
308
+ layout: R.value,
309
+ hfPMs: J,
310
+ painter: jt,
311
+ pagesContainer: r,
312
+ session: q,
313
+ renderHfFromContentOrPm: mt,
314
+ renderHeaderFooterContentByRId: ht,
315
+ readFontSetSignature: Ce,
316
+ buildFootnoteRenderItems: gt,
317
+ describeInvalidHighlightMarks: _t,
318
+ emptyTemplatePreviewEntries: dt,
319
+ emptyTemplatePreviewHidden: ft,
320
+ hyphenationReadiness: At,
321
+ markupView: l(S),
322
+ showCommentHighlights: l(se)
323
+ }, e, t));
324
+ } catch (e) {
325
+ let t = e instanceof Error ? e : Error(String(e));
326
+ D?.(t);
327
+ }
328
+ }
329
+ let Pt = _({
330
+ readState: () => N.value?.state ?? null,
331
+ runLayout: (e, t) => Z(e, t),
332
+ ...h,
333
+ clock: g
334
+ }), Q = null, Ft = Ne();
335
+ function It() {
336
+ Q !== null && (window.clearTimeout(Q), Q = null);
337
+ let e = N.value, t = k.value;
338
+ if (!(!e || !t)) try {
339
+ let n = $.api.getCanonicalDocument();
340
+ if (!n && H()) return;
341
+ let r = n ?? Ft.reconcile(Me(e.state.doc, t, { stylesheetSource: { type: "package" } }), e.state.doc);
342
+ k.value = r, X(), Xe?.(U(r)), G.emit("docChange", U(r));
343
+ } catch (e) {
344
+ D?.(e instanceof Error ? e : Error(String(e)));
345
+ }
346
+ }
347
+ function Lt() {
348
+ Q !== null && window.clearTimeout(Q), Q = window.setTimeout(() => {
349
+ Q = null, It();
350
+ }, ut);
351
+ }
352
+ let $ = y({
353
+ getHost: () => t.value,
354
+ getDocument: () => k.value,
355
+ getStyles: () => k.value?.package.styles ?? null,
356
+ getExtensionManager: () => W,
357
+ getExternalPlugins: kt,
358
+ getCollaboration: () => l(E),
359
+ getCollaborationModules: () => F.value,
360
+ getPrecomputedInitialState: () => null,
361
+ getReadOnly: () => l(o),
362
+ getExperimentalSession: () => l(d),
363
+ getEditingMode: () => l(T) ?? "editing",
364
+ getSuggestionAuthor: at,
365
+ onSessionRefusal: (e, t, n) => {
366
+ D?.(n ?? new v({
367
+ gap: t,
368
+ message: e
369
+ }));
370
+ },
371
+ getDocumentIdentity: () => String(A),
372
+ getDocumentContext: () => k.value,
373
+ onTransaction: zt,
374
+ onSelectionChange: (e) => {
375
+ P.value = e, O?.(e), G.emit("selectionChange", {
376
+ from: e.selection.from,
377
+ to: e.selection.to
378
+ });
379
+ },
380
+ onKeyDown: () => !1,
381
+ onCopy: () => Qe?.(),
382
+ onCut: () => $e?.(),
383
+ onPaste: () => et?.(),
384
+ onReadOnlyEditAttempt: () => tt?.(),
385
+ onEditorViewReady: Bt,
386
+ onEditorViewDestroy: () => {
387
+ N.value = null, z.value = !1, Ze?.(null);
388
+ },
389
+ onRemoteSelectionsChange: (e) => {
390
+ I.value = e;
391
+ }
392
+ }), Rt = () => {
393
+ let e = l(E)?.awareness, t = F.value, n = $.getView();
394
+ I.value = e && t && n ? ee(n.state, e, t) : [];
395
+ };
396
+ u(() => l(E), (e, t, n) => {
397
+ if (I.value = [], !e) {
398
+ F.value = null, $.retryViewCreation(), $.syncExternalDocument();
399
+ return;
400
+ }
401
+ let r = !1;
402
+ n(() => {
403
+ r = !0;
404
+ }), F.value = null, ve().then((e) => {
405
+ r || (F.value = e, $.retryViewCreation(), $.syncExternalDocument(), Rt());
406
+ }, (e) => {
407
+ r || (F.value = null, D?.(e instanceof Error ? e : Error(String(e))));
408
+ });
409
+ }, { immediate: !0 }), u(() => ({
410
+ awareness: l(E)?.awareness,
411
+ modules: F.value,
412
+ view: N.value
413
+ }), ({ awareness: e, modules: t, view: n }, r, i) => {
414
+ if (!e || !t || !n) {
415
+ I.value = [];
416
+ return;
417
+ }
418
+ e.on("change", Rt), Rt(), i(() => {
419
+ e.off("change", Rt), I.value = [];
420
+ });
421
+ }, { flush: "post" });
422
+ function zt({ newState: e, docChanged: t, transactions: n }) {
423
+ P.value = e;
424
+ let r = n[0]?.before;
425
+ if (t && r && Ft.noteBase(r), t) {
426
+ let e = $.api.getCanonicalDocument();
427
+ e && (k.value = e, X()), V.value = !0, K.incrementStateSeq(), Pt.schedule(), Lt();
428
+ }
429
+ K.requestRender();
430
+ }
431
+ function Bt(e) {
432
+ N.value = e, P.value = e.state, z.value = !0;
433
+ let t = k.value, n = A, r = ++j;
434
+ M = !0;
435
+ let i = () => {
436
+ j === r && (M = !1, !(ot || A !== n || $.getView() !== e) && (Z(e.state, { reason: "initial" }), K.requestRender()));
437
+ };
438
+ we(t, e.state.doc).then(i, i), Ut(e), Ze?.(e), l(o) || requestAnimationFrame(() => {
439
+ N.value === e && e.focus();
440
+ });
441
+ }
442
+ let Vt = {
443
+ getDocx: async (e) => (await Xt(e))?.buffer ?? null,
444
+ loadDocument: Yt,
445
+ loadDocx: Jt
446
+ }, Ht = me({
447
+ getEditorApi: () => $.api,
448
+ getLayout: () => R.value,
449
+ runLayout: (e, t) => Z(e, t),
450
+ getDocumentIO: () => Vt,
451
+ emitter: G
452
+ });
453
+ function Ut(e) {
454
+ fe(l(T) === "suggesting", e.state, e.dispatch, at());
455
+ }
456
+ u([() => l(T), at], () => {
457
+ Ht.setCanonicalMode(l(T) === "suggesting" ? {
458
+ type: "suggesting",
459
+ author: at()
460
+ } : { type: "editing" });
461
+ let e = N.value;
462
+ e && Ut(e);
463
+ for (let e of Y.listStories()) {
464
+ let t = Y.getView(e);
465
+ t && Ut(t);
466
+ }
467
+ }), u(() => l(o), (e) => {
468
+ $.syncEditable(), e && rn(), J.sync();
469
+ });
470
+ function Wt(e) {
471
+ let t = Ot();
472
+ if (t === e.state.plugins.includes(Tt)) return;
473
+ let n = e.state.plugins.filter((e) => e !== Tt && e !== Et);
474
+ if (t) {
475
+ let e = n.indexOf(Dt), t = e === -1 ? n.length : e;
476
+ n.splice(t, 0, Tt, Et);
477
+ }
478
+ e.updateState(e.state.reconfigure({ plugins: n }));
479
+ }
480
+ u(() => Ot(), () => {
481
+ let e = N.value;
482
+ e && Wt(e);
483
+ });
484
+ function Gt() {
485
+ $.ensureView();
486
+ }
487
+ function Kt() {
488
+ A += 1, V.value = !1, st.value = null, L.value = null, Y.activate(null), Pt.dispose(), $.destroyView(), H() && $.ensureView(), X(), $.ensureView(), $.getView() || qt();
489
+ }
490
+ function qt() {
491
+ let e = k.value;
492
+ if (!(!e || l(E))) try {
493
+ let t = b({
494
+ document: e,
495
+ styles: e.package.styles ?? null,
496
+ manager: W,
497
+ externalPlugins: kt(),
498
+ collaborationModules: null,
499
+ reason: "mount"
500
+ });
501
+ P.value = t;
502
+ let n = A, r = ++j;
503
+ M = !0;
504
+ let i = () => {
505
+ j === r && (M = !1, !(ot || A !== n || k.value !== e || $.getView()) && Z(t, { reason: "initial" }));
506
+ };
507
+ we(e, t.doc).then(i, i);
508
+ } catch (e) {
509
+ D?.(e instanceof Error ? e : Error(String(e)));
510
+ }
511
+ }
512
+ u([
513
+ t,
514
+ a,
515
+ it,
516
+ ...r ? [r] : []
517
+ ], () => {
518
+ t.value && k.value && !$.getView() && Gt(), X();
519
+ }, { flush: "post" });
520
+ async function Jt(e) {
521
+ B.value = null, z.value = !1;
522
+ try {
523
+ let t = e;
524
+ if (H()) {
525
+ let n = await w(e);
526
+ if (n.isErr()) throw n.error;
527
+ t = n.value;
528
+ }
529
+ let n = await De(t, { password: l(C) });
530
+ k.value = n, Kt();
531
+ } catch (e) {
532
+ let t = e instanceof Error ? e : Error(String(e));
533
+ B.value = t.message, D?.(t);
534
+ }
535
+ }
536
+ function Yt(e) {
537
+ B.value = null, k.value = e, Ft.reset(), Kt();
538
+ }
539
+ async function Xt(e) {
540
+ let t = N.value, n = k.value;
541
+ if (!t || !n) return null;
542
+ try {
543
+ let t = $.api.captureCanonicalSave();
544
+ if (t) {
545
+ let n = await _e({
546
+ snapshot: t,
547
+ options: e,
548
+ featureFlags: l(nt)
549
+ });
550
+ for (let t of n.diagnostics) e?.onDiagnostic || D?.(new ge({
551
+ gap: f.save,
552
+ diagnostic: t,
553
+ message: `Canonical save used a fidelity fallback: ${t.type} (${t.part}).`
554
+ }));
555
+ return n.tripwireResult && rt?.(n.tripwireResult), n;
556
+ }
557
+ } catch (e) {
558
+ return D?.(e instanceof Error ? e : Error(String(e))), null;
559
+ }
560
+ if (H()) return null;
561
+ Q !== null && It();
562
+ let r = Y.snapshotDocument(J.snapshotDocument(n)), i = t.state, a = Pe(Me(i.doc, r, { stylesheetSource: { type: "package" } })), { resolveSelectiveSaveFlags: o } = await import("@stll/folio-core/docx/selectiveSaveFlags"), s = o(l(nt)), c = a.originalBuffer ?? null, u = s.selectiveSave && e?.mode !== pe.full, d = u || s.selectiveSaveTripwire, { repackDocx: p, createDocx: m } = await import("@stll/folio-core/docx/rezip"), h = null;
563
+ if (d && c) {
564
+ let { attemptSelectiveSave: e } = await import("@stll/folio-core/docx/selectiveSave");
565
+ h = await e(a, c, {
566
+ changedParaIds: Ie(i),
567
+ structuralChange: Le(i),
568
+ hasUntrackedChanges: Re(i),
569
+ maxBytes: s.selectiveSaveMaxBytes
570
+ });
571
+ }
572
+ let g = u ? h : null, _ = null, v = () => ze({
573
+ state: i,
574
+ document: a,
575
+ repack: () => p(a)
576
+ });
577
+ if (!g) _ = c ? await v() : await m(a), g = _;
578
+ else if (s.selectiveSaveTripwire) try {
579
+ _ = await v();
580
+ } catch {}
581
+ if (s.selectiveSaveTripwire && _ && rt) try {
582
+ let { compareSelectiveVsFull: e } = await import("@stll/folio-core/docx/selectiveSaveTripwire");
583
+ rt(await e(h, _));
584
+ } catch {}
585
+ return {
586
+ buffer: g,
587
+ document: a
588
+ };
589
+ }
590
+ async function Zt(e) {
591
+ let t = N.value, n = t?.state, r = await Xt({ mode: e?.selective === !1 ? pe.full : pe.preferSelective });
592
+ return r ? (N.value === t && t?.state.doc === n?.doc && (r.version === void 0 || $.api.isCanonicalSaveCurrent(r.version)) && (k.value = r.document, X(), V.value = !1), new Blob([r.buffer], { type: "application/vnd.openxmlformats-officedocument.wordprocessingml.document" })) : null;
593
+ }
594
+ function Qt() {
595
+ let e = $.api.getCanonicalDocument();
596
+ if (e) return e;
597
+ if (H()) return null;
598
+ let t = k.value;
599
+ if (!t) return null;
600
+ let n = $.api.getDocument() ?? t;
601
+ return U(Y.snapshotDocument(J.snapshotDocument(n)));
602
+ }
603
+ function $t(e) {
604
+ bt(f.modelEdits, "Direct document model changes are unavailable in this session.") || (k.value = e, X(), L.value && !Y.getView(L.value) && (L.value = null));
605
+ }
606
+ function en(e) {
607
+ return J.getView(e);
608
+ }
609
+ function tn() {
610
+ X();
611
+ }
612
+ function nn(e) {
613
+ let t = Y.activate(e);
614
+ t && (Ut(t), L.value = e, requestAnimationFrame(() => t.focus()));
615
+ }
616
+ function rn() {
617
+ Y.activate(null), L.value = null;
618
+ }
619
+ function an() {
620
+ let e = L.value;
621
+ return e ? Y.getView(e) : null;
622
+ }
623
+ function on() {
624
+ return W.getCommands();
625
+ }
626
+ function sn() {
627
+ let e = an();
628
+ e ? e.focus() : N.value?.focus();
629
+ }
630
+ function cn() {
631
+ let e = N.value;
632
+ e && Z(e.state, { reason: "manual" });
633
+ }
634
+ u([
635
+ () => l(le),
636
+ () => l(ue),
637
+ () => l(x),
638
+ () => l(S),
639
+ () => l(se)
640
+ ], () => cn());
641
+ function ln() {
642
+ ot = !0, j += 1, M = !1, Pt.dispose(), Q !== null && (window.clearTimeout(Q), Q = null), $.destroyView(), I.value = [], J.destroy(), Y.destroy(), W.destroy(), P.value = null, R.value = null, k.value = null, z.value = !1;
643
+ }
644
+ return i(ln), {
645
+ setEmbeddedFontFamilies: (e) => {
646
+ if (e) {
647
+ q.embeddedFontFamilyMap = new Map(e);
648
+ return;
649
+ }
650
+ delete q.embeddedFontFamilyMap;
651
+ },
652
+ editor: Ht,
653
+ editorView: N,
654
+ editorState: P,
655
+ remoteSelections: I,
656
+ headerFooterSelection: st,
657
+ activeNoteStory: L,
658
+ isReady: z,
659
+ isDirty: V,
660
+ parseError: B,
661
+ layout: R,
662
+ blocks: vt,
663
+ measures: yt,
664
+ syncCoordinator: K,
665
+ loadBuffer: Jt,
666
+ loadDocument: Yt,
667
+ save: Zt,
668
+ getDocument: Qt,
669
+ setDocument: $t,
670
+ getHeaderFooterView: en,
671
+ syncHeaderFooterViews: tn,
672
+ openNoteStory: nn,
673
+ closeNoteStory: rn,
674
+ getActiveNoteView: an,
675
+ getCommands: on,
676
+ focus: sn,
677
+ reLayout: cn,
678
+ destroy: ln
679
+ };
680
+ }
681
+ //#endregion
682
+ //#region src/composables/useFindReplace.ts
683
+ function vt({ editorView: t, pagesRef: n, getDocument: r, layout: a, commentRoot: l, revealComment: d, displayMode: f, readOnly: p, onReadonlyEditAttempt: m, onResultChange: h }) {
684
+ let g = new We(), _ = s(""), v = s(""), ee = o(le()), y = c([]), b = s(-1), te = e(() => y.value.at(b.value) ?? null), ne = () => se({
685
+ editingMode: t.value?.editable === !1 ? "viewing" : "editing",
686
+ readOnlyProp: p.value,
687
+ displayMode: f.value
688
+ }), re = e(ne), ie = e(() => {
689
+ let e = te.value;
690
+ return ne() === null && !!t.value && !!e && ce() && ue(e).status === "allowed";
691
+ }), x = null, S, ae = null, oe = (e) => {
692
+ let n = t.value?.state.doc;
693
+ return {
694
+ query: _.value,
695
+ options: {
696
+ ...ee,
697
+ displayMode: f.value,
698
+ includeComments: !!l
699
+ },
700
+ document: e,
701
+ ...n ? { bodyVersion: n } : {},
702
+ context: { renderedStories: Ye(a.value) }
703
+ };
704
+ }, ce = () => {
705
+ let e = r();
706
+ return !!e && qe(ae, Ke(oe(e)));
707
+ }, de = () => g.getResult(), fe = () => h(de()), C = () => {
708
+ clearTimeout(S), S = void 0;
709
+ }, pe = () => {
710
+ C(), g.clear(), x?.destroy(), x = null, y.value = [], ae = null, b.value = -1;
711
+ }, me = () => {
712
+ pe(), _.value = "", fe();
713
+ }, he = (e) => (b.value = e, x?.navigate(e, d), fe(), !0), w = (e = "query") => {
714
+ C();
715
+ let i = r(), o = n.value, s = t.value?.state.doc;
716
+ if (!i || !_.value.trim()) return me(), [];
717
+ let c = oe(i), u = Ge({
718
+ document: c.document,
719
+ state: t.value?.state ?? null,
720
+ searchText: c.query,
721
+ options: c.options,
722
+ context: c.context
723
+ });
724
+ if (u === null) return pe(), fe(), [];
725
+ let d = Ke(c), f = e === "refresh" && ae?.query === d.query, p = g.setMatches(u, f ? g.getResult()?.currentIndex ?? 0 : 0);
726
+ return ae = d, y.value = u, b.value = u.length > 0 ? p.currentIndex : -1, x?.destroy(), x = o ? Je({
727
+ container: o,
728
+ document: i,
729
+ bodyDoc: s,
730
+ matches: u,
731
+ commentRoot: l?.value ?? void 0,
732
+ layout: a.value
733
+ }) : null, x?.paint(b.value), u.at(0) && !f ? he(0) : fe(), u;
734
+ }, ge = () => {
735
+ C(), S = setTimeout(() => w("refresh"), 120);
736
+ }, _e = (e, t) => (_.value = e, Object.assign(ee, le(), t), w(), de()), ve = (e) => {
737
+ let t = g.goTo(e);
738
+ return t ? he(t.index) : !1;
739
+ }, ye = (e) => {
740
+ let t = g.navigate(e);
741
+ return t ? (he(t.index), t.match) : null;
742
+ }, be = () => ce() ? !1 : (w("refresh"), !0), xe = () => {
743
+ let e = ne();
744
+ return e === null ? !1 : (m?.(e), !0);
745
+ };
746
+ return u(f, () => {
747
+ _.value.trim() && w();
748
+ }), i(() => {
749
+ C(), x?.destroy();
750
+ }), {
751
+ searchText: _,
752
+ replaceText: v,
753
+ options: ee,
754
+ matches: y,
755
+ currentIndex: b,
756
+ currentMatch: te,
757
+ canReplaceCurrent: ie,
758
+ replacementRefusal: re,
759
+ performSearch: w,
760
+ scheduleSearch: ge,
761
+ find: _e,
762
+ getFindResult: de,
763
+ goToMatch: ve,
764
+ findNext: () => ye("next"),
765
+ findPrevious: () => ye("previous"),
766
+ replaceCurrent: () => {
767
+ let e = t.value;
768
+ if (!e || xe() || be()) return !1;
769
+ let n = te.value;
770
+ if (!ie.value || !e || !n) return !1;
771
+ if (n.text === v.value) return !0;
772
+ let r = E(e.state.doc, n);
773
+ return r ? (e.dispatch(e.state.tr.insertText(v.value, r.from, r.to)), w(), !0) : !1;
774
+ },
775
+ replaceAll: () => {
776
+ let e = t.value, n = y.value.length;
777
+ if (!e || xe() || be()) return {
778
+ replacedCount: 0,
779
+ skippedCount: n
780
+ };
781
+ let r = y.value.filter((e) => ue(e).status === "allowed"), i = r.filter((e) => e.text === v.value).length, a = r.filter((e) => e.text !== v.value).flatMap((t) => {
782
+ let n = E(e.state.doc, t);
783
+ return n ? [n] : [];
784
+ }).toSorted((e, t) => t.from - e.from), o = a.length + i, s = {
785
+ replacedCount: o,
786
+ skippedCount: n - o
787
+ };
788
+ if (!a.length) return s;
789
+ let c = e.state.tr;
790
+ for (let e of a) c = c.insertText(v.value, e.from, e.to);
791
+ return e.dispatch(c), w(), s;
792
+ },
793
+ clear: me
794
+ };
795
+ }
796
+ function yt(e, t) {
797
+ if (t < e.top + 40) {
798
+ let n = Math.max(0, e.top + 40 - t);
799
+ return -Math.min(12, n / 40 * 12);
800
+ }
801
+ if (t > e.bottom - 40) {
802
+ let n = Math.max(0, t - (e.bottom - 40));
803
+ return Math.min(12, n / 40 * 12);
804
+ }
805
+ return 0;
806
+ }
807
+ //#endregion
808
+ //#region src/composables/useDragAutoScroll.ts
809
+ function z({ pagesContainer: e, onScrollExtendSelection: t }) {
810
+ let n = null, r = 0, a = 0, o = !1;
811
+ function s() {
812
+ return x(e.value);
813
+ }
814
+ function c() {
815
+ o = !1, n !== null && (cancelAnimationFrame(n), n = null);
816
+ }
817
+ function l() {
818
+ if (!o) return;
819
+ let e = s();
820
+ if (!e) return;
821
+ let i = yt(e.getBoundingClientRect(), a);
822
+ i !== 0 && (S(e, i), t(r, a)), n = requestAnimationFrame(l);
823
+ }
824
+ function u() {
825
+ o || (o = !0, n = requestAnimationFrame(l));
826
+ }
827
+ function d(e, t) {
828
+ if (r = e, a = t, !o) {
829
+ let e = s();
830
+ if (!e) return;
831
+ let n = e.getBoundingClientRect();
832
+ (t < n.top + 40 || t > n.bottom - 40) && u();
833
+ }
834
+ }
835
+ return i(() => c()), {
836
+ updateMousePosition: d,
837
+ stopAutoScroll: c
838
+ };
839
+ }
840
+ //#endregion
841
+ //#region src/composables/useTableResize.ts
842
+ function B() {
843
+ let e = {
844
+ active: !1,
845
+ startX: 0,
846
+ handle: null,
847
+ columnIndex: 0,
848
+ tablePmStart: 0,
849
+ origWidths: {
850
+ left: 0,
851
+ right: 0
852
+ }
853
+ }, t = {
854
+ active: !1,
855
+ startY: 0,
856
+ handle: null,
857
+ rowIndex: 0,
858
+ isEdge: !1,
859
+ tablePmStart: 0,
860
+ origHeight: 0
861
+ }, n = {
862
+ active: !1,
863
+ startX: 0,
864
+ handle: null,
865
+ columnIndex: 0,
866
+ tablePmStart: 0,
867
+ origWidth: 0
868
+ }, r = null;
869
+ function i() {
870
+ return e.active || t.active || n.active;
871
+ }
872
+ function a(i, a) {
873
+ let o = i.target;
874
+ return o instanceof HTMLElement ? o.classList.contains("layout-table-resize-handle") ? (i.preventDefault(), i.stopPropagation(), r = a, e.active = !0, e.startX = i.clientX, e.handle = o, o.classList.add("dragging"), e.columnIndex = parseInt(o.dataset.columnIndex ?? "0", 10), e.tablePmStart = parseInt(o.dataset.tablePmStart ?? "0", 10), V(a, e), !0) : o.classList.contains("layout-table-row-resize-handle") || o.classList.contains("layout-table-edge-handle-bottom") ? (i.preventDefault(), i.stopPropagation(), r = a, t.active = !0, t.startY = i.clientY, t.handle = o, t.isEdge = o.dataset.isEdge === "bottom", o.classList.add("dragging"), t.rowIndex = parseInt(o.dataset.rowIndex ?? "0", 10), t.tablePmStart = parseInt(o.dataset.tablePmStart ?? "0", 10), H(a, t, o), !0) : o.classList.contains("layout-table-edge-handle-right") ? (i.preventDefault(), i.stopPropagation(), r = a, n.active = !0, n.startX = i.clientX, n.handle = o, o.classList.add("dragging"), n.columnIndex = parseInt(o.dataset.columnIndex ?? "0", 10), n.tablePmStart = parseInt(o.dataset.tablePmStart ?? "0", 10), U(a, n), !0) : !1 : !1;
875
+ }
876
+ function o(r) {
877
+ if (e.active && e.handle) {
878
+ r.preventDefault();
879
+ let t = r.clientX - e.startX, n = parseFloat(e.handle.style.left);
880
+ e.handle.style.left = `${n + t}px`, e.startX = r.clientX;
881
+ let i = Math.round(t * O), a = e.origWidths.left + i, o = e.origWidths.right - i;
882
+ a >= Xe && o >= Xe && (e.origWidths = {
883
+ left: a,
884
+ right: o
885
+ });
886
+ return;
887
+ }
888
+ if (t.active && t.handle) {
889
+ r.preventDefault();
890
+ let e = r.clientY - t.startY, n = parseFloat(t.handle.style.top);
891
+ t.handle.style.top = `${n + e}px`, t.startY = r.clientY;
892
+ let i = Math.round(e * O), a = t.origHeight + i;
893
+ a >= D && (t.origHeight = a);
894
+ return;
895
+ }
896
+ if (n.active && n.handle) {
897
+ r.preventDefault();
898
+ let e = r.clientX - n.startX, t = parseFloat(n.handle.style.left);
899
+ n.handle.style.left = `${t + e}px`, n.startX = r.clientX;
900
+ let i = Math.round(e * O), a = n.origWidth + i;
901
+ a >= Xe && (n.origWidth = a);
902
+ }
903
+ }
904
+ function s(i) {
905
+ if (e.active) {
906
+ e.active = !1, e.handle?.classList.remove("dragging"), r && Ze(r, {
907
+ pmStart: e.tablePmStart,
908
+ colIdx: e.columnIndex,
909
+ newLeft: e.origWidths.left,
910
+ newRight: e.origWidths.right
911
+ }), e.handle = null;
912
+ return;
913
+ }
914
+ if (t.active) {
915
+ t.active = !1, t.handle?.classList.remove("dragging"), r && $e(r, {
916
+ pmStart: t.tablePmStart,
917
+ rowIdx: t.rowIndex,
918
+ newHeight: t.origHeight
919
+ }), t.handle = null;
920
+ return;
921
+ }
922
+ n.active && (n.active = !1, n.handle?.classList.remove("dragging"), r && Qe(r, {
923
+ pmStart: n.tablePmStart,
924
+ colIdx: n.columnIndex,
925
+ newWidth: n.origWidth
926
+ }), n.handle = null);
927
+ }
928
+ function c() {
929
+ return document.addEventListener("mousemove", o), document.addEventListener("mouseup", s), () => {
930
+ document.removeEventListener("mousemove", o), document.removeEventListener("mouseup", s);
931
+ };
932
+ }
933
+ return {
934
+ tryStartResize: a,
935
+ install: c,
936
+ isResizing: i
937
+ };
938
+ }
939
+ function V(e, t) {
940
+ let n = tt(e, t.tablePmStart, t.columnIndex);
941
+ n && (t.origWidths = n);
942
+ }
943
+ function H(e, t, n) {
944
+ let r = nt(e, t.tablePmStart, t.rowIndex);
945
+ if (r != null) {
946
+ t.origHeight = r;
947
+ return;
948
+ }
949
+ let i = n.closest(".layout-table")?.querySelector(`[data-row-index="${t.rowIndex}"]`), a = i ? i.getBoundingClientRect().height : 30;
950
+ t.origHeight = Math.round(a * O);
951
+ }
952
+ function U(e, t) {
953
+ let n = et(e, t.tablePmStart, t.columnIndex);
954
+ n != null && (t.origWidth = n);
955
+ }
956
+ //#endregion
957
+ //#region src/composables/useTrackedChanges.ts
958
+ function bt(t, n) {
959
+ return e(() => (n.value, rt(t.value?.state ?? null)));
960
+ }
961
+ //#endregion
962
+ //#region src/composables/useZoom.ts
963
+ var W = at, xt = it, St = [
964
+ .5,
965
+ .75,
966
+ 1,
967
+ 1.25,
968
+ 1.5,
969
+ 2
970
+ ];
971
+ function Ct(t = 1) {
972
+ let i = s(Math.max(W, Math.min(xt, t))), a = e(() => Math.round(i.value * 100)), o = e(() => i.value <= W), c = e(() => i.value >= xt);
973
+ function l(e) {
974
+ i.value = Math.max(W, Math.min(xt, Math.round(e * 100) / 100));
975
+ }
976
+ function u() {
977
+ l(i.value + k);
978
+ }
979
+ function d() {
980
+ l(i.value - k);
981
+ }
982
+ function f() {
983
+ l(1);
984
+ }
985
+ function p(e) {
986
+ (e.ctrlKey || e.metaKey) && (e.preventDefault(), e.deltaY < 0 ? u() : d());
987
+ }
988
+ function m(e) {
989
+ (e.ctrlKey || e.metaKey) && (e.shiftKey || e.altKey || (e.key === "=" || e.key === "+" ? (e.preventDefault(), u()) : e.key === "-" ? (e.preventDefault(), d()) : e.key === "0" && (e.preventDefault(), f())));
990
+ }
991
+ function h() {
992
+ r(() => document.addEventListener("keydown", m)), n(() => document.removeEventListener("keydown", m));
993
+ }
994
+ return {
995
+ zoom: i,
996
+ zoomPercent: a,
997
+ isMinZoom: o,
998
+ isMaxZoom: c,
999
+ setZoom: l,
1000
+ zoomIn: u,
1001
+ zoomOut: d,
1002
+ resetZoom: f,
1003
+ handleWheel: p,
1004
+ handleKeyDown: m,
1005
+ installShortcuts: h,
1006
+ ZOOM_PRESETS: St
1007
+ };
1008
+ }
1009
+ //#endregion
1010
+ export { z as a, I as c, st as d, B as i, N as l, rt as n, vt as o, bt as r, R as s, Ct as t, F as u };