@sciexpr/vue 0.2.0 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -1,64 +1,68 @@
1
- import { ref as v, watch as q, shallowRef as te, defineComponent as B, useSlots as ae, openBlock as i, createElementBlock as d, normalizeClass as N, unref as S, toDisplayString as w, computed as F, inject as Y, provide as K, Fragment as C, renderList as $, createCommentVNode as M, renderSlot as oe, createTextVNode as le, createElementVNode as y, createBlock as G, Teleport as ne, normalizeStyle as H, withDirectives as D, vModelText as j, createVNode as se, nextTick as V, createStaticVNode as ce, vShow as Z, onMounted as ie, onUnmounted as re } from "vue";
1
+ import { ref as v, watch as B, shallowRef as te, defineComponent as E, useSlots as ae, openBlock as i, createElementBlock as m, normalizeClass as N, unref as S, toDisplayString as w, computed as F, inject as Y, provide as K, Fragment as C, renderList as $, createCommentVNode as M, renderSlot as oe, createTextVNode as le, createElementVNode as h, createBlock as G, Teleport as ne, normalizeStyle as H, withDirectives as D, vModelText as j, createVNode as se, nextTick as V, createStaticVNode as ce, vShow as Z, onMounted as ie, onUnmounted as re } from "vue";
2
2
  import { KatexRenderer as Q, UnicodeRenderer as ue, MathMLRenderer as de } from "@sciexpr/renderer";
3
3
  import { ParserRegistry as U } from "@sciexpr/parser";
4
- import { AIPipeline as A } from "@sciexpr/ai";
4
+ import { AIPipeline as O } from "@sciexpr/ai";
5
5
  import { ExpressionKind as me } from "@sciexpr/core";
6
6
  function ut(e) {
7
- const o = v(""), l = v(""), n = v(""), c = v(null), u = new U(), r = e.katexRenderer ?? new Q(), t = new ue(), s = new de();
8
- function m(a) {
7
+ const o = v(""), l = v(""), n = v(""), c = v(null), r = new U(), u = e.katexRenderer ?? new Q(), a = new ue(), s = new de();
8
+ function d(t) {
9
9
  var b;
10
10
  try {
11
- const h = u.parse(a, { hint: "auto" });
12
- if (!h || h.children.length === 0) {
11
+ const y = r.parse(t, { hint: "auto" });
12
+ if (!y || y.children.length === 0) {
13
13
  o.value = "", c.value = null;
14
14
  return;
15
15
  }
16
- const g = r.render(h, {
16
+ const g = u.render(y, {
17
17
  displayMode: e.displayMode,
18
18
  ...e.renderOptions
19
19
  });
20
- o.value = g.value, (b = g.warnings) != null && b.length, l.value = s.render(h).value, n.value = t.render(h).value, c.value = null;
21
- } catch (h) {
20
+ o.value = g.value, (b = g.warnings) != null && b.length, l.value = s.render(y).value, n.value = a.render(y).value, c.value = null;
21
+ } catch (y) {
22
22
  c.value = {
23
- message: h instanceof Error ? h.message : String(h)
23
+ message: y instanceof Error ? y.message : String(y)
24
24
  }, o.value = "";
25
25
  }
26
26
  }
27
- return q(e.source, (a) => {
28
- m(a);
29
- }, { immediate: !0 }), {
27
+ return B(e.source, (t) => {
28
+ d(t);
29
+ }, { immediate: !0 }), u.ready.then(() => {
30
+ d(e.source.value);
31
+ }), {
30
32
  html: o,
31
33
  mathml: l,
32
34
  unicode: n,
33
35
  error: c,
34
- render: m
36
+ render: d
35
37
  };
36
38
  }
37
39
  function J(e) {
38
- const o = v(""), l = v(null), n = te(null), c = new U(), u = new Q();
39
- function r(t) {
40
+ const o = v(""), l = v(null), n = te(null), c = new U(), r = new Q();
41
+ function u(a) {
40
42
  var s;
41
43
  try {
42
- const m = c.parse(t, { hint: "auto" });
43
- if (n.value = m, !m || m.children.length === 0) {
44
+ const d = c.parse(a, { hint: "auto" });
45
+ if (n.value = d, !d || d.children.length === 0) {
44
46
  o.value = "", l.value = null;
45
47
  return;
46
48
  }
47
- const a = u.render(m, {
49
+ const t = r.render(d, {
48
50
  displayMode: ((s = e.displayMode) == null ? void 0 : s.value) ?? !1
49
51
  });
50
- o.value = a.value, l.value = null;
51
- } catch (m) {
52
+ o.value = t.value, l.value = null;
53
+ } catch (d) {
52
54
  l.value = {
53
- message: m instanceof Error ? m.message : String(m)
54
- }, o.value = t;
55
+ message: d instanceof Error ? d.message : String(d)
56
+ }, o.value = a;
55
57
  }
56
58
  }
57
- return q([e.source, e.displayMode ?? v(!1)], ([t]) => {
58
- r(t);
59
- }, { immediate: !0 }), { html: o, error: l, ast: n, render: r };
59
+ return B([e.source, e.displayMode ?? v(!1)], ([a]) => {
60
+ u(a);
61
+ }, { immediate: !0 }), r.ready.then(() => {
62
+ u(e.source.value);
63
+ }), { html: o, error: l, ast: n, render: u };
60
64
  }
61
- const pe = ["data-source"], be = ["title"], xe = ["innerHTML"], ve = /* @__PURE__ */ B({
65
+ const pe = ["data-source"], be = ["title"], xe = ["innerHTML"], ve = /* @__PURE__ */ E({
62
66
  __name: "Formula",
63
67
  props: {
64
68
  source: { default: "" },
@@ -68,101 +72,109 @@ const pe = ["data-source"], be = ["title"], xe = ["innerHTML"], ve = /* @__PURE_
68
72
  fallbackText: { default: "" }
69
73
  },
70
74
  setup(e) {
71
- var t, s, m;
72
- const o = e, l = ae(), n = (m = (s = (t = l.default) == null ? void 0 : t.call(l)) == null ? void 0 : s[0]) == null ? void 0 : m.children, c = v(o.source || n || ""), { html: u, error: r } = J({
75
+ var s, d, t;
76
+ const o = e, l = ae(), n = (t = (d = (s = l.default) == null ? void 0 : s.call(l)) == null ? void 0 : d[0]) == null ? void 0 : t.children, c = v(o.source || n || "");
77
+ B(() => o.source, (b) => {
78
+ c.value = b || n || "";
79
+ });
80
+ const r = v(o.displayMode);
81
+ B(() => o.displayMode, (b) => {
82
+ r.value = b;
83
+ });
84
+ const { html: u, error: a } = J({
73
85
  source: c,
74
- displayMode: v(o.displayMode)
86
+ displayMode: r
75
87
  });
76
- return (a, b) => (i(), d("span", {
88
+ return (b, y) => (i(), m("span", {
77
89
  class: N(["sciexpr-formula", o.className, {
78
90
  "sciexpr-display": o.displayMode,
79
- "sciexpr-error": S(r)
91
+ "sciexpr-error": S(a)
80
92
  }]),
81
93
  "data-source": c.value
82
94
  }, [
83
- S(r) ? (i(), d("span", {
95
+ S(a) ? (i(), m("span", {
84
96
  key: 0,
85
97
  class: "sciexpr-formula-error",
86
- title: S(r).message
87
- }, w(e.fallbackText || c.value), 9, be)) : (i(), d("span", {
98
+ title: S(a).message
99
+ }, w(e.fallbackText || c.value), 9, be)) : (i(), m("span", {
88
100
  key: 1,
89
101
  innerHTML: S(u),
90
102
  class: "sciexpr-formula-content"
91
103
  }, null, 8, xe))
92
104
  ], 10, pe));
93
105
  }
94
- }), E = (e, o) => {
106
+ }), A = (e, o) => {
95
107
  const l = e.__vccOpts || e;
96
108
  for (const [n, c] of o)
97
109
  l[n] = c;
98
110
  return l;
99
- }, dt = /* @__PURE__ */ E(ve, [["__scopeId", "data-v-b2381271"]]);
111
+ }, dt = /* @__PURE__ */ A(ve, [["__scopeId", "data-v-557e5ff9"]]);
100
112
  function fe(e) {
101
- const o = v(e.initialValue ?? ""), l = v(0), n = v(""), c = v(null), u = v(null), r = new U();
102
- function t(g, I) {
113
+ const o = v(e.initialValue ?? ""), l = v(0), n = v(""), c = v(null), r = v(null), u = new U();
114
+ function a(g, I) {
103
115
  o.value = g, I !== void 0 && (l.value = I);
104
116
  }
105
117
  function s(g) {
106
- const I = o.value.slice(0, l.value), R = o.value.slice(l.value);
107
- o.value = I + g + R, l.value += g.length;
118
+ const I = o.value.slice(0, l.value), T = o.value.slice(l.value);
119
+ o.value = I + g + T, l.value += g.length;
108
120
  }
109
- function m(g, I) {
110
- const R = o.value;
111
- o.value = g + R + I, l.value = o.value.length;
121
+ function d(g, I) {
122
+ const T = o.value;
123
+ o.value = g + T + I, l.value = o.value.length;
112
124
  }
113
- function a() {
125
+ function t() {
114
126
  try {
115
- const g = r.parse(o.value, { hint: "auto" });
116
- return u.value = g, g;
127
+ const g = u.parse(o.value, { hint: "auto" });
128
+ return r.value = g, g;
117
129
  } catch {
118
- return u.value = null, null;
130
+ return r.value = null, null;
119
131
  }
120
132
  }
121
- const b = F(() => o.value.trim().length === 0), h = F(() => o.value);
133
+ const b = F(() => o.value.trim().length === 0), y = F(() => o.value);
122
134
  return {
123
135
  // State
124
136
  value: o,
125
137
  cursor: l,
126
138
  html: n,
127
- ast: u,
139
+ ast: r,
128
140
  error: c,
129
141
  // Computed
130
142
  isEmpty: b,
131
- latexSource: h,
143
+ latexSource: y,
132
144
  // Actions
133
- handleInput: t,
145
+ handleInput: a,
134
146
  insertText: s,
135
- wrapSelection: m,
136
- parse: a
147
+ wrapSelection: d,
148
+ parse: t
137
149
  };
138
150
  }
139
151
  function ye(e) {
140
- const o = v([]), l = v(!1), n = v(0), c = v(""), u = e.pipeline ?? new A(), r = e.config ?? { enabled: !0, minTriggerLength: 2, maxItems: 10 };
141
- async function t(b, h) {
142
- if (!r.enabled) {
152
+ const o = v([]), l = v(!1), n = v(0), c = v(""), r = e.pipeline ?? new O(), u = e.config ?? { enabled: !0, minTriggerLength: 2, maxItems: 10 };
153
+ async function a(b, y) {
154
+ if (!u.enabled) {
143
155
  l.value = !1;
144
156
  return;
145
157
  }
146
- const g = he(b, h);
147
- if (!g || g.length < (r.minTriggerLength ?? 2)) {
158
+ const g = he(b, y);
159
+ if (!g || g.length < (u.minTriggerLength ?? 2)) {
148
160
  l.value = !1;
149
161
  return;
150
162
  }
151
163
  c.value = g;
152
164
  const I = {
153
165
  currentInput: b,
154
- cursorPosition: h,
166
+ cursorPosition: y,
155
167
  expressionType: me.Math
156
- }, R = await u.getCompletions(I);
157
- o.value = R.items.slice(0, r.maxItems ?? 10), l.value = o.value.length > 0, n.value = 0;
168
+ }, T = await r.getCompletions(I);
169
+ o.value = T.items.slice(0, u.maxItems ?? 10), l.value = o.value.length > 0, n.value = 0;
158
170
  }
159
171
  function s(b) {
160
172
  return l.value = !1, b.text;
161
173
  }
162
- function m(b) {
174
+ function d(b) {
163
175
  b === "up" ? n.value = Math.max(0, n.value - 1) : n.value = Math.min(o.value.length - 1, n.value + 1);
164
176
  }
165
- function a() {
177
+ function t() {
166
178
  l.value = !1, o.value = [];
167
179
  }
168
180
  return {
@@ -170,33 +182,33 @@ function ye(e) {
170
182
  visible: l,
171
183
  selectedIndex: n,
172
184
  query: c,
173
- trigger: t,
185
+ trigger: a,
174
186
  select: s,
175
- moveSelection: m,
176
- close: a
187
+ moveSelection: d,
188
+ close: t
177
189
  };
178
190
  }
179
191
  function he(e, o) {
180
192
  const l = e.slice(0, o), n = l.lastIndexOf("\\");
181
193
  if (n !== -1) {
182
- const r = l.slice(n).match(/^\\[a-zA-Z]*$/);
183
- if (r) return r[0];
194
+ const u = l.slice(n).match(/^\\[a-zA-Z]*$/);
195
+ if (u) return u[0];
184
196
  }
185
197
  const c = l.match(/([a-zA-Z_]+)$/);
186
198
  return c ? c[1] : "";
187
199
  }
188
- const O = Symbol("sciexpr-ai-pipeline");
200
+ const q = Symbol("sciexpr-ai-pipeline");
189
201
  function ge(e) {
190
- const o = e ? new A(e) : Y(O, null);
191
- function l(u) {
192
- const r = new A(u);
193
- K(O, r);
202
+ const o = e ? new O(e) : Y(q, null);
203
+ function l(r) {
204
+ const u = new O(r);
205
+ K(q, u);
194
206
  }
195
- function n(u) {
196
- o && K(O, new A({ completionProvider: u }));
207
+ function n(r) {
208
+ o && K(q, new O({ completionProvider: r }));
197
209
  }
198
- function c(u) {
199
- o && K(O, new A({ knowledgeBaseProvider: u }));
210
+ function c(r) {
211
+ o && K(q, new O({ knowledgeBaseProvider: r }));
200
212
  }
201
213
  return {
202
214
  pipeline: o,
@@ -208,7 +220,7 @@ function ge(e) {
208
220
  const we = {
209
221
  key: 0,
210
222
  class: "sciexpr-toolbar-group-label"
211
- }, ke = ["title", "disabled", "onClick"], Ce = /* @__PURE__ */ B({
223
+ }, ke = ["title", "disabled", "onClick"], Ce = /* @__PURE__ */ E({
212
224
  __name: "Toolbar",
213
225
  props: {
214
226
  categories: {},
@@ -292,31 +304,31 @@ const we = {
292
304
  ]
293
305
  }
294
306
  ];
295
- function c(u) {
296
- l("insert", u);
307
+ function c(r) {
308
+ l("insert", r);
297
309
  }
298
- return (u, r) => (i(), d("div", {
310
+ return (r, u) => (i(), m("div", {
299
311
  class: N(["sciexpr-toolbar", { "sciexpr-toolbar-compact": e.compact }]),
300
312
  role: "toolbar",
301
313
  "aria-label": "Formula toolbar"
302
314
  }, [
303
- (i(), d(C, null, $(n, (t) => (i(), d(C, {
304
- key: t.id
315
+ (i(), m(C, null, $(n, (a) => (i(), m(C, {
316
+ key: a.id
305
317
  }, [
306
- !e.categories || e.categories.includes(t.id) ? (i(), d("div", {
318
+ !e.categories || e.categories.includes(a.id) ? (i(), m("div", {
307
319
  key: 0,
308
320
  class: N(["sciexpr-toolbar-group", { "sciexpr-toolbar-group-compact": e.compact }])
309
321
  }, [
310
- e.compact ? M("", !0) : (i(), d("span", we, w(t.icon) + " " + w(t.label), 1)),
311
- (i(!0), d(C, null, $(t.commands, (s) => (i(), d("button", {
322
+ e.compact ? M("", !0) : (i(), m("span", we, w(a.icon) + " " + w(a.label), 1)),
323
+ (i(!0), m(C, null, $(a.commands, (s) => (i(), m("button", {
312
324
  key: s.latex,
313
325
  class: N(["sciexpr-toolbar-btn", { "sciexpr-toolbar-btn-compact": e.compact }]),
314
326
  title: s.description,
315
327
  disabled: e.disabled,
316
328
  type: "button",
317
- onClick: (m) => c(s.latex)
329
+ onClick: (d) => c(s.latex)
318
330
  }, [
319
- oe(u.$slots, `btn-${s.label}`, { command: s }, () => [
331
+ oe(r.$slots, `btn-${s.label}`, { command: s }, () => [
320
332
  le(w(s.label), 1)
321
333
  ], !0)
322
334
  ], 10, ke))), 128))
@@ -324,7 +336,7 @@ const we = {
324
336
  ], 64))), 64))
325
337
  ], 2));
326
338
  }
327
- }), Se = /* @__PURE__ */ E(Ce, [["__scopeId", "data-v-329eccb9"]]), Ne = {
339
+ }), Se = /* @__PURE__ */ A(Ce, [["__scopeId", "data-v-329eccb9"]]), Ne = {
328
340
  key: 0,
329
341
  class: "sciexpr-preview-error"
330
342
  }, _e = {
@@ -336,7 +348,7 @@ const we = {
336
348
  }, Ie = {
337
349
  key: 3,
338
350
  class: "sciexpr-preview-source"
339
- }, Le = /* @__PURE__ */ B({
351
+ }, Le = /* @__PURE__ */ E({
340
352
  __name: "LivePreview",
341
353
  props: {
342
354
  source: {},
@@ -345,38 +357,38 @@ const we = {
345
357
  },
346
358
  setup(e) {
347
359
  const o = e, l = v(o.source), n = v(o.displayMode);
348
- q(() => o.source, (r) => {
349
- l.value = r;
350
- }), q(() => o.displayMode, (r) => {
351
- n.value = r;
360
+ B(() => o.source, (u) => {
361
+ l.value = u;
362
+ }), B(() => o.displayMode, (u) => {
363
+ n.value = u;
352
364
  });
353
- const { html: c, error: u } = J({
365
+ const { html: c, error: r } = J({
354
366
  source: l,
355
367
  displayMode: n
356
368
  });
357
- return (r, t) => (i(), d("div", {
369
+ return (u, a) => (i(), m("div", {
358
370
  class: N(["sciexpr-preview", { "sciexpr-preview-display": e.displayMode }])
359
371
  }, [
360
- S(u) ? (i(), d("div", Ne, [
361
- t[0] || (t[0] = y("span", { class: "sciexpr-preview-error-icon" }, "⚠", -1)),
362
- y("span", null, w(S(u).message), 1)
363
- ])) : S(c) ? (i(), d("div", _e, [
364
- y("span", { innerHTML: S(c) }, null, 8, $e)
365
- ])) : (i(), d("div", Me, [...t[1] || (t[1] = [
366
- y("span", { class: "sciexpr-preview-empty-text" }, "Preview", -1)
372
+ S(r) ? (i(), m("div", Ne, [
373
+ a[0] || (a[0] = h("span", { class: "sciexpr-preview-error-icon" }, "⚠", -1)),
374
+ h("span", null, w(S(r).message), 1)
375
+ ])) : S(c) ? (i(), m("div", _e, [
376
+ h("span", { innerHTML: S(c) }, null, 8, $e)
377
+ ])) : (i(), m("div", Me, [...a[1] || (a[1] = [
378
+ h("span", { class: "sciexpr-preview-empty-text" }, "Preview", -1)
367
379
  ])])),
368
- e.showSource && e.source ? (i(), d("div", Ie, [
369
- y("code", null, w(e.source), 1)
380
+ e.showSource && e.source ? (i(), m("div", Ie, [
381
+ h("code", null, w(e.source), 1)
370
382
  ])) : M("", !0)
371
383
  ], 2));
372
384
  }
373
- }), Pe = /* @__PURE__ */ E(Le, [["__scopeId", "data-v-b3730bc4"]]), Te = ["aria-selected", "onClick", "onMouseenter"], Re = { class: "sciexpr-autocomplete-label" }, Be = {
385
+ }), Pe = /* @__PURE__ */ A(Le, [["__scopeId", "data-v-b3730bc4"]]), Re = ["aria-selected", "onClick", "onMouseenter"], Te = { class: "sciexpr-autocomplete-label" }, Be = {
374
386
  key: 0,
375
387
  class: "sciexpr-autocomplete-desc"
376
388
  }, Ee = {
377
389
  key: 1,
378
390
  class: "sciexpr-autocomplete-source"
379
- }, Ae = /* @__PURE__ */ B({
391
+ }, Ae = /* @__PURE__ */ E({
380
392
  __name: "AutocompleteDropdown",
381
393
  props: {
382
394
  items: {},
@@ -386,46 +398,46 @@ const we = {
386
398
  },
387
399
  emits: ["select", "close"],
388
400
  setup(e, { emit: o }) {
389
- const l = o, n = Y(O, null);
390
- function c(r) {
391
- l("select", r);
401
+ const l = o, n = Y(q, null);
402
+ function c(u) {
403
+ l("select", u);
392
404
  }
393
- function u(r) {
405
+ function r(u) {
394
406
  return {
395
407
  symbol: "#0d6efd",
396
408
  command: "#6f42c1",
397
409
  template: "#198754",
398
410
  correction: "#fd7e14",
399
411
  formula: "#d63384"
400
- }[r] ?? "#6c757d";
412
+ }[u] ?? "#6c757d";
401
413
  }
402
- return (r, t) => (i(), G(ne, { to: "body" }, [
403
- e.visible && e.items.length > 0 ? (i(), d("div", {
414
+ return (u, a) => (i(), G(ne, { to: "body" }, [
415
+ e.visible && e.items.length > 0 ? (i(), m("div", {
404
416
  key: 0,
405
417
  class: "sciexpr-autocomplete",
406
418
  style: H(e.position ? { top: e.position.top + "px", left: e.position.left + "px" } : {}),
407
419
  role: "listbox"
408
420
  }, [
409
- (i(!0), d(C, null, $(e.items, (s, m) => (i(), d("div", {
410
- key: `${s.text}-${m}`,
411
- class: N(["sciexpr-autocomplete-item", { selected: m === e.selectedIndex }]),
421
+ (i(!0), m(C, null, $(e.items, (s, d) => (i(), m("div", {
422
+ key: `${s.text}-${d}`,
423
+ class: N(["sciexpr-autocomplete-item", { selected: d === e.selectedIndex }]),
412
424
  role: "option",
413
- "aria-selected": m === e.selectedIndex,
414
- onClick: (a) => c(s),
415
- onMouseenter: (a) => r.$emit("select", s)
425
+ "aria-selected": d === e.selectedIndex,
426
+ onClick: (t) => c(s),
427
+ onMouseenter: (t) => u.$emit("select", s)
416
428
  }, [
417
- y("span", {
429
+ h("span", {
418
430
  class: "sciexpr-autocomplete-category",
419
- style: H({ background: u(s.category) })
431
+ style: H({ background: r(s.category) })
420
432
  }, w(s.category), 5),
421
- y("span", Re, w(s.label), 1),
422
- s.description ? (i(), d("span", Be, w(s.description), 1)) : M("", !0),
423
- S(n) ? (i(), d("span", Ee, w(s.previewHtml ? "AI" : ""), 1)) : M("", !0)
424
- ], 42, Te))), 128))
433
+ h("span", Te, w(s.label), 1),
434
+ s.description ? (i(), m("span", Be, w(s.description), 1)) : M("", !0),
435
+ S(n) ? (i(), m("span", Ee, w(s.previewHtml ? "AI" : ""), 1)) : M("", !0)
436
+ ], 42, Re))), 128))
425
437
  ], 4)) : M("", !0)
426
438
  ]));
427
439
  }
428
- }), Oe = /* @__PURE__ */ E(Ae, [["__scopeId", "data-v-d18e03d1"]]), qe = { class: "sciexpr-editor-input-wrap" }, Fe = ["placeholder", "readonly", "rows"], He = /* @__PURE__ */ B({
440
+ }), Oe = /* @__PURE__ */ A(Ae, [["__scopeId", "data-v-d18e03d1"]]), qe = { class: "sciexpr-editor-input-wrap" }, Fe = ["placeholder", "readonly", "rows"], He = /* @__PURE__ */ E({
429
441
  __name: "FormulaEditor",
430
442
  props: {
431
443
  value: { default: "" },
@@ -440,100 +452,100 @@ const we = {
440
452
  },
441
453
  emits: ["update:value", "change", "error"],
442
454
  setup(e, { emit: o }) {
443
- const l = e, n = o, c = v(null), u = v(null), r = v({ top: 0, left: 0 }), t = v(l.value);
444
- q(() => l.value, (p) => {
445
- t.value = p;
455
+ const l = e, n = o, c = v(null), r = v(null), u = v({ top: 0, left: 0 }), a = v(l.value);
456
+ B(() => l.value, (p) => {
457
+ a.value = p;
446
458
  });
447
- const s = fe({ initialValue: t.value }), { pipeline: m } = ge(), a = ye({
459
+ const s = fe({ initialValue: a.value }), { pipeline: d } = ge(), t = ye({
448
460
  config: l.autocomplete,
449
- pipeline: m
461
+ pipeline: d
450
462
  });
451
463
  function b(p) {
452
464
  const x = p.target, f = x.value, k = x.selectionStart;
453
- t.value = f, s.value.value = f, s.cursor.value = k, n("update:value", f), n("change", f), a.trigger(f, k), W();
465
+ a.value = f, s.value.value = f, s.cursor.value = k, n("update:value", f), n("change", f), t.trigger(f, k), W();
454
466
  }
455
- function h(p) {
456
- if (a.visible.value) {
467
+ function y(p) {
468
+ if (t.visible.value) {
457
469
  if (p.key === "ArrowDown") {
458
- p.preventDefault(), a.moveSelection("down");
470
+ p.preventDefault(), t.moveSelection("down");
459
471
  return;
460
472
  }
461
473
  if (p.key === "ArrowUp") {
462
- p.preventDefault(), a.moveSelection("up");
474
+ p.preventDefault(), t.moveSelection("up");
463
475
  return;
464
476
  }
465
477
  if (p.key === "Enter" || p.key === "Tab") {
466
478
  p.preventDefault();
467
- const x = a.suggestions.value[a.selectedIndex.value];
479
+ const x = t.suggestions.value[t.selectedIndex.value];
468
480
  x && z(x.text);
469
481
  return;
470
482
  }
471
483
  if (p.key === "Escape") {
472
- a.close();
484
+ t.close();
473
485
  return;
474
486
  }
475
487
  }
476
- (p.ctrlKey || p.metaKey) && (p.key === "b" && (p.preventDefault(), ee("\\mathbf{", "}")), p.key === "/" && (p.preventDefault(), R("\\frac{}{}")));
488
+ (p.ctrlKey || p.metaKey) && (p.key === "b" && (p.preventDefault(), ee("\\mathbf{", "}")), p.key === "/" && (p.preventDefault(), T("\\frac{}{}")));
477
489
  }
478
490
  function g(p) {
479
- R(p);
491
+ T(p);
480
492
  }
481
493
  function I(p) {
482
494
  z(p.text);
483
495
  }
484
- function R(p) {
496
+ function T(p) {
485
497
  const x = c.value;
486
498
  if (!x) return;
487
- const f = x.selectionStart, k = x.selectionEnd, L = t.value.slice(0, f), P = t.value.slice(k);
488
- t.value = L + p + P, n("update:value", t.value), V(() => {
499
+ const f = x.selectionStart, k = x.selectionEnd, L = a.value.slice(0, f), P = a.value.slice(k);
500
+ a.value = L + p + P, n("update:value", a.value), V(() => {
489
501
  x.focus();
490
502
  const _ = f + p.length;
491
- x.setSelectionRange(_, _), a.close();
503
+ x.setSelectionRange(_, _), t.close();
492
504
  });
493
505
  }
494
506
  function z(p) {
495
507
  const x = c.value;
496
508
  if (!x) return;
497
- const f = x.selectionStart, k = t.value.slice(0, f), L = k.lastIndexOf("\\");
509
+ const f = x.selectionStart, k = a.value.slice(0, f), L = k.lastIndexOf("\\");
498
510
  let P;
499
511
  if (L !== -1 && f - L < 30)
500
512
  P = L;
501
513
  else {
502
- const T = k.match(/([a-zA-Z_]+)$/);
503
- P = T ? f - T[0].length : f;
514
+ const R = k.match(/([a-zA-Z_]+)$/);
515
+ P = R ? f - R[0].length : f;
504
516
  }
505
- const _ = t.value.slice(f);
506
- t.value = t.value.slice(0, P) + p + _, n("update:value", t.value), V(() => {
517
+ const _ = a.value.slice(f);
518
+ a.value = a.value.slice(0, P) + p + _, n("update:value", a.value), V(() => {
507
519
  x.focus();
508
- const T = P + p.length;
509
- x.setSelectionRange(T, T), a.close();
520
+ const R = P + p.length;
521
+ x.setSelectionRange(R, R), t.close();
510
522
  });
511
523
  }
512
524
  function ee(p, x) {
513
525
  const f = c.value;
514
526
  if (!f) return;
515
- const k = f.selectionStart, L = f.selectionEnd, P = t.value.slice(k, L) || "", _ = t.value.slice(0, k) + p + P + x + t.value.slice(L);
516
- t.value = _, n("update:value", _), V(() => {
527
+ const k = f.selectionStart, L = f.selectionEnd, P = a.value.slice(k, L) || "", _ = a.value.slice(0, k) + p + P + x + a.value.slice(L);
528
+ a.value = _, n("update:value", _), V(() => {
517
529
  f.focus();
518
- const T = k + p.length + P.length;
519
- f.setSelectionRange(T, T);
530
+ const R = k + p.length + P.length;
531
+ f.setSelectionRange(R, R);
520
532
  });
521
533
  }
522
534
  function W() {
523
535
  const p = c.value;
524
536
  if (!p) return;
525
- const x = p.getBoundingClientRect(), f = p.selectionStart, k = 20, L = 8, _ = t.value.slice(0, f).split(`
526
- `), T = _[_.length - 1].length;
527
- r.value = {
537
+ const x = p.getBoundingClientRect(), f = p.selectionStart, k = 20, L = 8, _ = a.value.slice(0, f).split(`
538
+ `), R = _[_.length - 1].length;
539
+ u.value = {
528
540
  top: x.top + _.length * k + 24 + window.scrollY,
529
- left: x.left + T * L + window.scrollX
541
+ left: x.left + R * L + window.scrollX
530
542
  };
531
543
  }
532
- return F(() => t.value.trim().length > 0), (p, x) => {
544
+ return F(() => a.value.trim().length > 0), (p, x) => {
533
545
  var f;
534
- return i(), d("div", {
546
+ return i(), m("div", {
535
547
  ref_key: "editorRef",
536
- ref: u,
548
+ ref: r,
537
549
  class: N(["sciexpr-editor", { "sciexpr-editor-display": e.displayMode }])
538
550
  }, [
539
551
  e.showToolbar && !e.readonly ? (i(), G(Se, {
@@ -541,11 +553,11 @@ const we = {
541
553
  categories: (f = e.toolbar) == null ? void 0 : f.categories,
542
554
  onInsert: g
543
555
  }, null, 8, ["categories"])) : M("", !0),
544
- y("div", qe, [
545
- D(y("textarea", {
556
+ h("div", qe, [
557
+ D(h("textarea", {
546
558
  ref_key: "textareaRef",
547
559
  ref: c,
548
- "onUpdate:modelValue": x[0] || (x[0] = (k) => t.value = k),
560
+ "onUpdate:modelValue": x[0] || (x[0] = (k) => a.value = k),
549
561
  class: N(["sciexpr-editor-textarea", {
550
562
  "sciexpr-editor-textarea-display": e.displayMode,
551
563
  "sciexpr-editor-textarea-readonly": e.readonly
@@ -559,30 +571,30 @@ const we = {
559
571
  autocorrect: "off",
560
572
  autocapitalize: "off",
561
573
  onInput: b,
562
- onKeydown: h,
574
+ onKeydown: y,
563
575
  onFocus: W
564
576
  }, null, 42, Fe), [
565
- [j, t.value]
577
+ [j, a.value]
566
578
  ])
567
579
  ]),
568
580
  se(Oe, {
569
- items: S(a).suggestions.value,
570
- visible: S(a).visible.value,
571
- "selected-index": S(a).selectedIndex.value,
572
- position: r.value,
581
+ items: S(t).suggestions.value,
582
+ visible: S(t).visible.value,
583
+ "selected-index": S(t).selectedIndex.value,
584
+ position: u.value,
573
585
  onSelect: I,
574
- onClose: x[1] || (x[1] = (k) => S(a).close())
586
+ onClose: x[1] || (x[1] = (k) => S(t).close())
575
587
  }, null, 8, ["items", "visible", "selected-index", "position"]),
576
588
  e.showPreview ? (i(), G(Pe, {
577
589
  key: 1,
578
- source: t.value,
590
+ source: a.value,
579
591
  "display-mode": e.displayMode,
580
592
  "show-source": !1
581
593
  }, null, 8, ["source", "display-mode"])) : M("", !0)
582
594
  ], 2);
583
595
  };
584
596
  }
585
- }), mt = /* @__PURE__ */ E(He, [["__scopeId", "data-v-d6181c80"]]), De = { class: "sciexpr-symbol-panel" }, Ke = { class: "sciexpr-symbol-search" }, Ve = { class: "sciexpr-symbol-tabs" }, Ge = ["onClick"], Ue = { class: "sciexpr-symbol-grid" }, ze = ["title", "disabled", "onClick"], We = { class: "sciexpr-symbol-unicode" }, Ze = { class: "sciexpr-symbol-name" }, Xe = ["title", "disabled", "onClick"], Ye = { class: "sciexpr-symbol-unicode" }, je = { class: "sciexpr-symbol-name" }, Qe = /* @__PURE__ */ B({
597
+ }), mt = /* @__PURE__ */ A(He, [["__scopeId", "data-v-d6181c80"]]), De = { class: "sciexpr-symbol-panel" }, Ke = { class: "sciexpr-symbol-search" }, Ve = { class: "sciexpr-symbol-tabs" }, Ge = ["onClick"], Ue = { class: "sciexpr-symbol-grid" }, ze = ["title", "disabled", "onClick"], We = { class: "sciexpr-symbol-unicode" }, Ze = { class: "sciexpr-symbol-name" }, Xe = ["title", "disabled", "onClick"], Ye = { class: "sciexpr-symbol-unicode" }, je = { class: "sciexpr-symbol-name" }, Qe = /* @__PURE__ */ E({
586
598
  __name: "SymbolPanel",
587
599
  props: {
588
600
  disabled: { type: Boolean }
@@ -701,78 +713,78 @@ const we = {
701
713
  { latex: "\\ce{->[H2O]}", unicode: "→[H₂O]", name: "With condition" }
702
714
  ]
703
715
  }
704
- ], c = v(n[0].id), u = v(""), r = F(() => {
705
- if (!u.value) return n;
706
- const s = u.value.toLowerCase();
707
- return n.map((m) => ({
708
- ...m,
709
- symbols: m.symbols.filter(
710
- (a) => a.name.toLowerCase().includes(s) || a.latex.toLowerCase().includes(s)
716
+ ], c = v(n[0].id), r = v(""), u = F(() => {
717
+ if (!r.value) return n;
718
+ const s = r.value.toLowerCase();
719
+ return n.map((d) => ({
720
+ ...d,
721
+ symbols: d.symbols.filter(
722
+ (t) => t.name.toLowerCase().includes(s) || t.latex.toLowerCase().includes(s)
711
723
  )
712
- })).filter((m) => m.symbols.length > 0);
724
+ })).filter((d) => d.symbols.length > 0);
713
725
  });
714
- function t(s) {
726
+ function a(s) {
715
727
  l("insert", s);
716
728
  }
717
- return (s, m) => (i(), d("div", De, [
718
- y("div", Ke, [
719
- D(y("input", {
720
- "onUpdate:modelValue": m[0] || (m[0] = (a) => u.value = a),
729
+ return (s, d) => (i(), m("div", De, [
730
+ h("div", Ke, [
731
+ D(h("input", {
732
+ "onUpdate:modelValue": d[0] || (d[0] = (t) => r.value = t),
721
733
  type: "text",
722
734
  class: "sciexpr-symbol-search-input",
723
735
  placeholder: "Search symbols..."
724
736
  }, null, 512), [
725
- [j, u.value]
737
+ [j, r.value]
726
738
  ])
727
739
  ]),
728
- y("div", Ve, [
729
- (i(), d(C, null, $(n, (a) => y("button", {
730
- key: a.id,
731
- class: N(["sciexpr-symbol-tab", { active: c.value === a.id }]),
732
- onClick: (b) => c.value = a.id,
740
+ h("div", Ve, [
741
+ (i(), m(C, null, $(n, (t) => h("button", {
742
+ key: t.id,
743
+ class: N(["sciexpr-symbol-tab", { active: c.value === t.id }]),
744
+ onClick: (b) => c.value = t.id,
733
745
  type: "button"
734
- }, w(a.label), 11, Ge)), 64))
746
+ }, w(t.label), 11, Ge)), 64))
735
747
  ]),
736
- y("div", Ue, [
737
- u.value ? (i(!0), d(C, { key: 0 }, $(r.value, (a) => (i(), d(C, {
738
- key: a.id
748
+ h("div", Ue, [
749
+ r.value ? (i(!0), m(C, { key: 0 }, $(u.value, (t) => (i(), m(C, {
750
+ key: t.id
739
751
  }, [
740
- (i(!0), d(C, null, $(a.symbols, (b) => (i(), d("button", {
752
+ (i(!0), m(C, null, $(t.symbols, (b) => (i(), m("button", {
741
753
  key: b.latex,
742
754
  class: N(["sciexpr-symbol-btn", { "sciexpr-symbol-btn-disabled": e.disabled }]),
743
755
  title: `${b.name} — ${b.latex}`,
744
756
  disabled: e.disabled,
745
757
  type: "button",
746
- onClick: (h) => t(b.latex)
758
+ onClick: (y) => a(b.latex)
747
759
  }, [
748
- y("span", We, w(b.unicode), 1),
749
- y("span", Ze, w(b.name), 1)
760
+ h("span", We, w(b.unicode), 1),
761
+ h("span", Ze, w(b.name), 1)
750
762
  ], 10, ze))), 128))
751
- ], 64))), 128)) : (i(), d(C, { key: 1 }, $(n, (a) => (i(), d(C, {
752
- key: a.id
763
+ ], 64))), 128)) : (i(), m(C, { key: 1 }, $(n, (t) => (i(), m(C, {
764
+ key: t.id
753
765
  }, [
754
- c.value === a.id ? (i(!0), d(C, { key: 0 }, $(a.symbols, (b) => (i(), d("button", {
766
+ c.value === t.id ? (i(!0), m(C, { key: 0 }, $(t.symbols, (b) => (i(), m("button", {
755
767
  key: b.latex,
756
768
  class: N(["sciexpr-symbol-btn", { "sciexpr-symbol-btn-disabled": e.disabled }]),
757
769
  title: `${b.name} — ${b.latex}`,
758
770
  disabled: e.disabled,
759
771
  type: "button",
760
- onClick: (h) => t(b.latex)
772
+ onClick: (y) => a(b.latex)
761
773
  }, [
762
- y("span", Ye, w(b.unicode), 1),
763
- y("span", je, w(b.name), 1)
774
+ h("span", Ye, w(b.unicode), 1),
775
+ h("span", je, w(b.name), 1)
764
776
  ], 10, Xe))), 128)) : M("", !0)
765
777
  ], 64))), 64))
766
778
  ])
767
779
  ]));
768
780
  }
769
- }), pt = /* @__PURE__ */ E(Qe, [["__scopeId", "data-v-8a9ec119"]]), Je = { class: "sciexpr-element-grid" }, et = ["title", "disabled", "onClick"], tt = {
781
+ }), pt = /* @__PURE__ */ A(Qe, [["__scopeId", "data-v-8a9ec119"]]), Je = { class: "sciexpr-element-grid" }, et = ["title", "disabled", "onClick"], tt = {
770
782
  key: 0,
771
783
  class: "sciexpr-element-number"
772
784
  }, at = {
773
785
  key: 1,
774
786
  class: "sciexpr-element-symbol"
775
- }, X = 18, ot = 6, lt = /* @__PURE__ */ B({
787
+ }, X = 18, ot = 6, lt = /* @__PURE__ */ E({
776
788
  __name: "ElementTable",
777
789
  props: {
778
790
  disabled: { type: Boolean },
@@ -824,70 +836,70 @@ const we = {
824
836
  { symbol: "Pt", name: "Platinum", atomicNumber: 78, row: 6, col: 10, block: "d" },
825
837
  { symbol: "Pb", name: "Lead", atomicNumber: 82, row: 6, col: 14, block: "p" }
826
838
  ], c = F(() => {
827
- const t = [];
839
+ const a = [];
828
840
  for (let s = 0; s < ot; s++)
829
- t.push(new Array(X).fill(null));
841
+ a.push(new Array(X).fill(null));
830
842
  for (const s of n)
831
- t[s.row - 1][s.col - 1] = s;
832
- return t;
843
+ a[s.row - 1][s.col - 1] = s;
844
+ return a;
833
845
  });
834
- function u(t) {
846
+ function r(a) {
835
847
  return {
836
848
  s: "#ff6b6b",
837
849
  p: "#ffd93d",
838
850
  d: "#6bcb77",
839
851
  f: "#4d96ff"
840
- }[t] ?? "#adb5bd";
852
+ }[a] ?? "#adb5bd";
841
853
  }
842
- function r(t) {
843
- l("insert", t);
854
+ function u(a) {
855
+ l("insert", a);
844
856
  }
845
- return (t, s) => (i(), d("div", {
857
+ return (a, s) => (i(), m("div", {
846
858
  class: N(["sciexpr-element-table", { "sciexpr-element-table-compact": e.compact }])
847
859
  }, [
848
860
  s[0] || (s[0] = ce('<div class="sciexpr-element-legend" data-v-a5437c7c><span class="legend-item" data-v-a5437c7c><span class="legend-dot" style="background:#ff6b6b;" data-v-a5437c7c></span> s-block</span><span class="legend-item" data-v-a5437c7c><span class="legend-dot" style="background:#ffd93d;" data-v-a5437c7c></span> p-block</span><span class="legend-item" data-v-a5437c7c><span class="legend-dot" style="background:#6bcb77;" data-v-a5437c7c></span> d-block</span><span class="legend-item" data-v-a5437c7c><span class="legend-dot" style="background:#4d96ff;" data-v-a5437c7c></span> f-block</span></div>', 1)),
849
- y("div", Je, [
850
- (i(!0), d(C, null, $(c.value, (m) => (i(), d(C, {
851
- key: c.value.indexOf(m)
861
+ h("div", Je, [
862
+ (i(!0), m(C, null, $(c.value, (d) => (i(), m(C, {
863
+ key: c.value.indexOf(d)
852
864
  }, [
853
- (i(!0), d(C, null, $(m, (a, b) => D((i(), d("button", {
865
+ (i(!0), m(C, null, $(d, (t, b) => D((i(), m("button", {
854
866
  key: b,
855
867
  class: N(["sciexpr-element-cell", {
856
868
  "sciexpr-element-cell-compact": e.compact,
857
869
  "sciexpr-element-cell-disabled": e.disabled
858
870
  }]),
859
- style: H(a ? {
860
- gridRow: a.row,
861
- gridColumn: a.col,
862
- "--block-color": u(a.block)
871
+ style: H(t ? {
872
+ gridRow: t.row,
873
+ gridColumn: t.col,
874
+ "--block-color": r(t.block)
863
875
  } : {}),
864
- title: a ? `${a.name} (${a.atomicNumber})` : "",
876
+ title: t ? `${t.name} (${t.atomicNumber})` : "",
865
877
  disabled: e.disabled,
866
878
  type: "button",
867
- onClick: (h) => a && r(a.symbol)
879
+ onClick: (y) => t && u(t.symbol)
868
880
  }, [
869
- a ? (i(), d("span", tt, w(a.atomicNumber), 1)) : M("", !0),
870
- a ? (i(), d("span", at, w(a.symbol), 1)) : M("", !0)
881
+ t ? (i(), m("span", tt, w(t.atomicNumber), 1)) : M("", !0),
882
+ t ? (i(), m("span", at, w(t.symbol), 1)) : M("", !0)
871
883
  ], 14, et)), [
872
- [Z, a !== null]
884
+ [Z, t !== null]
873
885
  ])), 128)),
874
- (i(), d(C, null, $(X, (a) => D(y("div", {
875
- key: "empty-" + a,
886
+ (i(), m(C, null, $(X, (t) => D(h("div", {
887
+ key: "empty-" + t,
876
888
  class: "sciexpr-element-cell sciexpr-element-empty",
877
- style: H({ gridRow: c.value.indexOf(m) + 1, gridColumn: a })
889
+ style: H({ gridRow: c.value.indexOf(d) + 1, gridColumn: t })
878
890
  }, null, 4), [
879
- [Z, !m[a - 1]]
891
+ [Z, !d[t - 1]]
880
892
  ])), 64))
881
893
  ], 64))), 128))
882
894
  ])
883
895
  ], 2));
884
896
  }
885
- }), bt = /* @__PURE__ */ E(lt, [["__scopeId", "data-v-a5437c7c"]]);
897
+ }), bt = /* @__PURE__ */ A(lt, [["__scopeId", "data-v-a5437c7c"]]);
886
898
  function xt(e) {
887
899
  function o(l) {
888
900
  for (const n of e) {
889
- const c = l.key.toLowerCase() === n.key.toLowerCase(), u = !!n.ctrl === (l.ctrlKey || l.metaKey), r = !!n.shift === l.shiftKey, t = !!n.alt === l.altKey;
890
- if (c && u && r && t) {
901
+ const c = l.key.toLowerCase() === n.key.toLowerCase(), r = !!n.ctrl === (l.ctrlKey || l.metaKey), u = !!n.shift === l.shiftKey, a = !!n.alt === l.altKey;
902
+ if (c && r && u && a) {
891
903
  l.preventDefault(), n.action();
892
904
  return;
893
905
  }
@@ -912,7 +924,7 @@ const vt = [
912
924
  }, description: "Superscript (^)" }
913
925
  ];
914
926
  export {
915
- O as AI_PIPELINE_KEY,
927
+ q as AI_PIPELINE_KEY,
916
928
  Oe as AutocompleteDropdown,
917
929
  vt as BUILTIN_SHORTCUTS,
918
930
  bt as ElementTable,