@chaibuilder/pages 0.4.8-beta.2 → 0.4.8-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-C657rWjb.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-CpcOqKZB.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-De2uSYsE.cjs"),t=require("./index-B9qohq82.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-CHMJEiI7.cjs"),t=require("./index-CqIGt4M7.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-Y1TSYFEO.js";
2
- import { g as d, c as f, a as e } from "./index-C657rWjb.js";
1
+ import { c, T as l, P as m, a as u, D as v, Q as i } from "./B4MFY5CR-DmzYJmsY.js";
2
+ import { g as d, c as f, a as e } from "./index-CpcOqKZB.js";
3
3
  var p = (a) => {
4
4
  const [r, t] = c({
5
5
  prefix: "TanstackQueryDevtools"
@@ -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-Y1TSYFEO.js";
2
- import { g as v, c as C, a as e } from "./index-C657rWjb.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-DmzYJmsY.js";
2
+ import { g as v, c as C, a as e } from "./index-CpcOqKZB.js";
3
3
  var h = (t) => {
4
4
  const [r, o] = s({
5
5
  prefix: "TanstackQueryDevtools"
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./B4MFY5CR-De2uSYsE.cjs"),t=require("./index-B9qohq82.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-CHMJEiI7.cjs"),t=require("./index-CqIGt4M7.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,8 +1,8 @@
1
1
  import { jsxs as i, Fragment as w, jsx as a } from "react/jsx-runtime";
2
- import { Dialog as u, DialogContent as h, DialogHeader as b, DialogTitle as N, Label as r, Textarea as y, DialogFooter as D, Button as p } from "@chaibuilder/sdk/ui";
3
- import { Eye as F } from "lucide-react";
2
+ import { Dialog as u, DialogContent as h, DialogHeader as N, DialogTitle as b, Label as r, Textarea as D, DialogFooter as F, Button as p } from "@chaibuilder/sdk/ui";
3
+ import { Eye as y } from "lucide-react";
4
4
  import { useState as n } from "react";
5
- function E({
5
+ function k({
6
6
  asset: e,
7
7
  onSave: l,
8
8
  onCancel: o
@@ -19,7 +19,7 @@ function E({
19
19
  };
20
20
  return /* @__PURE__ */ i(w, { children: [
21
21
  /* @__PURE__ */ a(u, { open: !0, onOpenChange: () => o(), children: /* @__PURE__ */ i(h, { className: "sm:max-w-[700px]", children: [
22
- /* @__PURE__ */ a(b, { children: /* @__PURE__ */ a(N, { children: "Edit Asset Details" }) }),
22
+ /* @__PURE__ */ a(N, { children: /* @__PURE__ */ a(b, { children: "Edit Asset Details" }) }),
23
23
  /* @__PURE__ */ i("div", { className: "flex gap-4", children: [
24
24
  /* @__PURE__ */ i("div", { className: "relative group", children: [
25
25
  /* @__PURE__ */ a(
@@ -34,7 +34,7 @@ function E({
34
34
  {
35
35
  onClick: () => s(!0),
36
36
  className: "absolute inset-0 flex items-center justify-center bg-black/50 opacity-0 group-hover:opacity-100 transition-opacity rounded-md",
37
- children: /* @__PURE__ */ a(F, { className: "h-8 w-8 text-white" })
37
+ children: /* @__PURE__ */ a(y, { className: "h-8 w-8 text-white" })
38
38
  }
39
39
  )
40
40
  ] }),
@@ -62,7 +62,7 @@ function E({
62
62
  /* @__PURE__ */ i("div", { className: "grid gap-2", children: [
63
63
  /* @__PURE__ */ a(r, { htmlFor: "description", children: "Description" }),
64
64
  /* @__PURE__ */ a(
65
- y,
65
+ D,
66
66
  {
67
67
  id: "description",
68
68
  value: c,
@@ -74,7 +74,7 @@ function E({
74
74
  ] })
75
75
  ] })
76
76
  ] }),
77
- /* @__PURE__ */ i(D, { children: [
77
+ /* @__PURE__ */ i(F, { children: [
78
78
  /* @__PURE__ */ a(p, { variant: "outline", onClick: o, children: "Cancel" }),
79
79
  /* @__PURE__ */ a(p, { onClick: x, disabled: d, children: d ? "Saving..." : "Save Changes" })
80
80
  ] })
@@ -90,7 +90,7 @@ function E({
90
90
  ] });
91
91
  }
92
92
  function S(e) {
93
- return e < 1024 ? `${e.toFixed(2)} KB` : `${(e / 1024).toFixed(2)} MB`;
93
+ return e < 1024 ? `${e.toFixed(2)} B` : e < 1024 * 1024 ? `${(e / 1024).toFixed(2)} KB` : `${(e / (1024 * 1024)).toFixed(2)} MB`;
94
94
  }
95
95
  function g(e) {
96
96
  if (!e) return "N/A";
@@ -104,5 +104,5 @@ function g(e) {
104
104
  }).format(l);
105
105
  }
106
106
  export {
107
- E as default
107
+ k as default
108
108
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),a=require("@chaibuilder/sdk/ui"),g=require("lucide-react"),n=require("react");function p({asset:t,onSave:l,onCancel:r}){const[s,m]=n.useState(t.description||""),[c,o]=n.useState(!1),[h,d]=n.useState(!1),x=async()=>{o(!0);try{await l({description:s||void 0})}finally{o(!1)}};return e.jsxs(e.Fragment,{children:[e.jsx(a.Dialog,{open:!0,onOpenChange:()=>r(),children:e.jsxs(a.DialogContent,{className:"sm:max-w-[700px]",children:[e.jsx(a.DialogHeader,{children:e.jsx(a.DialogTitle,{children:"Edit Asset Details"})}),e.jsxs("div",{className:"flex gap-4",children:[e.jsxs("div",{className:"relative group",children:[e.jsx("img",{src:t.url,className:"max-h-96 w-96 border rounded-md p-2"}),e.jsx("button",{onClick:()=>d(!0),className:"absolute inset-0 flex items-center justify-center bg-black/50 opacity-0 group-hover:opacity-100 transition-opacity rounded-md",children:e.jsx(g.Eye,{className:"h-8 w-8 text-white"})})]}),e.jsxs("div",{className:"grid gap-3 w-full",children:[e.jsx(a.Label,{htmlFor:"description",children:"Details"}),e.jsx("div",{className:"grid grid-cols-1 gap-2 text-sm border rounded-md p-2",children:[{label:"File Name",value:t.name},{label:"Type",value:t.type},{label:"Format",value:t.format},{label:"Size",value:j(t.size)},{label:"Dimensions",value:`${t.width} × ${t.height}`},{label:"Created",value:u(t.createdAt)},{label:"Updated",value:u((t==null?void 0:t.updatedAt)||"")}].map(i=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(a.Label,{className:"w-max text-left px-2 w-1/4 font-normal text-gray-700",children:i.label}),":",e.jsx("div",{className:"w-max text-left font-medium text-gray-900 capitalize",children:i.value})]}))}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(a.Label,{htmlFor:"description",children:"Description"}),e.jsx(a.Textarea,{id:"description",value:s,placeholder:"Enter a description for the asset",onChange:i=>m(i.target.value),rows:3})]})]})]}),e.jsxs(a.DialogFooter,{children:[e.jsx(a.Button,{variant:"outline",onClick:r,children:"Cancel"}),e.jsx(a.Button,{onClick:x,disabled:c,children:c?"Saving...":"Save Changes"})]})]})}),e.jsx(a.Dialog,{open:h,onOpenChange:d,children:e.jsx(a.DialogContent,{className:"w-[60vw] h-[60vh] p-0 flex items-center justify-center bg-gray-100",children:e.jsx("img",{src:t.url,className:"w-full h-full object-contain",alt:t.name})})})]})}function j(t){return t<1024?`${t.toFixed(2)} KB`:`${(t/1024).toFixed(2)} MB`}function u(t){if(!t)return"N/A";const l=new Date(t);return new Intl.DateTimeFormat("en-US",{month:"short",day:"numeric",year:"numeric",hour:"2-digit",minute:"2-digit"}).format(l)}exports.default=p;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),a=require("@chaibuilder/sdk/ui"),g=require("lucide-react"),r=require("react");function p({asset:t,onSave:l,onCancel:n}){const[s,m]=r.useState(t.description||""),[o,c]=r.useState(!1),[x,d]=r.useState(!1),h=async()=>{c(!0);try{await l({description:s||void 0})}finally{c(!1)}};return e.jsxs(e.Fragment,{children:[e.jsx(a.Dialog,{open:!0,onOpenChange:()=>n(),children:e.jsxs(a.DialogContent,{className:"sm:max-w-[700px]",children:[e.jsx(a.DialogHeader,{children:e.jsx(a.DialogTitle,{children:"Edit Asset Details"})}),e.jsxs("div",{className:"flex gap-4",children:[e.jsxs("div",{className:"relative group",children:[e.jsx("img",{src:t.url,className:"max-h-96 w-96 border rounded-md p-2"}),e.jsx("button",{onClick:()=>d(!0),className:"absolute inset-0 flex items-center justify-center bg-black/50 opacity-0 group-hover:opacity-100 transition-opacity rounded-md",children:e.jsx(g.Eye,{className:"h-8 w-8 text-white"})})]}),e.jsxs("div",{className:"grid gap-3 w-full",children:[e.jsx(a.Label,{htmlFor:"description",children:"Details"}),e.jsx("div",{className:"grid grid-cols-1 gap-2 text-sm border rounded-md p-2",children:[{label:"File Name",value:t.name},{label:"Type",value:t.type},{label:"Format",value:t.format},{label:"Size",value:f(t.size)},{label:"Dimensions",value:`${t.width} × ${t.height}`},{label:"Created",value:u(t.createdAt)},{label:"Updated",value:u((t==null?void 0:t.updatedAt)||"")}].map(i=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(a.Label,{className:"w-max text-left px-2 w-1/4 font-normal text-gray-700",children:i.label}),":",e.jsx("div",{className:"w-max text-left font-medium text-gray-900 capitalize",children:i.value})]}))}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(a.Label,{htmlFor:"description",children:"Description"}),e.jsx(a.Textarea,{id:"description",value:s,placeholder:"Enter a description for the asset",onChange:i=>m(i.target.value),rows:3})]})]})]}),e.jsxs(a.DialogFooter,{children:[e.jsx(a.Button,{variant:"outline",onClick:n,children:"Cancel"}),e.jsx(a.Button,{onClick:h,disabled:o,children:o?"Saving...":"Save Changes"})]})]})}),e.jsx(a.Dialog,{open:x,onOpenChange:d,children:e.jsx(a.DialogContent,{className:"w-[60vw] h-[60vh] p-0 flex items-center justify-center bg-gray-100",children:e.jsx("img",{src:t.url,className:"w-full h-full object-contain",alt:t.name})})})]})}function f(t){return t<1024?`${t.toFixed(2)} B`:t<1024*1024?`${(t/1024).toFixed(2)} KB`:`${(t/(1024*1024)).toFixed(2)} MB`}function u(t){if(!t)return"N/A";const l=new Date(t);return new Intl.DateTimeFormat("en-US",{month:"short",day:"numeric",year:"numeric",hour:"2-digit",minute:"2-digit"}).format(l)}exports.default=p;
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),n=require("react"),L=require("@chaibuilder/sdk"),t=require("@chaibuilder/sdk/ui"),P=require("lodash-es"),j=require("lucide-react"),X=require("react-dropzone"),A=require("@tanstack/react-query"),b=require("sonner"),a=require("./index-CqIGt4M7.cjs"),Z=()=>{const l=a.useAssetsApiUrl(),c=A.useQueryClient(),d=a.useFetch();return A.useMutation({mutationFn:async({file:r,folderId:m,name:h})=>d(l,{action:a.ACTIONS.UPLOAD_ASSET,data:{file:r,folderId:m,name:h}}),onSuccess:()=>{c.invalidateQueries({queryKey:[a.QUERY_KEY_BASE,a.ACTIONS.GET_ASSETS]}),b.toast.success("Asset uploaded successfully")},onError:()=>{b.toast.error("Failed to upload asset")}})},ee=()=>{const l=a.useAssetsApiUrl(),c=A.useQueryClient(),d=a.useFetch();return A.useMutation({mutationFn:async r=>d(l,{action:a.ACTIONS.DELETE_ASSET,data:{id:r}}),onSuccess:()=>{c.invalidateQueries({queryKey:[a.QUERY_KEY_BASE,a.ACTIONS.GET_ASSETS]}),b.toast.success("Asset deleted successfully")},onError:()=>{b.toast.error("Failed to delete asset")}})},se=()=>{const l=a.useAssetsApiUrl(),c=A.useQueryClient(),d=a.useFetch();return A.useMutation({mutationFn:async r=>d(l,{action:a.ACTIONS.UPDATE_ASSET,data:r}),onSuccess:()=>{c.invalidateQueries({queryKey:[a.QUERY_KEY_BASE,a.ACTIONS.GET_ASSETS]}),b.toast.success("Asset updated successfully")},onError:()=>{b.toast.error("Failed to update asset")}})},te=(l={})=>{const c=a.useAssetsApiUrl(),d=a.useFetch(),{search:r,page:m=1,limit:h=10}=l;return A.useQuery({queryKey:[a.QUERY_KEY_BASE,a.ACTIONS.GET_ASSETS,r,m,h],queryFn:async()=>await d(c,{action:a.ACTIONS.GET_ASSETS,data:{search:r,page:m,limit:h}}),retry:1})};function ae(){const[c,d]=n.useState([]),[r,m]=n.useState({query:"",page:1,pageSize:10}),h=P.debounce(()=>r.query,300)(),{data:o,isLoading:w}=te({search:(h==null?void 0:h.toLowerCase().trim())||"",page:r.page,limit:r.pageSize}),y=o?Math.ceil(o.total/o.pageSize):0,u=(o==null?void 0:o.page)||1,p=u<y,g=u>1,{mutate:C,isPending:q}=se(),{mutate:N,isPending:f}=Z(),{mutate:E,isPending:T}=ee(),v=n.useCallback(x=>{x>=1&&x<=y&&m(S=>({...S,page:x}))},[y]),F=n.useCallback(()=>{p&&v(u+1)},[u,p,v]),k=n.useCallback(()=>{g&&v(u-1)},[u,g,v]),I=n.useCallback(x=>{m(S=>({...S,query:x,page:1}))},[]),U=n.useCallback(x=>{d(S=>P.find(S,{id:x.id})?[]:[x])},[!1]),z=n.useCallback(()=>{d([])},[]);return{query:(r==null?void 0:r.query)||"",selectedAssets:c,assets:(o==null?void 0:o.assets)||[],currentPage:u,totalPages:y,hasNextPage:p,hasPreviousPage:g,uploadAsset:N,updateAsset:C,deleteAsset:E,goToPage:v,nextPage:F,previousPage:k,updateSearchQuery:I,clearSelectedAssets:z,updateSelectedAssets:U,isLoadingAssets:w,isUploadingAsset:f,isUpdatingAsset:q,isDeletingAsset:T}}const le=n.lazy(()=>Promise.resolve().then(()=>require("./asset-metadata-editor-IRTgc3or.cjs"))),ne=n.lazy(()=>Promise.resolve().then(()=>require("./image-editor-DHmv5L8S.cjs")));function ie({close:l,onSelect:c,mode:d="image"}){const m=n.useMemo(()=>[d],[d]),[h,o]=n.useState("browse"),[w,y]=n.useState(null),[u,p]=n.useState(null),[g,C]=n.useState({show:!1,file:""}),{query:q,assets:N,selectedAssets:f,uploadAsset:E,updateAsset:T,deleteAsset:v,updateSearchQuery:F,clearSelectedAssets:k,updateSelectedAssets:I,isLoadingAssets:U,isUploadingAsset:z,isUpdatingAsset:x}=ae(),S=n.useRef(null),_=n.useCallback(async s=>new Promise((i,M)=>{const Q=s[0],D=new FileReader;D.readAsDataURL(Q),D.onload=async()=>{const B=await E({file:D.result,folderId:null,name:Q.name},{onSuccess:()=>{o("browse")}});i(B)},D.onerror=B=>M(B)}),[E]),{getRootProps:O,getInputProps:R,isDragActive:K}=X.useDropzone({onDrop:_,accept:{"image/*":m.includes("image")?[]:[]},maxSize:10*1024*1024}),Y=()=>{c([f[0].url]),l()},G=async s=>{p(s)},$=async()=>{u&&(await v(u.id),p(null))},H=s=>{y(s)},V=async(s,i)=>{await T(P.merge(s,P.pick(i,["id","description"]))),l()},J=s=>{F(s.target.value)},W=async(s,i)=>{try{i?await E({file:s,folderId:null,name:g.name||""}):await T({id:g.id||"",file:s}),C({show:!1,file:""}),o("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(t.Tabs,{value:h,onValueChange:s=>o(s),className:"flex-1 flex flex-col h-full",children:[e.jsxs("div",{className:"flex justify-between items-center mb-2",children:[e.jsxs(t.TabsList,{children:[e.jsx(t.TabsTrigger,{value:"browse",children:"Browse Assets"}),e.jsx(t.TabsTrigger,{value:"upload",children:"Upload"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[f.length>0&&e.jsx(e.Fragment,{children:e.jsx(t.Button,{variant:"outline",size:"sm",onClick:()=>k(),title:"Clear selection",children:"Clear"})}),e.jsx(t.Button,{size:"sm",onClick:Y,disabled:f.length===0,children:"Select Asset"})]})]}),e.jsxs(t.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(j.Search,{className:"absolute left-2 top-2.5 h-4 w-4 text-muted-foreground"}),e.jsx(t.Input,{placeholder:"Search assets...",value:q,onChange:J,className:"pl-8"})]})}),U&&N.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"})]}):N.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center 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(t.Button,{size:"lg",onClick:()=>o("upload"),children:"Upload Assets"})})]}):e.jsxs("div",{ref:S,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:[N.map(s=>e.jsx(t.Card,{className:L.mergeClasses("cursor-pointer overflow-hidden transition-all",f.some(i=>i.id===s.id)?"ring-2 ring-primary":"hover:ring-2 hover:ring-primary/20"),onClick:()=>I(s),children:e.jsxs(t.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.thumbnailUrl||"/placeholder.svg",alt:s.name,className:"object-cover w-full h-full min-h-[100px]"}):e.jsxs("div",{className:"flex items-center justify-center h-full",children:[e.jsx(j.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(t.Button,{variant:"secondary",size:"icon",className:"h-8 w-8",onClick:i=>{i.stopPropagation(),H(s)},children:e.jsx(j.ImageIcon,{className:"h-4 w-4"})}),e.jsx(t.Button,{variant:"secondary",size:"icon",className:"h-8 w-8",onClick:i=>{i.stopPropagation(),C({id:s.id,show:!0,file:s.url,name:s.name})},children:e.jsx(j.Edit,{className:"h-4 w-4"})}),e.jsx(t.Button,{variant:"destructive",size:"icon",className:"h-8 w-8",onClick:i=>{i.stopPropagation(),G(s)},children:e.jsx(j.Trash2,{className:"h-4 w-4"})})]}),f.some(i=>i.id===s.id)&&e.jsx("div",{className:"absolute top-2 left-2",children:e.jsx("input",{type:"checkbox",checked:f.some(i=>i.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:re((s==null?void 0:s.size)||0)}),e.jsx("span",{children:oe(s.createdAt)})]})]})]})},s.id)),U&&N.length>0&&e.jsx("div",{className:"col-span-full flex justify-center py-4",children:e.jsx(j.Loader2,{className:"h-6 w-6 animate-spin text-muted-foreground"})})]})]}),e.jsx(t.TabsContent,{value:"upload",className:"flex-1 ",children:e.jsxs("div",{...O(),className:L.mergeClasses("border-2 border-dashed rounded-lg h-[380px] flex flex-col items-center justify-center text-center cursor-pointer hover:bg-gray-50",K?"border-primary bg-primary/5":"border-muted-foreground/20"),children:[e.jsx("input",{...R()}),x||z?e.jsxs("div",{className:"flex flex-col items-center",children:[e.jsx(j.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(j.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"]})]})]})]})})]})]}),w&&e.jsx(n.Suspense,{fallback:e.jsx("div",{children:"Loading..."}),children:e.jsx(le,{asset:w,onSave:s=>V(w,s),onCancel:()=>{y(null)}})}),g.show&&e.jsx(n.Suspense,{fallback:e.jsx("div",{children:"Loading..."}),children:e.jsx(ne,{imageUrl:g.file,onSave:W,onClose:()=>C({show:!1,file:""}),defaultSavedImageName:g.name,isEditing:!!g.id})}),u&&e.jsx(t.Dialog,{open:!!u,onOpenChange:()=>p(null),children:e.jsxs(t.DialogContent,{children:[e.jsxs(t.DialogHeader,{children:[e.jsx(t.DialogTitle,{children:"Delete Asset"}),e.jsxs(t.DialogDescription,{children:['Are you sure you want to delete "',u.name,'"? This action cannot be undone.']})]}),e.jsxs(t.DialogFooter,{className:"gap-2 sm:gap-0",children:[e.jsx(t.Button,{variant:"outline",onClick:()=>p(null),children:"Cancel"}),e.jsx(t.Button,{variant:"destructive",onClick:$,children:"Delete"})]})]})})]})}function re(l){return l<1024?`${l.toFixed(2)} B`:l<1024*1024?`${(l/1024).toFixed(2)} KB`:`${(l/(1024*1024)).toFixed(2)} MB`}function oe(l){const c=new Date(l);return new Intl.DateTimeFormat("en-US",{month:"short",day:"numeric",year:"numeric"}).format(c)}exports.default=ie;
@@ -2,13 +2,13 @@ import { jsxs as a, Fragment as Q, jsx as e } from "react/jsx-runtime";
2
2
  import X, { useState as w, useCallback as A, useMemo as oe, useRef as ce, Suspense as Y } from "react";
3
3
  import { mergeClasses as $ } from "@chaibuilder/sdk";
4
4
  import { Tabs as de, TabsList as ue, TabsTrigger as H, Button as f, TabsContent as V, Input as me, Card as he, CardContent as ge, Dialog as pe, DialogContent as fe, DialogHeader as ye, DialogTitle as ve, DialogDescription as xe, DialogFooter as Ne } from "@chaibuilder/sdk/ui";
5
- import { debounce as Ae, find as Se, merge as we } from "lodash-es";
6
- import { Search as be, Film as Ce, ImageIcon as Ee, Edit as Te, Trash2 as De, Loader2 as W, Upload as Pe } from "lucide-react";
7
- import { useDropzone as Ue } from "react-dropzone";
8
- import { useQueryClient as R, useMutation as K, useQuery as Fe } from "@tanstack/react-query";
5
+ import { debounce as Ae, find as Se, merge as we, pick as be } from "lodash-es";
6
+ import { Search as Ce, Film as Ee, ImageIcon as Te, Edit as De, Trash2 as Pe, Loader2 as W, Upload as Ue } from "lucide-react";
7
+ import { useDropzone as Fe } from "react-dropzone";
8
+ import { useQueryClient as R, useMutation as K, useQuery as ze } from "@tanstack/react-query";
9
9
  import { toast as b } from "sonner";
10
- import { W as F, X as z, Y as y, Z as k } from "./index-C657rWjb.js";
11
- const ze = () => {
10
+ import { W as F, X as z, Y as y, Z as k } from "./index-CpcOqKZB.js";
11
+ const ke = () => {
12
12
  const t = F(), r = R(), o = z();
13
13
  return K({
14
14
  mutationFn: async ({
@@ -28,7 +28,7 @@ const ze = () => {
28
28
  b.error("Failed to upload asset");
29
29
  }
30
30
  });
31
- }, ke = () => {
31
+ }, Me = () => {
32
32
  const t = F(), r = R(), o = z();
33
33
  return K({
34
34
  mutationFn: async (i) => o(t, {
@@ -44,7 +44,7 @@ const ze = () => {
44
44
  b.error("Failed to delete asset");
45
45
  }
46
46
  });
47
- }, Me = () => {
47
+ }, Ie = () => {
48
48
  const t = F(), r = R(), o = z();
49
49
  return K({
50
50
  mutationFn: async (i) => o(t, {
@@ -60,9 +60,9 @@ const ze = () => {
60
60
  b.error("Failed to update asset");
61
61
  }
62
62
  });
63
- }, Ie = (t = {}) => {
63
+ }, qe = (t = {}) => {
64
64
  const r = F(), o = z(), { search: i, page: d = 1, limit: u = 10 } = t;
65
- return Fe({
65
+ return ze({
66
66
  queryKey: [k, y.GET_ASSETS, i, d, u],
67
67
  queryFn: async () => await o(r, {
68
68
  action: y.GET_ASSETS,
@@ -75,16 +75,16 @@ const ze = () => {
75
75
  retry: 1
76
76
  });
77
77
  };
78
- function qe() {
78
+ function je() {
79
79
  const [r, o] = w([]), [i, d] = w({
80
80
  query: "",
81
81
  page: 1,
82
82
  pageSize: 10
83
- }), u = Ae(() => i.query, 300)(), { data: n, isLoading: C } = Ie({
83
+ }), u = Ae(() => i.query, 300)(), { data: n, isLoading: C } = qe({
84
84
  search: (u == null ? void 0 : u.toLowerCase().trim()) || "",
85
85
  page: i.page,
86
86
  limit: i.pageSize
87
- }), v = n ? Math.ceil(n.total / n.pageSize) : 0, c = (n == null ? void 0 : n.page) || 1, g = c < v, m = c > 1, { mutate: E, isPending: M } = Me(), { mutate: S, isPending: p } = ze(), { mutate: T, isPending: D } = ke(), x = A(
87
+ }), v = n ? Math.ceil(n.total / n.pageSize) : 0, c = (n == null ? void 0 : n.page) || 1, g = c < v, m = c > 1, { mutate: E, isPending: M } = Ie(), { mutate: S, isPending: p } = ke(), { mutate: T, isPending: D } = Me(), x = A(
88
88
  (h) => {
89
89
  h >= 1 && h <= v && d((N) => ({
90
90
  ...N,
@@ -137,8 +137,8 @@ function qe() {
137
137
  isDeletingAsset: D
138
138
  };
139
139
  }
140
- const je = X.lazy(() => import("./asset-metadata-editor-r5vYHUfm.js")), _e = X.lazy(() => import("./image-editor-CwVua57o.js"));
141
- function Xe({
140
+ const _e = X.lazy(() => import("./asset-metadata-editor-CyTBhS-V.js")), Le = X.lazy(() => import("./image-editor-By8RDHso.js"));
141
+ function Ze({
142
142
  close: t,
143
143
  onSelect: r,
144
144
  mode: o = "image"
@@ -160,7 +160,7 @@ function Xe({
160
160
  isUploadingAsset: _,
161
161
  isUpdatingAsset: h
162
162
  // isDeletingAsset,
163
- } = qe(), N = ce(null), G = A(
163
+ } = je(), N = ce(null), G = A(
164
164
  async (s) => new Promise((l, L) => {
165
165
  const O = s[0], U = new FileReader();
166
166
  U.readAsDataURL(O), U.onload = async () => {
@@ -180,7 +180,7 @@ function Xe({
180
180
  }, U.onerror = (B) => L(B);
181
181
  }),
182
182
  [T]
183
- ), { getRootProps: Z, getInputProps: J, isDragActive: ee } = Ue({
183
+ ), { getRootProps: Z, getInputProps: J, isDragActive: ee } = Fe({
184
184
  onDrop: G,
185
185
  accept: {
186
186
  "image/*": d.includes("image") ? [] : []
@@ -195,7 +195,7 @@ function Xe({
195
195
  }, le = (s) => {
196
196
  v(s);
197
197
  }, ie = async (s, l) => {
198
- await D(we(s, l)), t();
198
+ await D(we(s, be(l, ["id", "description"]))), t();
199
199
  }, ne = (s) => {
200
200
  I(s.target.value);
201
201
  }, re = async (s, l) => {
@@ -251,7 +251,7 @@ function Xe({
251
251
  ] }),
252
252
  /* @__PURE__ */ a(V, { value: "browse", className: "flex-1 flex flex-col", children: [
253
253
  /* @__PURE__ */ e("div", { className: "flex items-center gap-2 mb-2", children: /* @__PURE__ */ a("div", { className: "relative w-full", children: [
254
- /* @__PURE__ */ e(be, { className: "absolute left-2 top-2.5 h-4 w-4 text-muted-foreground" }),
254
+ /* @__PURE__ */ e(Ce, { className: "absolute left-2 top-2.5 h-4 w-4 text-muted-foreground" }),
255
255
  /* @__PURE__ */ e(
256
256
  me,
257
257
  {
@@ -303,7 +303,7 @@ function Xe({
303
303
  className: "object-cover w-full h-full min-h-[100px]"
304
304
  }
305
305
  ) : /* @__PURE__ */ a("div", { className: "flex items-center justify-center h-full", children: [
306
- /* @__PURE__ */ e(Ce, { className: "h-12 w-12 text-muted-foreground" }),
306
+ /* @__PURE__ */ e(Ee, { className: "h-12 w-12 text-muted-foreground" }),
307
307
  s.thumbnailUrl && /* @__PURE__ */ e(
308
308
  "img",
309
309
  {
@@ -323,7 +323,7 @@ function Xe({
323
323
  onClick: (l) => {
324
324
  l.stopPropagation(), le(s);
325
325
  },
326
- children: /* @__PURE__ */ e(Ee, { className: "h-4 w-4" })
326
+ children: /* @__PURE__ */ e(Te, { className: "h-4 w-4" })
327
327
  }
328
328
  ),
329
329
  /* @__PURE__ */ e(
@@ -340,7 +340,7 @@ function Xe({
340
340
  name: s.name
341
341
  });
342
342
  },
343
- children: /* @__PURE__ */ e(Te, { className: "h-4 w-4" })
343
+ children: /* @__PURE__ */ e(De, { className: "h-4 w-4" })
344
344
  }
345
345
  ),
346
346
  /* @__PURE__ */ e(
@@ -352,7 +352,7 @@ function Xe({
352
352
  onClick: (l) => {
353
353
  l.stopPropagation(), ae(s);
354
354
  },
355
- children: /* @__PURE__ */ e(De, { className: "h-4 w-4" })
355
+ children: /* @__PURE__ */ e(Pe, { className: "h-4 w-4" })
356
356
  }
357
357
  )
358
358
  ] }),
@@ -378,8 +378,8 @@ function Xe({
378
378
  }
379
379
  ),
380
380
  /* @__PURE__ */ a("div", { className: "text-xs text-muted-foreground flex items-center justify-between", children: [
381
- /* @__PURE__ */ e("span", { children: Le((s == null ? void 0 : s.size) || 0) }),
382
- /* @__PURE__ */ e("span", { children: Be(s.createdAt) })
381
+ /* @__PURE__ */ e("span", { children: Be((s == null ? void 0 : s.size) || 0) }),
382
+ /* @__PURE__ */ e("span", { children: Qe(s.createdAt) })
383
383
  ] })
384
384
  ] })
385
385
  ] })
@@ -406,7 +406,7 @@ function Xe({
406
406
  /* @__PURE__ */ e("h3", { className: "text-lg font-medium mb-1", children: "Uploading files..." }),
407
407
  /* @__PURE__ */ e("p", { className: "text-sm text-muted-foreground", children: "Please wait while your files are being processed." })
408
408
  ] }) : /* @__PURE__ */ a(Q, { children: [
409
- /* @__PURE__ */ e(Pe, { className: "h-12 w-12 text-muted-foreground mb-4" }),
409
+ /* @__PURE__ */ e(Ue, { className: "h-12 w-12 text-muted-foreground mb-4" }),
410
410
  /* @__PURE__ */ e("h3", { className: "text-lg font-medium mb-1", children: "Drag & drop files here" }),
411
411
  /* @__PURE__ */ e("p", { className: "text-sm text-muted-foreground mb-4", children: "or click to browse your files" }),
412
412
  /* @__PURE__ */ a("div", { className: "text-xs text-muted-foreground", children: [
@@ -429,7 +429,7 @@ function Xe({
429
429
  )
430
430
  ] }),
431
431
  C && /* @__PURE__ */ e(Y, { fallback: /* @__PURE__ */ e("div", { children: "Loading..." }), children: /* @__PURE__ */ e(
432
- je,
432
+ _e,
433
433
  {
434
434
  asset: C,
435
435
  onSave: (s) => ie(C, s),
@@ -439,7 +439,7 @@ function Xe({
439
439
  }
440
440
  ) }),
441
441
  m.show && /* @__PURE__ */ e(Y, { fallback: /* @__PURE__ */ e("div", { children: "Loading..." }), children: /* @__PURE__ */ e(
442
- _e,
442
+ Le,
443
443
  {
444
444
  imageUrl: m.file,
445
445
  onSave: re,
@@ -471,10 +471,10 @@ function Xe({
471
471
  )
472
472
  ] });
473
473
  }
474
- function Le(t) {
474
+ function Be(t) {
475
475
  return t < 1024 ? `${t.toFixed(2)} B` : t < 1024 * 1024 ? `${(t / 1024).toFixed(2)} KB` : `${(t / (1024 * 1024)).toFixed(2)} MB`;
476
476
  }
477
- function Be(t) {
477
+ function Qe(t) {
478
478
  const r = new Date(t);
479
479
  return new Intl.DateTimeFormat("en-US", {
480
480
  month: "short",
@@ -483,5 +483,5 @@ function Be(t) {
483
483
  }).format(r);
484
484
  }
485
485
  export {
486
- Xe as default
486
+ Ze as default
487
487
  };
@@ -1,32 +1,32 @@
1
- import { jsx as l } from "react/jsx-runtime";
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
- ({ imageUrl: n, onSave: d, onClose: i, defaultSavedImageName: g, isEditing: m = !1 }) => {
1
+ import { jsx as d } 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(
8
+ ({ imageUrl: n, onSave: i, onClose: l, defaultSavedImageName: g, isEditing: m = !1 }) => {
9
9
  const [b, c] = p(!0), [h, C] = p(!1);
10
- y(() => {
10
+ k(() => {
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
- () => O((e, o = !1) => {
17
+ () => S((e, o = !1) => {
18
18
  const t = e.imageBase64;
19
- d(t, o), c(!1);
19
+ i(t, o), c(!1);
20
20
  }, 300),
21
- [d]
21
+ [i]
22
22
  ), a = I(
23
23
  (e, o = !1) => {
24
24
  f(e, o);
25
25
  },
26
26
  [f]
27
27
  ), u = I(() => {
28
- c(!1), i();
29
- }, [i]), r = s(
28
+ c(!1), l();
29
+ }, [l]), r = s(
30
30
  () => ({
31
31
  tabsIds: [
32
32
  "Adjust",
@@ -56,25 +56,25 @@ const R = T(
56
56
  onClick: (e, o) => o((...t) => {
57
57
  a(t[0], !1);
58
58
  }),
59
- icon: k
59
+ icon: w
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: A
66
+ icon: E
67
67
  }
68
68
  ] : [],
69
69
  [m, a]
70
70
  );
71
- return /* @__PURE__ */ l(w, { open: !0, onOpenChange: (e) => !e && u(), children: /* @__PURE__ */ l(
72
- E,
71
+ return /* @__PURE__ */ d(T, { open: !0, onOpenChange: (e) => !e && u(), children: /* @__PURE__ */ d(
72
+ y,
73
73
  {
74
74
  id: "chai-image-editor-container",
75
75
  className: "flex-1 overflow-hidden p-4 min-w-[1280px]",
76
- children: b && h && /* @__PURE__ */ l(
77
- S,
76
+ children: b && h && /* @__PURE__ */ d(
77
+ A,
78
78
  {
79
79
  theme: v,
80
80
  source: n,
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("react/jsx-runtime"),t=require("react"),T=require("react-filerobot-image-editor"),I=require("@chaibuilder/sdk/ui"),y=require("lodash-es"),p=require("lucide-react"),b=t.memo(({imageUrl:n,onSave:r,onClose:d,defaultSavedImageName:g,isEditing:u=!1})=>{const[h,c]=t.useState(!0),[x,C]=t.useState(!1);t.useEffect(()=>{const e=new Image;return e.src=n,e.onload=()=>C(!0),()=>{e.onload=null}},[n]);const m=t.useMemo(()=>y.debounce((e,o=!1)=>{const a=e.imageBase64;r(a,o),c(!1)},300),[r]),s=t.useCallback((e,o=!1)=>{m(e,o)},[m]),f=t.useCallback(()=>{c(!1),d()},[d]),l=t.useMemo(()=>({tabsIds:["Adjust","Annotate","Watermark","Finetune","Resize","Filters"],defaultTabId:"Adjust",defaultToolId:"Crop"}),[]),v=t.useMemo(()=>({colors:{primary:"#000000",secondary:"#000000",tertiary:"#000000"}}),[]),S=t.useMemo(()=>u?[{label:"Update this file",onClick:(e,o)=>o((...a)=>{s(a[0],!1)}),icon:p.Save},{label:"Save as new file",onClick:(e,o)=>o((...a)=>{s(a[0],!0)}),icon:p.Copy}]:[],[u,s]);return i.jsx(I.Dialog,{open:!0,onOpenChange:e=>!e&&f(),children:i.jsx(I.DialogContent,{id:"chai-image-editor-container",className:"flex-1 overflow-hidden p-4 min-w-[1280px]",children:h&&x&&i.jsx(T,{theme:v,source:n,onSave:s,onClose:f,Text:{text:"Add text here"},Rotate:{angle:90,componentType:"slider"},tabsIds:l.tabsIds,defaultTabId:l.defaultTabId,defaultToolId:l.defaultToolId,savingPixelRatio:2,previewPixelRatio:1,defaultSavedImageName:g,moreSaveOptions:S,useZoomPresetsMenu:!0})})})});b.displayName="ImageEditor";exports.default=b;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("react/jsx-runtime"),I=require("@chaibuilder/sdk/ui"),T=require("lodash-es"),p=require("lucide-react"),t=require("react"),y=require("react-filerobot-image-editor"),b=t.memo(({imageUrl:n,onSave:d,onClose:r,defaultSavedImageName:g,isEditing:u=!1})=>{const[h,c]=t.useState(!0),[x,C]=t.useState(!1);t.useEffect(()=>{const e=new Image;return e.src=n,e.onload=()=>C(!0),()=>{e.onload=null}},[n]);const m=t.useMemo(()=>T.debounce((e,o=!1)=>{const a=e.imageBase64;d(a,o),c(!1)},300),[d]),s=t.useCallback((e,o=!1)=>{m(e,o)},[m]),f=t.useCallback(()=>{c(!1),r()},[r]),l=t.useMemo(()=>({tabsIds:["Adjust","Annotate","Watermark","Finetune","Resize","Filters"],defaultTabId:"Adjust",defaultToolId:"Crop"}),[]),v=t.useMemo(()=>({colors:{primary:"#000000",secondary:"#000000",tertiary:"#000000"}}),[]),S=t.useMemo(()=>u?[{label:"Update this file",onClick:(e,o)=>o((...a)=>{s(a[0],!1)}),icon:p.Save},{label:"Save as new file",onClick:(e,o)=>o((...a)=>{s(a[0],!0)}),icon:p.Copy}]:[],[u,s]);return i.jsx(I.Dialog,{open:!0,onOpenChange:e=>!e&&f(),children:i.jsx(I.DialogContent,{id:"chai-image-editor-container",className:"flex-1 overflow-hidden p-4 min-w-[1280px]",children:h&&x&&i.jsx(y,{theme:v,source:n,onSave:s,onClose:f,Text:{text:"Add text here"},Rotate:{angle:90,componentType:"slider"},tabsIds:l.tabsIds,defaultTabId:l.defaultTabId,defaultToolId:l.defaultToolId,savingPixelRatio:2,previewPixelRatio:1,defaultSavedImageName:g,moreSaveOptions:S,useZoomPresetsMenu:!0})})})});b.displayName="ImageEditor";exports.default=b;
@@ -7422,7 +7422,7 @@ var Ed = (e, t = !1) => {
7422
7422
  const t = oa(() => {
7423
7423
  const n = this, [s] = R(this, yt), [a] = R(this, vt), [i] = R(this, Et), [l] = R(this, bt), [o] = R(this, gt);
7424
7424
  let c;
7425
- return R(this, wt) ? c = R(this, wt) : (c = ia(() => import("./HO4MOOFI-BYHU8reo.js")), te(this, wt, c)), Ca(R(this, Yt), R(this, pt)), ra(c, aa({
7425
+ return R(this, wt) ? c = R(this, wt) : (c = ia(() => import("./HO4MOOFI-PgDfNOYI.js")), te(this, wt, c)), Ca(R(this, Yt), R(this, pt)), ra(c, aa({
7426
7426
  get queryFlavor() {
7427
7427
  return R(n, zt);
7428
7428
  },
@@ -7516,7 +7516,7 @@ var Ed = (e, t = !1) => {
7516
7516
  const t = oa(() => {
7517
7517
  const n = this, [s] = R(this, At), [a] = R(this, xt), [i] = R(this, Tt), [l] = R(this, Ct), [o] = R(this, St), [c] = R(this, Pt);
7518
7518
  let h;
7519
- return R(this, _t) ? h = R(this, _t) : (h = ia(() => import("./HUY7CZI3-Bu2JpU4v.js")), te(this, _t, h)), Ca(R(this, en), R(this, Nt)), ra(h, aa({
7519
+ return R(this, _t) ? h = R(this, _t) : (h = ia(() => import("./HUY7CZI3-BByK5e-X.js")), te(this, _t, h)), Ca(R(this, en), R(this, Nt)), ra(h, aa({
7520
7520
  get queryFlavor() {
7521
7521
  return R(n, Zt);
7522
7522
  },
@@ -7634,7 +7634,7 @@ var Iu = process.env.NODE_ENV !== "development" ? function() {
7634
7634
  } : Pu;
7635
7635
  process.env.NODE_ENV;
7636
7636
  const ku = Qa(
7637
- () => import("./digital-asset-manager-C8r5r7TV.js")
7637
+ () => import("./digital-asset-manager-DeLcDhkr.js")
7638
7638
  );
7639
7639
  ul();
7640
7640
  ec();