@floegence/floe-webapp-core 0.35.44 → 0.35.46

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