vite-plugin-asset-manager 1.0.2 → 1.0.4

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/README.md CHANGED
@@ -1,5 +1,5 @@
1
1
  <p align="center">
2
- <img src="./.github/assets/demo.gif" alt="Vite Plugin Asset Manager Demo" />
2
+ <img src="./.github/assets/banner.png" alt="Vite Plugin Asset Manager" />
3
3
  </p>
4
4
 
5
5
  <h1 align="center">vite-plugin-asset-manager</h1>
@@ -88,6 +88,7 @@ Start your dev server and access the Asset Manager in three ways:
88
88
  | Solid | ✅ | Fully automatic |
89
89
  | Qwik | ✅ | Fully automatic |
90
90
  | **Nuxt 3/4** | ✅ | [Official module](#nuxt-module) |
91
+ | **Next.js 14+** | ✅ | [Official package](#nextjs-integration) |
91
92
  | **TanStack Start** | ✅ | [Manual setup required](./docs/SSR_INTEGRATION.md#tanstack-start-setup) ([playground](./playgrounds/tanstack/)) |
92
93
 
93
94
  ### Nuxt Module
@@ -111,9 +112,64 @@ Features:
111
112
  - Supports Nuxt 3 and 4 directory structures
112
113
  - Dev-only (zero production footprint)
113
114
 
115
+ ### Next.js Integration
116
+
117
+ For Next.js 14+ projects, use the official integration package:
118
+
119
+ ```bash
120
+ npm install nextjs-asset-manager -D
121
+ ```
122
+
123
+ **Step 1:** Wrap your Next.js config to suppress dev server request logging:
124
+
125
+ ```ts
126
+ // next.config.ts
127
+ import type { NextConfig } from "next"
128
+ import { withAssetManager } from "nextjs-asset-manager"
129
+
130
+ const nextConfig: NextConfig = {}
131
+ export default withAssetManager(nextConfig)
132
+ ```
133
+
134
+ **Step 2:** Create an API catch-all route:
135
+
136
+ ```ts
137
+ // app/api/asset-manager/[[...path]]/route.ts
138
+ import { createHandler } from 'nextjs-asset-manager'
139
+
140
+ const { GET, POST } = createHandler()
141
+ export { GET, POST }
142
+ ```
143
+
144
+ **Step 3:** Add the client component to your root layout:
145
+
146
+ ```tsx
147
+ // app/layout.tsx
148
+ import { AssetManagerScript } from 'nextjs-asset-manager'
149
+
150
+ export default function RootLayout({ children }: { children: React.ReactNode }) {
151
+ return (
152
+ <html lang="en">
153
+ <body>
154
+ {children}
155
+ <AssetManagerScript />
156
+ </body>
157
+ </html>
158
+ )
159
+ }
160
+ ```
161
+
162
+ Features:
163
+ - Dev-only (returns 404 in production)
164
+ - Automatic floating icon injection via client component
165
+ - Suppresses asset manager request logging in dev server
166
+ - Default base path: `/api/asset-manager`
167
+ - Singleton management for HMR stability
168
+ - Composable with other `withX` plugins (`withSentryConfig`, `withBundleAnalyzer`, etc.)
169
+
114
170
  ### Other SSR Frameworks
115
171
 
116
- For SSR frameworks (Next.js, Remix, SvelteKit, Solid Start), manual script injection is required. See the **[SSR Integration Guide](./docs/SSR_INTEGRATION.md)** for setup instructions.
172
+ For SSR frameworks (Remix, SvelteKit, Solid Start), manual script injection is required. See the **[SSR Integration Guide](./docs/SSR_INTEGRATION.md)** for setup instructions.
117
173
 
118
174
  ## Configuration
119
175
 
@@ -207,6 +263,7 @@ pnpm run playground:solid
207
263
  pnpm run playground:qwik
208
264
  pnpm run playground:tanstack
209
265
  pnpm run playground:nuxt
266
+ pnpm run playground:nextjs
210
267
  ```
211
268
 
212
269
  ## License
@@ -0,0 +1,2 @@
1
+ import{j as e,r}from"./vendor-react-CZ2o2ZY4.js";import{Z as B,a0 as T,h as A,X as W,E as M,p as $,W as F,a1 as P,x as V,a2 as _,C as X,L as H,e as O}from"./vendor-icons-BoR7i9s2.js";import{c as N,g as h,B as y,F as q,u as K,a as G,b as Y,d as Z}from"./index-CA_WpBq4.js";import{S as Q,s as C,Q as J,R as ee,U as te,V as ae,a as se}from"./vendor-ui-ClWphj76.js";import"./vendor-virtual-Cr-nkJSX.js";function w({className:o,orientation:t="horizontal",...s}){return e.jsx(Q,{"data-slot":"separator",orientation:t,className:N("bg-border shrink-0 data-[orientation=horizontal]:h-px data-[orientation=horizontal]:w-full data-[orientation=vertical]:w-px data-[orientation=vertical]:self-stretch",o),...s})}const ne=r.memo(function({asset:t,onDimensionsLoad:s}){const[l,a]=r.useState(!1),i=`${h()}/api/file?path=${encodeURIComponent(t.path)}`,n=r.useCallback(u=>{const c=u.currentTarget;s?.({width:c.naturalWidth,height:c.naturalHeight})},[s]),d=r.useCallback(()=>a(!0),[]);return l?e.jsx("div",{className:"flex items-center justify-center h-full text-muted-foreground text-sm",children:"Failed to load image"}):e.jsxs("div",{className:"relative w-full aspect-square overflow-hidden",children:[e.jsx("div",{className:"absolute inset-0 checkerboard"}),e.jsx("img",{src:i,alt:t.name,className:"relative w-full h-full object-contain",onLoad:n,onError:d})]})}),re=r.memo(function({asset:t}){const[s,l]=r.useState(!1),a=`${h()}/api/file?path=${encodeURIComponent(t.path)}`,i=`${h()}/api/thumbnail?path=${encodeURIComponent(t.path)}`,n=t.path.split(".").pop()?.toUpperCase()||"VIDEO",d=r.useCallback(()=>l(!0),[]),u=r.useCallback(()=>{const c=document.createElement("a");c.href=a,c.download=t.name,c.click()},[a,t.name]);if(s){const c=n==="AVI";return e.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-4 p-6 text-center",children:[e.jsx(B,{className:"w-12 h-12 text-yellow-500",weight:"duotone"}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("h3",{className:"font-semibold text-foreground",children:"Unable to play video"}),e.jsx("p",{className:"text-sm text-muted-foreground max-w-md",children:c?e.jsx(e.Fragment,{children:"This AVI file uses a codec that isn't supported by your browser. Most AVI files use legacy codecs (DivX, Xvid) that HTML5 video can't play."}):e.jsxs(e.Fragment,{children:["This ",n," video format or codec isn't supported by your browser's HTML5 video player."]})}),c&&e.jsx("p",{className:"text-xs text-muted-foreground max-w-md pt-2",children:"💡 Tip: Convert to MP4 (H.264) or WebM for browser compatibility"})]}),e.jsxs(y,{onClick:u,variant:"outline",size:"sm",className:"gap-2",children:[e.jsx(T,{className:"w-4 h-4"}),"Download Video"]})]})}return e.jsx("div",{className:"relative w-full aspect-video bg-black rounded-lg overflow-hidden",children:e.jsx("video",{src:a,poster:i,controls:!0,className:"w-full h-full object-contain",onError:d,preload:"metadata",children:"Your browser does not support the video tag."})})}),oe=r.memo(function({asset:t}){const[s,l]=r.useState(!1),a=`${h()}/api/file?path=${encodeURIComponent(t.path)}`,i=r.useCallback(()=>l(!0),[]);return s?e.jsx("div",{className:"flex items-center justify-center h-full text-muted-foreground text-sm",children:"Failed to load audio"}):e.jsxs("div",{className:"flex flex-col items-center justify-center gap-4 p-6 bg-muted/30 rounded-lg",children:[e.jsx("div",{className:"w-20 h-20 rounded-full bg-primary/10 flex items-center justify-center",children:e.jsx(A,{weight:"duotone",className:"w-10 h-10 text-primary"})}),e.jsx("audio",{src:a,controls:!0,className:"w-full max-w-[280px]",onError:i,preload:"metadata",children:"Your browser does not support the audio tag."})]})}),E=5e4,ie=r.memo(function({asset:t}){const[s,l]=r.useState(null),[a,i]=r.useState(!0),[n,d]=r.useState(null),[u,c]=r.useState(!1);return r.useEffect(()=>{(async()=>{i(!0),d(null),c(!1);try{const b=await fetch(`${h()}/api/file?path=${encodeURIComponent(t.path)}`);if(!b.ok)throw new Error("Failed to fetch file");const j=await b.text();j.length>E?(l(j.slice(0,E)),c(!0)):l(j)}catch(b){d(b instanceof Error?b.message:"Failed to load file")}finally{i(!1)}})()},[t.path]),a?e.jsx("div",{className:"flex items-center justify-center h-40",children:e.jsx(W,{className:"w-6 h-6 animate-spin text-muted-foreground"})}):n?e.jsx("div",{className:"flex items-center justify-center h-40 text-muted-foreground text-sm",children:n}):e.jsxs("div",{className:"relative",children:[e.jsx("pre",{className:"bg-muted/50 rounded-lg p-4 overflow-x-auto text-xs font-mono max-h-80 overflow-y-auto",children:e.jsx("code",{className:"text-foreground/80 whitespace-pre-wrap wrap-break-word",children:s})}),u&&e.jsx("div",{className:"absolute bottom-0 left-0 right-0 h-12 bg-linear-to-t from-muted/80 to-transparent flex items-end justify-center pb-2",children:e.jsx("span",{className:"text-xs text-muted-foreground bg-muted px-2 py-1 rounded",children:"Content truncated (file too large)"})})]})}),le="The quick brown fox jumps over the lazy dog",de=[14,18,24,32,48],ce=r.memo(function({asset:t}){const[s,l]=r.useState(!1),[a,i]=r.useState(!1),d=`preview-font-${r.useId().replace(/:/g,"-")}`,u=`${h()}/api/file?path=${encodeURIComponent(t.path)}`;return r.useEffect(()=>((async()=>{try{const m=new FontFace(d,`url(${u})`);await m.load(),document.fonts.add(m),l(!0)}catch(m){console.error("Failed to load font:",m),i(!0)}})(),()=>{document.fonts.forEach(m=>{m.family===d&&document.fonts.delete(m)})}),[u,d]),a?e.jsx("div",{className:"flex items-center justify-center h-40 text-muted-foreground text-sm",children:"Failed to load font"}):s?e.jsxs("div",{className:"space-y-4 p-4 bg-muted/30 rounded-lg overflow-hidden",children:[de.map(c=>e.jsxs("div",{className:"space-y-1 overflow-hidden",children:[e.jsxs("span",{className:"text-[10px] text-muted-foreground font-mono",children:[c,"px"]}),e.jsx("p",{style:{fontFamily:d,fontSize:c},className:"text-foreground leading-tight truncate",children:le})]},c)),e.jsxs("div",{className:"pt-4 border-t border-border overflow-hidden",children:[e.jsx("span",{className:"text-[10px] text-muted-foreground font-mono mb-2 block",children:"Characters"}),e.jsx("p",{style:{fontFamily:d},className:"text-lg text-foreground leading-relaxed break-all",children:"ABCDEFGHIJKLMNOPQRSTUVWXYZ"}),e.jsx("p",{style:{fontFamily:d},className:"text-lg text-foreground leading-relaxed break-all",children:"abcdefghijklmnopqrstuvwxyz"}),e.jsx("p",{style:{fontFamily:d},className:"text-lg text-foreground leading-relaxed break-all",children:"0123456789 !@#$%^&*()"})]})]}):e.jsx("div",{className:"flex items-center justify-center h-40 text-muted-foreground text-sm",children:"Loading font..."})}),S=r.memo(function({asset:t}){return e.jsxs("div",{className:"flex flex-col items-center justify-center gap-4 p-8 bg-muted/30 rounded-lg",children:[e.jsx(q,{extension:t.extension,className:"w-20 h-20"}),e.jsxs("div",{className:"text-center",children:[e.jsx("p",{className:"text-sm font-medium text-foreground mb-1",children:t.name}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Download to preview this file type"})]})]})}),ue=r.memo(function({asset:t,onDimensionsLoad:s}){const l=()=>{switch(t.type){case"image":return e.jsx(ne,{asset:t,onDimensionsLoad:s});case"video":return e.jsx(re,{asset:t});case"audio":return e.jsx(oe,{asset:t});case"data":case"text":return e.jsx(ie,{asset:t});case"font":return e.jsx(ce,{asset:t});case"document":if(t.extension===".pdf"){const a=`${h()}/api/file?path=${encodeURIComponent(t.path)}`;return e.jsx("iframe",{src:a,className:"w-full aspect-[3/4] rounded-lg border border-border",title:t.name})}return e.jsx(S,{asset:t});default:return e.jsx(S,{asset:t})}};return e.jsxs("div",{className:"p-4 overflow-hidden",children:[e.jsx("h3",{className:"text-xs font-medium text-muted-foreground mb-3",children:"Preview"}),l()]})});function me(o){if(o===0)return"0 B";const t=1024,s=["B","KB","MB","GB"],l=Math.floor(Math.log(o)/Math.log(t));return parseFloat((o/Math.pow(t,l)).toFixed(1))+" "+s[l]}function xe(o){const t=new Date(o),l=new Date().getTime()-t.getTime(),a=Math.floor(l/(1e3*60*60*24)),i=new Intl.DateTimeFormat("en-GB",{day:"2-digit",month:"2-digit",year:"numeric",hour:"2-digit",minute:"2-digit",second:"2-digit"}).format(t);let n="";if(a===0)n="today";else if(a===1)n="yesterday";else if(a<30)n=`${a} days ago`;else if(a<365){const d=Math.floor(a/30);n=`${d} ${d===1?"month":"months"} ago`}else{const d=Math.floor(a/365);n=`${d} ${d===1?"year":"years"} ago`}return`${i} (${n})`}function fe(o){return o.path.startsWith("public/")?"/"+o.path.slice(7):"/"+o.path}function he(o,t){const s=(d,u)=>u===0?d:s(u,d%u),l=s(o,t),a=o/l,i=t/l;if(a===i)return"1:1";if(a<=20&&i<=20)return`${a}:${i}`;const n=o/t;return Math.abs(n-16/9)<.01?"16:9":Math.abs(n-4/3)<.01?"4:3":Math.abs(n-3/2)<.01?"3:2":Math.abs(n-21/9)<.01?"21:9":n.toFixed(2)+":1"}function pe(o){return o.charAt(0).toUpperCase()+o.slice(1)}const v=r.memo(function({label:t,value:s,copyable:l,externalLink:a}){const[i,n]=r.useState(!1),d=r.useCallback(async()=>{try{await navigator.clipboard.writeText(s),n(!0),C.success("Copied to clipboard"),setTimeout(()=>n(!1),2e3)}catch{C.error("Failed to copy")}},[s]),u=r.useCallback(()=>{a&&window.open(a,"_blank")},[a]);return e.jsxs("div",{className:"flex items-start justify-between gap-2 py-2",children:[e.jsx("span",{className:"text-xs text-muted-foreground shrink-0",children:t}),e.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[e.jsx("span",{className:"text-xs text-foreground font-medium text-right truncate",title:s,children:s}),l&&e.jsx("button",{onClick:d,className:"p-1 rounded hover:bg-muted/50 transition-colors shrink-0","aria-label":`Copy ${t}`,children:i?e.jsx(M,{weight:"bold",className:"w-3 h-3 text-emerald-500"}):e.jsx($,{weight:"bold",className:"w-3 h-3 text-muted-foreground"})}),a&&e.jsx("button",{onClick:u,className:"p-1 rounded hover:bg-muted/50 transition-colors shrink-0","aria-label":`Open ${t} externally`,children:e.jsx(F,{weight:"bold",className:"w-3 h-3 text-muted-foreground"})})]})]})}),ge=r.memo(function({asset:t,imageDimensions:s}){const l=fe(t),a=`${h()}/api/file?path=${encodeURIComponent(t.path)}`;return e.jsxs("div",{className:"p-4",children:[e.jsx("h3",{className:"text-xs font-medium text-muted-foreground mb-2",children:"Details"}),e.jsxs("div",{className:"divide-y divide-border",children:[e.jsx(v,{label:"Filepath",value:t.absolutePath,copyable:!0,externalLink:a}),e.jsx(v,{label:"Public Path",value:l,copyable:!0}),e.jsx(v,{label:"Type",value:pe(t.type)}),s&&e.jsxs(e.Fragment,{children:[e.jsx(v,{label:"Image Size",value:`${s.width} x ${s.height}`}),e.jsx(v,{label:"Aspect Ratio",value:he(s.width,s.height)})]}),e.jsx(v,{label:"File size",value:me(t.size)}),e.jsx(v,{label:"Last modified",value:xe(t.mtime)})]})]})}),be={"es-import":"ES Import","dynamic-import":"Dynamic Import",require:"Require","css-url":"CSS url()","html-src":"HTML src","html-href":"HTML href"},ve=r.memo(function({asset:t}){const{importers:s,loading:l,openInEditor:a}=K(t.path);return e.jsxs("div",{className:"p-4",children:[e.jsxs("h3",{className:"text-xs font-medium text-muted-foreground mb-2",children:["Importers ",!l&&`(${s.length})`]}),l?e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground py-2",children:[e.jsx(P,{className:"w-4 h-4 animate-spin"}),e.jsx("span",{className:"text-xs",children:"Scanning..."})]}):s.length===0?e.jsx("p",{className:"text-xs text-muted-foreground py-2",children:"No imports found"}):e.jsx("div",{className:"space-y-1",children:s.map((i,n)=>e.jsxs("button",{onClick:()=>a(i),className:"w-full text-left p-2 rounded-md hover:bg-muted/50 transition-colors group",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx(V,{weight:"bold",className:"w-3.5 h-3.5 text-muted-foreground shrink-0"}),e.jsx("span",{className:"text-xs font-medium truncate",children:i.filePath}),e.jsxs("span",{className:"text-xs text-muted-foreground shrink-0",children:[":",i.line]})]}),e.jsx(F,{weight:"bold",className:"w-3.5 h-3.5 text-muted-foreground opacity-0 group-hover:opacity-100 transition-opacity shrink-0"})]}),e.jsxs("div",{className:"mt-1 pl-5",children:[e.jsx("code",{className:"text-[10px] text-muted-foreground font-mono truncate block",children:i.snippet}),e.jsx("span",{className:"text-[10px] text-muted-foreground/70",children:be[i.importType]||i.importType})]})]},`${i.filePath}:${i.line}:${n}`))})]})});function je(o){const[t,s]=r.useState([]),[l,a]=r.useState(!0),[i,n]=r.useState(null),{subscribe:d}=G(),u=r.useCallback(async()=>{if(!o){s([]),a(!1);return}try{a(!0),n(null);const c=await fetch(`${h()}/api/duplicates?hash=${encodeURIComponent(o)}`);if(!c.ok)throw new Error("Failed to fetch duplicates");const m=await c.json();s(m.duplicates)}catch(c){n(c instanceof Error?c.message:"Unknown error")}finally{a(!1)}},[o]);return r.useEffect(()=>{u();const c=d("asset-manager:duplicates-update",()=>{u()}),m=d("asset-manager:update",()=>{u()});return()=>{c(),m()}},[o,u,d]),{duplicates:t,loading:l,error:i}}function we(o){if(o===0)return"0 B";const t=1024,s=["B","KB","MB","GB"],l=Math.floor(Math.log(o)/Math.log(t));return parseFloat((o/Math.pow(t,l)).toFixed(1))+" "+s[l]}const ye=r.memo(function({asset:t,onSelectAsset:s}){const{duplicates:l,loading:a}=je(t.contentHash),i=l.filter(n=>n.path!==t.path);return e.jsxs("div",{className:"p-4",children:[e.jsxs("h3",{className:"text-xs font-medium text-muted-foreground mb-2",children:["Duplicates ",!a&&`(${i.length})`]}),a?e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground py-2",children:[e.jsx(P,{className:"w-4 h-4 animate-spin"}),e.jsx("span",{className:"text-xs",children:"Scanning..."})]}):i.length===0?e.jsx("p",{className:"text-xs text-muted-foreground py-2",children:"No duplicates found"}):e.jsx("div",{className:"space-y-1",children:i.map(n=>e.jsxs("button",{onClick:()=>s?.(n),className:"w-full text-left p-2 rounded-md hover:bg-muted/50 transition-colors group",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx($,{weight:"bold",className:"w-3.5 h-3.5 text-blue-400 shrink-0"}),e.jsx("span",{className:"text-xs font-medium truncate",children:n.name})]}),e.jsx("span",{className:"text-xs text-muted-foreground font-mono tabular-nums shrink-0",children:we(n.size)})]}),e.jsx("div",{className:"mt-1 pl-5",children:e.jsxs("div",{className:"flex items-center gap-1 text-[10px] text-muted-foreground",children:[e.jsx(_,{weight:"fill",className:"w-3 h-3"}),e.jsx("span",{className:"truncate",children:n.directory})]})})]},n.id))})]})}),Ne=r.memo(function({asset:t}){const s=`${h()}/api/file?path=${encodeURIComponent(t.path)}`,{isIgnored:l,toggleIgnored:a}=Y(),i=l(t.path),n=r.useCallback(()=>{const u=document.createElement("a");u.href=s,u.download=t.name,document.body.appendChild(u),u.click(),document.body.removeChild(u)},[s,t.name]),d=r.useCallback(()=>{a(t.path)},[t.path,a]);return e.jsxs("div",{className:"p-4",children:[e.jsx("h3",{className:"text-xs font-medium text-muted-foreground mb-3",children:"Actions"}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(y,{variant:"secondary",size:"sm",onClick:n,className:"w-full justify-start gap-2",children:[e.jsx(T,{weight:"bold",className:"w-4 h-4"}),"Download"]}),t.importersCount===0&&e.jsx(y,{variant:i?"default":"outline",size:"sm",onClick:d,className:"w-full justify-start gap-2",title:i?"Remove from ignore list - asset will appear in unused filter again":"Mark as intentionally unused - won't appear in unused filter",children:i?e.jsxs(e.Fragment,{children:[e.jsx(X,{weight:"bold",className:"w-4 h-4"}),"Unmark as Ignored"]}):e.jsxs(e.Fragment,{children:[e.jsx(H,{weight:"bold",className:"w-4 h-4"}),"Mark as Ignored"]})})]})]})});function ke({className:o,orientation:t="horizontal",...s}){return e.jsx(J,{"data-slot":"tabs","data-orientation":t,className:N("gap-2 group/tabs flex data-[orientation=horizontal]:flex-col",o),...s})}const Ce=se("rounded-lg p-[3px] group-data-horizontal/tabs:h-8 data-[variant=line]:rounded-none group/tabs-list text-muted-foreground inline-flex w-fit items-center justify-center group-data-[orientation=vertical]/tabs:h-fit group-data-[orientation=vertical]/tabs:flex-col",{variants:{variant:{default:"bg-muted",line:"gap-1 bg-transparent"}},defaultVariants:{variant:"default"}});function Ie({className:o,variant:t="default",...s}){return e.jsx(ee,{"data-slot":"tabs-list","data-variant":t,className:N(Ce({variant:t}),o),...s})}function $e({className:o,...t}){return e.jsx(te,{"data-slot":"tabs-trigger",className:N("gap-1.5 rounded-md border border-transparent px-1.5 py-0.5 text-xs font-medium group-data-vertical/tabs:py-[calc(--spacing(1.25))] [&_svg:not([class*='size-'])]:size-3.5 focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:outline-ring text-foreground/60 hover:text-foreground dark:text-muted-foreground dark:hover:text-foreground relative inline-flex h-[calc(100%-1px)] flex-1 items-center justify-center whitespace-nowrap transition-all group-data-[orientation=vertical]/tabs:w-full group-data-[orientation=vertical]/tabs:justify-start focus-visible:ring-[3px] focus-visible:outline-1 disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0","group-data-[variant=line]/tabs-list:bg-transparent group-data-[variant=line]/tabs-list:data-active:bg-transparent dark:group-data-[variant=line]/tabs-list:data-active:border-transparent dark:group-data-[variant=line]/tabs-list:data-active:bg-transparent","data-active:bg-background dark:data-active:text-foreground dark:data-active:border-input dark:data-active:bg-input/30 data-active:text-foreground","after:bg-foreground after:absolute after:opacity-0 after:transition-opacity group-data-[orientation=horizontal]/tabs:after:inset-x-0 group-data-[orientation=horizontal]/tabs:after:bottom-[-5px] group-data-[orientation=horizontal]/tabs:after:h-0.5 group-data-[orientation=vertical]/tabs:after:inset-y-0 group-data-[orientation=vertical]/tabs:after:-right-1 group-data-[orientation=vertical]/tabs:after:w-0.5 group-data-[variant=line]/tabs-list:data-active:after:opacity-100",o),...t})}function Ee({className:o,...t}){return e.jsx(ae,{"data-slot":"tabs-content",className:N("text-xs/relaxed flex-1 outline-none",o),...t})}const Se=r.memo(function({asset:t}){const[s,l]=r.useState(null),a=r.useMemo(()=>Z(t),[t]),i=r.useCallback(async(n,d)=>{try{await navigator.clipboard.writeText(n),l(d),C.success("Copied to clipboard"),setTimeout(()=>l(null),2e3)}catch{C.error("Failed to copy")}},[]);return a.length===0?null:e.jsx("div",{className:"p-4",children:e.jsxs(ke,{defaultValue:a[0].type,children:[e.jsx("div",{className:"flex items-center justify-between mb-3",children:e.jsx(Ie,{variant:"line",activateOnFocus:!0,children:a.map(n=>e.jsx($e,{value:n.type,children:n.label},n.type))})}),a.map(n=>e.jsx(Ee,{value:n.type,children:e.jsxs("div",{className:"relative",children:[e.jsx("pre",{className:"bg-muted/50 rounded-lg p-4 pr-12 overflow-x-auto text-xs font-mono",children:e.jsx("code",{className:"text-foreground/80",children:n.code})}),e.jsx(y,{variant:"ghost",size:"icon-sm",className:"absolute top-2 right-2",onClick:()=>i(n.code,n.type),"aria-label":"Copy code",children:s===n.type?e.jsx(M,{weight:"bold",className:"w-4 h-4 text-emerald-500"}):e.jsx($,{weight:"bold",className:"w-4 h-4"})})]})},n.type))]})})}),Te=300,Me=600,Fe=384,Le=r.memo(function({asset:t,onClose:s,onSelectAsset:l,flatAssetList:a=[],onAssetChange:i}){const n=r.useRef(null),[d,u]=r.useState({assetId:t.id,dimensions:null}),[c,m]=r.useState(Fe),[b,j]=r.useState(!1),D=d.assetId===t.id?d.dimensions:null,z=r.useCallback(f=>{f.preventDefault(),j(!0);const x=f.clientX,k=c,I=p=>{const U=x-p.clientX,L=Math.min(Math.max(k+U,Te),Me);m(L)},g=()=>{j(!1),document.removeEventListener("mousemove",I),document.removeEventListener("mouseup",g)};document.addEventListener("mousemove",I),document.addEventListener("mouseup",g)},[c]);r.useEffect(()=>{const f=x=>{x.key==="Escape"&&(x.preventDefault(),s())};return document.addEventListener("keydown",f),()=>document.removeEventListener("keydown",f)},[s]),r.useEffect(()=>{if(!a.length||!i)return;const f=x=>{const k=x.target;if(k.tagName==="INPUT"||k.tagName==="TEXTAREA")return;const g=a.findIndex(p=>p.id===t.id);if(g!==-1){if(x.key==="ArrowRight"||x.key==="j"){x.preventDefault();const p=Math.min(g+1,a.length-1);p!==g&&i(a[p])}else if(x.key==="ArrowLeft"||x.key==="k"){x.preventDefault();const p=Math.max(g-1,0);p!==g&&i(a[p])}}};return document.addEventListener("keydown",f),()=>document.removeEventListener("keydown",f)},[t.id,a,i]),r.useEffect(()=>{n.current?.focus()},[]);const R=r.useCallback(f=>{u({assetId:t.id,dimensions:f})},[t.id]);return e.jsxs("aside",{role:"region","aria-label":`Preview of ${t.name}`,style:{width:typeof window<"u"&&window.innerWidth>=768?c:void 0},className:`fixed top-0 right-0 z-50 h-screen md:h-screen border-l border-border bg-card/80 backdrop-blur-sm flex flex-col overflow-hidden animate-slide-in-right
2
+ max-md:top-auto max-md:bottom-0 max-md:left-0 max-md:right-0 max-md:h-[85vh] max-md:w-full! max-md:rounded-t-2xl max-md:border-l-0 max-md:border-t`,children:[e.jsx("div",{onMouseDown:z,className:`absolute left-0 top-0 h-full w-1.5 cursor-col-resize hover:bg-primary/50 active:bg-primary/70 transition-colors z-10 max-md:hidden ${b?"bg-primary/70":""}`,"aria-hidden":"true"}),e.jsx("div",{className:"md:hidden flex justify-center pt-2 pb-1","aria-hidden":"true",children:e.jsx("div",{className:"w-10 h-1 rounded-full bg-muted-foreground/30"})}),e.jsxs("div",{className:"flex items-center justify-between p-3 md:p-4 border-b border-border shrink-0",children:[e.jsx("h2",{className:"text-sm font-semibold text-foreground truncate pr-2 max-w-[80%]",title:t.name,children:t.name}),e.jsx(y,{ref:n,variant:"ghost",size:"icon-sm",onClick:s,"aria-label":"Close preview panel",className:"shrink-0 min-h-11 min-w-11 md:min-h-0 md:min-w-0",children:e.jsx(O,{weight:"bold",className:"w-5 h-5 md:w-4 md:h-4"})})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto",children:[e.jsx(ue,{asset:t,onDimensionsLoad:R}),e.jsx(w,{}),e.jsx(ge,{asset:t,imageDimensions:D}),e.jsx(w,{}),e.jsx(ve,{asset:t}),(t.duplicatesCount??0)>0&&e.jsxs(e.Fragment,{children:[e.jsx(w,{}),e.jsx(ye,{asset:t,onSelectAsset:l})]}),e.jsx(w,{}),e.jsx(Ne,{asset:t}),e.jsx(w,{}),e.jsx(Se,{asset:t})]})]})});export{Le as PreviewPanel};
@@ -0,0 +1,134 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-4W13jd9f.js","assets/vendor-react-CZ2o2ZY4.js","assets/vendor-icons-BoR7i9s2.js","assets/vendor-ui-ClWphj76.js","assets/vendor-virtual-Cr-nkJSX.js"])))=>i.map(i=>d[i]);
2
+ import{r as n,j as e,e as ds,c as us}from"./vendor-react-CZ2o2ZY4.js";import{c as ms,o as St,e as je,a as dt,b as ut,d as fs,t as $t,f as mt,g as Q,h as ie,i as Re,j as X,k as Oe,l as _e,m as we,n as ft,p as me,q as zt,r as Z,s as ps,u as pt,v as ht,w as xt,x as ae,y as hs,z as xs,A as gs,B as It,C as gt,D as bs,E as W,F as vs,G as ws,H as js,I as ys,J as Ns,K as Dt,L as Et,M as Le,N as At,O as ks,P as Cs,Q as Ss,R as $s,S as bt,T as zs,U as Is,V as Ds,W as Es,X as As,Y as Ps,Z as Fs,_ as Ms,$ as Ts}from"./vendor-icons-BoR7i9s2.js";import{t as Rs,c as Os,B as _s,a as Ls,M as Us,b as Bs,d as Pt,e as Ft,f as Mt,g as Tt,C as Vs,h as Gs,S as Hs,i as Ks,j as Zs,k as Js,l as Ws,A as Ys,D as Rt,m as qs,n as Qs,o as Ot,p as _t,q as Lt,r as Xs,s as D,u as ea,v as ta,w as sa,x as aa,y as na,z as oa,E as ra,F as ia,G as la,H as ca,I as da,J as ua,K as ma,L as fa,N as pa,O as ha,P as xa,T as ga}from"./vendor-ui-ClWphj76.js";import{u as ba}from"./vendor-virtual-Cr-nkJSX.js";(function(){const s=document.createElement("link").relList;if(s&&s.supports&&s.supports("modulepreload"))return;for(const o of document.querySelectorAll('link[rel="modulepreload"]'))r(o);new MutationObserver(o=>{for(const l of o)if(l.type==="childList")for(const u of l.addedNodes)u.tagName==="LINK"&&u.rel==="modulepreload"&&r(u)}).observe(document,{childList:!0,subtree:!0});function a(o){const l={};return o.integrity&&(l.integrity=o.integrity),o.referrerPolicy&&(l.referrerPolicy=o.referrerPolicy),o.crossOrigin==="use-credentials"?l.credentials="include":o.crossOrigin==="anonymous"?l.credentials="omit":l.credentials="same-origin",l}function r(o){if(o.ep)return;o.ep=!0;const l=a(o);fetch(o.href,l)}})();const va="modulepreload",wa=function(t){return"/__asset_manager__/"+t},vt={},ja=function(s,a,r){let o=Promise.resolve();if(a&&a.length>0){let d=function(c){return Promise.all(c.map(m=>Promise.resolve(m).then(p=>({status:"fulfilled",value:p}),p=>({status:"rejected",reason:p}))))};document.getElementsByTagName("link");const u=document.querySelector("meta[property=csp-nonce]"),i=u?.nonce||u?.getAttribute("nonce");o=d(a.map(c=>{if(c=wa(c),c in vt)return;vt[c]=!0;const m=c.endsWith(".css"),p=m?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${c}"]${p}`))return;const g=document.createElement("link");if(g.rel=m?"stylesheet":va,m||(g.as="script"),g.crossOrigin="",g.href=c,i&&g.setAttribute("nonce",i),document.head.appendChild(g),m)return new Promise((f,v)=>{g.addEventListener("load",f),g.addEventListener("error",()=>v(new Error(`Unable to preload CSS for ${c}`)))})}))}function l(u){const i=new Event("vite:preloadError",{cancelable:!0});if(i.payload=u,window.dispatchEvent(i),!i.defaultPrevented)throw u}return o.then(u=>{for(const i of u||[])i.status==="rejected"&&l(i.reason);return s().catch(l)})},Ut=n.forwardRef(function({value:s,onChange:a,searching:r,onFocus:o},l){return e.jsxs("div",{className:"relative group",children:[e.jsx("div",{className:"absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none",children:r?e.jsx(ms,{weight:"bold",className:"w-4 h-4 text-muted-foreground animate-spin"}):e.jsx(St,{weight:"bold",className:"w-4 h-4 text-muted-foreground group-focus-within:text-primary transition-colors"})}),e.jsx("input",{ref:l,type:"text",value:s,onChange:u=>a(u.target.value),onFocus:o,placeholder:"Search assets...",className:`
3
+ w-full pl-9 sm:pl-10 pr-10 sm:pr-20 py-2
4
+ bg-input/50 border border-border rounded-lg
5
+ text-sm text-foreground placeholder:text-muted-foreground
6
+ focus:outline-none focus:ring-2 focus:ring-primary/50 focus:border-primary/50
7
+ transition-all duration-200
8
+ `}),e.jsx("div",{className:"absolute inset-y-0 right-0 pr-2 flex items-center gap-1",children:s?e.jsx("button",{onClick:()=>a(""),className:"p-1 rounded-md hover:bg-muted transition-colors","aria-label":"Clear search",children:e.jsx(je,{weight:"bold",className:"w-3.5 h-3.5 text-muted-foreground hover:text-foreground"})}):e.jsx("kbd",{className:"hidden sm:flex items-center px-1.5 py-0.5 rounded border border-border bg-muted/50 text-[10px] font-mono text-muted-foreground",children:e.jsx("span",{children:"/"})})})]})});Ut.displayName="SearchBar";function w(...t){return Rs(Os(t))}const ya=Ls("focus-visible:border-ring focus-visible:ring-ring/30 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:aria-invalid:border-destructive/50 rounded-md border border-transparent bg-clip-padding text-xs/relaxed font-medium focus-visible:ring-[2px] aria-invalid:ring-[2px] [&_svg:not([class*='size-'])]:size-4 inline-flex items-center justify-center whitespace-nowrap transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none shrink-0 [&_svg]:shrink-0 outline-none group/button select-none",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/80",outline:"border-border dark:bg-input/30 hover:bg-input/50 hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80 aria-expanded:bg-secondary aria-expanded:text-secondary-foreground",ghost:"hover:bg-muted hover:text-foreground dark:hover:bg-muted/50 aria-expanded:bg-muted aria-expanded:text-foreground",destructive:"bg-destructive/10 hover:bg-destructive/20 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/20 text-destructive focus-visible:border-destructive/40 dark:hover:bg-destructive/30",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-7 gap-1 px-2 text-xs/relaxed has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3.5",xs:"h-5 gap-1 rounded-sm px-2 text-[0.625rem] has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-2.5",sm:"h-6 gap-1 px-2 text-xs/relaxed has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3",lg:"h-8 gap-1 px-2.5 text-xs/relaxed has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2 [&_svg:not([class*='size-'])]:size-4",icon:"size-7 [&_svg:not([class*='size-'])]:size-3.5","icon-xs":"size-5 rounded-sm [&_svg:not([class*='size-'])]:size-2.5","icon-sm":"size-6 [&_svg:not([class*='size-'])]:size-3","icon-lg":"size-8 [&_svg:not([class*='size-'])]:size-4"}},defaultVariants:{variant:"default",size:"default"}});function M({className:t,variant:s="default",size:a="default",...r}){return e.jsx(_s,{"data-slot":"button",className:w(ya({variant:s,size:a,className:t})),...r})}function Bt({...t}){return e.jsx(Us,{"data-slot":"dropdown-menu",...t})}function Vt({...t}){return e.jsx(Bs,{"data-slot":"dropdown-menu-trigger",...t})}function Gt({align:t="start",alignOffset:s=0,side:a="bottom",sideOffset:r=4,positionMethod:o="fixed",className:l,...u}){return e.jsx(Pt,{children:e.jsx(Ft,{className:"isolate z-50 outline-none",align:t,alignOffset:s,side:a,sideOffset:r,positionMethod:o,children:e.jsx(Mt,{"data-slot":"dropdown-menu-content",className:w("data-open:animate-in data-closed:animate-out data-closed:fade-out-0 data-open:fade-in-0 data-closed:zoom-out-95 data-open:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 ring-foreground/10 bg-popover text-popover-foreground min-w-32 rounded-lg p-1 shadow-md ring-1 duration-100 data-[side=inline-start]:slide-in-from-right-2 data-[side=inline-end]:slide-in-from-left-2 z-50 max-h-(--available-height) w-(--anchor-width) origin-(--transform-origin) overflow-x-hidden overflow-y-auto outline-none data-closed:overflow-hidden",l),...u})})})}function Pe({className:t,inset:s,variant:a="default",...r}){return e.jsx(Tt,{"data-slot":"dropdown-menu-item","data-inset":s,"data-variant":a,className:w("focus:bg-accent focus:text-accent-foreground data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 dark:data-[variant=destructive]:focus:bg-destructive/20 data-[variant=destructive]:focus:text-destructive data-[variant=destructive]:*:[svg]:text-destructive not-data-[variant=destructive]:focus:**:text-accent-foreground min-h-7 gap-2 rounded-md px-2 py-1 text-xs/relaxed [&_svg:not([class*='size-'])]:size-3.5 group/dropdown-menu-item relative flex cursor-default items-center outline-hidden select-none data-disabled:pointer-events-none data-disabled:opacity-50 data-[inset]:pl-8 [&_svg]:pointer-events-none [&_svg]:shrink-0",t),...r})}const Na={theme:"system",setTheme:()=>null},Ht=n.createContext(Na);function ka({children:t,defaultTheme:s="system",storageKey:a="vite-asset-manager-theme",...r}){const[o,l]=n.useState(()=>localStorage.getItem(a)||s);n.useEffect(()=>{const i=window.document.documentElement,d=window.matchMedia("(prefers-color-scheme: dark)"),c=m=>{i.classList.remove("light","dark"),i.classList.add(m)};if(o==="system"){c(d.matches?"dark":"light");const m=p=>{c(p.matches?"dark":"light")};return d.addEventListener("change",m),()=>d.removeEventListener("change",m)}c(o)},[o]);const u={theme:o,setTheme:i=>{localStorage.setItem(a,i),l(i)}};return e.jsx(Ht.Provider,{...r,value:u,children:t})}const Ca=()=>{const t=n.useContext(Ht);if(t===void 0)throw new Error("useTheme must be used within a ThemeProvider");return t};function Sa(){const{setTheme:t}=Ca();return e.jsxs(Bt,{children:[e.jsxs(Vt,{openOnHover:!0,render:e.jsx(M,{variant:"ghost",size:"icon-xs"}),children:[e.jsx(dt,{className:"size-3 scale-100 rotate-0 transition-all dark:scale-0 dark:-rotate-90"}),e.jsx(ut,{className:"absolute size-3 scale-0 rotate-90 transition-all dark:scale-100 dark:rotate-0"}),e.jsx("span",{className:"sr-only",children:"Toggle theme"})]}),e.jsxs(Gt,{align:"end",side:"top",children:[e.jsxs(Pe,{onClick:()=>t("light"),children:[e.jsx(dt,{className:"size-3"}),"Light"]}),e.jsxs(Pe,{onClick:()=>t("dark"),children:[e.jsx(ut,{className:"size-3"}),"Dark"]}),e.jsxs(Pe,{onClick:()=>t("system"),children:[e.jsx(fs,{className:"size-3"}),"System"]})]})]})}const $a="1.0.4",za={version:$a};let ne=null;function P(){return ne!==null?ne:typeof window>"u"?(ne="/__asset_manager__",ne):(ne=window.location.pathname.replace(/\/$/,"")||"/__asset_manager__",ne)}let Y=null;const oe=new Map;let ge=null,be=0,ve=0,Ue="disconnected";const Be=new Set;function re(t){Ue!==t&&(Ue=t,Be.forEach(s=>s()))}function Ia(t){return Be.add(t),()=>Be.delete(t)}function Da(){return Ue}const Ea=10,Aa=1e3;function Kt(){if(!(Y?.readyState===EventSource.OPEN||Y?.readyState===EventSource.CONNECTING))try{re("connecting");const t=new EventSource(`${P()}/api/events`);Y=t,t.onopen=()=>{be=0,re("connected")},t.onmessage=s=>{try{const a=JSON.parse(s.data);if(a.type==="connected")return;if(a.event){const r=oe.get(a.event);r&&r.forEach(o=>o(a.data))}}catch{}},t.onerror=()=>{Y?.close(),Y=null,ve>0&&be<Ea?(be++,re("reconnecting"),ge=window.setTimeout(()=>{Kt()},Aa)):re("disconnected")}}catch{re("disconnected")}}function Pa(){ge&&(clearTimeout(ge),ge=null),Y&&(Y.close(),Y=null),be=0,re("disconnected")}function ye(){const t=n.useSyncExternalStore(Ia,Da);return n.useEffect(()=>(ve++,Kt(),()=>{ve--,ve===0&&Pa()}),[]),{subscribe:n.useCallback((a,r)=>(oe.has(a)||oe.set(a,new Set),oe.get(a).add(r),()=>{const o=oe.get(a);o&&(o.delete(r),o.size===0&&oe.delete(a))}),[]),status:t}}const Fa={violet:"text-violet-400 bg-violet-500/10",pink:"text-pink-400 bg-pink-500/10",cyan:"text-cyan-400 bg-cyan-500/10",amber:"text-amber-400 bg-amber-500/10",rose:"text-rose-400 bg-rose-500/10",emerald:"text-emerald-400 bg-emerald-500/10",purple:"text-purple-400 bg-purple-500/10",zinc:"text-zinc-400 bg-zinc-500/10",blue:"text-blue-400 bg-blue-500/10"},Ma={connecting:{dotClass:"bg-amber-500 animate-pulse",label:"Connecting..."},connected:{dotClass:"bg-emerald-500 animate-pulse",label:"Watching"},reconnecting:{dotClass:"bg-amber-500 animate-pulse",label:"Reconnecting..."},disconnected:{dotClass:"bg-zinc-500",label:"Disconnected"}},wt=n.memo(function({total:s,searchQuery:a,onSearchChange:r,searching:o,searchInputRef:l,onSearchFocus:u,selectedType:i,onTypeSelect:d,showUnusedOnly:c,onUnusedFilterToggle:m,showDuplicatesOnly:p,onDuplicatesFilterToggle:g,stats:f}){const{status:v}=ye(),{dotClass:k,label:b}=Ma[v];return e.jsxs("aside",{className:"w-full md:w-72 bg-sidebar border-r border-sidebar-border flex flex-col noise-bg h-full",children:[e.jsx("div",{className:"p-5 border-b border-sidebar-border",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"w-9 h-9 rounded-lg bg-linear-to-br from-violet-500 to-purple-600 flex items-center justify-center shadow-lg shadow-violet-500/20",children:e.jsx($t,{weight:"fill"})}),e.jsx("div",{className:`absolute -bottom-0.5 -right-0.5 w-3 h-3 rounded-full border-2 border-sidebar ${k}`})]}),e.jsxs("div",{children:[e.jsx("h1",{className:"font-mono text-sm font-semibold tracking-wide text-foreground",children:"ASSET MANAGER"}),e.jsx("p",{className:"text-[10px] text-muted-foreground font-mono tracking-wider",children:"VITE PLUGIN"})]})]})}),e.jsx("div",{className:"p-4",children:e.jsx(Ut,{ref:l,value:a,onChange:r,searching:o,onFocus:u})}),e.jsx("div",{className:"px-3 sm:px-4 pb-4",children:e.jsxs("div",{className:"rounded-lg bg-card/50 border border-border p-3 sm:p-4",children:[e.jsxs("div",{className:"flex items-baseline justify-between mb-3",children:[e.jsx("span",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider",children:"Total Assets"}),e.jsx("span",{className:"font-mono text-xl sm:text-2xl font-bold text-foreground tabular-nums",children:s})]}),f&&e.jsxs("div",{className:"grid grid-cols-2 gap-1.5 sm:gap-2",children:[e.jsx(G,{icon:e.jsx(mt,{weight:"fill",className:"w-3.5 h-3.5"}),label:"Images",count:f.images,color:"violet",onClick:()=>d("image"),active:i==="image"}),e.jsx(G,{icon:e.jsx(Q,{weight:"fill",className:"w-3.5 h-3.5"}),label:"Videos",count:f.videos,color:"pink",onClick:()=>d("video"),active:i==="video"}),e.jsx(G,{icon:e.jsx(ie,{weight:"fill",className:"w-3.5 h-3.5"}),label:"Audio",count:f.audio,color:"cyan",onClick:()=>d("audio"),active:i==="audio"}),e.jsx(G,{icon:e.jsx(Re,{weight:"fill",className:"w-3.5 h-3.5"}),label:"Docs",count:f.documents,color:"amber",onClick:()=>d("document"),active:i==="document"}),e.jsx(G,{icon:e.jsx(X,{weight:"fill",className:"w-3.5 h-3.5"}),label:"Fonts",count:f.fonts,color:"rose",onClick:()=>d("font"),active:i==="font"}),e.jsx(G,{icon:e.jsx(Oe,{weight:"fill",className:"w-3.5 h-3.5"}),label:"Data",count:f.data,color:"emerald",onClick:()=>d("data"),active:i==="data"}),e.jsx(G,{icon:e.jsx(_e,{weight:"fill",className:"w-3.5 h-3.5"}),label:"Text",count:f.text,color:"purple",onClick:()=>d("text"),active:i==="text"}),e.jsx(G,{icon:e.jsx(we,{weight:"fill",className:"w-3.5 h-3.5"}),label:"Other",count:f.other,color:"zinc",onClick:()=>d("other"),active:i==="other"}),e.jsx(G,{icon:e.jsx(ft,{weight:"fill",className:"w-3.5 h-3.5"}),label:"Unused",count:f.unused,color:"amber",onClick:m,active:c}),e.jsx(G,{icon:e.jsx(me,{weight:"fill",className:"w-3.5 h-3.5"}),label:"Dupes",count:f.duplicateFiles,color:"blue",onClick:g,active:p})]})]})}),e.jsxs("div",{className:"flex-1 overflow-y-auto px-4 py-2",children:[e.jsx("div",{className:"text-[10px] font-medium text-muted-foreground uppercase tracking-wider mb-2 px-2",children:"Browse"}),e.jsxs("nav",{className:"space-y-1",children:[e.jsx(L,{icon:e.jsx(zt,{weight:"duotone",className:"w-4 h-4"}),label:"All Assets",count:s,active:i===null,onClick:()=>d(null)}),f&&e.jsxs(e.Fragment,{children:[e.jsx(L,{icon:e.jsx(mt,{weight:"duotone",className:"w-4 h-4"}),label:"Images",count:f.images,active:i==="image",onClick:()=>d("image")}),e.jsx(L,{icon:e.jsx(Q,{weight:"duotone",className:"w-4 h-4"}),label:"Videos",count:f.videos,active:i==="video",onClick:()=>d("video")}),e.jsx(L,{icon:e.jsx(ie,{weight:"duotone",className:"w-4 h-4"}),label:"Audio",count:f.audio,active:i==="audio",onClick:()=>d("audio")}),e.jsx(L,{icon:e.jsx(Re,{weight:"duotone",className:"w-4 h-4"}),label:"Documents",count:f.documents,active:i==="document",onClick:()=>d("document")}),e.jsx(L,{icon:e.jsx(X,{weight:"duotone",className:"w-4 h-4"}),label:"Fonts",count:f.fonts,active:i==="font",onClick:()=>d("font")}),e.jsx(L,{icon:e.jsx(Oe,{weight:"duotone",className:"w-4 h-4"}),label:"Data",count:f.data,active:i==="data",onClick:()=>d("data")}),e.jsx(L,{icon:e.jsx(_e,{weight:"duotone",className:"w-4 h-4"}),label:"Text",count:f.text,active:i==="text",onClick:()=>d("text")}),e.jsx(L,{icon:e.jsx(we,{weight:"duotone",className:"w-4 h-4"}),label:"Other",count:f.other,active:i==="other",onClick:()=>d("other")}),e.jsx("div",{className:"my-2 border-t border-sidebar-border"}),e.jsx(L,{icon:e.jsx(ft,{weight:"duotone",className:"w-4 h-4"}),label:"Unused Assets",count:f.unused,active:c,onClick:m}),e.jsx(L,{icon:e.jsx(me,{weight:"duotone",className:"w-4 h-4"}),label:"Duplicates",count:f.duplicateFiles,active:p,onClick:g})]})]})]}),e.jsx("div",{className:"p-4 border-t border-sidebar-border",children:e.jsxs("div",{className:"flex items-center justify-between text-[10px] text-muted-foreground",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:`w-2 h-2 rounded-full ${k}`}),e.jsx("span",{className:"font-mono",children:b})]}),e.jsxs("div",{className:"flex relative items-center gap-2",children:[e.jsx(Sa,{}),e.jsxs("span",{className:"font-mono opacity-50",children:["v",za.version]})]})]})})]})}),G=n.memo(function({icon:s,label:a,count:r,color:o,onClick:l,active:u=!1}){return e.jsxs("button",{onClick:l,className:`
9
+ relative flex items-center gap-1.5 sm:gap-2 px-2 sm:px-2.5 py-1.5 rounded-md
10
+ transition-all duration-200 ease-out
11
+ ${Fa[o]}
12
+ ${u?"shadow-[inset_0_0_12px_rgba(255,255,255,0.15)] brightness-110 scale-[1.02]":"hover:brightness-110 hover:scale-[1.01]"}
13
+ active:scale-[0.98]
14
+ focus:outline-none focus-visible:brightness-125
15
+ `,children:[u&&e.jsx("span",{className:"absolute left-0 top-1/2 -translate-y-1/2 w-0.5 h-3/5 rounded-full bg-white/40"}),s,e.jsx("span",{className:`text-[9px] sm:text-[10px] font-medium truncate transition-colors ${u?"text-foreground":"text-muted-foreground"}`,children:a}),e.jsx("span",{className:"ml-auto font-mono text-xs font-semibold tabular-nums",children:r})]})}),L=n.memo(function({icon:s,label:a,count:r,active:o=!1,onClick:l}){return e.jsxs("button",{onClick:l,className:`
16
+ w-full flex items-center gap-2.5 px-3 py-1.5 rounded-lg text-sm transition-all border
17
+ ${o?"bg-primary/10 text-primary border-primary/20":"text-muted-foreground hover:text-foreground hover:bg-card/50 border-transparent"}
18
+ `,children:[s,e.jsx("span",{className:"font-medium",children:a}),e.jsx("span",{className:`
19
+ ml-auto font-mono text-xs tabular-nums
20
+ ${o?"text-primary":"text-muted-foreground/60"}
21
+ `,children:r})]})}),Zt=new Map([["png",{icon:Z,color:"text-violet-400"}],["jpg",{icon:Z,color:"text-violet-400"}],["jpeg",{icon:Z,color:"text-violet-400"}],["gif",{icon:Z,color:"text-violet-400"}],["svg",{icon:Z,color:"text-violet-400"}],["webp",{icon:Z,color:"text-violet-400"}],["avif",{icon:Z,color:"text-violet-400"}],["ico",{icon:Z,color:"text-violet-400"}],["bmp",{icon:Z,color:"text-violet-400"}],["mp4",{icon:Q,color:"text-pink-400"}],["webm",{icon:Q,color:"text-pink-400"}],["mov",{icon:Q,color:"text-pink-400"}],["avi",{icon:Q,color:"text-pink-400"}],["ogg",{icon:Q,color:"text-pink-400"}],["mp3",{icon:ie,color:"text-cyan-400"}],["wav",{icon:ie,color:"text-cyan-400"}],["flac",{icon:ie,color:"text-cyan-400"}],["aac",{icon:ie,color:"text-cyan-400"}],["pdf",{icon:ps,color:"text-red-400"}],["doc",{icon:pt,color:"text-blue-400"}],["docx",{icon:pt,color:"text-blue-400"}],["xls",{icon:ht,color:"text-emerald-400"}],["xlsx",{icon:ht,color:"text-emerald-400"}],["ppt",{icon:xt,color:"text-orange-400"}],["pptx",{icon:xt,color:"text-orange-400"}],["txt",{icon:Re,color:"text-zinc-400"}],["woff",{icon:X,color:"text-rose-400"}],["woff2",{icon:X,color:"text-rose-400"}],["ttf",{icon:X,color:"text-rose-400"}],["otf",{icon:X,color:"text-rose-400"}],["eot",{icon:X,color:"text-rose-400"}],["json",{icon:ae,color:"text-amber-400"}],["md",{icon:_e,color:"text-purple-400"}],["csv",{icon:hs,color:"text-emerald-400"}],["js",{icon:ae,color:"text-yellow-400"}],["ts",{icon:ae,color:"text-blue-400"}],["jsx",{icon:ae,color:"text-cyan-400"}],["tsx",{icon:ae,color:"text-cyan-400"}],["css",{icon:xs,color:"text-blue-400"}],["html",{icon:ae,color:"text-orange-400"}]]),Jt={icon:we,color:"text-zinc-500"},Ve=n.memo(function({extension:s,className:a="w-12 h-12"}){const r=s.toLowerCase().replace(".",""),o=Zt.get(r)??Jt,l=o.icon;return e.jsx("div",{className:`${o.color} ${a}`,children:e.jsx(l,{weight:"duotone",className:"w-full h-full"})})});function Ta(t){const s=t.toLowerCase().replace(".","");return Zt.get(s)?.color??Jt.color}const Ra=n.memo(function({asset:s}){const a=n.useRef(null),r=n.useRef(null),[o,l]=n.useState(!1),[u,i]=n.useState(!1),d=`${P()}/api/file?path=${encodeURIComponent(s.path)}`,c=n.useCallback(()=>l(!0),[]);return n.useEffect(()=>{const m=r.current;if(!m)return;const p=new IntersectionObserver(([g])=>{i(g.isIntersecting)},{threshold:.1});return p.observe(m),()=>p.disconnect()},[]),n.useEffect(()=>{const m=a.current;m&&(u?m.play().catch(()=>{}):m.pause())},[u]),o?e.jsx("div",{className:"relative w-full h-full flex items-center justify-center bg-card",children:e.jsx(Ve,{extension:s.extension,className:"w-16 h-16"})}):e.jsxs("div",{ref:r,className:"relative w-full h-full",children:[e.jsx("video",{ref:a,src:u?d:void 0,muted:!0,loop:!0,playsInline:!0,preload:"metadata",onError:c,className:"w-full h-full object-cover"}),e.jsx("div",{className:"absolute inset-0 flex items-center justify-center pointer-events-none",children:e.jsx("div",{className:"w-8 h-8 rounded-full bg-black/40 flex items-center justify-center",children:e.jsx(gs,{weight:"fill",className:"w-4 h-4 text-white ml-0.5"})})})]})}),Oa=n.memo(function({asset:s}){const[a,r]=n.useState(!1),[o,l]=n.useState(!1),[u,i]=n.useState(!1),d=n.useRef(null),m=`card-font-${n.useId().replace(/:/g,"-")}`,p=`${P()}/api/file?path=${encodeURIComponent(s.path)}`;return n.useEffect(()=>{const g=d.current;if(!g)return;const f=new IntersectionObserver(([v])=>{v.isIntersecting&&(i(!0),f.disconnect())},{threshold:.1});return f.observe(g),()=>f.disconnect()},[]),n.useEffect(()=>u?((async()=>{try{const f=new FontFace(m,`url(${p})`);await f.load(),document.fonts.add(f),r(!0)}catch(f){console.error("Failed to load font:",f),l(!0)}})(),()=>{document.fonts.forEach(f=>{f.family===m&&document.fonts.delete(f)})}):void 0,[u,p,m]),o?e.jsx("div",{className:"relative w-full h-full flex items-center justify-center bg-card",children:e.jsx(Ve,{extension:s.extension,className:"w-16 h-16"})}):e.jsx("div",{ref:d,className:"relative w-full h-full flex items-center justify-center bg-card",children:a?e.jsx("span",{style:{fontFamily:m},className:"text-5xl text-foreground select-none",children:"Ag"}):e.jsx("div",{className:"w-6 h-6 border-2 border-muted-foreground/30 border-t-muted-foreground rounded-full animate-spin"})})});function _a({...t}){return e.jsx(Vs,{"data-slot":"context-menu",...t})}function La({className:t,...s}){return e.jsx(Gs,{"data-slot":"context-menu-trigger",className:w("select-none",t),...s})}function Wt({className:t,align:s="start",alignOffset:a=4,side:r="right",sideOffset:o=0,...l}){return e.jsx(Pt,{children:e.jsx(Ft,{className:"isolate z-50 outline-none",align:s,alignOffset:a,side:r,sideOffset:o,children:e.jsx(Mt,{"data-slot":"context-menu-content",className:w("data-open:animate-in data-closed:animate-out data-closed:fade-out-0 data-open:fade-in-0 data-closed:zoom-out-95 data-open:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 ring-foreground/10 bg-popover text-popover-foreground min-w-32 rounded-lg p-1 shadow-md ring-1 duration-100 data-[side=inline-start]:slide-in-from-right-2 data-[side=inline-end]:slide-in-from-left-2 z-50 max-h-(--available-height) origin-(--transform-origin) overflow-x-hidden overflow-y-auto outline-none",t),...l})})})}function Ua({...t}){return e.jsx(Js,{"data-slot":"context-menu-group",...t})}function Ba({className:t,inset:s,...a}){return e.jsx(Ws,{"data-slot":"context-menu-label","data-inset":s,className:w("text-muted-foreground px-2 py-1.5 text-xs data-[inset]:pl-8",t),...a})}function J({className:t,inset:s,variant:a="default",...r}){return e.jsx(Tt,{"data-slot":"context-menu-item","data-inset":s,"data-variant":a,className:w("focus:bg-accent focus:text-accent-foreground data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 dark:data-[variant=destructive]:focus:bg-destructive/20 data-[variant=destructive]:focus:text-destructive data-[variant=destructive]:*:[svg]:text-destructive not-data-[variant=destructive]:focus:**:text-accent-foreground min-h-7 gap-2 rounded-md px-2 py-1 text-xs/relaxed [&_svg:not([class*='size-'])]:size-3.5 group/context-menu-item relative flex cursor-default items-center outline-hidden select-none data-disabled:pointer-events-none data-disabled:opacity-50 data-[inset]:pl-8 [&_svg]:pointer-events-none [&_svg]:shrink-0",t),...r})}function Va({...t}){return e.jsx(Ks,{"data-slot":"context-menu-sub",...t})}function Ga({className:t,inset:s,children:a,...r}){return e.jsxs(Zs,{"data-slot":"context-menu-sub-trigger","data-inset":s,className:w("focus:bg-accent focus:text-accent-foreground data-open:bg-accent data-open:text-accent-foreground not-data-[variant=destructive]:focus:**:text-accent-foreground min-h-7 gap-2 rounded-md px-2 py-1 text-xs [&_svg:not([class*='size-'])]:size-3.5 flex cursor-default items-center outline-hidden select-none data-[inset]:pl-8 [&_svg]:pointer-events-none [&_svg]:shrink-0",t),...r,children:[a,e.jsx(It,{className:"ml-auto"})]})}function Ha({...t}){return e.jsx(Wt,{"data-slot":"context-menu-sub-content",className:"shadow-lg",side:"right",...t})}function ue({className:t,...s}){return e.jsx(Hs,{"data-slot":"context-menu-separator",className:w("bg-border/50 -mx-1 my-1 h-px",t),...s})}function Ge({...t}){return e.jsx(Ys,{"data-slot":"alert-dialog",...t})}function jt({...t}){return e.jsx(Xs,{"data-slot":"alert-dialog-trigger",...t})}function Ka({...t}){return e.jsx(_t,{"data-slot":"alert-dialog-portal",...t})}function Za({className:t,...s}){return e.jsx(Lt,{"data-slot":"alert-dialog-overlay",className:w("data-open:animate-in data-closed:animate-out data-closed:fade-out-0 data-open:fade-in-0 bg-black/80 duration-100 supports-backdrop-filter:backdrop-blur-xs fixed inset-0 isolate z-50",t),...s})}function He({className:t,size:s="default",...a}){return e.jsxs(Ka,{children:[e.jsx(Za,{}),e.jsx(Rt,{"data-slot":"alert-dialog-content","data-size":s,className:w("data-open:animate-in data-closed:animate-out data-closed:fade-out-0 data-open:fade-in-0 data-closed:zoom-out-95 data-open:zoom-in-95 bg-background ring-foreground/10 gap-3 rounded-xl p-4 ring-1 duration-100 data-[size=default]:max-w-xs data-[size=sm]:max-w-64 data-[size=default]:sm:max-w-sm group/alert-dialog-content fixed top-1/2 left-1/2 z-50 grid w-full -translate-x-1/2 -translate-y-1/2 outline-none",t),...a})]})}function Ke({className:t,...s}){return e.jsx("div",{"data-slot":"alert-dialog-header",className:w("grid grid-rows-[auto_1fr] place-items-center gap-1 text-center has-data-[slot=alert-dialog-media]:grid-rows-[auto_auto_1fr] has-data-[slot=alert-dialog-media]:gap-x-4 sm:group-data-[size=default]/alert-dialog-content:place-items-start sm:group-data-[size=default]/alert-dialog-content:text-left sm:group-data-[size=default]/alert-dialog-content:has-data-[slot=alert-dialog-media]:grid-rows-[auto_1fr]",t),...s})}function Ze({className:t,...s}){return e.jsx("div",{"data-slot":"alert-dialog-footer",className:w("flex flex-col-reverse gap-2 group-data-[size=sm]/alert-dialog-content:grid group-data-[size=sm]/alert-dialog-content:grid-cols-2 sm:flex-row sm:justify-end",t),...s})}function Je({className:t,...s}){return e.jsx(qs,{"data-slot":"alert-dialog-title",className:w("text-sm font-medium sm:group-data-[size=default]/alert-dialog-content:group-has-data-[slot=alert-dialog-media]/alert-dialog-content:col-start-2",t),...s})}function We({className:t,...s}){return e.jsx(Qs,{"data-slot":"alert-dialog-description",className:w("text-muted-foreground *:[a]:hover:text-foreground text-xs/relaxed text-balance md:text-pretty *:[a]:underline *:[a]:underline-offset-3",t),...s})}function Ye({className:t,...s}){return e.jsx(M,{"data-slot":"alert-dialog-action",className:w(t),...s})}function qe({className:t,variant:s="outline",size:a="default",...r}){return e.jsx(Ot,{"data-slot":"alert-dialog-cancel",className:w(t),render:e.jsx(M,{variant:s,size:a}),...r})}const Yt=n.createContext(void 0),yt="vite-asset-manager-ignored-assets";function Ja({children:t}){const[s,a]=n.useState(()=>{try{const c=localStorage.getItem(yt);return c?new Set(JSON.parse(c)):new Set}catch{return new Set}}),r=n.useRef(s);n.useEffect(()=>{r.current=s},[s]),n.useEffect(()=>{localStorage.setItem(yt,JSON.stringify([...s]))},[s]);const o=n.useCallback(c=>r.current.has(c),[]),l=n.useCallback(c=>{a(m=>new Set(m).add(c))},[]),u=n.useCallback(c=>{a(m=>{const p=new Set(m);return p.delete(c),p})},[]),i=n.useCallback(c=>{a(m=>{const p=new Set(m);return p.has(c)?p.delete(c):p.add(c),p})},[]),d=n.useCallback(()=>{a(new Set)},[]);return e.jsx(Yt.Provider,{value:{ignoredPaths:s,isIgnored:o,addIgnored:l,removeIgnored:u,toggleIgnored:i,clearAll:d},children:t})}function Qe(){const t=n.useContext(Yt);if(!t)throw new Error("useIgnoredAssets must be used within IgnoredAssetsProvider");return t}function Wa(t){const[s,a]=n.useState([]),[r,o]=n.useState(!0),[l,u]=n.useState(null),{subscribe:i}=ye(),d=n.useCallback(async()=>{if(!t){a([]),o(!1);return}try{o(!0),u(null);const m=await fetch(`${P()}/api/importers?path=${encodeURIComponent(t)}`);if(!m.ok)throw new Error("Failed to fetch importers");const p=await m.json();a(p.importers)}catch(m){u(m instanceof Error?m.message:"Unknown error")}finally{o(!1)}},[t]),c=n.useCallback(async m=>{try{const p=await fetch(`${P()}/api/open-in-editor?file=${encodeURIComponent(m.filePath)}&line=${m.line}&column=${m.column}`,{method:"POST"});if(!p.ok){const g=await p.json();throw new Error(g.error||"Failed to open editor")}}catch(p){D.error(p instanceof Error?p.message:"Failed to open in editor")}},[]);return n.useEffect(()=>(d(),i("asset-manager:importers-update",p=>{p.affectedAssets?.includes(t)&&d()})),[t,d,i]),{importers:s,loading:r,error:l,openInEditor:c}}function qt(){const[t,s]=n.useState(!1),a=n.useCallback(async r=>{s(!0);try{const o=r.map(i=>i.path),l=await fetch(`${P()}/api/bulk-delete`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({paths:o})});if(!l.ok){const i=await l.json();throw new Error(i.message||"Delete failed")}const u=await l.json();return u.deleted>0&&D.success(`Deleted ${u.deleted} asset${u.deleted>1?"s":""}`),u.failed>0&&D.error(`Failed to delete ${u.failed} asset${u.failed>1?"s":""}`),u.deleted>0}catch(o){return D.error(o instanceof Error?o.message:"Failed to delete assets"),!1}finally{s(!1)}},[]);return{isDeleting:t,bulkDelete:a}}function le(t){return t.path.startsWith("public/")?"/"+t.path.slice(7):"/"+t.path}function Ya(t){return t.name.replace(/\.[^.]+$/,"").replace(/[-_]/g," ")}function Ne(t){return t.path.startsWith("public/")}function qa(t){const s=le(t),a=Ya(t),r=Ne(t);return[{type:"html",label:"Plain Image",code:`<img
22
+ width="24"
23
+ height="24"
24
+ src="${s}"
25
+ alt="${a}"
26
+ />`},{type:"react",label:"React",code:r?`<img src="${s}" alt="${a}" />`:`import ${t.name.replace(/\.[^.]+$/,"").replace(/[-.\s]/g,"")} from '${t.path}'
27
+
28
+ <img src={${t.name.replace(/\.[^.]+$/,"").replace(/[-.\s]/g,"")}} alt="${a}" />`},{type:"vue",label:"Vue",code:r?`<template>
29
+ <img src="${s}" alt="${a}" />
30
+ </template>`:`<script setup>
31
+ import ${t.name.replace(/\.[^.]+$/,"").replace(/[-.\s]/g,"")} from '${t.path}'
32
+ <\/script>
33
+
34
+ <template>
35
+ <img :src="${t.name.replace(/\.[^.]+$/,"").replace(/[-.\s]/g,"")}" alt="${a}" />
36
+ </template>`}]}function Qa(t){const s=le(t),a=Ne(t);return[{type:"html",label:"Plain HTML",code:`<video
37
+ src="${s}"
38
+ controls
39
+ ></video>`},{type:"react",label:"React",code:a?`<video src="${s}" controls />`:`import videoSrc from '${t.path}'
40
+
41
+ <video src={videoSrc} controls />`},{type:"vue",label:"Vue",code:a?`<template>
42
+ <video src="${s}" controls></video>
43
+ </template>`:`<script setup>
44
+ import videoSrc from '${t.path}'
45
+ <\/script>
46
+
47
+ <template>
48
+ <video :src="videoSrc" controls></video>
49
+ </template>`}]}function Xa(t){const s=le(t),a=Ne(t);return[{type:"html",label:"Plain HTML",code:`<audio
50
+ src="${s}"
51
+ controls
52
+ ></audio>`},{type:"react",label:"React",code:a?`<audio src="${s}" controls />`:`import audioSrc from '${t.path}'
53
+
54
+ <audio src={audioSrc} controls />`},{type:"vue",label:"Vue",code:a?`<template>
55
+ <audio src="${s}" controls></audio>
56
+ </template>`:`<script setup>
57
+ import audioSrc from '${t.path}'
58
+ <\/script>
59
+
60
+ <template>
61
+ <audio :src="audioSrc" controls></audio>
62
+ </template>`}]}function en(t){const s=le(t),a=t.name.replace(/\.[^.]+$/,"").replace(/[-_]/g," "),r=t.extension.replace(".",""),o={woff2:"woff2",woff:"woff",ttf:"truetype",otf:"opentype",eot:"embedded-opentype"};return[{type:"html",label:"CSS @font-face",code:`@font-face {
63
+ font-family: '${a}';
64
+ src: url('${s}') format('${o[r]||r}');
65
+ font-weight: normal;
66
+ font-style: normal;
67
+ font-display: swap;
68
+ }`},{type:"react",label:"React (CSS-in-JS)",code:`// In your global styles or CSS module
69
+ @font-face {
70
+ font-family: '${a}';
71
+ src: url('${s}') format('${o[r]||r}');
72
+ font-weight: normal;
73
+ font-style: normal;
74
+ font-display: swap;
75
+ }
76
+
77
+ // Usage
78
+ <span style={{ fontFamily: "'${a}'" }}>Text</span>`},{type:"vue",label:"Vue",code:`<style>
79
+ @font-face {
80
+ font-family: '${a}';
81
+ src: url('${s}') format('${o[r]||r}');
82
+ font-weight: normal;
83
+ font-style: normal;
84
+ font-display: swap;
85
+ }
86
+ </style>
87
+
88
+ <template>
89
+ <span style="font-family: '${a}'">Text</span>
90
+ </template>`}]}function tn(t){const s=le(t),a=Ne(t);return[{type:"html",label:"Fetch",code:`fetch('${s}')
91
+ .then(res => res.json())
92
+ .then(data => console.log(data))`},{type:"react",label:"React",code:a?`const [data, setData] = useState(null)
93
+
94
+ useEffect(() => {
95
+ fetch('${s}')
96
+ .then(res => res.json())
97
+ .then(setData)
98
+ }, [])`:`import data from '${t.path}'
99
+
100
+ // Use directly
101
+ console.log(data)`},{type:"vue",label:"Vue",code:a?`<script setup>
102
+ import { ref, onMounted } from 'vue'
103
+
104
+ const data = ref(null)
105
+
106
+ onMounted(async () => {
107
+ const res = await fetch('${s}')
108
+ data.value = await res.json()
109
+ })
110
+ <\/script>`:`<script setup>
111
+ import data from '${t.path}'
112
+ <\/script>`}]}function sn(t){const s=le(t);return[{type:"html",label:"Link",code:`<a href="${s}" download="${t.name}">
113
+ Download ${t.name}
114
+ </a>`},{type:"react",label:"React",code:`<a href="${s}" download="${t.name}">
115
+ Download {asset.name}
116
+ </a>`},{type:"vue",label:"Vue",code:`<template>
117
+ <a href="${s}" download="${t.name}">
118
+ Download ${t.name}
119
+ </a>
120
+ </template>`}]}function an(t){switch(t.type){case"image":return qa(t);case"video":return Qa(t);case"audio":return Xa(t);case"font":return en(t);case"data":return tn(t);default:return sn(t)}}function nn({asset:t,onPreview:s}){const[a,r]=n.useState("idle"),[o,l]=n.useState("idle"),[u,i]=n.useState(!1),{isIgnored:d,toggleIgnored:c}=Qe(),{importers:m,openInEditor:p}=Wa(t.path),{isDeleting:g,bulkDelete:f}=qt(),v=d(t.path),k=m.length>0,b=n.useCallback(()=>{s?.(t)},[t,s]),C=n.useCallback(async()=>{try{await navigator.clipboard.writeText(t.path),r("copied"),D.success("Path copied to clipboard"),setTimeout(()=>r("idle"),2e3)}catch(N){D.error("Failed to copy path to clipboard"),console.error("Copy path error:",N)}},[t.path]),I=n.useCallback(async N=>{try{const U=an(t).find(H=>H.type===N);if(!U){D.error("Import code not available for this asset type");return}await navigator.clipboard.writeText(U.code),l("copied"),D.success(`${U.label} code copied to clipboard`),setTimeout(()=>l("idle"),2e3)}catch(_){D.error("Failed to copy import code"),console.error("Copy import code error:",_)}},[t]),x=n.useCallback(async()=>{if(!k){D.error("No source files import this asset");return}i(!0);try{await p(m[0]),D.success("Opening in editor...")}catch(N){D.error("Failed to open in editor"),console.error("Open in editor error:",N)}finally{i(!1)}},[m,k,p]),T=n.useCallback(async()=>{try{const N=await fetch(`${P()}/api/reveal-in-finder?path=${encodeURIComponent(t.path)}`,{method:"POST"});if(!N.ok){const U=await N.json();throw new Error(U.message||"Failed to reveal file")}const _=/Mac|iPhone|iPad|iPod/.test(navigator.userAgent);D.success(`File revealed in ${_?"Finder":"Explorer"}`)}catch(N){D.error("Failed to reveal file in system explorer"),console.error("Reveal in finder error:",N)}},[t.path]),$=n.useCallback(()=>{c(t.path),D.success(v?"Asset unmarked as ignored":"Asset marked as ignored")},[t.path,v,c]),R=n.useCallback(async()=>{try{await f([t])&&D.success("Asset deleted successfully")}catch(N){D.error("Failed to delete asset"),console.error("Delete error:",N)}},[t,f]);return{handlePreview:b,handleCopyPath:C,handleCopyImportCode:I,handleOpenInEditor:x,handleRevealInFinder:T,handleToggleIgnore:$,handleDelete:R,ignored:v,hasImporters:k,copyPathState:a,copyCodeState:o,isDeleting:g,isOpeningEditor:u}}const on=typeof navigator<"u"&&/Mac|iPhone|iPad|iPod/.test(navigator.userAgent),rn=n.memo(function({asset:s,children:a,onPreview:r,isSelected:o=!1,onToggleSelect:l,autoSelect:u=!0}){const i=nn({asset:s,onPreview:r}),[d,c]=n.useState(!1),m=n.useCallback(f=>{u&&!o&&l&&l(s.id,!1)},[u,o,l,s.id]),p=n.useCallback(()=>{c(!0)},[]),g=n.useCallback(async()=>{await i.handleDelete(),c(!1)},[i]);return e.jsxs(_a,{children:[e.jsx(La,{onContextMenu:m,children:a}),e.jsxs(Wt,{className:"w-56",children:[e.jsxs(J,{onClick:i.handlePreview,children:[e.jsx(gt,{weight:"bold",className:"w-4 h-4 mr-2"}),"Open Preview"]}),e.jsxs(J,{onClick:i.handleCopyPath,children:[e.jsx(bs,{weight:"bold",className:"w-4 h-4 mr-2"}),"Copy Path",i.copyPathState==="copied"&&e.jsx(W,{weight:"bold",className:"w-3 h-3 ml-auto text-emerald-500"})]}),e.jsx(ue,{}),e.jsxs(Va,{children:[e.jsxs(Ga,{children:[e.jsx(vs,{weight:"bold",className:"w-4 h-4 mr-2"}),"Copy Import Code"]}),e.jsxs(Ha,{children:[e.jsxs(J,{onClick:()=>i.handleCopyImportCode("html"),children:[e.jsx(ws,{weight:"bold",className:"w-4 h-4 mr-2"}),"HTML",i.copyCodeState==="copied"&&e.jsx(W,{weight:"bold",className:"w-3 h-3 ml-auto text-emerald-500"})]}),e.jsxs(J,{onClick:()=>i.handleCopyImportCode("react"),children:[e.jsx(js,{weight:"bold",className:"w-4 h-4 mr-2"}),"React",i.copyCodeState==="copied"&&e.jsx(W,{weight:"bold",className:"w-3 h-3 ml-auto text-emerald-500"})]}),e.jsxs(J,{onClick:()=>i.handleCopyImportCode("vue"),children:[e.jsx(ys,{weight:"bold",className:"w-4 h-4 mr-2"}),"Vue",i.copyCodeState==="copied"&&e.jsx(W,{weight:"bold",className:"w-3 h-3 ml-auto text-emerald-500"})]})]})]}),e.jsx(ue,{}),e.jsxs(J,{onClick:i.handleOpenInEditor,disabled:!i.hasImporters,children:[e.jsx(Ns,{weight:"bold",className:"w-4 h-4 mr-2"}),"Open in Editor",i.hasImporters&&e.jsx("span",{className:"ml-auto text-[10px] text-muted-foreground",children:"⌘O"})]}),e.jsxs(J,{onClick:i.handleRevealInFinder,children:[e.jsx(Dt,{weight:"bold",className:"w-4 h-4 mr-2"}),"Reveal in ",on?"Finder":"Explorer",e.jsx("span",{className:"ml-auto text-[10px] text-muted-foreground",children:"⌘⇧R"})]}),s.importersCount===0&&e.jsxs(e.Fragment,{children:[e.jsx(ue,{}),e.jsx(J,{onClick:i.handleToggleIgnore,children:i.ignored?e.jsxs(e.Fragment,{children:[e.jsx(gt,{weight:"bold",className:"w-4 h-4 mr-2"}),"Unmark as Ignored"]}):e.jsxs(e.Fragment,{children:[e.jsx(Et,{weight:"bold",className:"w-4 h-4 mr-2"}),"Mark as Ignored"]})})]}),e.jsx(ue,{}),e.jsxs(J,{variant:"destructive",onClick:p,disabled:i.isDeleting,children:[e.jsx(Le,{weight:"bold",className:"w-4 h-4 mr-2"}),i.isDeleting?"Deleting...":"Delete",e.jsx("span",{className:"ml-auto text-[10px]",children:"⌫"})]}),o&&e.jsxs(e.Fragment,{children:[e.jsx(ue,{}),e.jsx(Ua,{children:e.jsx(Ba,{className:"text-[10px] text-muted-foreground px-2 py-1.5",children:"Selected asset"})})]})]}),e.jsx(Ge,{open:d,onOpenChange:c,children:e.jsxs(He,{children:[e.jsxs(Ke,{children:[e.jsx(Je,{children:"Delete asset?"}),e.jsx(We,{children:"This action cannot be undone. The following file will be permanently deleted from your computer:"})]}),e.jsx("div",{className:"text-xs font-mono bg-muted/50 rounded p-2 text-muted-foreground truncate",children:s.path}),e.jsxs(Ze,{children:[e.jsx(qe,{children:"Cancel"}),e.jsx(Ye,{variant:"destructive",onClick:g,children:i.isDeleting?"Deleting...":"Delete"})]})]})})]})});function ln({className:t,...s}){return e.jsx(ea,{"data-slot":"checkbox",className:w("border-input dark:bg-input/30 data-checked:bg-primary data-checked:text-primary-foreground dark:data-checked:bg-primary data-checked:border-primary aria-invalid:aria-checked:border-primary aria-invalid:border-destructive dark:aria-invalid:border-destructive/50 focus-visible:border-ring focus-visible:ring-ring/30 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 flex size-4 items-center justify-center rounded-[4px] border transition-shadow group-has-disabled/field:opacity-50 focus-visible:ring-[2px] aria-invalid:ring-[2px] peer relative shrink-0 outline-none after:absolute after:-inset-x-3 after:-inset-y-2 disabled:cursor-not-allowed disabled:opacity-50",t),...s,children:e.jsx(ta,{"data-slot":"checkbox-indicator",className:"[&>svg]:size-3.5 grid place-content-center text-current transition-none",children:e.jsx(W,{})})})}const Fe=new Map;function cn(t){const s=Fe.get(t);if(s)return s;if(t===0)return Fe.set(0,"0 B"),"0 B";const a=1024,r=["B","KB","MB","GB"],o=Math.floor(Math.log(t)/Math.log(a)),l=parseFloat((t/Math.pow(a,o)).toFixed(1))+" "+r[o];return Fe.set(t,l),l}const dn=n.memo(function({asset:s,index:a=0,onPreview:r,isSelected:o=!1,isFocused:l=!1,onToggleSelect:u}){const[i,d]=n.useState(!1),[c,m]=n.useState(!1),{isIgnored:p}=Qe(),g=p(s.path),f=n.useRef(null),v=s.type==="image",k=`${P()}/api/thumbnail?path=${encodeURIComponent(s.path)}`,b=n.useCallback(()=>{r?.(s)},[s,r]),C=n.useCallback((R,N)=>{const _=N.event;u?.(s.id,_.shiftKey??!1)},[s.id,u]),I=n.useCallback(async R=>{R.stopPropagation();try{await navigator.clipboard.writeText(s.path),d(!0),setTimeout(()=>d(!1),1500)}catch(N){console.error("Failed to copy path:",N)}},[s.path]),x=n.useCallback(()=>m(!0),[]),T=`stagger-${Math.min(a%8+1,8)}`,$=Ta(s.extension);return e.jsx(rn,{asset:s,onPreview:r,isSelected:o,onToggleSelect:u,autoSelect:!0,children:e.jsxs("div",{ref:f,onClick:b,role:"gridcell",tabIndex:l?0:-1,"aria-selected":o,className:`
121
+ group relative cursor-pointer
122
+ bg-white/80 dark:bg-zinc-900/50 rounded-lg overflow-hidden
123
+ border border-zinc-200 dark:border-zinc-800/80
124
+ transition-all duration-150 ease-out
125
+ hover:bg-zinc-50 dark:hover:bg-zinc-900/80 hover:border-zinc-300 dark:hover:border-zinc-700/80
126
+ animate-fade-in-up opacity-0 ${T}
127
+ ${o?"ring-1 ring-violet-500/70 border-violet-500/50 bg-violet-500/5":""}
128
+ ${l?"ring-2 ring-blue-500 ring-offset-1 ring-offset-white dark:ring-offset-zinc-950":""}
129
+ `,children:[u&&e.jsx("div",{className:`absolute top-2 left-2 z-10 transition-opacity duration-100 ${o?"opacity-100":"opacity-0 group-hover:opacity-100 sm:group-hover:opacity-100"}`,onClick:R=>R.stopPropagation(),children:e.jsx(ln,{checked:o,onCheckedChange:C,className:"border-zinc-400 dark:border-zinc-600 data-[state=checked]:bg-violet-500 data-[state=checked]:border-violet-500 min-h-11 min-w-11 sm:min-h-0 sm:min-w-0"})}),e.jsxs("div",{className:"relative h-45 bg-zinc-100 dark:bg-zinc-950/50",children:[e.jsx("div",{className:"absolute inset-0 checkerboard opacity-30"}),e.jsx("div",{className:"relative w-full h-full flex items-center justify-center p-3",children:v&&!c?e.jsx("img",{src:k,alt:s.name,className:"max-w-full max-h-full object-contain",loading:"lazy",onError:x}):s.type==="video"?e.jsx(Ra,{asset:s}):s.type==="font"?e.jsx(Oa,{asset:s}):e.jsx(Ve,{extension:s.extension,className:"w-12 h-12 opacity-60"})}),e.jsx("div",{className:"absolute inset-0 bg-white/70 dark:bg-zinc-950/70 opacity-0 group-hover:opacity-100 transition-opacity duration-150 flex items-center justify-center backdrop-blur-[2px]",children:e.jsx("button",{onClick:I,className:"flex items-center gap-1.5 px-2.5 py-1.5 sm:px-2.5 sm:py-1.5 min-h-11 sm:min-h-0 rounded-md bg-zinc-900/10 dark:bg-white/10 hover:bg-zinc-900/20 dark:hover:bg-white/20 transition-colors text-xs text-zinc-600 dark:text-zinc-300 hover:text-zinc-900 dark:hover:text-white",title:"Copy path","aria-label":"Copy file path",children:i?e.jsxs(e.Fragment,{children:[e.jsx(W,{weight:"bold",className:"w-3.5 h-3.5 text-emerald-400"}),e.jsx("span",{className:"text-emerald-400",children:"Copied"})]}):e.jsxs(e.Fragment,{children:[e.jsx(me,{weight:"bold",className:"w-3.5 h-3.5"}),e.jsx("span",{children:"Copy path"})]})})})]}),e.jsxs("div",{className:"px-3 py-2.5 border-t border-zinc-200 dark:border-zinc-800/50",children:[e.jsx("p",{className:"text-[13px] font-medium text-zinc-800 dark:text-zinc-200 truncate leading-tight",title:s.name,children:s.name}),e.jsxs("div",{className:"flex items-center justify-between gap-2 mt-1.5",children:[e.jsxs("div",{className:"flex items-center gap-1 min-w-0 overflow-hidden",children:[e.jsx("span",{className:`text-[10px] font-mono font-medium uppercase px-1.5 py-0.5 rounded-sm ${$} bg-current/10 shrink-0`,children:e.jsx("span",{className:$,children:s.extension.replace(".","")})}),s.importersCount===0&&!g&&e.jsx("span",{className:"text-[10px] font-mono font-medium uppercase px-1.5 py-0.5 rounded-sm bg-amber-500/10 text-amber-500 shrink-0",children:"unused"}),s.importersCount===0&&g&&e.jsxs("span",{className:"flex items-center gap-0.5 text-[10px] font-mono font-medium uppercase px-1.5 py-0.5 rounded-sm bg-zinc-200 dark:bg-zinc-800 text-zinc-500 shrink-0",children:[e.jsx(Et,{weight:"fill",className:"w-2.5 h-2.5"}),"ignored"]}),(s.duplicatesCount??0)>0&&e.jsxs("span",{className:"text-[10px] font-mono font-medium uppercase px-1.5 py-0.5 rounded-sm bg-blue-500/10 text-blue-400 shrink-0",children:[s.duplicatesCount," dupe",s.duplicatesCount===1?"":"s"]})]}),e.jsx("span",{className:"text-[11px] text-zinc-500 font-mono tabular-nums shrink-0",children:cn(s.size)})]})]})]})})});function un({items:t,columns:s,scrollElement:a,rowHeight:r,gap:o=16,overscan:l=2}){const u=Math.ceil(t.length/s),i=ba({count:u,getScrollElement:()=>a.current,estimateSize:()=>r+o,overscan:l}),d=n.useCallback(m=>{const p=m*s;return t.slice(p,p+s)},[t,s]),c=n.useCallback(m=>{const p=Math.floor(m/s);i.scrollToIndex(p,{align:"center"})},[s,i]);return{virtualRows:i.getVirtualItems(),totalHeight:i.getTotalSize(),getRowItems:d,scrollToItem:c}}const mn=180,Nt=24;function Me(t){if(t<=0)return 1;const s=t-48,a=Math.floor((s+Nt)/(mn+Nt));return Math.max(1,a)}function Qt(t){const[s,a]=n.useState(()=>typeof window>"u"?3:Me(window.innerWidth));return n.useEffect(()=>{const r=t?.current,o=()=>{a(Me(r?r.clientWidth:window.innerWidth))};if(o(),r&&typeof ResizeObserver<"u"){const l=new ResizeObserver(o);return l.observe(r),()=>l.disconnect()}else return window.addEventListener("resize",o),()=>window.removeEventListener("resize",o)},[t]),s}const fn=180,pn=60,kt=24,hn=180,xn=n.memo(function({assets:s,scrollContainerRef:a,onPreview:r,selectedAssets:o,focusedAssetId:l,onToggleSelect:u}){const i=Qt(a),{virtualRows:d,totalHeight:c,getRowItems:m,scrollToItem:p}=un({items:s,columns:i,scrollElement:a,rowHeight:fn+pn,gap:kt,overscan:2});n.useEffect(()=>{if(l){const f=s.findIndex(v=>v.id===l);f!==-1&&p(f)}},[l,s,p]);const g=n.useCallback((f,v)=>f*i+v,[i]);return s.length===0?null:e.jsx("div",{role:"grid","aria-multiselectable":"true",className:"px-6 pt-4",children:e.jsx("div",{style:{height:c,position:"relative"},children:d.map(f=>{const v=m(f.index);return e.jsx("div",{role:"row",style:{position:"absolute",top:0,left:0,width:"100%",transform:`translateY(${f.start}px)`,display:"grid",gridTemplateColumns:`repeat(${i}, minmax(${hn}px, 1fr))`,gap:kt},children:v.map((k,b)=>e.jsx(dn,{asset:k,index:g(f.index,b),onPreview:r,isSelected:o?.has(k.id),isFocused:k.id===l,onToggleSelect:u},k.id))},f.key)})})})}),gn=sa;function bn({className:t,...s}){return e.jsx(oa,{"data-slot":"select-value",className:w("flex flex-1 text-left",t),...s})}function vn({className:t,size:s="default",children:a,...r}){return e.jsxs(aa,{"data-slot":"select-trigger","data-size":s,className:w("border-input data-[placeholder]:text-muted-foreground bg-input/20 dark:bg-input/30 dark:hover:bg-input/50 focus-visible:border-ring focus-visible:ring-ring/30 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:aria-invalid:border-destructive/50 gap-1.5 rounded-md border px-2 py-1.5 text-xs/relaxed transition-colors focus-visible:ring-[2px] aria-invalid:ring-[2px] data-[size=default]:h-7 data-[size=sm]:h-6 *:data-[slot=select-value]:flex *:data-[slot=select-value]:gap-1.5 [&_svg:not([class*='size-'])]:size-3.5 flex w-fit items-center justify-between whitespace-nowrap outline-none disabled:cursor-not-allowed disabled:opacity-50 *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center [&_svg]:pointer-events-none [&_svg]:shrink-0",t),...r,children:[a,e.jsx(na,{render:e.jsx(At,{className:"text-muted-foreground size-3.5 pointer-events-none"})})]})}function wn({className:t,children:s,side:a="bottom",sideOffset:r=4,align:o="center",alignOffset:l=0,alignItemWithTrigger:u=!0,...i}){return e.jsx(ra,{children:e.jsx(ia,{side:a,sideOffset:r,align:o,alignOffset:l,alignItemWithTrigger:u,className:"isolate z-50",children:e.jsxs(la,{"data-slot":"select-content","data-align-trigger":u,className:w("bg-popover text-popover-foreground data-open:animate-in data-closed:animate-out data-closed:fade-out-0 data-open:fade-in-0 data-closed:zoom-out-95 data-open:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 ring-foreground/10 min-w-32 rounded-lg shadow-md ring-1 duration-100 data-[side=inline-start]:slide-in-from-right-2 data-[side=inline-end]:slide-in-from-left-2 relative isolate z-50 max-h-(--available-height) w-(--anchor-width) origin-(--transform-origin) overflow-x-hidden overflow-y-auto data-[align-trigger=true]:animate-none",t),...i,children:[e.jsx(yn,{}),e.jsx(ca,{children:s}),e.jsx(Nn,{})]})})})}function jn({className:t,children:s,...a}){return e.jsxs(da,{"data-slot":"select-item",className:w("focus:bg-accent focus:text-accent-foreground not-data-[variant=destructive]:focus:**:text-accent-foreground min-h-7 gap-2 rounded-md px-2 py-1 text-xs/relaxed [&_svg:not([class*='size-'])]:size-3.5 *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2 relative flex w-full cursor-default items-center outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0",t),...a,children:[e.jsx(ua,{className:"flex flex-1 gap-2 shrink-0 whitespace-nowrap",children:s}),e.jsx(ma,{render:e.jsx("span",{className:"pointer-events-none absolute right-2 flex items-center justify-center"}),children:e.jsx(W,{className:"pointer-events-none"})})]})}function yn({className:t,...s}){return e.jsx(fa,{"data-slot":"select-scroll-up-button",className:w("bg-popover z-10 flex cursor-default items-center justify-center py-1 [&_svg:not([class*='size-'])]:size-3.5 top-0 w-full",t),...s,children:e.jsx(ks,{})})}function Nn({className:t,...s}){return e.jsx(pa,{"data-slot":"select-scroll-down-button",className:w("bg-popover z-10 flex cursor-default items-center justify-center py-1 [&_svg:not([class*='size-'])]:size-3.5 bottom-0 w-full",t),...s,children:e.jsx(At,{})})}const kn=[{value:"name-asc",label:"Name (A → Z)"},{value:"name-desc",label:"Name (Z → A)"},{value:"size-asc",label:"Size (Smallest)"},{value:"size-desc",label:"Size (Largest)"},{value:"mtime-desc",label:"Date (Newest)"},{value:"mtime-asc",label:"Date (Oldest)"},{value:"type-asc",label:"Type (A → Z)"},{value:"type-desc",label:"Type (Z → A)"}];function Cn(t){const[s,a]=t.split("-");return{field:s,direction:a}}function Sn(t){return`${t.field}-${t.direction}`}function $n({value:t,onChange:s}){const a=Sn(t),r=o=>{o&&s(Cn(o))};return e.jsxs(gn,{value:a,onValueChange:r,children:[e.jsxs(vn,{size:"sm",className:w("h-7! px-2.5 gap-1.5","bg-input/20 dark:bg-input/30 border-border/50 hover:bg-input/30 dark:hover:bg-input/40"),children:[e.jsx(Cs,{weight:"bold",className:"w-3.5 h-3.5 text-muted-foreground"}),e.jsx(bn,{placeholder:"Sort by..."})]}),e.jsx(wn,{children:kn.map(o=>e.jsx(jn,{value:o.value,children:o.label},o.value))})]})}const zn=n.memo(function({selectedCount:s,totalCount:a,selectedAssets:r,onSelectAll:o,onDeselectAll:l,onDelete:u,isDeleting:i,visible:d}){const[c,m]=n.useState(!1),[p,g]=n.useState(!1),f=n.useCallback(async()=>{const C=r.map(I=>I.path).join(`
130
+ `);try{await navigator.clipboard.writeText(C),D.success(`Copied ${s} path${s>1?"s":""} to clipboard`)}catch{D.error("Failed to copy paths to clipboard")}},[r,s]),v=n.useCallback(async()=>{m(!0);try{const C=r.map(R=>R.path),I=await fetch(`${P()}/api/bulk-download`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({paths:C})});if(!I.ok)throw new Error("Download failed");const x=await I.blob(),T=URL.createObjectURL(x),$=document.createElement("a");$.href=T,$.download=`assets-${Date.now()}.zip`,document.body.appendChild($),$.click(),document.body.removeChild($),URL.revokeObjectURL(T),D.success(`Downloaded ${s} asset${s>1?"s":""} as ZIP`)}catch{D.error("Failed to download assets")}finally{m(!1)}},[r,s]),k=n.useCallback(async()=>{await u(),g(!1)},[u]),b=s===a&&a>0;return e.jsxs("div",{className:`sticky top-0 md:top-0 z-10 bg-card/95 backdrop-blur border-b border-border px-3 sm:px-4 flex items-center justify-between transition-all duration-300 ease-out ${d?"h-14 sm:h-13 py-2 sm:py-3 opacity-100 translate-y-0":"h-0 py-0 opacity-0 -translate-y-full pointer-events-none overflow-hidden"}`,"aria-hidden":!d,children:[e.jsxs("div",{className:"flex items-center gap-2 sm:gap-3",children:[e.jsx(M,{variant:"ghost",size:"icon-sm",onClick:b?l:o,title:b?"Deselect all":"Select all",children:b?e.jsx(Ss,{weight:"fill",className:"w-4 h-4 sm:w-5 sm:h-5 text-primary"}):e.jsx($s,{weight:"regular",className:"w-4 h-4 sm:w-5 sm:h-5"})}),e.jsxs("span",{className:"text-xs sm:text-sm font-medium",children:[s," selected"]}),e.jsxs(M,{variant:"ghost",size:"sm",onClick:l,className:"text-muted-foreground hidden sm:flex",children:[e.jsx(je,{weight:"bold",className:"w-3 h-3 mr-1"}),"Clear"]})]}),e.jsxs("div",{className:"flex items-center gap-1 sm:gap-2",children:[e.jsxs(M,{variant:"outline",size:"sm",onClick:f,disabled:s===0,className:"hidden sm:flex",children:[e.jsx(me,{weight:"bold",className:"w-4 h-4 mr-1.5"}),"Copy Paths"]}),e.jsx(M,{variant:"outline",size:"icon-sm",onClick:f,disabled:s===0,className:"sm:hidden",title:"Copy paths",children:e.jsx(me,{weight:"bold",className:"w-4 h-4"})}),e.jsxs(M,{variant:"outline",size:"sm",onClick:v,disabled:s===0||c,className:"hidden sm:flex",children:[e.jsx(bt,{weight:"bold",className:"w-4 h-4 mr-1.5"}),c?"Downloading...":"Download ZIP"]}),e.jsx(M,{variant:"outline",size:"icon-sm",onClick:v,disabled:s===0||c,className:"sm:hidden",title:"Download ZIP",children:e.jsx(bt,{weight:"bold",className:"w-4 h-4"})}),e.jsxs(Ge,{open:p,onOpenChange:g,children:[e.jsx(jt,{render:e.jsxs(M,{variant:"destructive",size:"sm",disabled:s===0||i,className:"hidden sm:flex",children:[e.jsx(Le,{weight:"bold",className:"w-4 h-4 mr-1.5"}),"Delete"]})}),e.jsx(jt,{render:e.jsx(M,{variant:"destructive",size:"icon-sm",disabled:s===0||i,className:"sm:hidden",title:"Delete",children:e.jsx(Le,{weight:"bold",className:"w-4 h-4"})})}),e.jsxs(He,{children:[e.jsxs(Ke,{children:[e.jsxs(Je,{children:["Delete ",s," asset",s>1?"s":"","?"]}),e.jsx(We,{children:"This action cannot be undone. The following files will be permanently deleted from your computer:"})]}),e.jsxs("ul",{className:"max-h-32 overflow-y-auto text-xs font-mono bg-muted/50 rounded p-2 space-y-0.5",children:[r.slice(0,10).map(C=>e.jsx("li",{className:"truncate text-muted-foreground",children:C.path},C.id)),r.length>10&&e.jsxs("li",{className:"text-muted-foreground/60",children:["...and ",r.length-10," more"]})]}),e.jsxs(Ze,{children:[e.jsx(qe,{children:"Cancel"}),e.jsx(Ye,{variant:"destructive",onClick:k,children:i?"Deleting...":"Delete"})]})]})]})]})]})}),In=[{value:"small",label:"Small",description:"< 100 KB"},{value:"medium",label:"Medium",description:"100 KB – 1 MB"},{value:"large",label:"Large",description:"1 – 10 MB"},{value:"xlarge",label:"Extra large",description:"> 10 MB"}],Dn=[{value:"today",label:"Today"},{value:"last7days",label:"Last 7 days"},{value:"last30days",label:"Last 30 days"},{value:"last90days",label:"Last 90 days"},{value:"thisYear",label:"This year"}],En=n.memo(function({sizeFilter:s,dateFilter:a,extensionFilter:r,onSizeChange:o,onDateChange:l,onExtensionChange:u,onClearAll:i,activeCount:d,availableExtensions:c}){const[m,p]=n.useState(!1),g=b=>{s?.preset===b?o(void 0):o({preset:b})},f=b=>{a?.preset===b?l(void 0):l({preset:b})},v=b=>{const C=r?.extensions||[],I=C.includes(b)?C.filter(x=>x!==b):[...C,b];u(I.length>0?{extensions:I}:void 0)},k=()=>{i()};return e.jsxs(Bt,{open:m,onOpenChange:p,children:[e.jsx(Vt,{children:e.jsxs(M,{variant:"outline",size:"sm",className:w("h-7! gap-1.5 px-2.5 font-medium transition-all duration-200","bg-input/20 dark:bg-input/30 border-border/50 hover:bg-input/30 dark:hover:bg-input/40",d>0&&"border-primary/40 bg-primary/5 hover:bg-primary/10"),children:[e.jsx(zs,{weight:"bold",className:w("w-3.5 h-3.5 transition-colors",d>0?"text-primary":"text-muted-foreground")}),e.jsx("span",{className:w(d>0&&"text-primary"),children:"Filters"}),d>0&&e.jsx("span",{className:w("ml-0.5 flex items-center justify-center","min-w-4.5 h-4.5 px-1 rounded-full","bg-primary text-primary-foreground","text-[10px] font-semibold tabular-nums","animate-in zoom-in-50 duration-150"),children:d})]})}),e.jsxs(Gt,{align:"end",sideOffset:6,className:w("w-[calc(100vw-2rem)] sm:w-80 md:w-72 p-0 overflow-hidden","bg-popover/95 backdrop-blur-xl","border border-border/50","shadow-xl shadow-black/10","animate-in fade-in-0 zoom-in-95 duration-150"),children:[e.jsxs("div",{className:"max-h-105 sm:max-h-125 overflow-y-auto overscroll-contain",children:[e.jsx(Te,{icon:e.jsx(Oe,{weight:"bold",className:"w-3.5 h-3.5"}),title:"File Size",children:e.jsx("div",{className:"grid grid-cols-2 gap-1.5",children:In.map(b=>e.jsxs(An,{selected:s?.preset===b.value,onClick:()=>g(b.value),children:[e.jsx("span",{className:"font-medium",children:b.label}),e.jsx("span",{className:"text-[10px] text-muted-foreground/80",children:b.description})]},b.value))})}),e.jsx(Te,{icon:e.jsx(Is,{weight:"bold",className:"w-3.5 h-3.5"}),title:"Modified",children:e.jsx("div",{className:"flex flex-wrap gap-1.5",children:Dn.map(b=>e.jsx(Ct,{selected:a?.preset===b.value,onClick:()=>f(b.value),children:b.label},b.value))})}),c.length>0&&e.jsx(Te,{icon:e.jsx(we,{weight:"bold",className:"w-3.5 h-3.5"}),title:"Extensions",scrollable:!0,children:e.jsx("div",{className:"flex flex-wrap gap-1",children:c.sort().map(b=>e.jsx(Ct,{selected:r?.extensions?.includes(b),onClick:()=>v(b),mono:!0,children:b},b))})})]}),d>0&&e.jsxs("div",{className:w("flex items-center justify-between","px-3 py-2.5 border-t border-border/50","bg-muted/30"),children:[e.jsxs("span",{className:"text-xs text-muted-foreground",children:[d," ",d===1?"filter":"filters"," active"]}),e.jsxs("button",{onClick:k,className:w("inline-flex items-center gap-1","text-xs font-medium text-muted-foreground","hover:text-foreground transition-colors","focus:outline-none focus-visible:ring-1 focus-visible:ring-ring rounded"),children:[e.jsx(je,{weight:"bold",className:"w-3 h-3"}),"Clear all"]})]})]})]})});function Te({icon:t,title:s,children:a,scrollable:r}){return e.jsxs("div",{className:"px-3 py-3 border-b border-border/30 last:border-b-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2.5",children:[e.jsx("span",{className:"text-muted-foreground",children:t}),e.jsx("span",{className:"text-xs font-semibold uppercase tracking-wider text-muted-foreground/80",children:s})]}),e.jsx("div",{className:w(r&&"max-h-28 overflow-y-auto overscroll-contain pr-1"),children:a})]})}function An({selected:t,onClick:s,children:a}){return e.jsxs("button",{onClick:s,className:w("relative flex flex-col items-start","px-2.5 py-2 rounded-lg","text-left text-xs","border transition-all duration-150","focus:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1",t?"bg-primary/10 border-primary/30 text-primary":"bg-muted/40 border-transparent hover:bg-muted/70 hover:border-border/50"),children:[t&&e.jsx(W,{weight:"bold",className:"absolute top-1.5 right-1.5 w-3 h-3 text-primary animate-in zoom-in-50 duration-100"}),a]})}function Ct({selected:t,onClick:s,children:a,mono:r}){return e.jsxs("button",{onClick:s,className:w("inline-flex items-center gap-1","px-2 py-1 rounded-md","text-xs transition-all duration-150","border focus:outline-none focus-visible:ring-2 focus-visible:ring-ring",r&&"font-mono",t?"bg-primary/15 border-primary/30 text-primary font-medium":"bg-muted/40 border-transparent text-muted-foreground hover:bg-muted/70 hover:text-foreground"),children:[t&&e.jsx(W,{weight:"bold",className:"w-2.5 h-2.5 shrink-0"}),a]})}function Pn({...t}){return e.jsx(ha,{"data-slot":"sheet",...t})}function Fn({...t}){return e.jsx(_t,{"data-slot":"sheet-portal",...t})}function Mn({className:t,...s}){return e.jsx(Lt,{"data-slot":"sheet-overlay",className:w("data-open:animate-in data-closed:animate-out data-closed:fade-out-0 data-open:fade-in-0 bg-black/80 duration-100 data-ending-style:opacity-0 data-starting-style:opacity-0 supports-backdrop-filter:backdrop-blur-xs fixed inset-0 z-50",t),...s})}function Tn({className:t,children:s,side:a="right",showCloseButton:r=!0,...o}){return e.jsxs(Fn,{children:[e.jsx(Mn,{}),e.jsxs(Rt,{"data-slot":"sheet-content","data-side":a,className:w("bg-background data-open:animate-in data-closed:animate-out data-[side=right]:data-closed:slide-out-to-right-10 data-[side=right]:data-open:slide-in-from-right-10 data-[side=left]:data-closed:slide-out-to-left-10 data-[side=left]:data-open:slide-in-from-left-10 data-[side=top]:data-closed:slide-out-to-top-10 data-[side=top]:data-open:slide-in-from-top-10 data-closed:fade-out-0 data-open:fade-in-0 data-[side=bottom]:data-closed:slide-out-to-bottom-10 data-[side=bottom]:data-open:slide-in-from-bottom-10 fixed z-50 flex flex-col bg-clip-padding text-xs/relaxed shadow-lg transition duration-200 ease-in-out data-[side=bottom]:inset-x-0 data-[side=bottom]:bottom-0 data-[side=bottom]:h-auto data-[side=bottom]:border-t data-[side=left]:inset-y-0 data-[side=left]:left-0 data-[side=left]:h-full data-[side=left]:w-3/4 data-[side=left]:border-r data-[side=right]:inset-y-0 data-[side=right]:right-0 data-[side=right]:h-full data-[side=right]:w-3/4 data-[side=right]:border-l data-[side=top]:inset-x-0 data-[side=top]:top-0 data-[side=top]:h-auto data-[side=top]:border-b data-[side=left]:sm:max-w-sm data-[side=right]:sm:max-w-sm",t),...o,children:[s,r&&e.jsxs(Ot,{"data-slot":"sheet-close",render:e.jsx(M,{variant:"ghost",className:"absolute top-4 right-4",size:"icon-sm"}),children:[e.jsx(je,{}),e.jsx("span",{className:"sr-only",children:"Close"})]})]})]})}function Rn(t,s,a){const[r,o]=n.useState([]),[l,u]=n.useState(0),[i,d]=n.useState(!0),[c,m]=n.useState(null),{subscribe:p}=ye(),g=a?.toString()??"",f=n.useCallback(async()=>{try{d(!0),m(null);const v=new URLSearchParams;t&&v.append("type",t),g&&new URLSearchParams(g).forEach((T,$)=>v.append($,T));const k=v.toString(),b=k?`${P()}/api/assets/grouped?${k}`:`${P()}/api/assets/grouped`,C=await fetch(b);if(!C.ok)throw new Error("Failed to fetch assets");const I=await C.json();o(I.groups),u(I.total)}catch(v){m(v instanceof Error?v.message:"Unknown error")}finally{d(!1)}},[t,s,g]);return n.useEffect(()=>(f(),p("asset-manager:update",()=>{f()})),[f,p]),{groups:r,total:l,loading:i,error:c,refetch:f}}function On(t){const[s,a]=n.useState([]),[r,o]=n.useState(!1),l=t?.toString()??"",u=n.useCallback(async d=>{if(!d.trim()){a([]);return}o(!0);try{const c=new URLSearchParams;c.append("q",d),l&&new URLSearchParams(l).forEach((f,v)=>c.append(v,f));const m=await fetch(`${P()}/api/search?${c.toString()}`);if(!m.ok)throw new Error("Search failed");const p=await m.json();a(p.assets)}catch{a([])}finally{o(!1)}},[l]),i=n.useCallback(()=>{a([])},[]);return{results:s,searching:r,search:u,clear:i}}function _n(){const[t,s]=n.useState({total:0,images:0,videos:0,audio:0,documents:0,fonts:0,data:0,text:0,other:0,unused:0,duplicateGroups:0,duplicateFiles:0,extensionBreakdown:{}}),[a,r]=n.useState(!0),[o,l]=n.useState(null),{subscribe:u}=ye(),i=n.useCallback(async()=>{try{l(null);const d=await fetch(`${P()}/api/stats`);if(!d.ok)throw new Error("Failed to fetch stats");const c=await d.json();s({total:c.total,images:c.byType.image,videos:c.byType.video,audio:c.byType.audio,documents:c.byType.document,fonts:c.byType.font,data:c.byType.data,text:c.byType.text,other:c.byType.other,unused:c.unused,duplicateGroups:c.duplicateGroups??0,duplicateFiles:c.duplicateFiles??0,extensionBreakdown:c.extensionBreakdown??{}})}catch(d){l(d instanceof Error?d.message:"Unknown error")}finally{r(!1)}},[]);return n.useEffect(()=>(i(),u("asset-manager:update",()=>{i()})),[i,u]),{stats:t,loading:a,error:o}}function Ln(t){const{flatAssetList:s,focusedAssetId:a,setFocusedAssetId:r,isGridFocused:o,setIsGridFocused:l,selectedAssets:u,toggleSelection:i,selectAll:d,clearSelection:c,previewAsset:m,setPreviewAsset:p,searchInputRef:g,onCopyPaths:f,onDelete:v,onOpenInEditor:k,onRevealInFinder:b}=t,C=Qt();n.useEffect(()=>{const I=x=>{const T=x.target,$=T.tagName==="INPUT"||T.tagName==="TEXTAREA",N=/Mac|iPhone|iPad|iPod/.test(navigator.userAgent)?x.metaKey:x.ctrlKey,_=()=>{if(u.size>0)return s.filter(z=>u.has(z.id));if(a){const z=s.find(S=>S.id===a);return z?[z]:[]}return[]},U=z=>{if(s.length===0)return;const S=a?s.findIndex(ee=>ee.id===a):-1;let A=S;z==="ArrowRight"?A=Math.min(S+1,s.length-1):z==="ArrowLeft"?A=Math.max(S-1,0):z==="ArrowDown"||z==="j"?A=Math.min(S+C,s.length-1):(z==="ArrowUp"||z==="k")&&(A=Math.max(S-C,0)),S===-1&&(A=0),A!==S&&A>=0&&A<s.length&&(r(s[A].id),l(!0))},H=z=>{if(s.length===0)return;const S=a?s.findIndex(ee=>ee.id===a):-1;let A;S===-1?A=z===1?0:s.length-1:A=(S+z+s.length)%s.length,r(s[A].id),l(!0)};if(x.key==="/"){x.preventDefault(),g.current?.focus(),l(!1);return}if(x.key==="Escape"){m?(p(null),l(!0)):document.activeElement===g.current&&(g.current?.blur(),l(!0));return}if(o||!$&&!m){if(["ArrowUp","ArrowDown","ArrowLeft","ArrowRight","j","k"].includes(x.key)){x.preventDefault(),U(x.key);return}if(x.key===" "){x.preventDefault(),a&&i(a,!1);return}if(x.key==="Enter"){if(x.preventDefault(),a){const z=s.find(S=>S.id===a);z&&p(z)}return}if(x.key==="Tab"&&!x.shiftKey){x.preventDefault(),H(1);return}if(x.key==="Tab"&&x.shiftKey){x.preventDefault(),H(-1);return}if(N&&x.key==="a"){x.preventDefault(),d();return}if(N&&x.key==="d"){x.preventDefault(),c();return}}const B=_();if(B.length!==0){if(x.key==="Delete"||x.key==="Backspace"){$||(x.preventDefault(),v(B));return}if(N&&x.key==="c"&&!$){x.preventDefault(),f(B);return}if(N&&x.key==="o"){x.preventDefault(),B.length===1&&k(B[0]);return}if(N&&x.shiftKey&&x.key==="r"){x.preventDefault(),B.length===1&&b(B[0]);return}}};return document.addEventListener("keydown",I),()=>document.removeEventListener("keydown",I)},[s,a,r,o,l,u,i,d,c,m,p,g,f,v,k,b,C])}const Un={small:{max:100*1024},medium:{min:100*1024,max:1024*1024},large:{min:1024*1024,max:10*1024*1024},xlarge:{min:10*1024*1024}};function Bn(t){const s=Date.now(),a=864e5;return{today:{start:s-a},last7days:{start:s-7*a},last30days:{start:s-30*a},last90days:{start:s-90*a},thisYear:{start:new Date(new Date().getFullYear(),0,1).getTime()}}[t]||{}}function Vn(){const[t,s]=n.useState(),[a,r]=n.useState(),[o,l]=n.useState(),u=n.useMemo(()=>{let c=0;return t&&t.preset!=="any"&&c++,a&&a.preset!=="any"&&c++,o?.extensions.length&&c++,c},[t,a,o]),i=n.useCallback(()=>{s(void 0),r(void 0),l(void 0)},[]),d=n.useMemo(()=>{const c=new URLSearchParams;if(t&&t.preset!=="any"){const m=Un[t.preset]||{};m.min&&c.append("minSize",String(m.min)),m.max&&c.append("maxSize",String(m.max))}if(a&&a.preset!=="any"){const m=Bn(a.preset);m.start&&c.append("minDate",String(m.start)),m.end&&c.append("maxDate",String(m.end))}return o?.extensions.length&&c.append("extensions",o.extensions.join(",")),c.toString()},[t,a,o]);return{sizeFilter:t,setSizeFilter:s,dateFilter:a,setDateFilter:r,extensionFilter:o,setExtensionFilter:l,activeFilterCount:u,clearAll:i,filterParamsString:d}}function Gn(t,s){const{field:a,direction:r}=s,o=r==="asc"?1:-1;return[...t].sort((l,u)=>{let i=0;switch(a){case"name":{const d=l.name,c=u.name;i=d.localeCompare(c,void 0,{sensitivity:"base"});break}case"size":{const d=l.size,c=u.size;i=d-c;break}case"mtime":{const d=l.mtime,c=u.mtime;i=d-c;break}case"type":{const d=l.type,c=u.type;i=d.localeCompare(c);break}}return i*o})}function Hn(){const[t]=n.useState(()=>typeof window>"u"?!1:new URLSearchParams(window.location.search).get("embedded")==="true");return t}const Kn=n.lazy(()=>ja(()=>import("./index-4W13jd9f.js"),__vite__mapDeps([0,1,2,3,4])).then(t=>({default:t.PreviewPanel}))),Zn=e.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-4",children:[e.jsx("div",{className:"w-10 h-10 rounded-full border-2 border-primary/30 border-t-primary animate-spin"}),e.jsx("p",{className:"text-muted-foreground text-sm",children:"Loading assets..."})]}),Jn=t=>e.jsxs("div",{className:"flex flex-col items-center justify-center py-20 text-muted-foreground",children:[e.jsx("div",{className:"w-20 h-20 rounded-2xl bg-muted/50 flex items-center justify-center mb-6",children:e.jsx(St,{weight:"duotone",className:"w-10 h-10 text-muted-foreground/50"})}),e.jsx("p",{className:"text-lg font-medium text-foreground mb-1",children:"No results found"}),e.jsxs("p",{className:"text-sm",children:['No assets match "',t,'"']})]}),Wn=e.jsxs("div",{className:"flex flex-col items-center justify-center py-20 text-muted-foreground",children:[e.jsx("div",{className:"w-20 h-20 rounded-2xl bg-muted/50 flex items-center justify-center mb-6",children:e.jsx(zt,{weight:"duotone",className:"w-10 h-10 text-muted-foreground/50"})}),e.jsx("p",{className:"text-lg font-medium text-foreground mb-1",children:"No assets found"}),e.jsx("p",{className:"text-sm",children:"Add images, videos, or documents to your project"})]});function Yn(){const t=Hn(),[s,a]=n.useState(null),[r,o]=n.useState(!1),[l,u]=n.useState(!1),[i,d]=n.useState(!1),{sizeFilter:c,setSizeFilter:m,dateFilter:p,setDateFilter:g,extensionFilter:f,setExtensionFilter:v,activeFilterCount:k,clearAll:b,filterParamsString:C}=Vn(),I=n.useMemo(()=>C?new URLSearchParams(C):void 0,[C]),{groups:x,loading:T}=Rn(s,void 0,I),{stats:$}=_n(),{results:R,searching:N,search:_,clear:U}=On(I),{isIgnored:H}=Qe(),{isDeleting:B,bulkDelete:z}=qt(),[S,A]=n.useState(""),[ee,Xe]=n.useState(()=>new Set),[ke,fe]=n.useState(null),[Ce,Xt]=n.useState({field:"name",direction:"asc"}),[V,te]=n.useState(()=>new Set),[Se,ce]=n.useState(null),[de,et]=n.useState(null),[$e,ze]=n.useState(!1),[K,Ie]=n.useState(null),De=n.useRef(null),tt=n.useRef(null),st=n.useRef(!1),[es,at]=n.useState(""),nt=n.useCallback(h=>{fe(h)},[]),ts=n.useCallback(()=>{fe(null)},[]),ot=n.useCallback(()=>{o(h=>!h)},[]),rt=n.useCallback(()=>{u(h=>!h)},[]);n.useEffect(()=>{te(new Set),ce(null)},[s,r,l,S,I]),n.useEffect(()=>{x.length>0&&!st.current&&(st.current=!0,Xe(new Set(x.map(h=>h.directory))))},[x]),n.useEffect(()=>{const h=setTimeout(()=>{S?_(S):U()},200);return()=>clearTimeout(h)},[S,_,U]);const O=n.useMemo(()=>{let h=x;if(S&&R.length>0){const j=new Map;R.forEach(E=>{const F=E.directory;j.has(F)||j.set(F,[]),j.get(F).push(E)}),h=Array.from(j.entries()).map(([E,F])=>({directory:E,assets:F,count:F.length}))}let y=h;return r&&(y=y.map(j=>{const E=j.assets.filter(F=>F.importersCount===0&&!H(F.path));return{...j,assets:E,count:E.length}}).filter(j=>j.count>0)),l&&(y=y.map(j=>{const E=j.assets.filter(F=>(F.duplicatesCount??0)>0);return{...j,assets:E,count:E.length}}).filter(j=>j.count>0)),y.map(j=>({...j,assets:Gn(j.assets,Ce)}))},[x,R,S,Ce,r,l,H]),pe=n.useMemo(()=>O.flatMap(h=>h.assets),[O]),ss=n.useCallback(h=>{Xe(y=>{const j=new Set(y);return j.has(h)?j.delete(h):j.add(h),j})},[]),it=n.useCallback((h,y)=>{te(j=>{const E=new Set(j);if(y&&Se){const F=O.flatMap(q=>q.assets),he=F.findIndex(q=>q.id===Se),xe=F.findIndex(q=>q.id===h);if(he!==-1&&xe!==-1){const[q,cs]=he<xe?[he,xe]:[xe,he];for(let Ae=q;Ae<=cs;Ae++)E.add(F[Ae].id)}}else E.has(h)?E.delete(h):E.add(h);return E}),ce(h)},[Se,O]),lt=n.useCallback(()=>{const h=O.flatMap(y=>y.assets.map(j=>j.id));te(new Set(h))},[O]),ct=n.useCallback(()=>{te(new Set),ce(null)},[]),Ee=n.useMemo(()=>O.flatMap(y=>y.assets).filter(y=>V.has(y.id)),[O,V]),as=n.useCallback(async()=>{await z(Ee)&&(te(new Set),ce(null))},[z,Ee]),ns=n.useCallback(async()=>{if(!K)return;await z(K)&&(te(new Set),ce(null),et(null)),Ie(null)},[z,K]),os=n.useCallback(async h=>{try{const y=h.map(j=>j.path).join(`
131
+ `);await navigator.clipboard.writeText(y)}catch(y){console.error("Failed to copy paths:",y)}},[]),rs=n.useCallback(async h=>{try{const y=await fetch(`${P()}/api/importers?path=${encodeURIComponent(h.path)}`);if(y.ok){const j=await y.json();if(j.importers&&j.importers.length>0){const E=j.importers[0];await fetch(`${P()}/api/open-in-editor?file=${encodeURIComponent(E.file)}&line=${E.line}&column=${E.column}`,{method:"POST"})}}}catch(y){console.error("Failed to open in editor:",y)}},[]),is=n.useCallback(async h=>{try{await fetch(`${P()}/api/reveal-in-finder?path=${encodeURIComponent(h.path)}`,{method:"POST"})}catch(y){console.error("Failed to reveal in finder:",y)}},[]);Ln({flatAssetList:pe,focusedAssetId:de,setFocusedAssetId:et,isGridFocused:$e,setIsGridFocused:ze,selectedAssets:V,toggleSelection:it,selectAll:lt,clearSelection:ct,previewAsset:ke,setPreviewAsset:fe,searchInputRef:De,onCopyPaths:os,onDelete:h=>{Ie(h)},onOpenInEditor:rs,onRevealInFinder:is}),n.useEffect(()=>{if(de&&$e){const h=pe.find(y=>y.id===de);h&&at(`Focused on ${h.name}`)}},[de,$e,pe]),n.useEffect(()=>{V.size>0&&at(`${V.size} asset${V.size===1?"":"s"} selected`)},[V.size]);const ls=n.useMemo(()=>O.reduce((h,y)=>h+y.count,0),[O]),se=n.useMemo(()=>{let h=0;for(const y of x)for(const j of y.assets)j.importersCount===0&&H(j.path)&&h++;return{...$,unused:Math.max(0,($.unused||0)-h),duplicateFiles:$.duplicateFiles||0,extensionBreakdown:$.extensionBreakdown||{}}},[$,x,H]);return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"sr-only",role:"status","aria-live":"polite","aria-atomic":"true",children:es}),e.jsxs("div",{className:"flex h-screen bg-background noise-bg",children:[e.jsx("div",{className:"hidden md:block",children:e.jsx(wt,{total:se.total,searchQuery:S,onSearchChange:A,searching:N,searchInputRef:De,onSearchFocus:()=>ze(!1),selectedType:s,onTypeSelect:a,showUnusedOnly:r,onUnusedFilterToggle:ot,showDuplicatesOnly:l,onDuplicatesFilterToggle:rt,stats:se})}),e.jsx(Pn,{open:i,onOpenChange:d,children:e.jsx(Tn,{side:"left",className:"p-0 w-70 sm:w-[320px]",children:e.jsx(wt,{total:se.total,searchQuery:S,onSearchChange:A,searching:N,searchInputRef:De,onSearchFocus:()=>ze(!1),selectedType:s,onTypeSelect:h=>{a(h),d(!1)},showUnusedOnly:r,onUnusedFilterToggle:()=>{ot(),d(!1)},showDuplicatesOnly:l,onDuplicatesFilterToggle:()=>{rt(),d(!1)},stats:se})})}),e.jsxs("main",{ref:tt,className:"flex-1 overflow-auto flex flex-col",children:[e.jsx("header",{className:`sticky top-0 z-40 w-full border-b border-border bg-background/95 backdrop-blur supports-backdrop-filter:bg-background/60 ${t?"":"md:hidden"}`,children:e.jsxs("div",{className:"flex h-14 items-center justify-between px-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[!t&&e.jsx(M,{variant:"ghost",size:"icon-sm",className:"md:hidden","aria-label":"Toggle sidebar",onClick:()=>d(!0),children:e.jsx(Ds,{weight:"bold",className:"h-5 w-5"})}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-7 h-7 rounded-md bg-linear-to-br from-violet-500 to-purple-600 flex items-center justify-center shadow-md shadow-violet-500/20",children:e.jsx($t,{weight:"fill",className:"w-4 h-4 text-white"})}),e.jsx("div",{children:e.jsx("h1",{className:"font-mono text-xs font-semibold tracking-wide text-foreground",children:"ASSET MANAGER"})})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"font-mono text-xs text-muted-foreground tabular-nums",children:se.total}),t&&e.jsx(M,{variant:"ghost",size:"icon-sm",onClick:()=>window.open(window.location.pathname,"_blank"),"aria-label":"Open full dashboard in new tab",title:"Open full dashboard in new tab",children:e.jsx(Es,{weight:"bold",className:"h-5 w-5"})})]})]})}),T?Zn:e.jsxs(e.Fragment,{children:[e.jsx(zn,{selectedCount:V.size,totalCount:ls,selectedAssets:Ee,onSelectAll:lt,onDeselectAll:ct,onDelete:as,isDeleting:B,visible:V.size>0}),e.jsxs("div",{className:"p-3 sm:p-4 md:p-6 pt-2 space-y-3 sm:space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-end gap-1.5 sm:gap-2",children:[e.jsx(En,{sizeFilter:c,dateFilter:p,extensionFilter:f,onSizeChange:m,onDateChange:g,onExtensionChange:v,onClearAll:b,activeCount:k,availableExtensions:Object.keys(se.extensionBreakdown||{})}),e.jsx($n,{value:Ce,onChange:Xt})]}),O.length===0?S?Jn(S):Wn:O.map(h=>e.jsxs("div",{className:"rounded-xl border border-border bg-card/30 overflow-hidden",children:[e.jsxs("button",{onClick:()=>ss(h.directory),className:"w-full flex items-center justify-between cursor-pointer px-4 py-3 hover:bg-muted/30 transition-colors",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(It,{weight:"bold",className:`w-4 h-4 text-muted-foreground transition-transform duration-200 ${ee.has(h.directory)?"rotate-90":""}`}),e.jsx(Dt,{weight:"duotone",className:"w-5 h-5 text-amber-400"}),e.jsx("span",{className:"font-mono text-sm font-medium text-foreground",children:h.directory})]}),e.jsxs("span",{className:"text-xs text-muted-foreground font-mono bg-muted/50 px-2 py-0.5 rounded-md",children:[h.count," ",h.count===1?"item":"items"]})]}),e.jsx("div",{className:`
132
+ overflow-hidden transition-all duration-300 ease-in-out
133
+ ${ee.has(h.directory)?"max-h-500 opacity-100":"max-h-0 opacity-0"}
134
+ `,children:e.jsx("div",{className:"border-t border-border",children:e.jsx(xn,{assets:h.assets,scrollContainerRef:tt,onPreview:nt,selectedAssets:V,focusedAssetId:de,onToggleSelect:it})})})]},h.directory))]})]})]})]}),ke&&e.jsx(n.Suspense,{fallback:e.jsx("aside",{className:"fixed top-0 right-0 z-50 h-screen w-96 border-l border-border bg-card/80 backdrop-blur-sm flex items-center justify-center",children:e.jsx("div",{className:"w-8 h-8 rounded-full border-2 border-primary/30 border-t-primary animate-spin"})}),children:e.jsx(Kn,{asset:ke,onClose:ts,onSelectAsset:nt,flatAssetList:pe,onAssetChange:fe})}),e.jsx(Ge,{open:K!==null,onOpenChange:h=>{h||Ie(null)},children:e.jsxs(He,{children:[e.jsxs(Ke,{children:[e.jsxs(Je,{children:["Delete ",K?.length??0," asset",(K?.length??0)!==1?"s":"","?"]}),e.jsx(We,{children:"This action cannot be undone. The following files will be permanently deleted from your computer:"})]}),e.jsxs("ul",{className:"max-h-32 overflow-y-auto text-xs font-mono bg-muted/50 rounded p-2 space-y-0.5",children:[K?.slice(0,10).map(h=>e.jsx("li",{className:"truncate text-muted-foreground",children:h.path},h.id)),(K?.length??0)>10&&e.jsxs("li",{className:"text-muted-foreground/60",children:["...and ",(K?.length??0)-10," more"]})]}),e.jsxs(Ze,{children:[e.jsx(qe,{children:"Cancel"}),e.jsx(Ye,{variant:"destructive",onClick:ns,children:B?"Deleting...":"Delete"})]})]})})]})}const qn=({...t})=>{const{theme:s="system"}=xa();return e.jsx(ga,{theme:s,className:"toaster group",icons:{success:e.jsx(Ts,{className:"size-4"}),info:e.jsx(Ms,{className:"size-4"}),warning:e.jsx(Fs,{className:"size-4"}),error:e.jsx(Ps,{className:"size-4"}),loading:e.jsx(As,{className:"size-4 animate-spin"})},style:{"--normal-bg":"var(--popover)","--normal-text":"var(--popover-foreground)","--normal-border":"var(--border)","--border-radius":"var(--radius)"},toastOptions:{classNames:{toast:"cn-toast"}},...t})};ds.createRoot(document.getElementById("root")).render(e.jsx(us.StrictMode,{children:e.jsx(ka,{defaultTheme:"dark",children:e.jsxs(Ja,{children:[e.jsx(Yn,{}),e.jsx(qn,{position:"bottom-center"})]})})}));export{M as B,Ve as F,ye as a,Qe as b,w as c,an as d,P as g,Wa as u};