@chaibuilder/pages 0.4.6 → 0.4.7

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-Dq_xGZ55.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-CSVDtkP9.js";
5
5
  var _s = (e) => e != null, zs = (e) => e.filter(_s);
6
6
  function Rs(e) {
7
7
  return (...t) => {
@@ -1,5 +1,5 @@
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";
1
+ import { c, T as l, P as m, a as u, D as v, Q as i } from "./B4MFY5CR-B0gjiEA3.js";
2
+ import { g as d, c as f, a as e } from "./index-CSVDtkP9.js";
3
3
  var p = (a) => {
4
4
  const [r, t] = c({
5
5
  prefix: "TanstackQueryDevtools"
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./B4MFY5CR-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
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./B4MFY5CR-0MVmdo7C.cjs"),t=require("./index-Cv2dcnN-.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 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";
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-B0gjiEA3.js";
2
+ import { g as v, c as C, a as e } from "./index-CSVDtkP9.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-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
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./B4MFY5CR-0MVmdo7C.cjs"),t=require("./index-Cv2dcnN-.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;
@@ -0,0 +1,108 @@
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";
4
+ import { useState as n } from "react";
5
+ function E({
6
+ asset: e,
7
+ onSave: l,
8
+ onCancel: o
9
+ }) {
10
+ const [c, f] = n(e.description || ""), [d, m] = n(!1), [v, s] = n(!1), x = async () => {
11
+ m(!0);
12
+ try {
13
+ await l({
14
+ description: c || void 0
15
+ });
16
+ } finally {
17
+ m(!1);
18
+ }
19
+ };
20
+ return /* @__PURE__ */ i(w, { children: [
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" }) }),
23
+ /* @__PURE__ */ i("div", { className: "flex gap-4", children: [
24
+ /* @__PURE__ */ i("div", { className: "relative group", children: [
25
+ /* @__PURE__ */ a(
26
+ "img",
27
+ {
28
+ src: e.url,
29
+ className: "max-h-96 w-96 border rounded-md p-2"
30
+ }
31
+ ),
32
+ /* @__PURE__ */ a(
33
+ "button",
34
+ {
35
+ onClick: () => s(!0),
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" })
38
+ }
39
+ )
40
+ ] }),
41
+ /* @__PURE__ */ i("div", { className: "grid gap-3 w-full", children: [
42
+ /* @__PURE__ */ a(r, { htmlFor: "description", children: "Details" }),
43
+ /* @__PURE__ */ a("div", { className: "grid grid-cols-1 gap-2 text-sm border rounded-md p-2", children: [
44
+ { label: "File Name", value: e.name },
45
+ { label: "Type", value: e.type },
46
+ { label: "Format", value: e.format },
47
+ { label: "Size", value: S(e.size) },
48
+ {
49
+ label: "Dimensions",
50
+ value: `${e.width} × ${e.height}`
51
+ },
52
+ { label: "Created", value: g(e.createdAt) },
53
+ {
54
+ label: "Updated",
55
+ value: g((e == null ? void 0 : e.updatedAt) || "")
56
+ }
57
+ ].map((t) => /* @__PURE__ */ i("div", { className: "flex items-center gap-2", children: [
58
+ /* @__PURE__ */ a(r, { className: "w-max text-left px-2 w-1/4 font-normal text-gray-700", children: t.label }),
59
+ ":",
60
+ /* @__PURE__ */ a("div", { className: "w-max text-left font-medium text-gray-900 capitalize", children: t.value })
61
+ ] })) }),
62
+ /* @__PURE__ */ i("div", { className: "grid gap-2", children: [
63
+ /* @__PURE__ */ a(r, { htmlFor: "description", children: "Description" }),
64
+ /* @__PURE__ */ a(
65
+ y,
66
+ {
67
+ id: "description",
68
+ value: c,
69
+ placeholder: "Enter a description for the asset",
70
+ onChange: (t) => f(t.target.value),
71
+ rows: 3
72
+ }
73
+ )
74
+ ] })
75
+ ] })
76
+ ] }),
77
+ /* @__PURE__ */ i(D, { children: [
78
+ /* @__PURE__ */ a(p, { variant: "outline", onClick: o, children: "Cancel" }),
79
+ /* @__PURE__ */ a(p, { onClick: x, disabled: d, children: d ? "Saving..." : "Save Changes" })
80
+ ] })
81
+ ] }) }),
82
+ /* @__PURE__ */ a(u, { open: v, onOpenChange: s, children: /* @__PURE__ */ a(h, { className: "w-[60vw] h-[60vh] p-0 flex items-center justify-center bg-gray-100", children: /* @__PURE__ */ a(
83
+ "img",
84
+ {
85
+ src: e.url,
86
+ className: "w-full h-full object-contain",
87
+ alt: e.name
88
+ }
89
+ ) }) })
90
+ ] });
91
+ }
92
+ function S(e) {
93
+ return e < 1024 ? `${e.toFixed(2)} KB` : `${(e / 1024).toFixed(2)} MB`;
94
+ }
95
+ function g(e) {
96
+ if (!e) return "N/A";
97
+ const l = new Date(e);
98
+ return new Intl.DateTimeFormat("en-US", {
99
+ month: "short",
100
+ day: "numeric",
101
+ year: "numeric",
102
+ hour: "2-digit",
103
+ minute: "2-digit"
104
+ }).format(l);
105
+ }
106
+ export {
107
+ E as default
108
+ };
@@ -0,0 +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;
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),a=require("react"),Q=require("@chaibuilder/sdk"),t=require("@chaibuilder/sdk/ui"),B=require("lodash-es"),j=require("lucide-react"),X=require("react-dropzone"),A=require("@tanstack/react-query"),b=require("sonner"),i=require("./index-Cv2dcnN-.cjs"),Z=()=>{const l=i.useAssetsApiUrl(),c=A.useQueryClient(),d=i.useFetch();return A.useMutation({mutationFn:async({file:r,folderId:m,name:h})=>d(l,{action:i.ACTIONS.UPLOAD_ASSET,data:{file:r,folderId:m,name:h}}),onSuccess:()=>{c.invalidateQueries({queryKey:[i.ACTIONS.GET_ASSETS]}),b.toast.success("Asset uploaded successfully")},onError:()=>{b.toast.error("Failed to upload asset")}})},ee=()=>{const l=i.useAssetsApiUrl(),c=A.useQueryClient(),d=i.useFetch();return A.useMutation({mutationFn:async r=>d(l,{action:i.ACTIONS.DELETE_ASSET,data:{id:r}}),onSuccess:()=>{c.invalidateQueries({queryKey:[i.ACTIONS.GET_ASSETS]}),b.toast.success("Asset deleted successfully")},onError:()=>{b.toast.error("Failed to delete asset")}})},se=()=>{const l=i.useAssetsApiUrl(),c=A.useQueryClient(),d=i.useFetch();return A.useMutation({mutationFn:async r=>d(l,{action:i.ACTIONS.UPDATE_ASSET,data:r}),onSuccess:()=>{c.invalidateQueries({queryKey:[i.ACTIONS.GET_ASSETS]}),b.toast.success("Asset updated successfully")},onError:()=>{b.toast.error("Failed to update asset")}})},te=(l={})=>{const c=i.useAssetsApiUrl(),d=i.useFetch(),{search:r,page:m=1,limit:h=10}=l;return A.useQuery({queryKey:[i.QUERY_KEY_BASE,i.ACTIONS.GET_ASSETS,r,m,h],queryFn:async()=>(await d(c,{action:i.ACTIONS.GET_ASSETS,data:{search:r,page:m,limit:h}})).data,retry:1})};function ae(){const[c,d]=a.useState([]),[r,m]=a.useState({query:"",page:1,pageSize:10}),h=B.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:T,isPending:E}=ee(),v=a.useCallback(x=>{x>=1&&x<=y&&m(S=>({...S,page:x}))},[y]),U=a.useCallback(()=>{p&&v(u+1)},[u,p,v]),F=a.useCallback(()=>{g&&v(u-1)},[u,g,v]),I=a.useCallback(x=>{m(S=>({...S,query:x,page:1}))},[]),D=a.useCallback(x=>{d(S=>B.find(S,{id:x.id})?[]:[x])},[!1]),k=a.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:T,goToPage:v,nextPage:U,previousPage:F,updateSearchQuery:I,clearSelectedAssets:k,updateSelectedAssets:D,isLoadingAssets:w,isUploadingAsset:f,isUpdatingAsset:q,isDeletingAsset:E}}const le=a.lazy(()=>Promise.resolve().then(()=>require("./asset-metadata-editor-zw9u1BB9.cjs"))),ne=a.lazy(()=>Promise.resolve().then(()=>require("./image-editor-D8wu5UNM.cjs")));function ie({close:l,onSelect:c,mode:d="image"}){const m=a.useMemo(()=>[d],[d]),[h,o]=a.useState("browse"),[w,y]=a.useState(null),[u,p]=a.useState(null),[g,C]=a.useState({show:!1,file:""}),{query:q,assets:N,selectedAssets:f,uploadAsset:T,updateAsset:E,deleteAsset:v,updateSearchQuery:U,clearSelectedAssets:F,updateSelectedAssets:I,isLoadingAssets:D,isUploadingAsset:k,isUpdatingAsset:x}=ae(),S=a.useRef(null),L=a.useCallback(async s=>new Promise((n,z)=>{const O=s[0],P=new FileReader;P.readAsDataURL(O),P.onload=async()=>{const M=await T({file:P.result,folderId:null,name:O.name});o("browse"),n(M)},P.onerror=M=>z(M)}),[T]),{getRootProps:_,getInputProps:R,isDragActive:K}=X.useDropzone({onDrop:L,accept:{"image/*":m.includes("image")?[]:[],"video/*":m.includes("video")?[]:[]},maxSize:10*1024*1024}),G=()=>{c([f[0].url]),l()},Y=async s=>{p(s)},$=async()=>{u&&(await v(u.id),p(null))},H=s=>{y(s)},V=async(s,n)=>{await E(B.merge(s,n)),l()},J=s=>{U(s.target.value)},W=async(s,n)=>{try{n?await T({file:s,folderId:null,name:g.name||""}):await E({id:g.id||"",file:s}),C({show:!1,file:""}),o("browse")}catch(z){console.error("Error saving edited image:",z)}};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:()=>F(),title:"Clear selection",children:"Clear"})}),e.jsx(t.Button,{size:"sm",onClick:G,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"})]})}),D&&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 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(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:Q.mergeClasses("cursor-pointer overflow-hidden transition-all",f.some(n=>n.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"}):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:n=>{n.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:n=>{n.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:n=>{n.stopPropagation(),Y(s)},children:e.jsx(j.Trash2,{className:"h-4 w-4"})})]}),f.some(n=>n.id===s.id)&&e.jsx("div",{className:"absolute top-2 left-2",children:e.jsx("input",{type:"checkbox",checked:f.some(n=>n.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&&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",{..._(),className:Q.mergeClasses("border-2 border-dashed rounded-lg h-[380px] flex flex-col items-center justify-center text-center cursor-pointer hover:bg-gray-50",K?"border-primary bg-primary/5":"border-muted-foreground/20"),children:[e.jsx("input",{...R()}),x||k?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(a.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(a.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)} KB`:`${(l/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;