@chaibuilder/pages 0.4.5 → 0.4.6

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-Eeaqj2pE.cjs"),t=require("./index-BH25LDvP.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-CJ_zQjzE.cjs"),t=require("./index-Dhwd3gtU.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-BpF1oV0W.js";
2
- import { g as d, c as f, a as e } from "./index-xGrIPO1U.js";
1
+ import { c, T as l, P as m, a as u, D as v, Q as i } from "./B4MFY5CR-94OKrKm9.js";
2
+ import { g as d, c as f, a as e } from "./index-Dq_xGZ55.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-BpF1oV0W.js";
2
- import { g as v, c as C, a as e } from "./index-xGrIPO1U.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-94OKrKm9.js";
2
+ import { g as v, c as C, a as e } from "./index-Dq_xGZ55.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-Eeaqj2pE.cjs"),t=require("./index-BH25LDvP.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-CJ_zQjzE.cjs"),t=require("./index-Dhwd3gtU.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 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),r=require("react"),W=require("react-dropzone"),g=require("lucide-react"),i=require("@chaibuilder/sdk/ui"),z=require("lodash-es"),D=require("@chaibuilder/sdk"),x=require("@tanstack/react-query"),c=require("./index-BH25LDvP.cjs"),j=require("sonner"),X=(t={})=>{c.useApiUrl(),c.useFetch();const{search:n,page:o=1,limit:l=10}=t;return x.useQuery({queryKey:[c.ACTIONS.GET_ASSETS,{search:n,page:o,limit:l}],queryFn:async()=>{const u=localStorage.getItem("assets")||"[]";return JSON.parse(u)},retry:1})},Z=()=>{c.useApiUrl();const t=x.useQueryClient();return c.useFetch(),x.useMutation({mutationFn:async n=>{const o=localStorage.getItem("assets")||"[]";return localStorage.setItem("assets",JSON.stringify([...JSON.parse(o)||[],{id:Math.random().toString(36).substring(2,15),name:"123",url:n,createdAt:new Date().toISOString(),updatedAt:new Date().toISOString(),type:"image",size:Math.random()*1e3}])),!0},onSuccess:()=>{t.invalidateQueries({queryKey:[c.ACTIONS.GET_ASSETS]}),j.toast.success("Asset uploaded successfully")},onError:()=>{j.toast.error("Failed to upload asset")}})},$=()=>{c.useApiUrl();const t=x.useQueryClient();return c.useFetch(),x.useMutation({mutationFn:async n=>{const o=localStorage.getItem("assets")||"[]";return localStorage.setItem("assets",JSON.stringify((JSON.parse(o)||[]).filter(l=>l.id!==n))),!0},onSuccess:()=>{t.invalidateQueries({queryKey:[c.ACTIONS.GET_ASSETS]}),j.toast.success("Asset deleted successfully")},onError:()=>{j.toast.error("Failed to delete asset")}})},ee=()=>{c.useApiUrl();const t=x.useQueryClient();return c.useFetch(),x.useMutation({mutationFn:async n=>{const o=localStorage.getItem("assets")||"[]";return localStorage.setItem("assets",JSON.stringify((JSON.parse(o)||[]).map(l=>l.id===n.id?{...l,url:n.file}:l))),!0},onSuccess:()=>{t.invalidateQueries({queryKey:[c.ACTIONS.GET_ASSETS]}),j.toast.success("Asset updated successfully")},onError:()=>{j.toast.error("Failed to update asset")}})};function se(){const[n,o]=r.useState([]),[l,u]=r.useState({query:"",page:1,pageSize:10}),y=z.debounce(()=>l.query,300)(),{data:p,isLoading:v}=X({search:(y==null?void 0:y.toLowerCase().trim())||"",page:l.page,limit:l.pageSize}),{mutate:w,isPaused:h}=ee(),{mutate:S,isPending:E}=Z(),{mutate:f,isPending:m}=$(),N=r.useCallback(()=>{u(d=>({...d,page:d.page+1}))},[]),A=r.useCallback(d=>{u(b=>({...b,query:d}))},[]),F=r.useCallback(d=>{o(b=>z.find(b,{id:d.id})?[]:[d])},[!1]),C=r.useCallback(()=>{o([])},[]);return{query:(l==null?void 0:l.query)||"",selectedAssets:n,assets:p||[],uploadAsset:S,updateAsset:w,deleteAsset:f,loadMoreAssets:N,updateSearchQuery:A,clearSelectedAssets:C,updateSelectedAssets:F,isLoadingAssets:v,isUploadingAsset:E,isUpdatingAsset:h,isDeletingAsset:m}}const te=r.lazy(()=>Promise.resolve().then(()=>require("./asset-metadata-editor-YXDey62L.cjs"))),ae=r.lazy(()=>Promise.resolve().then(()=>require("./image-editor-D8wu5UNM.cjs")));function re({close:t,onSelect:n,mode:o="image"}){const u=r.useMemo(()=>[o],[o]),[y,p]=r.useState("browse"),[v,w]=r.useState(null),[h,S]=r.useState({show:!1,file:""}),{query:E,assets:f,selectedAssets:m,uploadAsset:N,updateAsset:A,deleteAsset:F,loadMoreAssets:C,updateSearchQuery:d,clearSelectedAssets:b,updateSelectedAssets:k,isLoadingAssets:T,isUploadingAsset:O,isUpdatingAsset:B}=se(),U=r.useRef(null);r.useEffect(()=>{const s=U.current;if(!s)return;const a=()=>{s.scrollHeight-s.scrollTop<=s.clientHeight*1.5&&!T&&C()};return s.addEventListener("scroll",a),()=>s.removeEventListener("scroll",a)},[T,C]);const P=r.useCallback(async s=>new Promise((a,M)=>{const Y=s[0],q=new FileReader;q.readAsDataURL(Y),q.onload=async()=>{const I=await N(q.result);p("browse"),a(I)},q.onerror=I=>M(I)}),[N]),{getRootProps:L,getInputProps:Q,isDragActive:R}=W.useDropzone({onDrop:P,accept:{"image/*":u.includes("image")?[]:[],"video/*":u.includes("video")?[]:[]},maxSize:10*1024*1024}),J=()=>{n([m[0].url]),t()},G=async s=>{await F(s.id)},K=s=>{w(s)},_=async(s,a)=>{await A(z.merge(s,a)),t()},H=s=>{d(s.target.value)},V=async(s,a)=>{try{a?await N(s):await A({id:h.id,file:s}),S({show:!1,file:""}),p("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(i.Tabs,{value:y,onValueChange:s=>p(s),className:"flex-1 flex flex-col h-full",children:[e.jsxs("div",{className:"flex justify-between items-center mb-2",children:[e.jsxs(i.TabsList,{children:[e.jsx(i.TabsTrigger,{value:"browse",children:"Browse Assets"}),e.jsx(i.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(i.Button,{variant:"outline",size:"sm",onClick:()=>b(),title:"Clear selection",children:"Clear"})}),e.jsx(i.Button,{size:"sm",onClick:J,disabled:m.length===0,children:"Select Asset"})]})]}),e.jsxs(i.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(g.Search,{className:"absolute left-2 top-2.5 h-4 w-4 text-muted-foreground"}),e.jsx(i.Input,{placeholder:"Search assets...",value:E,onChange:H,className:"pl-8"})]})}),T&&f.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"})]}):f.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(i.Button,{size:"lg",onClick:()=>p("upload"),children:"Upload Assets"})})]}):e.jsxs("div",{ref:U,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:[f.map(s=>e.jsx(i.Card,{className:D.mergeClasses("cursor-pointer overflow-hidden transition-all",m.some(a=>a.id===s.id)?"ring-2 ring-primary":"hover:ring-2 hover:ring-primary/20"),onClick:()=>k(s),children:e.jsxs(i.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(g.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(i.Button,{variant:"secondary",size:"icon",className:"h-8 w-8",onClick:a=>{a.stopPropagation(),K(s)},children:e.jsx(g.ImageIcon,{className:"h-4 w-4"})}),e.jsx(i.Button,{variant:"secondary",size:"icon",className:"h-8 w-8",onClick:a=>{a.stopPropagation(),S({id:s.id,show:!0,file:s.url,name:s.name})},children:e.jsx(g.Edit,{className:"h-4 w-4"})}),e.jsx(i.Button,{variant:"destructive",size:"icon",className:"h-8 w-8",onClick:a=>{a.stopPropagation(),G(s)},children:e.jsx(g.Trash2,{className:"h-4 w-4"})})]}),m.some(a=>a.id===s.id)&&e.jsx("div",{className:"absolute top-2 left-2",children:e.jsx("input",{type:"checkbox",checked:m.some(a=>a.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:ie(s.createdAt)})]})]})]})},s.id)),T&&f.length>0&&e.jsx("div",{className:"col-span-full flex justify-center py-4",children:e.jsx(g.Loader2,{className:"h-6 w-6 animate-spin text-muted-foreground"})})]})]}),e.jsx(i.TabsContent,{value:"upload",className:"flex-1 ",children:e.jsxs("div",{...L(),className:D.mergeClasses("border-2 border-dashed rounded-lg h-[380px] flex flex-col items-center justify-center text-center cursor-pointer hover:bg-gray-50",R?"border-primary bg-primary/5":"border-muted-foreground/20"),children:[e.jsx("input",{...Q()}),B||O?e.jsxs("div",{className:"flex flex-col items-center",children:[e.jsx(g.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(g.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: ",u.join(", ")]}),e.jsxs("p",{children:["Maximum file size: ",10,"MB"]})]})]})]})})]})]}),v&&e.jsx(r.Suspense,{fallback:e.jsx("div",{children:"Loading..."}),children:e.jsx(te,{asset:v,onSave:s=>_(v,s),onCancel:()=>{w(null)}})}),h.show&&e.jsx(r.Suspense,{fallback:e.jsx("div",{children:"Loading..."}),children:e.jsx(ae,{imageUrl:h.file,onSave:V,onClose:()=>S({show:!1,file:""}),defaultSavedImageName:h.name,isEditing:!!h.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 ie(t){const n=new Date(t);return new Intl.DateTimeFormat("en-US",{month:"short",day:"numeric",year:"numeric"}).format(n)}exports.default=re;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),r=require("react"),W=require("react-dropzone"),g=require("lucide-react"),i=require("@chaibuilder/sdk/ui"),z=require("lodash-es"),D=require("@chaibuilder/sdk"),x=require("@tanstack/react-query"),c=require("./index-Dhwd3gtU.cjs"),j=require("sonner"),X=(t={})=>{c.useApiUrl(),c.useFetch();const{search:n,page:o=1,limit:l=10}=t;return x.useQuery({queryKey:[c.ACTIONS.GET_ASSETS,{search:n,page:o,limit:l}],queryFn:async()=>{const u=localStorage.getItem("assets")||"[]";return JSON.parse(u)},retry:1})},Z=()=>{c.useApiUrl();const t=x.useQueryClient();return c.useFetch(),x.useMutation({mutationFn:async n=>{const o=localStorage.getItem("assets")||"[]";return localStorage.setItem("assets",JSON.stringify([...JSON.parse(o)||[],{id:Math.random().toString(36).substring(2,15),name:"123",url:n,createdAt:new Date().toISOString(),updatedAt:new Date().toISOString(),type:"image",size:Math.random()*1e3}])),!0},onSuccess:()=>{t.invalidateQueries({queryKey:[c.ACTIONS.GET_ASSETS]}),j.toast.success("Asset uploaded successfully")},onError:()=>{j.toast.error("Failed to upload asset")}})},$=()=>{c.useApiUrl();const t=x.useQueryClient();return c.useFetch(),x.useMutation({mutationFn:async n=>{const o=localStorage.getItem("assets")||"[]";return localStorage.setItem("assets",JSON.stringify((JSON.parse(o)||[]).filter(l=>l.id!==n))),!0},onSuccess:()=>{t.invalidateQueries({queryKey:[c.ACTIONS.GET_ASSETS]}),j.toast.success("Asset deleted successfully")},onError:()=>{j.toast.error("Failed to delete asset")}})},ee=()=>{c.useApiUrl();const t=x.useQueryClient();return c.useFetch(),x.useMutation({mutationFn:async n=>{const o=localStorage.getItem("assets")||"[]";return localStorage.setItem("assets",JSON.stringify((JSON.parse(o)||[]).map(l=>l.id===n.id?{...l,url:n.file}:l))),!0},onSuccess:()=>{t.invalidateQueries({queryKey:[c.ACTIONS.GET_ASSETS]}),j.toast.success("Asset updated successfully")},onError:()=>{j.toast.error("Failed to update asset")}})};function se(){const[n,o]=r.useState([]),[l,u]=r.useState({query:"",page:1,pageSize:10}),y=z.debounce(()=>l.query,300)(),{data:p,isLoading:v}=X({search:(y==null?void 0:y.toLowerCase().trim())||"",page:l.page,limit:l.pageSize}),{mutate:w,isPaused:h}=ee(),{mutate:S,isPending:E}=Z(),{mutate:f,isPending:m}=$(),N=r.useCallback(()=>{u(d=>({...d,page:d.page+1}))},[]),A=r.useCallback(d=>{u(b=>({...b,query:d}))},[]),F=r.useCallback(d=>{o(b=>z.find(b,{id:d.id})?[]:[d])},[!1]),C=r.useCallback(()=>{o([])},[]);return{query:(l==null?void 0:l.query)||"",selectedAssets:n,assets:p||[],uploadAsset:S,updateAsset:w,deleteAsset:f,loadMoreAssets:N,updateSearchQuery:A,clearSelectedAssets:C,updateSelectedAssets:F,isLoadingAssets:v,isUploadingAsset:E,isUpdatingAsset:h,isDeletingAsset:m}}const te=r.lazy(()=>Promise.resolve().then(()=>require("./asset-metadata-editor-YXDey62L.cjs"))),ae=r.lazy(()=>Promise.resolve().then(()=>require("./image-editor-D8wu5UNM.cjs")));function re({close:t,onSelect:n,mode:o="image"}){const u=r.useMemo(()=>[o],[o]),[y,p]=r.useState("browse"),[v,w]=r.useState(null),[h,S]=r.useState({show:!1,file:""}),{query:E,assets:f,selectedAssets:m,uploadAsset:N,updateAsset:A,deleteAsset:F,loadMoreAssets:C,updateSearchQuery:d,clearSelectedAssets:b,updateSelectedAssets:k,isLoadingAssets:T,isUploadingAsset:O,isUpdatingAsset:B}=se(),U=r.useRef(null);r.useEffect(()=>{const s=U.current;if(!s)return;const a=()=>{s.scrollHeight-s.scrollTop<=s.clientHeight*1.5&&!T&&C()};return s.addEventListener("scroll",a),()=>s.removeEventListener("scroll",a)},[T,C]);const P=r.useCallback(async s=>new Promise((a,M)=>{const Y=s[0],q=new FileReader;q.readAsDataURL(Y),q.onload=async()=>{const I=await N(q.result);p("browse"),a(I)},q.onerror=I=>M(I)}),[N]),{getRootProps:L,getInputProps:Q,isDragActive:R}=W.useDropzone({onDrop:P,accept:{"image/*":u.includes("image")?[]:[],"video/*":u.includes("video")?[]:[]},maxSize:10*1024*1024}),J=()=>{n([m[0].url]),t()},G=async s=>{await F(s.id)},K=s=>{w(s)},_=async(s,a)=>{await A(z.merge(s,a)),t()},H=s=>{d(s.target.value)},V=async(s,a)=>{try{a?await N(s):await A({id:h.id,file:s}),S({show:!1,file:""}),p("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(i.Tabs,{value:y,onValueChange:s=>p(s),className:"flex-1 flex flex-col h-full",children:[e.jsxs("div",{className:"flex justify-between items-center mb-2",children:[e.jsxs(i.TabsList,{children:[e.jsx(i.TabsTrigger,{value:"browse",children:"Browse Assets"}),e.jsx(i.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(i.Button,{variant:"outline",size:"sm",onClick:()=>b(),title:"Clear selection",children:"Clear"})}),e.jsx(i.Button,{size:"sm",onClick:J,disabled:m.length===0,children:"Select Asset"})]})]}),e.jsxs(i.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(g.Search,{className:"absolute left-2 top-2.5 h-4 w-4 text-muted-foreground"}),e.jsx(i.Input,{placeholder:"Search assets...",value:E,onChange:H,className:"pl-8"})]})}),T&&f.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"})]}):f.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(i.Button,{size:"lg",onClick:()=>p("upload"),children:"Upload Assets"})})]}):e.jsxs("div",{ref:U,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:[f.map(s=>e.jsx(i.Card,{className:D.mergeClasses("cursor-pointer overflow-hidden transition-all",m.some(a=>a.id===s.id)?"ring-2 ring-primary":"hover:ring-2 hover:ring-primary/20"),onClick:()=>k(s),children:e.jsxs(i.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(g.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(i.Button,{variant:"secondary",size:"icon",className:"h-8 w-8",onClick:a=>{a.stopPropagation(),K(s)},children:e.jsx(g.ImageIcon,{className:"h-4 w-4"})}),e.jsx(i.Button,{variant:"secondary",size:"icon",className:"h-8 w-8",onClick:a=>{a.stopPropagation(),S({id:s.id,show:!0,file:s.url,name:s.name})},children:e.jsx(g.Edit,{className:"h-4 w-4"})}),e.jsx(i.Button,{variant:"destructive",size:"icon",className:"h-8 w-8",onClick:a=>{a.stopPropagation(),G(s)},children:e.jsx(g.Trash2,{className:"h-4 w-4"})})]}),m.some(a=>a.id===s.id)&&e.jsx("div",{className:"absolute top-2 left-2",children:e.jsx("input",{type:"checkbox",checked:m.some(a=>a.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:ie(s.createdAt)})]})]})]})},s.id)),T&&f.length>0&&e.jsx("div",{className:"col-span-full flex justify-center py-4",children:e.jsx(g.Loader2,{className:"h-6 w-6 animate-spin text-muted-foreground"})})]})]}),e.jsx(i.TabsContent,{value:"upload",className:"flex-1 ",children:e.jsxs("div",{...L(),className:D.mergeClasses("border-2 border-dashed rounded-lg h-[380px] flex flex-col items-center justify-center text-center cursor-pointer hover:bg-gray-50",R?"border-primary bg-primary/5":"border-muted-foreground/20"),children:[e.jsx("input",{...Q()}),B||O?e.jsxs("div",{className:"flex flex-col items-center",children:[e.jsx(g.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(g.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: ",u.join(", ")]}),e.jsxs("p",{children:["Maximum file size: ",10,"MB"]})]})]})]})})]})]}),v&&e.jsx(r.Suspense,{fallback:e.jsx("div",{children:"Loading..."}),children:e.jsx(te,{asset:v,onSave:s=>_(v,s),onCancel:()=>{w(null)}})}),h.show&&e.jsx(r.Suspense,{fallback:e.jsx("div",{children:"Loading..."}),children:e.jsx(ae,{imageUrl:h.file,onSave:V,onClose:()=>S({show:!1,file:""}),defaultSavedImageName:h.name,isEditing:!!h.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 ie(t){const n=new Date(t);return new Intl.DateTimeFormat("en-US",{month:"short",day:"numeric",year:"numeric"}).format(n)}exports.default=re;
@@ -6,7 +6,7 @@ import { Tabs as pe, TabsList as fe, TabsTrigger as _, Button as h, TabsContent
6
6
  import { debounce as xe, find as Ne, merge as we } from "lodash-es";
7
7
  import { mergeClasses as R } from "@chaibuilder/sdk";
8
8
  import { useQuery as be, useQueryClient as j, useMutation as L } from "@tanstack/react-query";
9
- import { W as z, X as F, Y as M } from "./index-xGrIPO1U.js";
9
+ import { W as z, X as F, Y as M } from "./index-Dq_xGZ55.js";
10
10
  import { toast as p } from "sonner";
11
11
  const Ae = (a = {}) => {
12
12
  z(), F();