@ram_28/kf-ai-sdk 1.0.12 → 1.0.13

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/kanban.mjs CHANGED
@@ -1,44 +1,410 @@
1
- import { useState as G, useRef as k, useCallback as h, useEffect as rt, useMemo as ot, createContext as qt, useContext as Qt } from "react";
2
- import { useQueryClient as At, useQueries as Tt, keepPreviousData as kt, useQuery as Pt, useMutation as j } from "@tanstack/react-query";
3
- import { a as F } from "./client-CfvLiGfP.js";
4
- import { u as Et } from "./useFilter-CXFqEHyI.js";
5
- const ct = 50, dt = 5, ut = 5;
6
- function Ft({
7
- onCardMove: i,
8
- onError: c,
9
- columns: d,
10
- announceMove: a
1
+ var $t = (a) => {
2
+ throw TypeError(a);
3
+ };
4
+ var St = (a, e, s) => e.has(a) || $t("Cannot " + s);
5
+ var l = (a, e, s) => (St(a, e, "read from private field"), s ? s.call(a) : e.get(a)), R = (a, e, s) => e.has(a) ? $t("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(a) : e.set(a, s), v = (a, e, s, t) => (St(a, e, "write to private field"), t ? t.call(a, s) : e.set(a, s), s), F = (a, e, s) => (St(a, e, "access private method"), s);
6
+ import * as B from "react";
7
+ import { useState as yt, useRef as G, useCallback as _, useEffect as _t, useMemo as Ht, createContext as ge, useContext as fe } from "react";
8
+ import { S as Vt, s as Gt, h as It, n as ct, r as pe, Q as Wt, a as kt, b as ye, c as me, e as be, d as Ce, f as De, g as Zt, i as Ut, j as jt, w as we, k as Oe, l as Se, m as _e, u as Qe } from "./useQuery-KpZFg80c.js";
9
+ import { a as M } from "./client-CfvLiGfP.js";
10
+ import { u as Ee } from "./useFilter-CXFqEHyI.js";
11
+ function ve() {
12
+ return {
13
+ context: void 0,
14
+ data: void 0,
15
+ error: null,
16
+ failureCount: 0,
17
+ failureReason: null,
18
+ isPaused: !1,
19
+ status: "idle",
20
+ variables: void 0,
21
+ submittedAt: 0
22
+ };
23
+ }
24
+ var z, W, $, N, Y, mt, Qt, Yt, Ke = (Yt = class extends Vt {
25
+ constructor(e, s) {
26
+ super();
27
+ R(this, Y);
28
+ R(this, z);
29
+ R(this, W);
30
+ R(this, $);
31
+ R(this, N);
32
+ v(this, z, e), this.setOptions(s), this.bindMethods(), F(this, Y, mt).call(this);
33
+ }
34
+ bindMethods() {
35
+ this.mutate = this.mutate.bind(this), this.reset = this.reset.bind(this);
36
+ }
37
+ setOptions(e) {
38
+ var t;
39
+ const s = this.options;
40
+ this.options = l(this, z).defaultMutationOptions(e), Gt(this.options, s) || l(this, z).getMutationCache().notify({
41
+ type: "observerOptionsUpdated",
42
+ mutation: l(this, $),
43
+ observer: this
44
+ }), s != null && s.mutationKey && this.options.mutationKey && It(s.mutationKey) !== It(this.options.mutationKey) ? this.reset() : ((t = l(this, $)) == null ? void 0 : t.state.status) === "pending" && l(this, $).setOptions(this.options);
45
+ }
46
+ onUnsubscribe() {
47
+ var e;
48
+ this.hasListeners() || (e = l(this, $)) == null || e.removeObserver(this);
49
+ }
50
+ onMutationUpdate(e) {
51
+ F(this, Y, mt).call(this), F(this, Y, Qt).call(this, e);
52
+ }
53
+ getCurrentResult() {
54
+ return l(this, W);
55
+ }
56
+ reset() {
57
+ var e;
58
+ (e = l(this, $)) == null || e.removeObserver(this), v(this, $, void 0), F(this, Y, mt).call(this), F(this, Y, Qt).call(this);
59
+ }
60
+ mutate(e, s) {
61
+ var t;
62
+ return v(this, N, s), (t = l(this, $)) == null || t.removeObserver(this), v(this, $, l(this, z).getMutationCache().build(l(this, z), this.options)), l(this, $).addObserver(this), l(this, $).execute(e);
63
+ }
64
+ }, z = new WeakMap(), W = new WeakMap(), $ = new WeakMap(), N = new WeakMap(), Y = new WeakSet(), mt = function() {
65
+ var s;
66
+ const e = ((s = l(this, $)) == null ? void 0 : s.state) ?? ve();
67
+ v(this, W, {
68
+ ...e,
69
+ isPending: e.status === "pending",
70
+ isSuccess: e.status === "success",
71
+ isError: e.status === "error",
72
+ isIdle: e.status === "idle",
73
+ mutate: this.mutate,
74
+ reset: this.reset
75
+ });
76
+ }, Qt = function(e) {
77
+ ct.batch(() => {
78
+ var s, t, i, d, f, y, Q, E;
79
+ if (l(this, N) && this.hasListeners()) {
80
+ const C = l(this, W).variables, O = l(this, W).context, K = {
81
+ client: l(this, z),
82
+ meta: this.options.meta,
83
+ mutationKey: this.options.mutationKey
84
+ };
85
+ if ((e == null ? void 0 : e.type) === "success") {
86
+ try {
87
+ (t = (s = l(this, N)).onSuccess) == null || t.call(
88
+ s,
89
+ e.data,
90
+ C,
91
+ O,
92
+ K
93
+ );
94
+ } catch (q) {
95
+ Promise.reject(q);
96
+ }
97
+ try {
98
+ (d = (i = l(this, N)).onSettled) == null || d.call(
99
+ i,
100
+ e.data,
101
+ null,
102
+ C,
103
+ O,
104
+ K
105
+ );
106
+ } catch (q) {
107
+ Promise.reject(q);
108
+ }
109
+ } else if ((e == null ? void 0 : e.type) === "error") {
110
+ try {
111
+ (y = (f = l(this, N)).onError) == null || y.call(
112
+ f,
113
+ e.error,
114
+ C,
115
+ O,
116
+ K
117
+ );
118
+ } catch (q) {
119
+ Promise.reject(q);
120
+ }
121
+ try {
122
+ (E = (Q = l(this, N)).onSettled) == null || E.call(
123
+ Q,
124
+ void 0,
125
+ e.error,
126
+ C,
127
+ O,
128
+ K
129
+ );
130
+ } catch (q) {
131
+ Promise.reject(q);
132
+ }
133
+ }
134
+ }
135
+ this.listeners.forEach((C) => {
136
+ C(l(this, W));
137
+ });
138
+ });
139
+ }, Yt);
140
+ function Bt(a, e) {
141
+ const s = new Set(e);
142
+ return a.filter((t) => !s.has(t));
143
+ }
144
+ function qe(a, e, s) {
145
+ const t = a.slice(0);
146
+ return t[e] = s, t;
147
+ }
148
+ var tt, H, it, at, I, Z, lt, dt, ht, T, Et, vt, Kt, qt, Pt, Jt, Pe = (Jt = class extends Vt {
149
+ constructor(e, s, t) {
150
+ super();
151
+ R(this, T);
152
+ R(this, tt);
153
+ R(this, H);
154
+ R(this, it);
155
+ R(this, at);
156
+ R(this, I);
157
+ R(this, Z);
158
+ R(this, lt);
159
+ R(this, dt);
160
+ R(this, ht, []);
161
+ v(this, tt, e), v(this, at, t), v(this, it, []), v(this, I, []), v(this, H, []), this.setQueries(s);
162
+ }
163
+ onSubscribe() {
164
+ this.listeners.size === 1 && l(this, I).forEach((e) => {
165
+ e.subscribe((s) => {
166
+ F(this, T, qt).call(this, e, s);
167
+ });
168
+ });
169
+ }
170
+ onUnsubscribe() {
171
+ this.listeners.size || this.destroy();
172
+ }
173
+ destroy() {
174
+ this.listeners = /* @__PURE__ */ new Set(), l(this, I).forEach((e) => {
175
+ e.destroy();
176
+ });
177
+ }
178
+ setQueries(e, s) {
179
+ if (v(this, it, e), v(this, at, s), process.env.NODE_ENV !== "production") {
180
+ const t = e.map(
181
+ (i) => l(this, tt).defaultQueryOptions(i).queryHash
182
+ );
183
+ new Set(t).size !== t.length && console.warn(
184
+ "[QueriesObserver]: Duplicate Queries found. This might result in unexpected behavior."
185
+ );
186
+ }
187
+ ct.batch(() => {
188
+ const t = l(this, I), i = F(this, T, Kt).call(this, l(this, it));
189
+ i.forEach(
190
+ (O) => O.observer.setOptions(O.defaultedQueryOptions)
191
+ );
192
+ const d = i.map((O) => O.observer), f = d.map(
193
+ (O) => O.getCurrentResult()
194
+ ), y = t.length !== d.length, Q = d.some(
195
+ (O, K) => O !== t[K]
196
+ ), E = y || Q, C = E ? !0 : f.some((O, K) => {
197
+ const q = l(this, H)[K];
198
+ return !q || !Gt(O, q);
199
+ });
200
+ !E && !C || (E && (v(this, ht, i), v(this, I, d)), v(this, H, f), this.hasListeners() && (E && (Bt(t, d).forEach((O) => {
201
+ O.destroy();
202
+ }), Bt(d, t).forEach((O) => {
203
+ O.subscribe((K) => {
204
+ F(this, T, qt).call(this, O, K);
205
+ });
206
+ })), F(this, T, Pt).call(this)));
207
+ });
208
+ }
209
+ getCurrentResult() {
210
+ return l(this, H);
211
+ }
212
+ getQueries() {
213
+ return l(this, I).map((e) => e.getCurrentQuery());
214
+ }
215
+ getObservers() {
216
+ return l(this, I);
217
+ }
218
+ getOptimisticResult(e, s) {
219
+ const t = F(this, T, Kt).call(this, e), i = t.map(
220
+ (d) => d.observer.getOptimisticResult(d.defaultedQueryOptions)
221
+ );
222
+ return [
223
+ i,
224
+ (d) => F(this, T, vt).call(this, d ?? i, s),
225
+ () => F(this, T, Et).call(this, i, t)
226
+ ];
227
+ }
228
+ }, tt = new WeakMap(), H = new WeakMap(), it = new WeakMap(), at = new WeakMap(), I = new WeakMap(), Z = new WeakMap(), lt = new WeakMap(), dt = new WeakMap(), ht = new WeakMap(), T = new WeakSet(), Et = function(e, s) {
229
+ return s.map((t, i) => {
230
+ const d = e[i];
231
+ return t.defaultedQueryOptions.notifyOnChangeProps ? d : t.observer.trackResult(d, (f) => {
232
+ s.forEach((y) => {
233
+ y.observer.trackProp(f);
234
+ });
235
+ });
236
+ });
237
+ }, vt = function(e, s) {
238
+ return s ? ((!l(this, Z) || l(this, H) !== l(this, dt) || s !== l(this, lt)) && (v(this, lt, s), v(this, dt, l(this, H)), v(this, Z, pe(
239
+ l(this, Z),
240
+ s(e)
241
+ ))), l(this, Z)) : e;
242
+ }, Kt = function(e) {
243
+ const s = /* @__PURE__ */ new Map();
244
+ l(this, I).forEach((i) => {
245
+ const d = i.options.queryHash;
246
+ if (!d) return;
247
+ const f = s.get(d);
248
+ f ? f.push(i) : s.set(d, [i]);
249
+ });
250
+ const t = [];
251
+ return e.forEach((i) => {
252
+ var Q;
253
+ const d = l(this, tt).defaultQueryOptions(i), y = ((Q = s.get(d.queryHash)) == null ? void 0 : Q.shift()) ?? new Wt(l(this, tt), d);
254
+ t.push({
255
+ defaultedQueryOptions: d,
256
+ observer: y
257
+ });
258
+ }), t;
259
+ }, qt = function(e, s) {
260
+ const t = l(this, I).indexOf(e);
261
+ t !== -1 && (v(this, H, qe(l(this, H), t, s)), F(this, T, Pt).call(this));
262
+ }, Pt = function() {
263
+ var e;
264
+ if (this.hasListeners()) {
265
+ const s = l(this, Z), t = F(this, T, Et).call(this, l(this, H), l(this, ht)), i = F(this, T, vt).call(this, t, (e = l(this, at)) == null ? void 0 : e.combine);
266
+ s !== i && ct.batch(() => {
267
+ this.listeners.forEach((d) => {
268
+ d(l(this, H));
269
+ });
270
+ });
271
+ }
272
+ }, Jt);
273
+ function ke({
274
+ queries: a,
275
+ ...e
276
+ }, s) {
277
+ const t = kt(), i = ye(), d = me(), f = B.useMemo(
278
+ () => a.map((g) => {
279
+ const P = t.defaultQueryOptions(
280
+ g
281
+ );
282
+ return P._optimisticResults = i ? "isRestoring" : "optimistic", P;
283
+ }),
284
+ [a, t, i]
285
+ );
286
+ f.forEach((g) => {
287
+ be(g);
288
+ const P = t.getQueryCache().get(g.queryHash);
289
+ Ce(g, d, P);
290
+ }), De(d);
291
+ const [y] = B.useState(
292
+ () => new Pe(
293
+ t,
294
+ f,
295
+ e
296
+ )
297
+ ), [Q, E, C] = y.getOptimisticResult(
298
+ f,
299
+ e.combine
300
+ ), O = !i && e.subscribed !== !1;
301
+ B.useSyncExternalStore(
302
+ B.useCallback(
303
+ (g) => O ? y.subscribe(ct.batchCalls(g)) : Zt,
304
+ [y, O]
305
+ ),
306
+ () => y.getCurrentResult(),
307
+ () => y.getCurrentResult()
308
+ ), B.useEffect(() => {
309
+ y.setQueries(
310
+ f,
311
+ e
312
+ );
313
+ }, [f, e, y]);
314
+ const q = Q.some(
315
+ (g, P) => Ut(f[P], g)
316
+ ) ? Q.flatMap((g, P) => {
317
+ const k = f[P];
318
+ if (k) {
319
+ const X = new Wt(t, k);
320
+ if (Ut(k, g))
321
+ return jt(k, X, d);
322
+ we(g, i) && jt(k, X, d);
323
+ }
324
+ return [];
325
+ }) : [];
326
+ if (q.length > 0)
327
+ throw Promise.all(q);
328
+ const J = Q.find(
329
+ (g, P) => {
330
+ const k = f[P];
331
+ return k && Oe({
332
+ result: g,
333
+ errorResetBoundary: d,
334
+ throwOnError: k.throwOnError,
335
+ query: t.getQueryCache().get(k.queryHash),
336
+ suspense: k.suspense
337
+ });
338
+ }
339
+ );
340
+ if (J != null && J.error)
341
+ throw J.error;
342
+ return E(C());
343
+ }
344
+ function ut(a, e) {
345
+ const s = kt(), [t] = B.useState(
346
+ () => new Ke(
347
+ s,
348
+ a
349
+ )
350
+ );
351
+ B.useEffect(() => {
352
+ t.setOptions(a);
353
+ }, [t, a]);
354
+ const i = B.useSyncExternalStore(
355
+ B.useCallback(
356
+ (f) => t.subscribe(ct.batchCalls(f)),
357
+ [t]
358
+ ),
359
+ () => t.getCurrentResult(),
360
+ () => t.getCurrentResult()
361
+ ), d = B.useCallback(
362
+ (f, y) => {
363
+ t.mutate(f, y).catch(Zt);
364
+ },
365
+ [t]
366
+ );
367
+ if (i.error && Se(t.options.throwOnError, [i.error]))
368
+ throw i.error;
369
+ return { ...i, mutate: d, mutateAsync: i.mutate };
370
+ }
371
+ const Xt = 50, zt = 5, Nt = 5;
372
+ function Ae({
373
+ onCardMove: a,
374
+ onError: e,
375
+ columns: s,
376
+ announceMove: t
11
377
  }) {
12
- const [s, O] = G({
378
+ const [i, d] = yt({
13
379
  isDragging: !1,
14
380
  draggedCard: null,
15
381
  dragOverColumn: null,
16
382
  dragOverPosition: null,
17
383
  dragSourceColumn: null
18
- }), q = k(null), _ = k(null), K = k(null), b = h(() => {
19
- O({
384
+ }), f = G(null), y = G(null), Q = G(null), E = _(() => {
385
+ d({
20
386
  isDragging: !1,
21
387
  draggedCard: null,
22
388
  dragOverColumn: null,
23
389
  dragOverPosition: null,
24
390
  dragSourceColumn: null
25
- }), _.current && (clearTimeout(_.current), _.current = null);
26
- }, []), D = h((u) => d.find((o) => o._id === u) || null, [d]), Y = h((u) => {
27
- for (const o of d) {
28
- const g = o.cards.find((m) => m._id === u);
29
- if (g)
30
- return { card: g, column: o };
391
+ }), y.current && (clearTimeout(y.current), y.current = null);
392
+ }, []), C = _((h) => s.find((c) => c._id === h) || null, [s]), O = _((h) => {
393
+ for (const c of s) {
394
+ const m = c.cards.find((D) => D._id === h);
395
+ if (m)
396
+ return { card: m, column: c };
31
397
  }
32
398
  return null;
33
- }, [d]), P = h((u, o) => {
34
- var g, m;
399
+ }, [s]), K = _((h, c) => {
400
+ var m, D;
35
401
  try {
36
- const l = u.target, y = D(o.columnId);
37
- if (!y)
402
+ const p = h.target, b = C(c.columnId);
403
+ if (!b)
38
404
  throw new Error("Source column not found");
39
- (g = u.dataTransfer) == null || g.setData("text/plain", o._id), (m = u.dataTransfer) == null || m.setData("application/json", JSON.stringify(o));
40
- const S = l.cloneNode(!0);
41
- S.style.cssText = `
405
+ (m = h.dataTransfer) == null || m.setData("text/plain", c._id), (D = h.dataTransfer) == null || D.setData("application/json", JSON.stringify(c));
406
+ const L = p.cloneNode(!0);
407
+ L.style.cssText = `
42
408
  position: fixed;
43
409
  top: -1000px;
44
410
  left: -1000px;
@@ -50,645 +416,645 @@ function Ft({
50
416
  max-width: 300px;
51
417
  background: white;
52
418
  border-radius: 8px;
53
- `, document.body.appendChild(S), q.current = S, u.dataTransfer && u.dataTransfer.setDragImage(S, u.offsetX || 50, u.offsetY || 20), O({
419
+ `, document.body.appendChild(L), f.current = L, h.dataTransfer && h.dataTransfer.setDragImage(L, h.offsetX || 50, h.offsetY || 20), d({
54
420
  isDragging: !0,
55
- draggedCard: o,
421
+ draggedCard: c,
56
422
  dragOverColumn: null,
57
423
  dragOverPosition: null,
58
- dragSourceColumn: y._id
59
- }), a == null || a(o, y.title, "being moved");
60
- } catch (l) {
61
- c == null || c(l instanceof Error ? l : new Error("Drag start failed")), b();
424
+ dragSourceColumn: b._id
425
+ }), t == null || t(c, b.title, "being moved");
426
+ } catch (p) {
427
+ e == null || e(p instanceof Error ? p : new Error("Drag start failed")), E();
62
428
  }
63
- }, [D, c, b, a]), z = h((u, o) => {
64
- if (u.preventDefault(), !s.isDragging || !s.draggedCard) return;
65
- const g = o ? D(o) : null;
66
- O((m) => ({
67
- ...m,
68
- dragOverColumn: (g == null ? void 0 : g._id) || null,
429
+ }, [C, e, E, t]), q = _((h, c) => {
430
+ if (h.preventDefault(), !i.isDragging || !i.draggedCard) return;
431
+ const m = c ? C(c) : null;
432
+ d((D) => ({
433
+ ...D,
434
+ dragOverColumn: (m == null ? void 0 : m._id) || null,
69
435
  dragOverPosition: null
70
436
  // Will be calculated based on mouse position
71
- })), $(u);
72
- }, [s.isDragging, s.draggedCard, D]), V = h((u, o) => {
73
- if (u.preventDefault(), !(!s.isDragging || !s.draggedCard))
437
+ })), P(h);
438
+ }, [i.isDragging, i.draggedCard, C]), J = _((h, c) => {
439
+ if (h.preventDefault(), !(!i.isDragging || !i.draggedCard))
74
440
  try {
75
- const g = s.draggedCard, m = s.dragSourceColumn, l = D(o), y = D(m);
76
- if (!l || !y)
441
+ const m = i.draggedCard, D = i.dragSourceColumn, p = C(c), b = C(D);
442
+ if (!p || !b)
77
443
  throw new Error("Target or source column not found");
78
- if (m === o) {
79
- b();
444
+ if (D === c) {
445
+ E();
80
446
  return;
81
447
  }
82
- if (l.limit && l.cards.length >= l.limit)
83
- throw new Error(`Column "${l.title}" has reached its limit of ${l.limit} cards`);
84
- i == null || i(g, m, o), a == null || a(g, y.title, l.title);
85
- } catch (g) {
86
- c == null || c(g instanceof Error ? g : new Error("Drop failed"));
448
+ if (p.limit && p.cards.length >= p.limit)
449
+ throw new Error(`Column "${p.title}" has reached its limit of ${p.limit} cards`);
450
+ a == null || a(m, D, c), t == null || t(m, b.title, p.title);
451
+ } catch (m) {
452
+ e == null || e(m instanceof Error ? m : new Error("Drop failed"));
87
453
  } finally {
88
- b();
454
+ E();
89
455
  }
90
- }, [s, D, i, c, b, a]), C = h(() => {
91
- q.current && (document.body.removeChild(q.current), q.current = null), b();
92
- }, [b]), $ = h((u) => {
93
- const o = u.target.closest(".kanban-container");
94
- if (!o) return;
95
- const g = o.getBoundingClientRect(), m = u.clientX - g.left, l = g.width;
96
- let y = 0;
97
- if (m < ct ? y = -dt : m > l - ct && (y = dt), y !== 0) {
98
- _.current && clearTimeout(_.current);
99
- const S = () => {
100
- o.scrollLeft += y, _.current = setTimeout(S, 16);
456
+ }, [i, C, a, e, E, t]), g = _(() => {
457
+ f.current && (document.body.removeChild(f.current), f.current = null), E();
458
+ }, [E]), P = _((h) => {
459
+ const c = h.target.closest(".kanban-container");
460
+ if (!c) return;
461
+ const m = c.getBoundingClientRect(), D = h.clientX - m.left, p = m.width;
462
+ let b = 0;
463
+ if (D < Xt ? b = -zt : D > p - Xt && (b = zt), b !== 0) {
464
+ y.current && clearTimeout(y.current);
465
+ const L = () => {
466
+ c.scrollLeft += b, y.current = setTimeout(L, 16);
101
467
  };
102
- _.current = setTimeout(S, 100);
468
+ y.current = setTimeout(L, 100);
103
469
  } else
104
- _.current && (clearTimeout(_.current), _.current = null);
105
- }, []), L = h((u, o) => {
106
- if (!["ArrowLeft", "ArrowRight", "ArrowUp", "ArrowDown", "Enter", "Space", "Escape"].includes(u.key))
470
+ y.current && (clearTimeout(y.current), y.current = null);
471
+ }, []), k = _((h, c) => {
472
+ if (!["ArrowLeft", "ArrowRight", "ArrowUp", "ArrowDown", "Enter", "Space", "Escape"].includes(h.key))
107
473
  return;
108
- u.preventDefault();
109
- const g = Y(o._id);
110
- if (!g) return;
111
- const { column: m } = g, l = d.findIndex((y) => y._id === m._id);
474
+ h.preventDefault();
475
+ const m = O(c._id);
476
+ if (!m) return;
477
+ const { column: D } = m, p = s.findIndex((b) => b._id === D._id);
112
478
  try {
113
- switch (u.key) {
479
+ switch (h.key) {
114
480
  case "ArrowLeft":
115
- if (l > 0) {
116
- const y = d[l - 1];
117
- i == null || i(o, m._id, y._id), a == null || a(o, m.title, y.title);
481
+ if (p > 0) {
482
+ const b = s[p - 1];
483
+ a == null || a(c, D._id, b._id), t == null || t(c, D.title, b.title);
118
484
  }
119
485
  break;
120
486
  case "ArrowRight":
121
- if (l < d.length - 1) {
122
- const y = d[l + 1];
123
- i == null || i(o, m._id, y._id), a == null || a(o, m.title, y.title);
487
+ if (p < s.length - 1) {
488
+ const b = s[p + 1];
489
+ a == null || a(c, D._id, b._id), t == null || t(c, D.title, b.title);
124
490
  }
125
491
  break;
126
492
  case "ArrowUp":
127
- a == null || a(o, "current position", "position above");
493
+ t == null || t(c, "current position", "position above");
128
494
  break;
129
495
  case "ArrowDown":
130
- a == null || a(o, "current position", "position below");
496
+ t == null || t(c, "current position", "position below");
131
497
  break;
132
498
  case "Enter":
133
499
  case "Space":
134
- a == null || a(o, m.title, "drag mode");
500
+ t == null || t(c, D.title, "drag mode");
135
501
  break;
136
502
  case "Escape":
137
- a == null || a(o, "drag mode", "cancelled");
503
+ t == null || t(c, "drag mode", "cancelled");
138
504
  break;
139
505
  }
140
- } catch (y) {
141
- c == null || c(y instanceof Error ? y : new Error("Keyboard navigation failed"));
506
+ } catch (b) {
507
+ e == null || e(b instanceof Error ? b : new Error("Keyboard navigation failed"));
142
508
  }
143
- }, [Y, d, i, c, a]), I = h((u, o) => {
144
- const g = u.touches[0];
145
- K.current = {
146
- x: g.clientX,
147
- y: g.clientY,
148
- card: o
509
+ }, [O, s, a, e, t]), X = _((h, c) => {
510
+ const m = h.touches[0];
511
+ Q.current = {
512
+ x: m.clientX,
513
+ y: m.clientY,
514
+ card: c
149
515
  };
150
- }, []), H = h((u) => {
151
- if (!K.current) return;
152
- const o = u.touches[0], g = Math.abs(o.clientX - K.current.x), m = Math.abs(o.clientY - K.current.y);
153
- if (g > ut || m > ut) {
154
- const l = K.current.card, y = D(l.columnId);
155
- if (!y) return;
156
- O({
516
+ }, []), et = _((h) => {
517
+ if (!Q.current) return;
518
+ const c = h.touches[0], m = Math.abs(c.clientX - Q.current.x), D = Math.abs(c.clientY - Q.current.y);
519
+ if (m > Nt || D > Nt) {
520
+ const p = Q.current.card, b = C(p.columnId);
521
+ if (!b) return;
522
+ d({
157
523
  isDragging: !0,
158
- draggedCard: l,
524
+ draggedCard: p,
159
525
  dragOverColumn: null,
160
526
  dragOverPosition: null,
161
- dragSourceColumn: y._id
162
- }), a == null || a(l, y.title, "being moved");
527
+ dragSourceColumn: b._id
528
+ }), t == null || t(p, b.title, "being moved");
163
529
  }
164
- }, [D, a]), p = h((u) => {
165
- if (!s.isDragging || !s.draggedCard || !K.current) {
166
- K.current = null;
530
+ }, [C, t]), S = _((h) => {
531
+ if (!i.isDragging || !i.draggedCard || !Q.current) {
532
+ Q.current = null;
167
533
  return;
168
534
  }
169
535
  try {
170
- const o = u.changedTouches[0], g = document.elementFromPoint(o.clientX, o.clientY), m = g == null ? void 0 : g.closest("[data-column-id]");
171
- if (m) {
172
- const l = m.dataset.columnId, y = s.draggedCard, S = s.dragSourceColumn, Q = D(l), J = D(S);
173
- if (Q && J && S !== l) {
174
- if (Q.limit && Q.cards.length >= Q.limit)
175
- throw new Error(`Column "${Q.title}" has reached its limit of ${Q.limit} cards`);
176
- i == null || i(y, S, l), a == null || a(y, J.title, Q.title);
536
+ const c = h.changedTouches[0], m = document.elementFromPoint(c.clientX, c.clientY), D = m == null ? void 0 : m.closest("[data-column-id]");
537
+ if (D) {
538
+ const p = D.dataset.columnId, b = i.draggedCard, L = i.dragSourceColumn, U = C(p), gt = C(L);
539
+ if (U && gt && L !== p) {
540
+ if (U.limit && U.cards.length >= U.limit)
541
+ throw new Error(`Column "${U.title}" has reached its limit of ${U.limit} cards`);
542
+ a == null || a(b, L, p), t == null || t(b, gt.title, U.title);
177
543
  }
178
544
  }
179
- } catch (o) {
180
- c == null || c(o instanceof Error ? o : new Error("Touch drop failed"));
545
+ } catch (c) {
546
+ e == null || e(c instanceof Error ? c : new Error("Touch drop failed"));
181
547
  } finally {
182
- K.current = null, b();
548
+ Q.current = null, E();
183
549
  }
184
- }, [s, D, i, c, b, a]), T = h((u, o, g) => {
185
- const m = `Moved "${u.title}" from ${o} to ${g}`, l = document.createElement("div");
186
- l.setAttribute("aria-live", "polite"), l.setAttribute("aria-atomic", "true"), l.className = "sr-only", l.textContent = m, document.body.appendChild(l), setTimeout(() => {
187
- document.body.removeChild(l);
188
- }, 1e3), console.log(`Kanban: ${m}`);
550
+ }, [i, C, a, e, E, t]), V = _((h, c, m) => {
551
+ const D = `Moved "${h.title}" from ${c} to ${m}`, p = document.createElement("div");
552
+ p.setAttribute("aria-live", "polite"), p.setAttribute("aria-atomic", "true"), p.className = "sr-only", p.textContent = D, document.body.appendChild(p), setTimeout(() => {
553
+ document.body.removeChild(p);
554
+ }, 1e3), console.log(`Kanban: ${D}`);
189
555
  }, []);
190
- return rt(() => () => {
191
- _.current && clearTimeout(_.current), q.current && document.body.contains(q.current) && document.body.removeChild(q.current);
556
+ return _t(() => () => {
557
+ y.current && clearTimeout(y.current), f.current && document.body.contains(f.current) && document.body.removeChild(f.current);
192
558
  }, []), {
193
559
  // State
194
- isDragging: s.isDragging,
195
- draggedCard: s.draggedCard,
196
- dragOverColumn: s.dragOverColumn,
197
- dragOverPosition: s.dragOverPosition,
198
- dragSourceColumn: s.dragSourceColumn,
560
+ isDragging: i.isDragging,
561
+ draggedCard: i.draggedCard,
562
+ dragOverColumn: i.dragOverColumn,
563
+ dragOverPosition: i.dragOverPosition,
564
+ dragSourceColumn: i.dragSourceColumn,
199
565
  // Handlers
200
- handleDragStart: P,
201
- handleDragOver: z,
202
- handleDrop: V,
203
- handleDragEnd: C,
204
- handleKeyDown: L,
205
- handleTouchStart: I,
206
- handleTouchMove: H,
207
- handleTouchEnd: p,
566
+ handleDragStart: K,
567
+ handleDragOver: q,
568
+ handleDrop: J,
569
+ handleDragEnd: g,
570
+ handleKeyDown: k,
571
+ handleTouchStart: X,
572
+ handleTouchMove: et,
573
+ handleTouchEnd: S,
208
574
  // Utilities
209
- announceMove: a || T,
210
- reset: b
575
+ announceMove: t || V,
576
+ reset: E
211
577
  };
212
578
  }
213
- function Xt(i) {
214
- var at, nt, it;
579
+ function Ie(a) {
580
+ var Tt, Rt, Ft;
215
581
  const {
216
- columns: c,
217
- source: d,
218
- enableDragDrop: a = !0,
219
- initialState: s,
220
- onCardMove: O,
221
- onCardCreate: q,
222
- onCardUpdate: _,
223
- onCardDelete: K,
224
- onError: b
225
- } = i, [D, Y] = G({
226
- query: (s == null ? void 0 : s.search) || ""
227
- }), [P] = G({
228
- field: ((at = s == null ? void 0 : s.sorting) == null ? void 0 : at.field) || null,
229
- direction: ((nt = s == null ? void 0 : s.sorting) == null ? void 0 : nt.direction) || null
230
- }), [z, V] = G(() => {
231
- const t = {};
232
- return c.forEach((e) => {
233
- t[e.id] = 10;
234
- }), t;
235
- }), C = k(b), $ = k(O), L = k(q), I = k(_), H = k(K);
236
- rt(() => {
237
- C.current = b, $.current = O, L.current = q, I.current = _, H.current = K;
238
- }, [b, O, q, _, K]);
239
- const p = At(), T = Et({
240
- initialConditions: s == null ? void 0 : s.filters,
241
- initialOperator: (s == null ? void 0 : s.filterOperator) || "And"
242
- }), u = h((t) => {
243
- const e = {
582
+ columns: e,
583
+ source: s,
584
+ enableDragDrop: t = !0,
585
+ initialState: i,
586
+ onCardMove: d,
587
+ onCardCreate: f,
588
+ onCardUpdate: y,
589
+ onCardDelete: Q,
590
+ onError: E
591
+ } = a, [C, O] = yt({
592
+ query: (i == null ? void 0 : i.search) || ""
593
+ }), [K] = yt({
594
+ field: ((Tt = i == null ? void 0 : i.sorting) == null ? void 0 : Tt.field) || null,
595
+ direction: ((Rt = i == null ? void 0 : i.sorting) == null ? void 0 : Rt.direction) || null
596
+ }), [q, J] = yt(() => {
597
+ const r = {};
598
+ return e.forEach((o) => {
599
+ r[o.id] = 10;
600
+ }), r;
601
+ }), g = G(E), P = G(d), k = G(f), X = G(y), et = G(Q);
602
+ _t(() => {
603
+ g.current = E, P.current = d, k.current = f, X.current = y, et.current = Q;
604
+ }, [E, d, f, y, Q]);
605
+ const S = kt(), V = Ee({
606
+ initialConditions: i == null ? void 0 : i.filters,
607
+ initialOperator: (i == null ? void 0 : i.filterOperator) || "And"
608
+ }), h = _((r) => {
609
+ const o = {
244
610
  LHSField: "columnId",
245
611
  Operator: "EQ",
246
- RHSValue: t,
612
+ RHSValue: r,
247
613
  RHSType: "Constant"
248
- }, r = T.payload;
249
- let n;
250
- r ? r.Operator === "And" ? n = {
251
- ...r,
252
- Condition: [...r.Condition || [], e]
253
- } : n = {
614
+ }, n = V.payload;
615
+ let u;
616
+ n ? n.Operator === "And" ? u = {
617
+ ...n,
618
+ Condition: [...n.Condition || [], o]
619
+ } : u = {
254
620
  Operator: "And",
255
- Condition: [r, e]
256
- } : n = {
621
+ Condition: [n, o]
622
+ } : u = {
257
623
  Operator: "And",
258
- Condition: [e]
624
+ Condition: [o]
259
625
  };
260
- const f = {
626
+ const w = {
261
627
  Page: 1,
262
628
  // Always page 1 due to expanding PageSize strategy
263
- PageSize: z[t] || 10,
264
- Filter: n
629
+ PageSize: q[r] || 10,
630
+ Filter: u
265
631
  };
266
- return P.field && P.direction ? f.Sort = [
267
- { [String(P.field)]: P.direction === "asc" ? "ASC" : "DESC" },
632
+ return K.field && K.direction ? w.Sort = [
633
+ { [String(K.field)]: K.direction === "asc" ? "ASC" : "DESC" },
268
634
  { position: "ASC" }
269
- ] : f.Sort = [
635
+ ] : w.Sort = [
270
636
  { columnId: "ASC" },
271
637
  { position: "ASC" }
272
- ], D.query && (f.Search = D.query), f;
273
- }, [T.payload, z, P, D.query]), o = Tt({
274
- queries: c.map((t) => {
275
- const e = u(t.id);
638
+ ], C.query && (w.Search = C.query), w;
639
+ }, [V.payload, q, K, C.query]), c = ke({
640
+ queries: e.map((r) => {
641
+ const o = h(r.id);
276
642
  return {
277
- queryKey: ["kanban-cards", d, t.id, e],
643
+ queryKey: ["kanban-cards", s, r.id, o],
278
644
  queryFn: async () => {
279
645
  try {
280
- return await F(d).list(e);
281
- } catch (r) {
282
- throw r;
646
+ return await M(s).list(o);
647
+ } catch (n) {
648
+ throw n;
283
649
  }
284
650
  },
285
- placeholderData: kt,
651
+ placeholderData: _e,
286
652
  staleTime: 30 * 1e3
287
653
  };
288
654
  })
289
- }), g = o.some((t) => t.isLoading), m = o.some((t) => t.isFetching), l = ((it = o.find((t) => t.error)) == null ? void 0 : it.error) || null, y = async () => {
290
- await Promise.all(o.map((t) => t.refetch()));
291
- }, S = ot(() => {
292
- const t = {};
293
- return D.query && (t.Search = D.query), T.payload && (t.Filter = T.payload), t;
294
- }, [D.query, T.payload]), {
295
- data: Q,
296
- isLoading: J,
297
- error: lt
298
- } = Pt({
299
- queryKey: ["kanban-count", d, S],
655
+ }), m = c.some((r) => r.isLoading), D = c.some((r) => r.isFetching), p = ((Ft = c.find((r) => r.error)) == null ? void 0 : Ft.error) || null, b = async () => {
656
+ await Promise.all(c.map((r) => r.refetch()));
657
+ }, L = Ht(() => {
658
+ const r = {};
659
+ return C.query && (r.Search = C.query), V.payload && (r.Filter = V.payload), r;
660
+ }, [C.query, V.payload]), {
661
+ data: U,
662
+ isLoading: gt,
663
+ error: xt
664
+ } = Qe({
665
+ queryKey: ["kanban-count", s, L],
300
666
  queryFn: async () => {
301
667
  try {
302
- return await F(d).count(S);
303
- } catch (t) {
304
- throw C.current && C.current(t), t;
668
+ return await M(s).count(L);
669
+ } catch (r) {
670
+ throw g.current && g.current(r), r;
305
671
  }
306
672
  },
307
673
  staleTime: 30 * 1e3,
308
674
  gcTime: 60 * 1e3
309
- }), et = j({
310
- mutationFn: async (t) => {
311
- const e = t.position ?? 999999;
312
- return (await F(d).create({ ...t, position: e }))._id;
675
+ }), At = ut({
676
+ mutationFn: async (r) => {
677
+ const o = r.position ?? 999999;
678
+ return (await M(s).create({ ...r, position: o }))._id;
313
679
  },
314
- onMutate: async (t) => {
315
- const e = t.columnId, r = u(e), n = ["kanban-cards", d, e, r];
316
- await p.cancelQueries({ queryKey: n });
317
- const f = p.getQueryData(n);
318
- if (f) {
319
- const U = f.Data, A = t.position ?? U.length, X = `temp-${Date.now()}`, E = {
320
- ...t,
321
- _id: X,
322
- position: A,
680
+ onMutate: async (r) => {
681
+ const o = r.columnId, n = h(o), u = ["kanban-cards", s, o, n];
682
+ await S.cancelQueries({ queryKey: u });
683
+ const w = S.getQueryData(u);
684
+ if (w) {
685
+ const rt = w.Data, j = r.position ?? rt.length, st = `temp-${Date.now()}`, x = {
686
+ ...r,
687
+ _id: st,
688
+ position: j,
323
689
  _created_at: /* @__PURE__ */ new Date(),
324
690
  _modified_at: /* @__PURE__ */ new Date()
325
691
  };
326
- p.setQueryData(n, {
327
- ...f,
328
- Data: [...f.Data, E]
692
+ S.setQueryData(u, {
693
+ ...w,
694
+ Data: [...w.Data, x]
329
695
  });
330
696
  }
331
- return { previousCards: f, queryKey: n };
697
+ return { previousCards: w, queryKey: u };
332
698
  },
333
- onSuccess: async (t, e, r) => {
334
- var n;
335
- r != null && r.queryKey && await p.invalidateQueries({ queryKey: r.queryKey }), (n = L.current) == null || n.call(L, {
336
- _id: t,
337
- ...e
699
+ onSuccess: async (r, o, n) => {
700
+ var u;
701
+ n != null && n.queryKey && await S.invalidateQueries({ queryKey: n.queryKey }), (u = k.current) == null || u.call(k, {
702
+ _id: r,
703
+ ...o
338
704
  });
339
705
  },
340
- onError: (t, e, r) => {
341
- var n;
342
- r != null && r.previousCards && (r != null && r.queryKey) && p.setQueryData(r.queryKey, r.previousCards), (n = C.current) == null || n.call(C, t);
706
+ onError: (r, o, n) => {
707
+ var u;
708
+ n != null && n.previousCards && (n != null && n.queryKey) && S.setQueryData(n.queryKey, n.previousCards), (u = g.current) == null || u.call(g, r);
343
709
  },
344
- onSettled: (t, e, r) => {
345
- const n = r.columnId, f = u(n);
346
- p.invalidateQueries({ queryKey: ["kanban-cards", d, n, f] });
710
+ onSettled: (r, o, n) => {
711
+ const u = n.columnId, w = h(u);
712
+ S.invalidateQueries({ queryKey: ["kanban-cards", s, u, w] });
347
713
  }
348
- }), Z = j({
349
- mutationFn: async ({ id: t, updates: e }) => (await F(d).update(t, e), { id: t, updates: e }),
350
- onMutate: async () => (await p.cancelQueries({ queryKey: ["kanban-cards", d] }), {}),
351
- onSuccess: async (t) => {
352
- var e;
353
- (e = I.current) == null || e.call(I, { _id: t.id, ...t.updates });
714
+ }), bt = ut({
715
+ mutationFn: async ({ id: r, updates: o }) => (await M(s).update(r, o), { id: r, updates: o }),
716
+ onMutate: async () => (await S.cancelQueries({ queryKey: ["kanban-cards", s] }), {}),
717
+ onSuccess: async (r) => {
718
+ var o;
719
+ (o = X.current) == null || o.call(X, { _id: r.id, ...r.updates });
354
720
  },
355
- onError: (t, e, r) => {
356
- var n;
357
- (n = C.current) == null || n.call(C, t);
721
+ onError: (r, o, n) => {
722
+ var u;
723
+ (u = g.current) == null || u.call(g, r);
358
724
  },
359
725
  onSettled: () => {
360
- p.invalidateQueries({ queryKey: ["kanban-cards", d] });
726
+ S.invalidateQueries({ queryKey: ["kanban-cards", s] });
361
727
  }
362
- }), v = j({
363
- mutationFn: async (t) => (await F(d).delete(t), t),
364
- onMutate: async () => (await p.cancelQueries({ queryKey: ["kanban-cards", d] }), {}),
365
- onSuccess: async (t) => {
366
- var e;
367
- (e = H.current) == null || e.call(H, t);
728
+ }), Ct = ut({
729
+ mutationFn: async (r) => (await M(s).delete(r), r),
730
+ onMutate: async () => (await S.cancelQueries({ queryKey: ["kanban-cards", s] }), {}),
731
+ onSuccess: async (r) => {
732
+ var o;
733
+ (o = et.current) == null || o.call(et, r);
368
734
  },
369
- onError: (t, e, r) => {
370
- var n;
371
- (n = C.current) == null || n.call(C, t);
735
+ onError: (r, o, n) => {
736
+ var u;
737
+ (u = g.current) == null || u.call(g, r);
372
738
  },
373
739
  onSettled: () => {
374
- p.invalidateQueries({ queryKey: ["kanban-cards", d] });
740
+ S.invalidateQueries({ queryKey: ["kanban-cards", s] });
375
741
  }
376
- }), B = j({
377
- mutationFn: async ({ cardId: t, fromColumnId: e, toColumnId: r, position: n }) => {
378
- const f = { columnId: r, ...n !== void 0 && { position: n } };
379
- return await F(d).update(t, f), { cardId: t, fromColumnId: e, toColumnId: r, position: n };
742
+ }), nt = ut({
743
+ mutationFn: async ({ cardId: r, fromColumnId: o, toColumnId: n, position: u }) => {
744
+ const w = { columnId: n, ...u !== void 0 && { position: u } };
745
+ return await M(s).update(r, w), { cardId: r, fromColumnId: o, toColumnId: n, position: u };
380
746
  },
381
- onMutate: async ({ cardId: t, fromColumnId: e, toColumnId: r, position: n }) => {
382
- const f = u(e), U = u(r), A = ["kanban-cards", d, e, f], X = ["kanban-cards", d, r, U];
383
- await p.cancelQueries({ queryKey: A }), await p.cancelQueries({ queryKey: X });
384
- const E = p.getQueryData(A), N = p.getQueryData(X);
385
- if (E && N) {
386
- const st = E.Data.find((M) => M._id === t);
387
- if (st) {
388
- const M = {
389
- ...E,
390
- Data: E.Data.filter((tt) => tt._id !== t)
391
- }, St = {
392
- ...st,
393
- columnId: r,
394
- position: n ?? N.Data.length,
747
+ onMutate: async ({ cardId: r, fromColumnId: o, toColumnId: n, position: u }) => {
748
+ const w = h(o), rt = h(n), j = ["kanban-cards", s, o, w], st = ["kanban-cards", s, n, rt];
749
+ await S.cancelQueries({ queryKey: j }), await S.cancelQueries({ queryKey: st });
750
+ const x = S.getQueryData(j), ot = S.getQueryData(st);
751
+ if (x && ot) {
752
+ const Lt = x.Data.find((wt) => wt._id === r);
753
+ if (Lt) {
754
+ const wt = {
755
+ ...x,
756
+ Data: x.Data.filter((Ot) => Ot._id !== r)
757
+ }, le = {
758
+ ...Lt,
759
+ columnId: n,
760
+ position: u ?? ot.Data.length,
395
761
  _modified_at: /* @__PURE__ */ new Date()
396
- }, Ot = {
397
- ...N,
398
- Data: [...N.Data, St].sort((tt, Kt) => tt.position - Kt.position)
762
+ }, de = {
763
+ ...ot,
764
+ Data: [...ot.Data, le].sort((Ot, he) => Ot.position - he.position)
399
765
  };
400
- p.setQueryData(A, M), p.setQueryData(X, Ot);
766
+ S.setQueryData(j, wt), S.setQueryData(st, de);
401
767
  }
402
768
  }
403
769
  return {
404
- previousFromData: E,
405
- previousToData: N,
406
- fromQueryKey: A,
407
- toQueryKey: X,
408
- fromColumnId: e,
409
- toColumnId: r
770
+ previousFromData: x,
771
+ previousToData: ot,
772
+ fromQueryKey: j,
773
+ toQueryKey: st,
774
+ fromColumnId: o,
775
+ toColumnId: n
410
776
  };
411
777
  },
412
- onSuccess: async (t) => {
413
- var e;
414
- (e = $.current) == null || e.call(
415
- $,
416
- { _id: t.cardId },
417
- t.fromColumnId,
418
- t.toColumnId
778
+ onSuccess: async (r) => {
779
+ var o;
780
+ (o = P.current) == null || o.call(
781
+ P,
782
+ { _id: r.cardId },
783
+ r.fromColumnId,
784
+ r.toColumnId
419
785
  );
420
786
  },
421
- onError: (t, e, r) => {
422
- var n;
423
- r != null && r.previousFromData && (r != null && r.fromQueryKey) && p.setQueryData(r.fromQueryKey, r.previousFromData), r != null && r.previousToData && (r != null && r.toQueryKey) && p.setQueryData(r.toQueryKey, r.previousToData), (n = C.current) == null || n.call(C, t);
787
+ onError: (r, o, n) => {
788
+ var u;
789
+ n != null && n.previousFromData && (n != null && n.fromQueryKey) && S.setQueryData(n.fromQueryKey, n.previousFromData), n != null && n.previousToData && (n != null && n.toQueryKey) && S.setQueryData(n.toQueryKey, n.previousToData), (u = g.current) == null || u.call(g, r);
424
790
  },
425
- onSettled: (t, e, r) => {
426
- const n = u(r.fromColumnId), f = u(r.toColumnId);
427
- p.invalidateQueries({ queryKey: ["kanban-cards", d, r.fromColumnId, n] }), p.invalidateQueries({ queryKey: ["kanban-cards", d, r.toColumnId, f] });
791
+ onSettled: (r, o, n) => {
792
+ const u = h(n.fromColumnId), w = h(n.toColumnId);
793
+ S.invalidateQueries({ queryKey: ["kanban-cards", s, n.fromColumnId, u] }), S.invalidateQueries({ queryKey: ["kanban-cards", s, n.toColumnId, w] });
428
794
  }
429
- }), x = j({
430
- mutationFn: async ({ cardIds: t, columnId: e }) => {
431
- const r = t.map((n, f) => ({ id: n, position: f, columnId: e }));
795
+ }), Dt = ut({
796
+ mutationFn: async ({ cardIds: r, columnId: o }) => {
797
+ const n = r.map((u, w) => ({ id: u, position: w, columnId: o }));
432
798
  await Promise.all(
433
- r.map(
434
- (n) => F(d).update(n.id, { position: n.position, columnId: n.columnId })
799
+ n.map(
800
+ (u) => M(s).update(u.id, { position: u.position, columnId: u.columnId })
435
801
  )
436
802
  );
437
803
  },
438
- onMutate: async ({ columnId: t }) => {
439
- const e = u(t), r = ["kanban-cards", d, t, e];
440
- return await p.cancelQueries({ queryKey: r }), {};
804
+ onMutate: async ({ columnId: r }) => {
805
+ const o = h(r), n = ["kanban-cards", s, r, o];
806
+ return await S.cancelQueries({ queryKey: n }), {};
441
807
  },
442
808
  onSuccess: () => {
443
809
  },
444
- onError: (t, e, r) => {
445
- var n;
446
- (n = C.current) == null || n.call(C, t);
810
+ onError: (r, o, n) => {
811
+ var u;
812
+ (u = g.current) == null || u.call(g, r);
447
813
  },
448
- onSettled: (t, e, r) => {
449
- const n = u(r.columnId);
450
- p.invalidateQueries({ queryKey: ["kanban-cards", d, r.columnId, n] });
814
+ onSettled: (r, o, n) => {
815
+ const u = h(n.columnId);
816
+ S.invalidateQueries({ queryKey: ["kanban-cards", s, n.columnId, u] });
451
817
  }
452
- }), gt = h(
453
- async (t, e, r) => {
818
+ }), Mt = _(
819
+ async (r, o, n) => {
454
820
  try {
455
- await B.mutateAsync({
456
- cardId: t._id,
457
- fromColumnId: e,
458
- toColumnId: r,
821
+ await nt.mutateAsync({
822
+ cardId: r._id,
823
+ fromColumnId: o,
824
+ toColumnId: n,
459
825
  position: void 0
460
826
  });
461
827
  } catch {
462
828
  }
463
829
  },
464
- [B]
465
- ), R = ot(() => c.sort((t, e) => t.position - e.position).map((t, e) => {
466
- var f;
467
- const n = ((f = o[e].data) == null ? void 0 : f.Data) || [];
830
+ [nt]
831
+ ), ft = Ht(() => e.sort((r, o) => r.position - o.position).map((r, o) => {
832
+ var w;
833
+ const u = ((w = c[o].data) == null ? void 0 : w.Data) || [];
468
834
  return {
469
- _id: t.id,
470
- title: t.title,
471
- position: t.position,
472
- color: t.color,
473
- limit: t.limit,
474
- cards: n.sort((U, A) => U.position - A.position),
835
+ _id: r.id,
836
+ title: r.title,
837
+ position: r.position,
838
+ color: r.color,
839
+ limit: r.limit,
840
+ cards: u.sort((rt, j) => rt.position - j.position),
475
841
  _created_at: /* @__PURE__ */ new Date(),
476
842
  _modified_at: /* @__PURE__ */ new Date()
477
843
  };
478
- }), [c, o]), w = Ft({
479
- onCardMove: gt,
480
- onError: C.current,
481
- columns: R,
482
- announceMove: (t, e, r) => {
844
+ }), [e, c]), A = Ae({
845
+ onCardMove: Mt,
846
+ onError: g.current,
847
+ columns: ft,
848
+ announceMove: (r, o, n) => {
483
849
  console.log(
484
- `Kanban: Moved "${t.title}" from ${e} to ${r}`
850
+ `Kanban: Moved "${r.title}" from ${o} to ${n}`
485
851
  );
486
852
  }
487
- }), yt = h(
488
- (t) => {
489
- var e, r;
853
+ }), te = _(
854
+ (r) => {
855
+ var o, n;
490
856
  return {
491
857
  draggable: !0,
492
858
  role: "option",
493
- "aria-selected": a && ((e = w.draggedCard) == null ? void 0 : e._id) === t._id,
494
- "aria-grabbed": a && ((r = w.draggedCard) == null ? void 0 : r._id) === t._id,
495
- onDragStart: (n) => {
496
- if (!a) return;
497
- n.dataTransfer.setData("text/plain", JSON.stringify(t));
498
- const f = n.nativeEvent || n;
499
- w.handleDragStart(f, t);
859
+ "aria-selected": t && ((o = A.draggedCard) == null ? void 0 : o._id) === r._id,
860
+ "aria-grabbed": t && ((n = A.draggedCard) == null ? void 0 : n._id) === r._id,
861
+ onDragStart: (u) => {
862
+ if (!t) return;
863
+ u.dataTransfer.setData("text/plain", JSON.stringify(r));
864
+ const w = u.nativeEvent || u;
865
+ A.handleDragStart(w, r);
500
866
  },
501
- onDragEnd: w.handleDragEnd,
502
- onKeyDown: (n) => {
503
- if (!a) return;
504
- const f = n.nativeEvent || n;
505
- w.handleKeyDown(f, t);
867
+ onDragEnd: A.handleDragEnd,
868
+ onKeyDown: (u) => {
869
+ if (!t) return;
870
+ const w = u.nativeEvent || u;
871
+ A.handleKeyDown(w, r);
506
872
  }
507
873
  };
508
874
  },
509
- [a, w]
510
- ), mt = h(
511
- (t) => ({
512
- "data-column-id": t,
875
+ [t, A]
876
+ ), ee = _(
877
+ (r) => ({
878
+ "data-column-id": r,
513
879
  role: "listbox",
514
- onDragOver: (e) => {
515
- if (!a) return;
516
- const r = e.nativeEvent || e;
517
- w.handleDragOver(r, t);
880
+ onDragOver: (o) => {
881
+ if (!t) return;
882
+ const n = o.nativeEvent || o;
883
+ A.handleDragOver(n, r);
518
884
  },
519
- onDrop: (e) => {
520
- if (!a) return;
521
- const r = e.nativeEvent || e;
522
- w.handleDrop(r, t);
885
+ onDrop: (o) => {
886
+ if (!t) return;
887
+ const n = o.nativeEvent || o;
888
+ A.handleDrop(n, r);
523
889
  }
524
890
  }),
525
- [a, w]
526
- ), ft = h((t) => {
527
- Y({ query: t });
528
- }, []), pt = h(() => {
529
- Y({ query: "" });
530
- }, []), ht = (Q == null ? void 0 : Q.Count) || 0, Ct = g || J, Dt = m, wt = et.isPending || Z.isPending || v.isPending || B.isPending || x.isPending, W = l || lt, _t = h(async () => {
531
- await y();
532
- }, [y]), bt = h(async () => {
533
- await p.invalidateQueries({
534
- predicate: (t) => t.queryKey[0] === "kanban-cards" || t.queryKey[0] === "kanban-count"
891
+ [t, A]
892
+ ), re = _((r) => {
893
+ O({ query: r });
894
+ }, []), se = _(() => {
895
+ O({ query: "" });
896
+ }, []), ie = (U == null ? void 0 : U.Count) || 0, ae = m || gt, ne = D, oe = At.isPending || bt.isPending || Ct.isPending || nt.isPending || Dt.isPending, pt = p || xt, ue = _(async () => {
897
+ await b();
898
+ }, [b]), ce = _(async () => {
899
+ await S.invalidateQueries({
900
+ predicate: (r) => r.queryKey[0] === "kanban-cards" || r.queryKey[0] === "kanban-count"
535
901
  });
536
- }, [p]);
537
- return rt(() => {
538
- W && C.current && C.current(W);
539
- }, [W]), {
902
+ }, [S]);
903
+ return _t(() => {
904
+ pt && g.current && g.current(pt);
905
+ }, [pt]), {
540
906
  // Data
541
- columns: R,
542
- totalCards: ht,
907
+ columns: ft,
908
+ totalCards: ie,
543
909
  // Loading States
544
- isLoading: Ct,
545
- isFetching: Dt,
546
- isUpdating: wt,
910
+ isLoading: ae,
911
+ isFetching: ne,
912
+ isUpdating: oe,
547
913
  // Error Handling
548
- error: W,
914
+ error: pt,
549
915
  // Card Operations (Flat Access)
550
- createCard: et.mutateAsync,
551
- updateCard: h(
552
- async (t, e) => {
553
- await Z.mutateAsync({ id: t, updates: e });
916
+ createCard: At.mutateAsync,
917
+ updateCard: _(
918
+ async (r, o) => {
919
+ await bt.mutateAsync({ id: r, updates: o });
554
920
  },
555
- [Z]
921
+ [bt]
556
922
  ),
557
- deleteCard: h(
558
- async (t) => {
559
- await v.mutateAsync(t);
923
+ deleteCard: _(
924
+ async (r) => {
925
+ await Ct.mutateAsync(r);
560
926
  },
561
- [v]
927
+ [Ct]
562
928
  ),
563
- moveCard: h(
564
- async (t, e, r, n) => {
565
- if (!n) {
566
- for (const f of R)
567
- if (f.cards.find((A) => A._id === t)) {
568
- n = f._id;
929
+ moveCard: _(
930
+ async (r, o, n, u) => {
931
+ if (!u) {
932
+ for (const w of ft)
933
+ if (w.cards.find((j) => j._id === r)) {
934
+ u = w._id;
569
935
  break;
570
936
  }
571
- if (!n)
572
- throw new Error(`Card ${t} not found in any column`);
937
+ if (!u)
938
+ throw new Error(`Card ${r} not found in any column`);
573
939
  }
574
- await B.mutateAsync({ cardId: t, fromColumnId: n, toColumnId: e, position: r });
940
+ await nt.mutateAsync({ cardId: r, fromColumnId: u, toColumnId: o, position: n });
575
941
  },
576
- [B, R]
942
+ [nt, ft]
577
943
  ),
578
- reorderCards: h(
579
- async (t, e) => {
580
- await x.mutateAsync({ cardIds: t, columnId: e });
944
+ reorderCards: _(
945
+ async (r, o) => {
946
+ await Dt.mutateAsync({ cardIds: r, columnId: o });
581
947
  },
582
- [x]
948
+ [Dt]
583
949
  ),
584
950
  // Search (Flat Access)
585
- searchQuery: D.query,
586
- setSearchQuery: ft,
587
- clearSearch: pt,
951
+ searchQuery: C.query,
952
+ setSearchQuery: re,
953
+ clearSearch: se,
588
954
  // Filter (Simplified chainable API)
589
- filter: T,
955
+ filter: V,
590
956
  // Drag Drop (Flat Access)
591
- isDragging: a ? w.isDragging : !1,
592
- draggedCard: a ? w.draggedCard : null,
593
- dragOverColumn: a ? w.dragOverColumn : null,
594
- handleDragStart: a ? w.handleDragStart : () => {
957
+ isDragging: t ? A.isDragging : !1,
958
+ draggedCard: t ? A.draggedCard : null,
959
+ dragOverColumn: t ? A.dragOverColumn : null,
960
+ handleDragStart: t ? A.handleDragStart : () => {
595
961
  },
596
- handleDragOver: a ? w.handleDragOver : () => {
962
+ handleDragOver: t ? A.handleDragOver : () => {
597
963
  },
598
- handleDrop: a ? w.handleDrop : () => {
964
+ handleDrop: t ? A.handleDrop : () => {
599
965
  },
600
- handleDragEnd: a ? w.handleDragEnd : () => {
966
+ handleDragEnd: t ? A.handleDragEnd : () => {
601
967
  },
602
- handleKeyDown: a ? w.handleKeyDown : () => {
968
+ handleKeyDown: t ? A.handleKeyDown : () => {
603
969
  },
604
970
  // Prop Getters
605
- getCardProps: a ? yt : (t) => ({}),
606
- getColumnProps: a ? mt : (t) => ({}),
971
+ getCardProps: t ? te : (r) => ({}),
972
+ getColumnProps: t ? ee : (r) => ({}),
607
973
  // Load More (Per Column)
608
- loadMore: h((t) => {
609
- V((e) => ({
610
- ...e,
611
- [t]: (e[t] || 10) + 10
974
+ loadMore: _((r) => {
975
+ J((o) => ({
976
+ ...o,
977
+ [r]: (o[r] || 10) + 10
612
978
  }));
613
979
  }, []),
614
980
  // Utilities
615
- refetch: _t,
616
- refresh: bt
981
+ refetch: ue,
982
+ refresh: ce
617
983
  };
618
984
  }
619
- const $t = qt(null);
620
- function Yt() {
621
- const i = Qt($t);
622
- if (!i)
985
+ const Te = ge(null);
986
+ function Ue() {
987
+ const a = fe(Te);
988
+ if (!a)
623
989
  throw new Error(
624
990
  "Kanban components must be used within a KanbanBoard component"
625
991
  );
626
- return i;
992
+ return a;
627
993
  }
628
- function Bt(i, c) {
629
- const d = c.reduce((a, s) => (a[s.columnId] || (a[s.columnId] = []), a[s.columnId].push(s), a), {});
630
- return i.map((a) => ({
631
- ...a,
632
- cards: (d[a._id] || []).sort((s, O) => s.position - O.position)
994
+ function je(a, e) {
995
+ const s = e.reduce((t, i) => (t[i.columnId] || (t[i.columnId] = []), t[i.columnId].push(i), t), {});
996
+ return a.map((t) => ({
997
+ ...t,
998
+ cards: (s[t._id] || []).sort((i, d) => i.position - d.position)
633
999
  }));
634
1000
  }
635
- function Nt(i, c) {
636
- if (i.cards.length === 0)
1001
+ function Be(a, e) {
1002
+ if (a.cards.length === 0)
637
1003
  return 0;
638
- if (c === void 0 || c >= i.cards.length)
639
- return i.cards[i.cards.length - 1].position + 1;
640
- if (c === 0) {
641
- const s = i.cards[0];
642
- return Math.max(0, s.position - 1);
1004
+ if (e === void 0 || e >= a.cards.length)
1005
+ return a.cards[a.cards.length - 1].position + 1;
1006
+ if (e === 0) {
1007
+ const i = a.cards[0];
1008
+ return Math.max(0, i.position - 1);
643
1009
  }
644
- const d = i.cards[c - 1], a = i.cards[c];
645
- return Math.floor((d.position + a.position) / 2);
1010
+ const s = a.cards[e - 1], t = a.cards[e];
1011
+ return Math.floor((s.position + t.position) / 2);
646
1012
  }
647
- function jt(i, c) {
648
- if (i.length === 0)
1013
+ function Xe(a, e) {
1014
+ if (a.length === 0)
649
1015
  return 0;
650
- if (c === void 0 || c >= i.length)
651
- return i[i.length - 1].position + 1;
652
- if (c === 0) {
653
- const s = i[0];
654
- return Math.max(0, s.position - 1);
1016
+ if (e === void 0 || e >= a.length)
1017
+ return a[a.length - 1].position + 1;
1018
+ if (e === 0) {
1019
+ const i = a[0];
1020
+ return Math.max(0, i.position - 1);
655
1021
  }
656
- const d = i[c - 1], a = i[c];
657
- return Math.floor((d.position + a.position) / 2);
1022
+ const s = a[e - 1], t = a[e];
1023
+ return Math.floor((s.position + t.position) / 2);
658
1024
  }
659
- function zt(i) {
660
- return i.sort((c, d) => c.position - d.position).map((c, d) => ({
661
- ...c,
662
- position: d
1025
+ function ze(a) {
1026
+ return a.sort((e, s) => e.position - s.position).map((e, s) => ({
1027
+ ...e,
1028
+ position: s
663
1029
  }));
664
1030
  }
665
- function Jt(i, c, d, a) {
666
- const s = `Failed to ${c} ${d}`, O = a ? ` (ID: ${a})` : "";
667
- return i instanceof Error ? new Error(`${s}${O}: ${i.message}`) : new Error(`${s}${O}: Unknown error`);
1031
+ function Ne(a, e, s, t) {
1032
+ const i = `Failed to ${e} ${s}`, d = t ? ` (ID: ${t})` : "";
1033
+ return a instanceof Error ? new Error(`${i}${d}: ${a.message}`) : new Error(`${i}${d}: Unknown error`);
668
1034
  }
669
- function Rt(i, c) {
670
- switch (c) {
1035
+ function Ye(a, e) {
1036
+ switch (e) {
671
1037
  case "list":
672
- return i && Array.isArray(i.Data);
1038
+ return a && Array.isArray(a.Data);
673
1039
  case "single":
674
- return i && typeof i == "object";
1040
+ return a && typeof a == "object";
675
1041
  case "create":
676
- return i && typeof i._id == "string";
1042
+ return a && typeof a._id == "string";
677
1043
  case "delete":
678
- return i && i.status === "success";
1044
+ return a && a.status === "success";
679
1045
  default:
680
1046
  return !1;
681
1047
  }
682
1048
  }
683
1049
  export {
684
- $t as KanbanContext,
685
- Nt as calculateCardPosition,
686
- jt as calculateColumnPosition,
687
- Jt as handleKanbanApiError,
688
- Bt as mergeCardsIntoColumns,
689
- zt as normalizePositions,
690
- Ft as useDragDropManager,
691
- Xt as useKanban,
692
- Yt as useKanbanContext,
693
- Rt as validateApiResponse
1050
+ Te as KanbanContext,
1051
+ Be as calculateCardPosition,
1052
+ Xe as calculateColumnPosition,
1053
+ Ne as handleKanbanApiError,
1054
+ je as mergeCardsIntoColumns,
1055
+ ze as normalizePositions,
1056
+ Ae as useDragDropManager,
1057
+ Ie as useKanban,
1058
+ Ue as useKanbanContext,
1059
+ Ye as validateApiResponse
694
1060
  };