@floegence/floe-webapp-core 0.36.59 → 0.36.61

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,42 +1,39 @@
1
- import { createSignal as tt, createMemo as u, onCleanup as We } from "solid-js";
2
- import { clientToCanvasWorld as Oe } from "../ui/canvasGeometry.js";
3
- import { ArrowUp as ht, Copy as M, Trash as j, MessageSquare as xt, Region as bt, TextTool as Ce } from "../icons/index.js";
4
- import { WORKBENCH_STICKY_FILTER_ID as Te } from "./types.js";
5
- import { WORKBENCH_DEFAULT_STICKY_NOTE_COLOR as Ne, WORKBENCH_DEFAULT_TEXT_COLOR as Ae, WORKBENCH_DEFAULT_TEXT_FONT as St, WORKBENCH_BACKGROUND_MATERIALS as At, WORKBENCH_REGION_FILL_OPTIONS as Ie, WORKBENCH_STICKY_NOTE_COLORS as Le, WORKBENCH_DEFAULT_BACKGROUND_MATERIAL as De, WORKBENCH_DEFAULT_REGION_FILL as pe } from "./workbenchOptions.js";
6
- import { resolveWorkbenchModeStrategy as Wt, createContextMenuPosition as Me, createWorkbenchWidgetFrame as je, createWorkbenchId as S, createWorkbenchViewportCenteredOnWidget as Ot, findNearestWidget as ze, sanitizeFilters as Fe, WORKBENCH_CONTEXT_MENU_WIDTH_PX as Re, estimateContextMenuHeight as Be, clampScale as Xe, WORKBENCH_MAX_SCALE as Ee, WORKBENCH_CANVAS_ZOOM_STEP as Ct, normalizeWorkbenchInteractionMode as Ye, createWorkbenchViewportAtScale as He, WORKBENCH_WORK_MIN_SCALE as Ke, createWorkbenchViewportFitForWidget as Ve } from "./workbenchHelpers.js";
7
- import { resolveWorkbenchWidgetDefinitions as Ue, getWidgetEntry as ve } from "./widgets/widgetRegistry.js";
8
- import { resolveTextAnnotationDefaultSize as Pe, resolveBackgroundLayerDefaultSize as qe, resolveStickyNoteDefaultSize as Ge } from "./workbenchPlacement.js";
1
+ import { createSignal as tt, createMemo as u, onCleanup as Oe } from "solid-js";
2
+ import { clientToCanvasWorld as Te } from "../ui/canvasGeometry.js";
3
+ import { ArrowUp as wt, Copy as M, Trash as j, MessageSquare as bt, Region as xt, TextTool as Ce } from "../icons/index.js";
4
+ import { WORKBENCH_STICKY_FILTER_ID as Ne } from "./types.js";
5
+ import { WORKBENCH_DEFAULT_STICKY_NOTE_COLOR as Ae, WORKBENCH_DEFAULT_TEXT_COLOR as Le, WORKBENCH_DEFAULT_TEXT_FONT as St, WORKBENCH_BACKGROUND_MATERIALS as Lt, WORKBENCH_REGION_FILL_OPTIONS as Ie, WORKBENCH_STICKY_NOTE_COLORS as De, WORKBENCH_DEFAULT_BACKGROUND_MATERIAL as pe, WORKBENCH_DEFAULT_REGION_FILL as Me } from "./workbenchOptions.js";
6
+ import { resolveWorkbenchModeStrategy as Wt, createContextMenuPosition as je, resolveWorkbenchLayerFront as Ot, createWorkbenchWidgetFrame as Fe, createWorkbenchId as S, createWorkbenchViewportCenteredOnWidget as Tt, compareWorkbenchLayerRenderOrder as Re, findNearestWidget as Be, sanitizeFilters as Xe, WORKBENCH_CONTEXT_MENU_WIDTH_PX as ze, estimateContextMenuHeight as Ee, clampScale as Ye, WORKBENCH_MAX_SCALE as He, WORKBENCH_CANVAS_ZOOM_STEP as Ct, normalizeWorkbenchInteractionMode as Ke, createWorkbenchViewportAtScale as Ve, WORKBENCH_WORK_MIN_SCALE as ve, createWorkbenchViewportFitForWidget as Ue } from "./workbenchHelpers.js";
7
+ import { resolveWorkbenchWidgetDefinitions as Pe, getWidgetEntry as qe } from "./widgets/widgetRegistry.js";
8
+ import { resolveTextAnnotationDefaultSize as Ze, resolveBackgroundLayerDefaultSize as Ge, resolveStickyNoteDefaultSize as $e } from "./workbenchPlacement.js";
9
9
  function It(o, d) {
10
10
  const a = o.findIndex((s) => s === d);
11
11
  return o[(a + 1) % o.length] ?? o[0];
12
12
  }
13
- function Tt(o, d, a) {
13
+ function Nt(o, d, a) {
14
14
  const s = String(d ?? "").trim();
15
15
  return o.includes(s) ? s : a;
16
16
  }
17
- function $e(o, d) {
17
+ function Je(o, d) {
18
18
  const a = Number(o);
19
19
  return Number.isFinite(a) ? Math.max(0.08, Math.min(1, a)) : d;
20
20
  }
21
- function Ze(o) {
22
- return It(Le, o);
21
+ function Qe(o) {
22
+ return It(De, o);
23
23
  }
24
- function Je(o) {
25
- return It(At, o);
24
+ function tn(o) {
25
+ return It(Lt, o);
26
26
  }
27
- function Nt(o) {
27
+ function At(o) {
28
28
  return !("kind" in o);
29
29
  }
30
- function Qe(o, d) {
31
- return o.z_index !== d.z_index ? o.z_index - d.z_index : o.created_at_unix_ms !== d.created_at_unix_ms ? o.created_at_unix_ms - d.created_at_unix_ms : o.id.localeCompare(d.id);
32
- }
33
30
  function et(o) {
34
31
  return o.reduce((d, a) => Math.max(d, a.z_index), 1);
35
32
  }
36
- function tn(o, d) {
33
+ function en(o, d) {
37
34
  return et([...o, ...d]);
38
35
  }
39
- function en(o) {
36
+ function nn(o) {
40
37
  return {
41
38
  id: o.id,
42
39
  type: "sticky_note",
@@ -49,24 +46,24 @@ function en(o) {
49
46
  created_at_unix_ms: o.created_at_unix_ms
50
47
  };
51
48
  }
52
- function nn(o, d, a) {
53
- const s = Date.now(), { width: _, height: y } = Ge();
49
+ function on(o, d, a) {
50
+ const s = Date.now(), { width: y, height: _ } = $e();
54
51
  return {
55
52
  id: S(),
56
53
  kind: "sticky_note",
57
54
  body: "Capture the thought, decision, or next step here.",
58
- color: Ne,
59
- x: o - _ / 2,
60
- y: d - y / 2,
61
- width: _,
62
- height: y,
55
+ color: Ae,
56
+ x: o - y / 2,
57
+ y: d - _ / 2,
58
+ width: y,
59
+ height: _,
63
60
  z_index: a,
64
61
  created_at_unix_ms: s,
65
62
  updated_at_unix_ms: s
66
63
  };
67
64
  }
68
- function on(o, d, a, s) {
69
- const _ = Date.now(), { width: y, height: h } = Pe(s);
65
+ function cn(o, d, a, s) {
66
+ const y = Date.now(), { width: _, height: w } = Ze(s);
70
67
  return {
71
68
  id: S(),
72
69
  kind: "text",
@@ -74,18 +71,18 @@ function on(o, d, a, s) {
74
71
  font_family: s?.font_family ?? St.fontFamily,
75
72
  font_size: s?.font_size ?? 30,
76
73
  font_weight: s?.font_weight ?? St.fontWeight,
77
- color: s?.color ?? Ae,
74
+ color: s?.color ?? Le,
78
75
  align: s?.align ?? "left",
79
- x: o - y / 2,
80
- y: d - h / 2,
81
- width: y,
82
- height: h,
76
+ x: o - _ / 2,
77
+ y: d - w / 2,
78
+ width: _,
79
+ height: w,
83
80
  z_index: a,
84
- created_at_unix_ms: _,
85
- updated_at_unix_ms: _
81
+ created_at_unix_ms: y,
82
+ updated_at_unix_ms: y
86
83
  };
87
84
  }
88
- function cn(o) {
85
+ function dn(o) {
89
86
  const d = Date.now();
90
87
  return {
91
88
  ...o,
@@ -97,32 +94,32 @@ function cn(o) {
97
94
  updated_at_unix_ms: d
98
95
  };
99
96
  }
100
- function dn(o, d, a, s) {
101
- const _ = Date.now(), { width: y, height: h } = qe(s), f = String(s?.name ?? "").trim() || "Focus area";
97
+ function an(o, d, a, s) {
98
+ const y = Date.now(), { width: _, height: w } = Ge(s), f = String(s?.name ?? "").trim() || "Focus area";
102
99
  return {
103
100
  id: S(),
104
101
  name: f,
105
- fill: Tt(
102
+ fill: Nt(
106
103
  Ie,
107
104
  s?.fill,
108
- pe
105
+ Me
109
106
  ),
110
- opacity: $e(s?.opacity, 0.72),
111
- material: Tt(
112
- At,
107
+ opacity: Je(s?.opacity, 0.72),
108
+ material: Nt(
109
+ Lt,
113
110
  s?.material,
114
- De
111
+ pe
115
112
  ),
116
- x: o - y / 2,
117
- y: d - h / 2,
118
- width: y,
119
- height: h,
113
+ x: o - _ / 2,
114
+ y: d - w / 2,
115
+ width: _,
116
+ height: w,
120
117
  z_index: a,
121
- created_at_unix_ms: _,
122
- updated_at_unix_ms: _
118
+ created_at_unix_ms: y,
119
+ updated_at_unix_ms: y
123
120
  };
124
121
  }
125
- function an(o) {
122
+ function sn(o) {
126
123
  const d = Date.now();
127
124
  return {
128
125
  ...o,
@@ -135,44 +132,44 @@ function an(o) {
135
132
  updated_at_unix_ms: d
136
133
  };
137
134
  }
138
- function Wn(o) {
139
- const [d, a] = tt(null), [s, _] = tt(null), [y, h] = tt({ width: 0, height: 0 });
140
- let f = null, C = null;
141
- const r = o.state, x = u(() => r().widgets), z = u(() => r().stickyNotes ?? []), nt = u(() => r().annotations ?? []), it = u(() => r().backgroundLayers ?? []), m = u(() => r().viewport), Lt = u(() => r().locked), F = u(() => r().filters), Dt = u(() => r().selectedWidgetId), R = u(
135
+ function On(o) {
136
+ const [d, a] = tt(null), [s, y] = tt(null), [_, w] = tt({ width: 0, height: 0 });
137
+ let f = null, T = null;
138
+ const r = o.state, b = u(() => r().widgets), W = u(() => r().stickyNotes ?? []), nt = u(() => r().annotations ?? []), it = u(() => r().backgroundLayers ?? []), m = u(() => r().viewport), Dt = u(() => r().locked), F = u(() => r().filters), pt = u(() => r().selectedWidgetId), R = u(
142
139
  () => r().selectedObject ?? (r().selectedWidgetId ? { kind: "widget", id: r().selectedWidgetId } : null)
143
- ), T = u(() => r().mode ?? "work"), pt = u(() => Wt(T())), ot = u(() => r().activeTool ?? "select"), Mt = u(() => r().theme), W = u(() => tn(x(), z())), jt = u(() => `${Math.round(m().scale * 100)}%`), zt = () => typeof o.widgetDefinitions == "function" ? o.widgetDefinitions() : o.widgetDefinitions, Ft = () => typeof o.textAnnotationDefaults == "function" ? o.textAnnotationDefaults() : o.textAnnotationDefaults, Rt = () => typeof o.backgroundLayerDefaults == "function" ? o.backgroundLayerDefaults() : o.backgroundLayerDefaults, N = u(
144
- () => Ue(zt())
145
- ), B = (e, t) => {
146
- const n = Number.isFinite(e) && e > 0 ? e : 0, i = Number.isFinite(t) && t > 0 ? t : 0, c = { width: n, height: i }, g = y();
147
- return g.width === n && g.height === i ? g : (h(c), c);
140
+ ), C = u(() => r().mode ?? "work"), Mt = u(() => Wt(C())), ot = u(() => r().activeTool ?? "select"), jt = u(() => r().theme), B = u(() => en(b(), W())), Ft = u(() => `${Math.round(m().scale * 100)}%`), Rt = () => typeof o.widgetDefinitions == "function" ? o.widgetDefinitions() : o.widgetDefinitions, Bt = () => typeof o.textAnnotationDefaults == "function" ? o.textAnnotationDefaults() : o.textAnnotationDefaults, Xt = () => typeof o.backgroundLayerDefaults == "function" ? o.backgroundLayerDefaults() : o.backgroundLayerDefaults, N = u(
141
+ () => Pe(Rt())
142
+ ), X = (e, t) => {
143
+ const n = Number.isFinite(e) && e > 0 ? e : 0, i = Number.isFinite(t) && t > 0 ? t : 0, c = { width: n, height: i }, g = _();
144
+ return g.width === n && g.height === i ? g : (w(c), c);
148
145
  }, ct = () => {
149
- C?.disconnect(), C = null;
150
- }, w = () => f ? B(f.clientWidth, f.clientHeight) : B(0, 0), Bt = (e) => {
146
+ T?.disconnect(), T = null;
147
+ }, h = () => f ? X(f.clientWidth, f.clientHeight) : X(0, 0), zt = (e) => {
151
148
  if (f === (e ?? null)) {
152
- w();
149
+ h();
153
150
  return;
154
151
  }
155
- ct(), f = e ?? null, w(), !(!f || typeof ResizeObserver > "u") && (C = new ResizeObserver((t) => {
152
+ ct(), f = e ?? null, h(), !(!f || typeof ResizeObserver > "u") && (T = new ResizeObserver((t) => {
156
153
  const n = t[0];
157
- B(
154
+ X(
158
155
  n?.contentRect.width ?? f?.clientWidth ?? 0,
159
156
  n?.contentRect.height ?? f?.clientHeight ?? 0
160
157
  );
161
- }), C.observe(f));
158
+ }), T.observe(f));
162
159
  };
163
- We(() => {
160
+ Oe(() => {
164
161
  ct(), f = null;
165
162
  });
166
- const Xt = (e) => {
163
+ const Et = (e) => {
167
164
  a({
168
165
  clientX: e.clientX,
169
166
  clientY: e.clientY,
170
167
  worldX: e.worldX,
171
168
  worldY: e.worldY,
172
- target: { kind: "canvas", mode: T() }
169
+ target: { kind: "canvas", mode: C() }
173
170
  });
174
- }, Et = (e, t) => {
175
- b(t.id), a({
171
+ }, Yt = (e, t) => {
172
+ x(t.id), a({
176
173
  clientX: e.clientX,
177
174
  clientY: e.clientY,
178
175
  worldX: t.x,
@@ -180,8 +177,8 @@ function Wn(o) {
180
177
  target: { kind: "widget", id: t.id },
181
178
  widgetId: t.id
182
179
  });
183
- }, Yt = (e, t) => {
184
- L(t.id), a({
180
+ }, Ht = (e, t) => {
181
+ I(t.id), a({
185
182
  clientX: e.clientX,
186
183
  clientY: e.clientY,
187
184
  worldX: t.x,
@@ -189,7 +186,7 @@ function Wn(o) {
189
186
  target: { kind: "sticky_note", id: t.id },
190
187
  widgetId: t.id
191
188
  });
192
- }, Ht = (e, t) => {
189
+ }, Kt = (e, t) => {
193
190
  a({
194
191
  clientX: e.clientX,
195
192
  clientY: e.clientY,
@@ -197,7 +194,7 @@ function Wn(o) {
197
194
  worldY: t.y,
198
195
  target: { kind: "annotation", id: t.id }
199
196
  });
200
- }, Kt = (e, t) => {
197
+ }, Vt = (e, t) => {
201
198
  a({
202
199
  clientX: e.clientX,
203
200
  clientY: e.clientY,
@@ -205,9 +202,9 @@ function Wn(o) {
205
202
  worldY: t.y,
206
203
  target: { kind: "background_layer", id: t.id }
207
204
  });
208
- }, l = () => a(null), Vt = (e) => r().widgets.find((t) => t.id === e) ?? null, A = (e) => r().widgets.find((t) => t.type === e) ?? null, X = (e) => r().stickyNotes?.find((t) => t.id === e) ?? null, dt = (e) => r().annotations?.find((t) => t.id === e) ?? null, at = (e) => r().backgroundLayers?.find((t) => t.id === e) ?? null, Ut = (e) => e.target ? e.target : e.widgetId ? X(e.widgetId) ? { kind: "sticky_note", id: e.widgetId } : { kind: "widget", id: e.widgetId } : { kind: "canvas", mode: T() }, I = (e, t) => {
205
+ }, l = () => a(null), vt = (e) => r().widgets.find((t) => t.id === e) ?? null, A = (e) => r().widgets.find((t) => t.type === e) ?? null, z = (e) => r().stickyNotes?.find((t) => t.id === e) ?? null, dt = (e) => r().annotations?.find((t) => t.id === e) ?? null, at = (e) => r().backgroundLayers?.find((t) => t.id === e) ?? null, Ut = (e) => e.target ? e.target : e.widgetId ? z(e.widgetId) ? { kind: "sticky_note", id: e.widgetId } : { kind: "widget", id: e.widgetId } : { kind: "canvas", mode: C() }, L = (e, t) => {
209
206
  if (t?.source === "pointer") {
210
- const n = f?.getBoundingClientRect(), i = n ? Oe(n, m(), {
207
+ const n = f?.getBoundingClientRect(), i = n ? Te(n, m(), {
211
208
  clientX: t.clientX,
212
209
  clientY: t.clientY
213
210
  }) : null;
@@ -218,7 +215,7 @@ function Wn(o) {
218
215
  worldX: e.worldX,
219
216
  worldY: e.worldY
220
217
  };
221
- }, vt = (e, t) => {
218
+ }, Pt = (e, t) => {
222
219
  const n = e.singleton ? A(e.type) : null;
223
220
  return n ? {
224
221
  id: `goto-${e.type}`,
@@ -239,7 +236,7 @@ function Wn(o) {
239
236
  label: `Add ${e.label}`,
240
237
  icon: e.icon,
241
238
  onSelect: (i) => {
242
- const c = I(t, i);
239
+ const c = L(t, i);
243
240
  Y(e.type, c.worldX, c.worldY), l();
244
241
  }
245
242
  };
@@ -248,14 +245,14 @@ function Wn(o) {
248
245
  if (!e) return [];
249
246
  const t = Ut(e);
250
247
  if (t.kind === "widget") {
251
- const n = x().find((c) => c.id === t.id), i = [];
248
+ const n = b().find((c) => c.id === t.id), i = [];
252
249
  return n && (i.push({
253
250
  id: "bring-to-front",
254
251
  kind: "action",
255
252
  label: "Bring to Front",
256
- icon: ht,
253
+ icon: wt,
257
254
  onSelect: () => {
258
- b(n.id), l();
255
+ x(n.id), l();
259
256
  }
260
257
  }), i.push({
261
258
  id: "duplicate",
@@ -277,14 +274,14 @@ function Wn(o) {
277
274
  }), i;
278
275
  }
279
276
  if (t.kind === "sticky_note") {
280
- const n = X(t.id), i = [];
277
+ const n = z(t.id), i = [];
281
278
  return n && (i.push({
282
279
  id: "bring-to-front",
283
280
  kind: "action",
284
281
  label: "Bring to Front",
285
- icon: ht,
282
+ icon: wt,
286
283
  onSelect: () => {
287
- L(n.id), l();
284
+ I(n.id), l();
288
285
  }
289
286
  }), i.push({
290
287
  id: "copy-content",
@@ -298,9 +295,9 @@ function Wn(o) {
298
295
  id: "change-color",
299
296
  kind: "action",
300
297
  label: "Change Color",
301
- icon: xt,
298
+ icon: bt,
302
299
  onSelect: () => {
303
- gt(n.id, { color: Ze(n.color) }), l();
300
+ gt(n.id, { color: Qe(n.color) }), l();
304
301
  }
305
302
  })), i.push({ id: "separator-delete", kind: "separator" }), i.push({
306
303
  id: "delete",
@@ -309,7 +306,7 @@ function Wn(o) {
309
306
  icon: j,
310
307
  destructive: !0,
311
308
  onSelect: () => {
312
- v(t.id), l();
309
+ U(t.id), l();
313
310
  }
314
311
  }), i;
315
312
  }
@@ -348,9 +345,9 @@ function Wn(o) {
348
345
  id: "change-material",
349
346
  kind: "action",
350
347
  label: "Change Material",
351
- icon: bt,
348
+ icon: xt,
352
349
  onSelect: () => {
353
- kt(n.id, { material: Je(n.material) }), l();
350
+ kt(n.id, { material: tn(n.material) }), l();
354
351
  }
355
352
  })), i.push({ id: "separator-delete", kind: "separator" }), i.push({
356
353
  id: "delete",
@@ -368,10 +365,10 @@ function Wn(o) {
368
365
  id: "create-background-region",
369
366
  kind: "action",
370
367
  label: "Add Region",
371
- icon: bt,
368
+ icon: xt,
372
369
  onSelect: (n) => {
373
- const i = I(e, n);
374
- U(i.worldX, i.worldY), l();
370
+ const i = L(e, n);
371
+ v(i.worldX, i.worldY), l();
375
372
  }
376
373
  },
377
374
  {
@@ -380,7 +377,7 @@ function Wn(o) {
380
377
  label: "Add Text",
381
378
  icon: Ce,
382
379
  onSelect: (n) => {
383
- const i = I(e, n);
380
+ const i = L(e, n);
384
381
  V(i.worldX, i.worldY), l();
385
382
  }
386
383
  }
@@ -389,29 +386,29 @@ function Wn(o) {
389
386
  id: "create-sticky-note",
390
387
  kind: "action",
391
388
  label: "Add Sticky",
392
- icon: xt,
389
+ icon: bt,
393
390
  onSelect: (n) => {
394
- const i = I(e, n);
391
+ const i = L(e, n);
395
392
  K(i.worldX, i.worldY), l();
396
393
  }
397
394
  },
398
- ...N().map((n) => vt(n, e))
395
+ ...N().map((n) => Pt(n, e))
399
396
  ];
400
- }), Pt = u(() => {
397
+ }), qt = u(() => {
401
398
  const e = d();
402
399
  if (!e) return;
403
400
  const t = st(), n = t.filter((c) => c.kind === "action").length, i = t.filter((c) => c.kind === "separator").length;
404
- return Me({
401
+ return je({
405
402
  clientX: e.clientX,
406
403
  clientY: e.clientY,
407
- menuWidth: Re,
408
- menuHeight: Be(n, i)
404
+ menuWidth: ze,
405
+ menuHeight: Ee(n, i)
409
406
  });
410
407
  }), E = (e, t) => {
411
- const n = ve(e, N()), i = n.singleton ? A(e) : null;
408
+ const n = qe(e, N()), i = n.singleton ? A(e) : null;
412
409
  if (i)
413
410
  return O(i, { centerViewport: !0 });
414
- const c = je(n, t), g = {
411
+ const c = Fe(n, t), g = {
415
412
  id: S(),
416
413
  type: e,
417
414
  title: n.defaultTitle,
@@ -419,7 +416,7 @@ function Wn(o) {
419
416
  y: c.y,
420
417
  width: c.width,
421
418
  height: c.height,
422
- z_index: W() + 1,
419
+ z_index: B() + 1,
423
420
  created_at_unix_ms: Date.now()
424
421
  };
425
422
  return o.setState((k) => ({
@@ -430,7 +427,7 @@ function Wn(o) {
430
427
  mode: "work",
431
428
  activeTool: "select"
432
429
  })), g;
433
- }, qt = (e, t, n) => E(e, {
430
+ }, Zt = (e, t, n) => E(e, {
434
431
  anchor: "top_left",
435
432
  worldX: t,
436
433
  worldY: n
@@ -450,7 +447,7 @@ function Wn(o) {
450
447
  selectedObject: t.selectedObject?.kind === "widget" && t.selectedObject.id === e ? null : t.selectedObject ?? null
451
448
  }));
452
449
  }, K = (e, t) => {
453
- const n = nn(e, t, W() + 1);
450
+ const n = on(e, t, B() + 1);
454
451
  return o.setState((i) => ({
455
452
  ...i,
456
453
  stickyNotes: [...i.stickyNotes ?? [], n],
@@ -460,11 +457,11 @@ function Wn(o) {
460
457
  activeTool: "select"
461
458
  })), n;
462
459
  }, V = (e, t) => {
463
- const n = on(
460
+ const n = cn(
464
461
  e,
465
462
  t,
466
463
  et(nt()) + 1,
467
- Ft()
464
+ Bt()
468
465
  );
469
466
  return o.setState((i) => ({
470
467
  ...i,
@@ -475,7 +472,7 @@ function Wn(o) {
475
472
  activeTool: "select"
476
473
  })), n;
477
474
  }, lt = (e) => {
478
- const t = cn(e);
475
+ const t = dn(e);
479
476
  return o.setState((n) => ({
480
477
  ...n,
481
478
  annotations: [...n.annotations ?? [], t],
@@ -484,12 +481,12 @@ function Wn(o) {
484
481
  mode: "background",
485
482
  activeTool: "select"
486
483
  })), t;
487
- }, U = (e, t) => {
488
- const n = dn(
484
+ }, v = (e, t) => {
485
+ const n = an(
489
486
  e,
490
487
  t,
491
488
  et(it()) + 1,
492
- Rt()
489
+ Xt()
493
490
  );
494
491
  return o.setState((i) => ({
495
492
  ...i,
@@ -500,7 +497,7 @@ function Wn(o) {
500
497
  activeTool: "select"
501
498
  })), n;
502
499
  }, ut = (e) => {
503
- const t = an(e);
500
+ const t = sn(e);
504
501
  return o.setState((n) => ({
505
502
  ...n,
506
503
  backgroundLayers: [...n.backgroundLayers ?? [], t],
@@ -510,23 +507,23 @@ function Wn(o) {
510
507
  activeTool: "select"
511
508
  })), t;
512
509
  }, Gt = (e) => {
513
- _(e);
514
- }, b = (e) => {
515
- _(e);
516
- const t = W(), n = x().find((i) => i.id === e);
517
- n && n.z_index < t && o.setState((i) => ({
518
- ...i,
519
- widgets: i.widgets.map((c) => c.id === e ? { ...c, z_index: t + 1 } : c)
520
- }));
521
- }, L = (e) => {
522
- _(e);
523
- const t = W();
524
- o.setState((n) => ({
510
+ y(e);
511
+ }, x = (e) => {
512
+ const t = Ot([...b(), ...W()], e);
513
+ t && (y(e), t.isTop || o.setState((n) => ({
514
+ ...n,
515
+ widgets: n.widgets.map(
516
+ (i) => i.id === e ? { ...i, z_index: t.nextZIndex } : i
517
+ )
518
+ })));
519
+ }, I = (e) => {
520
+ const t = Ot([...b(), ...W()], e);
521
+ t && (y(e), t.isTop || o.setState((n) => ({
525
522
  ...n,
526
523
  stickyNotes: (n.stickyNotes ?? []).map(
527
- (i) => i.id === e && i.z_index < t ? { ...i, z_index: t + 1, updated_at_unix_ms: Date.now() } : i
524
+ (i) => i.id === e ? { ...i, z_index: t.nextZIndex, updated_at_unix_ms: Date.now() } : i
528
525
  )
529
- }));
526
+ })));
530
527
  }, $t = (e, t) => {
531
528
  o.setState((n) => ({
532
529
  ...n,
@@ -534,21 +531,21 @@ function Wn(o) {
534
531
  (i) => i.id === e ? { ...i, x: t.x, y: t.y } : i
535
532
  )
536
533
  }));
537
- }, Zt = (e, t) => {
534
+ }, Jt = (e, t) => {
538
535
  o.setState((n) => ({
539
536
  ...n,
540
537
  widgets: n.widgets.map(
541
538
  (i) => i.id === e ? { ...i, width: t.width, height: t.height } : i
542
539
  )
543
540
  }));
544
- }, Jt = (e, t) => {
541
+ }, Qt = (e, t) => {
545
542
  o.setState((n) => ({
546
543
  ...n,
547
544
  stickyNotes: (n.stickyNotes ?? []).map(
548
545
  (i) => i.id === e ? { ...i, x: t.x, y: t.y, updated_at_unix_ms: Date.now() } : i
549
546
  )
550
547
  }));
551
- }, Qt = (e, t) => {
548
+ }, te = (e, t) => {
552
549
  o.setState((n) => ({
553
550
  ...n,
554
551
  stickyNotes: (n.stickyNotes ?? []).map(
@@ -567,27 +564,27 @@ function Wn(o) {
567
564
  } : i
568
565
  )
569
566
  }));
570
- }, v = (e) => {
567
+ }, U = (e) => {
571
568
  o.setState((t) => ({
572
569
  ...t,
573
570
  stickyNotes: (t.stickyNotes ?? []).filter((n) => n.id !== e),
574
571
  selectedObject: t.selectedObject?.kind === "sticky_note" && t.selectedObject.id === e ? null : t.selectedObject ?? null
575
572
  }));
576
- }, te = (e, t) => {
573
+ }, ee = (e, t) => {
577
574
  o.setState((n) => ({
578
575
  ...n,
579
576
  annotations: (n.annotations ?? []).map(
580
577
  (i) => i.id === e ? { ...i, x: t.x, y: t.y, updated_at_unix_ms: Date.now() } : i
581
578
  )
582
579
  }));
583
- }, ee = (e, t) => {
580
+ }, ne = (e, t) => {
584
581
  o.setState((n) => ({
585
582
  ...n,
586
583
  annotations: (n.annotations ?? []).map(
587
584
  (i) => i.id === e ? { ...i, width: t.width, height: t.height, updated_at_unix_ms: Date.now() } : i
588
585
  )
589
586
  }));
590
- }, ne = (e, t) => {
587
+ }, ie = (e, t) => {
591
588
  o.setState((n) => ({
592
589
  ...n,
593
590
  annotations: (n.annotations ?? []).map(
@@ -609,14 +606,14 @@ function Wn(o) {
609
606
  annotations: (t.annotations ?? []).filter((n) => n.id !== e),
610
607
  selectedObject: t.selectedObject?.kind === "annotation" && t.selectedObject.id === e ? null : t.selectedObject ?? null
611
608
  }));
612
- }, ie = (e, t) => {
609
+ }, oe = (e, t) => {
613
610
  o.setState((n) => ({
614
611
  ...n,
615
612
  backgroundLayers: (n.backgroundLayers ?? []).map(
616
613
  (i) => i.id === e ? { ...i, x: t.x, y: t.y, updated_at_unix_ms: Date.now() } : i
617
614
  )
618
615
  }));
619
- }, oe = (e, t) => {
616
+ }, ce = (e, t) => {
620
617
  o.setState((n) => ({
621
618
  ...n,
622
619
  backgroundLayers: (n.backgroundLayers ?? []).map(
@@ -644,28 +641,28 @@ function Wn(o) {
644
641
  selectedObject: t.selectedObject?.kind === "background_layer" && t.selectedObject.id === e ? null : t.selectedObject ?? null
645
642
  }));
646
643
  };
647
- let G = 0;
648
- const $ = (e) => {
644
+ let Z = 0;
645
+ const G = (e) => {
649
646
  o.setState((t) => ({ ...t, viewport: e }));
650
- }, ce = () => {
651
- G += 1;
647
+ }, de = () => {
648
+ Z += 1;
652
649
  }, D = (e) => {
653
- const t = m(), n = t.x, i = t.y, c = t.scale, g = performance.now(), k = 360, xe = ++G, be = (J) => 1 - Math.pow(1 - J, 3), mt = (J) => {
654
- if (xe !== G) return;
655
- const Se = J - g, wt = Math.min(Math.max(Se / k, 0), 1), Q = be(wt);
656
- $({
650
+ const t = m(), n = t.x, i = t.y, c = t.scale, g = performance.now(), k = 360, xe = ++Z, Se = (J) => 1 - Math.pow(1 - J, 3), mt = (J) => {
651
+ if (xe !== Z) return;
652
+ const We = J - g, ht = Math.min(Math.max(We / k, 0), 1), Q = Se(ht);
653
+ G({
657
654
  x: n + (e.x - n) * Q,
658
655
  y: i + (e.y - i) * Q,
659
656
  scale: c + (e.scale - c) * Q
660
- }), wt < 1 && requestAnimationFrame(mt);
657
+ }), ht < 1 && requestAnimationFrame(mt);
661
658
  };
662
659
  requestAnimationFrame(mt);
663
- }, de = (e) => {
660
+ }, ae = (e) => {
664
661
  const t = Wt(e), n = m();
665
662
  if (n.scale >= t.minScale) return;
666
- const i = w();
663
+ const i = h();
667
664
  D(
668
- He({
665
+ Ve({
669
666
  viewport: n,
670
667
  scale: t.minScale,
671
668
  minScale: t.minScale,
@@ -674,35 +671,35 @@ function Wn(o) {
674
671
  })
675
672
  );
676
673
  }, ft = (e) => {
677
- const t = m(), n = w(), i = (n.width / 2 - t.x) / t.scale, c = (n.height / 2 - t.y) / t.scale, g = Xe(
674
+ const t = m(), n = h(), i = (n.width / 2 - t.x) / t.scale, c = (n.height / 2 - t.y) / t.scale, g = Ye(
678
675
  e === "in" ? t.scale * Ct : t.scale / Ct,
679
- pt().minScale,
680
- Ee
676
+ Mt().minScale,
677
+ He
681
678
  ), k = {
682
679
  x: n.width / 2 - i * g,
683
680
  y: n.height / 2 - c * g,
684
681
  scale: g
685
682
  };
686
- $(k);
687
- }, ae = () => {
683
+ G(k);
684
+ }, se = () => {
688
685
  o.setState((e) => ({ ...e, locked: !e.locked }));
689
- }, se = (e) => {
686
+ }, re = (e) => {
690
687
  o.setState((t) => ({
691
688
  ...t,
692
689
  filters: { ...t.filters, [e]: !t.filters[e] }
693
690
  }));
694
- }, re = (e, t) => {
691
+ }, le = (e, t) => {
695
692
  o.setState((n) => {
696
693
  const i = { ...n.filters }, c = [...new Set(t.map((k) => String(k)).filter(Boolean))], g = c.length > 1 && c.every((k) => i[k] !== !1 == (k === e));
697
694
  for (const k of c)
698
695
  i[k] = g ? !0 : k === e;
699
696
  return { ...n, filters: i };
700
697
  });
701
- }, le = () => {
698
+ }, ue = () => {
702
699
  const e = N();
703
700
  o.setState((t) => ({
704
701
  ...t,
705
- filters: Fe(void 0, e)
702
+ filters: Xe(void 0, e)
706
703
  }));
707
704
  }, p = (e) => {
708
705
  o.setState((t) => ({
@@ -712,26 +709,26 @@ function Wn(o) {
712
709
  mode: t.mode === "background" ? "work" : t.mode,
713
710
  activeTool: "select"
714
711
  }));
715
- }, _t = () => {
712
+ }, yt = () => {
716
713
  o.setState(
717
714
  (e) => e.selectedWidgetId === null && !e.selectedObject ? e : { ...e, selectedWidgetId: null, selectedObject: null }
718
715
  );
719
- }, ue = (e) => {
716
+ }, ge = (e) => {
720
717
  o.setState((t) => ({
721
718
  ...t,
722
719
  selectedObject: e,
723
720
  selectedWidgetId: e?.kind === "widget" ? e.id : null,
724
721
  activeTool: "select"
725
722
  }));
726
- }, yt = (e) => {
723
+ }, _t = (e) => {
727
724
  o.setState((t) => ({
728
725
  ...t,
729
726
  selectedWidgetId: null,
730
727
  selectedObject: { kind: "sticky_note", id: e },
731
728
  mode: "work",
732
729
  activeTool: "select"
733
- })), L(e);
734
- }, ge = (e) => {
730
+ })), I(e);
731
+ }, ke = (e) => {
735
732
  o.setState((t) => ({
736
733
  ...t,
737
734
  selectedWidgetId: null,
@@ -739,7 +736,7 @@ function Wn(o) {
739
736
  mode: "background",
740
737
  activeTool: "select"
741
738
  }));
742
- }, ke = (e) => {
739
+ }, fe = (e) => {
743
740
  o.setState((t) => ({
744
741
  ...t,
745
742
  selectedWidgetId: null,
@@ -747,34 +744,34 @@ function Wn(o) {
747
744
  mode: "background",
748
745
  activeTool: "select"
749
746
  }));
750
- }, fe = (e) => {
751
- const t = Ye(e);
747
+ }, ye = (e) => {
748
+ const t = Ke(e);
752
749
  o.setState((n) => ({
753
750
  ...n,
754
751
  mode: t,
755
752
  activeTool: "select",
756
753
  selectedWidgetId: t === "work" ? n.selectedObject?.kind === "widget" ? n.selectedObject.id : n.selectedWidgetId : null,
757
754
  selectedObject: t === "work" ? n.selectedObject?.kind === "widget" || n.selectedObject?.kind === "sticky_note" ? n.selectedObject : n.selectedWidgetId ? { kind: "widget", id: n.selectedWidgetId } : null : n.selectedObject?.kind === "background_layer" || n.selectedObject?.kind === "annotation" ? n.selectedObject : null
758
- })), de(t);
755
+ })), ae(t);
759
756
  }, _e = (e) => {
760
757
  o.setState((t) => ({
761
758
  ...t,
762
759
  activeTool: e,
763
760
  mode: e === "text" || e === "background-region" ? "background" : e === "sticky-note" ? "work" : t.mode ?? "work"
764
761
  }));
765
- }, ye = (e, t) => {
762
+ }, me = (e, t) => {
766
763
  const n = ot();
767
- return n === "sticky-note" ? K(e, t) : n === "text" ? V(e, t) : n === "background-region" ? U(e, t) : null;
768
- }, me = () => {
769
- const e = w(), t = m();
764
+ return n === "sticky-note" ? K(e, t) : n === "text" ? V(e, t) : n === "background-region" ? v(e, t) : null;
765
+ }, he = () => {
766
+ const e = h(), t = m();
770
767
  return {
771
768
  worldX: e.width > 0 ? (e.width / 2 - t.x) / t.scale : 240,
772
769
  worldY: e.height > 0 ? (e.height / 2 - t.y) / t.scale : 180
773
770
  };
774
- }, Z = (e) => {
775
- const t = w();
771
+ }, $ = (e) => {
772
+ const t = h();
776
773
  t.width === 0 || t.height === 0 || D(
777
- Ot({
774
+ Tt({
778
775
  widget: e,
779
776
  scale: m().scale,
780
777
  frameWidth: t.width,
@@ -782,48 +779,48 @@ function Wn(o) {
782
779
  })
783
780
  );
784
781
  }, we = (e) => {
785
- const t = w();
782
+ const t = h();
786
783
  t.width === 0 || t.height === 0 || D(
787
- Ve({
784
+ Ue({
788
785
  widget: e,
789
786
  frameWidth: t.width,
790
787
  frameHeight: t.height
791
788
  })
792
789
  );
793
- }, he = (e) => {
794
- const t = w();
790
+ }, be = (e) => {
791
+ const t = h();
795
792
  t.width === 0 || t.height === 0 || D(
796
- Ot({
793
+ Tt({
797
794
  widget: e,
798
- scale: Ke,
795
+ scale: ve,
799
796
  frameWidth: t.width,
800
797
  frameHeight: t.height
801
798
  })
802
799
  );
803
- }, O = (e, t = {}) => (p(e.id), b(e.id), t.centerViewport !== !1 && Z(e), e);
800
+ }, O = (e, t = {}) => (p(e.id), x(e.id), t.centerViewport !== !1 && $(e), e);
804
801
  return {
805
- widgets: x,
806
- stickyNotes: z,
802
+ widgets: b,
803
+ stickyNotes: W,
807
804
  annotations: nt,
808
805
  backgroundLayers: it,
809
806
  viewport: m,
810
- canvasFrameSize: y,
811
- locked: Lt,
807
+ canvasFrameSize: _,
808
+ locked: Dt,
812
809
  filters: F,
813
- selectedWidgetId: Dt,
810
+ selectedWidgetId: pt,
814
811
  selectedObject: R,
815
- mode: T,
812
+ mode: C,
816
813
  activeTool: ot,
817
- theme: Mt,
818
- topZIndex: W,
819
- scaleLabel: jt,
814
+ theme: jt,
815
+ topZIndex: B,
816
+ scaleLabel: Ft,
820
817
  optimisticFrontWidgetId: s,
821
818
  widgetDefinitions: N,
822
- setCanvasFrameRef: Bt,
819
+ setCanvasFrameRef: zt,
823
820
  contextMenu: {
824
821
  state: d,
825
822
  items: st,
826
- position: Pt,
823
+ position: qt,
827
824
  close: l,
828
825
  retarget: (e) => {
829
826
  e.preventDefault(), e.stopPropagation(), a({
@@ -835,106 +832,106 @@ function Wn(o) {
835
832
  }
836
833
  },
837
834
  canvas: {
838
- openCanvasContextMenu: Xt,
839
- openWidgetContextMenu: Et,
840
- openStickyNoteContextMenu: Yt,
841
- openAnnotationContextMenu: Ht,
842
- openBackgroundLayerContextMenu: Kt,
835
+ openCanvasContextMenu: Et,
836
+ openWidgetContextMenu: Yt,
837
+ openStickyNoteContextMenu: Ht,
838
+ openAnnotationContextMenu: Kt,
839
+ openBackgroundLayerContextMenu: Vt,
843
840
  selectWidget: p,
844
- selectObject: ue,
845
- selectStickyNote: yt,
846
- selectAnnotation: ge,
847
- selectBackgroundLayer: ke,
848
- clearSelection: _t,
841
+ selectObject: ge,
842
+ selectStickyNote: _t,
843
+ selectAnnotation: ke,
844
+ selectBackgroundLayer: fe,
845
+ clearSelection: yt,
849
846
  startOptimisticFront: Gt,
850
- commitFront: b,
847
+ commitFront: x,
851
848
  commitMove: $t,
852
- commitResize: Zt,
853
- commitStickyFront: L,
854
- commitStickyMove: Jt,
855
- commitStickyResize: Qt,
856
- commitAnnotationMove: te,
857
- commitAnnotationResize: ee,
858
- commitBackgroundMove: ie,
859
- commitBackgroundResize: oe,
860
- commitViewport: $,
861
- cancelViewportNavigation: ce
849
+ commitResize: Jt,
850
+ commitStickyFront: I,
851
+ commitStickyMove: Qt,
852
+ commitStickyResize: te,
853
+ commitAnnotationMove: ee,
854
+ commitAnnotationResize: ne,
855
+ commitBackgroundMove: oe,
856
+ commitBackgroundResize: ce,
857
+ commitViewport: G,
858
+ cancelViewportNavigation: de
862
859
  },
863
860
  hud: {
864
861
  zoomIn: () => ft("in"),
865
862
  zoomOut: () => ft("out")
866
863
  },
867
864
  lock: {
868
- toggle: ae
865
+ toggle: se
869
866
  },
870
867
  filter: {
871
- toggle: se,
872
- solo: re,
873
- showAll: le
868
+ toggle: re,
869
+ solo: le,
870
+ showAll: ue
874
871
  },
875
872
  navigation: {
876
873
  handleArrowNavigation: (e) => {
877
874
  const t = R(), n = [
878
- ...x(),
879
- ...z().map((c) => en(c))
880
- ].sort(Qe), i = ze(
875
+ ...b(),
876
+ ...W().map((c) => nn(c))
877
+ ].sort(Re), i = Be(
881
878
  n,
882
879
  t?.kind === "widget" || t?.kind === "sticky_note" ? t.id : null,
883
880
  e,
884
881
  Object.fromEntries(
885
882
  n.map((c) => [
886
- Nt(c) ? c.type : "sticky_note",
887
- Nt(c) ? F()[c.type] !== !1 : F()[Te] !== !1
883
+ At(c) ? c.type : "sticky_note",
884
+ At(c) ? F()[c.type] !== !1 : F()[Ne] !== !1
888
885
  ])
889
886
  )
890
887
  );
891
- i && (x().some((c) => c.id === i.id) ? O(i) : yt(i.id));
888
+ i && (b().some((c) => c.id === i.id) ? O(i) : _t(i.id));
892
889
  },
893
- centerOnWidget: Z,
890
+ centerOnWidget: $,
894
891
  focusWidget: O,
895
- fitWidget: (e) => (p(e.id), b(e.id), we(e), e),
896
- overviewWidget: (e) => (p(e.id), b(e.id), he(e), e)
892
+ fitWidget: (e) => (p(e.id), x(e.id), we(e), e),
893
+ overviewWidget: (e) => (p(e.id), x(e.id), be(e), e)
897
894
  },
898
895
  selection: {
899
- clear: _t
896
+ clear: yt
900
897
  },
901
898
  widgetActions: {
902
899
  deleteSelected: () => {
903
900
  const e = R();
904
- e && (e.kind === "widget" && H(e.id), e.kind === "sticky_note" && v(e.id), e.kind === "annotation" && P(e.id), e.kind === "background_layer" && q(e.id));
901
+ e && (e.kind === "widget" && H(e.id), e.kind === "sticky_note" && U(e.id), e.kind === "annotation" && P(e.id), e.kind === "background_layer" && q(e.id));
905
902
  },
906
903
  deleteWidget: H,
907
- deleteStickyNote: v,
904
+ deleteStickyNote: U,
908
905
  deleteAnnotation: P,
909
906
  deleteBackgroundLayer: q,
910
- addWidget: qt,
907
+ addWidget: Zt,
911
908
  addWidgetAtWorldTopLeft: rt,
912
909
  addWidgetAtWorldCenter: Y,
913
910
  addStickyNoteAtCursor: K,
914
911
  addTextAnnotationAtCursor: V,
915
912
  duplicateTextAnnotationFrom: lt,
916
- addBackgroundLayerAtCursor: U,
913
+ addBackgroundLayerAtCursor: v,
917
914
  duplicateBackgroundLayerFrom: ut,
918
- createActiveToolAt: ye,
915
+ createActiveToolAt: me,
919
916
  ensureWidget: (e, t) => {
920
917
  const n = A(e);
921
918
  if (n)
922
919
  return O(n, { centerViewport: t?.centerViewport ?? !0 });
923
- const i = me(), c = Y(
920
+ const i = he(), c = Y(
924
921
  e,
925
922
  t?.worldX ?? i.worldX,
926
923
  t?.worldY ?? i.worldY
927
924
  );
928
- return (t?.centerViewport ?? !0) && c && Z(c), c;
925
+ return (t?.centerViewport ?? !0) && c && $(c), c;
929
926
  },
930
927
  updateStickyNote: gt,
931
- updateTextAnnotation: ne,
928
+ updateTextAnnotation: ie,
932
929
  updateBackgroundLayer: kt
933
930
  },
934
931
  queries: {
935
932
  findWidgetByType: A,
936
- findWidgetById: Vt,
937
- findStickyNoteById: X,
933
+ findWidgetById: vt,
934
+ findStickyNoteById: z,
938
935
  findAnnotationById: dt,
939
936
  findBackgroundLayerById: at
940
937
  },
@@ -944,7 +941,7 @@ function Wn(o) {
944
941
  }
945
942
  },
946
943
  modes: {
947
- setMode: fe,
944
+ setMode: ye,
948
945
  setActiveTool: _e
949
946
  },
950
947
  handleCloseRequest: () => {
@@ -957,5 +954,5 @@ function Wn(o) {
957
954
  };
958
955
  }
959
956
  export {
960
- Wn as useWorkbenchModel
957
+ On as useWorkbenchModel
961
958
  };