headroom-cms 0.1.1 → 0.1.2

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.
Files changed (48) hide show
  1. package/admin/assets/{AdminsPage-CnrQqwKA.js → AdminsPage-Dc3Rzdwx.js} +1 -1
  2. package/admin/assets/{AllContentPage-ByN1h3PP.js → AllContentPage-BhNvrxDQ.js} +1 -1
  3. package/admin/assets/{ApiKeysPage-FgNHZPBS.js → ApiKeysPage-B7eN8Oy5.js} +1 -1
  4. package/admin/assets/{AuditPage-DAPpo-sj.js → AuditPage-hd-SaWMS.js} +1 -1
  5. package/admin/assets/{BlockEditor-CZTwex-o.js → BlockEditor-BKqDtxKs.js} +1 -1
  6. package/admin/assets/{BlockTypeEditPage-Buuwbx1P.js → BlockTypeEditPage-Cy3fkD1c.js} +1 -1
  7. package/admin/assets/{BlockTypesPage-Dj0qmsqX.js → BlockTypesPage-B8lJ18bi.js} +1 -1
  8. package/admin/assets/{BulkActionBar-BMcUBJSH.js → BulkActionBar-4v-SYM43.js} +1 -1
  9. package/admin/assets/{CollectionEditPage-CLgQu2HS.js → CollectionEditPage-j3KxUSoP.js} +1 -1
  10. package/admin/assets/{CollectionsPage-BnCaxALz.js → CollectionsPage-CCtIb9WO.js} +1 -1
  11. package/admin/assets/{ContentCreatePage-CJI326o-.js → ContentCreatePage-Ddc6j4WO.js} +1 -1
  12. package/admin/assets/{ContentEditPage-A4i8P2Jd.js → ContentEditPage-DOGQTv8S.js} +3 -3
  13. package/admin/assets/{ContentListPage-Bc4mBIkB.js → ContentListPage-B51lrfUs.js} +1 -1
  14. package/admin/assets/{CustomBlockPreview-CCssn6vF.js → CustomBlockPreview-A-nwA7RD.js} +1 -1
  15. package/admin/assets/{FieldBuilder-YJGSk0nY.js → FieldBuilder-B5YuIrq9.js} +1 -1
  16. package/admin/assets/{LoginPage-Jrne8-Wr.js → LoginPage-B5FcCn1S.js} +1 -1
  17. package/admin/assets/{MediaPage-_qNXqsZg.js → MediaPage-DwVwPIir.js} +1 -1
  18. package/admin/assets/{SiteSettingsPage-CoZnavij.js → SiteSettingsPage-CimBfAlF.js} +1 -1
  19. package/admin/assets/SitesPage-BBXXQwRM.js +1 -0
  20. package/admin/assets/{TagsPage-BGpp0XZM.js → TagsPage-CQ9k8IWa.js} +1 -1
  21. package/admin/assets/{UsersPage-CKRJpAb6.js → UsersPage-j6pRJvSa.js} +1 -1
  22. package/admin/assets/{WebhookEditPage-BOcLe5OJ.js → WebhookEditPage-Cj6aTIwf.js} +1 -1
  23. package/admin/assets/{WebhooksPage-Czco583Y.js → WebhooksPage-wSrRa63x.js} +1 -1
  24. package/admin/assets/{badge-0Z1nL6DI.js → badge-DK6q6X8v.js} +1 -1
  25. package/admin/assets/{card-D1-S-QZ6.js → card-NiKFR8dW.js} +1 -1
  26. package/admin/assets/check-UCoo7qN1.js +1 -0
  27. package/admin/assets/{checkbox-BPqrj_XS.js → checkbox-Cv1_Hpta.js} +1 -1
  28. package/admin/assets/{command-ChD319uJ.js → command-Da-hMl-c.js} +1 -1
  29. package/admin/assets/{copy-BqH9rXYM.js → copy-BIxYwzJE.js} +1 -1
  30. package/admin/assets/{core.esm-Csvubn5Q.js → core.esm-C3N4hsfx.js} +1 -1
  31. package/admin/assets/{index-Ds50UTAc.js → index-CdJ9sfDz.js} +2 -2
  32. package/admin/assets/{plus-BgHSYWJN.js → plus-CTopr28W.js} +1 -1
  33. package/admin/assets/{search-DIzcfCVh.js → search-CURbafxm.js} +1 -1
  34. package/admin/assets/{select-CJXZv4wv.js → select-27FAx7H-.js} +1 -1
  35. package/admin/assets/{sortable.esm-Zh-9QRSf.js → sortable.esm-CL-OXMRL.js} +1 -1
  36. package/admin/assets/{table-B3EHrN_H.js → table-pnzwUf_S.js} +1 -1
  37. package/admin/assets/{trash-2-Gny2Upn-.js → trash-2-H30Pytad.js} +1 -1
  38. package/admin/assets/{useAdminResolver-BsQc_N4z.js → useAdminResolver-oE0-RZ44.js} +1 -1
  39. package/admin/assets/{useContent-CSobIico.js → useContent-CNxWXb6y.js} +1 -1
  40. package/admin/assets/{useMedia-CQnmMz4N.js → useMedia-BgfZGpqE.js} +1 -1
  41. package/admin/assets/{useTags-CYqbj5cK.js → useTags-CiyJ7ytD.js} +1 -1
  42. package/admin/assets/{useWebhooks-DXgtQ3aU.js → useWebhooks-D5KIBL2l.js} +1 -1
  43. package/admin/index.html +1 -1
  44. package/lambda/api/bootstrap +0 -0
  45. package/lambda/webhook-worker/bootstrap +0 -0
  46. package/package.json +1 -1
  47. package/admin/assets/SitesPage-ETqFT3nO.js +0 -1
  48. package/admin/assets/check-BGA0ADyt.js +0 -1
@@ -1 +1 @@
1
- import{j as e}from"./tanstack-BO6c-AOu.js";import{r as x,R as D,L as yt,u as bt}from"./react-vendor-DNVhVxD7.js";import{F as Ct,l as Nt,m as kt,n as Dt,o as St,T as Fe,b as Ge,p as Mt,q as It,r as Tt,E as _t,A as Ze,e as Je,f as et,g as tt,h as st,i as at,j as nt,k as rt,U as ye,u as Rt,a as At,s as zt,t as $t,v as Et}from"./useMedia-CQnmMz4N.js";import{n as Y,x as P,F as it,B as C,s as S,D as ie,i as le,j as oe,k as ce,l as de,L as O,I as K,m as he,a as ee,X as xe,J as Ft,K as Pt,M as Ut,N as We,S as Ot}from"./index-Ds50UTAc.js";import{C as Lt,c as Ht}from"./card-D1-S-QZ6.js";import{C as Se}from"./checkbox-BPqrj_XS.js";import{S as pe,a as ge,b as fe,c as we,d as te,C as Xt,h as Yt}from"./select-CJXZv4wv.js";import{s as Bt,t as Kt,u as Wt,v as Vt,w as qt,A as Qt}from"./radix-DQ3amgxj.js";import{d as lt,G as Gt,e as Zt,b as Jt,u as es,a as ts,D as ss,f as as,P as ns}from"./core.esm-Csvubn5Q.js";import{b as je,a as Pe,f as Ue}from"./format-CZ9bpk32.js";import{m as W}from"./media-url-DIg_vSyf.js";import{T as rs,a as is,b as ot,c as H,d as ls,e as X}from"./table-B3EHrN_H.js";import{C as Oe}from"./copy-BqH9rXYM.js";import{B as ct}from"./badge-0Z1nL6DI.js";import{T as os}from"./trash-2-Gny2Upn-.js";import{P as cs}from"./plus-BgHSYWJN.js";import{C as ds}from"./check-BGA0ADyt.js";import{S as Ve}from"./search-DIzcfCVh.js";const hs=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],us=Y("chevron-left",hs);const ms=[["path",{d:"M6 2v14a2 2 0 0 0 2 2h14",key:"ron5a4"}],["path",{d:"M18 22V8a2 2 0 0 0-2-2H2",key:"7s9ehn"}]],xs=Y("crop",ms);const ps=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 12.5 8 15l2 2.5",key:"1tg20x"}],["path",{d:"m14 12.5 2 2.5-2 2.5",key:"yinavb"}]],gs=Y("file-code",ps);const fs=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M7 3v18",key:"bbkbws"}],["path",{d:"M3 7.5h4",key:"zfgn84"}],["path",{d:"M3 12h18",key:"1i2n21"}],["path",{d:"M3 16.5h4",key:"1230mu"}],["path",{d:"M17 3v18",key:"in4fa5"}],["path",{d:"M17 7.5h4",key:"myr1c1"}],["path",{d:"M17 16.5h4",key:"go4c1d"}]],ws=Y("film",fs);const js=[["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]],ue=Y("folder",js);const vs=[["rect",{width:"7",height:"7",x:"3",y:"3",rx:"1",key:"1g98yp"}],["rect",{width:"7",height:"7",x:"14",y:"3",rx:"1",key:"6d4xhi"}],["rect",{width:"7",height:"7",x:"14",y:"14",rx:"1",key:"nxv5o0"}],["rect",{width:"7",height:"7",x:"3",y:"14",rx:"1",key:"1bb6yr"}]],ys=Y("layout-grid",vs);const bs=[["path",{d:"M3 5h.01",key:"18ugdj"}],["path",{d:"M3 12h.01",key:"nlz23k"}],["path",{d:"M3 19h.01",key:"noohij"}],["path",{d:"M8 5h13",key:"1pao27"}],["path",{d:"M8 12h13",key:"1za7za"}],["path",{d:"M8 19h13",key:"m83p4d"}]],Cs=Y("list",bs);const Ns=[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"m21 3-7 7",key:"1l2asr"}],["path",{d:"m3 21 7-7",key:"tjx5ai"}],["path",{d:"M9 21H3v-6",key:"wtvkvv"}]],ks=Y("maximize-2",Ns);const Ds=[["path",{d:"M9 18V5l12-2v13",key:"1jmyc2"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["circle",{cx:"18",cy:"16",r:"3",key:"1hluhg"}]],Ss=Y("music",Ds);const Ms=[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]],Is=Y("refresh-cw",Ms);function be({delayDuration:a=0,...t}){return e.jsx(Bt,{"data-slot":"tooltip-provider",delayDuration:a,...t})}function Ce({...a}){return e.jsx(Kt,{"data-slot":"tooltip",...a})}function Ne({...a}){return e.jsx(Wt,{"data-slot":"tooltip-trigger",...a})}function ke({className:a,sideOffset:t=0,children:s,...l}){return e.jsx(Vt,{children:e.jsxs(qt,{"data-slot":"tooltip-content",sideOffset:t,className:P("bg-foreground text-background animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-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 z-50 w-fit origin-(--radix-tooltip-content-transform-origin) rounded-md px-3 py-1.5 text-xs text-balance",a),...l,children:[s,e.jsx(Qt,{className:"bg-foreground fill-foreground z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px]"})]})})}function Me({mimeType:a,className:t}){return a==="application/pdf"?e.jsx(it,{className:P("text-blue-500",t)}):a.startsWith("video/")?e.jsx(ws,{className:P("text-purple-500",t)}):a.startsWith("audio/")?e.jsx(Ss,{className:P("text-green-500",t)}):a==="image/svg+xml"?e.jsx(gs,{className:P("text-orange-500",t)}):e.jsx(Ct,{className:P("text-muted-foreground",t)})}function Ts(a){return a==="application/pdf"?"PDF":a==="image/svg+xml"?"SVG":a.startsWith("image/")?"Image":a.startsWith("video/")?"Video":a.startsWith("audio/")?"Audio":a.split("/")[1]?.toUpperCase()??"File"}function _s({item:a,selected:t,onToggle:s,onSelect:l,onLightbox:n,folderName:r}){const{attributes:u,listeners:h,setNodeRef:o,isDragging:i}=lt({id:a.mediaId,data:{type:"media",mediaId:a.mediaId}}),p=a.mimeType.startsWith("image/")&&a.mimeType!=="image/svg+xml";return e.jsxs(ot,{ref:o,className:P("cursor-pointer",i&&"opacity-50"),onClick:l,children:[e.jsx(X,{onPointerDown:m=>m.stopPropagation(),onClick:m=>m.stopPropagation(),children:e.jsx(Se,{checked:t,onCheckedChange:s,"aria-label":`Select ${a.filename}`})}),e.jsx(X,{className:"w-6 p-1",children:e.jsx("div",{className:"cursor-grab text-muted-foreground",...u,...h,children:e.jsx(Gt,{className:"h-4 w-4"})})}),e.jsx(X,{className:"p-1",children:p?e.jsx("img",{src:W(a.urls?.thumb_sm??a.url),alt:a.alt||a.filename,className:P("h-8 w-8 rounded object-cover",n&&"cursor-zoom-in"),onClick:n?m=>{m.stopPropagation(),n()}:void 0}):e.jsx("div",{className:"flex h-8 w-8 items-center justify-center",children:e.jsx(Me,{mimeType:a.mimeType,className:"h-5 w-5"})})}),e.jsxs(X,{className:"max-w-[200px]",children:[r&&e.jsx("span",{className:"text-muted-foreground block truncate text-xs",children:r}),e.jsx("span",{className:"block truncate text-sm font-medium",children:a.filename})]}),e.jsx(X,{children:e.jsx("span",{className:"text-muted-foreground text-xs",children:Ts(a.mimeType)})}),e.jsx(X,{className:"text-right",children:e.jsx("span",{className:"text-muted-foreground text-xs",children:je(a.size)})}),e.jsx(X,{children:e.jsx("span",{className:"text-muted-foreground text-xs",children:a.width&&a.height?`${a.width}×${a.height}`:"—"})}),e.jsx(X,{children:a.tags.length>0&&e.jsxs("div",{className:"flex flex-wrap gap-1",children:[a.tags.slice(0,3).map(m=>e.jsx("span",{className:"bg-muted text-muted-foreground rounded px-1.5 py-0.5 text-[10px]",children:m},m)),a.tags.length>3&&e.jsxs("span",{className:"text-muted-foreground text-[10px]",children:["+",a.tags.length-3]})]})}),e.jsx(X,{children:e.jsx(be,{children:e.jsxs(Ce,{children:[e.jsx(Ne,{asChild:!0,children:e.jsx("span",{className:"text-muted-foreground text-xs",children:Pe(a.uploadedAt)})}),e.jsx(ke,{children:Ue(a.uploadedAt)})]})})}),e.jsx(X,{onPointerDown:m=>m.stopPropagation(),onClick:m=>m.stopPropagation(),children:e.jsx(C,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>{navigator.clipboard.writeText(W(a.url)),S.success("URL copied to clipboard")},children:e.jsx(Oe,{className:"h-3.5 w-3.5"})})})]})}function Rs({items:a,host:t,onSelect:s,selectedIds:l,onToggle:n,onToggleAll:r,allSelected:u,onLightbox:h,folderMap:o}){return e.jsxs(rs,{children:[e.jsx(is,{children:e.jsxs(ot,{children:[e.jsx(H,{className:"w-10",children:e.jsx(Se,{checked:u,onCheckedChange:r,"aria-label":"Select all"})}),e.jsx(H,{className:"w-6"}),e.jsx(H,{className:"w-12"}),e.jsx(H,{children:"Filename"}),e.jsx(H,{className:"w-20",children:"Type"}),e.jsx(H,{className:"w-24 text-right",children:"Size"}),e.jsx(H,{className:"w-28",children:"Dimensions"}),e.jsx(H,{className:"w-40",children:"Tags"}),e.jsx(H,{className:"w-32",children:"Uploaded"}),e.jsx(H,{className:"w-10"})]})}),e.jsx(ls,{children:a.map(i=>e.jsx(_s,{item:i,host:t,selected:l.has(i.mediaId),onToggle:()=>n(i.mediaId),onSelect:()=>s(i),folderName:o?.get(i.folderId??""),onLightbox:h&&i.mimeType.startsWith("image/")&&i.mimeType!=="image/svg+xml"?()=>h(i):void 0},i.mediaId))})]})}var As=Object.defineProperty,zs=(a,t,s)=>t in a?As(a,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):a[t]=s,T=(a,t,s)=>zs(a,typeof t!="symbol"?t+"":t,s);const De={x:0,y:0,width:0,height:0,unit:"px"},ae=(a,t,s)=>Math.min(Math.max(a,t),s),$s=(...a)=>a.filter(t=>t&&typeof t=="string").join(" "),qe=(a,t)=>a===t||a.width===t.width&&a.height===t.height&&a.x===t.x&&a.y===t.y&&a.unit===t.unit;function ne(a,t,s){return a.unit==="%"?{...De,...a,unit:"%"}:{unit:"%",x:a.x?a.x/t*100:0,y:a.y?a.y/s*100:0,width:a.width?a.width/t*100:0,height:a.height?a.height/s*100:0}}function G(a,t,s){return a.unit?a.unit==="px"?{...De,...a,unit:"px"}:{unit:"px",x:a.x?a.x*t/100:0,y:a.y?a.y*s/100:0,width:a.width?a.width*t/100:0,height:a.height?a.height*s/100:0}:{...De,...a,unit:"px"}}function Qe(a,t,s,l,n,r=0,u=0,h=l,o=n){const i={...a};let p=Math.min(r,l),m=Math.min(u,n),w=Math.min(h,l),c=Math.min(o,n);t&&(t>1?(p=u?u*t:p,m=p/t,w=h*t):(m=r?r/t:m,p=m*t,c=o/t)),i.y<0&&(i.height=Math.max(i.height+i.y,m),i.y=0),i.x<0&&(i.width=Math.max(i.width+i.x,p),i.x=0);const y=l-(i.x+i.width);y<0&&(i.x=Math.min(i.x,l-p),i.width+=y);const d=n-(i.y+i.height);if(d<0&&(i.y=Math.min(i.y,n-m),i.height+=d),i.width<p&&((s==="sw"||s=="nw")&&(i.x-=p-i.width),i.width=p),i.height<m&&((s==="nw"||s=="ne")&&(i.y-=m-i.height),i.height=m),i.width>w&&((s==="sw"||s=="nw")&&(i.x-=w-i.width),i.width=w),i.height>c&&((s==="nw"||s=="ne")&&(i.y-=c-i.height),i.height=c),t){const j=i.width/i.height;if(j<t){const v=Math.max(i.width/t,m);(s==="nw"||s=="ne")&&(i.y-=v-i.height),i.height=v}else if(j>t){const v=Math.max(i.height*t,p);(s==="sw"||s=="nw")&&(i.x-=v-i.width),i.width=v}}return i}function Es(a,t,s,l){const n={...a};return t==="ArrowLeft"?l==="nw"?(n.x-=s,n.y-=s,n.width+=s,n.height+=s):l==="w"?(n.x-=s,n.width+=s):l==="sw"?(n.x-=s,n.width+=s,n.height+=s):l==="ne"?(n.y+=s,n.width-=s,n.height-=s):l==="e"?n.width-=s:l==="se"&&(n.width-=s,n.height-=s):t==="ArrowRight"&&(l==="nw"?(n.x+=s,n.y+=s,n.width-=s,n.height-=s):l==="w"?(n.x+=s,n.width-=s):l==="sw"?(n.x+=s,n.width-=s,n.height-=s):l==="ne"?(n.y-=s,n.width+=s,n.height+=s):l==="e"?n.width+=s:l==="se"&&(n.width+=s,n.height+=s)),t==="ArrowUp"?l==="nw"?(n.x-=s,n.y-=s,n.width+=s,n.height+=s):l==="n"?(n.y-=s,n.height+=s):l==="ne"?(n.y-=s,n.width+=s,n.height+=s):l==="sw"?(n.x+=s,n.width-=s,n.height-=s):l==="s"?n.height-=s:l==="se"&&(n.width-=s,n.height-=s):t==="ArrowDown"&&(l==="nw"?(n.x+=s,n.y+=s,n.width-=s,n.height-=s):l==="n"?(n.y+=s,n.height-=s):l==="ne"?(n.y+=s,n.width-=s,n.height-=s):l==="sw"?(n.x-=s,n.width+=s,n.height+=s):l==="s"?n.height+=s:l==="se"&&(n.width+=s,n.height+=s)),n}const re={capture:!0,passive:!1};let Fs=0;const Z=class U extends x.PureComponent{constructor(){super(...arguments),T(this,"docMoveBound",!1),T(this,"mouseDownOnCrop",!1),T(this,"dragStarted",!1),T(this,"evData",{startClientX:0,startClientY:0,startCropX:0,startCropY:0,clientX:0,clientY:0,isResize:!0}),T(this,"componentRef",x.createRef()),T(this,"mediaRef",x.createRef()),T(this,"resizeObserver"),T(this,"initChangeCalled",!1),T(this,"instanceId",`rc-${Fs++}`),T(this,"state",{cropIsActive:!1,newCropIsBeingDrawn:!1}),T(this,"onCropPointerDown",t=>{const{crop:s,disabled:l}=this.props,n=this.getBox();if(!s)return;const r=G(s,n.width,n.height);if(l)return;t.cancelable&&t.preventDefault(),this.bindDocMove(),this.componentRef.current.focus({preventScroll:!0});const u=t.target.dataset.ord,h=!!u;let o=t.clientX,i=t.clientY,p=r.x,m=r.y;if(u){const w=t.clientX-n.x,c=t.clientY-n.y;let y=0,d=0;u==="ne"||u=="e"?(y=w-(r.x+r.width),d=c-r.y,p=r.x,m=r.y+r.height):u==="se"||u==="s"?(y=w-(r.x+r.width),d=c-(r.y+r.height),p=r.x,m=r.y):u==="sw"||u=="w"?(y=w-r.x,d=c-(r.y+r.height),p=r.x+r.width,m=r.y):(u==="nw"||u=="n")&&(y=w-r.x,d=c-r.y,p=r.x+r.width,m=r.y+r.height),o=p+n.x+y,i=m+n.y+d}this.evData={startClientX:o,startClientY:i,startCropX:p,startCropY:m,clientX:t.clientX,clientY:t.clientY,isResize:h,ord:u},this.mouseDownOnCrop=!0,this.setState({cropIsActive:!0})}),T(this,"onComponentPointerDown",t=>{const{crop:s,disabled:l,locked:n,keepSelection:r,onChange:u}=this.props,h=this.getBox();if(l||n||r&&s)return;t.cancelable&&t.preventDefault(),this.bindDocMove(),this.componentRef.current.focus({preventScroll:!0});const o=t.clientX-h.x,i=t.clientY-h.y,p={unit:"px",x:o,y:i,width:0,height:0};this.evData={startClientX:t.clientX,startClientY:t.clientY,startCropX:o,startCropY:i,clientX:t.clientX,clientY:t.clientY,isResize:!0},this.mouseDownOnCrop=!0,u(G(p,h.width,h.height),ne(p,h.width,h.height)),this.setState({cropIsActive:!0,newCropIsBeingDrawn:!0})}),T(this,"onDocPointerMove",t=>{const{crop:s,disabled:l,onChange:n,onDragStart:r}=this.props,u=this.getBox();if(l||!s||!this.mouseDownOnCrop)return;t.cancelable&&t.preventDefault(),this.dragStarted||(this.dragStarted=!0,r&&r(t));const{evData:h}=this;h.clientX=t.clientX,h.clientY=t.clientY;let o;h.isResize?o=this.resizeCrop():o=this.dragCrop(),qe(s,o)||n(G(o,u.width,u.height),ne(o,u.width,u.height))}),T(this,"onComponentKeyDown",t=>{const{crop:s,disabled:l,onChange:n,onComplete:r}=this.props;if(l)return;const u=t.key;let h=!1;if(!s)return;const o=this.getBox(),i=this.makePixelCrop(o),p=(navigator.platform.match("Mac")?t.metaKey:t.ctrlKey)?U.nudgeStepLarge:t.shiftKey?U.nudgeStepMedium:U.nudgeStep;if(u==="ArrowLeft"?(i.x-=p,h=!0):u==="ArrowRight"?(i.x+=p,h=!0):u==="ArrowUp"?(i.y-=p,h=!0):u==="ArrowDown"&&(i.y+=p,h=!0),h){t.cancelable&&t.preventDefault(),i.x=ae(i.x,0,o.width-i.width),i.y=ae(i.y,0,o.height-i.height);const m=G(i,o.width,o.height),w=ne(i,o.width,o.height);n(m,w),r&&r(m,w)}}),T(this,"onHandlerKeyDown",(t,s)=>{const{aspect:l=0,crop:n,disabled:r,minWidth:u=0,minHeight:h=0,maxWidth:o,maxHeight:i,onChange:p,onComplete:m}=this.props,w=this.getBox();if(r||!n)return;if(t.key==="ArrowUp"||t.key==="ArrowDown"||t.key==="ArrowLeft"||t.key==="ArrowRight")t.stopPropagation(),t.preventDefault();else return;const c=(navigator.platform.match("Mac")?t.metaKey:t.ctrlKey)?U.nudgeStepLarge:t.shiftKey?U.nudgeStepMedium:U.nudgeStep,y=G(n,w.width,w.height),d=Es(y,t.key,c,s),j=Qe(d,l,s,w.width,w.height,u,h,o,i);if(!qe(n,j)){const v=ne(j,w.width,w.height);p(j,v),m&&m(j,v)}}),T(this,"onDocPointerDone",t=>{const{crop:s,disabled:l,onComplete:n,onDragEnd:r}=this.props,u=this.getBox();this.unbindDocMove(),!(l||!s)&&this.mouseDownOnCrop&&(this.mouseDownOnCrop=!1,this.dragStarted=!1,r&&r(t),n&&n(G(s,u.width,u.height),ne(s,u.width,u.height)),this.setState({cropIsActive:!1,newCropIsBeingDrawn:!1}))}),T(this,"onDragFocus",()=>{var t;(t=this.componentRef.current)==null||t.scrollTo(0,0)})}get document(){return document}getBox(){const t=this.mediaRef.current;if(!t)return{x:0,y:0,width:0,height:0};const{x:s,y:l,width:n,height:r}=t.getBoundingClientRect();return{x:s,y:l,width:n,height:r}}componentDidUpdate(t){const{crop:s,onComplete:l}=this.props;if(l&&!t.crop&&s){const{width:n,height:r}=this.getBox();n&&r&&l(G(s,n,r),ne(s,n,r))}}componentWillUnmount(){this.resizeObserver&&this.resizeObserver.disconnect(),this.unbindDocMove()}bindDocMove(){this.docMoveBound||(this.document.addEventListener("pointermove",this.onDocPointerMove,re),this.document.addEventListener("pointerup",this.onDocPointerDone,re),this.document.addEventListener("pointercancel",this.onDocPointerDone,re),this.docMoveBound=!0)}unbindDocMove(){this.docMoveBound&&(this.document.removeEventListener("pointermove",this.onDocPointerMove,re),this.document.removeEventListener("pointerup",this.onDocPointerDone,re),this.document.removeEventListener("pointercancel",this.onDocPointerDone,re),this.docMoveBound=!1)}getCropStyle(){const{crop:t}=this.props;if(t)return{top:`${t.y}${t.unit}`,left:`${t.x}${t.unit}`,width:`${t.width}${t.unit}`,height:`${t.height}${t.unit}`}}dragCrop(){const{evData:t}=this,s=this.getBox(),l=this.makePixelCrop(s),n=t.clientX-t.startClientX,r=t.clientY-t.startClientY;return l.x=ae(t.startCropX+n,0,s.width-l.width),l.y=ae(t.startCropY+r,0,s.height-l.height),l}getPointRegion(t,s,l,n){const{evData:r}=this,u=r.clientX-t.x,h=r.clientY-t.y;let o;n&&s?o=s==="nw"||s==="n"||s==="ne":o=h<r.startCropY;let i;return l&&s?i=s==="nw"||s==="w"||s==="sw":i=u<r.startCropX,i?o?"nw":"sw":o?"ne":"se"}resolveMinDimensions(t,s,l=0,n=0){const r=Math.min(l,t.width),u=Math.min(n,t.height);return!s||!r&&!u?[r,u]:s>1?r?[r,r/s]:[u*s,u]:u?[u*s,u]:[r,r/s]}resizeCrop(){const{evData:t}=this,{aspect:s=0,maxWidth:l,maxHeight:n}=this.props,r=this.getBox(),[u,h]=this.resolveMinDimensions(r,s,this.props.minWidth,this.props.minHeight);let o=this.makePixelCrop(r);const i=this.getPointRegion(r,t.ord,u,h),p=t.ord||i;let m=t.clientX-t.startClientX,w=t.clientY-t.startClientY;(u&&p==="nw"||p==="w"||p==="sw")&&(m=Math.min(m,-u)),(h&&p==="nw"||p==="n"||p==="ne")&&(w=Math.min(w,-h));const c={unit:"px",x:0,y:0,width:0,height:0};i==="ne"?(c.x=t.startCropX,c.width=m,s?(c.height=c.width/s,c.y=t.startCropY-c.height):(c.height=Math.abs(w),c.y=t.startCropY-c.height)):i==="se"?(c.x=t.startCropX,c.y=t.startCropY,c.width=m,s?c.height=c.width/s:c.height=w):i==="sw"?(c.x=t.startCropX+m,c.y=t.startCropY,c.width=Math.abs(m),s?c.height=c.width/s:c.height=w):i==="nw"&&(c.x=t.startCropX+m,c.width=Math.abs(m),s?(c.height=c.width/s,c.y=t.startCropY-c.height):(c.height=Math.abs(w),c.y=t.startCropY+w));const y=Qe(c,s,i,r.width,r.height,u,h,l,n);return s||U.xyOrds.indexOf(p)>-1?o=y:U.xOrds.indexOf(p)>-1?(o.x=y.x,o.width=y.width):U.yOrds.indexOf(p)>-1&&(o.y=y.y,o.height=y.height),o.x=ae(o.x,0,r.width-o.width),o.y=ae(o.y,0,r.height-o.height),o}renderCropSelection(){const{ariaLabels:t=U.defaultProps.ariaLabels,disabled:s,locked:l,renderSelectionAddon:n,ruleOfThirds:r,crop:u}=this.props,h=this.getCropStyle();if(u)return D.createElement("div",{style:h,className:"ReactCrop__crop-selection",onPointerDown:this.onCropPointerDown,"aria-label":t.cropArea,tabIndex:0,onKeyDown:this.onComponentKeyDown,role:"group"},!s&&!l&&D.createElement("div",{className:"ReactCrop__drag-elements",onFocus:this.onDragFocus},D.createElement("div",{className:"ReactCrop__drag-bar ord-n","data-ord":"n"}),D.createElement("div",{className:"ReactCrop__drag-bar ord-e","data-ord":"e"}),D.createElement("div",{className:"ReactCrop__drag-bar ord-s","data-ord":"s"}),D.createElement("div",{className:"ReactCrop__drag-bar ord-w","data-ord":"w"}),D.createElement("div",{className:"ReactCrop__drag-handle ord-nw","data-ord":"nw",tabIndex:0,"aria-label":t.nwDragHandle,onKeyDown:o=>this.onHandlerKeyDown(o,"nw"),role:"button"}),D.createElement("div",{className:"ReactCrop__drag-handle ord-n","data-ord":"n",tabIndex:0,"aria-label":t.nDragHandle,onKeyDown:o=>this.onHandlerKeyDown(o,"n"),role:"button"}),D.createElement("div",{className:"ReactCrop__drag-handle ord-ne","data-ord":"ne",tabIndex:0,"aria-label":t.neDragHandle,onKeyDown:o=>this.onHandlerKeyDown(o,"ne"),role:"button"}),D.createElement("div",{className:"ReactCrop__drag-handle ord-e","data-ord":"e",tabIndex:0,"aria-label":t.eDragHandle,onKeyDown:o=>this.onHandlerKeyDown(o,"e"),role:"button"}),D.createElement("div",{className:"ReactCrop__drag-handle ord-se","data-ord":"se",tabIndex:0,"aria-label":t.seDragHandle,onKeyDown:o=>this.onHandlerKeyDown(o,"se"),role:"button"}),D.createElement("div",{className:"ReactCrop__drag-handle ord-s","data-ord":"s",tabIndex:0,"aria-label":t.sDragHandle,onKeyDown:o=>this.onHandlerKeyDown(o,"s"),role:"button"}),D.createElement("div",{className:"ReactCrop__drag-handle ord-sw","data-ord":"sw",tabIndex:0,"aria-label":t.swDragHandle,onKeyDown:o=>this.onHandlerKeyDown(o,"sw"),role:"button"}),D.createElement("div",{className:"ReactCrop__drag-handle ord-w","data-ord":"w",tabIndex:0,"aria-label":t.wDragHandle,onKeyDown:o=>this.onHandlerKeyDown(o,"w"),role:"button"})),n&&D.createElement("div",{className:"ReactCrop__selection-addon",onPointerDown:o=>o.stopPropagation()},n(this.state)),r&&D.createElement(D.Fragment,null,D.createElement("div",{className:"ReactCrop__rule-of-thirds-hz"}),D.createElement("div",{className:"ReactCrop__rule-of-thirds-vt"})))}makePixelCrop(t){const s={...De,...this.props.crop||{}};return G(s,t.width,t.height)}render(){const{aspect:t,children:s,circularCrop:l,className:n,crop:r,disabled:u,locked:h,style:o,ruleOfThirds:i}=this.props,{cropIsActive:p,newCropIsBeingDrawn:m}=this.state,w=r?this.renderCropSelection():null,c=$s("ReactCrop",n,p&&"ReactCrop--active",u&&"ReactCrop--disabled",h&&"ReactCrop--locked",m&&"ReactCrop--new-crop",r&&t&&"ReactCrop--fixed-aspect",r&&l&&"ReactCrop--circular-crop",r&&i&&"ReactCrop--rule-of-thirds",!this.dragStarted&&r&&!r.width&&!r.height&&"ReactCrop--invisible-crop",l&&"ReactCrop--no-animate");return D.createElement("div",{ref:this.componentRef,className:c,style:o},D.createElement("div",{ref:this.mediaRef,className:"ReactCrop__child-wrapper",onPointerDown:this.onComponentPointerDown},s),r?D.createElement("svg",{className:"ReactCrop__crop-mask",width:"100%",height:"100%"},D.createElement("defs",null,D.createElement("mask",{id:`hole-${this.instanceId}`},D.createElement("rect",{width:"100%",height:"100%",fill:"white"}),l?D.createElement("ellipse",{cx:`${r.x+r.width/2}${r.unit}`,cy:`${r.y+r.height/2}${r.unit}`,rx:`${r.width/2}${r.unit}`,ry:`${r.height/2}${r.unit}`,fill:"black"}):D.createElement("rect",{x:`${r.x}${r.unit}`,y:`${r.y}${r.unit}`,width:`${r.width}${r.unit}`,height:`${r.height}${r.unit}`,fill:"black"}))),D.createElement("rect",{fill:"black",fillOpacity:.5,width:"100%",height:"100%",mask:`url(#hole-${this.instanceId})`})):void 0,w)}};T(Z,"xOrds",["e","w"]),T(Z,"yOrds",["n","s"]),T(Z,"xyOrds",["nw","ne","se","sw"]),T(Z,"nudgeStep",1),T(Z,"nudgeStepMedium",10),T(Z,"nudgeStepLarge",100),T(Z,"defaultProps",{ariaLabels:{cropArea:"Use the arrow keys to move the crop selection area",nwDragHandle:"Use the arrow keys to move the north west drag handle to change the crop selection area",nDragHandle:"Use the up and down arrow keys to move the north drag handle to change the crop selection area",neDragHandle:"Use the arrow keys to move the north east drag handle to change the crop selection area",eDragHandle:"Use the up and down arrow keys to move the east drag handle to change the crop selection area",seDragHandle:"Use the arrow keys to move the south east drag handle to change the crop selection area",sDragHandle:"Use the up and down arrow keys to move the south drag handle to change the crop selection area",swDragHandle:"Use the arrow keys to move the south west drag handle to change the crop selection area",wDragHandle:"Use the up and down arrow keys to move the west drag handle to change the crop selection area"}});let Ps=Z;const Us=[{label:"Free",value:""},{label:"1:1 Square",value:"1"},{label:"4:3",value:"4/3"},{label:"3:2",value:"3/2"},{label:"16:9",value:"16/9"},{label:"2:3",value:"2/3"},{label:"3:4",value:"3/4"}],dt=[{label:"Original",value:"",ext:""},{label:"JPEG",value:"jpeg",ext:".jpg"},{label:"PNG",value:"png",ext:".png"},{label:"WebP",value:"webp",ext:".webp"},{label:"AVIF",value:"avif",ext:".avif"}],Os={"image/jpeg":".jpg","image/png":".png","image/gif":".gif","image/webp":".webp","image/avif":".avif","image/tiff":".tiff"};function $e(a,t){return a?dt.find(s=>s.value===a)?.ext||`.${a}`:Os[t]||".jpg"}function Ls(a,t){const s=a.lastIndexOf(".");return(s>0?a.substring(0,s):a)+t}function Hs({host:a,media:t,onClose:s,onSaved:l}){const n=x.useRef(null),[r,u]=x.useState(),[h,o]=x.useState(),[i,p]=x.useState(""),[m,w]=x.useState(""),[c,y]=x.useState(""),[d,j]=x.useState(""),[v,_]=x.useState("80"),[R,I]=x.useState(()=>{const b=$e("",t.mimeType),k=t.filename.lastIndexOf(".");return`${k>0?t.filename.substring(0,k):t.filename}-transformed${b}`});function E(b){const k=b==="__original__"?"":b;j(k);const q=$e(k,t.mimeType);I(J=>Ls(J,q))}const F=Nt(a,t.mediaId),[g,A]=x.useState(null),$=x.useCallback(()=>{if(!h||!g)return null;const b=(t.width??g.width)/g.width,k=(t.height??g.height)/g.height;return{cropX:Math.round(h.x*b),cropY:Math.round(h.y*k),cropW:Math.round(h.width*b),cropH:Math.round(h.height*k)}},[h,t.width,t.height,g]),se=x.useMemo(()=>$(),[$]);async function me(){const b=se,k=m?parseInt(m):void 0,q=c?parseInt(c):void 0;if(!b&&!k&&!q&&!d){S.error("Please specify a crop, resize, or format change");return}if(!R.trim()){S.error("Filename is required");return}const J=$e(d,t.mimeType);if(!R.trim().toLowerCase().endsWith(J)){S.error(`Filename must end with ${J} to match the output format`);return}try{const B=await F.mutateAsync({...b??{},...k?{width:k}:{},...q?{height:q}:{},...d?{format:d}:{},...v?{quality:parseInt(v)}:{},filename:R.trim()});S.success("Transform saved as new media"),l?.(B),s()}catch(B){S.error("Transform failed",{description:B instanceof Error?B.message:void 0})}}function V(b){p(b==="__free__"?"":b),u(void 0),o(void 0)}function Ie(b){if(!b)return;const k=b.split("/");return k.length===2?Number(k[0])/Number(k[1]):Number(b)||void 0}const Te=Ie(i);return e.jsx(ie,{open:!0,onOpenChange:()=>s(),children:e.jsxs(le,{className:"max-w-4xl max-h-[90vh] overflow-y-auto",children:[e.jsxs(oe,{children:[e.jsx(ce,{children:"Transform Image"}),e.jsx(de,{className:"sr-only",children:"Crop, resize, or convert image format"})]}),e.jsxs("div",{className:"grid grid-cols-[1fr_280px] gap-6",children:[e.jsx("div",{className:"min-h-0 overflow-hidden rounded border bg-muted/30 flex items-center justify-center",children:e.jsx(Ps,{crop:r,onChange:b=>u(b),onComplete:b=>o(b),aspect:Te,children:e.jsx("img",{ref:n,src:W(t.url),alt:t.alt||t.filename,className:"max-h-[60vh] max-w-full object-contain",onLoad:b=>{const k=b.currentTarget;A({width:k.naturalWidth,height:k.naturalHeight})}})})}),e.jsxs("div",{className:"space-y-5",children:[e.jsxs("div",{className:"text-muted-foreground text-sm",children:["Original: ",t.width,"×",t.height]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(O,{children:"Crop aspect ratio"}),e.jsxs(pe,{value:i||"__free__",onValueChange:V,children:[e.jsx(ge,{children:e.jsx(fe,{placeholder:"Free"})}),e.jsx(we,{children:Us.map(b=>e.jsx(te,{value:b.value||"__free__",children:b.label},b.value||"__free__"))})]}),h&&e.jsxs("div",{className:"text-xs text-muted-foreground",children:["Crop: ",se?.cropW,"×",se?.cropH," at (",se?.cropX,", ",se?.cropY,")"]}),h&&e.jsx(C,{variant:"ghost",size:"sm",onClick:()=>{u(void 0),o(void 0)},children:"Clear crop"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(O,{children:"Resize (optional)"}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsx("div",{children:e.jsx(K,{type:"number",placeholder:"Width",value:m,onChange:b=>w(b.target.value),min:1,max:2048})}),e.jsx("div",{children:e.jsx(K,{type:"number",placeholder:"Height",value:c,onChange:b=>y(b.target.value),min:1,max:2048})})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(O,{children:"Output format"}),e.jsxs(pe,{value:d||"__original__",onValueChange:E,children:[e.jsx(ge,{children:e.jsx(fe,{placeholder:"Original"})}),e.jsx(we,{children:dt.map(b=>e.jsx(te,{value:b.value||"__original__",children:b.label},b.value||"__original__"))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(O,{children:"Quality (1-100)"}),e.jsx(K,{type:"number",value:v,onChange:b=>_(b.target.value),min:1,max:100})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(O,{children:"Save as filename"}),e.jsx(K,{value:R,onChange:b=>I(b.target.value)})]})]})]}),e.jsxs(he,{children:[e.jsx(C,{variant:"outline",onClick:s,children:"Cancel"}),e.jsxs(C,{onClick:me,disabled:F.isPending,children:[F.isPending&&e.jsx(ee,{className:"mr-2 h-4 w-4 animate-spin"}),"Save as New Image"]})]})]})})}const Xs=new Set(["image/jpeg","image/png","image/gif","image/webp","image/avif","image/tiff"]);function Ys({host:a,media:t,onClose:s,folders:l,tagSuggestions:n}){const[r,u]=x.useState(t.alt??""),[h,o]=x.useState(t.caption??""),[i,p]=x.useState(t.userTags??[]),[m,w]=x.useState(t.folderId||"__none__"),[c,y]=x.useState(!1),d=Xs.has(t.mimeType),j=kt(a,t.mediaId),v=Dt(a,t.mediaId),{data:_,isLoading:R}=St(a,t.mediaId),I=t.tags.filter(g=>!t.userTags?.includes(g));async function E(){try{await j.mutateAsync({alt:r,caption:h,userTags:i,folderId:m==="__none__"?"":m}),S.success("Media updated"),s()}catch(g){S.error("Failed to update",{description:g instanceof Error?g.message:void 0})}}async function F(){try{await v.mutateAsync(),S.success("Media deleted"),s()}catch(g){S.error("Failed to delete",{description:g instanceof Error?g.message:void 0})}}return e.jsxs(ie,{open:!0,onOpenChange:()=>s(),children:[e.jsxs(le,{children:[e.jsxs(oe,{children:[e.jsx(ce,{children:t.filename}),e.jsx(de,{className:"sr-only",children:"View and edit media details"})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"text-muted-foreground text-sm",children:[t.mimeType," · ",je(t.size),t.width&&t.height&&` · ${t.width}×${t.height}`," · ",Ue(t.uploadedAt)]}),e.jsxs("div",{className:"flex gap-2",children:[d&&e.jsxs(C,{variant:"outline",size:"sm",onClick:()=>y(!0),children:[e.jsx(xs,{className:"mr-1.5 h-3.5 w-3.5"}),"Transform"]}),e.jsxs(C,{variant:"outline",size:"sm",onClick:()=>{navigator.clipboard.writeText(W(t.url)),S.success("URL copied to clipboard")},children:[e.jsx(Oe,{className:"mr-1.5 h-3.5 w-3.5"}),"Copy URL"]})]})]}),I.length>0&&e.jsxs("div",{className:"space-y-1",children:[e.jsx(O,{className:"text-xs text-muted-foreground",children:"Auto-detected tags"}),e.jsx("div",{className:"flex flex-wrap gap-1",children:I.map(g=>e.jsx(ct,{variant:"outline",className:"text-xs",children:g},g))})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(O,{children:"Tags"}),e.jsx(Fe,{tags:i,onChange:p,placeholder:"Add tags...",suggestions:n})]}),l&&l.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(O,{children:"Folder"}),e.jsxs(pe,{value:m,onValueChange:w,children:[e.jsx(ge,{children:e.jsx(fe,{placeholder:"No folder"})}),e.jsxs(we,{children:[e.jsx(te,{value:"__none__",children:"No folder"}),l.map(g=>e.jsx(te,{value:g.folderId,children:g.name},g.folderId))]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(O,{htmlFor:"alt",children:"Alt text"}),e.jsx(K,{id:"alt",value:r,onChange:g=>u(g.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(O,{htmlFor:"caption",children:"Caption"}),e.jsx(K,{id:"caption",value:h,onChange:g=>o(g.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(O,{className:"text-xs text-muted-foreground",children:"Used in"}),R?e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground text-sm",children:[e.jsx(ee,{className:"h-3.5 w-3.5 animate-spin"}),"Checking usage..."]}):_?.references.length?e.jsxs("div",{className:"space-y-1",children:[_.references.map(g=>e.jsxs(yt,{to:`/sites/${a}/content/${g.collection}/${g.contentId}`,className:"flex items-center gap-2 rounded px-2 py-1 text-sm hover:bg-muted",onClick:s,children:[e.jsx(it,{className:"h-3.5 w-3.5 text-muted-foreground"}),e.jsx("span",{className:"truncate",children:g.title||g.contentId}),e.jsxs("span",{className:"text-muted-foreground text-xs",children:["(",g.collection,")"]})]},g.contentId)),_.note&&e.jsx("p",{className:"text-muted-foreground text-xs italic",children:_.note})]}):e.jsx("p",{className:"text-muted-foreground text-sm",children:"Not referenced in any content."})]})]}),e.jsxs(he,{className:"flex justify-between",children:[e.jsxs(C,{variant:"destructive",size:"sm",onClick:F,children:[e.jsx(os,{className:"mr-2 h-4 w-4"}),"Delete"]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(C,{variant:"outline",onClick:s,children:"Cancel"}),e.jsx(C,{onClick:E,children:"Save"})]})]})]}),c&&e.jsx(Hs,{host:a,media:t,onClose:()=>y(!1),onSaved:()=>s()})]})}function Bs({tags:a,activeTag:t,onTagChange:s}){return a.length===0?null:e.jsxs("div",{className:"mb-4 flex flex-wrap items-center gap-1.5",children:[a.map(l=>e.jsx(ct,{variant:t===l?"default":"secondary",className:"cursor-pointer select-none",onClick:()=>s(t===l?void 0:l),children:l},l)),t&&e.jsxs(C,{variant:"ghost",size:"sm",className:"h-6 px-2 text-xs",onClick:()=>s(void 0),children:[e.jsx(xe,{className:"mr-1 h-3 w-3"}),"Clear"]})]})}function Ee({id:a,children:t}){const{setNodeRef:s,isOver:l}=Zt({id:a,data:{type:"folder"}});return e.jsx("div",{ref:s,children:t(l)})}function Ks({host:a,selectedFolderId:t,onSelect:s}){const{data:l}=Ge(a),n=Mt(a),r=It(a),u=Tt(a),[h,o]=x.useState(!1),[i,p]=x.useState(""),[m,w]=x.useState(null),[c,y]=x.useState(""),[d,j]=x.useState(null),v=x.useRef(null),_=x.useRef(null),R=l?.items??[];x.useEffect(()=>{h&&v.current?.focus()},[h]),x.useEffect(()=>{m&&_.current?.focus()},[m]);async function I(){const g=i.trim();if(!g){o(!1),p("");return}try{await n.mutateAsync(g),S.success("Folder created")}catch(A){S.error("Failed to create folder",{description:A instanceof Error?A.message:void 0})}o(!1),p("")}async function E(g){const A=c.trim();if(!A){w(null);return}try{await r.mutateAsync({folderId:g,name:A}),S.success("Folder renamed")}catch($){S.error("Failed to rename folder",{description:$ instanceof Error?$.message:void 0})}w(null)}async function F(){if(d){try{await u.mutateAsync(d.folderId),S.success("Folder deleted"),t===d.folderId&&s(null)}catch(g){S.error("Failed to delete folder",{description:g instanceof Error?g.message:void 0})}j(null)}}return e.jsxs("div",{className:"flex w-48 shrink-0 flex-col border-r",children:[e.jsxs("div",{className:"flex items-center justify-between border-b px-3 py-2",children:[e.jsx("span",{className:"text-sm font-medium",children:"Folders"}),e.jsx(C,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0",onClick:()=>o(!0),children:e.jsx(cs,{className:"h-4 w-4"})})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto py-1",children:[e.jsx(Ee,{id:"all-media",children:g=>e.jsx("button",{className:P("flex w-full items-center justify-between px-3 py-1.5 text-left text-sm hover:bg-accent/50",t===null&&"bg-accent font-medium",g&&"ring-2 ring-primary bg-primary/10"),onClick:()=>s(null),children:e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(ue,{className:"h-4 w-4"}),"All Media"]})})}),R.map(g=>e.jsx(Ee,{id:g.folderId,children:A=>e.jsx("div",{className:P("group flex w-full items-center justify-between px-3 py-1.5 text-sm hover:bg-accent/50",t===g.folderId&&"bg-accent font-medium",A&&"ring-2 ring-primary bg-primary/10"),children:m===g.folderId?e.jsx(K,{ref:_,value:c,onChange:$=>y($.target.value),onKeyDown:$=>{$.key==="Enter"&&E(g.folderId),$.key==="Escape"&&w(null)},onBlur:()=>E(g.folderId),className:"h-6 text-sm"}):e.jsxs(e.Fragment,{children:[e.jsxs("button",{className:"flex flex-1 items-center gap-2 text-left",onClick:()=>s(g.folderId),children:[e.jsx(ue,{className:"h-4 w-4 shrink-0"}),e.jsx("span",{className:"truncate",children:g.name})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"text-muted-foreground text-xs",children:g.count}),e.jsxs(Ft,{children:[e.jsx(Pt,{asChild:!0,children:e.jsx(C,{variant:"ghost",size:"sm",className:"h-5 w-5 p-0 opacity-0 group-hover:opacity-100",children:e.jsx(_t,{className:"h-3.5 w-3.5"})})}),e.jsxs(Ut,{align:"end",children:[e.jsx(We,{onClick:()=>{w(g.folderId),y(g.name)},children:"Rename"}),e.jsx(We,{disabled:g.count>0,onClick:()=>j(g),children:"Delete"})]})]})]})]})})},g.folderId)),e.jsx(Ee,{id:"unfiled",children:g=>e.jsx("button",{className:P("flex w-full items-center justify-between px-3 py-1.5 text-left text-sm hover:bg-accent/50",t==="unfiled"&&"bg-accent font-medium",g&&"ring-2 ring-primary bg-primary/10"),onClick:()=>s("unfiled"),children:e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(ue,{className:"h-4 w-4"}),"Unfiled"]})})}),h&&e.jsx("div",{className:"px-3 py-1.5",children:e.jsx(K,{ref:v,value:i,onChange:g=>p(g.target.value),onKeyDown:g=>{g.key==="Enter"&&I(),g.key==="Escape"&&(o(!1),p(""))},onBlur:I,placeholder:"Folder name...",className:"h-7 text-sm"})})]}),e.jsx(Ze,{open:!!d,onOpenChange:()=>j(null),children:e.jsxs(Je,{children:[e.jsxs(et,{children:[e.jsx(tt,{children:"Delete folder?"}),e.jsxs(st,{children:["This will delete the folder “",d?.name,"”. Media items in this folder will become unfiled."]})]}),e.jsxs(at,{children:[e.jsx(nt,{children:"Cancel"}),e.jsx(rt,{onClick:F,children:"Delete"})]})]})})]})}function Ws({selectedCount:a,folders:t,onDelete:s,onMove:l,onAddTags:n,onRemoveTags:r,onClear:u,isPending:h}){const[o,i]=x.useState(null),[p,m]=x.useState(""),[w,c]=x.useState([]);function y(){i(null),m(""),c([])}return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"mb-4 flex items-center gap-3 rounded-md border bg-muted/50 px-4 py-2",children:[e.jsxs("span",{className:"text-sm font-medium",children:[a," selected"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(C,{size:"sm",variant:"destructive",onClick:()=>i("delete"),disabled:h,children:"Delete"}),e.jsx(C,{size:"sm",variant:"outline",onClick:()=>i("move"),disabled:h,children:"Move to…"}),e.jsx(C,{size:"sm",variant:"outline",onClick:()=>i("addTags"),disabled:h,children:"Add tags"}),e.jsx(C,{size:"sm",variant:"outline",onClick:()=>i("removeTags"),disabled:h,children:"Remove tags"})]}),e.jsx(C,{size:"sm",variant:"ghost",onClick:u,className:"ml-auto",disabled:h,children:e.jsx(xe,{className:"h-4 w-4"})})]}),e.jsx(ie,{open:o==="delete",onOpenChange:d=>!d&&y(),children:e.jsxs(le,{children:[e.jsxs(oe,{children:[e.jsxs(ce,{children:["Delete ",a," item",a!==1?"s":"","?"]}),e.jsx(de,{children:"This action cannot be undone. The selected media items will be permanently deleted."})]}),e.jsxs(he,{children:[e.jsx(C,{variant:"outline",onClick:y,children:"Cancel"}),e.jsxs(C,{variant:"destructive",onClick:async()=>{y(),await s()},disabled:h,children:[h&&e.jsx(ee,{className:"mr-1 h-3 w-3 animate-spin"}),"Delete"]})]})]})}),e.jsx(ie,{open:o==="move",onOpenChange:d=>!d&&y(),children:e.jsxs(le,{children:[e.jsxs(oe,{children:[e.jsxs(ce,{children:["Move ",a," item",a!==1?"s":""]}),e.jsx(de,{children:"Choose a destination folder."})]}),e.jsxs(pe,{value:p,onValueChange:m,children:[e.jsx(ge,{children:e.jsx(fe,{placeholder:"Select folder..."})}),e.jsxs(we,{children:[e.jsx(te,{value:"__unfiled__",children:"Unfiled"}),t.map(d=>e.jsx(te,{value:d.folderId,children:d.name},d.folderId))]})]}),e.jsxs(he,{children:[e.jsx(C,{variant:"outline",onClick:y,children:"Cancel"}),e.jsxs(C,{onClick:async()=>{const d=p==="__unfiled__"?"":p;y(),await l(d)},disabled:!p||h,children:[h&&e.jsx(ee,{className:"mr-1 h-3 w-3 animate-spin"}),"Move"]})]})]})}),e.jsx(ie,{open:o==="addTags",onOpenChange:d=>!d&&y(),children:e.jsxs(le,{children:[e.jsxs(oe,{children:[e.jsxs(ce,{children:["Add tags to ",a," item",a!==1?"s":""]}),e.jsx(de,{className:"sr-only",children:"Select tags to add to the selected items"})]}),e.jsx(Fe,{tags:w,onChange:c,placeholder:"Add tags..."}),e.jsxs(he,{children:[e.jsx(C,{variant:"outline",onClick:y,children:"Cancel"}),e.jsxs(C,{onClick:async()=>{const d=[...w];y(),await n(d)},disabled:w.length===0||h,children:[h&&e.jsx(ee,{className:"mr-1 h-3 w-3 animate-spin"}),"Add"]})]})]})}),e.jsx(ie,{open:o==="removeTags",onOpenChange:d=>!d&&y(),children:e.jsxs(le,{children:[e.jsxs(oe,{children:[e.jsxs(ce,{children:["Remove tags from ",a," item",a!==1?"s":""]}),e.jsx(de,{className:"sr-only",children:"Select tags to remove from the selected items"})]}),e.jsx(Fe,{tags:w,onChange:c,placeholder:"Tags to remove..."}),e.jsxs(he,{children:[e.jsx(C,{variant:"outline",onClick:y,children:"Cancel"}),e.jsxs(C,{onClick:async()=>{const d=[...w];y(),await r(d)},disabled:w.length===0||h,children:[h&&e.jsx(ee,{className:"mr-1 h-3 w-3 animate-spin"}),"Remove"]})]})]})})]})}function Vs({onFiles:a,children:t}){const[s,l]=x.useState(!1),n=x.useRef(0),r=x.useCallback(i=>{i.preventDefault(),i.dataTransfer.types.includes("Files")&&(n.current++,l(!0))},[]),u=x.useCallback(i=>{i.preventDefault(),n.current--,n.current===0&&l(!1)},[]),h=x.useCallback(i=>{i.preventDefault(),i.dataTransfer.dropEffect="copy"},[]),o=x.useCallback(i=>{i.preventDefault(),n.current=0,l(!1);const p=Array.from(i.dataTransfer.files);p.length>0&&a(p)},[a]);return e.jsxs("div",{className:"relative flex-1",onDragEnter:r,onDragLeave:u,onDragOver:h,onDrop:o,children:[t,s&&e.jsx("div",{className:"absolute inset-0 z-40 flex items-center justify-center rounded-lg border-2 border-dashed border-primary bg-primary/5",children:e.jsxs("div",{className:"flex flex-col items-center gap-2 rounded-lg bg-background/90 px-6 py-4 shadow-lg",children:[e.jsx(ye,{className:"h-8 w-8 text-primary"}),e.jsx("p",{className:"text-lg font-medium",children:"Drop files to upload"}),e.jsx("p",{className:"text-muted-foreground text-sm",children:"Files will be uploaded to the current folder"})]})})]})}function qs({queue:a}){const{items:t,retry:s,dismiss:l,clearCompleted:n}=a,[r,u]=x.useState(!1),h=t.filter(c=>c.status==="uploading").length,o=t.filter(c=>c.status==="pending").length,i=t.filter(c=>c.status==="complete").length,p=t.filter(c=>c.status==="error").length,m=h===0&&o===0;if(x.useEffect(()=>{if(m&&t.length>0){const c=setTimeout(()=>u(!0),2e3);return()=>clearTimeout(c)}},[m,t.length]),t.length===0)return null;const w=m?`${i} uploaded${p?`, ${p} failed`:""}`:`Uploading ${h+o} file${h+o!==1?"s":""}`;return e.jsxs("div",{className:"fixed bottom-4 right-4 z-50 w-80 rounded-lg border bg-background shadow-lg",children:[e.jsxs("div",{className:"flex items-center justify-between border-b px-3 py-2",children:[e.jsx("span",{className:"text-sm font-medium",children:w}),e.jsxs("div",{className:"flex items-center gap-1",children:[m&&e.jsx(C,{variant:"ghost",size:"sm",className:"h-6 px-2 text-xs",onClick:n,children:"Clear"}),e.jsx(C,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0",onClick:()=>u(!r),children:r?e.jsx(Xt,{className:"h-4 w-4"}):e.jsx(Yt,{className:"h-4 w-4"})})]})]}),!r&&e.jsx("div",{className:"max-h-60 overflow-y-auto",children:t.map(c=>e.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 text-sm",children:[c.status==="uploading"&&e.jsx(ee,{className:"h-4 w-4 shrink-0 animate-spin"}),c.status==="complete"&&e.jsx(ds,{className:"h-4 w-4 shrink-0 text-green-500"}),c.status==="error"&&e.jsx(xe,{className:"h-4 w-4 shrink-0 text-destructive"}),c.status==="pending"&&e.jsx("div",{className:"h-4 w-4 shrink-0"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"truncate",children:c.file.name}),c.status==="uploading"&&e.jsx("div",{className:"bg-muted mt-0.5 h-1 w-full rounded-full",children:e.jsx("div",{className:"bg-primary h-full rounded-full transition-all",style:{width:`${c.progress}%`}})}),c.status==="error"&&e.jsx("p",{className:"text-destructive truncate text-xs",children:c.error})]}),c.status==="error"&&e.jsx(C,{variant:"ghost",size:"sm",className:"h-6 w-6 shrink-0 p-0",onClick:()=>s(c.id),children:e.jsx(Is,{className:"h-3 w-3"})}),(c.status==="complete"||c.status==="error")&&e.jsx(C,{variant:"ghost",size:"sm",className:"h-6 w-6 shrink-0 p-0",onClick:()=>l(c.id),children:e.jsx(xe,{className:"h-3 w-3"})})]},c.id))})]})}const Qs=3;let Gs=0;function Zs(a,t){const[s,l]=x.useState([]),n=Rt(a),r=At(a),u=x.useRef(0),h=x.useRef(s);h.current=s;const o=x.useRef(new Map),i=x.useCallback(async d=>{u.current++,l(j=>j.map(v=>v.id===d.id?{...v,status:"uploading",progress:0}:v));try{const{uploadUrl:j,mediaId:v}=await n.mutateAsync({filename:d.file.name,contentType:d.file.type,size:d.file.size});await new Promise((_,R)=>{const I=new XMLHttpRequest;o.current.set(d.id,I),I.upload.onprogress=E=>{if(E.lengthComputable){const F=Math.round(E.loaded/E.total*100);l(g=>g.map(A=>A.id===d.id?{...A,progress:F}:A))}},I.onload=()=>{o.current.delete(d.id),I.status>=200&&I.status<300?_():R(new Error(`Upload failed: ${I.status}`))},I.onerror=()=>{o.current.delete(d.id),R(new Error("Network error"))},I.onabort=()=>{o.current.delete(d.id),R(new Error("Upload aborted"))},I.open("PUT",j),I.setRequestHeader("Content-Type",d.file.type),I.send(d.file)}),await r.mutateAsync({mediaId:v,filename:d.file.name,folderId:d.folderId}),l(_=>_.map(R=>R.id===d.id?{...R,status:"complete",progress:100}:R))}catch(j){l(v=>v.map(_=>_.id===d.id?{..._,status:"error",error:j instanceof Error?j.message:"Upload failed"}:_))}finally{u.current--}},[n,r]),p=x.useRef(i);p.current=i,x.useEffect(()=>{const d=s.filter(v=>v.status==="pending"),j=Qs-u.current;for(let v=0;v<Math.min(d.length,j);v++)p.current(d[v])},[s]),x.useEffect(()=>{const d=o.current;return()=>{d.forEach(j=>j.abort())}},[]);const m=x.useCallback(d=>{const j=Array.from(d).map(v=>({id:`upload-${Gs++}`,file:v,folderId:t||void 0,status:"pending",progress:0}));l(v=>[...v,...j])},[t]),w=x.useCallback(d=>{l(j=>j.map(v=>v.id===d?{...v,status:"pending",progress:0,error:void 0}:v))},[]),c=x.useCallback(d=>{l(j=>j.filter(v=>v.id!==d))},[]),y=x.useCallback(()=>{l(d=>d.filter(j=>j.status!=="complete"&&j.status!=="error"))},[]);return{items:s,addFiles:m,retry:w,dismiss:c,clearCompleted:y}}function Js({items:a,currentIndex:t,onClose:s,onNavigate:l}){const n=a[t],r=t>0,u=t<a.length-1,h=x.useCallback(o=>{o.key==="Escape"?s():o.key==="ArrowLeft"&&r?l(t-1):o.key==="ArrowRight"&&u&&l(t+1)},[s,l,t,r,u]);return x.useEffect(()=>(document.addEventListener("keydown",h),document.body.style.overflow="hidden",()=>{document.removeEventListener("keydown",h),document.body.style.overflow=""}),[h]),n?e.jsxs("div",{className:"fixed inset-0 z-50 flex flex-col bg-black/90",onClick:s,children:[e.jsxs("div",{className:"flex items-center justify-between px-4 py-3 text-white",onClick:o=>o.stopPropagation(),children:[e.jsxs("div",{className:"text-sm",children:[e.jsx("span",{className:"font-medium",children:n.filename}),e.jsxs("span",{className:"ml-3 opacity-70",children:[n.width&&n.height&&`${n.width}×${n.height} · `,je(n.size)]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("span",{className:"text-sm opacity-70",children:[t+1," / ",a.length]}),e.jsx(C,{variant:"ghost",size:"icon",className:"text-white hover:bg-white/20",onClick:s,children:e.jsx(xe,{className:"h-5 w-5"})})]})]}),e.jsxs("div",{className:"relative flex flex-1 items-center justify-center px-16",onClick:o=>o.stopPropagation(),children:[e.jsx("img",{src:W(n.url),alt:n.alt||n.filename,className:"max-h-full max-w-full object-contain"}),r&&e.jsx(C,{variant:"ghost",size:"icon",className:"absolute left-4 top-1/2 -translate-y-1/2 text-white hover:bg-white/20",onClick:()=>l(t-1),children:e.jsx(us,{className:"h-8 w-8"})}),u&&e.jsx(C,{variant:"ghost",size:"icon",className:"absolute right-4 top-1/2 -translate-y-1/2 text-white hover:bg-white/20",onClick:()=>l(t+1),children:e.jsx(Jt,{className:"h-8 w-8"})})]})]}):null}function ea({open:a,duplicates:t,fileCount:s,onContinue:l,onCancel:n}){return e.jsx(Ze,{open:a,onOpenChange:r=>!r&&n(),children:e.jsxs(Je,{children:[e.jsxs(et,{children:[e.jsx(tt,{children:"Possible duplicates found"}),e.jsx(st,{children:s===1?"A file with the same name and size already exists:":`${t.length} of ${s} files may already exist:`})]}),e.jsx("div",{className:"max-h-48 space-y-2 overflow-y-auto",children:t.map(r=>e.jsxs("div",{className:"flex items-center gap-3 rounded-md border p-2",children:[r.mimeType.startsWith("image/")&&r.mimeType!=="image/svg+xml"?e.jsx("img",{src:W(r.urls?.thumb_sm??r.url),alt:r.filename,className:"h-10 w-10 rounded object-cover"}):e.jsx("div",{className:"flex h-10 w-10 items-center justify-center",children:e.jsx(Me,{mimeType:r.mimeType,className:"h-6 w-6"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"truncate text-sm font-medium",children:r.filename}),e.jsxs("p",{className:"text-muted-foreground text-xs",children:[je(r.size)," ·"," ",Pe(r.uploadedAt)]})]})]},r.mediaId))}),e.jsxs(at,{children:[e.jsx(nt,{onClick:n,children:"Cancel"}),e.jsx(rt,{onClick:l,children:"Upload Anyway"})]})]})})}function ta(a){const[t,s]=x.useState(()=>{try{const n=localStorage.getItem(`viewMode:${a}`);if(n==="grid"||n==="list")return n}catch{}return"grid"}),l=x.useCallback(n=>{s(n);try{localStorage.setItem(`viewMode:${a}`,n)}catch{}},[a]);return[t,l]}const sa=({activatorEvent:a,draggingNodeRect:t,transform:s})=>{if(a&&t){const l=a;if(l.clientX!==void 0)return{...s,x:s.x+l.clientX-t.left-t.width/2,y:s.y+l.clientY-t.top-t.height/2}}return s},aa=[{value:"date_desc",label:"Newest first"},{value:"date_asc",label:"Oldest first"},{value:"name_asc",label:"Name A-Z"},{value:"name_desc",label:"Name Z-A"},{value:"size_desc",label:"Size (largest)"},{value:"size_asc",label:"Size (smallest)"}];function na({item:a,selected:t,onToggle:s,onClick:l,folderName:n,onLightbox:r}){const{attributes:u,listeners:h,setNodeRef:o,isDragging:i}=lt({id:a.mediaId,data:{type:"media",mediaId:a.mediaId}}),p=a.mimeType.startsWith("image/")&&a.mimeType!=="image/svg+xml";function m(w){w.stopPropagation(),navigator.clipboard.writeText(W(a.url)),S.success("URL copied to clipboard")}return e.jsx(Lt,{ref:o,...u,...h,className:P("group relative cursor-pointer overflow-hidden",i&&"opacity-50",t&&"ring-2 ring-primary"),onClick:l,children:e.jsxs(Ht,{className:"p-0",children:[e.jsx("div",{className:P("absolute left-2 top-2 z-10 opacity-0 group-hover:opacity-100",t&&"opacity-100"),onPointerDown:w=>w.stopPropagation(),onClick:w=>w.stopPropagation(),children:e.jsx(Se,{checked:t,onCheckedChange:s,"aria-label":`Select ${a.filename}`})}),e.jsxs("div",{className:"absolute right-2 top-2 z-10 flex gap-1 opacity-0 group-hover:opacity-100",onPointerDown:w=>w.stopPropagation(),onClick:w=>w.stopPropagation(),children:[e.jsx(be,{children:e.jsxs(Ce,{children:[e.jsx(Ne,{asChild:!0,children:e.jsx("button",{className:"rounded bg-black/50 p-1 text-white hover:bg-black/70",onClick:m,children:e.jsx(Oe,{className:"h-3.5 w-3.5"})})}),e.jsx(ke,{children:"Copy URL"})]})}),p&&r&&e.jsx(be,{children:e.jsxs(Ce,{children:[e.jsx(Ne,{asChild:!0,children:e.jsx("button",{className:"rounded bg-black/50 p-1 text-white hover:bg-black/70",onClick:w=>{w.stopPropagation(),r()},children:e.jsx(ks,{className:"h-3.5 w-3.5"})})}),e.jsx(ke,{children:"View full size"})]})})]}),p?e.jsx("div",{className:"bg-muted flex aspect-square items-center justify-center",children:e.jsx("img",{src:W(a.urls?.thumb_md??a.url),alt:a.alt||a.filename,className:"h-full w-full object-cover"})}):e.jsx("div",{className:"bg-muted flex aspect-square items-center justify-center",children:e.jsx(Me,{mimeType:a.mimeType,className:"h-12 w-12"})}),e.jsxs("div",{className:"p-2",children:[e.jsx("p",{className:"truncate text-sm font-medium",children:a.filename}),n&&e.jsxs("div",{className:"flex items-center gap-1 text-muted-foreground",children:[e.jsx(ue,{className:"h-3 w-3"}),e.jsx("span",{className:"truncate text-xs",children:n})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-muted-foreground text-xs",children:je(a.size)}),e.jsx(be,{children:e.jsxs(Ce,{children:[e.jsx(Ne,{asChild:!0,children:e.jsx("span",{className:"text-muted-foreground text-xs",children:Pe(a.uploadedAt)})}),e.jsx(ke,{children:Ue(a.uploadedAt)})]})})]}),a.tags.length>0&&e.jsxs("div",{className:"mt-1 flex flex-wrap gap-1",children:[a.tags.slice(0,3).map(w=>e.jsx("span",{className:"bg-muted text-muted-foreground rounded px-1 py-0.5 text-[10px]",children:w},w)),a.tags.length>3&&e.jsxs("span",{className:"text-muted-foreground text-[10px]",children:["+",a.tags.length-3]})]})]})]})})}function Ca(){const{host:a}=bt(),[t,s]=ta("media"),[l,n]=x.useState("date_desc"),[r,u]=x.useState(""),[h,o]=x.useState(""),[i,p]=x.useState(null),[m,w]=x.useState(null),[c,y]=x.useState(void 0),[d,j]=x.useState(new Set),[v,_]=x.useState(null),[R,I]=x.useState(null),[E,F]=x.useState(null),[g,A]=x.useState([]),$=x.useRef(null),me=Zs(a,m&&m!=="unfiled"?m:void 0),V=zt(a),Ie=$t(a),Te=es(ts(ns,{activationConstraint:{distance:8}}));x.useEffect(()=>{const f=setTimeout(()=>{o(N=>{const M=r;return N!==M&&j(new Set),M})},300);return()=>clearTimeout(f)},[r]);const b=m===null?void 0:m==="unfiled"?"":m,{data:k,isLoading:q}=Et(a,{sort:l,q:h||void 0,folderId:b,tag:c}),{data:J}=Ge(a),B=x.useMemo(()=>J?.items??[],[J?.items]),Le=x.useMemo(()=>{const f=new Map;for(const N of B)f.set(N.folderId,N.name);return f},[B]),ve=x.useMemo(()=>(k?.items??[]).filter(f=>f.mimeType.startsWith("image/")&&f.mimeType!=="image/svg+xml"),[k?.items]),_e=x.useMemo(()=>{const f=new Map;return ve.forEach((N,M)=>f.set(N.mediaId,M)),f},[ve]),{allTags:ht,allUserTags:ut}=x.useMemo(()=>{const f=k?.items??[],N=new Set,M=new Set;for(const z of f){for(const L of z.tags)N.add(L);for(const L of z.userTags??[])M.add(L)}return{allTags:Array.from(N).sort(),allUserTags:Array.from(M).sort()}},[k?.items]),Re=k?.items.map(f=>f.mediaId)??[],Ae=Re.length>0&&Re.every(f=>d.has(f));function He(f){j(N=>{const M=new Set(N);return M.has(f)?M.delete(f):M.add(f),M})}function Xe(){j(Ae?new Set:new Set(Re))}async function mt(){const f=[...d],M=(await V.mutateAsync({mediaIds:f,action:"delete"})).failed.length;M?S.error(`${M} of ${f.length} failed to delete`):S.success(`${f.length} item(s) deleted`),j(new Set)}async function xt(f){const N=[...d],z=(await V.mutateAsync({mediaIds:N,action:"move",folderId:f})).failed.length;z?S.error(`${z} of ${N.length} failed to move`):S.success(`${N.length} item(s) moved`),j(new Set)}async function pt(f){const N=[...d],z=(await V.mutateAsync({mediaIds:N,action:"addTags",tags:f})).failed.length;z?S.error(`${z} of ${N.length} failed`):S.success(`Tags added to ${N.length} item(s)`),j(new Set)}async function gt(f){const N=[...d],z=(await V.mutateAsync({mediaIds:N,action:"removeTags",tags:f})).failed.length;z?S.error(`${z} of ${N.length} failed`):S.success(`Tags removed from ${N.length} item(s)`),j(new Set)}async function Ye(f){const M=Array.from(f).slice(0,5),z=[];for(const L of M)try{const ze=await Ie.mutateAsync({filename:L.name,size:L.size});z.push(...ze.duplicates)}catch{}z.length>0?(F(f),A(z)):me.addFiles(f)}function ft(f){f.target.files&&Ye(f.target.files),$.current&&($.current.value="")}function wt(f){_(String(f.active.id))}function jt(f){_(null);const{active:N,over:M}=f;if(!M||M.data.current?.type!=="folder")return;const z=M.id==="unfiled"||M.id==="all-media"?"":String(M.id),L=d.has(String(N.id))?[...d]:[String(N.id)];V.mutateAsync({mediaIds:L,action:"move",folderId:z}).then(ze=>{const Ke=ze.failed.length;Ke?S.error(`${Ke} of ${L.length} failed to move`):S.success(`${L.length} item(s) moved`)})}function vt(){_(null)}const Q=v?k?.items.find(f=>f.mediaId===v):null,Be=v&&d.has(v)?d.size:1;return e.jsxs(ss,{sensors:Te,modifiers:[sa],onDragStart:wt,onDragEnd:jt,onDragCancel:vt,children:[e.jsxs("div",{className:"-m-6 flex h-[calc(100vh-3.5rem)]",children:[e.jsx(Ks,{host:a,selectedFolderId:m,onSelect:f=>{w(f),j(new Set)}}),e.jsxs(Vs,{onFiles:f=>Ye(f),children:[e.jsxs("div",{className:"flex-1 overflow-y-auto p-6",children:[e.jsxs("div",{className:"mb-6 flex items-center justify-between",children:[e.jsx("h1",{className:"text-2xl font-semibold",children:"Media"}),e.jsxs("div",{children:[e.jsx("input",{ref:$,type:"file",multiple:!0,className:"hidden",onChange:ft}),e.jsxs(C,{onClick:()=>$.current?.click(),children:[e.jsx(ye,{className:"mr-2 h-4 w-4"}),"Upload"]})]})]}),d.size>0?e.jsx(Ws,{selectedCount:d.size,folders:B,onDelete:mt,onMove:xt,onAddTags:pt,onRemoveTags:gt,onClear:()=>j(new Set),isPending:V.isPending}):e.jsxs("div",{className:"mb-4 flex flex-wrap items-center gap-3",children:[e.jsxs("div",{className:"relative min-w-[200px] max-w-sm flex-1",children:[e.jsx(Ve,{className:"text-muted-foreground absolute left-2.5 top-2.5 h-4 w-4"}),e.jsx(K,{placeholder:"Search media...",value:r,onChange:f=>u(f.target.value),className:"pl-9"})]}),e.jsxs(pe,{value:l,onValueChange:n,children:[e.jsx(ge,{className:"w-[160px]",children:e.jsx(fe,{})}),e.jsx(we,{children:aa.map(f=>e.jsx(te,{value:f.value,children:f.label},f.value))})]}),e.jsxs("div",{className:"flex rounded-md border",children:[e.jsx(C,{variant:t==="grid"?"secondary":"ghost",size:"sm",className:"rounded-r-none px-2",onClick:()=>s("grid"),children:e.jsx(ys,{className:"h-4 w-4"})}),e.jsx(C,{variant:t==="list"?"secondary":"ghost",size:"sm",className:"rounded-l-none px-2",onClick:()=>s("list"),children:e.jsx(Cs,{className:"h-4 w-4"})})]})]}),e.jsx(Bs,{tags:ht,activeTag:c,onTagChange:f=>{y(f),j(new Set)}}),t==="grid"&&(k?.items.length??0)>0&&e.jsxs("div",{className:"mb-2 flex items-center gap-2",children:[e.jsx(Se,{checked:Ae,onCheckedChange:Xe,"aria-label":"Select all"}),e.jsx("span",{className:"text-muted-foreground text-sm",children:d.size>0?`${d.size} of ${k.items.length} selected`:"Select all"})]}),q?e.jsx("div",{className:"grid gap-4 sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-4",children:Array.from({length:8}).map((f,N)=>e.jsx(Ot,{className:"aspect-square"},N))}):k?.items.length?t==="list"?e.jsx(Rs,{items:k.items,host:a,onSelect:p,selectedIds:d,onToggle:He,onToggleAll:Xe,allSelected:Ae,folderMap:m===null?Le:void 0,onLightbox:f=>{const N=_e.get(f.mediaId);N!==void 0&&I(N)}}):e.jsx("div",{className:"grid gap-4 sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-4",children:k.items.map(f=>e.jsx(na,{item:f,selected:d.has(f.mediaId),onToggle:()=>He(f.mediaId),onClick:()=>p(f),folderName:m===null?Le.get(f.folderId??""):void 0,onLightbox:_e.has(f.mediaId)?()=>I(_e.get(f.mediaId)):void 0},f.mediaId))}):e.jsx("div",{className:"flex flex-col items-center justify-center py-16 text-center",children:h||c?e.jsxs(e.Fragment,{children:[e.jsx(Ve,{className:"text-muted-foreground mb-3 h-10 w-10"}),e.jsx("p",{className:"text-muted-foreground text-lg font-medium",children:"No results found"}),e.jsx("p",{className:"text-muted-foreground mt-1 text-sm",children:"Try adjusting your search or filters."})]}):m==="unfiled"?e.jsxs(e.Fragment,{children:[e.jsx(ue,{className:"text-muted-foreground mb-3 h-10 w-10"}),e.jsx("p",{className:"text-muted-foreground text-lg font-medium",children:"No unfiled media"}),e.jsx("p",{className:"text-muted-foreground mt-1 text-sm",children:"All media items are organized in folders."})]}):m?e.jsxs(e.Fragment,{children:[e.jsx(ue,{className:"text-muted-foreground mb-3 h-10 w-10"}),e.jsx("p",{className:"text-muted-foreground text-lg font-medium",children:"This folder is empty"}),e.jsx("p",{className:"text-muted-foreground mt-1 text-sm",children:"Upload files or drag media into this folder."})]}):e.jsxs(e.Fragment,{children:[e.jsx(ye,{className:"text-muted-foreground mb-3 h-10 w-10"}),e.jsx("p",{className:"text-muted-foreground text-lg font-medium",children:"No media yet"}),e.jsx("p",{className:"text-muted-foreground mt-1 text-sm",children:"Upload your first file to get started."}),e.jsxs(C,{className:"mt-4",onClick:()=>$.current?.click(),children:[e.jsx(ye,{className:"mr-2 h-4 w-4"}),"Upload"]})]})}),i&&e.jsx(Ys,{host:a,media:i,onClose:()=>p(null),folders:B,tagSuggestions:ut})]}),e.jsx(qs,{queue:me})]})]}),R!==null&&ve.length>0&&e.jsx(Js,{items:ve,currentIndex:R,host:a,onClose:()=>I(null),onNavigate:I}),e.jsx(ea,{open:g.length>0,host:a,duplicates:g,fileCount:E?Array.from(E).length:0,onContinue:()=>{E&&me.addFiles(E),F(null),A([])},onCancel:()=>{F(null),A([])}}),e.jsx(as,{children:v&&Q&&e.jsxs("div",{className:"flex items-center gap-2 rounded-lg border bg-background p-2 shadow-lg",children:[Q.mimeType.startsWith("image/")&&Q.mimeType!=="image/svg+xml"?e.jsx("img",{src:W(Q.urls?.thumb_sm??Q.url),alt:Q.filename,className:"h-10 w-10 rounded object-cover"}):e.jsx("div",{className:"flex h-10 w-10 items-center justify-center",children:e.jsx(Me,{mimeType:Q.mimeType,className:"h-6 w-6"})}),e.jsx("span",{className:"text-sm font-medium",children:Be>1?`Moving ${Be} items`:Q.filename})]})})]})}export{Ca as MediaPage};
1
+ import{j as e}from"./tanstack-BO6c-AOu.js";import{r as x,R as D,L as yt,u as bt}from"./react-vendor-DNVhVxD7.js";import{F as Ct,l as Nt,m as kt,n as Dt,o as St,T as Fe,b as Ge,p as Mt,q as It,r as Tt,E as _t,A as Ze,e as Je,f as et,g as tt,h as st,i as at,j as nt,k as rt,U as ye,u as Rt,a as At,s as zt,t as $t,v as Et}from"./useMedia-BgfZGpqE.js";import{n as Y,x as P,F as it,B as C,s as S,D as ie,i as le,j as oe,k as ce,l as de,L as O,I as K,m as he,a as ee,X as xe,J as Ft,K as Pt,M as Ut,N as We,S as Ot}from"./index-CdJ9sfDz.js";import{C as Lt,c as Ht}from"./card-NiKFR8dW.js";import{C as Se}from"./checkbox-Cv1_Hpta.js";import{S as pe,a as ge,b as fe,c as we,d as te,C as Xt,h as Yt}from"./select-27FAx7H-.js";import{s as Bt,t as Kt,u as Wt,v as Vt,w as qt,A as Qt}from"./radix-DQ3amgxj.js";import{d as lt,G as Gt,e as Zt,b as Jt,u as es,a as ts,D as ss,f as as,P as ns}from"./core.esm-C3N4hsfx.js";import{b as je,a as Pe,f as Ue}from"./format-CZ9bpk32.js";import{m as W}from"./media-url-DIg_vSyf.js";import{T as rs,a as is,b as ot,c as H,d as ls,e as X}from"./table-pnzwUf_S.js";import{C as Oe}from"./copy-BIxYwzJE.js";import{B as ct}from"./badge-DK6q6X8v.js";import{T as os}from"./trash-2-H30Pytad.js";import{P as cs}from"./plus-CTopr28W.js";import{C as ds}from"./check-UCoo7qN1.js";import{S as Ve}from"./search-CURbafxm.js";const hs=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],us=Y("chevron-left",hs);const ms=[["path",{d:"M6 2v14a2 2 0 0 0 2 2h14",key:"ron5a4"}],["path",{d:"M18 22V8a2 2 0 0 0-2-2H2",key:"7s9ehn"}]],xs=Y("crop",ms);const ps=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 12.5 8 15l2 2.5",key:"1tg20x"}],["path",{d:"m14 12.5 2 2.5-2 2.5",key:"yinavb"}]],gs=Y("file-code",ps);const fs=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M7 3v18",key:"bbkbws"}],["path",{d:"M3 7.5h4",key:"zfgn84"}],["path",{d:"M3 12h18",key:"1i2n21"}],["path",{d:"M3 16.5h4",key:"1230mu"}],["path",{d:"M17 3v18",key:"in4fa5"}],["path",{d:"M17 7.5h4",key:"myr1c1"}],["path",{d:"M17 16.5h4",key:"go4c1d"}]],ws=Y("film",fs);const js=[["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]],ue=Y("folder",js);const vs=[["rect",{width:"7",height:"7",x:"3",y:"3",rx:"1",key:"1g98yp"}],["rect",{width:"7",height:"7",x:"14",y:"3",rx:"1",key:"6d4xhi"}],["rect",{width:"7",height:"7",x:"14",y:"14",rx:"1",key:"nxv5o0"}],["rect",{width:"7",height:"7",x:"3",y:"14",rx:"1",key:"1bb6yr"}]],ys=Y("layout-grid",vs);const bs=[["path",{d:"M3 5h.01",key:"18ugdj"}],["path",{d:"M3 12h.01",key:"nlz23k"}],["path",{d:"M3 19h.01",key:"noohij"}],["path",{d:"M8 5h13",key:"1pao27"}],["path",{d:"M8 12h13",key:"1za7za"}],["path",{d:"M8 19h13",key:"m83p4d"}]],Cs=Y("list",bs);const Ns=[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"m21 3-7 7",key:"1l2asr"}],["path",{d:"m3 21 7-7",key:"tjx5ai"}],["path",{d:"M9 21H3v-6",key:"wtvkvv"}]],ks=Y("maximize-2",Ns);const Ds=[["path",{d:"M9 18V5l12-2v13",key:"1jmyc2"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["circle",{cx:"18",cy:"16",r:"3",key:"1hluhg"}]],Ss=Y("music",Ds);const Ms=[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]],Is=Y("refresh-cw",Ms);function be({delayDuration:a=0,...t}){return e.jsx(Bt,{"data-slot":"tooltip-provider",delayDuration:a,...t})}function Ce({...a}){return e.jsx(Kt,{"data-slot":"tooltip",...a})}function Ne({...a}){return e.jsx(Wt,{"data-slot":"tooltip-trigger",...a})}function ke({className:a,sideOffset:t=0,children:s,...l}){return e.jsx(Vt,{children:e.jsxs(qt,{"data-slot":"tooltip-content",sideOffset:t,className:P("bg-foreground text-background animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-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 z-50 w-fit origin-(--radix-tooltip-content-transform-origin) rounded-md px-3 py-1.5 text-xs text-balance",a),...l,children:[s,e.jsx(Qt,{className:"bg-foreground fill-foreground z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px]"})]})})}function Me({mimeType:a,className:t}){return a==="application/pdf"?e.jsx(it,{className:P("text-blue-500",t)}):a.startsWith("video/")?e.jsx(ws,{className:P("text-purple-500",t)}):a.startsWith("audio/")?e.jsx(Ss,{className:P("text-green-500",t)}):a==="image/svg+xml"?e.jsx(gs,{className:P("text-orange-500",t)}):e.jsx(Ct,{className:P("text-muted-foreground",t)})}function Ts(a){return a==="application/pdf"?"PDF":a==="image/svg+xml"?"SVG":a.startsWith("image/")?"Image":a.startsWith("video/")?"Video":a.startsWith("audio/")?"Audio":a.split("/")[1]?.toUpperCase()??"File"}function _s({item:a,selected:t,onToggle:s,onSelect:l,onLightbox:n,folderName:r}){const{attributes:u,listeners:h,setNodeRef:o,isDragging:i}=lt({id:a.mediaId,data:{type:"media",mediaId:a.mediaId}}),p=a.mimeType.startsWith("image/")&&a.mimeType!=="image/svg+xml";return e.jsxs(ot,{ref:o,className:P("cursor-pointer",i&&"opacity-50"),onClick:l,children:[e.jsx(X,{onPointerDown:m=>m.stopPropagation(),onClick:m=>m.stopPropagation(),children:e.jsx(Se,{checked:t,onCheckedChange:s,"aria-label":`Select ${a.filename}`})}),e.jsx(X,{className:"w-6 p-1",children:e.jsx("div",{className:"cursor-grab text-muted-foreground",...u,...h,children:e.jsx(Gt,{className:"h-4 w-4"})})}),e.jsx(X,{className:"p-1",children:p?e.jsx("img",{src:W(a.urls?.thumb_sm??a.url),alt:a.alt||a.filename,className:P("h-8 w-8 rounded object-cover",n&&"cursor-zoom-in"),onClick:n?m=>{m.stopPropagation(),n()}:void 0}):e.jsx("div",{className:"flex h-8 w-8 items-center justify-center",children:e.jsx(Me,{mimeType:a.mimeType,className:"h-5 w-5"})})}),e.jsxs(X,{className:"max-w-[200px]",children:[r&&e.jsx("span",{className:"text-muted-foreground block truncate text-xs",children:r}),e.jsx("span",{className:"block truncate text-sm font-medium",children:a.filename})]}),e.jsx(X,{children:e.jsx("span",{className:"text-muted-foreground text-xs",children:Ts(a.mimeType)})}),e.jsx(X,{className:"text-right",children:e.jsx("span",{className:"text-muted-foreground text-xs",children:je(a.size)})}),e.jsx(X,{children:e.jsx("span",{className:"text-muted-foreground text-xs",children:a.width&&a.height?`${a.width}×${a.height}`:"—"})}),e.jsx(X,{children:a.tags.length>0&&e.jsxs("div",{className:"flex flex-wrap gap-1",children:[a.tags.slice(0,3).map(m=>e.jsx("span",{className:"bg-muted text-muted-foreground rounded px-1.5 py-0.5 text-[10px]",children:m},m)),a.tags.length>3&&e.jsxs("span",{className:"text-muted-foreground text-[10px]",children:["+",a.tags.length-3]})]})}),e.jsx(X,{children:e.jsx(be,{children:e.jsxs(Ce,{children:[e.jsx(Ne,{asChild:!0,children:e.jsx("span",{className:"text-muted-foreground text-xs",children:Pe(a.uploadedAt)})}),e.jsx(ke,{children:Ue(a.uploadedAt)})]})})}),e.jsx(X,{onPointerDown:m=>m.stopPropagation(),onClick:m=>m.stopPropagation(),children:e.jsx(C,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>{navigator.clipboard.writeText(W(a.url)),S.success("URL copied to clipboard")},children:e.jsx(Oe,{className:"h-3.5 w-3.5"})})})]})}function Rs({items:a,host:t,onSelect:s,selectedIds:l,onToggle:n,onToggleAll:r,allSelected:u,onLightbox:h,folderMap:o}){return e.jsxs(rs,{children:[e.jsx(is,{children:e.jsxs(ot,{children:[e.jsx(H,{className:"w-10",children:e.jsx(Se,{checked:u,onCheckedChange:r,"aria-label":"Select all"})}),e.jsx(H,{className:"w-6"}),e.jsx(H,{className:"w-12"}),e.jsx(H,{children:"Filename"}),e.jsx(H,{className:"w-20",children:"Type"}),e.jsx(H,{className:"w-24 text-right",children:"Size"}),e.jsx(H,{className:"w-28",children:"Dimensions"}),e.jsx(H,{className:"w-40",children:"Tags"}),e.jsx(H,{className:"w-32",children:"Uploaded"}),e.jsx(H,{className:"w-10"})]})}),e.jsx(ls,{children:a.map(i=>e.jsx(_s,{item:i,host:t,selected:l.has(i.mediaId),onToggle:()=>n(i.mediaId),onSelect:()=>s(i),folderName:o?.get(i.folderId??""),onLightbox:h&&i.mimeType.startsWith("image/")&&i.mimeType!=="image/svg+xml"?()=>h(i):void 0},i.mediaId))})]})}var As=Object.defineProperty,zs=(a,t,s)=>t in a?As(a,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):a[t]=s,T=(a,t,s)=>zs(a,typeof t!="symbol"?t+"":t,s);const De={x:0,y:0,width:0,height:0,unit:"px"},ae=(a,t,s)=>Math.min(Math.max(a,t),s),$s=(...a)=>a.filter(t=>t&&typeof t=="string").join(" "),qe=(a,t)=>a===t||a.width===t.width&&a.height===t.height&&a.x===t.x&&a.y===t.y&&a.unit===t.unit;function ne(a,t,s){return a.unit==="%"?{...De,...a,unit:"%"}:{unit:"%",x:a.x?a.x/t*100:0,y:a.y?a.y/s*100:0,width:a.width?a.width/t*100:0,height:a.height?a.height/s*100:0}}function G(a,t,s){return a.unit?a.unit==="px"?{...De,...a,unit:"px"}:{unit:"px",x:a.x?a.x*t/100:0,y:a.y?a.y*s/100:0,width:a.width?a.width*t/100:0,height:a.height?a.height*s/100:0}:{...De,...a,unit:"px"}}function Qe(a,t,s,l,n,r=0,u=0,h=l,o=n){const i={...a};let p=Math.min(r,l),m=Math.min(u,n),w=Math.min(h,l),c=Math.min(o,n);t&&(t>1?(p=u?u*t:p,m=p/t,w=h*t):(m=r?r/t:m,p=m*t,c=o/t)),i.y<0&&(i.height=Math.max(i.height+i.y,m),i.y=0),i.x<0&&(i.width=Math.max(i.width+i.x,p),i.x=0);const y=l-(i.x+i.width);y<0&&(i.x=Math.min(i.x,l-p),i.width+=y);const d=n-(i.y+i.height);if(d<0&&(i.y=Math.min(i.y,n-m),i.height+=d),i.width<p&&((s==="sw"||s=="nw")&&(i.x-=p-i.width),i.width=p),i.height<m&&((s==="nw"||s=="ne")&&(i.y-=m-i.height),i.height=m),i.width>w&&((s==="sw"||s=="nw")&&(i.x-=w-i.width),i.width=w),i.height>c&&((s==="nw"||s=="ne")&&(i.y-=c-i.height),i.height=c),t){const j=i.width/i.height;if(j<t){const v=Math.max(i.width/t,m);(s==="nw"||s=="ne")&&(i.y-=v-i.height),i.height=v}else if(j>t){const v=Math.max(i.height*t,p);(s==="sw"||s=="nw")&&(i.x-=v-i.width),i.width=v}}return i}function Es(a,t,s,l){const n={...a};return t==="ArrowLeft"?l==="nw"?(n.x-=s,n.y-=s,n.width+=s,n.height+=s):l==="w"?(n.x-=s,n.width+=s):l==="sw"?(n.x-=s,n.width+=s,n.height+=s):l==="ne"?(n.y+=s,n.width-=s,n.height-=s):l==="e"?n.width-=s:l==="se"&&(n.width-=s,n.height-=s):t==="ArrowRight"&&(l==="nw"?(n.x+=s,n.y+=s,n.width-=s,n.height-=s):l==="w"?(n.x+=s,n.width-=s):l==="sw"?(n.x+=s,n.width-=s,n.height-=s):l==="ne"?(n.y-=s,n.width+=s,n.height+=s):l==="e"?n.width+=s:l==="se"&&(n.width+=s,n.height+=s)),t==="ArrowUp"?l==="nw"?(n.x-=s,n.y-=s,n.width+=s,n.height+=s):l==="n"?(n.y-=s,n.height+=s):l==="ne"?(n.y-=s,n.width+=s,n.height+=s):l==="sw"?(n.x+=s,n.width-=s,n.height-=s):l==="s"?n.height-=s:l==="se"&&(n.width-=s,n.height-=s):t==="ArrowDown"&&(l==="nw"?(n.x+=s,n.y+=s,n.width-=s,n.height-=s):l==="n"?(n.y+=s,n.height-=s):l==="ne"?(n.y+=s,n.width-=s,n.height-=s):l==="sw"?(n.x-=s,n.width+=s,n.height+=s):l==="s"?n.height+=s:l==="se"&&(n.width+=s,n.height+=s)),n}const re={capture:!0,passive:!1};let Fs=0;const Z=class U extends x.PureComponent{constructor(){super(...arguments),T(this,"docMoveBound",!1),T(this,"mouseDownOnCrop",!1),T(this,"dragStarted",!1),T(this,"evData",{startClientX:0,startClientY:0,startCropX:0,startCropY:0,clientX:0,clientY:0,isResize:!0}),T(this,"componentRef",x.createRef()),T(this,"mediaRef",x.createRef()),T(this,"resizeObserver"),T(this,"initChangeCalled",!1),T(this,"instanceId",`rc-${Fs++}`),T(this,"state",{cropIsActive:!1,newCropIsBeingDrawn:!1}),T(this,"onCropPointerDown",t=>{const{crop:s,disabled:l}=this.props,n=this.getBox();if(!s)return;const r=G(s,n.width,n.height);if(l)return;t.cancelable&&t.preventDefault(),this.bindDocMove(),this.componentRef.current.focus({preventScroll:!0});const u=t.target.dataset.ord,h=!!u;let o=t.clientX,i=t.clientY,p=r.x,m=r.y;if(u){const w=t.clientX-n.x,c=t.clientY-n.y;let y=0,d=0;u==="ne"||u=="e"?(y=w-(r.x+r.width),d=c-r.y,p=r.x,m=r.y+r.height):u==="se"||u==="s"?(y=w-(r.x+r.width),d=c-(r.y+r.height),p=r.x,m=r.y):u==="sw"||u=="w"?(y=w-r.x,d=c-(r.y+r.height),p=r.x+r.width,m=r.y):(u==="nw"||u=="n")&&(y=w-r.x,d=c-r.y,p=r.x+r.width,m=r.y+r.height),o=p+n.x+y,i=m+n.y+d}this.evData={startClientX:o,startClientY:i,startCropX:p,startCropY:m,clientX:t.clientX,clientY:t.clientY,isResize:h,ord:u},this.mouseDownOnCrop=!0,this.setState({cropIsActive:!0})}),T(this,"onComponentPointerDown",t=>{const{crop:s,disabled:l,locked:n,keepSelection:r,onChange:u}=this.props,h=this.getBox();if(l||n||r&&s)return;t.cancelable&&t.preventDefault(),this.bindDocMove(),this.componentRef.current.focus({preventScroll:!0});const o=t.clientX-h.x,i=t.clientY-h.y,p={unit:"px",x:o,y:i,width:0,height:0};this.evData={startClientX:t.clientX,startClientY:t.clientY,startCropX:o,startCropY:i,clientX:t.clientX,clientY:t.clientY,isResize:!0},this.mouseDownOnCrop=!0,u(G(p,h.width,h.height),ne(p,h.width,h.height)),this.setState({cropIsActive:!0,newCropIsBeingDrawn:!0})}),T(this,"onDocPointerMove",t=>{const{crop:s,disabled:l,onChange:n,onDragStart:r}=this.props,u=this.getBox();if(l||!s||!this.mouseDownOnCrop)return;t.cancelable&&t.preventDefault(),this.dragStarted||(this.dragStarted=!0,r&&r(t));const{evData:h}=this;h.clientX=t.clientX,h.clientY=t.clientY;let o;h.isResize?o=this.resizeCrop():o=this.dragCrop(),qe(s,o)||n(G(o,u.width,u.height),ne(o,u.width,u.height))}),T(this,"onComponentKeyDown",t=>{const{crop:s,disabled:l,onChange:n,onComplete:r}=this.props;if(l)return;const u=t.key;let h=!1;if(!s)return;const o=this.getBox(),i=this.makePixelCrop(o),p=(navigator.platform.match("Mac")?t.metaKey:t.ctrlKey)?U.nudgeStepLarge:t.shiftKey?U.nudgeStepMedium:U.nudgeStep;if(u==="ArrowLeft"?(i.x-=p,h=!0):u==="ArrowRight"?(i.x+=p,h=!0):u==="ArrowUp"?(i.y-=p,h=!0):u==="ArrowDown"&&(i.y+=p,h=!0),h){t.cancelable&&t.preventDefault(),i.x=ae(i.x,0,o.width-i.width),i.y=ae(i.y,0,o.height-i.height);const m=G(i,o.width,o.height),w=ne(i,o.width,o.height);n(m,w),r&&r(m,w)}}),T(this,"onHandlerKeyDown",(t,s)=>{const{aspect:l=0,crop:n,disabled:r,minWidth:u=0,minHeight:h=0,maxWidth:o,maxHeight:i,onChange:p,onComplete:m}=this.props,w=this.getBox();if(r||!n)return;if(t.key==="ArrowUp"||t.key==="ArrowDown"||t.key==="ArrowLeft"||t.key==="ArrowRight")t.stopPropagation(),t.preventDefault();else return;const c=(navigator.platform.match("Mac")?t.metaKey:t.ctrlKey)?U.nudgeStepLarge:t.shiftKey?U.nudgeStepMedium:U.nudgeStep,y=G(n,w.width,w.height),d=Es(y,t.key,c,s),j=Qe(d,l,s,w.width,w.height,u,h,o,i);if(!qe(n,j)){const v=ne(j,w.width,w.height);p(j,v),m&&m(j,v)}}),T(this,"onDocPointerDone",t=>{const{crop:s,disabled:l,onComplete:n,onDragEnd:r}=this.props,u=this.getBox();this.unbindDocMove(),!(l||!s)&&this.mouseDownOnCrop&&(this.mouseDownOnCrop=!1,this.dragStarted=!1,r&&r(t),n&&n(G(s,u.width,u.height),ne(s,u.width,u.height)),this.setState({cropIsActive:!1,newCropIsBeingDrawn:!1}))}),T(this,"onDragFocus",()=>{var t;(t=this.componentRef.current)==null||t.scrollTo(0,0)})}get document(){return document}getBox(){const t=this.mediaRef.current;if(!t)return{x:0,y:0,width:0,height:0};const{x:s,y:l,width:n,height:r}=t.getBoundingClientRect();return{x:s,y:l,width:n,height:r}}componentDidUpdate(t){const{crop:s,onComplete:l}=this.props;if(l&&!t.crop&&s){const{width:n,height:r}=this.getBox();n&&r&&l(G(s,n,r),ne(s,n,r))}}componentWillUnmount(){this.resizeObserver&&this.resizeObserver.disconnect(),this.unbindDocMove()}bindDocMove(){this.docMoveBound||(this.document.addEventListener("pointermove",this.onDocPointerMove,re),this.document.addEventListener("pointerup",this.onDocPointerDone,re),this.document.addEventListener("pointercancel",this.onDocPointerDone,re),this.docMoveBound=!0)}unbindDocMove(){this.docMoveBound&&(this.document.removeEventListener("pointermove",this.onDocPointerMove,re),this.document.removeEventListener("pointerup",this.onDocPointerDone,re),this.document.removeEventListener("pointercancel",this.onDocPointerDone,re),this.docMoveBound=!1)}getCropStyle(){const{crop:t}=this.props;if(t)return{top:`${t.y}${t.unit}`,left:`${t.x}${t.unit}`,width:`${t.width}${t.unit}`,height:`${t.height}${t.unit}`}}dragCrop(){const{evData:t}=this,s=this.getBox(),l=this.makePixelCrop(s),n=t.clientX-t.startClientX,r=t.clientY-t.startClientY;return l.x=ae(t.startCropX+n,0,s.width-l.width),l.y=ae(t.startCropY+r,0,s.height-l.height),l}getPointRegion(t,s,l,n){const{evData:r}=this,u=r.clientX-t.x,h=r.clientY-t.y;let o;n&&s?o=s==="nw"||s==="n"||s==="ne":o=h<r.startCropY;let i;return l&&s?i=s==="nw"||s==="w"||s==="sw":i=u<r.startCropX,i?o?"nw":"sw":o?"ne":"se"}resolveMinDimensions(t,s,l=0,n=0){const r=Math.min(l,t.width),u=Math.min(n,t.height);return!s||!r&&!u?[r,u]:s>1?r?[r,r/s]:[u*s,u]:u?[u*s,u]:[r,r/s]}resizeCrop(){const{evData:t}=this,{aspect:s=0,maxWidth:l,maxHeight:n}=this.props,r=this.getBox(),[u,h]=this.resolveMinDimensions(r,s,this.props.minWidth,this.props.minHeight);let o=this.makePixelCrop(r);const i=this.getPointRegion(r,t.ord,u,h),p=t.ord||i;let m=t.clientX-t.startClientX,w=t.clientY-t.startClientY;(u&&p==="nw"||p==="w"||p==="sw")&&(m=Math.min(m,-u)),(h&&p==="nw"||p==="n"||p==="ne")&&(w=Math.min(w,-h));const c={unit:"px",x:0,y:0,width:0,height:0};i==="ne"?(c.x=t.startCropX,c.width=m,s?(c.height=c.width/s,c.y=t.startCropY-c.height):(c.height=Math.abs(w),c.y=t.startCropY-c.height)):i==="se"?(c.x=t.startCropX,c.y=t.startCropY,c.width=m,s?c.height=c.width/s:c.height=w):i==="sw"?(c.x=t.startCropX+m,c.y=t.startCropY,c.width=Math.abs(m),s?c.height=c.width/s:c.height=w):i==="nw"&&(c.x=t.startCropX+m,c.width=Math.abs(m),s?(c.height=c.width/s,c.y=t.startCropY-c.height):(c.height=Math.abs(w),c.y=t.startCropY+w));const y=Qe(c,s,i,r.width,r.height,u,h,l,n);return s||U.xyOrds.indexOf(p)>-1?o=y:U.xOrds.indexOf(p)>-1?(o.x=y.x,o.width=y.width):U.yOrds.indexOf(p)>-1&&(o.y=y.y,o.height=y.height),o.x=ae(o.x,0,r.width-o.width),o.y=ae(o.y,0,r.height-o.height),o}renderCropSelection(){const{ariaLabels:t=U.defaultProps.ariaLabels,disabled:s,locked:l,renderSelectionAddon:n,ruleOfThirds:r,crop:u}=this.props,h=this.getCropStyle();if(u)return D.createElement("div",{style:h,className:"ReactCrop__crop-selection",onPointerDown:this.onCropPointerDown,"aria-label":t.cropArea,tabIndex:0,onKeyDown:this.onComponentKeyDown,role:"group"},!s&&!l&&D.createElement("div",{className:"ReactCrop__drag-elements",onFocus:this.onDragFocus},D.createElement("div",{className:"ReactCrop__drag-bar ord-n","data-ord":"n"}),D.createElement("div",{className:"ReactCrop__drag-bar ord-e","data-ord":"e"}),D.createElement("div",{className:"ReactCrop__drag-bar ord-s","data-ord":"s"}),D.createElement("div",{className:"ReactCrop__drag-bar ord-w","data-ord":"w"}),D.createElement("div",{className:"ReactCrop__drag-handle ord-nw","data-ord":"nw",tabIndex:0,"aria-label":t.nwDragHandle,onKeyDown:o=>this.onHandlerKeyDown(o,"nw"),role:"button"}),D.createElement("div",{className:"ReactCrop__drag-handle ord-n","data-ord":"n",tabIndex:0,"aria-label":t.nDragHandle,onKeyDown:o=>this.onHandlerKeyDown(o,"n"),role:"button"}),D.createElement("div",{className:"ReactCrop__drag-handle ord-ne","data-ord":"ne",tabIndex:0,"aria-label":t.neDragHandle,onKeyDown:o=>this.onHandlerKeyDown(o,"ne"),role:"button"}),D.createElement("div",{className:"ReactCrop__drag-handle ord-e","data-ord":"e",tabIndex:0,"aria-label":t.eDragHandle,onKeyDown:o=>this.onHandlerKeyDown(o,"e"),role:"button"}),D.createElement("div",{className:"ReactCrop__drag-handle ord-se","data-ord":"se",tabIndex:0,"aria-label":t.seDragHandle,onKeyDown:o=>this.onHandlerKeyDown(o,"se"),role:"button"}),D.createElement("div",{className:"ReactCrop__drag-handle ord-s","data-ord":"s",tabIndex:0,"aria-label":t.sDragHandle,onKeyDown:o=>this.onHandlerKeyDown(o,"s"),role:"button"}),D.createElement("div",{className:"ReactCrop__drag-handle ord-sw","data-ord":"sw",tabIndex:0,"aria-label":t.swDragHandle,onKeyDown:o=>this.onHandlerKeyDown(o,"sw"),role:"button"}),D.createElement("div",{className:"ReactCrop__drag-handle ord-w","data-ord":"w",tabIndex:0,"aria-label":t.wDragHandle,onKeyDown:o=>this.onHandlerKeyDown(o,"w"),role:"button"})),n&&D.createElement("div",{className:"ReactCrop__selection-addon",onPointerDown:o=>o.stopPropagation()},n(this.state)),r&&D.createElement(D.Fragment,null,D.createElement("div",{className:"ReactCrop__rule-of-thirds-hz"}),D.createElement("div",{className:"ReactCrop__rule-of-thirds-vt"})))}makePixelCrop(t){const s={...De,...this.props.crop||{}};return G(s,t.width,t.height)}render(){const{aspect:t,children:s,circularCrop:l,className:n,crop:r,disabled:u,locked:h,style:o,ruleOfThirds:i}=this.props,{cropIsActive:p,newCropIsBeingDrawn:m}=this.state,w=r?this.renderCropSelection():null,c=$s("ReactCrop",n,p&&"ReactCrop--active",u&&"ReactCrop--disabled",h&&"ReactCrop--locked",m&&"ReactCrop--new-crop",r&&t&&"ReactCrop--fixed-aspect",r&&l&&"ReactCrop--circular-crop",r&&i&&"ReactCrop--rule-of-thirds",!this.dragStarted&&r&&!r.width&&!r.height&&"ReactCrop--invisible-crop",l&&"ReactCrop--no-animate");return D.createElement("div",{ref:this.componentRef,className:c,style:o},D.createElement("div",{ref:this.mediaRef,className:"ReactCrop__child-wrapper",onPointerDown:this.onComponentPointerDown},s),r?D.createElement("svg",{className:"ReactCrop__crop-mask",width:"100%",height:"100%"},D.createElement("defs",null,D.createElement("mask",{id:`hole-${this.instanceId}`},D.createElement("rect",{width:"100%",height:"100%",fill:"white"}),l?D.createElement("ellipse",{cx:`${r.x+r.width/2}${r.unit}`,cy:`${r.y+r.height/2}${r.unit}`,rx:`${r.width/2}${r.unit}`,ry:`${r.height/2}${r.unit}`,fill:"black"}):D.createElement("rect",{x:`${r.x}${r.unit}`,y:`${r.y}${r.unit}`,width:`${r.width}${r.unit}`,height:`${r.height}${r.unit}`,fill:"black"}))),D.createElement("rect",{fill:"black",fillOpacity:.5,width:"100%",height:"100%",mask:`url(#hole-${this.instanceId})`})):void 0,w)}};T(Z,"xOrds",["e","w"]),T(Z,"yOrds",["n","s"]),T(Z,"xyOrds",["nw","ne","se","sw"]),T(Z,"nudgeStep",1),T(Z,"nudgeStepMedium",10),T(Z,"nudgeStepLarge",100),T(Z,"defaultProps",{ariaLabels:{cropArea:"Use the arrow keys to move the crop selection area",nwDragHandle:"Use the arrow keys to move the north west drag handle to change the crop selection area",nDragHandle:"Use the up and down arrow keys to move the north drag handle to change the crop selection area",neDragHandle:"Use the arrow keys to move the north east drag handle to change the crop selection area",eDragHandle:"Use the up and down arrow keys to move the east drag handle to change the crop selection area",seDragHandle:"Use the arrow keys to move the south east drag handle to change the crop selection area",sDragHandle:"Use the up and down arrow keys to move the south drag handle to change the crop selection area",swDragHandle:"Use the arrow keys to move the south west drag handle to change the crop selection area",wDragHandle:"Use the up and down arrow keys to move the west drag handle to change the crop selection area"}});let Ps=Z;const Us=[{label:"Free",value:""},{label:"1:1 Square",value:"1"},{label:"4:3",value:"4/3"},{label:"3:2",value:"3/2"},{label:"16:9",value:"16/9"},{label:"2:3",value:"2/3"},{label:"3:4",value:"3/4"}],dt=[{label:"Original",value:"",ext:""},{label:"JPEG",value:"jpeg",ext:".jpg"},{label:"PNG",value:"png",ext:".png"},{label:"WebP",value:"webp",ext:".webp"},{label:"AVIF",value:"avif",ext:".avif"}],Os={"image/jpeg":".jpg","image/png":".png","image/gif":".gif","image/webp":".webp","image/avif":".avif","image/tiff":".tiff"};function $e(a,t){return a?dt.find(s=>s.value===a)?.ext||`.${a}`:Os[t]||".jpg"}function Ls(a,t){const s=a.lastIndexOf(".");return(s>0?a.substring(0,s):a)+t}function Hs({host:a,media:t,onClose:s,onSaved:l}){const n=x.useRef(null),[r,u]=x.useState(),[h,o]=x.useState(),[i,p]=x.useState(""),[m,w]=x.useState(""),[c,y]=x.useState(""),[d,j]=x.useState(""),[v,_]=x.useState("80"),[R,I]=x.useState(()=>{const b=$e("",t.mimeType),k=t.filename.lastIndexOf(".");return`${k>0?t.filename.substring(0,k):t.filename}-transformed${b}`});function E(b){const k=b==="__original__"?"":b;j(k);const q=$e(k,t.mimeType);I(J=>Ls(J,q))}const F=Nt(a,t.mediaId),[g,A]=x.useState(null),$=x.useCallback(()=>{if(!h||!g)return null;const b=(t.width??g.width)/g.width,k=(t.height??g.height)/g.height;return{cropX:Math.round(h.x*b),cropY:Math.round(h.y*k),cropW:Math.round(h.width*b),cropH:Math.round(h.height*k)}},[h,t.width,t.height,g]),se=x.useMemo(()=>$(),[$]);async function me(){const b=se,k=m?parseInt(m):void 0,q=c?parseInt(c):void 0;if(!b&&!k&&!q&&!d){S.error("Please specify a crop, resize, or format change");return}if(!R.trim()){S.error("Filename is required");return}const J=$e(d,t.mimeType);if(!R.trim().toLowerCase().endsWith(J)){S.error(`Filename must end with ${J} to match the output format`);return}try{const B=await F.mutateAsync({...b??{},...k?{width:k}:{},...q?{height:q}:{},...d?{format:d}:{},...v?{quality:parseInt(v)}:{},filename:R.trim()});S.success("Transform saved as new media"),l?.(B),s()}catch(B){S.error("Transform failed",{description:B instanceof Error?B.message:void 0})}}function V(b){p(b==="__free__"?"":b),u(void 0),o(void 0)}function Ie(b){if(!b)return;const k=b.split("/");return k.length===2?Number(k[0])/Number(k[1]):Number(b)||void 0}const Te=Ie(i);return e.jsx(ie,{open:!0,onOpenChange:()=>s(),children:e.jsxs(le,{className:"max-w-4xl max-h-[90vh] overflow-y-auto",children:[e.jsxs(oe,{children:[e.jsx(ce,{children:"Transform Image"}),e.jsx(de,{className:"sr-only",children:"Crop, resize, or convert image format"})]}),e.jsxs("div",{className:"grid grid-cols-[1fr_280px] gap-6",children:[e.jsx("div",{className:"min-h-0 overflow-hidden rounded border bg-muted/30 flex items-center justify-center",children:e.jsx(Ps,{crop:r,onChange:b=>u(b),onComplete:b=>o(b),aspect:Te,children:e.jsx("img",{ref:n,src:W(t.url),alt:t.alt||t.filename,className:"max-h-[60vh] max-w-full object-contain",onLoad:b=>{const k=b.currentTarget;A({width:k.naturalWidth,height:k.naturalHeight})}})})}),e.jsxs("div",{className:"space-y-5",children:[e.jsxs("div",{className:"text-muted-foreground text-sm",children:["Original: ",t.width,"×",t.height]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(O,{children:"Crop aspect ratio"}),e.jsxs(pe,{value:i||"__free__",onValueChange:V,children:[e.jsx(ge,{children:e.jsx(fe,{placeholder:"Free"})}),e.jsx(we,{children:Us.map(b=>e.jsx(te,{value:b.value||"__free__",children:b.label},b.value||"__free__"))})]}),h&&e.jsxs("div",{className:"text-xs text-muted-foreground",children:["Crop: ",se?.cropW,"×",se?.cropH," at (",se?.cropX,", ",se?.cropY,")"]}),h&&e.jsx(C,{variant:"ghost",size:"sm",onClick:()=>{u(void 0),o(void 0)},children:"Clear crop"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(O,{children:"Resize (optional)"}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsx("div",{children:e.jsx(K,{type:"number",placeholder:"Width",value:m,onChange:b=>w(b.target.value),min:1,max:2048})}),e.jsx("div",{children:e.jsx(K,{type:"number",placeholder:"Height",value:c,onChange:b=>y(b.target.value),min:1,max:2048})})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(O,{children:"Output format"}),e.jsxs(pe,{value:d||"__original__",onValueChange:E,children:[e.jsx(ge,{children:e.jsx(fe,{placeholder:"Original"})}),e.jsx(we,{children:dt.map(b=>e.jsx(te,{value:b.value||"__original__",children:b.label},b.value||"__original__"))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(O,{children:"Quality (1-100)"}),e.jsx(K,{type:"number",value:v,onChange:b=>_(b.target.value),min:1,max:100})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(O,{children:"Save as filename"}),e.jsx(K,{value:R,onChange:b=>I(b.target.value)})]})]})]}),e.jsxs(he,{children:[e.jsx(C,{variant:"outline",onClick:s,children:"Cancel"}),e.jsxs(C,{onClick:me,disabled:F.isPending,children:[F.isPending&&e.jsx(ee,{className:"mr-2 h-4 w-4 animate-spin"}),"Save as New Image"]})]})]})})}const Xs=new Set(["image/jpeg","image/png","image/gif","image/webp","image/avif","image/tiff"]);function Ys({host:a,media:t,onClose:s,folders:l,tagSuggestions:n}){const[r,u]=x.useState(t.alt??""),[h,o]=x.useState(t.caption??""),[i,p]=x.useState(t.userTags??[]),[m,w]=x.useState(t.folderId||"__none__"),[c,y]=x.useState(!1),d=Xs.has(t.mimeType),j=kt(a,t.mediaId),v=Dt(a,t.mediaId),{data:_,isLoading:R}=St(a,t.mediaId),I=t.tags.filter(g=>!t.userTags?.includes(g));async function E(){try{await j.mutateAsync({alt:r,caption:h,userTags:i,folderId:m==="__none__"?"":m}),S.success("Media updated"),s()}catch(g){S.error("Failed to update",{description:g instanceof Error?g.message:void 0})}}async function F(){try{await v.mutateAsync(),S.success("Media deleted"),s()}catch(g){S.error("Failed to delete",{description:g instanceof Error?g.message:void 0})}}return e.jsxs(ie,{open:!0,onOpenChange:()=>s(),children:[e.jsxs(le,{children:[e.jsxs(oe,{children:[e.jsx(ce,{children:t.filename}),e.jsx(de,{className:"sr-only",children:"View and edit media details"})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"text-muted-foreground text-sm",children:[t.mimeType," · ",je(t.size),t.width&&t.height&&` · ${t.width}×${t.height}`," · ",Ue(t.uploadedAt)]}),e.jsxs("div",{className:"flex gap-2",children:[d&&e.jsxs(C,{variant:"outline",size:"sm",onClick:()=>y(!0),children:[e.jsx(xs,{className:"mr-1.5 h-3.5 w-3.5"}),"Transform"]}),e.jsxs(C,{variant:"outline",size:"sm",onClick:()=>{navigator.clipboard.writeText(W(t.url)),S.success("URL copied to clipboard")},children:[e.jsx(Oe,{className:"mr-1.5 h-3.5 w-3.5"}),"Copy URL"]})]})]}),I.length>0&&e.jsxs("div",{className:"space-y-1",children:[e.jsx(O,{className:"text-xs text-muted-foreground",children:"Auto-detected tags"}),e.jsx("div",{className:"flex flex-wrap gap-1",children:I.map(g=>e.jsx(ct,{variant:"outline",className:"text-xs",children:g},g))})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(O,{children:"Tags"}),e.jsx(Fe,{tags:i,onChange:p,placeholder:"Add tags...",suggestions:n})]}),l&&l.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(O,{children:"Folder"}),e.jsxs(pe,{value:m,onValueChange:w,children:[e.jsx(ge,{children:e.jsx(fe,{placeholder:"No folder"})}),e.jsxs(we,{children:[e.jsx(te,{value:"__none__",children:"No folder"}),l.map(g=>e.jsx(te,{value:g.folderId,children:g.name},g.folderId))]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(O,{htmlFor:"alt",children:"Alt text"}),e.jsx(K,{id:"alt",value:r,onChange:g=>u(g.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(O,{htmlFor:"caption",children:"Caption"}),e.jsx(K,{id:"caption",value:h,onChange:g=>o(g.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(O,{className:"text-xs text-muted-foreground",children:"Used in"}),R?e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground text-sm",children:[e.jsx(ee,{className:"h-3.5 w-3.5 animate-spin"}),"Checking usage..."]}):_?.references.length?e.jsxs("div",{className:"space-y-1",children:[_.references.map(g=>e.jsxs(yt,{to:`/sites/${a}/content/${g.collection}/${g.contentId}`,className:"flex items-center gap-2 rounded px-2 py-1 text-sm hover:bg-muted",onClick:s,children:[e.jsx(it,{className:"h-3.5 w-3.5 text-muted-foreground"}),e.jsx("span",{className:"truncate",children:g.title||g.contentId}),e.jsxs("span",{className:"text-muted-foreground text-xs",children:["(",g.collection,")"]})]},g.contentId)),_.note&&e.jsx("p",{className:"text-muted-foreground text-xs italic",children:_.note})]}):e.jsx("p",{className:"text-muted-foreground text-sm",children:"Not referenced in any content."})]})]}),e.jsxs(he,{className:"flex justify-between",children:[e.jsxs(C,{variant:"destructive",size:"sm",onClick:F,children:[e.jsx(os,{className:"mr-2 h-4 w-4"}),"Delete"]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(C,{variant:"outline",onClick:s,children:"Cancel"}),e.jsx(C,{onClick:E,children:"Save"})]})]})]}),c&&e.jsx(Hs,{host:a,media:t,onClose:()=>y(!1),onSaved:()=>s()})]})}function Bs({tags:a,activeTag:t,onTagChange:s}){return a.length===0?null:e.jsxs("div",{className:"mb-4 flex flex-wrap items-center gap-1.5",children:[a.map(l=>e.jsx(ct,{variant:t===l?"default":"secondary",className:"cursor-pointer select-none",onClick:()=>s(t===l?void 0:l),children:l},l)),t&&e.jsxs(C,{variant:"ghost",size:"sm",className:"h-6 px-2 text-xs",onClick:()=>s(void 0),children:[e.jsx(xe,{className:"mr-1 h-3 w-3"}),"Clear"]})]})}function Ee({id:a,children:t}){const{setNodeRef:s,isOver:l}=Zt({id:a,data:{type:"folder"}});return e.jsx("div",{ref:s,children:t(l)})}function Ks({host:a,selectedFolderId:t,onSelect:s}){const{data:l}=Ge(a),n=Mt(a),r=It(a),u=Tt(a),[h,o]=x.useState(!1),[i,p]=x.useState(""),[m,w]=x.useState(null),[c,y]=x.useState(""),[d,j]=x.useState(null),v=x.useRef(null),_=x.useRef(null),R=l?.items??[];x.useEffect(()=>{h&&v.current?.focus()},[h]),x.useEffect(()=>{m&&_.current?.focus()},[m]);async function I(){const g=i.trim();if(!g){o(!1),p("");return}try{await n.mutateAsync(g),S.success("Folder created")}catch(A){S.error("Failed to create folder",{description:A instanceof Error?A.message:void 0})}o(!1),p("")}async function E(g){const A=c.trim();if(!A){w(null);return}try{await r.mutateAsync({folderId:g,name:A}),S.success("Folder renamed")}catch($){S.error("Failed to rename folder",{description:$ instanceof Error?$.message:void 0})}w(null)}async function F(){if(d){try{await u.mutateAsync(d.folderId),S.success("Folder deleted"),t===d.folderId&&s(null)}catch(g){S.error("Failed to delete folder",{description:g instanceof Error?g.message:void 0})}j(null)}}return e.jsxs("div",{className:"flex w-48 shrink-0 flex-col border-r",children:[e.jsxs("div",{className:"flex items-center justify-between border-b px-3 py-2",children:[e.jsx("span",{className:"text-sm font-medium",children:"Folders"}),e.jsx(C,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0",onClick:()=>o(!0),children:e.jsx(cs,{className:"h-4 w-4"})})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto py-1",children:[e.jsx(Ee,{id:"all-media",children:g=>e.jsx("button",{className:P("flex w-full items-center justify-between px-3 py-1.5 text-left text-sm hover:bg-accent/50",t===null&&"bg-accent font-medium",g&&"ring-2 ring-primary bg-primary/10"),onClick:()=>s(null),children:e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(ue,{className:"h-4 w-4"}),"All Media"]})})}),R.map(g=>e.jsx(Ee,{id:g.folderId,children:A=>e.jsx("div",{className:P("group flex w-full items-center justify-between px-3 py-1.5 text-sm hover:bg-accent/50",t===g.folderId&&"bg-accent font-medium",A&&"ring-2 ring-primary bg-primary/10"),children:m===g.folderId?e.jsx(K,{ref:_,value:c,onChange:$=>y($.target.value),onKeyDown:$=>{$.key==="Enter"&&E(g.folderId),$.key==="Escape"&&w(null)},onBlur:()=>E(g.folderId),className:"h-6 text-sm"}):e.jsxs(e.Fragment,{children:[e.jsxs("button",{className:"flex flex-1 items-center gap-2 text-left",onClick:()=>s(g.folderId),children:[e.jsx(ue,{className:"h-4 w-4 shrink-0"}),e.jsx("span",{className:"truncate",children:g.name})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"text-muted-foreground text-xs",children:g.count}),e.jsxs(Ft,{children:[e.jsx(Pt,{asChild:!0,children:e.jsx(C,{variant:"ghost",size:"sm",className:"h-5 w-5 p-0 opacity-0 group-hover:opacity-100",children:e.jsx(_t,{className:"h-3.5 w-3.5"})})}),e.jsxs(Ut,{align:"end",children:[e.jsx(We,{onClick:()=>{w(g.folderId),y(g.name)},children:"Rename"}),e.jsx(We,{disabled:g.count>0,onClick:()=>j(g),children:"Delete"})]})]})]})]})})},g.folderId)),e.jsx(Ee,{id:"unfiled",children:g=>e.jsx("button",{className:P("flex w-full items-center justify-between px-3 py-1.5 text-left text-sm hover:bg-accent/50",t==="unfiled"&&"bg-accent font-medium",g&&"ring-2 ring-primary bg-primary/10"),onClick:()=>s("unfiled"),children:e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(ue,{className:"h-4 w-4"}),"Unfiled"]})})}),h&&e.jsx("div",{className:"px-3 py-1.5",children:e.jsx(K,{ref:v,value:i,onChange:g=>p(g.target.value),onKeyDown:g=>{g.key==="Enter"&&I(),g.key==="Escape"&&(o(!1),p(""))},onBlur:I,placeholder:"Folder name...",className:"h-7 text-sm"})})]}),e.jsx(Ze,{open:!!d,onOpenChange:()=>j(null),children:e.jsxs(Je,{children:[e.jsxs(et,{children:[e.jsx(tt,{children:"Delete folder?"}),e.jsxs(st,{children:["This will delete the folder “",d?.name,"”. Media items in this folder will become unfiled."]})]}),e.jsxs(at,{children:[e.jsx(nt,{children:"Cancel"}),e.jsx(rt,{onClick:F,children:"Delete"})]})]})})]})}function Ws({selectedCount:a,folders:t,onDelete:s,onMove:l,onAddTags:n,onRemoveTags:r,onClear:u,isPending:h}){const[o,i]=x.useState(null),[p,m]=x.useState(""),[w,c]=x.useState([]);function y(){i(null),m(""),c([])}return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"mb-4 flex items-center gap-3 rounded-md border bg-muted/50 px-4 py-2",children:[e.jsxs("span",{className:"text-sm font-medium",children:[a," selected"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(C,{size:"sm",variant:"destructive",onClick:()=>i("delete"),disabled:h,children:"Delete"}),e.jsx(C,{size:"sm",variant:"outline",onClick:()=>i("move"),disabled:h,children:"Move to…"}),e.jsx(C,{size:"sm",variant:"outline",onClick:()=>i("addTags"),disabled:h,children:"Add tags"}),e.jsx(C,{size:"sm",variant:"outline",onClick:()=>i("removeTags"),disabled:h,children:"Remove tags"})]}),e.jsx(C,{size:"sm",variant:"ghost",onClick:u,className:"ml-auto",disabled:h,children:e.jsx(xe,{className:"h-4 w-4"})})]}),e.jsx(ie,{open:o==="delete",onOpenChange:d=>!d&&y(),children:e.jsxs(le,{children:[e.jsxs(oe,{children:[e.jsxs(ce,{children:["Delete ",a," item",a!==1?"s":"","?"]}),e.jsx(de,{children:"This action cannot be undone. The selected media items will be permanently deleted."})]}),e.jsxs(he,{children:[e.jsx(C,{variant:"outline",onClick:y,children:"Cancel"}),e.jsxs(C,{variant:"destructive",onClick:async()=>{y(),await s()},disabled:h,children:[h&&e.jsx(ee,{className:"mr-1 h-3 w-3 animate-spin"}),"Delete"]})]})]})}),e.jsx(ie,{open:o==="move",onOpenChange:d=>!d&&y(),children:e.jsxs(le,{children:[e.jsxs(oe,{children:[e.jsxs(ce,{children:["Move ",a," item",a!==1?"s":""]}),e.jsx(de,{children:"Choose a destination folder."})]}),e.jsxs(pe,{value:p,onValueChange:m,children:[e.jsx(ge,{children:e.jsx(fe,{placeholder:"Select folder..."})}),e.jsxs(we,{children:[e.jsx(te,{value:"__unfiled__",children:"Unfiled"}),t.map(d=>e.jsx(te,{value:d.folderId,children:d.name},d.folderId))]})]}),e.jsxs(he,{children:[e.jsx(C,{variant:"outline",onClick:y,children:"Cancel"}),e.jsxs(C,{onClick:async()=>{const d=p==="__unfiled__"?"":p;y(),await l(d)},disabled:!p||h,children:[h&&e.jsx(ee,{className:"mr-1 h-3 w-3 animate-spin"}),"Move"]})]})]})}),e.jsx(ie,{open:o==="addTags",onOpenChange:d=>!d&&y(),children:e.jsxs(le,{children:[e.jsxs(oe,{children:[e.jsxs(ce,{children:["Add tags to ",a," item",a!==1?"s":""]}),e.jsx(de,{className:"sr-only",children:"Select tags to add to the selected items"})]}),e.jsx(Fe,{tags:w,onChange:c,placeholder:"Add tags..."}),e.jsxs(he,{children:[e.jsx(C,{variant:"outline",onClick:y,children:"Cancel"}),e.jsxs(C,{onClick:async()=>{const d=[...w];y(),await n(d)},disabled:w.length===0||h,children:[h&&e.jsx(ee,{className:"mr-1 h-3 w-3 animate-spin"}),"Add"]})]})]})}),e.jsx(ie,{open:o==="removeTags",onOpenChange:d=>!d&&y(),children:e.jsxs(le,{children:[e.jsxs(oe,{children:[e.jsxs(ce,{children:["Remove tags from ",a," item",a!==1?"s":""]}),e.jsx(de,{className:"sr-only",children:"Select tags to remove from the selected items"})]}),e.jsx(Fe,{tags:w,onChange:c,placeholder:"Tags to remove..."}),e.jsxs(he,{children:[e.jsx(C,{variant:"outline",onClick:y,children:"Cancel"}),e.jsxs(C,{onClick:async()=>{const d=[...w];y(),await r(d)},disabled:w.length===0||h,children:[h&&e.jsx(ee,{className:"mr-1 h-3 w-3 animate-spin"}),"Remove"]})]})]})})]})}function Vs({onFiles:a,children:t}){const[s,l]=x.useState(!1),n=x.useRef(0),r=x.useCallback(i=>{i.preventDefault(),i.dataTransfer.types.includes("Files")&&(n.current++,l(!0))},[]),u=x.useCallback(i=>{i.preventDefault(),n.current--,n.current===0&&l(!1)},[]),h=x.useCallback(i=>{i.preventDefault(),i.dataTransfer.dropEffect="copy"},[]),o=x.useCallback(i=>{i.preventDefault(),n.current=0,l(!1);const p=Array.from(i.dataTransfer.files);p.length>0&&a(p)},[a]);return e.jsxs("div",{className:"relative flex-1",onDragEnter:r,onDragLeave:u,onDragOver:h,onDrop:o,children:[t,s&&e.jsx("div",{className:"absolute inset-0 z-40 flex items-center justify-center rounded-lg border-2 border-dashed border-primary bg-primary/5",children:e.jsxs("div",{className:"flex flex-col items-center gap-2 rounded-lg bg-background/90 px-6 py-4 shadow-lg",children:[e.jsx(ye,{className:"h-8 w-8 text-primary"}),e.jsx("p",{className:"text-lg font-medium",children:"Drop files to upload"}),e.jsx("p",{className:"text-muted-foreground text-sm",children:"Files will be uploaded to the current folder"})]})})]})}function qs({queue:a}){const{items:t,retry:s,dismiss:l,clearCompleted:n}=a,[r,u]=x.useState(!1),h=t.filter(c=>c.status==="uploading").length,o=t.filter(c=>c.status==="pending").length,i=t.filter(c=>c.status==="complete").length,p=t.filter(c=>c.status==="error").length,m=h===0&&o===0;if(x.useEffect(()=>{if(m&&t.length>0){const c=setTimeout(()=>u(!0),2e3);return()=>clearTimeout(c)}},[m,t.length]),t.length===0)return null;const w=m?`${i} uploaded${p?`, ${p} failed`:""}`:`Uploading ${h+o} file${h+o!==1?"s":""}`;return e.jsxs("div",{className:"fixed bottom-4 right-4 z-50 w-80 rounded-lg border bg-background shadow-lg",children:[e.jsxs("div",{className:"flex items-center justify-between border-b px-3 py-2",children:[e.jsx("span",{className:"text-sm font-medium",children:w}),e.jsxs("div",{className:"flex items-center gap-1",children:[m&&e.jsx(C,{variant:"ghost",size:"sm",className:"h-6 px-2 text-xs",onClick:n,children:"Clear"}),e.jsx(C,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0",onClick:()=>u(!r),children:r?e.jsx(Xt,{className:"h-4 w-4"}):e.jsx(Yt,{className:"h-4 w-4"})})]})]}),!r&&e.jsx("div",{className:"max-h-60 overflow-y-auto",children:t.map(c=>e.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 text-sm",children:[c.status==="uploading"&&e.jsx(ee,{className:"h-4 w-4 shrink-0 animate-spin"}),c.status==="complete"&&e.jsx(ds,{className:"h-4 w-4 shrink-0 text-green-500"}),c.status==="error"&&e.jsx(xe,{className:"h-4 w-4 shrink-0 text-destructive"}),c.status==="pending"&&e.jsx("div",{className:"h-4 w-4 shrink-0"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"truncate",children:c.file.name}),c.status==="uploading"&&e.jsx("div",{className:"bg-muted mt-0.5 h-1 w-full rounded-full",children:e.jsx("div",{className:"bg-primary h-full rounded-full transition-all",style:{width:`${c.progress}%`}})}),c.status==="error"&&e.jsx("p",{className:"text-destructive truncate text-xs",children:c.error})]}),c.status==="error"&&e.jsx(C,{variant:"ghost",size:"sm",className:"h-6 w-6 shrink-0 p-0",onClick:()=>s(c.id),children:e.jsx(Is,{className:"h-3 w-3"})}),(c.status==="complete"||c.status==="error")&&e.jsx(C,{variant:"ghost",size:"sm",className:"h-6 w-6 shrink-0 p-0",onClick:()=>l(c.id),children:e.jsx(xe,{className:"h-3 w-3"})})]},c.id))})]})}const Qs=3;let Gs=0;function Zs(a,t){const[s,l]=x.useState([]),n=Rt(a),r=At(a),u=x.useRef(0),h=x.useRef(s);h.current=s;const o=x.useRef(new Map),i=x.useCallback(async d=>{u.current++,l(j=>j.map(v=>v.id===d.id?{...v,status:"uploading",progress:0}:v));try{const{uploadUrl:j,mediaId:v}=await n.mutateAsync({filename:d.file.name,contentType:d.file.type,size:d.file.size});await new Promise((_,R)=>{const I=new XMLHttpRequest;o.current.set(d.id,I),I.upload.onprogress=E=>{if(E.lengthComputable){const F=Math.round(E.loaded/E.total*100);l(g=>g.map(A=>A.id===d.id?{...A,progress:F}:A))}},I.onload=()=>{o.current.delete(d.id),I.status>=200&&I.status<300?_():R(new Error(`Upload failed: ${I.status}`))},I.onerror=()=>{o.current.delete(d.id),R(new Error("Network error"))},I.onabort=()=>{o.current.delete(d.id),R(new Error("Upload aborted"))},I.open("PUT",j),I.setRequestHeader("Content-Type",d.file.type),I.send(d.file)}),await r.mutateAsync({mediaId:v,filename:d.file.name,folderId:d.folderId}),l(_=>_.map(R=>R.id===d.id?{...R,status:"complete",progress:100}:R))}catch(j){l(v=>v.map(_=>_.id===d.id?{..._,status:"error",error:j instanceof Error?j.message:"Upload failed"}:_))}finally{u.current--}},[n,r]),p=x.useRef(i);p.current=i,x.useEffect(()=>{const d=s.filter(v=>v.status==="pending"),j=Qs-u.current;for(let v=0;v<Math.min(d.length,j);v++)p.current(d[v])},[s]),x.useEffect(()=>{const d=o.current;return()=>{d.forEach(j=>j.abort())}},[]);const m=x.useCallback(d=>{const j=Array.from(d).map(v=>({id:`upload-${Gs++}`,file:v,folderId:t||void 0,status:"pending",progress:0}));l(v=>[...v,...j])},[t]),w=x.useCallback(d=>{l(j=>j.map(v=>v.id===d?{...v,status:"pending",progress:0,error:void 0}:v))},[]),c=x.useCallback(d=>{l(j=>j.filter(v=>v.id!==d))},[]),y=x.useCallback(()=>{l(d=>d.filter(j=>j.status!=="complete"&&j.status!=="error"))},[]);return{items:s,addFiles:m,retry:w,dismiss:c,clearCompleted:y}}function Js({items:a,currentIndex:t,onClose:s,onNavigate:l}){const n=a[t],r=t>0,u=t<a.length-1,h=x.useCallback(o=>{o.key==="Escape"?s():o.key==="ArrowLeft"&&r?l(t-1):o.key==="ArrowRight"&&u&&l(t+1)},[s,l,t,r,u]);return x.useEffect(()=>(document.addEventListener("keydown",h),document.body.style.overflow="hidden",()=>{document.removeEventListener("keydown",h),document.body.style.overflow=""}),[h]),n?e.jsxs("div",{className:"fixed inset-0 z-50 flex flex-col bg-black/90",onClick:s,children:[e.jsxs("div",{className:"flex items-center justify-between px-4 py-3 text-white",onClick:o=>o.stopPropagation(),children:[e.jsxs("div",{className:"text-sm",children:[e.jsx("span",{className:"font-medium",children:n.filename}),e.jsxs("span",{className:"ml-3 opacity-70",children:[n.width&&n.height&&`${n.width}×${n.height} · `,je(n.size)]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("span",{className:"text-sm opacity-70",children:[t+1," / ",a.length]}),e.jsx(C,{variant:"ghost",size:"icon",className:"text-white hover:bg-white/20",onClick:s,children:e.jsx(xe,{className:"h-5 w-5"})})]})]}),e.jsxs("div",{className:"relative flex flex-1 items-center justify-center px-16",onClick:o=>o.stopPropagation(),children:[e.jsx("img",{src:W(n.url),alt:n.alt||n.filename,className:"max-h-full max-w-full object-contain"}),r&&e.jsx(C,{variant:"ghost",size:"icon",className:"absolute left-4 top-1/2 -translate-y-1/2 text-white hover:bg-white/20",onClick:()=>l(t-1),children:e.jsx(us,{className:"h-8 w-8"})}),u&&e.jsx(C,{variant:"ghost",size:"icon",className:"absolute right-4 top-1/2 -translate-y-1/2 text-white hover:bg-white/20",onClick:()=>l(t+1),children:e.jsx(Jt,{className:"h-8 w-8"})})]})]}):null}function ea({open:a,duplicates:t,fileCount:s,onContinue:l,onCancel:n}){return e.jsx(Ze,{open:a,onOpenChange:r=>!r&&n(),children:e.jsxs(Je,{children:[e.jsxs(et,{children:[e.jsx(tt,{children:"Possible duplicates found"}),e.jsx(st,{children:s===1?"A file with the same name and size already exists:":`${t.length} of ${s} files may already exist:`})]}),e.jsx("div",{className:"max-h-48 space-y-2 overflow-y-auto",children:t.map(r=>e.jsxs("div",{className:"flex items-center gap-3 rounded-md border p-2",children:[r.mimeType.startsWith("image/")&&r.mimeType!=="image/svg+xml"?e.jsx("img",{src:W(r.urls?.thumb_sm??r.url),alt:r.filename,className:"h-10 w-10 rounded object-cover"}):e.jsx("div",{className:"flex h-10 w-10 items-center justify-center",children:e.jsx(Me,{mimeType:r.mimeType,className:"h-6 w-6"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"truncate text-sm font-medium",children:r.filename}),e.jsxs("p",{className:"text-muted-foreground text-xs",children:[je(r.size)," ·"," ",Pe(r.uploadedAt)]})]})]},r.mediaId))}),e.jsxs(at,{children:[e.jsx(nt,{onClick:n,children:"Cancel"}),e.jsx(rt,{onClick:l,children:"Upload Anyway"})]})]})})}function ta(a){const[t,s]=x.useState(()=>{try{const n=localStorage.getItem(`viewMode:${a}`);if(n==="grid"||n==="list")return n}catch{}return"grid"}),l=x.useCallback(n=>{s(n);try{localStorage.setItem(`viewMode:${a}`,n)}catch{}},[a]);return[t,l]}const sa=({activatorEvent:a,draggingNodeRect:t,transform:s})=>{if(a&&t){const l=a;if(l.clientX!==void 0)return{...s,x:s.x+l.clientX-t.left-t.width/2,y:s.y+l.clientY-t.top-t.height/2}}return s},aa=[{value:"date_desc",label:"Newest first"},{value:"date_asc",label:"Oldest first"},{value:"name_asc",label:"Name A-Z"},{value:"name_desc",label:"Name Z-A"},{value:"size_desc",label:"Size (largest)"},{value:"size_asc",label:"Size (smallest)"}];function na({item:a,selected:t,onToggle:s,onClick:l,folderName:n,onLightbox:r}){const{attributes:u,listeners:h,setNodeRef:o,isDragging:i}=lt({id:a.mediaId,data:{type:"media",mediaId:a.mediaId}}),p=a.mimeType.startsWith("image/")&&a.mimeType!=="image/svg+xml";function m(w){w.stopPropagation(),navigator.clipboard.writeText(W(a.url)),S.success("URL copied to clipboard")}return e.jsx(Lt,{ref:o,...u,...h,className:P("group relative cursor-pointer overflow-hidden",i&&"opacity-50",t&&"ring-2 ring-primary"),onClick:l,children:e.jsxs(Ht,{className:"p-0",children:[e.jsx("div",{className:P("absolute left-2 top-2 z-10 opacity-0 group-hover:opacity-100",t&&"opacity-100"),onPointerDown:w=>w.stopPropagation(),onClick:w=>w.stopPropagation(),children:e.jsx(Se,{checked:t,onCheckedChange:s,"aria-label":`Select ${a.filename}`})}),e.jsxs("div",{className:"absolute right-2 top-2 z-10 flex gap-1 opacity-0 group-hover:opacity-100",onPointerDown:w=>w.stopPropagation(),onClick:w=>w.stopPropagation(),children:[e.jsx(be,{children:e.jsxs(Ce,{children:[e.jsx(Ne,{asChild:!0,children:e.jsx("button",{className:"rounded bg-black/50 p-1 text-white hover:bg-black/70",onClick:m,children:e.jsx(Oe,{className:"h-3.5 w-3.5"})})}),e.jsx(ke,{children:"Copy URL"})]})}),p&&r&&e.jsx(be,{children:e.jsxs(Ce,{children:[e.jsx(Ne,{asChild:!0,children:e.jsx("button",{className:"rounded bg-black/50 p-1 text-white hover:bg-black/70",onClick:w=>{w.stopPropagation(),r()},children:e.jsx(ks,{className:"h-3.5 w-3.5"})})}),e.jsx(ke,{children:"View full size"})]})})]}),p?e.jsx("div",{className:"bg-muted flex aspect-square items-center justify-center",children:e.jsx("img",{src:W(a.urls?.thumb_md??a.url),alt:a.alt||a.filename,className:"h-full w-full object-cover"})}):e.jsx("div",{className:"bg-muted flex aspect-square items-center justify-center",children:e.jsx(Me,{mimeType:a.mimeType,className:"h-12 w-12"})}),e.jsxs("div",{className:"p-2",children:[e.jsx("p",{className:"truncate text-sm font-medium",children:a.filename}),n&&e.jsxs("div",{className:"flex items-center gap-1 text-muted-foreground",children:[e.jsx(ue,{className:"h-3 w-3"}),e.jsx("span",{className:"truncate text-xs",children:n})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-muted-foreground text-xs",children:je(a.size)}),e.jsx(be,{children:e.jsxs(Ce,{children:[e.jsx(Ne,{asChild:!0,children:e.jsx("span",{className:"text-muted-foreground text-xs",children:Pe(a.uploadedAt)})}),e.jsx(ke,{children:Ue(a.uploadedAt)})]})})]}),a.tags.length>0&&e.jsxs("div",{className:"mt-1 flex flex-wrap gap-1",children:[a.tags.slice(0,3).map(w=>e.jsx("span",{className:"bg-muted text-muted-foreground rounded px-1 py-0.5 text-[10px]",children:w},w)),a.tags.length>3&&e.jsxs("span",{className:"text-muted-foreground text-[10px]",children:["+",a.tags.length-3]})]})]})]})})}function Ca(){const{host:a}=bt(),[t,s]=ta("media"),[l,n]=x.useState("date_desc"),[r,u]=x.useState(""),[h,o]=x.useState(""),[i,p]=x.useState(null),[m,w]=x.useState(null),[c,y]=x.useState(void 0),[d,j]=x.useState(new Set),[v,_]=x.useState(null),[R,I]=x.useState(null),[E,F]=x.useState(null),[g,A]=x.useState([]),$=x.useRef(null),me=Zs(a,m&&m!=="unfiled"?m:void 0),V=zt(a),Ie=$t(a),Te=es(ts(ns,{activationConstraint:{distance:8}}));x.useEffect(()=>{const f=setTimeout(()=>{o(N=>{const M=r;return N!==M&&j(new Set),M})},300);return()=>clearTimeout(f)},[r]);const b=m===null?void 0:m==="unfiled"?"":m,{data:k,isLoading:q}=Et(a,{sort:l,q:h||void 0,folderId:b,tag:c}),{data:J}=Ge(a),B=x.useMemo(()=>J?.items??[],[J?.items]),Le=x.useMemo(()=>{const f=new Map;for(const N of B)f.set(N.folderId,N.name);return f},[B]),ve=x.useMemo(()=>(k?.items??[]).filter(f=>f.mimeType.startsWith("image/")&&f.mimeType!=="image/svg+xml"),[k?.items]),_e=x.useMemo(()=>{const f=new Map;return ve.forEach((N,M)=>f.set(N.mediaId,M)),f},[ve]),{allTags:ht,allUserTags:ut}=x.useMemo(()=>{const f=k?.items??[],N=new Set,M=new Set;for(const z of f){for(const L of z.tags)N.add(L);for(const L of z.userTags??[])M.add(L)}return{allTags:Array.from(N).sort(),allUserTags:Array.from(M).sort()}},[k?.items]),Re=k?.items.map(f=>f.mediaId)??[],Ae=Re.length>0&&Re.every(f=>d.has(f));function He(f){j(N=>{const M=new Set(N);return M.has(f)?M.delete(f):M.add(f),M})}function Xe(){j(Ae?new Set:new Set(Re))}async function mt(){const f=[...d],M=(await V.mutateAsync({mediaIds:f,action:"delete"})).failed.length;M?S.error(`${M} of ${f.length} failed to delete`):S.success(`${f.length} item(s) deleted`),j(new Set)}async function xt(f){const N=[...d],z=(await V.mutateAsync({mediaIds:N,action:"move",folderId:f})).failed.length;z?S.error(`${z} of ${N.length} failed to move`):S.success(`${N.length} item(s) moved`),j(new Set)}async function pt(f){const N=[...d],z=(await V.mutateAsync({mediaIds:N,action:"addTags",tags:f})).failed.length;z?S.error(`${z} of ${N.length} failed`):S.success(`Tags added to ${N.length} item(s)`),j(new Set)}async function gt(f){const N=[...d],z=(await V.mutateAsync({mediaIds:N,action:"removeTags",tags:f})).failed.length;z?S.error(`${z} of ${N.length} failed`):S.success(`Tags removed from ${N.length} item(s)`),j(new Set)}async function Ye(f){const M=Array.from(f).slice(0,5),z=[];for(const L of M)try{const ze=await Ie.mutateAsync({filename:L.name,size:L.size});z.push(...ze.duplicates)}catch{}z.length>0?(F(f),A(z)):me.addFiles(f)}function ft(f){f.target.files&&Ye(f.target.files),$.current&&($.current.value="")}function wt(f){_(String(f.active.id))}function jt(f){_(null);const{active:N,over:M}=f;if(!M||M.data.current?.type!=="folder")return;const z=M.id==="unfiled"||M.id==="all-media"?"":String(M.id),L=d.has(String(N.id))?[...d]:[String(N.id)];V.mutateAsync({mediaIds:L,action:"move",folderId:z}).then(ze=>{const Ke=ze.failed.length;Ke?S.error(`${Ke} of ${L.length} failed to move`):S.success(`${L.length} item(s) moved`)})}function vt(){_(null)}const Q=v?k?.items.find(f=>f.mediaId===v):null,Be=v&&d.has(v)?d.size:1;return e.jsxs(ss,{sensors:Te,modifiers:[sa],onDragStart:wt,onDragEnd:jt,onDragCancel:vt,children:[e.jsxs("div",{className:"-m-6 flex h-[calc(100vh-3.5rem)]",children:[e.jsx(Ks,{host:a,selectedFolderId:m,onSelect:f=>{w(f),j(new Set)}}),e.jsxs(Vs,{onFiles:f=>Ye(f),children:[e.jsxs("div",{className:"flex-1 overflow-y-auto p-6",children:[e.jsxs("div",{className:"mb-6 flex items-center justify-between",children:[e.jsx("h1",{className:"text-2xl font-semibold",children:"Media"}),e.jsxs("div",{children:[e.jsx("input",{ref:$,type:"file",multiple:!0,className:"hidden",onChange:ft}),e.jsxs(C,{onClick:()=>$.current?.click(),children:[e.jsx(ye,{className:"mr-2 h-4 w-4"}),"Upload"]})]})]}),d.size>0?e.jsx(Ws,{selectedCount:d.size,folders:B,onDelete:mt,onMove:xt,onAddTags:pt,onRemoveTags:gt,onClear:()=>j(new Set),isPending:V.isPending}):e.jsxs("div",{className:"mb-4 flex flex-wrap items-center gap-3",children:[e.jsxs("div",{className:"relative min-w-[200px] max-w-sm flex-1",children:[e.jsx(Ve,{className:"text-muted-foreground absolute left-2.5 top-2.5 h-4 w-4"}),e.jsx(K,{placeholder:"Search media...",value:r,onChange:f=>u(f.target.value),className:"pl-9"})]}),e.jsxs(pe,{value:l,onValueChange:n,children:[e.jsx(ge,{className:"w-[160px]",children:e.jsx(fe,{})}),e.jsx(we,{children:aa.map(f=>e.jsx(te,{value:f.value,children:f.label},f.value))})]}),e.jsxs("div",{className:"flex rounded-md border",children:[e.jsx(C,{variant:t==="grid"?"secondary":"ghost",size:"sm",className:"rounded-r-none px-2",onClick:()=>s("grid"),children:e.jsx(ys,{className:"h-4 w-4"})}),e.jsx(C,{variant:t==="list"?"secondary":"ghost",size:"sm",className:"rounded-l-none px-2",onClick:()=>s("list"),children:e.jsx(Cs,{className:"h-4 w-4"})})]})]}),e.jsx(Bs,{tags:ht,activeTag:c,onTagChange:f=>{y(f),j(new Set)}}),t==="grid"&&(k?.items.length??0)>0&&e.jsxs("div",{className:"mb-2 flex items-center gap-2",children:[e.jsx(Se,{checked:Ae,onCheckedChange:Xe,"aria-label":"Select all"}),e.jsx("span",{className:"text-muted-foreground text-sm",children:d.size>0?`${d.size} of ${k.items.length} selected`:"Select all"})]}),q?e.jsx("div",{className:"grid gap-4 sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-4",children:Array.from({length:8}).map((f,N)=>e.jsx(Ot,{className:"aspect-square"},N))}):k?.items.length?t==="list"?e.jsx(Rs,{items:k.items,host:a,onSelect:p,selectedIds:d,onToggle:He,onToggleAll:Xe,allSelected:Ae,folderMap:m===null?Le:void 0,onLightbox:f=>{const N=_e.get(f.mediaId);N!==void 0&&I(N)}}):e.jsx("div",{className:"grid gap-4 sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-4",children:k.items.map(f=>e.jsx(na,{item:f,selected:d.has(f.mediaId),onToggle:()=>He(f.mediaId),onClick:()=>p(f),folderName:m===null?Le.get(f.folderId??""):void 0,onLightbox:_e.has(f.mediaId)?()=>I(_e.get(f.mediaId)):void 0},f.mediaId))}):e.jsx("div",{className:"flex flex-col items-center justify-center py-16 text-center",children:h||c?e.jsxs(e.Fragment,{children:[e.jsx(Ve,{className:"text-muted-foreground mb-3 h-10 w-10"}),e.jsx("p",{className:"text-muted-foreground text-lg font-medium",children:"No results found"}),e.jsx("p",{className:"text-muted-foreground mt-1 text-sm",children:"Try adjusting your search or filters."})]}):m==="unfiled"?e.jsxs(e.Fragment,{children:[e.jsx(ue,{className:"text-muted-foreground mb-3 h-10 w-10"}),e.jsx("p",{className:"text-muted-foreground text-lg font-medium",children:"No unfiled media"}),e.jsx("p",{className:"text-muted-foreground mt-1 text-sm",children:"All media items are organized in folders."})]}):m?e.jsxs(e.Fragment,{children:[e.jsx(ue,{className:"text-muted-foreground mb-3 h-10 w-10"}),e.jsx("p",{className:"text-muted-foreground text-lg font-medium",children:"This folder is empty"}),e.jsx("p",{className:"text-muted-foreground mt-1 text-sm",children:"Upload files or drag media into this folder."})]}):e.jsxs(e.Fragment,{children:[e.jsx(ye,{className:"text-muted-foreground mb-3 h-10 w-10"}),e.jsx("p",{className:"text-muted-foreground text-lg font-medium",children:"No media yet"}),e.jsx("p",{className:"text-muted-foreground mt-1 text-sm",children:"Upload your first file to get started."}),e.jsxs(C,{className:"mt-4",onClick:()=>$.current?.click(),children:[e.jsx(ye,{className:"mr-2 h-4 w-4"}),"Upload"]})]})}),i&&e.jsx(Ys,{host:a,media:i,onClose:()=>p(null),folders:B,tagSuggestions:ut})]}),e.jsx(qs,{queue:me})]})]}),R!==null&&ve.length>0&&e.jsx(Js,{items:ve,currentIndex:R,host:a,onClose:()=>I(null),onNavigate:I}),e.jsx(ea,{open:g.length>0,host:a,duplicates:g,fileCount:E?Array.from(E).length:0,onContinue:()=>{E&&me.addFiles(E),F(null),A([])},onCancel:()=>{F(null),A([])}}),e.jsx(as,{children:v&&Q&&e.jsxs("div",{className:"flex items-center gap-2 rounded-lg border bg-background p-2 shadow-lg",children:[Q.mimeType.startsWith("image/")&&Q.mimeType!=="image/svg+xml"?e.jsx("img",{src:W(Q.urls?.thumb_sm??Q.url),alt:Q.filename,className:"h-10 w-10 rounded object-cover"}):e.jsx("div",{className:"flex h-10 w-10 items-center justify-center",children:e.jsx(Me,{mimeType:Q.mimeType,className:"h-6 w-6"})}),e.jsx("span",{className:"text-sm font-medium",children:Be>1?`Moving ${Be} items`:Q.filename})]})})]})}export{Ca as MediaPage};
@@ -1 +1 @@
1
- import{j as e,a as Q}from"./tanstack-BO6c-AOu.js";import{u as R,e as G,r as h}from"./react-vendor-DNVhVxD7.js";import{a3 as K,S as b,a7 as Z,a8 as z,a9 as J,a2 as M,L as m,I as c,B as i,a as u,aa as V,D as A,i as P,j as k,k as T,l as F,m as E,s as n}from"./index-Ds50UTAc.js";import{B as W}from"./badge-0Z1nL6DI.js";import{C as g,a as p,b as f,c as S}from"./card-D1-S-QZ6.js";import{f as X}from"./format-CZ9bpk32.js";import"./radix-DQ3amgxj.js";function re(){const{host:a}=R(),{data:r,isLoading:t}=K(a);return t?e.jsxs("div",{className:"space-y-4",children:[e.jsx(b,{className:"h-8 w-64"}),e.jsx(b,{className:"h-48 w-full"})]}):r?e.jsx(Y,{site:r},r.host):e.jsx("p",{className:"text-muted-foreground",children:"Site not found."})}function Y({site:a}){const r=Q(),t=Z(a.host),x=z(a.host),j=J(a.host),y=G(),C=M()==="admin",v=a.status==="archived",[N,O]=h.useState(a.name),[B,l]=h.useState(!1),[L,d]=h.useState(!1),[D,o]=h.useState("");async function U(s){s.preventDefault();try{await t.mutateAsync({name:N}),n.success("Site updated")}catch(w){n.error("Failed to update site",{description:w instanceof Error?w.message:void 0})}}async function q(){try{await t.mutateAsync({status:"archived"}),n.success("Site archived"),l(!1),y("/sites")}catch(s){n.error("Failed to archive site",{description:s instanceof Error?s.message:void 0})}}async function H(){try{await t.mutateAsync({status:"active"}),n.success("Site unarchived")}catch(s){n.error("Failed to unarchive site",{description:s instanceof Error?s.message:void 0})}}async function I(){try{await x.mutateAsync(),await j.mutateAsync(),await r.invalidateQueries({queryKey:["sites"]}),n.success("Site deleted"),d(!1),o(""),y("/sites")}catch(s){n.error("Failed to delete site",{description:s instanceof Error?s.message:void 0})}}return e.jsxs("div",{className:"mx-auto max-w-2xl",children:[e.jsx("h1",{className:"mb-6 text-2xl font-semibold",children:"Site Settings"}),e.jsxs(g,{children:[e.jsx(p,{children:e.jsx(f,{children:"General"})}),e.jsx(S,{children:e.jsxs("form",{onSubmit:U,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(m,{htmlFor:"name",children:"Site Name"}),e.jsx(c,{id:"name",value:N,onChange:s=>O(s.target.value),required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(m,{children:"Host"}),e.jsx(c,{value:a.host,disabled:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(m,{children:"Status"}),e.jsx("div",{className:"flex items-center gap-2",children:v?e.jsx(W,{variant:"outline",children:"Archived"}):e.jsx(c,{value:a.status,disabled:!0})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(m,{children:"Created"}),e.jsx(c,{value:X(a.createdAt),disabled:!0})]}),e.jsxs(i,{type:"submit",disabled:t.isPending,children:[t.isPending&&e.jsx(u,{className:"mr-2 h-4 w-4 animate-spin"}),"Save"]})]})})]}),C&&e.jsxs(g,{className:"mt-6",children:[e.jsx(p,{children:e.jsx(f,{children:"Site Status"})}),e.jsx(S,{className:"space-y-4",children:v?e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-muted-foreground text-sm",children:"This site is archived. Unarchive it to allow content changes."}),e.jsxs(i,{variant:"outline",onClick:H,disabled:t.isPending,children:[t.isPending&&e.jsx(u,{className:"mr-2 h-4 w-4 animate-spin"}),"Unarchive Site"]})]}):e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-muted-foreground text-sm",children:"Archiving a site makes it read-only. Content cannot be created or modified while archived."}),e.jsxs(i,{variant:"outline",onClick:()=>l(!0),children:[e.jsx(V,{className:"mr-2 h-4 w-4"}),"Archive Site"]}),e.jsx(A,{open:B,onOpenChange:l,children:e.jsxs(P,{children:[e.jsxs(k,{children:[e.jsx(T,{children:"Archive Site"}),e.jsxs(F,{children:["Are you sure you want to archive ",e.jsx("strong",{children:a.host}),"? The site will become read-only."]})]}),e.jsxs(E,{children:[e.jsx(i,{variant:"outline",onClick:()=>l(!1),children:"Cancel"}),e.jsxs(i,{onClick:q,disabled:t.isPending,children:[t.isPending&&e.jsx(u,{className:"mr-2 h-4 w-4 animate-spin"}),"Archive"]})]})]})})]})})]}),C&&v&&e.jsxs(g,{className:"border-destructive mt-6",children:[e.jsx(p,{children:e.jsx(f,{className:"text-destructive",children:"Danger Zone"})}),e.jsxs(S,{className:"space-y-4",children:[e.jsx("p",{className:"text-muted-foreground text-sm",children:"Permanently delete this site and all its content, media, collections, and block types. This action cannot be undone."}),e.jsx(i,{variant:"destructive",onClick:()=>d(!0),children:"Delete Site"}),e.jsx(A,{open:L,onOpenChange:s=>{d(s),s||o("")},children:e.jsxs(P,{children:[e.jsxs(k,{children:[e.jsx(T,{children:"Delete Site"}),e.jsxs(F,{children:["This will permanently delete this site and all its content. Type ",e.jsx("strong",{children:a.host})," to confirm."]})]}),e.jsx(c,{placeholder:a.host,value:D,onChange:s=>o(s.target.value)}),e.jsxs(E,{children:[e.jsx(i,{variant:"outline",onClick:()=>{d(!1),o("")},children:"Cancel"}),e.jsxs(i,{variant:"destructive",onClick:I,disabled:D!==a.host||x.isPending||j.isPending,children:[(x.isPending||j.isPending)&&e.jsx(u,{className:"mr-2 h-4 w-4 animate-spin"}),"Delete Everything"]})]})]})})]})]})]})}export{re as SiteSettingsPage};
1
+ import{j as e,a as Q}from"./tanstack-BO6c-AOu.js";import{u as R,e as G,r as h}from"./react-vendor-DNVhVxD7.js";import{a3 as K,S as b,a7 as Z,a8 as z,a9 as J,a2 as M,L as m,I as c,B as i,a as u,aa as V,D as A,i as P,j as k,k as T,l as F,m as E,s as n}from"./index-CdJ9sfDz.js";import{B as W}from"./badge-DK6q6X8v.js";import{C as g,a as p,b as f,c as S}from"./card-NiKFR8dW.js";import{f as X}from"./format-CZ9bpk32.js";import"./radix-DQ3amgxj.js";function re(){const{host:a}=R(),{data:r,isLoading:t}=K(a);return t?e.jsxs("div",{className:"space-y-4",children:[e.jsx(b,{className:"h-8 w-64"}),e.jsx(b,{className:"h-48 w-full"})]}):r?e.jsx(Y,{site:r},r.host):e.jsx("p",{className:"text-muted-foreground",children:"Site not found."})}function Y({site:a}){const r=Q(),t=Z(a.host),x=z(a.host),j=J(a.host),y=G(),C=M()==="admin",v=a.status==="archived",[N,O]=h.useState(a.name),[B,l]=h.useState(!1),[L,d]=h.useState(!1),[D,o]=h.useState("");async function U(s){s.preventDefault();try{await t.mutateAsync({name:N}),n.success("Site updated")}catch(w){n.error("Failed to update site",{description:w instanceof Error?w.message:void 0})}}async function q(){try{await t.mutateAsync({status:"archived"}),n.success("Site archived"),l(!1),y("/sites")}catch(s){n.error("Failed to archive site",{description:s instanceof Error?s.message:void 0})}}async function H(){try{await t.mutateAsync({status:"active"}),n.success("Site unarchived")}catch(s){n.error("Failed to unarchive site",{description:s instanceof Error?s.message:void 0})}}async function I(){try{await x.mutateAsync(),await j.mutateAsync(),await r.invalidateQueries({queryKey:["sites"]}),n.success("Site deleted"),d(!1),o(""),y("/sites")}catch(s){n.error("Failed to delete site",{description:s instanceof Error?s.message:void 0})}}return e.jsxs("div",{className:"mx-auto max-w-2xl",children:[e.jsx("h1",{className:"mb-6 text-2xl font-semibold",children:"Site Settings"}),e.jsxs(g,{children:[e.jsx(p,{children:e.jsx(f,{children:"General"})}),e.jsx(S,{children:e.jsxs("form",{onSubmit:U,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(m,{htmlFor:"name",children:"Site Name"}),e.jsx(c,{id:"name",value:N,onChange:s=>O(s.target.value),required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(m,{children:"Host"}),e.jsx(c,{value:a.host,disabled:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(m,{children:"Status"}),e.jsx("div",{className:"flex items-center gap-2",children:v?e.jsx(W,{variant:"outline",children:"Archived"}):e.jsx(c,{value:a.status,disabled:!0})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(m,{children:"Created"}),e.jsx(c,{value:X(a.createdAt),disabled:!0})]}),e.jsxs(i,{type:"submit",disabled:t.isPending,children:[t.isPending&&e.jsx(u,{className:"mr-2 h-4 w-4 animate-spin"}),"Save"]})]})})]}),C&&e.jsxs(g,{className:"mt-6",children:[e.jsx(p,{children:e.jsx(f,{children:"Site Status"})}),e.jsx(S,{className:"space-y-4",children:v?e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-muted-foreground text-sm",children:"This site is archived. Unarchive it to allow content changes."}),e.jsxs(i,{variant:"outline",onClick:H,disabled:t.isPending,children:[t.isPending&&e.jsx(u,{className:"mr-2 h-4 w-4 animate-spin"}),"Unarchive Site"]})]}):e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-muted-foreground text-sm",children:"Archiving a site makes it read-only. Content cannot be created or modified while archived."}),e.jsxs(i,{variant:"outline",onClick:()=>l(!0),children:[e.jsx(V,{className:"mr-2 h-4 w-4"}),"Archive Site"]}),e.jsx(A,{open:B,onOpenChange:l,children:e.jsxs(P,{children:[e.jsxs(k,{children:[e.jsx(T,{children:"Archive Site"}),e.jsxs(F,{children:["Are you sure you want to archive ",e.jsx("strong",{children:a.host}),"? The site will become read-only."]})]}),e.jsxs(E,{children:[e.jsx(i,{variant:"outline",onClick:()=>l(!1),children:"Cancel"}),e.jsxs(i,{onClick:q,disabled:t.isPending,children:[t.isPending&&e.jsx(u,{className:"mr-2 h-4 w-4 animate-spin"}),"Archive"]})]})]})})]})})]}),C&&v&&e.jsxs(g,{className:"border-destructive mt-6",children:[e.jsx(p,{children:e.jsx(f,{className:"text-destructive",children:"Danger Zone"})}),e.jsxs(S,{className:"space-y-4",children:[e.jsx("p",{className:"text-muted-foreground text-sm",children:"Permanently delete this site and all its content, media, collections, and block types. This action cannot be undone."}),e.jsx(i,{variant:"destructive",onClick:()=>d(!0),children:"Delete Site"}),e.jsx(A,{open:L,onOpenChange:s=>{d(s),s||o("")},children:e.jsxs(P,{children:[e.jsxs(k,{children:[e.jsx(T,{children:"Delete Site"}),e.jsxs(F,{children:["This will permanently delete this site and all its content. Type ",e.jsx("strong",{children:a.host})," to confirm."]})]}),e.jsx(c,{placeholder:a.host,value:D,onChange:s=>o(s.target.value)}),e.jsxs(E,{children:[e.jsx(i,{variant:"outline",onClick:()=>{d(!1),o("")},children:"Cancel"}),e.jsxs(i,{variant:"destructive",onClick:I,disabled:D!==a.host||x.isPending||j.isPending,children:[(x.isPending||j.isPending)&&e.jsx(u,{className:"mr-2 h-4 w-4 animate-spin"}),"Delete Everything"]})]})]})})]})]})]})}export{re as SiteSettingsPage};
@@ -0,0 +1 @@
1
+ import{j as e}from"./tanstack-BO6c-AOu.js";import{r as n,e as H}from"./react-vendor-DNVhVxD7.js";import{b as P,u as B,d as L,e as O,g as E,H as v,D as N,h as S,B as o,U as F,i as I,j as T,k as U,l as M,L as D,I as w,m as R}from"./index-CdJ9sfDz.js";import{C as $,a as q,b as z,d as G}from"./card-NiKFR8dW.js";import{B as J}from"./badge-DK6q6X8v.js";import{C as K}from"./checkbox-Cv1_Hpta.js";import{P as b}from"./plus-CTopr28W.js";import"./radix-DQ3amgxj.js";import"./check-UCoo7qN1.js";function ae(){const[t,d]=n.useState(!1),{data:l,isLoading:m}=P(t),c=H(),i=n.useMemo(()=>[...l?.items??[]].sort((s,C)=>(s.name||s.host).localeCompare(C.name||C.host)),[l]),{user:a}=B(),{data:A}=L(),k=a?(A?.superAdminIds??[]).includes(a.sub):!1,h=O(),[g,x]=n.useState(!1),[r,j]=n.useState(""),[u,p]=n.useState("");if(m)return e.jsx(E,{});const f=()=>{r.trim()&&h.mutate({host:r.trim(),name:u.trim()||r.trim()},{onSuccess:()=>{x(!1),j(""),p("")}})};return i.length===0?e.jsxs("div",{className:"flex h-screen flex-col",children:[e.jsx(v,{}),e.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center gap-4",children:[e.jsx("p",{className:"text-muted-foreground",children:"No sites available."}),e.jsxs(N,{open:g,onOpenChange:x,children:[e.jsx(S,{asChild:!0,children:e.jsxs(o,{children:[e.jsx(b,{className:"mr-2 h-4 w-4"}),"Create Site"]})}),e.jsx(y,{newHost:r,setNewHost:j,newName:u,setNewName:p,onSubmit:f,isPending:h.isPending})]})]})]}):e.jsxs("div",{className:"flex h-screen flex-col",children:[e.jsx(v,{}),e.jsxs("div",{className:"flex-1 p-8",children:[e.jsxs("div",{className:"mb-6 flex items-center justify-between",children:[e.jsx("h1",{className:"text-2xl font-semibold",children:"Select a site"}),k&&e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[e.jsx(K,{checked:t,onCheckedChange:s=>d(s===!0)}),"Show archived sites"]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(o,{variant:"outline",onClick:()=>c("/users"),children:[e.jsx(F,{className:"mr-2 h-4 w-4"}),"All Users"]}),e.jsxs(N,{open:g,onOpenChange:x,children:[e.jsx(S,{asChild:!0,children:e.jsxs(o,{children:[e.jsx(b,{className:"mr-2 h-4 w-4"}),"Create Site"]})}),e.jsx(y,{newHost:r,setNewHost:j,newName:u,setNewName:p,onSubmit:f,isPending:h.isPending})]})]})]})]}),e.jsx("div",{className:"grid gap-4 sm:grid-cols-2 lg:grid-cols-3",children:i.map(s=>e.jsx($,{className:"cursor-pointer transition-shadow hover:shadow-md",onClick:()=>c(`/sites/${s.host}/content`),children:e.jsxs(q,{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(z,{children:s.name||s.host}),s.status==="archived"&&e.jsx(J,{variant:"outline",children:"Archived"})]}),e.jsx(G,{children:s.host})]})},s.host))})]})]})}function y({newHost:t,setNewHost:d,newName:l,setNewName:m,onSubmit:c,isPending:i}){return e.jsxs(I,{children:[e.jsxs(T,{children:[e.jsx(U,{children:"Create Site"}),e.jsx(M,{className:"sr-only",children:"Enter details for the new site"})]}),e.jsxs("div",{className:"space-y-4 py-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(D,{htmlFor:"host",children:"Host"}),e.jsx(w,{id:"host",placeholder:"example.com",value:t,onChange:a=>d(a.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(D,{htmlFor:"name",children:"Display Name"}),e.jsx(w,{id:"name",placeholder:"My Site",value:l,onChange:a=>m(a.target.value)})]})]}),e.jsx(R,{children:e.jsx(o,{onClick:c,disabled:!t.trim()||i,children:i?"Creating...":"Create"})})]})}export{ae as SitesPage};
@@ -1 +1 @@
1
- import{j as e}from"./tanstack-BO6c-AOu.js";import{u as p,r as x}from"./react-vendor-DNVhVxD7.js";import{u as b,a as D,b as y}from"./useTags-CYqbj5cK.js";import{I as w,B as c,S as v,s as d,D as N,i as C,j as P,k as S,l as k,m as A}from"./index-Ds50UTAc.js";import{T as E,a as B,b as j,c as m,d as F,e as h}from"./table-B3EHrN_H.js";import{P as H}from"./plus-BgHSYWJN.js";import{T as $}from"./trash-2-Gny2Upn-.js";import"./radix-DQ3amgxj.js";function J(){const{host:t}=p(),{data:s,isLoading:n}=b(t),o=D(t),[r,l]=x.useState(""),[T,u]=x.useState(null);async function f(a){a.preventDefault();const i=r.trim().toLowerCase();if(i)try{await o.mutateAsync(i),l(""),d.success(`Tag "${i}" created`)}catch(g){d.error("Failed to create tag",{description:g instanceof Error?g.message:void 0})}}return e.jsxs("div",{children:[e.jsx("div",{className:"mb-6 flex items-center justify-between",children:e.jsxs("h1",{className:"text-2xl font-semibold",children:["Tags",s?` (${s.length})`:""]})}),e.jsxs("form",{onSubmit:f,className:"mb-6 flex gap-2",children:[e.jsx(w,{value:r,onChange:a=>l(a.target.value),placeholder:"New tag name...",className:"max-w-xs"}),e.jsxs(c,{type:"submit",disabled:o.isPending||!r.trim(),children:[e.jsx(H,{className:"mr-2 h-4 w-4"}),"Add Tag"]})]}),n?e.jsx("div",{className:"space-y-2",children:Array.from({length:3}).map((a,i)=>e.jsx(v,{className:"h-12 w-full"},i))}):s?.length?e.jsxs(E,{children:[e.jsx(B,{children:e.jsxs(j,{children:[e.jsx(m,{children:"Tag"}),e.jsx(m,{children:"Published Content"}),e.jsx(m,{})]})}),e.jsx(F,{children:s.map(a=>e.jsxs(j,{children:[e.jsx(h,{className:"font-medium",children:a.tag}),e.jsx(h,{className:"text-muted-foreground",children:a.count}),e.jsx(h,{children:e.jsx(c,{variant:"ghost",size:"sm",disabled:a.count>0,title:a.count>0?"Cannot delete a tag that is in use":"Delete tag",onClick:()=>u(a.tag),children:e.jsx($,{className:"h-4 w-4"})})})]},a.tag))})]}):e.jsx("p",{className:"text-muted-foreground",children:"No tags yet. Tags are created automatically when you publish content with tags, or you can create them manually above."}),e.jsx(I,{host:t,tag:T,onClose:()=>u(null)})]})}function I({host:t,tag:s,onClose:n}){const o=y(t);async function r(){if(s)try{await o.mutateAsync(s),d.success(`Tag "${s}" deleted`),n()}catch(l){d.error("Failed to delete tag",{description:l instanceof Error?l.message:void 0})}}return e.jsx(N,{open:!!s,onOpenChange:()=>n(),children:e.jsxs(C,{children:[e.jsxs(P,{children:[e.jsx(S,{children:"Delete tag?"}),e.jsxs(k,{children:["This will remove the tag “",s,"” from the tag list. This action cannot be undone."]})]}),e.jsxs(A,{children:[e.jsx(c,{variant:"outline",onClick:n,children:"Cancel"}),e.jsx(c,{variant:"destructive",onClick:r,children:"Delete"})]})]})})}export{J as TagsPage};
1
+ import{j as e}from"./tanstack-BO6c-AOu.js";import{u as p,r as x}from"./react-vendor-DNVhVxD7.js";import{u as b,a as D,b as y}from"./useTags-CiyJ7ytD.js";import{I as w,B as c,S as v,s as d,D as N,i as C,j as P,k as S,l as k,m as A}from"./index-CdJ9sfDz.js";import{T as E,a as B,b as j,c as m,d as F,e as h}from"./table-pnzwUf_S.js";import{P as H}from"./plus-CTopr28W.js";import{T as $}from"./trash-2-H30Pytad.js";import"./radix-DQ3amgxj.js";function J(){const{host:t}=p(),{data:s,isLoading:n}=b(t),o=D(t),[r,l]=x.useState(""),[T,u]=x.useState(null);async function f(a){a.preventDefault();const i=r.trim().toLowerCase();if(i)try{await o.mutateAsync(i),l(""),d.success(`Tag "${i}" created`)}catch(g){d.error("Failed to create tag",{description:g instanceof Error?g.message:void 0})}}return e.jsxs("div",{children:[e.jsx("div",{className:"mb-6 flex items-center justify-between",children:e.jsxs("h1",{className:"text-2xl font-semibold",children:["Tags",s?` (${s.length})`:""]})}),e.jsxs("form",{onSubmit:f,className:"mb-6 flex gap-2",children:[e.jsx(w,{value:r,onChange:a=>l(a.target.value),placeholder:"New tag name...",className:"max-w-xs"}),e.jsxs(c,{type:"submit",disabled:o.isPending||!r.trim(),children:[e.jsx(H,{className:"mr-2 h-4 w-4"}),"Add Tag"]})]}),n?e.jsx("div",{className:"space-y-2",children:Array.from({length:3}).map((a,i)=>e.jsx(v,{className:"h-12 w-full"},i))}):s?.length?e.jsxs(E,{children:[e.jsx(B,{children:e.jsxs(j,{children:[e.jsx(m,{children:"Tag"}),e.jsx(m,{children:"Published Content"}),e.jsx(m,{})]})}),e.jsx(F,{children:s.map(a=>e.jsxs(j,{children:[e.jsx(h,{className:"font-medium",children:a.tag}),e.jsx(h,{className:"text-muted-foreground",children:a.count}),e.jsx(h,{children:e.jsx(c,{variant:"ghost",size:"sm",disabled:a.count>0,title:a.count>0?"Cannot delete a tag that is in use":"Delete tag",onClick:()=>u(a.tag),children:e.jsx($,{className:"h-4 w-4"})})})]},a.tag))})]}):e.jsx("p",{className:"text-muted-foreground",children:"No tags yet. Tags are created automatically when you publish content with tags, or you can create them manually above."}),e.jsx(I,{host:t,tag:T,onClose:()=>u(null)})]})}function I({host:t,tag:s,onClose:n}){const o=y(t);async function r(){if(s)try{await o.mutateAsync(s),d.success(`Tag "${s}" deleted`),n()}catch(l){d.error("Failed to delete tag",{description:l instanceof Error?l.message:void 0})}}return e.jsx(N,{open:!!s,onOpenChange:()=>n(),children:e.jsxs(C,{children:[e.jsxs(P,{children:[e.jsx(S,{children:"Delete tag?"}),e.jsxs(k,{children:["This will remove the tag “",s,"” from the tag list. This action cannot be undone."]})]}),e.jsxs(A,{children:[e.jsx(c,{variant:"outline",onClick:n,children:"Cancel"}),e.jsx(c,{variant:"destructive",onClick:r,children:"Delete"})]})]})})}export{J as TagsPage};
@@ -1 +1 @@
1
- import{j as e}from"./tanstack-BO6c-AOu.js";import{r as p}from"./react-vendor-DNVhVxD7.js";import{n as H,u as L,o as P,d as z,p as O,q as _,r as q,H as R,I as G,S as J,B as t,D as g,h as K,i as v,j as A,k as D,l as C,m as y,s as n}from"./index-Ds50UTAc.js";import{C as Q}from"./checkbox-BPqrj_XS.js";import{B as V}from"./badge-0Z1nL6DI.js";import{T as W,a as X,b as N,c as r,d as Y,e as c}from"./table-B3EHrN_H.js";import{T as Z}from"./trash-2-Gny2Upn-.js";import"./radix-DQ3amgxj.js";import"./check-BGA0ADyt.js";const $=[["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M5 5a1 1 0 0 0-1 1v7c0 5 3.5 7.5 7.67 8.94a1 1 0 0 0 .67.01c2.35-.82 4.48-1.97 5.9-3.71",key:"1jlk70"}],["path",{d:"M9.309 3.652A12.252 12.252 0 0 0 11.24 2.28a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1v7a9.784 9.784 0 0 1-.08 1.264",key:"18rp1v"}]],ee=H("shield-off",$);function oe(){const{user:w}=L(),{data:S,isLoading:T}=P(),{data:k}=z(),U=O(),m=_(),h=q(),u=S?.items??[],x=k?.superAdminIds??[],[j,F]=p.useState(""),[E,f]=p.useState(null),[d,o]=p.useState(null),b=j?u.filter(s=>s.email.toLowerCase().includes(j.toLowerCase())):u;async function M(s){try{await m.mutateAsync(s),n.success("User deleted"),f(null)}catch(a){n.error("Failed to delete user",{description:a instanceof Error?a.message:void 0})}}async function I(s){try{await h.mutateAsync(s),n.success("Two-factor authentication disabled"),o(null)}catch(a){n.error("Failed to disable 2FA",{description:a instanceof Error?a.message:void 0})}}async function B(s,a){const l=a?x.filter(i=>i!==s):[...x,s];if(l.length===0){n.error("At least one super admin is required");return}try{await U.mutateAsync({superAdminIds:l}),n.success(a?"Super admin removed":"Super admin added")}catch(i){n.error("Failed to update super admins",{description:i instanceof Error?i.message:void 0})}}return e.jsxs("div",{className:"flex h-screen flex-col",children:[e.jsx(R,{}),e.jsxs("div",{className:"flex-1 p-8",children:[e.jsx("div",{className:"mb-6 flex items-center justify-between",children:e.jsx("h1",{className:"text-2xl font-semibold",children:"All Users"})}),e.jsx("div",{className:"mb-4",children:e.jsx(G,{placeholder:"Search by email...",value:j,onChange:s=>F(s.target.value),className:"max-w-sm"})}),T?e.jsx("div",{className:"space-y-2",children:Array.from({length:5}).map((s,a)=>e.jsx(J,{className:"h-12 w-full"},a))}):b.length===0?e.jsx("p",{className:"text-muted-foreground",children:"No users found."}):e.jsxs(W,{children:[e.jsx(X,{children:e.jsxs(N,{children:[e.jsx(r,{children:"Email"}),e.jsx(r,{children:"Status"}),e.jsx(r,{children:"2FA"}),e.jsx(r,{children:"Super Admin"}),e.jsx(r,{})]})}),e.jsx(Y,{children:b.map(s=>{const a=s.sub===w?.sub,l=x.includes(s.sub);return e.jsxs(N,{children:[e.jsxs(c,{className:"text-sm",children:[s.email,a&&e.jsx("span",{className:"text-muted-foreground ml-2",children:"(you)"})]}),e.jsx(c,{className:"text-sm capitalize",children:s.status}),e.jsx(c,{children:s.mfaEnabled?e.jsx(V,{variant:"outline",className:"border-green-500 text-green-700",children:"Enabled"}):e.jsx("span",{className:"text-muted-foreground",children:"—"})}),e.jsx(c,{children:e.jsx(Q,{checked:l,onCheckedChange:()=>B(s.sub,l)})}),e.jsx(c,{className:"text-right",children:e.jsxs("div",{className:"flex items-center justify-end gap-1",children:[!a&&s.mfaEnabled&&e.jsx(t,{variant:"ghost",size:"sm",title:"Disable 2FA",onClick:()=>o(s.sub),children:e.jsx(ee,{className:"h-4 w-4"})}),!a&&e.jsxs(g,{open:E===s.sub,onOpenChange:i=>f(i?s.sub:null),children:[e.jsx(K,{asChild:!0,children:e.jsx(t,{variant:"ghost",size:"sm",className:"text-destructive",title:"Delete account",children:e.jsx(Z,{className:"h-4 w-4"})})}),e.jsxs(v,{children:[e.jsxs(A,{children:[e.jsx(D,{children:"Delete User Account"}),e.jsx(C,{className:"sr-only",children:"Confirm permanent deletion of this user account"})]}),e.jsxs("p",{className:"text-muted-foreground text-sm",children:["This will permanently delete the account for"," ",e.jsx("strong",{children:s.email}),". They will lose access to all sites."]}),e.jsxs(y,{children:[e.jsx(t,{variant:"outline",onClick:()=>f(null),children:"Cancel"}),e.jsx(t,{variant:"destructive",onClick:()=>M(s.sub),disabled:m.isPending,children:m.isPending?"Deleting...":"Delete Account"})]})]})]})]})})]},s.sub)})})]}),e.jsx(g,{open:d!==null,onOpenChange:s=>{s||o(null)},children:e.jsxs(v,{children:[e.jsxs(A,{children:[e.jsx(D,{children:"Disable Two-Factor Authentication"}),e.jsxs(C,{children:["This will disable 2FA for"," ",e.jsx("strong",{children:u.find(s=>s.sub===d)?.email}),". They will be able to log in with just their password."]})]}),e.jsxs(y,{children:[e.jsx(t,{variant:"outline",onClick:()=>o(null),children:"Cancel"}),e.jsx(t,{variant:"destructive",onClick:()=>{d&&I(d)},disabled:h.isPending,children:h.isPending?"Disabling...":"Disable 2FA"})]})]})})]})]})}export{oe as UsersPage};
1
+ import{j as e}from"./tanstack-BO6c-AOu.js";import{r as p}from"./react-vendor-DNVhVxD7.js";import{n as H,u as L,o as P,d as z,p as O,q as _,r as q,H as R,I as G,S as J,B as t,D as g,h as K,i as v,j as A,k as D,l as C,m as y,s as n}from"./index-CdJ9sfDz.js";import{C as Q}from"./checkbox-Cv1_Hpta.js";import{B as V}from"./badge-DK6q6X8v.js";import{T as W,a as X,b as N,c as r,d as Y,e as c}from"./table-pnzwUf_S.js";import{T as Z}from"./trash-2-H30Pytad.js";import"./radix-DQ3amgxj.js";import"./check-UCoo7qN1.js";const $=[["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M5 5a1 1 0 0 0-1 1v7c0 5 3.5 7.5 7.67 8.94a1 1 0 0 0 .67.01c2.35-.82 4.48-1.97 5.9-3.71",key:"1jlk70"}],["path",{d:"M9.309 3.652A12.252 12.252 0 0 0 11.24 2.28a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1v7a9.784 9.784 0 0 1-.08 1.264",key:"18rp1v"}]],ee=H("shield-off",$);function oe(){const{user:w}=L(),{data:S,isLoading:T}=P(),{data:k}=z(),U=O(),m=_(),h=q(),u=S?.items??[],x=k?.superAdminIds??[],[j,F]=p.useState(""),[E,f]=p.useState(null),[d,o]=p.useState(null),b=j?u.filter(s=>s.email.toLowerCase().includes(j.toLowerCase())):u;async function M(s){try{await m.mutateAsync(s),n.success("User deleted"),f(null)}catch(a){n.error("Failed to delete user",{description:a instanceof Error?a.message:void 0})}}async function I(s){try{await h.mutateAsync(s),n.success("Two-factor authentication disabled"),o(null)}catch(a){n.error("Failed to disable 2FA",{description:a instanceof Error?a.message:void 0})}}async function B(s,a){const l=a?x.filter(i=>i!==s):[...x,s];if(l.length===0){n.error("At least one super admin is required");return}try{await U.mutateAsync({superAdminIds:l}),n.success(a?"Super admin removed":"Super admin added")}catch(i){n.error("Failed to update super admins",{description:i instanceof Error?i.message:void 0})}}return e.jsxs("div",{className:"flex h-screen flex-col",children:[e.jsx(R,{}),e.jsxs("div",{className:"flex-1 p-8",children:[e.jsx("div",{className:"mb-6 flex items-center justify-between",children:e.jsx("h1",{className:"text-2xl font-semibold",children:"All Users"})}),e.jsx("div",{className:"mb-4",children:e.jsx(G,{placeholder:"Search by email...",value:j,onChange:s=>F(s.target.value),className:"max-w-sm"})}),T?e.jsx("div",{className:"space-y-2",children:Array.from({length:5}).map((s,a)=>e.jsx(J,{className:"h-12 w-full"},a))}):b.length===0?e.jsx("p",{className:"text-muted-foreground",children:"No users found."}):e.jsxs(W,{children:[e.jsx(X,{children:e.jsxs(N,{children:[e.jsx(r,{children:"Email"}),e.jsx(r,{children:"Status"}),e.jsx(r,{children:"2FA"}),e.jsx(r,{children:"Super Admin"}),e.jsx(r,{})]})}),e.jsx(Y,{children:b.map(s=>{const a=s.sub===w?.sub,l=x.includes(s.sub);return e.jsxs(N,{children:[e.jsxs(c,{className:"text-sm",children:[s.email,a&&e.jsx("span",{className:"text-muted-foreground ml-2",children:"(you)"})]}),e.jsx(c,{className:"text-sm capitalize",children:s.status}),e.jsx(c,{children:s.mfaEnabled?e.jsx(V,{variant:"outline",className:"border-green-500 text-green-700",children:"Enabled"}):e.jsx("span",{className:"text-muted-foreground",children:"—"})}),e.jsx(c,{children:e.jsx(Q,{checked:l,onCheckedChange:()=>B(s.sub,l)})}),e.jsx(c,{className:"text-right",children:e.jsxs("div",{className:"flex items-center justify-end gap-1",children:[!a&&s.mfaEnabled&&e.jsx(t,{variant:"ghost",size:"sm",title:"Disable 2FA",onClick:()=>o(s.sub),children:e.jsx(ee,{className:"h-4 w-4"})}),!a&&e.jsxs(g,{open:E===s.sub,onOpenChange:i=>f(i?s.sub:null),children:[e.jsx(K,{asChild:!0,children:e.jsx(t,{variant:"ghost",size:"sm",className:"text-destructive",title:"Delete account",children:e.jsx(Z,{className:"h-4 w-4"})})}),e.jsxs(v,{children:[e.jsxs(A,{children:[e.jsx(D,{children:"Delete User Account"}),e.jsx(C,{className:"sr-only",children:"Confirm permanent deletion of this user account"})]}),e.jsxs("p",{className:"text-muted-foreground text-sm",children:["This will permanently delete the account for"," ",e.jsx("strong",{children:s.email}),". They will lose access to all sites."]}),e.jsxs(y,{children:[e.jsx(t,{variant:"outline",onClick:()=>f(null),children:"Cancel"}),e.jsx(t,{variant:"destructive",onClick:()=>M(s.sub),disabled:m.isPending,children:m.isPending?"Deleting...":"Delete Account"})]})]})]})]})})]},s.sub)})})]}),e.jsx(g,{open:d!==null,onOpenChange:s=>{s||o(null)},children:e.jsxs(v,{children:[e.jsxs(A,{children:[e.jsx(D,{children:"Disable Two-Factor Authentication"}),e.jsxs(C,{children:["This will disable 2FA for"," ",e.jsx("strong",{children:u.find(s=>s.sub===d)?.email}),". They will be able to log in with just their password."]})]}),e.jsxs(y,{children:[e.jsx(t,{variant:"outline",onClick:()=>o(null),children:"Cancel"}),e.jsx(t,{variant:"destructive",onClick:()=>{d&&I(d)},disabled:h.isPending,children:h.isPending?"Disabling...":"Disable 2FA"})]})]})})]})]})}export{oe as UsersPage};
@@ -1 +1 @@
1
- import{j as e}from"./tanstack-BO6c-AOu.js";import{u as R,e as $,r as d}from"./react-vendor-DNVhVxD7.js";import{a as U,b as _,c as q,d as z,e as K,f as M}from"./useWebhooks-DXgtQ3aU.js";import{n as V,S as v,L as y,I as Y,B as l,a as G,D as J,h as Q,i as X,j as Z,k as ee,l as se,m as te,s as i}from"./index-Ds50UTAc.js";import{B as C}from"./badge-0Z1nL6DI.js";import{C as j,c as p,a as W,b as N}from"./card-D1-S-QZ6.js";import{T as ae,a as ne,b as T,c as b,d as re,e as f}from"./table-B3EHrN_H.js";import{f as oe}from"./format-CZ9bpk32.js";import{T as ie}from"./trash-2-Gny2Upn-.js";import"./radix-DQ3amgxj.js";const le=[["path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",key:"1ffxy3"}],["path",{d:"m21.854 2.147-10.94 10.939",key:"12cjpa"}]],ce=V("send",le),de=["content.published","content.unpublished","content.deleted"];function ve(){const{host:t,id:a}=R(),n=a==="new",{data:o,isLoading:c}=U(t,n?"":a);return!n&&c?e.jsxs("div",{className:"space-y-4",children:[e.jsx(v,{className:"h-8 w-64"}),e.jsx(v,{className:"h-64 w-full"})]}):n?e.jsx(w,{host:t,isNew:!0}):o?e.jsx(w,{host:t,isNew:!1,webhook:o},o.webhookId):e.jsx("p",{className:"text-muted-foreground",children:"Webhook not found."})}function w({host:t,isNew:a,webhook:n}){const o=$(),c=_(t),h=q(t,n?.webhookId??""),D=z(t,n?.webhookId??""),S=K(t,n?.webhookId??""),{data:u}=M(t,a?"":n?.webhookId??""),[m,E]=d.useState(n?.url??""),[x,I]=d.useState(n?.events??[]),[g,B]=d.useState(null),[F,k]=d.useState(!1);function L(s){I(r=>r.includes(s)?r.filter(O=>O!==s):[...r,s])}async function P(s){s.preventDefault();try{if(a){const r=await c.mutateAsync({url:m,events:x,enabled:!0});B(r.secret??null),i.success("Webhook created"),o(`/sites/${t}/settings/webhooks/${r.webhookId}`,{replace:!0})}else await h.mutateAsync({url:m,events:x,enabled:n?.enabled}),i.success("Webhook updated")}catch(r){i.error(a?"Failed to create":"Failed to update",{description:r instanceof Error?r.message:void 0})}}async function A(){try{await S.mutateAsync(),i.success("Test webhook sent")}catch(s){i.error("Test failed",{description:s instanceof Error?s.message:void 0})}}async function H(){try{await D.mutateAsync(),i.success("Webhook deleted"),o(`/sites/${t}/settings/webhooks`)}catch(s){i.error("Failed to delete",{description:s instanceof Error?s.message:void 0})}}return e.jsxs("div",{className:"mx-auto max-w-2xl space-y-6",children:[e.jsx("h1",{className:"text-2xl font-semibold",children:a?"New Webhook":"Edit Webhook"}),g&&e.jsx(j,{className:"border-yellow-500",children:e.jsxs(p,{className:"pt-6",children:[e.jsx("p",{className:"mb-2 text-sm font-medium",children:"Webhook Secret"}),e.jsx("p",{className:"text-muted-foreground mb-2 text-sm",children:"Save this secret now. You won't see it again."}),e.jsx("code",{className:"bg-muted rounded px-2 py-1 text-sm",children:g})]})}),e.jsxs(j,{children:[e.jsx(W,{children:e.jsx(N,{children:"Webhook Settings"})}),e.jsx(p,{children:e.jsxs("form",{onSubmit:P,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(y,{htmlFor:"url",children:"URL"}),e.jsx(Y,{id:"url",type:"url",value:m,onChange:s=>E(s.target.value),required:!0,placeholder:"https://example.com/webhook"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(y,{children:"Events"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:de.map(s=>e.jsx(C,{variant:x.includes(s)?"default":"outline",className:"cursor-pointer",onClick:()=>L(s),children:s},s))})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(l,{type:"submit",disabled:c.isPending||h.isPending,children:[(c.isPending||h.isPending)&&e.jsx(G,{className:"mr-2 h-4 w-4 animate-spin"}),a?"Create":"Save"]}),!a&&e.jsxs(l,{type:"button",variant:"outline",onClick:A,children:[e.jsx(ce,{className:"mr-2 h-4 w-4"}),"Test"]}),e.jsx(l,{type:"button",variant:"outline",onClick:()=>o(`/sites/${t}/settings/webhooks`),children:"Cancel"})]})]})})]}),!a&&u?.items&&u.items.length>0&&e.jsxs(j,{children:[e.jsx(W,{children:e.jsx(N,{children:"Recent Deliveries"})}),e.jsx(p,{children:e.jsxs(ae,{children:[e.jsx(ne,{children:e.jsxs(T,{children:[e.jsx(b,{children:"Event"}),e.jsx(b,{children:"Status"}),e.jsx(b,{children:"Time"})]})}),e.jsx(re,{children:u.items.map(s=>e.jsxs(T,{children:[e.jsx(f,{children:s.event}),e.jsx(f,{children:e.jsx(C,{variant:s.status==="success"?"default":"destructive",children:s.responseStatus??"Error"})}),e.jsx(f,{className:"text-muted-foreground",children:oe(s.createdAt)})]},s.deliveryId))})]})})]}),!a&&e.jsxs(J,{open:F,onOpenChange:k,children:[e.jsx(Q,{asChild:!0,children:e.jsxs(l,{variant:"destructive",children:[e.jsx(ie,{className:"mr-2 h-4 w-4"}),"Delete Webhook"]})}),e.jsxs(X,{children:[e.jsxs(Z,{children:[e.jsx(ee,{children:"Delete webhook?"}),e.jsx(se,{children:"This action cannot be undone."})]}),e.jsxs(te,{children:[e.jsx(l,{variant:"outline",onClick:()=>k(!1),children:"Cancel"}),e.jsx(l,{variant:"destructive",onClick:H,children:"Delete"})]})]})]})]})}export{ve as WebhookEditPage};
1
+ import{j as e}from"./tanstack-BO6c-AOu.js";import{u as R,e as $,r as d}from"./react-vendor-DNVhVxD7.js";import{a as U,b as _,c as q,d as z,e as K,f as M}from"./useWebhooks-D5KIBL2l.js";import{n as V,S as v,L as y,I as Y,B as l,a as G,D as J,h as Q,i as X,j as Z,k as ee,l as se,m as te,s as i}from"./index-CdJ9sfDz.js";import{B as C}from"./badge-DK6q6X8v.js";import{C as j,c as p,a as W,b as N}from"./card-NiKFR8dW.js";import{T as ae,a as ne,b as T,c as b,d as re,e as f}from"./table-pnzwUf_S.js";import{f as oe}from"./format-CZ9bpk32.js";import{T as ie}from"./trash-2-H30Pytad.js";import"./radix-DQ3amgxj.js";const le=[["path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",key:"1ffxy3"}],["path",{d:"m21.854 2.147-10.94 10.939",key:"12cjpa"}]],ce=V("send",le),de=["content.published","content.unpublished","content.deleted"];function ve(){const{host:t,id:a}=R(),n=a==="new",{data:o,isLoading:c}=U(t,n?"":a);return!n&&c?e.jsxs("div",{className:"space-y-4",children:[e.jsx(v,{className:"h-8 w-64"}),e.jsx(v,{className:"h-64 w-full"})]}):n?e.jsx(w,{host:t,isNew:!0}):o?e.jsx(w,{host:t,isNew:!1,webhook:o},o.webhookId):e.jsx("p",{className:"text-muted-foreground",children:"Webhook not found."})}function w({host:t,isNew:a,webhook:n}){const o=$(),c=_(t),h=q(t,n?.webhookId??""),D=z(t,n?.webhookId??""),S=K(t,n?.webhookId??""),{data:u}=M(t,a?"":n?.webhookId??""),[m,E]=d.useState(n?.url??""),[x,I]=d.useState(n?.events??[]),[g,B]=d.useState(null),[F,k]=d.useState(!1);function L(s){I(r=>r.includes(s)?r.filter(O=>O!==s):[...r,s])}async function P(s){s.preventDefault();try{if(a){const r=await c.mutateAsync({url:m,events:x,enabled:!0});B(r.secret??null),i.success("Webhook created"),o(`/sites/${t}/settings/webhooks/${r.webhookId}`,{replace:!0})}else await h.mutateAsync({url:m,events:x,enabled:n?.enabled}),i.success("Webhook updated")}catch(r){i.error(a?"Failed to create":"Failed to update",{description:r instanceof Error?r.message:void 0})}}async function A(){try{await S.mutateAsync(),i.success("Test webhook sent")}catch(s){i.error("Test failed",{description:s instanceof Error?s.message:void 0})}}async function H(){try{await D.mutateAsync(),i.success("Webhook deleted"),o(`/sites/${t}/settings/webhooks`)}catch(s){i.error("Failed to delete",{description:s instanceof Error?s.message:void 0})}}return e.jsxs("div",{className:"mx-auto max-w-2xl space-y-6",children:[e.jsx("h1",{className:"text-2xl font-semibold",children:a?"New Webhook":"Edit Webhook"}),g&&e.jsx(j,{className:"border-yellow-500",children:e.jsxs(p,{className:"pt-6",children:[e.jsx("p",{className:"mb-2 text-sm font-medium",children:"Webhook Secret"}),e.jsx("p",{className:"text-muted-foreground mb-2 text-sm",children:"Save this secret now. You won't see it again."}),e.jsx("code",{className:"bg-muted rounded px-2 py-1 text-sm",children:g})]})}),e.jsxs(j,{children:[e.jsx(W,{children:e.jsx(N,{children:"Webhook Settings"})}),e.jsx(p,{children:e.jsxs("form",{onSubmit:P,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(y,{htmlFor:"url",children:"URL"}),e.jsx(Y,{id:"url",type:"url",value:m,onChange:s=>E(s.target.value),required:!0,placeholder:"https://example.com/webhook"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(y,{children:"Events"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:de.map(s=>e.jsx(C,{variant:x.includes(s)?"default":"outline",className:"cursor-pointer",onClick:()=>L(s),children:s},s))})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(l,{type:"submit",disabled:c.isPending||h.isPending,children:[(c.isPending||h.isPending)&&e.jsx(G,{className:"mr-2 h-4 w-4 animate-spin"}),a?"Create":"Save"]}),!a&&e.jsxs(l,{type:"button",variant:"outline",onClick:A,children:[e.jsx(ce,{className:"mr-2 h-4 w-4"}),"Test"]}),e.jsx(l,{type:"button",variant:"outline",onClick:()=>o(`/sites/${t}/settings/webhooks`),children:"Cancel"})]})]})})]}),!a&&u?.items&&u.items.length>0&&e.jsxs(j,{children:[e.jsx(W,{children:e.jsx(N,{children:"Recent Deliveries"})}),e.jsx(p,{children:e.jsxs(ae,{children:[e.jsx(ne,{children:e.jsxs(T,{children:[e.jsx(b,{children:"Event"}),e.jsx(b,{children:"Status"}),e.jsx(b,{children:"Time"})]})}),e.jsx(re,{children:u.items.map(s=>e.jsxs(T,{children:[e.jsx(f,{children:s.event}),e.jsx(f,{children:e.jsx(C,{variant:s.status==="success"?"default":"destructive",children:s.responseStatus??"Error"})}),e.jsx(f,{className:"text-muted-foreground",children:oe(s.createdAt)})]},s.deliveryId))})]})})]}),!a&&e.jsxs(J,{open:F,onOpenChange:k,children:[e.jsx(Q,{asChild:!0,children:e.jsxs(l,{variant:"destructive",children:[e.jsx(ie,{className:"mr-2 h-4 w-4"}),"Delete Webhook"]})}),e.jsxs(X,{children:[e.jsxs(Z,{children:[e.jsx(ee,{children:"Delete webhook?"}),e.jsx(se,{children:"This action cannot be undone."})]}),e.jsxs(te,{children:[e.jsx(l,{variant:"outline",onClick:()=>k(!1),children:"Cancel"}),e.jsx(l,{variant:"destructive",onClick:H,children:"Delete"})]})]})]})]})}export{ve as WebhookEditPage};
@@ -1 +1 @@
1
- import{j as e}from"./tanstack-BO6c-AOu.js";import{u as m,e as x}from"./react-vendor-DNVhVxD7.js";import{u as h}from"./useWebhooks-DXgtQ3aU.js";import{B as j,S as b}from"./index-Ds50UTAc.js";import{B as l}from"./badge-0Z1nL6DI.js";import{T as u,a as f,b as c,c as r,d as p,e as t}from"./table-B3EHrN_H.js";import{P as N}from"./plus-BgHSYWJN.js";import"./radix-DQ3amgxj.js";function W(){const{host:o}=m(),n=x(),{data:i,isLoading:d}=h(o);return e.jsxs("div",{children:[e.jsxs("div",{className:"mb-6 flex items-center justify-between",children:[e.jsx("h1",{className:"text-2xl font-semibold",children:"Webhooks"}),e.jsxs(j,{onClick:()=>n(`/sites/${o}/settings/webhooks/new`),children:[e.jsx(N,{className:"mr-2 h-4 w-4"}),"New Webhook"]})]}),d?e.jsx("div",{className:"space-y-2",children:Array.from({length:3}).map((s,a)=>e.jsx(b,{className:"h-12 w-full"},a))}):i?.items.length?e.jsxs(u,{children:[e.jsx(f,{children:e.jsxs(c,{children:[e.jsx(r,{children:"URL"}),e.jsx(r,{children:"Events"}),e.jsx(r,{children:"Status"})]})}),e.jsx(p,{children:i.items.map(s=>e.jsxs(c,{className:"cursor-pointer",onClick:()=>n(`/sites/${o}/settings/webhooks/${s.webhookId}`),children:[e.jsx(t,{className:"max-w-xs truncate font-mono text-sm",children:s.url}),e.jsx(t,{children:e.jsx("div",{className:"flex flex-wrap gap-1",children:s.events.map(a=>e.jsx(l,{variant:"secondary",className:"text-xs",children:a},a))})}),e.jsx(t,{children:e.jsx(l,{variant:s.enabled?"default":"secondary",children:s.enabled?"Active":"Inactive"})})]},s.webhookId))})]}):e.jsx("p",{className:"text-muted-foreground",children:"No webhooks configured."})]})}export{W as WebhooksPage};
1
+ import{j as e}from"./tanstack-BO6c-AOu.js";import{u as m,e as x}from"./react-vendor-DNVhVxD7.js";import{u as h}from"./useWebhooks-D5KIBL2l.js";import{B as j,S as b}from"./index-CdJ9sfDz.js";import{B as l}from"./badge-DK6q6X8v.js";import{T as u,a as f,b as c,c as r,d as p,e as t}from"./table-pnzwUf_S.js";import{P as N}from"./plus-CTopr28W.js";import"./radix-DQ3amgxj.js";function W(){const{host:o}=m(),n=x(),{data:i,isLoading:d}=h(o);return e.jsxs("div",{children:[e.jsxs("div",{className:"mb-6 flex items-center justify-between",children:[e.jsx("h1",{className:"text-2xl font-semibold",children:"Webhooks"}),e.jsxs(j,{onClick:()=>n(`/sites/${o}/settings/webhooks/new`),children:[e.jsx(N,{className:"mr-2 h-4 w-4"}),"New Webhook"]})]}),d?e.jsx("div",{className:"space-y-2",children:Array.from({length:3}).map((s,a)=>e.jsx(b,{className:"h-12 w-full"},a))}):i?.items.length?e.jsxs(u,{children:[e.jsx(f,{children:e.jsxs(c,{children:[e.jsx(r,{children:"URL"}),e.jsx(r,{children:"Events"}),e.jsx(r,{children:"Status"})]})}),e.jsx(p,{children:i.items.map(s=>e.jsxs(c,{className:"cursor-pointer",onClick:()=>n(`/sites/${o}/settings/webhooks/${s.webhookId}`),children:[e.jsx(t,{className:"max-w-xs truncate font-mono text-sm",children:s.url}),e.jsx(t,{children:e.jsx("div",{className:"flex flex-wrap gap-1",children:s.events.map(a=>e.jsx(l,{variant:"secondary",className:"text-xs",children:a},a))})}),e.jsx(t,{children:e.jsx(l,{variant:s.enabled?"default":"secondary",children:s.enabled?"Active":"Inactive"})})]},s.webhookId))})]}):e.jsx("p",{className:"text-muted-foreground",children:"No webhooks configured."})]})}export{W as WebhooksPage};
@@ -1 +1 @@
1
- import{j as o}from"./tanstack-BO6c-AOu.js";import"./react-vendor-DNVhVxD7.js";import{x as n,ab as s}from"./index-Ds50UTAc.js";import{S as d}from"./radix-DQ3amgxj.js";const c=s("inline-flex items-center justify-center rounded-full border border-transparent px-2 py-0.5 text-xs font-medium w-fit whitespace-nowrap shrink-0 [&>svg]:size-3 gap-1 [&>svg]:pointer-events-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive transition-[color,box-shadow] overflow-hidden",{variants:{variant:{default:"bg-primary text-primary-foreground [a&]:hover:bg-primary/90",secondary:"bg-secondary text-secondary-foreground [a&]:hover:bg-secondary/90",destructive:"bg-destructive text-white [a&]:hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",outline:"border-border text-foreground [a&]:hover:bg-accent [a&]:hover:text-accent-foreground",ghost:"[a&]:hover:bg-accent [a&]:hover:text-accent-foreground",link:"text-primary underline-offset-4 [a&]:hover:underline"}},defaultVariants:{variant:"default"}});function l({className:r,variant:e="default",asChild:t=!1,...a}){const i=t?d:"span";return o.jsx(i,{"data-slot":"badge","data-variant":e,className:n(c({variant:e}),r),...a})}export{l as B};
1
+ import{j as o}from"./tanstack-BO6c-AOu.js";import"./react-vendor-DNVhVxD7.js";import{x as n,ab as s}from"./index-CdJ9sfDz.js";import{S as d}from"./radix-DQ3amgxj.js";const c=s("inline-flex items-center justify-center rounded-full border border-transparent px-2 py-0.5 text-xs font-medium w-fit whitespace-nowrap shrink-0 [&>svg]:size-3 gap-1 [&>svg]:pointer-events-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive transition-[color,box-shadow] overflow-hidden",{variants:{variant:{default:"bg-primary text-primary-foreground [a&]:hover:bg-primary/90",secondary:"bg-secondary text-secondary-foreground [a&]:hover:bg-secondary/90",destructive:"bg-destructive text-white [a&]:hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",outline:"border-border text-foreground [a&]:hover:bg-accent [a&]:hover:text-accent-foreground",ghost:"[a&]:hover:bg-accent [a&]:hover:text-accent-foreground",link:"text-primary underline-offset-4 [a&]:hover:underline"}},defaultVariants:{variant:"default"}});function l({className:r,variant:e="default",asChild:t=!1,...a}){const i=t?d:"span";return o.jsx(i,{"data-slot":"badge","data-variant":e,className:n(c({variant:e}),r),...a})}export{l as B};
@@ -1 +1 @@
1
- import{j as r}from"./tanstack-BO6c-AOu.js";import"./react-vendor-DNVhVxD7.js";import{x as d}from"./index-Ds50UTAc.js";function n({className:a,...t}){return r.jsx("div",{"data-slot":"card",className:d("bg-card text-card-foreground flex flex-col gap-6 rounded-xl border py-6 shadow-sm",a),...t})}function i({className:a,...t}){return r.jsx("div",{"data-slot":"card-header",className:d("@container/card-header grid auto-rows-min grid-rows-[auto_auto] items-start gap-2 px-6 has-data-[slot=card-action]:grid-cols-[1fr_auto] [.border-b]:pb-6",a),...t})}function c({className:a,...t}){return r.jsx("div",{"data-slot":"card-title",className:d("leading-none font-semibold",a),...t})}function l({className:a,...t}){return r.jsx("div",{"data-slot":"card-description",className:d("text-muted-foreground text-sm",a),...t})}function u({className:a,...t}){return r.jsx("div",{"data-slot":"card-content",className:d("px-6",a),...t})}export{n as C,i as a,c as b,u as c,l as d};
1
+ import{j as r}from"./tanstack-BO6c-AOu.js";import"./react-vendor-DNVhVxD7.js";import{x as d}from"./index-CdJ9sfDz.js";function n({className:a,...t}){return r.jsx("div",{"data-slot":"card",className:d("bg-card text-card-foreground flex flex-col gap-6 rounded-xl border py-6 shadow-sm",a),...t})}function i({className:a,...t}){return r.jsx("div",{"data-slot":"card-header",className:d("@container/card-header grid auto-rows-min grid-rows-[auto_auto] items-start gap-2 px-6 has-data-[slot=card-action]:grid-cols-[1fr_auto] [.border-b]:pb-6",a),...t})}function c({className:a,...t}){return r.jsx("div",{"data-slot":"card-title",className:d("leading-none font-semibold",a),...t})}function l({className:a,...t}){return r.jsx("div",{"data-slot":"card-description",className:d("text-muted-foreground text-sm",a),...t})}function u({className:a,...t}){return r.jsx("div",{"data-slot":"card-content",className:d("px-6",a),...t})}export{n as C,i as a,c as b,u as c,l as d};
@@ -0,0 +1 @@
1
+ import{n as c}from"./index-CdJ9sfDz.js";const e=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],t=c("check",e);export{t as C};
@@ -1 +1 @@
1
- import{j as r}from"./tanstack-BO6c-AOu.js";import"./react-vendor-DNVhVxD7.js";import{x as i}from"./index-Ds50UTAc.js";import{C as t}from"./check-BGA0ADyt.js";import{Q as o,U as s}from"./radix-DQ3amgxj.js";function p({className:e,...a}){return r.jsx(o,{"data-slot":"checkbox",className:i("peer border-input dark:bg-input/30 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground dark:data-[state=checked]:bg-primary data-[state=checked]:border-primary focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive size-4 shrink-0 rounded-[4px] border shadow-xs transition-shadow outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50",e),...a,children:r.jsx(s,{"data-slot":"checkbox-indicator",className:"grid place-content-center text-current transition-none",children:r.jsx(t,{className:"size-3.5"})})})}export{p as C};
1
+ import{j as r}from"./tanstack-BO6c-AOu.js";import"./react-vendor-DNVhVxD7.js";import{x as i}from"./index-CdJ9sfDz.js";import{C as t}from"./check-UCoo7qN1.js";import{Q as o,U as s}from"./radix-DQ3amgxj.js";function p({className:e,...a}){return r.jsx(o,{"data-slot":"checkbox",className:i("peer border-input dark:bg-input/30 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground dark:data-[state=checked]:bg-primary data-[state=checked]:border-primary focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive size-4 shrink-0 rounded-[4px] border shadow-xs transition-shadow outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50",e),...a,children:r.jsx(s,{"data-slot":"checkbox-indicator",className:"grid place-content-center text-current transition-none",children:r.jsx(t,{className:"size-3.5"})})})}export{p as C};