@floegence/floe-webapp-core 0.35.49 → 0.35.51

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.
@@ -1,150 +1,176 @@
1
- import { createSignal as l, createMemo as c, createEffect as w, onCleanup as X } from "solid-js";
2
- import { Paste as zt, Plus as At, Trash as Ft } from "../icons/index.js";
3
- import { NOTES_CONTEXT_MENU_WIDTH_PX as kt, estimateNotesContextMenuHeight as Bt } from "./NotesContextMenu.js";
4
- import { samePoint as ie, resolveFrameSize as W, resolveOverviewBounds as Vt, createOverviewItem as jt, clamp as _, createContextMenuPosition as Wt, NOTES_MOBILE_BREAKPOINT_PX as Ht, getNormalizedOverviewPoint as je, findTrashTopicNoteCount as $t, hasLiveNotesForTopic as Kt, NOTES_CANVAS_ZOOM_STEP as We, resolveCenteredViewport as Zt } from "./notesOverlayHelpers.js";
5
- import { normalizeNotesSnapshot as qt, groupTrashItems as Gt, visibleWorldRect as Ut, computeBoardBounds as Jt } from "./types.js";
6
- import { useNotification as Qt } from "../../context/NotificationContext.js";
7
- function m(r) {
1
+ import { createSignal as l, createMemo as c, createEffect as m, onCleanup as X, untrack as Qt } from "solid-js";
2
+ import { Paste as eo, Plus as to, Trash as oo } from "../icons/index.js";
3
+ import { NOTES_CONTEXT_MENU_WIDTH_PX as no, estimateNotesContextMenuHeight as ro } from "./NotesContextMenu.js";
4
+ import { samePoint as pe, resolveFrameSize as $, resolveOverviewBounds as io, createOverviewItem as co, clamp as M, createContextMenuPosition as so, NOTES_MOBILE_BREAKPOINT_PX as ao, getNormalizedOverviewPoint as et, findTrashTopicNoteCount as lo, hasLiveNotesForTopic as uo, NOTES_CANVAS_ZOOM_STEP as tt, resolveCenteredViewport as po } from "./notesOverlayHelpers.js";
5
+ import { normalizeNotesSnapshot as fo, groupTrashItems as mo, visibleWorldRect as wo, computeBoardBounds as ho } from "./types.js";
6
+ import { useNotification as vo } from "../../context/NotificationContext.js";
7
+ function w(r) {
8
8
  return r instanceof Error ? r.message : String(r);
9
9
  }
10
- function co(r) {
11
- const a = Qt(), [ce, He] = l(), [M, $e] = l({ width: 0, height: 0 }), [T, d] = l(null), [se, ae] = l(""), [H, le] = l(null), [de, $] = l(""), [K, S] = l(null), [ue, pe] = l(""), [fe, me] = l("amber"), [we, he] = l(!1), [ve, Te] = l(!1), [Z, ge] = l(null), [q, G] = l(""), [Ke, Y] = l(null), [Ze, qe] = l(Date.now()), [Ge, Ue] = l(!1), [ye, y] = l(null), [Je, xe] = l(null), [Ce, b] = l(null), [Ne, E] = l(/* @__PURE__ */ new Map());
12
- let P, U, J = null;
13
- const p = c(() => qt(r.controller.snapshot())), g = c(
14
- () => p().topics.filter((e) => e.deleted_at_unix_ms <= 0)
15
- ), Qe = c(() => g().length), x = c(() => {
10
+ function Mo(r) {
11
+ const a = vo();
12
+ let fe = 1, G = /* @__PURE__ */ new Set();
13
+ const L = /* @__PURE__ */ new Map(), Y = /* @__PURE__ */ new Map(), [me, ot] = l(), [_, nt] = l({ width: 0, height: 0 }), [h, d] = l(null), [we, he] = l(""), [K, ve] = l(null), [Te, Z] = l(""), [q, P] = l(null), [ge, ye] = l(""), [Ne, xe] = l("amber"), [Ce, Me] = l(!1), [_e, Pe] = l(!1), [U, be] = l(null), [J, Q] = l(""), [rt, b] = l(null), [it, ct] = l(Date.now()), [st, at] = l(!1), [Ie, v] = l(null), [lt, Oe] = l(null), [ke, I] = l(null), [De, R] = l(/* @__PURE__ */ new Map());
14
+ let O, ee, te = null;
15
+ const u = c(() => fo(r.controller.snapshot())), y = c(
16
+ () => u().topics.filter((e) => e.deleted_at_unix_ms <= 0)
17
+ ), dt = c(() => y().length), N = c(() => {
16
18
  const e = r.controller.activeTopicID();
17
- return g().some((t) => t.topic_id === e) ? e : g()[0]?.topic_id ?? "";
18
- }), I = c(
19
- () => g().find((e) => e.topic_id === x())
20
- ), et = c(() => {
21
- const e = Ne();
22
- return p().items.map((t) => {
19
+ return y().some((t) => t.topic_id === e) ? e : y()[0]?.topic_id ?? "";
20
+ }), k = c(
21
+ () => y().find((e) => e.topic_id === N())
22
+ ), ut = c(() => {
23
+ const e = De();
24
+ return u().items.map((t) => {
23
25
  const o = e.get(t.note_id);
24
- return !o || ie({ x: t.x, y: t.y }, o) ? t : {
26
+ return !o || pe({ x: t.x, y: t.y }, o) ? t : {
25
27
  ...t,
26
28
  x: o.x,
27
29
  y: o.y
28
30
  };
29
31
  });
30
- }), L = c(
31
- () => et().filter((e) => e.topic_id === x())
32
- ), tt = c(() => Gt(p().trash_items)), _e = c(() => p().trash_items.length), ot = c(() => p().items.length), nt = c(
33
- () => L().reduce((e, t) => Math.max(e, t.z_index), 1)
34
- ), h = c(
35
- () => Ce() ?? r.controller.viewport()
36
- ), rt = c(() => I()?.name ?? "No topic"), it = c(
37
- () => `${Math.round(h().scale * 100)}%`
38
- ), ct = c(() => {
39
- const e = W(M());
40
- return Ut(h(), e.width, e.height);
41
- }), R = c(
42
- () => Vt(Jt(L()), ct())
43
- ), st = c(
44
- () => L().map((e) => jt(e, R()))
45
- ), Me = c(() => {
46
- const e = R(), t = W(M()), o = h(), n = -o.x / o.scale, i = -o.y / o.scale, s = t.width / o.scale, u = t.height / o.scale, f = _(n, e.minX, e.maxX), C = _(i, e.minY, e.maxY), N = _(n + s, e.minX, e.maxX), re = _(i + u, e.minY, e.maxY), O = Math.max((N - f) / e.width * 100, 6), v = Math.max((re - C) / e.height * 100, 8), Be = (f - e.minX) / e.width * 100, Ve = (C - e.minY) / e.height * 100;
32
+ }), E = c(
33
+ () => ut().filter((e) => e.topic_id === N())
34
+ ), pt = c(() => mo(u().trash_items)), Se = c(() => u().trash_items.length), ft = c(() => u().items.length), mt = c(
35
+ () => E().reduce((e, t) => Math.max(e, t.z_index), 1)
36
+ ), T = c(
37
+ () => ke() ?? r.controller.viewport()
38
+ ), wt = c(() => k()?.name ?? "No topic"), ht = c(
39
+ () => `${Math.round(T().scale * 100)}%`
40
+ ), vt = c(() => {
41
+ const e = $(_());
42
+ return wo(T(), e.width, e.height);
43
+ }), F = c(
44
+ () => io(ho(E()), vt())
45
+ ), Tt = c(
46
+ () => E().map((e) => co(e, F()))
47
+ ), Xe = c(() => {
48
+ const e = F(), t = $(_()), o = T(), n = -o.x / o.scale, i = -o.y / o.scale, s = t.width / o.scale, p = t.height / o.scale, f = M(n, e.minX, e.maxX), x = M(i, e.minY, e.maxY), C = M(n + s, e.minX, e.maxX), ue = M(i + p, e.minY, e.maxY), S = Math.max((C - f) / e.width * 100, 6), g = Math.max((ue - x) / e.height * 100, 8), Je = (f - e.minX) / e.width * 100, Qe = (x - e.minY) / e.height * 100;
47
49
  return {
48
- left: Be,
49
- top: Ve,
50
- width: O,
51
- height: v,
52
- centerX: Be + O / 2,
53
- centerY: Ve + v / 2
50
+ left: Je,
51
+ top: Qe,
52
+ width: S,
53
+ height: g,
54
+ centerX: Je + S / 2,
55
+ centerY: Qe + g / 2
54
56
  };
55
- }), at = c(() => {
56
- const e = Me();
57
+ }), gt = c(() => {
58
+ const e = Xe();
57
59
  return {
58
60
  left: `${e.left}%`,
59
61
  top: `${e.top}%`,
60
62
  width: `${e.width}%`,
61
63
  height: `${e.height}%`
62
64
  };
63
- }), be = c(() => {
64
- const e = K();
65
- return e ? p().items.find((t) => t.note_id === e) : void 0;
66
- }), Q = () => {
67
- P !== void 0 && (window.clearTimeout(P), P = void 0);
68
- }, Pe = (e, t) => {
69
- E((o) => {
65
+ }), Le = c(() => {
66
+ const e = q();
67
+ return e ? u().items.find((t) => t.note_id === e) : void 0;
68
+ }), oe = (e) => Qt(() => u().items.some((t) => t.note_id === e)), Ye = () => {
69
+ const e = fe;
70
+ return fe += 1, e;
71
+ }, yt = (e) => {
72
+ const t = Ye();
73
+ return L.set(e, t), t;
74
+ }, Nt = (e) => {
75
+ const t = Ye();
76
+ return Y.set(e, t), t;
77
+ }, Re = (e, t) => L.get(e) === t, Ee = (e, t) => Y.get(e) === t, ne = (e) => {
78
+ L.delete(e);
79
+ }, re = (e) => {
80
+ Y.delete(e);
81
+ }, ie = (e) => {
82
+ ne(e), re(e), A(e), v((t) => t === e ? null : t);
83
+ }, xt = (e) => {
84
+ for (const t of u().items)
85
+ t.topic_id === e && ie(t.note_id);
86
+ }, Ct = (e) => {
87
+ ie(e), z(), b((t) => t === e ? null : t), d(
88
+ (t) => t?.noteID === e ? null : t
89
+ ), P((t) => t === e ? null : t);
90
+ }, Mt = () => {
91
+ L.clear(), Y.clear();
92
+ }, z = () => {
93
+ O !== void 0 && (window.clearTimeout(O), O = void 0);
94
+ }, Fe = (e, t) => {
95
+ R((o) => {
70
96
  const n = o.get(e);
71
- if (n && ie(n, t)) return o;
97
+ if (n && pe(n, t)) return o;
72
98
  const i = new Map(o);
73
99
  return i.set(e, t), i;
74
100
  });
75
- }, z = (e) => {
76
- E((t) => {
101
+ }, A = (e) => {
102
+ R((t) => {
77
103
  if (!t.has(e)) return t;
78
104
  const o = new Map(t);
79
105
  return o.delete(e), o;
80
106
  });
81
- }, A = () => {
82
- ge(null), G("");
83
- }, F = () => {
84
- S(null);
85
- }, D = () => {
86
- Te(!1);
87
- }, Ie = () => {
88
- Te(!0);
89
- }, k = () => {
90
- he(!1);
91
- }, ee = () => {
92
- he(!0);
93
107
  }, B = () => {
94
- le(null), $("");
95
- }, lt = () => {
96
- d(null), k(), D(), F(), A(), E(/* @__PURE__ */ new Map());
97
- }, dt = () => {
98
- if (T()) {
108
+ be(null), Q("");
109
+ }, V = () => {
110
+ P(null);
111
+ }, D = () => {
112
+ Pe(!1);
113
+ }, ze = () => {
114
+ Pe(!0);
115
+ }, j = () => {
116
+ Me(!1);
117
+ }, ce = () => {
118
+ Me(!0);
119
+ }, W = () => {
120
+ ve(null), Z("");
121
+ }, _t = () => {
122
+ d(null), j(), D(), V(), B(), R(/* @__PURE__ */ new Map()), Mt();
123
+ }, Pt = () => {
124
+ if (h()) {
99
125
  d(null);
100
126
  return;
101
127
  }
102
- if (K()) {
103
- F();
128
+ if (q()) {
129
+ V();
104
130
  return;
105
131
  }
106
- if (Z()) {
107
- A();
132
+ if (U()) {
133
+ B();
108
134
  return;
109
135
  }
110
- if (ve()) {
136
+ if (_e()) {
111
137
  D();
112
138
  return;
113
139
  }
114
- if (we()) {
115
- k();
140
+ if (Ce()) {
141
+ j();
116
142
  return;
117
143
  }
118
144
  r.onClose();
119
- }, V = (e) => {
145
+ }, H = (e) => {
120
146
  r.controller.setActiveTopicID(e);
121
- }, De = (e) => Kt(p().items, e), ut = (e, t, o = I()?.topic_id) => {
147
+ }, Ae = (e) => uo(u().items, e), bt = (e, t, o = k()?.topic_id) => {
122
148
  if (!o) return null;
123
- const n = g().find((f) => f.topic_id === o);
149
+ const n = y().find((f) => f.topic_id === o);
124
150
  if (!n) return null;
125
- const i = ce();
151
+ const i = me();
126
152
  if (!i) return null;
127
153
  const s = i.getBoundingClientRect();
128
154
  if (s.width <= 0 || s.height <= 0 || e < s.left || e > s.right || t < s.top || t > s.bottom)
129
155
  return null;
130
- const u = h();
156
+ const p = T();
131
157
  return {
132
158
  topicID: n.topic_id,
133
- worldX: (e - s.left - u.x) / u.scale,
134
- worldY: (t - s.top - u.y) / u.scale
159
+ worldX: (e - s.left - p.x) / p.scale,
160
+ worldY: (t - s.top - p.y) / p.scale
135
161
  };
136
- }, pt = (e, t) => {
162
+ }, It = (e, t) => {
137
163
  if (typeof document > "u") return [];
138
164
  if (typeof document.elementsFromPoint == "function")
139
165
  return document.elementsFromPoint(e, t);
140
166
  const o = document.elementFromPoint(e, t);
141
167
  return o ? [o] : [];
142
- }, ft = (e, t) => {
143
- const o = pt(e, t).filter((n) => n instanceof HTMLElement).map((n) => n.closest("[data-floe-notes-note-id]")).find(Boolean)?.dataset.floeNotesNoteId?.trim();
168
+ }, Ot = (e, t) => {
169
+ const o = It(e, t).filter((n) => n instanceof HTMLElement).map((n) => n.closest("[data-floe-notes-note-id]")).find(Boolean)?.dataset.floeNotesNoteId?.trim();
144
170
  if (o)
145
- return p().items.find((n) => n.note_id === o);
146
- }, te = (e, t, o) => {
147
- const n = ut(e, t, o?.topicID);
171
+ return u().items.find((n) => n.note_id === o);
172
+ }, se = (e, t, o) => {
173
+ const n = bt(e, t, o?.topicID);
148
174
  return n ? {
149
175
  clientX: e,
150
176
  clientY: t,
@@ -153,86 +179,86 @@ function co(r) {
153
179
  topicID: n.topicID,
154
180
  noteID: o?.noteID ?? null
155
181
  } : null;
156
- }, Oe = () => {
157
- const e = I();
182
+ }, Be = () => {
183
+ const e = k();
158
184
  if (!e) return null;
159
- const t = W(M()), o = h();
185
+ const t = $(_()), o = T();
160
186
  return {
161
187
  topicID: e.topic_id,
162
188
  worldX: (t.width / 2 - o.x) / o.scale,
163
189
  worldY: (t.height / 2 - o.y) / o.scale
164
190
  };
165
- }, Xe = (e, t, o) => {
166
- const n = te(e, t, o);
191
+ }, Ve = (e, t, o) => {
192
+ const n = se(e, t, o);
167
193
  return n ? (d(n), !0) : !1;
168
- }, mt = (e, t) => {
169
- const o = ft(e, t);
194
+ }, kt = (e, t) => {
195
+ const o = Ot(e, t);
170
196
  if (o) {
171
- j(o.note_id);
172
- const n = te(e, t, {
197
+ le(o.note_id);
198
+ const n = se(e, t, {
173
199
  topicID: o.topic_id,
174
200
  noteID: o.note_id
175
201
  });
176
202
  d(n);
177
203
  return;
178
204
  }
179
- d(te(e, t));
180
- }, Se = (e) => {
181
- b(e), r.controller.setViewport(e), b(null);
182
- }, Ye = (e, t, o) => Zt({
183
- viewport: h(),
184
- frame: M(),
185
- bounds: R(),
205
+ d(se(e, t));
206
+ }, je = (e) => {
207
+ I(e), r.controller.setViewport(e), I(null);
208
+ }, We = (e, t, o) => po({
209
+ viewport: T(),
210
+ frame: _(),
211
+ bounds: F(),
186
212
  worldX: e,
187
213
  worldY: t,
188
214
  scale: o
189
- }), Ee = (e) => {
190
- const t = h(), o = W(M()), n = (o.width / 2 - t.x) / t.scale, i = (o.height / 2 - t.y) / t.scale, s = e === "in" ? t.scale * We : t.scale / We;
191
- Se(Ye(n, i, s));
192
- }, Le = (e, t, o) => {
215
+ }), He = (e) => {
216
+ const t = T(), o = $(_()), n = (o.width / 2 - t.x) / t.scale, i = (o.height / 2 - t.y) / t.scale, s = e === "in" ? t.scale * tt : t.scale / tt;
217
+ je(We(n, i, s));
218
+ }, $e = (e, t, o) => {
193
219
  const n = o.surfaceRect;
194
220
  if (n.width <= 0 || n.height <= 0) return;
195
- const i = je(e, t, n), s = _(i.x - o.centerOffsetX, 0, 1), u = _(i.y - o.centerOffsetY, 0, 1), f = o.bounds;
196
- b(
197
- Ye(
221
+ const i = et(e, t, n), s = M(i.x - o.centerOffsetX, 0, 1), p = M(i.y - o.centerOffsetY, 0, 1), f = o.bounds;
222
+ I(
223
+ We(
198
224
  f.minX + s * f.width,
199
- f.minY + u * f.height
225
+ f.minY + p * f.height
200
226
  )
201
227
  );
202
- }, oe = (e) => {
203
- if (U?.abort(), U = void 0, e) {
204
- const t = Ce();
228
+ }, ae = (e) => {
229
+ if (ee?.abort(), ee = void 0, e) {
230
+ const t = ke();
205
231
  t && r.controller.setViewport(t);
206
232
  }
207
- b(null), xe(null);
208
- }, wt = (e) => {
233
+ I(null), Oe(null);
234
+ }, Dt = (e) => {
209
235
  if (e.button !== 0 && e.pointerType !== "touch" && e.pointerType !== "pen")
210
236
  return;
211
237
  const t = e.currentTarget, o = t.getBoundingClientRect();
212
238
  if (o.width <= 0 || o.height <= 0) return;
213
- const n = je(e.clientX, e.clientY, o), i = Me(), s = n.x * 100, u = n.y * 100, f = s >= i.left && s <= i.left + i.width && u >= i.top && u <= i.top + i.height, C = {
239
+ const n = et(e.clientX, e.clientY, o), i = Xe(), s = n.x * 100, p = n.y * 100, f = s >= i.left && s <= i.left + i.width && p >= i.top && p <= i.top + i.height, x = {
214
240
  pointerId: e.pointerId,
215
- bounds: R(),
241
+ bounds: F(),
216
242
  surfaceRect: o,
217
243
  centerOffsetX: f ? n.x - i.centerX / 100 : 0,
218
244
  centerOffsetY: f ? n.y - i.centerY / 100 : 0
219
245
  };
220
- oe(!1), e.preventDefault(), e.stopPropagation(), xe(C), Le(e.clientX, e.clientY, C), t.setPointerCapture?.(e.pointerId);
221
- const N = new AbortController();
222
- U = N;
223
- const re = (v) => {
224
- v.pointerId === e.pointerId && Le(v.clientX, v.clientY, C);
225
- }, O = (v) => {
226
- v.pointerId === e.pointerId && (t.hasPointerCapture?.(e.pointerId) && t.releasePointerCapture(e.pointerId), oe(!0));
246
+ ae(!1), e.preventDefault(), e.stopPropagation(), Oe(x), $e(e.clientX, e.clientY, x), t.setPointerCapture?.(e.pointerId);
247
+ const C = new AbortController();
248
+ ee = C;
249
+ const ue = (g) => {
250
+ g.pointerId === e.pointerId && $e(g.clientX, g.clientY, x);
251
+ }, S = (g) => {
252
+ g.pointerId === e.pointerId && (t.hasPointerCapture?.(e.pointerId) && t.releasePointerCapture(e.pointerId), ae(!0));
227
253
  };
228
- t.addEventListener("pointermove", re, { signal: N.signal }), t.addEventListener("pointerup", O, {
254
+ t.addEventListener("pointermove", ue, { signal: C.signal }), t.addEventListener("pointerup", S, {
229
255
  once: !0,
230
- signal: N.signal
231
- }), t.addEventListener("pointercancel", O, {
256
+ signal: C.signal
257
+ }), t.addEventListener("pointercancel", S, {
232
258
  once: !0,
233
- signal: N.signal
259
+ signal: C.signal
234
260
  });
235
- }, Re = async (e) => {
261
+ }, Ge = async (e) => {
236
262
  try {
237
263
  const t = await r.controller.createNote({
238
264
  topic_id: e.topicID,
@@ -240,11 +266,11 @@ function co(r) {
240
266
  y: e.worldY,
241
267
  body: ""
242
268
  });
243
- S(t.note_id);
269
+ P(t.note_id);
244
270
  } catch (t) {
245
- a.error("Create failed", m(t));
271
+ a.error("Create failed", w(t));
246
272
  }
247
- }, ze = async (e, t) => {
273
+ }, Ke = async (e, t) => {
248
274
  try {
249
275
  await r.controller.createNote({
250
276
  topic_id: e.topicID,
@@ -253,108 +279,117 @@ function co(r) {
253
279
  body: t
254
280
  }), a.success("Pasted", "Created a new note from clipboard text.");
255
281
  } catch (o) {
256
- a.error("Paste failed", m(o));
282
+ a.error("Paste failed", w(o));
257
283
  }
258
- }, Ae = (e) => {
259
- G(""), ge(e);
260
- }, Fe = async (e) => {
284
+ }, Ze = (e) => {
285
+ Q(""), be(e);
286
+ }, qe = async (e) => {
261
287
  try {
262
288
  const t = await navigator.clipboard.readText();
263
289
  if (!t.trim()) {
264
- a.info("Clipboard empty", "Paste text into the dialog to create a note."), Ae(e);
290
+ a.info("Clipboard empty", "Paste text into the dialog to create a note."), Ze(e);
265
291
  return;
266
292
  }
267
- await ze(e, t);
293
+ await Ke(e, t);
268
294
  } catch {
269
- a.info("Clipboard blocked", "Manual paste is available as a fallback."), Ae(e);
295
+ a.info("Clipboard blocked", "Manual paste is available as a fallback."), Ze(e);
270
296
  }
271
- }, ht = (e) => {
272
- Q(), Y(e), P = window.setTimeout(() => {
273
- P = void 0, Y((t) => t === e ? null : t);
297
+ }, St = (e) => {
298
+ z(), b(e), O = window.setTimeout(() => {
299
+ O = void 0, b((t) => t === e ? null : t);
274
300
  }, 1100);
275
- }, vt = (e) => {
276
- y(e);
277
- }, j = (e) => {
278
- y(e), Promise.resolve(r.controller.bringNoteToFront(e)).catch((t) => {
279
- a.error("Bring forward failed", m(t)), y((o) => o === e ? null : o);
301
+ }, Xt = (e) => {
302
+ v(e);
303
+ }, le = (e) => {
304
+ const t = yt(e);
305
+ v(e), Promise.resolve(r.controller.bringNoteToFront(e)).then(() => {
306
+ Re(e, t) && ne(e);
307
+ }).catch((o) => {
308
+ if (Re(e, t)) {
309
+ if (ne(e), !oe(e)) {
310
+ v((n) => n === e ? null : n);
311
+ return;
312
+ }
313
+ a.error("Bring forward failed", w(o)), v((n) => n === e ? null : n);
314
+ }
280
315
  });
281
- }, Tt = (e) => {
282
- d(null), S(e);
283
- }, gt = async (e) => {
316
+ }, Lt = (e) => {
317
+ d(null), P(e);
318
+ }, Yt = async (e) => {
284
319
  if (!e.body.trim()) {
285
- d(null), S(e.note_id);
320
+ d(null), P(e.note_id);
286
321
  return;
287
322
  }
288
323
  try {
289
- j(e.note_id), await navigator.clipboard.writeText(e.body), ht(e.note_id);
324
+ await navigator.clipboard.writeText(e.body), St(e.note_id);
290
325
  } catch {
291
326
  a.error("Copy failed", "Clipboard write was not available.");
292
327
  }
293
- }, ke = async (e) => {
328
+ }, Ue = async (e) => {
294
329
  try {
295
- z(e), await r.controller.deleteNote(e), Q(), Y((t) => t === e ? null : t), ee();
330
+ ie(e), await r.controller.deleteNote(e), z(), b((t) => t === e ? null : t), ce();
296
331
  } catch (t) {
297
- a.error("Delete failed", m(t));
332
+ a.error("Delete failed", w(t));
298
333
  }
299
- }, yt = async (e) => {
334
+ }, Rt = async (e) => {
300
335
  try {
301
- z(e), await r.controller.restoreNote(e);
336
+ A(e), await r.controller.restoreNote(e);
302
337
  } catch (t) {
303
- a.error("Restore failed", m(t));
338
+ a.error("Restore failed", w(t));
304
339
  }
305
- }, xt = async (e) => {
340
+ }, Et = async (e) => {
306
341
  if (r.controller.deleteTrashedNotePermanently)
307
342
  try {
308
- z(e), await r.controller.deleteTrashedNotePermanently(e);
343
+ A(e), await r.controller.deleteTrashedNotePermanently(e);
309
344
  } catch (t) {
310
- a.error("Delete failed", m(t));
345
+ a.error("Delete failed", w(t));
311
346
  }
312
- }, Ct = async (e) => {
347
+ }, Ft = async (e) => {
313
348
  try {
314
349
  await r.controller.clearTrashTopic(e);
315
350
  } catch (t) {
316
- a.error("Trash failed", m(t));
351
+ a.error("Trash failed", w(t));
317
352
  }
318
- }, Nt = async () => {
319
- const e = K();
353
+ }, zt = async () => {
354
+ const e = q();
320
355
  if (e)
321
356
  try {
322
357
  await r.controller.updateNote(e, {
323
- body: ue(),
324
- color_token: fe()
325
- }), a.success("Saved", "Note updated."), F();
358
+ body: ge(),
359
+ color_token: Ne()
360
+ }), a.success("Saved", "Note updated."), V();
326
361
  } catch (t) {
327
- a.error("Save failed", m(t));
362
+ a.error("Save failed", w(t));
328
363
  }
329
- }, _t = async () => {
330
- const e = Z();
331
- !e || !q().trim() || (await ze(e, q()), A());
332
- }, Mt = async () => {
333
- const e = se().trim();
364
+ }, At = async () => {
365
+ const e = U();
366
+ !e || !J().trim() || (await Ke(e, J()), B());
367
+ }, Bt = async () => {
368
+ const e = we().trim();
334
369
  if (e)
335
370
  try {
336
371
  const t = await r.controller.createTopic({ name: e });
337
- ae(""), V(t.topic_id);
372
+ he(""), H(t.topic_id);
338
373
  } catch (t) {
339
- a.error("Topic failed", m(t));
374
+ a.error("Topic failed", w(t));
340
375
  }
341
- }, bt = (e) => {
342
- le(e.topic_id), $(e.name);
343
- }, Pt = async () => {
344
- const e = H();
376
+ }, Vt = (e) => {
377
+ ve(e.topic_id), Z(e.name);
378
+ }, jt = async () => {
379
+ const e = K();
345
380
  if (!e) return;
346
- const t = de().trim();
347
- if (B(), !!t)
381
+ const t = Te().trim();
382
+ if (W(), !!t)
348
383
  try {
349
384
  await r.controller.updateTopic(e, { name: t });
350
385
  } catch (o) {
351
- a.error("Rename failed", m(o));
386
+ a.error("Rename failed", w(o));
352
387
  }
353
- }, It = async (e) => {
354
- const t = De(e.topic_id) + $t(p().trash_items, e.topic_id);
355
- H() === e.topic_id && B();
388
+ }, Wt = async (e) => {
389
+ const t = Ae(e.topic_id) + lo(u().trash_items, e.topic_id);
390
+ K() === e.topic_id && W();
356
391
  try {
357
- if (await r.controller.deleteTopic(e.topic_id) === !1) {
392
+ if (xt(e.topic_id), await r.controller.deleteTopic(e.topic_id) === !1) {
358
393
  a.info(
359
394
  "Keep one topic",
360
395
  "At least one topic needs to remain available."
@@ -362,7 +397,7 @@ function co(r) {
362
397
  return;
363
398
  }
364
399
  if (t > 0) {
365
- ee(), a.success(
400
+ ce(), a.success(
366
401
  "Topic deleted",
367
402
  "Live notes moved into trash for this topic."
368
403
  );
@@ -370,46 +405,44 @@ function co(r) {
370
405
  }
371
406
  a.success("Topic deleted", "The empty topic was removed.");
372
407
  } catch (o) {
373
- a.error("Delete failed", m(o));
408
+ a.error("Delete failed", w(o));
374
409
  }
375
- }, Dt = async (e, t) => {
376
- Pe(e, t);
410
+ }, Ht = async (e, t) => {
411
+ const o = Nt(e);
412
+ Fe(e, t);
377
413
  try {
378
414
  await r.controller.updateNote(e, {
379
415
  x: t.x,
380
416
  y: t.y
381
417
  });
382
- } catch (o) {
383
- z(e), a.error("Move failed", m(o));
418
+ } catch (n) {
419
+ if (!Ee(e, o) || (re(e), A(e), !oe(e))) return;
420
+ a.error("Move failed", w(n));
421
+ return;
384
422
  }
385
- }, Ot = async () => {
386
- const e = Oe();
387
- e && (D(), await Re(e));
388
- }, Xt = async () => {
389
- const e = Oe();
390
- e && (D(), await Fe(e));
391
- }, ne = c(() => {
392
- const e = T();
423
+ Ee(e, o) && re(e);
424
+ }, de = c(() => {
425
+ const e = h();
393
426
  if (!e) return [];
394
427
  const t = [
395
428
  {
396
429
  id: "paste",
397
430
  kind: "action",
398
431
  label: "Paste here",
399
- icon: zt,
432
+ icon: eo,
400
433
  onSelect: () => {
401
- const o = T();
402
- o && (d(null), Fe(o));
434
+ const o = h();
435
+ o && (d(null), qe(o));
403
436
  }
404
437
  },
405
438
  {
406
439
  id: "new",
407
440
  kind: "action",
408
441
  label: "New note",
409
- icon: At,
442
+ icon: to,
410
443
  onSelect: () => {
411
- const o = T();
412
- o && (d(null), Re(o));
444
+ const o = h();
445
+ o && (d(null), Ge(o));
413
446
  }
414
447
  }
415
448
  ];
@@ -417,25 +450,25 @@ function co(r) {
417
450
  id: "delete",
418
451
  kind: "action",
419
452
  label: "Delete",
420
- icon: Ft,
453
+ icon: oo,
421
454
  destructive: !0,
422
455
  onSelect: () => {
423
- const o = T();
424
- o?.noteID && (d(null), ke(o.noteID));
456
+ const o = h();
457
+ o?.noteID && (d(null), Ue(o.noteID));
425
458
  }
426
459
  })), t;
427
- }), St = c(() => {
428
- const e = T();
460
+ }), $t = c(() => {
461
+ const e = h();
429
462
  if (!e) return;
430
- const t = ne().filter((n) => n.kind === "action").length, o = ne().filter((n) => n.kind === "separator").length;
431
- return Wt({
463
+ const t = de().filter((n) => n.kind === "action").length, o = de().filter((n) => n.kind === "separator").length;
464
+ return so({
432
465
  clientX: e.clientX,
433
466
  clientY: e.clientY,
434
- menuWidth: kt,
435
- menuHeight: Bt(t, o)
467
+ menuWidth: no,
468
+ menuHeight: ro(t, o)
436
469
  });
437
- }), Yt = (e) => {
438
- const t = I();
470
+ }), Gt = (e) => {
471
+ const t = k();
439
472
  t && d({
440
473
  clientX: e.clientX,
441
474
  clientY: e.clientY,
@@ -443,61 +476,79 @@ function co(r) {
443
476
  worldY: e.worldY,
444
477
  topicID: t.topic_id
445
478
  });
446
- }, Et = (e, t) => {
447
- j(t.note_id), Xe(e.clientX, e.clientY, {
479
+ }, Kt = (e, t) => {
480
+ le(t.note_id), Ve(e.clientX, e.clientY, {
448
481
  topicID: t.topic_id,
449
482
  noteID: t.note_id
450
483
  });
451
- }, Lt = (e) => {
452
- k(), Xe(e.clientX, e.clientY);
453
- }, Rt = (e) => {
454
- e.preventDefault(), e.stopPropagation(), mt(e.clientX, e.clientY);
484
+ }, Zt = (e) => {
485
+ j(), Ve(e.clientX, e.clientY);
486
+ }, qt = (e) => {
487
+ e.preventDefault(), e.stopPropagation(), kt(e.clientX, e.clientY);
488
+ };
489
+ m(() => {
490
+ const e = new Set(u().items.map((t) => t.note_id));
491
+ for (const t of G)
492
+ e.has(t) || Ct(t);
493
+ G = e;
494
+ }), m(() => {
495
+ const e = h();
496
+ e?.noteID && (oe(e.noteID) || d(null));
497
+ }), m(() => {
498
+ r.open || (G = /* @__PURE__ */ new Set());
499
+ });
500
+ const Ut = async () => {
501
+ const e = Be();
502
+ e && (D(), await Ge(e));
503
+ }, Jt = async () => {
504
+ const e = Be();
505
+ e && (D(), await qe(e));
455
506
  };
456
- return w(() => {
457
- r.open || (lt(), B(), b(null), y(null), Y(null));
458
- }), w(() => {
459
- const e = x();
460
- e && r.controller.activeTopicID() !== e && V(e);
461
- }), w(() => {
462
- const e = be();
507
+ return m(() => {
508
+ r.open || (_t(), W(), I(null), v(null), b(null));
509
+ }), m(() => {
510
+ const e = N();
511
+ e && r.controller.activeTopicID() !== e && H(e);
512
+ }), m(() => {
513
+ const e = Le();
463
514
  if (!e) {
464
- J = null;
515
+ te = null;
465
516
  return;
466
517
  }
467
- J !== e.note_id && (J = e.note_id, pe(e.body), me(e.color_token));
468
- }), w(() => {
469
- const e = ye();
518
+ te !== e.note_id && (te = e.note_id, ye(e.body), xe(e.color_token));
519
+ }), m(() => {
520
+ const e = Ie();
470
521
  if (!e) return;
471
- const t = p().items.find((n) => n.note_id === e);
522
+ const t = u().items.find((n) => n.note_id === e);
472
523
  if (!t) {
473
- y(null);
524
+ v(null);
474
525
  return;
475
526
  }
476
- const o = p().items.reduce(
527
+ const o = u().items.reduce(
477
528
  (n, i) => Math.max(n, i.z_index),
478
529
  0
479
530
  );
480
- t.z_index >= o && y(null);
481
- }), w(() => {
482
- const e = p().items, t = Ne();
531
+ t.z_index >= o && v(null);
532
+ }), m(() => {
533
+ const e = u().items, t = De();
483
534
  if (t.size === 0) return;
484
535
  let o = null;
485
536
  for (const [n, i] of t) {
486
- const s = e.find((u) => u.note_id === n);
487
- (!s || ie({ x: s.x, y: s.y }, i)) && (o ??= new Map(t), o.delete(n));
537
+ const s = e.find((p) => p.note_id === n);
538
+ (!s || pe({ x: s.x, y: s.y }, i)) && (o ??= new Map(t), o.delete(n));
488
539
  }
489
- o && E(o);
490
- }), w(() => {
540
+ o && R(o);
541
+ }), m(() => {
491
542
  if (!r.open) return;
492
543
  const e = () => {
493
- Ue(window.innerWidth < Ht);
544
+ at(window.innerWidth < ao);
494
545
  };
495
546
  e(), window.addEventListener("resize", e), X(() => window.removeEventListener("resize", e));
496
- }), w(() => {
497
- const e = ce();
547
+ }), m(() => {
548
+ const e = me();
498
549
  if (!e) return;
499
550
  const t = () => {
500
- $e({
551
+ nt({
501
552
  width: e.clientWidth,
502
553
  height: e.clientHeight
503
554
  });
@@ -508,114 +559,114 @@ function co(r) {
508
559
  }
509
560
  const o = new ResizeObserver(t);
510
561
  o.observe(e), X(() => o.disconnect());
511
- }), w(() => {
562
+ }), m(() => {
512
563
  if (!r.open) return;
513
- const e = window.setInterval(() => qe(Date.now()), 60 * 1e3);
564
+ const e = window.setInterval(() => ct(Date.now()), 60 * 1e3);
514
565
  X(() => window.clearInterval(e));
515
- }), w(() => {
516
- x() && d(null);
566
+ }), m(() => {
567
+ N() && d(null);
517
568
  }), X(() => {
518
- Q(), oe(!1);
569
+ z(), ae(!1);
519
570
  }), {
520
571
  header: {
521
- topicCount: Qe,
522
- totalLiveNotes: ot,
523
- trashCount: _e
572
+ topicCount: dt,
573
+ totalLiveNotes: ft,
574
+ trashCount: Se
524
575
  },
525
576
  rail: {
526
- topics: g,
527
- activeTopicID: x,
528
- draftTopicTitle: se,
529
- renamingTopicID: H,
530
- renamingTopicTitle: de,
531
- getLiveNoteCount: De,
532
- setDraftTopicTitle: ae,
533
- submitTopic: Mt,
534
- selectTopic: V,
535
- startTopicRename: bt,
536
- setRenamingTopicTitle: $,
537
- saveTopicRename: Pt,
538
- cancelTopicRename: B,
539
- deleteTopic: It
577
+ topics: y,
578
+ activeTopicID: N,
579
+ draftTopicTitle: we,
580
+ renamingTopicID: K,
581
+ renamingTopicTitle: Te,
582
+ getLiveNoteCount: Ae,
583
+ setDraftTopicTitle: he,
584
+ submitTopic: Bt,
585
+ selectTopic: H,
586
+ startTopicRename: Vt,
587
+ setRenamingTopicTitle: Z,
588
+ saveTopicRename: jt,
589
+ cancelTopicRename: W,
590
+ deleteTopic: Wt
540
591
  },
541
592
  board: {
542
- activeTopic: I,
543
- activeTopicLabel: rt,
544
- activeItems: L,
545
- activeTopicID: x,
546
- topics: g,
547
- topZIndex: nt,
548
- viewport: h,
549
- boardScaleLabel: it,
550
- isMobile: Ge,
551
- overviewOpen: ve,
552
- optimisticFrontNoteID: ye,
553
- copiedNoteID: Ke,
554
- setCanvasFrameRef: He,
555
- commitViewport: Se,
556
- openCanvasContextMenu: Yt,
557
- zoomOut: () => Ee("out"),
558
- zoomIn: () => Ee("in"),
559
- openOverview: Ie,
560
- selectTopic: V,
561
- mobileCreateNote: Ot,
562
- mobilePaste: Xt,
563
- seedMoveProjection: Pe,
564
- copyNote: gt,
565
- openNoteContextMenu: Et,
566
- openEditor: Tt,
567
- moveToTrash: ke,
568
- startOptimisticFront: vt,
569
- commitFront: j,
570
- commitMove: Dt
593
+ activeTopic: k,
594
+ activeTopicLabel: wt,
595
+ activeItems: E,
596
+ activeTopicID: N,
597
+ topics: y,
598
+ topZIndex: mt,
599
+ viewport: T,
600
+ boardScaleLabel: ht,
601
+ isMobile: st,
602
+ overviewOpen: _e,
603
+ optimisticFrontNoteID: Ie,
604
+ copiedNoteID: rt,
605
+ setCanvasFrameRef: ot,
606
+ commitViewport: je,
607
+ openCanvasContextMenu: Gt,
608
+ zoomOut: () => He("out"),
609
+ zoomIn: () => He("in"),
610
+ openOverview: ze,
611
+ selectTopic: H,
612
+ mobileCreateNote: Ut,
613
+ mobilePaste: Jt,
614
+ seedMoveProjection: Fe,
615
+ copyNote: Yt,
616
+ openNoteContextMenu: Kt,
617
+ openEditor: Lt,
618
+ moveToTrash: Ue,
619
+ startOptimisticFront: Xt,
620
+ commitFront: le,
621
+ commitMove: Ht
571
622
  },
572
623
  overview: {
573
- items: st,
574
- viewportStyle: at,
575
- navigationState: Je,
576
- beginNavigation: wt,
624
+ items: Tt,
625
+ viewportStyle: gt,
626
+ navigationState: lt,
627
+ beginNavigation: Dt,
577
628
  close: D,
578
- open: Ie
629
+ open: ze
579
630
  },
580
631
  trash: {
581
- open: we,
582
- groups: tt,
583
- count: _e,
584
- now: Ze,
632
+ open: Ce,
633
+ groups: pt,
634
+ count: Se,
635
+ now: it,
585
636
  canDeleteNow: !!r.controller.deleteTrashedNotePermanently,
586
- close: k,
587
- openDock: ee,
588
- backdropContextMenu: Lt,
589
- restore: yt,
590
- deleteNow: xt,
591
- clearTopic: Ct
637
+ close: j,
638
+ openDock: ce,
639
+ backdropContextMenu: Zt,
640
+ restore: Rt,
641
+ deleteNow: Et,
642
+ clearTopic: Ft
592
643
  },
593
644
  contextMenu: {
594
- state: T,
595
- items: ne,
596
- position: St,
645
+ state: h,
646
+ items: de,
647
+ position: $t,
597
648
  close: () => d(null),
598
- retarget: Rt
649
+ retarget: qt
599
650
  },
600
651
  editor: {
601
- note: be,
602
- draftBody: ue,
603
- draftColor: fe,
604
- setDraftBody: pe,
605
- setDraftColor: me,
606
- close: F,
607
- save: Nt
652
+ note: Le,
653
+ draftBody: ge,
654
+ draftColor: Ne,
655
+ setDraftBody: ye,
656
+ setDraftColor: xe,
657
+ close: V,
658
+ save: zt
608
659
  },
609
660
  manualPaste: {
610
- open: () => !!Z(),
611
- text: q,
612
- setText: G,
613
- close: A,
614
- confirm: _t
661
+ open: () => !!U(),
662
+ text: J,
663
+ setText: Q,
664
+ close: B,
665
+ confirm: At
615
666
  },
616
- handleCloseRequest: dt
667
+ handleCloseRequest: Pt
617
668
  };
618
669
  }
619
670
  export {
620
- co as useNotesOverlayModel
671
+ Mo as useNotesOverlayModel
621
672
  };