@floegence/floe-webapp-core 0.36.43 → 0.36.45

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,184 +1,191 @@
1
- import { DEFAULT_WORKBENCH_VIEWPORT as k, WORKBENCH_BACKGROUND_REGION_FILTER_ID as I, WORKBENCH_LAYER_COMPONENT_FILTER_IDS as L } from "./types.js";
2
- import { WORKBENCH_DEFAULT_BACKGROUND_MATERIAL as O, WORKBENCH_DEFAULT_REGION_FILL as E, WORKBENCH_DEFAULT_TEXT_COLOR as R, WORKBENCH_DEFAULT_TEXT_FONT as N, WORKBENCH_DEFAULT_STICKY_NOTE_COLOR as S, resolveWorkbenchTextFontOption as B, WORKBENCH_BACKGROUND_MATERIALS as D, WORKBENCH_STICKY_NOTE_COLORS as K, WORKBENCH_TEXT_COLOR_OPTIONS as P, WORKBENCH_REGION_FILL_OPTIONS as U } from "./workbenchOptions.js";
3
- import { resolveWorkbenchWidgetDefinitions as T, getWidgetEntry as z, createWorkbenchFilterState as p, isValidWorkbenchWidgetType as X } from "./widgets/widgetRegistry.js";
4
- import { DEFAULT_WORKBENCH_THEME as C, isWorkbenchThemeId as j } from "./workbenchThemes.js";
5
- function G() {
6
- const t = globalThis.crypto;
7
- return t && typeof t.randomUUID == "function" ? `wb-${t.randomUUID()}` : `wb-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 8)}`;
8
- }
9
- function xt(t) {
10
- return t.renderMode ?? "canvas_scaled";
11
- }
12
- function gt(t) {
13
- return t.projectedSurfaceScaleBehavior ?? "stable_transform";
14
- }
15
- function Y(t) {
16
- const i = Number.isFinite(t.viewport.scale) && t.viewport.scale > 0 ? t.viewport.scale : 1, e = typeof window < "u" && Number.isFinite(window.devicePixelRatio) && window.devicePixelRatio > 0 ? window.devicePixelRatio : 1, o = Math.round((t.viewport.x + t.worldX * i) * e) / e, n = Math.round((t.viewport.y + t.worldY * i) * e) / e;
1
+ import { DEFAULT_WORKBENCH_VIEWPORT as O, WORKBENCH_BACKGROUND_REGION_FILTER_ID as D, WORKBENCH_LAYER_COMPONENT_FILTER_IDS as K } from "./types.js";
2
+ import { WORKBENCH_DEFAULT_BACKGROUND_MATERIAL as E, WORKBENCH_DEFAULT_REGION_FILL as S, WORKBENCH_DEFAULT_TEXT_COLOR as R, WORKBENCH_DEFAULT_TEXT_FONT as N, WORKBENCH_DEFAULT_STICKY_NOTE_COLOR as T, resolveWorkbenchTextFontOption as P, WORKBENCH_BACKGROUND_MATERIALS as U, WORKBENCH_STICKY_NOTE_COLORS as X, WORKBENCH_TEXT_COLOR_OPTIONS as j, WORKBENCH_REGION_FILL_OPTIONS as V } from "./workbenchOptions.js";
3
+ import { resolveWorkbenchWidgetDefinitions as z, getWidgetEntry as C, createWorkbenchFilterState as A, isValidWorkbenchWidgetType as Y } from "./widgets/widgetRegistry.js";
4
+ import { DEFAULT_WORKBENCH_THEME as H, isWorkbenchThemeId as G } from "./workbenchThemes.js";
5
+ function $() {
6
+ const e = globalThis.crypto;
7
+ return e && typeof e.randomUUID == "function" ? `wb-${e.randomUUID()}` : `wb-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 8)}`;
8
+ }
9
+ function We(e) {
10
+ return e.renderMode ?? "canvas_scaled";
11
+ }
12
+ function ke(e) {
13
+ return e.projectedSurfaceScaleBehavior ?? "stable_transform";
14
+ }
15
+ function q(e) {
16
+ const t = Number.isFinite(e.viewport.scale) && e.viewport.scale > 0 ? e.viewport.scale : 1, n = typeof window < "u" && Number.isFinite(window.devicePixelRatio) && window.devicePixelRatio > 0 ? window.devicePixelRatio : 1, o = Math.round((e.viewport.x + e.worldX * t) * n) / n, i = Math.round((e.viewport.y + e.worldY * t) * n) / n;
17
17
  return {
18
- widgetId: t.widgetId,
19
- worldX: t.worldX,
20
- worldY: t.worldY,
21
- worldWidth: t.worldWidth,
22
- worldHeight: t.worldHeight,
18
+ widgetId: e.widgetId,
19
+ worldX: e.worldX,
20
+ worldY: e.worldY,
21
+ worldWidth: e.worldWidth,
22
+ worldHeight: e.worldHeight,
23
23
  screenX: o,
24
- screenY: n,
25
- screenWidth: t.worldWidth * i,
26
- screenHeight: t.worldHeight * i,
27
- viewportScale: i
24
+ screenY: i,
25
+ screenWidth: e.worldWidth * t,
26
+ screenHeight: e.worldHeight * t,
27
+ viewportScale: t
28
28
  };
29
29
  }
30
- function yt(t) {
30
+ function Me(e) {
31
31
  return {
32
- ready: t.ready,
33
- rect: Y(t)
32
+ ready: e.ready,
33
+ rect: q(e)
34
34
  };
35
35
  }
36
- function V(t) {
37
- return t ? {
38
- x: Number.isFinite(t.x) ? t.x : 0,
39
- y: Number.isFinite(t.y) ? t.y : 0,
40
- scale: Number.isFinite(t.scale) && t.scale > 0 ? t.scale : 1
41
- } : { ...k };
36
+ function Z(e) {
37
+ return e ? {
38
+ x: Number.isFinite(e.x) ? e.x : 0,
39
+ y: Number.isFinite(e.y) ? e.y : 0,
40
+ scale: Number.isFinite(e.scale) && e.scale > 0 ? e.scale : 1
41
+ } : { ...O };
42
42
  }
43
- function $(t, i) {
44
- const e = p(i, t);
45
- for (const o of L)
46
- e[o] = typeof t?.[o] == "boolean" ? !!t[o] : !0;
47
- return e;
43
+ function J(e, t) {
44
+ const n = Z(e);
45
+ return {
46
+ ...n,
47
+ scale: b(n.scale, fe(t).minScale, g)
48
+ };
49
+ }
50
+ function Q(e, t) {
51
+ const n = A(t, e);
52
+ for (const o of K)
53
+ n[o] = typeof e?.[o] == "boolean" ? !!e[o] : !0;
54
+ return n;
48
55
  }
49
- function g(t) {
50
- return !!t && typeof t == "object" && !Array.isArray(t);
56
+ function y(e) {
57
+ return !!e && typeof e == "object" && !Array.isArray(e);
51
58
  }
52
- function f(t) {
53
- return String(t ?? "").trim();
59
+ function f(e) {
60
+ return String(e ?? "").trim();
54
61
  }
55
- function c(t, i) {
56
- const e = Number(t);
57
- return Number.isFinite(e) ? e : i;
62
+ function d(e, t) {
63
+ const n = Number(e);
64
+ return Number.isFinite(n) ? n : t;
58
65
  }
59
- function l(t, i) {
60
- const e = c(t, i);
61
- return e > 0 ? e : i;
66
+ function m(e, t) {
67
+ const n = d(e, t);
68
+ return n > 0 ? n : t;
62
69
  }
63
- function w(t, i) {
64
- const e = f(t);
65
- return e.length > 0 && e.length <= 128 ? e : `${i}-${G()}`;
70
+ function W(e, t) {
71
+ const n = f(e);
72
+ return n.length > 0 && n.length <= 128 ? n : `${t}-${$()}`;
66
73
  }
67
- function q(t) {
68
- return t === "annotation" || t === "background" ? t : "work";
74
+ function v(e) {
75
+ return p(e);
69
76
  }
70
- function Z(t, i) {
71
- const e = f(t);
72
- return e || (i === "annotation" || i === "background" ? I : "select");
77
+ function ee(e, t) {
78
+ const n = f(e);
79
+ return n || (t === "annotation" || t === "background" ? D : "select");
73
80
  }
74
- function y(t, i, e) {
75
- const o = f(t);
76
- return i.includes(o) ? o : e;
81
+ function w(e, t, n) {
82
+ const o = f(e);
83
+ return t.includes(o) ? o : n;
77
84
  }
78
- function J(t) {
79
- return y(t, K, S);
85
+ function te(e) {
86
+ return w(e, X, T);
80
87
  }
81
- function Q(t) {
82
- if (!g(t)) return null;
83
- const i = Date.now();
88
+ function ne(e) {
89
+ if (!y(e)) return null;
90
+ const t = Date.now();
84
91
  return {
85
- id: w(t.id, "sticky"),
92
+ id: W(e.id, "sticky"),
86
93
  kind: "sticky_note",
87
- body: f(t.body) || "Untitled note",
88
- color: J(t.color),
89
- x: c(t.x, 0),
90
- y: c(t.y, 0),
91
- width: l(t.width, 260),
92
- height: l(t.height, 190),
93
- z_index: Math.max(0, Math.trunc(c(t.z_index, 1))),
94
- created_at_unix_ms: Math.max(0, Math.trunc(c(t.created_at_unix_ms, i))),
95
- updated_at_unix_ms: Math.max(0, Math.trunc(c(t.updated_at_unix_ms, i)))
94
+ body: f(e.body) || "Untitled note",
95
+ color: te(e.color),
96
+ x: d(e.x, 0),
97
+ y: d(e.y, 0),
98
+ width: m(e.width, 260),
99
+ height: m(e.height, 190),
100
+ z_index: Math.max(0, Math.trunc(d(e.z_index, 1))),
101
+ created_at_unix_ms: Math.max(0, Math.trunc(d(e.created_at_unix_ms, t))),
102
+ updated_at_unix_ms: Math.max(0, Math.trunc(d(e.updated_at_unix_ms, t)))
96
103
  };
97
104
  }
98
- function v(t) {
99
- if (!Array.isArray(t)) return [];
100
- const i = /* @__PURE__ */ new Set();
101
- return t.map((e) => Q(e)).filter((e) => !e || i.has(e.id) ? !1 : (i.add(e.id), !0));
105
+ function ie(e) {
106
+ if (!Array.isArray(e)) return [];
107
+ const t = /* @__PURE__ */ new Set();
108
+ return e.map((n) => ne(n)).filter((n) => !n || t.has(n.id) ? !1 : (t.add(n.id), !0));
102
109
  }
103
- const tt = ["left", "center", "right"];
104
- function et(t) {
105
- return tt.includes(t) ? t : "left";
110
+ const re = ["left", "center", "right"];
111
+ function oe(e) {
112
+ return re.includes(e) ? e : "left";
106
113
  }
107
- function it(t) {
108
- if (!g(t)) return null;
109
- const i = Date.now(), e = B(t.font_family);
114
+ function ae(e) {
115
+ if (!y(e)) return null;
116
+ const t = Date.now(), n = P(e.font_family);
110
117
  return {
111
- id: w(t.id, "text"),
118
+ id: W(e.id, "text"),
112
119
  kind: "text",
113
- text: f(t.text) || "Text",
114
- font_family: e.fontFamily,
115
- font_size: Math.max(8, Math.min(160, Math.round(c(t.font_size, 28)))),
116
- font_weight: e.fontWeight,
117
- color: y(t.color, P, R),
118
- align: et(t.align),
119
- x: c(t.x, 0),
120
- y: c(t.y, 0),
121
- width: l(t.width, 280),
122
- height: l(t.height, 84),
123
- z_index: Math.max(0, Math.trunc(c(t.z_index, 1))),
124
- created_at_unix_ms: Math.max(0, Math.trunc(c(t.created_at_unix_ms, i))),
125
- updated_at_unix_ms: Math.max(0, Math.trunc(c(t.updated_at_unix_ms, i)))
120
+ text: f(e.text) || "Text",
121
+ font_family: n.fontFamily,
122
+ font_size: Math.max(8, Math.min(160, Math.round(d(e.font_size, 28)))),
123
+ font_weight: n.fontWeight,
124
+ color: w(e.color, j, R),
125
+ align: oe(e.align),
126
+ x: d(e.x, 0),
127
+ y: d(e.y, 0),
128
+ width: m(e.width, 280),
129
+ height: m(e.height, 84),
130
+ z_index: Math.max(0, Math.trunc(d(e.z_index, 1))),
131
+ created_at_unix_ms: Math.max(0, Math.trunc(d(e.created_at_unix_ms, t))),
132
+ updated_at_unix_ms: Math.max(0, Math.trunc(d(e.updated_at_unix_ms, t)))
126
133
  };
127
134
  }
128
- function nt(t) {
129
- if (!Array.isArray(t)) return [];
130
- const i = /* @__PURE__ */ new Set();
131
- return t.map((e) => it(e)).filter((e) => !e || i.has(e.id) ? !1 : (i.add(e.id), !0));
135
+ function ce(e) {
136
+ if (!Array.isArray(e)) return [];
137
+ const t = /* @__PURE__ */ new Set();
138
+ return e.map((n) => ae(n)).filter((n) => !n || t.has(n.id) ? !1 : (t.add(n.id), !0));
132
139
  }
133
- function rt(t) {
134
- return y(
135
- t,
136
- D,
137
- O
140
+ function de(e) {
141
+ return w(
142
+ e,
143
+ U,
144
+ E
138
145
  );
139
146
  }
140
- function ot(t) {
141
- if (!g(t)) return null;
142
- const i = Date.now();
147
+ function se(e) {
148
+ if (!y(e)) return null;
149
+ const t = Date.now();
143
150
  return {
144
- id: w(t.id, "region"),
145
- name: f(t.name) || "Canvas region",
146
- fill: y(t.fill, U, E),
147
- opacity: Math.max(0.08, Math.min(1, c(t.opacity, 0.72))),
148
- material: rt(t.material),
149
- x: c(t.x, 0),
150
- y: c(t.y, 0),
151
- width: l(t.width, 560),
152
- height: l(t.height, 360),
153
- z_index: Math.max(0, Math.trunc(c(t.z_index, 1))),
154
- created_at_unix_ms: Math.max(0, Math.trunc(c(t.created_at_unix_ms, i))),
155
- updated_at_unix_ms: Math.max(0, Math.trunc(c(t.updated_at_unix_ms, i)))
151
+ id: W(e.id, "region"),
152
+ name: f(e.name) || "Canvas region",
153
+ fill: w(e.fill, V, S),
154
+ opacity: Math.max(0.08, Math.min(1, d(e.opacity, 0.72))),
155
+ material: de(e.material),
156
+ x: d(e.x, 0),
157
+ y: d(e.y, 0),
158
+ width: m(e.width, 560),
159
+ height: m(e.height, 360),
160
+ z_index: Math.max(0, Math.trunc(d(e.z_index, 1))),
161
+ created_at_unix_ms: Math.max(0, Math.trunc(d(e.created_at_unix_ms, t))),
162
+ updated_at_unix_ms: Math.max(0, Math.trunc(d(e.updated_at_unix_ms, t)))
156
163
  };
157
164
  }
158
- function at(t) {
159
- if (!Array.isArray(t)) return [];
160
- const i = /* @__PURE__ */ new Set();
161
- return t.map((e) => ot(e)).filter((e) => !e || i.has(e.id) ? !1 : (i.add(e.id), !0));
162
- }
163
- function dt(t, i, e, o, n, a) {
164
- if (g(t)) {
165
- const d = f(t.kind), s = f(t.id);
166
- if (d === "widget" && i.some((h) => h.id === s)) return { kind: d, id: s };
167
- if (d === "sticky_note" && e.some((h) => h.id === s)) return { kind: d, id: s };
168
- if (d === "annotation" && o.some((h) => h.id === s)) return { kind: d, id: s };
169
- if (d === "background_layer" && n.some((h) => h.id === s))
170
- return { kind: d, id: s };
165
+ function he(e) {
166
+ if (!Array.isArray(e)) return [];
167
+ const t = /* @__PURE__ */ new Set();
168
+ return e.map((n) => se(n)).filter((n) => !n || t.has(n.id) ? !1 : (t.add(n.id), !0));
169
+ }
170
+ function le(e, t, n, o, i, a) {
171
+ if (y(e)) {
172
+ const c = f(e.kind), s = f(e.id);
173
+ if (c === "widget" && t.some((l) => l.id === s)) return { kind: c, id: s };
174
+ if (c === "sticky_note" && n.some((l) => l.id === s)) return { kind: c, id: s };
175
+ if (c === "annotation" && o.some((l) => l.id === s)) return { kind: c, id: s };
176
+ if (c === "background_layer" && i.some((l) => l.id === s))
177
+ return { kind: c, id: s };
171
178
  }
172
179
  return a ? { kind: "widget", id: a } : null;
173
180
  }
174
- function wt(t, i = {}) {
175
- const e = T(i.widgetDefinitions), o = i.createFallbackState ?? (() => ct(e)), n = t;
176
- if (!n || n.version !== 1 || !Array.isArray(n.widgets))
181
+ function Ne(e, t = {}) {
182
+ const n = z(t.widgetDefinitions), o = t.createFallbackState ?? (() => _e(n)), i = e;
183
+ if (!i || i.version !== 1 || !Array.isArray(i.widgets))
177
184
  return o();
178
- const a = n.widgets.filter(
179
- (r) => !!r && typeof r.id == "string" && X(r.type, e) && typeof r.title == "string"
185
+ const a = i.widgets.filter(
186
+ (r) => !!r && typeof r.id == "string" && Y(r.type, n) && typeof r.title == "string"
180
187
  ).map((r) => {
181
- const u = z(r.type, e);
188
+ const u = C(r.type, n);
182
189
  return {
183
190
  id: r.id,
184
191
  type: r.type,
@@ -190,75 +197,75 @@ function wt(t, i = {}) {
190
197
  z_index: Number.isFinite(r.z_index) && r.z_index >= 0 ? r.z_index : 1,
191
198
  created_at_unix_ms: Number.isFinite(r.created_at_unix_ms) ? r.created_at_unix_ms : Date.now()
192
199
  };
193
- }), d = typeof n.selectedWidgetId == "string" && a.some((r) => r.id === n.selectedWidgetId) ? n.selectedWidgetId : null, s = v(n.stickyNotes), h = nt(n.annotations), m = at(n.backgroundLayers), _ = q(n.mode);
200
+ }), c = typeof i.selectedWidgetId == "string" && a.some((r) => r.id === i.selectedWidgetId) ? i.selectedWidgetId : null, s = ie(i.stickyNotes), l = ce(i.annotations), x = he(i.backgroundLayers), h = v(i.mode), _ = J(i.viewport, h);
194
201
  return {
195
202
  version: 1,
196
203
  widgets: a,
197
- viewport: V(n.viewport),
198
- locked: typeof n.locked == "boolean" ? n.locked : !1,
199
- filters: $(n.filters, e),
200
- selectedWidgetId: d,
201
- theme: j(n.theme) ? n.theme : C,
202
- mode: _,
203
- activeTool: Z(n.activeTool, _),
204
- selectedObject: dt(
205
- n.selectedObject,
204
+ viewport: _,
205
+ locked: typeof i.locked == "boolean" ? i.locked : !1,
206
+ filters: Q(i.filters, n),
207
+ selectedWidgetId: c,
208
+ theme: G(i.theme) ? i.theme : H,
209
+ mode: h,
210
+ activeTool: ee(i.activeTool, h),
211
+ selectedObject: le(
212
+ i.selectedObject,
206
213
  a,
207
214
  s,
208
- h,
209
- m,
210
- d
215
+ l,
216
+ x,
217
+ c
211
218
  ),
212
219
  stickyNotes: s,
213
- annotations: h,
214
- backgroundLayers: m
220
+ annotations: l,
221
+ backgroundLayers: x
215
222
  };
216
223
  }
217
- function ct(t) {
218
- const i = T(t), e = Date.now(), o = [
224
+ function _e(e) {
225
+ const t = z(e), n = Date.now(), o = [
219
226
  { type: "terminal", title: "dev · terminal", x: 80, y: 80 },
220
227
  { type: "file-browser", title: "project · files", x: 600, y: 80 },
221
228
  { type: "system-monitor", title: "host · system monitor", x: 80, y: 420 },
222
229
  { type: "log-viewer", title: "services · logs", x: 540, y: 500 },
223
230
  { type: "code-editor", title: "Counter.tsx", x: 1e3, y: 180 }
224
- ], n = o.filter((a) => i.some((d) => d.type === a.type)).map((a, d) => {
225
- const s = z(a.type, i);
231
+ ], i = o.filter((a) => t.some((c) => c.type === a.type)).map((a, c) => {
232
+ const s = C(a.type, t);
226
233
  return {
227
- id: `wb-seed-${d + 1}`,
234
+ id: `wb-seed-${c + 1}`,
228
235
  type: a.type,
229
236
  title: a.title,
230
237
  x: a.x,
231
238
  y: a.y,
232
239
  width: s.defaultSize.width,
233
240
  height: s.defaultSize.height,
234
- z_index: d + 1,
235
- created_at_unix_ms: e - (o.length - d) * 6e5
241
+ z_index: c + 1,
242
+ created_at_unix_ms: n - (o.length - c) * 6e5
236
243
  };
237
244
  });
238
245
  return {
239
246
  version: 1,
240
- widgets: n,
241
- viewport: { ...k },
247
+ widgets: i,
248
+ viewport: { ...O },
242
249
  locked: !1,
243
- filters: p(i),
244
- selectedWidgetId: n[0]?.id ?? null,
245
- theme: C,
250
+ filters: A(t),
251
+ selectedWidgetId: i[0]?.id ?? null,
252
+ theme: H,
246
253
  mode: "work",
247
254
  activeTool: "select",
248
- selectedObject: n[0] ? { kind: "widget", id: n[0].id } : null,
255
+ selectedObject: i[0] ? { kind: "widget", id: i[0].id } : null,
249
256
  stickyNotes: [
250
257
  {
251
258
  id: "wb-seed-sticky-1",
252
259
  kind: "sticky_note",
253
260
  body: "Confirm the rollout checklist before touching production.",
254
- color: S,
261
+ color: T,
255
262
  x: 930,
256
263
  y: 620,
257
264
  width: 270,
258
265
  height: 170,
259
- z_index: n.length + 1,
260
- created_at_unix_ms: e - 25e4,
261
- updated_at_unix_ms: e - 25e4
266
+ z_index: i.length + 1,
267
+ created_at_unix_ms: n - 25e4,
268
+ updated_at_unix_ms: n - 25e4
262
269
  }
263
270
  ],
264
271
  annotations: [
@@ -276,131 +283,170 @@ function ct(t) {
276
283
  width: 320,
277
284
  height: 82,
278
285
  z_index: 1,
279
- created_at_unix_ms: e - 24e4,
280
- updated_at_unix_ms: e - 24e4
286
+ created_at_unix_ms: n - 24e4,
287
+ updated_at_unix_ms: n - 24e4
281
288
  }
282
289
  ],
283
290
  backgroundLayers: [
284
291
  {
285
292
  id: "wb-seed-region-1",
286
293
  name: "Review lane",
287
- fill: E,
294
+ fill: S,
288
295
  opacity: 0.58,
289
- material: O,
296
+ material: E,
290
297
  x: 512,
291
298
  y: 360,
292
299
  width: 760,
293
300
  height: 520,
294
301
  z_index: 1,
295
- created_at_unix_ms: e - 26e4,
296
- updated_at_unix_ms: e - 26e4
302
+ created_at_unix_ms: n - 26e4,
303
+ updated_at_unix_ms: n - 26e4
297
304
  }
298
305
  ]
299
306
  };
300
307
  }
301
- const bt = 1.18, Wt = 200, b = 0.2, W = 2.2, st = 48;
302
- function ht(t) {
303
- const i = A(t.scale, b, W);
308
+ const Oe = 1.18, Ee = 200, I = 0.35, L = 0.2, k = I, g = 2.2, ue = 48;
309
+ function p(e) {
310
+ return e === "annotation" || e === "background" ? "background" : "work";
311
+ }
312
+ function fe(e) {
313
+ return p(e) === "background" ? {
314
+ mode: "background",
315
+ label: "Composition Mode",
316
+ minScale: L,
317
+ workLayerLocked: !0,
318
+ layerEditingEnabled: !0
319
+ } : {
320
+ mode: "work",
321
+ label: "Work Mode",
322
+ minScale: I,
323
+ workLayerLocked: !1,
324
+ layerEditingEnabled: !1
325
+ };
326
+ }
327
+ function Se(e) {
328
+ const t = b(
329
+ e.scale,
330
+ e.minScale ?? L,
331
+ g
332
+ );
333
+ if (e.frameWidth <= 0 || e.frameHeight <= 0 || e.viewport.scale <= 0)
334
+ return { ...e.viewport, scale: t };
335
+ const n = (e.frameWidth / 2 - e.viewport.x) / e.viewport.scale, o = (e.frameHeight / 2 - e.viewport.y) / e.viewport.scale;
336
+ return {
337
+ x: e.frameWidth / 2 - n * t,
338
+ y: e.frameHeight / 2 - o * t,
339
+ scale: t
340
+ };
341
+ }
342
+ function me(e) {
343
+ const t = b(e.scale, k, g);
304
344
  return {
305
- x: t.frameWidth / 2 - (t.widget.x + t.widget.width / 2) * i,
306
- y: t.frameHeight / 2 - (t.widget.y + t.widget.height / 2) * i,
307
- scale: i
345
+ x: e.frameWidth / 2 - (e.widget.x + e.widget.width / 2) * t,
346
+ y: e.frameHeight / 2 - (e.widget.y + e.widget.height / 2) * t,
347
+ scale: t
308
348
  };
309
349
  }
310
- function Mt(t) {
311
- const i = t.minScale ?? b, e = t.maxScale ?? W, o = t.paddingPx ?? st, n = Math.max(t.frameWidth - o * 2, 1), a = Math.max(t.frameHeight - o * 2, 1), d = A(
350
+ function Re(e) {
351
+ const t = e.minScale ?? k, n = e.maxScale ?? g, o = e.paddingPx ?? ue, i = Math.max(e.frameWidth - o * 2, 1), a = Math.max(e.frameHeight - o * 2, 1), c = b(
312
352
  Math.min(
313
- n / Math.max(t.widget.width, 1),
314
- a / Math.max(t.widget.height, 1)
353
+ i / Math.max(e.widget.width, 1),
354
+ a / Math.max(e.widget.height, 1)
315
355
  ),
316
- i,
317
- e
356
+ t,
357
+ n
318
358
  );
319
- return ht({
320
- widget: t.widget,
321
- scale: d,
322
- frameWidth: t.frameWidth,
323
- frameHeight: t.frameHeight
359
+ return me({
360
+ widget: e.widget,
361
+ scale: c,
362
+ frameWidth: e.frameWidth,
363
+ frameHeight: e.frameHeight
324
364
  });
325
365
  }
326
- function _t(t, i) {
327
- return t.z_index !== i.z_index ? t.z_index - i.z_index : t.created_at_unix_ms !== i.created_at_unix_ms ? t.created_at_unix_ms - i.created_at_unix_ms : t.id.localeCompare(i.id);
366
+ function xe(e, t) {
367
+ return e.z_index !== t.z_index ? e.z_index - t.z_index : e.created_at_unix_ms !== t.created_at_unix_ms ? e.created_at_unix_ms - t.created_at_unix_ms : e.id.localeCompare(t.id);
328
368
  }
329
- function Nt(t) {
330
- const i = [...t].sort(_t), e = /* @__PURE__ */ new Map();
331
- for (const [o, n] of i.entries())
332
- e.set(n.id, o + 1);
369
+ function Te(e) {
370
+ const t = [...e].sort(xe), n = /* @__PURE__ */ new Map();
371
+ for (const [o, i] of t.entries())
372
+ n.set(i.id, o + 1);
333
373
  return {
334
- byWidgetId: e,
335
- topRenderLayer: Math.max(i.length, 1)
374
+ byWidgetId: n,
375
+ topRenderLayer: Math.max(t.length, 1)
336
376
  };
337
377
  }
338
- function kt(t) {
339
- const i = typeof window < "u" ? window.innerWidth : 1280, e = typeof window < "u" ? window.innerHeight : 800;
340
- let o = t.clientX, n = t.clientY;
341
- return o + t.menuWidth > i && (o = Math.max(0, i - t.menuWidth - 8)), n + t.menuHeight > e && (n = Math.max(0, e - t.menuHeight - 8)), { left: o, top: n };
342
- }
343
- function Ot(t, i, e, o) {
344
- const n = t.filter((_) => o[_.type]);
345
- if (n.length === 0) return null;
346
- if (!i) return n[0] ?? null;
347
- const a = n.find((_) => _.id === i);
348
- if (!a) return n[0] ?? null;
349
- const d = a.x + a.width / 2, s = a.y + a.height / 2;
350
- let h = null, m = 1 / 0;
351
- for (const _ of n) {
352
- if (_.id === i) continue;
353
- const r = _.x + _.width / 2 - d, u = _.y + _.height / 2 - s;
354
- let x = !1;
355
- switch (e) {
378
+ function ze(e) {
379
+ const t = typeof window < "u" ? window.innerWidth : 1280, n = typeof window < "u" ? window.innerHeight : 800;
380
+ let o = e.clientX, i = e.clientY;
381
+ return o + e.menuWidth > t && (o = Math.max(0, t - e.menuWidth - 8)), i + e.menuHeight > n && (i = Math.max(0, n - e.menuHeight - 8)), { left: o, top: i };
382
+ }
383
+ function Ce(e, t, n, o) {
384
+ const i = e.filter((h) => o[h.type]);
385
+ if (i.length === 0) return null;
386
+ if (!t) return i[0] ?? null;
387
+ const a = i.find((h) => h.id === t);
388
+ if (!a) return i[0] ?? null;
389
+ const c = a.x + a.width / 2, s = a.y + a.height / 2;
390
+ let l = null, x = 1 / 0;
391
+ for (const h of i) {
392
+ if (h.id === t) continue;
393
+ const _ = h.x + h.width / 2 - c, r = h.y + h.height / 2 - s;
394
+ let u = !1;
395
+ switch (n) {
356
396
  case "up":
357
- x = u < -10;
397
+ u = r < -10;
358
398
  break;
359
399
  case "down":
360
- x = u > 10;
400
+ u = r > 10;
361
401
  break;
362
402
  case "left":
363
- x = r < -10;
403
+ u = _ < -10;
364
404
  break;
365
405
  case "right":
366
- x = r > 10;
406
+ u = _ > 10;
367
407
  break;
368
408
  }
369
- if (!x) continue;
370
- const F = Math.sqrt(r * r + u * u), H = Math.atan2(
371
- Math.abs(e === "up" || e === "down" ? r : u),
372
- Math.abs(e === "up" || e === "down" ? u : r)
373
- ), M = F * (1 + H * 1.5);
374
- M < m && (m = M, h = _);
409
+ if (!u) continue;
410
+ const F = Math.sqrt(_ * _ + r * r), B = Math.atan2(
411
+ Math.abs(n === "up" || n === "down" ? _ : r),
412
+ Math.abs(n === "up" || n === "down" ? r : _)
413
+ ), M = F * (1 + B * 1.5);
414
+ M < x && (x = M, l = h);
375
415
  }
376
- return h;
416
+ return l;
377
417
  }
378
- function A(t, i = b, e = W) {
379
- return Math.max(i, Math.min(e, t));
418
+ function b(e, t = k, n = g) {
419
+ return Math.max(t, Math.min(n, e));
380
420
  }
381
- function Et(t, i = 0) {
382
- return 16 + Math.max(1, t) * 32 + Math.max(0, i) * 9;
421
+ function Ae(e, t = 0) {
422
+ return 16 + Math.max(1, e) * 32 + Math.max(0, t) * 9;
383
423
  }
384
424
  export {
385
- bt as WORKBENCH_CANVAS_ZOOM_STEP,
386
- Wt as WORKBENCH_CONTEXT_MENU_WIDTH_PX,
387
- W as WORKBENCH_MAX_SCALE,
388
- b as WORKBENCH_MIN_SCALE,
389
- st as WORKBENCH_VIEWPORT_FIT_PADDING_PX,
390
- A as clampScale,
391
- kt as createContextMenuPosition,
392
- ct as createDefaultWorkbenchState,
393
- G as createWorkbenchId,
394
- Y as createWorkbenchProjectedRect,
395
- Nt as createWorkbenchRenderLayerMap,
396
- ht as createWorkbenchViewportCenteredOnWidget,
397
- Mt as createWorkbenchViewportFitForWidget,
398
- yt as createWorkbenchWidgetSurfaceMetrics,
399
- Et as estimateContextMenuHeight,
400
- Ot as findNearestWidget,
401
- gt as resolveWorkbenchProjectedSurfaceScaleBehavior,
402
- xt as resolveWorkbenchWidgetRenderMode,
403
- $ as sanitizeFilters,
404
- V as sanitizeViewport,
405
- wt as sanitizeWorkbenchState
425
+ Oe as WORKBENCH_CANVAS_ZOOM_STEP,
426
+ L as WORKBENCH_COMPOSITION_MIN_SCALE,
427
+ Ee as WORKBENCH_CONTEXT_MENU_WIDTH_PX,
428
+ g as WORKBENCH_MAX_SCALE,
429
+ k as WORKBENCH_MIN_SCALE,
430
+ ue as WORKBENCH_VIEWPORT_FIT_PADDING_PX,
431
+ I as WORKBENCH_WORK_MIN_SCALE,
432
+ b as clampScale,
433
+ ze as createContextMenuPosition,
434
+ _e as createDefaultWorkbenchState,
435
+ $ as createWorkbenchId,
436
+ q as createWorkbenchProjectedRect,
437
+ Te as createWorkbenchRenderLayerMap,
438
+ Se as createWorkbenchViewportAtScale,
439
+ me as createWorkbenchViewportCenteredOnWidget,
440
+ Re as createWorkbenchViewportFitForWidget,
441
+ Me as createWorkbenchWidgetSurfaceMetrics,
442
+ Ae as estimateContextMenuHeight,
443
+ Ce as findNearestWidget,
444
+ p as normalizeWorkbenchInteractionMode,
445
+ fe as resolveWorkbenchModeStrategy,
446
+ ke as resolveWorkbenchProjectedSurfaceScaleBehavior,
447
+ We as resolveWorkbenchWidgetRenderMode,
448
+ Q as sanitizeFilters,
449
+ Z as sanitizeViewport,
450
+ Ne as sanitizeWorkbenchState,
451
+ J as sanitizeWorkbenchViewportForMode
406
452
  };