@inkbar/vue 0.5.0 → 0.7.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 (56) hide show
  1. package/README.md +24 -2
  2. package/dist/components/InkCommand.js +7 -0
  3. package/dist/components/InkCommand.js.map +1 -0
  4. package/dist/components/InkCommand.vue.d.ts +23 -0
  5. package/dist/components/InkCommand.vue.d.ts.map +1 -0
  6. package/dist/components/InkCommand.vue_vue_type_script_setup_true_lang.js +51 -0
  7. package/dist/components/InkCommand.vue_vue_type_script_setup_true_lang.js.map +1 -0
  8. package/dist/components/InkFindBar.js +7 -0
  9. package/dist/components/InkFindBar.js.map +1 -0
  10. package/dist/components/InkFindBar.vue.d.ts +4 -0
  11. package/dist/components/InkFindBar.vue.d.ts.map +1 -0
  12. package/dist/components/InkFindBar.vue_vue_type_script_setup_true_lang.js +133 -0
  13. package/dist/components/InkFindBar.vue_vue_type_script_setup_true_lang.js.map +1 -0
  14. package/dist/components/InkPageInput.js.map +1 -1
  15. package/dist/components/InkPageInput.vue.d.ts.map +1 -1
  16. package/dist/components/InkPageInput.vue_vue_type_script_setup_true_lang.js +1 -1
  17. package/dist/components/InkPageInput.vue_vue_type_script_setup_true_lang.js.map +1 -1
  18. package/dist/components/InkRoot.js.map +1 -1
  19. package/dist/components/InkRoot.vue.d.ts +8 -1
  20. package/dist/components/InkRoot.vue.d.ts.map +1 -1
  21. package/dist/components/InkRoot.vue_vue_type_script_setup_true_lang.js +154 -106
  22. package/dist/components/InkRoot.vue_vue_type_script_setup_true_lang.js.map +1 -1
  23. package/dist/components/InkSearchButton.js +7 -0
  24. package/dist/components/InkSearchButton.js.map +1 -0
  25. package/dist/components/InkSearchButton.vue.d.ts +19 -0
  26. package/dist/components/InkSearchButton.vue.d.ts.map +1 -0
  27. package/dist/components/InkSearchButton.vue_vue_type_script_setup_true_lang.js +43 -0
  28. package/dist/components/InkSearchButton.vue_vue_type_script_setup_true_lang.js.map +1 -0
  29. package/dist/components/InkToolButton.js.map +1 -1
  30. package/dist/components/InkToolButton.vue.d.ts.map +1 -1
  31. package/dist/components/InkToolButton.vue_vue_type_script_setup_true_lang.js +36 -35
  32. package/dist/components/InkToolButton.vue_vue_type_script_setup_true_lang.js.map +1 -1
  33. package/dist/components/InkViewport.js.map +1 -1
  34. package/dist/components/InkViewport.vue.d.ts.map +1 -1
  35. package/dist/components/InkViewport.vue_vue_type_script_setup_true_lang.js +6 -2
  36. package/dist/components/InkViewport.vue_vue_type_script_setup_true_lang.js.map +1 -1
  37. package/dist/components/SignatureForm.vue.d.ts +2 -2
  38. package/dist/composables/useCommand.d.ts +23 -0
  39. package/dist/composables/useCommand.d.ts.map +1 -0
  40. package/dist/composables/useCommand.js +22 -0
  41. package/dist/composables/useCommand.js.map +1 -0
  42. package/dist/composables/useSearch.d.ts +12 -0
  43. package/dist/composables/useSearch.d.ts.map +1 -0
  44. package/dist/composables/useSearch.js +27 -0
  45. package/dist/composables/useSearch.js.map +1 -0
  46. package/dist/context.d.ts +21 -4
  47. package/dist/context.d.ts.map +1 -1
  48. package/dist/context.js.map +1 -1
  49. package/dist/index.d.ts +7 -1
  50. package/dist/index.d.ts.map +1 -1
  51. package/dist/index.js +30 -25
  52. package/dist/ref-history.d.ts +12 -3
  53. package/dist/ref-history.d.ts.map +1 -1
  54. package/dist/ref-history.js +27 -16
  55. package/dist/ref-history.js.map +1 -1
  56. package/package.json +6 -5
@@ -1,12 +1,12 @@
1
1
  import { provideInkContext as e } from "../context.js";
2
2
  import { useReadable as t } from "../use-readable.js";
3
3
  import { createRefHistory as n } from "../ref-history.js";
4
- import { computed as r, createBlock as ee, defineComponent as i, onBeforeUnmount as a, onMounted as o, onUpdated as s, openBlock as c, ref as l, renderSlot as te, shallowRef as u, unref as d, useTemplateRef as f, watch as p, withCtx as m } from "vue";
5
- import { InkError as h, createMemorySignatureStore as g, createSignatureLibrary as _, openDocument as v } from "@inkbar/core";
6
- import { FONT_FAMILIES as y, SIGNATURE_FONTS as b, createToolOptions as x, cssVariableDefaults as S, trackToolStyle as C } from "@inkbar/core/dom";
7
- import { Primitive as w } from "reka-ui";
4
+ import { computed as r, createBlock as i, defineComponent as a, mergeProps as ee, onBeforeUnmount as te, onMounted as ne, onUnmounted as re, onUpdated as ie, openBlock as ae, ref as o, renderSlot as s, shallowRef as c, unref as l, useTemplateRef as u, watch as d, withCtx as f } from "vue";
5
+ import { InkError as p, createMemorySignatureStore as oe, createSignatureLibrary as se, openDocument as ce, readonly as m, writable as h } from "@inkbar/core";
6
+ import { FONT_FAMILIES as le, SIGNATURE_FONTS as ue, createPluginHost as de, createSearchController as g, createToolOptions as fe, cssVariableDefaults as pe, handleFindKey as me, pageSelectionText as _, trackToolStyle as v, viewerSearchOf as y } from "@inkbar/core/dom";
7
+ import { Primitive as b } from "reka-ui";
8
8
  //#region src/components/InkRoot.vue?vue&type=script&setup=true&lang.ts
9
- var T = /*@__PURE__*/ i({
9
+ var x = /*@__PURE__*/ a({
10
10
  __name: "InkRoot",
11
11
  props: {
12
12
  src: {},
@@ -16,6 +16,7 @@ var T = /*@__PURE__*/ i({
16
16
  annotations: { default: void 0 },
17
17
  tool: { default: void 0 },
18
18
  tools: { default: void 0 },
19
+ plugins: { default: void 0 },
19
20
  decorateAnnotation: {
20
21
  type: Function,
21
22
  default: void 0
@@ -44,154 +45,201 @@ var T = /*@__PURE__*/ i({
44
45
  "error",
45
46
  "activate"
46
47
  ],
47
- setup(i, { expose: T, emit: E }) {
48
- let D = i, O = E, k = f("primitive"), A = u(null);
49
- function j() {
50
- let e = k.value?.$el;
51
- A.value = e instanceof HTMLElement ? e : null;
48
+ setup(a, { expose: x, emit: he }) {
49
+ let S = a, C = he, w = u("primitive"), T = c(null);
50
+ function E() {
51
+ let e = w.value?.$el;
52
+ T.value = e instanceof HTMLElement ? e : null;
52
53
  }
53
- let M = u(null), N = u(null), P = t(() => M.value?.status ?? null, { state: "idle" }), F = r(() => N.value ?? P.value), I = t(() => M.value?.annotations.list ?? null, []), L = t(() => M.value?.annotations.selection ?? null, []), R = u(null), z = u(null), B = l(D.tool ?? "select-text"), V = l(null), H = r(() => D.annotations !== void 0);
54
- function U(e) {
54
+ let D = c(null), O = c(null), k = t(() => D.value?.status ?? null, { state: "idle" }), A = r(() => O.value ?? k.value), j = t(() => D.value?.annotations.list ?? null, []), M = t(() => D.value?.annotations.selection ?? null, []), N = c(null), P = c(null), F = o(S.tool ?? "select-text"), I = o(null), L = r(() => S.annotations !== void 0);
55
+ function R(e) {
56
+ I.value = e, e && C("activate", e);
57
+ }
58
+ let z = () => {};
59
+ function ge(e) {
55
60
  return e === null ? null : typeof e == "string" ? e : "key" in e ? e.key : e;
56
61
  }
57
- let W = 0;
58
- function G() {
59
- M.value?.destroy(), M.value = null;
62
+ let B = 0;
63
+ function V() {
64
+ let e = D.value;
65
+ D.value = null, e?.destroy();
60
66
  }
61
- async function K() {
62
- let e = ++W, t = D.src;
63
- if (G(), q.clear(), t === null) {
64
- N.value = null;
67
+ async function H() {
68
+ let e = ++B, t = S.src;
69
+ if (V(), U.clear(), t === null) {
70
+ O.value = null;
65
71
  return;
66
72
  }
67
- N.value = { state: "loading" }, j();
73
+ O.value = { state: "loading" }, E();
68
74
  let n;
69
75
  try {
70
- n = await v(t, {
71
- assets: D.assets,
72
- password: D.password,
73
- defaults: D.defaults ?? (A.value ? S(A.value) : void 0),
74
- history: H.value ? !1 : D.history ?? !0,
75
- annotations: H.value ? {
76
+ n = await ce(t, {
77
+ assets: S.assets,
78
+ password: S.password,
79
+ defaults: S.defaults ?? (T.value ? pe(T.value) : void 0),
80
+ history: L.value ? !1 : S.history ?? !0,
81
+ annotations: L.value ? {
76
82
  mode: "controlled",
77
- initial: D.annotations ?? [],
83
+ initial: S.annotations ?? [],
78
84
  onChange: (e, t) => {
79
- O("update:annotations", e), O("change", t);
85
+ C("update:annotations", e), C("change", t);
80
86
  }
81
87
  } : { mode: "uncontrolled" }
82
88
  });
83
89
  } catch (t) {
84
- if (e !== W) return;
85
- let n = t instanceof h ? t : new h("InvalidPdf", t instanceof Error ? t.message : String(t), {}, t);
86
- N.value = {
90
+ if (e !== B) return;
91
+ let n = t instanceof p ? t : new p("InvalidPdf", t instanceof Error ? t.message : String(t), {}, t);
92
+ O.value = {
87
93
  state: "error",
88
94
  error: n
89
- }, O("error", n);
95
+ }, C("error", n);
90
96
  return;
91
97
  }
92
- if (e !== W) {
98
+ if (e !== B) {
93
99
  n.destroy();
94
100
  return;
95
101
  }
96
- n.annotations.mode === "controlled" && D.annotations !== void 0 && n.annotations.setControlledValue(D.annotations), M.value = n, N.value = null;
102
+ n.annotations.mode === "controlled" && S.annotations !== void 0 && n.annotations.setControlledValue(S.annotations), D.value = n, O.value = null;
97
103
  let r = n.status.get();
98
- r.state === "ready" ? O("ready", n) : r.state === "error" && O("error", r.error);
104
+ r.state === "ready" ? C("ready", n) : r.state === "error" && C("error", r.error);
99
105
  }
100
- let q = n({
101
- source: () => D.annotations,
102
- apply: (e) => M.value?.annotations.replaceAll(e, "history"),
103
- enabled: r(() => H.value && D.history === !0)
104
- }), J = t(() => M.value?.history.canUndo ?? null, !1), Y = t(() => M.value?.history.canRedo ?? null, !1), X = {
105
- canUndo: r(() => H.value ? q.canUndo.value : J.value),
106
- canRedo: r(() => H.value ? q.canRedo.value : Y.value),
107
- undo: () => H.value ? q.undo() : M.value?.history.undo(),
108
- redo: () => H.value ? q.redo() : M.value?.history.redo(),
109
- clear: () => H.value ? q.clear() : M.value?.history.clear(),
106
+ let U = n({
107
+ source: () => S.annotations,
108
+ apply: (e) => D.value?.annotations.replaceAll(e, "history"),
109
+ enabled: r(() => L.value && S.history === !0),
110
+ store: () => D.value?.annotations.mode === "controlled" ? D.value.annotations : null
111
+ }), _e = t(() => D.value?.history.canUndo ?? null, !1), ve = t(() => D.value?.history.canRedo ?? null, !1), W = {
112
+ canUndo: r(() => L.value ? U.canUndo.value : _e.value),
113
+ canRedo: r(() => L.value ? U.canRedo.value : ve.value),
114
+ undo: () => L.value ? U.undo() : D.value?.history.undo(),
115
+ redo: () => L.value ? U.redo() : D.value?.history.redo(),
116
+ clear: () => L.value ? U.clear() : D.value?.history.clear(),
110
117
  batch: (e) => {
111
- H.value ? q.batch(e) : M.value ? M.value.history.batch(e) : e();
112
- }
113
- }, Z = u(null), Q;
114
- p(M, (e) => {
118
+ L.value ? U.batch(e) : D.value ? D.value.history.batch(e) : e();
119
+ },
120
+ track: (e) => L.value ? U.track(e) : D.value?.history.track(e) ?? z,
121
+ react: (e) => L.value ? U.react(e) : D.value?.history.react(e) ?? z
122
+ }, G = h(null);
123
+ d(D, (e) => G.set(e), { flush: "sync" });
124
+ let K = c(null), q = h(null);
125
+ d(K, (e) => q.set(e), { flush: "sync" });
126
+ let J = h(null);
127
+ d(I, (e) => J.set(e), { flush: "sync" });
128
+ let Y = c(null), X = c(null);
129
+ function ye() {
130
+ let e = g({
131
+ document: m(G),
132
+ viewport: () => N.value
133
+ });
134
+ X.value = e, Y.value = de({
135
+ plugins: S.plugins ?? [],
136
+ document: m(G),
137
+ history: () => W,
138
+ activated: m(J),
139
+ setActivated: (e) => {
140
+ (e === null || D.value?.annotations.get(e)) && R(e);
141
+ },
142
+ root: m(q),
143
+ decorate: () => S.decorateAnnotation,
144
+ viewport: () => N.value,
145
+ search: y(e)
146
+ });
147
+ }
148
+ let be = { onKeydown: xe };
149
+ function xe(e) {
150
+ let t = X.value, n = e.currentTarget;
151
+ t && n instanceof HTMLElement && me(e, t, () => _(n));
152
+ }
153
+ let Z = c(null), Q;
154
+ d(D, (e) => {
115
155
  if (!e) {
116
156
  Z.value = null, Q = void 0;
117
157
  return;
118
158
  }
119
- let t = C({
159
+ let t = v({
120
160
  store: e.annotations,
121
- history: { batch: (e) => X.batch(e) },
122
- tools: D.tools,
123
- tool: B.value
161
+ history: { batch: (e) => W.batch(e) },
162
+ tools: [...S.tools ?? [], ...Y.value?.tools ?? []],
163
+ tool: F.value
124
164
  });
125
165
  Q = (e) => t.setTool(e), Z.value = t.toolStyle;
126
166
  }, {
127
167
  immediate: !0,
128
168
  flush: "sync"
129
- }), p(B, (e) => Q?.(e)), o(() => {
130
- j(), K();
131
- }), s(j), p([() => U(D.src), () => D.password], () => void K()), p(() => D.annotations, (e) => {
132
- e && M.value?.annotations.mode === "controlled" && M.value.annotations.setControlledValue(e);
133
- }), p(() => D.tool, (e) => {
134
- e && (B.value = e);
169
+ }), d(F, (e) => Q?.(e)), ne(() => {
170
+ E();
171
+ try {
172
+ ye();
173
+ } finally {
174
+ H();
175
+ }
176
+ }), ie(E), d([() => ge(S.src), () => S.password], () => void H()), d(() => S.annotations, (e) => {
177
+ e && D.value?.annotations.mode === "controlled" && D.value.annotations.setControlledValue(e);
178
+ }), d(() => S.tool, (e) => {
179
+ e && (F.value = e);
135
180
  });
136
- function ne(e) {
137
- let t = z.value;
138
- B.value === e && t?.active.get() === e && t.set(e), B.value = e, O("update:tool", e);
181
+ function Se(e) {
182
+ let t = P.value;
183
+ F.value === e && t?.active.get() === e && t.set(e), F.value = e, C("update:tool", e);
139
184
  }
140
- a(() => {
141
- W++, G();
185
+ te(() => {
186
+ B++, V();
187
+ }), re(() => {
188
+ Y.value?.destroy(), Y.value = null, X.value?.destroy(), X.value = null;
142
189
  });
143
- let $ = r(() => _(D.signatures ?? g()));
144
- p($, (e) => void e.refresh(), { immediate: !0 });
145
- let re = x();
190
+ let $ = r(() => se(S.signatures ?? oe()));
191
+ d($, (e) => void e.refresh(), { immediate: !0 });
192
+ let Ce = fe();
146
193
  return e({
147
- assets: r(() => D.assets),
148
- document: M,
149
- status: F,
150
- annotations: I,
151
- selection: L,
152
- viewport: R,
153
- tools: z,
154
- tool: B,
155
- setTool: ne,
156
- hostTools: r(() => D.tools),
157
- decorateAnnotation: r(() => D.decorateAnnotation),
158
- fonts: r(() => D.fonts ?? y),
159
- toolOptions: re,
194
+ assets: r(() => S.assets),
195
+ document: D,
196
+ status: A,
197
+ annotations: j,
198
+ selection: M,
199
+ viewport: N,
200
+ tools: P,
201
+ tool: F,
202
+ setTool: Se,
203
+ hostTools: r(() => S.tools),
204
+ decorateAnnotation: r(() => S.decorateAnnotation),
205
+ fonts: r(() => S.fonts ?? le),
206
+ toolOptions: Ce,
160
207
  signatures: $,
161
- signatureFonts: r(() => D.signatureFonts ?? b),
208
+ signatureFonts: r(() => S.signatureFonts ?? ue),
162
209
  toolStyle: Z,
163
- zoomModel: r(() => D.zoom),
164
- pageModel: r(() => D.page),
165
- reportZoom: (e) => O("update:zoom", e),
166
- reportPage: (e) => O("update:page", e),
167
- activated: V,
168
- setActivated(e) {
169
- V.value = e, e && O("activate", e);
170
- },
171
- history: X,
172
- rootEl: A
173
- }), T({
174
- document: M,
175
- status: F,
176
- rootEl: A,
177
- history: X
178
- }), (e, t) => (c(), ee(d(w), {
210
+ zoomModel: r(() => S.zoom),
211
+ pageModel: r(() => S.page),
212
+ reportZoom: (e) => C("update:zoom", e),
213
+ reportPage: (e) => C("update:page", e),
214
+ activated: I,
215
+ setActivated: R,
216
+ pluginHost: Y,
217
+ search: X,
218
+ viewportEl: K,
219
+ history: W,
220
+ rootEl: T
221
+ }), x({
222
+ document: D,
223
+ status: A,
224
+ rootEl: T,
225
+ history: W
226
+ }), (e, t) => (ae(), i(l(b), ee({
179
227
  ref_key: "primitive",
180
- ref: k,
181
- "as-child": D.asChild,
228
+ ref: w,
229
+ "as-child": S.asChild,
182
230
  as: "div",
183
231
  "data-ink-root": "",
184
- "data-state": F.value.state
185
- }, {
186
- default: m(() => [te(e.$slots, "default", {
187
- status: F.value,
188
- document: M.value
232
+ "data-state": A.value.state
233
+ }, be), {
234
+ default: f(() => [s(e.$slots, "default", {
235
+ status: A.value,
236
+ document: D.value
189
237
  })]),
190
238
  _: 3
191
- }, 8, ["as-child", "data-state"]));
239
+ }, 16, ["as-child", "data-state"]));
192
240
  }
193
241
  });
194
242
  //#endregion
195
- export { T as default };
243
+ export { x as default };
196
244
 
197
245
  //# sourceMappingURL=InkRoot.vue_vue_type_script_setup_true_lang.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"InkRoot.vue_vue_type_script_setup_true_lang.js","names":["_openBlock","_createBlock","_unref","_withCtx","_renderSlot","InkRoot_vue_vue_type_script_setup_true_lang_default","__expose","__emit","props","__props","emit","primitive","useTemplateRef","rootEl","shallowRef","syncRootEl","el","document","override","documentStatus","useReadable","status","computed","annotationList","selection","viewport","toolController","internalTool","ref","activated","controlled","identity","src","generation","release","open","gen","refHistory","doc","openDocument","cssVariableDefaults","next","change","cause","error","InkError","s","createRefHistory","list","coreCanUndo","coreCanRedo","inkHistory","fn","toolStyle","setStyleTool","watch","tracker","trackToolStyle","id","onMounted","onUpdated","t","setTool","tc","signatures","createSignatureLibrary","createMemorySignatureStore","lib","toolOptions","createToolOptions","provideInkContext","FONT_FAMILIES","SIGNATURE_FONTS","z","p","openBlock","createBlock","unref","Primitive","withCtx","renderSlot","_ctx"],"sources":["../../src/components/InkRoot.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport {\n createMemorySignatureStore,\n createSignatureLibrary,\n InkError,\n openDocument,\n} from '@inkbar/core'\nimport {\n createToolOptions,\n cssVariableDefaults,\n FONT_FAMILIES,\n SIGNATURE_FONTS,\n trackToolStyle,\n} from '@inkbar/core/dom'\nimport { Primitive } from 'reka-ui'\nimport {\n computed,\n onBeforeUnmount,\n onMounted,\n onUpdated,\n ref,\n shallowRef,\n useTemplateRef,\n watch,\n} from 'vue'\n\nimport { provideInkContext, type InkHistory, type InkStatus } from '../context'\nimport { createRefHistory } from '../ref-history'\nimport { useReadable } from '../use-readable'\n\nimport type {\n Annotation,\n AnnotationChange,\n AnnotationDefaults,\n DocumentSource,\n InkDocument,\n PdfAssets,\n SignatureStore,\n} from '@inkbar/core'\nimport type {\n DecorateAnnotation,\n Tool,\n ToolController,\n ToolId,\n ToolStyle,\n Viewport,\n ZoomValue,\n} from '@inkbar/core/dom'\n\nconst props = withDefaults(\n defineProps<{\n src: DocumentSource | null\n assets: PdfAssets\n password?: string | undefined\n /** Colour defaults. Without it, the theme's CSS variables on the root element apply. */\n defaults?: AnnotationDefaults | undefined\n /**\n * Pass (with v-model) to put annotations under the host's control. The mode is fixed when a\n * document opens: passing or dropping this prop later takes effect on the next open.\n */\n annotations?: Annotation[] | undefined\n tool?: ToolId | undefined\n /**\n * Host tools, added to the built-ins; one with a built-in's id replaces it. Read when a\n * document opens.\n */\n tools?: Tool[] | undefined\n /**\n * Adds `data-*` attributes, classes and a screen-reader description to each annotation's\n * element (see `DecorateAnnotation`). Decorations re-apply whenever the annotations change\n * and when this prop changes, without rebuilding the viewer. Pass a new function when its\n * output would change for any other reason.\n */\n decorateAnnotation?: DecorateAnnotation | undefined\n /**\n * The font families text boxes offer, replacing the PDF standard families\n * (`FONT_FAMILIES`). Fonts beyond those are the PDF writer's to embed.\n */\n fonts?: string[] | undefined\n /**\n * Where saved signatures live. Default: memory, gone on reload.\n * `createLocalSignatureStore` keeps them in the browser; a host can keep them anywhere.\n * A new store takes effect at once, for the menus and the `signature` tool alike.\n */\n signatures?: SignatureStore | undefined\n /** The handwriting fonts a typed signature offers; the host loads them. */\n signatureFonts?: string[] | undefined\n page?: number | undefined\n zoom?: ZoomValue | undefined\n /** Undo history. Defaults to on for uncontrolled, off for controlled. */\n history?: boolean | undefined\n asChild?: boolean\n }>(),\n {\n password: undefined,\n defaults: undefined,\n annotations: undefined,\n tool: undefined,\n tools: undefined,\n decorateAnnotation: undefined,\n fonts: undefined,\n signatures: undefined,\n signatureFonts: undefined,\n page: undefined,\n zoom: undefined,\n history: undefined,\n asChild: false,\n }\n)\n\nconst emit = defineEmits<{\n 'update:annotations': [next: Annotation[]]\n change: [change: AnnotationChange]\n 'update:tool': [tool: ToolId]\n 'update:page': [page: number]\n 'update:zoom': [zoom: ZoomValue]\n ready: [doc: InkDocument]\n error: [error: InkError]\n activate: [id: string]\n}>()\n\ntype TestHookElement = HTMLElement & { __inkDocument?: InkDocument | undefined }\n\n// A template ref on Primitive is a component instance; the context needs its element.\nconst primitive = useTemplateRef<{ $el: unknown }>('primitive')\nconst rootEl = shallowRef<HTMLElement | null>(null)\nfunction syncRootEl(): void {\n const el = primitive.value?.$el\n rootEl.value = el instanceof HTMLElement ? el : null\n}\n\nconst document = shallowRef<InkDocument | null>(null)\n/** Overrides the document's status while opening, and when opening itself failed. */\nconst override = shallowRef<InkStatus | null>(null)\nconst idle: InkStatus = { state: 'idle' }\nconst documentStatus = useReadable<InkStatus>(() => document.value?.status ?? null, idle)\nconst status = computed<InkStatus>(() => override.value ?? documentStatus.value)\nconst annotationList = useReadable<readonly Annotation[]>(\n () => document.value?.annotations.list ?? null,\n []\n)\nconst selection = useReadable<readonly string[]>(\n () => document.value?.annotations.selection ?? null,\n []\n)\nconst viewport = shallowRef<Viewport | null>(null)\nconst toolController = shallowRef<ToolController | null>(null)\nconst internalTool = ref<ToolId>(props.tool ?? 'select-text')\nconst activated = ref<string | null>(null)\n\nconst controlled = computed(() => props.annotations !== undefined)\n\n/** Signed URLs change; the key does not. Bytes and Blobs are their own identity. */\nfunction identity(src: DocumentSource | null): unknown {\n if (src === null) return null\n if (typeof src === 'string') return src\n if ('key' in src) return src.key\n return src\n}\n\nfunction setTestHook(doc: InkDocument | undefined): void {\n if (import.meta.env.DEV && rootEl.value)\n (rootEl.value as TestHookElement).__inkDocument = doc\n}\n\nlet generation = 0\nfunction release(): void {\n document.value?.destroy()\n document.value = null\n setTestHook(undefined)\n}\n\nasync function open(): Promise<void> {\n const gen = ++generation\n const src = props.src\n release()\n refHistory.clear()\n if (src === null) {\n override.value = null\n return\n }\n override.value = { state: 'loading' }\n syncRootEl()\n let doc: InkDocument\n try {\n doc = await openDocument(src, {\n assets: props.assets,\n password: props.password,\n defaults:\n props.defaults ?? (rootEl.value ? cssVariableDefaults(rootEl.value) : undefined),\n // Controlled hosts get the ref history below; core's own stack stays off.\n history: controlled.value ? false : (props.history ?? true),\n annotations: controlled.value\n ? {\n mode: 'controlled',\n initial: props.annotations ?? [],\n onChange: (next, change) => {\n emit('update:annotations', next)\n emit('change', change)\n },\n }\n : { mode: 'uncontrolled' },\n })\n } catch (cause) {\n if (gen !== generation) return\n const error =\n cause instanceof InkError\n ? cause\n : new InkError(\n 'InvalidPdf',\n cause instanceof Error ? cause.message : String(cause),\n {},\n cause\n )\n override.value = { state: 'error', error }\n emit('error', error)\n return\n }\n if (gen !== generation) {\n doc.destroy()\n return\n }\n // The prop may have changed while the file loaded, when there was no store to apply it to.\n if (doc.annotations.mode === 'controlled' && props.annotations !== undefined)\n doc.annotations.setControlledValue(props.annotations)\n document.value = doc\n override.value = null\n setTestHook(doc)\n const s = doc.status.get()\n if (s.state === 'ready') emit('ready', doc)\n else if (s.state === 'error') emit('error', s.error)\n}\n\nconst refHistory = createRefHistory({\n source: () => props.annotations,\n apply: (list) => document.value?.annotations.replaceAll(list, 'history'),\n enabled: computed(() => controlled.value && props.history === true),\n})\nconst coreCanUndo = useReadable(() => document.value?.history.canUndo ?? null, false)\nconst coreCanRedo = useReadable(() => document.value?.history.canRedo ?? null, false)\nconst inkHistory: InkHistory = {\n canUndo: computed(() =>\n controlled.value ? refHistory.canUndo.value : coreCanUndo.value\n ),\n canRedo: computed(() =>\n controlled.value ? refHistory.canRedo.value : coreCanRedo.value\n ),\n undo: () => (controlled.value ? refHistory.undo() : document.value?.history.undo()),\n redo: () => (controlled.value ? refHistory.redo() : document.value?.history.redo()),\n clear: () => (controlled.value ? refHistory.clear() : document.value?.history.clear()),\n batch: (fn) => {\n if (controlled.value) refHistory.batch(fn)\n else if (document.value) document.value.history.batch(fn)\n else fn()\n },\n}\n\n/** The document's tool style; it batches through `inkHistory`, whichever mode is on. */\nconst toolStyle = shallowRef<ToolStyle | null>(null)\nlet setStyleTool: ((id: ToolId) => void) | undefined\nwatch(\n document,\n (doc) => {\n if (!doc) {\n toolStyle.value = null\n setStyleTool = undefined\n return\n }\n const tracker = trackToolStyle({\n store: doc.annotations,\n history: { batch: (fn) => inkHistory.batch(fn) },\n tools: props.tools,\n tool: internalTool.value,\n })\n setStyleTool = (id) => tracker.setTool(id)\n toolStyle.value = tracker.toolStyle\n },\n // Sync: the style is in place before InkViewport's watcher mounts the engine with it.\n { immediate: true, flush: 'sync' }\n)\nwatch(internalTool, (id) => setStyleTool?.(id))\n\n// Open on the client only: on the server InkRoot renders its empty slot.\nonMounted(() => {\n syncRootEl()\n void open()\n})\nonUpdated(syncRootEl)\n\n// Separate sources, so a new `{ url, key }` object with the same key compares equal.\nwatch([() => identity(props.src), () => props.password], () => void open())\n\nwatch(\n () => props.annotations,\n (next) => {\n if (next && document.value?.annotations.mode === 'controlled')\n document.value.annotations.setControlledValue(next)\n }\n)\n\nwatch(\n () => props.tool,\n (t) => {\n if (t) internalTool.value = t\n }\n)\n\nfunction setTool(id: ToolId): void {\n // Picking the active tool again starts it afresh, as after a one-shot tool's use.\n const tc = toolController.value\n if (internalTool.value === id && tc?.active.get() === id) tc.set(id)\n internalTool.value = id\n emit('update:tool', id)\n}\n\nonBeforeUnmount(() => {\n generation++\n release()\n})\n\nconst signatures = computed(() =>\n createSignatureLibrary(props.signatures ?? createMemorySignatureStore())\n)\nwatch(signatures, (lib) => void lib.refresh(), { immediate: true })\n/** Tool options last as long as the root; the tool style is per document. */\nconst toolOptions = createToolOptions()\n\nprovideInkContext({\n assets: computed(() => props.assets),\n document,\n status,\n annotations: annotationList,\n selection,\n viewport,\n tools: toolController,\n tool: internalTool,\n setTool,\n hostTools: computed(() => props.tools),\n decorateAnnotation: computed(() => props.decorateAnnotation),\n fonts: computed(() => props.fonts ?? FONT_FAMILIES),\n toolOptions,\n signatures,\n signatureFonts: computed(() => props.signatureFonts ?? SIGNATURE_FONTS),\n toolStyle,\n zoomModel: computed(() => props.zoom),\n pageModel: computed(() => props.page),\n reportZoom: (z) => emit('update:zoom', z),\n reportPage: (p) => emit('update:page', p),\n activated,\n setActivated(id) {\n activated.value = id\n if (id) emit('activate', id)\n },\n history: inkHistory,\n rootEl,\n})\n\n// `history` is what `useHistory()` returns inside the root, for hosts that hold a template ref:\n// a controlled host calls `history.clear()` after loading its saved list.\ndefineExpose({ document, status, rootEl, history: inkHistory })\n</script>\n\n<template>\n <Primitive\n ref=\"primitive\"\n :as-child=\"props.asChild\"\n as=\"div\"\n data-ink-root\n :data-state=\"status.state\"\n >\n <slot :status=\"status\" :document=\"document\" />\n </Primitive>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAiDA,IAAMQ,IAAQC,GA6DRC,IAAOH,GAcPI,IAAYC,EAAiC,WAAW,GACxDC,IAASC,EAA+B,IAAI;EAClD,SAASC,IAAmB;GAC1B,IAAMC,IAAKL,EAAU,OAAO;GAC5B,EAAO,QAAQK,aAAc,cAAcA,IAAK;EAClD;EAEA,IAAMC,IAAWH,EAA+B,IAAI,GAE9CI,IAAWJ,EAA6B,IAAI,GAE5CK,IAAiBC,QAA6BH,EAAS,OAAO,UAAU,MAAM,EAD1D,OAAO,OACmD,CAAI,GAClFI,IAASC,QAA0BJ,EAAS,SAASC,EAAe,KAAK,GACzEI,IAAiBH,QACfH,EAAS,OAAO,YAAY,QAAQ,MAC1C,CAAC,CACH,GACMO,IAAYJ,QACVH,EAAS,OAAO,YAAY,aAAa,MAC/C,CAAC,CACH,GACMQ,IAAWX,EAA4B,IAAI,GAC3CY,IAAiBZ,EAAkC,IAAI,GACvDa,IAAeC,EAAYpB,EAAM,QAAQ,aAAa,GACtDqB,IAAYD,EAAmB,IAAI,GAEnCE,IAAaR,QAAed,EAAM,gBAAgB,KAAA,CAAS;EAGjE,SAASuB,EAAS,GAAqC;GAIrD,OAHIC,MAAQ,OAAa,OACrB,OAAOA,KAAQ,WAAiBA,IAChC,SAASA,IAAYA,EAAI,MACtBA;EACT;EAOA,IAAIC,IAAa;EACjB,SAASC,IAAgB;GAEvB,AADAjB,EAAS,OAAO,QAAQ,GACxB,EAAS,QAAQ;EAEnB;EAEA,eAAekB,IAAsB;GACnC,IAAMC,IAAM,EAA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,CAAC;GACxC;GACA,aAAa,GAAI;IAEf,AADA,EAAU,QAAQhB,GACdA,KAAIhD,EAAK,YAAYgD,CAAE;GAC7B;GACA,SAASP;GACT;EACF,CAAC,GAID7C,EAAa;GAAE;GAAU;GAAQ;GAAQ,SAAS6C;EAAW,CAAC,cAI5DnD,EAAA,GAAAC,GAQYC,EAAA4E,CAAA,GAAA;GAPN,SAAA;GAAJ,KAAInE;GACH,YAAUH,EAAM;GACjB,IAAG;GACH,iBAAA;GACC,cAAYa,EAAA,MAAO;;GAEpB,SAAAlB,QAA8C,CAA9CC,GAA8C6E,EAAA,QAAA,WAAA;IAAvC,QAAQ5D,EAAA;IAAS,UAAUJ,EAAA"}
1
+ {"version":3,"file":"InkRoot.vue_vue_type_script_setup_true_lang.js","names":["_openBlock","_createBlock","_unref","_mergeProps","_withCtx","_renderSlot","InkRoot_vue_vue_type_script_setup_true_lang_default","__expose","__emit","props","__props","emit","primitive","useTemplateRef","rootEl","shallowRef","syncRootEl","el","document","override","documentStatus","useReadable","status","computed","annotationList","selection","viewport","toolController","internalTool","ref","activated","controlled","setActivated","id","noop","identity","src","generation","release","doc","open","gen","refHistory","openDocument","cssVariableDefaults","next","change","cause","error","InkError","s","createRefHistory","list","coreCanUndo","coreCanRedo","inkHistory","fn","store","hostDocument","writable","viewportEl","hostRoot","hostActivated","pluginHost","search","setUpPlugins","controller","createSearchController","readonly","createPluginHost","viewerSearchOf","rootListeners","onKeydown","root","handleFindKey","pageSelectionText","toolStyle","setStyleTool","watch","tracker","trackToolStyle","onMounted","onUpdated","t","setTool","tc","onBeforeUnmount","onUnmounted","signatures","createSignatureLibrary","createMemorySignatureStore","lib","toolOptions","createToolOptions","provideInkContext","FONT_FAMILIES","SIGNATURE_FONTS","z","p","openBlock","createBlock","unref","Primitive","mergeProps","withCtx","renderSlot","_ctx"],"sources":["../../src/components/InkRoot.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport {\n createMemorySignatureStore,\n createSignatureLibrary,\n InkError,\n openDocument,\n readonly,\n writable,\n} from '@inkbar/core'\nimport {\n createPluginHost,\n createSearchController,\n createToolOptions,\n handleFindKey,\n pageSelectionText,\n viewerSearchOf,\n cssVariableDefaults,\n FONT_FAMILIES,\n SIGNATURE_FONTS,\n trackToolStyle,\n} from '@inkbar/core/dom'\nimport { Primitive } from 'reka-ui'\nimport {\n computed,\n onBeforeUnmount,\n onUnmounted,\n onMounted,\n onUpdated,\n ref,\n shallowRef,\n useTemplateRef,\n watch,\n} from 'vue'\n\nimport { provideInkContext, type InkHistory, type InkStatus } from '../context'\nimport { createRefHistory } from '../ref-history'\nimport { useReadable } from '../use-readable'\n\nimport type {\n Annotation,\n AnnotationChange,\n AnnotationDefaults,\n DocumentSource,\n InkDocument,\n PdfAssets,\n SignatureStore,\n} from '@inkbar/core'\nimport type {\n DecorateAnnotation,\n InkPlugin,\n PluginHost,\n SearchController,\n Tool,\n ToolController,\n ToolId,\n ToolStyle,\n Viewport,\n ZoomValue,\n} from '@inkbar/core/dom'\n\nconst props = withDefaults(\n defineProps<{\n src: DocumentSource | null\n assets: PdfAssets\n password?: string | undefined\n /** Colour defaults. Without it, the theme's CSS variables on the root element apply. */\n defaults?: AnnotationDefaults | undefined\n /**\n * Pass (with v-model) to put annotations under the host's control. The mode is fixed when a\n * document opens: passing or dropping this prop later takes effect on the next open.\n */\n annotations?: Annotation[] | undefined\n tool?: ToolId | undefined\n /**\n * Host tools, added to the built-ins; one with a built-in's id replaces it. Read when a\n * document opens.\n */\n tools?: Tool[] | undefined\n /**\n * Plugins, set up once when the root is created; a later change to this prop is not\n * applied. Their tools join `tools`, their decoration and page layers apply to every\n * document, and their commands are placed with `InkCommand` or `useCommand`.\n */\n plugins?: InkPlugin[] | undefined\n /**\n * Adds `data-*` attributes, classes and a screen-reader description to each annotation's\n * element (see `DecorateAnnotation`). Decorations re-apply whenever the annotations change\n * and when this prop changes, without rebuilding the viewer. Pass a new function when its\n * output would change for any other reason.\n */\n decorateAnnotation?: DecorateAnnotation | undefined\n /**\n * The font families text boxes offer, replacing the PDF standard families\n * (`FONT_FAMILIES`). Fonts beyond those are the PDF writer's to embed.\n */\n fonts?: string[] | undefined\n /**\n * Where saved signatures live. Default: memory, gone on reload.\n * `createLocalSignatureStore` keeps them in the browser; a host can keep them anywhere.\n * A new store takes effect at once, for the menus and the `signature` tool alike.\n */\n signatures?: SignatureStore | undefined\n /** The handwriting fonts a typed signature offers; the host loads them. */\n signatureFonts?: string[] | undefined\n page?: number | undefined\n zoom?: ZoomValue | undefined\n /** Undo history. Defaults to on for uncontrolled, off for controlled. */\n history?: boolean | undefined\n asChild?: boolean\n }>(),\n {\n password: undefined,\n defaults: undefined,\n annotations: undefined,\n tool: undefined,\n tools: undefined,\n plugins: undefined,\n decorateAnnotation: undefined,\n fonts: undefined,\n signatures: undefined,\n signatureFonts: undefined,\n page: undefined,\n zoom: undefined,\n history: undefined,\n asChild: false,\n }\n)\n\nconst emit = defineEmits<{\n 'update:annotations': [next: Annotation[]]\n change: [change: AnnotationChange]\n 'update:tool': [tool: ToolId]\n 'update:page': [page: number]\n 'update:zoom': [zoom: ZoomValue]\n ready: [doc: InkDocument]\n error: [error: InkError]\n activate: [id: string]\n}>()\n\ntype TestHookElement = HTMLElement & { __inkDocument?: InkDocument | undefined }\n\n// A template ref on Primitive is a component instance; the context needs its element.\nconst primitive = useTemplateRef<{ $el: unknown }>('primitive')\nconst rootEl = shallowRef<HTMLElement | null>(null)\nfunction syncRootEl(): void {\n const el = primitive.value?.$el\n rootEl.value = el instanceof HTMLElement ? el : null\n}\n\nconst document = shallowRef<InkDocument | null>(null)\n/** Overrides the document's status while opening, and when opening itself failed. */\nconst override = shallowRef<InkStatus | null>(null)\nconst idle: InkStatus = { state: 'idle' }\nconst documentStatus = useReadable<InkStatus>(() => document.value?.status ?? null, idle)\nconst status = computed<InkStatus>(() => override.value ?? documentStatus.value)\nconst annotationList = useReadable<readonly Annotation[]>(\n () => document.value?.annotations.list ?? null,\n []\n)\nconst selection = useReadable<readonly string[]>(\n () => document.value?.annotations.selection ?? null,\n []\n)\nconst viewport = shallowRef<Viewport | null>(null)\nconst toolController = shallowRef<ToolController | null>(null)\nconst internalTool = ref<ToolId>(props.tool ?? 'select-text')\nconst activated = ref<string | null>(null)\n\nconst controlled = computed(() => props.annotations !== undefined)\n\nfunction setActivated(id: string | null): void {\n activated.value = id\n if (id) emit('activate', id)\n}\n\nconst noop = () => {}\n\n/** Signed URLs change; the key does not. Bytes and Blobs are their own identity. */\nfunction identity(src: DocumentSource | null): unknown {\n if (src === null) return null\n if (typeof src === 'string') return src\n if ('key' in src) return src.key\n return src\n}\n\nfunction setTestHook(doc: InkDocument | undefined): void {\n if (import.meta.env.DEV && rootEl.value)\n (rootEl.value as TestHookElement).__inkDocument = doc\n}\n\nlet generation = 0\nfunction release(): void {\n // Cleared first, so the plugins close their stores while the document is still alive.\n const doc = document.value\n document.value = null\n doc?.destroy()\n setTestHook(undefined)\n}\n\nasync function open(): Promise<void> {\n const gen = ++generation\n const src = props.src\n release()\n refHistory.clear()\n if (src === null) {\n override.value = null\n return\n }\n override.value = { state: 'loading' }\n syncRootEl()\n let doc: InkDocument\n try {\n doc = await openDocument(src, {\n assets: props.assets,\n password: props.password,\n defaults:\n props.defaults ?? (rootEl.value ? cssVariableDefaults(rootEl.value) : undefined),\n // Controlled hosts get the ref history below; core's own stack stays off.\n history: controlled.value ? false : (props.history ?? true),\n annotations: controlled.value\n ? {\n mode: 'controlled',\n initial: props.annotations ?? [],\n onChange: (next, change) => {\n emit('update:annotations', next)\n emit('change', change)\n },\n }\n : { mode: 'uncontrolled' },\n })\n } catch (cause) {\n if (gen !== generation) return\n const error =\n cause instanceof InkError\n ? cause\n : new InkError(\n 'InvalidPdf',\n cause instanceof Error ? cause.message : String(cause),\n {},\n cause\n )\n override.value = { state: 'error', error }\n emit('error', error)\n return\n }\n if (gen !== generation) {\n doc.destroy()\n return\n }\n // The prop may have changed while the file loaded, when there was no store to apply it to.\n if (doc.annotations.mode === 'controlled' && props.annotations !== undefined)\n doc.annotations.setControlledValue(props.annotations)\n document.value = doc\n override.value = null\n setTestHook(doc)\n const s = doc.status.get()\n if (s.state === 'ready') emit('ready', doc)\n else if (s.state === 'error') emit('error', s.error)\n}\n\nconst refHistory = createRefHistory({\n source: () => props.annotations,\n apply: (list) => document.value?.annotations.replaceAll(list, 'history'),\n enabled: computed(() => controlled.value && props.history === true),\n store: () =>\n document.value?.annotations.mode === 'controlled' ? document.value.annotations : null,\n})\nconst coreCanUndo = useReadable(() => document.value?.history.canUndo ?? null, false)\nconst coreCanRedo = useReadable(() => document.value?.history.canRedo ?? null, false)\nconst inkHistory: InkHistory = {\n canUndo: computed(() =>\n controlled.value ? refHistory.canUndo.value : coreCanUndo.value\n ),\n canRedo: computed(() =>\n controlled.value ? refHistory.canRedo.value : coreCanRedo.value\n ),\n undo: () => (controlled.value ? refHistory.undo() : document.value?.history.undo()),\n redo: () => (controlled.value ? refHistory.redo() : document.value?.history.redo()),\n clear: () => (controlled.value ? refHistory.clear() : document.value?.history.clear()),\n batch: (fn) => {\n if (controlled.value) refHistory.batch(fn)\n else if (document.value) document.value.history.batch(fn)\n else fn()\n },\n track: (store) =>\n controlled.value\n ? refHistory.track(store)\n : (document.value?.history.track(store) ?? noop),\n react: (fn) =>\n controlled.value ? refHistory.react(fn) : (document.value?.history.react(fn) ?? noop),\n}\n\n/*\n * One plugin host for the root's life, built once mounted so that no `setup` runs on the\n * server, where nothing would clean it up. Until then `pluginHost` is null, and InkCommand\n * renders its command disabled. The host follows `hostDocument`, which is set after `document`\n * (a sync watch): when the host reads `inkHistory` for a new document, it is that document's\n * history.\n */\nconst hostDocument = writable<InkDocument | null>(null)\nwatch(document, (doc) => hostDocument.set(doc), { flush: 'sync' })\nconst viewportEl = shallowRef<HTMLElement | null>(null)\nconst hostRoot = writable<HTMLElement | null>(null)\nwatch(viewportEl, (el) => hostRoot.set(el), { flush: 'sync' })\nconst hostActivated = writable<string | null>(null)\nwatch(activated, (id) => hostActivated.set(id), { flush: 'sync' })\nconst pluginHost = shallowRef<PluginHost | null>(null)\n/** One search controller for the root's life, built with the plugin host that shares it. */\nconst search = shallowRef<SearchController | null>(null)\nfunction setUpPlugins(): void {\n const controller = createSearchController({\n document: readonly(hostDocument),\n viewport: () => viewport.value,\n })\n search.value = controller\n pluginHost.value = createPluginHost({\n plugins: props.plugins ?? [],\n document: readonly(hostDocument),\n history: () => inkHistory,\n activated: readonly(hostActivated),\n // As in `createViewer`: an id not in the open document is ignored.\n setActivated: (id) => {\n if (id === null || document.value?.annotations.get(id)) setActivated(id)\n },\n root: readonly(hostRoot),\n decorate: () => props.decorateAnnotation,\n viewport: () => viewport.value,\n search: viewerSearchOf(controller),\n })\n}\n\n// Reka's typed props stop at its own; listeners go through a bound object.\nconst rootListeners = { onKeydown }\n\n/** Ctrl/Cmd+F while focus is in the root and a find bar is mounted; else the browser's. */\nfunction onKeydown(e: KeyboardEvent): void {\n const controller = search.value\n const root = e.currentTarget\n if (controller && root instanceof HTMLElement)\n handleFindKey(e, controller, () => pageSelectionText(root))\n}\n\n/** The document's tool style; it batches through `inkHistory`, whichever mode is on. */\nconst toolStyle = shallowRef<ToolStyle | null>(null)\nlet setStyleTool: ((id: ToolId) => void) | undefined\nwatch(\n document,\n (doc) => {\n if (!doc) {\n toolStyle.value = null\n setStyleTool = undefined\n return\n }\n const tracker = trackToolStyle({\n store: doc.annotations,\n history: { batch: (fn) => inkHistory.batch(fn) },\n // The plugins' tools too, so a plugin tool's style group applies (the host is set by now:\n // it is built on mount, before the first document opens).\n tools: [...(props.tools ?? []), ...(pluginHost.value?.tools ?? [])],\n tool: internalTool.value,\n })\n setStyleTool = (id) => tracker.setTool(id)\n toolStyle.value = tracker.toolStyle\n },\n // Sync: the style is in place before InkViewport's watcher mounts the engine with it.\n { immediate: true, flush: 'sync' }\n)\nwatch(internalTool, (id) => setStyleTool?.(id))\n\n// Plugins and the document on the client only: on the server InkRoot renders its empty slot.\n// The plugins first, so the first document opens with their stores and reactions.\nonMounted(() => {\n syncRootEl()\n // A plugin whose setup throws still leaves the document to open; the error then goes to\n // Vue's error handling (`onErrorCaptured`, `app.config.errorHandler`).\n try {\n setUpPlugins()\n } finally {\n void open()\n }\n})\nonUpdated(syncRootEl)\n\n// Separate sources, so a new `{ url, key }` object with the same key compares equal.\nwatch([() => identity(props.src), () => props.password], () => void open())\n\nwatch(\n () => props.annotations,\n (next) => {\n if (next && document.value?.annotations.mode === 'controlled')\n document.value.annotations.setControlledValue(next)\n }\n)\n\nwatch(\n () => props.tool,\n (t) => {\n if (t) internalTool.value = t\n }\n)\n\nfunction setTool(id: ToolId): void {\n // Picking the active tool again starts it afresh, as after a one-shot tool's use.\n const tc = toolController.value\n if (internalTool.value === id && tc?.active.get() === id) tc.set(id)\n internalTool.value = id\n emit('update:tool', id)\n}\n\nonBeforeUnmount(() => {\n generation++\n release()\n})\n\n// After the children: InkViewport's engine, and the plugin layers with it, are gone by now, as\n// in `createViewer`, so no layer `destroy` runs after the plugins' cleanups.\nonUnmounted(() => {\n pluginHost.value?.destroy()\n pluginHost.value = null\n search.value?.destroy()\n search.value = null\n})\n\nconst signatures = computed(() =>\n createSignatureLibrary(props.signatures ?? createMemorySignatureStore())\n)\nwatch(signatures, (lib) => void lib.refresh(), { immediate: true })\n/** Tool options last as long as the root; the tool style is per document. */\nconst toolOptions = createToolOptions()\n\nprovideInkContext({\n assets: computed(() => props.assets),\n document,\n status,\n annotations: annotationList,\n selection,\n viewport,\n tools: toolController,\n tool: internalTool,\n setTool,\n hostTools: computed(() => props.tools),\n decorateAnnotation: computed(() => props.decorateAnnotation),\n fonts: computed(() => props.fonts ?? FONT_FAMILIES),\n toolOptions,\n signatures,\n signatureFonts: computed(() => props.signatureFonts ?? SIGNATURE_FONTS),\n toolStyle,\n zoomModel: computed(() => props.zoom),\n pageModel: computed(() => props.page),\n reportZoom: (z) => emit('update:zoom', z),\n reportPage: (p) => emit('update:page', p),\n activated,\n setActivated,\n pluginHost,\n search,\n viewportEl,\n history: inkHistory,\n rootEl,\n})\n\n// `history` is what `useHistory()` returns inside the root, for hosts that hold a template ref:\n// a controlled host calls `history.clear()` after loading its saved list.\ndefineExpose({ document, status, rootEl, history: inkHistory })\n</script>\n\n<template>\n <Primitive\n ref=\"primitive\"\n :as-child=\"props.asChild\"\n as=\"div\"\n data-ink-root\n :data-state=\"status.state\"\n v-bind=\"rootListeners\"\n >\n <slot :status=\"status\" :document=\"document\" />\n </Primitive>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA4DA,IAAMS,IAAQC,GAoERC,IAAOH,IAcPI,IAAYC,EAAiC,WAAW,GACxDC,IAASC,EAA+B,IAAI;EAClD,SAASC,IAAmB;GAC1B,IAAMC,IAAKL,EAAU,OAAO;GAC5B,EAAO,QAAQK,aAAc,cAAcA,IAAK;EAClD;EAEA,IAAMC,IAAWH,EAA+B,IAAI,GAE9CI,IAAWJ,EAA6B,IAAI,GAE5CK,IAAiBC,QAA6BH,EAAS,OAAO,UAAU,MAAM,EAD1D,OAAO,OACmD,CAAI,GAClFI,IAASC,QAA0BJ,EAAS,SAASC,EAAe,KAAK,GACzEI,IAAiBH,QACfH,EAAS,OAAO,YAAY,QAAQ,MAC1C,CAAC,CACH,GACMO,IAAYJ,QACVH,EAAS,OAAO,YAAY,aAAa,MAC/C,CAAC,CACH,GACMQ,IAAWX,EAA4B,IAAI,GAC3CY,IAAiBZ,EAAkC,IAAI,GACvDa,IAAeC,EAAYpB,EAAM,QAAQ,aAAa,GACtDqB,IAAYD,EAAmB,IAAI,GAEnCE,IAAaR,QAAed,EAAM,gBAAgB,KAAA,CAAS;EAEjE,SAASuB,EAAa,GAAyB;GAE7C,AADA,EAAU,QAAQC,GACdA,KAAItB,EAAK,YAAYsB,CAAE;EAC7B;EAEA,IAAMC,UAAa,CAAC;EAGpB,SAASC,GAAS,GAAqC;GAIrD,OAHIC,MAAQ,OAAa,OACrB,O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,QAAQ;EACjB,CAAC;EAED,IAAMwB,IAAajE,QACjBkE,GAAuBhF,EAAM,cAAciF,GAA2B,CAAC,CACzE;EACA,EAAMF,IAAa,MAAQ,KAAKG,EAAI,QAAQ,GAAG,EAAE,WAAW,GAAK,CAAC;EAElE,IAAMC,KAAcC,GAAkB;SAEtCC,EAAkB;GAChB,QAAQvE,QAAed,EAAM,MAAM;GACnC;GACA;GACA,aAAae;GACb;GACA;GACA,OAAOG;GACP,MAAMC;GACN;GACA,WAAWL,QAAed,EAAM,KAAK;GACrC,oBAAoBc,QAAed,EAAM,kBAAkB;GAC3D,OAAOc,QAAed,EAAM,SAASsF,EAAa;GAClD;GACA;GACA,gBAAgBxE,QAAed,EAAM,kBAAkBuF,EAAe;GACtE;GACA,WAAWzE,QAAed,EAAM,IAAI;GACpC,WAAWc,QAAed,EAAM,IAAI;GACpC,aAAa,MAAME,EAAK,eAAesF,CAAC;GACxC,aAAa,MAAMtF,EAAK,eAAeuF,CAAC;GACxC;GACA;GACA;GACA;GACA;GACA,SAAS3C;GACT;EACF,CAAC,GAIDhD,EAAa;GAAE;GAAU;GAAQ;GAAQ,SAASgD;EAAW,CAAC,cAI5DvD,GAAA,GAAAC,EASYC,EAAAoG,CAAA,GATZnG,GASY;GARN,SAAA;GAAJ,KAAIS;GACH,YAAUH,EAAM;GACjB,IAAG;GACH,iBAAA;GACC,cAAYa,EAAA,MAAO;EACZ,GAAAiD,EAAa,GAAA;GAErB,SAAAnE,QAA8C,CAA9CC,EAA8CqG,EAAA,QAAA,WAAA;IAAvC,QAAQpF,EAAA;IAAS,UAAUJ,EAAA"}
@@ -0,0 +1,7 @@
1
+ import e from "./InkSearchButton.vue_vue_type_script_setup_true_lang.js";
2
+ //#region src/components/InkSearchButton.vue
3
+ var t = e;
4
+ //#endregion
5
+ export { t as default };
6
+
7
+ //# sourceMappingURL=InkSearchButton.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"InkSearchButton.js","names":["_sfc_main","InkSearchButton_vue_vue_type_script_setup_true_lang_default","InkSearchButton_default"],"sources":["../../src/components/InkSearchButton.vue"],"sourcesContent":["<script setup lang=\"ts\">\n/*\n * Opens the find bar; pressed while it is open. Pressing it again focuses the field. Place it\n * in a toolbar next to `InkFindBar`, which it needs for the field to focus.\n */\nimport { Search } from '@inkbar/icons'\nimport { ToolbarButton } from 'reka-ui'\nimport { computed, mergeProps, nextTick } from 'vue'\n\nimport { useDocument } from '../composables/useDocument'\nimport { useSearch } from '../composables/useSearch'\nimport { useInkContext } from '../context'\n\nimport InkIcon from './InkIcon.vue'\n\n// Bound below, under the button's own label, so a caller's attributes cannot replace its copy.\ndefineOptions({ inheritAttrs: false })\n\nwithDefaults(defineProps<{ asChild?: boolean }>(), { asChild: false })\nconst ctx = useInkContext('InkSearchButton')\nconst { state, open } = useSearch()\nconst { isReady } = useDocument()\n\nasync function onClick(): Promise<void> {\n open()\n // The bar shows on the next render; its field takes focus then.\n await nextTick()\n const field = ctx.rootEl.value?.querySelector<HTMLInputElement>(\n '[data-ink-find-bar] input'\n )\n field?.focus()\n field?.select()\n}\n// Reka's typed props stop at its own; ARIA and listeners go through a bound object.\nconst attrs = computed(() => ({\n 'aria-label': 'Find',\n title: 'Find',\n 'aria-pressed': state.value.open,\n 'data-state': state.value.open ? 'on' : 'off',\n onClick,\n}))\n/** Disabled until a document is open, whatever the caller's `disabled` says, as in React and Svelte. */\nconst disabled = (fromCaller: unknown): boolean =>\n !isReady.value || (fromCaller != null && fromCaller !== false)\n</script>\n\n<template>\n <ToolbarButton\n :as-child=\"asChild\"\n class=\"ink-search-button\"\n data-ink-search-button\n v-bind=\"mergeProps($attrs, attrs, { disabled: disabled($attrs.disabled) })\"\n >\n <slot><InkIcon :icon=\"Search\" /></slot>\n </ToolbarButton>\n</template>\n"],"mappings":""}
@@ -0,0 +1,19 @@
1
+ type __VLS_Props = {
2
+ asChild?: boolean;
3
+ };
4
+ declare var __VLS_7: {};
5
+ type __VLS_Slots = {} & {
6
+ default?: (props: typeof __VLS_7) => any;
7
+ };
8
+ declare const __VLS_base: import('vue').DefineComponent<__VLS_Props, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
9
+ asChild: boolean;
10
+ }, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
11
+ declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
12
+ declare const _default: typeof __VLS_export;
13
+ export default _default;
14
+ type __VLS_WithSlots<T, S> = T & {
15
+ new (): {
16
+ $slots: S;
17
+ };
18
+ };
19
+ //# sourceMappingURL=InkSearchButton.vue.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"InkSearchButton.vue.d.ts","sourceRoot":"","sources":["../../src/components/InkSearchButton.vue"],"names":[],"mappings":"AA4EA,KAAK,WAAW,GAAG;IAAE,OAAO,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC;AAwEzC,QAAA,IAAI,OAAO,IAAW,CAAC;AACvB,KAAK,WAAW,GAAG,EAAE,GACnB;IAAE,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,OAAO,KAAK,GAAG,CAAA;CAAE,CAAC;AAG/C,QAAA,MAAM,UAAU;;6EAGd,CAAC;AACH,QAAA,MAAM,YAAY,EAAS,eAAe,CAAC,OAAO,UAAU,EAAE,WAAW,CAAC,CAAC;wBACtD,OAAO,YAAY;AAAxC,wBAAyC;AAWzC,KAAK,eAAe,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,GAAG;IAChC,QAAO;QACN,MAAM,EAAE,CAAC,CAAC;KACV,CAAA;CACD,CAAC"}
@@ -0,0 +1,43 @@
1
+ import { useInkContext as e } from "../context.js";
2
+ import { useDocument as t } from "../composables/useDocument.js";
3
+ import { useSearch as n } from "../composables/useSearch.js";
4
+ import r from "./InkIcon.js";
5
+ import { computed as i, createBlock as a, createVNode as o, defineComponent as s, mergeProps as c, nextTick as l, openBlock as u, renderSlot as d, unref as f, withCtx as p } from "vue";
6
+ import { ToolbarButton as m } from "reka-ui";
7
+ import { Search as h } from "@inkbar/icons";
8
+ //#region src/components/InkSearchButton.vue?vue&type=script&setup=true&lang.ts
9
+ var g = /*@__PURE__*/ s({
10
+ inheritAttrs: !1,
11
+ __name: "InkSearchButton",
12
+ props: { asChild: {
13
+ type: Boolean,
14
+ default: !1
15
+ } },
16
+ setup(s) {
17
+ let g = e("InkSearchButton"), { state: _, open: v } = n(), { isReady: y } = t();
18
+ async function b() {
19
+ v(), await l();
20
+ let e = g.rootEl.value?.querySelector("[data-ink-find-bar] input");
21
+ e?.focus(), e?.select();
22
+ }
23
+ let x = i(() => ({
24
+ "aria-label": "Find",
25
+ title: "Find",
26
+ "aria-pressed": _.value.open,
27
+ "data-state": _.value.open ? "on" : "off",
28
+ onClick: b
29
+ })), S = (e) => !y.value || e != null && e !== !1;
30
+ return (e, t) => (u(), a(f(m), c({
31
+ "as-child": s.asChild,
32
+ class: "ink-search-button",
33
+ "data-ink-search-button": ""
34
+ }, c(e.$attrs, x.value, { disabled: S(e.$attrs.disabled) })), {
35
+ default: p(() => [d(e.$slots, "default", {}, () => [o(r, { icon: f(h) }, null, 8, ["icon"])])]),
36
+ _: 3
37
+ }, 16, ["as-child"]));
38
+ }
39
+ });
40
+ //#endregion
41
+ export { g as default };
42
+
43
+ //# sourceMappingURL=InkSearchButton.vue_vue_type_script_setup_true_lang.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"InkSearchButton.vue_vue_type_script_setup_true_lang.js","names":["$attrs","_openBlock","_createBlock","_unref","_mergeProps","_withCtx","_renderSlot","_createVNode","InkIcon","InkIcon_default","InkSearchButton_vue_vue_type_script_setup_true_lang_default","ctx","useInkContext","useSearch","useDocument","onClick","open","nextTick","field","attrs","computed","state","disabled","isReady","fromCaller","openBlock","createBlock","unref","ToolbarButton","mergeProps","__props","_ctx","withCtx","renderSlot","createVNode","Search"],"sources":["../../src/components/InkSearchButton.vue"],"sourcesContent":["<script setup lang=\"ts\">\n/*\n * Opens the find bar; pressed while it is open. Pressing it again focuses the field. Place it\n * in a toolbar next to `InkFindBar`, which it needs for the field to focus.\n */\nimport { Search } from '@inkbar/icons'\nimport { ToolbarButton } from 'reka-ui'\nimport { computed, mergeProps, nextTick } from 'vue'\n\nimport { useDocument } from '../composables/useDocument'\nimport { useSearch } from '../composables/useSearch'\nimport { useInkContext } from '../context'\n\nimport InkIcon from './InkIcon.vue'\n\n// Bound below, under the button's own label, so a caller's attributes cannot replace its copy.\ndefineOptions({ inheritAttrs: false })\n\nwithDefaults(defineProps<{ asChild?: boolean }>(), { asChild: false })\nconst ctx = useInkContext('InkSearchButton')\nconst { state, open } = useSearch()\nconst { isReady } = useDocument()\n\nasync function onClick(): Promise<void> {\n open()\n // The bar shows on the next render; its field takes focus then.\n await nextTick()\n const field = ctx.rootEl.value?.querySelector<HTMLInputElement>(\n '[data-ink-find-bar] input'\n )\n field?.focus()\n field?.select()\n}\n// Reka's typed props stop at its own; ARIA and listeners go through a bound object.\nconst attrs = computed(() => ({\n 'aria-label': 'Find',\n title: 'Find',\n 'aria-pressed': state.value.open,\n 'data-state': state.value.open ? 'on' : 'off',\n onClick,\n}))\n/** Disabled until a document is open, whatever the caller's `disabled` says, as in React and Svelte. */\nconst disabled = (fromCaller: unknown): boolean =>\n !isReady.value || (fromCaller != null && fromCaller !== false)\n</script>\n\n<template>\n <ToolbarButton\n :as-child=\"asChild\"\n class=\"ink-search-button\"\n data-ink-search-button\n v-bind=\"mergeProps($attrs, attrs, { disabled: disabled($attrs.disabled) })\"\n >\n <slot><InkIcon :icon=\"Search\" /></slot>\n </ToolbarButton>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;EAmBA,IAAMW,IAAMC,EAAc,iBAAiB,GACrC,EAAE,UAAO,YAASC,EAAU,GAC5B,EAAE,eAAYC,EAAY;EAEhC,eAAeC,IAAyB;GAGtC,AAFAC,EAAK,GAEL,MAAMC,EAAS;GACf,IAAMC,IAAQP,EAAI,OAAO,OAAO,cAC9B,2BACF;GAEA,AADAO,GAAO,MAAM,GACbA,GAAO,OAAO;EAChB;EAEA,IAAMC,IAAQC,SAAgB;GAC5B,cAAc;GACd,OAAO;GACP,gBAAgBC,EAAM,MAAM;GAC5B,cAAcA,EAAM,MAAM,OAAO,OAAO;GACxC;EACF,EAAE,GAEIC,KAAY,MAChB,CAACC,EAAQ,SAAUC,KAAc,QAAQA,MAAe;oBAIxDvB,EAAA,GAAAC,EAOgBC,EAAAyB,CAAA,GAPhBxB,EAOgB;GANb,YAAU0B,EAAA;GACX,OAAM;GACN,0BAAA;EACQ,GAAAD,EAAW7B,EAAAA,QAAQmB,EAAA,OAAK,EAAA,UAAcG,EAAStB,EAAAA,OAAO,QAAQ,EAAA,CAAA,CAAA,GAAA;GAEtE,SAAAK,QAAuC,CAAvCC,EAAuCyB,EAAA,QAAA,WAAA,CAAA,SAAA,CAAjCxB,EAA0BC,GAAA,EAAhB,MAAML,EAAAgC,CAAA,EAAM,GAAA,MAAA,GAAA,CAAA,MAAA,CAAA,CAAA,CAAA,CAAA,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"InkToolButton.js","names":["_sfc_main","InkToolButton_vue_vue_type_script_setup_true_lang_default","InkToolButton_default"],"sources":["../../src/components/InkToolButton.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { TOOL_LABELS } from '@inkbar/core/dom'\nimport {\n Highlighter,\n MessageSquare,\n PenLine,\n PenTool,\n Signature,\n Square,\n SquareDashedMousePointer,\n TextCursor,\n Type,\n} from '@inkbar/icons'\nimport { ToolbarButton } from 'reka-ui'\nimport { computed } from 'vue'\n\nimport { useTool } from '../composables/useTool'\n\nimport InkIcon from './InkIcon.vue'\n\nimport type { ToolId } from '@inkbar/core/dom'\nimport type { IconNode } from '@inkbar/icons'\n\nconst ICONS: Readonly<Partial<Record<ToolId, IconNode>>> = {\n 'select-text': TextCursor,\n select: SquareDashedMousePointer,\n highlight: Highlighter,\n 'redact-area': Square,\n sketch: PenTool,\n draw: PenLine,\n note: MessageSquare,\n freetext: Type,\n signature: Signature,\n}\n\nconst props = withDefaults(\n defineProps<{ tool: ToolId; label?: string | undefined; asChild?: boolean }>(),\n { label: undefined, asChild: false }\n)\n\nconst { tool: current, setTool } = useTool()\nconst active = computed(() => current.value === props.tool)\n// A host tool has no built-in name or icon: `label` and the slot supply them.\nconst name = computed(() => props.label ?? TOOL_LABELS[props.tool] ?? props.tool)\nconst icon = computed(() => ICONS[props.tool])\n// Reka's typed props stop at its own; ARIA and listeners go through a bound object.\nconst attrs = computed(() => ({\n 'aria-pressed': String(active.value),\n 'aria-label': name.value,\n title: name.value,\n onClick: () => setTool(props.tool),\n}))\n</script>\n\n<template>\n <ToolbarButton\n :as-child=\"asChild\"\n class=\"ink-tool-button\"\n data-ink-tool-button\n :data-tool=\"tool\"\n :data-state=\"active ? 'on' : 'off'\"\n v-bind=\"attrs\"\n >\n <slot :active=\"active\" :label=\"name\"><InkIcon v-if=\"icon\" :icon=\"icon\" /></slot>\n </ToolbarButton>\n</template>\n"],"mappings":""}
1
+ {"version":3,"file":"InkToolButton.js","names":["_sfc_main","InkToolButton_vue_vue_type_script_setup_true_lang_default","InkToolButton_default"],"sources":["../../src/components/InkToolButton.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { TOOL_LABELS } from '@inkbar/core/dom'\nimport {\n Highlighter,\n MessageSquare,\n PenLine,\n PenTool,\n Signature,\n Square,\n SquareDashedMousePointer,\n TextCursor,\n Type,\n} from '@inkbar/icons'\nimport { ToolbarButton } from 'reka-ui'\nimport { computed } from 'vue'\n\nimport { useTool } from '../composables/useTool'\nimport { useInkContext } from '../context'\n\nimport InkIcon from './InkIcon.vue'\n\nimport type { ToolId } from '@inkbar/core/dom'\nimport type { IconNode } from '@inkbar/icons'\n\nconst ICONS: Readonly<Partial<Record<ToolId, IconNode>>> = {\n 'select-text': TextCursor,\n select: SquareDashedMousePointer,\n highlight: Highlighter,\n 'redact-area': Square,\n sketch: PenTool,\n draw: PenLine,\n note: MessageSquare,\n freetext: Type,\n signature: Signature,\n}\n\nconst props = withDefaults(\n defineProps<{ tool: ToolId; label?: string | undefined; asChild?: boolean }>(),\n { label: undefined, asChild: false }\n)\n\nconst ctx = useInkContext('InkToolButton')\nconst { tool: current, setTool } = useTool()\nconst active = computed(() => current.value === props.tool)\n/** A host or plugin tool by this id, for the name and icon core has none for. */\nconst own = computed(() =>\n [...(ctx.hostTools.value ?? []), ...(ctx.pluginHost.value?.tools ?? [])].find(\n (t) => t.id === props.tool\n )\n)\n// `label` and the slot win; then core's name and icon; then the tool's own.\nconst name = computed(\n () => props.label ?? TOOL_LABELS[props.tool] ?? own.value?.label ?? props.tool\n)\nconst icon = computed(() => ICONS[props.tool] ?? own.value?.icon)\n// Reka's typed props stop at its own; ARIA and listeners go through a bound object.\nconst attrs = computed(() => ({\n 'aria-pressed': String(active.value),\n 'aria-label': name.value,\n title: name.value,\n onClick: () => setTool(props.tool),\n}))\n</script>\n\n<template>\n <ToolbarButton\n :as-child=\"asChild\"\n class=\"ink-tool-button\"\n data-ink-tool-button\n :data-tool=\"tool\"\n :data-state=\"active ? 'on' : 'off'\"\n v-bind=\"attrs\"\n >\n <slot :active=\"active\" :label=\"name\"><InkIcon v-if=\"icon\" :icon=\"icon\" /></slot>\n </ToolbarButton>\n</template>\n"],"mappings":""}
@@ -1 +1 @@
1
- {"version":3,"file":"InkToolButton.vue.d.ts","sourceRoot":"","sources":["../../src/components/InkToolButton.vue"],"names":[],"mappings":"AAuFA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AAgB9C,KAAK,WAAW,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAAC,OAAO,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC;AAyEnF,QAAA,IAAI,OAAO;;;CAAW,CAAC;AACvB,K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