@fluid-app/fluid-cli-theme-dev 0.1.172 → 0.1.173

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 (92) hide show
  1. package/dist/dist-cli-preview/.vite/manifest.json +583 -181
  2. package/dist/dist-cli-preview/account-screens.css +1 -0
  3. package/dist/dist-cli-preview/account-screens.js +1 -1
  4. package/dist/dist-cli-preview/chunks/{Breadcrumb-BQKo8hPc.js → Breadcrumb-8-7shsB6.js} +1 -1
  5. package/dist/dist-cli-preview/chunks/Combobox-m3vSk0_A.js +521 -0
  6. package/dist/dist-cli-preview/chunks/{ContactsScreen-IsIZ_lQ0.js → ContactsScreen-CBjQOWmH.js} +1523 -1854
  7. package/dist/dist-cli-preview/chunks/MediaScreen-1akMnH12.js +17379 -0
  8. package/dist/dist-cli-preview/chunks/{MemberManagementProviders-DiQkiWzc.js → MemberManagementProviders-WSjb3a8B.js} +189 -199
  9. package/dist/dist-cli-preview/chunks/{MessagingScreen-B8ZxAE0L.js → MessagingScreen-By-jZq6v.js} +27645 -30195
  10. package/dist/dist-cli-preview/chunks/{MobileActionSheet-DMeTsLlK.js → MobileActionSheet-ERpw3qUF.js} +644 -589
  11. package/dist/dist-cli-preview/chunks/MySiteScreen-JAGvVMx-.js +1706 -0
  12. package/dist/dist-cli-preview/chunks/OrdersScreen-B1HQVMZC.js +9 -0
  13. package/dist/dist-cli-preview/chunks/{OrdersScreen-DrZ3SwEu.js → OrdersScreen-Cb32bBjd.js} +35 -35
  14. package/dist/dist-cli-preview/chunks/PortalTenantClientProvider-CguU_uRG.js +15 -0
  15. package/dist/dist-cli-preview/chunks/{ProfileScreen-Dxspc-6p.js → ProfileScreen-CCWM6TBs.js} +454 -463
  16. package/dist/dist-cli-preview/chunks/Select-5fzq5MB-.js +940 -0
  17. package/dist/dist-cli-preview/chunks/{SubscriptionsScreen-Be0C29uw.js → SubscriptionsScreen-DLdsaVJK.js} +3 -3
  18. package/dist/dist-cli-preview/chunks/Textarea-xoKqLVgY.js +330 -0
  19. package/dist/dist-cli-preview/chunks/{account-screen-runtime-DYMunv0A.js → account-screen-runtime-CCBl8DXt.js} +866 -860
  20. package/dist/dist-cli-preview/chunks/ar-D6LJV1_E.js +679 -0
  21. package/dist/dist-cli-preview/chunks/{arrow-left-Bd7dJtIV.js → arrow-left-CTYaRdTX.js} +1 -1
  22. package/dist/dist-cli-preview/chunks/bg-C5Ldmily.js +679 -0
  23. package/dist/dist-cli-preview/chunks/bn-kfMPWNR6.js +679 -0
  24. package/dist/dist-cli-preview/chunks/{cli-preview-C7Db08Ij.js → cli-preview-HAt0Lt-9.js} +20 -13
  25. package/dist/dist-cli-preview/chunks/{client.gen-Ck6Pm2jV.js → client.gen-B7RMYGYu.js} +1 -1
  26. package/dist/dist-cli-preview/chunks/copy-DHN1DxE_.js +14 -0
  27. package/dist/dist-cli-preview/chunks/{countries-api-adapter-InKUzF1q.js → countries-api-adapter-B4TefdRP.js} +2 -2
  28. package/dist/dist-cli-preview/chunks/{create-card-entry-container-C9z7JILL.js → create-card-entry-container-5NqOQ4D_.js} +3612 -3932
  29. package/dist/dist-cli-preview/chunks/cs-DqEgtV8D.js +679 -0
  30. package/dist/dist-cli-preview/chunks/da-BbuvL7Gx.js +679 -0
  31. package/dist/dist-cli-preview/chunks/de-BfJ7rQig.js +679 -0
  32. package/dist/dist-cli-preview/chunks/el-BO0rLq6D.js +679 -0
  33. package/dist/dist-cli-preview/chunks/es-BEVtEUXk.js +679 -0
  34. package/dist/dist-cli-preview/chunks/eye-qMoMW7-Z.js +20 -0
  35. package/dist/dist-cli-preview/chunks/fi-DjISV3UN.js +679 -0
  36. package/dist/dist-cli-preview/chunks/fr-1fFd-aKy.js +679 -0
  37. package/dist/dist-cli-preview/chunks/he-CaT9bwVp.js +679 -0
  38. package/dist/dist-cli-preview/chunks/{hey-api-client-DGRBsZ7Y.js → hey-api-client-JMNyZwcF.js} +79 -39
  39. package/dist/dist-cli-preview/chunks/hi-DkzEm57l.js +679 -0
  40. package/dist/dist-cli-preview/chunks/hr-DqM5N_bj.js +679 -0
  41. package/dist/dist-cli-preview/chunks/hu-DiLqjo5c.js +679 -0
  42. package/dist/dist-cli-preview/chunks/id-DA1KmwgX.js +679 -0
  43. package/dist/dist-cli-preview/chunks/index-BS4PnEcu.js +353 -0
  44. package/dist/dist-cli-preview/chunks/index-BhMjUmAr.js +2572 -0
  45. package/dist/dist-cli-preview/chunks/{screen-route-slug-utils-BDjSpDoe.js → index-Dor8vM2o.js} +2417 -3035
  46. package/dist/dist-cli-preview/chunks/it-CTEVWCRz.js +679 -0
  47. package/dist/dist-cli-preview/chunks/ja-fxqg1hhg.js +679 -0
  48. package/dist/dist-cli-preview/chunks/ko-Btp1_5YS.js +679 -0
  49. package/dist/dist-cli-preview/chunks/lock-DQTMeEw0.js +14 -0
  50. package/dist/dist-cli-preview/chunks/{log-out-CSPZjXTK.js → log-out-DUdRJX4l.js} +1 -1
  51. package/dist/dist-cli-preview/chunks/{map-pin-B2ScoijR.js → map-pin-DyIkpqP0.js} +1 -1
  52. package/dist/dist-cli-preview/chunks/media-vkLeBb90.js +4 -0
  53. package/dist/dist-cli-preview/chunks/member-permissions-ndhNmlOk.js +19 -0
  54. package/dist/dist-cli-preview/chunks/{mount-account-screen-5thBUz3X.js → mount-account-screen--gdc5WO_.js} +1869 -1884
  55. package/dist/dist-cli-preview/chunks/ms-DqRbmHx8.js +679 -0
  56. package/dist/dist-cli-preview/chunks/navigate-account-screen-AVNopuIP.js +38 -0
  57. package/dist/dist-cli-preview/chunks/nl-CkPNddxO.js +679 -0
  58. package/dist/dist-cli-preview/chunks/no-ftcy0RcQ.js +679 -0
  59. package/dist/dist-cli-preview/chunks/pl-wyJLqfip.js +679 -0
  60. package/dist/dist-cli-preview/chunks/{plus-CocoE5gC.js → plus-DZjrp536.js} +1 -1
  61. package/dist/dist-cli-preview/chunks/pt-7uHLacuI.js +679 -0
  62. package/dist/dist-cli-preview/chunks/ro-Dh12ghww.js +679 -0
  63. package/dist/dist-cli-preview/chunks/ru-DFM7xWFz.js +679 -0
  64. package/dist/dist-cli-preview/chunks/{schemas-D94nZk5x.js → schemas-BTblatUV.js} +1107 -1062
  65. package/dist/dist-cli-preview/chunks/screen-route-slug-utils-DozJp-uc.js +620 -0
  66. package/dist/dist-cli-preview/chunks/{sheet-haptics-context-iOjKcNDj.js → sheet-haptics-context-CYrEaGtf.js} +3 -3
  67. package/dist/dist-cli-preview/chunks/sidebar-9qopXeR1.js +598 -0
  68. package/dist/dist-cli-preview/chunks/sk-CsuNYa1k.js +679 -0
  69. package/dist/dist-cli-preview/chunks/sortable.esm-Dlen88Fc.js +3283 -0
  70. package/dist/dist-cli-preview/chunks/{store-api-context-B96Ip2FB.js → store-api-context-B9pW_xao.js} +1 -1
  71. package/dist/dist-cli-preview/chunks/sv-DVrPaJbh.js +679 -0
  72. package/dist/dist-cli-preview/chunks/th-BEkMpcVW.js +679 -0
  73. package/dist/dist-cli-preview/chunks/tl-CqwwplQC.js +679 -0
  74. package/dist/dist-cli-preview/chunks/tr-XEp4ekrM.js +679 -0
  75. package/dist/dist-cli-preview/chunks/{trash-2-wVweQZMw.js → trash-2-ClRyi9iY.js} +12 -12
  76. package/dist/dist-cli-preview/chunks/uk-DWdZFWBl.js +679 -0
  77. package/dist/dist-cli-preview/chunks/use-mobile-srOt50VV.js +254 -0
  78. package/dist/dist-cli-preview/chunks/{use-optional-store-lZUz976C.js → use-optional-store-BgrOjfZJ.js} +2 -2
  79. package/dist/dist-cli-preview/chunks/{use-store-DVmgsDXy.js → use-store-CUSQx1E-.js} +25 -36
  80. package/dist/dist-cli-preview/chunks/{useInfiniteQuery-Dtzov9uh.js → useInfiniteQuery-DGc8fotv.js} +1 -1
  81. package/dist/dist-cli-preview/chunks/user-Ca2sKJ-h.js +14 -0
  82. package/dist/dist-cli-preview/chunks/users-Dh7zTrKY.js +16 -0
  83. package/dist/dist-cli-preview/chunks/vi-H__PaPsC.js +679 -0
  84. package/dist/dist-cli-preview/chunks/zh_CN-B62j_w_1.js +679 -0
  85. package/dist/dist-cli-preview/chunks/zh_TW-CYUIGBvP.js +679 -0
  86. package/package.json +1 -1
  87. package/dist/dist-cli-preview/chunks/Combobox-cf11L_T-.js +0 -1455
  88. package/dist/dist-cli-preview/chunks/MySiteScreen-Dtw1rsF9.js +0 -4950
  89. package/dist/dist-cli-preview/chunks/OrdersScreen-DkltVCtr.js +0 -9
  90. package/dist/dist-cli-preview/chunks/sidebar-Ckzom4Xc.js +0 -848
  91. package/dist/dist-cli-preview/chunks/user-B81IrSgp.js +0 -31
  92. package/dist/dist-cli-preview/chunks/users-BXTjoCUz.js +0 -27
@@ -1,4950 +0,0 @@
1
- import { c as bt, j as i, M as ke, l, U as xt, W as De, X as yr, b6 as wr, O as T, L as _r, R as W, _ as Qe, a1 as ln, B as Cr, a0 as cn, bz as Sr, E as jr, a2 as Nr, aE as Dr, z as kr } from "./account-screen-runtime-DYMunv0A.js";
2
- import { u as Ee, C as Er, o as se, n as U, s as D, b as Pt, R as Ot, D as Ft, P as Rr } from "./schemas-D94nZk5x.js";
3
- import { c as Mr, a as Ar } from "./client.gen-Ck6Pm2jV.js";
4
- import { B as Lr, a as Ir, b as un, d as Tr, c as dn, e as Pr } from "./Breadcrumb-BQKo8hPc.js";
5
- import { c as Or, a as Fr, b as zr, u as Br, S as de, I as fn } from "./sheet-haptics-context-iOjKcNDj.js";
6
- import { E as $r, U as qr } from "./user-B81IrSgp.js";
7
- import { U as Kr, C as Ur } from "./users-BXTjoCUz.js";
8
- import { A as Ut } from "./arrow-left-Bd7dJtIV.js";
9
- import { u as Hr, T as Ht } from "./trash-2-wVweQZMw.js";
10
- import { u as En } from "./sidebar-Ckzom4Xc.js";
11
- import { P as hn } from "./plus-CocoE5gC.js";
12
- /**
13
- * @license lucide-react v0.575.0 - ISC
14
- *
15
- * This source code is licensed under the ISC license.
16
- * See the LICENSE file in the root directory of this source tree.
17
- */
18
- const Yr = [
19
- ["circle", { cx: "9", cy: "12", r: "1", key: "1vctgf" }],
20
- ["circle", { cx: "9", cy: "5", r: "1", key: "hp0tcf" }],
21
- ["circle", { cx: "9", cy: "19", r: "1", key: "fkjjf6" }],
22
- ["circle", { cx: "15", cy: "12", r: "1", key: "1tmaij" }],
23
- ["circle", { cx: "15", cy: "5", r: "1", key: "19l28e" }],
24
- ["circle", { cx: "15", cy: "19", r: "1", key: "f4zoj3" }]
25
- ], Rn = bt("grip-vertical", Yr);
26
- /**
27
- * @license lucide-react v0.575.0 - ISC
28
- *
29
- * This source code is licensed under the ISC license.
30
- * See the LICENSE file in the root directory of this source tree.
31
- */
32
- const Xr = [
33
- ["rect", { width: "7", height: "7", x: "3", y: "3", rx: "1", key: "1g98yp" }],
34
- ["rect", { width: "7", height: "7", x: "14", y: "3", rx: "1", key: "6d4xhi" }],
35
- ["rect", { width: "7", height: "7", x: "14", y: "14", rx: "1", key: "nxv5o0" }],
36
- ["rect", { width: "7", height: "7", x: "3", y: "14", rx: "1", key: "1bb6yr" }]
37
- ], Wr = bt("layout-grid", Xr);
38
- /**
39
- * @license lucide-react v0.575.0 - ISC
40
- *
41
- * This source code is licensed under the ISC license.
42
- * See the LICENSE file in the root directory of this source tree.
43
- */
44
- const Qr = [
45
- ["path", { d: "M9 17H7A5 5 0 0 1 7 7h2", key: "8i5ue5" }],
46
- ["path", { d: "M15 7h2a5 5 0 1 1 0 10h-2", key: "1b9ql8" }],
47
- ["line", { x1: "8", x2: "16", y1: "12", y2: "12", key: "1jonct" }]
48
- ], Vr = bt("link-2", Qr);
49
- /**
50
- * @license lucide-react v0.575.0 - ISC
51
- *
52
- * This source code is licensed under the ISC license.
53
- * See the LICENSE file in the root directory of this source tree.
54
- */
55
- const Gr = [
56
- [
57
- "path",
58
- {
59
- d: "M12 22a1 1 0 0 1 0-20 10 9 0 0 1 10 9 5 5 0 0 1-5 5h-2.25a1.75 1.75 0 0 0-1.4 2.8l.3.4a1.75 1.75 0 0 1-1.4 2.8z",
60
- key: "e79jfc"
61
- }
62
- ],
63
- ["circle", { cx: "13.5", cy: "6.5", r: ".5", fill: "currentColor", key: "1okk4w" }],
64
- ["circle", { cx: "17.5", cy: "10.5", r: ".5", fill: "currentColor", key: "f64h9f" }],
65
- ["circle", { cx: "6.5", cy: "12.5", r: ".5", fill: "currentColor", key: "qy21gx" }],
66
- ["circle", { cx: "8.5", cy: "7.5", r: ".5", fill: "currentColor", key: "fotxhn" }]
67
- ], Mn = bt("palette", Gr);
68
- function ze({
69
- className: e,
70
- ...t
71
- }) {
72
- return /* @__PURE__ */ i.jsx(
73
- "div",
74
- {
75
- "data-slot": "card",
76
- className: ke(
77
- "bg-card text-card-foreground flex h-full flex-col gap-6 rounded-xl border py-6 shadow-sm",
78
- e
79
- ),
80
- ...t
81
- }
82
- );
83
- }
84
- function Yt({
85
- className: e,
86
- ...t
87
- }) {
88
- return /* @__PURE__ */ i.jsx(
89
- "div",
90
- {
91
- "data-slot": "card-header",
92
- className: ke(
93
- "@container/card-header grid auto-rows-min grid-rows-[auto_auto] items-start gap-2 px-6 has-data-[slot=card-action]:grid-cols-[1fr_auto] [.border-b]:pb-6",
94
- e
95
- ),
96
- ...t
97
- }
98
- );
99
- }
100
- function An({
101
- className: e,
102
- ...t
103
- }) {
104
- return /* @__PURE__ */ i.jsx(
105
- "div",
106
- {
107
- "data-slot": "card-title",
108
- className: ke("leading-none font-semibold", e),
109
- ...t
110
- }
111
- );
112
- }
113
- function Jr({
114
- className: e,
115
- ...t
116
- }) {
117
- return /* @__PURE__ */ i.jsx(
118
- "div",
119
- {
120
- "data-slot": "card-action",
121
- className: ke(
122
- "col-start-2 row-span-2 row-start-1 self-start justify-self-end",
123
- e
124
- ),
125
- ...t
126
- }
127
- );
128
- }
129
- function yt({
130
- className: e,
131
- ...t
132
- }) {
133
- return /* @__PURE__ */ i.jsx(
134
- "div",
135
- {
136
- "data-slot": "card-content",
137
- className: ke("px-6", e),
138
- ...t
139
- }
140
- );
141
- }
142
- const Ln = l.createContext(null), Zr = Ln.Provider;
143
- function oe() {
144
- const e = l.use(Ln);
145
- if (!e)
146
- throw new Error("useMySiteApi must be used within a MySiteApiProvider");
147
- return e;
148
- }
149
- function es(e) {
150
- return e instanceof DOMException && e.name === "AbortError" || e instanceof Error && e.name === "AbortError";
151
- }
152
- function ts(e) {
153
- const t = Mr({
154
- baseUrl: e.baseUrl,
155
- credentials: "include",
156
- fetch: e.fetch,
157
- headers: {
158
- Accept: "application/json",
159
- "Content-Type": "application/json",
160
- ...e.defaultHeaders
161
- },
162
- throwOnError: !0
163
- });
164
- return t.interceptors.request.use((n) => {
165
- const r = e.getDefaultHeaders?.();
166
- if (!r)
167
- return n;
168
- const s = new Headers(n.headers);
169
- for (const [o, a] of Object.entries(r))
170
- s.set(o, a);
171
- return new Request(n, { headers: s });
172
- }), t.interceptors.error.use(
173
- Ar({
174
- onResponseError: (n) => {
175
- n.status === 401 && e.onAuthError?.();
176
- },
177
- shouldPassThroughTransportError: es
178
- })
179
- ), t;
180
- }
181
- const ns = (e) => e.client.get({
182
- responseStyle: "data",
183
- url: "/api/mysite/profile",
184
- ...e
185
- }), mn = (e) => e.client.put({
186
- responseStyle: "data",
187
- url: "/api/mysite/profile",
188
- ...e,
189
- headers: {
190
- "Content-Type": "application/json",
191
- ...e.headers
192
- }
193
- }), rs = (e) => e.client.get({
194
- responseStyle: "data",
195
- url: "/api/mysite/themes",
196
- ...e
197
- }), ss = (e) => e.client.put({
198
- responseStyle: "data",
199
- url: "/api/mysite/settings",
200
- ...e,
201
- headers: {
202
- "Content-Type": "application/json",
203
- ...e.headers
204
- }
205
- }), is = (e) => e.client.get({
206
- responseStyle: "data",
207
- url: "/api/mysite/links",
208
- ...e
209
- }), os = (e) => e.client.post({
210
- responseStyle: "data",
211
- url: "/api/mysite/links",
212
- ...e,
213
- headers: {
214
- "Content-Type": "application/json",
215
- ...e.headers
216
- }
217
- }), as = (e) => e.client.delete({
218
- responseStyle: "data",
219
- url: "/api/mysite/links/{id}",
220
- ...e
221
- }), ls = (e) => e.client.put({
222
- responseStyle: "data",
223
- url: "/api/mysite/links/{id}",
224
- ...e,
225
- headers: {
226
- "Content-Type": "application/json",
227
- ...e.headers
228
- }
229
- }), cs = (e) => e.client.patch({
230
- responseStyle: "data",
231
- url: "/api/mysite/links/bulk",
232
- ...e,
233
- headers: {
234
- "Content-Type": "application/json",
235
- ...e.headers
236
- }
237
- }), us = (e) => e.client.get({
238
- responseStyle: "data",
239
- url: "/api/mysite/favorites",
240
- ...e
241
- }), ds = (e) => e.client.post({
242
- responseStyle: "data",
243
- url: "/api/mysite/favorites",
244
- ...e,
245
- headers: {
246
- "Content-Type": "application/json",
247
- ...e.headers
248
- }
249
- }), fs = (e) => e.client.delete({
250
- responseStyle: "data",
251
- url: "/api/mysite/favorites/{id}",
252
- ...e
253
- }), hs = (e) => e.client.patch({
254
- responseStyle: "data",
255
- url: "/api/mysite/favorites/bulk",
256
- ...e,
257
- headers: {
258
- "Content-Type": "application/json",
259
- ...e.headers
260
- }
261
- });
262
- function pn(e) {
263
- return {
264
- id: e.id ?? 0,
265
- mysite_url: e.mysite_url ?? null,
266
- mysite_views: e.mysite_views ?? 0,
267
- mysite_leads: e.mysite_leads ?? 0,
268
- theme_id: e.theme_id ?? null,
269
- bio: e.bio ?? null,
270
- avatar_url: e.avatar_url ?? null,
271
- display_name: e.display_name ?? null,
272
- slug: e.slug ?? null
273
- };
274
- }
275
- function lt(e) {
276
- return {
277
- id: e.id ?? 0,
278
- url: e.url ?? "",
279
- title: e.title ?? "",
280
- position: e.position ?? 0
281
- };
282
- }
283
- function Mt(e) {
284
- return {
285
- id: e.id ?? 0,
286
- favoriteable_id: e.favoriteable_id ?? e.product_id ?? 0,
287
- favoriteable_type: e.favoriteable_type ?? "Product",
288
- name: e.name ?? e.product_name ?? null,
289
- image_url: e.image_url ?? e.product_image_url ?? null,
290
- product_id: e.product_id ?? e.favoriteable_id ?? 0,
291
- product_name: e.product_name ?? e.name ?? null,
292
- product_image_url: e.product_image_url ?? e.image_url ?? null,
293
- position: e.position ?? 0,
294
- created_at: e.created_at ?? null
295
- };
296
- }
297
- function ms(e) {
298
- return {
299
- id: e.id ?? 0,
300
- name: e.name ?? "",
301
- preview_url: e.preview_url ?? null
302
- };
303
- }
304
- function ps(e) {
305
- return {
306
- fetchProfile: async () => {
307
- const t = await ns({ client: e });
308
- return pn(t.profile ?? {});
309
- },
310
- updateProfile: async (t) => {
311
- const n = await mn({
312
- client: e,
313
- body: {
314
- profile: {
315
- display_name: t.display_name,
316
- bio: t.bio,
317
- avatar_url: t.avatar_url
318
- }
319
- }
320
- });
321
- return pn(n.profile ?? {});
322
- },
323
- updateSettings: async (t) => {
324
- await Promise.all([
325
- t.theme_id !== void 0 ? ss({
326
- client: e,
327
- body: { settings: { theme_id: t.theme_id } }
328
- }) : Promise.resolve(),
329
- t.slug !== void 0 ? mn({
330
- client: e,
331
- body: { profile: { slug: t.slug } }
332
- }) : Promise.resolve()
333
- ]);
334
- },
335
- listLinks: async () => ((await is({ client: e })).links ?? []).map(lt),
336
- createLink: async (t) => {
337
- const n = await os({
338
- client: e,
339
- body: { link: { title: t.title, url: t.url } }
340
- });
341
- return lt(n.link ?? {});
342
- },
343
- updateLink: async (t, n) => {
344
- const r = await ls({
345
- client: e,
346
- path: { id: t },
347
- body: { link: { title: n.title, url: n.url } }
348
- });
349
- return lt(r.link ?? {});
350
- },
351
- deleteLink: async (t) => {
352
- await as({ client: e, path: { id: t } });
353
- },
354
- reorderLinks: async (t) => ((await cs({
355
- client: e,
356
- body: { ordered_ids: t }
357
- })).links ?? []).map(lt),
358
- listFavorites: async () => ((await us({ client: e })).favorites ?? []).map(Mt),
359
- addFavorite: async (t) => {
360
- const n = await ds({
361
- client: e,
362
- body: { favorite: { product_id: t.product_id } }
363
- });
364
- return Mt(n.favorite ?? {});
365
- },
366
- deleteFavorite: async (t) => {
367
- await fs({
368
- client: e,
369
- path: { id: t }
370
- });
371
- },
372
- reorderFavorites: async (t) => ((await hs({
373
- client: e,
374
- body: { ordered_ids: t }
375
- })).favorites ?? []).map(Mt),
376
- listThemes: async () => ((await rs({ client: e })).themes ?? []).map(ms)
377
- };
378
- }
379
- const gs = {
380
- heading: "MySite",
381
- nav_profile: "Profile",
382
- nav_theme: "Theme",
383
- nav_content: "MySite Content",
384
- nav_buttons: "Buttons",
385
- visitor_details: "Visitor Details",
386
- views: "Views",
387
- leads: "Leads",
388
- your_mysite_link: "Your MySite Link",
389
- edit_link: "Edit Link",
390
- not_configured: "Not configured",
391
- slug_empty_error: "Slug cannot be empty",
392
- link_updated: "MySite link updated",
393
- link_update_failed: "Failed to update link",
394
- link_copied: "Link copied to clipboard",
395
- link_copy_failed: "Failed to copy link",
396
- cancel: "Cancel",
397
- save: "Save",
398
- saving: "Saving...",
399
- delete: "Delete",
400
- deleting: "Deleting...",
401
- remove: "Remove",
402
- removing: "Removing...",
403
- current_theme: "Current Theme",
404
- preview: "Preview",
405
- mysite_preview: "MySite Preview",
406
- no_site_configured: "No site configured",
407
- choose_a_theme: "Choose a Theme",
408
- no_themes_available: "No themes available",
409
- buttons_heading: "Buttons",
410
- add_button: "Add Button",
411
- no_buttons_empty: "No buttons yet. Add custom link buttons to display on your MySite.",
412
- drag_to_reorder: "Drag to reorder",
413
- edit_button_aria: "Edit button",
414
- delete_button_aria: "Delete button",
415
- edit_button_dialog: "Edit Button",
416
- add_button_dialog: "Add Button",
417
- button_text_label: "Button Text",
418
- button_text_placeholder: "Enter button text...",
419
- url_label: "URL",
420
- url_placeholder: "https://example.com",
421
- button_updated: "Button updated",
422
- button_update_failed: "Failed to update button",
423
- button_created: "Button created",
424
- button_create_failed: "Failed to create button",
425
- delete_button_dialog: "Delete Button",
426
- delete_button_confirm: 'Are you sure you want to delete the button "{{name}}"? This action cannot be undone.',
427
- button_deleted: "Button deleted",
428
- button_delete_failed: "Failed to delete button",
429
- reorder_buttons_failed: "Failed to reorder buttons",
430
- content_heading: "MySite Content",
431
- no_content_empty: "No featured content yet. Favorite products, media, or pages to display on your MySite.",
432
- untitled: "Untitled",
433
- no_image: "N/A",
434
- remove_favorite_aria: "Remove favorite",
435
- remove_content_dialog: "Remove Content",
436
- remove_content_confirm: 'Are you sure you want to remove "{{name}}" from your MySite? This action cannot be undone.',
437
- content_removed: "Content removed",
438
- content_remove_failed: "Failed to remove content",
439
- reorder_content_failed: "Failed to reorder content",
440
- theme_changed: 'Theme changed to "{{name}}"',
441
- theme_update_failed: "Failed to update theme",
442
- type_media: "Media",
443
- type_playlist: "Playlist",
444
- type_enrollment_pack: "Enrollment Pack",
445
- type_page: "Page",
446
- validation_button_text_required: "Button text is required",
447
- validation_url_invalid: "Must be a valid URL",
448
- loading: "Loading...",
449
- default_badge: "Default",
450
- dashboard_breadcrumb: "Dashboard",
451
- mysite_themes_title: "Mysite Themes",
452
- themes_library_heading: "Mysite Theme Library",
453
- no_mysite_themes_found: "No Mysite themes found",
454
- reset_cache: "Reset Cache",
455
- resetting: "Resetting...",
456
- cache_reset_started: "Cache reset started successfully",
457
- cache_reset_failed: "Failed to reset cache",
458
- last_save: "Last save:",
459
- customize: "Customize",
460
- add_theme: "Add Theme",
461
- rename_theme_aria: "Rename theme",
462
- cancel_rename_aria: "Cancel rename",
463
- theme_name_aria: "Theme name",
464
- rename_failed: "Couldn't rename theme. Try again.",
465
- name_validation_error: "Name {{error}}"
466
- }, vs = Fr({
467
- fallback: gs,
468
- loaders: {
469
- ar: () => import("./ar-D_B30x0o.js").then(
470
- (e) => e.default
471
- ),
472
- bg: () => import("./bg-CIgMfa9k.js").then(
473
- (e) => e.default
474
- ),
475
- bn: () => import("./bn-BgnBXWHo.js").then(
476
- (e) => e.default
477
- ),
478
- cs: () => import("./cs-DmLSumGB.js").then(
479
- (e) => e.default
480
- ),
481
- da: () => import("./da-EfkyseOR.js").then(
482
- (e) => e.default
483
- ),
484
- de: () => import("./de-EARi-xk5.js").then(
485
- (e) => e.default
486
- ),
487
- el: () => import("./el-BPz4rb5a.js").then(
488
- (e) => e.default
489
- ),
490
- es: () => import("./es-CFZtv6aF.js").then(
491
- (e) => e.default
492
- ),
493
- fi: () => import("./fi-Bn9_l4IH.js").then(
494
- (e) => e.default
495
- ),
496
- fr: () => import("./fr-BSouGEGN.js").then(
497
- (e) => e.default
498
- ),
499
- he: () => import("./he-BYEZTUry.js").then(
500
- (e) => e.default
501
- ),
502
- hi: () => import("./hi-BLnEaAml.js").then(
503
- (e) => e.default
504
- ),
505
- hr: () => import("./hr-B1T2UY_p.js").then(
506
- (e) => e.default
507
- ),
508
- hu: () => import("./hu-cQw9hgLe.js").then(
509
- (e) => e.default
510
- ),
511
- id: () => import("./id-Zd_5csjz.js").then(
512
- (e) => e.default
513
- ),
514
- it: () => import("./it-CmxC_FIJ.js").then(
515
- (e) => e.default
516
- ),
517
- ja: () => import("./ja-BcOunH2q.js").then(
518
- (e) => e.default
519
- ),
520
- ko: () => import("./ko-CG_0ufw6.js").then(
521
- (e) => e.default
522
- ),
523
- ms: () => import("./ms-DTN7PIDq.js").then(
524
- (e) => e.default
525
- ),
526
- nl: () => import("./nl-x2lc8Ct5.js").then(
527
- (e) => e.default
528
- ),
529
- no: () => import("./no-R8FScfrK.js").then(
530
- (e) => e.default
531
- ),
532
- pl: () => import("./pl-Bl9G1yOR.js").then(
533
- (e) => e.default
534
- ),
535
- pt: () => import("./pt-nD60RpwN.js").then(
536
- (e) => e.default
537
- ),
538
- ro: () => import("./ro-D6ybG7vp.js").then(
539
- (e) => e.default
540
- ),
541
- ru: () => import("./ru-C0oMeuhb.js").then(
542
- (e) => e.default
543
- ),
544
- sk: () => import("./sk-Bpdt_mn0.js").then(
545
- (e) => e.default
546
- ),
547
- sv: () => import("./sv-CEmTDhJy.js").then(
548
- (e) => e.default
549
- ),
550
- th: () => import("./th-F8oLBw5n.js").then(
551
- (e) => e.default
552
- ),
553
- tl: () => import("./tl-BXIS85ly.js").then(
554
- (e) => e.default
555
- ),
556
- tr: () => import("./tr-YXIIDIEV.js").then(
557
- (e) => e.default
558
- ),
559
- uk: () => import("./uk-CYYjeT-V.js").then(
560
- (e) => e.default
561
- ),
562
- vi: () => import("./vi-DT4XS4HU.js").then(
563
- (e) => e.default
564
- ),
565
- zh_CN: () => import("./zh_CN-BeGANQIJ.js").then(
566
- (e) => e.default
567
- ),
568
- zh_TW: () => import("./zh_TW-D9gGVyEb.js").then(
569
- (e) => e.default
570
- )
571
- }
572
- });
573
- function bs(e, t) {
574
- return Or(e, t);
575
- }
576
- const F = {
577
- profile: () => ["portal-mysite", "profile"],
578
- links: () => ["portal-mysite", "links"],
579
- favorites: () => ["portal-mysite", "favorites"],
580
- themes: () => ["portal-mysite", "themes"]
581
- };
582
- function In() {
583
- const e = oe();
584
- return xt({
585
- queryKey: F.profile(),
586
- queryFn: () => e.fetchProfile()
587
- });
588
- }
589
- function xs(e) {
590
- const t = oe(), n = De();
591
- return Ee({
592
- mutationFn: (r) => t.updateSettings(r),
593
- // Awaited so the mutation stays pending until the refetches land. Callers
594
- // otherwise show a success toast over the slug the user just replaced.
595
- onSuccess: async (r, s) => {
596
- await n.invalidateQueries({
597
- queryKey: F.profile()
598
- }), await e?.onSuccess?.(s);
599
- }
600
- });
601
- }
602
- function ys() {
603
- const e = oe();
604
- return xt({
605
- queryKey: F.links(),
606
- queryFn: () => e.listLinks()
607
- });
608
- }
609
- function ws() {
610
- const e = oe(), t = De();
611
- return Ee({
612
- mutationFn: (n) => e.createLink(n),
613
- onSuccess: () => {
614
- t.invalidateQueries({
615
- queryKey: F.links()
616
- });
617
- }
618
- });
619
- }
620
- function _s() {
621
- const e = oe(), t = De();
622
- return Ee({
623
- mutationFn: ({ linkId: n, body: r }) => e.updateLink(n, r),
624
- onSuccess: () => {
625
- t.invalidateQueries({
626
- queryKey: F.links()
627
- });
628
- }
629
- });
630
- }
631
- function Cs() {
632
- const e = oe(), t = De();
633
- return Ee({
634
- mutationFn: (n) => e.deleteLink(n),
635
- onSuccess: () => {
636
- t.invalidateQueries({
637
- queryKey: F.links()
638
- });
639
- }
640
- });
641
- }
642
- function Ss() {
643
- const e = oe(), t = De();
644
- return Ee({
645
- mutationFn: ({
646
- orderedIds: n
647
- }) => e.reorderLinks(n),
648
- onMutate: async ({ optimisticItems: n }) => {
649
- await t.cancelQueries({
650
- queryKey: F.links()
651
- });
652
- const r = t.getQueryData(
653
- F.links()
654
- );
655
- return t.setQueryData(F.links(), n), { previousData: r };
656
- },
657
- onError: (n, r, s) => {
658
- s?.previousData && t.setQueryData(
659
- F.links(),
660
- s.previousData
661
- );
662
- },
663
- onSettled: () => {
664
- t.invalidateQueries({
665
- queryKey: F.links()
666
- });
667
- }
668
- });
669
- }
670
- function js() {
671
- const e = oe();
672
- return xt({
673
- queryKey: F.favorites(),
674
- queryFn: () => e.listFavorites()
675
- });
676
- }
677
- function Ns() {
678
- const e = oe(), t = De();
679
- return Ee({
680
- mutationFn: (n) => e.deleteFavorite(n),
681
- onSuccess: () => {
682
- t.invalidateQueries({
683
- queryKey: F.favorites()
684
- });
685
- }
686
- });
687
- }
688
- function Ds() {
689
- const e = oe(), t = De();
690
- return Ee({
691
- mutationFn: ({
692
- orderedIds: n
693
- }) => e.reorderFavorites(n),
694
- onMutate: async ({ optimisticItems: n }) => {
695
- await t.cancelQueries({
696
- queryKey: F.favorites()
697
- });
698
- const r = t.getQueryData(
699
- F.favorites()
700
- );
701
- return t.setQueryData(F.favorites(), n), { previousData: r };
702
- },
703
- onError: (n, r, s) => {
704
- s?.previousData && t.setQueryData(
705
- F.favorites(),
706
- s.previousData
707
- );
708
- },
709
- onSettled: () => {
710
- t.invalidateQueries({
711
- queryKey: F.favorites()
712
- });
713
- }
714
- });
715
- }
716
- function ks() {
717
- const e = oe();
718
- return xt({
719
- queryKey: F.themes(),
720
- queryFn: () => e.listThemes()
721
- });
722
- }
723
- const { Provider: Es, useTranslation: Rs } = zr("Mysite"), Ms = Es, he = Rs;
724
- function As({
725
- children: e
726
- }) {
727
- const { locale: t } = yr(), n = Br(vs, t), r = l.useMemo(
728
- () => bs(t, n),
729
- [t, n]
730
- );
731
- return /* @__PURE__ */ i.jsx(Ms, { value: r, children: e });
732
- }
733
- const je = 300, ct = 500;
734
- function Ls(e) {
735
- switch (e) {
736
- case "idle":
737
- return "opacity-100 transition-none";
738
- case "fade-out":
739
- return "opacity-0 transition-opacity duration-300 ease-in-out";
740
- case "slide":
741
- return "opacity-0 2xl:translate-x-[50%] transition-transform duration-500 ease-in-out";
742
- case "fade-in":
743
- return "opacity-100 2xl:translate-x-[50%] transition-opacity duration-300 ease-in-out";
744
- case "editing":
745
- return "opacity-100 2xl:translate-x-[50%] transition-none";
746
- case "exit-fade-out":
747
- return "opacity-0 2xl:translate-x-[50%] transition-opacity duration-300 ease-in-out";
748
- case "exit-slide":
749
- return "opacity-0 transition-transform duration-500 ease-in-out";
750
- case "exit-fade-in":
751
- return "opacity-100 transition-opacity duration-300 ease-in-out";
752
- }
753
- }
754
- function Is(e) {
755
- switch (e) {
756
- case "idle":
757
- case "fade-out":
758
- case "exit-fade-in":
759
- return "transition-none";
760
- case "slide":
761
- return "2xl:-translate-x-[200%] transition-transform duration-500 ease-in-out";
762
- case "fade-in":
763
- case "editing":
764
- case "exit-fade-out":
765
- return "2xl:-translate-x-[200%] transition-none";
766
- case "exit-slide":
767
- return "transition-transform duration-500 ease-in-out";
768
- }
769
- }
770
- function Ts({
771
- views: e,
772
- leads: t
773
- }) {
774
- const { t: n } = he();
775
- return /* @__PURE__ */ i.jsxs(ze, { className: "h-auto gap-0 py-0 shadow-none", children: [
776
- /* @__PURE__ */ i.jsx(Yt, { className: "p-4 pb-3", children: /* @__PURE__ */ i.jsx(An, { className: "text-sm", children: n("visitor_details") }) }),
777
- /* @__PURE__ */ i.jsxs(yt, { className: "flex px-4 pb-4", children: [
778
- /* @__PURE__ */ i.jsxs("div", { className: "flex-1", children: [
779
- /* @__PURE__ */ i.jsxs("div", { className: "mb-2 flex items-center gap-1.5", children: [
780
- /* @__PURE__ */ i.jsx($r, { className: "text-muted-foreground size-3.5" }),
781
- /* @__PURE__ */ i.jsx("span", { className: "text-muted-foreground text-sm", children: n("views") })
782
- ] }),
783
- /* @__PURE__ */ i.jsx("p", { className: "text-foreground text-2xl font-bold", children: e.toLocaleString() })
784
- ] }),
785
- /* @__PURE__ */ i.jsx(wr, { orientation: "vertical", className: "bg-border mx-4 h-auto" }),
786
- /* @__PURE__ */ i.jsxs("div", { className: "flex-1", children: [
787
- /* @__PURE__ */ i.jsxs("div", { className: "mb-2 flex items-center gap-1.5", children: [
788
- /* @__PURE__ */ i.jsx(Kr, { className: "text-muted-foreground size-3.5" }),
789
- /* @__PURE__ */ i.jsx("span", { className: "text-muted-foreground text-sm", children: n("leads") })
790
- ] }),
791
- /* @__PURE__ */ i.jsx("p", { className: "text-foreground text-2xl font-bold", children: t.toLocaleString() })
792
- ] })
793
- ] })
794
- ] });
795
- }
796
- function Ps({
797
- mysiteUrl: e,
798
- displayUrl: t,
799
- onUpdateSlug: n,
800
- onToast: r
801
- }) {
802
- const { t: s } = he(), o = t.lastIndexOf("/"), a = o >= 0 ? t.slice(0, o + 1) : "", c = o >= 0 ? t.slice(o + 1) : t, [u, d] = l.useState(!1), [h, f] = l.useState(c), [m, p] = l.useState(!1), x = l.useCallback(() => {
803
- f(c), d(!0);
804
- }, [c]), g = l.useCallback(() => {
805
- d(!1), f(c);
806
- }, [c]), b = l.useCallback(async () => {
807
- const v = h.trim();
808
- if (!v) {
809
- r?.(s("slug_empty_error"), "error");
810
- return;
811
- }
812
- if (v === c) {
813
- d(!1);
814
- return;
815
- }
816
- if (n) {
817
- p(!0);
818
- try {
819
- await n(v), r?.(s("link_updated"), "success"), d(!1);
820
- } catch {
821
- r?.(s("link_update_failed"), "error");
822
- } finally {
823
- p(!1);
824
- }
825
- }
826
- }, [h, c, n, r, s]), w = l.useCallback(async () => {
827
- if (e)
828
- try {
829
- await navigator.clipboard.writeText(e), r?.(s("link_copied"), "success");
830
- } catch {
831
- r?.(s("link_copy_failed"), "error");
832
- }
833
- }, [e, r, s]);
834
- return /* @__PURE__ */ i.jsxs(ze, { className: "h-auto gap-0 py-0 shadow-none", children: [
835
- /* @__PURE__ */ i.jsxs(Yt, { className: "items-center p-4", children: [
836
- /* @__PURE__ */ i.jsx(An, { className: "text-sm", children: s("your_mysite_link") }),
837
- !u && n && /* @__PURE__ */ i.jsx(Jr, { children: /* @__PURE__ */ i.jsx(T, { variant: "link", size: "sm", onClick: x, children: s("edit_link") }) })
838
- ] }),
839
- /* @__PURE__ */ i.jsxs(yt, { className: "px-4 pb-4", children: [
840
- /* @__PURE__ */ i.jsxs("div", { className: "text-foreground flex items-center gap-2 rounded-lg border bg-gradient-to-r from-[rgba(72,187,120,0.2)] via-[rgba(236,72,153,0.15)] to-[rgba(251,146,60,0.15)] px-3 py-2.5", children: [
841
- u ? /* @__PURE__ */ i.jsxs(i.Fragment, { children: [
842
- /* @__PURE__ */ i.jsx("span", { className: "shrink-0 text-sm", children: a }),
843
- /* @__PURE__ */ i.jsx(
844
- "input",
845
- {
846
- type: "text",
847
- value: h,
848
- onChange: (v) => f(v.target.value),
849
- onKeyDown: (v) => {
850
- v.key === "Enter" && !m && b(), v.key === "Escape" && g();
851
- },
852
- className: "border-input text-foreground focus:ring-primary bg-background/60 min-w-0 flex-1 rounded-md border px-2 py-1 text-sm font-medium outline-none focus:ring-1",
853
- autoFocus: !0
854
- }
855
- )
856
- ] }) : /* @__PURE__ */ i.jsx("span", { className: "min-w-0 flex-1 truncate text-sm", children: t || s("not_configured") }),
857
- /* @__PURE__ */ i.jsx(
858
- T,
859
- {
860
- variant: "ghost",
861
- size: "icon",
862
- onClick: w,
863
- disabled: !e,
864
- children: /* @__PURE__ */ i.jsx(Ur, { className: "size-4" })
865
- }
866
- )
867
- ] }),
868
- /* @__PURE__ */ i.jsx(
869
- "div",
870
- {
871
- className: "grid transition-all duration-300 ease-in-out",
872
- style: {
873
- gridTemplateRows: u ? "1fr" : "0fr",
874
- opacity: u ? 1 : 0,
875
- marginTop: u ? 12 : 0
876
- },
877
- children: /* @__PURE__ */ i.jsx("div", { className: "overflow-hidden", children: /* @__PURE__ */ i.jsxs("div", { className: "flex justify-end gap-2", children: [
878
- /* @__PURE__ */ i.jsx(
879
- T,
880
- {
881
- variant: "secondary",
882
- size: "sm",
883
- onClick: g,
884
- children: s("cancel")
885
- }
886
- ),
887
- /* @__PURE__ */ i.jsx(T, { size: "sm", onClick: b, disabled: m, children: s(m ? "saving" : "save") })
888
- ] }) })
889
- }
890
- )
891
- ] })
892
- ] });
893
- }
894
- function Os({
895
- mysiteUrl: e,
896
- themeName: t,
897
- previewKey: n,
898
- isUpdating: r,
899
- onPreview: s
900
- }) {
901
- const { t: o } = he(), a = l.useRef(null), c = `${e}?preview=true`, u = l.useRef(!0);
902
- l.useEffect(() => {
903
- u.current = !0;
904
- }, [n]);
905
- const d = () => {
906
- if (u.current) {
907
- u.current = !1;
908
- return;
909
- }
910
- const h = a.current;
911
- h && (u.current = !0, h.src = c);
912
- };
913
- return /* @__PURE__ */ i.jsxs(ze, { className: "items-center gap-4 py-5", children: [
914
- /* @__PURE__ */ i.jsxs(Yt, { className: "w-full items-center px-5", children: [
915
- /* @__PURE__ */ i.jsxs("div", { children: [
916
- /* @__PURE__ */ i.jsx("p", { className: "text-muted-foreground text-xs", children: o("current_theme") }),
917
- /* @__PURE__ */ i.jsx("p", { className: "text-foreground text-sm font-semibold", children: t })
918
- ] }),
919
- /* @__PURE__ */ i.jsx(
920
- T,
921
- {
922
- className: "col-start-2 row-span-2 row-start-1 cursor-pointer self-center justify-self-end",
923
- variant: "secondary",
924
- size: "sm",
925
- onClick: s,
926
- disabled: !e,
927
- children: o("preview")
928
- }
929
- )
930
- ] }),
931
- /* @__PURE__ */ i.jsxs(yt, { className: "relative mx-auto my-auto w-[260px] px-0 sm:w-[320px]", children: [
932
- /* @__PURE__ */ i.jsxs("div", { className: "overflow-hidden rounded-[32px] border-[6px] border-[#1e2939] bg-[#1e2939] shadow-xl sm:rounded-[40px] sm:border-[8px]", children: [
933
- /* @__PURE__ */ i.jsxs("div", { className: "flex items-center justify-between bg-[#101828] px-5 py-1 sm:px-6 sm:py-1.5", children: [
934
- /* @__PURE__ */ i.jsx("span", { className: "text-[10px] font-medium text-[#ffffff] sm:text-[11px]", children: "9:41" }),
935
- /* @__PURE__ */ i.jsxs("div", { className: "flex items-center gap-1", children: [
936
- /* @__PURE__ */ i.jsx("div", { className: "h-2 w-2 rounded-full bg-[#ffffff60] sm:h-2.5 sm:w-2.5" }),
937
- /* @__PURE__ */ i.jsx("div", { className: "h-2 w-3.5 rounded-sm bg-[#ffffff60] sm:h-2.5 sm:w-4" })
938
- ] })
939
- ] }),
940
- /* @__PURE__ */ i.jsx(
941
- "div",
942
- {
943
- className: "relative h-[490px] overflow-y-auto bg-[#ffffff] sm:h-[600px]",
944
- style: { scrollbarWidth: "none" },
945
- "aria-busy": r,
946
- children: e ? /* @__PURE__ */ i.jsxs(i.Fragment, { children: [
947
- /* @__PURE__ */ i.jsx(
948
- "iframe",
949
- {
950
- ref: a,
951
- className: "h-full w-full origin-top-left bg-[#ffffff]",
952
- src: c,
953
- title: o("mysite_preview"),
954
- tabIndex: -1,
955
- sandbox: "allow-scripts allow-same-origin",
956
- onLoad: d
957
- },
958
- n
959
- ),
960
- r && /* @__PURE__ */ i.jsx("div", { className: "absolute inset-0 flex items-center justify-center bg-white/60", children: /* @__PURE__ */ i.jsx(_r, { className: "text-muted-foreground size-6 animate-spin" }) })
961
- ] }) : /* @__PURE__ */ i.jsx("div", { className: "flex h-full items-center justify-center", children: /* @__PURE__ */ i.jsx("p", { className: "text-muted-foreground text-sm", children: o("no_site_configured") }) })
962
- }
963
- )
964
- ] }),
965
- /* @__PURE__ */ i.jsx("div", { className: "absolute bottom-1.5 left-1/2 h-1 w-24 -translate-x-1/2 rounded-full bg-white sm:bottom-2 sm:w-28" })
966
- ] })
967
- ] });
968
- }
969
- const Fs = 137, zs = (e) => {
970
- let t = 0;
971
- for (const r of e)
972
- t = t * 31 + (r.codePointAt(0) ?? 0) >>> 0;
973
- return `color-mix(in oklab, hsl(${t * Fs % 360} 70% 50%) 28%, var(--color-muted))`;
974
- };
975
- function Bs({
976
- themes: e,
977
- selectedThemeId: t,
978
- onSelectTheme: n,
979
- isPending: r,
980
- onBack: s
981
- }) {
982
- const { t: o } = he();
983
- return /* @__PURE__ */ i.jsxs(i.Fragment, { children: [
984
- /* @__PURE__ */ i.jsxs("div", { className: "flex items-center gap-3", children: [
985
- /* @__PURE__ */ i.jsx(T, { variant: "ghost", size: "icon", onClick: s, children: /* @__PURE__ */ i.jsx(Ut, { className: "size-4" }) }),
986
- /* @__PURE__ */ i.jsx("h1", { className: "text-foreground text-xl font-bold", children: o("choose_a_theme") })
987
- ] }),
988
- e.length === 0 ? /* @__PURE__ */ i.jsx(ze, { children: /* @__PURE__ */ i.jsx(yt, { className: "py-8 text-center", children: /* @__PURE__ */ i.jsx("p", { className: "text-muted-foreground", children: o("no_themes_available") }) }) }) : /* @__PURE__ */ i.jsx("div", { className: "grid grid-cols-2 gap-4 sm:grid-cols-3", children: e.map((a) => {
989
- const c = a.id === t, u = a.preview_url || a.image_url;
990
- return /* @__PURE__ */ i.jsxs(
991
- "button",
992
- {
993
- type: "button",
994
- onClick: () => n(a),
995
- className: ke(
996
- "group focus:ring-primary relative overflow-hidden rounded-lg border-2 transition-all focus:ring-2 focus:ring-offset-2 focus:outline-none",
997
- c ? "border-primary ring-primary ring-2" : "border-border hover:border-muted-foreground/50"
998
- ),
999
- "aria-pressed": c,
1000
- disabled: r,
1001
- children: [
1002
- /* @__PURE__ */ i.jsxs("div", { className: "bg-muted relative aspect-[4/3] w-full", children: [
1003
- u ? /* @__PURE__ */ i.jsx(
1004
- "img",
1005
- {
1006
- src: u,
1007
- alt: a.name,
1008
- loading: "lazy",
1009
- className: "absolute inset-0 h-full w-full object-cover"
1010
- }
1011
- ) : /* @__PURE__ */ i.jsx(
1012
- "div",
1013
- {
1014
- className: "text-muted-foreground/50 flex h-full w-full items-center justify-center",
1015
- style: { backgroundColor: zs(a.name) },
1016
- children: /* @__PURE__ */ i.jsx(Mn, { className: "size-8" })
1017
- }
1018
- ),
1019
- c && /* @__PURE__ */ i.jsx("div", { className: "bg-primary/20 absolute inset-0 flex items-center justify-center", children: /* @__PURE__ */ i.jsx("div", { className: "bg-primary text-primary-foreground flex size-8 items-center justify-center rounded-full", children: /* @__PURE__ */ i.jsx(Er, { className: "size-5" }) }) }),
1020
- !c && /* @__PURE__ */ i.jsx("div", { className: "group-hover:bg-foreground/10 absolute inset-0 transition-colors" })
1021
- ] }),
1022
- /* @__PURE__ */ i.jsx("div", { className: "bg-card p-2", children: /* @__PURE__ */ i.jsx(
1023
- "p",
1024
- {
1025
- className: ke(
1026
- "truncate text-sm font-medium",
1027
- c ? "text-primary" : "text-foreground"
1028
- ),
1029
- children: a.name
1030
- }
1031
- ) })
1032
- ]
1033
- },
1034
- a.id
1035
- );
1036
- }) })
1037
- ] });
1038
- }
1039
- function $s() {
1040
- for (var e = arguments.length, t = new Array(e), n = 0; n < e; n++)
1041
- t[n] = arguments[n];
1042
- return l.useMemo(
1043
- () => (r) => {
1044
- t.forEach((s) => s(r));
1045
- },
1046
- // eslint-disable-next-line react-hooks/exhaustive-deps
1047
- t
1048
- );
1049
- }
1050
- const wt = typeof window < "u" && typeof window.document < "u" && typeof window.document.createElement < "u";
1051
- function Be(e) {
1052
- const t = Object.prototype.toString.call(e);
1053
- return t === "[object Window]" || // In Electron context the Window object serializes to [object global]
1054
- t === "[object global]";
1055
- }
1056
- function Xt(e) {
1057
- return "nodeType" in e;
1058
- }
1059
- function Q(e) {
1060
- var t, n;
1061
- return e ? Be(e) ? e : Xt(e) && (t = (n = e.ownerDocument) == null ? void 0 : n.defaultView) != null ? t : window : window;
1062
- }
1063
- function Wt(e) {
1064
- const {
1065
- Document: t
1066
- } = Q(e);
1067
- return e instanceof t;
1068
- }
1069
- function nt(e) {
1070
- return Be(e) ? !1 : e instanceof Q(e).HTMLElement;
1071
- }
1072
- function Tn(e) {
1073
- return e instanceof Q(e).SVGElement;
1074
- }
1075
- function $e(e) {
1076
- return e ? Be(e) ? e.document : Xt(e) ? Wt(e) ? e : nt(e) || Tn(e) ? e.ownerDocument : document : document : document;
1077
- }
1078
- const fe = wt ? l.useLayoutEffect : l.useEffect;
1079
- function Qt(e) {
1080
- const t = l.useRef(e);
1081
- return fe(() => {
1082
- t.current = e;
1083
- }), l.useCallback(function() {
1084
- for (var n = arguments.length, r = new Array(n), s = 0; s < n; s++)
1085
- r[s] = arguments[s];
1086
- return t.current == null ? void 0 : t.current(...r);
1087
- }, []);
1088
- }
1089
- function qs() {
1090
- const e = l.useRef(null), t = l.useCallback((r, s) => {
1091
- e.current = setInterval(r, s);
1092
- }, []), n = l.useCallback(() => {
1093
- e.current !== null && (clearInterval(e.current), e.current = null);
1094
- }, []);
1095
- return [t, n];
1096
- }
1097
- function Ze(e, t) {
1098
- t === void 0 && (t = [e]);
1099
- const n = l.useRef(e);
1100
- return fe(() => {
1101
- n.current !== e && (n.current = e);
1102
- }, t), n;
1103
- }
1104
- function rt(e, t) {
1105
- const n = l.useRef();
1106
- return l.useMemo(
1107
- () => {
1108
- const r = e(n.current);
1109
- return n.current = r, r;
1110
- },
1111
- // eslint-disable-next-line react-hooks/exhaustive-deps
1112
- [...t]
1113
- );
1114
- }
1115
- function ht(e) {
1116
- const t = Qt(e), n = l.useRef(null), r = l.useCallback(
1117
- (s) => {
1118
- s !== n.current && t?.(s, n.current), n.current = s;
1119
- },
1120
- //eslint-disable-next-line
1121
- []
1122
- );
1123
- return [n, r];
1124
- }
1125
- function zt(e) {
1126
- const t = l.useRef();
1127
- return l.useEffect(() => {
1128
- t.current = e;
1129
- }, [e]), t.current;
1130
- }
1131
- let At = {};
1132
- function st(e, t) {
1133
- return l.useMemo(() => {
1134
- if (t)
1135
- return t;
1136
- const n = At[e] == null ? 0 : At[e] + 1;
1137
- return At[e] = n, e + "-" + n;
1138
- }, [e, t]);
1139
- }
1140
- function Pn(e) {
1141
- return function(t) {
1142
- for (var n = arguments.length, r = new Array(n > 1 ? n - 1 : 0), s = 1; s < n; s++)
1143
- r[s - 1] = arguments[s];
1144
- return r.reduce((o, a) => {
1145
- const c = Object.entries(a);
1146
- for (const [u, d] of c) {
1147
- const h = o[u];
1148
- h != null && (o[u] = h + e * d);
1149
- }
1150
- return o;
1151
- }, {
1152
- ...t
1153
- });
1154
- };
1155
- }
1156
- const Oe = /* @__PURE__ */ Pn(1), et = /* @__PURE__ */ Pn(-1);
1157
- function Ks(e) {
1158
- return "clientX" in e && "clientY" in e;
1159
- }
1160
- function Vt(e) {
1161
- if (!e)
1162
- return !1;
1163
- const {
1164
- KeyboardEvent: t
1165
- } = Q(e.target);
1166
- return t && e instanceof t;
1167
- }
1168
- function Us(e) {
1169
- if (!e)
1170
- return !1;
1171
- const {
1172
- TouchEvent: t
1173
- } = Q(e.target);
1174
- return t && e instanceof t;
1175
- }
1176
- function Bt(e) {
1177
- if (Us(e)) {
1178
- if (e.touches && e.touches.length) {
1179
- const {
1180
- clientX: t,
1181
- clientY: n
1182
- } = e.touches[0];
1183
- return {
1184
- x: t,
1185
- y: n
1186
- };
1187
- } else if (e.changedTouches && e.changedTouches.length) {
1188
- const {
1189
- clientX: t,
1190
- clientY: n
1191
- } = e.changedTouches[0];
1192
- return {
1193
- x: t,
1194
- y: n
1195
- };
1196
- }
1197
- }
1198
- return Ks(e) ? {
1199
- x: e.clientX,
1200
- y: e.clientY
1201
- } : null;
1202
- }
1203
- const Fe = /* @__PURE__ */ Object.freeze({
1204
- Translate: {
1205
- toString(e) {
1206
- if (!e)
1207
- return;
1208
- const {
1209
- x: t,
1210
- y: n
1211
- } = e;
1212
- return "translate3d(" + (t ? Math.round(t) : 0) + "px, " + (n ? Math.round(n) : 0) + "px, 0)";
1213
- }
1214
- },
1215
- Scale: {
1216
- toString(e) {
1217
- if (!e)
1218
- return;
1219
- const {
1220
- scaleX: t,
1221
- scaleY: n
1222
- } = e;
1223
- return "scaleX(" + t + ") scaleY(" + n + ")";
1224
- }
1225
- },
1226
- Transform: {
1227
- toString(e) {
1228
- if (e)
1229
- return [Fe.Translate.toString(e), Fe.Scale.toString(e)].join(" ");
1230
- }
1231
- },
1232
- Transition: {
1233
- toString(e) {
1234
- let {
1235
- property: t,
1236
- duration: n,
1237
- easing: r
1238
- } = e;
1239
- return t + " " + n + "ms " + r;
1240
- }
1241
- }
1242
- }), gn = "a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";
1243
- function Hs(e) {
1244
- return e.matches(gn) ? e : e.querySelector(gn);
1245
- }
1246
- const Ys = {
1247
- display: "none"
1248
- };
1249
- function Xs(e) {
1250
- let {
1251
- id: t,
1252
- value: n
1253
- } = e;
1254
- return W.createElement("div", {
1255
- id: t,
1256
- style: Ys
1257
- }, n);
1258
- }
1259
- function Ws(e) {
1260
- let {
1261
- id: t,
1262
- announcement: n,
1263
- ariaLiveType: r = "assertive"
1264
- } = e;
1265
- const s = {
1266
- position: "fixed",
1267
- top: 0,
1268
- left: 0,
1269
- width: 1,
1270
- height: 1,
1271
- margin: -1,
1272
- border: 0,
1273
- padding: 0,
1274
- overflow: "hidden",
1275
- clip: "rect(0 0 0 0)",
1276
- clipPath: "inset(100%)",
1277
- whiteSpace: "nowrap"
1278
- };
1279
- return W.createElement("div", {
1280
- id: t,
1281
- style: s,
1282
- role: "status",
1283
- "aria-live": r,
1284
- "aria-atomic": !0
1285
- }, n);
1286
- }
1287
- function Qs() {
1288
- const [e, t] = l.useState("");
1289
- return {
1290
- announce: l.useCallback((r) => {
1291
- r != null && t(r);
1292
- }, []),
1293
- announcement: e
1294
- };
1295
- }
1296
- const On = /* @__PURE__ */ l.createContext(null);
1297
- function Vs(e) {
1298
- const t = l.useContext(On);
1299
- l.useEffect(() => {
1300
- if (!t)
1301
- throw new Error("useDndMonitor must be used within a children of <DndContext>");
1302
- return t(e);
1303
- }, [e, t]);
1304
- }
1305
- function Gs() {
1306
- const [e] = l.useState(() => /* @__PURE__ */ new Set()), t = l.useCallback((r) => (e.add(r), () => e.delete(r)), [e]);
1307
- return [l.useCallback((r) => {
1308
- let {
1309
- type: s,
1310
- event: o
1311
- } = r;
1312
- e.forEach((a) => {
1313
- var c;
1314
- return (c = a[s]) == null ? void 0 : c.call(a, o);
1315
- });
1316
- }, [e]), t];
1317
- }
1318
- const Js = {
1319
- draggable: `
1320
- To pick up a draggable item, press the space bar.
1321
- While dragging, use the arrow keys to move the item.
1322
- Press space again to drop the item in its new position, or press escape to cancel.
1323
- `
1324
- }, Zs = {
1325
- onDragStart(e) {
1326
- let {
1327
- active: t
1328
- } = e;
1329
- return "Picked up draggable item " + t.id + ".";
1330
- },
1331
- onDragOver(e) {
1332
- let {
1333
- active: t,
1334
- over: n
1335
- } = e;
1336
- return n ? "Draggable item " + t.id + " was moved over droppable area " + n.id + "." : "Draggable item " + t.id + " is no longer over a droppable area.";
1337
- },
1338
- onDragEnd(e) {
1339
- let {
1340
- active: t,
1341
- over: n
1342
- } = e;
1343
- return n ? "Draggable item " + t.id + " was dropped over droppable area " + n.id : "Draggable item " + t.id + " was dropped.";
1344
- },
1345
- onDragCancel(e) {
1346
- let {
1347
- active: t
1348
- } = e;
1349
- return "Dragging was cancelled. Draggable item " + t.id + " was dropped.";
1350
- }
1351
- };
1352
- function ei(e) {
1353
- let {
1354
- announcements: t = Zs,
1355
- container: n,
1356
- hiddenTextDescribedById: r,
1357
- screenReaderInstructions: s = Js
1358
- } = e;
1359
- const {
1360
- announce: o,
1361
- announcement: a
1362
- } = Qs(), c = st("DndLiveRegion"), [u, d] = l.useState(!1);
1363
- if (l.useEffect(() => {
1364
- d(!0);
1365
- }, []), Vs(l.useMemo(() => ({
1366
- onDragStart(f) {
1367
- let {
1368
- active: m
1369
- } = f;
1370
- o(t.onDragStart({
1371
- active: m
1372
- }));
1373
- },
1374
- onDragMove(f) {
1375
- let {
1376
- active: m,
1377
- over: p
1378
- } = f;
1379
- t.onDragMove && o(t.onDragMove({
1380
- active: m,
1381
- over: p
1382
- }));
1383
- },
1384
- onDragOver(f) {
1385
- let {
1386
- active: m,
1387
- over: p
1388
- } = f;
1389
- o(t.onDragOver({
1390
- active: m,
1391
- over: p
1392
- }));
1393
- },
1394
- onDragEnd(f) {
1395
- let {
1396
- active: m,
1397
- over: p
1398
- } = f;
1399
- o(t.onDragEnd({
1400
- active: m,
1401
- over: p
1402
- }));
1403
- },
1404
- onDragCancel(f) {
1405
- let {
1406
- active: m,
1407
- over: p
1408
- } = f;
1409
- o(t.onDragCancel({
1410
- active: m,
1411
- over: p
1412
- }));
1413
- }
1414
- }), [o, t])), !u)
1415
- return null;
1416
- const h = W.createElement(W.Fragment, null, W.createElement(Xs, {
1417
- id: r,
1418
- value: s.draggable
1419
- }), W.createElement(Ws, {
1420
- id: c,
1421
- announcement: a
1422
- }));
1423
- return n ? Qe.createPortal(h, n) : h;
1424
- }
1425
- var O;
1426
- (function(e) {
1427
- e.DragStart = "dragStart", e.DragMove = "dragMove", e.DragEnd = "dragEnd", e.DragCancel = "dragCancel", e.DragOver = "dragOver", e.RegisterDroppable = "registerDroppable", e.SetDroppableDisabled = "setDroppableDisabled", e.UnregisterDroppable = "unregisterDroppable";
1428
- })(O || (O = {}));
1429
- function mt() {
1430
- }
1431
- function pt(e, t) {
1432
- return l.useMemo(
1433
- () => ({
1434
- sensor: e,
1435
- options: t ?? {}
1436
- }),
1437
- // eslint-disable-next-line react-hooks/exhaustive-deps
1438
- [e, t]
1439
- );
1440
- }
1441
- function Fn() {
1442
- for (var e = arguments.length, t = new Array(e), n = 0; n < e; n++)
1443
- t[n] = arguments[n];
1444
- return l.useMemo(
1445
- () => [...t].filter((r) => r != null),
1446
- // eslint-disable-next-line react-hooks/exhaustive-deps
1447
- [...t]
1448
- );
1449
- }
1450
- const ie = /* @__PURE__ */ Object.freeze({
1451
- x: 0,
1452
- y: 0
1453
- });
1454
- function zn(e, t) {
1455
- return Math.sqrt(Math.pow(e.x - t.x, 2) + Math.pow(e.y - t.y, 2));
1456
- }
1457
- function Bn(e, t) {
1458
- let {
1459
- data: {
1460
- value: n
1461
- }
1462
- } = e, {
1463
- data: {
1464
- value: r
1465
- }
1466
- } = t;
1467
- return n - r;
1468
- }
1469
- function ti(e, t) {
1470
- let {
1471
- data: {
1472
- value: n
1473
- }
1474
- } = e, {
1475
- data: {
1476
- value: r
1477
- }
1478
- } = t;
1479
- return r - n;
1480
- }
1481
- function vn(e) {
1482
- let {
1483
- left: t,
1484
- top: n,
1485
- height: r,
1486
- width: s
1487
- } = e;
1488
- return [{
1489
- x: t,
1490
- y: n
1491
- }, {
1492
- x: t + s,
1493
- y: n
1494
- }, {
1495
- x: t,
1496
- y: n + r
1497
- }, {
1498
- x: t + s,
1499
- y: n + r
1500
- }];
1501
- }
1502
- function $n(e, t) {
1503
- if (!e || e.length === 0)
1504
- return null;
1505
- const [n] = e;
1506
- return n[t];
1507
- }
1508
- function bn(e, t, n) {
1509
- return t === void 0 && (t = e.left), n === void 0 && (n = e.top), {
1510
- x: t + e.width * 0.5,
1511
- y: n + e.height * 0.5
1512
- };
1513
- }
1514
- const qn = (e) => {
1515
- let {
1516
- collisionRect: t,
1517
- droppableRects: n,
1518
- droppableContainers: r
1519
- } = e;
1520
- const s = bn(t, t.left, t.top), o = [];
1521
- for (const a of r) {
1522
- const {
1523
- id: c
1524
- } = a, u = n.get(c);
1525
- if (u) {
1526
- const d = zn(bn(u), s);
1527
- o.push({
1528
- id: c,
1529
- data: {
1530
- droppableContainer: a,
1531
- value: d
1532
- }
1533
- });
1534
- }
1535
- }
1536
- return o.sort(Bn);
1537
- }, ni = (e) => {
1538
- let {
1539
- collisionRect: t,
1540
- droppableRects: n,
1541
- droppableContainers: r
1542
- } = e;
1543
- const s = vn(t), o = [];
1544
- for (const a of r) {
1545
- const {
1546
- id: c
1547
- } = a, u = n.get(c);
1548
- if (u) {
1549
- const d = vn(u), h = s.reduce((m, p, x) => m + zn(d[x], p), 0), f = Number((h / 4).toFixed(4));
1550
- o.push({
1551
- id: c,
1552
- data: {
1553
- droppableContainer: a,
1554
- value: f
1555
- }
1556
- });
1557
- }
1558
- }
1559
- return o.sort(Bn);
1560
- };
1561
- function ri(e, t) {
1562
- const n = Math.max(t.top, e.top), r = Math.max(t.left, e.left), s = Math.min(t.left + t.width, e.left + e.width), o = Math.min(t.top + t.height, e.top + e.height), a = s - r, c = o - n;
1563
- if (r < s && n < o) {
1564
- const u = t.width * t.height, d = e.width * e.height, h = a * c, f = h / (u + d - h);
1565
- return Number(f.toFixed(4));
1566
- }
1567
- return 0;
1568
- }
1569
- const si = (e) => {
1570
- let {
1571
- collisionRect: t,
1572
- droppableRects: n,
1573
- droppableContainers: r
1574
- } = e;
1575
- const s = [];
1576
- for (const o of r) {
1577
- const {
1578
- id: a
1579
- } = o, c = n.get(a);
1580
- if (c) {
1581
- const u = ri(c, t);
1582
- u > 0 && s.push({
1583
- id: a,
1584
- data: {
1585
- droppableContainer: o,
1586
- value: u
1587
- }
1588
- });
1589
- }
1590
- }
1591
- return s.sort(ti);
1592
- };
1593
- function ii(e, t, n) {
1594
- return {
1595
- ...e,
1596
- scaleX: t && n ? t.width / n.width : 1,
1597
- scaleY: t && n ? t.height / n.height : 1
1598
- };
1599
- }
1600
- function Kn(e, t) {
1601
- return e && t ? {
1602
- x: e.left - t.left,
1603
- y: e.top - t.top
1604
- } : ie;
1605
- }
1606
- function oi(e) {
1607
- return function(n) {
1608
- for (var r = arguments.length, s = new Array(r > 1 ? r - 1 : 0), o = 1; o < r; o++)
1609
- s[o - 1] = arguments[o];
1610
- return s.reduce((a, c) => ({
1611
- ...a,
1612
- top: a.top + e * c.y,
1613
- bottom: a.bottom + e * c.y,
1614
- left: a.left + e * c.x,
1615
- right: a.right + e * c.x
1616
- }), {
1617
- ...n
1618
- });
1619
- };
1620
- }
1621
- const ai = /* @__PURE__ */ oi(1);
1622
- function li(e) {
1623
- if (e.startsWith("matrix3d(")) {
1624
- const t = e.slice(9, -1).split(/, /);
1625
- return {
1626
- x: +t[12],
1627
- y: +t[13],
1628
- scaleX: +t[0],
1629
- scaleY: +t[5]
1630
- };
1631
- } else if (e.startsWith("matrix(")) {
1632
- const t = e.slice(7, -1).split(/, /);
1633
- return {
1634
- x: +t[4],
1635
- y: +t[5],
1636
- scaleX: +t[0],
1637
- scaleY: +t[3]
1638
- };
1639
- }
1640
- return null;
1641
- }
1642
- function ci(e, t, n) {
1643
- const r = li(t);
1644
- if (!r)
1645
- return e;
1646
- const {
1647
- scaleX: s,
1648
- scaleY: o,
1649
- x: a,
1650
- y: c
1651
- } = r, u = e.left - a - (1 - s) * parseFloat(n), d = e.top - c - (1 - o) * parseFloat(n.slice(n.indexOf(" ") + 1)), h = s ? e.width / s : e.width, f = o ? e.height / o : e.height;
1652
- return {
1653
- width: h,
1654
- height: f,
1655
- top: d,
1656
- right: u + h,
1657
- bottom: d + f,
1658
- left: u
1659
- };
1660
- }
1661
- const ui = {
1662
- ignoreTransform: !1
1663
- };
1664
- function qe(e, t) {
1665
- t === void 0 && (t = ui);
1666
- let n = e.getBoundingClientRect();
1667
- if (t.ignoreTransform) {
1668
- const {
1669
- transform: d,
1670
- transformOrigin: h
1671
- } = Q(e).getComputedStyle(e);
1672
- d && (n = ci(n, d, h));
1673
- }
1674
- const {
1675
- top: r,
1676
- left: s,
1677
- width: o,
1678
- height: a,
1679
- bottom: c,
1680
- right: u
1681
- } = n;
1682
- return {
1683
- top: r,
1684
- left: s,
1685
- width: o,
1686
- height: a,
1687
- bottom: c,
1688
- right: u
1689
- };
1690
- }
1691
- function xn(e) {
1692
- return qe(e, {
1693
- ignoreTransform: !0
1694
- });
1695
- }
1696
- function di(e) {
1697
- const t = e.innerWidth, n = e.innerHeight;
1698
- return {
1699
- top: 0,
1700
- left: 0,
1701
- right: t,
1702
- bottom: n,
1703
- width: t,
1704
- height: n
1705
- };
1706
- }
1707
- function fi(e, t) {
1708
- return t === void 0 && (t = Q(e).getComputedStyle(e)), t.position === "fixed";
1709
- }
1710
- function hi(e, t) {
1711
- t === void 0 && (t = Q(e).getComputedStyle(e));
1712
- const n = /(auto|scroll|overlay)/;
1713
- return ["overflow", "overflowX", "overflowY"].some((s) => {
1714
- const o = t[s];
1715
- return typeof o == "string" ? n.test(o) : !1;
1716
- });
1717
- }
1718
- function _t(e, t) {
1719
- const n = [];
1720
- function r(s) {
1721
- if (t != null && n.length >= t || !s)
1722
- return n;
1723
- if (Wt(s) && s.scrollingElement != null && !n.includes(s.scrollingElement))
1724
- return n.push(s.scrollingElement), n;
1725
- if (!nt(s) || Tn(s) || n.includes(s))
1726
- return n;
1727
- const o = Q(e).getComputedStyle(s);
1728
- return s !== e && hi(s, o) && n.push(s), fi(s, o) ? n : r(s.parentNode);
1729
- }
1730
- return e ? r(e) : n;
1731
- }
1732
- function Un(e) {
1733
- const [t] = _t(e, 1);
1734
- return t ?? null;
1735
- }
1736
- function Lt(e) {
1737
- return !wt || !e ? null : Be(e) ? e : Xt(e) ? Wt(e) || e === $e(e).scrollingElement ? window : nt(e) ? e : null : null;
1738
- }
1739
- function Hn(e) {
1740
- return Be(e) ? e.scrollX : e.scrollLeft;
1741
- }
1742
- function Yn(e) {
1743
- return Be(e) ? e.scrollY : e.scrollTop;
1744
- }
1745
- function $t(e) {
1746
- return {
1747
- x: Hn(e),
1748
- y: Yn(e)
1749
- };
1750
- }
1751
- var z;
1752
- (function(e) {
1753
- e[e.Forward = 1] = "Forward", e[e.Backward = -1] = "Backward";
1754
- })(z || (z = {}));
1755
- function Xn(e) {
1756
- return !wt || !e ? !1 : e === document.scrollingElement;
1757
- }
1758
- function Wn(e) {
1759
- const t = {
1760
- x: 0,
1761
- y: 0
1762
- }, n = Xn(e) ? {
1763
- height: window.innerHeight,
1764
- width: window.innerWidth
1765
- } : {
1766
- height: e.clientHeight,
1767
- width: e.clientWidth
1768
- }, r = {
1769
- x: e.scrollWidth - n.width,
1770
- y: e.scrollHeight - n.height
1771
- }, s = e.scrollTop <= t.y, o = e.scrollLeft <= t.x, a = e.scrollTop >= r.y, c = e.scrollLeft >= r.x;
1772
- return {
1773
- isTop: s,
1774
- isLeft: o,
1775
- isBottom: a,
1776
- isRight: c,
1777
- maxScroll: r,
1778
- minScroll: t
1779
- };
1780
- }
1781
- const mi = {
1782
- x: 0.2,
1783
- y: 0.2
1784
- };
1785
- function pi(e, t, n, r, s) {
1786
- let {
1787
- top: o,
1788
- left: a,
1789
- right: c,
1790
- bottom: u
1791
- } = n;
1792
- r === void 0 && (r = 10), s === void 0 && (s = mi);
1793
- const {
1794
- isTop: d,
1795
- isBottom: h,
1796
- isLeft: f,
1797
- isRight: m
1798
- } = Wn(e), p = {
1799
- x: 0,
1800
- y: 0
1801
- }, x = {
1802
- x: 0,
1803
- y: 0
1804
- }, g = {
1805
- height: t.height * s.y,
1806
- width: t.width * s.x
1807
- };
1808
- return !d && o <= t.top + g.height ? (p.y = z.Backward, x.y = r * Math.abs((t.top + g.height - o) / g.height)) : !h && u >= t.bottom - g.height && (p.y = z.Forward, x.y = r * Math.abs((t.bottom - g.height - u) / g.height)), !m && c >= t.right - g.width ? (p.x = z.Forward, x.x = r * Math.abs((t.right - g.width - c) / g.width)) : !f && a <= t.left + g.width && (p.x = z.Backward, x.x = r * Math.abs((t.left + g.width - a) / g.width)), {
1809
- direction: p,
1810
- speed: x
1811
- };
1812
- }
1813
- function gi(e) {
1814
- if (e === document.scrollingElement) {
1815
- const {
1816
- innerWidth: o,
1817
- innerHeight: a
1818
- } = window;
1819
- return {
1820
- top: 0,
1821
- left: 0,
1822
- right: o,
1823
- bottom: a,
1824
- width: o,
1825
- height: a
1826
- };
1827
- }
1828
- const {
1829
- top: t,
1830
- left: n,
1831
- right: r,
1832
- bottom: s
1833
- } = e.getBoundingClientRect();
1834
- return {
1835
- top: t,
1836
- left: n,
1837
- right: r,
1838
- bottom: s,
1839
- width: e.clientWidth,
1840
- height: e.clientHeight
1841
- };
1842
- }
1843
- function Qn(e) {
1844
- return e.reduce((t, n) => Oe(t, $t(n)), ie);
1845
- }
1846
- function vi(e) {
1847
- return e.reduce((t, n) => t + Hn(n), 0);
1848
- }
1849
- function bi(e) {
1850
- return e.reduce((t, n) => t + Yn(n), 0);
1851
- }
1852
- function xi(e, t) {
1853
- if (t === void 0 && (t = qe), !e)
1854
- return;
1855
- const {
1856
- top: n,
1857
- left: r,
1858
- bottom: s,
1859
- right: o
1860
- } = t(e);
1861
- Un(e) && (s <= 0 || o <= 0 || n >= window.innerHeight || r >= window.innerWidth) && e.scrollIntoView({
1862
- block: "center",
1863
- inline: "center"
1864
- });
1865
- }
1866
- const yi = [["x", ["left", "right"], vi], ["y", ["top", "bottom"], bi]];
1867
- class Gt {
1868
- constructor(t, n) {
1869
- this.rect = void 0, this.width = void 0, this.height = void 0, this.top = void 0, this.bottom = void 0, this.right = void 0, this.left = void 0;
1870
- const r = _t(n), s = Qn(r);
1871
- this.rect = {
1872
- ...t
1873
- }, this.width = t.width, this.height = t.height;
1874
- for (const [o, a, c] of yi)
1875
- for (const u of a)
1876
- Object.defineProperty(this, u, {
1877
- get: () => {
1878
- const d = c(r), h = s[o] - d;
1879
- return this.rect[u] + h;
1880
- },
1881
- enumerable: !0
1882
- });
1883
- Object.defineProperty(this, "rect", {
1884
- enumerable: !1
1885
- });
1886
- }
1887
- }
1888
- class Ve {
1889
- constructor(t) {
1890
- this.target = void 0, this.listeners = [], this.removeAll = () => {
1891
- this.listeners.forEach((n) => {
1892
- var r;
1893
- return (r = this.target) == null ? void 0 : r.removeEventListener(...n);
1894
- });
1895
- }, this.target = t;
1896
- }
1897
- add(t, n, r) {
1898
- var s;
1899
- (s = this.target) == null || s.addEventListener(t, n, r), this.listeners.push([t, n, r]);
1900
- }
1901
- }
1902
- function wi(e) {
1903
- const {
1904
- EventTarget: t
1905
- } = Q(e);
1906
- return e instanceof t ? e : $e(e);
1907
- }
1908
- function It(e, t) {
1909
- const n = Math.abs(e.x), r = Math.abs(e.y);
1910
- return typeof t == "number" ? Math.sqrt(n ** 2 + r ** 2) > t : "x" in t && "y" in t ? n > t.x && r > t.y : "x" in t ? n > t.x : "y" in t ? r > t.y : !1;
1911
- }
1912
- var ne;
1913
- (function(e) {
1914
- e.Click = "click", e.DragStart = "dragstart", e.Keydown = "keydown", e.ContextMenu = "contextmenu", e.Resize = "resize", e.SelectionChange = "selectionchange", e.VisibilityChange = "visibilitychange";
1915
- })(ne || (ne = {}));
1916
- function yn(e) {
1917
- e.preventDefault();
1918
- }
1919
- function _i(e) {
1920
- e.stopPropagation();
1921
- }
1922
- var E;
1923
- (function(e) {
1924
- e.Space = "Space", e.Down = "ArrowDown", e.Right = "ArrowRight", e.Left = "ArrowLeft", e.Up = "ArrowUp", e.Esc = "Escape", e.Enter = "Enter", e.Tab = "Tab";
1925
- })(E || (E = {}));
1926
- const Vn = {
1927
- start: [E.Space, E.Enter],
1928
- cancel: [E.Esc],
1929
- end: [E.Space, E.Enter, E.Tab]
1930
- }, Ci = (e, t) => {
1931
- let {
1932
- currentCoordinates: n
1933
- } = t;
1934
- switch (e.code) {
1935
- case E.Right:
1936
- return {
1937
- ...n,
1938
- x: n.x + 25
1939
- };
1940
- case E.Left:
1941
- return {
1942
- ...n,
1943
- x: n.x - 25
1944
- };
1945
- case E.Down:
1946
- return {
1947
- ...n,
1948
- y: n.y + 25
1949
- };
1950
- case E.Up:
1951
- return {
1952
- ...n,
1953
- y: n.y - 25
1954
- };
1955
- }
1956
- };
1957
- class Ct {
1958
- constructor(t) {
1959
- this.props = void 0, this.autoScrollEnabled = !1, this.referenceCoordinates = void 0, this.listeners = void 0, this.windowListeners = void 0, this.props = t;
1960
- const {
1961
- event: {
1962
- target: n
1963
- }
1964
- } = t;
1965
- this.props = t, this.listeners = new Ve($e(n)), this.windowListeners = new Ve(Q(n)), this.handleKeyDown = this.handleKeyDown.bind(this), this.handleCancel = this.handleCancel.bind(this), this.attach();
1966
- }
1967
- attach() {
1968
- this.handleStart(), this.windowListeners.add(ne.Resize, this.handleCancel), this.windowListeners.add(ne.VisibilityChange, this.handleCancel), setTimeout(() => this.listeners.add(ne.Keydown, this.handleKeyDown));
1969
- }
1970
- handleStart() {
1971
- const {
1972
- activeNode: t,
1973
- onStart: n
1974
- } = this.props, r = t.node.current;
1975
- r && xi(r), n(ie);
1976
- }
1977
- handleKeyDown(t) {
1978
- if (Vt(t)) {
1979
- const {
1980
- active: n,
1981
- context: r,
1982
- options: s
1983
- } = this.props, {
1984
- keyboardCodes: o = Vn,
1985
- coordinateGetter: a = Ci,
1986
- scrollBehavior: c = "smooth"
1987
- } = s, {
1988
- code: u
1989
- } = t;
1990
- if (o.end.includes(u)) {
1991
- this.handleEnd(t);
1992
- return;
1993
- }
1994
- if (o.cancel.includes(u)) {
1995
- this.handleCancel(t);
1996
- return;
1997
- }
1998
- const {
1999
- collisionRect: d
2000
- } = r.current, h = d ? {
2001
- x: d.left,
2002
- y: d.top
2003
- } : ie;
2004
- this.referenceCoordinates || (this.referenceCoordinates = h);
2005
- const f = a(t, {
2006
- active: n,
2007
- context: r.current,
2008
- currentCoordinates: h
2009
- });
2010
- if (f) {
2011
- const m = et(f, h), p = {
2012
- x: 0,
2013
- y: 0
2014
- }, {
2015
- scrollableAncestors: x
2016
- } = r.current;
2017
- for (const g of x) {
2018
- const b = t.code, {
2019
- isTop: w,
2020
- isRight: v,
2021
- isLeft: y,
2022
- isBottom: _,
2023
- maxScroll: N,
2024
- minScroll: S
2025
- } = Wn(g), C = gi(g), j = {
2026
- x: Math.min(b === E.Right ? C.right - C.width / 2 : C.right, Math.max(b === E.Right ? C.left : C.left + C.width / 2, f.x)),
2027
- y: Math.min(b === E.Down ? C.bottom - C.height / 2 : C.bottom, Math.max(b === E.Down ? C.top : C.top + C.height / 2, f.y))
2028
- }, R = b === E.Right && !v || b === E.Left && !y, L = b === E.Down && !_ || b === E.Up && !w;
2029
- if (R && j.x !== f.x) {
2030
- const M = g.scrollLeft + m.x, P = b === E.Right && M <= N.x || b === E.Left && M >= S.x;
2031
- if (P && !m.y) {
2032
- g.scrollTo({
2033
- left: M,
2034
- behavior: c
2035
- });
2036
- return;
2037
- }
2038
- P ? p.x = g.scrollLeft - M : p.x = b === E.Right ? g.scrollLeft - N.x : g.scrollLeft - S.x, p.x && g.scrollBy({
2039
- left: -p.x,
2040
- behavior: c
2041
- });
2042
- break;
2043
- } else if (L && j.y !== f.y) {
2044
- const M = g.scrollTop + m.y, P = b === E.Down && M <= N.y || b === E.Up && M >= S.y;
2045
- if (P && !m.x) {
2046
- g.scrollTo({
2047
- top: M,
2048
- behavior: c
2049
- });
2050
- return;
2051
- }
2052
- P ? p.y = g.scrollTop - M : p.y = b === E.Down ? g.scrollTop - N.y : g.scrollTop - S.y, p.y && g.scrollBy({
2053
- top: -p.y,
2054
- behavior: c
2055
- });
2056
- break;
2057
- }
2058
- }
2059
- this.handleMove(t, Oe(et(f, this.referenceCoordinates), p));
2060
- }
2061
- }
2062
- }
2063
- handleMove(t, n) {
2064
- const {
2065
- onMove: r
2066
- } = this.props;
2067
- t.preventDefault(), r(n);
2068
- }
2069
- handleEnd(t) {
2070
- const {
2071
- onEnd: n
2072
- } = this.props;
2073
- t.preventDefault(), this.detach(), n();
2074
- }
2075
- handleCancel(t) {
2076
- const {
2077
- onCancel: n
2078
- } = this.props;
2079
- t.preventDefault(), this.detach(), n();
2080
- }
2081
- detach() {
2082
- this.listeners.removeAll(), this.windowListeners.removeAll();
2083
- }
2084
- }
2085
- Ct.activators = [{
2086
- eventName: "onKeyDown",
2087
- handler: (e, t, n) => {
2088
- let {
2089
- keyboardCodes: r = Vn,
2090
- onActivation: s
2091
- } = t, {
2092
- active: o
2093
- } = n;
2094
- const {
2095
- code: a
2096
- } = e.nativeEvent;
2097
- if (r.start.includes(a)) {
2098
- const c = o.activatorNode.current;
2099
- return c && e.target !== c ? !1 : (e.preventDefault(), s?.({
2100
- event: e.nativeEvent
2101
- }), !0);
2102
- }
2103
- return !1;
2104
- }
2105
- }];
2106
- function wn(e) {
2107
- return !!(e && "distance" in e);
2108
- }
2109
- function _n(e) {
2110
- return !!(e && "delay" in e);
2111
- }
2112
- class Jt {
2113
- constructor(t, n, r) {
2114
- var s;
2115
- r === void 0 && (r = wi(t.event.target)), this.props = void 0, this.events = void 0, this.autoScrollEnabled = !0, this.document = void 0, this.activated = !1, this.initialCoordinates = void 0, this.timeoutId = null, this.listeners = void 0, this.documentListeners = void 0, this.windowListeners = void 0, this.props = t, this.events = n;
2116
- const {
2117
- event: o
2118
- } = t, {
2119
- target: a
2120
- } = o;
2121
- this.props = t, this.events = n, this.document = $e(a), this.documentListeners = new Ve(this.document), this.listeners = new Ve(r), this.windowListeners = new Ve(Q(a)), this.initialCoordinates = (s = Bt(o)) != null ? s : ie, this.handleStart = this.handleStart.bind(this), this.handleMove = this.handleMove.bind(this), this.handleEnd = this.handleEnd.bind(this), this.handleCancel = this.handleCancel.bind(this), this.handleKeydown = this.handleKeydown.bind(this), this.removeTextSelection = this.removeTextSelection.bind(this), this.attach();
2122
- }
2123
- attach() {
2124
- const {
2125
- events: t,
2126
- props: {
2127
- options: {
2128
- activationConstraint: n,
2129
- bypassActivationConstraint: r
2130
- }
2131
- }
2132
- } = this;
2133
- if (this.listeners.add(t.move.name, this.handleMove, {
2134
- passive: !1
2135
- }), this.listeners.add(t.end.name, this.handleEnd), t.cancel && this.listeners.add(t.cancel.name, this.handleCancel), this.windowListeners.add(ne.Resize, this.handleCancel), this.windowListeners.add(ne.DragStart, yn), this.windowListeners.add(ne.VisibilityChange, this.handleCancel), this.windowListeners.add(ne.ContextMenu, yn), this.documentListeners.add(ne.Keydown, this.handleKeydown), n) {
2136
- if (r != null && r({
2137
- event: this.props.event,
2138
- activeNode: this.props.activeNode,
2139
- options: this.props.options
2140
- }))
2141
- return this.handleStart();
2142
- if (_n(n)) {
2143
- this.timeoutId = setTimeout(this.handleStart, n.delay), this.handlePending(n);
2144
- return;
2145
- }
2146
- if (wn(n)) {
2147
- this.handlePending(n);
2148
- return;
2149
- }
2150
- }
2151
- this.handleStart();
2152
- }
2153
- detach() {
2154
- this.listeners.removeAll(), this.windowListeners.removeAll(), setTimeout(this.documentListeners.removeAll, 50), this.timeoutId !== null && (clearTimeout(this.timeoutId), this.timeoutId = null);
2155
- }
2156
- handlePending(t, n) {
2157
- const {
2158
- active: r,
2159
- onPending: s
2160
- } = this.props;
2161
- s(r, t, this.initialCoordinates, n);
2162
- }
2163
- handleStart() {
2164
- const {
2165
- initialCoordinates: t
2166
- } = this, {
2167
- onStart: n
2168
- } = this.props;
2169
- t && (this.activated = !0, this.documentListeners.add(ne.Click, _i, {
2170
- capture: !0
2171
- }), this.removeTextSelection(), this.documentListeners.add(ne.SelectionChange, this.removeTextSelection), n(t));
2172
- }
2173
- handleMove(t) {
2174
- var n;
2175
- const {
2176
- activated: r,
2177
- initialCoordinates: s,
2178
- props: o
2179
- } = this, {
2180
- onMove: a,
2181
- options: {
2182
- activationConstraint: c
2183
- }
2184
- } = o;
2185
- if (!s)
2186
- return;
2187
- const u = (n = Bt(t)) != null ? n : ie, d = et(s, u);
2188
- if (!r && c) {
2189
- if (wn(c)) {
2190
- if (c.tolerance != null && It(d, c.tolerance))
2191
- return this.handleCancel();
2192
- if (It(d, c.distance))
2193
- return this.handleStart();
2194
- }
2195
- if (_n(c) && It(d, c.tolerance))
2196
- return this.handleCancel();
2197
- this.handlePending(c, d);
2198
- return;
2199
- }
2200
- t.cancelable && t.preventDefault(), a(u);
2201
- }
2202
- handleEnd() {
2203
- const {
2204
- onAbort: t,
2205
- onEnd: n
2206
- } = this.props;
2207
- this.detach(), this.activated || t(this.props.active), n();
2208
- }
2209
- handleCancel() {
2210
- const {
2211
- onAbort: t,
2212
- onCancel: n
2213
- } = this.props;
2214
- this.detach(), this.activated || t(this.props.active), n();
2215
- }
2216
- handleKeydown(t) {
2217
- t.code === E.Esc && this.handleCancel();
2218
- }
2219
- removeTextSelection() {
2220
- var t;
2221
- (t = this.document.getSelection()) == null || t.removeAllRanges();
2222
- }
2223
- }
2224
- const Si = {
2225
- cancel: {
2226
- name: "pointercancel"
2227
- },
2228
- move: {
2229
- name: "pointermove"
2230
- },
2231
- end: {
2232
- name: "pointerup"
2233
- }
2234
- };
2235
- class St extends Jt {
2236
- constructor(t) {
2237
- const {
2238
- event: n
2239
- } = t, r = $e(n.target);
2240
- super(t, Si, r);
2241
- }
2242
- }
2243
- St.activators = [{
2244
- eventName: "onPointerDown",
2245
- handler: (e, t) => {
2246
- let {
2247
- nativeEvent: n
2248
- } = e, {
2249
- onActivation: r
2250
- } = t;
2251
- return !n.isPrimary || n.button !== 0 ? !1 : (r?.({
2252
- event: n
2253
- }), !0);
2254
- }
2255
- }];
2256
- const ji = {
2257
- move: {
2258
- name: "mousemove"
2259
- },
2260
- end: {
2261
- name: "mouseup"
2262
- }
2263
- };
2264
- var qt;
2265
- (function(e) {
2266
- e[e.RightClick = 2] = "RightClick";
2267
- })(qt || (qt = {}));
2268
- class Ni extends Jt {
2269
- constructor(t) {
2270
- super(t, ji, $e(t.event.target));
2271
- }
2272
- }
2273
- Ni.activators = [{
2274
- eventName: "onMouseDown",
2275
- handler: (e, t) => {
2276
- let {
2277
- nativeEvent: n
2278
- } = e, {
2279
- onActivation: r
2280
- } = t;
2281
- return n.button === qt.RightClick ? !1 : (r?.({
2282
- event: n
2283
- }), !0);
2284
- }
2285
- }];
2286
- const Tt = {
2287
- cancel: {
2288
- name: "touchcancel"
2289
- },
2290
- move: {
2291
- name: "touchmove"
2292
- },
2293
- end: {
2294
- name: "touchend"
2295
- }
2296
- };
2297
- class Di extends Jt {
2298
- constructor(t) {
2299
- super(t, Tt);
2300
- }
2301
- static setup() {
2302
- return window.addEventListener(Tt.move.name, t, {
2303
- capture: !1,
2304
- passive: !1
2305
- }), function() {
2306
- window.removeEventListener(Tt.move.name, t);
2307
- };
2308
- function t() {
2309
- }
2310
- }
2311
- }
2312
- Di.activators = [{
2313
- eventName: "onTouchStart",
2314
- handler: (e, t) => {
2315
- let {
2316
- nativeEvent: n
2317
- } = e, {
2318
- onActivation: r
2319
- } = t;
2320
- const {
2321
- touches: s
2322
- } = n;
2323
- return s.length > 1 ? !1 : (r?.({
2324
- event: n
2325
- }), !0);
2326
- }
2327
- }];
2328
- var Ge;
2329
- (function(e) {
2330
- e[e.Pointer = 0] = "Pointer", e[e.DraggableRect = 1] = "DraggableRect";
2331
- })(Ge || (Ge = {}));
2332
- var gt;
2333
- (function(e) {
2334
- e[e.TreeOrder = 0] = "TreeOrder", e[e.ReversedTreeOrder = 1] = "ReversedTreeOrder";
2335
- })(gt || (gt = {}));
2336
- function ki(e) {
2337
- let {
2338
- acceleration: t,
2339
- activator: n = Ge.Pointer,
2340
- canScroll: r,
2341
- draggingRect: s,
2342
- enabled: o,
2343
- interval: a = 5,
2344
- order: c = gt.TreeOrder,
2345
- pointerCoordinates: u,
2346
- scrollableAncestors: d,
2347
- scrollableAncestorRects: h,
2348
- delta: f,
2349
- threshold: m
2350
- } = e;
2351
- const p = Ri({
2352
- delta: f,
2353
- disabled: !o
2354
- }), [x, g] = qs(), b = l.useRef({
2355
- x: 0,
2356
- y: 0
2357
- }), w = l.useRef({
2358
- x: 0,
2359
- y: 0
2360
- }), v = l.useMemo(() => {
2361
- switch (n) {
2362
- case Ge.Pointer:
2363
- return u ? {
2364
- top: u.y,
2365
- bottom: u.y,
2366
- left: u.x,
2367
- right: u.x
2368
- } : null;
2369
- case Ge.DraggableRect:
2370
- return s;
2371
- }
2372
- }, [n, s, u]), y = l.useRef(null), _ = l.useCallback(() => {
2373
- const S = y.current;
2374
- if (!S)
2375
- return;
2376
- const C = b.current.x * w.current.x, j = b.current.y * w.current.y;
2377
- S.scrollBy(C, j);
2378
- }, []), N = l.useMemo(() => c === gt.TreeOrder ? [...d].reverse() : d, [c, d]);
2379
- l.useEffect(
2380
- () => {
2381
- if (!o || !d.length || !v) {
2382
- g();
2383
- return;
2384
- }
2385
- for (const S of N) {
2386
- if (r?.(S) === !1)
2387
- continue;
2388
- const C = d.indexOf(S), j = h[C];
2389
- if (!j)
2390
- continue;
2391
- const {
2392
- direction: R,
2393
- speed: L
2394
- } = pi(S, j, v, t, m);
2395
- for (const M of ["x", "y"])
2396
- p[M][R[M]] || (L[M] = 0, R[M] = 0);
2397
- if (L.x > 0 || L.y > 0) {
2398
- g(), y.current = S, x(_, a), b.current = L, w.current = R;
2399
- return;
2400
- }
2401
- }
2402
- b.current = {
2403
- x: 0,
2404
- y: 0
2405
- }, w.current = {
2406
- x: 0,
2407
- y: 0
2408
- }, g();
2409
- },
2410
- // eslint-disable-next-line react-hooks/exhaustive-deps
2411
- [
2412
- t,
2413
- _,
2414
- r,
2415
- g,
2416
- o,
2417
- a,
2418
- // eslint-disable-next-line react-hooks/exhaustive-deps
2419
- JSON.stringify(v),
2420
- // eslint-disable-next-line react-hooks/exhaustive-deps
2421
- JSON.stringify(p),
2422
- x,
2423
- d,
2424
- N,
2425
- h,
2426
- // eslint-disable-next-line react-hooks/exhaustive-deps
2427
- JSON.stringify(m)
2428
- ]
2429
- );
2430
- }
2431
- const Ei = {
2432
- x: {
2433
- [z.Backward]: !1,
2434
- [z.Forward]: !1
2435
- },
2436
- y: {
2437
- [z.Backward]: !1,
2438
- [z.Forward]: !1
2439
- }
2440
- };
2441
- function Ri(e) {
2442
- let {
2443
- delta: t,
2444
- disabled: n
2445
- } = e;
2446
- const r = zt(t);
2447
- return rt((s) => {
2448
- if (n || !r || !s)
2449
- return Ei;
2450
- const o = {
2451
- x: Math.sign(t.x - r.x),
2452
- y: Math.sign(t.y - r.y)
2453
- };
2454
- return {
2455
- x: {
2456
- [z.Backward]: s.x[z.Backward] || o.x === -1,
2457
- [z.Forward]: s.x[z.Forward] || o.x === 1
2458
- },
2459
- y: {
2460
- [z.Backward]: s.y[z.Backward] || o.y === -1,
2461
- [z.Forward]: s.y[z.Forward] || o.y === 1
2462
- }
2463
- };
2464
- }, [n, t, r]);
2465
- }
2466
- function Mi(e, t) {
2467
- const n = t != null ? e.get(t) : void 0, r = n ? n.node.current : null;
2468
- return rt((s) => {
2469
- var o;
2470
- return t == null ? null : (o = r ?? s) != null ? o : null;
2471
- }, [r, t]);
2472
- }
2473
- function Ai(e, t) {
2474
- return l.useMemo(() => e.reduce((n, r) => {
2475
- const {
2476
- sensor: s
2477
- } = r, o = s.activators.map((a) => ({
2478
- eventName: a.eventName,
2479
- handler: t(a.handler, r)
2480
- }));
2481
- return [...n, ...o];
2482
- }, []), [e, t]);
2483
- }
2484
- var tt;
2485
- (function(e) {
2486
- e[e.Always = 0] = "Always", e[e.BeforeDragging = 1] = "BeforeDragging", e[e.WhileDragging = 2] = "WhileDragging";
2487
- })(tt || (tt = {}));
2488
- var Kt;
2489
- (function(e) {
2490
- e.Optimized = "optimized";
2491
- })(Kt || (Kt = {}));
2492
- const Cn = /* @__PURE__ */ new Map();
2493
- function Li(e, t) {
2494
- let {
2495
- dragging: n,
2496
- dependencies: r,
2497
- config: s
2498
- } = t;
2499
- const [o, a] = l.useState(null), {
2500
- frequency: c,
2501
- measure: u,
2502
- strategy: d
2503
- } = s, h = l.useRef(e), f = b(), m = Ze(f), p = l.useCallback(function(w) {
2504
- w === void 0 && (w = []), !m.current && a((v) => v === null ? w : v.concat(w.filter((y) => !v.includes(y))));
2505
- }, [m]), x = l.useRef(null), g = rt((w) => {
2506
- if (f && !n)
2507
- return Cn;
2508
- if (!w || w === Cn || h.current !== e || o != null) {
2509
- const v = /* @__PURE__ */ new Map();
2510
- for (let y of e) {
2511
- if (!y)
2512
- continue;
2513
- if (o && o.length > 0 && !o.includes(y.id) && y.rect.current) {
2514
- v.set(y.id, y.rect.current);
2515
- continue;
2516
- }
2517
- const _ = y.node.current, N = _ ? new Gt(u(_), _) : null;
2518
- y.rect.current = N, N && v.set(y.id, N);
2519
- }
2520
- return v;
2521
- }
2522
- return w;
2523
- }, [e, o, n, f, u]);
2524
- return l.useEffect(() => {
2525
- h.current = e;
2526
- }, [e]), l.useEffect(
2527
- () => {
2528
- f || p();
2529
- },
2530
- // eslint-disable-next-line react-hooks/exhaustive-deps
2531
- [n, f]
2532
- ), l.useEffect(
2533
- () => {
2534
- o && o.length > 0 && a(null);
2535
- },
2536
- //eslint-disable-next-line react-hooks/exhaustive-deps
2537
- [JSON.stringify(o)]
2538
- ), l.useEffect(
2539
- () => {
2540
- f || typeof c != "number" || x.current !== null || (x.current = setTimeout(() => {
2541
- p(), x.current = null;
2542
- }, c));
2543
- },
2544
- // eslint-disable-next-line react-hooks/exhaustive-deps
2545
- [c, f, p, ...r]
2546
- ), {
2547
- droppableRects: g,
2548
- measureDroppableContainers: p,
2549
- measuringScheduled: o != null
2550
- };
2551
- function b() {
2552
- switch (d) {
2553
- case tt.Always:
2554
- return !1;
2555
- case tt.BeforeDragging:
2556
- return n;
2557
- default:
2558
- return !n;
2559
- }
2560
- }
2561
- }
2562
- function Gn(e, t) {
2563
- return rt((n) => e ? n || (typeof t == "function" ? t(e) : e) : null, [t, e]);
2564
- }
2565
- function Ii(e, t) {
2566
- return Gn(e, t);
2567
- }
2568
- function Ti(e) {
2569
- let {
2570
- callback: t,
2571
- disabled: n
2572
- } = e;
2573
- const r = Qt(t), s = l.useMemo(() => {
2574
- if (n || typeof window > "u" || typeof window.MutationObserver > "u")
2575
- return;
2576
- const {
2577
- MutationObserver: o
2578
- } = window;
2579
- return new o(r);
2580
- }, [r, n]);
2581
- return l.useEffect(() => () => s?.disconnect(), [s]), s;
2582
- }
2583
- function jt(e) {
2584
- let {
2585
- callback: t,
2586
- disabled: n
2587
- } = e;
2588
- const r = Qt(t), s = l.useMemo(
2589
- () => {
2590
- if (n || typeof window > "u" || typeof window.ResizeObserver > "u")
2591
- return;
2592
- const {
2593
- ResizeObserver: o
2594
- } = window;
2595
- return new o(r);
2596
- },
2597
- // eslint-disable-next-line react-hooks/exhaustive-deps
2598
- [n]
2599
- );
2600
- return l.useEffect(() => () => s?.disconnect(), [s]), s;
2601
- }
2602
- function Pi(e) {
2603
- return new Gt(qe(e), e);
2604
- }
2605
- function Sn(e, t, n) {
2606
- t === void 0 && (t = Pi);
2607
- const [r, s] = l.useState(null);
2608
- function o() {
2609
- s((u) => {
2610
- if (!e)
2611
- return null;
2612
- if (e.isConnected === !1) {
2613
- var d;
2614
- return (d = u ?? n) != null ? d : null;
2615
- }
2616
- const h = t(e);
2617
- return JSON.stringify(u) === JSON.stringify(h) ? u : h;
2618
- });
2619
- }
2620
- const a = Ti({
2621
- callback(u) {
2622
- if (e)
2623
- for (const d of u) {
2624
- const {
2625
- type: h,
2626
- target: f
2627
- } = d;
2628
- if (h === "childList" && f instanceof HTMLElement && f.contains(e)) {
2629
- o();
2630
- break;
2631
- }
2632
- }
2633
- }
2634
- }), c = jt({
2635
- callback: o
2636
- });
2637
- return fe(() => {
2638
- o(), e ? (c?.observe(e), a?.observe(document.body, {
2639
- childList: !0,
2640
- subtree: !0
2641
- })) : (c?.disconnect(), a?.disconnect());
2642
- }, [e]), r;
2643
- }
2644
- function Oi(e) {
2645
- const t = Gn(e);
2646
- return Kn(e, t);
2647
- }
2648
- const jn = [];
2649
- function Fi(e) {
2650
- const t = l.useRef(e), n = rt((r) => e ? r && r !== jn && e && t.current && e.parentNode === t.current.parentNode ? r : _t(e) : jn, [e]);
2651
- return l.useEffect(() => {
2652
- t.current = e;
2653
- }, [e]), n;
2654
- }
2655
- function zi(e) {
2656
- const [t, n] = l.useState(null), r = l.useRef(e), s = l.useCallback((o) => {
2657
- const a = Lt(o.target);
2658
- a && n((c) => c ? (c.set(a, $t(a)), new Map(c)) : null);
2659
- }, []);
2660
- return l.useEffect(() => {
2661
- const o = r.current;
2662
- if (e !== o) {
2663
- a(o);
2664
- const c = e.map((u) => {
2665
- const d = Lt(u);
2666
- return d ? (d.addEventListener("scroll", s, {
2667
- passive: !0
2668
- }), [d, $t(d)]) : null;
2669
- }).filter((u) => u != null);
2670
- n(c.length ? new Map(c) : null), r.current = e;
2671
- }
2672
- return () => {
2673
- a(e), a(o);
2674
- };
2675
- function a(c) {
2676
- c.forEach((u) => {
2677
- const d = Lt(u);
2678
- d?.removeEventListener("scroll", s);
2679
- });
2680
- }
2681
- }, [s, e]), l.useMemo(() => e.length ? t ? Array.from(t.values()).reduce((o, a) => Oe(o, a), ie) : Qn(e) : ie, [e, t]);
2682
- }
2683
- function Nn(e, t) {
2684
- t === void 0 && (t = []);
2685
- const n = l.useRef(null);
2686
- return l.useEffect(
2687
- () => {
2688
- n.current = null;
2689
- },
2690
- // eslint-disable-next-line react-hooks/exhaustive-deps
2691
- t
2692
- ), l.useEffect(() => {
2693
- const r = e !== ie;
2694
- r && !n.current && (n.current = e), !r && n.current && (n.current = null);
2695
- }, [e]), n.current ? et(e, n.current) : ie;
2696
- }
2697
- function Bi(e) {
2698
- l.useEffect(
2699
- () => {
2700
- if (!wt)
2701
- return;
2702
- const t = e.map((n) => {
2703
- let {
2704
- sensor: r
2705
- } = n;
2706
- return r.setup == null ? void 0 : r.setup();
2707
- });
2708
- return () => {
2709
- for (const n of t)
2710
- n?.();
2711
- };
2712
- },
2713
- // TO-DO: Sensors length could theoretically change which would not be a valid dependency
2714
- // eslint-disable-next-line react-hooks/exhaustive-deps
2715
- e.map((t) => {
2716
- let {
2717
- sensor: n
2718
- } = t;
2719
- return n;
2720
- })
2721
- );
2722
- }
2723
- function $i(e, t) {
2724
- return l.useMemo(() => e.reduce((n, r) => {
2725
- let {
2726
- eventName: s,
2727
- handler: o
2728
- } = r;
2729
- return n[s] = (a) => {
2730
- o(a, t);
2731
- }, n;
2732
- }, {}), [e, t]);
2733
- }
2734
- function Jn(e) {
2735
- return l.useMemo(() => e ? di(e) : null, [e]);
2736
- }
2737
- const Dn = [];
2738
- function qi(e, t) {
2739
- t === void 0 && (t = qe);
2740
- const [n] = e, r = Jn(n ? Q(n) : null), [s, o] = l.useState(Dn);
2741
- function a() {
2742
- o(() => e.length ? e.map((u) => Xn(u) ? r : new Gt(t(u), u)) : Dn);
2743
- }
2744
- const c = jt({
2745
- callback: a
2746
- });
2747
- return fe(() => {
2748
- c?.disconnect(), a(), e.forEach((u) => c?.observe(u));
2749
- }, [e]), s;
2750
- }
2751
- function Ki(e) {
2752
- if (!e)
2753
- return null;
2754
- if (e.children.length > 1)
2755
- return e;
2756
- const t = e.children[0];
2757
- return nt(t) ? t : e;
2758
- }
2759
- function Ui(e) {
2760
- let {
2761
- measure: t
2762
- } = e;
2763
- const [n, r] = l.useState(null), s = l.useCallback((d) => {
2764
- for (const {
2765
- target: h
2766
- } of d)
2767
- if (nt(h)) {
2768
- r((f) => {
2769
- const m = t(h);
2770
- return f ? {
2771
- ...f,
2772
- width: m.width,
2773
- height: m.height
2774
- } : m;
2775
- });
2776
- break;
2777
- }
2778
- }, [t]), o = jt({
2779
- callback: s
2780
- }), a = l.useCallback((d) => {
2781
- const h = Ki(d);
2782
- o?.disconnect(), h && o?.observe(h), r(h ? t(h) : null);
2783
- }, [t, o]), [c, u] = ht(a);
2784
- return l.useMemo(() => ({
2785
- nodeRef: c,
2786
- rect: n,
2787
- setRef: u
2788
- }), [n, c, u]);
2789
- }
2790
- const Hi = [{
2791
- sensor: St,
2792
- options: {}
2793
- }, {
2794
- sensor: Ct,
2795
- options: {}
2796
- }], Yi = {
2797
- current: {}
2798
- }, ft = {
2799
- draggable: {
2800
- measure: xn
2801
- },
2802
- droppable: {
2803
- measure: xn,
2804
- strategy: tt.WhileDragging,
2805
- frequency: Kt.Optimized
2806
- },
2807
- dragOverlay: {
2808
- measure: qe
2809
- }
2810
- };
2811
- class Je extends Map {
2812
- get(t) {
2813
- var n;
2814
- return t != null && (n = super.get(t)) != null ? n : void 0;
2815
- }
2816
- toArray() {
2817
- return Array.from(this.values());
2818
- }
2819
- getEnabled() {
2820
- return this.toArray().filter((t) => {
2821
- let {
2822
- disabled: n
2823
- } = t;
2824
- return !n;
2825
- });
2826
- }
2827
- getNodeFor(t) {
2828
- var n, r;
2829
- return (n = (r = this.get(t)) == null ? void 0 : r.node.current) != null ? n : void 0;
2830
- }
2831
- }
2832
- const Xi = {
2833
- activatorEvent: null,
2834
- active: null,
2835
- activeNode: null,
2836
- activeNodeRect: null,
2837
- collisions: null,
2838
- containerNodeRect: null,
2839
- draggableNodes: /* @__PURE__ */ new Map(),
2840
- droppableRects: /* @__PURE__ */ new Map(),
2841
- droppableContainers: /* @__PURE__ */ new Je(),
2842
- over: null,
2843
- dragOverlay: {
2844
- nodeRef: {
2845
- current: null
2846
- },
2847
- rect: null,
2848
- setRef: mt
2849
- },
2850
- scrollableAncestors: [],
2851
- scrollableAncestorRects: [],
2852
- measuringConfiguration: ft,
2853
- measureDroppableContainers: mt,
2854
- windowRect: null,
2855
- measuringScheduled: !1
2856
- }, Wi = {
2857
- activatorEvent: null,
2858
- activators: [],
2859
- active: null,
2860
- activeNodeRect: null,
2861
- ariaDescribedById: {
2862
- draggable: ""
2863
- },
2864
- dispatch: mt,
2865
- draggableNodes: /* @__PURE__ */ new Map(),
2866
- over: null,
2867
- measureDroppableContainers: mt
2868
- }, Nt = /* @__PURE__ */ l.createContext(Wi), Zn = /* @__PURE__ */ l.createContext(Xi);
2869
- function Qi() {
2870
- return {
2871
- draggable: {
2872
- active: null,
2873
- initialCoordinates: {
2874
- x: 0,
2875
- y: 0
2876
- },
2877
- nodes: /* @__PURE__ */ new Map(),
2878
- translate: {
2879
- x: 0,
2880
- y: 0
2881
- }
2882
- },
2883
- droppable: {
2884
- containers: new Je()
2885
- }
2886
- };
2887
- }
2888
- function Vi(e, t) {
2889
- switch (t.type) {
2890
- case O.DragStart:
2891
- return {
2892
- ...e,
2893
- draggable: {
2894
- ...e.draggable,
2895
- initialCoordinates: t.initialCoordinates,
2896
- active: t.active
2897
- }
2898
- };
2899
- case O.DragMove:
2900
- return e.draggable.active == null ? e : {
2901
- ...e,
2902
- draggable: {
2903
- ...e.draggable,
2904
- translate: {
2905
- x: t.coordinates.x - e.draggable.initialCoordinates.x,
2906
- y: t.coordinates.y - e.draggable.initialCoordinates.y
2907
- }
2908
- }
2909
- };
2910
- case O.DragEnd:
2911
- case O.DragCancel:
2912
- return {
2913
- ...e,
2914
- draggable: {
2915
- ...e.draggable,
2916
- active: null,
2917
- initialCoordinates: {
2918
- x: 0,
2919
- y: 0
2920
- },
2921
- translate: {
2922
- x: 0,
2923
- y: 0
2924
- }
2925
- }
2926
- };
2927
- case O.RegisterDroppable: {
2928
- const {
2929
- element: n
2930
- } = t, {
2931
- id: r
2932
- } = n, s = new Je(e.droppable.containers);
2933
- return s.set(r, n), {
2934
- ...e,
2935
- droppable: {
2936
- ...e.droppable,
2937
- containers: s
2938
- }
2939
- };
2940
- }
2941
- case O.SetDroppableDisabled: {
2942
- const {
2943
- id: n,
2944
- key: r,
2945
- disabled: s
2946
- } = t, o = e.droppable.containers.get(n);
2947
- if (!o || r !== o.key)
2948
- return e;
2949
- const a = new Je(e.droppable.containers);
2950
- return a.set(n, {
2951
- ...o,
2952
- disabled: s
2953
- }), {
2954
- ...e,
2955
- droppable: {
2956
- ...e.droppable,
2957
- containers: a
2958
- }
2959
- };
2960
- }
2961
- case O.UnregisterDroppable: {
2962
- const {
2963
- id: n,
2964
- key: r
2965
- } = t, s = e.droppable.containers.get(n);
2966
- if (!s || r !== s.key)
2967
- return e;
2968
- const o = new Je(e.droppable.containers);
2969
- return o.delete(n), {
2970
- ...e,
2971
- droppable: {
2972
- ...e.droppable,
2973
- containers: o
2974
- }
2975
- };
2976
- }
2977
- default:
2978
- return e;
2979
- }
2980
- }
2981
- function Gi(e) {
2982
- let {
2983
- disabled: t
2984
- } = e;
2985
- const {
2986
- active: n,
2987
- activatorEvent: r,
2988
- draggableNodes: s
2989
- } = l.useContext(Nt), o = zt(r), a = zt(n?.id);
2990
- return l.useEffect(() => {
2991
- if (!t && !r && o && a != null) {
2992
- if (!Vt(o) || document.activeElement === o.target)
2993
- return;
2994
- const c = s.get(a);
2995
- if (!c)
2996
- return;
2997
- const {
2998
- activatorNode: u,
2999
- node: d
3000
- } = c;
3001
- if (!u.current && !d.current)
3002
- return;
3003
- requestAnimationFrame(() => {
3004
- for (const h of [u.current, d.current]) {
3005
- if (!h)
3006
- continue;
3007
- const f = Hs(h);
3008
- if (f) {
3009
- f.focus();
3010
- break;
3011
- }
3012
- }
3013
- });
3014
- }
3015
- }, [r, t, s, a, o]), null;
3016
- }
3017
- function Ji(e, t) {
3018
- let {
3019
- transform: n,
3020
- ...r
3021
- } = t;
3022
- return e != null && e.length ? e.reduce((s, o) => o({
3023
- transform: s,
3024
- ...r
3025
- }), n) : n;
3026
- }
3027
- function Zi(e) {
3028
- return l.useMemo(
3029
- () => ({
3030
- draggable: {
3031
- ...ft.draggable,
3032
- ...e?.draggable
3033
- },
3034
- droppable: {
3035
- ...ft.droppable,
3036
- ...e?.droppable
3037
- },
3038
- dragOverlay: {
3039
- ...ft.dragOverlay,
3040
- ...e?.dragOverlay
3041
- }
3042
- }),
3043
- // eslint-disable-next-line react-hooks/exhaustive-deps
3044
- [e?.draggable, e?.droppable, e?.dragOverlay]
3045
- );
3046
- }
3047
- function eo(e) {
3048
- let {
3049
- activeNode: t,
3050
- measure: n,
3051
- initialRect: r,
3052
- config: s = !0
3053
- } = e;
3054
- const o = l.useRef(!1), {
3055
- x: a,
3056
- y: c
3057
- } = typeof s == "boolean" ? {
3058
- x: s,
3059
- y: s
3060
- } : s;
3061
- fe(() => {
3062
- if (!a && !c || !t) {
3063
- o.current = !1;
3064
- return;
3065
- }
3066
- if (o.current || !r)
3067
- return;
3068
- const d = t?.node.current;
3069
- if (!d || d.isConnected === !1)
3070
- return;
3071
- const h = n(d), f = Kn(h, r);
3072
- if (a || (f.x = 0), c || (f.y = 0), o.current = !0, Math.abs(f.x) > 0 || Math.abs(f.y) > 0) {
3073
- const m = Un(d);
3074
- m && m.scrollBy({
3075
- top: f.y,
3076
- left: f.x
3077
- });
3078
- }
3079
- }, [t, a, c, r, n]);
3080
- }
3081
- const er = /* @__PURE__ */ l.createContext({
3082
- ...ie,
3083
- scaleX: 1,
3084
- scaleY: 1
3085
- });
3086
- var Ne;
3087
- (function(e) {
3088
- e[e.Uninitialized = 0] = "Uninitialized", e[e.Initializing = 1] = "Initializing", e[e.Initialized = 2] = "Initialized";
3089
- })(Ne || (Ne = {}));
3090
- const tr = /* @__PURE__ */ l.memo(function(t) {
3091
- var n, r, s, o;
3092
- let {
3093
- id: a,
3094
- accessibility: c,
3095
- autoScroll: u = !0,
3096
- children: d,
3097
- sensors: h = Hi,
3098
- collisionDetection: f = si,
3099
- measuring: m,
3100
- modifiers: p,
3101
- ...x
3102
- } = t;
3103
- const g = l.useReducer(Vi, void 0, Qi), [b, w] = g, [v, y] = Gs(), [_, N] = l.useState(Ne.Uninitialized), S = _ === Ne.Initialized, {
3104
- draggable: {
3105
- active: C,
3106
- nodes: j,
3107
- translate: R
3108
- },
3109
- droppable: {
3110
- containers: L
3111
- }
3112
- } = b, M = C != null ? j.get(C) : null, P = l.useRef({
3113
- initial: null,
3114
- translated: null
3115
- }), H = l.useMemo(() => {
3116
- var K;
3117
- return C != null ? {
3118
- id: C,
3119
- // It's possible for the active node to unmount while dragging
3120
- data: (K = M?.data) != null ? K : Yi,
3121
- rect: P
3122
- } : null;
3123
- }, [C, M]), k = l.useRef(null), [Y, ae] = l.useState(null), [B, I] = l.useState(null), X = Ze(x, Object.values(x)), me = st("DndDescribedBy", a), Re = l.useMemo(() => L.getEnabled(), [L]), q = Zi(m), {
3124
- droppableRects: Z,
3125
- measureDroppableContainers: pe,
3126
- measuringScheduled: re
3127
- } = Li(Re, {
3128
- dragging: S,
3129
- dependencies: [R.x, R.y],
3130
- config: q.droppable
3131
- }), ee = Mi(j, C), it = l.useMemo(() => B ? Bt(B) : null, [B]), xe = xr(), ge = Ii(ee, q.draggable.measure);
3132
- eo({
3133
- activeNode: C != null ? j.get(C) : null,
3134
- config: xe.layoutShiftCompensation,
3135
- initialRect: ge,
3136
- measure: q.draggable.measure
3137
- });
3138
- const A = Sn(ee, q.draggable.measure, ge), Ke = Sn(ee ? ee.parentElement : null), le = l.useRef({
3139
- activatorEvent: null,
3140
- active: null,
3141
- activeNode: ee,
3142
- collisionRect: null,
3143
- collisions: null,
3144
- droppableRects: Z,
3145
- draggableNodes: j,
3146
- draggingNode: null,
3147
- draggingNodeRect: null,
3148
- droppableContainers: L,
3149
- over: null,
3150
- scrollableAncestors: [],
3151
- scrollAdjustedTranslate: null
3152
- }), Me = L.getNodeFor((n = le.current.over) == null ? void 0 : n.id), ve = Ui({
3153
- measure: q.dragOverlay.measure
3154
- }), Ae = (r = ve.nodeRef.current) != null ? r : ee, Le = S ? (s = ve.rect) != null ? s : A : null, Zt = !!(ve.nodeRef.current && ve.rect), en = Oi(Zt ? null : A), kt = Jn(Ae ? Q(Ae) : null), ye = Fi(S ? Me ?? ee : null), ot = qi(ye), at = Ji(p, {
3155
- transform: {
3156
- x: R.x - en.x,
3157
- y: R.y - en.y,
3158
- scaleX: 1,
3159
- scaleY: 1
3160
- },
3161
- activatorEvent: B,
3162
- active: H,
3163
- activeNodeRect: A,
3164
- containerNodeRect: Ke,
3165
- draggingNodeRect: Le,
3166
- over: le.current.over,
3167
- overlayNodeRect: ve.rect,
3168
- scrollableAncestors: ye,
3169
- scrollableAncestorRects: ot,
3170
- windowRect: kt
3171
- }), tn = it ? Oe(it, R) : null, nn = zi(ye), fr = Nn(nn), hr = Nn(nn, [A]), Ie = Oe(at, fr), Te = Le ? ai(Le, at) : null, Ue = H && Te ? f({
3172
- active: H,
3173
- collisionRect: Te,
3174
- droppableRects: Z,
3175
- droppableContainers: Re,
3176
- pointerCoordinates: tn
3177
- }) : null, rn = $n(Ue, "id"), [we, sn] = l.useState(null), mr = Zt ? at : Oe(at, hr), pr = ii(mr, (o = we?.rect) != null ? o : null, A), Et = l.useRef(null), on = l.useCallback(
3178
- (K, V) => {
3179
- let {
3180
- sensor: G,
3181
- options: _e
3182
- } = V;
3183
- if (k.current == null)
3184
- return;
3185
- const te = j.get(k.current);
3186
- if (!te)
3187
- return;
3188
- const J = K.nativeEvent, ce = new G({
3189
- active: k.current,
3190
- activeNode: te,
3191
- event: J,
3192
- options: _e,
3193
- // Sensors need to be instantiated with refs for arguments that change over time
3194
- // otherwise they are frozen in time with the stale arguments
3195
- context: le,
3196
- onAbort($) {
3197
- if (!j.get($))
3198
- return;
3199
- const {
3200
- onDragAbort: ue
3201
- } = X.current, be = {
3202
- id: $
3203
- };
3204
- ue?.(be), v({
3205
- type: "onDragAbort",
3206
- event: be
3207
- });
3208
- },
3209
- onPending($, Ce, ue, be) {
3210
- if (!j.get($))
3211
- return;
3212
- const {
3213
- onDragPending: Ye
3214
- } = X.current, Se = {
3215
- id: $,
3216
- constraint: Ce,
3217
- initialCoordinates: ue,
3218
- offset: be
3219
- };
3220
- Ye?.(Se), v({
3221
- type: "onDragPending",
3222
- event: Se
3223
- });
3224
- },
3225
- onStart($) {
3226
- const Ce = k.current;
3227
- if (Ce == null)
3228
- return;
3229
- const ue = j.get(Ce);
3230
- if (!ue)
3231
- return;
3232
- const {
3233
- onDragStart: be
3234
- } = X.current, He = {
3235
- activatorEvent: J,
3236
- active: {
3237
- id: Ce,
3238
- data: ue.data,
3239
- rect: P
3240
- }
3241
- };
3242
- Qe.unstable_batchedUpdates(() => {
3243
- be?.(He), N(Ne.Initializing), w({
3244
- type: O.DragStart,
3245
- initialCoordinates: $,
3246
- active: Ce
3247
- }), v({
3248
- type: "onDragStart",
3249
- event: He
3250
- }), ae(Et.current), I(J);
3251
- });
3252
- },
3253
- onMove($) {
3254
- w({
3255
- type: O.DragMove,
3256
- coordinates: $
3257
- });
3258
- },
3259
- onEnd: Pe(O.DragEnd),
3260
- onCancel: Pe(O.DragCancel)
3261
- });
3262
- Et.current = ce;
3263
- function Pe($) {
3264
- return async function() {
3265
- const {
3266
- active: ue,
3267
- collisions: be,
3268
- over: He,
3269
- scrollAdjustedTranslate: Ye
3270
- } = le.current;
3271
- let Se = null;
3272
- if (ue && Ye) {
3273
- const {
3274
- cancelDrop: Xe
3275
- } = X.current;
3276
- Se = {
3277
- activatorEvent: J,
3278
- active: ue,
3279
- collisions: be,
3280
- delta: Ye,
3281
- over: He
3282
- }, $ === O.DragEnd && typeof Xe == "function" && await Promise.resolve(Xe(Se)) && ($ = O.DragCancel);
3283
- }
3284
- k.current = null, Qe.unstable_batchedUpdates(() => {
3285
- w({
3286
- type: $
3287
- }), N(Ne.Uninitialized), sn(null), ae(null), I(null), Et.current = null;
3288
- const Xe = $ === O.DragEnd ? "onDragEnd" : "onDragCancel";
3289
- if (Se) {
3290
- const Rt = X.current[Xe];
3291
- Rt?.(Se), v({
3292
- type: Xe,
3293
- event: Se
3294
- });
3295
- }
3296
- });
3297
- };
3298
- }
3299
- },
3300
- // eslint-disable-next-line react-hooks/exhaustive-deps
3301
- [j]
3302
- ), gr = l.useCallback((K, V) => (G, _e) => {
3303
- const te = G.nativeEvent, J = j.get(_e);
3304
- if (
3305
- // Another sensor is already instantiating
3306
- k.current !== null || // No active draggable
3307
- !J || // Event has already been captured
3308
- te.dndKit || te.defaultPrevented
3309
- )
3310
- return;
3311
- const ce = {
3312
- active: J
3313
- };
3314
- K(G, V.options, ce) === !0 && (te.dndKit = {
3315
- capturedBy: V.sensor
3316
- }, k.current = _e, on(G, V));
3317
- }, [j, on]), an = Ai(h, gr);
3318
- Bi(h), fe(() => {
3319
- A && _ === Ne.Initializing && N(Ne.Initialized);
3320
- }, [A, _]), l.useEffect(
3321
- () => {
3322
- const {
3323
- onDragMove: K
3324
- } = X.current, {
3325
- active: V,
3326
- activatorEvent: G,
3327
- collisions: _e,
3328
- over: te
3329
- } = le.current;
3330
- if (!V || !G)
3331
- return;
3332
- const J = {
3333
- active: V,
3334
- activatorEvent: G,
3335
- collisions: _e,
3336
- delta: {
3337
- x: Ie.x,
3338
- y: Ie.y
3339
- },
3340
- over: te
3341
- };
3342
- Qe.unstable_batchedUpdates(() => {
3343
- K?.(J), v({
3344
- type: "onDragMove",
3345
- event: J
3346
- });
3347
- });
3348
- },
3349
- // eslint-disable-next-line react-hooks/exhaustive-deps
3350
- [Ie.x, Ie.y]
3351
- ), l.useEffect(
3352
- () => {
3353
- const {
3354
- active: K,
3355
- activatorEvent: V,
3356
- collisions: G,
3357
- droppableContainers: _e,
3358
- scrollAdjustedTranslate: te
3359
- } = le.current;
3360
- if (!K || k.current == null || !V || !te)
3361
- return;
3362
- const {
3363
- onDragOver: J
3364
- } = X.current, ce = _e.get(rn), Pe = ce && ce.rect.current ? {
3365
- id: ce.id,
3366
- rect: ce.rect.current,
3367
- data: ce.data,
3368
- disabled: ce.disabled
3369
- } : null, $ = {
3370
- active: K,
3371
- activatorEvent: V,
3372
- collisions: G,
3373
- delta: {
3374
- x: te.x,
3375
- y: te.y
3376
- },
3377
- over: Pe
3378
- };
3379
- Qe.unstable_batchedUpdates(() => {
3380
- sn(Pe), J?.($), v({
3381
- type: "onDragOver",
3382
- event: $
3383
- });
3384
- });
3385
- },
3386
- // eslint-disable-next-line react-hooks/exhaustive-deps
3387
- [rn]
3388
- ), fe(() => {
3389
- le.current = {
3390
- activatorEvent: B,
3391
- active: H,
3392
- activeNode: ee,
3393
- collisionRect: Te,
3394
- collisions: Ue,
3395
- droppableRects: Z,
3396
- draggableNodes: j,
3397
- draggingNode: Ae,
3398
- draggingNodeRect: Le,
3399
- droppableContainers: L,
3400
- over: we,
3401
- scrollableAncestors: ye,
3402
- scrollAdjustedTranslate: Ie
3403
- }, P.current = {
3404
- initial: Le,
3405
- translated: Te
3406
- };
3407
- }, [H, ee, Ue, Te, j, Ae, Le, Z, L, we, ye, Ie]), ki({
3408
- ...xe,
3409
- delta: R,
3410
- draggingRect: Te,
3411
- pointerCoordinates: tn,
3412
- scrollableAncestors: ye,
3413
- scrollableAncestorRects: ot
3414
- });
3415
- const vr = l.useMemo(() => ({
3416
- active: H,
3417
- activeNode: ee,
3418
- activeNodeRect: A,
3419
- activatorEvent: B,
3420
- collisions: Ue,
3421
- containerNodeRect: Ke,
3422
- dragOverlay: ve,
3423
- draggableNodes: j,
3424
- droppableContainers: L,
3425
- droppableRects: Z,
3426
- over: we,
3427
- measureDroppableContainers: pe,
3428
- scrollableAncestors: ye,
3429
- scrollableAncestorRects: ot,
3430
- measuringConfiguration: q,
3431
- measuringScheduled: re,
3432
- windowRect: kt
3433
- }), [H, ee, A, B, Ue, Ke, ve, j, L, Z, we, pe, ye, ot, q, re, kt]), br = l.useMemo(() => ({
3434
- activatorEvent: B,
3435
- activators: an,
3436
- active: H,
3437
- activeNodeRect: A,
3438
- ariaDescribedById: {
3439
- draggable: me
3440
- },
3441
- dispatch: w,
3442
- draggableNodes: j,
3443
- over: we,
3444
- measureDroppableContainers: pe
3445
- }), [B, an, H, A, w, me, j, we, pe]);
3446
- return W.createElement(On.Provider, {
3447
- value: y
3448
- }, W.createElement(Nt.Provider, {
3449
- value: br
3450
- }, W.createElement(Zn.Provider, {
3451
- value: vr
3452
- }, W.createElement(er.Provider, {
3453
- value: pr
3454
- }, d)), W.createElement(Gi, {
3455
- disabled: c?.restoreFocus === !1
3456
- })), W.createElement(ei, {
3457
- ...c,
3458
- hiddenTextDescribedById: me
3459
- }));
3460
- function xr() {
3461
- const K = Y?.autoScrollEnabled === !1, V = typeof u == "object" ? u.enabled === !1 : u === !1, G = S && !K && !V;
3462
- return typeof u == "object" ? {
3463
- ...u,
3464
- enabled: G
3465
- } : {
3466
- enabled: G
3467
- };
3468
- }
3469
- }), to = /* @__PURE__ */ l.createContext(null), kn = "button", no = "Draggable";
3470
- function ro(e) {
3471
- let {
3472
- id: t,
3473
- data: n,
3474
- disabled: r = !1,
3475
- attributes: s
3476
- } = e;
3477
- const o = st(no), {
3478
- activators: a,
3479
- activatorEvent: c,
3480
- active: u,
3481
- activeNodeRect: d,
3482
- ariaDescribedById: h,
3483
- draggableNodes: f,
3484
- over: m
3485
- } = l.useContext(Nt), {
3486
- role: p = kn,
3487
- roleDescription: x = "draggable",
3488
- tabIndex: g = 0
3489
- } = s ?? {}, b = u?.id === t, w = l.useContext(b ? er : to), [v, y] = ht(), [_, N] = ht(), S = $i(a, t), C = Ze(n);
3490
- fe(
3491
- () => (f.set(t, {
3492
- id: t,
3493
- key: o,
3494
- node: v,
3495
- activatorNode: _,
3496
- data: C
3497
- }), () => {
3498
- const R = f.get(t);
3499
- R && R.key === o && f.delete(t);
3500
- }),
3501
- // eslint-disable-next-line react-hooks/exhaustive-deps
3502
- [f, t]
3503
- );
3504
- const j = l.useMemo(() => ({
3505
- role: p,
3506
- tabIndex: g,
3507
- "aria-disabled": r,
3508
- "aria-pressed": b && p === kn ? !0 : void 0,
3509
- "aria-roledescription": x,
3510
- "aria-describedby": h.draggable
3511
- }), [r, p, g, b, x, h.draggable]);
3512
- return {
3513
- active: u,
3514
- activatorEvent: c,
3515
- activeNodeRect: d,
3516
- attributes: j,
3517
- isDragging: b,
3518
- listeners: r ? void 0 : S,
3519
- node: v,
3520
- over: m,
3521
- setNodeRef: y,
3522
- setActivatorNodeRef: N,
3523
- transform: w
3524
- };
3525
- }
3526
- function so() {
3527
- return l.useContext(Zn);
3528
- }
3529
- const io = "Droppable", oo = {
3530
- timeout: 25
3531
- };
3532
- function ao(e) {
3533
- let {
3534
- data: t,
3535
- disabled: n = !1,
3536
- id: r,
3537
- resizeObserverConfig: s
3538
- } = e;
3539
- const o = st(io), {
3540
- active: a,
3541
- dispatch: c,
3542
- over: u,
3543
- measureDroppableContainers: d
3544
- } = l.useContext(Nt), h = l.useRef({
3545
- disabled: n
3546
- }), f = l.useRef(!1), m = l.useRef(null), p = l.useRef(null), {
3547
- disabled: x,
3548
- updateMeasurementsFor: g,
3549
- timeout: b
3550
- } = {
3551
- ...oo,
3552
- ...s
3553
- }, w = Ze(g ?? r), v = l.useCallback(
3554
- () => {
3555
- if (!f.current) {
3556
- f.current = !0;
3557
- return;
3558
- }
3559
- p.current != null && clearTimeout(p.current), p.current = setTimeout(() => {
3560
- d(Array.isArray(w.current) ? w.current : [w.current]), p.current = null;
3561
- }, b);
3562
- },
3563
- //eslint-disable-next-line react-hooks/exhaustive-deps
3564
- [b]
3565
- ), y = jt({
3566
- callback: v,
3567
- disabled: x || !a
3568
- }), _ = l.useCallback((j, R) => {
3569
- y && (R && (y.unobserve(R), f.current = !1), j && y.observe(j));
3570
- }, [y]), [N, S] = ht(_), C = Ze(t);
3571
- return l.useEffect(() => {
3572
- !y || !N.current || (y.disconnect(), f.current = !1, y.observe(N.current));
3573
- }, [N, y]), l.useEffect(
3574
- () => (c({
3575
- type: O.RegisterDroppable,
3576
- element: {
3577
- id: r,
3578
- key: o,
3579
- disabled: n,
3580
- node: N,
3581
- rect: m,
3582
- data: C
3583
- }
3584
- }), () => c({
3585
- type: O.UnregisterDroppable,
3586
- key: o,
3587
- id: r
3588
- })),
3589
- // eslint-disable-next-line react-hooks/exhaustive-deps
3590
- [r]
3591
- ), l.useEffect(() => {
3592
- n !== h.current.disabled && (c({
3593
- type: O.SetDroppableDisabled,
3594
- id: r,
3595
- key: o,
3596
- disabled: n
3597
- }), h.current.disabled = n);
3598
- }, [r, o, n, c]), {
3599
- active: a,
3600
- rect: m,
3601
- isOver: u?.id === r,
3602
- node: N,
3603
- over: u,
3604
- setNodeRef: S
3605
- };
3606
- }
3607
- function Dt(e, t, n) {
3608
- const r = e.slice();
3609
- return r.splice(n < 0 ? r.length + n : n, 0, r.splice(t, 1)[0]), r;
3610
- }
3611
- function lo(e, t) {
3612
- return e.reduce((n, r, s) => {
3613
- const o = t.get(r);
3614
- return o && (n[s] = o), n;
3615
- }, Array(e.length));
3616
- }
3617
- function ut(e) {
3618
- return e !== null && e >= 0;
3619
- }
3620
- function co(e, t) {
3621
- if (e === t)
3622
- return !0;
3623
- if (e.length !== t.length)
3624
- return !1;
3625
- for (let n = 0; n < e.length; n++)
3626
- if (e[n] !== t[n])
3627
- return !1;
3628
- return !0;
3629
- }
3630
- function uo(e) {
3631
- return typeof e == "boolean" ? {
3632
- draggable: e,
3633
- droppable: e
3634
- } : e;
3635
- }
3636
- const nr = (e) => {
3637
- let {
3638
- rects: t,
3639
- activeIndex: n,
3640
- overIndex: r,
3641
- index: s
3642
- } = e;
3643
- const o = Dt(t, r, n), a = t[s], c = o[s];
3644
- return !c || !a ? null : {
3645
- x: c.left - a.left,
3646
- y: c.top - a.top,
3647
- scaleX: c.width / a.width,
3648
- scaleY: c.height / a.height
3649
- };
3650
- }, dt = {
3651
- scaleX: 1,
3652
- scaleY: 1
3653
- }, rr = (e) => {
3654
- var t;
3655
- let {
3656
- activeIndex: n,
3657
- activeNodeRect: r,
3658
- index: s,
3659
- rects: o,
3660
- overIndex: a
3661
- } = e;
3662
- const c = (t = o[n]) != null ? t : r;
3663
- if (!c)
3664
- return null;
3665
- if (s === n) {
3666
- const d = o[a];
3667
- return d ? {
3668
- x: 0,
3669
- y: n < a ? d.top + d.height - (c.top + c.height) : d.top - c.top,
3670
- ...dt
3671
- } : null;
3672
- }
3673
- const u = fo(o, s, n);
3674
- return s > n && s <= a ? {
3675
- x: 0,
3676
- y: -c.height - u,
3677
- ...dt
3678
- } : s < n && s >= a ? {
3679
- x: 0,
3680
- y: c.height + u,
3681
- ...dt
3682
- } : {
3683
- x: 0,
3684
- y: 0,
3685
- ...dt
3686
- };
3687
- };
3688
- function fo(e, t, n) {
3689
- const r = e[t], s = e[t - 1], o = e[t + 1];
3690
- return r ? n < t ? s ? r.top - (s.top + s.height) : o ? o.top - (r.top + r.height) : 0 : o ? o.top - (r.top + r.height) : s ? r.top - (s.top + s.height) : 0 : 0;
3691
- }
3692
- const sr = "Sortable", ir = /* @__PURE__ */ W.createContext({
3693
- activeIndex: -1,
3694
- containerId: sr,
3695
- disableTransforms: !1,
3696
- items: [],
3697
- overIndex: -1,
3698
- useDragOverlay: !1,
3699
- sortedRects: [],
3700
- strategy: nr,
3701
- disabled: {
3702
- draggable: !1,
3703
- droppable: !1
3704
- }
3705
- });
3706
- function or(e) {
3707
- let {
3708
- children: t,
3709
- id: n,
3710
- items: r,
3711
- strategy: s = nr,
3712
- disabled: o = !1
3713
- } = e;
3714
- const {
3715
- active: a,
3716
- dragOverlay: c,
3717
- droppableRects: u,
3718
- over: d,
3719
- measureDroppableContainers: h
3720
- } = so(), f = st(sr, n), m = c.rect !== null, p = l.useMemo(() => r.map((S) => typeof S == "object" && "id" in S ? S.id : S), [r]), x = a != null, g = a ? p.indexOf(a.id) : -1, b = d ? p.indexOf(d.id) : -1, w = l.useRef(p), v = !co(p, w.current), y = b !== -1 && g === -1 || v, _ = uo(o);
3721
- fe(() => {
3722
- v && x && h(p);
3723
- }, [v, p, x, h]), l.useEffect(() => {
3724
- w.current = p;
3725
- }, [p]);
3726
- const N = l.useMemo(
3727
- () => ({
3728
- activeIndex: g,
3729
- containerId: f,
3730
- disabled: _,
3731
- disableTransforms: y,
3732
- items: p,
3733
- overIndex: b,
3734
- useDragOverlay: m,
3735
- sortedRects: lo(p, u),
3736
- strategy: s
3737
- }),
3738
- // eslint-disable-next-line react-hooks/exhaustive-deps
3739
- [g, f, _.draggable, _.droppable, y, p, b, u, m, s]
3740
- );
3741
- return W.createElement(ir.Provider, {
3742
- value: N
3743
- }, t);
3744
- }
3745
- const ho = (e) => {
3746
- let {
3747
- id: t,
3748
- items: n,
3749
- activeIndex: r,
3750
- overIndex: s
3751
- } = e;
3752
- return Dt(n, r, s).indexOf(t);
3753
- }, mo = (e) => {
3754
- let {
3755
- containerId: t,
3756
- isSorting: n,
3757
- wasDragging: r,
3758
- index: s,
3759
- items: o,
3760
- newIndex: a,
3761
- previousItems: c,
3762
- previousContainerId: u,
3763
- transition: d
3764
- } = e;
3765
- return !d || !r || c !== o && s === a ? !1 : n ? !0 : a !== s && t === u;
3766
- }, po = {
3767
- duration: 200,
3768
- easing: "ease"
3769
- }, ar = "transform", go = /* @__PURE__ */ Fe.Transition.toString({
3770
- property: ar,
3771
- duration: 0,
3772
- easing: "linear"
3773
- }), vo = {
3774
- roleDescription: "sortable"
3775
- };
3776
- function bo(e) {
3777
- let {
3778
- disabled: t,
3779
- index: n,
3780
- node: r,
3781
- rect: s
3782
- } = e;
3783
- const [o, a] = l.useState(null), c = l.useRef(n);
3784
- return fe(() => {
3785
- if (!t && n !== c.current && r.current) {
3786
- const u = s.current;
3787
- if (u) {
3788
- const d = qe(r.current, {
3789
- ignoreTransform: !0
3790
- }), h = {
3791
- x: u.left - d.left,
3792
- y: u.top - d.top,
3793
- scaleX: u.width / d.width,
3794
- scaleY: u.height / d.height
3795
- };
3796
- (h.x || h.y) && a(h);
3797
- }
3798
- }
3799
- n !== c.current && (c.current = n);
3800
- }, [t, n, r, s]), l.useEffect(() => {
3801
- o && a(null);
3802
- }, [o]), o;
3803
- }
3804
- function lr(e) {
3805
- let {
3806
- animateLayoutChanges: t = mo,
3807
- attributes: n,
3808
- disabled: r,
3809
- data: s,
3810
- getNewIndex: o = ho,
3811
- id: a,
3812
- strategy: c,
3813
- resizeObserverConfig: u,
3814
- transition: d = po
3815
- } = e;
3816
- const {
3817
- items: h,
3818
- containerId: f,
3819
- activeIndex: m,
3820
- disabled: p,
3821
- disableTransforms: x,
3822
- sortedRects: g,
3823
- overIndex: b,
3824
- useDragOverlay: w,
3825
- strategy: v
3826
- } = l.useContext(ir), y = xo(r, p), _ = h.indexOf(a), N = l.useMemo(() => ({
3827
- sortable: {
3828
- containerId: f,
3829
- index: _,
3830
- items: h
3831
- },
3832
- ...s
3833
- }), [f, s, _, h]), S = l.useMemo(() => h.slice(h.indexOf(a)), [h, a]), {
3834
- rect: C,
3835
- node: j,
3836
- isOver: R,
3837
- setNodeRef: L
3838
- } = ao({
3839
- id: a,
3840
- data: N,
3841
- disabled: y.droppable,
3842
- resizeObserverConfig: {
3843
- updateMeasurementsFor: S,
3844
- ...u
3845
- }
3846
- }), {
3847
- active: M,
3848
- activatorEvent: P,
3849
- activeNodeRect: H,
3850
- attributes: k,
3851
- setNodeRef: Y,
3852
- listeners: ae,
3853
- isDragging: B,
3854
- over: I,
3855
- setActivatorNodeRef: X,
3856
- transform: me
3857
- } = ro({
3858
- id: a,
3859
- data: N,
3860
- attributes: {
3861
- ...vo,
3862
- ...n
3863
- },
3864
- disabled: y.draggable
3865
- }), Re = $s(L, Y), q = !!M, Z = q && !x && ut(m) && ut(b), pe = !w && B, re = pe && Z ? me : null, it = Z ? re ?? (c ?? v)({
3866
- rects: g,
3867
- activeNodeRect: H,
3868
- activeIndex: m,
3869
- overIndex: b,
3870
- index: _
3871
- }) : null, xe = ut(m) && ut(b) ? o({
3872
- id: a,
3873
- items: h,
3874
- activeIndex: m,
3875
- overIndex: b
3876
- }) : _, ge = M?.id, A = l.useRef({
3877
- activeId: ge,
3878
- items: h,
3879
- newIndex: xe,
3880
- containerId: f
3881
- }), Ke = h !== A.current.items, le = t({
3882
- active: M,
3883
- containerId: f,
3884
- isDragging: B,
3885
- isSorting: q,
3886
- id: a,
3887
- index: _,
3888
- items: h,
3889
- newIndex: A.current.newIndex,
3890
- previousItems: A.current.items,
3891
- previousContainerId: A.current.containerId,
3892
- transition: d,
3893
- wasDragging: A.current.activeId != null
3894
- }), Me = bo({
3895
- disabled: !le,
3896
- index: _,
3897
- node: j,
3898
- rect: C
3899
- });
3900
- return l.useEffect(() => {
3901
- q && A.current.newIndex !== xe && (A.current.newIndex = xe), f !== A.current.containerId && (A.current.containerId = f), h !== A.current.items && (A.current.items = h);
3902
- }, [q, xe, f, h]), l.useEffect(() => {
3903
- if (ge === A.current.activeId)
3904
- return;
3905
- if (ge != null && A.current.activeId == null) {
3906
- A.current.activeId = ge;
3907
- return;
3908
- }
3909
- const Ae = setTimeout(() => {
3910
- A.current.activeId = ge;
3911
- }, 50);
3912
- return () => clearTimeout(Ae);
3913
- }, [ge]), {
3914
- active: M,
3915
- activeIndex: m,
3916
- attributes: k,
3917
- data: N,
3918
- rect: C,
3919
- index: _,
3920
- newIndex: xe,
3921
- items: h,
3922
- isOver: R,
3923
- isSorting: q,
3924
- isDragging: B,
3925
- listeners: ae,
3926
- node: j,
3927
- overIndex: b,
3928
- over: I,
3929
- setNodeRef: Re,
3930
- setActivatorNodeRef: X,
3931
- setDroppableNodeRef: L,
3932
- setDraggableNodeRef: Y,
3933
- transform: Me ?? it,
3934
- transition: ve()
3935
- };
3936
- function ve() {
3937
- if (
3938
- // Temporarily disable transitions for a single frame to set up derived transforms
3939
- Me || // Or to prevent items jumping to back to their "new" position when items change
3940
- Ke && A.current.newIndex === _
3941
- )
3942
- return go;
3943
- if (!(pe && !Vt(P) || !d) && (q || le))
3944
- return Fe.Transition.toString({
3945
- ...d,
3946
- property: ar
3947
- });
3948
- }
3949
- }
3950
- function xo(e, t) {
3951
- var n, r;
3952
- return typeof e == "boolean" ? {
3953
- draggable: e,
3954
- // Backwards compatibility
3955
- droppable: !1
3956
- } : {
3957
- draggable: (n = e?.draggable) != null ? n : t.draggable,
3958
- droppable: (r = e?.droppable) != null ? r : t.droppable
3959
- };
3960
- }
3961
- function vt(e) {
3962
- if (!e)
3963
- return !1;
3964
- const t = e.data.current;
3965
- return !!(t && "sortable" in t && typeof t.sortable == "object" && "containerId" in t.sortable && "items" in t.sortable && "index" in t.sortable);
3966
- }
3967
- const yo = [E.Down, E.Right, E.Up, E.Left], cr = (e, t) => {
3968
- let {
3969
- context: {
3970
- active: n,
3971
- collisionRect: r,
3972
- droppableRects: s,
3973
- droppableContainers: o,
3974
- over: a,
3975
- scrollableAncestors: c
3976
- }
3977
- } = t;
3978
- if (yo.includes(e.code)) {
3979
- if (e.preventDefault(), !n || !r)
3980
- return;
3981
- const u = [];
3982
- o.getEnabled().forEach((f) => {
3983
- if (!f || f != null && f.disabled)
3984
- return;
3985
- const m = s.get(f.id);
3986
- if (m)
3987
- switch (e.code) {
3988
- case E.Down:
3989
- r.top < m.top && u.push(f);
3990
- break;
3991
- case E.Up:
3992
- r.top > m.top && u.push(f);
3993
- break;
3994
- case E.Left:
3995
- r.left > m.left && u.push(f);
3996
- break;
3997
- case E.Right:
3998
- r.left < m.left && u.push(f);
3999
- break;
4000
- }
4001
- });
4002
- const d = ni({
4003
- collisionRect: r,
4004
- droppableRects: s,
4005
- droppableContainers: u
4006
- });
4007
- let h = $n(d, "id");
4008
- if (h === a?.id && d.length > 1 && (h = d[1].id), h != null) {
4009
- const f = o.get(n.id), m = o.get(h), p = m ? s.get(m.id) : null, x = m?.node.current;
4010
- if (x && p && f && m) {
4011
- const b = _t(x).some((S, C) => c[C] !== S), w = ur(f, m), v = wo(f, m), y = b || !w ? {
4012
- x: 0,
4013
- y: 0
4014
- } : {
4015
- x: v ? r.width - p.width : 0,
4016
- y: v ? r.height - p.height : 0
4017
- }, _ = {
4018
- x: p.left,
4019
- y: p.top
4020
- };
4021
- return y.x && y.y ? _ : et(_, y);
4022
- }
4023
- }
4024
- }
4025
- };
4026
- function ur(e, t) {
4027
- return !vt(e) || !vt(t) ? !1 : e.data.current.sortable.containerId === t.data.current.sortable.containerId;
4028
- }
4029
- function wo(e, t) {
4030
- return !vt(e) || !vt(t) || !ur(e, t) ? !1 : e.data.current.sortable.index < t.data.current.sortable.index;
4031
- }
4032
- se({
4033
- id: U(),
4034
- url: D(),
4035
- text: D(),
4036
- order: U(),
4037
- clicks: U().optional().default(0)
4038
- });
4039
- const _o = se({
4040
- id: U(),
4041
- title: D().nullable().optional(),
4042
- name: D().nullable().optional(),
4043
- image_url: D().nullable().optional(),
4044
- type: D().optional()
4045
- }).passthrough();
4046
- se({
4047
- id: U(),
4048
- favoriteable_id: U().optional(),
4049
- favoriteable_type: D(),
4050
- order: U(),
4051
- user_company_id: U().optional(),
4052
- created_at: D().optional(),
4053
- favoriteable: _o.nullable()
4054
- }).passthrough();
4055
- se({
4056
- id: U()
4057
- }).passthrough();
4058
- se({
4059
- id: U(),
4060
- bio: D().nullable(),
4061
- facebook: D().nullable(),
4062
- twitter: D().nullable(),
4063
- instagram: D().nullable(),
4064
- youtube: D().nullable(),
4065
- pinterest: D().nullable(),
4066
- tiktok: D().nullable(),
4067
- linkedin: D().nullable(),
4068
- whatsapp: D().nullable(),
4069
- wechat: D().nullable(),
4070
- image_url: D().nullable()
4071
- });
4072
- se({
4073
- id: U(),
4074
- name: D(),
4075
- description: D().nullable(),
4076
- public: Pt(),
4077
- company_id: U().nullable(),
4078
- created_at: D().datetime(),
4079
- updated_at: D().datetime(),
4080
- image_url: D().nullable(),
4081
- picker_image_url: D().nullish(),
4082
- application_theme_template_id: U().nullable(),
4083
- default: Pt().nullable().optional()
4084
- });
4085
- const Co = se({
4086
- id: U(),
4087
- name: D(),
4088
- content: D().nullable(),
4089
- stylesheet: D().nullable(),
4090
- head: D().nullable(),
4091
- status: D()
4092
- });
4093
- se({
4094
- data: se({
4095
- legacy_theme: se({
4096
- id: U(),
4097
- name: D(),
4098
- description: D().nullable(),
4099
- image_url: D().nullable(),
4100
- public: Pt(),
4101
- company_id: U().nullable(),
4102
- template: Co
4103
- })
4104
- })
4105
- });
4106
- function dr(e) {
4107
- if (!e) return e;
4108
- try {
4109
- const t = new URL(e);
4110
- return t.searchParams.has("public_id") ? (t.searchParams.delete("public_id"), t.toString()) : e;
4111
- } catch {
4112
- return e;
4113
- }
4114
- }
4115
- function So(e) {
4116
- const t = e.trim();
4117
- return t ? /^https?:\/\//i.test(t) ? t : `https://${t}` : "";
4118
- }
4119
- function jo(e) {
4120
- return se({
4121
- title: D().min(1, e("validation_button_text_required")),
4122
- url: D().transform(So).pipe(D().url(e("validation_url_invalid")))
4123
- });
4124
- }
4125
- function No({
4126
- link: e,
4127
- onEdit: t,
4128
- onDelete: n
4129
- }) {
4130
- const { t: r } = he(), {
4131
- attributes: s,
4132
- listeners: o,
4133
- setNodeRef: a,
4134
- transform: c,
4135
- transition: u,
4136
- isDragging: d
4137
- } = lr({ id: e.id }), h = {
4138
- transform: Fe.Transform.toString(c),
4139
- transition: u
4140
- }, f = dr(e.url), m = f.length > 40 ? `${f.substring(0, 40)}...` : f;
4141
- return /* @__PURE__ */ i.jsxs(
4142
- "div",
4143
- {
4144
- ref: a,
4145
- style: h,
4146
- className: `border-border bg-card flex items-center gap-3 rounded-lg border p-3 sm:p-4 ${d ? "opacity-50 shadow-lg" : ""}`,
4147
- children: [
4148
- /* @__PURE__ */ i.jsx(
4149
- "button",
4150
- {
4151
- type: "button",
4152
- className: "text-muted-foreground hover:text-foreground cursor-grab touch-none",
4153
- "aria-label": r("drag_to_reorder"),
4154
- ...s,
4155
- ...o,
4156
- children: /* @__PURE__ */ i.jsx(Rn, { className: "size-5" })
4157
- }
4158
- ),
4159
- /* @__PURE__ */ i.jsxs("div", { className: "min-w-0 flex-1", children: [
4160
- /* @__PURE__ */ i.jsx("p", { className: "text-foreground truncate font-medium", children: e.title }),
4161
- /* @__PURE__ */ i.jsx("p", { className: "text-muted-foreground truncate text-sm", children: m })
4162
- ] }),
4163
- /* @__PURE__ */ i.jsxs("div", { className: "flex shrink-0 items-center gap-1", children: [
4164
- /* @__PURE__ */ i.jsx(
4165
- T,
4166
- {
4167
- variant: "ghost",
4168
- size: "sm",
4169
- className: "text-muted-foreground hover:text-foreground",
4170
- onClick: () => t(e),
4171
- "aria-label": r("edit_button_aria"),
4172
- children: /* @__PURE__ */ i.jsx(Rr, { className: "size-4" })
4173
- }
4174
- ),
4175
- /* @__PURE__ */ i.jsx(
4176
- T,
4177
- {
4178
- variant: "ghost",
4179
- size: "sm",
4180
- className: "text-muted-foreground hover:text-destructive",
4181
- onClick: () => n(e),
4182
- "aria-label": r("delete_button_aria"),
4183
- children: /* @__PURE__ */ i.jsx(Ht, { className: "size-4" })
4184
- }
4185
- )
4186
- ] })
4187
- ]
4188
- }
4189
- );
4190
- }
4191
- function Do({
4192
- onBack: e,
4193
- onRefreshPreview: t,
4194
- onToast: n
4195
- }) {
4196
- "use no memo";
4197
- const { t: r } = he(), { isMobile: s } = En(), o = l.useMemo(() => jo(r), [r]), { data: a = [], isLoading: c } = ys(), u = ws(), d = _s(), h = Cs(), f = Ss(), [m, p] = l.useState(!1), [x, g] = l.useState(null), [b, w] = l.useState(!1), [v, y] = l.useState(null), {
4198
- register: _,
4199
- handleSubmit: N,
4200
- reset: S,
4201
- formState: { errors: C, isSubmitting: j }
4202
- } = Hr(o, {
4203
- defaultValues: { title: "", url: "" }
4204
- }), R = Fn(
4205
- pt(St),
4206
- pt(Ct, {
4207
- coordinateGetter: cr
4208
- })
4209
- ), L = l.useCallback(() => {
4210
- g(null), S({ title: "", url: "" }), p(!0);
4211
- }, [S]), M = l.useCallback(
4212
- (I) => {
4213
- g(I), S({
4214
- title: I.title,
4215
- url: dr(I.url)
4216
- }), p(!0);
4217
- },
4218
- [S]
4219
- ), P = l.useCallback(() => {
4220
- p(!1), g(null), S({ title: "", url: "" });
4221
- }, [S]), H = l.useCallback(
4222
- (I) => {
4223
- x ? d.mutate(
4224
- {
4225
- linkId: x.id,
4226
- body: { title: I.title, url: I.url }
4227
- },
4228
- {
4229
- onSuccess: () => {
4230
- n?.(r("button_updated"), "success"), P(), t?.();
4231
- },
4232
- onError: () => {
4233
- n?.(r("button_update_failed"), "error");
4234
- }
4235
- }
4236
- ) : u.mutate(
4237
- { title: I.title, url: I.url },
4238
- {
4239
- onSuccess: () => {
4240
- n?.(r("button_created"), "success"), P(), t?.();
4241
- },
4242
- onError: () => {
4243
- n?.(r("button_create_failed"), "error");
4244
- }
4245
- }
4246
- );
4247
- },
4248
- [
4249
- x,
4250
- u,
4251
- d,
4252
- P,
4253
- t,
4254
- n,
4255
- r
4256
- ]
4257
- ), k = l.useCallback((I) => {
4258
- y(I), w(!0);
4259
- }, []), Y = l.useCallback(() => {
4260
- w(!1), y(null);
4261
- }, []), ae = l.useCallback(() => {
4262
- v && h.mutate(v.id, {
4263
- onSuccess: () => {
4264
- n?.(r("button_deleted"), "success"), Y(), t?.();
4265
- },
4266
- onError: () => {
4267
- n?.(r("button_delete_failed"), "error");
4268
- }
4269
- });
4270
- }, [
4271
- v,
4272
- h,
4273
- Y,
4274
- t,
4275
- n,
4276
- r
4277
- ]), B = l.useCallback(
4278
- (I) => {
4279
- const { active: X, over: me } = I;
4280
- if (me && X.id !== me.id) {
4281
- const Re = a.findIndex((re) => re.id === X.id), q = a.findIndex((re) => re.id === me.id), Z = Dt(a, Re, q), pe = Z.map((re) => re.id);
4282
- f.mutate(
4283
- { orderedIds: pe, optimisticItems: Z },
4284
- {
4285
- onSuccess: () => {
4286
- t?.();
4287
- },
4288
- onError: () => {
4289
- n?.(r("reorder_buttons_failed"), "error");
4290
- }
4291
- }
4292
- );
4293
- }
4294
- },
4295
- [a, f, t, n, r]
4296
- );
4297
- return /* @__PURE__ */ i.jsxs(i.Fragment, { children: [
4298
- /* @__PURE__ */ i.jsxs("div", { className: "flex items-center justify-between", children: [
4299
- /* @__PURE__ */ i.jsxs("div", { className: "flex items-center gap-3", children: [
4300
- /* @__PURE__ */ i.jsx(T, { variant: "ghost", size: "icon", onClick: e, children: /* @__PURE__ */ i.jsx(Ut, { className: "size-4" }) }),
4301
- /* @__PURE__ */ i.jsx("h1", { className: "text-foreground text-xl font-bold", children: r("buttons_heading") })
4302
- ] }),
4303
- /* @__PURE__ */ i.jsxs(T, { size: "sm", onClick: L, children: [
4304
- /* @__PURE__ */ i.jsx(hn, { className: "mr-1 size-4" }),
4305
- r("add_button")
4306
- ] })
4307
- ] }),
4308
- c ? /* @__PURE__ */ i.jsx("div", { className: "space-y-2", children: Array.from({ length: 3 }).map((I, X) => /* @__PURE__ */ i.jsxs(
4309
- "div",
4310
- {
4311
- className: "border-border bg-card flex items-center gap-3 rounded-lg border p-3 sm:p-4",
4312
- children: [
4313
- /* @__PURE__ */ i.jsx(de, { className: "size-5" }),
4314
- /* @__PURE__ */ i.jsxs("div", { className: "min-w-0 flex-1 space-y-2", children: [
4315
- /* @__PURE__ */ i.jsx(de, { className: "h-4 w-32" }),
4316
- /* @__PURE__ */ i.jsx(de, { className: "h-3 w-48" })
4317
- ] }),
4318
- /* @__PURE__ */ i.jsxs("div", { className: "flex gap-1", children: [
4319
- /* @__PURE__ */ i.jsx(de, { className: "size-8" }),
4320
- /* @__PURE__ */ i.jsx(de, { className: "size-8" })
4321
- ] })
4322
- ]
4323
- },
4324
- X
4325
- )) }) : a.length === 0 ? /* @__PURE__ */ i.jsxs(ze, { className: "p-6 text-center sm:p-8", children: [
4326
- /* @__PURE__ */ i.jsx("p", { className: "text-muted-foreground mb-4", children: r("no_buttons_empty") }),
4327
- /* @__PURE__ */ i.jsxs(T, { size: "sm", onClick: L, children: [
4328
- /* @__PURE__ */ i.jsx(hn, { className: "mr-1 size-4" }),
4329
- r("add_button")
4330
- ] })
4331
- ] }) : /* @__PURE__ */ i.jsx(
4332
- tr,
4333
- {
4334
- sensors: R,
4335
- collisionDetection: qn,
4336
- onDragEnd: B,
4337
- children: /* @__PURE__ */ i.jsx(
4338
- or,
4339
- {
4340
- items: a.map((I) => I.id),
4341
- strategy: rr,
4342
- children: /* @__PURE__ */ i.jsx("div", { className: "space-y-2", children: a.map((I) => /* @__PURE__ */ i.jsx(
4343
- No,
4344
- {
4345
- link: I,
4346
- onEdit: M,
4347
- onDelete: k
4348
- },
4349
- I.id
4350
- )) })
4351
- }
4352
- )
4353
- }
4354
- ),
4355
- /* @__PURE__ */ i.jsx(
4356
- Ot,
4357
- {
4358
- open: m,
4359
- onOpenChange: p,
4360
- title: r(x ? "edit_button_dialog" : "add_button_dialog"),
4361
- presentation: s ? "bottom-sheet" : "dialog",
4362
- children: /* @__PURE__ */ i.jsxs(
4363
- "form",
4364
- {
4365
- onSubmit: N(H),
4366
- className: "space-y-4",
4367
- children: [
4368
- /* @__PURE__ */ i.jsxs("div", { className: "space-y-2", children: [
4369
- /* @__PURE__ */ i.jsx(ln, { htmlFor: "title", children: r("button_text_label") }),
4370
- /* @__PURE__ */ i.jsx(
4371
- fn,
4372
- {
4373
- id: "title",
4374
- placeholder: r("button_text_placeholder"),
4375
- ..._("title"),
4376
- className: C.title ? "border-destructive" : ""
4377
- }
4378
- ),
4379
- C.title && /* @__PURE__ */ i.jsx("p", { className: "text-destructive text-sm", children: C.title.message })
4380
- ] }),
4381
- /* @__PURE__ */ i.jsxs("div", { className: "space-y-2", children: [
4382
- /* @__PURE__ */ i.jsx(ln, { htmlFor: "url", children: r("url_label") }),
4383
- /* @__PURE__ */ i.jsx(
4384
- fn,
4385
- {
4386
- id: "url",
4387
- placeholder: r("url_placeholder"),
4388
- ..._("url"),
4389
- className: C.url ? "border-destructive" : ""
4390
- }
4391
- ),
4392
- C.url && /* @__PURE__ */ i.jsx("p", { className: "text-destructive text-sm", children: C.url.message })
4393
- ] }),
4394
- /* @__PURE__ */ i.jsxs(Ft, { className: "flex justify-between", children: [
4395
- x ? /* @__PURE__ */ i.jsxs(
4396
- T,
4397
- {
4398
- type: "button",
4399
- variant: "destructive",
4400
- onClick: () => {
4401
- P(), k(x);
4402
- },
4403
- children: [
4404
- /* @__PURE__ */ i.jsx(Ht, { className: "mr-1 size-4" }),
4405
- r("delete")
4406
- ]
4407
- }
4408
- ) : /* @__PURE__ */ i.jsx("div", {}),
4409
- /* @__PURE__ */ i.jsxs("div", { className: "flex gap-2", children: [
4410
- /* @__PURE__ */ i.jsx(
4411
- T,
4412
- {
4413
- type: "button",
4414
- variant: "outline",
4415
- onClick: P,
4416
- children: r("cancel")
4417
- }
4418
- ),
4419
- /* @__PURE__ */ i.jsx(
4420
- T,
4421
- {
4422
- type: "submit",
4423
- disabled: j || u.isPending || d.isPending,
4424
- children: j || u.isPending || d.isPending ? r("saving") : r("save")
4425
- }
4426
- )
4427
- ] })
4428
- ] })
4429
- ]
4430
- }
4431
- )
4432
- }
4433
- ),
4434
- /* @__PURE__ */ i.jsxs(
4435
- Ot,
4436
- {
4437
- open: b,
4438
- onOpenChange: w,
4439
- title: r("delete_button_dialog"),
4440
- presentation: s ? "bottom-sheet" : "dialog",
4441
- size: "compact",
4442
- children: [
4443
- /* @__PURE__ */ i.jsx("p", { className: "text-muted-foreground", children: r("delete_button_confirm", {
4444
- name: v?.title ?? ""
4445
- }) }),
4446
- /* @__PURE__ */ i.jsxs(Ft, { children: [
4447
- /* @__PURE__ */ i.jsx(
4448
- T,
4449
- {
4450
- type: "button",
4451
- variant: "outline",
4452
- onClick: Y,
4453
- children: r("cancel")
4454
- }
4455
- ),
4456
- /* @__PURE__ */ i.jsx(
4457
- T,
4458
- {
4459
- type: "button",
4460
- variant: "destructive",
4461
- onClick: ae,
4462
- disabled: h.isPending,
4463
- children: h.isPending ? r("deleting") : r("delete")
4464
- }
4465
- )
4466
- ] })
4467
- ]
4468
- }
4469
- )
4470
- ] });
4471
- }
4472
- const ko = {
4473
- Medium: "type_media",
4474
- Library: "type_playlist",
4475
- EnrollmentPack: "type_enrollment_pack",
4476
- Page: "type_page"
4477
- };
4478
- function Eo({
4479
- favorite: e,
4480
- onDelete: t
4481
- }) {
4482
- const { t: n } = he(), {
4483
- attributes: r,
4484
- listeners: s,
4485
- setNodeRef: o,
4486
- transform: a,
4487
- transition: c,
4488
- isDragging: u
4489
- } = lr({ id: e.id }), d = {
4490
- transform: Fe.Transform.toString(a),
4491
- transition: c
4492
- }, h = e.name ?? n("untitled"), f = e.image_url, m = ko[e.favoriteable_type], p = e.favoriteable_type !== "Product" ? m ? n(m) : e.favoriteable_type : null;
4493
- return /* @__PURE__ */ i.jsxs(
4494
- "div",
4495
- {
4496
- ref: o,
4497
- style: d,
4498
- className: `border-border bg-card flex items-center gap-3 rounded-lg border p-3 sm:p-4 ${u ? "opacity-50 shadow-lg" : ""}`,
4499
- children: [
4500
- /* @__PURE__ */ i.jsx(
4501
- "button",
4502
- {
4503
- type: "button",
4504
- className: "text-muted-foreground hover:text-foreground cursor-grab touch-none",
4505
- "aria-label": n("drag_to_reorder"),
4506
- ...r,
4507
- ...s,
4508
- children: /* @__PURE__ */ i.jsx(Rn, { className: "size-5" })
4509
- }
4510
- ),
4511
- /* @__PURE__ */ i.jsx("div", { className: "bg-muted size-10 shrink-0 overflow-hidden rounded-md", children: f ? /* @__PURE__ */ i.jsx(
4512
- "img",
4513
- {
4514
- src: f,
4515
- alt: h,
4516
- loading: "lazy",
4517
- width: 40,
4518
- height: 40,
4519
- className: "h-full w-full object-cover"
4520
- }
4521
- ) : /* @__PURE__ */ i.jsx("div", { className: "text-muted-foreground flex h-full w-full items-center justify-center text-xs", children: n("no_image") }) }),
4522
- /* @__PURE__ */ i.jsxs("div", { className: "min-w-0 flex-1", children: [
4523
- /* @__PURE__ */ i.jsx("p", { className: "text-foreground truncate font-medium", children: h }),
4524
- p ? /* @__PURE__ */ i.jsx("span", { className: "text-muted-foreground text-xs", children: p }) : null
4525
- ] }),
4526
- /* @__PURE__ */ i.jsx("div", { className: "flex shrink-0 items-center gap-1", children: /* @__PURE__ */ i.jsx(
4527
- T,
4528
- {
4529
- variant: "ghost",
4530
- size: "sm",
4531
- className: "text-muted-foreground hover:text-destructive",
4532
- onClick: () => t(e),
4533
- "aria-label": n("remove_favorite_aria"),
4534
- children: /* @__PURE__ */ i.jsx(Ht, { className: "size-4" })
4535
- }
4536
- ) })
4537
- ]
4538
- }
4539
- );
4540
- }
4541
- function Ro({
4542
- onBack: e,
4543
- onRefreshPreview: t,
4544
- onToast: n
4545
- }) {
4546
- const { t: r } = he(), { isMobile: s } = En(), { data: o = [], isLoading: a } = js(), c = Ns(), u = Ds(), [d, h] = l.useState(!1), [f, m] = l.useState(null), p = Fn(
4547
- pt(St),
4548
- pt(Ct, {
4549
- coordinateGetter: cr
4550
- })
4551
- ), x = l.useCallback(
4552
- (v) => {
4553
- m(v), h(!0);
4554
- },
4555
- []
4556
- ), g = l.useCallback(() => {
4557
- h(!1), m(null);
4558
- }, []), b = l.useCallback(() => {
4559
- f && c.mutate(f.id, {
4560
- onSuccess: () => {
4561
- n?.(r("content_removed"), "success"), g(), t?.();
4562
- },
4563
- onError: () => {
4564
- n?.(r("content_remove_failed"), "error");
4565
- }
4566
- });
4567
- }, [
4568
- f,
4569
- c,
4570
- g,
4571
- t,
4572
- n,
4573
- r
4574
- ]), w = l.useCallback(
4575
- (v) => {
4576
- const { active: y, over: _ } = v;
4577
- if (_ && y.id !== _.id) {
4578
- const N = o.findIndex((R) => R.id === y.id), S = o.findIndex((R) => R.id === _.id), C = Dt(o, N, S), j = C.map((R) => R.id);
4579
- u.mutate(
4580
- { orderedIds: j, optimisticItems: C },
4581
- {
4582
- onSuccess: () => {
4583
- t?.();
4584
- },
4585
- onError: () => {
4586
- n?.(r("reorder_content_failed"), "error");
4587
- }
4588
- }
4589
- );
4590
- }
4591
- },
4592
- [o, u, t, n, r]
4593
- );
4594
- return /* @__PURE__ */ i.jsxs(i.Fragment, { children: [
4595
- /* @__PURE__ */ i.jsxs("div", { className: "flex items-center gap-3", children: [
4596
- /* @__PURE__ */ i.jsx(T, { variant: "ghost", size: "icon", onClick: e, children: /* @__PURE__ */ i.jsx(Ut, { className: "size-4" }) }),
4597
- /* @__PURE__ */ i.jsx("h1", { className: "text-foreground text-xl font-bold", children: r("content_heading") })
4598
- ] }),
4599
- a ? /* @__PURE__ */ i.jsx("div", { className: "space-y-2", children: Array.from({ length: 3 }).map((v, y) => /* @__PURE__ */ i.jsxs(
4600
- "div",
4601
- {
4602
- className: "border-border bg-card flex items-center gap-3 rounded-lg border p-3 sm:p-4",
4603
- children: [
4604
- /* @__PURE__ */ i.jsx(de, { className: "size-5" }),
4605
- /* @__PURE__ */ i.jsx(de, { className: "size-10 rounded-md" }),
4606
- /* @__PURE__ */ i.jsxs("div", { className: "min-w-0 flex-1 space-y-2", children: [
4607
- /* @__PURE__ */ i.jsx(de, { className: "h-4 w-32" }),
4608
- /* @__PURE__ */ i.jsx(de, { className: "h-3 w-20" })
4609
- ] }),
4610
- /* @__PURE__ */ i.jsx(de, { className: "size-8" })
4611
- ]
4612
- },
4613
- y
4614
- )) }) : o.length === 0 ? /* @__PURE__ */ i.jsx(ze, { className: "p-6 text-center sm:p-8", children: /* @__PURE__ */ i.jsx("p", { className: "text-muted-foreground", children: r("no_content_empty") }) }) : /* @__PURE__ */ i.jsx(
4615
- tr,
4616
- {
4617
- sensors: p,
4618
- collisionDetection: qn,
4619
- onDragEnd: w,
4620
- children: /* @__PURE__ */ i.jsx(
4621
- or,
4622
- {
4623
- items: o.map((v) => v.id),
4624
- strategy: rr,
4625
- children: /* @__PURE__ */ i.jsx("div", { className: "space-y-2", children: o.map((v) => /* @__PURE__ */ i.jsx(
4626
- Eo,
4627
- {
4628
- favorite: v,
4629
- onDelete: x
4630
- },
4631
- v.id
4632
- )) })
4633
- }
4634
- )
4635
- }
4636
- ),
4637
- /* @__PURE__ */ i.jsxs(
4638
- Ot,
4639
- {
4640
- open: d,
4641
- onOpenChange: h,
4642
- title: r("remove_content_dialog"),
4643
- presentation: s ? "bottom-sheet" : "dialog",
4644
- size: "compact",
4645
- children: [
4646
- /* @__PURE__ */ i.jsx("p", { className: "text-muted-foreground", children: r("remove_content_confirm", {
4647
- name: f?.name ?? r("untitled")
4648
- }) }),
4649
- /* @__PURE__ */ i.jsxs(Ft, { children: [
4650
- /* @__PURE__ */ i.jsx(
4651
- T,
4652
- {
4653
- type: "button",
4654
- variant: "outline",
4655
- onClick: g,
4656
- children: r("cancel")
4657
- }
4658
- ),
4659
- /* @__PURE__ */ i.jsx(
4660
- T,
4661
- {
4662
- type: "button",
4663
- variant: "destructive",
4664
- onClick: b,
4665
- disabled: c.isPending,
4666
- children: c.isPending ? r("removing") : r("remove")
4667
- }
4668
- )
4669
- ] })
4670
- ]
4671
- }
4672
- )
4673
- ] });
4674
- }
4675
- const Mo = [
4676
- { labelKey: "nav_profile", slug: "profile", icon: qr },
4677
- { labelKey: "nav_theme", key: "theme", icon: Mn },
4678
- { labelKey: "nav_content", key: "content", icon: Wr },
4679
- { labelKey: "nav_buttons", key: "buttons", icon: Vr }
4680
- ];
4681
- function We(e, t) {
4682
- jr({ title: e, type: t });
4683
- }
4684
- function Ao({
4685
- editingSection: e,
4686
- animPhase: t,
4687
- showEditContent: n,
4688
- onEditSection: r,
4689
- onBackClick: s
4690
- }) {
4691
- const { t: o } = he(), { navigate: a } = Cr(), { data: c, isLoading: u } = In(), { data: d = [] } = ks(), h = De(), f = xs({
4692
- // The theme saves through here too, and only a slug write moves the URL.
4693
- onSuccess: (k) => k.slug === void 0 ? void 0 : Sr(h)
4694
- }), [m, p] = l.useState(0), x = l.useCallback(() => p((k) => k + 1), []), [g, b] = l.useState(null), w = g ?? c?.theme_id ?? d.find((k) => k.name === "Default")?.id ?? d[0]?.id ?? null, y = d.find((k) => k.id === w)?.name ?? "Default", _ = c?.mysite_url ?? "", N = _ ? _.replace(/^https?:\/\//, "") : "", S = c?.mysite_views ?? 0, C = c?.mysite_leads ?? 0, j = l.useCallback(
4695
- (k) => {
4696
- if (k.id === w) return;
4697
- const Y = g;
4698
- b(k.id), f.mutate(
4699
- { theme_id: k.id },
4700
- {
4701
- onSuccess: () => {
4702
- We(o("theme_changed", { name: k.name }), "success"), x();
4703
- },
4704
- onError: () => {
4705
- b(Y), We(o("theme_update_failed"), "error");
4706
- }
4707
- }
4708
- );
4709
- },
4710
- [
4711
- w,
4712
- g,
4713
- f,
4714
- x,
4715
- o
4716
- ]
4717
- ), R = l.useCallback(
4718
- async (k) => {
4719
- await new Promise((Y, ae) => {
4720
- f.mutate(
4721
- { slug: k },
4722
- {
4723
- onSuccess: () => Y(),
4724
- onError: () => ae(new Error("Failed"))
4725
- }
4726
- );
4727
- });
4728
- },
4729
- [f]
4730
- ), L = l.useCallback(() => {
4731
- _ && window.open(`${_}?preview=true`, "_blank");
4732
- }, [_]), M = l.useMemo(() => e === "theme" ? o("nav_theme") : e === "buttons" ? o("nav_buttons") : e === "content" ? o("nav_content") : "", [e, o]);
4733
- if (u)
4734
- return /* @__PURE__ */ i.jsxs("div", { className: "flex h-full flex-col overflow-y-auto px-2 py-6 2xl:flex-row 2xl:overflow-hidden", children: [
4735
- /* @__PURE__ */ i.jsx("div", { className: "w-full px-4 2xl:w-2/3 2xl:shrink-0", children: /* @__PURE__ */ i.jsxs("div", { className: "flex flex-col gap-5", children: [
4736
- /* @__PURE__ */ i.jsx("div", { className: "bg-muted h-7 w-32 animate-pulse rounded-md" }),
4737
- /* @__PURE__ */ i.jsx("div", { className: "bg-muted h-20 w-full animate-pulse rounded-lg" }),
4738
- /* @__PURE__ */ i.jsx("div", { className: "bg-muted h-16 w-full animate-pulse rounded-lg" }),
4739
- /* @__PURE__ */ i.jsx("div", { className: "bg-muted h-40 w-full animate-pulse rounded-lg" })
4740
- ] }) }),
4741
- /* @__PURE__ */ i.jsx("div", { className: "w-full shrink-0 overflow-y-hidden px-4 pt-5 2xl:h-full 2xl:w-1/3 2xl:overflow-y-auto 2xl:pt-0", children: /* @__PURE__ */ i.jsxs("div", { className: "bg-muted flex h-full flex-col items-center gap-4 rounded-xl p-5", children: [
4742
- /* @__PURE__ */ i.jsxs("div", { className: "flex w-full items-center justify-between", children: [
4743
- /* @__PURE__ */ i.jsxs("div", { className: "space-y-1", children: [
4744
- /* @__PURE__ */ i.jsx("div", { className: "bg-background/50 h-3 w-24 animate-pulse rounded" }),
4745
- /* @__PURE__ */ i.jsx("div", { className: "bg-background/50 h-4 w-28 animate-pulse rounded" })
4746
- ] }),
4747
- /* @__PURE__ */ i.jsx("div", { className: "bg-background/50 h-8 w-20 animate-pulse rounded-md" })
4748
- ] }),
4749
- /* @__PURE__ */ i.jsx("div", { className: "bg-background/50 h-[490px] w-[260px] animate-pulse rounded-[36px] sm:h-[600px] sm:w-[320px]" })
4750
- ] }) })
4751
- ] });
4752
- const P = Ls(t), H = Is(t);
4753
- return /* @__PURE__ */ i.jsxs("div", { className: "flex h-full flex-col overflow-y-auto px-2 py-6 2xl:flex-row 2xl:overflow-hidden", children: [
4754
- /* @__PURE__ */ i.jsx(
4755
- "div",
4756
- {
4757
- className: `w-full px-4 2xl:w-2/3 2xl:shrink-0 ${P}`,
4758
- children: /* @__PURE__ */ i.jsx("div", { className: "flex min-w-0 flex-col gap-5 2xl:h-full 2xl:overflow-y-auto", children: n && e === "theme" ? /* @__PURE__ */ i.jsx(
4759
- Bs,
4760
- {
4761
- themes: d,
4762
- selectedThemeId: w,
4763
- onSelectTheme: j,
4764
- isPending: f.isPending,
4765
- onBack: s
4766
- }
4767
- ) : n && e === "buttons" ? /* @__PURE__ */ i.jsx(
4768
- Do,
4769
- {
4770
- onBack: s,
4771
- onRefreshPreview: x,
4772
- onToast: We
4773
- }
4774
- ) : n && e === "content" ? /* @__PURE__ */ i.jsx(
4775
- Ro,
4776
- {
4777
- onBack: s,
4778
- onRefreshPreview: x,
4779
- onToast: We
4780
- }
4781
- ) : /* @__PURE__ */ i.jsxs(i.Fragment, { children: [
4782
- /* @__PURE__ */ i.jsxs("div", { className: "flex items-center gap-2", children: [
4783
- /* @__PURE__ */ i.jsx("h1", { className: "text-foreground text-xl font-bold", children: o("heading") }),
4784
- t !== "idle" && M && /* @__PURE__ */ i.jsxs(i.Fragment, { children: [
4785
- /* @__PURE__ */ i.jsx(cn, { className: "text-muted-foreground size-4" }),
4786
- /* @__PURE__ */ i.jsx("span", { className: "text-foreground text-xl font-bold", children: M })
4787
- ] })
4788
- ] }),
4789
- /* @__PURE__ */ i.jsx(Ts, { views: S, leads: C }),
4790
- /* @__PURE__ */ i.jsx(
4791
- Ps,
4792
- {
4793
- mysiteUrl: _,
4794
- displayUrl: N,
4795
- onUpdateSlug: R,
4796
- onToast: We
4797
- }
4798
- ),
4799
- /* @__PURE__ */ i.jsx("div", { className: "border-border bg-card divide-border divide-y overflow-hidden rounded-lg border", children: Mo.map((k) => {
4800
- const Y = k.icon, ae = "group hover:bg-muted flex w-full items-center gap-2.5 px-3 py-2.5 transition-colors text-left cursor-pointer", B = "slug" in k ? () => a(k.slug) : () => r(k.key);
4801
- return /* @__PURE__ */ i.jsxs(
4802
- "button",
4803
- {
4804
- type: "button",
4805
- onClick: B,
4806
- className: ae,
4807
- children: [
4808
- /* @__PURE__ */ i.jsx("div", { className: "bg-muted text-foreground flex size-7 shrink-0 items-center justify-center rounded-full", children: /* @__PURE__ */ i.jsx(Y, { className: "size-3.5" }) }),
4809
- /* @__PURE__ */ i.jsx("span", { className: "text-foreground flex-1 text-sm font-medium", children: o(k.labelKey) }),
4810
- /* @__PURE__ */ i.jsx(cn, { className: "text-muted-foreground size-3 shrink-0 transition-transform group-hover:translate-x-0.5" })
4811
- ]
4812
- },
4813
- k.labelKey
4814
- );
4815
- }) })
4816
- ] }) })
4817
- }
4818
- ),
4819
- /* @__PURE__ */ i.jsx(
4820
- "div",
4821
- {
4822
- className: `w-full shrink-0 overflow-y-hidden px-4 pt-5 2xl:h-full 2xl:w-1/3 2xl:overflow-y-auto 2xl:pt-0 ${H}`,
4823
- children: /* @__PURE__ */ i.jsx(
4824
- Os,
4825
- {
4826
- mysiteUrl: _,
4827
- themeName: y,
4828
- previewKey: m,
4829
- isUpdating: f.isPending,
4830
- onPreview: L
4831
- }
4832
- )
4833
- }
4834
- )
4835
- ] });
4836
- }
4837
- function Lo() {
4838
- const [e, t] = l.useState("idle"), [n, r] = l.useState(null), s = l.useRef([]);
4839
- l.useEffect(() => {
4840
- const h = s;
4841
- return () => h.current.forEach(clearTimeout);
4842
- }, []);
4843
- const o = l.useCallback(() => {
4844
- s.current.forEach(clearTimeout), s.current = [];
4845
- }, []), a = l.useCallback((h, f) => {
4846
- const m = setTimeout(() => t(h), f);
4847
- s.current.push(m);
4848
- }, []), c = [
4849
- "slide",
4850
- "fade-in",
4851
- "editing",
4852
- "exit-fade-out",
4853
- "exit-slide"
4854
- ].includes(e), u = l.useCallback(
4855
- (h) => {
4856
- o(), r(h), t("fade-out"), a("slide", je), a("fade-in", je + ct), a("editing", je + ct + je);
4857
- },
4858
- [o, a]
4859
- ), d = l.useCallback(() => {
4860
- o(), t("exit-fade-out"), a("exit-slide", je), a("exit-fade-in", je + ct);
4861
- const h = setTimeout(
4862
- () => {
4863
- t("idle"), r(null);
4864
- },
4865
- je + ct + je
4866
- );
4867
- s.current.push(h);
4868
- }, [o, a]);
4869
- return {
4870
- editingSection: n,
4871
- animPhase: e,
4872
- showEditContent: c,
4873
- handleEditSection: u,
4874
- handleBackClick: d
4875
- };
4876
- }
4877
- function Io({
4878
- /* eslint-disable @typescript-eslint/no-unused-vars -- destructured to exclude from divProps spread */
4879
- background: e,
4880
- textColor: t,
4881
- accentColor: n,
4882
- padding: r,
4883
- borderRadius: s,
4884
- /* eslint-enable @typescript-eslint/no-unused-vars */
4885
- ...o
4886
- }) {
4887
- return /* @__PURE__ */ i.jsx(As, { children: /* @__PURE__ */ i.jsx(To, { ...o }) });
4888
- }
4889
- function To(e) {
4890
- const { t } = he(), {
4891
- editingSection: n,
4892
- animPhase: r,
4893
- showEditContent: s,
4894
- handleEditSection: o,
4895
- handleBackClick: a
4896
- } = Lo(), c = l.useMemo(() => n === "theme" ? t("nav_theme") : n === "buttons" ? t("nav_buttons") : n === "content" ? t("nav_content") : null, [n, t]), u = l.useCallback(
4897
- (d) => {
4898
- d.preventDefault(), n !== null && a();
4899
- },
4900
- [n, a]
4901
- );
4902
- return /* @__PURE__ */ i.jsxs(i.Fragment, { children: [
4903
- /* @__PURE__ */ i.jsx(Nr, { children: /* @__PURE__ */ i.jsx(Lr, { children: /* @__PURE__ */ i.jsxs(Ir, { className: "text-lg", children: [
4904
- /* @__PURE__ */ i.jsx(un, { children: c ? /* @__PURE__ */ i.jsx(Tr, { href: "#", onClick: u, children: "MySite" }) : /* @__PURE__ */ i.jsx(dn, { className: "font-semibold", children: "MySite" }) }),
4905
- c && /* @__PURE__ */ i.jsxs(i.Fragment, { children: [
4906
- /* @__PURE__ */ i.jsx(Pr, {}),
4907
- /* @__PURE__ */ i.jsx(un, { children: /* @__PURE__ */ i.jsx(dn, { className: "font-semibold", children: c }) })
4908
- ] })
4909
- ] }) }) }),
4910
- /* @__PURE__ */ i.jsx(
4911
- "div",
4912
- {
4913
- ...e,
4914
- className: `h-full min-h-0 flex-1 ${e.className ?? ""}`,
4915
- children: /* @__PURE__ */ i.jsx(
4916
- Ao,
4917
- {
4918
- editingSection: n,
4919
- animPhase: r,
4920
- showEditContent: s,
4921
- onEditSection: o,
4922
- onBackClick: a
4923
- }
4924
- )
4925
- }
4926
- )
4927
- ] });
4928
- }
4929
- function Wo() {
4930
- const { config: e } = Dr(), { fetch: t } = kr(), { baseUrl: n, defaultHeaders: r, onAuthError: s } = e, o = l.useMemo(
4931
- () => ps(
4932
- ts({
4933
- baseUrl: n,
4934
- fetch: t,
4935
- defaultHeaders: r,
4936
- onAuthError: s
4937
- })
4938
- ),
4939
- [n, r, s, t]
4940
- );
4941
- return /* @__PURE__ */ i.jsx(Zr, { value: o, children: /* @__PURE__ */ i.jsx(Po, {}) });
4942
- }
4943
- function Po() {
4944
- const { error: e } = In();
4945
- if (e) throw e;
4946
- return /* @__PURE__ */ i.jsx(Io, {});
4947
- }
4948
- export {
4949
- Wo as default
4950
- };