@floegence/floe-webapp-core 0.35.45 → 0.35.47

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