patent-editor 0.1.2 → 0.1.4

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/lib.js CHANGED
@@ -1,60 +1,60 @@
1
- var En = Object.defineProperty;
2
- var Nn = (e, t, n) => t in e ? En(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
3
- var Le = (e, t, n) => Nn(e, typeof t != "symbol" ? t + "" : t, n);
1
+ var Nn = Object.defineProperty;
2
+ var kn = (e, t, n) => t in e ? Nn(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
3
+ var Re = (e, t, n) => kn(e, typeof t != "symbol" ? t + "" : t, n);
4
4
  import { jsx as g, jsxs as A, Fragment as we } from "react/jsx-runtime";
5
- import Pe, { forwardRef as Ht, useState as z, useEffect as B, useCallback as de, useImperativeHandle as Ut, useRef as X, useMemo as Te } from "react";
6
- import { Extension as Ve, ReactRenderer as kn, Node as ee, mergeAttributes as ae, NodeViewWrapper as _n, ReactNodeViewRenderer as jt, useEditorState as An, EditorContent as Ln, useEditor as Pn } from "@tiptap/react";
7
- import Rn from "@tiptap/extension-document";
5
+ import De, { forwardRef as jt, useState as z, useEffect as B, useCallback as de, useImperativeHandle as Wt, useRef as X, useMemo as Te } from "react";
6
+ import { Extension as Je, ReactRenderer as _n, Node as ee, mergeAttributes as ae, NodeViewWrapper as An, ReactNodeViewRenderer as qt, useEditorState as Ln, EditorContent as Pn, useEditor as Rn } from "@tiptap/react";
7
+ import Dn from "@tiptap/extension-document";
8
8
  import Mn from "@tiptap/extension-paragraph";
9
- import Dn from "@tiptap/extension-text";
10
- import $n from "@tiptap/extension-heading";
11
- import On from "@tiptap/extension-bullet-list";
12
- import Fn from "@tiptap/extension-ordered-list";
13
- import zn from "@tiptap/extension-list-item";
14
- import Bn from "@tiptap/extension-blockquote";
15
- import Hn from "@tiptap/extension-code-block";
16
- import Un from "@tiptap/extension-horizontal-rule";
17
- import jn from "@tiptap/extension-task-list";
18
- import Wn from "@tiptap/extension-task-item";
19
- import qn from "@tiptap/extension-image";
20
- import { Table as Gn } from "@tiptap/extension-table";
21
- import Vn from "@tiptap/extension-table-row";
22
- import Kn from "@tiptap/extension-table-cell";
23
- import Jn from "@tiptap/extension-table-header";
24
- import Xn from "@tiptap/extension-placeholder";
25
- import Qn from "@tiptap/extension-history";
26
- import { dropCursor as Yn } from "prosemirror-dropcursor";
27
- import { gapCursor as Zn } from "prosemirror-gapcursor";
28
- import er from "@tiptap/extension-text-align";
29
- import { PluginKey as ke, Plugin as Ke, TextSelection as Wt } from "@tiptap/pm/state";
30
- import tr from "@tiptap/suggestion";
31
- import nr from "tippy.js";
32
- import { create as rr } from "zustand";
33
- import { DecorationSet as Ee, Decoration as le } from "@tiptap/pm/view";
34
- import { diff_match_patch as qt } from "diff-match-patch";
35
- import ar from "@tiptap/extension-bold";
36
- import sr from "@tiptap/extension-italic";
37
- import ir from "@tiptap/extension-underline";
38
- import or from "@tiptap/extension-strike";
39
- import cr from "@tiptap/extension-code";
40
- import lr from "@tiptap/extension-superscript";
41
- import dr from "@tiptap/extension-subscript";
42
- import ur from "@tiptap/extension-link";
43
- import { TextStyle as mr } from "@tiptap/extension-text-style";
44
- import fr from "@tiptap/extension-color";
45
- import gr from "@tiptap/extension-highlight";
46
- import pr from "katex";
9
+ import $n from "@tiptap/extension-text";
10
+ import On from "@tiptap/extension-heading";
11
+ import Fn from "@tiptap/extension-bullet-list";
12
+ import zn from "@tiptap/extension-ordered-list";
13
+ import Bn from "@tiptap/extension-list-item";
14
+ import Hn from "@tiptap/extension-blockquote";
15
+ import Un from "@tiptap/extension-code-block";
16
+ import jn from "@tiptap/extension-horizontal-rule";
17
+ import Wn from "@tiptap/extension-task-list";
18
+ import qn from "@tiptap/extension-task-item";
19
+ import Gn from "@tiptap/extension-image";
20
+ import { Table as Vn } from "@tiptap/extension-table";
21
+ import Kn from "@tiptap/extension-table-row";
22
+ import Jn from "@tiptap/extension-table-cell";
23
+ import Xn from "@tiptap/extension-table-header";
24
+ import Qn from "@tiptap/extension-placeholder";
25
+ import Yn from "@tiptap/extension-history";
26
+ import { dropCursor as Zn } from "prosemirror-dropcursor";
27
+ import { gapCursor as er } from "prosemirror-gapcursor";
28
+ import tr from "@tiptap/extension-text-align";
29
+ import { PluginKey as _e, Plugin as Xe, TextSelection as Ie } from "@tiptap/pm/state";
30
+ import nr from "@tiptap/suggestion";
31
+ import rr from "tippy.js";
32
+ import { create as ar } from "zustand";
33
+ import { DecorationSet as Ne, Decoration as le } from "@tiptap/pm/view";
34
+ import { diff_match_patch as Gt } from "diff-match-patch";
35
+ import sr from "@tiptap/extension-bold";
36
+ import ir from "@tiptap/extension-italic";
37
+ import or from "@tiptap/extension-underline";
38
+ import cr from "@tiptap/extension-strike";
39
+ import lr from "@tiptap/extension-code";
40
+ import dr from "@tiptap/extension-superscript";
41
+ import ur from "@tiptap/extension-subscript";
42
+ import mr from "@tiptap/extension-link";
43
+ import { TextStyle as fr } from "@tiptap/extension-text-style";
44
+ import gr from "@tiptap/extension-color";
45
+ import pr from "@tiptap/extension-highlight";
46
+ import hr from "katex";
47
47
  import "katex/dist/katex.min.css";
48
48
  import "mathlive";
49
- import { findWrapping as hr } from "@tiptap/pm/transform";
50
- import { Slice as br, Fragment as yr } from "@tiptap/pm/model";
51
- import { createPortal as vr } from "react-dom";
52
- import { Undo2 as Cr, Redo2 as wr, Bold as Gt, Italic as Vt, Underline as Kt, Strikethrough as Jt, Code as Xt, Superscript as Qt, Subscript as Yt, Pilcrow as xr, Heading1 as Sr, Heading2 as Tr, Heading3 as Ir, AlignLeft as Er, AlignCenter as Nr, AlignRight as kr, AlignJustify as _r, List as Ar, ListOrdered as Lr, Quote as Pr, FileCode2 as Rr, Table as Mr, Minus as Dr, CheckSquare as $r, Image as Zt, Link2 as gt, FileText as en, Box as Or, Workflow as Fr, FunctionSquare as zr, Sigma as Br, GitGraph as Hr, Square as St, Download as Ur, ChevronDown as tn, Trash2 as jr, Highlighter as Wr, Sparkles as qr, CaseSensitive as Gr, ChevronUp as Vr, Replace as Tt, X as Kr, ReplaceAll as Jr, PanelLeft as Xr, PanelLeftClose as Qr } from "lucide-react";
49
+ import { findWrapping as br } from "@tiptap/pm/transform";
50
+ import { Slice as yr, Fragment as vr } from "@tiptap/pm/model";
51
+ import { createPortal as Cr } from "react-dom";
52
+ import { Undo2 as wr, Redo2 as xr, Bold as Vt, Italic as Kt, Underline as Jt, Strikethrough as Xt, Code as Qt, Superscript as Yt, Subscript as Zt, Pilcrow as Sr, Heading1 as Tr, Heading2 as Ir, Heading3 as Er, AlignLeft as Nr, AlignCenter as kr, AlignRight as _r, AlignJustify as Ar, List as Lr, ListOrdered as Pr, Quote as Rr, FileCode2 as Dr, Table as Mr, Minus as $r, CheckSquare as Or, Image as en, Link2 as pt, FileText as tn, Box as Fr, Workflow as zr, FunctionSquare as Br, Sigma as Hr, GitGraph as Ur, Square as Tt, Download as jr, ChevronDown as nn, Trash2 as Wr, Highlighter as qr, Sparkles as Gr, CaseSensitive as Vr, ChevronUp as Kr, Replace as It, X as Jr, ReplaceAll as Xr, PanelLeft as Qr, PanelLeftClose as Yr } from "lucide-react";
53
53
  import re from "clsx";
54
- import { convertMillimetersToTwip as Se, Document as Yr, Packer as Zr, Paragraph as Je, AlignmentType as pt, TextRun as Xe } from "docx";
55
- import { saveAs as ea } from "file-saver";
56
- import { BubbleMenu as ta } from "@tiptap/react/menus";
57
- const na = new ke("slashCommand"), ra = Ve.create({
54
+ import { convertMillimetersToTwip as Se, Document as Zr, Packer as ea, Paragraph as Qe, AlignmentType as ht, TextRun as Ye } from "docx";
55
+ import { saveAs as ta } from "file-saver";
56
+ import { BubbleMenu as na } from "@tiptap/react/menus";
57
+ const ra = new _e("slashCommand"), aa = Je.create({
58
58
  name: "slashCommand",
59
59
  addOptions() {
60
60
  return {
@@ -68,14 +68,14 @@ const na = new ke("slashCommand"), ra = Ve.create({
68
68
  },
69
69
  addProseMirrorPlugins() {
70
70
  return [
71
- tr({
71
+ nr({
72
72
  editor: this.editor,
73
73
  ...this.options.suggestion,
74
- pluginKey: na
74
+ pluginKey: ra
75
75
  })
76
76
  ];
77
77
  }
78
- }), aa = {
78
+ }), sa = {
79
79
  visible: !0,
80
80
  activeTab: "chat",
81
81
  activeSectionType: null,
@@ -83,7 +83,7 @@ const na = new ke("slashCommand"), ra = Ve.create({
83
83
  regenerate: !1,
84
84
  chatReferences: [],
85
85
  pendingChatMessage: null
86
- }, N = rr((e) => ({
86
+ }, k = ar((e) => ({
87
87
  editor: null,
88
88
  document: null,
89
89
  selection: null,
@@ -94,7 +94,7 @@ const na = new ke("slashCommand"), ra = Ve.create({
94
94
  aiService: null,
95
95
  chatSessionAPI: null,
96
96
  chatSessionId: null,
97
- rightPanel: { ...aa },
97
+ rightPanel: { ...sa },
98
98
  setEditor: (t) => e({ editor: t }),
99
99
  setDocument: (t) => e({ document: t }),
100
100
  setSelection: (t) => e({ selection: t }),
@@ -162,7 +162,7 @@ const na = new ke("slashCommand"), ra = Ve.create({
162
162
  setPendingChatMessage: (t) => e((n) => ({
163
163
  rightPanel: { ...n.rightPanel, pendingChatMessage: t }
164
164
  }))
165
- })), nn = Ht(
165
+ })), rn = jt(
166
166
  ({ items: e, command: t }, n) => {
167
167
  const [r, a] = z(0);
168
168
  B(() => {
@@ -170,19 +170,19 @@ const na = new ke("slashCommand"), ra = Ve.create({
170
170
  }, [e]);
171
171
  const s = de(
172
172
  (i) => {
173
- const l = e[i];
174
- l && t(l);
173
+ const c = e[i];
174
+ c && t(c);
175
175
  },
176
176
  [e, t]
177
177
  );
178
- return Ut(n, () => ({
179
- onKeyDown: ({ event: i }) => i.key === "ArrowUp" ? (a((l) => (l + e.length - 1) % e.length), !0) : i.key === "ArrowDown" ? (a((l) => (l + 1) % e.length), !0) : i.key === "Enter" ? (s(r), !0) : !1
180
- })), e.length ? /* @__PURE__ */ g("div", { className: "slash-menu", children: e.map((i, l) => /* @__PURE__ */ A(
178
+ return Wt(n, () => ({
179
+ onKeyDown: ({ event: i }) => i.key === "ArrowUp" ? (a((c) => (c + e.length - 1) % e.length), !0) : i.key === "ArrowDown" ? (a((c) => (c + 1) % e.length), !0) : i.key === "Enter" ? (s(r), !0) : !1
180
+ })), e.length ? /* @__PURE__ */ g("div", { className: "slash-menu", children: e.map((i, c) => /* @__PURE__ */ A(
181
181
  "button",
182
182
  {
183
- className: `slash-menu-item ${l === r ? "slash-menu-item--active" : ""}`,
184
- onClick: () => s(l),
185
- onMouseEnter: () => a(l),
183
+ className: `slash-menu-item ${c === r ? "slash-menu-item--active" : ""}`,
184
+ onClick: () => s(c),
185
+ onMouseEnter: () => a(c),
186
186
  children: [
187
187
  /* @__PURE__ */ g("span", { className: "slash-menu-icon", children: i.icon }),
188
188
  /* @__PURE__ */ A("div", { className: "slash-menu-text", children: [
@@ -195,8 +195,8 @@ const na = new ke("slashCommand"), ra = Ve.create({
195
195
  )) }) : /* @__PURE__ */ g("div", { className: "slash-menu", children: /* @__PURE__ */ g("div", { className: "slash-menu-empty", children: "No results" }) });
196
196
  }
197
197
  );
198
- nn.displayName = "SlashMenuList";
199
- function sa(e) {
198
+ rn.displayName = "SlashMenuList";
199
+ function ia(e) {
200
200
  const t = e === "zh";
201
201
  return [
202
202
  {
@@ -295,14 +295,22 @@ function sa(e) {
295
295
  const a = window.prompt(t ? "请输入图片 URL" : "Enter image URL");
296
296
  a && n.chain().focus().deleteRange(r).setImage({ src: a }).run();
297
297
  }
298
+ },
299
+ {
300
+ title: t ? "权利要求" : "Claim",
301
+ description: t ? "插入权利要求条目 (Ctrl+Shift+C)" : "Insert a patent claim block (Ctrl+Shift+C)",
302
+ icon: "§",
303
+ command: ({ editor: n, range: r }) => {
304
+ n.chain().focus().deleteRange(r).run(), Ae(n).execCommand("insertClaim");
305
+ }
298
306
  }
299
307
  ];
300
308
  }
301
- function ia() {
309
+ function oa() {
302
310
  return {
303
311
  char: "/",
304
312
  items: ({ query: e }) => {
305
- const t = N.getState().editorLanguage, n = sa(t);
313
+ const t = k.getState().editorLanguage, n = ia(t);
306
314
  if (!e) return n;
307
315
  const r = e.toLowerCase();
308
316
  return n.filter(
@@ -313,10 +321,10 @@ function ia() {
313
321
  let e = null, t = null;
314
322
  return {
315
323
  onStart: (n) => {
316
- e = new kn(nn, {
324
+ e = new _n(rn, {
317
325
  props: n,
318
326
  editor: n.editor
319
- }), n.clientRect && (t = nr("body", {
327
+ }), n.clientRect && (t = rr("body", {
320
328
  getReferenceClientRect: n.clientRect,
321
329
  appendTo: () => document.body,
322
330
  content: e.element,
@@ -343,33 +351,33 @@ function ia() {
343
351
  }
344
352
  };
345
353
  }
346
- const oa = new ke("searchReplace");
347
- function Re(e, t, n) {
354
+ const ca = new _e("searchReplace");
355
+ function Me(e, t, n) {
348
356
  if (!t) return [];
349
357
  const r = [], a = e.textBetween(0, e.content.size, `
350
358
  `, "\0"), s = n ? t : t.toLowerCase(), i = n ? a : a.toLowerCase();
351
- let l = 0;
352
- for (; l < i.length; ) {
353
- const c = i.indexOf(s, l);
354
- if (c === -1) break;
359
+ let c = 0;
360
+ for (; c < i.length; ) {
361
+ const l = i.indexOf(s, c);
362
+ if (l === -1) break;
355
363
  let d = 0, o = -1, u = -1;
356
364
  e.descendants((m, h) => {
357
365
  if (o !== -1 && u !== -1) return !1;
358
366
  if (m.isText) {
359
367
  const p = m.text || "";
360
368
  for (let f = 0; f < p.length; f++) {
361
- if (d === c && (o = h + f), d === c + s.length)
369
+ if (d === l && (o = h + f), d === l + s.length)
362
370
  return u = h + f, !1;
363
371
  d++;
364
372
  }
365
- d === c + s.length && u === -1 && (u = h + p.length);
366
- } else m.isBlock && d > 0 && (d === c && (o = h), d++);
373
+ d === l + s.length && u === -1 && (u = h + p.length);
374
+ } else m.isBlock && d > 0 && (d === l && (o = h), d++);
367
375
  return !0;
368
- }), o !== -1 && u !== -1 && r.push({ from: o, to: u }), l = c + 1;
376
+ }), o !== -1 && u !== -1 && r.push({ from: o, to: u }), c = l + 1;
369
377
  }
370
378
  return r;
371
379
  }
372
- const ca = Ve.create({
380
+ const la = Je.create({
373
381
  name: "searchReplace",
374
382
  addStorage() {
375
383
  return {
@@ -382,35 +390,35 @@ const ca = Ve.create({
382
390
  },
383
391
  addCommands() {
384
392
  return {
385
- setSearchTerm: (e) => ({ editor: t }) => (this.storage.searchTerm = e, this.storage.results = Re(t.state.doc, e, this.storage.caseSensitive), this.storage.currentIndex = this.storage.results.length > 0 ? 0 : -1, t.view.dispatch(t.state.tr), !0),
393
+ setSearchTerm: (e) => ({ editor: t }) => (this.storage.searchTerm = e, this.storage.results = Me(t.state.doc, e, this.storage.caseSensitive), this.storage.currentIndex = this.storage.results.length > 0 ? 0 : -1, t.view.dispatch(t.state.tr), !0),
386
394
  setReplaceTerm: (e) => () => (this.storage.replaceTerm = e, !0),
387
- setCaseSensitive: (e) => ({ editor: t }) => (this.storage.caseSensitive = e, this.storage.results = Re(t.state.doc, this.storage.searchTerm, e), this.storage.currentIndex = this.storage.results.length > 0 ? 0 : -1, t.view.dispatch(t.state.tr), !0),
395
+ setCaseSensitive: (e) => ({ editor: t }) => (this.storage.caseSensitive = e, this.storage.results = Me(t.state.doc, this.storage.searchTerm, e), this.storage.currentIndex = this.storage.results.length > 0 ? 0 : -1, t.view.dispatch(t.state.tr), !0),
388
396
  nextSearchResult: () => ({ editor: e }) => {
389
397
  if (this.storage.results.length === 0) return !1;
390
398
  this.storage.currentIndex = (this.storage.currentIndex + 1) % this.storage.results.length;
391
399
  const t = this.storage.results[this.storage.currentIndex];
392
- return t && (e.commands.setTextSelection(t), It(e)), e.view.dispatch(e.state.tr), !0;
400
+ return t && (e.commands.setTextSelection(t), Et(e)), e.view.dispatch(e.state.tr), !0;
393
401
  },
394
402
  previousSearchResult: () => ({ editor: e }) => {
395
403
  if (this.storage.results.length === 0) return !1;
396
404
  this.storage.currentIndex = (this.storage.currentIndex - 1 + this.storage.results.length) % this.storage.results.length;
397
405
  const t = this.storage.results[this.storage.currentIndex];
398
- return t && (e.commands.setTextSelection(t), It(e)), e.view.dispatch(e.state.tr), !0;
406
+ return t && (e.commands.setTextSelection(t), Et(e)), e.view.dispatch(e.state.tr), !0;
399
407
  },
400
408
  replaceCurrent: () => ({ editor: e }) => {
401
409
  if (this.storage.results.length === 0 || this.storage.currentIndex < 0) return !1;
402
410
  const t = this.storage.results[this.storage.currentIndex];
403
- return t ? (e.chain().focus().insertContentAt(t, this.storage.replaceTerm).run(), this.storage.results = Re(e.state.doc, this.storage.searchTerm, this.storage.caseSensitive), this.storage.currentIndex >= this.storage.results.length && (this.storage.currentIndex = 0), e.view.dispatch(e.state.tr), !0) : !1;
411
+ return t ? (e.chain().focus().insertContentAt(t, this.storage.replaceTerm).run(), this.storage.results = Me(e.state.doc, this.storage.searchTerm, this.storage.caseSensitive), this.storage.currentIndex >= this.storage.results.length && (this.storage.currentIndex = 0), e.view.dispatch(e.state.tr), !0) : !1;
404
412
  },
405
413
  replaceAll: () => ({ editor: e }) => {
406
414
  if (this.storage.results.length === 0) return !1;
407
415
  const { searchTerm: t, replaceTerm: n, caseSensitive: r } = this.storage;
408
- let a = Re(e.state.doc, t, r);
416
+ let a = Me(e.state.doc, t, r);
409
417
  const s = e.state.tr;
410
418
  let i = 0;
411
- for (const l of a) {
412
- const c = l.from + i, d = l.to + i;
413
- s.insertText(n, c, d), i += n.length - (l.to - l.from);
419
+ for (const c of a) {
420
+ const l = c.from + i, d = c.to + i;
421
+ s.insertText(n, l, d), i += n.length - (c.to - c.from);
414
422
  }
415
423
  return e.view.dispatch(s), this.storage.results = [], this.storage.currentIndex = -1, !0;
416
424
  },
@@ -432,24 +440,24 @@ const ca = Ve.create({
432
440
  addProseMirrorPlugins() {
433
441
  const e = this.storage;
434
442
  return [
435
- new Ke({
436
- key: oa,
443
+ new Xe({
444
+ key: ca,
437
445
  props: {
438
446
  decorations: (t) => {
439
447
  if (!e.searchTerm || e.results.length === 0)
440
- return Ee.empty;
448
+ return Ne.empty;
441
449
  const n = e.results.map((r, a) => {
442
450
  const s = a === e.currentIndex ? "search-highlight search-highlight--current" : "search-highlight";
443
451
  return le.inline(r.from, r.to, { class: s });
444
452
  });
445
- return Ee.create(t.doc, n);
453
+ return Ne.create(t.doc, n);
446
454
  }
447
455
  }
448
456
  })
449
457
  ];
450
458
  }
451
459
  });
452
- function It(e) {
460
+ function Et(e) {
453
461
  requestAnimationFrame(() => {
454
462
  const t = e.view.domAtPos(e.state.selection.from);
455
463
  if (t != null && t.node) {
@@ -458,97 +466,97 @@ function It(e) {
458
466
  }
459
467
  });
460
468
  }
461
- const la = -1, da = 1, Et = 0;
462
- let tt = null;
463
- function ua() {
464
- return tt || (tt = new qt()), tt;
469
+ const da = -1, ua = 1, Nt = 0;
470
+ let nt = null;
471
+ function ma() {
472
+ return nt || (nt = new Gt()), nt;
465
473
  }
466
- const rn = new ke("patchDiff");
467
- function ma(e, t) {
474
+ const an = new _e("patchDiff");
475
+ function fa(e, t) {
468
476
  let n = null;
469
477
  return e.state.doc.descendants((r, a) => n ? !1 : r.type.name === "patent_section" && r.attrs.sectionType === t ? (n = { from: a + 1, to: a + r.nodeSize - 1 }, !1) : !0), n;
470
478
  }
471
- function an(e, t, n) {
479
+ function sn(e, t, n) {
472
480
  const r = [];
473
481
  let a = "", s = !0;
474
- return e.state.doc.nodesBetween(t, n, (i, l) => {
482
+ return e.state.doc.nodesBetween(t, n, (i, c) => {
475
483
  if (i.isText) {
476
- const c = l, d = Math.max(t, c) - c, o = Math.min(n, c + i.nodeSize) - c, u = i.text.slice(d, o);
477
- r.push({ textIdx: a.length, docPos: c + d, len: u.length }), a += u, s = !1;
484
+ const l = c, d = Math.max(t, l) - l, o = Math.min(n, l + i.nodeSize) - l, u = i.text.slice(d, o);
485
+ r.push({ textIdx: a.length, docPos: l + d, len: u.length }), a += u, s = !1;
478
486
  } else i.isLeaf ? (a += "\0", s = !1) : !s && i.isBlock && (a += "\0", s = !0);
479
487
  }), { text: a, segments: r };
480
488
  }
481
- function Ie(e, t) {
489
+ function Ee(e, t) {
482
490
  for (const n of e)
483
491
  if (t >= n.textIdx && t <= n.textIdx + n.len)
484
492
  return n.docPos + (t - n.textIdx);
485
493
  return -1;
486
494
  }
487
- function Nt(e, t, n, r, a) {
488
- const { text: s, segments: i } = an(e, n, r);
489
- let l = 0;
490
- for (; l <= s.length - t.length; ) {
491
- const c = s.indexOf(t, l);
492
- if (c === -1) return null;
493
- const d = Ie(i, c), o = Ie(i, c + t.length);
495
+ function kt(e, t, n, r, a) {
496
+ const { text: s, segments: i } = sn(e, n, r);
497
+ let c = 0;
498
+ for (; c <= s.length - t.length; ) {
499
+ const l = s.indexOf(t, c);
500
+ if (l === -1) return null;
501
+ const d = Ee(i, l), o = Ee(i, l + t.length);
494
502
  if (d >= 0 && o >= 0 && !(a && a.has(d)))
495
503
  return { from: d, to: o };
496
- l = c + 1;
504
+ c = l + 1;
497
505
  }
498
506
  return null;
499
507
  }
500
- function Ji(e, t, n, r, a) {
508
+ function Qi(e, t, n, r, a) {
501
509
  const s = t.target;
502
510
  let i = null;
503
- const l = /* @__PURE__ */ new Set();
511
+ const c = /* @__PURE__ */ new Set();
504
512
  if (a)
505
513
  for (const o of a)
506
- l.add(o.from);
514
+ c.add(o.from);
507
515
  if (!s)
508
516
  t.from != null && t.to != null && (i = { from: t.from, to: t.to });
509
517
  else if (s.type === "section" && s.sectionType)
510
- i = ma(e, s.sectionType);
518
+ i = fa(e, s.sectionType);
511
519
  else if (s.type === "ref" && s.refIndex != null) {
512
520
  const o = n[s.refIndex];
513
521
  (o == null ? void 0 : o.from) != null && (o == null ? void 0 : o.to) != null && (i = { from: o.from, to: o.to });
514
- } else s.type === "search" && s.searchText && (i = Nt(e, s.searchText, 0, e.state.doc.content.size, l));
522
+ } else s.type === "search" && s.searchText && (i = kt(e, s.searchText, 0, e.state.doc.content.size, c));
515
523
  if (!i) return null;
516
- let c = i;
524
+ let l = i;
517
525
  if (t.search) {
518
- const o = Nt(e, t.search, i.from, i.to, l);
519
- o && (c = o);
526
+ const o = kt(e, t.search, i.from, i.to, c);
527
+ o && (l = o);
520
528
  }
521
- const d = c.from < c.to ? e.state.doc.textBetween(c.from, c.to, " ", "\0") : "";
529
+ const d = l.from < l.to ? e.state.doc.textBetween(l.from, l.to, " ", "\0") : "";
522
530
  return {
523
531
  id: `patch_${Date.now()}_${r}`,
524
532
  type: t.op === "delete" ? "delete" : t.op === "insert" ? "insert" : "replace",
525
- from: c.from,
526
- to: t.op === "insert" ? c.from : c.to,
533
+ from: l.from,
534
+ to: t.op === "insert" ? l.from : l.to,
527
535
  content: t.content || "",
528
536
  originalText: d,
529
537
  reason: t.reason,
530
538
  status: "pending"
531
539
  };
532
540
  }
533
- let q = [], Be = [];
534
- function Xi(e) {
535
- return Be.push(e), () => {
536
- Be = Be.filter((t) => t !== e);
541
+ let q = [], Ue = [];
542
+ function Yi(e) {
543
+ return Ue.push(e), () => {
544
+ Ue = Ue.filter((t) => t !== e);
537
545
  };
538
546
  }
539
547
  function ye() {
540
- Be.forEach((e) => e());
548
+ Ue.forEach((e) => e());
541
549
  }
542
- function Qi() {
550
+ function Zi() {
543
551
  return [...q];
544
552
  }
545
- function Yi(e) {
553
+ function eo(e) {
546
554
  q = e, ye();
547
555
  }
548
- function Zi() {
556
+ function to() {
549
557
  q = [], ye();
550
558
  }
551
- function eo(e, t) {
559
+ function no(e, t) {
552
560
  const n = q.find((s) => s.id === t);
553
561
  if (!n || n.status !== "pending") return !1;
554
562
  n.status = "accepted";
@@ -557,8 +565,8 @@ function eo(e, t) {
557
565
  r.delete(n.from, n.to);
558
566
  else if (n.type === "insert")
559
567
  r.insertText(n.content, n.from);
560
- else if (sn(e, n.from, n.to)) {
561
- const i = on(e, n.content);
568
+ else if (on(e, n.from, n.to)) {
569
+ const i = cn(e, n.content);
562
570
  r.replaceWith(n.from, n.to, i);
563
571
  } else
564
572
  r.insertText(n.content, n.from, n.to);
@@ -566,96 +574,96 @@ function eo(e, t) {
566
574
  const a = r.mapping;
567
575
  for (const s of q) {
568
576
  if (s.id === t || s.status !== "pending") continue;
569
- const i = a.map(s.from, 1), l = a.map(s.to, -1);
570
- i >= l && s.type !== "insert" ? s.status = "rejected" : (s.from = i, s.to = s.type === "insert" ? i : l);
577
+ const i = a.map(s.from, 1), c = a.map(s.to, -1);
578
+ i >= c && s.type !== "insert" ? s.status = "rejected" : (s.from = i, s.to = s.type === "insert" ? i : c);
571
579
  }
572
- return q = q.filter((s) => s.id !== t && s.status === "pending"), Qe(e), ye(), !0;
580
+ return q = q.filter((s) => s.id !== t && s.status === "pending"), Ze(e), ye(), !0;
573
581
  }
574
- function to(e, t) {
582
+ function ro(e, t) {
575
583
  const n = q.find((r) => r.id === t);
576
- return !n || n.status !== "pending" ? !1 : (n.status = "rejected", q = q.filter((r) => r.id !== t), Qe(e), ye(), !0);
584
+ return !n || n.status !== "pending" ? !1 : (n.status = "rejected", q = q.filter((r) => r.id !== t), Ze(e), ye(), !0);
577
585
  }
578
- function no(e) {
586
+ function ao(e) {
579
587
  const n = [...q.filter((a) => a.status === "pending")].sort((a, s) => s.from - a.from), { tr: r } = e.state;
580
588
  for (const a of n)
581
589
  if (a.type === "delete")
582
590
  r.delete(a.from, a.to);
583
591
  else if (a.type === "insert")
584
592
  r.insertText(a.content, a.from);
585
- else if (sn(e, a.from, a.to)) {
586
- const i = on(e, a.content);
593
+ else if (on(e, a.from, a.to)) {
594
+ const i = cn(e, a.content);
587
595
  r.replaceWith(a.from, a.to, i);
588
596
  } else
589
597
  r.insertText(a.content, a.from, a.to);
590
- e.view.dispatch(r), q = [], Qe(e), ye();
598
+ e.view.dispatch(r), q = [], Ze(e), ye();
591
599
  }
592
- function ro(e) {
593
- q = [], Qe(e), ye();
600
+ function so(e) {
601
+ q = [], Ze(e), ye();
594
602
  }
595
- function Qe(e) {
596
- e.view.dispatch(e.state.tr.setMeta(rn, !0));
603
+ function Ze(e) {
604
+ e.view.dispatch(e.state.tr.setMeta(an, !0));
597
605
  }
598
- function fa(e, t, n) {
606
+ function ga(e, t, n) {
599
607
  const r = [];
600
608
  return e.nodesBetween(t, n, (a, s) => {
601
609
  if (a.isTextblock) {
602
- const i = s + 1, l = s + a.nodeSize - 1, c = Math.max(i, t), d = Math.min(l, n);
603
- return d > c && r.push({ from: c, to: d }), !1;
610
+ const i = s + 1, c = s + a.nodeSize - 1, l = Math.max(i, t), d = Math.min(c, n);
611
+ return d > l && r.push({ from: l, to: d }), !1;
604
612
  }
605
613
  return !0;
606
614
  }), r;
607
615
  }
608
- function ga(e, t) {
616
+ function pa(e, t) {
609
617
  if (!t.originalText || !t.content) return null;
610
618
  try {
611
- const l = e.resolve(t.from), c = e.resolve(t.to);
612
- if (l.parent !== c.parent || !l.parent.isTextblock) return null;
619
+ const c = e.resolve(t.from), l = e.resolve(t.to);
620
+ if (c.parent !== l.parent || !c.parent.isTextblock) return null;
613
621
  } catch {
614
622
  return null;
615
623
  }
616
- const n = ua(), r = n.diff_main(t.originalText, t.content);
624
+ const n = ma(), r = n.diff_main(t.originalText, t.content);
617
625
  n.diff_cleanupSemantic(r);
618
- const a = r.filter(([l]) => l === Et).reduce((l, [, c]) => l + c.length, 0);
626
+ const a = r.filter(([c]) => c === Nt).reduce((c, [, l]) => c + l.length, 0);
619
627
  if (t.originalText.length > 0 && a / t.originalText.length < 0.3) return null;
620
628
  const s = [];
621
629
  let i = t.from;
622
- for (const [l, c] of r)
623
- if (l === Et)
624
- i += c.length;
625
- else if (l === la) {
626
- const d = i + c.length;
630
+ for (const [c, l] of r)
631
+ if (c === Nt)
632
+ i += l.length;
633
+ else if (c === da) {
634
+ const d = i + l.length;
627
635
  s.push(
628
636
  le.inline(i, d, {
629
637
  class: "patch-diff-delete",
630
638
  "data-patch-id": t.id
631
639
  })
632
640
  ), i = d;
633
- } else l === da && s.push(
641
+ } else c === ua && s.push(
634
642
  le.widget(i, () => {
635
643
  const d = document.createElement("span");
636
- return d.className = "patch-diff-insert-inline", d.textContent = c, d.setAttribute("data-patch-id", t.id), d;
644
+ return d.className = "patch-diff-insert-inline", d.textContent = l, d.setAttribute("data-patch-id", t.id), d;
637
645
  }, { side: 1 })
638
646
  );
639
647
  return s;
640
648
  }
641
- function pa() {
642
- return new Ke({
643
- key: rn,
649
+ function ha() {
650
+ return new Xe({
651
+ key: an,
644
652
  props: {
645
653
  decorations(e) {
646
654
  const t = q.filter((r) => r.status === "pending");
647
- if (t.length === 0) return Ee.empty;
655
+ if (t.length === 0) return Ne.empty;
648
656
  const n = [];
649
657
  for (const r of t) {
650
658
  if (r.type === "replace") {
651
- const a = ga(e.doc, r);
659
+ const a = pa(e.doc, r);
652
660
  if (a) {
653
661
  n.push(...a);
654
662
  continue;
655
663
  }
656
664
  }
657
665
  if (r.type === "delete" || r.type === "replace") {
658
- const a = fa(e.doc, r.from, r.to);
666
+ const a = ga(e.doc, r.from, r.to);
659
667
  for (const s of a)
660
668
  n.push(
661
669
  le.inline(s.from, s.to, {
@@ -668,8 +676,8 @@ function pa() {
668
676
  `);
669
677
  n.push(
670
678
  le.widget(s, () => {
671
- const l = document.createElement(i ? "div" : "span");
672
- return l.className = i ? "patch-diff-insert-inline patch-diff-insert-block" : "patch-diff-insert-inline", l.textContent = r.content, l.setAttribute("data-patch-id", r.id), l;
679
+ const c = document.createElement(i ? "div" : "span");
680
+ return c.className = i ? "patch-diff-insert-inline patch-diff-insert-block" : "patch-diff-insert-inline", c.textContent = r.content, c.setAttribute("data-patch-id", r.id), c;
673
681
  }, { side: 1 })
674
682
  );
675
683
  }
@@ -681,17 +689,17 @@ function pa() {
681
689
  })
682
690
  );
683
691
  }
684
- return Ee.create(e.doc, n);
692
+ return Ne.create(e.doc, n);
685
693
  }
686
694
  }
687
695
  });
688
696
  }
689
- function sn(e, t, n) {
697
+ function on(e, t, n) {
690
698
  var s;
691
699
  const r = e.state.doc.resolve(t);
692
700
  return !!((s = r.parent.type.spec.content) != null && s.includes("block") && t === r.start() && n === r.end());
693
701
  }
694
- function on(e, t) {
702
+ function cn(e, t) {
695
703
  const n = e.state.schema;
696
704
  return t.split(/\n\n+/).filter((a) => a.trim().length > 0).map((a) => {
697
705
  const s = a.replace(/\n/g, " ").trim();
@@ -701,7 +709,7 @@ function on(e, t) {
701
709
  );
702
710
  });
703
711
  }
704
- const ha = ee.create({
712
+ const ba = ee.create({
705
713
  name: "hardBreak",
706
714
  inline: !0,
707
715
  group: "inline",
@@ -714,51 +722,48 @@ const ha = ee.create({
714
722
  },
715
723
  addKeyboardShortcuts() {
716
724
  return {
717
- "Shift-Enter": () => this.editor.commands.setHardBreak()
718
- };
719
- },
720
- addCommands() {
721
- return {
722
- setHardBreak: () => ({ commands: e }) => e.first([
723
- () => e.exitCode(),
724
- () => e.command(({ tr: t, dispatch: n }) => (n && t.replaceSelectionWith(this.type.create()).scrollIntoView(), !0))
725
- ])
725
+ "Shift-Enter": () => {
726
+ const e = this.editor.schema.nodes.hardBreak;
727
+ if (!e) return !1;
728
+ const t = this.editor.state.tr.replaceSelectionWith(e.create()).scrollIntoView();
729
+ return this.editor.view.dispatch(t), !0;
730
+ }
726
731
  };
727
732
  }
728
- }), ba = Ve.create({
733
+ }), ya = Je.create({
729
734
  name: "dragDropUX",
730
735
  addProseMirrorPlugins() {
731
736
  return [
732
- Yn({
737
+ Zn({
733
738
  width: 3,
734
739
  color: "#2563eb"
735
740
  }),
736
- Zn()
741
+ er()
737
742
  ];
738
743
  }
739
- }), ya = Ve.create({
744
+ }), va = Je.create({
740
745
  name: "patchDiff",
741
746
  addProseMirrorPlugins() {
742
- return [pa()];
747
+ return [ha()];
743
748
  }
744
- }), va = [
745
- Rn,
746
- Mn,
749
+ }), Ca = [
747
750
  Dn,
748
- ba,
749
- $n.configure({
751
+ Mn,
752
+ $n,
753
+ ya,
754
+ On.configure({
750
755
  levels: [1, 2, 3, 4, 5, 6]
751
756
  }),
752
- On,
753
757
  Fn,
754
758
  zn,
755
759
  Bn,
756
760
  Hn,
757
- ha,
758
761
  Un,
762
+ ba,
759
763
  jn,
760
- Wn.configure({ nested: !0 }),
761
- qn.extend({
764
+ Wn,
765
+ qn.configure({ nested: !0 }),
766
+ Gn.extend({
762
767
  addAttributes() {
763
768
  var e;
764
769
  return {
@@ -774,46 +779,46 @@ const ha = ee.create({
774
779
  inline: !0,
775
780
  allowBase64: !0
776
781
  }),
777
- Gn.configure({
782
+ Vn.configure({
778
783
  resizable: !0
779
784
  }),
780
- Vn,
781
785
  Kn,
782
786
  Jn,
783
- Xn.configure({
787
+ Xn,
788
+ Qn.configure({
784
789
  placeholder: ({ node: e }) => e.type.name === "heading" ? "Heading" : "Type / for commands..."
785
790
  }),
786
- Qn,
787
- ra.configure({
788
- suggestion: ia()
791
+ Yn,
792
+ aa.configure({
793
+ suggestion: oa()
789
794
  }),
790
- ca,
791
- er.configure({
795
+ la,
796
+ tr.configure({
792
797
  types: ["heading", "paragraph"],
793
798
  defaultAlignment: "left"
794
799
  }),
795
- ya
796
- ], Ca = [
797
- ar,
800
+ va
801
+ ], wa = [
798
802
  sr,
799
803
  ir,
800
804
  or,
801
805
  cr,
802
806
  lr,
803
807
  dr,
804
- ur.configure({
808
+ ur,
809
+ mr.configure({
805
810
  openOnClick: !1
806
811
  }),
807
- mr,
808
812
  fr,
809
- gr.configure({ multicolor: !0 })
810
- ], wa = [
811
- ...va,
812
- ...Ca
813
+ gr,
814
+ pr.configure({ multicolor: !0 })
815
+ ], xa = [
816
+ ...Ca,
817
+ ...wa
813
818
  ];
814
- class xa {
819
+ class Sa {
815
820
  constructor() {
816
- Le(this, "commands", /* @__PURE__ */ new Map());
821
+ Re(this, "commands", /* @__PURE__ */ new Map());
817
822
  }
818
823
  normalizeCommand(t) {
819
824
  return typeof t == "function" ? {
@@ -837,7 +842,7 @@ class xa {
837
842
  }
838
843
  async execute(t, n, r, a = {}) {
839
844
  var o, u, m, h;
840
- const s = Date.now(), i = a.transaction ?? !0, l = a.rollbackOnFail ?? !0, c = i ? n.editor.getJSON() : null, d = this.commands.get(t);
845
+ const s = Date.now(), i = a.transaction ?? !0, c = a.rollbackOnFail ?? !0, l = i ? n.editor.getJSON() : null, d = this.commands.get(t);
841
846
  if (!d)
842
847
  return console.warn(`Command "${t}" not found.`), (o = a.onComplete) == null || o.call(a, {
843
848
  name: t,
@@ -852,15 +857,15 @@ class xa {
852
857
  }), !1;
853
858
  try {
854
859
  const f = !!await d.execute(n, r);
855
- !f && c && l && n.editor.commands.setContent(c);
856
- const y = {
860
+ !f && l && c && n.editor.commands.setContent(l);
861
+ const C = {
857
862
  name: t,
858
863
  success: f,
859
864
  durationMs: Date.now() - s
860
865
  };
861
- return (m = a.onComplete) == null || m.call(a, y), f;
866
+ return (m = a.onComplete) == null || m.call(a, C), f;
862
867
  } catch (p) {
863
- c && l && n.editor.commands.setContent(c);
868
+ l && c && n.editor.commands.setContent(l);
864
869
  const f = {
865
870
  name: t,
866
871
  success: !1,
@@ -877,11 +882,11 @@ class xa {
877
882
  return Array.from(this.commands.keys()).sort();
878
883
  }
879
884
  }
880
- const ge = new xa();
881
- class Sa {
885
+ const ge = new Sa();
886
+ class Ta {
882
887
  constructor() {
883
- Le(this, "plugins", /* @__PURE__ */ new Map());
884
- Le(this, "lifecycleOrder", ["register", "init", "stateSync", "destroy"]);
888
+ Re(this, "plugins", /* @__PURE__ */ new Map());
889
+ Re(this, "lifecycleOrder", ["register", "init", "stateSync", "destroy"]);
885
890
  }
886
891
  logLifecycle(t, n) {
887
892
  t !== "stateSync" && console.info(`[PluginManager:${t}] ${n}`);
@@ -963,7 +968,7 @@ class Sa {
963
968
  });
964
969
  }
965
970
  }
966
- const W = new Sa(), kt = {
971
+ const W = new Ta(), _t = {
967
972
  zh: {
968
973
  language: "语言",
969
974
  bold: "加粗",
@@ -1130,13 +1135,13 @@ const W = new Sa(), kt = {
1130
1135
  autoSaveSaved: "Saved",
1131
1136
  autoSaveError: "Save failed"
1132
1137
  }
1133
- }, U = (e) => e === "en" ? kt.en : kt.zh, he = (e, t, n, r) => e === "en" ? t === "forward_reference" ? `Claim ${n} references later claim ${r}.` : t === "self_reference" ? `Claim ${n} references itself.` : `Claim ${n} has circular dependency.` : t === "forward_reference" ? `权利要求${n}引用了后置项权利要求${r}。` : t === "self_reference" ? `权利要求${n}引用了自身。` : `权利要求${n}存在循环依赖。`;
1134
- let Me = 0;
1135
- const De = () => {
1138
+ }, U = (e) => e === "en" ? _t.en : _t.zh, he = (e, t, n, r) => e === "en" ? t === "forward_reference" ? `Claim ${n} references later claim ${r}.` : t === "self_reference" ? `Claim ${n} references itself.` : `Claim ${n} has circular dependency.` : t === "forward_reference" ? `权利要求${n}引用了后置项权利要求${r}。` : t === "self_reference" ? `权利要求${n}引用了自身。` : `权利要求${n}存在循环依赖。`;
1139
+ let $e = 0;
1140
+ const Oe = () => {
1136
1141
  document.querySelectorAll('body > svg[id^="standalone-mermaid-"]').forEach((e) => e.remove()), document.querySelectorAll('body > svg[id^="d"]').forEach((e) => {
1137
1142
  (e.id.startsWith("dmermaid") || e.id.startsWith("dstandalone")) && e.remove();
1138
1143
  }), document.querySelectorAll('body > div[id^="dstandalone-mermaid-"]').forEach((e) => e.remove()), document.querySelectorAll('body > div[id^="dmermaid"]').forEach((e) => e.remove()), document.querySelectorAll('body > div[id^="standalone-mermaid-"]').forEach((e) => e.remove());
1139
- }, Ta = ee.create({
1144
+ }, Ia = ee.create({
1140
1145
  name: "mermaid",
1141
1146
  group: "block",
1142
1147
  atom: !0,
@@ -1158,10 +1163,10 @@ const De = () => {
1158
1163
  s.classList.add("mermaid-node");
1159
1164
  const i = document.createElement("div");
1160
1165
  i.className = "mermaid-view", i.contentEditable = "false";
1161
- const l = document.createElement("div");
1162
- l.className = "mermaid-preview", l.contentEditable = "false";
1163
1166
  const c = document.createElement("div");
1164
- c.className = "mermaid-view-hint", i.append(l, c);
1167
+ c.className = "mermaid-preview", c.contentEditable = "false";
1168
+ const l = document.createElement("div");
1169
+ l.className = "mermaid-view-hint", i.append(c, l);
1165
1170
  const d = document.createElement("div");
1166
1171
  d.className = "mermaid-edit";
1167
1172
  const o = document.createElement("textarea");
@@ -1176,64 +1181,64 @@ const De = () => {
1176
1181
  p.className = "mermaid-save-btn", p.type = "button", u.append(m, h, p), d.append(o, u), s.append(i, d);
1177
1182
  const f = (b) => {
1178
1183
  const T = typeof n == "function" ? n() : null;
1179
- typeof T == "number" && e.commands.command(({ tr: k, dispatch: M }) => (k.setNodeMarkup(T, void 0, { ...r.attrs, ...b }), M && M(k), !0));
1184
+ typeof T == "number" && e.commands.command(({ tr: E, dispatch: D }) => (E.setNodeMarkup(T, void 0, { ...r.attrs, ...b }), D && D(E), !0));
1180
1185
  };
1181
- let y = "";
1186
+ let C = "";
1182
1187
  const w = async (b) => {
1183
1188
  const T = b.trim();
1184
- if (T !== y) {
1189
+ if (T !== C) {
1185
1190
  if (!T) {
1186
- l.innerHTML = "", y = "";
1191
+ c.innerHTML = "", C = "";
1187
1192
  return;
1188
1193
  }
1189
1194
  try {
1190
- const k = await import("mermaid");
1191
- k.default.initialize({ startOnLoad: !1, theme: "default" }), Me += 1;
1192
- const M = `standalone-mermaid-${Me}`, { svg: D } = await k.default.render(M, T);
1193
- l.innerHTML = D, y = T;
1195
+ const E = await import("mermaid");
1196
+ E.default.initialize({ startOnLoad: !1, theme: "default" }), $e += 1;
1197
+ const D = `standalone-mermaid-${$e}`, { svg: M } = await E.default.render(D, T);
1198
+ c.innerHTML = M, C = T;
1194
1199
  } catch {
1195
- l.innerHTML = "", y = "";
1200
+ c.innerHTML = "", C = "";
1196
1201
  } finally {
1197
- De();
1202
+ Oe();
1198
1203
  }
1199
1204
  }
1200
- }, C = () => {
1205
+ }, y = () => {
1201
1206
  a || (a = !0, o.value = typeof r.attrs.code == "string" ? r.attrs.code : "", m.textContent = "", m.style.display = "none", _(), requestAnimationFrame(() => o.focus()));
1202
1207
  }, v = () => {
1203
1208
  a = !1, _();
1204
- }, S = async () => {
1209
+ }, x = async () => {
1205
1210
  const b = o.value;
1206
1211
  m.textContent = "", m.style.display = "none";
1207
1212
  const T = b.trim();
1208
1213
  if (T)
1209
1214
  try {
1210
- const k = await import("mermaid");
1211
- k.default.initialize({ startOnLoad: !1, theme: "default" }), Me += 1;
1212
- const M = `standalone-mermaid-${Me}`, { svg: D } = await k.default.render(M, T);
1213
- l.innerHTML = D, y = T, De();
1215
+ const E = await import("mermaid");
1216
+ E.default.initialize({ startOnLoad: !1, theme: "default" }), $e += 1;
1217
+ const D = `standalone-mermaid-${$e}`, { svg: M } = await E.default.render(D, T);
1218
+ c.innerHTML = M, C = T, Oe();
1214
1219
  } catch {
1215
- De();
1216
- const k = N.getState().editorLanguage;
1217
- m.textContent = k === "en" ? "Mermaid syntax error, please fix and retry" : "Mermaid 语法错误,请修正后重试", m.style.display = "inline";
1220
+ Oe();
1221
+ const E = k.getState().editorLanguage;
1222
+ m.textContent = E === "en" ? "Mermaid syntax error, please fix and retry" : "Mermaid 语法错误,请修正后重试", m.style.display = "inline";
1218
1223
  return;
1219
1224
  }
1220
1225
  f({ code: b }), a = !1, _();
1221
1226
  };
1222
1227
  i.addEventListener("dblclick", (b) => {
1223
- b.preventDefault(), b.stopPropagation(), C();
1228
+ b.preventDefault(), b.stopPropagation(), y();
1224
1229
  }), p.addEventListener("click", (b) => {
1225
- b.stopPropagation(), S();
1230
+ b.stopPropagation(), x();
1226
1231
  }), h.addEventListener("click", (b) => {
1227
1232
  b.stopPropagation(), v();
1228
1233
  }), o.addEventListener("mousedown", (b) => b.stopPropagation()), o.addEventListener("keydown", (b) => b.stopPropagation()), o.addEventListener("keypress", (b) => b.stopPropagation());
1229
1234
  const _ = () => {
1230
- const b = N.getState().editorLanguage, T = U(b), k = typeof r.attrs.code == "string" ? r.attrs.code : "";
1235
+ const b = k.getState().editorLanguage, T = U(b), E = typeof r.attrs.code == "string" ? r.attrs.code : "";
1231
1236
  i.style.display = a ? "none" : "block", d.style.display = a ? "block" : "none", p.textContent = T.mermaidSaveAndRender || "保存并渲染", h.textContent = T.mermaidCancel || "取消";
1232
- const M = k.trim().length > 0, D = l.querySelector("svg") !== null;
1233
- a || (M && D ? (c.textContent = T.mermaidDoubleClickToEdit || "双击编辑", c.className = "mermaid-view-hint mermaid-view-hint--subtle") : (c.textContent = T.mermaidDoubleClickToCreate || "双击编辑 Mermaid 图表", c.className = "mermaid-view-hint mermaid-view-hint--empty")), !a && k.trim() !== y && w(k);
1237
+ const D = E.trim().length > 0, M = c.querySelector("svg") !== null;
1238
+ a || (D && M ? (l.textContent = T.mermaidDoubleClickToEdit || "双击编辑", l.className = "mermaid-view-hint mermaid-view-hint--subtle") : (l.textContent = T.mermaidDoubleClickToCreate || "双击编辑 Mermaid 图表", l.className = "mermaid-view-hint mermaid-view-hint--empty")), !a && E.trim() !== C && w(E);
1234
1239
  };
1235
- let L = N.getState().editorLanguage;
1236
- const P = N.subscribe((b) => {
1240
+ let L = k.getState().editorLanguage;
1241
+ const P = k.subscribe((b) => {
1237
1242
  b.editorLanguage !== L && (L = b.editorLanguage, _());
1238
1243
  });
1239
1244
  return _(), {
@@ -1245,15 +1250,15 @@ const De = () => {
1245
1250
  ignoreMutation: () => !0,
1246
1251
  update: (b) => b.type.name !== "mermaid" ? !1 : (r = b, _(), !0),
1247
1252
  destroy: () => {
1248
- P(), De();
1253
+ P(), Oe();
1249
1254
  }
1250
1255
  };
1251
1256
  };
1252
1257
  }
1253
- }), Ia = {
1258
+ }), Ea = {
1254
1259
  name: "mermaid",
1255
1260
  version: "1.0.0",
1256
- extensions: [Ta],
1261
+ extensions: [Ia],
1257
1262
  toolbarItems: [
1258
1263
  {
1259
1264
  id: "mermaid-insert",
@@ -1277,7 +1282,7 @@ const De = () => {
1277
1282
  }
1278
1283
  }
1279
1284
  }
1280
- }, Ea = ee.create({
1285
+ }, Na = ee.create({
1281
1286
  name: "drawio",
1282
1287
  group: "block",
1283
1288
  atom: !0,
@@ -1300,83 +1305,83 @@ const De = () => {
1300
1305
  s.classList.add("drawio-node");
1301
1306
  const i = document.createElement("div");
1302
1307
  i.className = "drawio-view", i.contentEditable = "false";
1303
- const l = document.createElement("img");
1304
- l.className = "drawio-preview-img", l.style.display = "none";
1305
- const c = document.createElement("div");
1306
- c.className = "drawio-view-hint", i.append(l, c), s.append(i);
1307
- const d = (C) => {
1308
+ const c = document.createElement("img");
1309
+ c.className = "drawio-preview-img", c.style.display = "none";
1310
+ const l = document.createElement("div");
1311
+ l.className = "drawio-view-hint", i.append(c, l), s.append(i);
1312
+ const d = (y) => {
1308
1313
  const v = typeof n == "function" ? n() : null;
1309
- typeof v == "number" && e.commands.command(({ tr: S, dispatch: _ }) => (S.setNodeMarkup(v, void 0, { ...r.attrs, ...C }), _ && _(S), !0));
1314
+ typeof v == "number" && e.commands.command(({ tr: x, dispatch: _ }) => (x.setNodeMarkup(v, void 0, { ...r.attrs, ...y }), _ && _(x), !0));
1310
1315
  };
1311
1316
  let o = null, u = null, m = null;
1312
1317
  const h = () => {
1313
1318
  if (a) return;
1314
1319
  a = !0, u = document.createElement("div"), u.className = "drawio-modal-overlay";
1315
- const C = document.createElement("div");
1316
- C.className = "drawio-modal-content";
1320
+ const y = document.createElement("div");
1321
+ y.className = "drawio-modal-content";
1317
1322
  const v = document.createElement("div");
1318
1323
  v.className = "drawio-modal-header";
1319
- const S = N.getState().editorLanguage, _ = document.createElement("span");
1320
- _.textContent = S === "en" ? "Edit Draw.io Diagram" : "编辑 Draw.io 图表", _.className = "drawio-modal-title";
1324
+ const x = k.getState().editorLanguage, _ = document.createElement("span");
1325
+ _.textContent = x === "en" ? "Edit Draw.io Diagram" : "编辑 Draw.io 图表", _.className = "drawio-modal-title";
1321
1326
  const L = document.createElement("button");
1322
- L.className = "drawio-modal-close-btn", L.textContent = "✕", L.type = "button", L.addEventListener("click", () => p()), v.append(_, L), m = document.createElement("iframe"), m.className = "drawio-modal-iframe", m.setAttribute("frameborder", "0"), C.append(v, m), u.appendChild(C), document.body.appendChild(u);
1323
- const P = S === "en" ? "en" : "zh";
1327
+ L.className = "drawio-modal-close-btn", L.textContent = "✕", L.type = "button", L.addEventListener("click", () => p()), v.append(_, L), m = document.createElement("iframe"), m.className = "drawio-modal-iframe", m.setAttribute("frameborder", "0"), y.append(v, m), u.appendChild(y), document.body.appendChild(u);
1328
+ const P = x === "en" ? "en" : "zh";
1324
1329
  m.src = `https://embed.diagrams.net/?embed=1&proto=json&spin=1&lang=${P}`;
1325
1330
  const b = m;
1326
1331
  o = (T) => {
1327
- var M, D;
1332
+ var D, M;
1328
1333
  if (!b || T.source !== b.contentWindow) return;
1329
- let k;
1334
+ let E;
1330
1335
  try {
1331
- k = typeof T.data == "string" ? JSON.parse(T.data) : T.data;
1336
+ E = typeof T.data == "string" ? JSON.parse(T.data) : T.data;
1332
1337
  } catch {
1333
1338
  return;
1334
1339
  }
1335
- if (k.event === "init") {
1340
+ if (E.event === "init") {
1336
1341
  const Y = typeof r.attrs.xml == "string" ? r.attrs.xml : "";
1337
- (M = b.contentWindow) == null || M.postMessage(
1342
+ (D = b.contentWindow) == null || D.postMessage(
1338
1343
  JSON.stringify({ action: "load", autosave: 0, xml: Y || "" }),
1339
1344
  "*"
1340
1345
  );
1341
- } else if (k.event === "save") {
1342
- const Y = k.xml || "";
1343
- (D = b.contentWindow) == null || D.postMessage(
1346
+ } else if (E.event === "save") {
1347
+ const Y = E.xml || "";
1348
+ (M = b.contentWindow) == null || M.postMessage(
1344
1349
  JSON.stringify({ action: "export", format: "svg" }),
1345
1350
  "*"
1346
1351
  ), d({ xml: Y });
1347
- } else if (k.event === "export") {
1348
- const Y = k.data || "";
1352
+ } else if (E.event === "export") {
1353
+ const Y = E.data || "";
1349
1354
  d({ svg: Y }), p();
1350
- } else k.event === "exit" && p();
1355
+ } else E.event === "exit" && p();
1351
1356
  }, window.addEventListener("message", o);
1352
1357
  }, p = () => {
1353
1358
  a = !1, o && (window.removeEventListener("message", o), o = null), m && (m.src = "about:blank", m = null), u && (u.remove(), u = null), f();
1354
1359
  };
1355
- i.addEventListener("dblclick", (C) => {
1356
- C.preventDefault(), C.stopPropagation(), h();
1360
+ i.addEventListener("dblclick", (y) => {
1361
+ y.preventDefault(), y.stopPropagation(), h();
1357
1362
  });
1358
1363
  const f = () => {
1359
- const C = N.getState().editorLanguage, v = U(C), S = typeof r.attrs.svg == "string" ? r.attrs.svg : "";
1360
- S ? (l.src = S, l.style.display = "block") : (l.src = "", l.style.display = "none"), S ? (c.textContent = v.mermaidDoubleClickToEdit || "双击编辑", c.className = "drawio-view-hint drawio-view-hint--subtle") : (c.textContent = v.drawioDoubleClickToEdit || "双击编辑 Draw.io 图表", c.className = "drawio-view-hint drawio-view-hint--empty");
1364
+ const y = k.getState().editorLanguage, v = U(y), x = typeof r.attrs.svg == "string" ? r.attrs.svg : "";
1365
+ x ? (c.src = x, c.style.display = "block") : (c.src = "", c.style.display = "none"), x ? (l.textContent = v.mermaidDoubleClickToEdit || "双击编辑", l.className = "drawio-view-hint drawio-view-hint--subtle") : (l.textContent = v.drawioDoubleClickToEdit || "双击编辑 Draw.io 图表", l.className = "drawio-view-hint drawio-view-hint--empty");
1361
1366
  };
1362
- let y = N.getState().editorLanguage;
1363
- const w = N.subscribe((C) => {
1364
- C.editorLanguage !== y && (y = C.editorLanguage, f());
1367
+ let C = k.getState().editorLanguage;
1368
+ const w = k.subscribe((y) => {
1369
+ y.editorLanguage !== C && (C = y.editorLanguage, f());
1365
1370
  });
1366
1371
  return f(), {
1367
1372
  dom: s,
1368
1373
  ignoreMutation: () => !0,
1369
- update: (C) => C.type.name !== "drawio" ? !1 : (r = C, f(), !0),
1374
+ update: (y) => y.type.name !== "drawio" ? !1 : (r = y, f(), !0),
1370
1375
  destroy: () => {
1371
1376
  w(), o && (window.removeEventListener("message", o), o = null), m && (m.src = "about:blank", m = null), u && (u.remove(), u = null);
1372
1377
  }
1373
1378
  };
1374
1379
  };
1375
1380
  }
1376
- }), Na = {
1381
+ }), ka = {
1377
1382
  name: "drawio",
1378
1383
  version: "1.0.0",
1379
- extensions: [Ea],
1384
+ extensions: [Na],
1380
1385
  toolbarItems: [
1381
1386
  {
1382
1387
  id: "drawio-insert",
@@ -1400,30 +1405,30 @@ const De = () => {
1400
1405
  }
1401
1406
  }
1402
1407
  }
1403
- }, cn = ({
1408
+ }, ln = ({
1404
1409
  node: e,
1405
1410
  updateAttributes: t,
1406
1411
  selected: n,
1407
1412
  editor: r
1408
1413
  }) => {
1409
- const a = X(null), [s, i] = z(!1), l = e.type.name === "math_block", c = X(!1), d = X(t), o = X(e.attrs.latex ?? "");
1414
+ const a = X(null), [s, i] = z(!1), c = e.type.name === "math_block", l = X(!1), d = X(t), o = X(e.attrs.latex ?? "");
1410
1415
  B(() => {
1411
1416
  d.current = t;
1412
1417
  }, [t]), B(() => {
1413
1418
  o.current = e.attrs.latex ?? "";
1414
1419
  }, [e.attrs.latex]);
1415
1420
  const u = de(() => {
1416
- c.current || (c.current = !0, i(!0));
1421
+ l.current || (l.current = !0, i(!0));
1417
1422
  }, []), m = de(() => {
1418
- var f, y;
1419
- if (!c.current) return;
1420
- c.current = !1;
1423
+ var f, C;
1424
+ if (!l.current) return;
1425
+ l.current = !1;
1421
1426
  const p = ((f = a.current) == null ? void 0 : f.value) ?? o.current;
1422
- d.current({ latex: p }), i(!1), (y = globalThis.mathVirtualKeyboard) == null || y.hide({ animate: !0 });
1427
+ d.current({ latex: p }), i(!1), (C = globalThis.mathVirtualKeyboard) == null || C.hide({ animate: !0 });
1423
1428
  }, []);
1424
1429
  B(() => {
1425
- var f, y, w;
1426
- const p = !!((w = (y = (f = r == null ? void 0 : r.view) == null ? void 0 : f.state) == null ? void 0 : y.selection) != null && w.empty);
1430
+ var f, C, w;
1431
+ const p = !!((w = (C = (f = r == null ? void 0 : r.view) == null ? void 0 : f.state) == null ? void 0 : C.selection) != null && w.empty);
1427
1432
  n && p && u();
1428
1433
  }, [n, u]), B(() => {
1429
1434
  s && requestAnimationFrame(() => {
@@ -1437,39 +1442,39 @@ const De = () => {
1437
1442
  if (!p) return;
1438
1443
  const f = () => {
1439
1444
  setTimeout(() => {
1440
- var C, v, S;
1441
- if (!c.current) return;
1445
+ var y, v, x;
1446
+ if (!l.current) return;
1442
1447
  const w = document.activeElement;
1443
- (w == null ? void 0 : w.tagName) === "MATH-FIELD" || (C = w == null ? void 0 : w.closest) != null && C.call(w, "math-field") || (v = w == null ? void 0 : w.closest) != null && v.call(w, ".ML__keyboard") || (S = document.querySelector(".ML__keyboard")) != null && S.contains(w) || m();
1448
+ (w == null ? void 0 : w.tagName) === "MATH-FIELD" || (y = w == null ? void 0 : w.closest) != null && y.call(w, "math-field") || (v = w == null ? void 0 : w.closest) != null && v.call(w, ".ML__keyboard") || (x = document.querySelector(".ML__keyboard")) != null && x.contains(w) || m();
1444
1449
  }, 300);
1445
- }, y = (w) => {
1450
+ }, C = (w) => {
1446
1451
  w.key === "Escape" && m();
1447
1452
  };
1448
- return p.addEventListener("focusout", f), p.addEventListener("keydown", y), () => {
1449
- p.removeEventListener("focusout", f), p.removeEventListener("keydown", y);
1453
+ return p.addEventListener("focusout", f), p.addEventListener("keydown", C), () => {
1454
+ p.removeEventListener("focusout", f), p.removeEventListener("keydown", C);
1450
1455
  };
1451
1456
  }, [s, m]), B(() => {
1452
1457
  !s && a.current && a.current.value !== e.attrs.latex && (a.current.value = e.attrs.latex ?? "");
1453
1458
  }, [e.attrs.latex, s]);
1454
1459
  let h = "";
1455
1460
  try {
1456
- h = pr.renderToString(e.attrs.latex || "", {
1461
+ h = hr.renderToString(e.attrs.latex || "", {
1457
1462
  throwOnError: !1,
1458
- displayMode: l
1463
+ displayMode: c
1459
1464
  });
1460
1465
  } catch {
1461
1466
  h = e.attrs.latex || "";
1462
1467
  }
1463
1468
  return /* @__PURE__ */ g(
1464
- _n,
1469
+ An,
1465
1470
  {
1466
- as: l ? "div" : "span",
1467
- className: l ? "math-block" : "math-inline",
1471
+ as: c ? "div" : "span",
1472
+ className: c ? "math-block" : "math-inline",
1468
1473
  children: s ? /* @__PURE__ */ g(
1469
1474
  "math-field",
1470
1475
  {
1471
1476
  ref: a,
1472
- className: l ? "math-live-field math-live-field--block" : "math-live-field",
1477
+ className: c ? "math-live-field math-live-field--block" : "math-live-field",
1473
1478
  children: e.attrs.latex
1474
1479
  }
1475
1480
  ) : /* @__PURE__ */ A("span", { className: "math-preview", onClick: u, children: [
@@ -1478,7 +1483,7 @@ const De = () => {
1478
1483
  ] })
1479
1484
  }
1480
1485
  );
1481
- }, ka = ee.create({
1486
+ }, _a = ee.create({
1482
1487
  name: "math_inline",
1483
1488
  group: "inline",
1484
1489
  inline: !0,
@@ -1504,14 +1509,14 @@ const De = () => {
1504
1509
  return ["span", ae(e, { "data-type": "math_inline" })];
1505
1510
  },
1506
1511
  addNodeView() {
1507
- return jt(cn, {
1512
+ return qt(ln, {
1508
1513
  stopEvent: ({ event: e }) => {
1509
1514
  const t = e.target;
1510
1515
  return t.tagName.toLowerCase() === "math-field" || t.closest("math-field") !== null;
1511
1516
  }
1512
1517
  });
1513
1518
  }
1514
- }), _a = ee.create({
1519
+ }), Aa = ee.create({
1515
1520
  name: "math_block",
1516
1521
  group: "block",
1517
1522
  atom: !0,
@@ -1527,17 +1532,17 @@ const De = () => {
1527
1532
  return ["div", ae(e, { "data-type": "math_block" })];
1528
1533
  },
1529
1534
  addNodeView() {
1530
- return jt(cn, {
1535
+ return qt(ln, {
1531
1536
  stopEvent: ({ event: e }) => {
1532
1537
  const t = e.target;
1533
1538
  return t.tagName.toLowerCase() === "math-field" || t.closest("math-field") !== null;
1534
1539
  }
1535
1540
  });
1536
1541
  }
1537
- }), Aa = {
1542
+ }), La = {
1538
1543
  name: "math",
1539
1544
  version: "1.0.0",
1540
- extensions: [ka, _a],
1545
+ extensions: [_a, Aa],
1541
1546
  toolbarItems: [
1542
1547
  {
1543
1548
  id: "math-inline-insert",
@@ -1580,13 +1585,13 @@ const De = () => {
1580
1585
  }
1581
1586
  }
1582
1587
  }
1583
- }, ht = (e, t, n = {}) => {
1588
+ }, bt = (e, t, n = {}) => {
1584
1589
  const r = n.from ?? 0, a = n.to ?? e.state.doc.content.size;
1585
1590
  let s = null;
1586
- return e.state.doc.nodesBetween(r, a, (i, l) => s ? !1 : i.type.name === t ? (s = { node: i, pos: l }, !1) : !0), s;
1587
- }, bt = (e, t, n = {}) => {
1591
+ return e.state.doc.nodesBetween(r, a, (i, c) => s ? !1 : i.type.name === t ? (s = { node: i, pos: c }, !1) : !0), s;
1592
+ }, yt = (e, t, n = {}) => {
1588
1593
  const r = n.from ?? 0, a = n.to ?? e.state.doc.content.size, s = [];
1589
- return e.state.doc.nodesBetween(r, a, (i, l) => (t(i, l) && s.push({ node: i, pos: l }), !0)), s;
1594
+ return e.state.doc.nodesBetween(r, a, (i, c) => (t(i, c) && s.push({ node: i, pos: c }), !0)), s;
1590
1595
  }, be = (e, t) => {
1591
1596
  const { $from: n } = e.state.selection;
1592
1597
  for (let r = n.depth; r >= 0; r -= 1) {
@@ -1598,7 +1603,7 @@ const De = () => {
1598
1603
  };
1599
1604
  }
1600
1605
  return null;
1601
- }, La = (e) => {
1606
+ }, Pa = (e) => {
1602
1607
  const { $from: t } = e.state.selection;
1603
1608
  for (let n = t.depth; n >= 0; n -= 1) {
1604
1609
  const r = t.node(n);
@@ -1609,51 +1614,51 @@ const De = () => {
1609
1614
  };
1610
1615
  }
1611
1616
  return null;
1612
- }, Pa = (e, t) => e.state.schema.nodes[t] || null, Ra = (e) => {
1617
+ }, Ra = (e, t) => e.state.schema.nodes[t] || null, Da = (e) => {
1613
1618
  const t = Array.isArray(e.content) ? e.content : e.content ? [e.content] : void 0;
1614
1619
  return {
1615
1620
  type: e.type,
1616
1621
  attrs: e.attrs,
1617
1622
  content: t
1618
1623
  };
1619
- }, qe = (e, t) => {
1620
- const n = Ra(t);
1624
+ }, Ve = (e, t) => {
1625
+ const n = Da(t);
1621
1626
  return typeof t.position == "number" ? e.chain().focus().insertContentAt(t.position, n).run() : e.chain().focus().insertContent(n).run();
1622
1627
  }, pe = (e, t) => typeof t.position != "number" && !t.type ? !1 : e.commands.command(({ tr: n, state: r, dispatch: a }) => {
1623
- var c;
1624
- const s = typeof t.position == "number" ? t.position : (c = ht(e, t.type || "")) == null ? void 0 : c.pos;
1628
+ var l;
1629
+ const s = typeof t.position == "number" ? t.position : (l = bt(e, t.type || "")) == null ? void 0 : l.pos;
1625
1630
  if (typeof s != "number")
1626
1631
  return !1;
1627
1632
  const i = r.doc.nodeAt(s);
1628
1633
  if (!i || t.type && i.type.name !== t.type)
1629
1634
  return !1;
1630
- const l = { ...i.attrs, ...t.attrs };
1631
- return n.setNodeMarkup(s, void 0, l), a && a(n), !0;
1632
- }), yt = (e, t) => typeof t.position != "number" && !t.type ? !1 : e.commands.command(({ tr: n, state: r, dispatch: a }) => {
1633
- var l;
1634
- const s = typeof t.position == "number" ? t.position : (l = ht(e, t.type || "")) == null ? void 0 : l.pos;
1635
+ const c = { ...i.attrs, ...t.attrs };
1636
+ return n.setNodeMarkup(s, void 0, c), a && a(n), !0;
1637
+ }), vt = (e, t) => typeof t.position != "number" && !t.type ? !1 : e.commands.command(({ tr: n, state: r, dispatch: a }) => {
1638
+ var c;
1639
+ const s = typeof t.position == "number" ? t.position : (c = bt(e, t.type || "")) == null ? void 0 : c.pos;
1635
1640
  if (typeof s != "number")
1636
1641
  return !1;
1637
1642
  const i = r.doc.nodeAt(s);
1638
1643
  return !i || t.type && i.type.name !== t.type ? !1 : (n.delete(s, s + i.nodeSize), a && a(n), !0);
1639
- }), ln = (e, t) => {
1640
- const n = Pa(e, t.type);
1644
+ }), dn = (e, t) => {
1645
+ const n = Ra(e, t.type);
1641
1646
  return n ? e.commands.command(({ tr: r, state: a, dispatch: s }) => {
1642
- const { from: i, to: l } = a.selection, c = a.selection.$from.blockRange(a.selection.$to);
1643
- if (!c)
1647
+ const { from: i, to: c } = a.selection, l = a.selection.$from.blockRange(a.selection.$to);
1648
+ if (!l)
1644
1649
  return !1;
1645
- const d = hr(c, n, t.attrs);
1646
- return d ? (r.wrap(c, d), s && s(r.scrollIntoView()), i <= l) : !1;
1650
+ const d = br(l, n, t.attrs);
1651
+ return d ? (r.wrap(l, d), s && s(r.scrollIntoView()), i <= c) : !1;
1647
1652
  }) : !1;
1648
1653
  }, Ma = (e, t) => {
1649
1654
  if (t.length === 0)
1650
1655
  return !1;
1651
1656
  const n = e.getJSON();
1652
1657
  for (const r of t)
1653
- if (!(r.type === "insertNode" ? qe(e, r.payload) : r.type === "updateNodeAttrs" ? pe(e, r.payload) : r.type === "removeNode" ? yt(e, r.payload) : ln(e, r.payload)))
1658
+ if (!(r.type === "insertNode" ? Ve(e, r.payload) : r.type === "updateNodeAttrs" ? pe(e, r.payload) : r.type === "removeNode" ? vt(e, r.payload) : dn(e, r.payload)))
1654
1659
  return e.commands.setContent(n), !1;
1655
1660
  return !0;
1656
- }, Da = ee.create({
1661
+ }, $a = () => `claim_${Date.now().toString(36)}_${Math.random().toString(36).slice(2, 8)}`, Oa = ee.create({
1657
1662
  name: "claim",
1658
1663
  group: "block",
1659
1664
  content: "inline*",
@@ -1676,6 +1681,40 @@ const De = () => {
1676
1681
  0
1677
1682
  ];
1678
1683
  },
1684
+ addKeyboardShortcuts() {
1685
+ return {
1686
+ Enter: () => {
1687
+ const { state: e, dispatch: t } = this.editor.view, { $from: n, empty: r } = e.selection, a = At(n);
1688
+ if (a === null) return !1;
1689
+ const s = n.node(a), c = n.before(a) + s.nodeSize;
1690
+ if (!r || n.pos !== c - 1) return !1;
1691
+ const l = c;
1692
+ let d = 0;
1693
+ e.doc.descendants((h) => (h.type.name === "claim" && d++, !0));
1694
+ const o = e.schema.nodes.claim.create(
1695
+ {
1696
+ number: d + 1,
1697
+ claimId: $a(),
1698
+ dependsOn: [],
1699
+ dependsOnClaimIds: []
1700
+ }
1701
+ ), u = e.tr.insert(l, o), m = l + 1;
1702
+ return u.setSelection(Ie.create(u.doc, m)), t(u), !0;
1703
+ },
1704
+ Backspace: () => {
1705
+ const { state: e, dispatch: t } = this.editor.view, { $from: n, empty: r } = e.selection;
1706
+ if (!r) return !1;
1707
+ const a = At(n);
1708
+ if (a === null) return !1;
1709
+ const s = n.node(a);
1710
+ if (s.content.size > 0) return !1;
1711
+ let i = 0;
1712
+ if (e.doc.descendants((m) => (m.type.name === "claim" && i++, !0)), i <= 1) return !1;
1713
+ const c = n.before(a), l = c + s.nodeSize, d = e.tr.delete(c, l), o = Math.min(c, d.doc.content.size), u = d.doc.resolve(o);
1714
+ return d.setSelection(Ie.near(u)), t(d), !0;
1715
+ }
1716
+ };
1717
+ },
1679
1718
  addNodeView() {
1680
1719
  return ({ editor: e, node: t, getPos: n }) => {
1681
1720
  let r = t;
@@ -1685,59 +1724,64 @@ const De = () => {
1685
1724
  s.className = "claim-label", s.contentEditable = "false";
1686
1725
  const i = document.createElement("span");
1687
1726
  i.className = "claim-body";
1688
- const l = () => {
1689
- const o = N.getState().editorLanguage, u = U(o), m = Number(r.attrs.number || 1);
1690
- s.textContent = `${u.claimLabel(m)}. `;
1727
+ const c = () => {
1728
+ const o = k.getState().editorLanguage, u = U(o), m = Number(r.attrs.number || 1);
1729
+ s.textContent = `${u.claimLabel(m)}. `, r.content.size > 0 ? (i.removeAttribute("data-placeholder"), a.classList.remove("claim-line--empty")) : (i.setAttribute("data-placeholder", o === "en" ? "Type claim content... (Enter to add next)" : "输入权利要求内容… (Enter 添加下一条)"), a.classList.add("claim-line--empty"));
1691
1730
  };
1692
- let c = N.getState().editorLanguage;
1693
- const d = N.subscribe((o) => {
1694
- o.editorLanguage !== c && (c = o.editorLanguage, l());
1731
+ let l = k.getState().editorLanguage;
1732
+ const d = k.subscribe((o) => {
1733
+ o.editorLanguage !== l && (l = o.editorLanguage, c());
1695
1734
  });
1696
1735
  return a.addEventListener("mousedown", (o) => {
1697
1736
  const u = o.target;
1698
1737
  if (!(u instanceof HTMLElement) || u === i || i.contains(u)) return;
1699
1738
  const m = typeof n == "function" ? n() : null;
1700
1739
  if (typeof m != "number") return;
1701
- const h = m + r.nodeSize - 1, p = Wt.create(e.state.doc, h);
1740
+ const h = m + r.nodeSize - 1, p = Ie.create(e.state.doc, h);
1702
1741
  e.view.dispatch(e.state.tr.setSelection(p));
1703
- }), a.append(s, i), l(), {
1742
+ }), a.append(s, i), c(), {
1704
1743
  dom: a,
1705
1744
  contentDOM: i,
1706
- update: (o) => o.type.name !== "claim" ? !1 : (r = o, l(), !0),
1745
+ update: (o) => o.type.name !== "claim" ? !1 : (r = o, c(), !0),
1707
1746
  destroy: () => d()
1708
1747
  };
1709
1748
  };
1710
1749
  }
1711
1750
  });
1712
- let $e = 0;
1713
- const lt = [];
1714
- let Oe = !1;
1715
- const $a = 2e4, _t = 6e4;
1716
- let G = null, He = !1, ce = null, xe = null;
1717
- const dt = /* @__PURE__ */ new Map();
1718
- function At() {
1719
- ce && (window.removeEventListener("message", ce), ce = null), G && (G.src = "about:blank", G.remove(), G = null), He = !1;
1751
+ function At(e) {
1752
+ for (let t = e.depth; t >= 0; t--)
1753
+ if (e.node(t).type.name === "claim") return t;
1754
+ return null;
1755
+ }
1756
+ let Fe = 0;
1757
+ const dt = [];
1758
+ let ze = !1;
1759
+ const Fa = 2e4, Lt = 6e4;
1760
+ let G = null, je = !1, ce = null, xe = null;
1761
+ const ut = /* @__PURE__ */ new Map();
1762
+ function Pt() {
1763
+ ce && (window.removeEventListener("message", ce), ce = null), G && (G.src = "about:blank", G.remove(), G = null), je = !1;
1720
1764
  }
1721
- function Oa(e, t) {
1722
- const n = dt.get(e);
1765
+ function za(e, t) {
1766
+ const n = ut.get(e);
1723
1767
  if (n) {
1724
1768
  t(n);
1725
1769
  return;
1726
1770
  }
1727
- lt.push({ xml: e, callback: t }), ut();
1771
+ dt.push({ xml: e, callback: t }), mt();
1728
1772
  }
1729
- function ut() {
1730
- if (Oe || lt.length === 0) return;
1731
- Oe = !0, xe && (clearTimeout(xe), xe = null);
1732
- const { xml: e, callback: t } = lt.shift(), n = dt.get(e);
1773
+ function mt() {
1774
+ if (ze || dt.length === 0) return;
1775
+ ze = !0, xe && (clearTimeout(xe), xe = null);
1776
+ const { xml: e, callback: t } = dt.shift(), n = ut.get(e);
1733
1777
  if (n) {
1734
- t(n), Oe = !1, xe = setTimeout(At, _t), ut();
1778
+ t(n), ze = !1, xe = setTimeout(Pt, Lt), mt();
1735
1779
  return;
1736
1780
  }
1737
1781
  ce && (window.removeEventListener("message", ce), ce = null);
1738
1782
  let r = null;
1739
1783
  const a = (i) => {
1740
- r && (clearTimeout(r), r = null), i && dt.set(e, i), t(i), Oe = !1, xe = setTimeout(At, _t), ut();
1784
+ r && (clearTimeout(r), r = null), i && ut.set(e, i), t(i), ze = !1, xe = setTimeout(Pt, Lt), mt();
1741
1785
  }, s = () => {
1742
1786
  var i;
1743
1787
  (i = G.contentWindow) == null || i.postMessage(
@@ -1746,25 +1790,25 @@ function ut() {
1746
1790
  );
1747
1791
  };
1748
1792
  ce = (i) => {
1749
- var c;
1793
+ var l;
1750
1794
  if (!G || i.source !== G.contentWindow) return;
1751
- let l;
1795
+ let c;
1752
1796
  try {
1753
- l = typeof i.data == "string" ? JSON.parse(i.data) : i.data;
1797
+ c = typeof i.data == "string" ? JSON.parse(i.data) : i.data;
1754
1798
  } catch {
1755
1799
  return;
1756
1800
  }
1757
- l.event === "init" ? (He = !0, s()) : l.event === "load" ? (c = G.contentWindow) == null || c.postMessage(
1801
+ c.event === "init" ? (je = !0, s()) : c.event === "load" ? (l = G.contentWindow) == null || l.postMessage(
1758
1802
  JSON.stringify({ action: "export", format: "svg" }),
1759
1803
  "*"
1760
- ) : l.event === "export" && a(l.data || "");
1761
- }, window.addEventListener("message", ce), r = setTimeout(() => a(""), $a), G ? He && s() : (G = document.createElement("iframe"), G.style.cssText = "position:fixed;left:-9999px;top:-9999px;width:1px;height:1px;opacity:0;pointer-events:none;", document.body.appendChild(G), He = !1, G.src = "https://embed.diagrams.net/?embed=1&proto=json&spin=0&chrome=0");
1804
+ ) : c.event === "export" && a(c.data || "");
1805
+ }, window.addEventListener("message", ce), r = setTimeout(() => a(""), Fa), G ? je && s() : (G = document.createElement("iframe"), G.style.cssText = "position:fixed;left:-9999px;top:-9999px;width:1px;height:1px;opacity:0;pointer-events:none;", document.body.appendChild(G), je = !1, G.src = "https://embed.diagrams.net/?embed=1&proto=json&spin=0&chrome=0");
1762
1806
  }
1763
- const Fe = () => {
1807
+ const Be = () => {
1764
1808
  document.querySelectorAll('body > svg[id^="fig-mermaid-"]').forEach((e) => e.remove()), document.querySelectorAll('body > svg[id^="d"]').forEach((e) => {
1765
1809
  (e.id.startsWith("dmermaid") || e.id.startsWith("dfi")) && e.remove();
1766
1810
  }), document.querySelectorAll("body > #dmermaid-svg").forEach((e) => e.remove()), document.querySelectorAll("body > style[data-mermaid-style]").forEach((e) => e.remove());
1767
- }, Fa = ee.create({
1811
+ }, Ba = ee.create({
1768
1812
  name: "figure",
1769
1813
  group: "block",
1770
1814
  content: "inline*",
@@ -1795,10 +1839,10 @@ const Fe = () => {
1795
1839
  let r = t, a = !1, s = !1;
1796
1840
  const i = document.createElement("figure");
1797
1841
  i.setAttribute("data-type", "figure"), i.className = "figure-block";
1798
- const l = document.createElement("div");
1799
- l.className = "figure-visual", l.contentEditable = "false", l.setAttribute("spellcheck", "false");
1800
- const c = document.createElement("img");
1801
- c.className = "figure-img-preview";
1842
+ const c = document.createElement("div");
1843
+ c.className = "figure-visual", c.contentEditable = "false", c.setAttribute("spellcheck", "false");
1844
+ const l = document.createElement("img");
1845
+ l.className = "figure-img-preview";
1802
1846
  const d = document.createElement("div");
1803
1847
  d.className = "figure-upload-area";
1804
1848
  const o = document.createElement("span");
@@ -1813,98 +1857,98 @@ const Fe = () => {
1813
1857
  p.className = "figure-mermaid-preview", p.contentEditable = "false";
1814
1858
  const f = document.createElement("div");
1815
1859
  f.className = "figure-mermaid-view-hint", h.append(p, f);
1816
- const y = document.createElement("div");
1817
- y.className = "figure-mermaid-edit";
1860
+ const C = document.createElement("div");
1861
+ C.className = "figure-mermaid-edit";
1818
1862
  const w = document.createElement("textarea");
1819
1863
  w.className = "figure-mermaid-editor", w.spellcheck = !1;
1820
- const C = document.createElement("div");
1821
- C.className = "figure-mermaid-toolbar";
1864
+ const y = document.createElement("div");
1865
+ y.className = "figure-mermaid-toolbar";
1822
1866
  const v = document.createElement("button");
1823
1867
  v.className = "figure-mermaid-save-btn", v.type = "button";
1824
- const S = document.createElement("button");
1825
- S.className = "figure-mermaid-cancel-btn", S.type = "button";
1868
+ const x = document.createElement("button");
1869
+ x.className = "figure-mermaid-cancel-btn", x.type = "button";
1826
1870
  const _ = document.createElement("span");
1827
- _.className = "figure-mermaid-error-inline", C.append(_, S, v), y.append(w, C);
1871
+ _.className = "figure-mermaid-error-inline", y.append(_, x, v), C.append(w, y);
1828
1872
  const L = document.createElement("div");
1829
1873
  L.className = "figure-drawio-view", L.contentEditable = "false";
1830
1874
  const P = document.createElement("img");
1831
1875
  P.className = "figure-drawio-preview-img", P.style.display = "none";
1832
1876
  const b = document.createElement("div");
1833
- b.className = "figure-drawio-view-hint", L.append(P, b), l.append(c, d, m), l.append(h, y), l.append(L);
1877
+ b.className = "figure-drawio-view-hint", L.append(P, b), c.append(l, d, m), c.append(h, C), c.append(L);
1834
1878
  const T = document.createElement("figcaption");
1835
1879
  T.className = "figure-caption";
1836
- const k = document.createElement("span");
1837
- k.className = "figure-id-label", k.contentEditable = "false";
1838
- const M = document.createElement("span");
1839
- M.className = "figure-caption-content", T.append(k, M), i.append(l, T);
1840
- const D = (I) => {
1841
- const E = typeof n == "function" ? n() : null;
1842
- typeof E == "number" && e.commands.command(({ tr: R, dispatch: j }) => (R.setNodeMarkup(E, void 0, { ...r.attrs, ...I }), j && j(R), !0));
1880
+ const E = document.createElement("span");
1881
+ E.className = "figure-id-label", E.contentEditable = "false";
1882
+ const D = document.createElement("span");
1883
+ D.className = "figure-caption-content", T.append(E, D), i.append(c, T);
1884
+ const M = (I) => {
1885
+ const N = typeof n == "function" ? n() : null;
1886
+ typeof N == "number" && e.commands.command(({ tr: R, dispatch: j }) => (R.setNodeMarkup(N, void 0, { ...r.attrs, ...I }), j && j(R), !0));
1843
1887
  }, Y = (I) => {
1844
1888
  if (!I || I.length === 0) return;
1845
- const E = I[0];
1846
- if (!E.type.startsWith("image/")) return;
1889
+ const N = I[0];
1890
+ if (!N.type.startsWith("image/")) return;
1847
1891
  const R = new FileReader();
1848
1892
  R.onload = () => {
1849
- typeof R.result == "string" && D({ imageSrc: R.result });
1850
- }, R.readAsDataURL(E);
1893
+ typeof R.result == "string" && M({ imageSrc: R.result });
1894
+ }, R.readAsDataURL(N);
1851
1895
  };
1852
1896
  u.addEventListener("change", () => Y(u.files)), d.addEventListener("click", () => u.click()), m.addEventListener("click", (I) => {
1853
1897
  I.stopPropagation(), u.click();
1854
- }), l.addEventListener("dragover", (I) => {
1898
+ }), c.addEventListener("dragover", (I) => {
1855
1899
  r.attrs.contentType === "image" && (I.preventDefault(), I.stopPropagation(), d.classList.add("figure-upload-area--dragover"));
1856
- }), l.addEventListener("dragleave", () => {
1900
+ }), c.addEventListener("dragleave", () => {
1857
1901
  d.classList.remove("figure-upload-area--dragover");
1858
- }), l.addEventListener("drop", (I) => {
1859
- var E;
1860
- d.classList.remove("figure-upload-area--dragover"), r.attrs.contentType === "image" && (I.preventDefault(), I.stopPropagation(), Y(((E = I.dataTransfer) == null ? void 0 : E.files) ?? null));
1902
+ }), c.addEventListener("drop", (I) => {
1903
+ var N;
1904
+ d.classList.remove("figure-upload-area--dragover"), r.attrs.contentType === "image" && (I.preventDefault(), I.stopPropagation(), Y(((N = I.dataTransfer) == null ? void 0 : N.files) ?? null));
1861
1905
  });
1862
- const _e = () => {
1906
+ const Le = () => {
1863
1907
  a || (a = !0, w.value = typeof r.attrs.mermaidCode == "string" ? r.attrs.mermaidCode : "", _.textContent = "", _.style.display = "none", se(), requestAnimationFrame(() => w.focus()));
1864
- }, x = () => {
1908
+ }, S = () => {
1865
1909
  a = !1, se();
1866
1910
  }, H = async () => {
1867
1911
  const I = w.value;
1868
1912
  _.textContent = "", _.style.display = "none";
1869
- const E = I.trim();
1870
- if (E)
1913
+ const N = I.trim();
1914
+ if (N)
1871
1915
  try {
1872
1916
  const R = await import("mermaid");
1873
- R.default.initialize({ startOnLoad: !1, theme: "default" }), $e += 1;
1874
- const j = `fig-mermaid-${$e}`, { svg: F } = await R.default.render(j, E);
1875
- p.innerHTML = F, Fe();
1917
+ R.default.initialize({ startOnLoad: !1, theme: "default" }), Fe += 1;
1918
+ const j = `fig-mermaid-${Fe}`, { svg: F } = await R.default.render(j, N);
1919
+ p.innerHTML = F, Be();
1876
1920
  } catch {
1877
- Fe();
1878
- const R = N.getState().editorLanguage;
1921
+ Be();
1922
+ const R = k.getState().editorLanguage;
1879
1923
  _.textContent = R === "en" ? "Mermaid syntax error, please fix and retry" : "Mermaid 语法错误,请修正后重试", _.style.display = "inline";
1880
1924
  return;
1881
1925
  }
1882
- D({ mermaidCode: I }), a = !1, se();
1926
+ M({ mermaidCode: I }), a = !1, se();
1883
1927
  };
1884
1928
  h.addEventListener("dblclick", (I) => {
1885
- I.preventDefault(), I.stopPropagation(), _e();
1929
+ I.preventDefault(), I.stopPropagation(), Le();
1886
1930
  }), v.addEventListener("click", (I) => {
1887
1931
  I.stopPropagation(), H();
1888
- }), S.addEventListener("click", (I) => {
1889
- I.stopPropagation(), x();
1932
+ }), x.addEventListener("click", (I) => {
1933
+ I.stopPropagation(), S();
1890
1934
  }), w.addEventListener("mousedown", (I) => I.stopPropagation()), w.addEventListener("keydown", (I) => I.stopPropagation()), w.addEventListener("keypress", (I) => I.stopPropagation());
1891
1935
  let $ = null, O = null, K = null;
1892
- const Sn = () => {
1936
+ const Tn = () => {
1893
1937
  if (s) return;
1894
1938
  s = !0, se(), O = document.createElement("div"), O.className = "drawio-modal-overlay";
1895
1939
  const I = document.createElement("div");
1896
1940
  I.className = "drawio-modal-content";
1897
- const E = document.createElement("div");
1898
- E.className = "drawio-modal-header";
1899
- const R = document.createElement("span"), j = N.getState().editorLanguage;
1941
+ const N = document.createElement("div");
1942
+ N.className = "drawio-modal-header";
1943
+ const R = document.createElement("span"), j = k.getState().editorLanguage;
1900
1944
  R.textContent = j === "en" ? "Edit Draw.io Diagram" : "编辑 Draw.io 图表", R.className = "drawio-modal-title";
1901
1945
  const F = document.createElement("button");
1902
- F.className = "drawio-modal-close-btn", F.textContent = "✕", F.type = "button", F.addEventListener("click", () => Ze()), E.append(R, F), K = document.createElement("iframe"), K.className = "drawio-modal-iframe", K.setAttribute("frameborder", "0"), I.append(E, K), O.appendChild(I), document.body.appendChild(O);
1946
+ F.className = "drawio-modal-close-btn", F.textContent = "✕", F.type = "button", F.addEventListener("click", () => et()), N.append(R, F), K = document.createElement("iframe"), K.className = "drawio-modal-iframe", K.setAttribute("frameborder", "0"), I.append(N, K), O.appendChild(I), document.body.appendChild(O);
1903
1947
  const Ce = j === "en" ? "en" : "zh";
1904
1948
  K.src = `https://embed.diagrams.net/?embed=1&proto=json&spin=1&lang=${Ce}`;
1905
1949
  const te = K;
1906
1950
  $ = (ne) => {
1907
- var ue, Ae;
1951
+ var ue, Pe;
1908
1952
  if (!te || ne.source !== te.contentWindow) return;
1909
1953
  let J;
1910
1954
  try {
@@ -1920,84 +1964,84 @@ const Fe = () => {
1920
1964
  );
1921
1965
  } else if (J.event === "save") {
1922
1966
  const me = J.xml || "";
1923
- (Ae = te.contentWindow) == null || Ae.postMessage(
1967
+ (Pe = te.contentWindow) == null || Pe.postMessage(
1924
1968
  JSON.stringify({ action: "export", format: "svg" }),
1925
1969
  "*"
1926
- ), D({ drawioXml: me });
1970
+ ), M({ drawioXml: me });
1927
1971
  } else if (J.event === "export") {
1928
1972
  const me = J.data || "";
1929
- D({ drawioSvg: me }), Ze();
1930
- } else J.event === "exit" && Ze();
1973
+ M({ drawioSvg: me }), et();
1974
+ } else J.event === "exit" && et();
1931
1975
  }, window.addEventListener("message", $);
1932
- }, Ze = () => {
1976
+ }, et = () => {
1933
1977
  s = !1, $ && (window.removeEventListener("message", $), $ = null), K && (K.src = "about:blank", K = null), O && (O.remove(), O = null), se();
1934
1978
  };
1935
1979
  L.addEventListener("dblclick", (I) => {
1936
- I.preventDefault(), I.stopPropagation(), Sn();
1980
+ I.preventDefault(), I.stopPropagation(), Tn();
1937
1981
  }), i.addEventListener("mousedown", (I) => {
1938
- const E = I.target;
1939
- if (!(E instanceof HTMLElement) || E === M || M.contains(E) || E === w || y.contains(E) || E === d || d.contains(E) || E === m || E === u || h.contains(E) || L.contains(E)) return;
1982
+ const N = I.target;
1983
+ if (!(N instanceof HTMLElement) || N === D || D.contains(N) || N === w || C.contains(N) || N === d || d.contains(N) || N === m || N === u || h.contains(N) || L.contains(N)) return;
1940
1984
  const R = typeof n == "function" ? n() : null;
1941
1985
  if (typeof R != "number") return;
1942
- const j = R + r.nodeSize - 1, F = Wt.create(e.state.doc, j);
1986
+ const j = R + r.nodeSize - 1, F = Ie.create(e.state.doc, j);
1943
1987
  e.view.dispatch(e.state.tr.setSelection(F));
1944
1988
  });
1945
- let et = !1, ve = "";
1946
- const Tn = async (I) => {
1947
- const E = I.trim();
1948
- if (E !== ve) {
1949
- if (!E) {
1989
+ let tt = !1, ve = "";
1990
+ const In = async (I) => {
1991
+ const N = I.trim();
1992
+ if (N !== ve) {
1993
+ if (!N) {
1950
1994
  p.innerHTML = "", ve = "";
1951
1995
  return;
1952
1996
  }
1953
1997
  try {
1954
1998
  const R = await import("mermaid");
1955
- R.default.initialize({ startOnLoad: !1, theme: "default" }), $e += 1;
1956
- const j = `fig-mermaid-${$e}`, { svg: F } = await R.default.render(j, E);
1957
- p.innerHTML = F, ve = E;
1999
+ R.default.initialize({ startOnLoad: !1, theme: "default" }), Fe += 1;
2000
+ const j = `fig-mermaid-${Fe}`, { svg: F } = await R.default.render(j, N);
2001
+ p.innerHTML = F, ve = N;
1958
2002
  } catch {
1959
2003
  p.innerHTML = "", ve = "";
1960
2004
  } finally {
1961
- Fe();
2005
+ Be();
1962
2006
  }
1963
2007
  }
1964
2008
  }, se = () => {
1965
- const I = N.getState().editorLanguage, E = U(I), R = ["image", "mermaid", "drawio"].includes(r.attrs.contentType) ? r.attrs.contentType : "image", j = typeof r.attrs.id == "string" ? r.attrs.id.trim() : "", F = typeof r.attrs.imageSrc == "string" ? r.attrs.imageSrc : "", Ce = typeof r.attrs.mermaidCode == "string" ? r.attrs.mermaidCode : "";
1966
- j ? (k.textContent = `[${j}] `, k.style.display = "inline") : (k.textContent = "", k.style.display = "none");
2009
+ const I = k.getState().editorLanguage, N = U(I), R = ["image", "mermaid", "drawio"].includes(r.attrs.contentType) ? r.attrs.contentType : "image", j = typeof r.attrs.id == "string" ? r.attrs.id.trim() : "", F = typeof r.attrs.imageSrc == "string" ? r.attrs.imageSrc : "", Ce = typeof r.attrs.mermaidCode == "string" ? r.attrs.mermaidCode : "";
2010
+ j ? (E.textContent = `[${j}] `, E.style.display = "inline") : (E.textContent = "", E.style.display = "none");
1967
2011
  const te = R === "image", ne = R === "mermaid", J = R === "drawio";
1968
- c.style.display = te && F ? "block" : "none", d.style.display = te && !F ? "flex" : "none", m.style.display = te && F ? "block" : "none", h.style.display = ne && !a ? "block" : "none", y.style.display = ne && a ? "block" : "none", L.style.display = J ? "flex" : "none", te && F && (c.src = F);
2012
+ l.style.display = te && F ? "block" : "none", d.style.display = te && !F ? "flex" : "none", m.style.display = te && F ? "block" : "none", h.style.display = ne && !a ? "block" : "none", C.style.display = ne && a ? "block" : "none", L.style.display = J ? "flex" : "none", te && F && (l.src = F);
1969
2013
  const ue = typeof r.attrs.drawioSvg == "string" ? r.attrs.drawioSvg : "";
1970
- J && (ue ? (P.src = ue, P.style.display = "block") : (P.src = "", P.style.display = "none")), o.textContent = E.figureUploadHint || "点击上传或拖拽图片", m.textContent = E.figureReplaceImage || "更换图片", v.textContent = E.mermaidSaveAndRender || "保存并渲染", S.textContent = E.mermaidCancel || "取消";
1971
- const Ae = Ce.trim().length > 0, me = p.querySelector("svg") !== null;
1972
- ne && !a && (Ae && me ? (f.textContent = E.mermaidDoubleClickToEdit || "双击编辑", f.className = "figure-mermaid-view-hint figure-mermaid-view-hint--subtle") : (f.textContent = E.mermaidDoubleClickToCreate || "双击编辑 Mermaid 图表", f.className = "figure-mermaid-view-hint figure-mermaid-view-hint--empty")), J && !s && (ue ? (b.textContent = E.mermaidDoubleClickToEdit || "双击编辑", b.className = "figure-drawio-view-hint figure-mermaid-view-hint--subtle") : (b.textContent = E.drawioDoubleClickToEdit || "双击编辑 Draw.io 图表", b.className = "figure-drawio-view-hint figure-mermaid-view-hint--empty")), ne && !a && Ce.trim() !== ve && Tn(Ce);
1973
- const wt = typeof r.attrs.drawioXml == "string" ? r.attrs.drawioXml : "";
1974
- J && wt && !ue && !et && !s && (et = !0, Oa(wt, (xt) => {
1975
- xt && D({ drawioSvg: xt }), et = !1;
2014
+ J && (ue ? (P.src = ue, P.style.display = "block") : (P.src = "", P.style.display = "none")), o.textContent = N.figureUploadHint || "点击上传或拖拽图片", m.textContent = N.figureReplaceImage || "更换图片", v.textContent = N.mermaidSaveAndRender || "保存并渲染", x.textContent = N.mermaidCancel || "取消";
2015
+ const Pe = Ce.trim().length > 0, me = p.querySelector("svg") !== null;
2016
+ ne && !a && (Pe && me ? (f.textContent = N.mermaidDoubleClickToEdit || "双击编辑", f.className = "figure-mermaid-view-hint figure-mermaid-view-hint--subtle") : (f.textContent = N.mermaidDoubleClickToCreate || "双击编辑 Mermaid 图表", f.className = "figure-mermaid-view-hint figure-mermaid-view-hint--empty")), J && !s && (ue ? (b.textContent = N.mermaidDoubleClickToEdit || "双击编辑", b.className = "figure-drawio-view-hint figure-mermaid-view-hint--subtle") : (b.textContent = N.drawioDoubleClickToEdit || "双击编辑 Draw.io 图表", b.className = "figure-drawio-view-hint figure-mermaid-view-hint--empty")), ne && !a && Ce.trim() !== ve && In(Ce);
2017
+ const xt = typeof r.attrs.drawioXml == "string" ? r.attrs.drawioXml : "";
2018
+ J && xt && !ue && !tt && !s && (tt = !0, za(xt, (St) => {
2019
+ St && M({ drawioSvg: St }), tt = !1;
1976
2020
  }));
1977
2021
  };
1978
- let Ct = N.getState().editorLanguage;
1979
- const In = N.subscribe((I) => {
1980
- I.editorLanguage !== Ct && (Ct = I.editorLanguage, se());
2022
+ let wt = k.getState().editorLanguage;
2023
+ const En = k.subscribe((I) => {
2024
+ I.editorLanguage !== wt && (wt = I.editorLanguage, se());
1981
2025
  });
1982
2026
  return se(), {
1983
2027
  dom: i,
1984
- contentDOM: M,
2028
+ contentDOM: D,
1985
2029
  stopEvent: (I) => {
1986
- const E = I.target;
1987
- return !!(E === w || y.contains(E) || E === u);
2030
+ const N = I.target;
2031
+ return !!(N === w || C.contains(N) || N === u);
1988
2032
  },
1989
2033
  ignoreMutation: (I) => {
1990
- const E = I.target;
1991
- return !!(l.contains(E) || k.contains(E));
2034
+ const N = I.target;
2035
+ return !!(c.contains(N) || E.contains(N));
1992
2036
  },
1993
2037
  update: (I) => I.type.name !== "figure" ? !1 : (r = I, se(), !0),
1994
2038
  destroy: () => {
1995
- In(), Fe(), $ && (window.removeEventListener("message", $), $ = null), K && (K.src = "about:blank", K = null), O && (O.remove(), O = null);
2039
+ En(), Be(), $ && (window.removeEventListener("message", $), $ = null), K && (K.src = "about:blank", K = null), O && (O.remove(), O = null);
1996
2040
  }
1997
2041
  };
1998
2042
  };
1999
2043
  }
2000
- }), za = ee.create({
2044
+ }), Ha = ee.create({
2001
2045
  name: "reference",
2002
2046
  group: "inline",
2003
2047
  inline: !0,
@@ -2058,7 +2102,7 @@ const Fe = () => {
2058
2102
  return ({ node: e, editor: t }) => {
2059
2103
  let n = e;
2060
2104
  const r = document.createElement("span"), a = () => {
2061
- const s = n.attrs.lang === "en" ? "en" : "zh", i = U(s), l = n.attrs.targetType === "figure" ? "figure" : "claim", c = Number(n.attrs.resolvedNumber), d = typeof n.attrs.resolvedFigureId == "string" && n.attrs.resolvedFigureId ? n.attrs.resolvedFigureId : null, o = l === "figure" ? d || (s === "en" ? "Figure ?" : "附图?") : Number.isFinite(c) ? i.claimLabel(c) : s === "en" ? "Claim ?" : "权利要求?", u = n.attrs.displayText || o;
2105
+ const s = n.attrs.lang === "en" ? "en" : "zh", i = U(s), c = n.attrs.targetType === "figure" ? "figure" : "claim", l = Number(n.attrs.resolvedNumber), d = typeof n.attrs.resolvedFigureId == "string" && n.attrs.resolvedFigureId ? n.attrs.resolvedFigureId : null, o = c === "figure" ? d || (s === "en" ? "Figure ?" : "附图?") : Number.isFinite(l) ? i.claimLabel(l) : s === "en" ? "Claim ?" : "权利要求?", u = n.attrs.displayText || o;
2062
2106
  r.textContent = u, r.className = `reference-link${n.attrs.invalid ? " reference-link-invalid" : ""}`, r.setAttribute("data-type", "reference"), r.setAttribute("data-highlight", n.attrs.highlight ? "true" : "false"), r.title = n.attrs.invalid ? i.referenceNavigateDisabledTitle : i.referenceNavigateTitle;
2063
2107
  };
2064
2108
  return a(), r.addEventListener("click", () => {
@@ -2067,20 +2111,20 @@ const Fe = () => {
2067
2111
  return;
2068
2112
  let i = null;
2069
2113
  if (s === "figure") {
2070
- const l = typeof n.attrs.targetFigureId == "string" ? n.attrs.targetFigureId : "";
2071
- if (!l)
2114
+ const c = typeof n.attrs.targetFigureId == "string" ? n.attrs.targetFigureId : "";
2115
+ if (!c)
2072
2116
  return;
2073
- t.state.doc.descendants((c, d) => c.type.name !== "figure" ? !0 : c.attrs.id === l ? (i = d, !1) : !0), typeof i == "number" && t.chain().focus().setTextSelection(i + 1).run();
2117
+ t.state.doc.descendants((l, d) => l.type.name !== "figure" ? !0 : l.attrs.id === c ? (i = d, !1) : !0), typeof i == "number" && t.chain().focus().setTextSelection(i + 1).run();
2074
2118
  return;
2075
2119
  }
2076
- n.attrs.targetClaimId && (t.state.doc.descendants((l, c) => l.type.name !== "claim" ? !0 : l.attrs.claimId === n.attrs.targetClaimId ? (i = c, !1) : !0), typeof i == "number" && t.chain().focus().setTextSelection(i + 1).run());
2120
+ n.attrs.targetClaimId && (t.state.doc.descendants((c, l) => c.type.name !== "claim" ? !0 : c.attrs.claimId === n.attrs.targetClaimId ? (i = l, !1) : !0), typeof i == "number" && t.chain().focus().setTextSelection(i + 1).run());
2077
2121
  }), {
2078
2122
  dom: r,
2079
2123
  update: (s) => s.type.name !== this.name ? !1 : (n = s, a(), !0)
2080
2124
  };
2081
2125
  };
2082
2126
  }
2083
- }), Lt = {
2127
+ }), Rt = {
2084
2128
  technical_field: "sectionTitle_technical_field",
2085
2129
  background_art: "sectionTitle_background_art",
2086
2130
  summary: "sectionTitle_summary",
@@ -2095,7 +2139,7 @@ const Fe = () => {
2095
2139
  design_description: "sectionTitle_design_description",
2096
2140
  design_views: "sectionTitle_design_views",
2097
2141
  design_brief: "sectionTitle_design_brief"
2098
- }, Ba = /* @__PURE__ */ new Set([
2142
+ }, Ua = /* @__PURE__ */ new Set([
2099
2143
  "abstract",
2100
2144
  "abstract_drawing",
2101
2145
  "claims",
@@ -2106,22 +2150,22 @@ const Fe = () => {
2106
2150
  "design_description",
2107
2151
  "design_views",
2108
2152
  "design_brief"
2109
- ]), Ha = /* @__PURE__ */ new Set([
2153
+ ]), ja = /* @__PURE__ */ new Set([
2110
2154
  "technical_field",
2111
2155
  "background_art",
2112
2156
  "summary",
2113
2157
  "drawing_description",
2114
2158
  "detailed_description"
2115
- ]), vt = (e) => {
2159
+ ]), Ct = (e) => {
2116
2160
  if (e.isText)
2117
2161
  return (e.text ?? "").trim().length > 0;
2118
2162
  if (e.isAtom || e.isLeaf || !["patent_section", "patent_title", "paragraph"].includes(e.type.name))
2119
2163
  return !0;
2120
2164
  let t = !1;
2121
2165
  return e.forEach((n) => {
2122
- !t && vt(n) && (t = !0);
2166
+ !t && Ct(n) && (t = !0);
2123
2167
  }), t;
2124
- }, Ua = ee.create({
2168
+ }, Wa = ee.create({
2125
2169
  name: "patent_title",
2126
2170
  group: "block",
2127
2171
  content: "inline*",
@@ -2150,41 +2194,41 @@ const Fe = () => {
2150
2194
  s.className = "pb-heading", s.contentEditable = "false";
2151
2195
  const i = document.createElement("div");
2152
2196
  i.className = "ps-placeholder", i.contentEditable = "false";
2153
- const l = document.createElement("h1");
2154
- l.className = "pt-title-content", a.append(s, i, l);
2155
- const c = () => {
2197
+ const c = document.createElement("h1");
2198
+ c.className = "pt-title-content", a.append(s, i, c);
2199
+ const l = () => {
2156
2200
  const f = typeof n == "function" ? n() : null;
2157
2201
  return typeof f == "number" ? f : null;
2158
2202
  }, d = () => {
2159
- const f = c();
2160
- f !== null && N.getState().setActiveSection("patent_title", f);
2203
+ const f = l();
2204
+ f !== null && k.getState().setActiveSection("patent_title", f);
2161
2205
  }, o = () => {
2162
- const f = c();
2163
- f !== null && (N.getState().openDraftingPanel("patent_title", f), e.commands.focus(f + 1));
2206
+ const f = l();
2207
+ f !== null && (k.getState().openDraftingPanel("patent_title", f), e.commands.focus(f + 1));
2164
2208
  };
2165
- i.addEventListener("click", o), l.addEventListener("focusin", d), l.addEventListener("click", d);
2209
+ i.addEventListener("click", o), c.addEventListener("focusin", d), c.addEventListener("click", d);
2166
2210
  const u = () => {
2167
- const f = N.getState(), y = U(f.editorLanguage), w = typeof y.bookTitle_description == "string" ? y.bookTitle_description : "说明书", C = typeof y.patentTitlePlaceholder == "string" ? y.patentTitlePlaceholder : "专利名称";
2211
+ const f = k.getState(), C = U(f.editorLanguage), w = typeof C.bookTitle_description == "string" ? C.bookTitle_description : "说明书", y = typeof C.patentTitlePlaceholder == "string" ? C.patentTitlePlaceholder : "专利名称";
2168
2212
  s.textContent = w;
2169
- const v = vt(r), S = f.rightPanel.activeSectionPos === c();
2170
- i.textContent = `[${C}]`, i.style.display = v ? "none" : "", i.classList.toggle("ps-placeholder--active", S && !v), l.classList.toggle("pt-title-content--has-content", v);
2213
+ const v = Ct(r), x = f.rightPanel.activeSectionPos === l();
2214
+ i.textContent = `[${y}]`, i.style.display = v ? "none" : "", i.classList.toggle("ps-placeholder--active", x && !v), c.classList.toggle("pt-title-content--has-content", v);
2171
2215
  };
2172
- let m = N.getState().editorLanguage, h = N.getState().rightPanel.activeSectionPos;
2173
- const p = N.subscribe((f) => {
2174
- const y = f.editorLanguage !== m, w = f.rightPanel.activeSectionPos !== h;
2175
- m = f.editorLanguage, h = f.rightPanel.activeSectionPos, (y || w) && u();
2216
+ let m = k.getState().editorLanguage, h = k.getState().rightPanel.activeSectionPos;
2217
+ const p = k.subscribe((f) => {
2218
+ const C = f.editorLanguage !== m, w = f.rightPanel.activeSectionPos !== h;
2219
+ m = f.editorLanguage, h = f.rightPanel.activeSectionPos, (C || w) && u();
2176
2220
  });
2177
2221
  return u(), {
2178
2222
  dom: a,
2179
- contentDOM: l,
2223
+ contentDOM: c,
2180
2224
  update: (f) => f.type.name !== "patent_title" ? !1 : (r = f, u(), !0),
2181
2225
  destroy: () => {
2182
- p(), i.removeEventListener("click", o), l.removeEventListener("focusin", d), l.removeEventListener("click", d);
2226
+ p(), i.removeEventListener("click", o), c.removeEventListener("focusin", d), c.removeEventListener("click", d);
2183
2227
  }
2184
2228
  };
2185
2229
  };
2186
2230
  }
2187
- }), ja = ee.create({
2231
+ }), qa = ee.create({
2188
2232
  name: "patent_section",
2189
2233
  group: "block",
2190
2234
  content: "block+",
@@ -2216,15 +2260,15 @@ const Fe = () => {
2216
2260
  const n = [];
2217
2261
  return t.forEach((r) => {
2218
2262
  r.type.name === "patent_section" || r.type.name === "patent_title" ? e(r.content).forEach((s) => n.push(s)) : r.isBlock && r.content.size > 0 ? n.push(r.copy(e(r.content))) : n.push(r);
2219
- }), yr.from(n);
2263
+ }), vr.from(n);
2220
2264
  };
2221
2265
  return [
2222
- new Ke({
2223
- key: new ke("patentSectionLock"),
2266
+ new Xe({
2267
+ key: new _e("patentSectionLock"),
2224
2268
  props: {
2225
2269
  transformPasted: (t) => {
2226
2270
  const n = e(t.content);
2227
- return new br(n, t.openStart, t.openEnd);
2271
+ return new yr(n, t.openStart, t.openEnd);
2228
2272
  }
2229
2273
  },
2230
2274
  filterTransaction: (t, n) => {
@@ -2251,63 +2295,79 @@ const Fe = () => {
2251
2295
  s.contentEditable = "false";
2252
2296
  const i = document.createElement("div");
2253
2297
  i.className = "ps-body";
2254
- const l = document.createElement("div");
2255
- l.className = "ps-placeholder", l.contentEditable = "false";
2256
2298
  const c = document.createElement("div");
2257
- c.className = "ps-content", i.append(l, c), a.append(s, i);
2258
- const d = () => {
2299
+ c.className = "ps-placeholder", c.contentEditable = "false";
2300
+ const l = document.createElement("div");
2301
+ l.className = "ps-content";
2302
+ const d = document.createElement("button");
2303
+ d.type = "button", d.className = "claim-add-btn", d.contentEditable = "false", i.append(c, l, d), a.append(s, i);
2304
+ const o = () => {
2259
2305
  const y = typeof n == "function" ? n() : null;
2260
2306
  return typeof y == "number" ? y : null;
2261
- }, o = () => {
2262
- const y = d();
2263
- if (y === null) return;
2264
- N.getState().setActiveSection(r.attrs.sectionType, y);
2265
2307
  }, u = () => {
2266
- const y = d();
2308
+ const y = o();
2267
2309
  if (y === null) return;
2268
- N.getState().openDraftingPanel(r.attrs.sectionType, y), e.commands.focus(y + 1);
2310
+ k.getState().setActiveSection(r.attrs.sectionType, y);
2311
+ }, m = () => {
2312
+ const y = o();
2313
+ if (y === null) return;
2314
+ k.getState().openDraftingPanel(r.attrs.sectionType, y), e.commands.focus(y + 1);
2315
+ }, h = (y) => {
2316
+ y.preventDefault(), y.stopPropagation();
2317
+ const v = `claim_${Date.now().toString(36)}_${Math.random().toString(36).slice(2, 8)}`;
2318
+ let x = 0;
2319
+ e.state.doc.descendants((E) => (E.type.name === "claim" && x++, !0));
2320
+ const _ = o();
2321
+ if (_ === null) return;
2322
+ const L = _ + r.nodeSize - 1, P = e.state.schema.nodes.claim.create({
2323
+ number: x + 1,
2324
+ claimId: v,
2325
+ dependsOn: [],
2326
+ dependsOnClaimIds: []
2327
+ }), b = e.state.tr.insert(L, P), T = L + 1;
2328
+ b.setSelection(Ie.create(b.doc, T)), e.view.dispatch(b), e.view.focus();
2269
2329
  };
2270
- l.addEventListener("click", u), c.addEventListener("focusin", o), c.addEventListener("click", o);
2271
- const m = () => {
2272
- const y = N.getState(), w = U(y.editorLanguage), C = Object.keys(Lt).includes(r.attrs.sectionType) ? r.attrs.sectionType : "technical_field", v = Ba.has(C), S = Ha.has(C), _ = Lt[C], L = typeof w[_] == "string" ? w[_] : C, P = vt(r), b = y.rightPanel.activeSectionPos === d();
2273
- a.className = `ps${P ? "" : " ps--empty"}${S ? " ps--sub" : ""}`, a.setAttribute("data-section-type", C), s.className = v ? "pb-heading" : "ps-heading ps-heading--sub", s.textContent = L, l.textContent = `[${L}]`, l.style.display = P ? "none" : "", l.classList.toggle("ps-placeholder--active", b && !P), c.classList.toggle("ps-content--has-content", P);
2330
+ c.addEventListener("click", m), l.addEventListener("focusin", u), l.addEventListener("click", u), d.addEventListener("mousedown", h);
2331
+ const p = () => {
2332
+ const y = k.getState(), v = U(y.editorLanguage), x = Object.keys(Rt).includes(r.attrs.sectionType) ? r.attrs.sectionType : "technical_field", _ = Ua.has(x), L = ja.has(x), P = x === "claims", b = Rt[x], T = typeof v[b] == "string" ? v[b] : x, E = Ct(r), D = y.rightPanel.activeSectionPos === o();
2333
+ a.className = `ps${E ? "" : " ps--empty"}${L ? " ps--sub" : ""}`, a.setAttribute("data-section-type", x), s.className = _ ? "pb-heading" : "ps-heading ps-heading--sub", s.textContent = T, c.textContent = `[${T}]`, c.style.display = E ? "none" : "", c.classList.toggle("ps-placeholder--active", D && !E), l.classList.toggle("ps-content--has-content", E), P ? (d.style.display = "", d.textContent = y.editorLanguage === "en" ? "+ Add Claim" : "+ 添加权利要求") : d.style.display = "none";
2274
2334
  };
2275
- let h = N.getState().editorLanguage, p = N.getState().rightPanel.activeSectionPos;
2276
- const f = N.subscribe((y) => {
2277
- const w = y.editorLanguage !== h, C = y.rightPanel.activeSectionPos !== p;
2278
- h = y.editorLanguage, p = y.rightPanel.activeSectionPos, (w || C) && m();
2335
+ let f = k.getState().editorLanguage, C = k.getState().rightPanel.activeSectionPos;
2336
+ const w = k.subscribe((y) => {
2337
+ const v = y.editorLanguage !== f, x = y.rightPanel.activeSectionPos !== C;
2338
+ f = y.editorLanguage, C = y.rightPanel.activeSectionPos, (v || x) && p();
2279
2339
  });
2280
- return m(), {
2340
+ return p(), {
2281
2341
  dom: a,
2282
- contentDOM: c,
2283
- update: (y) => y.type.name !== "patent_section" ? !1 : (r = y, m(), !0),
2342
+ contentDOM: l,
2343
+ update: (y) => y.type.name !== "patent_section" ? !1 : (r = y, p(), !0),
2284
2344
  destroy: () => {
2285
- f(), l.removeEventListener("click", u), c.removeEventListener("focusin", o), c.removeEventListener("click", o);
2345
+ w(), c.removeEventListener("click", m), l.removeEventListener("focusin", u), l.removeEventListener("click", u), d.removeEventListener("mousedown", h);
2286
2346
  }
2287
2347
  };
2288
2348
  };
2289
2349
  }
2290
- }), Wa = [
2350
+ }), Ga = [
2291
2351
  "abstract",
2292
2352
  // 说明书摘要
2293
2353
  "abstract_drawing"
2294
2354
  // 摘要附图
2295
- ], qa = [
2355
+ ], Va = [
2296
2356
  "technical_field",
2297
2357
  "background_art",
2298
2358
  "summary",
2299
2359
  "drawing_description",
2300
2360
  "detailed_description"
2301
- ], Ga = [
2361
+ ], Ka = [
2302
2362
  "drawing_figures"
2303
2363
  // 说明书附图
2304
- ], Va = [
2364
+ ], Ja = [
2305
2365
  "design_product_name",
2306
2366
  "design_usage",
2307
2367
  "design_description",
2308
2368
  "design_views",
2309
2369
  "design_brief"
2310
- ], Ue = (e) => ({
2370
+ ], We = (e) => ({
2311
2371
  type: "patent_section",
2312
2372
  attrs: {
2313
2373
  sectionType: e,
@@ -2318,26 +2378,26 @@ const Fe = () => {
2318
2378
  type: "paragraph"
2319
2379
  }
2320
2380
  ]
2321
- }), dn = () => ({
2381
+ }), un = () => ({
2322
2382
  type: "patent_title",
2323
2383
  content: []
2324
- }), Ka = () => [
2325
- ...Wa.map(Ue),
2326
- dn(),
2327
- ...qa.map(Ue),
2328
- ...Ga.map(Ue)
2329
- ], Ja = () => [
2330
- dn(),
2331
- ...Va.map(Ue)
2332
- ], un = (e = "invention") => ({ type: "doc", content: e === "design" ? Ja() : Ka() }), Pt = 400, V = {
2384
+ }), Xa = () => [
2385
+ ...Ga.map(We),
2386
+ un(),
2387
+ ...Va.map(We),
2388
+ ...Ka.map(We)
2389
+ ], Qa = () => [
2390
+ un(),
2391
+ ...Ja.map(We)
2392
+ ], mn = (e = "invention") => ({ type: "doc", content: e === "design" ? Qa() : Xa() }), Dt = 400, V = {
2333
2393
  lastClaimWarningSignature: "",
2334
2394
  lastInvalidReferenceSignature: "",
2335
2395
  lastClaimGraphSignature: "",
2336
2396
  invalidReferenceHandler: null,
2337
2397
  claimGraphHandler: null
2338
- }, fe = (e) => bt(e, (t) => t.type.name === "claim"), Ne = (e) => bt(e, (t) => t.type.name === "figure"), mn = () => `claim_${Date.now().toString(36)}_${Math.random().toString(36).slice(2, 8)}`, Z = (e) => typeof e != "string" ? "" : e.trim(), Rt = (e) => {
2339
- const n = N.getState().editorLanguage === "en" ? "Fig." : "图", r = /* @__PURE__ */ new Set();
2340
- Ne(e).forEach((s) => {
2398
+ }, fe = (e) => yt(e, (t) => t.type.name === "claim"), ke = (e) => yt(e, (t) => t.type.name === "figure"), fn = () => `claim_${Date.now().toString(36)}_${Math.random().toString(36).slice(2, 8)}`, Z = (e) => typeof e != "string" ? "" : e.trim(), Mt = (e) => {
2399
+ const n = k.getState().editorLanguage === "en" ? "Fig." : "图", r = /* @__PURE__ */ new Set();
2400
+ ke(e).forEach((s) => {
2341
2401
  const i = Z(s.node.attrs.id);
2342
2402
  i && r.add(i);
2343
2403
  });
@@ -2345,46 +2405,46 @@ const Fe = () => {
2345
2405
  for (; r.has(`${n}${a}`); )
2346
2406
  a += 1;
2347
2407
  return `${n}${a}`;
2348
- }, Xa = /^(Fig\.|图)(\d+)$/, Qa = (e) => {
2349
- const n = N.getState().editorLanguage === "en" ? "Fig." : "图", r = Ne(e);
2408
+ }, Ya = /^(Fig\.|图)(\d+)$/, Za = (e) => {
2409
+ const n = k.getState().editorLanguage === "en" ? "Fig." : "图", r = ke(e);
2350
2410
  if (r.length === 0) return;
2351
2411
  const a = [];
2352
2412
  let s = 1;
2353
- for (const l of r) {
2354
- const c = Z(l.node.attrs.id);
2355
- if (!Xa.exec(c)) continue;
2413
+ for (const c of r) {
2414
+ const l = Z(c.node.attrs.id);
2415
+ if (!Ya.exec(l)) continue;
2356
2416
  const o = `${n}${s}`;
2357
- c !== o && a.push({ pos: l.pos, expectedId: o, currentId: c }), s++;
2417
+ l !== o && a.push({ pos: c.pos, expectedId: o, currentId: l }), s++;
2358
2418
  }
2359
2419
  if (a.length === 0) return;
2360
2420
  const { tr: i } = e.state;
2361
- for (const l of a) {
2362
- const c = i.doc.nodeAt(l.pos);
2363
- !c || c.type.name !== "figure" || i.setNodeMarkup(l.pos, void 0, { ...c.attrs, id: l.expectedId });
2421
+ for (const c of a) {
2422
+ const l = i.doc.nodeAt(c.pos);
2423
+ !l || l.type.name !== "figure" || i.setNodeMarkup(c.pos, void 0, { ...l.attrs, id: c.expectedId });
2364
2424
  }
2365
2425
  i.steps.length > 0 && (i.setMeta("addToHistory", !1), e.view.dispatch(i));
2366
- }, je = (e) => {
2426
+ }, qe = (e) => {
2367
2427
  if (!Array.isArray(e))
2368
2428
  return [];
2369
2429
  const t = e.map((n) => Number(n)).filter((n) => Number.isFinite(n) && n > 0);
2370
2430
  return Array.from(new Set(t)).sort((n, r) => n - r);
2371
- }, nt = (e) => {
2431
+ }, rt = (e) => {
2372
2432
  if (!Array.isArray(e))
2373
2433
  return [];
2374
2434
  const t = e.map((n) => typeof n == "string" ? n.trim() : "").filter(Boolean);
2375
2435
  return Array.from(new Set(t));
2376
- }, Mt = (e, t) => {
2436
+ }, $t = (e, t) => {
2377
2437
  if (e.length !== t.length)
2378
2438
  return !1;
2379
2439
  for (let n = 0; n < e.length; n += 1)
2380
2440
  if (e[n] !== t[n])
2381
2441
  return !1;
2382
2442
  return !0;
2383
- }, mt = (e, t, n, r, a) => {
2443
+ }, ft = (e, t, n, r, a) => {
2384
2444
  const s = U(e);
2385
2445
  return a ? t === "figure" ? s.invalidFigureReference : s.invalidClaimReference : t === "figure" ? r || (e === "en" ? "Figure ?" : "附图?") : typeof n != "number" ? s.invalidClaimReference : s.claimLabel(n);
2386
- }, Ge = () => N.getState().editorLanguage === "en" ? "en" : "zh", Ya = (e) => {
2387
- const t = [], n = Ge(), r = new Map(e.map((d) => [d.claimId, d.number]));
2446
+ }, Ke = () => k.getState().editorLanguage === "en" ? "en" : "zh", es = (e) => {
2447
+ const t = [], n = Ke(), r = new Map(e.map((d) => [d.claimId, d.number]));
2388
2448
  e.forEach((d) => {
2389
2449
  d.dependsOnClaimIds.forEach((o) => {
2390
2450
  const u = r.get(o);
@@ -2402,16 +2462,16 @@ const Fe = () => {
2402
2462
  });
2403
2463
  });
2404
2464
  });
2405
- const a = new Map(e.map((d) => [d.claimId, d.dependsOnClaimIds])), s = /* @__PURE__ */ new Set(), i = /* @__PURE__ */ new Set(), l = /* @__PURE__ */ new Set(), c = (d) => {
2465
+ const a = new Map(e.map((d) => [d.claimId, d.dependsOnClaimIds])), s = /* @__PURE__ */ new Set(), i = /* @__PURE__ */ new Set(), c = /* @__PURE__ */ new Set(), l = (d) => {
2406
2466
  if (i.has(d)) {
2407
- l.add(d);
2467
+ c.add(d);
2408
2468
  return;
2409
2469
  }
2410
2470
  if (s.has(d))
2411
2471
  return;
2412
- s.add(d), i.add(d), (a.get(d) || []).forEach((u) => c(u)), i.delete(d);
2472
+ s.add(d), i.add(d), (a.get(d) || []).forEach((u) => l(u)), i.delete(d);
2413
2473
  };
2414
- return e.forEach((d) => c(d.claimId)), l.forEach((d) => {
2474
+ return e.forEach((d) => l(d.claimId)), c.forEach((d) => {
2415
2475
  const o = e.find((u) => u.claimId === d);
2416
2476
  o && t.push({
2417
2477
  claimId: d,
@@ -2422,36 +2482,36 @@ const Fe = () => {
2422
2482
  }), t;
2423
2483
  }, ie = (e) => {
2424
2484
  const t = fe(e), n = /* @__PURE__ */ new Set(), r = t.map((o, u) => {
2425
- const m = typeof o.node.attrs.claimId == "string" ? o.node.attrs.claimId : "", h = m && !n.has(m) ? m : mn();
2485
+ const m = typeof o.node.attrs.claimId == "string" ? o.node.attrs.claimId : "", h = m && !n.has(m) ? m : fn();
2426
2486
  return n.add(h), { pos: o.pos, node: o.node, claimId: h, number: u + 1 };
2427
2487
  }), a = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map();
2428
2488
  r.forEach((o) => {
2429
2489
  a.set(o.number, o.claimId), s.set(o.claimId, o.number);
2430
2490
  });
2431
2491
  const i = r.map((o) => {
2432
- const u = nt(o.node.attrs.dependsOnClaimIds), h = je(o.node.attrs.dependsOn).map((C) => a.get(C)).filter((C) => typeof C == "string"), f = (u.length > 0 ? u : h).filter((C, v, S) => S.indexOf(C) === v).filter((C) => C !== o.claimId && s.has(C)), y = f.map((C) => s.get(C)).filter((C) => typeof C == "number").sort((C, v) => C - v), w = {
2492
+ const u = rt(o.node.attrs.dependsOnClaimIds), h = qe(o.node.attrs.dependsOn).map((y) => a.get(y)).filter((y) => typeof y == "string"), f = (u.length > 0 ? u : h).filter((y, v, x) => x.indexOf(y) === v).filter((y) => y !== o.claimId && s.has(y)), C = f.map((y) => s.get(y)).filter((y) => typeof y == "number").sort((y, v) => y - v), w = {
2433
2493
  ...o.node.attrs,
2434
2494
  claimId: o.claimId,
2435
2495
  number: o.number,
2436
- dependsOn: y,
2496
+ dependsOn: C,
2437
2497
  dependsOnClaimIds: f
2438
2498
  };
2439
2499
  return { claimId: o.claimId, number: o.number, dependsOnClaimIds: f, pos: o.pos, attrs: w };
2440
- }), l = Ya(i), c = e.commands.command(({ tr: o, dispatch: u }) => {
2500
+ }), c = es(i), l = e.commands.command(({ tr: o, dispatch: u }) => {
2441
2501
  let m = !1;
2442
2502
  return i.forEach((h) => {
2443
2503
  const p = e.state.doc.nodeAt(h.pos);
2444
2504
  if (!p || p.type.name !== "claim")
2445
2505
  return;
2446
2506
  const f = { ...h.attrs };
2447
- (p.attrs.number !== f.number || p.attrs.claimId !== f.claimId || !Mt(je(p.attrs.dependsOn), je(f.dependsOn)) || !Mt(
2448
- nt(p.attrs.dependsOnClaimIds),
2449
- nt(f.dependsOnClaimIds)
2507
+ (p.attrs.number !== f.number || p.attrs.claimId !== f.claimId || !$t(qe(p.attrs.dependsOn), qe(f.dependsOn)) || !$t(
2508
+ rt(p.attrs.dependsOnClaimIds),
2509
+ rt(f.dependsOnClaimIds)
2450
2510
  )) && (o.setNodeMarkup(h.pos, void 0, f), m = !0);
2451
2511
  }), m && u && u(o), !0;
2452
- }), d = l.map((o) => `${o.claimId}:${o.code}`).join("|");
2453
- return d !== V.lastClaimGraphSignature && (V.lastClaimGraphSignature = d, V.claimGraphHandler && V.claimGraphHandler({ issues: l }), l.length > 0 && console.warn(`Claim graph validation found ${l.length} issue(s).`)), c;
2454
- }, fn = (e) => {
2512
+ }), d = c.map((o) => `${o.claimId}:${o.code}`).join("|");
2513
+ return d !== V.lastClaimGraphSignature && (V.lastClaimGraphSignature = d, V.claimGraphHandler && V.claimGraphHandler({ issues: c }), c.length > 0 && console.warn(`Claim graph validation found ${c.length} issue(s).`)), l;
2514
+ }, gn = (e) => {
2455
2515
  const t = /* @__PURE__ */ new Map();
2456
2516
  return fe(e).forEach((n) => {
2457
2517
  const r = typeof n.node.attrs.claimId == "string" ? n.node.attrs.claimId : "", a = Number(n.node.attrs.number);
@@ -2461,9 +2521,9 @@ const Fe = () => {
2461
2521
  pos: n.pos
2462
2522
  });
2463
2523
  }), t;
2464
- }, gn = (e) => {
2524
+ }, pn = (e) => {
2465
2525
  const t = /* @__PURE__ */ new Map();
2466
- return Ne(e).forEach((n) => {
2526
+ return ke(e).forEach((n) => {
2467
2527
  const r = Z(n.node.attrs.id);
2468
2528
  r && t.set(r, {
2469
2529
  id: r,
@@ -2471,49 +2531,49 @@ const Fe = () => {
2471
2531
  });
2472
2532
  }), t;
2473
2533
  }, Q = (e) => {
2474
- const t = fn(e), n = gn(e), r = [], a = Ge();
2475
- if (!e.commands.command(({ tr: l, state: c, dispatch: d }) => {
2534
+ const t = gn(e), n = pn(e), r = [], a = Ke();
2535
+ if (!e.commands.command(({ tr: c, state: l, dispatch: d }) => {
2476
2536
  let o = !1;
2477
- return c.doc.descendants((u, m) => {
2537
+ return l.doc.descendants((u, m) => {
2478
2538
  if (u.type.name !== "reference")
2479
2539
  return !0;
2480
- const h = u.attrs.targetType === "figure" ? "figure" : "claim", p = typeof u.attrs.targetClaimId == "string" && u.attrs.targetClaimId ? u.attrs.targetClaimId : null, f = typeof u.attrs.targetFigureId == "string" && u.attrs.targetFigureId ? Z(u.attrs.targetFigureId) : null, y = h === "claim" && p ? t.get(p) : void 0, w = h === "figure" && f ? n.get(f) : void 0, C = y ? y.number : null, v = w ? w.id : null, S = h === "figure" ? !w : !y, _ = mt(a, h, C, v, S), L = h === "figure" ? v || u.attrs.target || f || null : y ? String(y.number) : u.attrs.target || p || null, P = {
2540
+ const h = u.attrs.targetType === "figure" ? "figure" : "claim", p = typeof u.attrs.targetClaimId == "string" && u.attrs.targetClaimId ? u.attrs.targetClaimId : null, f = typeof u.attrs.targetFigureId == "string" && u.attrs.targetFigureId ? Z(u.attrs.targetFigureId) : null, C = h === "claim" && p ? t.get(p) : void 0, w = h === "figure" && f ? n.get(f) : void 0, y = C ? C.number : null, v = w ? w.id : null, x = h === "figure" ? !w : !C, _ = ft(a, h, y, v, x), L = h === "figure" ? v || u.attrs.target || f || null : C ? String(C.number) : u.attrs.target || p || null, P = {
2481
2541
  ...u.attrs,
2482
2542
  targetType: h,
2483
2543
  targetClaimId: p,
2484
2544
  targetFigureId: f,
2485
- resolvedNumber: C,
2545
+ resolvedNumber: y,
2486
2546
  resolvedFigureId: v,
2487
- invalid: S,
2547
+ invalid: x,
2488
2548
  lang: a,
2489
2549
  displayText: _,
2490
2550
  target: L
2491
2551
  };
2492
2552
  return Object.keys(P).some(
2493
2553
  (T) => P[T] !== u.attrs[T]
2494
- ) && (l.setNodeMarkup(m, void 0, P), o = !0), S && r.push({ targetType: h, targetClaimId: p, targetFigureId: f, position: m }), !0;
2495
- }), o && d && d(l), !0;
2554
+ ) && (c.setNodeMarkup(m, void 0, P), o = !0), x && r.push({ targetType: h, targetClaimId: p, targetFigureId: f, position: m }), !0;
2555
+ }), o && d && d(c), !0;
2496
2556
  }))
2497
2557
  return !1;
2498
- const i = r.map((l) => `${l.position}:${l.targetType}:${l.targetClaimId || l.targetFigureId || "null"}`).join("|");
2499
- return i !== V.lastInvalidReferenceSignature && (V.lastInvalidReferenceSignature = i, r.forEach((l) => {
2500
- V.invalidReferenceHandler && V.invalidReferenceHandler(l);
2558
+ const i = r.map((c) => `${c.position}:${c.targetType}:${c.targetClaimId || c.targetFigureId || "null"}`).join("|");
2559
+ return i !== V.lastInvalidReferenceSignature && (V.lastInvalidReferenceSignature = i, r.forEach((c) => {
2560
+ V.invalidReferenceHandler && V.invalidReferenceHandler(c);
2501
2561
  })), !0;
2502
- }, Dt = (e) => {
2562
+ }, Ot = (e) => {
2503
2563
  const t = be(e, "claim"), n = t && typeof t.node.attrs.claimId == "string" ? t.node.attrs.claimId : null;
2504
2564
  return e.commands.command(({ tr: r, state: a, dispatch: s }) => {
2505
2565
  let i = !1;
2506
- return a.doc.descendants((l, c) => {
2507
- if (l.type.name !== "reference")
2566
+ return a.doc.descendants((c, l) => {
2567
+ if (c.type.name !== "reference")
2508
2568
  return !0;
2509
- const d = l.attrs.targetType !== "figure" && !!n && l.attrs.targetClaimId === n && !l.attrs.invalid;
2510
- return l.attrs.highlight !== d && (r.setNodeMarkup(c, void 0, { ...l.attrs, highlight: d }), i = !0), !0;
2569
+ const d = c.attrs.targetType !== "figure" && !!n && c.attrs.targetClaimId === n && !c.attrs.invalid;
2570
+ return c.attrs.highlight !== d && (r.setNodeMarkup(l, void 0, { ...c.attrs, highlight: d }), i = !0), !0;
2511
2571
  }), i && s && s(r), !0;
2512
2572
  });
2513
- }, Za = (e) => {
2514
- const t = fe(e).map((r) => ({ pos: r.pos, length: r.node.textContent.length })).filter((r) => r.length > Pt), n = t.map((r) => `${r.pos}:${r.length}`).join("|");
2515
- n !== V.lastClaimWarningSignature && (V.lastClaimWarningSignature = n, t.length !== 0 && console.warn(`Claim content is too long for ${t.length} block(s). Suggested max: ${Pt}.`));
2516
- }, rt = (e, t) => {
2573
+ }, ts = (e) => {
2574
+ const t = fe(e).map((r) => ({ pos: r.pos, length: r.node.textContent.length })).filter((r) => r.length > Dt), n = t.map((r) => `${r.pos}:${r.length}`).join("|");
2575
+ n !== V.lastClaimWarningSignature && (V.lastClaimWarningSignature = n, t.length !== 0 && console.warn(`Claim content is too long for ${t.length} block(s). Suggested max: ${Dt}.`));
2576
+ }, at = (e, t) => {
2517
2577
  if (typeof t == "number")
2518
2578
  return t;
2519
2579
  const n = be(e, "claim");
@@ -2521,16 +2581,16 @@ const Fe = () => {
2521
2581
  return n.pos;
2522
2582
  const r = fe(e)[0];
2523
2583
  return r ? r.pos : null;
2524
- }, es = (e, t, n) => e.commands.command(({ tr: r, state: a, dispatch: s }) => {
2584
+ }, ns = (e, t, n) => e.commands.command(({ tr: r, state: a, dispatch: s }) => {
2525
2585
  const i = a.doc.nodeAt(t);
2526
2586
  if (!i || i.type.name !== "claim")
2527
2587
  return !1;
2528
- const l = t + 1, c = t + i.nodeSize - 1;
2529
- return n.trim().length === 0 ? r.delete(l, c) : r.replaceWith(l, c, a.schema.text(n)), s && s(r), !0;
2530
- }), ts = {
2588
+ const c = t + 1, l = t + i.nodeSize - 1;
2589
+ return n.trim().length === 0 ? r.delete(c, l) : r.replaceWith(c, l, a.schema.text(n)), s && s(r), !0;
2590
+ }), rs = {
2531
2591
  name: "patent",
2532
2592
  version: "1.0.0",
2533
- extensions: [Da, Fa, za, Ua, ja],
2593
+ extensions: [Oa, Ba, Ha, Wa, qa],
2534
2594
  toolbarItems: [
2535
2595
  {
2536
2596
  id: "patent-claim-insert",
@@ -2560,52 +2620,52 @@ const Fe = () => {
2560
2620
  execute: ({ editor: e }, t) => {
2561
2621
  const n = typeof t == "object" && t ? t : {}, r = n.placement || "current", a = typeof n.text == "string" ? n.text : "", s = fe(e).length, i = {
2562
2622
  number: n.number || s + 1,
2563
- claimId: mn(),
2623
+ claimId: fn(),
2564
2624
  dependsOn: [],
2565
2625
  dependsOnClaimIds: []
2566
- }, l = a ? [{ type: "text", text: a }] : [];
2567
- let c;
2626
+ }, c = a ? [{ type: "text", text: a }] : [];
2627
+ let l;
2568
2628
  if (r === "end") {
2569
2629
  const o = fe(e).at(-1), u = o ? o.pos + o.node.nodeSize : e.state.doc.content.size;
2570
- c = qe(e, { type: "claim", position: u, attrs: i, content: l });
2630
+ l = Ve(e, { type: "claim", position: u, attrs: i, content: c });
2571
2631
  } else
2572
- c = qe(e, { type: "claim", attrs: i, content: l });
2573
- return !c || !ie(e) ? !1 : Q(e);
2632
+ l = Ve(e, { type: "claim", attrs: i, content: c });
2633
+ return !l || !ie(e) ? !1 : Q(e);
2574
2634
  }
2575
2635
  },
2576
2636
  updateClaim: {
2577
2637
  description: "Update claim attrs and content",
2578
2638
  category: "patent",
2579
2639
  execute: ({ editor: e }, t) => {
2580
- const n = typeof t == "object" && t ? t : {}, r = rt(e, n.position);
2640
+ const n = typeof t == "object" && t ? t : {}, r = at(e, n.position);
2581
2641
  if (typeof r != "number")
2582
2642
  return !1;
2583
2643
  const a = {};
2584
- return typeof n.number == "number" && (a.number = n.number), !(Object.keys(a).length === 0 ? !0 : pe(e, { type: "claim", position: r, attrs: a })) || !(typeof n.text == "string" ? es(e, r, n.text) : !0) || !ie(e) ? !1 : Q(e);
2644
+ return typeof n.number == "number" && (a.number = n.number), !(Object.keys(a).length === 0 ? !0 : pe(e, { type: "claim", position: r, attrs: a })) || !(typeof n.text == "string" ? ns(e, r, n.text) : !0) || !ie(e) ? !1 : Q(e);
2585
2645
  }
2586
2646
  },
2587
2647
  setClaimDependency: {
2588
2648
  description: "Set claim dependency and regenerate prefix",
2589
2649
  category: "patent",
2590
2650
  execute: ({ editor: e }, t) => {
2591
- const n = typeof t == "object" && t ? t : {}, r = rt(e, n.position);
2651
+ const n = typeof t == "object" && t ? t : {}, r = at(e, n.position);
2592
2652
  if (typeof r != "number")
2593
2653
  return !1;
2594
2654
  const a = e.state.doc.nodeAt(r);
2595
2655
  if (!a || a.type.name !== "claim")
2596
2656
  return !1;
2597
- const s = Number(a.attrs.number), i = typeof a.attrs.claimId == "string" ? a.attrs.claimId : "", l = /* @__PURE__ */ new Map();
2657
+ const s = Number(a.attrs.number), i = typeof a.attrs.claimId == "string" ? a.attrs.claimId : "", c = /* @__PURE__ */ new Map();
2598
2658
  fe(e).forEach((m) => {
2599
2659
  const h = Number(m.node.attrs.number), p = typeof m.node.attrs.claimId == "string" ? m.node.attrs.claimId : "";
2600
- Number.isFinite(h) && h > 0 && p && l.set(h, p);
2660
+ Number.isFinite(h) && h > 0 && p && c.set(h, p);
2601
2661
  });
2602
- const c = je(n.dependsOn).filter(
2662
+ const l = qe(n.dependsOn).filter(
2603
2663
  (m) => Number.isFinite(s) && m > 0 && m < s
2604
- ), d = c.map((m) => l.get(m)).filter((m) => typeof m == "string" && m.length > 0 && m !== i);
2664
+ ), d = l.map((m) => c.get(m)).filter((m) => typeof m == "string" && m.length > 0 && m !== i);
2605
2665
  return !pe(e, {
2606
2666
  type: "claim",
2607
2667
  position: r,
2608
- attrs: { dependsOn: c, dependsOnClaimIds: d }
2668
+ attrs: { dependsOn: l, dependsOnClaimIds: d }
2609
2669
  }) || !ie(e) ? !1 : Q(e);
2610
2670
  }
2611
2671
  },
@@ -2617,14 +2677,14 @@ const Fe = () => {
2617
2677
  if (!(n != null && n.lang))
2618
2678
  return !1;
2619
2679
  const r = n.lang === "en" ? "en" : "zh";
2620
- N.getState().setEditorLanguage(r);
2680
+ k.getState().setEditorLanguage(r);
2621
2681
  const s = (n.scope || "all") === "current" ? be(e, "reference") : null;
2622
- return e.commands.command(({ tr: l, state: c, dispatch: d }) => {
2682
+ return e.commands.command(({ tr: c, state: l, dispatch: d }) => {
2623
2683
  let o = !1;
2624
- return c.doc.descendants((u, m) => (u.type.name !== "reference" || s && m !== s.pos || u.attrs.lang !== r && (l.setNodeMarkup(m, void 0, {
2684
+ return l.doc.descendants((u, m) => (u.type.name !== "reference" || s && m !== s.pos || u.attrs.lang !== r && (c.setNodeMarkup(m, void 0, {
2625
2685
  ...u.attrs,
2626
2686
  lang: r
2627
- }), o = !0), !0)), o && d && d(l), !0;
2687
+ }), o = !0), !0)), o && d && d(c), !0;
2628
2688
  }) ? Q(e) : !1;
2629
2689
  }
2630
2690
  },
@@ -2637,8 +2697,8 @@ const Fe = () => {
2637
2697
  description: "Delete claim node and reorder numbers",
2638
2698
  category: "patent",
2639
2699
  execute: ({ editor: e }, t) => {
2640
- const r = rt(e, (typeof t == "object" && t ? t : {}).position);
2641
- return typeof r != "number" || !yt(e, { type: "claim", position: r }) || !ie(e) ? !1 : Q(e);
2700
+ const r = at(e, (typeof t == "object" && t ? t : {}).position);
2701
+ return typeof r != "number" || !vt(e, { type: "claim", position: r }) || !ie(e) ? !1 : Q(e);
2642
2702
  }
2643
2703
  },
2644
2704
  reorderClaims: {
@@ -2657,7 +2717,7 @@ const Fe = () => {
2657
2717
  shortcut: "Ctrl+Shift+F",
2658
2718
  isActive: ({ editor: e }) => e.isActive("figure"),
2659
2719
  execute: ({ editor: e }, t) => {
2660
- const n = typeof t == "object" && t ? t : {}, r = Z(n.id) || Rt(e), a = n.contentType && ["image", "mermaid", "drawio"].includes(n.contentType) ? n.contentType : "image";
2720
+ const n = typeof t == "object" && t ? t : {}, r = Z(n.id) || Mt(e), a = n.contentType && ["image", "mermaid", "drawio"].includes(n.contentType) ? n.contentType : "image";
2661
2721
  return e.chain().focus().insertContent({
2662
2722
  type: "figure",
2663
2723
  attrs: { id: r, contentType: a, imageSrc: "", mermaidCode: "", drawioXml: "" },
@@ -2675,10 +2735,10 @@ const Fe = () => {
2675
2735
  const s = e.state.doc.nodeAt(a);
2676
2736
  if (!s || s.type.name !== "figure")
2677
2737
  return !1;
2678
- const l = (typeof n.id == "string" ? Z(n.id) : Z(s.attrs.id)) || Rt(e);
2679
- if (Ne(e).some((o) => o.pos === a ? !1 : Z(o.node.attrs.id) === l))
2738
+ const c = (typeof n.id == "string" ? Z(n.id) : Z(s.attrs.id)) || Mt(e);
2739
+ if (ke(e).some((o) => o.pos === a ? !1 : Z(o.node.attrs.id) === c))
2680
2740
  return !1;
2681
- const d = { id: l };
2741
+ const d = { id: c };
2682
2742
  return typeof n.contentType == "string" && ["image", "mermaid", "drawio"].includes(n.contentType) && (d.contentType = n.contentType), typeof n.imageSrc == "string" && (d.imageSrc = n.imageSrc), typeof n.mermaidCode == "string" && (d.mermaidCode = n.mermaidCode), typeof n.drawioXml == "string" && (d.drawioXml = n.drawioXml), pe(e, {
2683
2743
  type: "figure",
2684
2744
  position: a,
@@ -2692,7 +2752,7 @@ const Fe = () => {
2692
2752
  execute: ({ editor: e }) => {
2693
2753
  const t = /* @__PURE__ */ new Set();
2694
2754
  let n = !1;
2695
- return Ne(e).forEach((r) => {
2755
+ return ke(e).forEach((r) => {
2696
2756
  const a = Z(r.node.attrs.id);
2697
2757
  if (a) {
2698
2758
  if (t.has(a)) {
@@ -2716,13 +2776,13 @@ const Fe = () => {
2716
2776
  return typeof n.targetClaimId == "string" && n.targetClaimId.trim().length > 0;
2717
2777
  },
2718
2778
  execute: ({ editor: e }, t) => {
2719
- const n = typeof t == "object" && t ? t : {}, r = fn(e), a = typeof n.targetClaimId == "string" ? n.targetClaimId.trim() : "";
2779
+ const n = typeof t == "object" && t ? t : {}, r = gn(e), a = typeof n.targetClaimId == "string" ? n.targetClaimId.trim() : "";
2720
2780
  if (!a)
2721
2781
  return !1;
2722
2782
  const s = r.get(a);
2723
2783
  if (!s)
2724
2784
  return !1;
2725
- const i = s.number, l = n.lang || Ge(), c = n.displayText || mt(l, "claim", i, null, !1);
2785
+ const i = s.number, c = n.lang || Ke(), l = n.displayText || ft(c, "claim", i, null, !1);
2726
2786
  return e.chain().focus().insertContent({
2727
2787
  type: "reference",
2728
2788
  attrs: {
@@ -2731,9 +2791,9 @@ const Fe = () => {
2731
2791
  targetFigureId: null,
2732
2792
  resolvedNumber: i,
2733
2793
  resolvedFigureId: null,
2734
- lang: l,
2794
+ lang: c,
2735
2795
  invalid: !1,
2736
- displayText: c,
2796
+ displayText: l,
2737
2797
  target: n.target || String(i),
2738
2798
  highlight: !1
2739
2799
  }
@@ -2752,13 +2812,13 @@ const Fe = () => {
2752
2812
  return typeof n.targetFigureId == "string" && n.targetFigureId.trim().length > 0;
2753
2813
  },
2754
2814
  execute: ({ editor: e }, t) => {
2755
- const n = typeof t == "object" && t ? t : {}, r = gn(e), a = typeof n.targetFigureId == "string" ? Z(n.targetFigureId) : "";
2815
+ const n = typeof t == "object" && t ? t : {}, r = pn(e), a = typeof n.targetFigureId == "string" ? Z(n.targetFigureId) : "";
2756
2816
  if (!a)
2757
2817
  return !1;
2758
2818
  const s = r.get(a);
2759
2819
  if (!s)
2760
2820
  return !1;
2761
- const i = n.lang || Ge(), l = n.displayText || mt(i, "figure", null, s.id, !1);
2821
+ const i = n.lang || Ke(), c = n.displayText || ft(i, "figure", null, s.id, !1);
2762
2822
  return e.chain().focus().insertContent({
2763
2823
  type: "reference",
2764
2824
  attrs: {
@@ -2769,7 +2829,7 @@ const Fe = () => {
2769
2829
  resolvedFigureId: s.id,
2770
2830
  lang: i,
2771
2831
  invalid: !1,
2772
- displayText: l,
2832
+ displayText: c,
2773
2833
  target: n.target || s.id,
2774
2834
  highlight: !1
2775
2835
  }
@@ -2782,14 +2842,14 @@ const Fe = () => {
2782
2842
  execute: ({ editor: e }, t) => {
2783
2843
  const n = typeof t == "object" && t ? t : null;
2784
2844
  return !(n != null && n.targetClaimId) || !e.commands.command(({ tr: a, state: s, dispatch: i }) => {
2785
- let l = !1;
2786
- return s.doc.descendants((c, d) => (c.type.name !== "reference" || !c.attrs.invalid || (a.setNodeMarkup(d, void 0, {
2787
- ...c.attrs,
2845
+ let c = !1;
2846
+ return s.doc.descendants((l, d) => (l.type.name !== "reference" || !l.attrs.invalid || (a.setNodeMarkup(d, void 0, {
2847
+ ...l.attrs,
2788
2848
  targetType: "claim",
2789
2849
  targetClaimId: n.targetClaimId,
2790
2850
  targetFigureId: null,
2791
2851
  invalid: !1
2792
- }), l = !0), !0)), l && i && i(a), l;
2852
+ }), c = !0), !0)), c && i && i(a), c;
2793
2853
  }) ? !1 : Q(e);
2794
2854
  }
2795
2855
  },
@@ -2807,7 +2867,7 @@ const Fe = () => {
2807
2867
  description: "Insert patent document skeleton with all sections",
2808
2868
  category: "patent",
2809
2869
  execute: ({ editor: e }, t) => {
2810
- const n = typeof t == "object" && t ? t : {}, r = n.patentType === "utility_model" ? "utility_model" : n.patentType === "design" ? "design" : "invention", a = un(r);
2870
+ const n = typeof t == "object" && t ? t : {}, r = n.patentType === "utility_model" ? "utility_model" : n.patentType === "design" ? "design" : "invention", a = mn(r);
2811
2871
  return e.commands.setContent(a);
2812
2872
  }
2813
2873
  },
@@ -2827,16 +2887,16 @@ const Fe = () => {
2827
2887
  }
2828
2888
  },
2829
2889
  onStateChange: (e) => {
2830
- ie(e) && (Q(e), Dt(e), Za(e), Qa(e));
2890
+ ie(e) && (Q(e), Ot(e), ts(e), Za(e));
2831
2891
  },
2832
2892
  onSelectionChange: (e) => {
2833
- Dt(e);
2893
+ Ot(e);
2834
2894
  }
2835
- }, ns = [Ia, Na, Aa, ts];
2836
- ns.forEach((e) => W.register(e));
2837
- const rs = (e = {}) => {
2895
+ }, as = [Ea, ka, La, rs];
2896
+ as.forEach((e) => W.register(e));
2897
+ const ss = (e = {}) => {
2838
2898
  const t = [
2839
- ...wa,
2899
+ ...xa,
2840
2900
  ...W.getExtensions(),
2841
2901
  ...e.extensions || []
2842
2902
  ];
@@ -2844,40 +2904,40 @@ const rs = (e = {}) => {
2844
2904
  ...e,
2845
2905
  extensions: t
2846
2906
  };
2847
- }, at = (e) => {
2907
+ }, st = (e) => {
2848
2908
  const { from: t, to: n } = e.state.selection;
2849
2909
  return {
2850
2910
  editor: e,
2851
2911
  selection: { from: t, to: n },
2852
- store: N.getState()
2912
+ store: k.getState()
2853
2913
  };
2854
- }, Ye = (e) => ({
2855
- execCommand: (t, n, r) => W.executeCommand(t, at(e), n, r),
2856
- canExecCommand: (t, n) => W.canExecuteCommand(t, at(e), n),
2857
- isCommandActive: (t) => W.isCommandActive(t, at(e)),
2914
+ }, Ae = (e) => ({
2915
+ execCommand: (t, n, r) => W.executeCommand(t, st(e), n, r),
2916
+ canExecCommand: (t, n) => W.canExecuteCommand(t, st(e), n),
2917
+ isCommandActive: (t) => W.isCommandActive(t, st(e)),
2858
2918
  listCommands: () => W.getCommandNames(),
2859
- insertNode: (t) => qe(e, t),
2919
+ insertNode: (t) => Ve(e, t),
2860
2920
  updateNodeAttrs: (t) => pe(e, t),
2861
- removeNode: (t) => yt(e, t),
2862
- wrapSelection: (t) => ln(e, t),
2921
+ removeNode: (t) => vt(e, t),
2922
+ wrapSelection: (t) => dn(e, t),
2863
2923
  applyTransactionBatch: (t) => Ma(e, t),
2864
- findNodeByType: (t, n) => ht(e, t, n),
2924
+ findNodeByType: (t, n) => bt(e, t, n),
2865
2925
  findAncestorNode: (t) => be(e, t),
2866
- findCurrentBlock: () => La(e),
2867
- findNodesByPredicate: (t, n) => bt(e, t, n)
2868
- }), as = /* @__PURE__ */ new Set([
2926
+ findCurrentBlock: () => Pa(e),
2927
+ findNodesByPredicate: (t, n) => yt(e, t, n)
2928
+ }), is = /* @__PURE__ */ new Set([
2869
2929
  "abstract",
2870
2930
  "abstract_drawing",
2871
2931
  "claims",
2872
2932
  "drawing_figures"
2873
- ]), ss = /* @__PURE__ */ new Set([
2933
+ ]), os = /* @__PURE__ */ new Set([
2874
2934
  "technical_field",
2875
2935
  "background_art",
2876
2936
  "summary",
2877
2937
  "drawing_description",
2878
2938
  "detailed_description"
2879
2939
  ]);
2880
- function is(e, t) {
2940
+ function cs(e, t) {
2881
2941
  const n = U(t), r = [];
2882
2942
  return e.state.doc.descendants((a) => {
2883
2943
  if (a.type.name === "patent_title") {
@@ -2890,76 +2950,76 @@ function is(e, t) {
2890
2950
  }), !1;
2891
2951
  }
2892
2952
  if (a.type.name === "patent_section") {
2893
- const s = a.attrs.sectionType, i = `sectionTitle_${s}`, l = typeof n[i] == "string" ? n[i] : s, c = [];
2953
+ const s = a.attrs.sectionType, i = `sectionTitle_${s}`, c = typeof n[i] == "string" ? n[i] : s, l = [];
2894
2954
  return a.forEach((d) => {
2895
2955
  const o = d.textContent.trim();
2896
- o && c.push(o);
2897
- }), r.push({ type: "patent_section", sectionType: s, title: l, paragraphs: c }), !1;
2956
+ o && l.push(o);
2957
+ }), r.push({ type: "patent_section", sectionType: s, title: c, paragraphs: l }), !1;
2898
2958
  }
2899
2959
  return !0;
2900
2960
  }), r;
2901
2961
  }
2902
- function $t(e) {
2903
- return new Je({
2904
- children: [new Xe({ text: e, bold: !0, size: 32, font: "黑体" })],
2905
- alignment: pt.CENTER,
2962
+ function Ft(e) {
2963
+ return new Qe({
2964
+ children: [new Ye({ text: e, bold: !0, size: 32, font: "黑体" })],
2965
+ alignment: ht.CENTER,
2906
2966
  spacing: { before: 400, after: 200 }
2907
2967
  });
2908
2968
  }
2909
- function Ot(e) {
2910
- return new Je({
2911
- children: [new Xe({ text: e, bold: !0, size: 28, font: "黑体" })],
2912
- alignment: pt.CENTER,
2969
+ function zt(e) {
2970
+ return new Qe({
2971
+ children: [new Ye({ text: e, bold: !0, size: 28, font: "黑体" })],
2972
+ alignment: ht.CENTER,
2913
2973
  spacing: { before: 240, after: 120 }
2914
2974
  });
2915
2975
  }
2916
- function os(e) {
2917
- return new Je({
2918
- children: [new Xe({ text: e, bold: !0, size: 36, font: "宋体" })],
2919
- alignment: pt.CENTER,
2976
+ function ls(e) {
2977
+ return new Qe({
2978
+ children: [new Ye({ text: e, bold: !0, size: 36, font: "宋体" })],
2979
+ alignment: ht.CENTER,
2920
2980
  spacing: { before: 200, after: 200 }
2921
2981
  });
2922
2982
  }
2923
- function st(e) {
2924
- return new Je({
2925
- children: [new Xe({ text: e, size: 24, font: "宋体" })],
2983
+ function it(e) {
2984
+ return new Qe({
2985
+ children: [new Ye({ text: e, size: 24, font: "宋体" })],
2926
2986
  spacing: { line: 360 },
2927
2987
  indent: { firstLine: Se(7) }
2928
2988
  });
2929
2989
  }
2930
- function cs(e, t) {
2990
+ function ds(e, t) {
2931
2991
  const n = U(t), r = [];
2932
2992
  let a = !1;
2933
2993
  for (const s of e) {
2934
- if (as.has(s.sectionType)) {
2935
- r.push($t(s.title));
2994
+ if (is.has(s.sectionType)) {
2995
+ r.push(Ft(s.title));
2936
2996
  for (const i of s.paragraphs)
2937
- r.push(st(i));
2997
+ r.push(it(i));
2938
2998
  continue;
2939
2999
  }
2940
3000
  if (s.type === "patent_title") {
2941
3001
  if (!a) {
2942
3002
  const i = typeof n.bookTitle_description == "string" ? n.bookTitle_description : "说明书";
2943
- r.push($t(i)), a = !0;
3003
+ r.push(Ft(i)), a = !0;
2944
3004
  }
2945
3005
  for (const i of s.paragraphs)
2946
- r.push(os(i));
3006
+ r.push(ls(i));
2947
3007
  continue;
2948
3008
  }
2949
- if (ss.has(s.sectionType)) {
2950
- r.push(Ot(s.title));
3009
+ if (os.has(s.sectionType)) {
3010
+ r.push(zt(s.title));
2951
3011
  for (const i of s.paragraphs)
2952
- r.push(st(i));
3012
+ r.push(it(i));
2953
3013
  continue;
2954
3014
  }
2955
- r.push(Ot(s.title));
3015
+ r.push(zt(s.title));
2956
3016
  for (const i of s.paragraphs)
2957
- r.push(st(i));
3017
+ r.push(it(i));
2958
3018
  }
2959
3019
  return r;
2960
3020
  }
2961
- async function Ft(e, t) {
2962
- const n = is(e, t), r = cs(n, t), a = n.find((d) => d.type === "patent_title"), s = a != null && a.paragraphs[0] ? `${a.paragraphs[0]}.docx` : "patent-document.docx", i = {
3021
+ async function Bt(e, t) {
3022
+ const n = cs(e, t), r = ds(n, t), a = n.find((d) => d.type === "patent_title"), s = a != null && a.paragraphs[0] ? `${a.paragraphs[0]}.docx` : "patent-document.docx", i = {
2963
3023
  properties: {
2964
3024
  page: {
2965
3025
  margin: {
@@ -2971,32 +3031,32 @@ async function Ft(e, t) {
2971
3031
  }
2972
3032
  },
2973
3033
  children: r
2974
- }, l = new Yr({
3034
+ }, c = new Zr({
2975
3035
  sections: [i]
2976
- }), c = await Zr.toBlob(l);
2977
- ea(c, s);
3036
+ }), l = await ea.toBlob(c);
3037
+ ta(l, s);
2978
3038
  }
2979
- async function ls(e) {
3039
+ async function us(e) {
2980
3040
  window.print();
2981
3041
  }
2982
- const ds = ["history", "text", "structure", "format", "technical", "patent"], it = (e) => e.split("_").map((t) => t.charAt(0).toUpperCase() + t.slice(1)).join(" "), ot = ({ btn: e, items: t }) => {
2983
- const [n, r] = z(!1), a = X(null), s = X(null), [i, l] = z({ top: 0, left: 0 }), c = de(() => {
3042
+ const ms = ["history", "text", "structure", "format", "technical", "patent"], ot = (e) => e.split("_").map((t) => t.charAt(0).toUpperCase() + t.slice(1)).join(" "), ct = ({ btn: e, items: t }) => {
3043
+ const [n, r] = z(!1), a = X(null), s = X(null), [i, c] = z({ top: 0, left: 0 }), l = de(() => {
2984
3044
  if (!a.current) return;
2985
3045
  const d = a.current.getBoundingClientRect();
2986
- l({ top: d.bottom + 4, left: d.left });
3046
+ c({ top: d.bottom + 4, left: d.left });
2987
3047
  }, []);
2988
3048
  return B(() => {
2989
3049
  if (!n) return;
2990
- c();
3050
+ l();
2991
3051
  const d = (u) => {
2992
3052
  var h, p;
2993
3053
  const m = u.target;
2994
3054
  (h = a.current) != null && h.contains(m) || (p = s.current) != null && p.contains(m) || r(!1);
2995
- }, o = () => c();
3055
+ }, o = () => l();
2996
3056
  return document.addEventListener("mousedown", d), window.addEventListener("scroll", o, !0), () => {
2997
3057
  document.removeEventListener("mousedown", d), window.removeEventListener("scroll", o, !0);
2998
3058
  };
2999
- }, [n, c]), /* @__PURE__ */ A("div", { className: "flex items-center", children: [
3059
+ }, [n, l]), /* @__PURE__ */ A("div", { className: "flex items-center", children: [
3000
3060
  /* @__PURE__ */ g(
3001
3061
  "button",
3002
3062
  {
@@ -3021,10 +3081,10 @@ const ds = ["history", "text", "structure", "format", "technical", "patent"], it
3021
3081
  e.disabled ? "text-gray-400 cursor-not-allowed bg-gray-100" : "hover:bg-gray-200 text-gray-500"
3022
3082
  ),
3023
3083
  disabled: e.disabled,
3024
- children: /* @__PURE__ */ g(tn, { size: 12 })
3084
+ children: /* @__PURE__ */ g(nn, { size: 12 })
3025
3085
  }
3026
3086
  ),
3027
- n && vr(
3087
+ n && Cr(
3028
3088
  /* @__PURE__ */ g(
3029
3089
  "div",
3030
3090
  {
@@ -3047,21 +3107,21 @@ const ds = ["history", "text", "structure", "format", "technical", "patent"], it
3047
3107
  document.body
3048
3108
  )
3049
3109
  ] });
3050
- }, us = ({
3110
+ }, fs = ({
3051
3111
  editor: e,
3052
- groupOrder: t = ds,
3112
+ groupOrder: t = ms,
3053
3113
  collapsibleGroups: n = !0,
3054
3114
  defaultCollapsedGroups: r = []
3055
3115
  }) => {
3056
- const [a, s] = z(() => new Set(r)), { editorLanguage: i, setEditorLanguage: l } = N(), c = U(i);
3116
+ const [a, s] = z(() => new Set(r)), { editorLanguage: i, setEditorLanguage: c } = k(), l = U(i);
3057
3117
  if (!e)
3058
3118
  return null;
3059
- const d = Ye(e), o = i === "zh", u = [
3119
+ const d = Ae(e), o = i === "zh", u = [
3060
3120
  {
3061
3121
  id: "core-undo",
3062
3122
  label: "Undo",
3063
3123
  group: "history",
3064
- icon: Cr,
3124
+ icon: wr,
3065
3125
  tooltip: "Undo (Ctrl+Z)",
3066
3126
  isActive: !1,
3067
3127
  disabled: !e.can().chain().focus().undo().run(),
@@ -3073,7 +3133,7 @@ const ds = ["history", "text", "structure", "format", "technical", "patent"], it
3073
3133
  id: "core-redo",
3074
3134
  label: "Redo",
3075
3135
  group: "history",
3076
- icon: wr,
3136
+ icon: xr,
3077
3137
  tooltip: "Redo (Ctrl+Y)",
3078
3138
  isActive: !1,
3079
3139
  disabled: !e.can().chain().focus().redo().run(),
@@ -3085,7 +3145,7 @@ const ds = ["history", "text", "structure", "format", "technical", "patent"], it
3085
3145
  id: "core-bold",
3086
3146
  label: "Bold",
3087
3147
  group: "text",
3088
- icon: Gt,
3148
+ icon: Vt,
3089
3149
  tooltip: "Bold",
3090
3150
  isActive: e.isActive("bold"),
3091
3151
  disabled: !1,
@@ -3097,7 +3157,7 @@ const ds = ["history", "text", "structure", "format", "technical", "patent"], it
3097
3157
  id: "core-italic",
3098
3158
  label: "Italic",
3099
3159
  group: "text",
3100
- icon: Vt,
3160
+ icon: Kt,
3101
3161
  tooltip: "Italic",
3102
3162
  isActive: e.isActive("italic"),
3103
3163
  disabled: !1,
@@ -3109,7 +3169,7 @@ const ds = ["history", "text", "structure", "format", "technical", "patent"], it
3109
3169
  id: "core-underline",
3110
3170
  label: "Underline",
3111
3171
  group: "text",
3112
- icon: Kt,
3172
+ icon: Jt,
3113
3173
  tooltip: "Underline",
3114
3174
  isActive: e.isActive("underline"),
3115
3175
  disabled: !1,
@@ -3121,7 +3181,7 @@ const ds = ["history", "text", "structure", "format", "technical", "patent"], it
3121
3181
  id: "core-strike",
3122
3182
  label: "Strike",
3123
3183
  group: "text",
3124
- icon: Jt,
3184
+ icon: Xt,
3125
3185
  tooltip: "Strike",
3126
3186
  isActive: e.isActive("strike"),
3127
3187
  disabled: !1,
@@ -3133,7 +3193,7 @@ const ds = ["history", "text", "structure", "format", "technical", "patent"], it
3133
3193
  id: "core-code",
3134
3194
  label: "Code",
3135
3195
  group: "text",
3136
- icon: Xt,
3196
+ icon: Qt,
3137
3197
  tooltip: "Code",
3138
3198
  isActive: e.isActive("code"),
3139
3199
  disabled: !1,
@@ -3145,7 +3205,7 @@ const ds = ["history", "text", "structure", "format", "technical", "patent"], it
3145
3205
  id: "core-superscript",
3146
3206
  label: "Superscript",
3147
3207
  group: "text",
3148
- icon: Qt,
3208
+ icon: Yt,
3149
3209
  tooltip: "Superscript (Ctrl+.)",
3150
3210
  isActive: e.isActive("superscript"),
3151
3211
  disabled: !1,
@@ -3157,7 +3217,7 @@ const ds = ["history", "text", "structure", "format", "technical", "patent"], it
3157
3217
  id: "core-subscript",
3158
3218
  label: "Subscript",
3159
3219
  group: "text",
3160
- icon: Yt,
3220
+ icon: Zt,
3161
3221
  tooltip: "Subscript (Ctrl+,)",
3162
3222
  isActive: e.isActive("subscript"),
3163
3223
  disabled: !1,
@@ -3169,7 +3229,7 @@ const ds = ["history", "text", "structure", "format", "technical", "patent"], it
3169
3229
  id: "core-paragraph",
3170
3230
  label: "Paragraph",
3171
3231
  group: "structure",
3172
- icon: xr,
3232
+ icon: Sr,
3173
3233
  tooltip: "Paragraph",
3174
3234
  isActive: e.isActive("paragraph"),
3175
3235
  disabled: !1,
@@ -3181,7 +3241,7 @@ const ds = ["history", "text", "structure", "format", "technical", "patent"], it
3181
3241
  id: "core-heading1",
3182
3242
  label: "H1",
3183
3243
  group: "structure",
3184
- icon: Sr,
3244
+ icon: Tr,
3185
3245
  tooltip: "Heading 1",
3186
3246
  isActive: e.isActive("heading", { level: 1 }),
3187
3247
  disabled: !1,
@@ -3193,7 +3253,7 @@ const ds = ["history", "text", "structure", "format", "technical", "patent"], it
3193
3253
  id: "core-heading2",
3194
3254
  label: "H2",
3195
3255
  group: "structure",
3196
- icon: Tr,
3256
+ icon: Ir,
3197
3257
  tooltip: "Heading 2",
3198
3258
  isActive: e.isActive("heading", { level: 2 }),
3199
3259
  disabled: !1,
@@ -3205,7 +3265,7 @@ const ds = ["history", "text", "structure", "format", "technical", "patent"], it
3205
3265
  id: "core-heading3",
3206
3266
  label: "H3",
3207
3267
  group: "structure",
3208
- icon: Ir,
3268
+ icon: Er,
3209
3269
  tooltip: "Heading 3",
3210
3270
  isActive: e.isActive("heading", { level: 3 }),
3211
3271
  disabled: !1,
@@ -3217,7 +3277,7 @@ const ds = ["history", "text", "structure", "format", "technical", "patent"], it
3217
3277
  id: "core-align-left",
3218
3278
  label: o ? "左对齐" : "Align Left",
3219
3279
  group: "format",
3220
- icon: Er,
3280
+ icon: Nr,
3221
3281
  tooltip: o ? "左对齐" : "Align Left",
3222
3282
  isActive: e.isActive({ textAlign: "left" }),
3223
3283
  disabled: !1,
@@ -3229,7 +3289,7 @@ const ds = ["history", "text", "structure", "format", "technical", "patent"], it
3229
3289
  id: "core-align-center",
3230
3290
  label: o ? "居中" : "Center",
3231
3291
  group: "format",
3232
- icon: Nr,
3292
+ icon: kr,
3233
3293
  tooltip: o ? "居中对齐" : "Align Center",
3234
3294
  isActive: e.isActive({ textAlign: "center" }),
3235
3295
  disabled: !1,
@@ -3241,7 +3301,7 @@ const ds = ["history", "text", "structure", "format", "technical", "patent"], it
3241
3301
  id: "core-align-right",
3242
3302
  label: o ? "右对齐" : "Align Right",
3243
3303
  group: "format",
3244
- icon: kr,
3304
+ icon: _r,
3245
3305
  tooltip: o ? "右对齐" : "Align Right",
3246
3306
  isActive: e.isActive({ textAlign: "right" }),
3247
3307
  disabled: !1,
@@ -3253,7 +3313,7 @@ const ds = ["history", "text", "structure", "format", "technical", "patent"], it
3253
3313
  id: "core-align-justify",
3254
3314
  label: o ? "两端对齐" : "Justify",
3255
3315
  group: "format",
3256
- icon: _r,
3316
+ icon: Ar,
3257
3317
  tooltip: o ? "两端对齐" : "Justify",
3258
3318
  isActive: e.isActive({ textAlign: "justify" }),
3259
3319
  disabled: !1,
@@ -3265,7 +3325,7 @@ const ds = ["history", "text", "structure", "format", "technical", "patent"], it
3265
3325
  id: "core-bullet-list",
3266
3326
  label: "Bullet List",
3267
3327
  group: "structure",
3268
- icon: Ar,
3328
+ icon: Lr,
3269
3329
  tooltip: "Bullet List",
3270
3330
  isActive: e.isActive("bulletList"),
3271
3331
  disabled: !1,
@@ -3277,7 +3337,7 @@ const ds = ["history", "text", "structure", "format", "technical", "patent"], it
3277
3337
  id: "core-ordered-list",
3278
3338
  label: "Ordered List",
3279
3339
  group: "structure",
3280
- icon: Lr,
3340
+ icon: Pr,
3281
3341
  tooltip: "Ordered List",
3282
3342
  isActive: e.isActive("orderedList"),
3283
3343
  disabled: !1,
@@ -3289,7 +3349,7 @@ const ds = ["history", "text", "structure", "format", "technical", "patent"], it
3289
3349
  id: "core-blockquote",
3290
3350
  label: "Blockquote",
3291
3351
  group: "structure",
3292
- icon: Pr,
3352
+ icon: Rr,
3293
3353
  tooltip: "Blockquote",
3294
3354
  isActive: e.isActive("blockquote"),
3295
3355
  disabled: !1,
@@ -3301,7 +3361,7 @@ const ds = ["history", "text", "structure", "format", "technical", "patent"], it
3301
3361
  id: "core-code-block",
3302
3362
  label: "Code Block",
3303
3363
  group: "structure",
3304
- icon: Rr,
3364
+ icon: Dr,
3305
3365
  tooltip: "Code Block",
3306
3366
  isActive: e.isActive("codeBlock"),
3307
3367
  disabled: !1,
@@ -3325,7 +3385,7 @@ const ds = ["history", "text", "structure", "format", "technical", "patent"], it
3325
3385
  id: "core-horizontal-rule",
3326
3386
  label: "Horizontal Rule",
3327
3387
  group: "structure",
3328
- icon: Dr,
3388
+ icon: $r,
3329
3389
  tooltip: "Horizontal Rule",
3330
3390
  isActive: !1,
3331
3391
  disabled: !1,
@@ -3337,7 +3397,7 @@ const ds = ["history", "text", "structure", "format", "technical", "patent"], it
3337
3397
  id: "core-task-list",
3338
3398
  label: "Task List",
3339
3399
  group: "structure",
3340
- icon: $r,
3400
+ icon: Or,
3341
3401
  tooltip: "Task List",
3342
3402
  isActive: e.isActive("taskList"),
3343
3403
  disabled: !1,
@@ -3346,24 +3406,24 @@ const ds = ["history", "text", "structure", "format", "technical", "patent"], it
3346
3406
  }
3347
3407
  }
3348
3408
  ], m = {
3349
- GitGraph: Hr,
3350
- Sigma: Br,
3351
- FunctionSquare: zr,
3352
- Workflow: Fr,
3353
- Box: Or,
3354
- FileText: en,
3355
- Link2: gt,
3356
- Image: Zt
3409
+ GitGraph: Ur,
3410
+ Sigma: Hr,
3411
+ FunctionSquare: Br,
3412
+ Workflow: zr,
3413
+ Box: Fr,
3414
+ FileText: tn,
3415
+ Link2: pt,
3416
+ Image: en
3357
3417
  }, h = W.getToolbarItems().map((b) => {
3358
- const T = W.getCommandMeta(b.command), k = b.tooltip || (T == null ? void 0 : T.description) || b.label, M = b.shortcut || (T == null ? void 0 : T.shortcut), D = M ? `${k} (${M})` : k;
3418
+ const T = W.getCommandMeta(b.command), E = b.tooltip || (T == null ? void 0 : T.description) || b.label, D = b.shortcut || (T == null ? void 0 : T.shortcut), M = D ? `${E} (${D})` : E;
3359
3419
  return {
3360
3420
  id: b.id,
3361
3421
  label: b.label,
3362
3422
  group: b.group || "technical",
3363
- icon: b.icon ? m[b.icon] || St : St,
3423
+ icon: b.icon ? m[b.icon] || Tt : Tt,
3364
3424
  isActive: d.isCommandActive(b.command),
3365
3425
  disabled: !d.canExecCommand(b.command),
3366
- tooltip: D,
3426
+ tooltip: M,
3367
3427
  run: () => {
3368
3428
  d.execCommand(b.command);
3369
3429
  }
@@ -3372,21 +3432,21 @@ const ds = ["history", "text", "structure", "format", "technical", "patent"], it
3372
3432
  id: "core-export",
3373
3433
  label: o ? "导出" : "Export",
3374
3434
  group: "patent",
3375
- icon: Ur,
3435
+ icon: jr,
3376
3436
  tooltip: o ? "导出文档" : "Export Document",
3377
3437
  isActive: !1,
3378
3438
  disabled: !1,
3379
- run: () => void Ft(e, i)
3439
+ run: () => void Bt(e, i)
3380
3440
  }, f = [
3381
- { label: o ? "导出 Word (.docx)" : "Export Word (.docx)", onClick: () => void Ft(e, i) },
3382
- { label: o ? "导出 PDF (打印)" : "Export PDF (Print)", onClick: () => void ls() }
3383
- ], y = [...u, ...h, p], w = y.map((b) => b.group).filter((b, T, k) => k.indexOf(b) === T && !t.includes(b)), v = [...t, ...w].map((b) => ({
3441
+ { label: o ? "导出 Word (.docx)" : "Export Word (.docx)", onClick: () => void Bt(e, i) },
3442
+ { label: o ? "导出 PDF (打印)" : "Export PDF (Print)", onClick: () => void us() }
3443
+ ], C = [...u, ...h, p], w = C.map((b) => b.group).filter((b, T, E) => E.indexOf(b) === T && !t.includes(b)), v = [...t, ...w].map((b) => ({
3384
3444
  group: b,
3385
- items: y.filter((T) => T.group === b)
3386
- })).filter((b) => b.items.length > 0), S = (b) => {
3445
+ items: C.filter((T) => T.group === b)
3446
+ })).filter((b) => b.items.length > 0), x = (b) => {
3387
3447
  s((T) => {
3388
- const k = new Set(T);
3389
- return k.has(b) ? k.delete(b) : k.add(b), k;
3448
+ const E = new Set(T);
3449
+ return E.has(b) ? E.delete(b) : E.add(b), E;
3390
3450
  });
3391
3451
  }, _ = [
3392
3452
  { label: o ? "插入表格 3×3" : "Insert Table 3×3", onClick: () => e.chain().focus().insertTable({ rows: 3, cols: 3, withHeaderRow: !0 }).run() },
@@ -3401,10 +3461,10 @@ const ds = ["history", "text", "structure", "format", "technical", "patent"], it
3401
3461
  { label: o ? "切换表头" : "Toggle Header Row", onClick: () => e.chain().focus().toggleHeaderRow().run() },
3402
3462
  { label: o ? "删除表格" : "Delete Table", onClick: () => e.chain().focus().deleteTable().run() }
3403
3463
  ], L = [
3404
- { label: c.insertImageFigure, onClick: () => void d.execCommand("patent.insertFigure", { contentType: "image" }) },
3405
- { label: c.insertMermaidFigure, onClick: () => void d.execCommand("patent.insertFigure", { contentType: "mermaid" }) },
3406
- { label: c.insertDrawioFigure, onClick: () => void d.execCommand("patent.insertFigure", { contentType: "drawio" }) }
3407
- ], P = (b) => b.id === "core-table" ? /* @__PURE__ */ g(ot, { btn: b, items: _ }, b.id) : b.id === "core-export" ? /* @__PURE__ */ g(ot, { btn: b, items: f }, b.id) : b.id === "patent-figure-insert" ? /* @__PURE__ */ g(ot, { btn: b, items: L }, b.id) : /* @__PURE__ */ g(
3464
+ { label: l.insertImageFigure, onClick: () => void d.execCommand("patent.insertFigure", { contentType: "image" }) },
3465
+ { label: l.insertMermaidFigure, onClick: () => void d.execCommand("patent.insertFigure", { contentType: "mermaid" }) },
3466
+ { label: l.insertDrawioFigure, onClick: () => void d.execCommand("patent.insertFigure", { contentType: "drawio" }) }
3467
+ ], P = (b) => b.id === "core-table" ? /* @__PURE__ */ g(ct, { btn: b, items: _ }, b.id) : b.id === "core-export" ? /* @__PURE__ */ g(ct, { btn: b, items: f }, b.id) : b.id === "patent-figure-insert" ? /* @__PURE__ */ g(ct, { btn: b, items: L }, b.id) : /* @__PURE__ */ g(
3408
3468
  "button",
3409
3469
  {
3410
3470
  onClick: b.run,
@@ -3421,13 +3481,13 @@ const ds = ["history", "text", "structure", "format", "technical", "patent"], it
3421
3481
  );
3422
3482
  return /* @__PURE__ */ g("div", { className: "border-b border-gray-200 bg-gray-50 sticky top-0 z-10 overflow-x-auto", children: /* @__PURE__ */ A("div", { className: "flex flex-nowrap md:flex-wrap gap-2 p-2 min-w-max md:min-w-0", children: [
3423
3483
  /* @__PURE__ */ A("div", { className: "flex items-center gap-1 pr-2 mr-2 border-r border-gray-200", children: [
3424
- /* @__PURE__ */ g("span", { className: "text-xs text-gray-500", children: c.language }),
3484
+ /* @__PURE__ */ g("span", { className: "text-xs text-gray-500", children: l.language }),
3425
3485
  /* @__PURE__ */ A(
3426
3486
  "select",
3427
3487
  {
3428
3488
  value: i,
3429
3489
  onChange: (b) => {
3430
- l(b.target.value === "en" ? "en" : "zh");
3490
+ c(b.target.value === "en" ? "en" : "zh");
3431
3491
  },
3432
3492
  className: "text-xs border border-gray-200 rounded px-2 py-1 bg-white text-gray-700",
3433
3493
  children: [
@@ -3444,75 +3504,75 @@ const ds = ["history", "text", "structure", "format", "technical", "patent"], it
3444
3504
  "button",
3445
3505
  {
3446
3506
  onClick: () => {
3447
- S(b.group);
3507
+ x(b.group);
3448
3508
  },
3449
3509
  className: "px-2 py-1 text-xs rounded bg-gray-200 text-gray-700 hover:bg-gray-300",
3450
- title: T ? `Expand ${it(b.group)}` : `Collapse ${it(b.group)}`,
3451
- children: it(b.group)
3510
+ title: T ? `Expand ${ot(b.group)}` : `Collapse ${ot(b.group)}`,
3511
+ children: ot(b.group)
3452
3512
  }
3453
3513
  ),
3454
3514
  (!n || !T) && b.items.map(P)
3455
3515
  ] }, b.group);
3456
3516
  })
3457
3517
  ] }) });
3458
- }, ms = ({ editor: e }) => {
3459
- const [t, n] = z(0), [r, a] = z(""), [s, i] = z(""), l = N((x) => x.editorLanguage), c = U(l);
3518
+ }, gs = ({ editor: e }) => {
3519
+ const [t, n] = z(0), [r, a] = z(""), [s, i] = z(""), c = k((S) => S.editorLanguage), l = U(c);
3460
3520
  if (B(() => {
3461
3521
  if (!e) return;
3462
- const x = () => n((H) => H + 1);
3463
- return e.on("selectionUpdate", x), e.on("update", x), () => {
3464
- e.off("selectionUpdate", x), e.off("update", x);
3522
+ const S = () => n((H) => H + 1);
3523
+ return e.on("selectionUpdate", S), e.on("update", S), () => {
3524
+ e.off("selectionUpdate", S), e.off("update", S);
3465
3525
  };
3466
3526
  }, [e]), !e) return null;
3467
- const d = Ye(e), o = [];
3468
- e.state.doc.descendants((x) => {
3469
- if (x.type.name !== "claim") return !0;
3470
- const H = typeof x.attrs.claimId == "string" ? x.attrs.claimId : "", $ = Number(x.attrs.number);
3527
+ const d = Ae(e), o = [];
3528
+ e.state.doc.descendants((S) => {
3529
+ if (S.type.name !== "claim") return !0;
3530
+ const H = typeof S.attrs.claimId == "string" ? S.attrs.claimId : "", $ = Number(S.attrs.number);
3471
3531
  return !H || !Number.isFinite($) || o.push({
3472
3532
  id: H,
3473
3533
  number: $,
3474
- label: l === "en" ? `Claim ${$}` : `权利要求${$}`
3534
+ label: c === "en" ? `Claim ${$}` : `权利要求${$}`
3475
3535
  }), !0;
3476
3536
  });
3477
3537
  const u = [];
3478
- e.state.doc.descendants((x) => {
3479
- if (x.type.name !== "figure") return !0;
3480
- const H = typeof x.attrs.id == "string" ? x.attrs.id.trim() : "";
3538
+ e.state.doc.descendants((S) => {
3539
+ if (S.type.name !== "figure") return !0;
3540
+ const H = typeof S.attrs.id == "string" ? S.attrs.id.trim() : "";
3481
3541
  return H && u.push({ id: H, label: H }), !0;
3482
3542
  });
3483
- const m = d.findAncestorNode("claim"), h = m && typeof m.node.attrs.claimId == "string" ? m.node.attrs.claimId : "", p = Number(m == null ? void 0 : m.node.attrs.number), f = Array.isArray(m == null ? void 0 : m.node.attrs.dependsOn) ? m.node.attrs.dependsOn.map((x) => Number(x)).filter((x) => Number.isFinite(x)) : [], y = o.filter(
3484
- (x) => Number.isFinite(p) && x.number < p
3485
- ), w = new Set(f), C = !!h, v = (x) => {
3486
- if (!C) return;
3487
- const H = w.has(x) ? f.filter(($) => $ !== x) : [...f, x].sort(($, O) => $ - O);
3543
+ const m = d.findAncestorNode("claim"), h = m && typeof m.node.attrs.claimId == "string" ? m.node.attrs.claimId : "", p = Number(m == null ? void 0 : m.node.attrs.number), f = Array.isArray(m == null ? void 0 : m.node.attrs.dependsOn) ? m.node.attrs.dependsOn.map((S) => Number(S)).filter((S) => Number.isFinite(S)) : [], C = o.filter(
3544
+ (S) => Number.isFinite(p) && S.number < p
3545
+ ), w = new Set(f), y = !!h, v = (S) => {
3546
+ if (!y) return;
3547
+ const H = w.has(S) ? f.filter(($) => $ !== S) : [...f, S].sort(($, O) => $ - O);
3488
3548
  d.execCommand("patent.setClaimDependency", { dependsOn: H });
3489
- }, S = d.findAncestorNode("figure"), _ = !!S, L = S && typeof S.node.attrs.id == "string" ? S.node.attrs.id.trim() : "", P = S && typeof S.node.attrs.contentType == "string" ? S.node.attrs.contentType : "image", [b, T] = z(""), k = X(null), M = X(null), D = (S == null ? void 0 : S.pos) ?? null;
3490
- D !== M.current && (M.current = D, _ && L !== b && T(L));
3491
- const Y = (x) => {
3492
- S && d.execCommand("patent.updateFigure", {
3493
- position: S.pos,
3494
- contentType: x
3549
+ }, x = d.findAncestorNode("figure"), _ = !!x, L = x && typeof x.node.attrs.id == "string" ? x.node.attrs.id.trim() : "", P = x && typeof x.node.attrs.contentType == "string" ? x.node.attrs.contentType : "image", [b, T] = z(""), E = X(null), D = X(null), M = (x == null ? void 0 : x.pos) ?? null;
3550
+ M !== D.current && (D.current = M, _ && L !== b && T(L));
3551
+ const Y = (S) => {
3552
+ x && d.execCommand("patent.updateFigure", {
3553
+ position: x.pos,
3554
+ contentType: S
3495
3555
  });
3496
- }, _e = () => {
3497
- if (!S) return;
3498
- const x = b.trim();
3499
- x !== L && d.execCommand("patent.updateFigure", {
3500
- position: S.pos,
3501
- id: x
3556
+ }, Le = () => {
3557
+ if (!x) return;
3558
+ const S = b.trim();
3559
+ S !== L && d.execCommand("patent.updateFigure", {
3560
+ position: x.pos,
3561
+ id: S
3502
3562
  });
3503
3563
  };
3504
3564
  return /* @__PURE__ */ g("div", { className: "border-b border-gray-200 bg-gray-50 p-2", children: /* @__PURE__ */ A("div", { className: "bg-white border border-gray-200 rounded-md px-2 py-2 flex flex-wrap items-center gap-2", children: [
3505
3565
  o.length > 0 && /* @__PURE__ */ A(we, { children: [
3506
- /* @__PURE__ */ g("span", { className: "text-xs text-gray-500", children: c.referenceTarget }),
3566
+ /* @__PURE__ */ g("span", { className: "text-xs text-gray-500", children: l.referenceTarget }),
3507
3567
  /* @__PURE__ */ A(
3508
3568
  "select",
3509
3569
  {
3510
3570
  value: r || "__none__",
3511
- onChange: (x) => a(x.target.value === "__none__" ? "" : x.target.value),
3571
+ onChange: (S) => a(S.target.value === "__none__" ? "" : S.target.value),
3512
3572
  className: "text-xs border border-gray-200 rounded px-2 py-1 bg-white",
3513
3573
  children: [
3514
- /* @__PURE__ */ g("option", { value: "__none__", children: c.referenceTargetPlaceholder }),
3515
- o.map((x) => /* @__PURE__ */ g("option", { value: x.id, children: x.label }, x.id))
3574
+ /* @__PURE__ */ g("option", { value: "__none__", children: l.referenceTargetPlaceholder }),
3575
+ o.map((S) => /* @__PURE__ */ g("option", { value: S.id, children: S.label }, S.id))
3516
3576
  ]
3517
3577
  }
3518
3578
  ),
@@ -3526,22 +3586,22 @@ const ds = ["history", "text", "structure", "format", "technical", "patent"], it
3526
3586
  });
3527
3587
  },
3528
3588
  className: "p-2 hover:bg-blue-50 text-blue-600 rounded",
3529
- title: c.insertReference,
3530
- children: /* @__PURE__ */ g(gt, { size: 16 })
3589
+ title: l.insertReference,
3590
+ children: /* @__PURE__ */ g(pt, { size: 16 })
3531
3591
  }
3532
3592
  )
3533
3593
  ] }),
3534
3594
  u.length > 0 && /* @__PURE__ */ A(we, { children: [
3535
- /* @__PURE__ */ g("span", { className: "text-xs text-gray-500", children: c.figureReferenceTarget }),
3595
+ /* @__PURE__ */ g("span", { className: "text-xs text-gray-500", children: l.figureReferenceTarget }),
3536
3596
  /* @__PURE__ */ A(
3537
3597
  "select",
3538
3598
  {
3539
3599
  value: s || "__none__",
3540
- onChange: (x) => i(x.target.value === "__none__" ? "" : x.target.value),
3600
+ onChange: (S) => i(S.target.value === "__none__" ? "" : S.target.value),
3541
3601
  className: "text-xs border border-gray-200 rounded px-2 py-1 bg-white",
3542
3602
  children: [
3543
- /* @__PURE__ */ g("option", { value: "__none__", children: c.figureReferenceTargetPlaceholder }),
3544
- u.map((x) => /* @__PURE__ */ g("option", { value: x.id, children: x.label }, x.id))
3603
+ /* @__PURE__ */ g("option", { value: "__none__", children: l.figureReferenceTargetPlaceholder }),
3604
+ u.map((S) => /* @__PURE__ */ g("option", { value: S.id, children: S.label }, S.id))
3545
3605
  ]
3546
3606
  }
3547
3607
  ),
@@ -3555,41 +3615,41 @@ const ds = ["history", "text", "structure", "format", "technical", "patent"], it
3555
3615
  });
3556
3616
  },
3557
3617
  className: "p-2 hover:bg-blue-50 text-blue-600 rounded",
3558
- title: c.insertFigureReference,
3559
- children: /* @__PURE__ */ g(Zt, { size: 16 })
3618
+ title: l.insertFigureReference,
3619
+ children: /* @__PURE__ */ g(en, { size: 16 })
3560
3620
  }
3561
3621
  )
3562
3622
  ] }),
3563
3623
  /* @__PURE__ */ g("div", { className: "h-6 w-px bg-gray-200 mx-1" }),
3564
3624
  _ && /* @__PURE__ */ A(we, { children: [
3565
- /* @__PURE__ */ g("span", { className: "text-xs font-medium text-gray-700", children: c.currentFigure }),
3566
- /* @__PURE__ */ g("span", { className: "text-xs text-gray-500", children: c.figureId }),
3625
+ /* @__PURE__ */ g("span", { className: "text-xs font-medium text-gray-700", children: l.currentFigure }),
3626
+ /* @__PURE__ */ g("span", { className: "text-xs text-gray-500", children: l.figureId }),
3567
3627
  /* @__PURE__ */ g(
3568
3628
  "input",
3569
3629
  {
3570
- ref: k,
3630
+ ref: E,
3571
3631
  type: "text",
3572
3632
  value: b,
3573
- onChange: (x) => T(x.target.value),
3574
- onBlur: _e,
3575
- onKeyDown: (x) => {
3576
- x.key === "Enter" && (_e(), x.target.blur());
3633
+ onChange: (S) => T(S.target.value),
3634
+ onBlur: Le,
3635
+ onKeyDown: (S) => {
3636
+ S.key === "Enter" && (Le(), S.target.blur());
3577
3637
  },
3578
3638
  className: "text-xs border border-gray-200 rounded px-2 py-1 bg-white w-20",
3579
- placeholder: l === "en" ? "Fig.1" : "图1"
3639
+ placeholder: c === "en" ? "Fig.1" : "图1"
3580
3640
  }
3581
3641
  ),
3582
- /* @__PURE__ */ g("span", { className: "text-xs text-gray-500", children: c.switchFigureType }),
3642
+ /* @__PURE__ */ g("span", { className: "text-xs text-gray-500", children: l.switchFigureType }),
3583
3643
  /* @__PURE__ */ A(
3584
3644
  "select",
3585
3645
  {
3586
3646
  value: P,
3587
- onChange: (x) => Y(x.target.value),
3647
+ onChange: (S) => Y(S.target.value),
3588
3648
  className: "text-xs border border-gray-200 rounded px-2 py-1 bg-white",
3589
3649
  children: [
3590
- /* @__PURE__ */ g("option", { value: "image", children: c.figureContentTypeImage }),
3591
- /* @__PURE__ */ g("option", { value: "mermaid", children: c.figureContentTypeMermaid }),
3592
- /* @__PURE__ */ g("option", { value: "drawio", children: c.figureContentTypeDrawio })
3650
+ /* @__PURE__ */ g("option", { value: "image", children: l.figureContentTypeImage }),
3651
+ /* @__PURE__ */ g("option", { value: "mermaid", children: l.figureContentTypeMermaid }),
3652
+ /* @__PURE__ */ g("option", { value: "drawio", children: l.figureContentTypeDrawio })
3593
3653
  ]
3594
3654
  }
3595
3655
  ),
@@ -3598,7 +3658,7 @@ const ds = ["history", "text", "structure", "format", "technical", "patent"], it
3598
3658
  e.isActive("image") && (() => {
3599
3659
  const H = e.getAttributes("image").width || "";
3600
3660
  return /* @__PURE__ */ A(we, { children: [
3601
- /* @__PURE__ */ g("span", { className: "text-xs font-medium text-gray-700", children: l === "zh" ? "图片" : "Image" }),
3661
+ /* @__PURE__ */ g("span", { className: "text-xs font-medium text-gray-700", children: c === "zh" ? "图片" : "Image" }),
3602
3662
  ["25%", "50%", "75%", "100%"].map((O) => /* @__PURE__ */ g(
3603
3663
  "button",
3604
3664
  {
@@ -3611,47 +3671,47 @@ const ds = ["history", "text", "structure", "format", "technical", "patent"], it
3611
3671
  /* @__PURE__ */ g("div", { className: "h-6 w-px bg-gray-200 mx-1" })
3612
3672
  ] });
3613
3673
  })(),
3614
- C ? /* @__PURE__ */ A(we, { children: [
3615
- /* @__PURE__ */ g("span", { className: "text-xs font-medium text-gray-700", children: c.currentClaim(p) }),
3616
- y.length > 0 && /* @__PURE__ */ A("div", { className: "flex flex-wrap gap-1 items-center", children: [
3617
- /* @__PURE__ */ g("span", { className: "text-xs text-gray-500", children: c.dependsOn }),
3618
- y.map((x) => /* @__PURE__ */ g(
3674
+ y ? /* @__PURE__ */ A(we, { children: [
3675
+ /* @__PURE__ */ g("span", { className: "text-xs font-medium text-gray-700", children: l.currentClaim(p) }),
3676
+ C.length > 0 && /* @__PURE__ */ A("div", { className: "flex flex-wrap gap-1 items-center", children: [
3677
+ /* @__PURE__ */ g("span", { className: "text-xs text-gray-500", children: l.dependsOn }),
3678
+ C.map((S) => /* @__PURE__ */ g(
3619
3679
  "button",
3620
3680
  {
3621
- onClick: () => v(x.number),
3622
- className: `text-xs px-2 py-0.5 rounded border ${w.has(x.number) ? "bg-blue-50 text-blue-700 border-blue-200" : "bg-white text-gray-600 border-gray-200 hover:bg-gray-50"}`,
3623
- children: x.number
3681
+ onClick: () => v(S.number),
3682
+ className: `text-xs px-2 py-0.5 rounded border ${w.has(S.number) ? "bg-blue-50 text-blue-700 border-blue-200" : "bg-white text-gray-600 border-gray-200 hover:bg-gray-50"}`,
3683
+ children: S.number
3624
3684
  },
3625
- x.id
3685
+ S.id
3626
3686
  ))
3627
3687
  ] })
3628
- ] }) : _ ? null : /* @__PURE__ */ g("span", { className: "text-xs text-gray-400", children: c.placeCursorToEditDependencies }),
3688
+ ] }) : _ ? null : /* @__PURE__ */ g("span", { className: "text-xs text-gray-400", children: l.placeCursorToEditDependencies }),
3629
3689
  /* @__PURE__ */ g("div", { className: "h-6 w-px bg-gray-200 mx-1" }),
3630
3690
  /* @__PURE__ */ g(
3631
3691
  "button",
3632
3692
  {
3633
3693
  onClick: async () => {
3634
- if (C && await d.execCommand("patent.deleteClaim") || e.chain().focus().deleteSelection().run()) return;
3635
- const { from: x } = e.state.selection;
3636
- x > 1 && e.chain().focus().deleteRange({ from: x - 1, to: x }).run();
3694
+ if (y && await d.execCommand("patent.deleteClaim") || e.chain().focus().deleteSelection().run()) return;
3695
+ const { from: S } = e.state.selection;
3696
+ S > 1 && e.chain().focus().deleteRange({ from: S - 1, to: S }).run();
3637
3697
  },
3638
3698
  className: "p-2 hover:bg-red-50 text-red-600 rounded",
3639
- title: c.deleteSelection,
3640
- children: /* @__PURE__ */ g(jr, { size: 16 })
3699
+ title: l.deleteSelection,
3700
+ children: /* @__PURE__ */ g(Wr, { size: 16 })
3641
3701
  }
3642
3702
  )
3643
3703
  ] }) });
3644
- }, fs = (e) => {
3704
+ }, ps = (e) => {
3645
3705
  if (!Array.isArray(e))
3646
3706
  return [];
3647
3707
  const t = e.map((n) => Number(n)).filter((n) => Number.isFinite(n) && n > 0);
3648
3708
  return Array.from(new Set(t)).sort((n, r) => n - r);
3649
- }, gs = (e) => {
3709
+ }, hs = (e) => {
3650
3710
  if (!Array.isArray(e))
3651
3711
  return [];
3652
3712
  const t = e.map((n) => typeof n == "string" ? n.trim() : "").filter(Boolean);
3653
3713
  return Array.from(new Set(t));
3654
- }, ps = (e) => {
3714
+ }, bs = (e) => {
3655
3715
  const t = e.attrs.lang === "en" ? "en" : "zh", n = e.attrs.targetType === "figure" ? "figure" : "claim", r = typeof e.attrs.displayText == "string" ? e.attrs.displayText.trim() : "";
3656
3716
  if (r)
3657
3717
  return r;
@@ -3661,9 +3721,9 @@ const ds = ["history", "text", "structure", "format", "technical", "patent"], it
3661
3721
  }
3662
3722
  const a = Number(e.attrs.resolvedNumber);
3663
3723
  return Number.isFinite(a) ? t === "en" ? `Claim ${a}` : `权利要求${a}` : t === "en" ? "Claim ?" : "权利要求?";
3664
- }, pn = (e) => {
3724
+ }, hn = (e) => {
3665
3725
  if (e.type.name === "reference")
3666
- return ps(e);
3726
+ return bs(e);
3667
3727
  if (e.type.name === "hardBreak")
3668
3728
  return `
3669
3729
  `;
@@ -3671,9 +3731,9 @@ const ds = ["history", "text", "structure", "format", "technical", "patent"], it
3671
3731
  return e.text || "";
3672
3732
  let t = "";
3673
3733
  return e.forEach((n) => {
3674
- t += pn(n);
3734
+ t += hn(n);
3675
3735
  }), t;
3676
- }, hs = (e) => {
3736
+ }, ys = (e) => {
3677
3737
  const t = [];
3678
3738
  e.state.doc.descendants((r, a) => {
3679
3739
  if (r.type.name !== "claim")
@@ -3682,9 +3742,9 @@ const ds = ["history", "text", "structure", "format", "technical", "patent"], it
3682
3742
  return !Number.isFinite(i) || i <= 0 || t.push({
3683
3743
  claimId: s,
3684
3744
  number: i,
3685
- dependsOn: fs(r.attrs.dependsOn),
3686
- dependsOnClaimIds: gs(r.attrs.dependsOnClaimIds),
3687
- body: pn(r).trim(),
3745
+ dependsOn: ps(r.attrs.dependsOn),
3746
+ dependsOnClaimIds: hs(r.attrs.dependsOnClaimIds),
3747
+ body: hn(r).trim(),
3688
3748
  pos: a
3689
3749
  }), !0;
3690
3750
  });
@@ -3696,7 +3756,7 @@ const ds = ["history", "text", "structure", "format", "technical", "patent"], it
3696
3756
  dependsOnClaimIds: Array.from(new Set(s))
3697
3757
  };
3698
3758
  });
3699
- }, bs = (e, t = "zh") => {
3759
+ }, vs = (e, t = "zh") => {
3700
3760
  const n = [], r = new Map(e.map((o) => [o.claimId, o.number]));
3701
3761
  e.forEach((o) => {
3702
3762
  o.dependsOnClaimIds.forEach((u) => {
@@ -3712,14 +3772,14 @@ const ds = ["history", "text", "structure", "format", "technical", "patent"], it
3712
3772
  });
3713
3773
  });
3714
3774
  });
3715
- const a = new Map(e.map((o) => [o.claimId, o.dependsOnClaimIds])), s = /* @__PURE__ */ new Set(), i = /* @__PURE__ */ new Set(), l = /* @__PURE__ */ new Set(), c = (o) => {
3775
+ const a = new Map(e.map((o) => [o.claimId, o.dependsOnClaimIds])), s = /* @__PURE__ */ new Set(), i = /* @__PURE__ */ new Set(), c = /* @__PURE__ */ new Set(), l = (o) => {
3716
3776
  if (i.has(o)) {
3717
- l.add(o);
3777
+ c.add(o);
3718
3778
  return;
3719
3779
  }
3720
- s.has(o) || (s.add(o), i.add(o), (a.get(o) || []).forEach((u) => c(u)), i.delete(o));
3780
+ s.has(o) || (s.add(o), i.add(o), (a.get(o) || []).forEach((u) => l(u)), i.delete(o));
3721
3781
  };
3722
- e.forEach((o) => c(o.claimId)), l.forEach((o) => {
3782
+ e.forEach((o) => l(o.claimId)), c.forEach((o) => {
3723
3783
  const u = e.find((m) => m.claimId === o);
3724
3784
  u && n.push({
3725
3785
  claimId: o,
@@ -3735,10 +3795,10 @@ const ds = ["history", "text", "structure", "format", "technical", "patent"], it
3735
3795
  }), e.forEach((o) => {
3736
3796
  if (o.dependsOn.length > 1) {
3737
3797
  const u = o.dependsOn, m = u.some((p) => {
3738
- const f = e.find((y) => y.number === p);
3798
+ const f = e.find((C) => C.number === p);
3739
3799
  return f && f.dependsOn.length === 0;
3740
3800
  }), h = u.some((p) => {
3741
- const f = e.find((y) => y.number === p);
3801
+ const f = e.find((C) => C.number === p);
3742
3802
  return f && f.dependsOn.length > 0;
3743
3803
  });
3744
3804
  m && h && n.push({
@@ -3748,7 +3808,7 @@ const ds = ["history", "text", "structure", "format", "technical", "patent"], it
3748
3808
  });
3749
3809
  }
3750
3810
  }), n;
3751
- }, ys = (e) => {
3811
+ }, Cs = (e) => {
3752
3812
  const t = new Map(e.map((o) => [o.claimId, o.dependsOnClaimIds])), n = /* @__PURE__ */ new Map();
3753
3813
  e.forEach((o) => {
3754
3814
  o.dependsOnClaimIds.forEach((u) => {
@@ -3756,36 +3816,36 @@ const ds = ["history", "text", "structure", "format", "technical", "patent"], it
3756
3816
  m.includes(o.claimId) || m.push(o.claimId), n.set(u, m);
3757
3817
  });
3758
3818
  });
3759
- const r = e.filter((o) => (t.get(o.claimId) || []).length === 0).sort((o, u) => o.number - u.number).map((o) => o.claimId), a = e.map((o) => o.claimId), s = [...r, ...a.filter((o) => !r.includes(o))], i = new Map(e.map((o) => [o.claimId, o])), l = [], c = /* @__PURE__ */ new Set(), d = (o, u) => {
3760
- if (c.has(o))
3819
+ const r = e.filter((o) => (t.get(o.claimId) || []).length === 0).sort((o, u) => o.number - u.number).map((o) => o.claimId), a = e.map((o) => o.claimId), s = [...r, ...a.filter((o) => !r.includes(o))], i = new Map(e.map((o) => [o.claimId, o])), c = [], l = /* @__PURE__ */ new Set(), d = (o, u) => {
3820
+ if (l.has(o))
3761
3821
  return;
3762
- c.add(o);
3822
+ l.add(o);
3763
3823
  const m = i.get(o);
3764
3824
  if (!m)
3765
3825
  return;
3766
- l.push({
3826
+ c.push({
3767
3827
  claimId: o,
3768
3828
  number: m.number,
3769
3829
  depth: u
3770
3830
  }), (n.get(o) || []).map((p) => i.get(p)).filter((p) => !!p).sort((p, f) => p.number - f.number).map((p) => p.claimId).forEach((p) => d(p, u + 1));
3771
3831
  };
3772
- return s.forEach((o) => d(o, 0)), l;
3773
- }, vs = (e) => e.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&apos;"), Cs = (e) => `<claims>${e.sort((n, r) => n.number - r.number).map((n) => `<claim id="${n.number}"><claim-text>${vs(n.body)}</claim-text></claim>`).join("")}</claims>`, ws = (e) => ["Claims", "", ...e.sort((n, r) => n.number - r.number).map((n) => `${n.number}. ${n.body}`)].join(`
3774
- `), zt = (e, t, n) => {
3832
+ return s.forEach((o) => d(o, 0)), c;
3833
+ }, ws = (e) => e.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&apos;"), xs = (e) => `<claims>${e.sort((n, r) => n.number - r.number).map((n) => `<claim id="${n.number}"><claim-text>${ws(n.body)}</claim-text></claim>`).join("")}</claims>`, Ss = (e) => ["Claims", "", ...e.sort((n, r) => n.number - r.number).map((n) => `${n.number}. ${n.body}`)].join(`
3834
+ `), Ht = (e, t, n) => {
3775
3835
  const r = new Blob([t], { type: n }), a = URL.createObjectURL(r), s = document.createElement("a");
3776
3836
  s.href = a, s.download = e, s.click(), URL.revokeObjectURL(a);
3777
- }, xs = ({ editor: e }) => {
3778
- const [t, n] = z(!1), r = N((o) => o.editorLanguage), a = U(r), s = An({
3837
+ }, Ts = ({ editor: e }) => {
3838
+ const [t, n] = z(!1), r = k((o) => o.editorLanguage), a = U(r), s = Ln({
3779
3839
  editor: e,
3780
- selector: (o) => hs(o.editor)
3840
+ selector: (o) => ys(o.editor)
3781
3841
  }), i = Te(
3782
- () => bs(s, r),
3842
+ () => vs(s, r),
3783
3843
  [s, r]
3784
- ), l = Te(() => ys(s), [s]), c = Te(
3844
+ ), c = Te(() => Cs(s), [s]), l = Te(
3785
3845
  () => new Map(s.map((o) => [o.claimId, o.pos])),
3786
3846
  [s]
3787
3847
  ), d = (o) => {
3788
- const u = c.get(o);
3848
+ const u = l.get(o);
3789
3849
  typeof u == "number" && e.chain().focus().setTextSelection(u + 1).run();
3790
3850
  };
3791
3851
  return /* @__PURE__ */ A("div", { className: "border-b border-gray-200 bg-white px-3 py-2", children: [
@@ -3799,7 +3859,7 @@ const ds = ["history", "text", "structure", "format", "technical", "patent"], it
3799
3859
  /* @__PURE__ */ g(
3800
3860
  "button",
3801
3861
  {
3802
- onClick: () => zt("claims-cnipa.xml", Cs(s), "application/xml;charset=utf-8"),
3862
+ onClick: () => Ht("claims-cnipa.xml", xs(s), "application/xml;charset=utf-8"),
3803
3863
  className: "px-3 py-2 text-left text-xs hover:bg-gray-50 text-gray-700",
3804
3864
  children: a.exportCnipaXml
3805
3865
  }
@@ -3807,14 +3867,14 @@ const ds = ["history", "text", "structure", "format", "technical", "patent"], it
3807
3867
  /* @__PURE__ */ g(
3808
3868
  "button",
3809
3869
  {
3810
- onClick: () => zt("claims-word-mapping.txt", ws(s), "text/plain;charset=utf-8"),
3870
+ onClick: () => Ht("claims-word-mapping.txt", Ss(s), "text/plain;charset=utf-8"),
3811
3871
  className: "px-3 py-2 text-left text-xs hover:bg-gray-50 text-gray-700",
3812
3872
  children: a.exportWordMapping
3813
3873
  }
3814
3874
  )
3815
3875
  ] })
3816
3876
  ] }),
3817
- l.length > 0 && /* @__PURE__ */ g(
3877
+ c.length > 0 && /* @__PURE__ */ g(
3818
3878
  "button",
3819
3879
  {
3820
3880
  onClick: () => n((o) => !o),
@@ -3832,9 +3892,9 @@ const ds = ["history", "text", "structure", "format", "technical", "patent"], it
3832
3892
  },
3833
3893
  `${o.claimId}-${o.code}-${u}`
3834
3894
  )) }),
3835
- t && l.length > 0 && /* @__PURE__ */ A("div", { className: "mt-2 border border-gray-200 rounded p-2 bg-gray-50", children: [
3895
+ t && c.length > 0 && /* @__PURE__ */ A("div", { className: "mt-2 border border-gray-200 rounded p-2 bg-gray-50", children: [
3836
3896
  /* @__PURE__ */ g("div", { className: "text-xs font-medium text-gray-600 mb-1", children: a.claimDependencyTree }),
3837
- /* @__PURE__ */ g("div", { className: "space-y-0.5", children: l.map((o) => /* @__PURE__ */ g(
3897
+ /* @__PURE__ */ g("div", { className: "space-y-0.5", children: c.map((o) => /* @__PURE__ */ g(
3838
3898
  "button",
3839
3899
  {
3840
3900
  onClick: () => d(o.claimId),
@@ -3846,7 +3906,7 @@ const ds = ["history", "text", "structure", "format", "technical", "patent"], it
3846
3906
  )) })
3847
3907
  ] })
3848
3908
  ] });
3849
- }, hn = {
3909
+ }, bn = {
3850
3910
  // Invention & Utility Model
3851
3911
  technical_field: [],
3852
3912
  background_art: ["technical_field"],
@@ -3864,10 +3924,10 @@ const ds = ["history", "text", "structure", "format", "technical", "patent"], it
3864
3924
  design_views: ["design_description"],
3865
3925
  design_brief: ["design_description", "design_views"]
3866
3926
  };
3867
- function ao(e, t) {
3868
- return (hn[e] || []).filter((r) => !t.has(r));
3927
+ function io(e, t) {
3928
+ return (bn[e] || []).filter((r) => !t.has(r));
3869
3929
  }
3870
- function Ss(e) {
3930
+ function Is(e) {
3871
3931
  const t = [];
3872
3932
  return e.state.doc.descendants((n, r) => n.type.name === "patent_title" ? (t.push({
3873
3933
  sectionType: "patent_title",
@@ -3879,7 +3939,7 @@ function Ss(e) {
3879
3939
  content: n.textContent || ""
3880
3940
  }), !1) : !0), t;
3881
3941
  }
3882
- function bn(e) {
3942
+ function yn(e) {
3883
3943
  const { from: t } = e.state.selection, n = e.state.doc.resolve(t);
3884
3944
  for (let r = n.depth; r >= 0; r--) {
3885
3945
  const a = n.node(r);
@@ -3898,10 +3958,10 @@ function bn(e) {
3898
3958
  }
3899
3959
  return null;
3900
3960
  }
3901
- function Ts(e, t) {
3902
- const n = hn[t];
3961
+ function Es(e, t) {
3962
+ const n = bn[t];
3903
3963
  if (!n || n.length === 0) return [];
3904
- const r = Ss(e), a = new Map(r.map((s) => [s.sectionType, s]));
3964
+ const r = Is(e), a = new Map(r.map((s) => [s.sectionType, s]));
3905
3965
  return n.map((s) => {
3906
3966
  const i = a.get(s);
3907
3967
  return !i || i.content.trim().length === 0 ? null : {
@@ -3910,23 +3970,23 @@ function Ts(e, t) {
3910
3970
  };
3911
3971
  }).filter((s) => s !== null && s.content.length > 0);
3912
3972
  }
3913
- function so(e, t = {}) {
3914
- const n = N.getState().editorLanguage, { from: r, to: a } = e.state.selection, s = r !== a ? e.state.doc.textBetween(r, a, " ", "\0") : void 0;
3915
- let i = t.sectionType, l = t.targetSectionPos;
3973
+ function oo(e, t = {}) {
3974
+ const n = k.getState().editorLanguage, { from: r, to: a } = e.state.selection, s = r !== a ? e.state.doc.textBetween(r, a, " ", "\0") : void 0;
3975
+ let i = t.sectionType, c = t.targetSectionPos;
3916
3976
  if (!i) {
3917
- const u = bn(e);
3918
- u && (i = u.sectionType, l = u.pos);
3977
+ const u = yn(e);
3978
+ u && (i = u.sectionType, c = u.pos);
3919
3979
  }
3920
- const c = t.scope || (i ? "section" : s ? "selection" : "document"), d = i ? Ts(e, i) : void 0;
3980
+ const l = t.scope || (i ? "section" : s ? "selection" : "document"), d = i ? Es(e, i) : void 0;
3921
3981
  let o;
3922
- if (c === "selection" && r !== a) {
3982
+ if (l === "selection" && r !== a) {
3923
3983
  const m = Math.max(0, r - 200), h = Math.min(e.state.doc.content.size, a + 200), p = e.state.doc.textBetween(m, r, " ", "\0"), f = e.state.doc.textBetween(a, h, " ", "\0");
3924
3984
  o = `...${p}[SELECTED]${f}...`;
3925
3985
  }
3926
3986
  return {
3927
- scope: c,
3987
+ scope: l,
3928
3988
  sectionType: i,
3929
- targetSectionPos: l,
3989
+ targetSectionPos: c,
3930
3990
  userInput: t.userInput,
3931
3991
  selectedText: s,
3932
3992
  dependencyContext: d,
@@ -3934,25 +3994,25 @@ function so(e, t = {}) {
3934
3994
  language: n
3935
3995
  };
3936
3996
  }
3937
- const Is = ({ editor: e, onSelectionOptimize: t }) => {
3938
- const { addChatReference: n, openChatPanel: r, editorLanguage: a } = N(), s = a === "zh", i = (d) => re(
3997
+ const Ns = ({ editor: e, onSelectionOptimize: t }) => {
3998
+ const { addChatReference: n, openChatPanel: r, editorLanguage: a } = k(), s = a === "zh", i = (d) => re(
3939
3999
  "p-1.5 rounded transition-colors",
3940
4000
  d ? "bg-blue-100 text-blue-600" : "text-gray-600 hover:bg-gray-100"
3941
- ), l = () => {
4001
+ ), c = () => {
3942
4002
  const { from: d, to: o } = e.state.selection;
3943
4003
  if (d === o) return;
3944
- const u = e.state.doc.textBetween(d, o, " "), m = bn(e);
4004
+ const u = e.state.doc.textBetween(d, o, " "), m = yn(e);
3945
4005
  if (t) {
3946
4006
  t({ text: u, from: d, to: o, sectionType: m == null ? void 0 : m.sectionType });
3947
4007
  return;
3948
4008
  }
3949
4009
  n({ text: u, from: d, to: o, sectionType: m == null ? void 0 : m.sectionType }), r();
3950
- }, c = () => {
4010
+ }, l = () => {
3951
4011
  const d = e.getAttributes("link").href, o = window.prompt("URL", d || "https://");
3952
4012
  o !== null && (o === "" ? e.chain().focus().extendMarkRange("link").unsetLink().run() : e.chain().focus().extendMarkRange("link").setLink({ href: o }).run());
3953
4013
  };
3954
4014
  return /* @__PURE__ */ g(
3955
- ta,
4015
+ na,
3956
4016
  {
3957
4017
  editor: e,
3958
4018
  shouldShow: ({ editor: d, state: o }) => {
@@ -3966,7 +4026,7 @@ const Is = ({ editor: e, onSelectionOptimize: t }) => {
3966
4026
  onClick: () => e.chain().focus().toggleBold().run(),
3967
4027
  className: i(e.isActive("bold")),
3968
4028
  title: "Bold",
3969
- children: /* @__PURE__ */ g(Gt, { size: 15 })
4029
+ children: /* @__PURE__ */ g(Vt, { size: 15 })
3970
4030
  }
3971
4031
  ),
3972
4032
  /* @__PURE__ */ g(
@@ -3975,7 +4035,7 @@ const Is = ({ editor: e, onSelectionOptimize: t }) => {
3975
4035
  onClick: () => e.chain().focus().toggleItalic().run(),
3976
4036
  className: i(e.isActive("italic")),
3977
4037
  title: "Italic",
3978
- children: /* @__PURE__ */ g(Vt, { size: 15 })
4038
+ children: /* @__PURE__ */ g(Kt, { size: 15 })
3979
4039
  }
3980
4040
  ),
3981
4041
  /* @__PURE__ */ g(
@@ -3984,7 +4044,7 @@ const Is = ({ editor: e, onSelectionOptimize: t }) => {
3984
4044
  onClick: () => e.chain().focus().toggleUnderline().run(),
3985
4045
  className: i(e.isActive("underline")),
3986
4046
  title: "Underline",
3987
- children: /* @__PURE__ */ g(Kt, { size: 15 })
4047
+ children: /* @__PURE__ */ g(Jt, { size: 15 })
3988
4048
  }
3989
4049
  ),
3990
4050
  /* @__PURE__ */ g(
@@ -3993,7 +4053,7 @@ const Is = ({ editor: e, onSelectionOptimize: t }) => {
3993
4053
  onClick: () => e.chain().focus().toggleStrike().run(),
3994
4054
  className: i(e.isActive("strike")),
3995
4055
  title: "Strikethrough",
3996
- children: /* @__PURE__ */ g(Jt, { size: 15 })
4056
+ children: /* @__PURE__ */ g(Xt, { size: 15 })
3997
4057
  }
3998
4058
  ),
3999
4059
  /* @__PURE__ */ g(
@@ -4002,7 +4062,7 @@ const Is = ({ editor: e, onSelectionOptimize: t }) => {
4002
4062
  onClick: () => e.chain().focus().toggleCode().run(),
4003
4063
  className: i(e.isActive("code")),
4004
4064
  title: "Code",
4005
- children: /* @__PURE__ */ g(Xt, { size: 15 })
4065
+ children: /* @__PURE__ */ g(Qt, { size: 15 })
4006
4066
  }
4007
4067
  ),
4008
4068
  /* @__PURE__ */ g(
@@ -4011,7 +4071,7 @@ const Is = ({ editor: e, onSelectionOptimize: t }) => {
4011
4071
  onClick: () => e.chain().focus().toggleSuperscript().run(),
4012
4072
  className: i(e.isActive("superscript")),
4013
4073
  title: "Superscript",
4014
- children: /* @__PURE__ */ g(Qt, { size: 15 })
4074
+ children: /* @__PURE__ */ g(Yt, { size: 15 })
4015
4075
  }
4016
4076
  ),
4017
4077
  /* @__PURE__ */ g(
@@ -4020,7 +4080,7 @@ const Is = ({ editor: e, onSelectionOptimize: t }) => {
4020
4080
  onClick: () => e.chain().focus().toggleSubscript().run(),
4021
4081
  className: i(e.isActive("subscript")),
4022
4082
  title: "Subscript",
4023
- children: /* @__PURE__ */ g(Yt, { size: 15 })
4083
+ children: /* @__PURE__ */ g(Zt, { size: 15 })
4024
4084
  }
4025
4085
  ),
4026
4086
  /* @__PURE__ */ g("div", { className: "bubble-menu-divider" }),
@@ -4030,38 +4090,38 @@ const Is = ({ editor: e, onSelectionOptimize: t }) => {
4030
4090
  onClick: () => e.chain().focus().toggleHighlight().run(),
4031
4091
  className: i(e.isActive("highlight")),
4032
4092
  title: "Highlight",
4033
- children: /* @__PURE__ */ g(Wr, { size: 15 })
4093
+ children: /* @__PURE__ */ g(qr, { size: 15 })
4034
4094
  }
4035
4095
  ),
4036
4096
  /* @__PURE__ */ g(
4037
4097
  "button",
4038
4098
  {
4039
- onClick: c,
4099
+ onClick: l,
4040
4100
  className: i(e.isActive("link")),
4041
4101
  title: "Link",
4042
- children: /* @__PURE__ */ g(gt, { size: 15 })
4102
+ children: /* @__PURE__ */ g(pt, { size: 15 })
4043
4103
  }
4044
4104
  ),
4045
4105
  /* @__PURE__ */ g("div", { className: "bubble-menu-divider" }),
4046
4106
  /* @__PURE__ */ g(
4047
4107
  "button",
4048
4108
  {
4049
- onClick: l,
4109
+ onClick: c,
4050
4110
  className: "p-1.5 rounded transition-colors text-purple-500 hover:bg-purple-50",
4051
4111
  title: s ? "AI 优化" : "AI Optimize",
4052
- children: /* @__PURE__ */ g(qr, { size: 15 })
4112
+ children: /* @__PURE__ */ g(Gr, { size: 15 })
4053
4113
  }
4054
4114
  )
4055
4115
  ] })
4056
4116
  }
4057
4117
  );
4058
- }, Es = ({ editor: e }) => {
4059
- var C;
4060
- const [t, n] = z(!1), [r, a] = z(!1), [s, i] = z(""), [l, c] = z(""), [d, o] = z(!1), u = X(null), m = e.extensionStorage.searchReplace, h = ((C = m == null ? void 0 : m.results) == null ? void 0 : C.length) ?? 0, p = (m == null ? void 0 : m.currentIndex) ?? -1;
4118
+ }, ks = ({ editor: e }) => {
4119
+ var y;
4120
+ const [t, n] = z(!1), [r, a] = z(!1), [s, i] = z(""), [c, l] = z(""), [d, o] = z(!1), u = X(null), m = e.extensionStorage.searchReplace, h = ((y = m == null ? void 0 : m.results) == null ? void 0 : y.length) ?? 0, p = (m == null ? void 0 : m.currentIndex) ?? -1;
4061
4121
  B(() => {
4062
- const v = (S) => {
4122
+ const v = (x) => {
4063
4123
  n(!0);
4064
- const _ = S.detail;
4124
+ const _ = x.detail;
4065
4125
  _ != null && _.replace && a(!0), requestAnimationFrame(() => {
4066
4126
  var L;
4067
4127
  return (L = u.current) == null ? void 0 : L.focus();
@@ -4074,15 +4134,15 @@ const Is = ({ editor: e, onSelectionOptimize: t }) => {
4074
4134
  i(v), e.commands.setSearchTerm(v);
4075
4135
  },
4076
4136
  [e]
4077
- ), y = de(() => {
4137
+ ), C = de(() => {
4078
4138
  n(!1), e.commands.clearSearch(), e.commands.focus();
4079
4139
  }, [e]);
4080
4140
  B(() => {
4081
- const v = (S) => {
4082
- S.key === "Escape" && t && y();
4141
+ const v = (x) => {
4142
+ x.key === "Escape" && t && C();
4083
4143
  };
4084
4144
  return window.addEventListener("keydown", v), () => window.removeEventListener("keydown", v);
4085
- }, [t, y]);
4145
+ }, [t, C]);
4086
4146
  const w = () => {
4087
4147
  const v = !d;
4088
4148
  o(v), e.commands.setCaseSensitive(v);
@@ -4112,30 +4172,30 @@ const Is = ({ editor: e, onSelectionOptimize: t }) => {
4112
4172
  onClick: w,
4113
4173
  className: re("find-replace-btn", d && "find-replace-btn--active"),
4114
4174
  title: "Case Sensitive",
4115
- children: /* @__PURE__ */ g(Gr, { size: 15 })
4175
+ children: /* @__PURE__ */ g(Vr, { size: 15 })
4116
4176
  }
4117
4177
  ),
4118
- /* @__PURE__ */ g("button", { onClick: () => e.commands.previousSearchResult(), className: "find-replace-btn", title: "Previous", children: /* @__PURE__ */ g(Vr, { size: 15 }) }),
4119
- /* @__PURE__ */ g("button", { onClick: () => e.commands.nextSearchResult(), className: "find-replace-btn", title: "Next", children: /* @__PURE__ */ g(tn, { size: 15 }) }),
4178
+ /* @__PURE__ */ g("button", { onClick: () => e.commands.previousSearchResult(), className: "find-replace-btn", title: "Previous", children: /* @__PURE__ */ g(Kr, { size: 15 }) }),
4179
+ /* @__PURE__ */ g("button", { onClick: () => e.commands.nextSearchResult(), className: "find-replace-btn", title: "Next", children: /* @__PURE__ */ g(nn, { size: 15 }) }),
4120
4180
  /* @__PURE__ */ g(
4121
4181
  "button",
4122
4182
  {
4123
4183
  onClick: () => a((v) => !v),
4124
4184
  className: re("find-replace-btn", r && "find-replace-btn--active"),
4125
4185
  title: "Toggle Replace",
4126
- children: /* @__PURE__ */ g(Tt, { size: 15 })
4186
+ children: /* @__PURE__ */ g(It, { size: 15 })
4127
4187
  }
4128
4188
  ),
4129
- /* @__PURE__ */ g("button", { onClick: y, className: "find-replace-btn", title: "Close (Esc)", children: /* @__PURE__ */ g(Kr, { size: 15 }) })
4189
+ /* @__PURE__ */ g("button", { onClick: C, className: "find-replace-btn", title: "Close (Esc)", children: /* @__PURE__ */ g(Jr, { size: 15 }) })
4130
4190
  ] }),
4131
4191
  r && /* @__PURE__ */ A("div", { className: "find-replace-row", children: [
4132
4192
  /* @__PURE__ */ g(
4133
4193
  "input",
4134
4194
  {
4135
4195
  type: "text",
4136
- value: l,
4196
+ value: c,
4137
4197
  onChange: (v) => {
4138
- c(v.target.value), e.commands.setReplaceTerm(v.target.value);
4198
+ l(v.target.value), e.commands.setReplaceTerm(v.target.value);
4139
4199
  },
4140
4200
  onKeyDown: (v) => {
4141
4201
  v.key === "Enter" && e.commands.replaceCurrent();
@@ -4144,15 +4204,15 @@ const Is = ({ editor: e, onSelectionOptimize: t }) => {
4144
4204
  className: "find-replace-input"
4145
4205
  }
4146
4206
  ),
4147
- /* @__PURE__ */ g("button", { onClick: () => e.commands.replaceCurrent(), className: "find-replace-btn", title: "Replace", children: /* @__PURE__ */ g(Tt, { size: 15 }) }),
4148
- /* @__PURE__ */ g("button", { onClick: () => e.commands.replaceAll(), className: "find-replace-btn", title: "Replace All", children: /* @__PURE__ */ g(Jr, { size: 15 }) })
4207
+ /* @__PURE__ */ g("button", { onClick: () => e.commands.replaceCurrent(), className: "find-replace-btn", title: "Replace", children: /* @__PURE__ */ g(It, { size: 15 }) }),
4208
+ /* @__PURE__ */ g("button", { onClick: () => e.commands.replaceAll(), className: "find-replace-btn", title: "Replace All", children: /* @__PURE__ */ g(Xr, { size: 15 }) })
4149
4209
  ] })
4150
4210
  ] }) : null;
4151
- }, Ns = ({ editor: e }) => {
4152
- const { editorLanguage: t } = N(), n = t === "zh", r = Te(() => {
4153
- const a = e.state, i = a.doc.textBetween(0, a.doc.content.size, " ", "\0").replace(/\s/g, "").length, { from: l, to: c } = a.selection;
4211
+ }, _s = ({ editor: e }) => {
4212
+ const { editorLanguage: t } = k(), n = t === "zh", r = Te(() => {
4213
+ const a = e.state, i = a.doc.textBetween(0, a.doc.content.size, " ", "\0").replace(/\s/g, "").length, { from: c, to: l } = a.selection;
4154
4214
  let d = 0;
4155
- return l !== c && (d = a.doc.textBetween(l, c, " ", "\0").replace(/\s/g, "").length), { charCount: i, selectionCount: d };
4215
+ return c !== l && (d = a.doc.textBetween(c, l, " ", "\0").replace(/\s/g, "").length), { charCount: i, selectionCount: d };
4156
4216
  }, [e.state.doc, e.state.selection]);
4157
4217
  return /* @__PURE__ */ A("div", { className: "word-count-bar", children: [
4158
4218
  /* @__PURE__ */ A("span", { children: [
@@ -4166,34 +4226,34 @@ const Is = ({ editor: e, onSelectionOptimize: t }) => {
4166
4226
  r.selectionCount
4167
4227
  ] })
4168
4228
  ] });
4169
- }, ks = {
4229
+ }, As = {
4170
4230
  empty: "○",
4171
4231
  filled: "●"
4172
- }, _s = {
4232
+ }, Ls = {
4173
4233
  empty: "text-gray-400",
4174
4234
  filled: "text-green-500"
4175
- }, As = /* @__PURE__ */ new Set([
4235
+ }, Ps = /* @__PURE__ */ new Set([
4176
4236
  "technical_field",
4177
4237
  "background_art",
4178
4238
  "summary",
4179
4239
  "drawing_description",
4180
4240
  "detailed_description"
4181
- ]), Ls = ({ editor: e }) => {
4182
- const { editorLanguage: t } = N(), n = U(t), [r, a] = z(!1), [s, i] = z(0);
4241
+ ]), Rs = ({ editor: e }) => {
4242
+ const { editorLanguage: t } = k(), n = U(t), [r, a] = z(!1), [s, i] = z(0);
4183
4243
  B(() => {
4184
- const c = () => i((d) => d + 1);
4185
- return e.on("update", c), () => {
4186
- e.off("update", c);
4244
+ const l = () => i((d) => d + 1);
4245
+ return e.on("update", l), () => {
4246
+ e.off("update", l);
4187
4247
  };
4188
4248
  }, [e]);
4189
- const l = Te(() => {
4190
- const c = [];
4249
+ const c = Te(() => {
4250
+ const l = [];
4191
4251
  let d = !1;
4192
4252
  return e.state.doc.descendants((o, u) => {
4193
4253
  if (o.type.name === "patent_title") {
4194
4254
  if (!d) {
4195
4255
  const f = typeof n.bookTitle_description == "string" ? n.bookTitle_description : "说明书";
4196
- c.push({
4256
+ l.push({
4197
4257
  type: "book-group",
4198
4258
  pos: u,
4199
4259
  title: f,
@@ -4201,7 +4261,7 @@ const Is = ({ editor: e, onSelectionOptimize: t }) => {
4201
4261
  }), d = !0;
4202
4262
  }
4203
4263
  const m = o.textContent || "", h = m.trim().length > 0, p = typeof n.patentTitlePlaceholder == "string" ? n.patentTitlePlaceholder : "Patent Title";
4204
- return c.push({
4264
+ return l.push({
4205
4265
  type: "section",
4206
4266
  pos: u,
4207
4267
  title: h ? m.trim() : p,
@@ -4211,19 +4271,19 @@ const Is = ({ editor: e, onSelectionOptimize: t }) => {
4211
4271
  }), !1;
4212
4272
  }
4213
4273
  if (o.type.name === "patent_section") {
4214
- const m = o.attrs.sectionType, h = As.has(m), p = `sectionTitle_${m}`, f = typeof n[p] == "string" ? n[p] : m, y = o.textContent || "", w = y.trim().length > 0;
4215
- return c.push({
4274
+ const m = o.attrs.sectionType, h = Ps.has(m), p = `sectionTitle_${m}`, f = typeof n[p] == "string" ? n[p] : m, C = o.textContent || "", w = C.trim().length > 0;
4275
+ return l.push({
4216
4276
  type: "section",
4217
4277
  pos: u,
4218
4278
  title: f,
4219
4279
  state: w ? "filled" : "empty",
4220
- charCount: y.replace(/\s/g, "").length,
4280
+ charCount: C.replace(/\s/g, "").length,
4221
4281
  indent: h
4222
4282
  }), !1;
4223
4283
  }
4224
4284
  if (o.type.name === "heading") {
4225
4285
  const m = o.attrs.level, h = o.textContent || "";
4226
- return h.trim() && c.push({
4286
+ return h.trim() && l.push({
4227
4287
  type: "heading",
4228
4288
  pos: u,
4229
4289
  title: h,
@@ -4232,7 +4292,7 @@ const Is = ({ editor: e, onSelectionOptimize: t }) => {
4232
4292
  }), !1;
4233
4293
  }
4234
4294
  return !0;
4235
- }), c;
4295
+ }), l;
4236
4296
  }, [e, s, n]);
4237
4297
  return r ? /* @__PURE__ */ g("div", { className: "outline-panel outline-panel--collapsed", children: /* @__PURE__ */ g(
4238
4298
  "button",
@@ -4240,11 +4300,11 @@ const Is = ({ editor: e, onSelectionOptimize: t }) => {
4240
4300
  onClick: () => a(!1),
4241
4301
  className: "outline-panel-toggle",
4242
4302
  title: t === "zh" ? "展开大纲" : "Expand Outline",
4243
- children: /* @__PURE__ */ g(Xr, { size: 16 })
4303
+ children: /* @__PURE__ */ g(Qr, { size: 16 })
4244
4304
  }
4245
4305
  ) }) : /* @__PURE__ */ A("div", { className: "outline-panel", children: [
4246
4306
  /* @__PURE__ */ A("div", { className: "outline-panel-header", children: [
4247
- /* @__PURE__ */ g(en, { size: 14 }),
4307
+ /* @__PURE__ */ g(tn, { size: 14 }),
4248
4308
  /* @__PURE__ */ g("span", { children: t === "zh" ? "文档大纲" : "Outline" }),
4249
4309
  /* @__PURE__ */ g(
4250
4310
  "button",
@@ -4252,38 +4312,38 @@ const Is = ({ editor: e, onSelectionOptimize: t }) => {
4252
4312
  onClick: () => a(!0),
4253
4313
  className: "outline-panel-toggle ml-auto",
4254
4314
  title: t === "zh" ? "收起大纲" : "Collapse Outline",
4255
- children: /* @__PURE__ */ g(Qr, { size: 14 })
4315
+ children: /* @__PURE__ */ g(Yr, { size: 14 })
4256
4316
  }
4257
4317
  )
4258
4318
  ] }),
4259
4319
  /* @__PURE__ */ A("div", { className: "outline-panel-list", children: [
4260
- l.length === 0 && /* @__PURE__ */ g("div", { className: "outline-panel-empty", children: t === "zh" ? "暂无章节" : "No sections yet" }),
4261
- l.map((c, d) => /* @__PURE__ */ A(
4320
+ c.length === 0 && /* @__PURE__ */ g("div", { className: "outline-panel-empty", children: t === "zh" ? "暂无章节" : "No sections yet" }),
4321
+ c.map((l, d) => /* @__PURE__ */ A(
4262
4322
  "button",
4263
4323
  {
4264
4324
  className: re(
4265
4325
  "outline-panel-item",
4266
- c.type === "heading" && `outline-panel-item--h${c.level}`,
4267
- c.type === "book-group" && "outline-panel-item--book",
4268
- c.indent && "outline-panel-item--indent"
4326
+ l.type === "heading" && `outline-panel-item--h${l.level}`,
4327
+ l.type === "book-group" && "outline-panel-item--book",
4328
+ l.indent && "outline-panel-item--indent"
4269
4329
  ),
4270
4330
  onClick: () => {
4271
- c.type !== "book-group" && (e.chain().setTextSelection(c.pos + 1).focus().run(), requestAnimationFrame(() => {
4272
- const o = e.view.nodeDOM(c.pos);
4331
+ l.type !== "book-group" && (e.chain().setTextSelection(l.pos + 1).focus().run(), requestAnimationFrame(() => {
4332
+ const o = e.view.nodeDOM(l.pos);
4273
4333
  o == null || o.scrollIntoView({ behavior: "smooth", block: "start" });
4274
4334
  }));
4275
4335
  },
4276
4336
  children: [
4277
- c.type === "section" && c.state && /* @__PURE__ */ g("span", { className: re("outline-item-state", _s[c.state]), children: ks[c.state] || "○" }),
4278
- /* @__PURE__ */ g("span", { className: "outline-item-title", children: c.title }),
4279
- c.type !== "book-group" && /* @__PURE__ */ g("span", { className: "outline-item-count", children: c.charCount })
4337
+ l.type === "section" && l.state && /* @__PURE__ */ g("span", { className: re("outline-item-state", Ls[l.state]), children: As[l.state] || "○" }),
4338
+ /* @__PURE__ */ g("span", { className: "outline-item-title", children: l.title }),
4339
+ l.type !== "book-group" && /* @__PURE__ */ g("span", { className: "outline-item-count", children: l.charCount })
4280
4340
  ]
4281
4341
  },
4282
- `${c.pos}-${d}`
4342
+ `${l.pos}-${d}`
4283
4343
  ))
4284
4344
  ] })
4285
4345
  ] });
4286
- }, Ps = ({
4346
+ }, Ds = ({
4287
4347
  editor: e,
4288
4348
  mode: t = "edit",
4289
4349
  className: n
@@ -4297,16 +4357,16 @@ const Is = ({ editor: e, onSelectionOptimize: t }) => {
4297
4357
  t === "readonly" ? "cursor-default" : "cursor-text",
4298
4358
  n
4299
4359
  ),
4300
- children: /* @__PURE__ */ g(Ln, { editor: e, className: "h-full" })
4360
+ children: /* @__PURE__ */ g(Pn, { editor: e, className: "h-full" })
4301
4361
  }
4302
- )), yn = "patent-editor-draft", Rs = 1500, Ms = () => {
4362
+ )), vn = "patent-editor-draft", Ms = 1500, $s = () => {
4303
4363
  try {
4304
- const e = localStorage.getItem(yn);
4364
+ const e = localStorage.getItem(vn);
4305
4365
  return e ? JSON.parse(e) : null;
4306
4366
  } catch {
4307
4367
  return null;
4308
4368
  }
4309
- }, Ds = ({
4369
+ }, Os = ({
4310
4370
  initialContent: e,
4311
4371
  onChange: t,
4312
4372
  className: n,
@@ -4314,7 +4374,7 @@ const Is = ({ editor: e, onSelectionOptimize: t }) => {
4314
4374
  onEditorReady: a,
4315
4375
  onSelectionOptimize: s
4316
4376
  }) => {
4317
- const { setEditor: i, setDocument: l, editorLanguage: c, autoSaveStatus: d } = N(), { setAutoSaveStatus: o, setLastSavedAt: u } = N(), m = X(null), h = e || (t ? null : Ms()) || {
4377
+ const { setEditor: i, setDocument: c, editorLanguage: l, autoSaveStatus: d } = k(), { setAutoSaveStatus: o, setLastSavedAt: u } = k(), m = X(null), h = e || (t ? null : $s()) || {
4318
4378
  type: "doc",
4319
4379
  content: [
4320
4380
  {
@@ -4324,21 +4384,21 @@ const Is = ({ editor: e, onSelectionOptimize: t }) => {
4324
4384
  ]
4325
4385
  }, p = de((v) => {
4326
4386
  try {
4327
- o("saving"), localStorage.setItem(yn, JSON.stringify(v)), o("saved"), u(/* @__PURE__ */ new Date());
4387
+ o("saving"), localStorage.setItem(vn, JSON.stringify(v)), o("saved"), u(/* @__PURE__ */ new Date());
4328
4388
  } catch {
4329
4389
  o("error");
4330
4390
  }
4331
- }, [o, u]), f = Pn(
4332
- rs({
4391
+ }, [o, u]), f = Rn(
4392
+ ss({
4333
4393
  content: h,
4334
4394
  onUpdate: ({ editor: v }) => {
4335
- const S = v.getJSON();
4336
- l(S), W.notifyStateChange(v), t && t(S), t || (m.current && clearTimeout(m.current), m.current = setTimeout(() => {
4337
- p(S);
4338
- }, Rs));
4395
+ const x = v.getJSON();
4396
+ c(x), W.notifyStateChange(v), t && t(x), t || (m.current && clearTimeout(m.current), m.current = setTimeout(() => {
4397
+ p(x);
4398
+ }, Ms));
4339
4399
  },
4340
4400
  onCreate: ({ editor: v }) => {
4341
- i(v), a == null || a(v), W.initializePlugins(v), Ye(v).execCommand("patent.normalizeClaims"), W.notifyStateChange(v);
4401
+ i(v), a == null || a(v), W.initializePlugins(v), Ae(v).execCommand("patent.normalizeClaims"), W.notifyStateChange(v);
4342
4402
  },
4343
4403
  onSelectionUpdate: ({ editor: v }) => {
4344
4404
  W.notifySelectionChange(v);
@@ -4349,11 +4409,11 @@ const Is = ({ editor: e, onSelectionOptimize: t }) => {
4349
4409
  }
4350
4410
  }
4351
4411
  })
4352
- ), y = X(!1);
4412
+ ), C = X(!1);
4353
4413
  if (B(() => {
4354
4414
  if (!(!f || !e)) {
4355
- if (!y.current) {
4356
- y.current = !0;
4415
+ if (!C.current) {
4416
+ C.current = !0;
4357
4417
  return;
4358
4418
  }
4359
4419
  f.commands.setContent(e);
@@ -4362,43 +4422,43 @@ const Is = ({ editor: e, onSelectionOptimize: t }) => {
4362
4422
  m.current && clearTimeout(m.current), f && (W.destroyPlugins(f), f.destroy());
4363
4423
  }, [f]), B(() => {
4364
4424
  f && W.notifyStateChange(f);
4365
- }, [f, c]), !f)
4425
+ }, [f, l]), !f)
4366
4426
  return null;
4367
- const w = U(c), C = d === "saving" ? w.autoSaveSaving : d === "saved" ? w.autoSaveSaved : d === "error" ? w.autoSaveError : "";
4427
+ const w = U(l), y = d === "saving" ? w.autoSaveSaving : d === "saved" ? w.autoSaveSaved : d === "error" ? w.autoSaveError : "";
4368
4428
  return /* @__PURE__ */ A("div", { className: `editor-container flex flex-col h-full ${n}`, children: [
4369
4429
  !r && /* @__PURE__ */ A("div", { className: "flex items-center", children: [
4370
- /* @__PURE__ */ g(us, { editor: f }),
4371
- C && /* @__PURE__ */ g("span", { className: `auto-save-indicator auto-save-indicator--${d} ml-2`, children: C })
4430
+ /* @__PURE__ */ g(fs, { editor: f }),
4431
+ y && /* @__PURE__ */ g("span", { className: `auto-save-indicator auto-save-indicator--${d} ml-2`, children: y })
4372
4432
  ] }),
4373
- !r && f && /* @__PURE__ */ g(ms, { editor: f }),
4374
- !r && f && /* @__PURE__ */ g(xs, { editor: f }),
4375
- !r && f && /* @__PURE__ */ g(Is, { editor: f, onSelectionOptimize: s }),
4376
- !r && f && /* @__PURE__ */ g(Es, { editor: f }),
4433
+ !r && f && /* @__PURE__ */ g(gs, { editor: f }),
4434
+ !r && f && /* @__PURE__ */ g(Ts, { editor: f }),
4435
+ !r && f && /* @__PURE__ */ g(Ns, { editor: f, onSelectionOptimize: s }),
4436
+ !r && f && /* @__PURE__ */ g(ks, { editor: f }),
4377
4437
  /* @__PURE__ */ A("div", { className: "flex flex-1 overflow-hidden", children: [
4378
- !r && f && /* @__PURE__ */ g(Ls, { editor: f }),
4379
- /* @__PURE__ */ g("div", { className: "flex-1 overflow-y-auto bg-white p-4 relative", children: /* @__PURE__ */ g(Ps, { editor: f, mode: r ? "readonly" : "edit" }) })
4438
+ !r && f && /* @__PURE__ */ g(Rs, { editor: f }),
4439
+ /* @__PURE__ */ g("div", { className: "flex-1 overflow-y-auto bg-white p-4 relative", children: /* @__PURE__ */ g(Ds, { editor: f, mode: r ? "readonly" : "edit" }) })
4380
4440
  ] }),
4381
- !r && /* @__PURE__ */ g(Ns, { editor: f })
4441
+ !r && /* @__PURE__ */ g(_s, { editor: f })
4382
4442
  ] });
4383
4443
  };
4384
- function vn(e) {
4444
+ function Cn(e) {
4385
4445
  const t = e.getReader(), n = new TextDecoder();
4386
4446
  let r = "";
4387
4447
  return new ReadableStream({
4388
4448
  async pull(a) {
4389
4449
  var s;
4390
4450
  for (; ; ) {
4391
- const { done: i, value: l } = await t.read();
4451
+ const { done: i, value: c } = await t.read();
4392
4452
  if (i) {
4393
4453
  a.close();
4394
4454
  return;
4395
4455
  }
4396
- r += n.decode(l, { stream: !0 });
4397
- const c = r.split(`
4456
+ r += n.decode(c, { stream: !0 });
4457
+ const l = r.split(`
4398
4458
  `);
4399
- r = c.pop() || "";
4459
+ r = l.pop() || "";
4400
4460
  let d = "";
4401
- for (const o of c) {
4461
+ for (const o of l) {
4402
4462
  if (o.startsWith("event: ")) {
4403
4463
  d = o.slice(7).trim();
4404
4464
  continue;
@@ -4433,7 +4493,7 @@ function vn(e) {
4433
4493
  }
4434
4494
  });
4435
4495
  }
4436
- function $s(e, t) {
4496
+ function Fs(e, t) {
4437
4497
  let n = null;
4438
4498
  return {
4439
4499
  async request(r) {
@@ -4448,39 +4508,39 @@ function $s(e, t) {
4448
4508
  throw new Error(`AI service error: ${s.status} ${s.statusText}`);
4449
4509
  if (!s.body)
4450
4510
  throw new Error("AI service returned no body");
4451
- return vn(s.body);
4511
+ return Cn(s.body);
4452
4512
  },
4453
4513
  abort() {
4454
4514
  n == null || n.abort(), n = null;
4455
4515
  }
4456
4516
  };
4457
4517
  }
4458
- function Os(e, t) {
4518
+ function zs(e, t) {
4459
4519
  let n = null;
4460
4520
  const r = e.replace(/\/+$/, "");
4461
4521
  async function a(s, i) {
4462
- const l = await fetch(s, {
4522
+ const c = await fetch(s, {
4463
4523
  ...i,
4464
4524
  headers: { "Content-Type": "application/json", ...t, ...i == null ? void 0 : i.headers }
4465
4525
  });
4466
- if (!l.ok) throw new Error(`Chat API error: ${l.status} ${l.statusText}`);
4467
- const c = await l.json();
4468
- return c.data ?? c;
4526
+ if (!c.ok) throw new Error(`Chat API error: ${c.status} ${c.statusText}`);
4527
+ const l = await c.json();
4528
+ return l.data ?? l;
4469
4529
  }
4470
4530
  return {
4471
- async createSession(s, i, l) {
4531
+ async createSession(s, i, c) {
4472
4532
  return a(`${r}/api/v1/chat/sessions`, {
4473
4533
  method: "POST",
4474
- body: JSON.stringify({ patentId: s, title: i, language: l })
4534
+ body: JSON.stringify({ patentId: s, title: i, language: c })
4475
4535
  });
4476
4536
  },
4477
- async listSessions(s, i = 1, l = 20) {
4478
- const c = new URLSearchParams({ page: String(i), pageSize: String(l) });
4479
- return s && c.set("patentId", s), a(`${r}/api/v1/chat/sessions?${c}`);
4537
+ async listSessions(s, i = 1, c = 20) {
4538
+ const l = new URLSearchParams({ page: String(i), pageSize: String(c) });
4539
+ return s && l.set("patentId", s), a(`${r}/api/v1/chat/sessions?${l}`);
4480
4540
  },
4481
- async getMessages(s, i = 1, l = 50) {
4482
- const c = new URLSearchParams({ page: String(i), pageSize: String(l) });
4483
- return a(`${r}/api/v1/chat/sessions/${s}/messages?${c}`);
4541
+ async getMessages(s, i = 1, c = 50) {
4542
+ const l = new URLSearchParams({ page: String(i), pageSize: String(c) });
4543
+ return a(`${r}/api/v1/chat/sessions/${s}/messages?${l}`);
4484
4544
  },
4485
4545
  async deleteSession(s) {
4486
4546
  await fetch(`${r}/api/v1/chat/sessions/${s}`, {
@@ -4496,54 +4556,54 @@ function Os(e, t) {
4496
4556
  },
4497
4557
  async subscribeStream(s, i) {
4498
4558
  n = new AbortController();
4499
- const l = `${r}/api/v1/chat/sessions/${s}/stream?messageId=${i}`, c = await fetch(l, {
4559
+ const c = `${r}/api/v1/chat/sessions/${s}/stream?messageId=${i}`, l = await fetch(c, {
4500
4560
  headers: { Accept: "text/event-stream", ...t },
4501
4561
  signal: n.signal
4502
4562
  });
4503
- if (!c.ok) throw new Error(`Chat stream error: ${c.status} ${c.statusText}`);
4504
- if (!c.body) throw new Error("Chat stream returned no body");
4505
- return vn(c.body);
4563
+ if (!l.ok) throw new Error(`Chat stream error: ${l.status} ${l.statusText}`);
4564
+ if (!l.body) throw new Error("Chat stream returned no body");
4565
+ return Cn(l.body);
4506
4566
  },
4507
4567
  abort() {
4508
4568
  n == null || n.abort(), n = null;
4509
4569
  }
4510
4570
  };
4511
4571
  }
4512
- const Fs = Ht(
4513
- ({ initialContent: e, patentType: t, onChange: n, className: r, readOnly: a = !1, language: s, aiService: i, chatSessionAPI: l, aiBaseUrl: c, aiHeaders: d, onSelectionOptimize: o }, u) => {
4514
- const { setEditorLanguage: m, setAIService: h, setChatSessionAPI: p } = N(), f = X(null), y = de((C) => {
4515
- f.current = C;
4516
- }, []), w = Pe.useMemo(() => {
4572
+ const Bs = jt(
4573
+ ({ initialContent: e, patentType: t, onChange: n, className: r, readOnly: a = !1, language: s, aiService: i, chatSessionAPI: c, aiBaseUrl: l, aiHeaders: d, onSelectionOptimize: o }, u) => {
4574
+ const { setEditorLanguage: m, setAIService: h, setChatSessionAPI: p } = k(), f = X(null), C = de((y) => {
4575
+ f.current = y;
4576
+ }, []), w = De.useMemo(() => {
4517
4577
  if (e) return e;
4518
- if (t) return un(t);
4578
+ if (t) return mn(t);
4519
4579
  }, [e, t]);
4520
- return Pe.useEffect(() => {
4580
+ return De.useEffect(() => {
4521
4581
  s && m(s);
4522
- }, [s, m]), Pe.useEffect(() => {
4523
- i ? h(i) : c && h($s(c, d));
4524
- }, [i, c, d, h]), Pe.useEffect(() => {
4525
- l ? p(l) : c && p(Os(c, d));
4526
- }, [l, c, d, p]), Ut(u, () => ({
4582
+ }, [s, m]), De.useEffect(() => {
4583
+ i ? h(i) : l && h(Fs(l, d));
4584
+ }, [i, l, d, h]), De.useEffect(() => {
4585
+ c ? p(c) : l && p(zs(l, d));
4586
+ }, [c, l, d, p]), Wt(u, () => ({
4527
4587
  getContent: () => {
4528
- var C;
4529
- return ((C = f.current) == null ? void 0 : C.getJSON()) ?? null;
4588
+ var y;
4589
+ return ((y = f.current) == null ? void 0 : y.getJSON()) ?? null;
4530
4590
  },
4531
- setContent: (C) => {
4591
+ setContent: (y) => {
4532
4592
  var v;
4533
- (v = f.current) == null || v.commands.setContent(C);
4593
+ (v = f.current) == null || v.commands.setContent(y);
4534
4594
  },
4535
4595
  getEditor: () => f.current,
4536
- execCommand: async (C, v) => f.current ? Ye(f.current).execCommand(C, v) : null,
4596
+ execCommand: async (y, v) => f.current ? Ae(f.current).execCommand(y, v) : null,
4537
4597
  focus: () => {
4538
- var C;
4539
- (C = f.current) == null || C.commands.focus();
4598
+ var y;
4599
+ (y = f.current) == null || y.commands.focus();
4540
4600
  }
4541
4601
  })), /* @__PURE__ */ g(
4542
- Ds,
4602
+ Os,
4543
4603
  {
4544
4604
  initialContent: w,
4545
4605
  onChange: n,
4546
- onEditorReady: y,
4606
+ onEditorReady: C,
4547
4607
  className: r,
4548
4608
  readOnly: a,
4549
4609
  onSelectionOptimize: o
@@ -4551,30 +4611,30 @@ const Fs = Ht(
4551
4611
  );
4552
4612
  }
4553
4613
  );
4554
- Fs.displayName = "PatentEditor";
4555
- async function io(e, t, n) {
4556
- var a, s, i, l;
4614
+ Bs.displayName = "PatentEditor";
4615
+ async function co(e, t, n) {
4616
+ var a, s, i, c;
4557
4617
  let r = !1;
4558
- (a = n.onStart) == null || a.call(n), n.mode === "section" && typeof n.targetSectionPos == "number" && wn(e, n.targetSectionPos);
4618
+ (a = n.onStart) == null || a.call(n), n.mode === "section" && typeof n.targetSectionPos == "number" && xn(e, n.targetSectionPos);
4559
4619
  try {
4560
- let c = Cn(e, n);
4620
+ let l = wn(e, n);
4561
4621
  for (; ; ) {
4562
4622
  const { done: d, value: o } = await t.read();
4563
4623
  if (d) break;
4564
4624
  if (!o) continue;
4565
4625
  (s = n.onChunk) == null || s.call(n, o);
4566
- const u = e.state.tr.insertText(o, c);
4567
- e.view.dispatch(u), c = u.mapping.map(c, 1);
4626
+ const u = e.state.tr.insertText(o, l);
4627
+ e.view.dispatch(u), l = u.mapping.map(l, 1);
4568
4628
  }
4569
4629
  (i = n.onComplete) == null || i.call(n);
4570
- } catch (c) {
4571
- (l = n.onError) == null || l.call(n, c instanceof Error ? c : new Error(String(c)));
4630
+ } catch (l) {
4631
+ (c = n.onError) == null || c.call(n, l instanceof Error ? l : new Error(String(l)));
4572
4632
  }
4573
4633
  }
4574
- async function oo(e, t, n, r) {
4575
- var s, i, l, c, d, o, u, m;
4634
+ async function lo(e, t, n, r) {
4635
+ var s, i, c, l, d, o, u, m;
4576
4636
  const a = new AbortController();
4577
- (s = r.onStart) == null || s.call(r), r.mode === "section" && typeof r.targetSectionPos == "number" && wn(e, r.targetSectionPos);
4637
+ (s = r.onStart) == null || s.call(r), r.mode === "section" && typeof r.targetSectionPos == "number" && xn(e, r.targetSectionPos);
4578
4638
  try {
4579
4639
  const h = await fetch(t, {
4580
4640
  method: "POST",
@@ -4587,25 +4647,25 @@ async function oo(e, t, n, r) {
4587
4647
  const p = (i = h.body) == null ? void 0 : i.getReader();
4588
4648
  if (!p) throw new Error("No response body");
4589
4649
  const f = new TextDecoder();
4590
- let y = Cn(e, r), w = "";
4650
+ let C = wn(e, r), w = "";
4591
4651
  for (; ; ) {
4592
- const { done: C, value: v } = await p.read();
4593
- if (C) break;
4652
+ const { done: y, value: v } = await p.read();
4653
+ if (y) break;
4594
4654
  w += f.decode(v, { stream: !0 });
4595
- const S = w.split(`
4655
+ const x = w.split(`
4596
4656
  `);
4597
- w = S.pop() || "";
4598
- for (const _ of S) {
4657
+ w = x.pop() || "";
4658
+ for (const _ of x) {
4599
4659
  if (!_.startsWith("data: ")) continue;
4600
4660
  const L = _.slice(6).trim();
4601
4661
  if (L === "[DONE]")
4602
- return (l = r.onComplete) == null || l.call(r), { abort: () => a.abort() };
4662
+ return (c = r.onComplete) == null || c.call(r), { abort: () => a.abort() };
4603
4663
  try {
4604
- const P = JSON.parse(L), b = P.content || P.text || ((c = P.delta) == null ? void 0 : c.content) || "";
4664
+ const P = JSON.parse(L), b = P.content || P.text || ((l = P.delta) == null ? void 0 : l.content) || "";
4605
4665
  if (!b) continue;
4606
4666
  (d = r.onChunk) == null || d.call(r, b);
4607
- const T = e.state.tr.insertText(b, y);
4608
- e.view.dispatch(T), y = T.mapping.map(y, 1);
4667
+ const T = e.state.tr.insertText(b, C);
4668
+ e.view.dispatch(T), C = T.mapping.map(C, 1);
4609
4669
  } catch {
4610
4670
  }
4611
4671
  }
@@ -4616,7 +4676,7 @@ async function oo(e, t, n, r) {
4616
4676
  }
4617
4677
  return { abort: () => a.abort() };
4618
4678
  }
4619
- function Cn(e, t) {
4679
+ function wn(e, t) {
4620
4680
  if (t.mode === "section" && typeof t.targetSectionPos == "number") {
4621
4681
  const n = e.state.doc.nodeAt(t.targetSectionPos);
4622
4682
  if (n && n.type.name === "patent_section")
@@ -4624,7 +4684,7 @@ function Cn(e, t) {
4624
4684
  }
4625
4685
  return e.state.selection.from;
4626
4686
  }
4627
- function wn(e, t) {
4687
+ function xn(e, t) {
4628
4688
  const n = e.state.doc.nodeAt(t);
4629
4689
  if (!n || n.type.name !== "patent_section") return;
4630
4690
  const r = t + 1, a = t + n.nodeSize - 1;
@@ -4633,7 +4693,7 @@ function wn(e, t) {
4633
4693
  s.replaceWith(r, a, i), s.setMeta("addToHistory", !1), e.view.dispatch(s);
4634
4694
  }
4635
4695
  }
4636
- const Bt = {
4696
+ const Ut = {
4637
4697
  technical_field: {
4638
4698
  zh: "本发明涉及航天器自主导航与控制技术领域,具体涉及一种基于多传感器融合的航天器自主避障控制方法、系统、电子设备及计算机可读存储介质。该方法综合利用激光雷达、红外传感器和星敏感器的探测数据,通过实时环境感知与路径规划算法,实现航天器在复杂空间环境中的自主安全避障机动。",
4639
4699
  en: "The present invention relates to the field of autonomous navigation and control technology for spacecraft, and specifically to a method, system, electronic device, and computer-readable storage medium for autonomous obstacle avoidance control of spacecraft based on multi-sensor fusion."
@@ -4703,7 +4763,7 @@ S103:局部实时避障控制。采用模型预测控制(MPC)策略,以
4703
4763
  S104:安全验证。对计算得到的控制指令进行轨迹传播仿真,验证机动后轨迹在未来72小时内不会与TLE目录中的已知空间目标产生碰撞风险(miss distance > 1km)。`,
4704
4764
  en: "The technical solution of the embodiments of the present invention will be described clearly and completely below with reference to the drawings."
4705
4765
  }
4706
- }, ze = {
4766
+ }, He = {
4707
4767
  "help-draft": {
4708
4768
  zh: `当然可以帮你撰写技术方案!请先描述以下信息:
4709
4769
 
@@ -4763,7 +4823,7 @@ S104:安全验证。对计算得到的控制指令进行轨迹传播仿真,
4763
4823
  en: "That is a great question. As an AI patent writing assistant, I can help you with..."
4764
4824
  }
4765
4825
  }, oe = (e) => new Promise((t) => setTimeout(t, e));
4766
- function ft(e, t = 30) {
4826
+ function gt(e, t = 30) {
4767
4827
  let n = !1;
4768
4828
  return new ReadableStream({
4769
4829
  async pull(r) {
@@ -4781,47 +4841,47 @@ function ft(e, t = 30) {
4781
4841
  }
4782
4842
  });
4783
4843
  }
4784
- function zs(e) {
4785
- const t = [], n = We(e, 3);
4844
+ function Hs(e) {
4845
+ const t = [], n = Ge(e, 3);
4786
4846
  for (const r of n)
4787
4847
  t.push({ type: "delta", content: r });
4788
4848
  return t.push({ type: "done", usage: { tokens: e.length * 2 } }), t;
4789
4849
  }
4790
- function We(e, t) {
4850
+ function Ge(e, t) {
4791
4851
  const n = [];
4792
4852
  for (let r = 0; r < e.length; r += t)
4793
4853
  n.push(e.slice(r, r + t));
4794
4854
  return n;
4795
4855
  }
4796
- function Bs(e, t, n) {
4856
+ function Us(e, t, n) {
4797
4857
  const r = n === "zh", a = [];
4798
4858
  let s;
4799
- if (e.includes("技术方案") || e.includes("draft") ? s = ze["help-draft"][r ? "zh" : "en"] : e.includes("审查") || e.includes("review") || e.includes("Review") ? s = ze.review[r ? "zh" : "en"] : e.includes("权利要求") || e.includes("claims") || e.includes("Optimize") ? s = ze.claims[r ? "zh" : "en"] : s = ze.default[r ? "zh" : "en"], t.length > 0) {
4859
+ if (e.includes("技术方案") || e.includes("draft") ? s = He["help-draft"][r ? "zh" : "en"] : e.includes("审查") || e.includes("review") || e.includes("Review") ? s = He.review[r ? "zh" : "en"] : e.includes("权利要求") || e.includes("claims") || e.includes("Optimize") ? s = He.claims[r ? "zh" : "en"] : s = He.default[r ? "zh" : "en"], t.length > 0) {
4800
4860
  const i = r ? `正在分析引用的 ${t.length} 段文本并生成优化建议...
4801
4861
 
4802
4862
  ` : `Analyzing ${t.length} referenced text(s) and generating suggestions...
4803
4863
 
4804
4864
  `;
4805
- for (const l of We(i, 4))
4806
- a.push({ type: "delta", content: l });
4807
- for (const l of We(s, 4))
4808
- a.push({ type: "delta", content: l });
4809
- for (let l = 0; l < t.length; l++) {
4810
- const c = t[l], d = c.text;
4865
+ for (const c of Ge(i, 4))
4866
+ a.push({ type: "delta", content: c });
4867
+ for (const c of Ge(s, 4))
4868
+ a.push({ type: "delta", content: c });
4869
+ for (let c = 0; c < t.length; c++) {
4870
+ const l = t[c], d = l.text;
4811
4871
  let o;
4812
- r ? (o = d.replace(/一种/g, "一种基于本发明的").replace(/方法/g, "技术方案").replace(/包括/g, "具体包括"), o === d && (o = `根据本发明优选实施例,${d}`)) : o = `According to a preferred embodiment, ${d.charAt(0).toLowerCase()}${d.slice(1)}`, c.from != null && c.to != null ? a.push({
4872
+ r ? (o = d.replace(/一种/g, "一种基于本发明的").replace(/方法/g, "技术方案").replace(/包括/g, "具体包括"), o === d && (o = `根据本发明优选实施例,${d}`)) : o = `According to a preferred embodiment, ${d.charAt(0).toLowerCase()}${d.slice(1)}`, l.from != null && l.to != null ? a.push({
4813
4873
  type: "patch",
4814
4874
  patch: {
4815
4875
  op: "replace",
4816
- target: { type: "ref", refIndex: l },
4876
+ target: { type: "ref", refIndex: c },
4817
4877
  content: o,
4818
4878
  reason: r ? "优化为更专业的专利表述" : "Optimized for professional patent language"
4819
4879
  }
4820
- }) : c.source ? a.push({
4880
+ }) : l.source ? a.push({
4821
4881
  type: "patch",
4822
4882
  patch: {
4823
4883
  op: "replace",
4824
- target: { type: "section", sectionType: c.source },
4884
+ target: { type: "section", sectionType: l.source },
4825
4885
  search: d,
4826
4886
  content: o,
4827
4887
  reason: r ? "优化为更专业的专利表述" : "Optimized for professional patent language"
@@ -4837,39 +4897,39 @@ function Bs(e, t, n) {
4837
4897
  });
4838
4898
  }
4839
4899
  } else
4840
- for (const i of We(s, 4))
4900
+ for (const i of Ge(s, 4))
4841
4901
  a.push({ type: "delta", content: i });
4842
4902
  return a.push({ type: "done", usage: { tokens: s.length * 2 } }), a;
4843
4903
  }
4844
- function co() {
4904
+ function uo() {
4845
4905
  let e = null;
4846
4906
  return {
4847
4907
  async request(t) {
4848
- var l;
4908
+ var c;
4849
4909
  if (e = new AbortController(), await oe(300), e.signal.aborted)
4850
4910
  throw new DOMException("Aborted", "AbortError");
4851
- const n = t.language === "zh" ? "zh" : "en", r = t.sectionType || "technical_field", a = ((l = Bt[r]) == null ? void 0 : l[n]) || Bt.technical_field[n];
4911
+ const n = t.language === "zh" ? "zh" : "en", r = t.sectionType || "technical_field", a = ((c = Ut[r]) == null ? void 0 : c[n]) || Ut.technical_field[n];
4852
4912
  let s = a;
4853
4913
  t.instruction && (s = (n === "zh" ? `[基于指令"${t.instruction}"生成]
4854
4914
 
4855
4915
  ` : `[Generated based on instruction "${t.instruction}"]
4856
4916
 
4857
4917
  `) + a);
4858
- const i = zs(s);
4859
- return ft(i, 25);
4918
+ const i = Hs(s);
4919
+ return gt(i, 25);
4860
4920
  },
4861
4921
  abort() {
4862
4922
  e == null || e.abort(), e = null;
4863
4923
  }
4864
4924
  };
4865
4925
  }
4866
- function lo() {
4926
+ function mo() {
4867
4927
  const e = /* @__PURE__ */ new Map();
4868
4928
  let t = null, n = null;
4869
4929
  return {
4870
4930
  async createSession(r, a, s) {
4871
4931
  await oe(100);
4872
- const i = `sess_${Date.now()}`, l = {
4932
+ const i = `sess_${Date.now()}`, c = {
4873
4933
  sessionId: i,
4874
4934
  patentId: r || void 0,
4875
4935
  title: a || (s === "zh" ? "新对话" : "New Chat"),
@@ -4877,7 +4937,7 @@ function lo() {
4877
4937
  createdAt: (/* @__PURE__ */ new Date()).toISOString(),
4878
4938
  updatedAt: (/* @__PURE__ */ new Date()).toISOString()
4879
4939
  };
4880
- return e.set(i, { session: l, messages: [] }), l;
4940
+ return e.set(i, { session: c, messages: [] }), c;
4881
4941
  },
4882
4942
  async listSessions() {
4883
4943
  await oe(50);
@@ -4906,39 +4966,39 @@ function lo() {
4906
4966
  status: "done",
4907
4967
  createdAt: (/* @__PURE__ */ new Date()).toISOString()
4908
4968
  }), s.session.messageCount = s.messages.length, s.session.lastMessage = a.content, s.session.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
4909
- const l = Bs(
4969
+ const c = Us(
4910
4970
  a.content,
4911
4971
  a.references || [],
4912
4972
  a.language
4913
4973
  );
4914
- return n = { messageId: i, events: l }, { messageId: i, sessionId: r, status: "processing" };
4974
+ return n = { messageId: i, events: c }, { messageId: i, sessionId: r, status: "processing" };
4915
4975
  },
4916
4976
  async subscribeStream(r, a) {
4917
4977
  t = new AbortController(), await oe(100);
4918
4978
  const s = e.get(r);
4919
4979
  if (!s) throw new Error("Session not found");
4920
4980
  if (!n || n.messageId !== a)
4921
- return ft([{ type: "done" }]);
4981
+ return gt([{ type: "done" }]);
4922
4982
  const i = n.events;
4923
4983
  n = null;
4924
- const l = ft(i, 18), c = `${a}_a`;
4984
+ const c = gt(i, 18), l = `${a}_a`;
4925
4985
  let d = "";
4926
4986
  for (const o of i)
4927
4987
  o.type === "delta" && (d += o.content);
4928
4988
  return s.messages.push({
4929
- messageId: c,
4989
+ messageId: l,
4930
4990
  role: "assistant",
4931
4991
  content: d,
4932
4992
  status: "done",
4933
4993
  createdAt: (/* @__PURE__ */ new Date()).toISOString()
4934
- }), s.session.messageCount = s.messages.length, s.session.updatedAt = (/* @__PURE__ */ new Date()).toISOString(), l;
4994
+ }), s.session.messageCount = s.messages.length, s.session.updatedAt = (/* @__PURE__ */ new Date()).toISOString(), c;
4935
4995
  },
4936
4996
  abort() {
4937
4997
  t == null || t.abort(), t = null;
4938
4998
  }
4939
4999
  };
4940
5000
  }
4941
- function Hs(e) {
5001
+ function js(e) {
4942
5002
  const t = [], n = e.replace(/\r\n/g, `
4943
5003
  `).trim();
4944
5004
  if (!n) return t;
@@ -4953,98 +5013,98 @@ function Hs(e) {
4953
5013
  if (a.length === 0)
4954
5014
  return t.push({ number: 1, text: n, dependsOn: [] }), t;
4955
5015
  for (let i = 0; i < a.length; i++) {
4956
- const l = a[i].index + a[i].matchLength, c = i + 1 < a.length ? a[i + 1].index : n.length, d = n.slice(l, c).trim(), o = a[i].number, u = Us(d, o);
5016
+ const c = a[i].index + a[i].matchLength, l = i + 1 < a.length ? a[i + 1].index : n.length, d = n.slice(c, l).trim(), o = a[i].number, u = Ws(d, o);
4957
5017
  t.push({ number: o, text: d, dependsOn: u });
4958
5018
  }
4959
5019
  return t;
4960
5020
  }
4961
- function Us(e, t) {
5021
+ function Ws(e, t) {
4962
5022
  const n = [], r = /根据权利要求(\d+)(?:\s*[-~至到]\s*(\d+))?/g;
4963
5023
  let a;
4964
5024
  for (; (a = r.exec(e)) !== null; ) {
4965
- const i = parseInt(a[1], 10), l = a[2] ? parseInt(a[2], 10) : i;
4966
- for (let c = i; c <= l; c++)
4967
- c !== t && c > 0 && n.push(c);
5025
+ const i = parseInt(a[1], 10), c = a[2] ? parseInt(a[2], 10) : i;
5026
+ for (let l = i; l <= c; l++)
5027
+ l !== t && l > 0 && n.push(l);
4968
5028
  }
4969
5029
  const s = /claims?\s+(\d+)(?:\s*[-~to]+\s*(\d+))?/gi;
4970
5030
  for (; (a = s.exec(e)) !== null; ) {
4971
- const i = parseInt(a[1], 10), l = a[2] ? parseInt(a[2], 10) : i;
4972
- for (let c = i; c <= l; c++)
4973
- c !== t && c > 0 && n.push(c);
5031
+ const i = parseInt(a[1], 10), c = a[2] ? parseInt(a[2], 10) : i;
5032
+ for (let l = i; l <= c; l++)
5033
+ l !== t && l > 0 && n.push(l);
4974
5034
  }
4975
- return [...new Set(n)].sort((i, l) => i - l);
5035
+ return [...new Set(n)].sort((i, c) => i - c);
4976
5036
  }
4977
- function js() {
5037
+ function qs() {
4978
5038
  return `claim_${Date.now().toString(36)}_${Math.random().toString(36).slice(2, 8)}`;
4979
5039
  }
4980
- function uo(e) {
4981
- return Hs(e).map((n) => ({
5040
+ function fo(e) {
5041
+ return js(e).map((n) => ({
4982
5042
  type: "claim",
4983
5043
  attrs: {
4984
5044
  number: n.number,
4985
- claimId: js(),
5045
+ claimId: qs(),
4986
5046
  dependsOn: n.dependsOn,
4987
5047
  dependsOnClaimIds: []
4988
5048
  },
4989
5049
  content: n.text ? [{ type: "text", text: n.text }] : void 0
4990
5050
  }));
4991
5051
  }
4992
- const Ws = -1, qs = 1, Gs = 0, xn = new ke("docDiff");
4993
- let ct = null;
4994
- function Vs() {
4995
- return ct || (ct = new qt()), ct;
5052
+ const Gs = -1, Vs = 1, Ks = 0, Sn = new _e("docDiff");
5053
+ let lt = null;
5054
+ function Js() {
5055
+ return lt || (lt = new Gt()), lt;
4996
5056
  }
4997
- function Ks(e, t, n) {
5057
+ function Xs(e, t, n) {
4998
5058
  const r = [];
4999
5059
  return e.nodesBetween(t, n, (a, s) => {
5000
5060
  if (a.isTextblock) {
5001
- const i = s + 1, l = s + a.nodeSize - 1, c = Math.max(i, t), d = Math.min(l, n);
5002
- return d > c && r.push({ from: c, to: d }), !1;
5061
+ const i = s + 1, c = s + a.nodeSize - 1, l = Math.max(i, t), d = Math.min(c, n);
5062
+ return d > l && r.push({ from: l, to: d }), !1;
5003
5063
  }
5004
5064
  return !0;
5005
5065
  }), r;
5006
5066
  }
5007
- function mo(e, t) {
5008
- const n = e.state.doc, r = n.content.size, { text: a, segments: s } = an(e, 0, r), i = Vs(), l = i.diff_main(t, a);
5009
- i.diff_cleanupSemantic(l);
5010
- const c = [];
5067
+ function go(e, t) {
5068
+ const n = e.state.doc, r = n.content.size, { text: a, segments: s } = sn(e, 0, r), i = Js(), c = i.diff_main(t, a);
5069
+ i.diff_cleanupSemantic(c);
5070
+ const l = [];
5011
5071
  let d = 0;
5012
- for (const [m, h] of l)
5013
- if (m === Gs)
5072
+ for (const [m, h] of c)
5073
+ if (m === Ks)
5014
5074
  d += h.length;
5015
- else if (m === qs) {
5075
+ else if (m === Vs) {
5016
5076
  let p = 0;
5017
5077
  for (; p < h.length; ) {
5018
5078
  for (; p < h.length && h[p] === "\0"; ) p++;
5019
5079
  if (p >= h.length) break;
5020
5080
  const f = p;
5021
5081
  for (; p < h.length && h[p] !== "\0"; ) p++;
5022
- const y = Ie(s, d + f), w = Ie(s, d + p);
5023
- if (y >= 0 && w >= 0 && w > y)
5024
- for (const C of Ks(n, y, w))
5025
- c.push(
5026
- le.inline(C.from, C.to, { class: "patch-diff-insert-inline" })
5082
+ const C = Ee(s, d + f), w = Ee(s, d + p);
5083
+ if (C >= 0 && w >= 0 && w > C)
5084
+ for (const y of Xs(n, C, w))
5085
+ l.push(
5086
+ le.inline(y.from, y.to, { class: "patch-diff-insert-inline" })
5027
5087
  );
5028
5088
  }
5029
5089
  d += h.length;
5030
- } else if (m === Ws) {
5031
- const p = Ie(s, d);
5090
+ } else if (m === Gs) {
5091
+ const p = Ee(s, d);
5032
5092
  if (p >= 0) {
5033
5093
  const f = h.replace(/\0/g, " ");
5034
- c.push(
5094
+ l.push(
5035
5095
  le.widget(
5036
5096
  p,
5037
5097
  () => {
5038
- const y = document.createElement("span");
5039
- return y.className = "patch-diff-delete", y.textContent = f, y;
5098
+ const C = document.createElement("span");
5099
+ return C.className = "patch-diff-delete", C.textContent = f, C;
5040
5100
  },
5041
5101
  { side: -1 }
5042
5102
  )
5043
5103
  );
5044
5104
  }
5045
5105
  }
5046
- const o = Ee.create(n, c), u = new Ke({
5047
- key: xn,
5106
+ const o = Ne.create(n, l), u = new Xe({
5107
+ key: Sn,
5048
5108
  props: {
5049
5109
  decorations() {
5050
5110
  return o;
@@ -5053,109 +5113,109 @@ function mo(e, t) {
5053
5113
  });
5054
5114
  e.registerPlugin(u);
5055
5115
  }
5056
- function fo(e) {
5057
- e.unregisterPlugin(xn);
5116
+ function po(e) {
5117
+ e.unregisterPlugin(Sn);
5058
5118
  }
5059
- function go(e, t) {
5119
+ function ho(e, t) {
5060
5120
  const n = [], r = t === "zh";
5061
5121
  let a = 0;
5062
5122
  const s = () => `v_${++a}`;
5063
- return e.state.doc.descendants((i, l) => {
5123
+ return e.state.doc.descendants((i, c) => {
5064
5124
  if (i.type.name === "patent_title") {
5065
- const c = i.textContent.trim();
5066
- if (c.length === 0)
5125
+ const l = i.textContent.trim();
5126
+ if (l.length === 0)
5067
5127
  n.push({
5068
5128
  id: s(),
5069
5129
  severity: "warning",
5070
5130
  message: r ? "专利名称为空" : "Patent title is empty",
5071
5131
  sectionType: "patent_title",
5072
- pos: l
5132
+ pos: c
5073
5133
  });
5074
5134
  else {
5075
- const d = c.replace(/\s/g, "").length;
5135
+ const d = l.replace(/\s/g, "").length;
5076
5136
  d > 25 && r && n.push({
5077
5137
  id: s(),
5078
5138
  severity: "error",
5079
5139
  message: `专利名称超过25个汉字(当前${d}字)`,
5080
5140
  sectionType: "patent_title",
5081
- pos: l
5141
+ pos: c
5082
5142
  });
5083
5143
  }
5084
5144
  return !1;
5085
5145
  }
5086
5146
  if (i.type.name === "patent_section") {
5087
- const c = i.attrs.sectionType, d = i.textContent.trim();
5147
+ const l = i.attrs.sectionType, d = i.textContent.trim();
5088
5148
  if (d.length === 0 && n.push({
5089
5149
  id: s(),
5090
5150
  severity: "warning",
5091
- message: r ? `章节"${c}"内容为空` : `Section "${c}" is empty`,
5092
- sectionType: c,
5093
- pos: l
5094
- }), c === "abstract") {
5151
+ message: r ? `章节"${l}"内容为空` : `Section "${l}" is empty`,
5152
+ sectionType: l,
5153
+ pos: c
5154
+ }), l === "abstract") {
5095
5155
  const o = d.replace(/\s/g, "").length;
5096
5156
  o > 0 && o < 50 && n.push({
5097
5157
  id: s(),
5098
5158
  severity: "warning",
5099
5159
  message: r ? `摘要字数过少(${o}字),建议50~300字` : `Abstract too short (${o} chars), recommend 50-300`,
5100
- sectionType: c,
5101
- pos: l
5160
+ sectionType: l,
5161
+ pos: c
5102
5162
  }), o > 300 && n.push({
5103
5163
  id: s(),
5104
5164
  severity: "warning",
5105
5165
  message: r ? `摘要字数过多(${o}字),建议不超过300字` : `Abstract too long (${o} chars), recommend ≤300`,
5106
- sectionType: c,
5107
- pos: l
5166
+ sectionType: l,
5167
+ pos: c
5108
5168
  });
5109
5169
  }
5110
5170
  return !1;
5111
5171
  }
5112
5172
  if (i.type.name === "claim") {
5113
- const c = i.textContent.trim();
5114
- c.length > 0 && !c.endsWith("。") && !c.endsWith(".") && n.push({
5173
+ const l = i.textContent.trim();
5174
+ l.length > 0 && !l.endsWith("。") && !l.endsWith(".") && n.push({
5115
5175
  id: s(),
5116
5176
  severity: "warning",
5117
5177
  message: r ? `权利要求${i.attrs.number}末尾应以句号结束` : `Claim ${i.attrs.number} should end with a period`,
5118
- pos: l
5178
+ pos: c
5119
5179
  });
5120
5180
  }
5121
5181
  return !0;
5122
5182
  }), n;
5123
5183
  }
5124
5184
  export {
5125
- Ds as EditorView,
5126
- rn as PatchDiffPluginKey,
5127
- Fs as PatentEditor,
5128
- no as acceptAllPatches,
5129
- eo as acceptPatch,
5130
- mo as applyDocDiffDecorations,
5131
- so as buildAIContext,
5132
- uo as buildClaimsJSONContent,
5133
- un as buildPatentDocument,
5134
- Zi as clearPatches,
5135
- Os as createChatSessionAPI,
5136
- Ye as createCommandExecutor,
5137
- rs as createEditorConfig,
5138
- co as createMockAIService,
5139
- lo as createMockChatSessionAPI,
5140
- $s as createSSEAdapter,
5141
- ls as exportToPdf,
5142
- Ft as exportToWord,
5143
- hs as extractClaimsFromEditor,
5144
- bn as findSectionAtCursor,
5145
- Ss as getAllSections,
5146
- ao as getMissingSectionDeps,
5147
- Qi as getPatches,
5148
- Xi as onPatchChange,
5185
+ Os as EditorView,
5186
+ an as PatchDiffPluginKey,
5187
+ Bs as PatentEditor,
5188
+ ao as acceptAllPatches,
5189
+ no as acceptPatch,
5190
+ go as applyDocDiffDecorations,
5191
+ oo as buildAIContext,
5192
+ fo as buildClaimsJSONContent,
5193
+ mn as buildPatentDocument,
5194
+ to as clearPatches,
5195
+ zs as createChatSessionAPI,
5196
+ Ae as createCommandExecutor,
5197
+ ss as createEditorConfig,
5198
+ uo as createMockAIService,
5199
+ mo as createMockChatSessionAPI,
5200
+ Fs as createSSEAdapter,
5201
+ us as exportToPdf,
5202
+ Bt as exportToWord,
5203
+ ys as extractClaimsFromEditor,
5204
+ yn as findSectionAtCursor,
5205
+ Is as getAllSections,
5206
+ io as getMissingSectionDeps,
5207
+ Zi as getPatches,
5208
+ Yi as onPatchChange,
5149
5209
  W as pluginManager,
5150
- ro as rejectAllPatches,
5151
- to as rejectPatch,
5152
- fo as removeDocDiffDecorations,
5153
- Ji as resolvePatchTarget,
5154
- hn as sectionContextDeps,
5155
- Yi as setPatches,
5156
- N as useEditorStore,
5157
- go as validatePatentDocument,
5158
- io as writeStream,
5159
- oo as writeStreamFromSSE
5210
+ so as rejectAllPatches,
5211
+ ro as rejectPatch,
5212
+ po as removeDocDiffDecorations,
5213
+ Qi as resolvePatchTarget,
5214
+ bn as sectionContextDeps,
5215
+ eo as setPatches,
5216
+ k as useEditorStore,
5217
+ ho as validatePatentDocument,
5218
+ co as writeStream,
5219
+ lo as writeStreamFromSSE
5160
5220
  };
5161
5221
  //# sourceMappingURL=lib.js.map