vite-plugin-asset-manager 1.0.3 → 1.0.5

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>
@@ -26,6 +26,10 @@
26
26
  <a href="#keyboard-shortcuts">Shortcuts</a>
27
27
  </p>
28
28
 
29
+ <p align="center">
30
+ <img src="./.github/assets/demo.gif" alt="Vite Plugin Asset Manager Demo" width="800" />
31
+ </p>
32
+
29
33
  ---
30
34
 
31
35
  ## Installation
@@ -88,12 +92,11 @@ Start your dev server and access the Asset Manager in three ways:
88
92
  | Solid | ✅ | Fully automatic |
89
93
  | Qwik | ✅ | Fully automatic |
90
94
  | **Nuxt 3/4** | ✅ | [Official module](#nuxt-module) |
95
+ | **Next.js 14+** | ✅ | [Official package](#nextjs-integration) |
91
96
  | **TanStack Start** | ✅ | [Manual setup required](./docs/SSR_INTEGRATION.md#tanstack-start-setup) ([playground](./playgrounds/tanstack/)) |
92
97
 
93
98
  ### Nuxt Module
94
99
 
95
- For Nuxt 3/4 projects, use the official module for automatic integration:
96
-
97
100
  ```bash
98
101
  npm install @vite-asset-manager/nuxt -D
99
102
  ```
@@ -105,15 +108,26 @@ export default defineNuxtConfig({
105
108
  })
106
109
  ```
107
110
 
108
- Features:
109
- - Automatic floating icon injection (no manual setup)
110
- - Nuxt DevTools integration
111
- - Supports Nuxt 3 and 4 directory structures
112
- - Dev-only (zero production footprint)
111
+ Zero-config with automatic floating icon injection, Nuxt DevTools integration, and Nuxt 3/4 support. See the **[full Nuxt documentation](https://www.npmjs.com/package/@vite-asset-manager/nuxt)** for all options.
112
+
113
+ ### Next.js Integration
114
+
115
+ ```bash
116
+ npm install nextjs-asset-manager -D
117
+ ```
118
+
119
+ ```ts
120
+ // app/api/asset-manager/[[...path]]/route.ts
121
+ import { createHandler } from 'nextjs-asset-manager'
122
+ const { GET, POST } = createHandler()
123
+ export { GET, POST }
124
+ ```
125
+
126
+ Three-step setup: wrap config, add route handler, add client component. See the **[full Next.js documentation](https://www.npmjs.com/package/nextjs-asset-manager)** for all options.
113
127
 
114
128
  ### Other SSR Frameworks
115
129
 
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.
130
+ For TanStack Start, Remix, SvelteKit, and Solid Start, manual script injection is required. See the **[SSR Integration Guide](./docs/SSR_INTEGRATION.md)** for setup instructions.
117
131
 
118
132
  ## Configuration
119
133
 
@@ -207,6 +221,7 @@ pnpm run playground:solid
207
221
  pnpm run playground:qwik
208
222
  pnpm run playground:tanstack
209
223
  pnpm run playground:nuxt
224
+ pnpm run playground:nextjs
210
225
  ```
211
226
 
212
227
  ## License
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vite-plugin-asset-manager",
3
- "version": "1.0.3",
3
+ "version": "1.0.5",
4
4
  "type": "module",
5
5
  "description": "Visual asset management for Vite",
6
6
  "author": "Ejiro Asiuwhu <ejiroasiuwhu10@gmail.com>",
@@ -51,46 +51,47 @@
51
51
  "vite": ">=5.0.0"
52
52
  },
53
53
  "dependencies": {
54
- "@base-ui/react": "^1.1.0",
55
- "@phosphor-icons/react": "^2.1.10",
56
- "@tanstack/react-virtual": "^3.13.18",
57
- "class-variance-authority": "^0.7.1",
58
- "clsx": "^2.1.1",
59
- "next-themes": "^0.4.6",
60
54
  "picocolors": "^1.1.1",
61
- "react-resizable-panels": "^4.6.2",
62
- "shadcn": "^3.8.4",
63
- "sonner": "^2.0.7",
64
- "tailwind-merge": "^3.4.0",
65
- "tw-animate-css": "^1.4.0",
66
- "@vite-asset-manager/core": "^1.0.3"
55
+ "@vite-asset-manager/core": "^1.0.5"
67
56
  },
68
57
  "devDependencies": {
58
+ "@base-ui/react": "^1.2.0",
69
59
  "@eslint/js": "^9.39.2",
60
+ "@phosphor-icons/react": "^2.1.10",
61
+ "@playwright/test": "^1.58.2",
70
62
  "@tailwindcss/postcss": "^4.1.18",
63
+ "@tanstack/react-virtual": "^3.13.18",
71
64
  "@testing-library/jest-dom": "^6.9.1",
72
65
  "@testing-library/react": "^16.3.2",
73
66
  "@testing-library/user-event": "^14.6.1",
74
67
  "@types/node": "^25.2.3",
75
- "@types/react": "^19.2.13",
68
+ "@types/react": "^19.2.14",
76
69
  "@types/react-dom": "^19.2.3",
77
70
  "@typescript-eslint/eslint-plugin": "^8.55.0",
78
71
  "@typescript-eslint/parser": "^8.55.0",
79
72
  "@vitejs/plugin-react": "^5.1.4",
80
73
  "@vitest/coverage-v8": "^4.0.18",
81
74
  "@vitest/ui": "^4.0.18",
75
+ "class-variance-authority": "^0.7.1",
76
+ "clsx": "^2.1.1",
82
77
  "eslint": "^9.39.2",
83
78
  "eslint-config-prettier": "^10.1.8",
84
79
  "eslint-plugin-react": "^7.37.5",
85
80
  "eslint-plugin-react-hooks": "^7.0.1",
86
81
  "jsdom": "^27.4.0",
87
82
  "memfs": "^4.56.10",
83
+ "next-themes": "^0.4.6",
88
84
  "postcss": "^8.5.6",
89
85
  "prettier": "^3.8.1",
90
86
  "react": "^19.2.4",
91
87
  "react-dom": "^19.2.4",
88
+ "react-resizable-panels": "^4.6.4",
89
+ "shadcn": "^3.8.4",
90
+ "sonner": "^2.0.7",
91
+ "tailwind-merge": "^3.4.1",
92
92
  "tailwindcss": "^4.1.18",
93
93
  "tsup": "^8.5.1",
94
+ "tw-animate-css": "^1.4.0",
94
95
  "typescript": "^5.9.3",
95
96
  "vite": "^7.3.1",
96
97
  "vitest": "^4.0.18"
@@ -100,7 +101,7 @@
100
101
  "build:floating-icon": "vite build --config vite.config.floating-icon.ts",
101
102
  "build:plugin": "tsup",
102
103
  "build": "pnpm run build:ui && pnpm run build:floating-icon && pnpm run build:plugin",
103
- "build:all": "pnpm run build:packages && pnpm run build && rm -rf packages/core/dist/client && cp -r dist/client packages/core/dist/client",
104
+ "build:all": "pnpm run build:packages && pnpm run build",
104
105
  "dev": "tsup --watch",
105
106
  "lint": "eslint src/",
106
107
  "lint:fix": "eslint src/ --fix",
@@ -112,6 +113,10 @@
112
113
  "test:coverage": "vitest run --coverage",
113
114
  "test:server": "vitest run --project server",
114
115
  "test:client": "vitest run --project ui",
116
+ "test:e2e": "playwright test --config e2e/playwright.config.ts",
117
+ "test:e2e:ui": "playwright test --config e2e/playwright.config.ts --ui",
118
+ "test:e2e:headed": "playwright test --config e2e/playwright.config.ts --headed",
119
+ "test:e2e:debug": "playwright test --config e2e/playwright.config.ts --debug",
115
120
  "playground:react": "pnpm --filter playground-react dev",
116
121
  "playground:vue": "pnpm --filter playground-vue dev",
117
122
  "playground:vanilla": "pnpm --filter playground-vanilla dev",
@@ -122,6 +127,7 @@
122
127
  "playground:qwik": "pnpm --filter playground-qwik dev",
123
128
  "playground:tanstack": "pnpm --filter playground-tanstack dev",
124
129
  "playground:nuxt": "pnpm --filter playground-nuxt dev",
125
- "build:packages": "pnpm --filter @vite-asset-manager/core build && pnpm --filter @vite-asset-manager/nuxt build"
130
+ "playground:nextjs": "pnpm --filter playground-nextjs dev",
131
+ "build:packages": "pnpm --filter @vite-asset-manager/core build && pnpm --filter @vite-asset-manager/nuxt build && pnpm --filter nextjs-asset-manager build"
126
132
  }
127
133
  }
@@ -1,134 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-DqMF0zb0.js","assets/vendor-react-CZ2o2ZY4.js","assets/vendor-icons-BoR7i9s2.js","assets/vendor-ui-CBXnYcgF.js","assets/vendor-virtual-Cr-nkJSX.js"])))=>i.map(i=>d[i]);
2
- import{r as n,j as e,e as ls,c as cs}from"./vendor-react-CZ2o2ZY4.js";import{c as ds,o as kt,e as ve,a as lt,b as ct,d as us,t as Ct,f as dt,g as q,h as oe,i as Fe,j as Q,k as Me,l as Te,m as be,n as ut,p as de,q as St,r as K,s as ms,u as mt,v as ft,w as pt,x as se,y as fs,z as ps,A as hs,B as zt,C as ht,D as xs,E as J,F as gs,G as bs,H as vs,I as ws,J as js,K as $t,L as _t,M as Re,N as It,O as ys,P as Ns,Q as ks,R as Cs,S as xt,T as Ss,U as zs,V as $s,W as _s,X as Is,Y as Ds,Z as Es,_ as As,$ as Ps}from"./vendor-icons-BoR7i9s2.js";import{t as Fs,c as Ms,B as Ts,a as Rs,M as Os,b as Ls,d as Dt,e as Et,f as At,g as Pt,C as Us,h as Bs,S as Vs,i as Gs,j as Hs,k as Ks,l as Zs,A as Js,D as Ft,m as Ws,n as Ys,o as Mt,p as Tt,q as Rt,r as qs,s as I,u as Qs,v as Xs,w as ea,x as ta,y as sa,z as aa,E as na,F as oa,G as ra,H as ia,I as la,J as ca,K as da,L as ua,N as ma,O as fa,P as pa,T as ha}from"./vendor-ui-CBXnYcgF.js";import{u as xa}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 ga="modulepreload",ba=function(t){return"/__asset_manager__/"+t},gt={},va=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=ba(c),c in gt)return;gt[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":ga,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)})},Ot=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(ds,{weight:"bold",className:"w-4 h-4 text-muted-foreground animate-spin"}):e.jsx(kt,{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(ve,{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:"/"})})})]})});Ot.displayName="SearchBar";function w(...t){return Fs(Ms(t))}const wa=Rs("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 P({className:t,variant:s="default",size:a="default",...r}){return e.jsx(Ts,{"data-slot":"button",className:w(wa({variant:s,size:a,className:t})),...r})}function Lt({...t}){return e.jsx(Os,{"data-slot":"dropdown-menu",...t})}function Ut({...t}){return e.jsx(Ls,{"data-slot":"dropdown-menu-trigger",...t})}function Bt({align:t="start",alignOffset:s=0,side:a="bottom",sideOffset:r=4,positionMethod:o="fixed",className:l,...u}){return e.jsx(Dt,{children:e.jsx(Et,{className:"isolate z-50 outline-none",align:t,alignOffset:s,side:a,sideOffset:r,positionMethod:o,children:e.jsx(At,{"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 De({className:t,inset:s,variant:a="default",...r}){return e.jsx(Pt,{"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 ja={theme:"system",setTheme:()=>null},Vt=n.createContext(ja);function ya({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(Vt.Provider,{...r,value:u,children:t})}const Na=()=>{const t=n.useContext(Vt);if(t===void 0)throw new Error("useTheme must be used within a ThemeProvider");return t};function ka(){const{setTheme:t}=Na();return e.jsxs(Lt,{children:[e.jsxs(Ut,{openOnHover:!0,render:e.jsx(P,{variant:"ghost",size:"icon-xs"}),children:[e.jsx(lt,{className:"size-3 scale-100 rotate-0 transition-all dark:scale-0 dark:-rotate-90"}),e.jsx(ct,{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(Bt,{align:"end",side:"top",children:[e.jsxs(De,{onClick:()=>t("light"),children:[e.jsx(lt,{className:"size-3"}),"Light"]}),e.jsxs(De,{onClick:()=>t("dark"),children:[e.jsx(ct,{className:"size-3"}),"Dark"]}),e.jsxs(De,{onClick:()=>t("system"),children:[e.jsx(us,{className:"size-3"}),"System"]})]})]})}const Ca="1.0.3",Sa={version:Ca};let W=null;const ae=new Map;let he=null,xe=0,ge=0,Oe="disconnected";const Le=new Set;function ne(t){Oe!==t&&(Oe=t,Le.forEach(s=>s()))}function za(t){return Le.add(t),()=>Le.delete(t)}function $a(){return Oe}const _a=10,Ia=1e3;function Gt(){if(!(W?.readyState===EventSource.OPEN||W?.readyState===EventSource.CONNECTING))try{ne("connecting");const t=new EventSource("/__asset_manager__/api/events");W=t,t.onopen=()=>{xe=0,ne("connected")},t.onmessage=s=>{try{const a=JSON.parse(s.data);if(a.type==="connected")return;if(a.event){const r=ae.get(a.event);r&&r.forEach(o=>o(a.data))}}catch{}},t.onerror=()=>{W?.close(),W=null,ge>0&&xe<_a?(xe++,ne("reconnecting"),he=window.setTimeout(()=>{Gt()},Ia)):ne("disconnected")}}catch{ne("disconnected")}}function Da(){he&&(clearTimeout(he),he=null),W&&(W.close(),W=null),xe=0,ne("disconnected")}function we(){const t=n.useSyncExternalStore(za,$a);return n.useEffect(()=>(ge++,Gt(),()=>{ge--,ge===0&&Da()}),[]),{subscribe:n.useCallback((a,r)=>(ae.has(a)||ae.set(a,new Set),ae.get(a).add(r),()=>{const o=ae.get(a);o&&(o.delete(r),o.size===0&&ae.delete(a))}),[]),status:t}}const Ea={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"},Aa={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"}},bt=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}=we(),{dotClass:k,label:b}=Aa[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(Ct,{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(Ot,{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(V,{icon:e.jsx(dt,{weight:"fill",className:"w-3.5 h-3.5"}),label:"Images",count:f.images,color:"violet",onClick:()=>d("image"),active:i==="image"}),e.jsx(V,{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(V,{icon:e.jsx(oe,{weight:"fill",className:"w-3.5 h-3.5"}),label:"Audio",count:f.audio,color:"cyan",onClick:()=>d("audio"),active:i==="audio"}),e.jsx(V,{icon:e.jsx(Fe,{weight:"fill",className:"w-3.5 h-3.5"}),label:"Docs",count:f.documents,color:"amber",onClick:()=>d("document"),active:i==="document"}),e.jsx(V,{icon:e.jsx(Q,{weight:"fill",className:"w-3.5 h-3.5"}),label:"Fonts",count:f.fonts,color:"rose",onClick:()=>d("font"),active:i==="font"}),e.jsx(V,{icon:e.jsx(Me,{weight:"fill",className:"w-3.5 h-3.5"}),label:"Data",count:f.data,color:"emerald",onClick:()=>d("data"),active:i==="data"}),e.jsx(V,{icon:e.jsx(Te,{weight:"fill",className:"w-3.5 h-3.5"}),label:"Text",count:f.text,color:"purple",onClick:()=>d("text"),active:i==="text"}),e.jsx(V,{icon:e.jsx(be,{weight:"fill",className:"w-3.5 h-3.5"}),label:"Other",count:f.other,color:"zinc",onClick:()=>d("other"),active:i==="other"}),e.jsx(V,{icon:e.jsx(ut,{weight:"fill",className:"w-3.5 h-3.5"}),label:"Unused",count:f.unused,color:"amber",onClick:m,active:c}),e.jsx(V,{icon:e.jsx(de,{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(O,{icon:e.jsx(St,{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(O,{icon:e.jsx(dt,{weight:"duotone",className:"w-4 h-4"}),label:"Images",count:f.images,active:i==="image",onClick:()=>d("image")}),e.jsx(O,{icon:e.jsx(q,{weight:"duotone",className:"w-4 h-4"}),label:"Videos",count:f.videos,active:i==="video",onClick:()=>d("video")}),e.jsx(O,{icon:e.jsx(oe,{weight:"duotone",className:"w-4 h-4"}),label:"Audio",count:f.audio,active:i==="audio",onClick:()=>d("audio")}),e.jsx(O,{icon:e.jsx(Fe,{weight:"duotone",className:"w-4 h-4"}),label:"Documents",count:f.documents,active:i==="document",onClick:()=>d("document")}),e.jsx(O,{icon:e.jsx(Q,{weight:"duotone",className:"w-4 h-4"}),label:"Fonts",count:f.fonts,active:i==="font",onClick:()=>d("font")}),e.jsx(O,{icon:e.jsx(Me,{weight:"duotone",className:"w-4 h-4"}),label:"Data",count:f.data,active:i==="data",onClick:()=>d("data")}),e.jsx(O,{icon:e.jsx(Te,{weight:"duotone",className:"w-4 h-4"}),label:"Text",count:f.text,active:i==="text",onClick:()=>d("text")}),e.jsx(O,{icon:e.jsx(be,{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(O,{icon:e.jsx(ut,{weight:"duotone",className:"w-4 h-4"}),label:"Unused Assets",count:f.unused,active:c,onClick:m}),e.jsx(O,{icon:e.jsx(de,{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(ka,{}),e.jsxs("span",{className:"font-mono opacity-50",children:["v",Sa.version]})]})]})})]})}),V=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
- ${Ea[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})]})}),O=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})]})}),Ht=new Map([["png",{icon:K,color:"text-violet-400"}],["jpg",{icon:K,color:"text-violet-400"}],["jpeg",{icon:K,color:"text-violet-400"}],["gif",{icon:K,color:"text-violet-400"}],["svg",{icon:K,color:"text-violet-400"}],["webp",{icon:K,color:"text-violet-400"}],["avif",{icon:K,color:"text-violet-400"}],["ico",{icon:K,color:"text-violet-400"}],["bmp",{icon:K,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:oe,color:"text-cyan-400"}],["wav",{icon:oe,color:"text-cyan-400"}],["flac",{icon:oe,color:"text-cyan-400"}],["aac",{icon:oe,color:"text-cyan-400"}],["pdf",{icon:ms,color:"text-red-400"}],["doc",{icon:mt,color:"text-blue-400"}],["docx",{icon:mt,color:"text-blue-400"}],["xls",{icon:ft,color:"text-emerald-400"}],["xlsx",{icon:ft,color:"text-emerald-400"}],["ppt",{icon:pt,color:"text-orange-400"}],["pptx",{icon:pt,color:"text-orange-400"}],["txt",{icon:Fe,color:"text-zinc-400"}],["woff",{icon:Q,color:"text-rose-400"}],["woff2",{icon:Q,color:"text-rose-400"}],["ttf",{icon:Q,color:"text-rose-400"}],["otf",{icon:Q,color:"text-rose-400"}],["eot",{icon:Q,color:"text-rose-400"}],["json",{icon:se,color:"text-amber-400"}],["md",{icon:Te,color:"text-purple-400"}],["csv",{icon:fs,color:"text-emerald-400"}],["js",{icon:se,color:"text-yellow-400"}],["ts",{icon:se,color:"text-blue-400"}],["jsx",{icon:se,color:"text-cyan-400"}],["tsx",{icon:se,color:"text-cyan-400"}],["css",{icon:ps,color:"text-blue-400"}],["html",{icon:se,color:"text-orange-400"}]]),Kt={icon:be,color:"text-zinc-500"},Ue=n.memo(function({extension:s,className:a="w-12 h-12"}){const r=s.toLowerCase().replace(".",""),o=Ht.get(r)??Kt,l=o.icon;return e.jsx("div",{className:`${o.color} ${a}`,children:e.jsx(l,{weight:"duotone",className:"w-full h-full"})})});function Pa(t){const s=t.toLowerCase().replace(".","");return Ht.get(s)?.color??Kt.color}const Fa=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=`/__asset_manager__/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(Ue,{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(hs,{weight:"fill",className:"w-4 h-4 text-white ml-0.5"})})})]})}),Ma=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=`/__asset_manager__/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(Ue,{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 Ta({...t}){return e.jsx(Us,{"data-slot":"context-menu",...t})}function Ra({className:t,...s}){return e.jsx(Bs,{"data-slot":"context-menu-trigger",className:w("select-none",t),...s})}function Zt({className:t,align:s="start",alignOffset:a=4,side:r="right",sideOffset:o=0,...l}){return e.jsx(Dt,{children:e.jsx(Et,{className:"isolate z-50 outline-none",align:s,alignOffset:a,side:r,sideOffset:o,children:e.jsx(At,{"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 Oa({...t}){return e.jsx(Ks,{"data-slot":"context-menu-group",...t})}function La({className:t,inset:s,...a}){return e.jsx(Zs,{"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 Z({className:t,inset:s,variant:a="default",...r}){return e.jsx(Pt,{"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 Ua({...t}){return e.jsx(Gs,{"data-slot":"context-menu-sub",...t})}function Ba({className:t,inset:s,children:a,...r}){return e.jsxs(Hs,{"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(zt,{className:"ml-auto"})]})}function Va({...t}){return e.jsx(Zt,{"data-slot":"context-menu-sub-content",className:"shadow-lg",side:"right",...t})}function ce({className:t,...s}){return e.jsx(Vs,{"data-slot":"context-menu-separator",className:w("bg-border/50 -mx-1 my-1 h-px",t),...s})}function Be({...t}){return e.jsx(Js,{"data-slot":"alert-dialog",...t})}function vt({...t}){return e.jsx(qs,{"data-slot":"alert-dialog-trigger",...t})}function Ga({...t}){return e.jsx(Tt,{"data-slot":"alert-dialog-portal",...t})}function Ha({className:t,...s}){return e.jsx(Rt,{"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 Ve({className:t,size:s="default",...a}){return e.jsxs(Ga,{children:[e.jsx(Ha,{}),e.jsx(Ft,{"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 Ge({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 He({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 Ke({className:t,...s}){return e.jsx(Ws,{"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 Ze({className:t,...s}){return e.jsx(Ys,{"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 Je({className:t,...s}){return e.jsx(P,{"data-slot":"alert-dialog-action",className:w(t),...s})}function We({className:t,variant:s="outline",size:a="default",...r}){return e.jsx(Mt,{"data-slot":"alert-dialog-cancel",className:w(t),render:e.jsx(P,{variant:s,size:a}),...r})}const Jt=n.createContext(void 0),wt="vite-asset-manager-ignored-assets";function Ka({children:t}){const[s,a]=n.useState(()=>{try{const c=localStorage.getItem(wt);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(wt,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(Jt.Provider,{value:{ignoredPaths:s,isIgnored:o,addIgnored:l,removeIgnored:u,toggleIgnored:i,clearAll:d},children:t})}function Ye(){const t=n.useContext(Jt);if(!t)throw new Error("useIgnoredAssets must be used within IgnoredAssetsProvider");return t}function Za(t){const[s,a]=n.useState([]),[r,o]=n.useState(!0),[l,u]=n.useState(null),{subscribe:i}=we(),d=n.useCallback(async()=>{if(!t){a([]),o(!1);return}try{o(!0),u(null);const m=await fetch(`/__asset_manager__/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(`/__asset_manager__/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){I.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 Wt(){const[t,s]=n.useState(!1),a=n.useCallback(async r=>{s(!0);try{const o=r.map(i=>i.path),l=await fetch("/__asset_manager__/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&&I.success(`Deleted ${u.deleted} asset${u.deleted>1?"s":""}`),u.failed>0&&I.error(`Failed to delete ${u.failed} asset${u.failed>1?"s":""}`),u.deleted>0}catch(o){return I.error(o instanceof Error?o.message:"Failed to delete assets"),!1}finally{s(!1)}},[]);return{isDeleting:t,bulkDelete:a}}function re(t){return t.path.startsWith("public/")?"/"+t.path.slice(7):"/"+t.path}function Ja(t){return t.name.replace(/\.[^.]+$/,"").replace(/[-_]/g," ")}function je(t){return t.path.startsWith("public/")}function Wa(t){const s=re(t),a=Ja(t),r=je(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 Ya(t){const s=re(t),a=je(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 qa(t){const s=re(t),a=je(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 Qa(t){const s=re(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 Xa(t){const s=re(t),a=je(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 en(t){const s=re(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 tn(t){switch(t.type){case"image":return Wa(t);case"video":return Ya(t);case"audio":return qa(t);case"font":return Qa(t);case"data":return Xa(t);default:return en(t)}}function sn({asset:t,onPreview:s}){const[a,r]=n.useState("idle"),[o,l]=n.useState("idle"),[u,i]=n.useState(!1),{isIgnored:d,toggleIgnored:c}=Ye(),{importers:m,openInEditor:p}=Za(t.path),{isDeleting:g,bulkDelete:f}=Wt(),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"),I.success("Path copied to clipboard"),setTimeout(()=>r("idle"),2e3)}catch(N){I.error("Failed to copy path to clipboard"),console.error("Copy path error:",N)}},[t.path]),_=n.useCallback(async N=>{try{const L=tn(t).find(G=>G.type===N);if(!L){I.error("Import code not available for this asset type");return}await navigator.clipboard.writeText(L.code),l("copied"),I.success(`${L.label} code copied to clipboard`),setTimeout(()=>l("idle"),2e3)}catch(R){I.error("Failed to copy import code"),console.error("Copy import code error:",R)}},[t]),x=n.useCallback(async()=>{if(!k){I.error("No source files import this asset");return}i(!0);try{await p(m[0]),I.success("Opening in editor...")}catch(N){I.error("Failed to open in editor"),console.error("Open in editor error:",N)}finally{i(!1)}},[m,k,p]),F=n.useCallback(async()=>{try{const N=await fetch(`/__asset_manager__/api/reveal-in-finder?path=${encodeURIComponent(t.path)}`,{method:"POST"});if(!N.ok){const L=await N.json();throw new Error(L.message||"Failed to reveal file")}const R=/Mac|iPhone|iPad|iPod/.test(navigator.userAgent);I.success(`File revealed in ${R?"Finder":"Explorer"}`)}catch(N){I.error("Failed to reveal file in system explorer"),console.error("Reveal in finder error:",N)}},[t.path]),z=n.useCallback(()=>{c(t.path),I.success(v?"Asset unmarked as ignored":"Asset marked as ignored")},[t.path,v,c]),M=n.useCallback(async()=>{try{await f([t])&&I.success("Asset deleted successfully")}catch(N){I.error("Failed to delete asset"),console.error("Delete error:",N)}},[t,f]);return{handlePreview:b,handleCopyPath:C,handleCopyImportCode:_,handleOpenInEditor:x,handleRevealInFinder:F,handleToggleIgnore:z,handleDelete:M,ignored:v,hasImporters:k,copyPathState:a,copyCodeState:o,isDeleting:g,isOpeningEditor:u}}const an=typeof navigator<"u"&&/Mac|iPhone|iPad|iPod/.test(navigator.userAgent),nn=n.memo(function({asset:s,children:a,onPreview:r,isSelected:o=!1,onToggleSelect:l,autoSelect:u=!0}){const i=sn({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(Ta,{children:[e.jsx(Ra,{onContextMenu:m,children:a}),e.jsxs(Zt,{className:"w-56",children:[e.jsxs(Z,{onClick:i.handlePreview,children:[e.jsx(ht,{weight:"bold",className:"w-4 h-4 mr-2"}),"Open Preview"]}),e.jsxs(Z,{onClick:i.handleCopyPath,children:[e.jsx(xs,{weight:"bold",className:"w-4 h-4 mr-2"}),"Copy Path",i.copyPathState==="copied"&&e.jsx(J,{weight:"bold",className:"w-3 h-3 ml-auto text-emerald-500"})]}),e.jsx(ce,{}),e.jsxs(Ua,{children:[e.jsxs(Ba,{children:[e.jsx(gs,{weight:"bold",className:"w-4 h-4 mr-2"}),"Copy Import Code"]}),e.jsxs(Va,{children:[e.jsxs(Z,{onClick:()=>i.handleCopyImportCode("html"),children:[e.jsx(bs,{weight:"bold",className:"w-4 h-4 mr-2"}),"HTML",i.copyCodeState==="copied"&&e.jsx(J,{weight:"bold",className:"w-3 h-3 ml-auto text-emerald-500"})]}),e.jsxs(Z,{onClick:()=>i.handleCopyImportCode("react"),children:[e.jsx(vs,{weight:"bold",className:"w-4 h-4 mr-2"}),"React",i.copyCodeState==="copied"&&e.jsx(J,{weight:"bold",className:"w-3 h-3 ml-auto text-emerald-500"})]}),e.jsxs(Z,{onClick:()=>i.handleCopyImportCode("vue"),children:[e.jsx(ws,{weight:"bold",className:"w-4 h-4 mr-2"}),"Vue",i.copyCodeState==="copied"&&e.jsx(J,{weight:"bold",className:"w-3 h-3 ml-auto text-emerald-500"})]})]})]}),e.jsx(ce,{}),e.jsxs(Z,{onClick:i.handleOpenInEditor,disabled:!i.hasImporters,children:[e.jsx(js,{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(Z,{onClick:i.handleRevealInFinder,children:[e.jsx($t,{weight:"bold",className:"w-4 h-4 mr-2"}),"Reveal in ",an?"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(ce,{}),e.jsx(Z,{onClick:i.handleToggleIgnore,children:i.ignored?e.jsxs(e.Fragment,{children:[e.jsx(ht,{weight:"bold",className:"w-4 h-4 mr-2"}),"Unmark as Ignored"]}):e.jsxs(e.Fragment,{children:[e.jsx(_t,{weight:"bold",className:"w-4 h-4 mr-2"}),"Mark as Ignored"]})})]}),e.jsx(ce,{}),e.jsxs(Z,{variant:"destructive",onClick:p,disabled:i.isDeleting,children:[e.jsx(Re,{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(ce,{}),e.jsx(Oa,{children:e.jsx(La,{className:"text-[10px] text-muted-foreground px-2 py-1.5",children:"Selected asset"})})]})]}),e.jsx(Be,{open:d,onOpenChange:c,children:e.jsxs(Ve,{children:[e.jsxs(Ge,{children:[e.jsx(Ke,{children:"Delete asset?"}),e.jsx(Ze,{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(He,{children:[e.jsx(We,{children:"Cancel"}),e.jsx(Je,{variant:"destructive",onClick:g,children:i.isDeleting?"Deleting...":"Delete"})]})]})})]})});function on({className:t,...s}){return e.jsx(Qs,{"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(Xs,{"data-slot":"checkbox-indicator",className:"[&>svg]:size-3.5 grid place-content-center text-current transition-none",children:e.jsx(J,{})})})}const Ee=new Map;function rn(t){const s=Ee.get(t);if(s)return s;if(t===0)return Ee.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 Ee.set(t,l),l}const ln=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}=Ye(),g=p(s.path),f=n.useRef(null),v=s.type==="image",k=`/__asset_manager__/api/thumbnail?path=${encodeURIComponent(s.path)}`,b=n.useCallback(()=>{r?.(s)},[s,r]),C=n.useCallback((M,N)=>{const R=N.event;u?.(s.id,R.shiftKey??!1)},[s.id,u]),_=n.useCallback(async M=>{M.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),[]),F=`stagger-${Math.min(a%8+1,8)}`,z=Pa(s.extension);return e.jsx(nn,{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 ${F}
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:M=>M.stopPropagation(),children:e.jsx(on,{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(Fa,{asset:s}):s.type==="font"?e.jsx(Ma,{asset:s}):e.jsx(Ue,{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:_,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(J,{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(de,{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 ${z} bg-current/10 shrink-0`,children:e.jsx("span",{className:z,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(_t,{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:rn(s.size)})]})]})]})})});function cn({items:t,columns:s,scrollElement:a,rowHeight:r,gap:o=16,overscan:l=2}){const u=Math.ceil(t.length/s),i=xa({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 dn=180,jt=24;function Ae(t){if(t<=0)return 1;const s=t-48,a=Math.floor((s+jt)/(dn+jt));return Math.max(1,a)}function Yt(t){const[s,a]=n.useState(()=>typeof window>"u"?3:Ae(window.innerWidth));return n.useEffect(()=>{const r=t?.current,o=()=>{a(Ae(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 un=180,mn=60,yt=24,fn=180,pn=n.memo(function({assets:s,scrollContainerRef:a,onPreview:r,selectedAssets:o,focusedAssetId:l,onToggleSelect:u}){const i=Yt(a),{virtualRows:d,totalHeight:c,getRowItems:m,scrollToItem:p}=cn({items:s,columns:i,scrollElement:a,rowHeight:un+mn,gap:yt,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(${fn}px, 1fr))`,gap:yt},children:v.map((k,b)=>e.jsx(ln,{asset:k,index:g(f.index,b),onPreview:r,isSelected:o?.has(k.id),isFocused:k.id===l,onToggleSelect:u},k.id))},f.key)})})})}),hn=ea;function xn({className:t,...s}){return e.jsx(aa,{"data-slot":"select-value",className:w("flex flex-1 text-left",t),...s})}function gn({className:t,size:s="default",children:a,...r}){return e.jsxs(ta,{"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(sa,{render:e.jsx(It,{className:"text-muted-foreground size-3.5 pointer-events-none"})})]})}function bn({className:t,children:s,side:a="bottom",sideOffset:r=4,align:o="center",alignOffset:l=0,alignItemWithTrigger:u=!0,...i}){return e.jsx(na,{children:e.jsx(oa,{side:a,sideOffset:r,align:o,alignOffset:l,alignItemWithTrigger:u,className:"isolate z-50",children:e.jsxs(ra,{"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(wn,{}),e.jsx(ia,{children:s}),e.jsx(jn,{})]})})})}function vn({className:t,children:s,...a}){return e.jsxs(la,{"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(ca,{className:"flex flex-1 gap-2 shrink-0 whitespace-nowrap",children:s}),e.jsx(da,{render:e.jsx("span",{className:"pointer-events-none absolute right-2 flex items-center justify-center"}),children:e.jsx(J,{className:"pointer-events-none"})})]})}function wn({className:t,...s}){return e.jsx(ua,{"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(ys,{})})}function jn({className:t,...s}){return e.jsx(ma,{"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(It,{})})}const yn=[{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 Nn(t){const[s,a]=t.split("-");return{field:s,direction:a}}function kn(t){return`${t.field}-${t.direction}`}function Cn({value:t,onChange:s}){const a=kn(t),r=o=>{o&&s(Nn(o))};return e.jsxs(hn,{value:a,onValueChange:r,children:[e.jsxs(gn,{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(Ns,{weight:"bold",className:"w-3.5 h-3.5 text-muted-foreground"}),e.jsx(xn,{placeholder:"Sort by..."})]}),e.jsx(bn,{children:yn.map(o=>e.jsx(vn,{value:o.value,children:o.label},o.value))})]})}const Sn=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(_=>_.path).join(`
130
- `);try{await navigator.clipboard.writeText(C),I.success(`Copied ${s} path${s>1?"s":""} to clipboard`)}catch{I.error("Failed to copy paths to clipboard")}},[r,s]),v=n.useCallback(async()=>{m(!0);try{const C=r.map(M=>M.path),_=await fetch("/__asset_manager__/api/bulk-download",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({paths:C})});if(!_.ok)throw new Error("Download failed");const x=await _.blob(),F=URL.createObjectURL(x),z=document.createElement("a");z.href=F,z.download=`assets-${Date.now()}.zip`,document.body.appendChild(z),z.click(),document.body.removeChild(z),URL.revokeObjectURL(F),I.success(`Downloaded ${s} asset${s>1?"s":""} as ZIP`)}catch{I.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(P,{variant:"ghost",size:"icon-sm",onClick:b?l:o,title:b?"Deselect all":"Select all",children:b?e.jsx(ks,{weight:"fill",className:"w-4 h-4 sm:w-5 sm:h-5 text-primary"}):e.jsx(Cs,{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(P,{variant:"ghost",size:"sm",onClick:l,className:"text-muted-foreground hidden sm:flex",children:[e.jsx(ve,{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(P,{variant:"outline",size:"sm",onClick:f,disabled:s===0,className:"hidden sm:flex",children:[e.jsx(de,{weight:"bold",className:"w-4 h-4 mr-1.5"}),"Copy Paths"]}),e.jsx(P,{variant:"outline",size:"icon-sm",onClick:f,disabled:s===0,className:"sm:hidden",title:"Copy paths",children:e.jsx(de,{weight:"bold",className:"w-4 h-4"})}),e.jsxs(P,{variant:"outline",size:"sm",onClick:v,disabled:s===0||c,className:"hidden sm:flex",children:[e.jsx(xt,{weight:"bold",className:"w-4 h-4 mr-1.5"}),c?"Downloading...":"Download ZIP"]}),e.jsx(P,{variant:"outline",size:"icon-sm",onClick:v,disabled:s===0||c,className:"sm:hidden",title:"Download ZIP",children:e.jsx(xt,{weight:"bold",className:"w-4 h-4"})}),e.jsxs(Be,{open:p,onOpenChange:g,children:[e.jsx(vt,{render:e.jsxs(P,{variant:"destructive",size:"sm",disabled:s===0||i,className:"hidden sm:flex",children:[e.jsx(Re,{weight:"bold",className:"w-4 h-4 mr-1.5"}),"Delete"]})}),e.jsx(vt,{render:e.jsx(P,{variant:"destructive",size:"icon-sm",disabled:s===0||i,className:"sm:hidden",title:"Delete",children:e.jsx(Re,{weight:"bold",className:"w-4 h-4"})})}),e.jsxs(Ve,{children:[e.jsxs(Ge,{children:[e.jsxs(Ke,{children:["Delete ",s," asset",s>1?"s":"","?"]}),e.jsx(Ze,{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(He,{children:[e.jsx(We,{children:"Cancel"}),e.jsx(Je,{variant:"destructive",onClick:k,children:i?"Deleting...":"Delete"})]})]})]})]})]})}),zn=[{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"}],$n=[{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"}],_n=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||[],_=C.includes(b)?C.filter(x=>x!==b):[...C,b];u(_.length>0?{extensions:_}:void 0)},k=()=>{i()};return e.jsxs(Lt,{open:m,onOpenChange:p,children:[e.jsx(Ut,{children:e.jsxs(P,{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(Ss,{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(Bt,{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(Pe,{icon:e.jsx(Me,{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:zn.map(b=>e.jsxs(In,{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(Pe,{icon:e.jsx(zs,{weight:"bold",className:"w-3.5 h-3.5"}),title:"Modified",children:e.jsx("div",{className:"flex flex-wrap gap-1.5",children:$n.map(b=>e.jsx(Nt,{selected:a?.preset===b.value,onClick:()=>f(b.value),children:b.label},b.value))})}),c.length>0&&e.jsx(Pe,{icon:e.jsx(be,{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(Nt,{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(ve,{weight:"bold",className:"w-3 h-3"}),"Clear all"]})]})]})]})});function Pe({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 In({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(J,{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 Nt({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(J,{weight:"bold",className:"w-2.5 h-2.5 shrink-0"}),a]})}function Dn({...t}){return e.jsx(fa,{"data-slot":"sheet",...t})}function En({...t}){return e.jsx(Tt,{"data-slot":"sheet-portal",...t})}function An({className:t,...s}){return e.jsx(Rt,{"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 Pn({className:t,children:s,side:a="right",showCloseButton:r=!0,...o}){return e.jsxs(En,{children:[e.jsx(An,{}),e.jsxs(Ft,{"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(Mt,{"data-slot":"sheet-close",render:e.jsx(P,{variant:"ghost",className:"absolute top-4 right-4",size:"icon-sm"}),children:[e.jsx(ve,{}),e.jsx("span",{className:"sr-only",children:"Close"})]})]})]})}function Fn(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}=we(),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((F,z)=>v.append(z,F));const k=v.toString(),b=k?`/__asset_manager__/api/assets/grouped?${k}`:"/__asset_manager__/api/assets/grouped",C=await fetch(b);if(!C.ok)throw new Error("Failed to fetch assets");const _=await C.json();o(_.groups),u(_.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 Mn(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(`/__asset_manager__/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 Tn(){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}=we(),i=n.useCallback(async()=>{try{l(null);const d=await fetch("/__asset_manager__/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 Rn(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=Yt();n.useEffect(()=>{const _=x=>{const F=x.target,z=F.tagName==="INPUT"||F.tagName==="TEXTAREA",N=/Mac|iPhone|iPad|iPod/.test(navigator.userAgent)?x.metaKey:x.ctrlKey,R=()=>{if(u.size>0)return s.filter($=>u.has($.id));if(a){const $=s.find(S=>S.id===a);return $?[$]:[]}return[]},L=$=>{if(s.length===0)return;const S=a?s.findIndex(X=>X.id===a):-1;let E=S;$==="ArrowRight"?E=Math.min(S+1,s.length-1):$==="ArrowLeft"?E=Math.max(S-1,0):$==="ArrowDown"||$==="j"?E=Math.min(S+C,s.length-1):($==="ArrowUp"||$==="k")&&(E=Math.max(S-C,0)),S===-1&&(E=0),E!==S&&E>=0&&E<s.length&&(r(s[E].id),l(!0))},G=$=>{if(s.length===0)return;const S=a?s.findIndex(X=>X.id===a):-1;let E;S===-1?E=$===1?0:s.length-1:E=(S+$+s.length)%s.length,r(s[E].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||!z&&!m){if(["ArrowUp","ArrowDown","ArrowLeft","ArrowRight","j","k"].includes(x.key)){x.preventDefault(),L(x.key);return}if(x.key===" "){x.preventDefault(),a&&i(a,!1);return}if(x.key==="Enter"){if(x.preventDefault(),a){const $=s.find(S=>S.id===a);$&&p($)}return}if(x.key==="Tab"&&!x.shiftKey){x.preventDefault(),G(1);return}if(x.key==="Tab"&&x.shiftKey){x.preventDefault(),G(-1);return}if(N&&x.key==="a"){x.preventDefault(),d();return}if(N&&x.key==="d"){x.preventDefault(),c();return}}const U=R();if(U.length!==0){if(x.key==="Delete"||x.key==="Backspace"){z||(x.preventDefault(),v(U));return}if(N&&x.key==="c"&&!z){x.preventDefault(),f(U);return}if(N&&x.key==="o"){x.preventDefault(),U.length===1&&k(U[0]);return}if(N&&x.shiftKey&&x.key==="r"){x.preventDefault(),U.length===1&&b(U[0]);return}}};return document.addEventListener("keydown",_),()=>document.removeEventListener("keydown",_)},[s,a,r,o,l,u,i,d,c,m,p,g,f,v,k,b,C])}const On={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 Ln(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 Un(){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=On[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=Ln(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 Bn(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 Vn(){const[t]=n.useState(()=>typeof window>"u"?!1:new URLSearchParams(window.location.search).get("embedded")==="true");return t}const Gn=n.lazy(()=>va(()=>import("./index-DqMF0zb0.js"),__vite__mapDeps([0,1,2,3,4])).then(t=>({default:t.PreviewPanel}))),Hn=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..."})]}),Kn=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(kt,{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,'"']})]}),Zn=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 assets found"}),e.jsx("p",{className:"text-sm",children:"Add images, videos, or documents to your project"})]});function Jn(){const t=Vn(),[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}=Un(),_=n.useMemo(()=>C?new URLSearchParams(C):void 0,[C]),{groups:x,loading:F}=Fn(s,void 0,_),{stats:z}=Tn(),{results:M,searching:N,search:R,clear:L}=Mn(_),{isIgnored:G}=Ye(),{isDeleting:U,bulkDelete:$}=Wt(),[S,E]=n.useState(""),[X,qe]=n.useState(()=>new Set),[ye,ue]=n.useState(null),[Ne,qt]=n.useState({field:"name",direction:"asc"}),[B,ee]=n.useState(()=>new Set),[ke,ie]=n.useState(null),[le,Qe]=n.useState(null),[Ce,Se]=n.useState(!1),[H,ze]=n.useState(null),$e=n.useRef(null),Xe=n.useRef(null),et=n.useRef(!1),[Qt,tt]=n.useState(""),st=n.useCallback(h=>{ue(h)},[]),Xt=n.useCallback(()=>{ue(null)},[]),at=n.useCallback(()=>{o(h=>!h)},[]),nt=n.useCallback(()=>{u(h=>!h)},[]);n.useEffect(()=>{ee(new Set),ie(null)},[s,r,l,S,_]),n.useEffect(()=>{x.length>0&&!et.current&&(et.current=!0,qe(new Set(x.map(h=>h.directory))))},[x]),n.useEffect(()=>{const h=setTimeout(()=>{S?R(S):L()},200);return()=>clearTimeout(h)},[S,R,L]);const T=n.useMemo(()=>{let h=x;if(S&&M.length>0){const j=new Map;M.forEach(D=>{const A=D.directory;j.has(A)||j.set(A,[]),j.get(A).push(D)}),h=Array.from(j.entries()).map(([D,A])=>({directory:D,assets:A,count:A.length}))}let y=h;return r&&(y=y.map(j=>{const D=j.assets.filter(A=>A.importersCount===0&&!G(A.path));return{...j,assets:D,count:D.length}}).filter(j=>j.count>0)),l&&(y=y.map(j=>{const D=j.assets.filter(A=>(A.duplicatesCount??0)>0);return{...j,assets:D,count:D.length}}).filter(j=>j.count>0)),y.map(j=>({...j,assets:Bn(j.assets,Ne)}))},[x,M,S,Ne,r,l,G]),me=n.useMemo(()=>T.flatMap(h=>h.assets),[T]),es=n.useCallback(h=>{qe(y=>{const j=new Set(y);return j.has(h)?j.delete(h):j.add(h),j})},[]),ot=n.useCallback((h,y)=>{ee(j=>{const D=new Set(j);if(y&&ke){const A=T.flatMap(Y=>Y.assets),fe=A.findIndex(Y=>Y.id===ke),pe=A.findIndex(Y=>Y.id===h);if(fe!==-1&&pe!==-1){const[Y,is]=fe<pe?[fe,pe]:[pe,fe];for(let Ie=Y;Ie<=is;Ie++)D.add(A[Ie].id)}}else D.has(h)?D.delete(h):D.add(h);return D}),ie(h)},[ke,T]),rt=n.useCallback(()=>{const h=T.flatMap(y=>y.assets.map(j=>j.id));ee(new Set(h))},[T]),it=n.useCallback(()=>{ee(new Set),ie(null)},[]),_e=n.useMemo(()=>T.flatMap(y=>y.assets).filter(y=>B.has(y.id)),[T,B]),ts=n.useCallback(async()=>{await $(_e)&&(ee(new Set),ie(null))},[$,_e]),ss=n.useCallback(async()=>{if(!H)return;await $(H)&&(ee(new Set),ie(null),Qe(null)),ze(null)},[$,H]),as=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)}},[]),ns=n.useCallback(async h=>{try{const y=await fetch(`/__asset_manager__/api/importers?path=${encodeURIComponent(h.path)}`);if(y.ok){const j=await y.json();if(j.importers&&j.importers.length>0){const D=j.importers[0];await fetch(`/__asset_manager__/api/open-in-editor?file=${encodeURIComponent(D.file)}&line=${D.line}&column=${D.column}`,{method:"POST"})}}}catch(y){console.error("Failed to open in editor:",y)}},[]),os=n.useCallback(async h=>{try{await fetch(`/__asset_manager__/api/reveal-in-finder?path=${encodeURIComponent(h.path)}`,{method:"POST"})}catch(y){console.error("Failed to reveal in finder:",y)}},[]);Rn({flatAssetList:me,focusedAssetId:le,setFocusedAssetId:Qe,isGridFocused:Ce,setIsGridFocused:Se,selectedAssets:B,toggleSelection:ot,selectAll:rt,clearSelection:it,previewAsset:ye,setPreviewAsset:ue,searchInputRef:$e,onCopyPaths:as,onDelete:h=>{ze(h)},onOpenInEditor:ns,onRevealInFinder:os}),n.useEffect(()=>{if(le&&Ce){const h=me.find(y=>y.id===le);h&&tt(`Focused on ${h.name}`)}},[le,Ce,me]),n.useEffect(()=>{B.size>0&&tt(`${B.size} asset${B.size===1?"":"s"} selected`)},[B.size]);const rs=n.useMemo(()=>T.reduce((h,y)=>h+y.count,0),[T]),te=n.useMemo(()=>{let h=0;for(const y of x)for(const j of y.assets)j.importersCount===0&&G(j.path)&&h++;return{...z,unused:Math.max(0,(z.unused||0)-h),duplicateFiles:z.duplicateFiles||0,extensionBreakdown:z.extensionBreakdown||{}}},[z,x,G]);return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"sr-only",role:"status","aria-live":"polite","aria-atomic":"true",children:Qt}),e.jsxs("div",{className:"flex h-screen bg-background noise-bg",children:[e.jsx("div",{className:"hidden md:block",children:e.jsx(bt,{total:te.total,searchQuery:S,onSearchChange:E,searching:N,searchInputRef:$e,onSearchFocus:()=>Se(!1),selectedType:s,onTypeSelect:a,showUnusedOnly:r,onUnusedFilterToggle:at,showDuplicatesOnly:l,onDuplicatesFilterToggle:nt,stats:te})}),e.jsx(Dn,{open:i,onOpenChange:d,children:e.jsx(Pn,{side:"left",className:"p-0 w-70 sm:w-[320px]",children:e.jsx(bt,{total:te.total,searchQuery:S,onSearchChange:E,searching:N,searchInputRef:$e,onSearchFocus:()=>Se(!1),selectedType:s,onTypeSelect:h=>{a(h),d(!1)},showUnusedOnly:r,onUnusedFilterToggle:()=>{at(),d(!1)},showDuplicatesOnly:l,onDuplicatesFilterToggle:()=>{nt(),d(!1)},stats:te})})}),e.jsxs("main",{ref:Xe,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(P,{variant:"ghost",size:"icon-sm",className:"md:hidden","aria-label":"Toggle sidebar",onClick:()=>d(!0),children:e.jsx($s,{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(Ct,{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:te.total}),t&&e.jsx(P,{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(_s,{weight:"bold",className:"h-5 w-5"})})]})]})}),F?Hn:e.jsxs(e.Fragment,{children:[e.jsx(Sn,{selectedCount:B.size,totalCount:rs,selectedAssets:_e,onSelectAll:rt,onDeselectAll:it,onDelete:ts,isDeleting:U,visible:B.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(_n,{sizeFilter:c,dateFilter:p,extensionFilter:f,onSizeChange:m,onDateChange:g,onExtensionChange:v,onClearAll:b,activeCount:k,availableExtensions:Object.keys(te.extensionBreakdown||{})}),e.jsx(Cn,{value:Ne,onChange:qt})]}),T.length===0?S?Kn(S):Zn:T.map(h=>e.jsxs("div",{className:"rounded-xl border border-border bg-card/30 overflow-hidden",children:[e.jsxs("button",{onClick:()=>es(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(zt,{weight:"bold",className:`w-4 h-4 text-muted-foreground transition-transform duration-200 ${X.has(h.directory)?"rotate-90":""}`}),e.jsx($t,{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
- ${X.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(pn,{assets:h.assets,scrollContainerRef:Xe,onPreview:st,selectedAssets:B,focusedAssetId:le,onToggleSelect:ot})})})]},h.directory))]})]})]})]}),ye&&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(Gn,{asset:ye,onClose:Xt,onSelectAsset:st,flatAssetList:me,onAssetChange:ue})}),e.jsx(Be,{open:H!==null,onOpenChange:h=>{h||ze(null)},children:e.jsxs(Ve,{children:[e.jsxs(Ge,{children:[e.jsxs(Ke,{children:["Delete ",H?.length??0," asset",(H?.length??0)!==1?"s":"","?"]}),e.jsx(Ze,{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:[H?.slice(0,10).map(h=>e.jsx("li",{className:"truncate text-muted-foreground",children:h.path},h.id)),(H?.length??0)>10&&e.jsxs("li",{className:"text-muted-foreground/60",children:["...and ",(H?.length??0)-10," more"]})]}),e.jsxs(He,{children:[e.jsx(We,{children:"Cancel"}),e.jsx(Je,{variant:"destructive",onClick:ss,children:U?"Deleting...":"Delete"})]})]})})]})}const Wn=({...t})=>{const{theme:s="system"}=pa();return e.jsx(ha,{theme:s,className:"toaster group",icons:{success:e.jsx(Ps,{className:"size-4"}),info:e.jsx(As,{className:"size-4"}),warning:e.jsx(Es,{className:"size-4"}),error:e.jsx(Ds,{className:"size-4"}),loading:e.jsx(Is,{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})};ls.createRoot(document.getElementById("root")).render(e.jsx(cs.StrictMode,{children:e.jsx(ya,{defaultTheme:"dark",children:e.jsxs(Ka,{children:[e.jsx(Jn,{}),e.jsx(Wn,{position:"bottom-center"})]})})}));export{P as B,Ue as F,we as a,Ye as b,w as c,tn as g,Za as u};
@@ -1,2 +0,0 @@
1
- import{j as e,r}from"./vendor-react-CZ2o2ZY4.js";import{Z as U,a0 as S,h as L,X as B,E as T,p as C,W as $,a1 as M,x as A,a2 as W,C as V,L as X,e as H}from"./vendor-icons-BoR7i9s2.js";import{c as y,B as w,F as O,u as q,a as K,b as G,g as Y}from"./index-BiBe_7iw.js";import{S as Z,s as k,Q,R as J,U as ee,V as te,a as ae}from"./vendor-ui-CBXnYcgF.js";import"./vendor-virtual-Cr-nkJSX.js";function j({className:o,orientation:t="horizontal",...s}){return e.jsx(Z,{"data-slot":"separator",orientation:t,className:y("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 se=r.memo(function({asset:t,onDimensionsLoad:s}){const[l,a]=r.useState(!1),i=`/__asset_manager__/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})]})}),ne=r.memo(function({asset:t}){const[s,l]=r.useState(!1),a=`/__asset_manager__/api/file?path=${encodeURIComponent(t.path)}`,i=`/__asset_manager__/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(U,{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(w,{onClick:u,variant:"outline",size:"sm",className:"gap-2",children:[e.jsx(S,{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."})})}),re=r.memo(function({asset:t}){const[s,l]=r.useState(!1),a=`/__asset_manager__/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(L,{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."})]})}),I=5e4,oe=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 g=await fetch(`/__asset_manager__/api/file?path=${encodeURIComponent(t.path)}`);if(!g.ok)throw new Error("Failed to fetch file");const v=await g.text();v.length>I?(l(v.slice(0,I)),c(!0)):l(v)}catch(g){d(g instanceof Error?g.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(B,{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)"})})]})}),ie="The quick brown fox jumps over the lazy dog",le=[14,18,24,32,48],de=r.memo(function({asset:t}){const[s,l]=r.useState(!1),[a,i]=r.useState(!1),d=`preview-font-${r.useId().replace(/:/g,"-")}`,u=`/__asset_manager__/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:[le.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:ie})]},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..."})}),E=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(O,{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"})]})]})}),ce=r.memo(function({asset:t,onDimensionsLoad:s}){const l=()=>{switch(t.type){case"image":return e.jsx(se,{asset:t,onDimensionsLoad:s});case"video":return e.jsx(ne,{asset:t});case"audio":return e.jsx(re,{asset:t});case"data":case"text":return e.jsx(oe,{asset:t});case"font":return e.jsx(de,{asset:t});case"document":if(t.extension===".pdf"){const a=`/__asset_manager__/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(E,{asset:t});default:return e.jsx(E,{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 ue(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 me(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 xe(o){return o.path.startsWith("public/")?"/"+o.path.slice(7):"/"+o.path}function fe(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 he(o){return o.charAt(0).toUpperCase()+o.slice(1)}const b=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),k.success("Copied to clipboard"),setTimeout(()=>n(!1),2e3)}catch{k.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(T,{weight:"bold",className:"w-3 h-3 text-emerald-500"}):e.jsx(C,{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($,{weight:"bold",className:"w-3 h-3 text-muted-foreground"})})]})]})}),pe=r.memo(function({asset:t,imageDimensions:s}){const l=xe(t),a=`/__asset_manager__/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(b,{label:"Filepath",value:t.absolutePath,copyable:!0,externalLink:a}),e.jsx(b,{label:"Public Path",value:l,copyable:!0}),e.jsx(b,{label:"Type",value:he(t.type)}),s&&e.jsxs(e.Fragment,{children:[e.jsx(b,{label:"Image Size",value:`${s.width} x ${s.height}`}),e.jsx(b,{label:"Aspect Ratio",value:fe(s.width,s.height)})]}),e.jsx(b,{label:"File size",value:ue(t.size)}),e.jsx(b,{label:"Last modified",value:me(t.mtime)})]})]})}),ge={"es-import":"ES Import","dynamic-import":"Dynamic Import",require:"Require","css-url":"CSS url()","html-src":"HTML src","html-href":"HTML href"},be=r.memo(function({asset:t}){const{importers:s,loading:l,openInEditor:a}=q(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(M,{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(A,{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($,{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:ge[i.importType]||i.importType})]})]},`${i.filePath}:${i.line}:${n}`))})]})});function ve(o){const[t,s]=r.useState([]),[l,a]=r.useState(!0),[i,n]=r.useState(null),{subscribe:d}=K(),u=r.useCallback(async()=>{if(!o){s([]),a(!1);return}try{a(!0),n(null);const c=await fetch(`/__asset_manager__/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 je(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 we=r.memo(function({asset:t,onSelectAsset:s}){const{duplicates:l,loading:a}=ve(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(M,{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(C,{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:je(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(W,{weight:"fill",className:"w-3 h-3"}),e.jsx("span",{className:"truncate",children:n.directory})]})})]},n.id))})]})}),ye=r.memo(function({asset:t}){const s=`/__asset_manager__/api/file?path=${encodeURIComponent(t.path)}`,{isIgnored:l,toggleIgnored:a}=G(),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(w,{variant:"secondary",size:"sm",onClick:n,className:"w-full justify-start gap-2",children:[e.jsx(S,{weight:"bold",className:"w-4 h-4"}),"Download"]}),t.importersCount===0&&e.jsx(w,{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(V,{weight:"bold",className:"w-4 h-4"}),"Unmark as Ignored"]}):e.jsxs(e.Fragment,{children:[e.jsx(X,{weight:"bold",className:"w-4 h-4"}),"Mark as Ignored"]})})]})]})});function Ne({className:o,orientation:t="horizontal",...s}){return e.jsx(Q,{"data-slot":"tabs","data-orientation":t,className:y("gap-2 group/tabs flex data-[orientation=horizontal]:flex-col",o),...s})}const ke=ae("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 _e({className:o,variant:t="default",...s}){return e.jsx(J,{"data-slot":"tabs-list","data-variant":t,className:y(ke({variant:t}),o),...s})}function Ce({className:o,...t}){return e.jsx(ee,{"data-slot":"tabs-trigger",className:y("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 Ie({className:o,...t}){return e.jsx(te,{"data-slot":"tabs-content",className:y("text-xs/relaxed flex-1 outline-none",o),...t})}const Ee=r.memo(function({asset:t}){const[s,l]=r.useState(null),a=r.useMemo(()=>Y(t),[t]),i=r.useCallback(async(n,d)=>{try{await navigator.clipboard.writeText(n),l(d),k.success("Copied to clipboard"),setTimeout(()=>l(null),2e3)}catch{k.error("Failed to copy")}},[]);return a.length===0?null:e.jsx("div",{className:"p-4",children:e.jsxs(Ne,{defaultValue:a[0].type,children:[e.jsx("div",{className:"flex items-center justify-between mb-3",children:e.jsx(_e,{variant:"line",activateOnFocus:!0,children:a.map(n=>e.jsx(Ce,{value:n.type,children:n.label},n.type))})}),a.map(n=>e.jsx(Ie,{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(w,{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(T,{weight:"bold",className:"w-4 h-4 text-emerald-500"}):e.jsx(C,{weight:"bold",className:"w-4 h-4"})})]})},n.type))]})})}),Se=300,Te=600,$e=384,Re=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($e),[g,v]=r.useState(!1),F=d.assetId===t.id?d.dimensions:null,P=r.useCallback(f=>{f.preventDefault(),v(!0);const x=f.clientX,N=c,_=h=>{const z=x-h.clientX,R=Math.min(Math.max(N+z,Se),Te);m(R)},p=()=>{v(!1),document.removeEventListener("mousemove",_),document.removeEventListener("mouseup",p)};document.addEventListener("mousemove",_),document.addEventListener("mouseup",p)},[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 N=x.target;if(N.tagName==="INPUT"||N.tagName==="TEXTAREA")return;const p=a.findIndex(h=>h.id===t.id);if(p!==-1){if(x.key==="ArrowRight"||x.key==="j"){x.preventDefault();const h=Math.min(p+1,a.length-1);h!==p&&i(a[h])}else if(x.key==="ArrowLeft"||x.key==="k"){x.preventDefault();const h=Math.max(p-1,0);h!==p&&i(a[h])}}};return document.addEventListener("keydown",f),()=>document.removeEventListener("keydown",f)},[t.id,a,i]),r.useEffect(()=>{n.current?.focus()},[]);const D=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:P,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 ${g?"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(w,{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(H,{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(ce,{asset:t,onDimensionsLoad:D}),e.jsx(j,{}),e.jsx(pe,{asset:t,imageDimensions:F}),e.jsx(j,{}),e.jsx(be,{asset:t}),(t.duplicatesCount??0)>0&&e.jsxs(e.Fragment,{children:[e.jsx(j,{}),e.jsx(we,{asset:t,onSelectAsset:l})]}),e.jsx(j,{}),e.jsx(ye,{asset:t}),e.jsx(j,{}),e.jsx(Ee,{asset:t})]})]})});export{Re as PreviewPanel};