@chaibuilder/pages 0.4.8-beta.7 → 0.4.9-beta.1

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 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./B4MFY5CR-CZIhZc_v.cjs"),t=require("./index-D6MzyrPC.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-DQuqriTv.cjs"),t=require("./index-BwLbexF2.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-C-y1qMcz.js";
2
- import { g as d, c as f, a as e } from "./index-B9yYtFHS.js";
1
+ import { c, T as l, P as m, a as u, D as v, Q as i } from "./B4MFY5CR-CPM2Nh-Q.js";
2
+ import { g as d, c as f, a as e } from "./index-BCGeOsps.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-C-y1qMcz.js";
2
- import { g as v, c as C, a as e } from "./index-B9yYtFHS.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-CPM2Nh-Q.js";
2
+ import { g as v, c as C, a as e } from "./index-BCGeOsps.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-CZIhZc_v.cjs"),t=require("./index-D6MzyrPC.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-DQuqriTv.cjs"),t=require("./index-BwLbexF2.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;
@@ -7,7 +7,7 @@ import { Search as Ee, Film as Te, ImageIcon as De, Edit as Pe, Trash2 as Ue, Lo
7
7
  import { useDropzone as ze } from "react-dropzone";
8
8
  import { useQueryClient as K, useMutation as G, useQuery as ke } 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-B9yYtFHS.js";
10
+ import { W as F, X as z, Y as y, Z as k } from "./index-BCGeOsps.js";
11
11
  const Me = () => {
12
12
  const a = F(), r = K(), o = z();
13
13
  return G({
@@ -1 +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"),y=require("lodash-es"),j=require("lucide-react"),X=require("react-dropzone"),N=require("@tanstack/react-query"),w=require("sonner"),a=require("./index-D6MzyrPC.cjs"),Z=()=>{const l=a.useAssetsApiUrl(),c=N.useQueryClient(),d=a.useFetch();return N.useMutation({mutationFn:async({file:r,folderId:h,name:g})=>d(l,{action:a.ACTIONS.UPLOAD_ASSET,data:{file:r,folderId:h,name:g}}),onSuccess:()=>{c.invalidateQueries({queryKey:[a.QUERY_KEY_BASE,a.ACTIONS.GET_ASSETS]}),w.toast.success("Asset uploaded successfully")},onError:()=>{w.toast.error("Failed to upload asset")}})},ee=()=>{const l=a.useAssetsApiUrl(),c=N.useQueryClient(),d=a.useFetch();return N.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]}),w.toast.success("Asset deleted successfully")},onError:()=>{w.toast.error("Failed to delete asset")}})},se=()=>{const l=a.useAssetsApiUrl(),c=N.useQueryClient(),d=a.useFetch();return N.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]}),w.toast.success("Asset updated successfully")},onError:()=>{w.toast.error("Failed to update asset")}})},te=(l={})=>{const c=a.useAssetsApiUrl(),d=a.useFetch(),{search:r,page:h=1,limit:g=10}=l;return N.useQuery({queryKey:[a.QUERY_KEY_BASE,a.ACTIONS.GET_ASSETS,r,h,g],queryFn:async()=>await d(c,{action:a.ACTIONS.GET_ASSETS,data:{search:r,page:h,limit:g}}),retry:1})};function ae(){const[c,d]=n.useState([]),[r,h]=n.useState({query:"",page:1,pageSize:10}),g=y.debounce(()=>r.query,300)(),{data:o,isLoading:C}=te({search:(g==null?void 0:g.toLowerCase().trim())||"",page:r.page,limit:r.pageSize}),v=o?Math.ceil(o.total/o.pageSize):0,u=(o==null?void 0:o.page)||1,f=u<v,x=u>1,{mutate:E,isPending:k}=se(),{mutate:b,isPending:m}=Z(),{mutate:T,isPending:U}=ee(),S=n.useCallback(p=>{p>=1&&p<=v&&h(A=>({...A,page:p}))},[v]),q=n.useCallback(()=>{f&&S(u+1)},[u,f,S]),F=n.useCallback(()=>{x&&S(u-1)},[u,x,S]),I=n.useCallback(p=>{h(A=>({...A,query:p,page:1}))},[]),D=n.useCallback(p=>{d(A=>y.find(A,{id:p.id})?[]:[p])},[!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:v,hasNextPage:f,hasPreviousPage:x,uploadAsset:b,updateAsset:E,deleteAsset:T,goToPage:S,nextPage:q,previousPage:F,updateSearchQuery:I,clearSelectedAssets:z,updateSelectedAssets:D,isLoadingAssets:C,isUploadingAsset:m,isUpdatingAsset:k,isDeletingAsset:U}}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 h=n.useMemo(()=>[d],[d]),[g,o]=n.useState("browse"),[C,v]=n.useState(null),[u,f]=n.useState(null),[x,E]=n.useState({show:!1,file:""}),{query:k,assets:b,selectedAssets:m,uploadAsset:T,updateAsset:U,deleteAsset:S,updateSearchQuery:q,clearSelectedAssets:F,updateSelectedAssets:I,isLoadingAssets:D,isUploadingAsset:z,isUpdatingAsset:p}=ae(),A=n.useRef(null),_=n.useCallback(async s=>new Promise((i,M)=>{const Q=s[0],P=new FileReader;P.readAsDataURL(Q),P.onload=async()=>{const B=await T({file:P.result,folderId:null,name:Q.name},{onSuccess:()=>{o("browse")}});i(B)},P.onerror=B=>M(B)}),[T]),{getRootProps:O,getInputProps:R,isDragActive:K}=X.useDropzone({onDrop:_,accept:{"image/*":h.includes("image")?[]:[]},maxSize:10*1024*1024}),Y=()=>{console.log("selectedAssets",m,y.pick(y.first(m),["url","width","height","description"])),m.length!==0&&(c(y.pick(y.first(m),["url","width","height","description"])),l())},G=async s=>{f(s)},$=async()=>{u&&(await S(u.id),f(null))},H=s=>{v(s)},V=async(s,i)=>{await U(y.merge(s,y.pick(i,["id","description"]))),l()},J=s=>{q(s.target.value)},W=async(s,i)=>{try{i?await T({file:s,folderId:null,name:x.name||""}):await U({id:x.id||"",file:s}),E({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:g,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:[m.length>0&&e.jsx(e.Fragment,{children:e.jsx(t.Button,{variant:"outline",size:"sm",onClick:()=>F(),title:"Clear selection",children:"Clear"})}),e.jsx(t.Button,{size:"sm",onClick:Y,disabled:m.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:k,onChange:J,className:"pl-8"})]})}),D&&b.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"})]}):b.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:A,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:[b.map(s=>e.jsx(t.Card,{className:L.mergeClasses("cursor-pointer overflow-hidden transition-all",m.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(),E({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"})})]}),m.some(i=>i.id===s.id)&&e.jsx("div",{className:"absolute top-2 left-2",children:e.jsx("input",{type:"checkbox",checked:m.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)),D&&b.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()}),p||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: ",h.join(", ")]}),e.jsxs("p",{children:["Maximum file size: ",10,"MB"]})]})]})]})})]})]}),C&&e.jsx(n.Suspense,{fallback:e.jsx("div",{children:"Loading..."}),children:e.jsx(le,{asset:C,onSave:s=>V(C,s),onCancel:()=>{v(null)}})}),x.show&&e.jsx(n.Suspense,{fallback:e.jsx("div",{children:"Loading..."}),children:e.jsx(ne,{imageUrl:x.file,onSave:W,onClose:()=>E({show:!1,file:""}),defaultSavedImageName:x.name,isEditing:!!x.id})}),u&&e.jsx(t.Dialog,{open:!!u,onOpenChange:()=>f(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:()=>f(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;
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"),y=require("lodash-es"),j=require("lucide-react"),X=require("react-dropzone"),N=require("@tanstack/react-query"),w=require("sonner"),a=require("./index-BwLbexF2.cjs"),Z=()=>{const l=a.useAssetsApiUrl(),c=N.useQueryClient(),d=a.useFetch();return N.useMutation({mutationFn:async({file:r,folderId:h,name:g})=>d(l,{action:a.ACTIONS.UPLOAD_ASSET,data:{file:r,folderId:h,name:g}}),onSuccess:()=>{c.invalidateQueries({queryKey:[a.QUERY_KEY_BASE,a.ACTIONS.GET_ASSETS]}),w.toast.success("Asset uploaded successfully")},onError:()=>{w.toast.error("Failed to upload asset")}})},ee=()=>{const l=a.useAssetsApiUrl(),c=N.useQueryClient(),d=a.useFetch();return N.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]}),w.toast.success("Asset deleted successfully")},onError:()=>{w.toast.error("Failed to delete asset")}})},se=()=>{const l=a.useAssetsApiUrl(),c=N.useQueryClient(),d=a.useFetch();return N.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]}),w.toast.success("Asset updated successfully")},onError:()=>{w.toast.error("Failed to update asset")}})},te=(l={})=>{const c=a.useAssetsApiUrl(),d=a.useFetch(),{search:r,page:h=1,limit:g=10}=l;return N.useQuery({queryKey:[a.QUERY_KEY_BASE,a.ACTIONS.GET_ASSETS,r,h,g],queryFn:async()=>await d(c,{action:a.ACTIONS.GET_ASSETS,data:{search:r,page:h,limit:g}}),retry:1})};function ae(){const[c,d]=n.useState([]),[r,h]=n.useState({query:"",page:1,pageSize:10}),g=y.debounce(()=>r.query,300)(),{data:o,isLoading:C}=te({search:(g==null?void 0:g.toLowerCase().trim())||"",page:r.page,limit:r.pageSize}),v=o?Math.ceil(o.total/o.pageSize):0,u=(o==null?void 0:o.page)||1,f=u<v,x=u>1,{mutate:E,isPending:k}=se(),{mutate:b,isPending:m}=Z(),{mutate:T,isPending:U}=ee(),S=n.useCallback(p=>{p>=1&&p<=v&&h(A=>({...A,page:p}))},[v]),q=n.useCallback(()=>{f&&S(u+1)},[u,f,S]),F=n.useCallback(()=>{x&&S(u-1)},[u,x,S]),I=n.useCallback(p=>{h(A=>({...A,query:p,page:1}))},[]),D=n.useCallback(p=>{d(A=>y.find(A,{id:p.id})?[]:[p])},[!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:v,hasNextPage:f,hasPreviousPage:x,uploadAsset:b,updateAsset:E,deleteAsset:T,goToPage:S,nextPage:q,previousPage:F,updateSearchQuery:I,clearSelectedAssets:z,updateSelectedAssets:D,isLoadingAssets:C,isUploadingAsset:m,isUpdatingAsset:k,isDeletingAsset:U}}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 h=n.useMemo(()=>[d],[d]),[g,o]=n.useState("browse"),[C,v]=n.useState(null),[u,f]=n.useState(null),[x,E]=n.useState({show:!1,file:""}),{query:k,assets:b,selectedAssets:m,uploadAsset:T,updateAsset:U,deleteAsset:S,updateSearchQuery:q,clearSelectedAssets:F,updateSelectedAssets:I,isLoadingAssets:D,isUploadingAsset:z,isUpdatingAsset:p}=ae(),A=n.useRef(null),_=n.useCallback(async s=>new Promise((i,M)=>{const Q=s[0],P=new FileReader;P.readAsDataURL(Q),P.onload=async()=>{const B=await T({file:P.result,folderId:null,name:Q.name},{onSuccess:()=>{o("browse")}});i(B)},P.onerror=B=>M(B)}),[T]),{getRootProps:O,getInputProps:R,isDragActive:K}=X.useDropzone({onDrop:_,accept:{"image/*":h.includes("image")?[]:[]},maxSize:10*1024*1024}),Y=()=>{console.log("selectedAssets",m,y.pick(y.first(m),["url","width","height","description"])),m.length!==0&&(c(y.pick(y.first(m),["url","width","height","description"])),l())},G=async s=>{f(s)},$=async()=>{u&&(await S(u.id),f(null))},H=s=>{v(s)},V=async(s,i)=>{await U(y.merge(s,y.pick(i,["id","description"]))),l()},J=s=>{q(s.target.value)},W=async(s,i)=>{try{i?await T({file:s,folderId:null,name:x.name||""}):await U({id:x.id||"",file:s}),E({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:g,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:[m.length>0&&e.jsx(e.Fragment,{children:e.jsx(t.Button,{variant:"outline",size:"sm",onClick:()=>F(),title:"Clear selection",children:"Clear"})}),e.jsx(t.Button,{size:"sm",onClick:Y,disabled:m.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:k,onChange:J,className:"pl-8"})]})}),D&&b.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"})]}):b.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:A,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:[b.map(s=>e.jsx(t.Card,{className:L.mergeClasses("cursor-pointer overflow-hidden transition-all",m.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(),E({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"})})]}),m.some(i=>i.id===s.id)&&e.jsx("div",{className:"absolute top-2 left-2",children:e.jsx("input",{type:"checkbox",checked:m.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)),D&&b.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()}),p||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: ",h.join(", ")]}),e.jsxs("p",{children:["Maximum file size: ",10,"MB"]})]})]})]})})]})]}),C&&e.jsx(n.Suspense,{fallback:e.jsx("div",{children:"Loading..."}),children:e.jsx(le,{asset:C,onSave:s=>V(C,s),onCancel:()=>{v(null)}})}),x.show&&e.jsx(n.Suspense,{fallback:e.jsx("div",{children:"Loading..."}),children:e.jsx(ne,{imageUrl:x.file,onSave:W,onClose:()=>E({show:!1,file:""}),defaultSavedImageName:x.name,isEditing:!!x.id})}),u&&e.jsx(t.Dialog,{open:!!u,onOpenChange:()=>f(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:()=>f(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;
@@ -252,23 +252,7 @@ const qe = {
252
252
  DELETE_ASSET: "DELETE_ASSET",
253
253
  UPDATE_ASSET: "UPDATE_ASSET",
254
254
  GET_ASSETS: "GET_ASSETS"
255
- }, V = "chaibuilder", Es = async (e, t, n = {}) => await fetch(e, {
256
- method: "POST",
257
- headers: {
258
- "Content-Type": "application/json",
259
- ...n
260
- },
261
- body: JSON.stringify(t)
262
- });
263
- if (import.meta.vitest) {
264
- const { it: e, expect: t } = import.meta.vitest;
265
- e("should fetch API", async () => {
266
- const n = await Es("/v1/api/chai", {
267
- action: "test"
268
- });
269
- t(n).toBeDefined();
270
- });
271
- }
255
+ }, V = "chaibuilder";
272
256
  let dl = 0;
273
257
  function Ms(e, t) {
274
258
  const n = `atom${++dl}`, s = {
@@ -410,7 +394,24 @@ const El = vl("__chai_user", null), st = () => {
410
394
  retry: !1,
411
395
  enabled: !1
412
396
  });
413
- }, Wu = () => {
397
+ }, Es = async (e, t, n = {}) => await fetch(e, {
398
+ method: "POST",
399
+ headers: {
400
+ "Content-Type": "application/json",
401
+ ...n
402
+ },
403
+ body: JSON.stringify(t)
404
+ });
405
+ if (import.meta.vitest) {
406
+ const { it: e, expect: t } = import.meta.vitest;
407
+ e("should fetch API", async () => {
408
+ const n = await Es("/v1/api/chai", {
409
+ action: "test"
410
+ });
411
+ t(n).toBeDefined();
412
+ });
413
+ }
414
+ const Wu = () => {
414
415
  const { user: e } = st(), t = rt("onSessionExpired"), n = Y(
415
416
  () => e == null ? void 0 : e.accessToken,
416
417
  [e == null ? void 0 : e.accessToken]
@@ -7422,7 +7423,7 @@ var Ed = (e, t = !1) => {
7422
7423
  const t = oa(() => {
7423
7424
  const n = this, [s] = R(this, yt), [a] = R(this, vt), [i] = R(this, Et), [l] = R(this, bt), [o] = R(this, gt);
7424
7425
  let c;
7425
- return R(this, wt) ? c = R(this, wt) : (c = ia(() => import("./HO4MOOFI-D1WZ0Hg3.js")), te(this, wt, c)), Ca(R(this, Yt), R(this, pt)), ra(c, aa({
7426
+ return R(this, wt) ? c = R(this, wt) : (c = ia(() => import("./HO4MOOFI-C4C1eu_i.js")), te(this, wt, c)), Ca(R(this, Yt), R(this, pt)), ra(c, aa({
7426
7427
  get queryFlavor() {
7427
7428
  return R(n, zt);
7428
7429
  },
@@ -7516,7 +7517,7 @@ var Ed = (e, t = !1) => {
7516
7517
  const t = oa(() => {
7517
7518
  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
7519
  let h;
7519
- return R(this, _t) ? h = R(this, _t) : (h = ia(() => import("./HUY7CZI3-DABOTt0o.js")), te(this, _t, h)), Ca(R(this, en), R(this, Nt)), ra(h, aa({
7520
+ return R(this, _t) ? h = R(this, _t) : (h = ia(() => import("./HUY7CZI3-D0DMRo6d.js")), te(this, _t, h)), Ca(R(this, en), R(this, Nt)), ra(h, aa({
7520
7521
  get queryFlavor() {
7521
7522
  return R(n, Zt);
7522
7523
  },
@@ -7634,7 +7635,7 @@ var Iu = process.env.NODE_ENV !== "development" ? function() {
7634
7635
  } : Pu;
7635
7636
  process.env.NODE_ENV;
7636
7637
  const ku = Qa(
7637
- () => import("./digital-asset-manager-ty2MhSyj.js")
7638
+ () => import("./digital-asset-manager-B9r4C600.js")
7638
7639
  );
7639
7640
  ul();
7640
7641
  ec();
@@ -7794,9 +7795,10 @@ export {
7794
7795
  cn as a3,
7795
7796
  Rn as a4,
7796
7797
  un as a5,
7797
- Ho as a6,
7798
- Wu as a7,
7799
- dn as a8,
7798
+ st as a6,
7799
+ Ho as a7,
7800
+ Wu as a8,
7801
+ dn as a9,
7800
7802
  Ee as b,
7801
7803
  Ge as c,
7802
7804
  Dc as d,