@nice2dev/erp-adapter 1.0.8 → 1.0.11

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.
package/dist/index.mjs CHANGED
@@ -9,18 +9,22 @@ class Ce {
9
9
  ...this.cfg.headers
10
10
  };
11
11
  if (this.cfg.tokenFactory) {
12
- const o = await this.cfg.tokenFactory();
13
- a.Authorization = `Bearer ${o}`;
12
+ const r = await this.cfg.tokenFactory();
13
+ a.Authorization = `Bearer ${r}`;
14
14
  }
15
- const r = await n(`${this.cfg.baseUrl}${e}`, { ...t, headers: { ...a, ...t == null ? void 0 : t.headers } });
16
- if (!r.ok) throw new Error(`ERP request failed: ${r.status} ${r.statusText}`);
17
- return r.json();
15
+ const o = await n(`${this.cfg.baseUrl}${e}`, {
16
+ ...t,
17
+ headers: { ...a, ...t == null ? void 0 : t.headers }
18
+ });
19
+ if (!o.ok)
20
+ throw new Error(`ERP request failed: ${o.status} ${o.statusText}`);
21
+ return o.json();
18
22
  }
19
23
  /** Load paged/filtered/sorted data. */
20
24
  async load(e) {
21
- var a, r;
25
+ var a, o;
22
26
  const t = new URLSearchParams();
23
- (e == null ? void 0 : e.skip) != null && t.set("skip", String(e.skip)), (e == null ? void 0 : e.take) != null && t.set("take", String(e.take)), e != null && e.search && t.set("search", e.search), (a = e == null ? void 0 : e.sort) != null && a.length && t.set("sort", JSON.stringify(e.sort)), (r = e == null ? void 0 : e.filters) != null && r.length && t.set("filters", JSON.stringify(e.filters));
27
+ (e == null ? void 0 : e.skip) != null && t.set("skip", String(e.skip)), (e == null ? void 0 : e.take) != null && t.set("take", String(e.take)), e != null && e.search && t.set("search", e.search), (a = e == null ? void 0 : e.sort) != null && a.length && t.set("sort", JSON.stringify(e.sort)), (o = e == null ? void 0 : e.filters) != null && o.length && t.set("filters", JSON.stringify(e.filters));
24
28
  const n = t.toString();
25
29
  return this.request(n ? `?${n}` : "");
26
30
  }
@@ -42,69 +46,81 @@ class Ce {
42
46
  }
43
47
  /** Batch delete. */
44
48
  async removeBatch(e) {
45
- return this.request("/batch-delete", { method: "POST", body: JSON.stringify({ ids: e }) });
49
+ return this.request("/batch-delete", {
50
+ method: "POST",
51
+ body: JSON.stringify({ ids: e })
52
+ });
46
53
  }
47
54
  /** Batch create — send multiple items in a single request. */
48
55
  async createBatch(e) {
49
- return this.request("/batch", { method: "POST", body: JSON.stringify({ items: e }) });
56
+ return this.request("/batch", {
57
+ method: "POST",
58
+ body: JSON.stringify({ items: e })
59
+ });
50
60
  }
51
61
  /** Batch update — send multiple items with ids in a single request. */
52
62
  async updateBatch(e) {
53
- return this.request("/batch", { method: "PUT", body: JSON.stringify({ items: e }) });
63
+ return this.request("/batch", {
64
+ method: "PUT",
65
+ body: JSON.stringify({ items: e })
66
+ });
54
67
  }
55
68
  /** Partial update (PATCH) a single entity. */
56
69
  async patch(e, t) {
57
- return this.request(`/${e}`, { method: "PATCH", body: JSON.stringify(t) });
70
+ return this.request(`/${e}`, {
71
+ method: "PATCH",
72
+ body: JSON.stringify(t)
73
+ });
58
74
  }
59
75
  }
60
- async function Ve(u) {
76
+ async function Ve(c) {
61
77
  const e = await import("@microsoft/signalr");
62
78
  let t = "disconnected";
63
- const n = /* @__PURE__ */ new Set(), a = (c) => {
64
- t = c, n.forEach((g) => g(c));
65
- }, o = new e.HubConnectionBuilder().withUrl(u.hubUrl, {
66
- accessTokenFactory: u.accessTokenFactory ? () => u.accessTokenFactory() : void 0
79
+ const n = /* @__PURE__ */ new Set(), a = (u) => {
80
+ t = u, n.forEach((g) => g(u));
81
+ }, r = new e.HubConnectionBuilder().withUrl(c.hubUrl, {
82
+ accessTokenFactory: c.accessTokenFactory ? () => c.accessTokenFactory() : void 0
67
83
  }).withAutomaticReconnect().build();
68
- return o.onreconnecting(() => a("reconnecting")), o.onreconnected(() => a("connected")), o.onclose(() => a("disconnected")), {
84
+ return r.onreconnecting(() => a("reconnecting")), r.onreconnected(() => a("connected")), r.onclose(() => a("disconnected")), {
69
85
  get status() {
70
86
  return t;
71
87
  },
72
88
  async start() {
73
- a("connecting"), await o.start(), a("connected");
89
+ a("connecting"), await r.start(), a("connected");
74
90
  },
75
91
  async stop() {
76
- await o.stop(), a("disconnected");
92
+ await r.stop(), a("disconnected");
77
93
  },
78
- on(c, g) {
79
- o.on(c, g);
94
+ on(u, g) {
95
+ r.on(u, g);
80
96
  },
81
- off(c, g) {
82
- o.off(c, g);
97
+ off(u, g) {
98
+ r.off(u, g);
83
99
  },
84
- invoke(c, ...g) {
85
- return o.invoke(c, ...g);
100
+ invoke(u, ...g) {
101
+ return r.invoke(u, ...g);
86
102
  },
87
- onStatusChange(c) {
88
- return n.add(c), () => n.delete(c);
103
+ onStatusChange(u) {
104
+ return n.add(u), () => n.delete(u);
89
105
  }
90
106
  };
91
107
  }
92
- function he(u) {
108
+ function he(c) {
93
109
  const {
94
110
  adapter: e,
95
111
  entityName: t,
96
112
  keyField: n,
97
113
  initialData: a = [],
98
- onBeforeChange: r,
99
- onAfterChange: o,
100
- onConflict: l,
101
- subscribeMethod: c = "SubscribeToEntity",
114
+ onBeforeChange: o,
115
+ onAfterChange: r,
116
+ onConflict: i,
117
+ subscribeMethod: u = "SubscribeToEntity",
102
118
  unsubscribeMethod: g = "UnsubscribeFromEntity",
103
119
  changeEventName: v = "EntityChanged",
104
120
  flashChanges: w = !0,
105
121
  flashDuration: V = 500,
106
122
  optimisticUpdates: O = !0
107
- } = u, [Q, N] = E(a), [X, q] = E(e.status), [Z, U] = E(/* @__PURE__ */ new Set()), [K, x] = E(/* @__PURE__ */ new Set()), [Y, ae] = E(null), j = oe(/* @__PURE__ */ new Map()), B = oe(/* @__PURE__ */ new Map()), _ = h(
123
+ } = c, [Q, N] = E(a), [X, q] = E(e.status), [Z, U] = E(/* @__PURE__ */ new Set()), [K, x] = E(/* @__PURE__ */ new Set()), [Y, ae] = E(null), j = oe(/* @__PURE__ */ new Map()), B = oe(/* @__PURE__ */ new Map()), _ = h(
108
124
  (y, k) => {
109
125
  const { operation: P, key: C, data: S, changes: I } = k;
110
126
  switch (P) {
@@ -112,10 +128,11 @@ function he(u) {
112
128
  return !S || y.some((R) => R[n] === C) ? y : [...y, S];
113
129
  case "update":
114
130
  return y.map((R) => {
115
- if (R[n] !== C) return R;
131
+ if (R[n] !== C)
132
+ return R;
116
133
  const H = j.current.get(C);
117
- if (H && l) {
118
- const se = l(
134
+ if (H && i) {
135
+ const se = i(
119
136
  { ...R, ...H.changes },
120
137
  S ?? { ...R, ...I },
121
138
  k
@@ -130,10 +147,11 @@ function he(u) {
130
147
  return y;
131
148
  }
132
149
  },
133
- [n, l]
150
+ [n, i]
134
151
  ), L = h(
135
152
  (y) => {
136
- if (!w) return;
153
+ if (!w)
154
+ return;
137
155
  const k = B.current.get(y);
138
156
  k && clearTimeout(k), U((C) => /* @__PURE__ */ new Set([...C, y]));
139
157
  const P = setTimeout(() => {
@@ -147,12 +165,12 @@ function he(u) {
147
165
  [w, V]
148
166
  ), z = h(
149
167
  async (y) => {
150
- y.entityName === t && (r && !await r(y) || (N((k) => {
168
+ y.entityName === t && (o && !await o(y) || (N((k) => {
151
169
  const P = _(k, y);
152
- return o == null || o(y, P), P;
170
+ return r == null || r(y, P), P;
153
171
  }), L(y.key)));
154
172
  },
155
- [t, r, _, o, L]
173
+ [t, o, _, r, L]
156
174
  ), p = h(
157
175
  (y) => {
158
176
  z(y);
@@ -160,7 +178,8 @@ function he(u) {
160
178
  [z]
161
179
  ), le = h(
162
180
  (y, k) => {
163
- if (!O) return;
181
+ if (!O)
182
+ return;
164
183
  const P = Q.find((C) => C[n] === y);
165
184
  P && (j.current.set(y, { original: P, changes: k }), x((C) => /* @__PURE__ */ new Set([...C, y])));
166
185
  },
@@ -170,24 +189,25 @@ function he(u) {
170
189
  const P = new Set(k);
171
190
  return P.delete(y), P;
172
191
  });
173
- }, []), F = h((y) => {
174
- const k = j.current.get(y);
175
- k && (N(
176
- (P) => P.map(
177
- (C) => C[n] === y ? k.original : C
178
- )
179
- ), j.current.delete(y), x((P) => {
180
- const C = new Set(P);
181
- return C.delete(y), C;
182
- }));
183
- }, [n]), ne = h(async () => {
192
+ }, []), F = h(
193
+ (y) => {
194
+ const k = j.current.get(y);
195
+ k && (N(
196
+ (P) => P.map((C) => C[n] === y ? k.original : C)
197
+ ), j.current.delete(y), x((P) => {
198
+ const C = new Set(P);
199
+ return C.delete(y), C;
200
+ }));
201
+ },
202
+ [n]
203
+ ), ne = h(async () => {
184
204
  if (e.status === "connected")
185
205
  try {
186
- await e.invoke(c, t), ae(null);
206
+ await e.invoke(u, t), ae(null);
187
207
  } catch (y) {
188
208
  ae(y instanceof Error ? y : new Error(String(y)));
189
209
  }
190
- }, [e, c, t]), re = h(async () => {
210
+ }, [e, u, t]), re = h(async () => {
191
211
  if (e.status === "connected")
192
212
  try {
193
213
  await e.invoke(g, t);
@@ -216,32 +236,32 @@ function he(u) {
216
236
  resubscribe: ne
217
237
  };
218
238
  }
219
- function Pe(u) {
239
+ function Pe(c) {
220
240
  const {
221
241
  adapter: e,
222
242
  entityName: t,
223
243
  keyField: n,
224
244
  fetchMethod: a = "GetEntities",
225
- insertMethod: r = "InsertEntity",
226
- updateMethod: o = "UpdateEntity",
227
- deleteMethod: l = "DeleteEntity"
228
- } = u;
245
+ insertMethod: o = "InsertEntity",
246
+ updateMethod: r = "UpdateEntity",
247
+ deleteMethod: i = "DeleteEntity"
248
+ } = c;
229
249
  return {
230
250
  /** Fetch all entities from the hub. */
231
- async fetchAll(c) {
232
- return e.invoke(a, t, c);
251
+ async fetchAll(u) {
252
+ return e.invoke(a, t, u);
233
253
  },
234
254
  /** Insert a new entity via the hub. */
235
- async insert(c) {
236
- return e.invoke(r, t, c);
255
+ async insert(u) {
256
+ return e.invoke(o, t, u);
237
257
  },
238
258
  /** Update an existing entity via the hub. */
239
- async update(c, g) {
240
- return e.invoke(o, t, c, g);
259
+ async update(u, g) {
260
+ return e.invoke(r, t, u, g);
241
261
  },
242
262
  /** Delete an entity via the hub. */
243
- async remove(c) {
244
- return e.invoke(l, t, c);
263
+ async remove(u) {
264
+ return e.invoke(i, t, u);
245
265
  },
246
266
  /** Get the key field name. */
247
267
  getKeyField() {
@@ -249,8 +269,8 @@ function Pe(u) {
249
269
  }
250
270
  };
251
271
  }
252
- function Ae(u, e, t) {
253
- const n = new Map(u.map((a) => [a[t], a]));
272
+ function Ae(c, e, t) {
273
+ const n = new Map(c.map((a) => [a[t], a]));
254
274
  for (const a of e)
255
275
  switch (a.operation) {
256
276
  case "insert":
@@ -258,11 +278,8 @@ function Ae(u, e, t) {
258
278
  break;
259
279
  case "update":
260
280
  if (n.has(a.key)) {
261
- const r = n.get(a.key);
262
- n.set(
263
- a.key,
264
- a.data ?? { ...r, ...a.changes }
265
- );
281
+ const o = n.get(a.key);
282
+ n.set(a.key, a.data ?? { ...o, ...a.changes });
266
283
  }
267
284
  break;
268
285
  case "delete":
@@ -271,16 +288,16 @@ function Ae(u, e, t) {
271
288
  }
272
289
  return Array.from(n.values());
273
290
  }
274
- function pe(u) {
291
+ function pe(c) {
275
292
  const {
276
293
  adapter: e,
277
294
  entityType: t,
278
295
  entityId: n,
279
296
  currentUser: a,
280
- initialStatus: r = "viewing",
281
- heartbeatInterval: o = 3e4,
282
- idleTimeout: l = 6e4,
283
- awayTimeout: c = 3e5,
297
+ initialStatus: o = "viewing",
298
+ heartbeatInterval: r = 3e4,
299
+ idleTimeout: i = 6e4,
300
+ awayTimeout: u = 3e5,
284
301
  joinMethod: g = "JoinEntityView",
285
302
  leaveMethod: v = "LeaveEntityView",
286
303
  updateMethod: w = "UpdateEntityPresence",
@@ -289,7 +306,7 @@ function pe(u) {
289
306
  leftEventName: Q = "EntityUserLeft",
290
307
  onPresenceChange: N,
291
308
  onEditConflict: X
292
- } = u, [q, Z] = E([]), [U, K] = E(r), [x, Y] = E(), [ae, j] = E(e.status), B = oe(Date.now()), _ = oe(null), L = oe(null), z = oe(null), p = Array.isArray(n) ? n : [n], le = `${t}:${p.sort().join(",")}`, J = h(
309
+ } = c, [q, Z] = E([]), [U, K] = E(o), [x, Y] = E(), [ae, j] = E(e.status), B = oe(Date.now()), _ = oe(null), L = oe(null), z = oe(null), p = Array.isArray(n) ? n : [n], le = `${t}:${p.sort().join(",")}`, J = h(
293
310
  async (m, T, s) => {
294
311
  if (e.status === "connected")
295
312
  try {
@@ -350,10 +367,10 @@ function pe(u) {
350
367
  }, [e, t, p, N]), S = h(() => {
351
368
  B.current = Date.now(), L.current && clearTimeout(L.current), z.current && clearTimeout(z.current), (U === "idle" || U === "away") && F(x ? "editing" : "viewing", x), L.current = setTimeout(() => {
352
369
  F("idle", x);
353
- }, l), z.current = setTimeout(() => {
370
+ }, i), z.current = setTimeout(() => {
354
371
  F("away", x);
355
- }, c);
356
- }, [U, x, l, c, F]), I = h(
372
+ }, u);
373
+ }, [U, x, i, u, F]), I = h(
357
374
  (m) => {
358
375
  m.entityType !== t || !m.entityIds.some((s) => p.includes(s)) || (Z(m.presence.filter((s) => s.user.id !== a.id)), N == null || N(m.presence));
359
376
  },
@@ -417,18 +434,18 @@ function pe(u) {
417
434
  p
418
435
  ]), te(() => (_.current = setInterval(() => {
419
436
  J(U, x);
420
- }, o), () => {
437
+ }, r), () => {
421
438
  _.current && clearInterval(_.current);
422
- }), [o, J, U, x]), te(() => {
439
+ }), [r, J, U, x]), te(() => {
423
440
  const m = ["mousemove", "keydown", "mousedown", "touchstart", "scroll"];
424
441
  return m.forEach((T) => window.addEventListener(T, S, { passive: !0 })), L.current = setTimeout(() => {
425
442
  F("idle", x);
426
- }, l), z.current = setTimeout(() => {
443
+ }, i), z.current = setTimeout(() => {
427
444
  F("away", x);
428
- }, c), () => {
445
+ }, u), () => {
429
446
  m.forEach((T) => window.removeEventListener(T, S)), L.current && clearTimeout(L.current), z.current && clearTimeout(z.current);
430
447
  };
431
- }, [S, l, c, x, F]);
448
+ }, [S, i, u, x, F]);
432
449
  const se = q.filter((m) => m.status === "viewing" || m.status === "idle").map((m) => m.user), ie = q.filter((m) => m.status === "editing").map((m) => m.user), ue = ie.length > 0;
433
450
  return {
434
451
  presence: q,
@@ -446,7 +463,7 @@ function pe(u) {
446
463
  refresh: C
447
464
  };
448
465
  }
449
- function me(u) {
466
+ function me(c) {
450
467
  const e = [
451
468
  "#3b82f6",
452
469
  // blue
@@ -470,12 +487,12 @@ function me(u) {
470
487
  // teal
471
488
  ];
472
489
  let t = 0;
473
- for (let n = 0; n < u.length; n++)
474
- t = u.charCodeAt(n) + ((t << 5) - t);
490
+ for (let n = 0; n < c.length; n++)
491
+ t = c.charCodeAt(n) + ((t << 5) - t);
475
492
  return e[Math.abs(t) % e.length];
476
493
  }
477
- function Oe(u) {
478
- switch (u) {
494
+ function Oe(c) {
495
+ switch (c) {
479
496
  case "viewing":
480
497
  return "Viewing";
481
498
  case "editing":
@@ -488,60 +505,57 @@ function Oe(u) {
488
505
  return "Unknown";
489
506
  }
490
507
  }
491
- function xe(u) {
492
- const {
493
- adapter: e,
494
- entityType: t,
495
- currentUser: n,
496
- batchEventName: a = "BatchPresenceUpdate"
497
- } = u, [r, o] = E(/* @__PURE__ */ new Map()), l = h(
508
+ function xe(c) {
509
+ const { adapter: e, entityType: t, currentUser: n, batchEventName: a = "BatchPresenceUpdate" } = c, [o, r] = E(
510
+ /* @__PURE__ */ new Map()
511
+ ), i = h(
498
512
  (w) => {
499
- w.entityType === t && o(new Map(Object.entries(w.presenceByEntity)));
513
+ w.entityType === t && r(new Map(Object.entries(w.presenceByEntity)));
500
514
  },
501
515
  [t]
502
516
  );
503
- te(() => (e.on(a, l), () => {
504
- e.off(a, l);
505
- }), [e, a, l]);
506
- const c = h(
507
- (w) => r.get(w) ?? [],
508
- [r]
517
+ te(() => (e.on(a, i), () => {
518
+ e.off(a, i);
519
+ }), [e, a, i]);
520
+ const u = h(
521
+ (w) => o.get(w) ?? [],
522
+ [o]
509
523
  ), g = h(
510
524
  (w) => {
511
- const V = r.get(w);
525
+ const V = o.get(w);
512
526
  return (V == null ? void 0 : V.some((O) => O.status === "editing" && O.user.id !== n.id)) ?? !1;
513
527
  },
514
- [r, n.id]
528
+ [o, n.id]
515
529
  ), v = h(
516
530
  (w) => {
517
- const V = r.get(w);
531
+ const V = o.get(w);
518
532
  return (V == null ? void 0 : V.filter((O) => O.status === "editing").map((O) => O.user)) ?? [];
519
533
  },
520
- [r]
534
+ [o]
521
535
  );
522
536
  return {
523
- presenceByEntity: r,
524
- getPresence: c,
537
+ presenceByEntity: o,
538
+ getPresence: u,
525
539
  isEntityBeingEdited: g,
526
540
  getEntityEditors: v
527
541
  };
528
542
  }
529
- function G(u) {
530
- return `${String(u.rowKey)}:${u.field}`;
543
+ function G(c) {
544
+ return `${String(c.rowKey)}:${c.field}`;
531
545
  }
532
- function fe(u) {
533
- return u ? typeof u == "number" ? u : new Date(u).getTime() : Date.now();
546
+ function fe(c) {
547
+ return c ? typeof c == "number" ? c : new Date(c).getTime() : Date.now();
534
548
  }
535
- function Le(u) {
549
+ function Le(c) {
536
550
  const {
537
551
  adapter: e,
538
552
  entityType: t,
539
553
  keyField: n,
540
554
  currentUser: a,
541
- initialData: r = [],
542
- conflictStrategy: o = "last-write-wins",
543
- mergeFunction: l,
544
- onConflict: c,
555
+ initialData: o = [],
556
+ conflictStrategy: r = "last-write-wins",
557
+ mergeFunction: i,
558
+ onConflict: u,
545
559
  onBeforeCommit: g,
546
560
  onAfterCommit: v,
547
561
  enableCellLocking: w = !0,
@@ -552,19 +566,23 @@ function Le(u) {
552
566
  flashChanges: X = !0,
553
567
  flashDuration: q = 500,
554
568
  liveDataOptions: Z = {}
555
- } = u, [U, K] = E(/* @__PURE__ */ new Map()), [x, Y] = E(/* @__PURE__ */ new Map()), [ae, j] = E([]), [B, _] = E(null), [L, z] = E([]), [p, le] = E([]), [J, F] = E(null), [ne, re] = E([]), y = oe(null), k = oe(/* @__PURE__ */ new Map()), P = h((i) => (k.current.has(i) || k.current.set(i, me(i)), k.current.get(i)), []), C = h(
556
- (i, f, d) => {
557
- if (!d.changes) return f;
558
- const A = x.get(G({ rowKey: d.key, field: Object.keys(d.changes)[0] }));
559
- if (!A) return f;
569
+ } = c, [U, K] = E(/* @__PURE__ */ new Map()), [x, Y] = E(/* @__PURE__ */ new Map()), [ae, j] = E([]), [B, _] = E(null), [L, z] = E([]), [p, le] = E([]), [J, F] = E(null), [ne, re] = E([]), y = oe(null), k = oe(/* @__PURE__ */ new Map()), P = h((l) => (k.current.has(l) || k.current.set(l, me(l)), k.current.get(l)), []), C = h(
570
+ (l, f, d) => {
571
+ if (!d.changes)
572
+ return f;
573
+ const A = x.get(
574
+ G({ rowKey: d.key, field: Object.keys(d.changes)[0] })
575
+ );
576
+ if (!A)
577
+ return f;
560
578
  const M = A.timestamp, D = fe(d.timestamp);
561
- switch (o) {
579
+ switch (r) {
562
580
  case "last-write-wins":
563
581
  return M > D ? "local" : "remote";
564
582
  case "first-write-wins":
565
583
  return M < D ? "local" : "remote";
566
584
  case "merge":
567
- return l ? l(i, f, Object.keys(d.changes)[0]) : "merge";
585
+ return i ? i(l, f, Object.keys(d.changes)[0]) : "merge";
568
586
  case "ask-user":
569
587
  const W = {
570
588
  cell: { rowKey: d.key, field: Object.keys(d.changes)[0] },
@@ -583,12 +601,12 @@ function Le(u) {
583
601
  return "remote";
584
602
  }
585
603
  },
586
- [x, o, l, a]
604
+ [x, r, i, a]
587
605
  ), S = he({
588
606
  adapter: e,
589
607
  entityName: t,
590
608
  keyField: n,
591
- initialData: r,
609
+ initialData: o,
592
610
  flashChanges: X,
593
611
  flashDuration: q,
594
612
  optimisticUpdates: N,
@@ -611,15 +629,33 @@ function Le(u) {
611
629
  editingCell: J
612
630
  }).catch(() => {
613
631
  });
614
- }, [e, O, t, a.id, B, L, p, J]);
632
+ }, [
633
+ e,
634
+ O,
635
+ t,
636
+ a.id,
637
+ B,
638
+ L,
639
+ p,
640
+ J
641
+ ]);
615
642
  te(() => {
616
643
  if (O)
617
644
  return y.current && clearTimeout(y.current), y.current = setTimeout(R, Q), () => {
618
645
  y.current && clearTimeout(y.current);
619
646
  };
620
- }, [O, R, Q, B, L, p, J]), te(() => {
621
- if (!O) return;
622
- const i = (f) => {
647
+ }, [
648
+ O,
649
+ R,
650
+ Q,
651
+ B,
652
+ L,
653
+ p,
654
+ J
655
+ ]), te(() => {
656
+ if (!O)
657
+ return;
658
+ const l = (f) => {
623
659
  f.entityType !== t || f.userId === a.id || re((d) => {
624
660
  const A = d.findIndex((D) => D.user.id === f.userId), M = {
625
661
  user: { id: f.userId, name: f.userName, avatarUrl: f.avatarUrl },
@@ -636,12 +672,13 @@ function Le(u) {
636
672
  return [...d, M];
637
673
  });
638
674
  };
639
- return e.on("GridSelectionUpdated", i), () => {
640
- e.off("GridSelectionUpdated", i);
675
+ return e.on("GridSelectionUpdated", l), () => {
676
+ e.off("GridSelectionUpdated", l);
641
677
  };
642
678
  }, [e, O, t, a.id, P]), te(() => {
643
- if (!w) return;
644
- const i = (d) => {
679
+ if (!w)
680
+ return;
681
+ const l = (d) => {
645
682
  d.entityType === t && K((A) => {
646
683
  const M = new Map(A);
647
684
  return M.set(G(d.cell), { user: d.user, timestamp: d.timestamp }), M;
@@ -652,12 +689,13 @@ function Le(u) {
652
689
  return M.delete(G(d.cell)), M;
653
690
  });
654
691
  };
655
- return e.on("CellLocked", i), e.on("CellUnlocked", f), () => {
656
- e.off("CellLocked", i), e.off("CellUnlocked", f);
692
+ return e.on("CellLocked", l), e.on("CellUnlocked", f), () => {
693
+ e.off("CellLocked", l), e.off("CellUnlocked", f);
657
694
  };
658
695
  }, [e, w, t]), te(() => {
659
- if (!w) return;
660
- const i = setInterval(() => {
696
+ if (!w)
697
+ return;
698
+ const l = setInterval(() => {
661
699
  const f = Date.now();
662
700
  K((d) => {
663
701
  const A = new Map(d);
@@ -667,70 +705,72 @@ function Le(u) {
667
705
  return M ? A : d;
668
706
  });
669
707
  }, 1e4);
670
- return () => clearInterval(i);
708
+ return () => clearInterval(l);
671
709
  }, [w, V]);
672
710
  const H = h(
673
- (i) => {
674
- if (!w) return !1;
675
- const f = U.get(G(i));
711
+ (l) => {
712
+ if (!w)
713
+ return !1;
714
+ const f = U.get(G(l));
676
715
  return f ? f.user.id !== a.id && Date.now() - f.timestamp < V : !1;
677
716
  },
678
717
  [w, U, a.id, V]
679
718
  ), se = h(
680
- (i) => {
681
- const f = U.get(G(i));
719
+ (l) => {
720
+ const f = U.get(G(l));
682
721
  return !f || Date.now() - f.timestamp > V ? null : f.user;
683
722
  },
684
723
  [U, V]
685
724
  ), ie = h(
686
- (i) => H(i) ? !1 : (F(i), I.startEditing(`${i.rowKey}:${i.field}`), w && e.status === "connected" && (e.invoke("AcquireCellLock", {
725
+ (l) => H(l) ? !1 : (F(l), I.startEditing(`${l.rowKey}:${l.field}`), w && e.status === "connected" && (e.invoke("AcquireCellLock", {
687
726
  entityType: t,
688
- cell: i,
727
+ cell: l,
689
728
  user: a,
690
729
  timestamp: Date.now()
691
730
  }).catch(() => {
692
731
  }), K((f) => {
693
732
  const d = new Map(f);
694
- return d.set(G(i), { user: a, timestamp: Date.now() }), d;
733
+ return d.set(G(l), { user: a, timestamp: Date.now() }), d;
695
734
  })), !0),
696
735
  [H, I, w, e, t, a]
697
736
  ), ue = h(
698
- async (i, f) => {
699
- const d = S.data.find((D) => D[n] === i.rowKey);
700
- if (!d) return !1;
701
- const A = d[i.field];
702
- if (g && !await g(i, A, f))
703
- return m(i), !1;
737
+ async (l, f) => {
738
+ const d = S.data.find((D) => D[n] === l.rowKey);
739
+ if (!d)
740
+ return !1;
741
+ const A = d[l.field];
742
+ if (g && !await g(l, A, f))
743
+ return m(l), !1;
704
744
  const M = {
705
- cell: i,
745
+ cell: l,
706
746
  originalValue: A,
707
747
  newValue: f,
708
748
  timestamp: Date.now()
709
749
  };
710
750
  Y((D) => {
711
751
  const W = new Map(D);
712
- return W.set(G(i), M), W;
713
- }), N && S.registerPendingChange(i.rowKey, { [i.field]: f });
752
+ return W.set(G(l), M), W;
753
+ }), N && S.registerPendingChange(l.rowKey, { [l.field]: f });
714
754
  try {
715
755
  return await e.invoke("UpdateEntityField", {
716
756
  entityType: t,
717
- entityId: i.rowKey,
718
- field: i.field,
757
+ entityId: l.rowKey,
758
+ field: l.field,
719
759
  value: f,
720
760
  userId: a.id,
721
761
  timestamp: M.timestamp
722
- }), S.confirmPendingChange(i.rowKey), Y((D) => {
762
+ }), S.confirmPendingChange(l.rowKey), Y((D) => {
723
763
  const W = new Map(D);
724
- return W.delete(G(i)), W;
725
- }), v == null || v(i, f), w && (e.invoke("ReleaseCellLock", { entityType: t, cell: i }).catch(() => {
764
+ return W.delete(G(l)), W;
765
+ }), v == null || v(l, f), w && (e.invoke("ReleaseCellLock", { entityType: t, cell: l }).catch(() => {
726
766
  }), K((D) => {
727
767
  const W = new Map(D);
728
- return W.delete(G(i)), W;
768
+ return W.delete(G(l)), W;
729
769
  })), F(null), I.stopEditing(), !0;
730
770
  } catch (D) {
731
- throw S.rollbackPendingChange(i.rowKey), Y((W) => {
771
+ throw S.rollbackPendingChange(l.rowKey), Y((W) => {
732
772
  const ce = new Map(W);
733
- return ce.delete(G(i)), ce;
773
+ return ce.delete(G(l)), ce;
734
774
  }), D;
735
775
  }
736
776
  },
@@ -747,46 +787,46 @@ function Le(u) {
747
787
  I
748
788
  ]
749
789
  ), m = h(
750
- (i) => {
751
- F(null), I.stopEditing(), w && e.status === "connected" && (e.invoke("ReleaseCellLock", { entityType: t, cell: i }).catch(() => {
790
+ (l) => {
791
+ F(null), I.stopEditing(), w && e.status === "connected" && (e.invoke("ReleaseCellLock", { entityType: t, cell: l }).catch(() => {
752
792
  }), K((f) => {
753
793
  const d = new Map(f);
754
- return d.delete(G(i)), d;
794
+ return d.delete(G(l)), d;
755
795
  })), Y((f) => {
756
796
  const d = new Map(f);
757
- return d.delete(G(i)), d;
797
+ return d.delete(G(l)), d;
758
798
  });
759
799
  },
760
800
  [I, w, e, t]
761
801
  ), T = h(
762
- (i, f) => {
763
- const d = ae.find((A) => G(A.cell) === G(i));
802
+ (l, f) => {
803
+ const d = ae.find((A) => G(A.cell) === G(l));
764
804
  d && (f === "remote" && S.applyRemoteUpdate({
765
805
  operation: "update",
766
806
  entityName: t,
767
- key: i.rowKey,
768
- changes: { [i.field]: d.remoteValue }
769
- }), j((A) => A.filter((M) => G(M.cell) !== G(i))));
807
+ key: l.rowKey,
808
+ changes: { [l.field]: d.remoteValue }
809
+ }), j((A) => A.filter((M) => G(M.cell) !== G(l))));
770
810
  },
771
811
  [ae, S, t]
772
812
  ), s = h(
773
- async (i) => {
774
- await e.invoke("InsertEntity", t, i);
813
+ async (l) => {
814
+ await e.invoke("InsertEntity", t, l);
775
815
  },
776
816
  [e, t]
777
817
  ), b = h(
778
- async (i, f) => {
779
- N && S.registerPendingChange(i, f);
818
+ async (l, f) => {
819
+ N && S.registerPendingChange(l, f);
780
820
  try {
781
- await e.invoke("UpdateEntity", t, i, f), S.confirmPendingChange(i);
821
+ await e.invoke("UpdateEntity", t, l, f), S.confirmPendingChange(l);
782
822
  } catch (d) {
783
- throw S.rollbackPendingChange(i), d;
823
+ throw S.rollbackPendingChange(l), d;
784
824
  }
785
825
  },
786
826
  [e, t, N, S]
787
827
  ), $ = h(
788
- async (i) => {
789
- await e.invoke("DeleteEntity", t, i);
828
+ async (l) => {
829
+ await e.invoke("DeleteEntity", t, l);
790
830
  },
791
831
  [e, t]
792
832
  ), ee = de(
@@ -832,7 +872,8 @@ function Le(u) {
832
872
  class Re {
833
873
  constructor(e) {
834
874
  this.accessToken = null, this.refreshToken = null, this.tokenFactory = async () => {
835
- if (!this.accessToken) throw new Error("Not authenticated");
875
+ if (!this.accessToken)
876
+ throw new Error("Not authenticated");
836
877
  return this.accessToken;
837
878
  }, this.cfg = e;
838
879
  }
@@ -846,7 +887,8 @@ class Re {
846
887
  headers: { "Content-Type": "application/json" },
847
888
  body: JSON.stringify(t)
848
889
  });
849
- if (!a.ok) throw new Error(`Auth request failed: ${a.status}`);
890
+ if (!a.ok)
891
+ throw new Error(`Auth request failed: ${a.status}`);
850
892
  return a.json();
851
893
  }
852
894
  /** Login with username/password. */
@@ -858,8 +900,11 @@ class Re {
858
900
  /** Refresh the access token. */
859
901
  async refresh() {
860
902
  var t, n;
861
- if (!this.refreshToken) throw new Error("No refresh token");
862
- const e = await this.post("/refresh", { refreshToken: this.refreshToken });
903
+ if (!this.refreshToken)
904
+ throw new Error("No refresh token");
905
+ const e = await this.post("/refresh", {
906
+ refreshToken: this.refreshToken
907
+ });
863
908
  return e.token && (this.accessToken = e.token, this.refreshToken = e.refreshToken ?? this.refreshToken, (n = (t = this.cfg).onTokens) == null || n.call(t, e.token, this.refreshToken)), e;
864
909
  }
865
910
  /** Get current user info. */
@@ -867,7 +912,8 @@ class Re {
867
912
  const t = await (this.cfg.fetch ?? globalThis.fetch)(`${this.cfg.baseUrl}/me`, {
868
913
  headers: { Authorization: `Bearer ${this.accessToken}` }
869
914
  });
870
- if (!t.ok) throw new Error(`Auth /me failed: ${t.status}`);
915
+ if (!t.ok)
916
+ throw new Error(`Auth /me failed: ${t.status}`);
871
917
  return t.json();
872
918
  }
873
919
  /** Logout (invalidate tokens on server). */
@@ -894,32 +940,35 @@ class De {
894
940
  async upload(e, t) {
895
941
  const n = this.cfg.fetch ?? globalThis.fetch, a = new FormData();
896
942
  a.append("file", e), t && a.append("folder", t);
897
- const r = await n(this.cfg.baseUrl, {
943
+ const o = await n(this.cfg.baseUrl, {
898
944
  method: "POST",
899
945
  headers: await this.headers(),
900
946
  body: a
901
947
  });
902
- if (!r.ok) throw new Error(`File upload failed: ${r.status}`);
903
- return r.json();
948
+ if (!o.ok)
949
+ throw new Error(`File upload failed: ${o.status}`);
950
+ return o.json();
904
951
  }
905
952
  /** Upload multiple files. */
906
953
  async uploadMultiple(e, t) {
907
954
  const n = this.cfg.fetch ?? globalThis.fetch, a = new FormData();
908
- e.forEach((o) => a.append("files", o)), t && a.append("folder", t);
909
- const r = await n(`${this.cfg.baseUrl}/batch`, {
955
+ e.forEach((r) => a.append("files", r)), t && a.append("folder", t);
956
+ const o = await n(`${this.cfg.baseUrl}/batch`, {
910
957
  method: "POST",
911
958
  headers: await this.headers(),
912
959
  body: a
913
960
  });
914
- if (!r.ok) throw new Error(`Batch upload failed: ${r.status}`);
915
- return r.json();
961
+ if (!o.ok)
962
+ throw new Error(`Batch upload failed: ${o.status}`);
963
+ return o.json();
916
964
  }
917
965
  /** Get file metadata by id. */
918
966
  async getInfo(e) {
919
967
  const n = await (this.cfg.fetch ?? globalThis.fetch)(`${this.cfg.baseUrl}/${e}/info`, {
920
968
  headers: { ...await this.headers(), "Content-Type": "application/json" }
921
969
  });
922
- if (!n.ok) throw new Error(`File info failed: ${n.status}`);
970
+ if (!n.ok)
971
+ throw new Error(`File info failed: ${n.status}`);
923
972
  return n.json();
924
973
  }
925
974
  /** Get a download URL (or blob URL) for a file. */
@@ -927,7 +976,8 @@ class De {
927
976
  const n = await (this.cfg.fetch ?? globalThis.fetch)(`${this.cfg.baseUrl}/${e}`, {
928
977
  headers: await this.headers()
929
978
  });
930
- if (!n.ok) throw new Error(`File download failed: ${n.status}`);
979
+ if (!n.ok)
980
+ throw new Error(`File download failed: ${n.status}`);
931
981
  const a = await n.blob();
932
982
  return URL.createObjectURL(a);
933
983
  }
@@ -937,43 +987,45 @@ class De {
937
987
  method: "DELETE",
938
988
  headers: { ...await this.headers(), "Content-Type": "application/json" }
939
989
  });
940
- if (!n.ok) throw new Error(`File delete failed: ${n.status}`);
990
+ if (!n.ok)
991
+ throw new Error(`File delete failed: ${n.status}`);
941
992
  return n.json();
942
993
  }
943
994
  /**
944
995
  * Upload a file with progress tracking via XMLHttpRequest.
945
996
  * Falls back to standard fetch-based upload if XHR is unavailable.
946
997
  */
947
- uploadWithProgress(e, t, n, a) {
948
- return typeof XMLHttpRequest > "u" ? this.upload(e, n) : new Promise(async (r, o) => {
949
- const l = new XMLHttpRequest(), c = new FormData();
950
- if (c.append("file", e), n && c.append("folder", n), a) {
998
+ async uploadWithProgress(e, t, n, a) {
999
+ if (typeof XMLHttpRequest > "u")
1000
+ return this.upload(e, n);
1001
+ const o = await this.headers();
1002
+ return new Promise((r, i) => {
1003
+ const u = new XMLHttpRequest(), g = new FormData();
1004
+ if (g.append("file", e), n && g.append("folder", n), a) {
951
1005
  if (a.aborted) {
952
- o(new DOMException("Aborted", "AbortError"));
1006
+ i(new DOMException("Aborted", "AbortError"));
953
1007
  return;
954
1008
  }
955
1009
  a.addEventListener("abort", () => {
956
- l.abort(), o(new DOMException("Aborted", "AbortError"));
1010
+ u.abort(), i(new DOMException("Aborted", "AbortError"));
957
1011
  });
958
1012
  }
959
- l.upload.addEventListener("progress", (v) => {
1013
+ u.upload.addEventListener("progress", (v) => {
960
1014
  t({
961
1015
  loaded: v.loaded,
962
1016
  total: v.total,
963
1017
  percent: v.lengthComputable ? v.loaded / v.total : NaN
964
1018
  });
965
- }), l.addEventListener("load", () => {
966
- if (l.status >= 200 && l.status < 300)
1019
+ }), u.addEventListener("load", () => {
1020
+ if (u.status >= 200 && u.status < 300)
967
1021
  try {
968
- r(JSON.parse(l.responseText));
1022
+ r(JSON.parse(u.responseText));
969
1023
  } catch {
970
- o(new Error("Invalid JSON response"));
1024
+ i(new Error("Invalid JSON response"));
971
1025
  }
972
1026
  else
973
- o(new Error(`File upload failed: ${l.status}`));
974
- }), l.addEventListener("error", () => o(new Error("Network error during upload"))), l.addEventListener("abort", () => o(new DOMException("Aborted", "AbortError"))), l.open("POST", this.cfg.baseUrl);
975
- const g = await this.headers();
976
- Object.entries(g).forEach(([v, w]) => l.setRequestHeader(v, w)), l.send(c);
1027
+ i(new Error(`File upload failed: ${u.status}`));
1028
+ }), u.addEventListener("error", () => i(new Error("Network error during upload"))), u.addEventListener("abort", () => i(new DOMException("Aborted", "AbortError"))), u.open("POST", this.cfg.baseUrl), Object.entries(o).forEach(([v, w]) => u.setRequestHeader(v, w)), u.send(g);
977
1029
  });
978
1030
  }
979
1031
  /**
@@ -981,18 +1033,19 @@ class De {
981
1033
  * Returns progress for each file individually.
982
1034
  */
983
1035
  async uploadMultipleWithProgress(e, t, n, a) {
984
- const r = [];
985
- for (let o = 0; o < e.length; o++) {
986
- if (a != null && a.aborted) throw new DOMException("Aborted", "AbortError");
987
- const l = await this.uploadWithProgress(
988
- e[o],
989
- (c) => t(o, c),
1036
+ const o = [];
1037
+ for (let r = 0; r < e.length; r++) {
1038
+ if (a != null && a.aborted)
1039
+ throw new DOMException("Aborted", "AbortError");
1040
+ const i = await this.uploadWithProgress(
1041
+ e[r],
1042
+ (u) => t(r, u),
990
1043
  n,
991
1044
  a
992
1045
  );
993
- r.push(l);
1046
+ o.push(i);
994
1047
  }
995
- return r;
1048
+ return o;
996
1049
  }
997
1050
  }
998
1051
  class Ne {
@@ -1010,7 +1063,8 @@ class Ne {
1010
1063
  headers: await this.headers(),
1011
1064
  body: JSON.stringify(e)
1012
1065
  });
1013
- if (!n.ok) throw new Error(`Export request failed: ${n.status}`);
1066
+ if (!n.ok)
1067
+ throw new Error(`Export request failed: ${n.status}`);
1014
1068
  return n.json();
1015
1069
  }
1016
1070
  /** Download an exported file as a Blob. */
@@ -1018,66 +1072,69 @@ class Ne {
1018
1072
  const n = await (this.cfg.fetch ?? globalThis.fetch)(e, {
1019
1073
  headers: await this.headers()
1020
1074
  });
1021
- if (!n.ok) throw new Error(`Export download failed: ${n.status}`);
1075
+ if (!n.ok)
1076
+ throw new Error(`Export download failed: ${n.status}`);
1022
1077
  return n.blob();
1023
1078
  }
1024
1079
  /** Trigger browser download for an export. */
1025
1080
  async downloadToFile(e, t) {
1026
- var l;
1081
+ var i;
1027
1082
  const n = await this.requestExport(e);
1028
- if (!((l = n.data) != null && l.downloadUrl)) throw new Error("No download URL returned");
1029
- const a = await this.download(n.data.downloadUrl), r = URL.createObjectURL(a), o = document.createElement("a");
1030
- o.href = r, o.download = t ?? `export.${e.format}`, document.body.appendChild(o), o.click(), document.body.removeChild(o), URL.revokeObjectURL(r);
1083
+ if (!((i = n.data) != null && i.downloadUrl))
1084
+ throw new Error("No download URL returned");
1085
+ const a = await this.download(n.data.downloadUrl), o = URL.createObjectURL(a), r = document.createElement("a");
1086
+ r.href = o, r.download = t ?? `export.${e.format}`, document.body.appendChild(r), r.click(), document.body.removeChild(r), URL.revokeObjectURL(o);
1031
1087
  }
1032
1088
  }
1033
- function Ue(u) {
1089
+ function Ue(c) {
1034
1090
  return (e) => {
1035
1091
  const t = e ?? globalThis.fetch;
1036
- return (a, r) => {
1037
- const c = { url: typeof a == "string" ? a : a instanceof URL ? a.toString() : a.url, init: r ?? {}, meta: {} };
1092
+ return (a, o) => {
1093
+ const u = { url: typeof a == "string" ? a : a instanceof URL ? a.toString() : a.url, init: o ?? {}, meta: {} };
1038
1094
  let g = (v) => t(v.url, v.init);
1039
- for (let v = u.length - 1; v >= 0; v--) {
1040
- const w = u[v], V = g;
1095
+ for (let v = c.length - 1; v >= 0; v--) {
1096
+ const w = c[v], V = g;
1041
1097
  g = (O) => w(O, V);
1042
1098
  }
1043
- return g(c);
1099
+ return g(u);
1044
1100
  };
1045
1101
  };
1046
1102
  }
1047
1103
  function Fe() {
1048
- return async (u, e) => {
1049
- const t = performance.now(), n = (u.init.method ?? "GET").toUpperCase();
1104
+ return async (c, e) => {
1105
+ const t = performance.now(), n = (c.init.method ?? "GET").toUpperCase();
1050
1106
  try {
1051
- const a = await e(u), r = (performance.now() - t).toFixed(1);
1052
- return console.debug(`[ERP] ${n} ${u.url} → ${a.status} (${r}ms)`), a;
1107
+ const a = await e(c), o = (performance.now() - t).toFixed(1);
1108
+ return console.debug(`[ERP] ${n} ${c.url} → ${a.status} (${o}ms)`), a;
1053
1109
  } catch (a) {
1054
- const r = (performance.now() - t).toFixed(1);
1055
- throw console.error(`[ERP] ${n} ${u.url} FAILED (${r}ms)`, a), a;
1110
+ const o = (performance.now() - t).toFixed(1);
1111
+ throw console.error(`[ERP] ${n} ${c.url} FAILED (${o}ms)`, a), a;
1056
1112
  }
1057
1113
  };
1058
1114
  }
1059
- function Me(u) {
1060
- const e = (u == null ? void 0 : u.maxRetries) ?? 3, t = (u == null ? void 0 : u.baseDelay) ?? 500, n = new Set((u == null ? void 0 : u.retryOn) ?? [408, 429, 500, 502, 503, 504]);
1061
- return async (a, r) => {
1062
- let o;
1063
- for (let l = 0; l <= e; l++) {
1115
+ function Me(c) {
1116
+ const e = (c == null ? void 0 : c.maxRetries) ?? 3, t = (c == null ? void 0 : c.baseDelay) ?? 500, n = new Set((c == null ? void 0 : c.retryOn) ?? [408, 429, 500, 502, 503, 504]);
1117
+ return async (a, o) => {
1118
+ let r;
1119
+ for (let i = 0; i <= e; i++) {
1064
1120
  try {
1065
- const g = await r(a);
1066
- if (g.ok || !n.has(g.status) || l === e)
1121
+ const g = await o(a);
1122
+ if (g.ok || !n.has(g.status) || i === e)
1067
1123
  return g;
1068
- o = new Error(`HTTP ${g.status}`);
1124
+ r = new Error(`HTTP ${g.status}`);
1069
1125
  } catch (g) {
1070
- if (o = g, l === e) throw g;
1126
+ if (r = g, i === e)
1127
+ throw g;
1071
1128
  }
1072
- const c = t * Math.pow(2, l) * (0.5 + Math.random() * 0.5);
1073
- await new Promise((g) => setTimeout(g, c));
1129
+ const u = t * Math.pow(2, i) * (0.5 + Math.random() * 0.5);
1130
+ await new Promise((g) => setTimeout(g, u));
1074
1131
  }
1075
- throw o;
1132
+ throw r;
1076
1133
  };
1077
1134
  }
1078
- function Ie(u) {
1135
+ function Ie(c) {
1079
1136
  return async (e, t) => {
1080
- const n = typeof u == "function" ? await u() : u;
1137
+ const n = typeof c == "function" ? await c() : c;
1081
1138
  return e.init.headers = { ...e.init.headers, ...n }, t(e);
1082
1139
  };
1083
1140
  }
@@ -1100,7 +1157,8 @@ class $e {
1100
1157
  return this.inFlight;
1101
1158
  }
1102
1159
  drain() {
1103
- if (this.processing) return;
1160
+ if (this.processing)
1161
+ return;
1104
1162
  this.processing = !0;
1105
1163
  const e = () => {
1106
1164
  if (this.queue.length === 0 || this.backingOff) {
@@ -1113,10 +1171,10 @@ class $e {
1113
1171
  }
1114
1172
  const t = Date.now();
1115
1173
  if (this.timestamps = this.timestamps.filter((a) => t - a < 1e3), this.timestamps.length >= this.maxPerSecond) {
1116
- const a = this.timestamps[0], r = 1e3 - (t - a) + 1;
1174
+ const a = this.timestamps[0], o = 1e3 - (t - a) + 1;
1117
1175
  setTimeout(() => {
1118
1176
  this.processing = !1, this.drain();
1119
- }, r);
1177
+ }, o);
1120
1178
  return;
1121
1179
  }
1122
1180
  const n = this.queue.shift();
@@ -1166,32 +1224,30 @@ class Be {
1166
1224
  }
1167
1225
  /** Optimistically create an item. */
1168
1226
  async create(e) {
1169
- const t = `__temp_${this.nextMutationId}`, n = { ...e, [this.keyField]: t }, r = {
1227
+ const t = `__temp_${this.nextMutationId}`, n = { ...e, [this.keyField]: t }, o = {
1170
1228
  id: String(this.nextMutationId++),
1171
1229
  type: "create",
1172
1230
  optimisticData: n,
1173
1231
  timestamp: Date.now(),
1174
1232
  status: "pending"
1175
1233
  };
1176
- this.items = [...this.items, n], this.mutations.push(r), this.notify();
1234
+ this.items = [...this.items, n], this.mutations.push(o), this.notify();
1177
1235
  try {
1178
- const o = await this.adapter.create(e);
1179
- return o.success ? (this.items = this.items.map(
1180
- (l) => l[this.keyField] === t ? o.data : l
1181
- ), r.status = "confirmed", r.entityId = o.data[this.keyField]) : (this.items = this.items.filter(
1182
- (l) => l[this.keyField] !== t
1183
- ), r.status = "failed", r.error = o.error), this.notify(), o;
1184
- } catch (o) {
1236
+ const r = await this.adapter.create(e);
1237
+ return r.success ? (this.items = this.items.map(
1238
+ (i) => i[this.keyField] === t ? r.data : i
1239
+ ), o.status = "confirmed", o.entityId = r.data[this.keyField]) : (this.items = this.items.filter(
1240
+ (i) => i[this.keyField] !== t
1241
+ ), o.status = "failed", o.error = r.error), this.notify(), r;
1242
+ } catch (r) {
1185
1243
  throw this.items = this.items.filter(
1186
- (l) => l[this.keyField] !== t
1187
- ), r.status = "failed", r.error = o instanceof Error ? o.message : String(o), this.notify(), o;
1244
+ (i) => i[this.keyField] !== t
1245
+ ), o.status = "failed", o.error = r instanceof Error ? r.message : String(r), this.notify(), r;
1188
1246
  }
1189
1247
  }
1190
1248
  /** Optimistically update an item. */
1191
1249
  async update(e, t) {
1192
- const n = this.items.findIndex(
1193
- (l) => l[this.keyField] === e
1194
- ), a = n >= 0 ? { ...this.items[n] } : void 0, o = {
1250
+ const n = this.items.findIndex((i) => i[this.keyField] === e), a = n >= 0 ? { ...this.items[n] } : void 0, r = {
1195
1251
  id: String(this.nextMutationId++),
1196
1252
  type: "update",
1197
1253
  entityId: e,
@@ -1199,27 +1255,23 @@ class Be {
1199
1255
  timestamp: Date.now(),
1200
1256
  status: "pending"
1201
1257
  };
1202
- n >= 0 && (this.items = this.items.map(
1203
- (l, c) => c === n ? { ...l, ...t } : l
1204
- )), this.mutations.push(o), this.notify();
1258
+ n >= 0 && (this.items = this.items.map((i, u) => u === n ? { ...i, ...t } : i)), this.mutations.push(r), this.notify();
1205
1259
  try {
1206
- const l = await this.adapter.update(e, t);
1207
- return l.success ? (this.items = this.items.map(
1208
- (c) => c[this.keyField] === e ? l.data : c
1209
- ), o.status = "confirmed") : (a && n >= 0 && (this.items = this.items.map(
1210
- (c) => c[this.keyField] === e ? a : c
1211
- )), o.status = "failed", o.error = l.error), this.notify(), l;
1212
- } catch (l) {
1260
+ const i = await this.adapter.update(e, t);
1261
+ return i.success ? (this.items = this.items.map(
1262
+ (u) => u[this.keyField] === e ? i.data : u
1263
+ ), r.status = "confirmed") : (a && n >= 0 && (this.items = this.items.map(
1264
+ (u) => u[this.keyField] === e ? a : u
1265
+ )), r.status = "failed", r.error = i.error), this.notify(), i;
1266
+ } catch (i) {
1213
1267
  throw a && n >= 0 && (this.items = this.items.map(
1214
- (c) => c[this.keyField] === e ? a : c
1215
- )), o.status = "failed", o.error = l instanceof Error ? l.message : String(l), this.notify(), l;
1268
+ (u) => u[this.keyField] === e ? a : u
1269
+ )), r.status = "failed", r.error = i instanceof Error ? i.message : String(i), this.notify(), i;
1216
1270
  }
1217
1271
  }
1218
1272
  /** Optimistically delete an item. */
1219
1273
  async remove(e) {
1220
- const t = this.items.findIndex(
1221
- (o) => o[this.keyField] === e
1222
- ), n = t >= 0 ? { ...this.items[t] } : void 0, r = {
1274
+ const t = this.items.findIndex((r) => r[this.keyField] === e), n = t >= 0 ? { ...this.items[t] } : void 0, o = {
1223
1275
  id: String(this.nextMutationId++),
1224
1276
  type: "delete",
1225
1277
  entityId: e,
@@ -1227,14 +1279,12 @@ class Be {
1227
1279
  timestamp: Date.now(),
1228
1280
  status: "pending"
1229
1281
  };
1230
- this.items = this.items.filter(
1231
- (o) => o[this.keyField] !== e
1232
- ), this.mutations.push(r), this.notify();
1282
+ this.items = this.items.filter((r) => r[this.keyField] !== e), this.mutations.push(o), this.notify();
1233
1283
  try {
1234
- const o = await this.adapter.remove(e);
1235
- return o.success ? r.status = "confirmed" : (n && this.items.splice(t, 0, n), r.status = "failed", r.error = o.error), this.notify(), o;
1236
- } catch (o) {
1237
- throw n && this.items.splice(t, 0, n), r.status = "failed", r.error = o instanceof Error ? o.message : String(o), this.notify(), o;
1284
+ const r = await this.adapter.remove(e);
1285
+ return r.success ? o.status = "confirmed" : (n && this.items.splice(t, 0, n), o.status = "failed", o.error = r.error), this.notify(), r;
1286
+ } catch (r) {
1287
+ throw n && this.items.splice(t, 0, n), o.status = "failed", o.error = r instanceof Error ? r.message : String(r), this.notify(), r;
1238
1288
  }
1239
1289
  }
1240
1290
  }
@@ -1250,13 +1300,13 @@ class ze {
1250
1300
  }
1251
1301
  /** A fetch-compatible function that queues mutations when offline. */
1252
1302
  fetch(e, t) {
1253
- var o, l;
1303
+ var r, i;
1254
1304
  const n = typeof e == "string" ? e : e instanceof URL ? e.toString() : e.url, a = ((t == null ? void 0 : t.method) ?? "GET").toUpperCase();
1255
1305
  if (this.isOnline())
1256
1306
  return this.baseFetch(e, t);
1257
1307
  if (a === "GET" || a === "HEAD")
1258
1308
  return Promise.reject(new Error("Offline: GET requests are not queued"));
1259
- const r = {
1309
+ const o = {
1260
1310
  id: `q_${this.nextId++}`,
1261
1311
  url: n,
1262
1312
  method: a,
@@ -1264,8 +1314,8 @@ class ze {
1264
1314
  body: typeof (t == null ? void 0 : t.body) == "string" ? t.body : void 0,
1265
1315
  timestamp: Date.now()
1266
1316
  };
1267
- return this.queue.push(r), this.persistQueue(), (l = (o = this.config).onQueued) == null || l.call(o, r), Promise.resolve(new Response(
1268
- JSON.stringify({ queued: !0, queueId: r.id }),
1317
+ return this.queue.push(o), this.persistQueue(), (i = (r = this.config).onQueued) == null || i.call(r, o), Promise.resolve(new Response(
1318
+ JSON.stringify({ queued: !0, queueId: o.id }),
1269
1319
  { status: 202, headers: { "Content-Type": "application/json" } }
1270
1320
  ));
1271
1321
  }
@@ -1295,22 +1345,22 @@ class ze {
1295
1345
  for (; this.queue.length > 0 && this.isOnline(); ) {
1296
1346
  const a = this.queue[0];
1297
1347
  try {
1298
- const r = await this.baseFetch(a.url, {
1348
+ const o = await this.baseFetch(a.url, {
1299
1349
  method: a.method,
1300
1350
  headers: a.headers,
1301
1351
  body: a.body
1302
1352
  });
1303
1353
  e.push({
1304
1354
  entry: a,
1305
- success: r.ok,
1306
- status: r.status,
1307
- error: r.ok ? void 0 : `HTTP ${r.status}`
1355
+ success: o.ok,
1356
+ status: o.status,
1357
+ error: o.ok ? void 0 : `HTTP ${o.status}`
1308
1358
  }), this.queue.shift();
1309
- } catch (r) {
1359
+ } catch (o) {
1310
1360
  e.push({
1311
1361
  entry: a,
1312
1362
  success: !1,
1313
- error: r instanceof Error ? r.message : String(r)
1363
+ error: o instanceof Error ? o.message : String(o)
1314
1364
  });
1315
1365
  break;
1316
1366
  }
@@ -1418,178 +1468,66 @@ const ye = [
1418
1468
  }
1419
1469
  ], be = [
1420
1470
  {
1421
- type: "NicePixelEditor",
1422
- label: "Pixel Editor",
1423
- category: "Graphics",
1424
- icon: "grid",
1425
- defaultProps: { width: 32, height: 32, palette: [] },
1471
+ type: "NiceLoginForm",
1472
+ label: "Login Form",
1473
+ category: "Auth",
1474
+ icon: "log-in",
1475
+ defaultProps: { showRemember: !0, showForgotPassword: !0 },
1426
1476
  propDescriptors: [
1427
- { name: "width", type: "number", label: "Canvas width (px)", min: 1, max: 256, defaultValue: 32 },
1428
- { name: "height", type: "number", label: "Canvas height (px)", min: 1, max: 256, defaultValue: 32 },
1429
- { name: "palette", type: "json", label: "Color palette (JSON array)" },
1430
- { name: "gridVisible", type: "boolean", label: "Show grid", defaultValue: !0 },
1431
- { name: "zoom", type: "number", label: "Zoom level", min: 1, max: 32, step: 1, defaultValue: 8 },
1432
- { name: "layers", type: "boolean", label: "Enable layers", defaultValue: !0 },
1433
- { name: "onion", type: "boolean", label: "Onion skin (animation)", defaultValue: !1 }
1477
+ { name: "title", type: "string", label: "Form title", defaultValue: "Sign In" },
1478
+ { name: "showRemember", type: "boolean", label: "Show 'Remember me'", defaultValue: !0 },
1479
+ { name: "showForgotPassword", type: "boolean", label: "Show 'Forgot password'", defaultValue: !0 },
1480
+ { name: "showRegisterLink", type: "boolean", label: "Show register link", defaultValue: !1 },
1481
+ { name: "showLogo", type: "boolean", label: "Show logo", defaultValue: !0 },
1482
+ { name: "logoUrl", type: "string", label: "Logo URL", group: "Branding" },
1483
+ { name: "primaryColor", type: "color", label: "Primary color", defaultValue: "#1976d2", group: "Branding" },
1484
+ { name: "variant", type: "variant", label: "Visual style", defaultValue: "card" }
1434
1485
  ]
1435
1486
  },
1436
1487
  {
1437
- type: "NiceVectorEditor",
1438
- label: "Vector Editor",
1439
- category: "Graphics",
1440
- icon: "pen-tool",
1441
- defaultProps: { width: 800, height: 600 },
1488
+ type: "NiceCaptcha",
1489
+ label: "Captcha",
1490
+ category: "Auth",
1491
+ icon: "shield",
1492
+ defaultProps: { provider: "recaptcha", size: "normal" },
1442
1493
  propDescriptors: [
1443
- { name: "width", type: "number", label: "Canvas width", min: 100, max: 4096, defaultValue: 800, group: "Layout" },
1444
- { name: "height", type: "number", label: "Canvas height", min: 100, max: 4096, defaultValue: 600, group: "Layout" },
1445
- { name: "showRulers", type: "boolean", label: "Show rulers", defaultValue: !0 },
1446
- { name: "snapToGrid", type: "boolean", label: "Snap to grid", defaultValue: !0 },
1447
- { name: "gridSize", type: "number", label: "Grid size", min: 1, max: 100, defaultValue: 10 },
1448
- { name: "fillColor", type: "color", label: "Default fill", defaultValue: "#ffffff" },
1449
- { name: "strokeColor", type: "color", label: "Default stroke", defaultValue: "#000000" },
1450
- { name: "strokeWidth", type: "number", label: "Stroke width", min: 0, max: 20, step: 0.5, defaultValue: 1 }
1494
+ { name: "provider", type: "select", label: "Provider", options: [
1495
+ { label: "reCAPTCHA v2", value: "recaptcha" },
1496
+ { label: "reCAPTCHA v3", value: "recaptcha-v3" },
1497
+ { label: "hCaptcha", value: "hcaptcha" },
1498
+ { label: "Turnstile", value: "turnstile" }
1499
+ ], defaultValue: "recaptcha" },
1500
+ { name: "siteKey", type: "string", label: "Site key" },
1501
+ { name: "size", type: "select", label: "Size", options: [
1502
+ { label: "Normal", value: "normal" },
1503
+ { label: "Compact", value: "compact" },
1504
+ { label: "Invisible", value: "invisible" }
1505
+ ], defaultValue: "normal" },
1506
+ { name: "theme", type: "select", label: "Theme", options: [
1507
+ { label: "Light", value: "light" },
1508
+ { label: "Dark", value: "dark" }
1509
+ ], defaultValue: "light" }
1451
1510
  ]
1452
1511
  },
1453
1512
  {
1454
- type: "NicePhotoEditor",
1455
- label: "Photo Editor",
1456
- category: "Graphics",
1457
- icon: "image",
1458
- defaultProps: { src: "" },
1513
+ type: "Nice2FASetup",
1514
+ label: "2FA Setup",
1515
+ category: "Auth",
1516
+ icon: "key",
1517
+ defaultProps: { method: "totp" },
1459
1518
  propDescriptors: [
1460
- { name: "src", type: "string", label: "Image source URL" },
1461
- { name: "crop", type: "boolean", label: "Allow crop", defaultValue: !0 },
1462
- { name: "rotate", type: "boolean", label: "Allow rotate", defaultValue: !0 },
1463
- { name: "filters", type: "boolean", label: "Show filters", defaultValue: !0 },
1464
- { name: "adjustments", type: "boolean", label: "Show adjustments", defaultValue: !0 },
1465
- { name: "text", type: "boolean", label: "Allow text overlay", defaultValue: !0 },
1466
- { name: "outputFormat", type: "select", label: "Output format", options: [
1467
- { label: "PNG", value: "png" },
1468
- { label: "JPEG", value: "jpeg" },
1469
- { label: "WebP", value: "webp" }
1470
- ], defaultValue: "png" },
1471
- { name: "maxWidth", type: "number", label: "Max output width", min: 100, max: 8192, group: "Output" }
1519
+ { name: "method", type: "select", label: "2FA method", options: [
1520
+ { label: "TOTP (Authenticator)", value: "totp" },
1521
+ { label: "SMS", value: "sms" },
1522
+ { label: "Email", value: "email" }
1523
+ ], defaultValue: "totp" },
1524
+ { name: "issuer", type: "string", label: "Issuer name", defaultValue: "OmniVerk" },
1525
+ { name: "showBackupCodes", type: "boolean", label: "Show backup codes", defaultValue: !0 },
1526
+ { name: "showQR", type: "boolean", label: "Show QR code", defaultValue: !0 },
1527
+ { name: "codeLength", type: "number", label: "Code length", min: 4, max: 8, defaultValue: 6 }
1472
1528
  ]
1473
1529
  }
1474
1530
  ], ge = [
1475
- {
1476
- type: "NiceModelEditor",
1477
- label: "3D Model Editor",
1478
- category: "3D",
1479
- icon: "cube",
1480
- defaultProps: { modelUrl: "" },
1481
- propDescriptors: [
1482
- { name: "modelUrl", type: "string", label: "Model URL (.glb / .gltf)" },
1483
- { name: "environmentMap", type: "select", label: "Environment", options: [
1484
- { label: "Studio", value: "studio" },
1485
- { label: "Outdoor", value: "outdoor" },
1486
- { label: "Warehouse", value: "warehouse" },
1487
- { label: "None", value: "none" }
1488
- ], defaultValue: "studio" },
1489
- { name: "showGrid", type: "boolean", label: "Show grid", defaultValue: !0 },
1490
- { name: "showAxes", type: "boolean", label: "Show axes", defaultValue: !0 },
1491
- { name: "enablePhysics", type: "boolean", label: "Enable physics", defaultValue: !1 },
1492
- { name: "wireframe", type: "boolean", label: "Wireframe mode", defaultValue: !1 },
1493
- { name: "backgroundColor", type: "color", label: "Background", defaultValue: "#1a1a2e" },
1494
- { name: "height", type: "size", label: "Viewport height", group: "Layout" }
1495
- ]
1496
- },
1497
- {
1498
- type: "NiceModelViewer",
1499
- label: "3D Model Viewer",
1500
- category: "3D",
1501
- icon: "eye",
1502
- defaultProps: { modelUrl: "", autoRotate: !0 },
1503
- propDescriptors: [
1504
- { name: "modelUrl", type: "string", label: "Model URL (.glb / .gltf)" },
1505
- { name: "autoRotate", type: "boolean", label: "Auto-rotate", defaultValue: !0 },
1506
- { name: "rotateSpeed", type: "number", label: "Rotate speed", min: 0.1, max: 10, step: 0.1, defaultValue: 1 },
1507
- { name: "zoom", type: "boolean", label: "Allow zoom", defaultValue: !0 },
1508
- { name: "pan", type: "boolean", label: "Allow pan", defaultValue: !0 },
1509
- { name: "environmentMap", type: "select", label: "Environment", options: [
1510
- { label: "Studio", value: "studio" },
1511
- { label: "Outdoor", value: "outdoor" },
1512
- { label: "Warehouse", value: "warehouse" },
1513
- { label: "None", value: "none" }
1514
- ], defaultValue: "studio" },
1515
- { name: "backgroundColor", type: "color", label: "Background", defaultValue: "#1a1a2e" },
1516
- { name: "showAnnotations", type: "boolean", label: "Show annotations", defaultValue: !1 },
1517
- { name: "height", type: "size", label: "Viewport height", group: "Layout" }
1518
- ]
1519
- }
1520
- ], we = [
1521
- {
1522
- type: "NiceLeaderboard",
1523
- label: "Leaderboard",
1524
- category: "Gamification",
1525
- icon: "trophy",
1526
- defaultProps: { dataSource: [], maxRows: 10 },
1527
- propDescriptors: [
1528
- { name: "dataSource", type: "json", label: "Data source (JSON)" },
1529
- { name: "maxRows", type: "number", label: "Max visible rows", min: 3, max: 100, defaultValue: 10 },
1530
- { name: "showRank", type: "boolean", label: "Show rank column", defaultValue: !0 },
1531
- { name: "showAvatar", type: "boolean", label: "Show avatar", defaultValue: !0 },
1532
- { name: "highlightCurrentUser", type: "boolean", label: "Highlight current user", defaultValue: !0 },
1533
- { name: "scoreField", type: "string", label: "Score field name", defaultValue: "score" },
1534
- { name: "nameField", type: "string", label: "Name field name", defaultValue: "name" },
1535
- { name: "variant", type: "variant", label: "Visual style", defaultValue: "default" }
1536
- ]
1537
- },
1538
- {
1539
- type: "NiceAchievement",
1540
- label: "Achievement Badge",
1541
- category: "Gamification",
1542
- icon: "award",
1543
- defaultProps: { title: "Achievement", unlocked: !1 },
1544
- propDescriptors: [
1545
- { name: "title", type: "string", label: "Achievement title", defaultValue: "Achievement" },
1546
- { name: "description", type: "string", label: "Description" },
1547
- { name: "icon", type: "string", label: "Icon URL" },
1548
- { name: "unlocked", type: "boolean", label: "Unlocked", defaultValue: !1 },
1549
- { name: "progress", type: "number", label: "Progress (0-100)", min: 0, max: 100, defaultValue: 0 },
1550
- { name: "rarity", type: "select", label: "Rarity", options: [
1551
- { label: "Common", value: "common" },
1552
- { label: "Rare", value: "rare" },
1553
- { label: "Epic", value: "epic" },
1554
- { label: "Legendary", value: "legendary" }
1555
- ], defaultValue: "common" },
1556
- { name: "size", type: "size", label: "Badge size", group: "Layout" }
1557
- ]
1558
- },
1559
- {
1560
- type: "NiceQuest",
1561
- label: "Quest Tracker",
1562
- category: "Gamification",
1563
- icon: "map",
1564
- defaultProps: { title: "Quest", steps: [] },
1565
- propDescriptors: [
1566
- { name: "title", type: "string", label: "Quest title", defaultValue: "Quest" },
1567
- { name: "description", type: "string", label: "Quest description" },
1568
- { name: "steps", type: "json", label: "Steps (JSON array of {title, completed})" },
1569
- { name: "reward", type: "string", label: "Reward description" },
1570
- { name: "rewardXP", type: "number", label: "Reward XP", min: 0, defaultValue: 100 },
1571
- { name: "showProgress", type: "boolean", label: "Show progress bar", defaultValue: !0 },
1572
- { name: "variant", type: "variant", label: "Visual style", defaultValue: "default" }
1573
- ]
1574
- },
1575
- {
1576
- type: "NiceXPBar",
1577
- label: "XP Progress Bar",
1578
- category: "Gamification",
1579
- icon: "zap",
1580
- defaultProps: { currentXP: 0, maxXP: 1e3, level: 1 },
1581
- propDescriptors: [
1582
- { name: "currentXP", type: "number", label: "Current XP", min: 0, defaultValue: 0 },
1583
- { name: "maxXP", type: "number", label: "Max XP (next level)", min: 1, defaultValue: 1e3 },
1584
- { name: "level", type: "number", label: "Current level", min: 1, defaultValue: 1 },
1585
- { name: "showLabel", type: "boolean", label: "Show XP label", defaultValue: !0 },
1586
- { name: "showLevel", type: "boolean", label: "Show level badge", defaultValue: !0 },
1587
- { name: "color", type: "color", label: "Bar color", defaultValue: "#4caf50" },
1588
- { name: "animated", type: "boolean", label: "Animate changes", defaultValue: !0 },
1589
- { name: "height", type: "size", label: "Bar height", group: "Layout" }
1590
- ]
1591
- }
1592
- ], ve = [
1593
1531
  {
1594
1532
  type: "NiceAddress",
1595
1533
  label: "Address Editor",
@@ -1688,68 +1626,134 @@ const ye = [
1688
1626
  { name: "readOnly", type: "boolean", label: "Read only", defaultValue: !1 }
1689
1627
  ]
1690
1628
  }
1691
- ], Se = [
1629
+ ], we = [
1692
1630
  {
1693
- type: "NiceLoginForm",
1694
- label: "Login Form",
1695
- category: "Auth",
1696
- icon: "log-in",
1697
- defaultProps: { showRemember: !0, showForgotPassword: !0 },
1631
+ type: "NiceLeaderboard",
1632
+ label: "Leaderboard",
1633
+ category: "Gamification",
1634
+ icon: "trophy",
1635
+ defaultProps: { dataSource: [], maxRows: 10 },
1698
1636
  propDescriptors: [
1699
- { name: "title", type: "string", label: "Form title", defaultValue: "Sign In" },
1700
- { name: "showRemember", type: "boolean", label: "Show 'Remember me'", defaultValue: !0 },
1701
- { name: "showForgotPassword", type: "boolean", label: "Show 'Forgot password'", defaultValue: !0 },
1702
- { name: "showRegisterLink", type: "boolean", label: "Show register link", defaultValue: !1 },
1703
- { name: "showLogo", type: "boolean", label: "Show logo", defaultValue: !0 },
1704
- { name: "logoUrl", type: "string", label: "Logo URL", group: "Branding" },
1705
- { name: "primaryColor", type: "color", label: "Primary color", defaultValue: "#1976d2", group: "Branding" },
1706
- { name: "variant", type: "variant", label: "Visual style", defaultValue: "card" }
1637
+ { name: "dataSource", type: "json", label: "Data source (JSON)" },
1638
+ { name: "maxRows", type: "number", label: "Max visible rows", min: 3, max: 100, defaultValue: 10 },
1639
+ { name: "showRank", type: "boolean", label: "Show rank column", defaultValue: !0 },
1640
+ { name: "showAvatar", type: "boolean", label: "Show avatar", defaultValue: !0 },
1641
+ { name: "highlightCurrentUser", type: "boolean", label: "Highlight current user", defaultValue: !0 },
1642
+ { name: "scoreField", type: "string", label: "Score field name", defaultValue: "score" },
1643
+ { name: "nameField", type: "string", label: "Name field name", defaultValue: "name" },
1644
+ { name: "variant", type: "variant", label: "Visual style", defaultValue: "default" }
1707
1645
  ]
1708
1646
  },
1709
1647
  {
1710
- type: "NiceCaptcha",
1711
- label: "Captcha",
1712
- category: "Auth",
1713
- icon: "shield",
1714
- defaultProps: { provider: "recaptcha", size: "normal" },
1648
+ type: "NiceAchievement",
1649
+ label: "Achievement Badge",
1650
+ category: "Gamification",
1651
+ icon: "award",
1652
+ defaultProps: { title: "Achievement", unlocked: !1 },
1715
1653
  propDescriptors: [
1716
- { name: "provider", type: "select", label: "Provider", options: [
1717
- { label: "reCAPTCHA v2", value: "recaptcha" },
1718
- { label: "reCAPTCHA v3", value: "recaptcha-v3" },
1719
- { label: "hCaptcha", value: "hcaptcha" },
1720
- { label: "Turnstile", value: "turnstile" }
1721
- ], defaultValue: "recaptcha" },
1722
- { name: "siteKey", type: "string", label: "Site key" },
1723
- { name: "size", type: "select", label: "Size", options: [
1724
- { label: "Normal", value: "normal" },
1725
- { label: "Compact", value: "compact" },
1726
- { label: "Invisible", value: "invisible" }
1727
- ], defaultValue: "normal" },
1728
- { name: "theme", type: "select", label: "Theme", options: [
1729
- { label: "Light", value: "light" },
1730
- { label: "Dark", value: "dark" }
1731
- ], defaultValue: "light" }
1654
+ { name: "title", type: "string", label: "Achievement title", defaultValue: "Achievement" },
1655
+ { name: "description", type: "string", label: "Description" },
1656
+ { name: "icon", type: "string", label: "Icon URL" },
1657
+ { name: "unlocked", type: "boolean", label: "Unlocked", defaultValue: !1 },
1658
+ { name: "progress", type: "number", label: "Progress (0-100)", min: 0, max: 100, defaultValue: 0 },
1659
+ { name: "rarity", type: "select", label: "Rarity", options: [
1660
+ { label: "Common", value: "common" },
1661
+ { label: "Rare", value: "rare" },
1662
+ { label: "Epic", value: "epic" },
1663
+ { label: "Legendary", value: "legendary" }
1664
+ ], defaultValue: "common" },
1665
+ { name: "size", type: "size", label: "Badge size", group: "Layout" }
1732
1666
  ]
1733
1667
  },
1734
1668
  {
1735
- type: "Nice2FASetup",
1736
- label: "2FA Setup",
1737
- category: "Auth",
1738
- icon: "key",
1739
- defaultProps: { method: "totp" },
1669
+ type: "NiceQuest",
1670
+ label: "Quest Tracker",
1671
+ category: "Gamification",
1672
+ icon: "map",
1673
+ defaultProps: { title: "Quest", steps: [] },
1740
1674
  propDescriptors: [
1741
- { name: "method", type: "select", label: "2FA method", options: [
1742
- { label: "TOTP (Authenticator)", value: "totp" },
1743
- { label: "SMS", value: "sms" },
1744
- { label: "Email", value: "email" }
1745
- ], defaultValue: "totp" },
1746
- { name: "issuer", type: "string", label: "Issuer name", defaultValue: "OmniVerk" },
1747
- { name: "showBackupCodes", type: "boolean", label: "Show backup codes", defaultValue: !0 },
1748
- { name: "showQR", type: "boolean", label: "Show QR code", defaultValue: !0 },
1749
- { name: "codeLength", type: "number", label: "Code length", min: 4, max: 8, defaultValue: 6 }
1675
+ { name: "title", type: "string", label: "Quest title", defaultValue: "Quest" },
1676
+ { name: "description", type: "string", label: "Quest description" },
1677
+ { name: "steps", type: "json", label: "Steps (JSON array of {title, completed})" },
1678
+ { name: "reward", type: "string", label: "Reward description" },
1679
+ { name: "rewardXP", type: "number", label: "Reward XP", min: 0, defaultValue: 100 },
1680
+ { name: "showProgress", type: "boolean", label: "Show progress bar", defaultValue: !0 },
1681
+ { name: "variant", type: "variant", label: "Visual style", defaultValue: "default" }
1682
+ ]
1683
+ },
1684
+ {
1685
+ type: "NiceXPBar",
1686
+ label: "XP Progress Bar",
1687
+ category: "Gamification",
1688
+ icon: "zap",
1689
+ defaultProps: { currentXP: 0, maxXP: 1e3, level: 1 },
1690
+ propDescriptors: [
1691
+ { name: "currentXP", type: "number", label: "Current XP", min: 0, defaultValue: 0 },
1692
+ { name: "maxXP", type: "number", label: "Max XP (next level)", min: 1, defaultValue: 1e3 },
1693
+ { name: "level", type: "number", label: "Current level", min: 1, defaultValue: 1 },
1694
+ { name: "showLabel", type: "boolean", label: "Show XP label", defaultValue: !0 },
1695
+ { name: "showLevel", type: "boolean", label: "Show level badge", defaultValue: !0 },
1696
+ { name: "color", type: "color", label: "Bar color", defaultValue: "#4caf50" },
1697
+ { name: "animated", type: "boolean", label: "Animate changes", defaultValue: !0 },
1698
+ { name: "height", type: "size", label: "Bar height", group: "Layout" }
1750
1699
  ]
1751
1700
  }
1752
- ], ke = [
1701
+ ], ve = [
1702
+ {
1703
+ type: "NicePixelEditor",
1704
+ label: "Pixel Editor",
1705
+ category: "Graphics",
1706
+ icon: "grid",
1707
+ defaultProps: { width: 32, height: 32, palette: [] },
1708
+ propDescriptors: [
1709
+ { name: "width", type: "number", label: "Canvas width (px)", min: 1, max: 256, defaultValue: 32 },
1710
+ { name: "height", type: "number", label: "Canvas height (px)", min: 1, max: 256, defaultValue: 32 },
1711
+ { name: "palette", type: "json", label: "Color palette (JSON array)" },
1712
+ { name: "gridVisible", type: "boolean", label: "Show grid", defaultValue: !0 },
1713
+ { name: "zoom", type: "number", label: "Zoom level", min: 1, max: 32, step: 1, defaultValue: 8 },
1714
+ { name: "layers", type: "boolean", label: "Enable layers", defaultValue: !0 },
1715
+ { name: "onion", type: "boolean", label: "Onion skin (animation)", defaultValue: !1 }
1716
+ ]
1717
+ },
1718
+ {
1719
+ type: "NiceVectorEditor",
1720
+ label: "Vector Editor",
1721
+ category: "Graphics",
1722
+ icon: "pen-tool",
1723
+ defaultProps: { width: 800, height: 600 },
1724
+ propDescriptors: [
1725
+ { name: "width", type: "number", label: "Canvas width", min: 100, max: 4096, defaultValue: 800, group: "Layout" },
1726
+ { name: "height", type: "number", label: "Canvas height", min: 100, max: 4096, defaultValue: 600, group: "Layout" },
1727
+ { name: "showRulers", type: "boolean", label: "Show rulers", defaultValue: !0 },
1728
+ { name: "snapToGrid", type: "boolean", label: "Snap to grid", defaultValue: !0 },
1729
+ { name: "gridSize", type: "number", label: "Grid size", min: 1, max: 100, defaultValue: 10 },
1730
+ { name: "fillColor", type: "color", label: "Default fill", defaultValue: "#ffffff" },
1731
+ { name: "strokeColor", type: "color", label: "Default stroke", defaultValue: "#000000" },
1732
+ { name: "strokeWidth", type: "number", label: "Stroke width", min: 0, max: 20, step: 0.5, defaultValue: 1 }
1733
+ ]
1734
+ },
1735
+ {
1736
+ type: "NicePhotoEditor",
1737
+ label: "Photo Editor",
1738
+ category: "Graphics",
1739
+ icon: "image",
1740
+ defaultProps: { src: "" },
1741
+ propDescriptors: [
1742
+ { name: "src", type: "string", label: "Image source URL" },
1743
+ { name: "crop", type: "boolean", label: "Allow crop", defaultValue: !0 },
1744
+ { name: "rotate", type: "boolean", label: "Allow rotate", defaultValue: !0 },
1745
+ { name: "filters", type: "boolean", label: "Show filters", defaultValue: !0 },
1746
+ { name: "adjustments", type: "boolean", label: "Show adjustments", defaultValue: !0 },
1747
+ { name: "text", type: "boolean", label: "Allow text overlay", defaultValue: !0 },
1748
+ { name: "outputFormat", type: "select", label: "Output format", options: [
1749
+ { label: "PNG", value: "png" },
1750
+ { label: "JPEG", value: "jpeg" },
1751
+ { label: "WebP", value: "webp" }
1752
+ ], defaultValue: "png" },
1753
+ { name: "maxWidth", type: "number", label: "Max output width", min: 100, max: 8192, group: "Output" }
1754
+ ]
1755
+ }
1756
+ ], Se = [
1753
1757
  {
1754
1758
  type: "NiceComments",
1755
1759
  label: "Comments",
@@ -1807,17 +1811,63 @@ const ye = [
1807
1811
  { name: "maxLength", type: "number", label: "Max content length", min: 0, defaultValue: 0 }
1808
1812
  ]
1809
1813
  }
1814
+ ], ke = [
1815
+ {
1816
+ type: "NiceModelEditor",
1817
+ label: "3D Model Editor",
1818
+ category: "3D",
1819
+ icon: "cube",
1820
+ defaultProps: { modelUrl: "" },
1821
+ propDescriptors: [
1822
+ { name: "modelUrl", type: "string", label: "Model URL (.glb / .gltf)" },
1823
+ { name: "environmentMap", type: "select", label: "Environment", options: [
1824
+ { label: "Studio", value: "studio" },
1825
+ { label: "Outdoor", value: "outdoor" },
1826
+ { label: "Warehouse", value: "warehouse" },
1827
+ { label: "None", value: "none" }
1828
+ ], defaultValue: "studio" },
1829
+ { name: "showGrid", type: "boolean", label: "Show grid", defaultValue: !0 },
1830
+ { name: "showAxes", type: "boolean", label: "Show axes", defaultValue: !0 },
1831
+ { name: "enablePhysics", type: "boolean", label: "Enable physics", defaultValue: !1 },
1832
+ { name: "wireframe", type: "boolean", label: "Wireframe mode", defaultValue: !1 },
1833
+ { name: "backgroundColor", type: "color", label: "Background", defaultValue: "#1a1a2e" },
1834
+ { name: "height", type: "size", label: "Viewport height", group: "Layout" }
1835
+ ]
1836
+ },
1837
+ {
1838
+ type: "NiceModelViewer",
1839
+ label: "3D Model Viewer",
1840
+ category: "3D",
1841
+ icon: "eye",
1842
+ defaultProps: { modelUrl: "", autoRotate: !0 },
1843
+ propDescriptors: [
1844
+ { name: "modelUrl", type: "string", label: "Model URL (.glb / .gltf)" },
1845
+ { name: "autoRotate", type: "boolean", label: "Auto-rotate", defaultValue: !0 },
1846
+ { name: "rotateSpeed", type: "number", label: "Rotate speed", min: 0.1, max: 10, step: 0.1, defaultValue: 1 },
1847
+ { name: "zoom", type: "boolean", label: "Allow zoom", defaultValue: !0 },
1848
+ { name: "pan", type: "boolean", label: "Allow pan", defaultValue: !0 },
1849
+ { name: "environmentMap", type: "select", label: "Environment", options: [
1850
+ { label: "Studio", value: "studio" },
1851
+ { label: "Outdoor", value: "outdoor" },
1852
+ { label: "Warehouse", value: "warehouse" },
1853
+ { label: "None", value: "none" }
1854
+ ], defaultValue: "studio" },
1855
+ { name: "backgroundColor", type: "color", label: "Background", defaultValue: "#1a1a2e" },
1856
+ { name: "showAnnotations", type: "boolean", label: "Show annotations", defaultValue: !1 },
1857
+ { name: "height", type: "size", label: "Viewport height", group: "Layout" }
1858
+ ]
1859
+ }
1810
1860
  ], je = [
1811
1861
  ...ye,
1812
- ...be,
1813
- ...ge,
1814
- ...we,
1815
1862
  ...ve,
1816
- ...Se,
1817
- ...ke
1863
+ ...ke,
1864
+ ...we,
1865
+ ...ge,
1866
+ ...be,
1867
+ ...Se
1818
1868
  ];
1819
- async function Te(u, e) {
1820
- const t = await fetch(u, {
1869
+ async function Te(c, e) {
1870
+ const t = await fetch(c, {
1821
1871
  ...e,
1822
1872
  headers: {
1823
1873
  "Content-Type": "application/json",
@@ -1839,15 +1889,15 @@ async function Te(u, e) {
1839
1889
  }
1840
1890
  return t.json();
1841
1891
  }
1842
- function Je(u) {
1892
+ function Je(c) {
1843
1893
  const {
1844
1894
  baseUrl: e,
1845
1895
  currency: t = "PLN",
1846
1896
  timeout: n = 3e4,
1847
1897
  fetcher: a = Te,
1848
- getAuthToken: r,
1849
- onError: o
1850
- } = u, [l, c] = E([]), [g, v] = E(null), [w, V] = E(null), [O, Q] = E(null), [N, X] = E(null), [q, Z] = E(null), [U, K] = E([]), [x, Y] = E([]), [ae, j] = E(null), [B, _] = E({
1898
+ getAuthToken: o,
1899
+ onError: r
1900
+ } = c, [i, u] = E([]), [g, v] = E(null), [w, V] = E(null), [O, Q] = E(null), [N, X] = E(null), [q, Z] = E(null), [U, K] = E([]), [x, Y] = E([]), [ae, j] = E(null), [B, _] = E({
1851
1901
  offers: !1,
1852
1902
  calculate: !1,
1853
1903
  compare: !1,
@@ -1859,15 +1909,15 @@ function Je(u) {
1859
1909
  }), L = oe(/* @__PURE__ */ new Map()), z = h(() => {
1860
1910
  const s = {
1861
1911
  "Content-Type": "application/json"
1862
- }, b = r == null ? void 0 : r();
1912
+ }, b = o == null ? void 0 : o();
1863
1913
  return b && (s.Authorization = `Bearer ${b}`), s;
1864
- }, [r]), p = h(
1914
+ }, [o]), p = h(
1865
1915
  async (s, b = {}, $) => {
1866
1916
  const ee = L.current.get(s);
1867
1917
  ee && ee.abort();
1868
- const i = new AbortController();
1869
- L.current.set(s, i);
1870
- const f = setTimeout(() => i.abort(), n);
1918
+ const l = new AbortController();
1919
+ L.current.set(s, l);
1920
+ const f = setTimeout(() => l.abort(), n);
1871
1921
  _((d) => ({ ...d, [$]: !0 })), j(null);
1872
1922
  try {
1873
1923
  const d = `${e}${s}`;
@@ -1877,7 +1927,7 @@ function Je(u) {
1877
1927
  ...z(),
1878
1928
  ...b.headers
1879
1929
  },
1880
- signal: i.signal
1930
+ signal: l.signal
1881
1931
  });
1882
1932
  } catch (d) {
1883
1933
  const A = {
@@ -1887,19 +1937,19 @@ function Je(u) {
1887
1937
  endpoint: s,
1888
1938
  statusCode: d.statusCode
1889
1939
  };
1890
- throw d.name !== "AbortError" && (j(A), o == null || o(A)), A;
1940
+ throw d.name !== "AbortError" && (j(A), r == null || r(A)), A;
1891
1941
  } finally {
1892
1942
  clearTimeout(f), L.current.delete(s), _((d) => ({ ...d, [$]: !1 }));
1893
1943
  }
1894
1944
  },
1895
- [e, n, a, z, o]
1945
+ [e, n, a, z, r]
1896
1946
  ), le = h(
1897
1947
  async (s) => {
1898
1948
  var f, d;
1899
1949
  const b = new URLSearchParams();
1900
1950
  s != null && s.loanType && b.set("loanType", s.loanType), s != null && s.minAmount && b.set("minAmount", String(s.minAmount)), s != null && s.maxAmount && b.set("maxAmount", String(s.maxAmount)), s != null && s.minTerm && b.set("minTerm", String(s.minTerm)), s != null && s.maxTerm && b.set("maxTerm", String(s.maxTerm)), s != null && s.maxApr && b.set("maxApr", String(s.maxApr)), (f = s == null ? void 0 : s.banks) != null && f.length && b.set("banks", s.banks.join(",")), (d = s == null ? void 0 : s.features) != null && d.length && b.set("features", s.features.join(",")), b.set("currency", (s == null ? void 0 : s.currency) || t);
1901
- const $ = b.toString(), ee = `/offers${$ ? `?${$}` : ""}`, i = await p(ee, { method: "GET" }, "offers");
1902
- return c(i), i;
1951
+ const $ = b.toString(), ee = `/offers${$ ? `?${$}` : ""}`, l = await p(ee, { method: "GET" }, "offers");
1952
+ return u(l), l;
1903
1953
  },
1904
1954
  [p, t]
1905
1955
  ), J = h((s) => {
@@ -1984,7 +2034,7 @@ function Je(u) {
1984
2034
  [p]
1985
2035
  ), S = h(
1986
2036
  async (s, b, $, ee) => {
1987
- const i = await p(
2037
+ const l = await p(
1988
2038
  "/calculations",
1989
2039
  {
1990
2040
  method: "POST",
@@ -1992,7 +2042,7 @@ function Je(u) {
1992
2042
  },
1993
2043
  "savedCalculations"
1994
2044
  );
1995
- return K((f) => [...f, i]), i;
2045
+ return K((f) => [...f, l]), l;
1996
2046
  },
1997
2047
  [p]
1998
2048
  ), I = h(
@@ -2040,7 +2090,7 @@ function Je(u) {
2040
2090
  }, [p]), m = h(() => {
2041
2091
  j(null);
2042
2092
  }, []), T = h(() => {
2043
- c([]), v(null), V(null), Q(null), X(null), Z(null), K([]), Y([]), j(null), _({
2093
+ u([]), v(null), V(null), Q(null), X(null), Z(null), K([]), Y([]), j(null), _({
2044
2094
  offers: !1,
2045
2095
  calculate: !1,
2046
2096
  compare: !1,
@@ -2055,7 +2105,7 @@ function Je(u) {
2055
2105
  L.current.forEach((s) => s.abort()), L.current.clear();
2056
2106
  }, []), {
2057
2107
  // State
2058
- offers: l,
2108
+ offers: i,
2059
2109
  selectedOffer: g,
2060
2110
  latestCalculation: w,
2061
2111
  latestComparison: O,
@@ -2098,20 +2148,20 @@ class Ge {
2098
2148
  this.baseUrl = e.baseUrl, this.currency = e.currency || "PLN", this.timeout = e.timeout || 3e4, this.getAuthToken = e.getAuthToken;
2099
2149
  }
2100
2150
  async request(e, t = {}) {
2101
- var l;
2102
- const n = new AbortController(), a = setTimeout(() => n.abort(), this.timeout), r = {
2151
+ var i;
2152
+ const n = new AbortController(), a = setTimeout(() => n.abort(), this.timeout), o = {
2103
2153
  "Content-Type": "application/json"
2104
- }, o = (l = this.getAuthToken) == null ? void 0 : l.call(this);
2105
- o && (r.Authorization = `Bearer ${o}`);
2154
+ }, r = (i = this.getAuthToken) == null ? void 0 : i.call(this);
2155
+ r && (o.Authorization = `Bearer ${r}`);
2106
2156
  try {
2107
- const c = await fetch(`${this.baseUrl}${e}`, {
2157
+ const u = await fetch(`${this.baseUrl}${e}`, {
2108
2158
  ...t,
2109
- headers: { ...r, ...t.headers },
2159
+ headers: { ...o, ...t.headers },
2110
2160
  signal: n.signal
2111
2161
  });
2112
- if (!c.ok)
2113
- throw new Error(`HTTP ${c.status}: ${c.statusText}`);
2114
- return c.json();
2162
+ if (!u.ok)
2163
+ throw new Error(`HTTP ${u.status}: ${u.statusText}`);
2164
+ return u.json();
2115
2165
  } finally {
2116
2166
  clearTimeout(a);
2117
2167
  }
@@ -2174,20 +2224,20 @@ export {
2174
2224
  je as allControlRegistries,
2175
2225
  Ae as applyBatchChanges,
2176
2226
  ye as audioControlRegistry,
2177
- Se as authControlRegistry,
2178
- ve as businessControlRegistry,
2227
+ be as authControlRegistry,
2228
+ ge as businessControlRegistry,
2179
2229
  Ue as createMiddlewarePipeline,
2180
2230
  Ve as createSignalRAdapter,
2181
2231
  Pe as createSignalRDataOperations,
2182
2232
  Oe as formatPresenceStatus,
2183
2233
  we as gamificationControlRegistry,
2184
2234
  me as generateUserColor,
2185
- be as graphicControlRegistry,
2235
+ ve as graphicControlRegistry,
2186
2236
  Ie as headerMiddleware,
2187
2237
  Fe as loggingMiddleware,
2188
2238
  Me as retryMiddleware,
2189
- ke as socialControlRegistry,
2190
- ge as threeControlRegistry,
2239
+ Se as socialControlRegistry,
2240
+ ke as threeControlRegistry,
2191
2241
  Le as useCollaborativeDataGrid,
2192
2242
  pe as useEntityPresence,
2193
2243
  Je as useLoanApi,