@hiai-gg/docsmint 2.1.1 → 2.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -8,18 +8,19 @@ import { t as o } from "../action_cancel-BdsWzQKU.js";
8
8
  import { t as s } from "../action_loading-iQ0KsN6i.js";
9
9
  import { t as c } from "../error_generic-BlWqOE-a.js";
10
10
  import { l } from "../version_snapshot_label_placeholder-BhKq1NQ7.js";
11
- import { a as u, c as d, d as f, f as p, i as m, l as h, n as g, o as _, r as v, s as y, t as ee, u as b } from "../version_restored_from-DYFFSuQj.js";
12
- import { t as x } from "../version_create_snapshot-D8xjbuCq.js";
13
- import { t as te } from "../rotate-ccw-DAUX7np7.js";
14
- import { n as S, t as C } from "../client-BDdDd84W.js";
15
- import { t as w } from "../CreateSnapshotDialog-BLrtuYs5.js";
16
- import { a as T } from "../route-context-6OHiGtfb.js";
11
+ import { a as u, c as d, d as f, f as p, i as m, l as ee, n as te, o as h, r as g, s as _, t as ne, u as v } from "../version_restored_from-DYFFSuQj.js";
12
+ import { t as y } from "../version_create_snapshot-D8xjbuCq.js";
13
+ import { t as re } from "../rotate-ccw-DAUX7np7.js";
14
+ import { n as b, t as x } from "../client-BDdDd84W.js";
15
+ import { t as S } from "../CreateSnapshotDialog-BLrtuYs5.js";
16
+ import { a as C } from "../route-context-6OHiGtfb.js";
17
17
  import "svelte/internal/disclose-version";
18
- import * as E from "svelte/internal/client";
18
+ import * as w from "svelte/internal/client";
19
+ import { onDestroy as T } from "svelte";
19
20
  import "svelte/internal/flags/legacy";
20
21
  // ../node_modules/.bun/lucide-svelte@1.0.1+5d720e49779a0e36/node_modules/lucide-svelte/dist/icons/history.svelte
21
- function D(e, t) {
22
- let n = E.legacy_rest_props(t, [
22
+ function E(e, t) {
23
+ let n = w.legacy_rest_props(t, [
23
24
  "children",
24
25
  "$$slots",
25
26
  "$$events",
@@ -29,269 +30,337 @@ function D(e, t) {
29
30
  ["path", { d: "M3 3v5h5" }],
30
31
  ["path", { d: "M12 7v5l4 2" }]
31
32
  ];
32
- i(e, E.spread_props({ name: "history" }, () => n, {
33
+ i(e, w.spread_props({ name: "history" }, () => n, {
33
34
  get iconNode() {
34
35
  return r;
35
36
  },
36
37
  children: (e, n) => {
37
- var r = E.comment(), i = E.first_child(r);
38
- E.slot(i, t, "default", {}, null), E.append(e, r);
38
+ var r = w.comment(), i = w.first_child(r);
39
+ w.slot(i, t, "default", {}, null), w.append(e, r);
39
40
  },
40
41
  $$slots: { default: !0 }
41
42
  }));
42
43
  }
43
44
  // ../node_modules/.bun/lucide-svelte@1.0.1+5d720e49779a0e36/node_modules/lucide-svelte/dist/icons/star.svelte
44
- function O(e, t) {
45
- let n = E.legacy_rest_props(t, [
45
+ function D(e, t) {
46
+ let n = w.legacy_rest_props(t, [
46
47
  "children",
47
48
  "$$slots",
48
49
  "$$events",
49
50
  "$$legacy"
50
51
  ]), r = [["path", { d: "M11.525 2.295a.53.53 0 0 1 .95 0l2.31 4.679a2.123 2.123 0 0 0 1.595 1.16l5.166.756a.53.53 0 0 1 .294.904l-3.736 3.638a2.123 2.123 0 0 0-.611 1.878l.882 5.14a.53.53 0 0 1-.771.56l-4.618-2.428a2.122 2.122 0 0 0-1.973 0L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.122 2.122 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a2.122 2.122 0 0 0 1.597-1.16z" }]];
51
- i(e, E.spread_props({ name: "star" }, () => n, {
52
+ i(e, w.spread_props({ name: "star" }, () => n, {
52
53
  get iconNode() {
53
54
  return r;
54
55
  },
55
56
  children: (e, n) => {
56
- var r = E.comment(), i = E.first_child(r);
57
- E.slot(i, t, "default", {}, null), E.append(e, r);
57
+ var r = w.comment(), i = w.first_child(r);
58
+ w.slot(i, t, "default", {}, null), w.append(e, r);
58
59
  },
59
60
  $$slots: { default: !0 }
60
61
  }));
61
62
  }
62
63
  // src/lib/components/VersionHistory.svelte
63
- var ne = E.from_html("<div class=\"inline-flex w-full overflow-hidden rounded-md border border-border text-xs\" role=\"tablist\"><button type=\"button\" role=\"tab\"> </button> <button type=\"button\" role=\"tab\"> </button></div>"), re = E.from_html("<div class=\"flex items-center justify-center gap-2 py-6 text-sm text-muted-foreground\"><!> <span> </span></div>"), ie = E.from_html("<p class=\"py-4 text-center text-xs text-destructive\"> </p>"), ae = E.from_html("<p class=\"py-4 text-center text-xs text-muted-foreground\"> </p>"), oe = E.from_html("<span class=\"truncate text-xs font-medium text-foreground\"> </span>"), se = E.from_html("<span class=\"truncate text-[11px] text-muted-foreground\"> </span>"), ce = E.from_html("<div class=\"mt-1 flex flex-wrap items-center gap-1\"><span class=\"inline-flex items-center gap-1 rounded-full bg-amber-100 px-2 py-0.5 text-[10px] font-medium text-amber-800 dark:bg-amber-900/30 dark:text-amber-300\"><!> </span> <!></div>"), le = E.from_html("<div class=\"mt-1 inline-flex items-center gap-1 text-[11px] text-muted-foreground\"><!> <code class=\"rounded bg-muted px-1 font-mono text-[10px]\"> </code></div>"), ue = E.from_html("<div class=\"flex items-start gap-3 rounded-md border border-border p-3 text-sm hover:bg-accent transition-colors\"><!> <div class=\"flex-1 min-w-0\"><div class=\"flex items-center justify-between gap-2\"><div class=\"flex flex-col gap-0.5 min-w-0\"><!> <span class=\"text-xs text-muted-foreground\"> </span></div> <button type=\"button\" class=\"inline-flex items-center gap-1 rounded-md px-2 py-1 text-xs text-muted-foreground hover:bg-background hover:text-foreground transition-colors\"><!> </button></div> <!> <!> <p class=\"mt-1 truncate text-xs text-muted-foreground\"> </p></div></div>"), de = E.from_html("<div class=\"flex flex-col gap-1 overflow-y-auto max-h-80\"></div>"), fe = E.from_html("<p class=\"sr-only\" role=\"alert\"> </p>"), pe = E.from_html("<div class=\"flex flex-col gap-2 p-4\"><div class=\"flex items-center justify-between gap-2\"><div class=\"flex items-center gap-2 text-sm font-medium text-foreground\"><!> <span> </span></div> <button type=\"button\" class=\"inline-flex items-center gap-1 rounded-md border border-border bg-background px-2 py-1 text-xs font-medium hover:bg-accent disabled:opacity-50\"><!> </button></div> <!> <!></div> <!> <!> <!>", 1);
64
- function k(i, k) {
65
- E.push(k, !0);
66
- let A = E.state(E.proxy([])), j = E.state(!0), M = E.state(null), N = E.state("all"), P = E.state(!1), F = E.state(!1), I = E.state(null), L = E.state(!1), R = E.state(null), z = T();
67
- async function B() {
68
- E.set(j, !0), E.set(M, null);
64
+ var ie = w.from_html("<div class=\"inline-flex w-full overflow-hidden rounded-md border border-border text-xs\" role=\"tablist\"><button type=\"button\" role=\"tab\"> </button> <button type=\"button\" role=\"tab\"> </button></div>"), ae = w.from_html("<p role=\"status\" class=\"text-sm text-muted-foreground\">Opening version…</p>"), oe = w.from_html("<p role=\"alert\" class=\"text-sm text-destructive\"> </p>"), se = w.from_html("<button type=\"button\" class=\"self-start rounded-md border border-border px-3 py-2 text-sm\">Return to current</button>"), ce = w.from_html("<div class=\"flex items-center justify-center gap-2 py-6 text-sm text-muted-foreground\"><!> <span> </span></div>"), le = w.from_html("<p class=\"py-4 text-center text-xs text-destructive\"> </p>"), ue = w.from_html("<p class=\"py-4 text-center text-xs text-muted-foreground\"> </p>"), de = w.from_html("<span class=\"truncate text-xs font-medium text-foreground\"> </span>"), fe = w.from_html("<span class=\"truncate text-[11px] text-muted-foreground\"> </span>"), pe = w.from_html("<div class=\"mt-1 flex flex-wrap items-center gap-1\"><span class=\"inline-flex items-center gap-1 rounded-full bg-amber-100 px-2 py-0.5 text-[10px] font-medium text-amber-800 dark:bg-amber-900/30 dark:text-amber-300\"><!> </span> <!></div>"), me = w.from_html("<div class=\"mt-1 inline-flex items-center gap-1 text-[11px] text-muted-foreground\"><!> <code class=\"rounded bg-muted px-1 font-mono text-[10px]\"> </code></div>"), he = w.from_html("<button type=\"button\" class=\"mt-1 block w-full truncate rounded text-left text-xs text-muted-foreground hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring\"> </button>"), ge = w.from_html("<p class=\"mt-1 truncate text-xs text-muted-foreground\"> </p>"), _e = w.from_html("<div class=\"flex items-start gap-3 rounded-md border border-border p-3 text-sm hover:bg-accent transition-colors\"><!> <div class=\"flex-1 min-w-0\"><div class=\"flex items-center justify-between gap-2\"><div class=\"flex flex-col gap-0.5 min-w-0\"><!> <span class=\"text-xs text-muted-foreground\"> </span></div> <button type=\"button\" class=\"inline-flex items-center gap-1 rounded-md px-2 py-1 text-xs text-muted-foreground hover:bg-background hover:text-foreground transition-colors\"><!> </button></div> <!> <!> <!></div></div>"), ve = w.from_html("<div class=\"flex flex-col gap-1 overflow-y-auto max-h-80\"></div>"), ye = w.from_html("<p class=\"px-4 text-sm text-destructive\" role=\"alert\"> </p>"), be = w.from_html("<div class=\"flex flex-col gap-2 p-4\"><div class=\"flex items-center justify-between gap-2\"><div class=\"flex items-center gap-2 text-sm font-medium text-foreground\"><!> <span> </span></div> <button type=\"button\" class=\"inline-flex items-center gap-1 rounded-md border border-border bg-background px-2 py-1 text-xs font-medium hover:bg-accent disabled:opacity-50\"><!> </button></div> <!> <!> <!> <!> <!></div> <!> <!> <!>", 1);
65
+ function O(i, O) {
66
+ w.push(O, !0);
67
+ let xe = w.prop(O, "refreshRevision", 3, 0), k = w.state(w.proxy([])), A = w.state(!0), j = w.state(null), M = w.state("all"), N = w.state(!1), P = w.state(!1), F = w.state(null), I = w.state(!1), L = w.state(null), R = C(), z, B, V = w.state(null), H = w.state(!1), U = w.state(null);
68
+ T(() => {
69
+ z?.abort(), B?.abort();
70
+ });
71
+ async function Se(e) {
72
+ z?.abort();
73
+ let t = new AbortController();
74
+ z = t;
75
+ let n = O.documentId;
76
+ w.set(H, !0), w.set(V, null);
77
+ try {
78
+ let r = await b(`/api/documents/${n}/versions/${e.id}`, { signal: t.signal }, R.fetch);
79
+ if (t.signal.aborted || n !== O.documentId) return;
80
+ w.set(U, e.id, !0), O.onPreview?.(r);
81
+ } catch {
82
+ !t.signal.aborted && n === O.documentId && w.set(V, "Could not open this version. Please try again.");
83
+ } finally {
84
+ z === t && w.set(H, !1);
85
+ }
86
+ }
87
+ function W() {
88
+ z?.abort(), w.set(H, !1), w.set(V, null), w.set(U, null), O.onPreview?.(null);
89
+ }
90
+ async function G() {
91
+ B?.abort();
92
+ let e = new AbortController();
93
+ B = e, w.set(A, !0), w.set(j, null);
69
94
  try {
70
- E.set(A, await S(`/api/documents/${k.documentId}/versions`, {}, z.fetch), !0);
71
- } catch (e) {
72
- E.set(M, e instanceof Error ? e.message : String(e), !0), console.error("Failed to load versions", e);
95
+ let t = await b(`/api/documents/${O.documentId}/versions`, { signal: e.signal }, R.fetch);
96
+ e.signal.aborted || w.set(k, t, !0);
97
+ } catch (t) {
98
+ if (e.signal.aborted) return;
99
+ w.set(j, t instanceof Error ? t.message : String(t), !0), console.error("Failed to load versions", t);
73
100
  } finally {
74
- E.set(j, !1);
101
+ B === e && w.set(A, !1);
75
102
  }
76
103
  }
77
- E.user_effect(() => {
78
- k.documentId, B();
79
- }), E.user_effect(() => {
80
- E.get(F) || E.get(L) || E.get(I) !== null && E.set(I, null);
104
+ w.user_effect(() => {
105
+ O.documentId, W();
106
+ }), w.user_effect(() => {
107
+ xe(), G();
108
+ }), w.user_effect(() => {
109
+ w.get(P) || w.get(I) || w.get(F) !== null && w.set(F, null);
81
110
  });
82
- let V = E.derived(() => E.get(N) === "snapshots" ? E.get(A).filter((e) => e.isSnapshot === !0) : E.get(A)), me = E.derived(() => E.get(A).reduce((e, t) => t.isSnapshot ? e + 1 : e, 0)), he = E.derived(() => E.get(I)?.label ? `${v()} (${E.get(I).label})` : v());
83
- function H(e) {
111
+ let K = w.derived(() => w.get(M) === "snapshots" ? w.get(k).filter((e) => e.isSnapshot === !0) : w.get(k)), Ce = w.derived(() => w.get(k).reduce((e, t) => t.isSnapshot ? e + 1 : e, 0)), we = w.derived(() => w.get(F)?.label ? `${g()} (${w.get(F).label})` : g());
112
+ function q(e) {
84
113
  if (!e) return "";
85
114
  let t = e.replace(/```[\s\S]*?```/g, "").replace(/[#*_`>~-]/g, "").replace(/\s+/g, " ").trim();
86
115
  return t.length > 100 ? `${t.slice(0, 100)}…` : t;
87
116
  }
88
- function ge(e) {
117
+ function Te(e) {
89
118
  let t = typeof e == "string" ? new Date(e) : e, n = Date.now() - t.getTime();
90
119
  if (Number.isNaN(n)) return "";
91
120
  let r = Math.floor(n / 6e4);
92
- if (r < 1) return b({ count: 0 });
93
- if (r < 60) return b({ count: r });
121
+ if (r < 1) return v({ count: 0 });
122
+ if (r < 60) return v({ count: r });
94
123
  let i = Math.floor(r / 60);
95
124
  return i < 24 ? f({ count: i }) : p({ count: Math.floor(i / 24) });
96
125
  }
97
- function _e(e) {
98
- E.set(I, e, !0), E.set(R, null), E.set(F, !0);
126
+ function Ee(e) {
127
+ w.set(F, e, !0), w.set(L, null), w.set(P, !0);
99
128
  }
100
- function ve() {
101
- E.get(L) || (E.set(I, null), E.set(R, null));
129
+ function De() {
130
+ w.get(I) || (w.set(F, null), w.set(L, null));
102
131
  }
103
- async function ye() {
104
- let e = E.get(I);
105
- if (e && !E.get(L)) {
106
- E.set(L, !0), E.set(R, null);
132
+ async function Oe() {
133
+ let e = w.get(F);
134
+ if (e && !w.get(I)) {
135
+ w.set(I, !0), O.onRestoringChange?.(!0), w.set(L, null);
107
136
  try {
108
- await S(`/api/documents/${k.documentId}/versions/${e.id}/restore`, { method: "POST" }, z.fetch), await B(), E.set(I, null), E.set(F, !1), k.onRestored?.(e), typeof window < "u" && window.dispatchEvent(new CustomEvent("version-restored", { detail: {
109
- documentId: k.documentId,
137
+ let t = O.documentId;
138
+ if (O.beforeRestore && !await O.beforeRestore()) {
139
+ w.set(L, "Could not save the current changes. Try again before restoring.");
140
+ return;
141
+ }
142
+ if (t !== O.documentId) return;
143
+ let n = await b(`/api/documents/${t}/versions/${e.id}/restore`, {
144
+ method: "POST",
145
+ body: {}
146
+ }, R.fetch);
147
+ if (t !== O.documentId) return;
148
+ w.set(F, null), w.set(P, !1), W(), await O.onRestored?.(e, n), G(), typeof window < "u" && window.dispatchEvent(new CustomEvent("version-restored", { detail: {
149
+ documentId: O.documentId,
110
150
  versionId: e.id
111
151
  } }));
112
152
  } catch (e) {
113
- e instanceof C ? E.set(R, `${l()}: ${e.message}`) : E.set(R, e instanceof Error ? e.message : c(), !0), console.error("Failed to restore version", e);
153
+ e instanceof x ? w.set(L, `${l()}: ${e.message}`) : w.set(L, e instanceof Error ? e.message : c(), !0), console.error("Failed to restore version", e);
114
154
  } finally {
115
- E.set(L, !1);
155
+ w.set(I, !1), O.onRestoringChange?.(!1);
116
156
  }
117
157
  }
118
158
  }
119
- function be() {
120
- B();
159
+ function ke() {
160
+ G();
121
161
  }
122
- function xe(e) {
162
+ function Ae(e) {
123
163
  if (!e) return null;
124
- let t = E.get(A).find((t) => t.id === e);
164
+ let t = w.get(k).find((t) => t.id === e);
125
165
  return t ? t.label ?? e.slice(0, 8) : e.slice(0, 8);
126
166
  }
127
- var U = pe(), W = E.first_child(U), G = E.child(W), K = E.child(G), q = E.child(K);
128
- D(q, { class: "h-4 w-4" });
129
- var Se = E.sibling(q, 2), Ce = E.only_child(Se, !0);
130
- E.reset(K);
131
- var J = E.sibling(K, 2), Y = E.child(J);
132
- t(Y, { class: "h-3 w-3" });
133
- var we = E.sibling(Y);
134
- E.reset(J), E.reset(G);
135
- var X = E.sibling(G, 2), Te = (e) => {
136
- var t = ne(), n = E.child(t), r = E.only_child(n), i = E.sibling(n, 2), a = E.only_child(i);
137
- E.reset(t), E.template_effect((e, o, s) => {
138
- E.set_attribute(t, "aria-label", e), E.set_attribute(n, "aria-selected", E.get(N) === "all"), E.set_class(n, 1, `flex-1 px-2 py-1 transition-colors ${E.get(N) === "all" ? "bg-primary text-primary-foreground" : "bg-background text-muted-foreground hover:bg-accent"}`), E.set_text(r, `${o ?? ""} (${E.get(A).length ?? ""})`), E.set_attribute(i, "aria-selected", E.get(N) === "snapshots"), E.set_class(i, 1, `flex-1 px-2 py-1 transition-colors ${E.get(N) === "snapshots" ? "bg-primary text-primary-foreground" : "bg-background text-muted-foreground hover:bg-accent"}`), E.set_text(a, `${s ?? ""} (${E.get(me) ?? ""})`);
167
+ var J = be(), Y = w.first_child(J), X = w.child(Y), Z = w.child(X), Q = w.child(Z);
168
+ E(Q, { class: "h-4 w-4" });
169
+ var je = w.sibling(Q, 2), Me = w.only_child(je, !0);
170
+ w.reset(Z);
171
+ var $ = w.sibling(Z, 2), Ne = w.child($);
172
+ t(Ne, { class: "h-3 w-3" });
173
+ var Pe = w.sibling(Ne);
174
+ w.reset($), w.reset(X);
175
+ var Fe = w.sibling(X, 2), Ie = (e) => {
176
+ var t = ie(), n = w.child(t), r = w.only_child(n), i = w.sibling(n, 2), a = w.only_child(i);
177
+ w.reset(t), w.template_effect((e, o, s) => {
178
+ w.set_attribute(t, "aria-label", e), w.set_attribute(n, "aria-selected", w.get(M) === "all"), w.set_class(n, 1, `flex-1 px-2 py-1 transition-colors ${w.get(M) === "all" ? "bg-primary text-primary-foreground" : "bg-background text-muted-foreground hover:bg-accent"}`), w.set_text(r, `${o ?? ""} (${w.get(k).length ?? ""})`), w.set_attribute(i, "aria-selected", w.get(M) === "snapshots"), w.set_class(i, 1, `flex-1 px-2 py-1 transition-colors ${w.get(M) === "snapshots" ? "bg-primary text-primary-foreground" : "bg-background text-muted-foreground hover:bg-accent"}`), w.set_text(a, `${s ?? ""} (${w.get(Ce) ?? ""})`);
139
179
  }, [
140
180
  () => d(),
141
181
  () => d(),
142
- () => y()
143
- ]), E.delegated("click", n, () => E.set(N, "all")), E.delegated("click", i, () => E.set(N, "snapshots")), E.append(e, t);
182
+ () => _()
183
+ ]), w.delegated("click", n, () => w.set(M, "all")), w.delegated("click", i, () => w.set(M, "snapshots")), w.append(e, t);
184
+ };
185
+ w.if(Fe, (e) => {
186
+ w.get(k).length > 0 && e(Ie);
187
+ });
188
+ var Le = w.sibling(Fe, 2), Re = (e) => {
189
+ var t = ae();
190
+ w.append(e, t);
191
+ };
192
+ w.if(Le, (e) => {
193
+ w.get(H) && e(Re);
194
+ });
195
+ var ze = w.sibling(Le, 2), Be = (e) => {
196
+ var t = oe(), n = w.only_child(t, !0);
197
+ w.template_effect(() => w.set_text(n, w.get(V))), w.append(e, t);
198
+ };
199
+ w.if(ze, (e) => {
200
+ w.get(V) && e(Be);
201
+ });
202
+ var Ve = w.sibling(ze, 2), He = (e) => {
203
+ var t = se();
204
+ w.delegated("click", t, W), w.append(e, t);
144
205
  };
145
- E.if(X, (e) => {
146
- E.get(A).length > 0 && e(Te);
206
+ w.if(Ve, (e) => {
207
+ w.get(U) && e(He);
147
208
  });
148
- var Ee = E.sibling(X, 2), De = (e) => {
149
- var t = re(), n = E.child(t);
209
+ var Ue = w.sibling(Ve, 2), We = (e) => {
210
+ var t = ce(), n = w.child(t);
150
211
  a(n, { class: "h-3.5 w-3.5 animate-spin" });
151
- var r = E.sibling(n, 2), i = E.only_child(r, !0);
152
- E.reset(t), E.template_effect((e) => E.set_text(i, e), [() => s()]), E.append(e, t);
153
- }, Z = (e) => {
154
- var t = ie(), n = E.only_child(t, !0);
155
- E.template_effect(() => E.set_text(n, E.get(M))), E.append(e, t);
156
- }, Oe = (e) => {
157
- var t = ae(), n = E.only_child(t, !0);
158
- E.template_effect((e) => E.set_text(n, e), [() => _()]), E.append(e, t);
159
- }, ke = (e) => {
160
- var t = de();
161
- E.each(t, 21, () => E.get(V), (e) => e.id, (e, t) => {
162
- var i = ue(), a = E.child(i), o = (e) => {
212
+ var r = w.sibling(n, 2), i = w.only_child(r, !0);
213
+ w.reset(t), w.template_effect((e) => w.set_text(i, e), [() => s()]), w.append(e, t);
214
+ }, Ge = (e) => {
215
+ var t = le(), n = w.only_child(t, !0);
216
+ w.template_effect(() => w.set_text(n, w.get(j))), w.append(e, t);
217
+ }, Ke = (e) => {
218
+ var t = ue(), n = w.only_child(t, !0);
219
+ w.template_effect((e) => w.set_text(n, e), [() => h()]), w.append(e, t);
220
+ }, qe = (e) => {
221
+ var t = ve();
222
+ w.each(t, 21, () => w.get(K), (e) => e.id, (e, t) => {
223
+ var i = _e(), a = w.child(i), o = (e) => {
163
224
  {
164
- let t = E.derived(() => h());
165
- O(e, {
225
+ let t = w.derived(() => ee());
226
+ D(e, {
166
227
  class: "mt-0.5 h-3.5 w-3.5 shrink-0 fill-amber-400 text-amber-500",
167
228
  get "aria-label"() {
168
- return E.get(t);
229
+ return w.get(t);
169
230
  }
170
231
  });
171
232
  }
172
233
  }, s = (e) => {
173
234
  r(e, { class: "mt-0.5 h-3.5 w-3.5 shrink-0 text-muted-foreground" });
174
235
  };
175
- E.if(a, (e) => {
176
- E.get(t).isSnapshot ? e(o) : e(s, -1);
236
+ w.if(a, (e) => {
237
+ w.get(t).isSnapshot ? e(o) : e(s, -1);
177
238
  });
178
- var c = E.sibling(a, 2), l = E.child(c), u = E.child(l), d = E.child(u), f = (e) => {
179
- var n = oe(), r = E.only_child(n, !0);
180
- E.template_effect(() => {
181
- E.set_attribute(n, "title", E.get(t).label), E.set_text(r, E.get(t).label);
182
- }), E.append(e, n);
239
+ var c = w.sibling(a, 2), l = w.child(c), u = w.child(l), d = w.child(u), f = (e) => {
240
+ var n = de(), r = w.only_child(n, !0);
241
+ w.template_effect(() => {
242
+ w.set_attribute(n, "title", w.get(t).label), w.set_text(r, w.get(t).label);
243
+ }), w.append(e, n);
183
244
  };
184
- E.if(d, (e) => {
185
- E.get(t).label && e(f);
245
+ w.if(d, (e) => {
246
+ w.get(t).label && e(f);
186
247
  });
187
- var p = E.sibling(d, 2), _ = E.only_child(p, !0);
188
- E.reset(u);
189
- var v = E.sibling(u, 2), y = E.child(v);
190
- te(y, { class: "h-3 w-3" });
191
- var b = E.sibling(y);
192
- E.reset(v), E.reset(l);
193
- var x = E.sibling(l, 2), S = (e) => {
194
- var n = ce(), r = E.child(n), i = E.child(r);
195
- O(i, { class: "h-2.5 w-2.5" });
196
- var a = E.sibling(i);
197
- E.reset(r);
198
- var o = E.sibling(r, 2), s = (e) => {
199
- var n = se(), r = E.only_child(n, !0);
200
- E.template_effect(() => {
201
- E.set_attribute(n, "title", E.get(t).description), E.set_text(r, E.get(t).description);
202
- }), E.append(e, n);
248
+ var p = w.sibling(d, 2), h = w.only_child(p, !0);
249
+ w.reset(u);
250
+ var g = w.sibling(u, 2), _ = w.child(g);
251
+ re(_, { class: "h-3 w-3" });
252
+ var v = w.sibling(_);
253
+ w.reset(g), w.reset(l);
254
+ var y = w.sibling(l, 2), b = (e) => {
255
+ var n = pe(), r = w.child(n), i = w.child(r);
256
+ D(i, { class: "h-2.5 w-2.5" });
257
+ var a = w.sibling(i);
258
+ w.reset(r);
259
+ var o = w.sibling(r, 2), s = (e) => {
260
+ var n = fe(), r = w.only_child(n, !0);
261
+ w.template_effect(() => {
262
+ w.set_attribute(n, "title", w.get(t).description), w.set_text(r, w.get(t).description);
263
+ }), w.append(e, n);
203
264
  };
204
- E.if(o, (e) => {
205
- E.get(t).description && e(s);
206
- }), E.reset(n), E.template_effect((e) => E.set_text(a, ` ${e ?? ""}`), [() => h()]), E.append(e, n);
265
+ w.if(o, (e) => {
266
+ w.get(t).description && e(s);
267
+ }), w.reset(n), w.template_effect((e) => w.set_text(a, ` ${e ?? ""}`), [() => ee()]), w.append(e, n);
207
268
  };
208
- E.if(x, (e) => {
209
- E.get(t).isSnapshot && e(S);
269
+ w.if(y, (e) => {
270
+ w.get(t).isSnapshot && e(b);
210
271
  });
211
- var C = E.sibling(x, 2), w = (e) => {
212
- var r = le(), i = E.child(r);
272
+ var x = w.sibling(y, 2), S = (e) => {
273
+ var r = me(), i = w.child(r);
213
274
  n(i, { class: "h-3 w-3" });
214
- var a = E.sibling(i), o = E.sibling(a), s = E.only_child(o, !0);
215
- E.reset(r), E.template_effect((e, t) => {
216
- E.set_text(a, ` ${e ?? ""} `), E.set_text(s, t);
217
- }, [() => ee(), () => xe(E.get(t).restoredFrom) ?? "—"]), E.append(e, r);
275
+ var a = w.sibling(i), o = w.sibling(a), s = w.only_child(o, !0);
276
+ w.reset(r), w.template_effect((e, t) => {
277
+ w.set_text(a, ` ${e ?? ""} `), w.set_text(s, t);
278
+ }, [() => ne(), () => Ae(w.get(t).restoredFrom) ?? "—"]), w.append(e, r);
218
279
  };
219
- E.if(C, (e) => {
220
- E.get(t).restoredFrom && e(w);
280
+ w.if(x, (e) => {
281
+ w.get(t).restoredFrom && e(S);
221
282
  });
222
- var T = E.sibling(C, 2), D = E.only_child(T, !0);
223
- E.reset(c), E.reset(i), E.template_effect((e, t, n, r, i, a) => {
224
- E.set_text(_, e), E.set_attribute(v, "title", t), E.set_attribute(v, "aria-label", n), E.set_text(b, ` ${r ?? ""}`), E.set_attribute(T, "title", i), E.set_text(D, a);
283
+ var C = w.sibling(x, 2), T = (e) => {
284
+ var n = he(), r = w.only_child(n, !0);
285
+ w.template_effect((e) => {
286
+ w.set_attribute(n, "aria-pressed", w.get(U) === w.get(t).id), n.disabled = w.get(I), w.set_text(r, e);
287
+ }, [() => q(w.get(t).content) || "View version"]), w.delegated("click", n, () => void Se(w.get(t))), w.append(e, n);
288
+ }, E = (e) => {
289
+ var n = ge(), r = w.only_child(n, !0);
290
+ w.template_effect((e) => w.set_text(r, e), [() => q(w.get(t).content)]), w.append(e, n);
291
+ };
292
+ w.if(C, (e) => {
293
+ O.onPreview ? e(T) : e(E, -1);
294
+ }), w.reset(c), w.reset(i), w.template_effect((e, t, n, r) => {
295
+ w.set_text(h, e), w.set_attribute(g, "title", t), w.set_attribute(g, "aria-label", n), w.set_text(v, ` ${r ?? ""}`);
225
296
  }, [
226
- () => ge(E.get(t).createdAt),
297
+ () => Te(w.get(t).createdAt),
227
298
  () => m(),
228
299
  () => m(),
229
- () => g(),
230
- () => H(E.get(t).content),
231
- () => H(E.get(t).content)
232
- ]), E.delegated("click", v, () => _e(E.get(t))), E.append(e, i);
233
- }), E.reset(t), E.append(e, t);
300
+ () => te()
301
+ ]), w.delegated("click", g, () => Ee(w.get(t))), w.append(e, i);
302
+ }), w.reset(t), w.append(e, t);
234
303
  };
235
- E.if(Ee, (e) => {
236
- E.get(j) ? e(De) : E.get(M) ? e(Z, 1) : E.get(V).length === 0 ? e(Oe, 2) : e(ke, -1);
237
- }), E.reset(W);
238
- var Q = E.sibling(W, 2);
304
+ w.if(Ue, (e) => {
305
+ w.get(A) ? e(We) : w.get(j) ? e(Ge, 1) : w.get(K).length === 0 ? e(Ke, 2) : e(qe, -1);
306
+ }), w.reset(Y);
307
+ var Je = w.sibling(Y, 2);
239
308
  {
240
- let t = E.derived(() => m()), n = E.derived(() => g()), r = E.derived(() => o());
241
- e(Q, {
309
+ let t = w.derived(() => m()), n = w.derived(() => te()), r = w.derived(() => o());
310
+ e(Je, {
242
311
  get title() {
243
- return E.get(t);
312
+ return w.get(t);
244
313
  },
245
314
  get description() {
246
- return E.get(he);
315
+ return w.get(we);
247
316
  },
248
317
  get confirmLabel() {
249
- return E.get(n);
318
+ return w.get(n);
250
319
  },
251
320
  get cancelLabel() {
252
- return E.get(r);
321
+ return w.get(r);
253
322
  },
254
323
  variant: "default",
255
324
  get busy() {
256
- return E.get(L);
325
+ return w.get(I);
257
326
  },
258
- onConfirm: ye,
259
- onCancel: ve,
327
+ onConfirm: Oe,
328
+ onCancel: De,
260
329
  get open() {
261
- return E.get(F);
330
+ return w.get(P);
262
331
  },
263
332
  set open(e) {
264
- E.set(F, e, !0);
333
+ w.set(P, e, !0);
265
334
  }
266
335
  });
267
336
  }
268
- var $ = E.sibling(Q, 2), Ae = (e) => {
269
- var t = fe(), n = E.only_child(t, !0);
270
- E.template_effect(() => E.set_text(n, E.get(R))), E.append(e, t);
337
+ var Ye = w.sibling(Je, 2), Xe = (e) => {
338
+ var t = ye(), n = w.only_child(t, !0);
339
+ w.template_effect(() => w.set_text(n, w.get(L))), w.append(e, t);
271
340
  };
272
- E.if($, (e) => {
273
- E.get(R) && e(Ae);
341
+ w.if(Ye, (e) => {
342
+ w.get(L) && e(Xe);
274
343
  });
275
- var je = E.sibling($, 2);
276
- w(je, {
344
+ var Ze = w.sibling(Ye, 2);
345
+ S(Ze, {
277
346
  get documentId() {
278
- return k.documentId;
347
+ return O.documentId;
279
348
  },
280
- onSuccess: be,
349
+ onSuccess: ke,
281
350
  get open() {
282
- return E.get(P);
351
+ return w.get(N);
283
352
  },
284
353
  set open(e) {
285
- E.set(P, e, !0);
354
+ w.set(N, e, !0);
286
355
  }
287
- }), E.template_effect((e, t, n, r) => {
288
- E.set_text(Ce, e), J.disabled = E.get(j), E.set_attribute(J, "title", t), E.set_attribute(J, "aria-label", n), E.set_text(we, ` ${r ?? ""}`);
356
+ }), w.template_effect((e, t, n, r) => {
357
+ w.set_text(Me, e), $.disabled = w.get(A), w.set_attribute($, "title", t), w.set_attribute($, "aria-label", n), w.set_text(Pe, ` ${r ?? ""}`);
289
358
  }, [
290
359
  () => u(),
291
- () => x(),
292
- () => x(),
293
- () => x()
294
- ]), E.delegated("click", J, () => E.set(P, !0)), E.append(i, U), E.pop();
360
+ () => y(),
361
+ () => y(),
362
+ () => y()
363
+ ]), w.delegated("click", $, () => w.set(N, !0)), w.append(i, J), w.pop();
295
364
  }
296
- E.delegate(["click"]);
297
- export { k as VersionHistory };
365
+ w.delegate(["click"]);
366
+ export { O as VersionHistory };
@@ -2216,13 +2216,9 @@ function HiAiEditor($$renderer, $$props) {
2216
2216
  const parse = async () => {
2217
2217
  try {
2218
2218
  const cached = cacheDocumentId && cacheUpdatedAt ? await getCachedParsedContent(cacheDocumentId, cacheUpdatedAt) : null;
2219
- if (generation !== deferredParseGeneration || editor !== ed) return;
2219
+ if (generation !== deferredParseGeneration || editor !== ed || content !== source || contentJson) return;
2220
2220
  const parsed = cached ?? sanitizeEditorContent(markdownToJson(source));
2221
2221
  ed.commands.setContent(parsed, { emitUpdate: false });
2222
- onUpdate({
2223
- markdown: source,
2224
- json: parsed
2225
- });
2226
2222
  if (!cached && cacheDocumentId && cacheUpdatedAt) cacheParsedContent(cacheDocumentId, cacheUpdatedAt, parsed);
2227
2223
  } catch (err) {
2228
2224
  if (generation === deferredParseGeneration) console.warn("HiAiEditor: deferred markdown parsing failed", err);
@@ -2340,15 +2336,18 @@ function HiAiEditor($$renderer, $$props) {
2340
2336
  $$renderer.push(`<div class="editor-wrapper svelte-9hjz5q" role="presentation">`);
2341
2337
  if (ready && editor) {
2342
2338
  $$renderer.push("<!--[0-->");
2343
- EditorToolbar($$renderer, {
2344
- editor,
2345
- documentId,
2346
- toolbarExtensions,
2347
- editorActions,
2348
- editorActionContext,
2349
- minimal: minimalToolbar
2350
- });
2351
- $$renderer.push(`<!----> <div${$.attr_class("editor-content svelte-9hjz5q", void 0, { "deferred-loading": deferredContentLoading })}${$.attr("aria-busy", deferredContentLoading)}>`);
2339
+ if (editable) {
2340
+ $$renderer.push("<!--[0-->");
2341
+ EditorToolbar($$renderer, {
2342
+ editor,
2343
+ documentId,
2344
+ toolbarExtensions,
2345
+ editorActions,
2346
+ editorActionContext,
2347
+ minimal: minimalToolbar
2348
+ });
2349
+ } else $$renderer.push("<!--[-1-->");
2350
+ $$renderer.push(`<!--]--> <div${$.attr_class("editor-content svelte-9hjz5q", void 0, { "deferred-loading": deferredContentLoading })}${$.attr("aria-busy", deferredContentLoading)}>`);
2352
2351
  if (deferredContentLoading) $$renderer.push(`<!--[0--><div class="large-document-loader svelte-9hjz5q" role="status" aria-live="polite"><div class="large-document-loader-heading svelte-9hjz5q"><span class="large-document-spinner svelte-9hjz5q" aria-hidden="true"></span> <span class="svelte-9hjz5q">Preparing large document…</span></div> <div class="large-document-loader-lines svelte-9hjz5q" aria-hidden="true"><span style="width: 72%" class="svelte-9hjz5q"></span> <span style="width: 94%" class="svelte-9hjz5q"></span> <span style="width: 83%" class="svelte-9hjz5q"></span> <span style="width: 61%" class="svelte-9hjz5q"></span></div></div>`);
2353
2352
  else $$renderer.push("<!--[-1-->");
2354
2353
  $$renderer.push(`<!--]--> `);
@@ -27,7 +27,9 @@ function startCollaboration(documentId, accessToken, onUpdate, realtime) {
27
27
  });
28
28
  provider.on("sync", (_synced) => {});
29
29
  provider.on("status", (_status) => {});
30
- provider.on("connection-close", () => {});
30
+ provider.on("connection-close", (event) => {
31
+ if (event?.code === 4009) provider.disconnect();
32
+ });
31
33
  const updateHandler = onUpdate;
32
34
  if (updateHandler) doc.on("update", updateHandler);
33
35
  const session = {
@@ -1,4 +1,4 @@
1
- import { t as HiAiEditor } from "../../assets/HiAiEditor-DeHWAIj-.js";
1
+ import { t as HiAiEditor } from "../../assets/HiAiEditor-BQGlGd3z.js";
2
2
  import "svelte/internal/server";
3
3
  // src/lib/components/editor/CompactEditor.svelte
4
4
  function CompactEditor($$renderer, $$props) {
@@ -1 +1 @@
1
- export { t as DocsmintDocumentEditorHost } from "../../assets/HiAiEditor-DeHWAIj-.js";
1
+ export { t as DocsmintDocumentEditorHost } from "../../assets/HiAiEditor-BQGlGd3z.js";