@ram_28/kf-ai-sdk 1.0.11 → 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.
Files changed (195) hide show
  1. package/README.md +55 -48
  2. package/dist/api/client.d.ts +14 -14
  3. package/dist/api/client.d.ts.map +1 -1
  4. package/dist/api/datetime.d.ts +5 -5
  5. package/dist/api/datetime.d.ts.map +1 -1
  6. package/dist/api/index.d.ts +1 -1
  7. package/dist/api/index.d.ts.map +1 -1
  8. package/dist/api/metadata.d.ts +2 -2
  9. package/dist/api/metadata.d.ts.map +1 -1
  10. package/dist/api.cjs +1 -0
  11. package/dist/api.d.ts +4 -0
  12. package/dist/api.d.ts.map +1 -0
  13. package/dist/api.mjs +27 -0
  14. package/dist/api.types.cjs +1 -0
  15. package/dist/api.types.d.ts +4 -0
  16. package/dist/api.types.d.ts.map +1 -0
  17. package/dist/api.types.mjs +1 -0
  18. package/dist/auth/AuthProvider.d.ts +3 -3
  19. package/dist/auth/AuthProvider.d.ts.map +1 -1
  20. package/dist/auth/authClient.d.ts +4 -4
  21. package/dist/auth/authClient.d.ts.map +1 -1
  22. package/dist/auth/authConfig.d.ts +5 -5
  23. package/dist/auth/authConfig.d.ts.map +1 -1
  24. package/dist/auth/index.d.ts +1 -1
  25. package/dist/auth/index.d.ts.map +1 -1
  26. package/dist/auth/types.d.ts +21 -21
  27. package/dist/auth/types.d.ts.map +1 -1
  28. package/dist/auth/useAuth.d.ts +2 -2
  29. package/dist/auth/useAuth.d.ts.map +1 -1
  30. package/dist/auth.cjs +1 -0
  31. package/dist/auth.d.ts +5 -0
  32. package/dist/auth.d.ts.map +1 -0
  33. package/dist/auth.mjs +280 -0
  34. package/dist/auth.types.cjs +1 -0
  35. package/dist/auth.types.d.ts +2 -0
  36. package/dist/auth.types.d.ts.map +1 -0
  37. package/dist/auth.types.mjs +1 -0
  38. package/dist/base-types.d.ts +2 -0
  39. package/dist/base-types.d.ts.map +1 -0
  40. package/dist/client-C15j4O5B.cjs +1 -0
  41. package/dist/client-CfvLiGfP.js +233 -0
  42. package/dist/cn-Dr87sK3i.js +2775 -0
  43. package/dist/cn-mXUIg4vp.cjs +1 -0
  44. package/dist/components/hooks/index.d.ts +3 -3
  45. package/dist/components/hooks/index.d.ts.map +1 -1
  46. package/dist/components/hooks/useFilter/index.d.ts +2 -2
  47. package/dist/components/hooks/useFilter/index.d.ts.map +1 -1
  48. package/dist/components/hooks/useFilter/types.d.ts +19 -31
  49. package/dist/components/hooks/useFilter/types.d.ts.map +1 -1
  50. package/dist/components/hooks/useFilter/useFilter.d.ts +2 -2
  51. package/dist/components/hooks/useFilter/useFilter.d.ts.map +1 -1
  52. package/dist/components/hooks/useForm/apiClient.d.ts +6 -6
  53. package/dist/components/hooks/useForm/apiClient.d.ts.map +1 -1
  54. package/dist/components/hooks/useForm/expressionValidator.utils.d.ts +7 -7
  55. package/dist/components/hooks/useForm/expressionValidator.utils.d.ts.map +1 -1
  56. package/dist/components/hooks/useForm/index.d.ts +5 -5
  57. package/dist/components/hooks/useForm/index.d.ts.map +1 -1
  58. package/dist/components/hooks/useForm/optimizedExpressionValidator.utils.d.ts +10 -10
  59. package/dist/components/hooks/useForm/optimizedExpressionValidator.utils.d.ts.map +1 -1
  60. package/dist/components/hooks/useForm/ruleClassifier.utils.d.ts +7 -12
  61. package/dist/components/hooks/useForm/ruleClassifier.utils.d.ts.map +1 -1
  62. package/dist/components/hooks/useForm/schemaParser.utils.d.ts +7 -7
  63. package/dist/components/hooks/useForm/schemaParser.utils.d.ts.map +1 -1
  64. package/dist/components/hooks/useForm/types.d.ts +67 -76
  65. package/dist/components/hooks/useForm/types.d.ts.map +1 -1
  66. package/dist/components/hooks/useForm/useForm.d.ts +2 -2
  67. package/dist/components/hooks/useForm/useForm.d.ts.map +1 -1
  68. package/dist/components/hooks/useKanban/apiClient.d.ts +16 -16
  69. package/dist/components/hooks/useKanban/apiClient.d.ts.map +1 -1
  70. package/dist/components/hooks/useKanban/context.d.ts +3 -3
  71. package/dist/components/hooks/useKanban/context.d.ts.map +1 -1
  72. package/dist/components/hooks/useKanban/dragDropManager.d.ts +7 -7
  73. package/dist/components/hooks/useKanban/dragDropManager.d.ts.map +1 -1
  74. package/dist/components/hooks/useKanban/index.d.ts +1 -1
  75. package/dist/components/hooks/useKanban/index.d.ts.map +1 -1
  76. package/dist/components/hooks/useKanban/types.d.ts +65 -67
  77. package/dist/components/hooks/useKanban/types.d.ts.map +1 -1
  78. package/dist/components/hooks/useKanban/useKanban.d.ts +2 -2
  79. package/dist/components/hooks/useKanban/useKanban.d.ts.map +1 -1
  80. package/dist/components/hooks/useTable/index.d.ts +1 -1
  81. package/dist/components/hooks/useTable/index.d.ts.map +1 -1
  82. package/dist/components/hooks/useTable/types.d.ts +10 -10
  83. package/dist/components/hooks/useTable/types.d.ts.map +1 -1
  84. package/dist/components/hooks/useTable/useTable.d.ts +2 -2
  85. package/dist/components/hooks/useTable/useTable.d.ts.map +1 -1
  86. package/dist/filter.cjs +1 -0
  87. package/dist/filter.d.ts +3 -0
  88. package/dist/filter.d.ts.map +1 -0
  89. package/dist/filter.mjs +6 -0
  90. package/dist/filter.types.cjs +1 -0
  91. package/dist/filter.types.d.ts +2 -0
  92. package/dist/filter.types.d.ts.map +1 -0
  93. package/dist/filter.types.mjs +1 -0
  94. package/dist/form.cjs +1 -0
  95. package/dist/form.d.ts +3 -0
  96. package/dist/form.d.ts.map +1 -0
  97. package/dist/form.mjs +2355 -0
  98. package/dist/form.types.cjs +1 -0
  99. package/dist/form.types.d.ts +2 -0
  100. package/dist/form.types.d.ts.map +1 -0
  101. package/dist/form.types.mjs +1 -0
  102. package/dist/jsx-runtime-BYECrxsp.cjs +30 -0
  103. package/dist/jsx-runtime-DGlMoOmv.js +630 -0
  104. package/dist/kanban.cjs +13 -0
  105. package/dist/kanban.d.ts +5 -0
  106. package/dist/kanban.d.ts.map +1 -0
  107. package/dist/kanban.mjs +1060 -0
  108. package/dist/kanban.types.cjs +1 -0
  109. package/dist/kanban.types.d.ts +2 -0
  110. package/dist/kanban.types.d.ts.map +1 -0
  111. package/dist/kanban.types.mjs +1 -0
  112. package/dist/kanban.ui.cjs +1 -0
  113. package/dist/kanban.ui.d.ts +2 -0
  114. package/dist/kanban.ui.d.ts.map +1 -0
  115. package/dist/kanban.ui.mjs +104 -0
  116. package/dist/metadata-2FLBsFcf.cjs +1 -0
  117. package/dist/metadata-DBcoDth-.js +43 -0
  118. package/dist/table.cjs +1 -0
  119. package/dist/table.d.ts +2 -0
  120. package/dist/table.d.ts.map +1 -0
  121. package/dist/table.mjs +148 -0
  122. package/dist/table.types.cjs +1 -0
  123. package/dist/table.types.d.ts +2 -0
  124. package/dist/table.types.d.ts.map +1 -0
  125. package/dist/table.types.mjs +1 -0
  126. package/dist/types/base-fields.d.ts +45 -45
  127. package/dist/types/base-fields.d.ts.map +1 -1
  128. package/dist/types/common.d.ts +45 -61
  129. package/dist/types/common.d.ts.map +1 -1
  130. package/dist/types.cjs +1 -0
  131. package/dist/types.mjs +1 -0
  132. package/dist/useFilter-CXFqEHyI.js +129 -0
  133. package/dist/useFilter-D-bCDo6Z.cjs +1 -0
  134. package/dist/useQuery-BScHEo7x.cjs +1 -0
  135. package/dist/useQuery-KpZFg80c.js +748 -0
  136. package/dist/utils/formatting.d.ts +4 -4
  137. package/dist/utils/formatting.d.ts.map +1 -1
  138. package/dist/utils.cjs +4 -0
  139. package/dist/utils.d.ts +3 -0
  140. package/dist/utils.d.ts.map +1 -0
  141. package/dist/utils.mjs +105 -0
  142. package/package.json +147 -9
  143. package/sdk/api/client.ts +51 -51
  144. package/sdk/api/datetime.ts +5 -5
  145. package/sdk/api/index.ts +28 -33
  146. package/sdk/api/metadata.ts +4 -4
  147. package/sdk/api.ts +24 -0
  148. package/sdk/api.types.ts +58 -0
  149. package/sdk/auth/AuthProvider.tsx +18 -18
  150. package/sdk/auth/authClient.ts +9 -9
  151. package/sdk/auth/authConfig.ts +9 -9
  152. package/sdk/auth/index.ts +5 -5
  153. package/sdk/auth/types.ts +21 -21
  154. package/sdk/auth/useAuth.ts +2 -2
  155. package/sdk/auth.ts +22 -0
  156. package/sdk/auth.types.ts +28 -0
  157. package/sdk/base-types.ts +45 -0
  158. package/sdk/components/hooks/index.ts +22 -22
  159. package/sdk/components/hooks/useFilter/index.ts +8 -14
  160. package/sdk/components/hooks/useFilter/types.ts +29 -58
  161. package/sdk/components/hooks/useFilter/useFilter.ts +41 -44
  162. package/sdk/components/hooks/useForm/apiClient.ts +8 -8
  163. package/sdk/components/hooks/useForm/expressionValidator.utils.ts +18 -18
  164. package/sdk/components/hooks/useForm/index.ts +24 -24
  165. package/sdk/components/hooks/useForm/optimizedExpressionValidator.utils.ts +22 -22
  166. package/sdk/components/hooks/useForm/ruleClassifier.utils.ts +26 -62
  167. package/sdk/components/hooks/useForm/schemaParser.utils.ts +24 -24
  168. package/sdk/components/hooks/useForm/types.ts +66 -82
  169. package/sdk/components/hooks/useForm/useForm.ts +15 -21
  170. package/sdk/components/hooks/useKanban/apiClient.ts +54 -54
  171. package/sdk/components/hooks/useKanban/context.ts +3 -3
  172. package/sdk/components/hooks/useKanban/dragDropManager.ts +19 -19
  173. package/sdk/components/hooks/useKanban/index.ts +26 -26
  174. package/sdk/components/hooks/useKanban/types.ts +69 -71
  175. package/sdk/components/hooks/useKanban/useKanban.ts +43 -51
  176. package/sdk/components/hooks/useKanban/useKanbanSimple.ts +4 -4
  177. package/sdk/components/hooks/useTable/index.ts +5 -1
  178. package/sdk/components/hooks/useTable/types.ts +10 -10
  179. package/sdk/components/hooks/useTable/useTable.ts +10 -10
  180. package/sdk/filter.ts +13 -0
  181. package/sdk/filter.types.ts +17 -0
  182. package/sdk/form.ts +15 -0
  183. package/sdk/form.types.ts +46 -0
  184. package/sdk/kanban.ts +23 -0
  185. package/sdk/kanban.types.ts +50 -0
  186. package/sdk/kanban.ui.ts +16 -0
  187. package/sdk/table.ts +7 -0
  188. package/sdk/table.types.ts +13 -0
  189. package/sdk/types/base-fields.ts +47 -47
  190. package/sdk/types/common.ts +47 -71
  191. package/sdk/types/index.ts +1 -1
  192. package/sdk/utils/formatting.ts +4 -4
  193. package/sdk/utils.ts +10 -0
  194. package/dist/index.cjs +0 -45
  195. package/dist/index.mjs +0 -6387
@@ -0,0 +1,1060 @@
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
377
+ }) {
378
+ const [i, d] = yt({
379
+ isDragging: !1,
380
+ draggedCard: null,
381
+ dragOverColumn: null,
382
+ dragOverPosition: null,
383
+ dragSourceColumn: null
384
+ }), f = G(null), y = G(null), Q = G(null), E = _(() => {
385
+ d({
386
+ isDragging: !1,
387
+ draggedCard: null,
388
+ dragOverColumn: null,
389
+ dragOverPosition: null,
390
+ dragSourceColumn: null
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 };
397
+ }
398
+ return null;
399
+ }, [s]), K = _((h, c) => {
400
+ var m, D;
401
+ try {
402
+ const p = h.target, b = C(c.columnId);
403
+ if (!b)
404
+ throw new Error("Source column not found");
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 = `
408
+ position: fixed;
409
+ top: -1000px;
410
+ left: -1000px;
411
+ opacity: 0.9;
412
+ transform: rotate(-2deg) scale(0.95);
413
+ box-shadow: 0 10px 25px rgba(0,0,0,0.2);
414
+ pointer-events: none;
415
+ z-index: 9999;
416
+ max-width: 300px;
417
+ background: white;
418
+ border-radius: 8px;
419
+ `, document.body.appendChild(L), f.current = L, h.dataTransfer && h.dataTransfer.setDragImage(L, h.offsetX || 50, h.offsetY || 20), d({
420
+ isDragging: !0,
421
+ draggedCard: c,
422
+ dragOverColumn: null,
423
+ dragOverPosition: null,
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();
428
+ }
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,
435
+ dragOverPosition: null
436
+ // Will be calculated based on mouse position
437
+ })), P(h);
438
+ }, [i.isDragging, i.draggedCard, C]), J = _((h, c) => {
439
+ if (h.preventDefault(), !(!i.isDragging || !i.draggedCard))
440
+ try {
441
+ const m = i.draggedCard, D = i.dragSourceColumn, p = C(c), b = C(D);
442
+ if (!p || !b)
443
+ throw new Error("Target or source column not found");
444
+ if (D === c) {
445
+ E();
446
+ return;
447
+ }
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"));
453
+ } finally {
454
+ E();
455
+ }
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);
467
+ };
468
+ y.current = setTimeout(L, 100);
469
+ } else
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))
473
+ return;
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);
478
+ try {
479
+ switch (h.key) {
480
+ case "ArrowLeft":
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);
484
+ }
485
+ break;
486
+ case "ArrowRight":
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);
490
+ }
491
+ break;
492
+ case "ArrowUp":
493
+ t == null || t(c, "current position", "position above");
494
+ break;
495
+ case "ArrowDown":
496
+ t == null || t(c, "current position", "position below");
497
+ break;
498
+ case "Enter":
499
+ case "Space":
500
+ t == null || t(c, D.title, "drag mode");
501
+ break;
502
+ case "Escape":
503
+ t == null || t(c, "drag mode", "cancelled");
504
+ break;
505
+ }
506
+ } catch (b) {
507
+ e == null || e(b instanceof Error ? b : new Error("Keyboard navigation failed"));
508
+ }
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
515
+ };
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({
523
+ isDragging: !0,
524
+ draggedCard: p,
525
+ dragOverColumn: null,
526
+ dragOverPosition: null,
527
+ dragSourceColumn: b._id
528
+ }), t == null || t(p, b.title, "being moved");
529
+ }
530
+ }, [C, t]), S = _((h) => {
531
+ if (!i.isDragging || !i.draggedCard || !Q.current) {
532
+ Q.current = null;
533
+ return;
534
+ }
535
+ try {
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);
543
+ }
544
+ }
545
+ } catch (c) {
546
+ e == null || e(c instanceof Error ? c : new Error("Touch drop failed"));
547
+ } finally {
548
+ Q.current = null, E();
549
+ }
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}`);
555
+ }, []);
556
+ return _t(() => () => {
557
+ y.current && clearTimeout(y.current), f.current && document.body.contains(f.current) && document.body.removeChild(f.current);
558
+ }, []), {
559
+ // State
560
+ isDragging: i.isDragging,
561
+ draggedCard: i.draggedCard,
562
+ dragOverColumn: i.dragOverColumn,
563
+ dragOverPosition: i.dragOverPosition,
564
+ dragSourceColumn: i.dragSourceColumn,
565
+ // Handlers
566
+ handleDragStart: K,
567
+ handleDragOver: q,
568
+ handleDrop: J,
569
+ handleDragEnd: g,
570
+ handleKeyDown: k,
571
+ handleTouchStart: X,
572
+ handleTouchMove: et,
573
+ handleTouchEnd: S,
574
+ // Utilities
575
+ announceMove: t || V,
576
+ reset: E
577
+ };
578
+ }
579
+ function Ie(a) {
580
+ var Tt, Rt, Ft;
581
+ const {
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 = {
610
+ LHSField: "columnId",
611
+ Operator: "EQ",
612
+ RHSValue: r,
613
+ RHSType: "Constant"
614
+ }, n = V.payload;
615
+ let u;
616
+ n ? n.Operator === "And" ? u = {
617
+ ...n,
618
+ Condition: [...n.Condition || [], o]
619
+ } : u = {
620
+ Operator: "And",
621
+ Condition: [n, o]
622
+ } : u = {
623
+ Operator: "And",
624
+ Condition: [o]
625
+ };
626
+ const w = {
627
+ Page: 1,
628
+ // Always page 1 due to expanding PageSize strategy
629
+ PageSize: q[r] || 10,
630
+ Filter: u
631
+ };
632
+ return K.field && K.direction ? w.Sort = [
633
+ { [String(K.field)]: K.direction === "asc" ? "ASC" : "DESC" },
634
+ { position: "ASC" }
635
+ ] : w.Sort = [
636
+ { columnId: "ASC" },
637
+ { position: "ASC" }
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);
642
+ return {
643
+ queryKey: ["kanban-cards", s, r.id, o],
644
+ queryFn: async () => {
645
+ try {
646
+ return await M(s).list(o);
647
+ } catch (n) {
648
+ throw n;
649
+ }
650
+ },
651
+ placeholderData: _e,
652
+ staleTime: 30 * 1e3
653
+ };
654
+ })
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],
666
+ queryFn: async () => {
667
+ try {
668
+ return await M(s).count(L);
669
+ } catch (r) {
670
+ throw g.current && g.current(r), r;
671
+ }
672
+ },
673
+ staleTime: 30 * 1e3,
674
+ gcTime: 60 * 1e3
675
+ }), At = ut({
676
+ mutationFn: async (r) => {
677
+ const o = r.position ?? 999999;
678
+ return (await M(s).create({ ...r, position: o }))._id;
679
+ },
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,
689
+ _created_at: /* @__PURE__ */ new Date(),
690
+ _modified_at: /* @__PURE__ */ new Date()
691
+ };
692
+ S.setQueryData(u, {
693
+ ...w,
694
+ Data: [...w.Data, x]
695
+ });
696
+ }
697
+ return { previousCards: w, queryKey: u };
698
+ },
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
704
+ });
705
+ },
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);
709
+ },
710
+ onSettled: (r, o, n) => {
711
+ const u = n.columnId, w = h(u);
712
+ S.invalidateQueries({ queryKey: ["kanban-cards", s, u, w] });
713
+ }
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 });
720
+ },
721
+ onError: (r, o, n) => {
722
+ var u;
723
+ (u = g.current) == null || u.call(g, r);
724
+ },
725
+ onSettled: () => {
726
+ S.invalidateQueries({ queryKey: ["kanban-cards", s] });
727
+ }
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);
734
+ },
735
+ onError: (r, o, n) => {
736
+ var u;
737
+ (u = g.current) == null || u.call(g, r);
738
+ },
739
+ onSettled: () => {
740
+ S.invalidateQueries({ queryKey: ["kanban-cards", s] });
741
+ }
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 };
746
+ },
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,
761
+ _modified_at: /* @__PURE__ */ new Date()
762
+ }, de = {
763
+ ...ot,
764
+ Data: [...ot.Data, le].sort((Ot, he) => Ot.position - he.position)
765
+ };
766
+ S.setQueryData(j, wt), S.setQueryData(st, de);
767
+ }
768
+ }
769
+ return {
770
+ previousFromData: x,
771
+ previousToData: ot,
772
+ fromQueryKey: j,
773
+ toQueryKey: st,
774
+ fromColumnId: o,
775
+ toColumnId: n
776
+ };
777
+ },
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
785
+ );
786
+ },
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);
790
+ },
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] });
794
+ }
795
+ }), Dt = ut({
796
+ mutationFn: async ({ cardIds: r, columnId: o }) => {
797
+ const n = r.map((u, w) => ({ id: u, position: w, columnId: o }));
798
+ await Promise.all(
799
+ n.map(
800
+ (u) => M(s).update(u.id, { position: u.position, columnId: u.columnId })
801
+ )
802
+ );
803
+ },
804
+ onMutate: async ({ columnId: r }) => {
805
+ const o = h(r), n = ["kanban-cards", s, r, o];
806
+ return await S.cancelQueries({ queryKey: n }), {};
807
+ },
808
+ onSuccess: () => {
809
+ },
810
+ onError: (r, o, n) => {
811
+ var u;
812
+ (u = g.current) == null || u.call(g, r);
813
+ },
814
+ onSettled: (r, o, n) => {
815
+ const u = h(n.columnId);
816
+ S.invalidateQueries({ queryKey: ["kanban-cards", s, n.columnId, u] });
817
+ }
818
+ }), Mt = _(
819
+ async (r, o, n) => {
820
+ try {
821
+ await nt.mutateAsync({
822
+ cardId: r._id,
823
+ fromColumnId: o,
824
+ toColumnId: n,
825
+ position: void 0
826
+ });
827
+ } catch {
828
+ }
829
+ },
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) || [];
834
+ return {
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),
841
+ _created_at: /* @__PURE__ */ new Date(),
842
+ _modified_at: /* @__PURE__ */ new Date()
843
+ };
844
+ }), [e, c]), A = Ae({
845
+ onCardMove: Mt,
846
+ onError: g.current,
847
+ columns: ft,
848
+ announceMove: (r, o, n) => {
849
+ console.log(
850
+ `Kanban: Moved "${r.title}" from ${o} to ${n}`
851
+ );
852
+ }
853
+ }), te = _(
854
+ (r) => {
855
+ var o, n;
856
+ return {
857
+ draggable: !0,
858
+ role: "option",
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);
866
+ },
867
+ onDragEnd: A.handleDragEnd,
868
+ onKeyDown: (u) => {
869
+ if (!t) return;
870
+ const w = u.nativeEvent || u;
871
+ A.handleKeyDown(w, r);
872
+ }
873
+ };
874
+ },
875
+ [t, A]
876
+ ), ee = _(
877
+ (r) => ({
878
+ "data-column-id": r,
879
+ role: "listbox",
880
+ onDragOver: (o) => {
881
+ if (!t) return;
882
+ const n = o.nativeEvent || o;
883
+ A.handleDragOver(n, r);
884
+ },
885
+ onDrop: (o) => {
886
+ if (!t) return;
887
+ const n = o.nativeEvent || o;
888
+ A.handleDrop(n, r);
889
+ }
890
+ }),
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"
901
+ });
902
+ }, [S]);
903
+ return _t(() => {
904
+ pt && g.current && g.current(pt);
905
+ }, [pt]), {
906
+ // Data
907
+ columns: ft,
908
+ totalCards: ie,
909
+ // Loading States
910
+ isLoading: ae,
911
+ isFetching: ne,
912
+ isUpdating: oe,
913
+ // Error Handling
914
+ error: pt,
915
+ // Card Operations (Flat Access)
916
+ createCard: At.mutateAsync,
917
+ updateCard: _(
918
+ async (r, o) => {
919
+ await bt.mutateAsync({ id: r, updates: o });
920
+ },
921
+ [bt]
922
+ ),
923
+ deleteCard: _(
924
+ async (r) => {
925
+ await Ct.mutateAsync(r);
926
+ },
927
+ [Ct]
928
+ ),
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;
935
+ break;
936
+ }
937
+ if (!u)
938
+ throw new Error(`Card ${r} not found in any column`);
939
+ }
940
+ await nt.mutateAsync({ cardId: r, fromColumnId: u, toColumnId: o, position: n });
941
+ },
942
+ [nt, ft]
943
+ ),
944
+ reorderCards: _(
945
+ async (r, o) => {
946
+ await Dt.mutateAsync({ cardIds: r, columnId: o });
947
+ },
948
+ [Dt]
949
+ ),
950
+ // Search (Flat Access)
951
+ searchQuery: C.query,
952
+ setSearchQuery: re,
953
+ clearSearch: se,
954
+ // Filter (Simplified chainable API)
955
+ filter: V,
956
+ // Drag Drop (Flat Access)
957
+ isDragging: t ? A.isDragging : !1,
958
+ draggedCard: t ? A.draggedCard : null,
959
+ dragOverColumn: t ? A.dragOverColumn : null,
960
+ handleDragStart: t ? A.handleDragStart : () => {
961
+ },
962
+ handleDragOver: t ? A.handleDragOver : () => {
963
+ },
964
+ handleDrop: t ? A.handleDrop : () => {
965
+ },
966
+ handleDragEnd: t ? A.handleDragEnd : () => {
967
+ },
968
+ handleKeyDown: t ? A.handleKeyDown : () => {
969
+ },
970
+ // Prop Getters
971
+ getCardProps: t ? te : (r) => ({}),
972
+ getColumnProps: t ? ee : (r) => ({}),
973
+ // Load More (Per Column)
974
+ loadMore: _((r) => {
975
+ J((o) => ({
976
+ ...o,
977
+ [r]: (o[r] || 10) + 10
978
+ }));
979
+ }, []),
980
+ // Utilities
981
+ refetch: ue,
982
+ refresh: ce
983
+ };
984
+ }
985
+ const Te = ge(null);
986
+ function Ue() {
987
+ const a = fe(Te);
988
+ if (!a)
989
+ throw new Error(
990
+ "Kanban components must be used within a KanbanBoard component"
991
+ );
992
+ return a;
993
+ }
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)
999
+ }));
1000
+ }
1001
+ function Be(a, e) {
1002
+ if (a.cards.length === 0)
1003
+ return 0;
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);
1009
+ }
1010
+ const s = a.cards[e - 1], t = a.cards[e];
1011
+ return Math.floor((s.position + t.position) / 2);
1012
+ }
1013
+ function Xe(a, e) {
1014
+ if (a.length === 0)
1015
+ return 0;
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);
1021
+ }
1022
+ const s = a[e - 1], t = a[e];
1023
+ return Math.floor((s.position + t.position) / 2);
1024
+ }
1025
+ function ze(a) {
1026
+ return a.sort((e, s) => e.position - s.position).map((e, s) => ({
1027
+ ...e,
1028
+ position: s
1029
+ }));
1030
+ }
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`);
1034
+ }
1035
+ function Ye(a, e) {
1036
+ switch (e) {
1037
+ case "list":
1038
+ return a && Array.isArray(a.Data);
1039
+ case "single":
1040
+ return a && typeof a == "object";
1041
+ case "create":
1042
+ return a && typeof a._id == "string";
1043
+ case "delete":
1044
+ return a && a.status === "success";
1045
+ default:
1046
+ return !1;
1047
+ }
1048
+ }
1049
+ export {
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
1060
+ };