@chaibuilder/pages 0.4.6-beta.1 → 0.4.6-beta.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,7 +1,7 @@
1
1
  var ps = Object.defineProperty;
2
2
  var xs = (e, t, n) => t in e ? ps(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
3
3
  var qe = (e, t, n) => xs(e, typeof t != "symbol" ? t + "" : t, n);
4
- import { s as Vn, m as Gn, b as R, d as rr, e as U, a as m, f as W, h as oe, S as B, c as D, i as we, u as $e, j as V, k as A, l as Ne, o as ut, P as zo, n as j, D as ws, t as q, p as Ft, q as ln, r as k, v as F, w as $s, x as Rt, y as Cs, z as Ss, A as wn, F as ks, B as Es, C as Ds, E as Kt, G as Ms, H as As, I as Fs, J as or, K as Kr, L as Ts, M as qt, $ as Ro, N as Br, O as Is, Q as Ps, R as zn, T as Ls, U as Os, V as qs } from "./index-CG2G27hJ.js";
4
+ import { s as Vn, m as Gn, b as R, d as rr, e as U, a as m, f as W, h as oe, S as B, c as D, i as we, u as $e, j as V, k as A, l as Ne, o as ut, P as zo, n as j, D as ws, t as q, p as Ft, q as ln, r as k, v as F, w as $s, x as Rt, y as Cs, z as Ss, A as wn, F as ks, B as Es, C as Ds, E as Kt, G as Ms, H as As, I as Fs, J as or, K as Kr, L as Ts, M as qt, $ as Ro, N as Br, O as Is, Q as Ps, R as zn, T as Ls, U as Os, V as qs } from "./index-CHnFBKHF.js";
5
5
  var _s = (e) => e != null, zs = (e) => e.filter(_s);
6
6
  function Rs(e) {
7
7
  return (...t) => {
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./B4MFY5CR-CGzb3p_w.cjs"),t=require("./index-Ce2dcOYb.cjs");var s=c=>{const[r,o]=e.createLocalStorage({prefix:"TanstackQueryDevtools"}),l=t.getPreferredColorScheme(),a=t.createMemo(()=>{const n=r.theme_preference||e.THEME_PREFERENCE;return n!=="system"?n:l()});return t.createComponent(e.QueryDevtoolsContext.Provider,{value:c,get children(){return t.createComponent(e.PiPProvider,{localStore:r,setLocalStore:o,get children(){return t.createComponent(e.ThemeContext.Provider,{value:a,get children(){return t.createComponent(e.Devtools,{localStore:r,setLocalStore:o})}})}})}})},u=s;exports.default=u;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./B4MFY5CR-C8daQItO.cjs"),t=require("./index-BosOek7g.cjs");var s=c=>{const[r,o]=e.createLocalStorage({prefix:"TanstackQueryDevtools"}),l=t.getPreferredColorScheme(),a=t.createMemo(()=>{const n=r.theme_preference||e.THEME_PREFERENCE;return n!=="system"?n:l()});return t.createComponent(e.QueryDevtoolsContext.Provider,{value:c,get children(){return t.createComponent(e.PiPProvider,{localStore:r,setLocalStore:o,get children(){return t.createComponent(e.ThemeContext.Provider,{value:a,get children(){return t.createComponent(e.Devtools,{localStore:r,setLocalStore:o})}})}})}})},u=s;exports.default=u;
@@ -1,5 +1,5 @@
1
- import { c, T as l, P as m, a as u, D as v, Q as i } from "./B4MFY5CR-BSGjETfq.js";
2
- import { g as d, c as f, a as e } from "./index-CG2G27hJ.js";
1
+ import { c, T as l, P as m, a as u, D as v, Q as i } from "./B4MFY5CR-DuN0t56f.js";
2
+ import { g as d, c as f, a as e } from "./index-CHnFBKHF.js";
3
3
  var p = (a) => {
4
4
  const [r, t] = c({
5
5
  prefix: "TanstackQueryDevtools"
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./B4MFY5CR-CGzb3p_w.cjs"),t=require("./index-Ce2dcOYb.cjs");var u=o=>{const[r,n]=e.createLocalStorage({prefix:"TanstackQueryDevtools"}),c=t.getPreferredColorScheme(),a=t.createMemo(()=>{const l=r.theme_preference||e.THEME_PREFERENCE;return l!=="system"?l:c()});return t.createComponent(e.QueryDevtoolsContext.Provider,{value:o,get children(){return t.createComponent(e.PiPProvider,{disabled:!0,localStore:r,setLocalStore:n,get children(){return t.createComponent(e.ThemeContext.Provider,{value:a,get children(){return t.createComponent(e.ParentPanel,{get children(){return t.createComponent(e.ContentView,{localStore:r,setLocalStore:n,get onClose(){return o.onClose},showPanelViewOnly:!0})}})}})}})}})},i=u;exports.default=i;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./B4MFY5CR-C8daQItO.cjs"),t=require("./index-BosOek7g.cjs");var u=o=>{const[r,n]=e.createLocalStorage({prefix:"TanstackQueryDevtools"}),c=t.getPreferredColorScheme(),a=t.createMemo(()=>{const l=r.theme_preference||e.THEME_PREFERENCE;return l!=="system"?l:c()});return t.createComponent(e.QueryDevtoolsContext.Provider,{value:o,get children(){return t.createComponent(e.PiPProvider,{disabled:!0,localStore:r,setLocalStore:n,get children(){return t.createComponent(e.ThemeContext.Provider,{value:a,get children(){return t.createComponent(e.ParentPanel,{get children(){return t.createComponent(e.ContentView,{localStore:r,setLocalStore:n,get onClose(){return o.onClose},showPanelViewOnly:!0})}})}})}})}})},i=u;exports.default=i;
@@ -1,5 +1,5 @@
1
- import { c as s, T as c, P as u, a as i, b as m, C as P, Q as d } from "./B4MFY5CR-BSGjETfq.js";
2
- import { g as v, c as C, a as e } from "./index-CG2G27hJ.js";
1
+ import { c as s, T as c, P as u, a as i, b as m, C as P, Q as d } from "./B4MFY5CR-DuN0t56f.js";
2
+ import { g as v, c as C, a as e } from "./index-CHnFBKHF.js";
3
3
  var h = (t) => {
4
4
  const [r, o] = s({
5
5
  prefix: "TanstackQueryDevtools"
@@ -1,12 +1,12 @@
1
1
  import { jsx as a, jsxs as t } from "react/jsx-runtime";
2
- import { useState as l } from "react";
3
- import { Dialog as b, DialogContent as w, DialogHeader as F, DialogTitle as C, Label as d, Input as S, Textarea as y, DialogFooter as A, Button as g } from "@chaibuilder/sdk/ui";
2
+ import { Dialog as b, DialogContent as w, DialogHeader as F, DialogTitle as C, Label as l, Input as S, Textarea as y, DialogFooter as A, Button as g } from "@chaibuilder/sdk/ui";
3
+ import { useState as d } from "react";
4
4
  function E({
5
5
  asset: e,
6
6
  onSave: r,
7
7
  onCancel: o
8
8
  }) {
9
- const i = e.name.lastIndexOf("."), f = i > 0 ? e.name.substring(0, i) : e.name, c = i > 0 ? e.name.substring(i) : "", [m, x] = l(f), [s, v] = l(e.description || ""), [u, h] = l(!1), N = async () => {
9
+ const i = e.name.lastIndexOf("."), f = i > 0 ? e.name.substring(0, i) : e.name, c = i > 0 ? e.name.substring(i) : "", [m, x] = d(f), [s, v] = d(e.description || ""), [u, h] = d(!1), N = async () => {
10
10
  h(!0);
11
11
  try {
12
12
  const D = {
@@ -22,7 +22,7 @@ function E({
22
22
  /* @__PURE__ */ a(F, { children: /* @__PURE__ */ a(C, { children: "Edit Asset Details" }) }),
23
23
  /* @__PURE__ */ t("div", { className: "grid gap-3 py-2", children: [
24
24
  /* @__PURE__ */ t("div", { className: "grid gap-2", children: [
25
- /* @__PURE__ */ a(d, { htmlFor: "name", children: "Name" }),
25
+ /* @__PURE__ */ a(l, { htmlFor: "name", children: "Name" }),
26
26
  /* @__PURE__ */ t("div", { className: "flex", children: [
27
27
  /* @__PURE__ */ a(
28
28
  S,
@@ -38,7 +38,7 @@ function E({
38
38
  /* @__PURE__ */ a("p", { className: "text-xs text-muted-foreground", children: "Only the file name can be changed, not the extension." })
39
39
  ] }),
40
40
  /* @__PURE__ */ t("div", { className: "grid gap-2", children: [
41
- /* @__PURE__ */ a(d, { htmlFor: "description", children: "Description" }),
41
+ /* @__PURE__ */ a(l, { htmlFor: "description", children: "Description" }),
42
42
  /* @__PURE__ */ a(
43
43
  y,
44
44
  {
@@ -61,7 +61,7 @@ function E({
61
61
  { label: "Created", value: p(e.createdAt) },
62
62
  { label: "Updated", value: p((e == null ? void 0 : e.updatedAt) || "") }
63
63
  ].map((n) => /* @__PURE__ */ t("div", { className: "flex items-center gap-2", children: [
64
- /* @__PURE__ */ a(d, { className: "w-max text-left px-2 w-1/4 font-normal text-gray-700", children: n.label }),
64
+ /* @__PURE__ */ a(l, { className: "w-max text-left px-2 w-1/4 font-normal text-gray-700", children: n.label }),
65
65
  ":",
66
66
  /* @__PURE__ */ a("div", { className: "w-max text-left font-medium text-gray-900 capitalize", children: n.value })
67
67
  ] })) })
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),l=require("react"),a=require("@chaibuilder/sdk/ui");function j({asset:e,onSave:r,onCancel:d}){const i=e.name.lastIndexOf("."),h=i>0?e.name.substring(0,i):e.name,o=i>0?e.name.substring(i):"",[s,g]=l.useState(h),[c,f]=l.useState(e.description||""),[m,u]=l.useState(!1),p=async()=>{u(!0);try{const v={name:s+o,description:c||void 0};await r(v)}finally{u(!1)}};return t.jsx(a.Dialog,{open:!0,onOpenChange:()=>d(),children:t.jsxs(a.DialogContent,{className:"sm:max-w-[500px]",children:[t.jsx(a.DialogHeader,{children:t.jsx(a.DialogTitle,{children:"Edit Asset Details"})}),t.jsxs("div",{className:"grid gap-3 py-2",children:[t.jsxs("div",{className:"grid gap-2",children:[t.jsx(a.Label,{htmlFor:"name",children:"Name"}),t.jsxs("div",{className:"flex",children:[t.jsx(a.Input,{id:"name",value:s,onChange:n=>g(n.target.value),className:"rounded-r-none"}),t.jsx("div",{className:"px-3 py-1 text-sm font-medium bg-muted text-muted-foreground rounded-r-md border border-l-0 flex items-center",children:o||""})]}),t.jsx("p",{className:"text-xs text-muted-foreground",children:"Only the file name can be changed, not the extension."})]}),t.jsxs("div",{className:"grid gap-2",children:[t.jsx(a.Label,{htmlFor:"description",children:"Description"}),t.jsx(a.Textarea,{id:"description",value:c,placeholder:"Enter a description for the asset",onChange:n=>f(n.target.value),rows:3})]}),t.jsx("div",{className:"grid grid-cols-1 gap-2 text-sm border rounded-md p-2",children:[{label:"Type",value:e.type},{label:"Format",value:e.format},{label:"Size",value:N(e.size)},{label:"Dimensions",value:`${e.width} × ${e.height}`},{label:"Created",value:x(e.createdAt)},{label:"Updated",value:x((e==null?void 0:e.updatedAt)||"")}].map(n=>t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(a.Label,{className:"w-max text-left px-2 w-1/4 font-normal text-gray-700",children:n.label}),":",t.jsx("div",{className:"w-max text-left font-medium text-gray-900 capitalize",children:n.value})]}))})]}),t.jsxs(a.DialogFooter,{children:[t.jsx(a.Button,{variant:"outline",onClick:d,children:"Cancel"}),t.jsx(a.Button,{onClick:p,disabled:m,children:m?"Saving...":"Save Changes"})]})]})})}function N(e){return e<1024?e+" B":e<1024*1024?(e/1024).toFixed(1)+" KB":e<1024*1024*1024?(e/(1024*1024)).toFixed(1)+" MB":(e/(1024*1024*1024)).toFixed(1)+" GB"}function x(e){if(!e)return"N/A";const r=new Date(e);return new Intl.DateTimeFormat("en-US",{month:"short",day:"numeric",year:"numeric",hour:"2-digit",minute:"2-digit"}).format(r)}exports.default=j;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),a=require("@chaibuilder/sdk/ui"),l=require("react");function j({asset:e,onSave:r,onCancel:d}){const i=e.name.lastIndexOf("."),h=i>0?e.name.substring(0,i):e.name,o=i>0?e.name.substring(i):"",[s,g]=l.useState(h),[c,f]=l.useState(e.description||""),[m,u]=l.useState(!1),p=async()=>{u(!0);try{const v={name:s+o,description:c||void 0};await r(v)}finally{u(!1)}};return t.jsx(a.Dialog,{open:!0,onOpenChange:()=>d(),children:t.jsxs(a.DialogContent,{className:"sm:max-w-[500px]",children:[t.jsx(a.DialogHeader,{children:t.jsx(a.DialogTitle,{children:"Edit Asset Details"})}),t.jsxs("div",{className:"grid gap-3 py-2",children:[t.jsxs("div",{className:"grid gap-2",children:[t.jsx(a.Label,{htmlFor:"name",children:"Name"}),t.jsxs("div",{className:"flex",children:[t.jsx(a.Input,{id:"name",value:s,onChange:n=>g(n.target.value),className:"rounded-r-none"}),t.jsx("div",{className:"px-3 py-1 text-sm font-medium bg-muted text-muted-foreground rounded-r-md border border-l-0 flex items-center",children:o||""})]}),t.jsx("p",{className:"text-xs text-muted-foreground",children:"Only the file name can be changed, not the extension."})]}),t.jsxs("div",{className:"grid gap-2",children:[t.jsx(a.Label,{htmlFor:"description",children:"Description"}),t.jsx(a.Textarea,{id:"description",value:c,placeholder:"Enter a description for the asset",onChange:n=>f(n.target.value),rows:3})]}),t.jsx("div",{className:"grid grid-cols-1 gap-2 text-sm border rounded-md p-2",children:[{label:"Type",value:e.type},{label:"Format",value:e.format},{label:"Size",value:N(e.size)},{label:"Dimensions",value:`${e.width} × ${e.height}`},{label:"Created",value:x(e.createdAt)},{label:"Updated",value:x((e==null?void 0:e.updatedAt)||"")}].map(n=>t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(a.Label,{className:"w-max text-left px-2 w-1/4 font-normal text-gray-700",children:n.label}),":",t.jsx("div",{className:"w-max text-left font-medium text-gray-900 capitalize",children:n.value})]}))})]}),t.jsxs(a.DialogFooter,{children:[t.jsx(a.Button,{variant:"outline",onClick:d,children:"Cancel"}),t.jsx(a.Button,{onClick:p,disabled:m,children:m?"Saving...":"Save Changes"})]})]})})}function N(e){return e<1024?e+" B":e<1024*1024?(e/1024).toFixed(1)+" KB":e<1024*1024*1024?(e/(1024*1024)).toFixed(1)+" MB":(e/(1024*1024*1024)).toFixed(1)+" GB"}function x(e){if(!e)return"N/A";const r=new Date(e);return new Intl.DateTimeFormat("en-US",{month:"short",day:"numeric",year:"numeric",hour:"2-digit",minute:"2-digit"}).format(r)}exports.default=j;
@@ -0,0 +1,458 @@
1
+ import { jsxs as a, Fragment as B, jsx as e } from "react/jsx-runtime";
2
+ import Z, { useState as C, useCallback as x, useMemo as le, useRef as ie, Suspense as Y } from "react";
3
+ import { mergeClasses as O } from "@chaibuilder/sdk";
4
+ import { Tabs as re, TabsList as ne, TabsTrigger as V, Button as S, TabsContent as W, Input as oe, Card as ce, CardContent as de } from "@chaibuilder/sdk/ui";
5
+ import { debounce as ue, find as me, merge as he } from "lodash-es";
6
+ import { Search as ge, Film as pe, ImageIcon as fe, Edit as ve, Trash2 as ye, Loader2 as X, Upload as xe } from "lucide-react";
7
+ import { useDropzone as Ne } from "react-dropzone";
8
+ import { useQueryClient as Q, useMutation as R, useQuery as Se } from "@tanstack/react-query";
9
+ import { toast as w } from "sonner";
10
+ import { W as z, X as F, Y as g, Z as we } from "./index-CHnFBKHF.js";
11
+ const Ae = () => {
12
+ const t = z(), o = Q(), c = F();
13
+ return R({
14
+ mutationFn: async ({
15
+ file: i,
16
+ folderId: d,
17
+ name: u
18
+ }) => c(t, {
19
+ action: g.UPLOAD_ASSET,
20
+ data: { file: i, folderId: d, name: u }
21
+ }),
22
+ onSuccess: () => {
23
+ o.invalidateQueries({
24
+ queryKey: [g.GET_ASSETS]
25
+ }), w.success("Asset uploaded successfully");
26
+ },
27
+ onError: () => {
28
+ w.error("Failed to upload asset");
29
+ }
30
+ });
31
+ }, be = () => {
32
+ const t = z(), o = Q(), c = F();
33
+ return R({
34
+ mutationFn: async (i) => c(t, {
35
+ action: g.DELETE_ASSET,
36
+ data: { id: i }
37
+ }),
38
+ onSuccess: () => {
39
+ o.invalidateQueries({
40
+ queryKey: [g.GET_ASSETS]
41
+ }), w.success("Asset deleted successfully");
42
+ },
43
+ onError: () => {
44
+ w.error("Failed to delete asset");
45
+ }
46
+ });
47
+ }, Ee = () => {
48
+ const t = z(), o = Q(), c = F();
49
+ return R({
50
+ mutationFn: async (i) => c(t, {
51
+ action: g.UPDATE_ASSET,
52
+ data: i
53
+ }),
54
+ onSuccess: () => {
55
+ o.invalidateQueries({
56
+ queryKey: [g.GET_ASSETS]
57
+ }), w.success("Asset updated successfully");
58
+ },
59
+ onError: () => {
60
+ w.error("Failed to update asset");
61
+ }
62
+ });
63
+ }, Ce = (t = {}) => {
64
+ const o = z(), c = F(), { search: i, page: d = 1, limit: u = 10 } = t;
65
+ return Se({
66
+ queryKey: [we, g.GET_ASSETS, i, d, u],
67
+ queryFn: async () => (await c(o, {
68
+ action: g.GET_ASSETS,
69
+ data: {
70
+ search: i,
71
+ page: d,
72
+ limit: u
73
+ }
74
+ })).data,
75
+ retry: 1
76
+ });
77
+ };
78
+ function Te() {
79
+ const [o, c] = C([]), [i, d] = C({
80
+ query: "",
81
+ page: 1,
82
+ pageSize: 10
83
+ }), u = ue(() => i.query, 300)(), { data: r, isLoading: A } = Ce({
84
+ search: (u == null ? void 0 : u.toLowerCase().trim()) || "",
85
+ page: i.page,
86
+ limit: i.pageSize
87
+ }), p = r ? Math.ceil(r.total / r.pageSize) : 0, n = (r == null ? void 0 : r.page) || 1, f = n < p, b = n > 1, { mutate: N, isPending: h } = Ee(), { mutate: E, isPending: T } = Ae(), { mutate: D, isPending: M } = be(), v = x(
88
+ (m) => {
89
+ m >= 1 && m <= p && d((y) => ({
90
+ ...y,
91
+ page: m
92
+ }));
93
+ },
94
+ [p]
95
+ ), I = x(() => {
96
+ f && v(n + 1);
97
+ }, [n, f, v]), P = x(() => {
98
+ b && v(n - 1);
99
+ }, [n, b, v]), k = x((m) => {
100
+ d((y) => ({
101
+ ...y,
102
+ query: m,
103
+ page: 1
104
+ // Reset to first page on new search
105
+ }));
106
+ }, []), q = x(
107
+ (m) => {
108
+ c((y) => me(y, { id: m.id }) ? [] : [m]);
109
+ },
110
+ [!1]
111
+ ), j = x(() => {
112
+ c([]);
113
+ }, []);
114
+ return {
115
+ // Data
116
+ query: (i == null ? void 0 : i.query) || "",
117
+ selectedAssets: o,
118
+ assets: (r == null ? void 0 : r.assets) || [],
119
+ currentPage: n,
120
+ totalPages: p,
121
+ hasNextPage: f,
122
+ hasPreviousPage: b,
123
+ // Mutations
124
+ uploadAsset: E,
125
+ updateAsset: N,
126
+ deleteAsset: D,
127
+ goToPage: v,
128
+ nextPage: I,
129
+ previousPage: P,
130
+ updateSearchQuery: k,
131
+ clearSelectedAssets: j,
132
+ updateSelectedAssets: q,
133
+ // Loading
134
+ isLoadingAssets: A,
135
+ isUploadingAsset: T,
136
+ isUpdatingAsset: h,
137
+ isDeletingAsset: M
138
+ };
139
+ }
140
+ const Pe = Z.lazy(() => import("./asset-metadata-editor-B5xHNQG_.js")), Ue = Z.lazy(() => import("./image-editor-CwVua57o.js"));
141
+ function Re({
142
+ close: t,
143
+ onSelect: o,
144
+ mode: c = "image"
145
+ }) {
146
+ const d = le(() => [c], [c]), [u, r] = C("browse"), [A, p] = C(null), [n, f] = C({ show: !1, file: "" }), {
147
+ // Data
148
+ query: b,
149
+ assets: N,
150
+ selectedAssets: h,
151
+ // Mutations
152
+ uploadAsset: E,
153
+ updateAsset: T,
154
+ deleteAsset: D,
155
+ updateSearchQuery: M,
156
+ clearSelectedAssets: v,
157
+ updateSelectedAssets: I,
158
+ // Loading
159
+ isLoadingAssets: P,
160
+ isUploadingAsset: k,
161
+ isUpdatingAsset: q
162
+ // isDeletingAsset,
163
+ } = Te(), j = ie(null), m = x(
164
+ async (s) => new Promise((l, _) => {
165
+ const K = s[0], U = new FileReader();
166
+ U.readAsDataURL(K), U.onload = async () => {
167
+ const L = await E({
168
+ file: U.result,
169
+ folderId: null,
170
+ name: K.name
171
+ });
172
+ r("browse"), l(L);
173
+ }, U.onerror = (L) => _(L);
174
+ }),
175
+ [E]
176
+ ), { getRootProps: y, getInputProps: G, isDragActive: H } = Ne({
177
+ onDrop: m,
178
+ accept: {
179
+ "image/*": d.includes("image") ? [] : [],
180
+ "video/*": d.includes("video") ? [] : []
181
+ },
182
+ maxSize: 10 * 1024 * 1024
183
+ }), J = () => {
184
+ o([h[0].url]), t();
185
+ }, $ = async (s) => {
186
+ await D(s.id);
187
+ }, ee = (s) => {
188
+ p(s);
189
+ }, se = async (s, l) => {
190
+ await T(he(s, l)), t();
191
+ }, ae = (s) => {
192
+ M(s.target.value);
193
+ }, te = async (s, l) => {
194
+ try {
195
+ l ? await E({
196
+ file: s,
197
+ folderId: null,
198
+ name: n.name || ""
199
+ }) : await T({
200
+ id: n.id || "",
201
+ file: s
202
+ }), f({ show: !1, file: "" }), r("browse");
203
+ } catch (_) {
204
+ console.error("Error saving edited image:", _);
205
+ }
206
+ };
207
+ return /* @__PURE__ */ a(B, { children: [
208
+ /* @__PURE__ */ a("div", { className: "min-w-[700px] min-h-[600px] w-[900px] max-w-[900px]", children: [
209
+ /* @__PURE__ */ e("h1", { className: "text-lg font-medium pb-4", children: "Digital Asset Manager" }),
210
+ /* @__PURE__ */ a(
211
+ re,
212
+ {
213
+ value: u,
214
+ onValueChange: (s) => r(s),
215
+ className: "flex-1 flex flex-col h-full",
216
+ children: [
217
+ /* @__PURE__ */ a("div", { className: "flex justify-between items-center mb-2", children: [
218
+ /* @__PURE__ */ a(ne, { children: [
219
+ /* @__PURE__ */ e(V, { value: "browse", children: "Browse Assets" }),
220
+ /* @__PURE__ */ e(V, { value: "upload", children: "Upload" })
221
+ ] }),
222
+ /* @__PURE__ */ a("div", { className: "flex items-center gap-2", children: [
223
+ h.length > 0 && /* @__PURE__ */ e(B, { children: /* @__PURE__ */ e(
224
+ S,
225
+ {
226
+ variant: "outline",
227
+ size: "sm",
228
+ onClick: () => v(),
229
+ title: "Clear selection",
230
+ children: "Clear"
231
+ }
232
+ ) }),
233
+ /* @__PURE__ */ e(
234
+ S,
235
+ {
236
+ size: "sm",
237
+ onClick: J,
238
+ disabled: h.length === 0,
239
+ children: "Select Asset"
240
+ }
241
+ )
242
+ ] })
243
+ ] }),
244
+ /* @__PURE__ */ a(W, { value: "browse", className: "flex-1 flex flex-col", children: [
245
+ /* @__PURE__ */ e("div", { className: "flex items-center gap-2 mb-2", children: /* @__PURE__ */ a("div", { className: "relative w-full", children: [
246
+ /* @__PURE__ */ e(ge, { className: "absolute left-2 top-2.5 h-4 w-4 text-muted-foreground" }),
247
+ /* @__PURE__ */ e(
248
+ oe,
249
+ {
250
+ placeholder: "Search assets...",
251
+ value: b,
252
+ onChange: ae,
253
+ className: "pl-8"
254
+ }
255
+ )
256
+ ] }) }),
257
+ P && N.length === 0 ? /* @__PURE__ */ a("div", { className: "grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-5 gap-2 overflow-y-auto max-h-[550px] p-1", children: [
258
+ /* @__PURE__ */ e("div", { className: "bg-gray-200 h-64 w-full animate-pulse rounded" }),
259
+ /* @__PURE__ */ e("div", { className: "bg-gray-200 h-64 w-full animate-pulse rounded" }),
260
+ /* @__PURE__ */ e("div", { className: "bg-gray-200 h-64 w-full animate-pulse rounded" }),
261
+ /* @__PURE__ */ e("div", { className: "bg-gray-200 h-64 w-full animate-pulse rounded" }),
262
+ /* @__PURE__ */ e("div", { className: "bg-gray-200 h-64 w-full animate-pulse rounded" }),
263
+ /* @__PURE__ */ e("div", { className: "bg-gray-200 h-64 w-full animate-pulse rounded" }),
264
+ /* @__PURE__ */ e("div", { className: "bg-gray-200 h-64 w-full animate-pulse rounded" }),
265
+ /* @__PURE__ */ e("div", { className: "bg-gray-200 h-64 w-full animate-pulse rounded" }),
266
+ /* @__PURE__ */ e("div", { className: "bg-gray-200 h-64 w-full animate-pulse rounded" }),
267
+ /* @__PURE__ */ e("div", { className: "bg-gray-200 h-64 w-full animate-pulse rounded" })
268
+ ] }) : N.length === 0 ? /* @__PURE__ */ a("div", { className: "flex flex-col items-center justify-center h-full text-center p-12 h-[380px]", children: [
269
+ /* @__PURE__ */ a("div", { className: "text-muted-foreground mb-2", children: [
270
+ /* @__PURE__ */ e("h3", { className: "text-gray-800 font-medium", children: "No assets to display" }),
271
+ /* @__PURE__ */ e("p", { className: "text-sm", children: "You haven't uploaded any assets yet. Start by uploading your first asset." })
272
+ ] }),
273
+ /* @__PURE__ */ e("div", { className: "flex gap-2 pt-4", children: /* @__PURE__ */ e(S, { size: "lg", onClick: () => r("upload"), children: "Upload Assets" }) })
274
+ ] }) : /* @__PURE__ */ a(
275
+ "div",
276
+ {
277
+ ref: j,
278
+ className: "grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-5 gap-2 overflow-y-auto max-h-[550px] p-1",
279
+ children: [
280
+ N.map((s) => /* @__PURE__ */ e(
281
+ ce,
282
+ {
283
+ className: O(
284
+ "cursor-pointer overflow-hidden transition-all",
285
+ h.some((l) => l.id === s.id) ? "ring-2 ring-primary" : "hover:ring-2 hover:ring-primary/20"
286
+ ),
287
+ onClick: () => I(s),
288
+ children: /* @__PURE__ */ a(de, { className: "p-0 relative group", children: [
289
+ /* @__PURE__ */ a("div", { className: "aspect-square relative overflow-hidden bg-muted", children: [
290
+ s.type === "image" ? /* @__PURE__ */ e(
291
+ "img",
292
+ {
293
+ src: s.url || "/placeholder.svg",
294
+ alt: s.name,
295
+ className: "object-cover w-full h-full"
296
+ }
297
+ ) : /* @__PURE__ */ a("div", { className: "flex items-center justify-center h-full", children: [
298
+ /* @__PURE__ */ e(pe, { className: "h-12 w-12 text-muted-foreground" }),
299
+ s.thumbnailUrl && /* @__PURE__ */ e(
300
+ "img",
301
+ {
302
+ src: s.thumbnailUrl || "/placeholder.svg",
303
+ alt: s.name,
304
+ className: "absolute inset-0 object-cover w-full h-full"
305
+ }
306
+ )
307
+ ] }),
308
+ /* @__PURE__ */ a("div", { className: "absolute inset-0 bg-black/50 opacity-0 group-hover:opacity-100 transition-opacity flex items-center justify-center gap-2", children: [
309
+ /* @__PURE__ */ e(
310
+ S,
311
+ {
312
+ variant: "secondary",
313
+ size: "icon",
314
+ className: "h-8 w-8",
315
+ onClick: (l) => {
316
+ l.stopPropagation(), ee(s);
317
+ },
318
+ children: /* @__PURE__ */ e(fe, { className: "h-4 w-4" })
319
+ }
320
+ ),
321
+ /* @__PURE__ */ e(
322
+ S,
323
+ {
324
+ variant: "secondary",
325
+ size: "icon",
326
+ className: "h-8 w-8",
327
+ onClick: (l) => {
328
+ l.stopPropagation(), f({
329
+ id: s.id,
330
+ show: !0,
331
+ file: s.url,
332
+ name: s.name
333
+ });
334
+ },
335
+ children: /* @__PURE__ */ e(ve, { className: "h-4 w-4" })
336
+ }
337
+ ),
338
+ /* @__PURE__ */ e(
339
+ S,
340
+ {
341
+ variant: "destructive",
342
+ size: "icon",
343
+ className: "h-8 w-8",
344
+ onClick: (l) => {
345
+ l.stopPropagation(), $(s);
346
+ },
347
+ children: /* @__PURE__ */ e(ye, { className: "h-4 w-4" })
348
+ }
349
+ )
350
+ ] }),
351
+ h.some((l) => l.id === s.id) && /* @__PURE__ */ e("div", { className: "absolute top-2 left-2", children: /* @__PURE__ */ e(
352
+ "input",
353
+ {
354
+ type: "checkbox",
355
+ checked: h.some(
356
+ (l) => l.id === s.id
357
+ ),
358
+ readOnly: !0,
359
+ className: "rounded-full"
360
+ }
361
+ ) })
362
+ ] }),
363
+ /* @__PURE__ */ a("div", { className: "p-2", children: [
364
+ /* @__PURE__ */ e(
365
+ "div",
366
+ {
367
+ className: "text-sm font-medium truncate",
368
+ title: s.name,
369
+ children: s.name
370
+ }
371
+ ),
372
+ /* @__PURE__ */ a("div", { className: "text-xs text-muted-foreground flex items-center justify-between", children: [
373
+ /* @__PURE__ */ e("span", { children: ze((s == null ? void 0 : s.size) || 0) }),
374
+ /* @__PURE__ */ e("span", { children: Fe(s.createdAt) })
375
+ ] })
376
+ ] })
377
+ ] })
378
+ },
379
+ s.id
380
+ )),
381
+ P && N.length > 0 && /* @__PURE__ */ e("div", { className: "col-span-full flex justify-center py-4", children: /* @__PURE__ */ e(X, { className: "h-6 w-6 animate-spin text-muted-foreground" }) })
382
+ ]
383
+ }
384
+ )
385
+ ] }),
386
+ /* @__PURE__ */ e(W, { value: "upload", className: "flex-1 ", children: /* @__PURE__ */ a(
387
+ "div",
388
+ {
389
+ ...y(),
390
+ className: O(
391
+ "border-2 border-dashed rounded-lg h-[380px] flex flex-col items-center justify-center text-center cursor-pointer hover:bg-gray-50",
392
+ H ? "border-primary bg-primary/5" : "border-muted-foreground/20"
393
+ ),
394
+ children: [
395
+ /* @__PURE__ */ e("input", { ...G() }),
396
+ q || k ? /* @__PURE__ */ a("div", { className: "flex flex-col items-center", children: [
397
+ /* @__PURE__ */ e(X, { className: "h-12 w-12 text-primary animate-spin mb-4" }),
398
+ /* @__PURE__ */ e("h3", { className: "text-lg font-medium mb-1", children: "Uploading files..." }),
399
+ /* @__PURE__ */ e("p", { className: "text-sm text-muted-foreground", children: "Please wait while your files are being processed." })
400
+ ] }) : /* @__PURE__ */ a(B, { children: [
401
+ /* @__PURE__ */ e(xe, { className: "h-12 w-12 text-muted-foreground mb-4" }),
402
+ /* @__PURE__ */ e("h3", { className: "text-lg font-medium mb-1", children: "Drag & drop files here" }),
403
+ /* @__PURE__ */ e("p", { className: "text-sm text-muted-foreground mb-4", children: "or click to browse your files" }),
404
+ /* @__PURE__ */ a("div", { className: "text-xs text-muted-foreground", children: [
405
+ /* @__PURE__ */ a("p", { children: [
406
+ "Accepted file types: ",
407
+ d.join(", ")
408
+ ] }),
409
+ /* @__PURE__ */ a("p", { children: [
410
+ "Maximum file size: ",
411
+ 10,
412
+ "MB"
413
+ ] })
414
+ ] })
415
+ ] })
416
+ ]
417
+ }
418
+ ) })
419
+ ]
420
+ }
421
+ )
422
+ ] }),
423
+ A && /* @__PURE__ */ e(Y, { fallback: /* @__PURE__ */ e("div", { children: "Loading..." }), children: /* @__PURE__ */ e(
424
+ Pe,
425
+ {
426
+ asset: A,
427
+ onSave: (s) => se(A, s),
428
+ onCancel: () => {
429
+ p(null);
430
+ }
431
+ }
432
+ ) }),
433
+ n.show && /* @__PURE__ */ e(Y, { fallback: /* @__PURE__ */ e("div", { children: "Loading..." }), children: /* @__PURE__ */ e(
434
+ Ue,
435
+ {
436
+ imageUrl: n.file,
437
+ onSave: te,
438
+ onClose: () => f({ show: !1, file: "" }),
439
+ defaultSavedImageName: n.name,
440
+ isEditing: !!n.id
441
+ }
442
+ ) })
443
+ ] });
444
+ }
445
+ function ze(t) {
446
+ return t < 1024 ? t + " B" : t < 1024 * 1024 ? (t / 1024).toFixed(1) + " KB" : t < 1024 * 1024 * 1024 ? (t / (1024 * 1024)).toFixed(1) + " MB" : (t / (1024 * 1024 * 1024)).toFixed(1) + " GB";
447
+ }
448
+ function Fe(t) {
449
+ const o = new Date(t);
450
+ return new Intl.DateTimeFormat("en-US", {
451
+ month: "short",
452
+ day: "numeric",
453
+ year: "numeric"
454
+ }).format(o);
455
+ }
456
+ export {
457
+ Re as default
458
+ };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),a=require("react"),Q=require("@chaibuilder/sdk"),o=require("@chaibuilder/sdk/ui"),B=require("lodash-es"),p=require("lucide-react"),J=require("react-dropzone"),S=require("@tanstack/react-query"),N=require("sonner"),r=require("./index-BosOek7g.cjs"),W=()=>{const t=r.useAssetsApiUrl(),d=S.useQueryClient(),u=r.useFetch();return S.useMutation({mutationFn:async({file:i,folderId:m,name:h})=>u(t,{action:r.ACTIONS.UPLOAD_ASSET,data:{file:i,folderId:m,name:h}}),onSuccess:()=>{d.invalidateQueries({queryKey:[r.ACTIONS.GET_ASSETS]}),N.toast.success("Asset uploaded successfully")},onError:()=>{N.toast.error("Failed to upload asset")}})},X=()=>{const t=r.useAssetsApiUrl(),d=S.useQueryClient(),u=r.useFetch();return S.useMutation({mutationFn:async i=>u(t,{action:r.ACTIONS.DELETE_ASSET,data:{id:i}}),onSuccess:()=>{d.invalidateQueries({queryKey:[r.ACTIONS.GET_ASSETS]}),N.toast.success("Asset deleted successfully")},onError:()=>{N.toast.error("Failed to delete asset")}})},Z=()=>{const t=r.useAssetsApiUrl(),d=S.useQueryClient(),u=r.useFetch();return S.useMutation({mutationFn:async i=>u(t,{action:r.ACTIONS.UPDATE_ASSET,data:i}),onSuccess:()=>{d.invalidateQueries({queryKey:[r.ACTIONS.GET_ASSETS]}),N.toast.success("Asset updated successfully")},onError:()=>{N.toast.error("Failed to update asset")}})},$=(t={})=>{const d=r.useAssetsApiUrl(),u=r.useFetch(),{search:i,page:m=1,limit:h=10}=t;return S.useQuery({queryKey:[r.QUERY_KEY_BASE,r.ACTIONS.GET_ASSETS,i,m,h],queryFn:async()=>(await u(d,{action:r.ACTIONS.GET_ASSETS,data:{search:i,page:m,limit:h}})).data,retry:1})};function ee(){const[d,u]=a.useState([]),[i,m]=a.useState({query:"",page:1,pageSize:10}),h=B.debounce(()=>i.query,300)(),{data:n,isLoading:b}=$({search:(h==null?void 0:h.toLowerCase().trim())||"",page:i.page,limit:i.pageSize}),f=n?Math.ceil(n.total/n.pageSize):0,c=(n==null?void 0:n.page)||1,j=c<f,w=c>1,{mutate:A,isPending:x}=Z(),{mutate:C,isPending:T}=W(),{mutate:q,isPending:U}=X(),y=a.useCallback(g=>{g>=1&&g<=f&&m(v=>({...v,page:g}))},[f]),F=a.useCallback(()=>{j&&y(c+1)},[c,j,y]),E=a.useCallback(()=>{w&&y(c-1)},[c,w,y]),I=a.useCallback(g=>{m(v=>({...v,query:g,page:1}))},[]),k=a.useCallback(g=>{u(v=>B.find(v,{id:g.id})?[]:[g])},[!1]),z=a.useCallback(()=>{u([])},[]);return{query:(i==null?void 0:i.query)||"",selectedAssets:d,assets:(n==null?void 0:n.assets)||[],currentPage:c,totalPages:f,hasNextPage:j,hasPreviousPage:w,uploadAsset:C,updateAsset:A,deleteAsset:q,goToPage:y,nextPage:F,previousPage:E,updateSearchQuery:I,clearSelectedAssets:z,updateSelectedAssets:k,isLoadingAssets:b,isUploadingAsset:T,isUpdatingAsset:x,isDeletingAsset:U}}const se=a.lazy(()=>Promise.resolve().then(()=>require("./asset-metadata-editor-Bzt3zj6x.cjs"))),te=a.lazy(()=>Promise.resolve().then(()=>require("./image-editor-D8wu5UNM.cjs")));function ae({close:t,onSelect:d,mode:u="image"}){const m=a.useMemo(()=>[u],[u]),[h,n]=a.useState("browse"),[b,f]=a.useState(null),[c,j]=a.useState({show:!1,file:""}),{query:w,assets:A,selectedAssets:x,uploadAsset:C,updateAsset:T,deleteAsset:q,updateSearchQuery:U,clearSelectedAssets:y,updateSelectedAssets:F,isLoadingAssets:E,isUploadingAsset:I,isUpdatingAsset:k}=ee(),z=a.useRef(null),g=a.useCallback(async s=>new Promise((l,M)=>{const O=s[0],P=new FileReader;P.readAsDataURL(O),P.onload=async()=>{const D=await C({file:P.result,folderId:null,name:O.name});n("browse"),l(D)},P.onerror=D=>M(D)}),[C]),{getRootProps:v,getInputProps:L,isDragActive:_}=J.useDropzone({onDrop:g,accept:{"image/*":m.includes("image")?[]:[],"video/*":m.includes("video")?[]:[]},maxSize:10*1024*1024}),R=()=>{d([x[0].url]),t()},G=async s=>{await q(s.id)},K=s=>{f(s)},Y=async(s,l)=>{await T(B.merge(s,l)),t()},V=s=>{U(s.target.value)},H=async(s,l)=>{try{l?await C({file:s,folderId:null,name:c.name||""}):await T({id:c.id||"",file:s}),j({show:!1,file:""}),n("browse")}catch(M){console.error("Error saving edited image:",M)}};return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"min-w-[700px] min-h-[600px] w-[900px] max-w-[900px]",children:[e.jsx("h1",{className:"text-lg font-medium pb-4",children:"Digital Asset Manager"}),e.jsxs(o.Tabs,{value:h,onValueChange:s=>n(s),className:"flex-1 flex flex-col h-full",children:[e.jsxs("div",{className:"flex justify-between items-center mb-2",children:[e.jsxs(o.TabsList,{children:[e.jsx(o.TabsTrigger,{value:"browse",children:"Browse Assets"}),e.jsx(o.TabsTrigger,{value:"upload",children:"Upload"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[x.length>0&&e.jsx(e.Fragment,{children:e.jsx(o.Button,{variant:"outline",size:"sm",onClick:()=>y(),title:"Clear selection",children:"Clear"})}),e.jsx(o.Button,{size:"sm",onClick:R,disabled:x.length===0,children:"Select Asset"})]})]}),e.jsxs(o.TabsContent,{value:"browse",className:"flex-1 flex flex-col",children:[e.jsx("div",{className:"flex items-center gap-2 mb-2",children:e.jsxs("div",{className:"relative w-full",children:[e.jsx(p.Search,{className:"absolute left-2 top-2.5 h-4 w-4 text-muted-foreground"}),e.jsx(o.Input,{placeholder:"Search assets...",value:w,onChange:V,className:"pl-8"})]})}),E&&A.length===0?e.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-5 gap-2 overflow-y-auto max-h-[550px] p-1",children:[e.jsx("div",{className:"bg-gray-200 h-64 w-full animate-pulse rounded"}),e.jsx("div",{className:"bg-gray-200 h-64 w-full animate-pulse rounded"}),e.jsx("div",{className:"bg-gray-200 h-64 w-full animate-pulse rounded"}),e.jsx("div",{className:"bg-gray-200 h-64 w-full animate-pulse rounded"}),e.jsx("div",{className:"bg-gray-200 h-64 w-full animate-pulse rounded"}),e.jsx("div",{className:"bg-gray-200 h-64 w-full animate-pulse rounded"}),e.jsx("div",{className:"bg-gray-200 h-64 w-full animate-pulse rounded"}),e.jsx("div",{className:"bg-gray-200 h-64 w-full animate-pulse rounded"}),e.jsx("div",{className:"bg-gray-200 h-64 w-full animate-pulse rounded"}),e.jsx("div",{className:"bg-gray-200 h-64 w-full animate-pulse rounded"})]}):A.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center h-full text-center p-12 h-[380px]",children:[e.jsxs("div",{className:"text-muted-foreground mb-2",children:[e.jsx("h3",{className:"text-gray-800 font-medium",children:"No assets to display"}),e.jsx("p",{className:"text-sm",children:"You haven't uploaded any assets yet. Start by uploading your first asset."})]}),e.jsx("div",{className:"flex gap-2 pt-4",children:e.jsx(o.Button,{size:"lg",onClick:()=>n("upload"),children:"Upload Assets"})})]}):e.jsxs("div",{ref:z,className:"grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-5 gap-2 overflow-y-auto max-h-[550px] p-1",children:[A.map(s=>e.jsx(o.Card,{className:Q.mergeClasses("cursor-pointer overflow-hidden transition-all",x.some(l=>l.id===s.id)?"ring-2 ring-primary":"hover:ring-2 hover:ring-primary/20"),onClick:()=>F(s),children:e.jsxs(o.CardContent,{className:"p-0 relative group",children:[e.jsxs("div",{className:"aspect-square relative overflow-hidden bg-muted",children:[s.type==="image"?e.jsx("img",{src:s.url||"/placeholder.svg",alt:s.name,className:"object-cover w-full h-full"}):e.jsxs("div",{className:"flex items-center justify-center h-full",children:[e.jsx(p.Film,{className:"h-12 w-12 text-muted-foreground"}),s.thumbnailUrl&&e.jsx("img",{src:s.thumbnailUrl||"/placeholder.svg",alt:s.name,className:"absolute inset-0 object-cover w-full h-full"})]}),e.jsxs("div",{className:"absolute inset-0 bg-black/50 opacity-0 group-hover:opacity-100 transition-opacity flex items-center justify-center gap-2",children:[e.jsx(o.Button,{variant:"secondary",size:"icon",className:"h-8 w-8",onClick:l=>{l.stopPropagation(),K(s)},children:e.jsx(p.ImageIcon,{className:"h-4 w-4"})}),e.jsx(o.Button,{variant:"secondary",size:"icon",className:"h-8 w-8",onClick:l=>{l.stopPropagation(),j({id:s.id,show:!0,file:s.url,name:s.name})},children:e.jsx(p.Edit,{className:"h-4 w-4"})}),e.jsx(o.Button,{variant:"destructive",size:"icon",className:"h-8 w-8",onClick:l=>{l.stopPropagation(),G(s)},children:e.jsx(p.Trash2,{className:"h-4 w-4"})})]}),x.some(l=>l.id===s.id)&&e.jsx("div",{className:"absolute top-2 left-2",children:e.jsx("input",{type:"checkbox",checked:x.some(l=>l.id===s.id),readOnly:!0,className:"rounded-full"})})]}),e.jsxs("div",{className:"p-2",children:[e.jsx("div",{className:"text-sm font-medium truncate",title:s.name,children:s.name}),e.jsxs("div",{className:"text-xs text-muted-foreground flex items-center justify-between",children:[e.jsx("span",{children:le((s==null?void 0:s.size)||0)}),e.jsx("span",{children:re(s.createdAt)})]})]})]})},s.id)),E&&A.length>0&&e.jsx("div",{className:"col-span-full flex justify-center py-4",children:e.jsx(p.Loader2,{className:"h-6 w-6 animate-spin text-muted-foreground"})})]})]}),e.jsx(o.TabsContent,{value:"upload",className:"flex-1 ",children:e.jsxs("div",{...v(),className:Q.mergeClasses("border-2 border-dashed rounded-lg h-[380px] flex flex-col items-center justify-center text-center cursor-pointer hover:bg-gray-50",_?"border-primary bg-primary/5":"border-muted-foreground/20"),children:[e.jsx("input",{...L()}),k||I?e.jsxs("div",{className:"flex flex-col items-center",children:[e.jsx(p.Loader2,{className:"h-12 w-12 text-primary animate-spin mb-4"}),e.jsx("h3",{className:"text-lg font-medium mb-1",children:"Uploading files..."}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Please wait while your files are being processed."})]}):e.jsxs(e.Fragment,{children:[e.jsx(p.Upload,{className:"h-12 w-12 text-muted-foreground mb-4"}),e.jsx("h3",{className:"text-lg font-medium mb-1",children:"Drag & drop files here"}),e.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:"or click to browse your files"}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:[e.jsxs("p",{children:["Accepted file types: ",m.join(", ")]}),e.jsxs("p",{children:["Maximum file size: ",10,"MB"]})]})]})]})})]})]}),b&&e.jsx(a.Suspense,{fallback:e.jsx("div",{children:"Loading..."}),children:e.jsx(se,{asset:b,onSave:s=>Y(b,s),onCancel:()=>{f(null)}})}),c.show&&e.jsx(a.Suspense,{fallback:e.jsx("div",{children:"Loading..."}),children:e.jsx(te,{imageUrl:c.file,onSave:H,onClose:()=>j({show:!1,file:""}),defaultSavedImageName:c.name,isEditing:!!c.id})})]})}function le(t){return t<1024?t+" B":t<1024*1024?(t/1024).toFixed(1)+" KB":t<1024*1024*1024?(t/(1024*1024)).toFixed(1)+" MB":(t/(1024*1024*1024)).toFixed(1)+" GB"}function re(t){const d=new Date(t);return new Intl.DateTimeFormat("en-US",{month:"short",day:"numeric",year:"numeric"}).format(d)}exports.default=ae;
@@ -1,20 +1,20 @@
1
1
  import { jsx as l } from "react/jsx-runtime";
2
- import { Dialog as T, DialogContent as y } from "@chaibuilder/sdk/ui";
3
- import { debounce as S } from "lodash-es";
4
- import { Save as w, Copy as E } from "lucide-react";
5
- import { memo as O, useState as p, useEffect as k, useMemo as s, useCallback as I } from "react";
6
- import A from "react-filerobot-image-editor";
7
- const R = O(
2
+ import { memo as T, useState as p, useEffect as y, useMemo as s, useCallback as I } from "react";
3
+ import S from "react-filerobot-image-editor";
4
+ import { Dialog as w, DialogContent as E } from "@chaibuilder/sdk/ui";
5
+ import { debounce as O } from "lodash-es";
6
+ import { Save as k, Copy as A } from "lucide-react";
7
+ const R = T(
8
8
  ({ imageUrl: n, onSave: d, onClose: i, defaultSavedImageName: g, isEditing: m = !1 }) => {
9
9
  const [b, c] = p(!0), [h, C] = p(!1);
10
- k(() => {
10
+ y(() => {
11
11
  const e = new Image();
12
12
  return e.src = n, e.onload = () => C(!0), () => {
13
13
  e.onload = null;
14
14
  };
15
15
  }, [n]);
16
16
  const f = s(
17
- () => S((e, o = !1) => {
17
+ () => O((e, o = !1) => {
18
18
  const t = e.imageBase64;
19
19
  d(t, o), c(!1);
20
20
  }, 300),
@@ -56,25 +56,25 @@ const R = O(
56
56
  onClick: (e, o) => o((...t) => {
57
57
  a(t[0], !1);
58
58
  }),
59
- icon: w
59
+ icon: k
60
60
  },
61
61
  {
62
62
  label: "Save as new file",
63
63
  onClick: (e, o) => o((...t) => {
64
64
  a(t[0], !0);
65
65
  }),
66
- icon: E
66
+ icon: A
67
67
  }
68
68
  ] : [],
69
69
  [m, a]
70
70
  );
71
- return /* @__PURE__ */ l(T, { open: !0, onOpenChange: (e) => !e && u(), children: /* @__PURE__ */ l(
72
- y,
71
+ return /* @__PURE__ */ l(w, { open: !0, onOpenChange: (e) => !e && u(), children: /* @__PURE__ */ l(
72
+ E,
73
73
  {
74
74
  id: "chai-image-editor-container",
75
75
  className: "flex-1 overflow-hidden p-4 min-w-[1280px]",
76
76
  children: b && h && /* @__PURE__ */ l(
77
- A,
77
+ S,
78
78
  {
79
79
  theme: v,
80
80
  source: n,