@chaibuilder/pages 0.4.16 → 0.4.18
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.
- package/dist/{B4MFY5CR-BG0CJbRg.js → B4MFY5CR-C7PbvQZA.js} +1 -1
- package/dist/{B4MFY5CR-BFhuj7MO.cjs → B4MFY5CR-D-RGlI6C.cjs} +1 -1
- package/dist/{HO4MOOFI-BKZ0rHoD.cjs → HO4MOOFI-BE7IxSw6.cjs} +1 -1
- package/dist/{HO4MOOFI-Ds8uNsOs.js → HO4MOOFI-B_GoCYM2.js} +2 -2
- package/dist/{HUY7CZI3-CoycOkLI.js → HUY7CZI3-DCGMm6Rr.js} +2 -2
- package/dist/{HUY7CZI3-DnUD8BzY.cjs → HUY7CZI3-fNYcYVC1.cjs} +1 -1
- package/dist/{digital-asset-manager-D1P-iPRq.js → digital-asset-manager-BjrjrGhU.js} +1 -1
- package/dist/{digital-asset-manager-DK5idohB.cjs → digital-asset-manager-fcMMKnD-.cjs} +1 -1
- package/dist/{index-CwntNsgH.cjs → index-BAUeoBr8.cjs} +2 -2
- package/dist/{index-Ch0kaQDy.js → index-DOVQkWCn.js} +4 -3
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/dist/server.d.ts +1 -0
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./B4MFY5CR-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./B4MFY5CR-D-RGlI6C.cjs"),t=require("./index-BAUeoBr8.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-
|
|
2
|
-
import { g as d, c as f, a as e } from "./index-
|
|
1
|
+
import { c, T as l, P as m, a as u, D as v, Q as i } from "./B4MFY5CR-C7PbvQZA.js";
|
|
2
|
+
import { g as d, c as f, a as e } from "./index-DOVQkWCn.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-
|
|
2
|
-
import { g as v, c as C, a as e } from "./index-
|
|
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-C7PbvQZA.js";
|
|
2
|
+
import { g as v, c as C, a as e } from "./index-DOVQkWCn.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-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./B4MFY5CR-D-RGlI6C.cjs"),t=require("./index-BAUeoBr8.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 { Loader as F, AlertCircle as $e, ChevronLeft as Be, Pencil as qe, Search
|
|
|
7
7
|
import { useDropzone as Ve } from "react-dropzone";
|
|
8
8
|
import { useQueryClient as K, useMutation as Q, useQuery as ie } from "@tanstack/react-query";
|
|
9
9
|
import { toast as P } from "sonner";
|
|
10
|
-
import { W as I, X as U, Y as v, Z as $ } from "./index-
|
|
10
|
+
import { W as I, X as U, Y as v, Z as $ } from "./index-DOVQkWCn.js";
|
|
11
11
|
const We = () => {
|
|
12
12
|
const n = I(), a = K(), s = U();
|
|
13
13
|
return Q({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),c=require("react"),G=require("@chaibuilder/sdk"),r=require("@chaibuilder/sdk/ui"),I=require("lodash-es"),h=require("lucide-react"),me=require("react-dropzone"),S=require("@tanstack/react-query"),D=require("sonner"),n=require("./index-CwntNsgH.cjs"),xe=()=>{const i=n.useAssetsApiUrl(),a=S.useQueryClient(),o=n.useFetch();return S.useMutation({mutationFn:async({file:s,folderId:m,name:l})=>o(i,{action:n.ACTIONS.UPLOAD_ASSET,data:{file:s,folderId:m,name:l}}),onSuccess:s=>{if(s!=null&&s.error)throw new Error(s==null?void 0:s.error);a.invalidateQueries({queryKey:[n.QUERY_KEY_BASE,n.ACTIONS.GET_ASSETS]}),D.toast.success("Asset uploaded successfully")},onError:()=>{D.toast.error("Failed to upload asset")}})},he=()=>{const i=n.useAssetsApiUrl(),a=S.useQueryClient(),o=n.useFetch();return S.useMutation({mutationFn:async s=>o(i,{action:n.ACTIONS.DELETE_ASSET,data:{id:s}}),onSuccess:s=>{if(s!=null&&s.error)throw new Error(s==null?void 0:s.error);a.invalidateQueries({queryKey:[n.QUERY_KEY_BASE,n.ACTIONS.GET_ASSETS]}),D.toast.success("Asset deleted successfully")},onError:()=>{D.toast.error("Failed to delete asset")}})},fe=()=>{const i=n.useAssetsApiUrl(),a=S.useQueryClient(),o=n.useFetch();return S.useMutation({mutationFn:async s=>o(i,{action:n.ACTIONS.UPDATE_ASSET,data:s}),onSuccess:s=>{if(s!=null&&s.error)throw new Error(s==null?void 0:s.error);a.invalidateQueries({queryKey:[n.QUERY_KEY_BASE,n.ACTIONS.GET_ASSETS]}),D.toast.success("Asset updated successfully")},onError:()=>{D.toast.error("Failed to update asset")}})},ge=(i={})=>{const a=n.useAssetsApiUrl(),o=n.useFetch(),{search:s,page:m=1,limit:l=30}=i;return S.useQuery({queryKey:[n.QUERY_KEY_BASE,n.ACTIONS.GET_ASSETS,s,m,l],queryFn:async()=>{const j=await o(a,{action:n.ACTIONS.GET_ASSETS,data:{search:s,page:m,limit:l}});return j.page=m,j.limit=l,j},staleTime:1e3*60*5,retry:1})},pe=i=>{const a=n.useAssetsApiUrl(),o=n.useFetch();return S.useQuery({queryKey:[n.QUERY_KEY_BASE,n.ACTIONS.GET_ASSET,i],queryFn:async()=>i?await o(a,{action:n.ACTIONS.GET_ASSET,data:{id:i}}):null,staleTime:1e3*60*5,retry:1})};function je(i){const a=isNaN(i)?0:typeof i=="number"?i:parseInt(i);return a?a<1024?`${a.toFixed(2)} B`:a<1024*1024?`${(a/1024).toFixed(2)} KB`:`${(a/(1024*1024)).toFixed(2)} MB`:"0 B"}function R(i){if(!i)return"N/A";const a=new Date(i);return new Intl.DateTimeFormat("en-US",{month:"short",day:"numeric",year:"numeric",hour:"2-digit",minute:"2-digit"}).format(a)}function Y(i,a){let o=i,s=a==null?void 0:a.description;return(!s||typeof s!="string")&&(s=""),(!o||typeof o!="string")&&(o=""),o!==s}const ve=({assetId:i,onBack:a,onEdit:o,onSave:s,isSaving:m})=>{var p,w,A;const{data:l,isLoading:j,isError:v}=pe(i||""),[g,x]=c.useState("");return c.useEffect(()=>{l!=null&&l.description&&x(l.description)},[l]),j?e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsx(h.Loader,{className:"h-8 w-8 animate-spin"})}):v||!(l!=null&&l.id)?e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsxs("div",{className:"text-center max-w-md mx-auto p-6",children:[e.jsx("div",{className:"flex justify-center mb-4",children:e.jsx(h.AlertCircle,{className:"h-12 w-12 text-gray-400"})}),e.jsx("h3",{className:"text-lg font-medium text-gray-900 mb-2",children:"No Asset Found"}),e.jsx("p",{className:"text-sm text-gray-500 mb-6",children:v?"There was an error loading the asset. Please try again later.":"The asset you're looking for doesn't exist or has been removed."}),e.jsxs("div",{className:"flex justify-center gap-4",children:[e.jsx(r.Button,{variant:"outline",onClick:a,children:"Back to Assets"}),v&&e.jsx(r.Button,{variant:"default",onClick:()=>window.location.reload(),children:"Try Again"})]})]})}):e.jsxs("div",{className:"flex-1 flex flex-col gap-y-4 overflow-hidden",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(r.Button,{variant:"outline",size:"sm",onClick:a,disabled:m,children:[e.jsx(h.ChevronLeft,{className:"h-4 w-4"}),"Back to Assets"]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(r.Button,{variant:"outline",onClick:a,disabled:m,children:"Cancel"}),e.jsxs(r.Button,{variant:"default",onClick:()=>o(l),disabled:m,children:[e.jsx(h.Pencil,{className:"h-4 w-4"}),"Edit Image"]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 items-start gap-6 flex-1 overflow-hidden",children:[e.jsx("div",{className:"relative h-[calc(80vh-200px)] w-full flex items-start justify-center",children:e.jsx("img",{src:`${l.url}?v=${((p=l.metadata)==null?void 0:p.updatedAt)||l.createdAt}`,alt:l.name,className:"w-full h-full object-contain rounded-lg max-h-max max-w-max shadow-2xl shadow-black/30"})}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"grid gap-3 border rounded-md pt-2 bg-gray-100",children:[e.jsx(r.Label,{className:"w-full text-center",children:"Details"}),e.jsx("div",{className:"grid grid-cols-1 gap-2 text-sm border rounded-md p-2 bg-white",children:[{label:"File Name",value:l.name},{label:"Type",value:l.type,capitalize:!0},{label:"Format",value:((w=l.metadata)==null?void 0:w.format)||l.type,capitalize:!0},{label:"Size",value:je(l.size)},{label:"Dimensions",value:`${l.width||0} × ${l.height||0}`},{label:"Created",value:R(l.createdAt)},{label:"Updated",value:R(((A=l.metadata)==null?void 0:A.updatedAt)||l.createdAt)}].map(d=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(r.Label,{className:"w-max text-left px-2 w-1/4 font-normal text-gray-700",children:d.label}),":",e.jsx("div",{className:"w-max text-left font-medium text-gray-900"+d.capitalize?" capitalize":"",children:d.value})]},d.label))})]}),l.usedOn&&l.usedOn.length>0&&e.jsxs("div",{className:"grid gap-3",children:[e.jsx(r.Label,{children:"Used On"}),e.jsx("div",{className:"grid grid-cols-1 gap-2 text-sm border rounded-md p-2",children:l.usedOn.map((d,f)=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-max text-left font-medium text-gray-900",children:d.name}),e.jsxs("div",{className:"text-gray-500",children:["(",d.slug,")"]})]},f))})]}),e.jsxs("div",{className:"grid gap-3 border rounded-md pt-2 bg-gray-100 relative",children:[e.jsx(r.Label,{className:"w-full text-center",children:"Description"}),e.jsx(r.Textarea,{id:"description",value:g,placeholder:"Enter a description for the asset",onChange:d=>x(d.target.value),rows:3,disabled:m,className:"hover:border-black/40 bg-white"}),e.jsx("div",{className:"flex justify-end items-start absolute top-1.5 right-2",children:e.jsx("button",{type:"button",onClick:()=>s(g),disabled:m||!Y(g,l),className:`py-0 bg-blue-500 text-white px-3 py-0.5 rounded-md text-sm ${m||!Y(g,l)?"opacity-50 cursor-not-allowed":""}`,children:m?e.jsxs(e.Fragment,{children:[e.jsx(h.Loader,{className:"h-4 w-4 mr-2 animate-spin"}),"Saving..."]}):"Save"})})]})]})]})]})},Ne=c.lazy(()=>Promise.resolve().then(()=>require("./image-editor-BWLJT1mr.cjs")));function ye(i){const a=isNaN(i)?0:typeof i=="number"?i:parseInt(i);return a?a<1024?`${a.toFixed(2)} B`:a<1024*1024?`${(a/1024).toFixed(2)} KB`:`${(a/(1024*1024)).toFixed(2)} MB`:"0 B"}const be=({isUpdatingAsset:i,allowedTypes:a,maxFileSize:o,uploadAsset:s,isUploadingAsset:m})=>{const l=i||m,j=c.useCallback(async p=>new Promise((w,A)=>{const d=p[0],f=new FileReader;f.readAsDataURL(d),f.onload=async()=>{const F=await s({file:f.result,folderId:void 0,name:d.name});w(F)},f.onerror=F=>A(F)}),[s]),{getRootProps:v,getInputProps:g,isDragActive:x}=me.useDropzone({onDrop:j,accept:{"image/*":a.includes("image")?[]:[]},maxSize:o*1024*1024,disabled:i||m});return e.jsx("div",{className:`flex flex-col items-center justify-center w-full border-2 hover:border-black/50 border-dashed p-0 rounded-lg border-slate-300 py-2 h-[60px] ${l?"opacity-90 bg-gray-100 pointer-events-none":"hover:border-black/50 hover:bg-gray-100"}`,children:e.jsxs("div",{...v(),className:G.mergeClasses("rounded-lg text-center cursor-pointer w-full h-max flex flex-col items-center justify-center",x?"border-primary bg-primary/5":"border-muted-foreground/20"),children:[e.jsx("input",{...g()}),l?e.jsx("div",{className:"flex flex-col items-center",children:e.jsxs("div",{className:"leading-tight flex items-center gap-2",children:[e.jsx("div",{className:"flex items-center justify-center rounded-full bg-indigo-100 p-2",children:e.jsx(h.Loader,{className:"h-4 w-4 text-indigo-500 animate-spin"})}),e.jsxs("div",{className:"text-left",children:[e.jsx("div",{className:"font-medium",children:i?"Updating file...":"Uploading file..."}),e.jsxs("div",{className:"text-xs text-muted-foreground font-light",children:["Please wait while we ",i?"update":"upload"," ","your file..."]})]})]})}):e.jsx("div",{className:"flex flex-col items-center",children:e.jsxs("div",{className:"leading-tight flex items-center gap-2",children:[e.jsx("div",{className:"flex items-center justify-center rounded-full bg-indigo-100 p-2 border border-indigo-500",children:e.jsx(h.Upload,{className:"h-4 w-4 text-indigo-500"})}),e.jsxs("div",{className:"text-left",children:[e.jsxs("div",{className:"font-medium",children:["Drop your file here or"," ",e.jsx("span",{className:"text-indigo-500 cursor-pointer hover:underline",children:"browse"})]}),e.jsxs("div",{className:"text-xs text-muted-foreground font-light",children:[e.jsxs("span",{className:"",children:["Accepted file types:"," ",e.jsx("span",{className:"capitalize text-indigo-400",children:a.join(", ")})," & "]}),e.jsxs("span",{children:["Max file size:"," ",e.jsxs("span",{className:"capitalize text-indigo-400",children:[o," MB"]})]})]})]})]})})]})})};function we({close:i,onSelect:a,mode:o="image",assetId:s}){const j=c.useMemo(()=>[o],[o]),[v,g]=c.useState(null),[x,p]=c.useState(null),[w,A]=c.useState(null),[d,f]=c.useState({show:!1,file:""}),[F,O]=c.useState(!1),[V,P]=c.useState(s?"details":"grid"),[U,W]=c.useState(""),[B,H]=c.useState(""),[N,L]=c.useState(1),[$]=c.useState(30),[C,Q]=c.useState([]);c.useEffect(()=>{s&&(g(s),P("details"))},[s]),c.useEffect(()=>{const t=setTimeout(()=>{W(B),L(1)},300);return()=>clearTimeout(t)},[B]);const{data:T,isLoading:_}=ge({search:U.toLowerCase().trim(),page:N,limit:$}),E=(T==null?void 0:T.assets)||[],J=(T==null?void 0:T.total)||0,y=Math.ceil(J/$),z=N<y,q=N>1,X=(E==null?void 0:E.length)>0,{mutate:Z}=he(),{mutate:M,isPending:ee}=xe(),{mutate:K,isPending:te}=fe(),k=c.useCallback(t=>{t>=1&&t<=y&&L(t)},[y]),se=c.useCallback(()=>{z&&k(N+1)},[N,z,k]),ae=c.useCallback(()=>{q&&k(N-1)},[N,q,k]),le=t=>{H(t.target.value)},ie=c.useCallback(t=>{Q(u=>I.find(u,{id:t.id})?[]:[t])},[!1]),re=c.useCallback(()=>{Q([])},[]),ne=()=>{C.length!==0&&(a(I.pick(I.first(C),["id","url","width","height","description"])),i())},ce=async t=>{p(t)},oe=async()=>{x&&(A(x==null?void 0:x.id),await Z(x.id,{onSuccess:()=>{A(null),p(null)},onError:()=>{A(null)}}),p(null))},de=t=>{g(t.id),P("details")},ue=async(t,u)=>{try{u?(await M({file:t,folderId:void 0,name:d.name||""}),f({show:!1,file:""})):(await K({id:d.id||"",file:t}),f({show:!1,file:""}))}catch(b){console.error("Error saving edited image:",b)}};return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"max-w-[1232px] max-h-[1232px] w-[80vw] h-[80vh] space-y-4 flex flex-col",children:[e.jsx("h1",{className:"text-lg font-medium",children:"Digital Asset Manager"}),V==="grid"?e.jsxs(e.Fragment,{children:[e.jsx(be,{maxFileSize:10,allowedTypes:j,uploadAsset:M,isUpdatingAsset:te,isUploadingAsset:ee}),e.jsxs("div",{className:"border p-2 rounded-lg flex-1 flex flex-col gap-y-3 overflow-hidden relative",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"relative w-1/2 ",children:[e.jsx(h.Search,{strokeWidth:3,className:`absolute left-2 top-2.5 h-4 w-4 text-muted-foreground ${B.length>0?"text-indigo-800":""}`}),e.jsx(r.Input,{placeholder:"Search assets...",onChange:le,value:B,className:"pl-8 hover:shadow-lg"})]}),C.length>0?e.jsx("div",{className:"flex justify-between items-center",children:e.jsxs("div",{className:"flex items-center gap-2",children:[C.length>0&&e.jsx(e.Fragment,{children:e.jsx(r.Button,{variant:"outline",size:"sm",onClick:()=>re(),title:"Clear selection",children:"Clear"})}),e.jsx(r.Button,{size:"sm",onClick:ne,disabled:C.length===0,children:"Select Asset"})]})}):null]}),e.jsx("div",{className:"flex-1 overflow-y-auto",children:_?e.jsxs("div",{className:"columns-1 gap-3 space-y-3 sm:columns-3 md:columns-5",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"})]}):!_&&!X?e.jsxs("div",{className:"flex flex-col items-center justify-center h-full border rounded-lg",children:[e.jsx("div",{className:"text-muted-foreground",children:e.jsx(h.Archive,{className:"h-9 w-9 text-indigo-500"})}),e.jsx("div",{className:"text-muted-foreground text-lg",children:"No assets found"}),e.jsx("div",{className:"text-muted-foreground text-sm",children:U.length>0?"No assets found for your search: "+U:"Start uploading assets to get started"}),e.jsx("br",{})]}):e.jsx("div",{className:"flex flex-wrap gap-3 p-1",children:E==null?void 0:E.map(t=>e.jsxs("div",{className:G.mergeClasses("relative cursor-pointer overflow-hidden transition-all rounded-lg border-2 group max-w-[180px] max-h-[180px] flex flex-col justify-between",C.some(u=>u.id===t.id)?"border-4 border-blue-500":"hover:border-black/50",w&&(x==null?void 0:x.id)===t.id?"opacity-50 pointer-events-none":"",w===t.id?"opacity-50 pointer-events-none":""),onClick:()=>ie(t),children:[e.jsxs("div",{className:"aspect-square relative overflow-hidden",children:[w===t.id?e.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black/50",children:e.jsx(h.Loader,{className:"h-8 w-8 animate-spin text-white"})}):null,t.type==="image"?e.jsx("img",{src:`${t.thumbnailUrl||"/placeholder.svg"}?v=${(t==null?void 0:t.updatedAt)||t.createdAt}`,alt:t.name,className:"object-contain w-full h-full min-h-[80px]"}):e.jsxs("div",{className:"flex items-center justify-center h-full",children:[e.jsx(h.Film,{className:"h-12 w-12 text-muted-foreground"}),t.thumbnailUrl&&e.jsx("img",{src:`${t.thumbnailUrl||"/placeholder.svg"}?v=${(t==null?void 0:t.updatedAt)||t.createdAt}`,alt:t.name,className:"absolute inset-0 object-cover w-full h-full"})]})]}),e.jsxs("div",{className:"py-1 px-2",children:[e.jsx("div",{className:"text-xs truncate",title:t.name,children:t.name}),e.jsxs("div",{className:"text-[10px] font-light text-muted-foreground flex items-center justify-between",children:[e.jsx("span",{children:ye((t==null?void 0:t.size)||0)}),e.jsxs("span",{children:["Used on"," ",e.jsxs("span",{className:"font-normal",children:[(t==null?void 0:t.usedOnCount)||0," "]}),(t==null?void 0:t.usedOnCount)===1?"page":"pages"]})]})]}),e.jsxs("div",{className:"absolute inset-0 bg-black/80 border-white border-4 rounded-lg opacity-0 group-hover:opacity-100 transition-opacity flex items-center justify-center gap-2",children:[e.jsx(r.Button,{variant:"secondary",size:"icon",className:"h-8 w-8 rounded-full",onClick:u=>{u.stopPropagation(),de(t)},children:e.jsx(h.ImageIcon,{className:"h-4 w-4"})}),e.jsx(r.Button,{variant:"secondary",size:"icon",className:"h-8 w-8 rounded-full",onClick:u=>{u.stopPropagation(),f({id:t.id,show:!0,file:t.url,name:t.name})},children:e.jsx(h.Edit,{className:"h-4 w-4"})}),e.jsx(r.Button,{variant:"destructive",size:"icon",className:"h-8 w-8 rounded-full",onClick:u=>{u.stopPropagation(),ce(t)},children:e.jsx(h.Trash2,{className:"h-4 w-4"})})]}),C.some(u=>u.id===t.id)&&e.jsx("div",{className:"absolute top-2 right-2 border border-white h-max rounded-full bg-blue-500 p-1",children:e.jsx(h.Check,{className:"w-3 h-3 text-white",strokeWidth:5})})]},t.id))})}),y>1&&e.jsx("div",{className:"absolute bottom-0 left-0 right-0 bg-white border-t p-4",children:e.jsxs("div",{className:"flex items-center justify-center space-x-2",children:[e.jsx(r.Button,{variant:"outline",size:"sm",onClick:ae,disabled:!q,children:"Previous"}),Array.from({length:Math.min(5,y)},(t,u)=>{const b=u+1;return e.jsx(r.Button,{variant:N===b?"default":"outline",size:"sm",onClick:()=>k(b),children:b},b)}),y>5&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-muted-foreground",children:"..."}),e.jsx(r.Button,{variant:N===y?"default":"outline",size:"sm",onClick:()=>k(y),children:y})]}),e.jsx(r.Button,{variant:"outline",size:"sm",onClick:se,disabled:!z,children:"Next"})]})})]})]}):e.jsx(ve,{assetId:v||s||"",onBack:()=>{P("grid"),g(null)},onEdit:t=>{f({id:t.id,show:!0,file:t.url,name:t.name})},onSave:async t=>{if(v){O(!0);try{const u=E.find(b=>b.id===v);u&&await K(I.merge(u,{description:t}))}finally{O(!1)}}},isSaving:F})]}),d.show&&e.jsx(c.Suspense,{fallback:e.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:e.jsx(h.Loader,{className:"h-8 w-8 animate-spin"})}),children:e.jsx(Ne,{imageUrl:d.file,onSave:ue,onClose:()=>f({show:!1,file:""}),defaultSavedImageName:d.name,isEditing:!!d.id})}),x&&e.jsx(r.Dialog,{open:!!x,onOpenChange:()=>p(null),children:e.jsxs(r.DialogContent,{children:[e.jsxs(r.DialogHeader,{children:[e.jsx(r.DialogTitle,{children:"Delete Asset"}),e.jsxs(r.DialogDescription,{children:['Are you sure you want to delete "',x.name,'"? This action cannot be undone.']})]}),e.jsxs(r.DialogFooter,{className:"gap-2 sm:gap-0",children:[e.jsx(r.Button,{variant:"outline",onClick:()=>p(null),children:"Cancel"}),e.jsx(r.Button,{variant:"destructive",onClick:oe,children:"Delete"})]})]})})]})}exports.default=we;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),c=require("react"),G=require("@chaibuilder/sdk"),r=require("@chaibuilder/sdk/ui"),I=require("lodash-es"),h=require("lucide-react"),me=require("react-dropzone"),S=require("@tanstack/react-query"),D=require("sonner"),n=require("./index-BAUeoBr8.cjs"),xe=()=>{const i=n.useAssetsApiUrl(),a=S.useQueryClient(),o=n.useFetch();return S.useMutation({mutationFn:async({file:s,folderId:m,name:l})=>o(i,{action:n.ACTIONS.UPLOAD_ASSET,data:{file:s,folderId:m,name:l}}),onSuccess:s=>{if(s!=null&&s.error)throw new Error(s==null?void 0:s.error);a.invalidateQueries({queryKey:[n.QUERY_KEY_BASE,n.ACTIONS.GET_ASSETS]}),D.toast.success("Asset uploaded successfully")},onError:()=>{D.toast.error("Failed to upload asset")}})},he=()=>{const i=n.useAssetsApiUrl(),a=S.useQueryClient(),o=n.useFetch();return S.useMutation({mutationFn:async s=>o(i,{action:n.ACTIONS.DELETE_ASSET,data:{id:s}}),onSuccess:s=>{if(s!=null&&s.error)throw new Error(s==null?void 0:s.error);a.invalidateQueries({queryKey:[n.QUERY_KEY_BASE,n.ACTIONS.GET_ASSETS]}),D.toast.success("Asset deleted successfully")},onError:()=>{D.toast.error("Failed to delete asset")}})},fe=()=>{const i=n.useAssetsApiUrl(),a=S.useQueryClient(),o=n.useFetch();return S.useMutation({mutationFn:async s=>o(i,{action:n.ACTIONS.UPDATE_ASSET,data:s}),onSuccess:s=>{if(s!=null&&s.error)throw new Error(s==null?void 0:s.error);a.invalidateQueries({queryKey:[n.QUERY_KEY_BASE,n.ACTIONS.GET_ASSETS]}),D.toast.success("Asset updated successfully")},onError:()=>{D.toast.error("Failed to update asset")}})},ge=(i={})=>{const a=n.useAssetsApiUrl(),o=n.useFetch(),{search:s,page:m=1,limit:l=30}=i;return S.useQuery({queryKey:[n.QUERY_KEY_BASE,n.ACTIONS.GET_ASSETS,s,m,l],queryFn:async()=>{const j=await o(a,{action:n.ACTIONS.GET_ASSETS,data:{search:s,page:m,limit:l}});return j.page=m,j.limit=l,j},staleTime:1e3*60*5,retry:1})},pe=i=>{const a=n.useAssetsApiUrl(),o=n.useFetch();return S.useQuery({queryKey:[n.QUERY_KEY_BASE,n.ACTIONS.GET_ASSET,i],queryFn:async()=>i?await o(a,{action:n.ACTIONS.GET_ASSET,data:{id:i}}):null,staleTime:1e3*60*5,retry:1})};function je(i){const a=isNaN(i)?0:typeof i=="number"?i:parseInt(i);return a?a<1024?`${a.toFixed(2)} B`:a<1024*1024?`${(a/1024).toFixed(2)} KB`:`${(a/(1024*1024)).toFixed(2)} MB`:"0 B"}function R(i){if(!i)return"N/A";const a=new Date(i);return new Intl.DateTimeFormat("en-US",{month:"short",day:"numeric",year:"numeric",hour:"2-digit",minute:"2-digit"}).format(a)}function Y(i,a){let o=i,s=a==null?void 0:a.description;return(!s||typeof s!="string")&&(s=""),(!o||typeof o!="string")&&(o=""),o!==s}const ve=({assetId:i,onBack:a,onEdit:o,onSave:s,isSaving:m})=>{var p,w,A;const{data:l,isLoading:j,isError:v}=pe(i||""),[g,x]=c.useState("");return c.useEffect(()=>{l!=null&&l.description&&x(l.description)},[l]),j?e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsx(h.Loader,{className:"h-8 w-8 animate-spin"})}):v||!(l!=null&&l.id)?e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsxs("div",{className:"text-center max-w-md mx-auto p-6",children:[e.jsx("div",{className:"flex justify-center mb-4",children:e.jsx(h.AlertCircle,{className:"h-12 w-12 text-gray-400"})}),e.jsx("h3",{className:"text-lg font-medium text-gray-900 mb-2",children:"No Asset Found"}),e.jsx("p",{className:"text-sm text-gray-500 mb-6",children:v?"There was an error loading the asset. Please try again later.":"The asset you're looking for doesn't exist or has been removed."}),e.jsxs("div",{className:"flex justify-center gap-4",children:[e.jsx(r.Button,{variant:"outline",onClick:a,children:"Back to Assets"}),v&&e.jsx(r.Button,{variant:"default",onClick:()=>window.location.reload(),children:"Try Again"})]})]})}):e.jsxs("div",{className:"flex-1 flex flex-col gap-y-4 overflow-hidden",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(r.Button,{variant:"outline",size:"sm",onClick:a,disabled:m,children:[e.jsx(h.ChevronLeft,{className:"h-4 w-4"}),"Back to Assets"]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(r.Button,{variant:"outline",onClick:a,disabled:m,children:"Cancel"}),e.jsxs(r.Button,{variant:"default",onClick:()=>o(l),disabled:m,children:[e.jsx(h.Pencil,{className:"h-4 w-4"}),"Edit Image"]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 items-start gap-6 flex-1 overflow-hidden",children:[e.jsx("div",{className:"relative h-[calc(80vh-200px)] w-full flex items-start justify-center",children:e.jsx("img",{src:`${l.url}?v=${((p=l.metadata)==null?void 0:p.updatedAt)||l.createdAt}`,alt:l.name,className:"w-full h-full object-contain rounded-lg max-h-max max-w-max shadow-2xl shadow-black/30"})}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"grid gap-3 border rounded-md pt-2 bg-gray-100",children:[e.jsx(r.Label,{className:"w-full text-center",children:"Details"}),e.jsx("div",{className:"grid grid-cols-1 gap-2 text-sm border rounded-md p-2 bg-white",children:[{label:"File Name",value:l.name},{label:"Type",value:l.type,capitalize:!0},{label:"Format",value:((w=l.metadata)==null?void 0:w.format)||l.type,capitalize:!0},{label:"Size",value:je(l.size)},{label:"Dimensions",value:`${l.width||0} × ${l.height||0}`},{label:"Created",value:R(l.createdAt)},{label:"Updated",value:R(((A=l.metadata)==null?void 0:A.updatedAt)||l.createdAt)}].map(d=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(r.Label,{className:"w-max text-left px-2 w-1/4 font-normal text-gray-700",children:d.label}),":",e.jsx("div",{className:"w-max text-left font-medium text-gray-900"+d.capitalize?" capitalize":"",children:d.value})]},d.label))})]}),l.usedOn&&l.usedOn.length>0&&e.jsxs("div",{className:"grid gap-3",children:[e.jsx(r.Label,{children:"Used On"}),e.jsx("div",{className:"grid grid-cols-1 gap-2 text-sm border rounded-md p-2",children:l.usedOn.map((d,f)=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-max text-left font-medium text-gray-900",children:d.name}),e.jsxs("div",{className:"text-gray-500",children:["(",d.slug,")"]})]},f))})]}),e.jsxs("div",{className:"grid gap-3 border rounded-md pt-2 bg-gray-100 relative",children:[e.jsx(r.Label,{className:"w-full text-center",children:"Description"}),e.jsx(r.Textarea,{id:"description",value:g,placeholder:"Enter a description for the asset",onChange:d=>x(d.target.value),rows:3,disabled:m,className:"hover:border-black/40 bg-white"}),e.jsx("div",{className:"flex justify-end items-start absolute top-1.5 right-2",children:e.jsx("button",{type:"button",onClick:()=>s(g),disabled:m||!Y(g,l),className:`py-0 bg-blue-500 text-white px-3 py-0.5 rounded-md text-sm ${m||!Y(g,l)?"opacity-50 cursor-not-allowed":""}`,children:m?e.jsxs(e.Fragment,{children:[e.jsx(h.Loader,{className:"h-4 w-4 mr-2 animate-spin"}),"Saving..."]}):"Save"})})]})]})]})]})},Ne=c.lazy(()=>Promise.resolve().then(()=>require("./image-editor-BWLJT1mr.cjs")));function ye(i){const a=isNaN(i)?0:typeof i=="number"?i:parseInt(i);return a?a<1024?`${a.toFixed(2)} B`:a<1024*1024?`${(a/1024).toFixed(2)} KB`:`${(a/(1024*1024)).toFixed(2)} MB`:"0 B"}const be=({isUpdatingAsset:i,allowedTypes:a,maxFileSize:o,uploadAsset:s,isUploadingAsset:m})=>{const l=i||m,j=c.useCallback(async p=>new Promise((w,A)=>{const d=p[0],f=new FileReader;f.readAsDataURL(d),f.onload=async()=>{const F=await s({file:f.result,folderId:void 0,name:d.name});w(F)},f.onerror=F=>A(F)}),[s]),{getRootProps:v,getInputProps:g,isDragActive:x}=me.useDropzone({onDrop:j,accept:{"image/*":a.includes("image")?[]:[]},maxSize:o*1024*1024,disabled:i||m});return e.jsx("div",{className:`flex flex-col items-center justify-center w-full border-2 hover:border-black/50 border-dashed p-0 rounded-lg border-slate-300 py-2 h-[60px] ${l?"opacity-90 bg-gray-100 pointer-events-none":"hover:border-black/50 hover:bg-gray-100"}`,children:e.jsxs("div",{...v(),className:G.mergeClasses("rounded-lg text-center cursor-pointer w-full h-max flex flex-col items-center justify-center",x?"border-primary bg-primary/5":"border-muted-foreground/20"),children:[e.jsx("input",{...g()}),l?e.jsx("div",{className:"flex flex-col items-center",children:e.jsxs("div",{className:"leading-tight flex items-center gap-2",children:[e.jsx("div",{className:"flex items-center justify-center rounded-full bg-indigo-100 p-2",children:e.jsx(h.Loader,{className:"h-4 w-4 text-indigo-500 animate-spin"})}),e.jsxs("div",{className:"text-left",children:[e.jsx("div",{className:"font-medium",children:i?"Updating file...":"Uploading file..."}),e.jsxs("div",{className:"text-xs text-muted-foreground font-light",children:["Please wait while we ",i?"update":"upload"," ","your file..."]})]})]})}):e.jsx("div",{className:"flex flex-col items-center",children:e.jsxs("div",{className:"leading-tight flex items-center gap-2",children:[e.jsx("div",{className:"flex items-center justify-center rounded-full bg-indigo-100 p-2 border border-indigo-500",children:e.jsx(h.Upload,{className:"h-4 w-4 text-indigo-500"})}),e.jsxs("div",{className:"text-left",children:[e.jsxs("div",{className:"font-medium",children:["Drop your file here or"," ",e.jsx("span",{className:"text-indigo-500 cursor-pointer hover:underline",children:"browse"})]}),e.jsxs("div",{className:"text-xs text-muted-foreground font-light",children:[e.jsxs("span",{className:"",children:["Accepted file types:"," ",e.jsx("span",{className:"capitalize text-indigo-400",children:a.join(", ")})," & "]}),e.jsxs("span",{children:["Max file size:"," ",e.jsxs("span",{className:"capitalize text-indigo-400",children:[o," MB"]})]})]})]})]})})]})})};function we({close:i,onSelect:a,mode:o="image",assetId:s}){const j=c.useMemo(()=>[o],[o]),[v,g]=c.useState(null),[x,p]=c.useState(null),[w,A]=c.useState(null),[d,f]=c.useState({show:!1,file:""}),[F,O]=c.useState(!1),[V,P]=c.useState(s?"details":"grid"),[U,W]=c.useState(""),[B,H]=c.useState(""),[N,L]=c.useState(1),[$]=c.useState(30),[C,Q]=c.useState([]);c.useEffect(()=>{s&&(g(s),P("details"))},[s]),c.useEffect(()=>{const t=setTimeout(()=>{W(B),L(1)},300);return()=>clearTimeout(t)},[B]);const{data:T,isLoading:_}=ge({search:U.toLowerCase().trim(),page:N,limit:$}),E=(T==null?void 0:T.assets)||[],J=(T==null?void 0:T.total)||0,y=Math.ceil(J/$),z=N<y,q=N>1,X=(E==null?void 0:E.length)>0,{mutate:Z}=he(),{mutate:M,isPending:ee}=xe(),{mutate:K,isPending:te}=fe(),k=c.useCallback(t=>{t>=1&&t<=y&&L(t)},[y]),se=c.useCallback(()=>{z&&k(N+1)},[N,z,k]),ae=c.useCallback(()=>{q&&k(N-1)},[N,q,k]),le=t=>{H(t.target.value)},ie=c.useCallback(t=>{Q(u=>I.find(u,{id:t.id})?[]:[t])},[!1]),re=c.useCallback(()=>{Q([])},[]),ne=()=>{C.length!==0&&(a(I.pick(I.first(C),["id","url","width","height","description"])),i())},ce=async t=>{p(t)},oe=async()=>{x&&(A(x==null?void 0:x.id),await Z(x.id,{onSuccess:()=>{A(null),p(null)},onError:()=>{A(null)}}),p(null))},de=t=>{g(t.id),P("details")},ue=async(t,u)=>{try{u?(await M({file:t,folderId:void 0,name:d.name||""}),f({show:!1,file:""})):(await K({id:d.id||"",file:t}),f({show:!1,file:""}))}catch(b){console.error("Error saving edited image:",b)}};return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"max-w-[1232px] max-h-[1232px] w-[80vw] h-[80vh] space-y-4 flex flex-col",children:[e.jsx("h1",{className:"text-lg font-medium",children:"Digital Asset Manager"}),V==="grid"?e.jsxs(e.Fragment,{children:[e.jsx(be,{maxFileSize:10,allowedTypes:j,uploadAsset:M,isUpdatingAsset:te,isUploadingAsset:ee}),e.jsxs("div",{className:"border p-2 rounded-lg flex-1 flex flex-col gap-y-3 overflow-hidden relative",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"relative w-1/2 ",children:[e.jsx(h.Search,{strokeWidth:3,className:`absolute left-2 top-2.5 h-4 w-4 text-muted-foreground ${B.length>0?"text-indigo-800":""}`}),e.jsx(r.Input,{placeholder:"Search assets...",onChange:le,value:B,className:"pl-8 hover:shadow-lg"})]}),C.length>0?e.jsx("div",{className:"flex justify-between items-center",children:e.jsxs("div",{className:"flex items-center gap-2",children:[C.length>0&&e.jsx(e.Fragment,{children:e.jsx(r.Button,{variant:"outline",size:"sm",onClick:()=>re(),title:"Clear selection",children:"Clear"})}),e.jsx(r.Button,{size:"sm",onClick:ne,disabled:C.length===0,children:"Select Asset"})]})}):null]}),e.jsx("div",{className:"flex-1 overflow-y-auto",children:_?e.jsxs("div",{className:"columns-1 gap-3 space-y-3 sm:columns-3 md:columns-5",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"})]}):!_&&!X?e.jsxs("div",{className:"flex flex-col items-center justify-center h-full border rounded-lg",children:[e.jsx("div",{className:"text-muted-foreground",children:e.jsx(h.Archive,{className:"h-9 w-9 text-indigo-500"})}),e.jsx("div",{className:"text-muted-foreground text-lg",children:"No assets found"}),e.jsx("div",{className:"text-muted-foreground text-sm",children:U.length>0?"No assets found for your search: "+U:"Start uploading assets to get started"}),e.jsx("br",{})]}):e.jsx("div",{className:"flex flex-wrap gap-3 p-1",children:E==null?void 0:E.map(t=>e.jsxs("div",{className:G.mergeClasses("relative cursor-pointer overflow-hidden transition-all rounded-lg border-2 group max-w-[180px] max-h-[180px] flex flex-col justify-between",C.some(u=>u.id===t.id)?"border-4 border-blue-500":"hover:border-black/50",w&&(x==null?void 0:x.id)===t.id?"opacity-50 pointer-events-none":"",w===t.id?"opacity-50 pointer-events-none":""),onClick:()=>ie(t),children:[e.jsxs("div",{className:"aspect-square relative overflow-hidden",children:[w===t.id?e.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black/50",children:e.jsx(h.Loader,{className:"h-8 w-8 animate-spin text-white"})}):null,t.type==="image"?e.jsx("img",{src:`${t.thumbnailUrl||"/placeholder.svg"}?v=${(t==null?void 0:t.updatedAt)||t.createdAt}`,alt:t.name,className:"object-contain w-full h-full min-h-[80px]"}):e.jsxs("div",{className:"flex items-center justify-center h-full",children:[e.jsx(h.Film,{className:"h-12 w-12 text-muted-foreground"}),t.thumbnailUrl&&e.jsx("img",{src:`${t.thumbnailUrl||"/placeholder.svg"}?v=${(t==null?void 0:t.updatedAt)||t.createdAt}`,alt:t.name,className:"absolute inset-0 object-cover w-full h-full"})]})]}),e.jsxs("div",{className:"py-1 px-2",children:[e.jsx("div",{className:"text-xs truncate",title:t.name,children:t.name}),e.jsxs("div",{className:"text-[10px] font-light text-muted-foreground flex items-center justify-between",children:[e.jsx("span",{children:ye((t==null?void 0:t.size)||0)}),e.jsxs("span",{children:["Used on"," ",e.jsxs("span",{className:"font-normal",children:[(t==null?void 0:t.usedOnCount)||0," "]}),(t==null?void 0:t.usedOnCount)===1?"page":"pages"]})]})]}),e.jsxs("div",{className:"absolute inset-0 bg-black/80 border-white border-4 rounded-lg opacity-0 group-hover:opacity-100 transition-opacity flex items-center justify-center gap-2",children:[e.jsx(r.Button,{variant:"secondary",size:"icon",className:"h-8 w-8 rounded-full",onClick:u=>{u.stopPropagation(),de(t)},children:e.jsx(h.ImageIcon,{className:"h-4 w-4"})}),e.jsx(r.Button,{variant:"secondary",size:"icon",className:"h-8 w-8 rounded-full",onClick:u=>{u.stopPropagation(),f({id:t.id,show:!0,file:t.url,name:t.name})},children:e.jsx(h.Edit,{className:"h-4 w-4"})}),e.jsx(r.Button,{variant:"destructive",size:"icon",className:"h-8 w-8 rounded-full",onClick:u=>{u.stopPropagation(),ce(t)},children:e.jsx(h.Trash2,{className:"h-4 w-4"})})]}),C.some(u=>u.id===t.id)&&e.jsx("div",{className:"absolute top-2 right-2 border border-white h-max rounded-full bg-blue-500 p-1",children:e.jsx(h.Check,{className:"w-3 h-3 text-white",strokeWidth:5})})]},t.id))})}),y>1&&e.jsx("div",{className:"absolute bottom-0 left-0 right-0 bg-white border-t p-4",children:e.jsxs("div",{className:"flex items-center justify-center space-x-2",children:[e.jsx(r.Button,{variant:"outline",size:"sm",onClick:ae,disabled:!q,children:"Previous"}),Array.from({length:Math.min(5,y)},(t,u)=>{const b=u+1;return e.jsx(r.Button,{variant:N===b?"default":"outline",size:"sm",onClick:()=>k(b),children:b},b)}),y>5&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-muted-foreground",children:"..."}),e.jsx(r.Button,{variant:N===y?"default":"outline",size:"sm",onClick:()=>k(y),children:y})]}),e.jsx(r.Button,{variant:"outline",size:"sm",onClick:se,disabled:!z,children:"Next"})]})})]})]}):e.jsx(ve,{assetId:v||s||"",onBack:()=>{P("grid"),g(null)},onEdit:t=>{f({id:t.id,show:!0,file:t.url,name:t.name})},onSave:async t=>{if(v){O(!0);try{const u=E.find(b=>b.id===v);u&&await K(I.merge(u,{description:t}))}finally{O(!1)}}},isSaving:F})]}),d.show&&e.jsx(c.Suspense,{fallback:e.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:e.jsx(h.Loader,{className:"h-8 w-8 animate-spin"})}),children:e.jsx(Ne,{imageUrl:d.file,onSave:ue,onClose:()=>f({show:!1,file:""}),defaultSavedImageName:d.name,isEditing:!!d.id})}),x&&e.jsx(r.Dialog,{open:!!x,onOpenChange:()=>p(null),children:e.jsxs(r.DialogContent,{children:[e.jsxs(r.DialogHeader,{children:[e.jsx(r.DialogTitle,{children:"Delete Asset"}),e.jsxs(r.DialogDescription,{children:['Are you sure you want to delete "',x.name,'"? This action cannot be undone.']})]}),e.jsxs(r.DialogFooter,{className:"gap-2 sm:gap-0",children:[e.jsx(r.Button,{variant:"outline",onClick:()=>p(null),children:"Cancel"}),e.jsx(r.Button,{variant:"destructive",onClick:oe,children:"Delete"})]})]})})]})}exports.default=we;
|