headroom-cms 0.1.4 → 0.1.6

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 (129) hide show
  1. package/admin/assets/AdminsPage-BqfhR4Zc.js +1 -0
  2. package/admin/assets/AllContentPage-C11eeRMt.js +1 -0
  3. package/admin/assets/ApiKeysPage-DJjOSLoR.js +1 -0
  4. package/admin/assets/AuditPage-DJNk7IaW.js +1 -0
  5. package/admin/assets/{BlockEditor-uSyk_TPt.js → BlockEditor-DDsml97y.js} +54 -54
  6. package/admin/assets/BlockTypeEditPage-Cg7BifaZ.js +1 -0
  7. package/admin/assets/BlockTypesPage-BDFj8TSL.js +1 -0
  8. package/admin/assets/BulkActionBar-CastJGEP.js +1 -0
  9. package/admin/assets/CollectionEditPage-DGW4iMfo.js +1 -0
  10. package/admin/assets/CollectionsPage-C8XNxRda.js +1 -0
  11. package/admin/assets/ContentCreatePage-CX4aOzTR.js +1 -0
  12. package/admin/assets/ContentEditPage-Dj3RK2BF.js +2 -0
  13. package/admin/assets/ContentListPage-CoDanHrR.js +1 -0
  14. package/admin/assets/{CustomBlockPreview-ers8OdZ0.js → CustomBlockPreview-DfDOcbmR.js} +1 -1
  15. package/admin/assets/FieldBuilder-8VVLG_j0.js +3 -0
  16. package/admin/assets/FilterBar-JCp03kkK.js +1 -0
  17. package/admin/assets/{LoginPage-uxiw8K1J.js → LoginPage-gPNC9XRN.js} +1 -1
  18. package/admin/assets/MediaField-Du7_gRse.js +1 -0
  19. package/admin/assets/MediaPage-D9763lEk.js +1 -0
  20. package/admin/assets/RelationshipPicker-D7dFI43Q.js +1 -0
  21. package/admin/assets/SiteSettingsPage-Tfiex2yn.js +1 -0
  22. package/admin/assets/SiteUsersPage-CSV8syR3.js +1 -0
  23. package/admin/assets/SitesPage-BFIZ3Y5K.js +1 -0
  24. package/admin/assets/SubmissionDetailPage-8vtUQsLd.js +1 -0
  25. package/admin/assets/SubmissionEditPage-PgowJuvq.js +1 -0
  26. package/admin/assets/SubmissionListPage-HFDQxPhn.js +1 -0
  27. package/admin/assets/TagInput-CDkKZboX.js +1 -0
  28. package/admin/assets/TagsPage-BW15-W4H.js +1 -0
  29. package/admin/assets/UsersPage-C-zlDeTy.js +1 -0
  30. package/admin/assets/WebhookEditPage-cPPALIbH.js +1 -0
  31. package/admin/assets/WebhooksPage-vkPC4m9a.js +1 -0
  32. package/admin/assets/{card-C7fgQS_U.js → card-10FqkZPA.js} +1 -1
  33. package/admin/assets/checkbox-fC1QPb_4.js +1 -0
  34. package/admin/assets/collapsible-B414SspL.js +1 -0
  35. package/admin/assets/command-BeacdV75.js +1 -0
  36. package/admin/assets/{core.esm-DRuhixPo.js → core.esm-B_kcYf6n.js} +2 -2
  37. package/admin/assets/index-Do_SK4Zl.css +1 -0
  38. package/admin/assets/index-wYNPRVrc.js +18 -0
  39. package/admin/assets/media-url-DIg_vSyf.js +1 -0
  40. package/admin/assets/popover-BJDj8C6y.js +1 -0
  41. package/admin/assets/{radix-lA_IxTIV.js → radix-C1kb_NqW.js} +2 -2
  42. package/admin/assets/react-vendor-C2CvUxFh.js +4 -0
  43. package/admin/assets/select-BV3jemT6.js +1 -0
  44. package/admin/assets/serializeToText-BJy0Ms5I.js +2 -0
  45. package/admin/assets/sortable.esm-QyXA6fio.js +1 -0
  46. package/admin/assets/{table-BjSue8Ev.js → table-WkEcC9MH.js} +1 -1
  47. package/admin/assets/{tanstack-oFmRhGwV.js → tanstack-Bs3zYPPV.js} +1 -1
  48. package/admin/assets/textarea-CHQ9tT69.js +1 -0
  49. package/admin/assets/useAdminResolver-CpZj93vH.js +1 -0
  50. package/admin/assets/useContent-D8yDRTTy.js +1 -0
  51. package/admin/assets/useContentSearch-B-_p0_QX.js +1 -0
  52. package/admin/assets/{useDebouncedValue-DHUCnm9B.js → useDebouncedValue-C-cQUcLG.js} +1 -1
  53. package/admin/assets/useFilterParams-DYdEuWPE.js +1 -0
  54. package/admin/assets/useMedia-m6zKB__r.js +1 -0
  55. package/admin/assets/usePageTitle-Bwf-MpTD.js +1 -0
  56. package/admin/assets/useSiteUsers-QbiItSH1.js +1 -0
  57. package/admin/assets/{useTags-BuXf7_7H.js → useTags-CLPWVUB3.js} +1 -1
  58. package/admin/assets/{useWebhooks-Cx9tbBME.js → useWebhooks-no0l3-mF.js} +1 -1
  59. package/admin/favicon-16x16.png +0 -0
  60. package/admin/favicon-32x32.png +0 -0
  61. package/admin/index.html +8 -7
  62. package/admin/sw.js +1 -1
  63. package/dist/api.d.ts +1 -0
  64. package/dist/api.d.ts.map +1 -1
  65. package/dist/api.js +8 -0
  66. package/dist/api.js.map +1 -1
  67. package/dist/cdn.js +1 -1
  68. package/dist/cdn.js.map +1 -1
  69. package/dist/index.d.ts +3 -0
  70. package/dist/index.d.ts.map +1 -1
  71. package/dist/index.js +13 -2
  72. package/dist/index.js.map +1 -1
  73. package/dist/scheduler.d.ts +25 -0
  74. package/dist/scheduler.d.ts.map +1 -0
  75. package/dist/scheduler.js +64 -0
  76. package/dist/scheduler.js.map +1 -0
  77. package/dist/storage.d.ts +1 -0
  78. package/dist/storage.d.ts.map +1 -1
  79. package/dist/storage.js +16 -0
  80. package/dist/storage.js.map +1 -1
  81. package/lambda/api/bootstrap +0 -0
  82. package/lambda/image-lambda/index.mjs +1 -1
  83. package/lambda/webhook-worker/bootstrap +0 -0
  84. package/package.json +1 -1
  85. package/src/api.ts +9 -0
  86. package/src/cdn.ts +1 -1
  87. package/src/index.ts +17 -2
  88. package/src/scheduler.ts +83 -0
  89. package/src/sst-env.d.ts +4 -0
  90. package/src/storage.ts +17 -0
  91. package/admin/assets/AdminsPage-Cvqw6UOu.js +0 -1
  92. package/admin/assets/AllContentPage-Cnkt8Fgm.js +0 -1
  93. package/admin/assets/ApiKeysPage-FLex3Chc.js +0 -1
  94. package/admin/assets/AuditPage-ClgwR_8y.js +0 -1
  95. package/admin/assets/BlockTypeEditPage-Dr_yNLDI.js +0 -1
  96. package/admin/assets/BlockTypesPage-CwsGPuAZ.js +0 -1
  97. package/admin/assets/BulkActionBar-C-88Wnqw.js +0 -1
  98. package/admin/assets/CollectionEditPage-Cimkb84B.js +0 -1
  99. package/admin/assets/CollectionsPage-CxnSFPCH.js +0 -1
  100. package/admin/assets/ContentCreatePage-DZCyOcte.js +0 -1
  101. package/admin/assets/ContentEditPage-RtHbU_l4.js +0 -3
  102. package/admin/assets/ContentListPage-qFcZVzg9.js +0 -1
  103. package/admin/assets/FieldBuilder-Ds-agLm7.js +0 -3
  104. package/admin/assets/MediaPage-CeepVDHQ.js +0 -1
  105. package/admin/assets/SiteSettingsPage-xkngL15i.js +0 -1
  106. package/admin/assets/SitesPage-BD9tou9-.js +0 -1
  107. package/admin/assets/TagsPage-BxSwTLpQ.js +0 -1
  108. package/admin/assets/UsersPage-BayuQyLh.js +0 -1
  109. package/admin/assets/WebhookEditPage-BrXm8Dht.js +0 -1
  110. package/admin/assets/WebhooksPage-BUE6XuIP.js +0 -1
  111. package/admin/assets/badge-B8OxObuF.js +0 -1
  112. package/admin/assets/check-CxKAR64t.js +0 -1
  113. package/admin/assets/checkbox-BV2kjQBe.js +0 -1
  114. package/admin/assets/command-qGFnWxcS.js +0 -1
  115. package/admin/assets/copy-CgYzmj06.js +0 -1
  116. package/admin/assets/index-DX9xeoQx.js +0 -18
  117. package/admin/assets/index-PpbsYFRh.css +0 -1
  118. package/admin/assets/plus-HdRn2U0S.js +0 -1
  119. package/admin/assets/popover-Cou924mw.js +0 -1
  120. package/admin/assets/react-vendor-B0Dih9Pj.js +0 -4
  121. package/admin/assets/search-C-3Q9nn7.js +0 -1
  122. package/admin/assets/select-CHW5R8qv.js +0 -1
  123. package/admin/assets/sortable.esm-CBJBhe4k.js +0 -1
  124. package/admin/assets/trash-2-CWWRVuRB.js +0 -1
  125. package/admin/assets/use-mobile-C1r2eP64.js +0 -1
  126. package/admin/assets/useAdminResolver-D6B6RXnk.js +0 -1
  127. package/admin/assets/useContent-f19XHVlJ.js +0 -1
  128. package/admin/assets/useMedia-DkvP1QLG.js +0 -1
  129. package/admin/vite.svg +0 -1
@@ -1 +0,0 @@
1
- import{j as e}from"./tanstack-oFmRhGwV.js";import{r as u,R as S,L as kt,u as Dt}from"./react-vendor-B0Dih9Pj.js";import{F as St,l as Mt,m as Tt,n as _t,o as It,T as Pe,A as Oe,p as Rt,e as Ue,f as He,g as Le,h as Xe,i as Ye,j as Be,k as Ke,b as ct,q as At,r as zt,s as Et,E as $t,U as Ne,u as Ft,a as Pt,t as Ot,v as Ut,w as Ht}from"./useMedia-DkvP1QLG.js";import{o as L,w as O,M as dt,B as k,t as M,D as le,j as oe,k as ce,l as de,m as he,L as H,I as V,n as me,a as ee,X as pe,O as Lt,P as Xt,R as Yt,V as nt,z as Bt,A as Kt,E as Vt,S as Wt}from"./index-DX9xeoQx.js";import{C as qt,c as Qt}from"./card-C7fgQS_U.js";import{C as Te}from"./checkbox-BV2kjQBe.js";import{S as ge,a as fe,b as we,c as je,d as se,C as Gt,h as Zt}from"./select-CHW5R8qv.js";import{s as Jt,t as es,u as ts,v as ss,w as as,A as ns}from"./radix-lA_IxTIV.js";import{d as ht,G as rs,e as is,b as ls,u as os,a as cs,D as ds,f as hs,P as ms}from"./core.esm-DRuhixPo.js";import{b as ve,a as Ve,f as We}from"./format-C88SDH8g.js";import{m as W,u as us}from"./use-mobile-C1r2eP64.js";import{T as xs,a as ps,b as mt,c as B,d as gs,e as K}from"./table-BjSue8Ev.js";import{C as qe}from"./copy-CgYzmj06.js";import{B as Qe}from"./badge-B8OxObuF.js";import{T as fs}from"./trash-2-CWWRVuRB.js";import{P as ws}from"./plus-HdRn2U0S.js";import{C as js}from"./check-CxKAR64t.js";import{S as rt}from"./search-C-3Q9nn7.js";const vs=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],ys=L("chevron-left",vs);const bs=[["path",{d:"M6 2v14a2 2 0 0 0 2 2h14",key:"ron5a4"}],["path",{d:"M18 22V8a2 2 0 0 0-2-2H2",key:"7s9ehn"}]],Ns=L("crop",bs);const Cs=[["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"}]],ks=L("file-code",Cs);const Ds=[["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"}]],Ss=L("film",Ds);const Ms=[["path",{d:"m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2",key:"usdka0"}]],Ts=L("folder-open",Ms);const _s=[["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"}]],te=L("folder",_s);const Is=[["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"}]],Rs=L("layout-grid",Is);const As=[["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"}]],zs=L("list",As);const Es=[["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"}]],$s=L("maximize-2",Es);const Fs=[["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"}]],Ps=L("music",Fs);const Os=[["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"}]],Us=L("refresh-cw",Os);function Ce({delayDuration:a=0,...t}){return e.jsx(Jt,{"data-slot":"tooltip-provider",delayDuration:a,...t})}function ke({...a}){return e.jsx(es,{"data-slot":"tooltip",...a})}function De({...a}){return e.jsx(ts,{"data-slot":"tooltip-trigger",...a})}function Se({className:a,sideOffset:t=0,children:s,...l}){return e.jsx(ss,{children:e.jsxs(as,{"data-slot":"tooltip-content",sideOffset:t,className:O("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(ns,{className:"bg-foreground fill-foreground z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px]"})]})})}function _e({mimeType:a,className:t}){return a==="application/pdf"?e.jsx(dt,{className:O("text-blue-500",t)}):a.startsWith("video/")?e.jsx(Ss,{className:O("text-purple-500",t)}):a.startsWith("audio/")?e.jsx(Ps,{className:O("text-green-500",t)}):a==="image/svg+xml"?e.jsx(ks,{className:O("text-orange-500",t)}):e.jsx(St,{className:O("text-muted-foreground",t)})}function Hs(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 Ls({item:a,selected:t,onToggle:s,onSelect:l,onLightbox:n,folderName:r}){const{attributes:c,listeners:h,setNodeRef:o,isDragging:i}=ht({id:a.mediaId,data:{type:"media",mediaId:a.mediaId}}),x=a.mimeType.startsWith("image/")&&a.mimeType!=="image/svg+xml";return e.jsxs(mt,{ref:o,className:O("cursor-pointer",i&&"opacity-50"),onClick:l,children:[e.jsx(K,{onPointerDown:g=>g.stopPropagation(),onClick:g=>g.stopPropagation(),children:e.jsx(Te,{checked:t,onCheckedChange:s,"aria-label":`Select ${a.filename}`})}),e.jsx(K,{className:"w-6 p-1 hidden md:table-cell",children:e.jsx("div",{className:"cursor-grab text-muted-foreground",...c,...h,children:e.jsx(rs,{className:"h-4 w-4"})})}),e.jsx(K,{className:"p-1",children:x?e.jsx("img",{src:W(a.urls?.thumb_sm??a.url),alt:a.alt||a.filename,className:O("h-8 w-8 rounded object-cover",n&&"cursor-zoom-in"),onClick:n?g=>{g.stopPropagation(),n()}:void 0}):e.jsx("div",{className:"flex h-8 w-8 items-center justify-center",children:e.jsx(_e,{mimeType:a.mimeType,className:"h-5 w-5"})})}),e.jsxs(K,{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(K,{className:"hidden md:table-cell",children:e.jsx("span",{className:"text-muted-foreground text-xs",children:Hs(a.mimeType)})}),e.jsx(K,{className:"text-right",children:e.jsx("span",{className:"text-muted-foreground text-xs",children:ve(a.size)})}),e.jsx(K,{className:"hidden lg:table-cell",children:e.jsx("span",{className:"text-muted-foreground text-xs",children:a.width&&a.height?`${a.width}×${a.height}`:"—"})}),e.jsx(K,{className:"hidden lg:table-cell",children:a.tags.length>0&&e.jsxs("div",{className:"flex flex-wrap gap-1",children:[a.tags.slice(0,3).map(g=>e.jsx("span",{className:"bg-muted text-muted-foreground rounded px-1.5 py-0.5 text-[10px]",children:g},g)),a.tags.length>3&&e.jsxs("span",{className:"text-muted-foreground text-[10px]",children:["+",a.tags.length-3]})]})}),e.jsx(K,{className:"hidden md:table-cell",children:e.jsx(Ce,{children:e.jsxs(ke,{children:[e.jsx(De,{asChild:!0,children:e.jsx("span",{className:"text-muted-foreground text-xs",children:Ve(a.uploadedAt)})}),e.jsx(Se,{children:We(a.uploadedAt)})]})})}),e.jsx(K,{onPointerDown:g=>g.stopPropagation(),onClick:g=>g.stopPropagation(),children:e.jsx(k,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>{navigator.clipboard.writeText(W(a.url)),M.success("URL copied to clipboard")},children:e.jsx(qe,{className:"h-3.5 w-3.5"})})})]})}function Xs({items:a,host:t,onSelect:s,selectedIds:l,onToggle:n,onToggleAll:r,allSelected:c,onLightbox:h,folderMap:o}){return e.jsx("div",{className:"overflow-x-auto",children:e.jsxs(xs,{children:[e.jsx(ps,{children:e.jsxs(mt,{children:[e.jsx(B,{className:"w-10",children:e.jsx(Te,{checked:c,onCheckedChange:r,"aria-label":"Select all"})}),e.jsx(B,{className:"w-6 hidden md:table-cell"}),e.jsx(B,{className:"w-12"}),e.jsx(B,{children:"Filename"}),e.jsx(B,{className:"w-20 hidden md:table-cell",children:"Type"}),e.jsx(B,{className:"w-24 text-right",children:"Size"}),e.jsx(B,{className:"w-28 hidden lg:table-cell",children:"Dimensions"}),e.jsx(B,{className:"w-40 hidden lg:table-cell",children:"Tags"}),e.jsx(B,{className:"w-32 hidden md:table-cell",children:"Uploaded"}),e.jsx(B,{className:"w-10"})]})}),e.jsx(gs,{children:a.map(i=>e.jsx(Ls,{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 Ys=Object.defineProperty,Bs=(a,t,s)=>t in a?Ys(a,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):a[t]=s,T=(a,t,s)=>Bs(a,typeof t!="symbol"?t+"":t,s);const Me={x:0,y:0,width:0,height:0,unit:"px"},ne=(a,t,s)=>Math.min(Math.max(a,t),s),Ks=(...a)=>a.filter(t=>t&&typeof t=="string").join(" "),it=(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 re(a,t,s){return a.unit==="%"?{...Me,...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"?{...Me,...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}:{...Me,...a,unit:"px"}}function lt(a,t,s,l,n,r=0,c=0,h=l,o=n){const i={...a};let x=Math.min(r,l),g=Math.min(c,n),m=Math.min(h,l),d=Math.min(o,n);t&&(t>1?(x=c?c*t:x,g=x/t,m=h*t):(g=r?r/t:g,x=g*t,d=o/t)),i.y<0&&(i.height=Math.max(i.height+i.y,g),i.y=0),i.x<0&&(i.width=Math.max(i.width+i.x,x),i.x=0);const b=l-(i.x+i.width);b<0&&(i.x=Math.min(i.x,l-x),i.width+=b);const p=n-(i.y+i.height);if(p<0&&(i.y=Math.min(i.y,n-g),i.height+=p),i.width<x&&((s==="sw"||s=="nw")&&(i.x-=x-i.width),i.width=x),i.height<g&&((s==="nw"||s=="ne")&&(i.y-=g-i.height),i.height=g),i.width>m&&((s==="sw"||s=="nw")&&(i.x-=m-i.width),i.width=m),i.height>d&&((s==="nw"||s=="ne")&&(i.y-=d-i.height),i.height=d),t){const j=i.width/i.height;if(j<t){const w=Math.max(i.width/t,g);(s==="nw"||s=="ne")&&(i.y-=w-i.height),i.height=w}else if(j>t){const w=Math.max(i.height*t,x);(s==="sw"||s=="nw")&&(i.x-=w-i.width),i.width=w}}return i}function Vs(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 ie={capture:!0,passive:!1};let Ws=0;const Z=class U extends u.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",u.createRef()),T(this,"mediaRef",u.createRef()),T(this,"resizeObserver"),T(this,"initChangeCalled",!1),T(this,"instanceId",`rc-${Ws++}`),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 c=t.target.dataset.ord,h=!!c;let o=t.clientX,i=t.clientY,x=r.x,g=r.y;if(c){const m=t.clientX-n.x,d=t.clientY-n.y;let b=0,p=0;c==="ne"||c=="e"?(b=m-(r.x+r.width),p=d-r.y,x=r.x,g=r.y+r.height):c==="se"||c==="s"?(b=m-(r.x+r.width),p=d-(r.y+r.height),x=r.x,g=r.y):c==="sw"||c=="w"?(b=m-r.x,p=d-(r.y+r.height),x=r.x+r.width,g=r.y):(c==="nw"||c=="n")&&(b=m-r.x,p=d-r.y,x=r.x+r.width,g=r.y+r.height),o=x+n.x+b,i=g+n.y+p}this.evData={startClientX:o,startClientY:i,startCropX:x,startCropY:g,clientX:t.clientX,clientY:t.clientY,isResize:h,ord:c},this.mouseDownOnCrop=!0,this.setState({cropIsActive:!0})}),T(this,"onComponentPointerDown",t=>{const{crop:s,disabled:l,locked:n,keepSelection:r,onChange:c}=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,x={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,c(G(x,h.width,h.height),re(x,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,c=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(),it(s,o)||n(G(o,c.width,c.height),re(o,c.width,c.height))}),T(this,"onComponentKeyDown",t=>{const{crop:s,disabled:l,onChange:n,onComplete:r}=this.props;if(l)return;const c=t.key;let h=!1;if(!s)return;const o=this.getBox(),i=this.makePixelCrop(o),x=(navigator.platform.match("Mac")?t.metaKey:t.ctrlKey)?U.nudgeStepLarge:t.shiftKey?U.nudgeStepMedium:U.nudgeStep;if(c==="ArrowLeft"?(i.x-=x,h=!0):c==="ArrowRight"?(i.x+=x,h=!0):c==="ArrowUp"?(i.y-=x,h=!0):c==="ArrowDown"&&(i.y+=x,h=!0),h){t.cancelable&&t.preventDefault(),i.x=ne(i.x,0,o.width-i.width),i.y=ne(i.y,0,o.height-i.height);const g=G(i,o.width,o.height),m=re(i,o.width,o.height);n(g,m),r&&r(g,m)}}),T(this,"onHandlerKeyDown",(t,s)=>{const{aspect:l=0,crop:n,disabled:r,minWidth:c=0,minHeight:h=0,maxWidth:o,maxHeight:i,onChange:x,onComplete:g}=this.props,m=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 d=(navigator.platform.match("Mac")?t.metaKey:t.ctrlKey)?U.nudgeStepLarge:t.shiftKey?U.nudgeStepMedium:U.nudgeStep,b=G(n,m.width,m.height),p=Vs(b,t.key,d,s),j=lt(p,l,s,m.width,m.height,c,h,o,i);if(!it(n,j)){const w=re(j,m.width,m.height);x(j,w),g&&g(j,w)}}),T(this,"onDocPointerDone",t=>{const{crop:s,disabled:l,onComplete:n,onDragEnd:r}=this.props,c=this.getBox();this.unbindDocMove(),!(l||!s)&&this.mouseDownOnCrop&&(this.mouseDownOnCrop=!1,this.dragStarted=!1,r&&r(t),n&&n(G(s,c.width,c.height),re(s,c.width,c.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),re(s,n,r))}}componentWillUnmount(){this.resizeObserver&&this.resizeObserver.disconnect(),this.unbindDocMove()}bindDocMove(){this.docMoveBound||(this.document.addEventListener("pointermove",this.onDocPointerMove,ie),this.document.addEventListener("pointerup",this.onDocPointerDone,ie),this.document.addEventListener("pointercancel",this.onDocPointerDone,ie),this.docMoveBound=!0)}unbindDocMove(){this.docMoveBound&&(this.document.removeEventListener("pointermove",this.onDocPointerMove,ie),this.document.removeEventListener("pointerup",this.onDocPointerDone,ie),this.document.removeEventListener("pointercancel",this.onDocPointerDone,ie),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=ne(t.startCropX+n,0,s.width-l.width),l.y=ne(t.startCropY+r,0,s.height-l.height),l}getPointRegion(t,s,l,n){const{evData:r}=this,c=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=c<r.startCropX,i?o?"nw":"sw":o?"ne":"se"}resolveMinDimensions(t,s,l=0,n=0){const r=Math.min(l,t.width),c=Math.min(n,t.height);return!s||!r&&!c?[r,c]:s>1?r?[r,r/s]:[c*s,c]:c?[c*s,c]:[r,r/s]}resizeCrop(){const{evData:t}=this,{aspect:s=0,maxWidth:l,maxHeight:n}=this.props,r=this.getBox(),[c,h]=this.resolveMinDimensions(r,s,this.props.minWidth,this.props.minHeight);let o=this.makePixelCrop(r);const i=this.getPointRegion(r,t.ord,c,h),x=t.ord||i;let g=t.clientX-t.startClientX,m=t.clientY-t.startClientY;(c&&x==="nw"||x==="w"||x==="sw")&&(g=Math.min(g,-c)),(h&&x==="nw"||x==="n"||x==="ne")&&(m=Math.min(m,-h));const d={unit:"px",x:0,y:0,width:0,height:0};i==="ne"?(d.x=t.startCropX,d.width=g,s?(d.height=d.width/s,d.y=t.startCropY-d.height):(d.height=Math.abs(m),d.y=t.startCropY-d.height)):i==="se"?(d.x=t.startCropX,d.y=t.startCropY,d.width=g,s?d.height=d.width/s:d.height=m):i==="sw"?(d.x=t.startCropX+g,d.y=t.startCropY,d.width=Math.abs(g),s?d.height=d.width/s:d.height=m):i==="nw"&&(d.x=t.startCropX+g,d.width=Math.abs(g),s?(d.height=d.width/s,d.y=t.startCropY-d.height):(d.height=Math.abs(m),d.y=t.startCropY+m));const b=lt(d,s,i,r.width,r.height,c,h,l,n);return s||U.xyOrds.indexOf(x)>-1?o=b:U.xOrds.indexOf(x)>-1?(o.x=b.x,o.width=b.width):U.yOrds.indexOf(x)>-1&&(o.y=b.y,o.height=b.height),o.x=ne(o.x,0,r.width-o.width),o.y=ne(o.y,0,r.height-o.height),o}renderCropSelection(){const{ariaLabels:t=U.defaultProps.ariaLabels,disabled:s,locked:l,renderSelectionAddon:n,ruleOfThirds:r,crop:c}=this.props,h=this.getCropStyle();if(c)return S.createElement("div",{style:h,className:"ReactCrop__crop-selection",onPointerDown:this.onCropPointerDown,"aria-label":t.cropArea,tabIndex:0,onKeyDown:this.onComponentKeyDown,role:"group"},!s&&!l&&S.createElement("div",{className:"ReactCrop__drag-elements",onFocus:this.onDragFocus},S.createElement("div",{className:"ReactCrop__drag-bar ord-n","data-ord":"n"}),S.createElement("div",{className:"ReactCrop__drag-bar ord-e","data-ord":"e"}),S.createElement("div",{className:"ReactCrop__drag-bar ord-s","data-ord":"s"}),S.createElement("div",{className:"ReactCrop__drag-bar ord-w","data-ord":"w"}),S.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"}),S.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"}),S.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"}),S.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"}),S.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"}),S.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"}),S.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"}),S.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&&S.createElement("div",{className:"ReactCrop__selection-addon",onPointerDown:o=>o.stopPropagation()},n(this.state)),r&&S.createElement(S.Fragment,null,S.createElement("div",{className:"ReactCrop__rule-of-thirds-hz"}),S.createElement("div",{className:"ReactCrop__rule-of-thirds-vt"})))}makePixelCrop(t){const s={...Me,...this.props.crop||{}};return G(s,t.width,t.height)}render(){const{aspect:t,children:s,circularCrop:l,className:n,crop:r,disabled:c,locked:h,style:o,ruleOfThirds:i}=this.props,{cropIsActive:x,newCropIsBeingDrawn:g}=this.state,m=r?this.renderCropSelection():null,d=Ks("ReactCrop",n,x&&"ReactCrop--active",c&&"ReactCrop--disabled",h&&"ReactCrop--locked",g&&"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 S.createElement("div",{ref:this.componentRef,className:d,style:o},S.createElement("div",{ref:this.mediaRef,className:"ReactCrop__child-wrapper",onPointerDown:this.onComponentPointerDown},s),r?S.createElement("svg",{className:"ReactCrop__crop-mask",width:"100%",height:"100%"},S.createElement("defs",null,S.createElement("mask",{id:`hole-${this.instanceId}`},S.createElement("rect",{width:"100%",height:"100%",fill:"white"}),l?S.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"}):S.createElement("rect",{x:`${r.x}${r.unit}`,y:`${r.y}${r.unit}`,width:`${r.width}${r.unit}`,height:`${r.height}${r.unit}`,fill:"black"}))),S.createElement("rect",{fill:"black",fillOpacity:.5,width:"100%",height:"100%",mask:`url(#hole-${this.instanceId})`})):void 0,m)}};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 qs=Z;const Qs=[{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"}],ut=[{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"}],Gs={"image/jpeg":".jpg","image/png":".png","image/gif":".gif","image/webp":".webp","image/avif":".avif","image/tiff":".tiff"};function $e(a,t){return a?ut.find(s=>s.value===a)?.ext||`.${a}`:Gs[t]||".jpg"}function Zs(a,t){const s=a.lastIndexOf(".");return(s>0?a.substring(0,s):a)+t}function Js({host:a,media:t,onClose:s,onSaved:l}){const n=u.useRef(null),[r,c]=u.useState(),[h,o]=u.useState(),[i,x]=u.useState(""),[g,m]=u.useState(""),[d,b]=u.useState(""),[p,j]=u.useState(""),[w,A]=u.useState("80"),[_,I]=u.useState(()=>{const v=$e("",t.mimeType),R=t.filename.lastIndexOf(".");return`${R>0?t.filename.substring(0,R):t.filename}-transformed${v}`});function E(v){const R=v==="__original__"?"":v;j(R);const q=$e(R,t.mimeType);I(ae=>Zs(ae,q))}const F=Mt(a,t.mediaId),[y,N]=u.useState(null),P=u.useCallback(()=>{if(!h||!y)return null;const v=(t.width??y.width)/y.width,R=(t.height??y.height)/y.height;return{cropX:Math.round(h.x*v),cropY:Math.round(h.y*R),cropW:Math.round(h.width*v),cropH:Math.round(h.height*R)}},[h,t.width,t.height,y]),X=u.useMemo(()=>P(),[P]);async function ue(){const v=X,R=g?parseInt(g):void 0,q=d?parseInt(d):void 0;if(!v&&!R&&!q&&!p){M.error("Please specify a crop, resize, or format change");return}if(!_.trim()){M.error("Filename is required");return}const ae=$e(p,t.mimeType);if(!_.trim().toLowerCase().endsWith(ae)){M.error(`Filename must end with ${ae} to match the output format`);return}try{const $=await F.mutateAsync({...v??{},...R?{width:R}:{},...q?{height:q}:{},...p?{format:p}:{},...w?{quality:parseInt(w)}:{},filename:_.trim()});M.success("Transform saved as new media"),l?.($),s()}catch($){M.error("Transform failed",{description:$ instanceof Error?$.message:void 0})}}function J(v){x(v==="__free__"?"":v),c(void 0),o(void 0)}function Ge(v){if(!v)return;const R=v.split("/");return R.length===2?Number(R[0])/Number(R[1]):Number(v)||void 0}const xe=Ge(i);return e.jsx(le,{open:!0,onOpenChange:()=>s(),children:e.jsxs(oe,{className:"max-w-4xl max-h-[90vh] overflow-y-auto",children:[e.jsxs(ce,{children:[e.jsx(de,{children:"Transform Image"}),e.jsx(he,{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(qs,{crop:r,onChange:v=>c(v),onComplete:v=>o(v),aspect:xe,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:v=>{const R=v.currentTarget;N({width:R.naturalWidth,height:R.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(H,{children:"Crop aspect ratio"}),e.jsxs(ge,{value:i||"__free__",onValueChange:J,children:[e.jsx(fe,{children:e.jsx(we,{placeholder:"Free"})}),e.jsx(je,{children:Qs.map(v=>e.jsx(se,{value:v.value||"__free__",children:v.label},v.value||"__free__"))})]}),h&&e.jsxs("div",{className:"text-xs text-muted-foreground",children:["Crop: ",X?.cropW,"×",X?.cropH," at (",X?.cropX,", ",X?.cropY,")"]}),h&&e.jsx(k,{variant:"ghost",size:"sm",onClick:()=>{c(void 0),o(void 0)},children:"Clear crop"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(H,{children:"Resize (optional)"}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsx("div",{children:e.jsx(V,{type:"number",placeholder:"Width",value:g,onChange:v=>m(v.target.value),min:1,max:2048})}),e.jsx("div",{children:e.jsx(V,{type:"number",placeholder:"Height",value:d,onChange:v=>b(v.target.value),min:1,max:2048})})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(H,{children:"Output format"}),e.jsxs(ge,{value:p||"__original__",onValueChange:E,children:[e.jsx(fe,{children:e.jsx(we,{placeholder:"Original"})}),e.jsx(je,{children:ut.map(v=>e.jsx(se,{value:v.value||"__original__",children:v.label},v.value||"__original__"))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(H,{children:"Quality (1-100)"}),e.jsx(V,{type:"number",value:w,onChange:v=>A(v.target.value),min:1,max:100})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(H,{children:"Save as filename"}),e.jsx(V,{value:_,onChange:v=>I(v.target.value)})]})]})]}),e.jsxs(me,{children:[e.jsx(k,{variant:"outline",onClick:s,children:"Cancel"}),e.jsxs(k,{onClick:ue,disabled:F.isPending,children:[F.isPending&&e.jsx(ee,{className:"mr-2 h-4 w-4 animate-spin"}),"Save as New Image"]})]})]})})}const ea=new Set(["image/jpeg","image/png","image/gif","image/webp","image/avif","image/tiff"]);function ta({host:a,media:t,onClose:s,onDeleted:l,folders:n,tagSuggestions:r}){const[c,h]=u.useState(t.alt??""),[o,i]=u.useState(t.caption??""),[x,g]=u.useState(t.userTags??[]),[m,d]=u.useState(t.folderId||"__none__"),[b,p]=u.useState(!1),j=ea.has(t.mimeType),w=Tt(a,t.mediaId),A=_t(a,t.mediaId),{data:_,isLoading:I}=It(a,t.mediaId),E=t.tags.filter(N=>!t.userTags?.includes(N));async function F(){try{await w.mutateAsync({alt:c,caption:o,userTags:x,folderId:m==="__none__"?"":m}),M.success("Media updated"),s()}catch(N){M.error("Failed to update",{description:N instanceof Error?N.message:void 0})}}async function y(){try{await A.mutateAsync(),M.success("Media deleted"),l?.(t.mediaId),s()}catch(N){M.error("Failed to delete",{description:N instanceof Error?N.message:void 0})}}return e.jsxs(le,{open:!0,onOpenChange:()=>s(),children:[e.jsxs(oe,{children:[e.jsxs(ce,{children:[e.jsx(de,{children:t.filename}),e.jsx(he,{className:"sr-only",children:"View and edit media details"})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"text-muted-foreground text-sm",children:[t.mimeType," · ",ve(t.size),t.width&&t.height&&` · ${t.width}×${t.height}`," · ",We(t.uploadedAt)]}),e.jsxs("div",{className:"flex gap-2",children:[j&&e.jsxs(k,{variant:"outline",size:"sm",onClick:()=>p(!0),children:[e.jsx(Ns,{className:"mr-1.5 h-3.5 w-3.5"}),"Transform"]}),e.jsxs(k,{variant:"outline",size:"sm",onClick:()=>{navigator.clipboard.writeText(W(t.url)),M.success("URL copied to clipboard")},children:[e.jsx(qe,{className:"mr-1.5 h-3.5 w-3.5"}),"Copy URL"]})]})]}),E.length>0&&e.jsxs("div",{className:"space-y-1",children:[e.jsx(H,{className:"text-xs text-muted-foreground",children:"Auto-detected tags"}),e.jsx("div",{className:"flex flex-wrap gap-1",children:E.map(N=>e.jsx(Qe,{variant:"outline",className:"text-xs",children:N},N))})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(H,{children:"Tags"}),e.jsx(Pe,{tags:x,onChange:g,placeholder:"Add tags...",suggestions:r})]}),n&&n.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(H,{children:"Folder"}),e.jsxs(ge,{value:m,onValueChange:d,children:[e.jsx(fe,{children:e.jsx(we,{placeholder:"No folder"})}),e.jsxs(je,{children:[e.jsx(se,{value:"__none__",children:"No folder"}),n.map(N=>e.jsx(se,{value:N.folderId,children:N.name},N.folderId))]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(H,{htmlFor:"alt",children:"Alt text"}),e.jsx(V,{id:"alt",value:c,onChange:N=>h(N.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(H,{htmlFor:"caption",children:"Caption"}),e.jsx(V,{id:"caption",value:o,onChange:N=>i(N.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(H,{className:"text-xs text-muted-foreground",children:"Used in"}),I?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(N=>e.jsxs(kt,{to:`/sites/${a}/content/${N.collection}/${N.contentId}`,className:"flex items-center gap-2 rounded px-2 py-1 text-sm hover:bg-muted",onClick:s,children:[e.jsx(dt,{className:"h-3.5 w-3.5 text-muted-foreground"}),e.jsx("span",{className:"truncate",children:N.title||N.contentId}),e.jsxs("span",{className:"text-muted-foreground text-xs",children:["(",N.collection,")"]})]},N.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(me,{className:"flex justify-between",children:[e.jsxs(Oe,{children:[e.jsx(Rt,{asChild:!0,children:e.jsxs(k,{variant:"destructive",size:"sm",children:[e.jsx(fs,{className:"mr-2 h-4 w-4"}),"Delete"]})}),e.jsxs(Ue,{children:[e.jsxs(He,{children:[e.jsx(Le,{children:"Delete media?"}),e.jsxs(Xe,{children:["This will permanently delete “",t.filename,"”. This action cannot be undone."]})]}),e.jsxs(Ye,{children:[e.jsx(Be,{children:"Cancel"}),e.jsx(Ke,{onClick:y,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete"})]})]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(k,{variant:"outline",onClick:s,children:"Cancel"}),e.jsx(k,{onClick:F,children:"Save"})]})]})]}),b&&e.jsx(Js,{host:a,media:t,onClose:()=>p(!1),onSaved:()=>s()})]})}function sa({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(Qe,{variant:t===l?"default":"secondary",className:"cursor-pointer select-none",onClick:()=>s(t===l?void 0:l),children:l},l)),t&&e.jsxs(k,{variant:"ghost",size:"sm",className:"h-6 px-2 text-xs",onClick:()=>s(void 0),children:[e.jsx(pe,{className:"mr-1 h-3 w-3"}),"Clear"]})]})}function Fe({id:a,children:t}){const{setNodeRef:s,isOver:l}=is({id:a,data:{type:"folder"}});return e.jsx("div",{ref:s,children:t(l)})}function ot({host:a,selectedFolderId:t,onSelect:s}){const{data:l}=ct(a),n=At(a),r=zt(a),c=Et(a),[h,o]=u.useState(!1),[i,x]=u.useState(""),[g,m]=u.useState(null),[d,b]=u.useState(""),[p,j]=u.useState(null),w=u.useRef(null),A=u.useRef(null),_=l?.items??[];u.useEffect(()=>{h&&w.current?.focus()},[h]),u.useEffect(()=>{g&&A.current?.focus()},[g]);async function I(){const y=i.trim();if(!y){o(!1),x("");return}try{await n.mutateAsync(y),M.success("Folder created")}catch(N){M.error("Failed to create folder",{description:N instanceof Error?N.message:void 0})}o(!1),x("")}async function E(y){const N=d.trim();if(!N){m(null);return}try{await r.mutateAsync({folderId:y,name:N}),M.success("Folder renamed")}catch(P){M.error("Failed to rename folder",{description:P instanceof Error?P.message:void 0})}m(null)}async function F(){if(p){try{await c.mutateAsync(p.folderId),M.success("Folder deleted"),t===p.folderId&&s(null)}catch(y){M.error("Failed to delete folder",{description:y instanceof Error?y.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(k,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0",onClick:()=>o(!0),children:e.jsx(ws,{className:"h-4 w-4"})})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto py-1",children:[e.jsx(Fe,{id:"all-media",children:y=>e.jsx("button",{className:O("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",y&&"ring-2 ring-primary bg-primary/10"),onClick:()=>s(null),children:e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(te,{className:"h-4 w-4"}),"All Media"]})})}),_.map(y=>e.jsx(Fe,{id:y.folderId,children:N=>e.jsx("div",{className:O("group flex w-full items-center justify-between px-3 py-1.5 text-sm hover:bg-accent/50",t===y.folderId&&"bg-accent font-medium",N&&"ring-2 ring-primary bg-primary/10"),children:g===y.folderId?e.jsx(V,{ref:A,value:d,onChange:P=>b(P.target.value),onKeyDown:P=>{P.key==="Enter"&&E(y.folderId),P.key==="Escape"&&m(null)},onBlur:()=>E(y.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(y.folderId),children:[e.jsx(te,{className:"h-4 w-4 shrink-0"}),e.jsx("span",{className:"truncate",children:y.name})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"text-muted-foreground text-xs",children:y.count}),e.jsxs(Lt,{children:[e.jsx(Xt,{asChild:!0,children:e.jsx(k,{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(Yt,{align:"end",children:[e.jsx(nt,{onClick:()=>{m(y.folderId),b(y.name)},children:"Rename"}),e.jsx(nt,{disabled:y.count>0,onClick:()=>j(y),children:"Delete"})]})]})]})]})})},y.folderId)),e.jsx(Fe,{id:"unfiled",children:y=>e.jsx("button",{className:O("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",y&&"ring-2 ring-primary bg-primary/10"),onClick:()=>s("unfiled"),children:e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(te,{className:"h-4 w-4"}),"Unfiled"]})})}),h&&e.jsx("div",{className:"px-3 py-1.5",children:e.jsx(V,{ref:w,value:i,onChange:y=>x(y.target.value),onKeyDown:y=>{y.key==="Enter"&&I(),y.key==="Escape"&&(o(!1),x(""))},onBlur:I,placeholder:"Folder name...",className:"h-7 text-sm"})})]}),e.jsx(Oe,{open:!!p,onOpenChange:()=>j(null),children:e.jsxs(Ue,{children:[e.jsxs(He,{children:[e.jsx(Le,{children:"Delete folder?"}),e.jsxs(Xe,{children:["This will delete the folder “",p?.name,"”. Media items in this folder will become unfiled."]})]}),e.jsxs(Ye,{children:[e.jsx(Be,{children:"Cancel"}),e.jsx(Ke,{onClick:F,children:"Delete"})]})]})})]})}function aa({selectedCount:a,folders:t,onDelete:s,onMove:l,onAddTags:n,onRemoveTags:r,onClear:c,isPending:h}){const[o,i]=u.useState(null),[x,g]=u.useState(""),[m,d]=u.useState([]);function b(){i(null),g(""),d([])}return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"mb-4 min-w-0",children:[e.jsxs("div",{className:"mb-1 flex items-center justify-between",children:[e.jsxs("span",{className:"text-sm font-medium",children:[a," selected"]}),e.jsx(k,{size:"sm",variant:"ghost",onClick:c,disabled:h,children:e.jsx(pe,{className:"h-4 w-4"})})]}),e.jsxs("div",{className:"flex items-center gap-2 overflow-x-auto rounded-md border bg-muted/50 px-3 py-2 max-w-[calc(100vw-1.5rem)]",children:[e.jsx(k,{size:"sm",variant:"destructive",onClick:()=>i("delete"),disabled:h,className:"shrink-0",children:"Delete"}),e.jsx(k,{size:"sm",variant:"outline",onClick:()=>i("move"),disabled:h,className:"shrink-0",children:"Move to…"}),e.jsx(k,{size:"sm",variant:"outline",onClick:()=>i("addTags"),disabled:h,className:"shrink-0",children:"Add tags"}),e.jsx(k,{size:"sm",variant:"outline",onClick:()=>i("removeTags"),disabled:h,className:"shrink-0",children:"Remove tags"})]})]}),e.jsx(le,{open:o==="delete",onOpenChange:p=>!p&&b(),children:e.jsxs(oe,{children:[e.jsxs(ce,{children:[e.jsxs(de,{children:["Delete ",a," item",a!==1?"s":"","?"]}),e.jsx(he,{children:"This action cannot be undone. The selected media items will be permanently deleted."})]}),e.jsxs(me,{children:[e.jsx(k,{variant:"outline",onClick:b,children:"Cancel"}),e.jsxs(k,{variant:"destructive",onClick:async()=>{b(),await s()},disabled:h,children:[h&&e.jsx(ee,{className:"mr-1 h-3 w-3 animate-spin"}),"Delete"]})]})]})}),e.jsx(le,{open:o==="move",onOpenChange:p=>!p&&b(),children:e.jsxs(oe,{children:[e.jsxs(ce,{children:[e.jsxs(de,{children:["Move ",a," item",a!==1?"s":""]}),e.jsx(he,{children:"Choose a destination folder."})]}),e.jsxs(ge,{value:x,onValueChange:g,children:[e.jsx(fe,{children:e.jsx(we,{placeholder:"Select folder..."})}),e.jsxs(je,{children:[e.jsx(se,{value:"__unfiled__",children:"Unfiled"}),t.map(p=>e.jsx(se,{value:p.folderId,children:p.name},p.folderId))]})]}),e.jsxs(me,{children:[e.jsx(k,{variant:"outline",onClick:b,children:"Cancel"}),e.jsxs(k,{onClick:async()=>{const p=x==="__unfiled__"?"":x;b(),await l(p)},disabled:!x||h,children:[h&&e.jsx(ee,{className:"mr-1 h-3 w-3 animate-spin"}),"Move"]})]})]})}),e.jsx(le,{open:o==="addTags",onOpenChange:p=>!p&&b(),children:e.jsxs(oe,{children:[e.jsxs(ce,{children:[e.jsxs(de,{children:["Add tags to ",a," item",a!==1?"s":""]}),e.jsx(he,{className:"sr-only",children:"Select tags to add to the selected items"})]}),e.jsx(Pe,{tags:m,onChange:d,placeholder:"Add tags..."}),e.jsxs(me,{children:[e.jsx(k,{variant:"outline",onClick:b,children:"Cancel"}),e.jsxs(k,{onClick:async()=>{const p=[...m];b(),await n(p)},disabled:m.length===0||h,children:[h&&e.jsx(ee,{className:"mr-1 h-3 w-3 animate-spin"}),"Add"]})]})]})}),e.jsx(le,{open:o==="removeTags",onOpenChange:p=>!p&&b(),children:e.jsxs(oe,{children:[e.jsxs(ce,{children:[e.jsxs(de,{children:["Remove tags from ",a," item",a!==1?"s":""]}),e.jsx(he,{className:"sr-only",children:"Select tags to remove from the selected items"})]}),e.jsx(Pe,{tags:m,onChange:d,placeholder:"Tags to remove..."}),e.jsxs(me,{children:[e.jsx(k,{variant:"outline",onClick:b,children:"Cancel"}),e.jsxs(k,{onClick:async()=>{const p=[...m];b(),await r(p)},disabled:m.length===0||h,children:[h&&e.jsx(ee,{className:"mr-1 h-3 w-3 animate-spin"}),"Remove"]})]})]})})]})}function na({onFiles:a,children:t}){const[s,l]=u.useState(!1),n=u.useRef(0),r=u.useCallback(i=>{i.preventDefault(),i.dataTransfer.types.includes("Files")&&(n.current++,l(!0))},[]),c=u.useCallback(i=>{i.preventDefault(),n.current--,n.current===0&&l(!1)},[]),h=u.useCallback(i=>{i.preventDefault(),i.dataTransfer.dropEffect="copy"},[]),o=u.useCallback(i=>{i.preventDefault(),n.current=0,l(!1);const x=Array.from(i.dataTransfer.files);x.length>0&&a(x)},[a]);return e.jsxs("div",{className:"relative flex-1",onDragEnter:r,onDragLeave:c,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(Ne,{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 ra({queue:a}){const{items:t,retry:s,dismiss:l,clearCompleted:n}=a,[r,c]=u.useState(!1),h=t.filter(d=>d.status==="uploading").length,o=t.filter(d=>d.status==="pending").length,i=t.filter(d=>d.status==="complete").length,x=t.filter(d=>d.status==="error").length,g=h===0&&o===0;if(u.useEffect(()=>{if(g&&t.length>0){const d=setTimeout(()=>c(!0),2e3);return()=>clearTimeout(d)}},[g,t.length]),t.length===0)return null;const m=g?`${i} uploaded${x?`, ${x} 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:m}),e.jsxs("div",{className:"flex items-center gap-1",children:[g&&e.jsx(k,{variant:"ghost",size:"sm",className:"h-6 px-2 text-xs",onClick:n,children:"Clear"}),e.jsx(k,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0",onClick:()=>c(!r),children:r?e.jsx(Gt,{className:"h-4 w-4"}):e.jsx(Zt,{className:"h-4 w-4"})})]})]}),!r&&e.jsx("div",{className:"max-h-60 overflow-y-auto",children:t.map(d=>e.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 text-sm",children:[d.status==="uploading"&&e.jsx(ee,{className:"h-4 w-4 shrink-0 animate-spin"}),d.status==="complete"&&e.jsx(js,{className:"h-4 w-4 shrink-0 text-green-500"}),d.status==="error"&&e.jsx(pe,{className:"h-4 w-4 shrink-0 text-destructive"}),d.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:d.file.name}),d.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:`${d.progress}%`}})}),d.status==="error"&&e.jsx("p",{className:"text-destructive truncate text-xs",children:d.error})]}),d.status==="error"&&e.jsx(k,{variant:"ghost",size:"sm",className:"h-6 w-6 shrink-0 p-0",onClick:()=>s(d.id),children:e.jsx(Us,{className:"h-3 w-3"})}),(d.status==="complete"||d.status==="error")&&e.jsx(k,{variant:"ghost",size:"sm",className:"h-6 w-6 shrink-0 p-0",onClick:()=>l(d.id),children:e.jsx(pe,{className:"h-3 w-3"})})]},d.id))})]})}const ia=3;let la=0;function oa(a,t){const[s,l]=u.useState([]),n=Ft(a),r=Pt(a),c=u.useRef(0),h=u.useRef(s);h.current=s;const o=u.useRef(new Map),i=u.useCallback(async p=>{c.current++,l(j=>j.map(w=>w.id===p.id?{...w,status:"uploading",progress:0}:w));try{const{uploadUrl:j,mediaId:w}=await n.mutateAsync({filename:p.file.name,contentType:p.file.type,size:p.file.size});await new Promise((A,_)=>{const I=new XMLHttpRequest;o.current.set(p.id,I),I.upload.onprogress=E=>{if(E.lengthComputable){const F=Math.round(E.loaded/E.total*100);l(y=>y.map(N=>N.id===p.id?{...N,progress:F}:N))}},I.onload=()=>{o.current.delete(p.id),I.status>=200&&I.status<300?A():_(new Error(`Upload failed: ${I.status}`))},I.onerror=()=>{o.current.delete(p.id),_(new Error("Network error"))},I.onabort=()=>{o.current.delete(p.id),_(new Error("Upload aborted"))},I.open("PUT",j),I.setRequestHeader("Content-Type",p.file.type),I.send(p.file)}),await r.mutateAsync({mediaId:w,filename:p.file.name,folderId:p.folderId}),l(A=>A.map(_=>_.id===p.id?{..._,status:"complete",progress:100}:_))}catch(j){l(w=>w.map(A=>A.id===p.id?{...A,status:"error",error:j instanceof Error?j.message:"Upload failed"}:A))}finally{c.current--}},[n,r]),x=u.useRef(i);x.current=i,u.useEffect(()=>{const p=s.filter(w=>w.status==="pending"),j=ia-c.current;for(let w=0;w<Math.min(p.length,j);w++)x.current(p[w])},[s]),u.useEffect(()=>{const p=o.current;return()=>{p.forEach(j=>j.abort())}},[]);const g=u.useCallback(p=>{const j=Array.from(p).map(w=>({id:`upload-${la++}`,file:w,folderId:t||void 0,status:"pending",progress:0}));l(w=>[...w,...j])},[t]),m=u.useCallback(p=>{l(j=>j.map(w=>w.id===p?{...w,status:"pending",progress:0,error:void 0}:w))},[]),d=u.useCallback(p=>{l(j=>j.filter(w=>w.id!==p))},[]),b=u.useCallback(()=>{l(p=>p.filter(j=>j.status!=="complete"&&j.status!=="error"))},[]);return{items:s,addFiles:g,retry:m,dismiss:d,clearCompleted:b}}function ca({items:a,currentIndex:t,onClose:s,onNavigate:l}){const n=a[t],r=t>0,c=t<a.length-1,h=u.useRef(null),o=u.useCallback(i=>{i.key==="Escape"?s():i.key==="ArrowLeft"&&r?l(t-1):i.key==="ArrowRight"&&c&&l(t+1)},[s,l,t,r,c]);return u.useEffect(()=>(document.addEventListener("keydown",o),document.body.style.overflow="hidden",()=>{document.removeEventListener("keydown",o),document.body.style.overflow=""}),[o]),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:i=>i.stopPropagation(),children:[e.jsxs("div",{className:"min-w-0 flex-1 text-sm",children:[e.jsx("span",{className:"font-medium truncate block",children:n.filename}),e.jsxs("span",{className:"opacity-70 text-xs",children:[n.width&&n.height&&`${n.width}×${n.height} · `,ve(n.size)]})]}),e.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[e.jsxs("span",{className:"text-sm opacity-70",children:[t+1," / ",a.length]}),e.jsx(k,{variant:"ghost",size:"icon",className:"text-white hover:bg-white/20",onClick:s,children:e.jsx(pe,{className:"h-5 w-5"})})]})]}),e.jsxs("div",{className:"relative flex flex-1 items-center justify-center px-4 md:px-16",onClick:i=>i.stopPropagation(),onTouchStart:i=>{h.current=i.touches[0].clientX},onTouchEnd:i=>{if(h.current===null)return;const x=i.changedTouches[0].clientX-h.current;h.current=null,x>50&&r?l(t-1):x<-50&&c&&l(t+1)},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(k,{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(ys,{className:"h-8 w-8"})}),c&&e.jsx(k,{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(ls,{className:"h-8 w-8"})})]})]}):null}function da({open:a,duplicates:t,fileCount:s,onContinue:l,onCancel:n}){return e.jsx(Oe,{open:a,onOpenChange:r=>!r&&n(),children:e.jsxs(Ue,{children:[e.jsxs(He,{children:[e.jsx(Le,{children:"Possible duplicates found"}),e.jsx(Xe,{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(_e,{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:[ve(r.size)," ·"," ",Ve(r.uploadedAt)]})]})]},r.mediaId))}),e.jsxs(Ye,{children:[e.jsx(Be,{onClick:n,children:"Cancel"}),e.jsx(Ke,{onClick:l,children:"Upload Anyway"})]})]})})}function ha(a){const[t,s]=u.useState(()=>{try{const n=localStorage.getItem(`viewMode:${a}`);if(n==="grid"||n==="list")return n}catch{}return"grid"}),l=u.useCallback(n=>{s(n);try{localStorage.setItem(`viewMode:${a}`,n)}catch{}},[a]);return[t,l]}const ma=({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},ua=[{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 xa({item:a,selected:t,onToggle:s,onClick:l,folderName:n,onLightbox:r}){const{attributes:c,listeners:h,setNodeRef:o,isDragging:i}=ht({id:a.mediaId,data:{type:"media",mediaId:a.mediaId}}),x=a.mimeType.startsWith("image/")&&a.mimeType!=="image/svg+xml";function g(m){m.stopPropagation(),navigator.clipboard.writeText(W(a.url)),M.success("URL copied to clipboard")}return e.jsx(qt,{ref:o,...c,...h,className:O("group relative cursor-pointer overflow-hidden",i&&"opacity-50",t&&"ring-2 ring-primary"),onClick:l,children:e.jsxs(Qt,{className:"p-0",children:[e.jsx("div",{className:O("absolute left-2 top-2 z-10 opacity-0 group-hover:opacity-100 [@media(hover:none)]:opacity-100 [@media(hover:none)]:rounded [@media(hover:none)]:bg-black/30 [@media(hover:none)]:p-0.5",t&&"opacity-100"),onPointerDown:m=>m.stopPropagation(),onClick:m=>m.stopPropagation(),children:e.jsx(Te,{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 [@media(hover:none)]:opacity-100",onPointerDown:m=>m.stopPropagation(),onClick:m=>m.stopPropagation(),children:[e.jsx(Ce,{children:e.jsxs(ke,{children:[e.jsx(De,{asChild:!0,children:e.jsx("button",{className:"rounded bg-black/50 p-1 text-white hover:bg-black/70",onClick:g,children:e.jsx(qe,{className:"h-3.5 w-3.5"})})}),e.jsx(Se,{children:"Copy URL"})]})}),x&&r&&e.jsx(Ce,{children:e.jsxs(ke,{children:[e.jsx(De,{asChild:!0,children:e.jsx("button",{className:"rounded bg-black/50 p-1 text-white hover:bg-black/70",onClick:m=>{m.stopPropagation(),r()},children:e.jsx($s,{className:"h-3.5 w-3.5"})})}),e.jsx(Se,{children:"View full size"})]})})]}),x?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(_e,{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(te,{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:ve(a.size)}),e.jsx(Ce,{children:e.jsxs(ke,{children:[e.jsx(De,{asChild:!0,children:e.jsx("span",{className:"text-muted-foreground text-xs",children:Ve(a.uploadedAt)})}),e.jsx(Se,{children:We(a.uploadedAt)})]})})]}),a.tags.length>0&&e.jsxs("div",{className:"mt-1 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 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]})]})]})]})})}function Aa(){const{host:a}=Dt(),t=us(),[s,l]=ha("media"),[n,r]=u.useState("date_desc"),[c,h]=u.useState(""),[o,i]=u.useState(""),[x,g]=u.useState(null),[m,d]=u.useState(null),[b,p]=u.useState(void 0),[j,w]=u.useState(new Set),[A,_]=u.useState(null),[I,E]=u.useState(null),[F,y]=u.useState(null),[N,P]=u.useState([]),[X,ue]=u.useState(!1),J=u.useRef(null),xe=oa(a,m&&m!=="unfiled"?m:void 0),v=Ot(a),R=Ut(a),q=os(cs(ms,{activationConstraint:{distance:t?1e5:8}}));u.useEffect(()=>{const f=setTimeout(()=>{i(C=>{const D=c;return C!==D&&w(new Set),D})},300);return()=>clearTimeout(f)},[c]);const ae=m===null?void 0:m==="unfiled"?"":m,{data:$,isLoading:xt}=Ht(a,{sort:n,q:o||void 0,folderId:ae,tag:b}),{data:Ze}=ct(a),ye=u.useMemo(()=>Ze?.items??[],[Ze?.items]),Ie=u.useMemo(()=>{const f=new Map;for(const C of ye)f.set(C.folderId,C.name);return f},[ye]),be=u.useMemo(()=>($?.items??[]).filter(f=>f.mimeType.startsWith("image/")&&f.mimeType!=="image/svg+xml"),[$?.items]),Re=u.useMemo(()=>{const f=new Map;return be.forEach((C,D)=>f.set(C.mediaId,D)),f},[be]),{allTags:pt,allUserTags:gt}=u.useMemo(()=>{const f=$?.items??[],C=new Set,D=new Set;for(const z of f){for(const Y of z.tags)C.add(Y);for(const Y of z.userTags??[])D.add(Y)}return{allTags:Array.from(C).sort(),allUserTags:Array.from(D).sort()}},[$?.items]),Ae=$?.items.map(f=>f.mediaId)??[],ze=Ae.length>0&&Ae.every(f=>j.has(f));function Je(f){w(C=>{const D=new Set(C);return D.has(f)?D.delete(f):D.add(f),D})}function et(){w(ze?new Set:new Set(Ae))}async function ft(){const f=[...j],D=(await v.mutateAsync({mediaIds:f,action:"delete"})).failed.length;D?M.error(`${D} of ${f.length} failed to delete`):M.success(`${f.length} item(s) deleted`),w(new Set)}async function wt(f){const C=[...j],z=(await v.mutateAsync({mediaIds:C,action:"move",folderId:f})).failed.length;z?M.error(`${z} of ${C.length} failed to move`):M.success(`${C.length} item(s) moved`),w(new Set)}async function jt(f){const C=[...j],z=(await v.mutateAsync({mediaIds:C,action:"addTags",tags:f})).failed.length;z?M.error(`${z} of ${C.length} failed`):M.success(`Tags added to ${C.length} item(s)`),w(new Set)}async function vt(f){const C=[...j],z=(await v.mutateAsync({mediaIds:C,action:"removeTags",tags:f})).failed.length;z?M.error(`${z} of ${C.length} failed`):M.success(`Tags removed from ${C.length} item(s)`),w(new Set)}async function tt(f){const C=Array.from(f),D=C.slice(0,5),z=[];for(const Y of D)try{const Ee=await R.mutateAsync({filename:Y.name,size:Y.size});z.push(...Ee.duplicates)}catch{}z.length>0?(y(C),P(z)):xe.addFiles(C)}function yt(f){f.target.files&&tt(f.target.files),J.current&&(J.current.value="")}function bt(f){_(String(f.active.id))}function Nt(f){_(null);const{active:C,over:D}=f;if(!D||D.data.current?.type!=="folder")return;const z=D.id==="unfiled"||D.id==="all-media"?"":String(D.id),Y=j.has(String(C.id))?[...j]:[String(C.id)];v.mutateAsync({mediaIds:Y,action:"move",folderId:z}).then(Ee=>{const at=Ee.failed.length;at?M.error(`${at} of ${Y.length} failed to move`):M.success(`${Y.length} item(s) moved`)})}function Ct(){_(null)}const Q=A?$?.items.find(f=>f.mediaId===A):null,st=A&&j.has(A)?j.size:1;return e.jsxs(ds,{sensors:q,modifiers:[ma],onDragStart:bt,onDragEnd:Nt,onDragCancel:Ct,children:[e.jsxs("div",{className:"-m-2 md:-m-6 relative flex min-h-[calc(100dvh-3.5rem)] md:h-[calc(100vh-3.5rem)]",children:[e.jsx("div",{className:"hidden md:block",children:e.jsx(ot,{host:a,selectedFolderId:m,onSelect:f=>{d(f),w(new Set)}})}),e.jsx(Bt,{open:X,onOpenChange:ue,children:e.jsxs(Kt,{side:"left",className:"w-64 p-0 pt-[env(safe-area-inset-top,0px)] pl-[env(safe-area-inset-left,0px)] [&_[data-slot=sheet-close]]:top-[calc(1rem+env(safe-area-inset-top,0px))]","data-testid":"folder-overlay-backdrop",children:[e.jsx(Vt,{className:"sr-only",children:"Folders"}),e.jsx(ot,{host:a,selectedFolderId:m,onSelect:f=>{d(f),w(new Set),ue(!1)}})]})}),e.jsxs(na,{onFiles:f=>tt(f),children:[e.jsxs("div",{className:"flex-1 overflow-y-auto p-2 md: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:J,type:"file",multiple:!0,className:"hidden",onChange:yt}),e.jsxs(k,{onClick:()=>J.current?.click(),children:[e.jsx(Ne,{className:"mr-2 h-4 w-4"}),"Upload"]})]})]}),j.size>0?e.jsx(aa,{selectedCount:j.size,folders:ye,onDelete:ft,onMove:wt,onAddTags:jt,onRemoveTags:vt,onClear:()=>w(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(rt,{className:"text-muted-foreground absolute left-2.5 top-2.5 h-4 w-4"}),e.jsx(V,{placeholder:"Search media...",value:c,onChange:f=>h(f.target.value),className:"pl-9"})]}),e.jsxs(ge,{value:n,onValueChange:r,children:[e.jsx(fe,{className:"w-[160px]",children:e.jsx(we,{})}),e.jsx(je,{children:ua.map(f=>e.jsx(se,{value:f.value,children:f.label},f.value))})]}),e.jsx(k,{variant:X?"secondary":"ghost",size:"sm",className:"md:hidden px-2",onClick:()=>ue(!X),"aria-label":"Toggle folders",children:e.jsx(Ts,{className:"h-4 w-4"})}),!X&&m!==null&&t&&e.jsxs(Qe,{variant:"secondary",className:"gap-1 md:hidden",children:[e.jsx(te,{className:"h-3 w-3"}),m==="unfiled"?"Unfiled":Ie.get(m)??"All Media"]}),e.jsxs("div",{className:"flex rounded-md border",children:[e.jsx(k,{variant:s==="grid"?"secondary":"ghost",size:"sm",className:"rounded-r-none px-2",onClick:()=>l("grid"),children:e.jsx(Rs,{className:"h-4 w-4"})}),e.jsx(k,{variant:s==="list"?"secondary":"ghost",size:"sm",className:"rounded-l-none px-2",onClick:()=>l("list"),children:e.jsx(zs,{className:"h-4 w-4"})})]})]}),e.jsx(sa,{tags:pt,activeTag:b,onTagChange:f=>{p(f),w(new Set)}}),s==="grid"&&($?.items.length??0)>0&&e.jsxs("div",{className:"mb-2 flex items-center gap-2",children:[e.jsx(Te,{checked:ze,onCheckedChange:et,"aria-label":"Select all"}),e.jsx("span",{className:"text-muted-foreground text-sm",children:j.size>0?`${j.size} of ${$.items.length} selected`:"Select all"})]}),xt?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,C)=>e.jsx(Wt,{className:"aspect-square"},C))}):$?.items.length?s==="list"?e.jsx(Xs,{items:$.items,host:a,onSelect:g,selectedIds:j,onToggle:Je,onToggleAll:et,allSelected:ze,folderMap:m===null?Ie:void 0,onLightbox:f=>{const C=Re.get(f.mediaId);C!==void 0&&E(C)}}):e.jsx("div",{className:"grid gap-4 sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-4",children:$.items.map(f=>e.jsx(xa,{item:f,selected:j.has(f.mediaId),onToggle:()=>Je(f.mediaId),onClick:()=>g(f),folderName:m===null?Ie.get(f.folderId??""):void 0,onLightbox:Re.has(f.mediaId)?()=>E(Re.get(f.mediaId)):void 0},f.mediaId))}):e.jsx("div",{className:"flex flex-col items-center justify-center py-16 text-center",children:o||b?e.jsxs(e.Fragment,{children:[e.jsx(rt,{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(te,{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(te,{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(Ne,{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(k,{className:"mt-4",onClick:()=>J.current?.click(),children:[e.jsx(Ne,{className:"mr-2 h-4 w-4"}),"Upload"]})]})}),x&&e.jsx(ta,{host:a,media:x,onClose:()=>g(null),onDeleted:f=>{w(C=>{if(!C.has(f))return C;const D=new Set(C);return D.delete(f),D})},folders:ye,tagSuggestions:gt})]}),e.jsx(ra,{queue:xe})]})]}),I!==null&&be.length>0&&e.jsx(ca,{items:be,currentIndex:I,host:a,onClose:()=>E(null),onNavigate:E}),e.jsx(da,{open:N.length>0,host:a,duplicates:N,fileCount:F?Array.from(F).length:0,onContinue:()=>{F&&xe.addFiles(F),y(null),P([])},onCancel:()=>{y(null),P([])}}),e.jsx(hs,{children:A&&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(_e,{mimeType:Q.mimeType,className:"h-6 w-6"})}),e.jsx("span",{className:"text-sm font-medium",children:st>1?`Moving ${st} items`:Q.filename})]})})]})}export{Aa as MediaPage};
@@ -1 +0,0 @@
1
- import{j as e,a as Q}from"./tanstack-oFmRhGwV.js";import{u as R,e as G,r as h}from"./react-vendor-B0Dih9Pj.js";import{a8 as K,S as b,ac as Z,ad as z,ae as J,a7 as M,L as m,I as c,B as i,a as u,af as V,D as A,j as P,k,l as T,m as F,n as E,t as n}from"./index-DX9xeoQx.js";import{B as W}from"./badge-B8OxObuF.js";import{C as g,a as p,b as f,c as S}from"./card-C7fgQS_U.js";import{f as X}from"./format-C88SDH8g.js";import"./radix-lA_IxTIV.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 +0,0 @@
1
- import{j as e}from"./tanstack-oFmRhGwV.js";import{r as u,e as V}from"./react-vendor-B0Dih9Pj.js";import{b as X,u as Z,d as ee,e as te,g as se,h as ae,H as U,D as G,i as J,B as k,U as ne,j as oe,k as ie,l as le,m as re,L as R,I as W,n as ce}from"./index-DX9xeoQx.js";import{C as de,a as me,b as he,d as ue}from"./card-C7fgQS_U.js";import{B as ge}from"./badge-B8OxObuF.js";import{C as b}from"./checkbox-BV2kjQBe.js";import{P as Y}from"./plus-HdRn2U0S.js";import"./radix-lA_IxTIV.js";import"./check-CxKAR64t.js";const pe={name:"pages",label:"Pages",labelSingular:"Page",slug:"pages",singleton:!1,fields:[{name:"content",label:"Content",type:"blocks",options:{}}]},xe={name:"posts",label:"Blog Posts",labelSingular:"Blog Post",slug:"/blog",singleton:!1,fields:[{name:"author",label:"Author",type:"text",options:{}},{name:"content",label:"Content",type:"blocks",options:{}}]},fe={name:"site-settings",label:"Site Settings",labelSingular:"Site Settings",slug:"site-settings",singleton:!0,fields:[{name:"siteName",label:"Site Name",type:"text",options:{}},{name:"tagline",label:"Tagline",type:"text",options:{}},{name:"footerText",label:"Footer Text",type:"text",options:{}},{name:"menuItems",label:"Menu Items",type:"array",options:{itemFields:[{name:"label",label:"Label",type:"text",options:{}},{name:"href",label:"URL",type:"text",options:{}}]}}]};function C(s,o){return{id:o,type:"paragraph",props:{textColor:"default",backgroundColor:"default",textAlignment:"left"},content:[{type:"text",text:s}],children:[]}}function $(s,o,d){return{id:d,type:"heading",props:{textColor:"default",backgroundColor:"default",textAlignment:"left",level:o},content:[{type:"text",text:s}],children:[]}}const z=[{title:"Home",slug:"home",body:{content:[$("Welcome to Headroom",1,"home-h1"),C("This is your new site powered by Headroom CMS. Edit this page to add your own content.","home-p1"),$("Getting Started",2,"home-h2"),C("Head over to the admin panel to manage your content, collections, and media.","home-p2")]}},{title:"About",slug:"about",body:{content:[$("About Us",1,"about-h1"),C("Tell your visitors about your company, team, or project. This is a great place to share your story.","about-p1")]}},{title:"Contact",slug:"contact",body:{content:[$("Contact",1,"contact-h1"),C("Get in touch with us. Replace this with your contact information or a contact form.","contact-p1")]}}],K=[{title:"Welcome to Headroom",slug:"welcome-to-headroom",body:{author:"Admin",content:[C("This is your first blog post. You can edit or delete it and start writing your own content.","post-p1"),C("Headroom makes it easy to create and manage your content with a powerful block editor, media library, and flexible collections.","post-p2")]}}],Se={siteName:"Headroom Site",tagline:"A site powered by Headroom CMS",footerText:"© 2026 Headroom Site. Built with Headroom CMS.",menuItems:[{label:"Home",href:"/"},{label:"About",href:"/about"},{label:"Blog",href:"/blog"},{label:"Contact",href:"/contact"}]};function Q(s){const d=[s.createPages,s.createPosts,s.createSettings].filter(Boolean).length;if(!s.addSampleContent)return d;let g=0;return s.createPages&&(g+=z.length*2),s.createPosts&&(g+=K.length*2),s.createSettings&&(g+=3),d+g}async function be(s,o,d,g){const r={collectionsCreated:[],contentCreated:[],errors:[]},x=Q(d);let a=0;const m=t=>{g?.({completed:a,total:x,label:t})},y=[{key:"pages",enabled:d.createPages,schema:pe},{key:"posts",enabled:d.createPosts,schema:xe},{key:"site-settings",enabled:d.createSettings,schema:fe}],p=new Set;for(const{key:t,enabled:n,schema:f}of y)if(n){m(`Creating ${t} collection...`);try{await s.apiFetch(`/v1/admin/sites/${o}/collections`,{method:"POST",body:JSON.stringify(f)}),r.collectionsCreated.push(t),p.add(t)}catch(h){r.errors.push(`Failed to create ${t} collection: ${h instanceof Error?h.message:String(h)}`)}a++}if(!d.addSampleContent)return m("Done"),r;if(p.has("pages"))for(const t of z){m(`Creating page "${t.title}"...`);try{const n=await s.apiFetch(`/v1/admin/sites/${o}/content`,{method:"POST",body:JSON.stringify({collection:"pages",params:{title:t.title,slug:t.slug,body:t.body}})});a++,m(`Publishing page "${t.title}"...`),await s.apiFetch(`/v1/admin/sites/${o}/content/${n.contentId}/publish`,{method:"POST"}),a++,r.contentCreated.push(`pages/${t.slug}`)}catch(n){r.errors.push(`Failed to create page "${t.title}": ${n instanceof Error?n.message:String(n)}`),a+=2}}if(p.has("posts"))for(const t of K){m(`Creating post "${t.title}"...`);try{const n=await s.apiFetch(`/v1/admin/sites/${o}/content`,{method:"POST",body:JSON.stringify({collection:"posts",params:{title:t.title,slug:t.slug,body:t.body}})});a++,m(`Publishing post "${t.title}"...`),await s.apiFetch(`/v1/admin/sites/${o}/content/${n.contentId}/publish`,{method:"POST"}),a++,r.contentCreated.push(`posts/${t.slug}`)}catch(n){r.errors.push(`Failed to create post "${t.title}": ${n instanceof Error?n.message:String(n)}`),a+=2}}if(p.has("site-settings")){m("Configuring settings...");try{const t=await s.apiFetch(`/v1/admin/sites/${o}/collections/site-settings`);a++,t.singletonContentId?(m("Saving settings draft..."),await s.apiFetch(`/v1/admin/sites/${o}/content/${t.singletonContentId}/draft`,{method:"PUT",body:JSON.stringify({title:"Site Settings",slug:"site-settings",body:Se})}),a++,m("Publishing settings..."),await s.apiFetch(`/v1/admin/sites/${o}/content/${t.singletonContentId}/publish`,{method:"POST"}),a++,r.contentCreated.push("site-settings")):a+=2}catch(t){r.errors.push(`Failed to populate settings: ${t instanceof Error?t.message:String(t)}`),a+=3}}return m("Done"),r}function $e(){const[s,o]=u.useState(!1),{data:d,isLoading:g}=X(s),r=V(),x=u.useMemo(()=>[...d?.items??[]].sort((l,A)=>(l.name||l.host).localeCompare(A.name||A.host)),[d]),{user:a}=Z(),{data:m}=ee(),y=a?(m?.superAdminIds??[]).includes(a.sub):!1,p=te(),t=se(),[n,f]=u.useState(!1),[h,j]=u.useState(""),[S,c]=u.useState(""),[N,i]=u.useState(!0),[v,D]=u.useState(!0),[w,O]=u.useState(!0),[P,E]=u.useState(!0),[F,L]=u.useState(!1),[H,T]=u.useState(null),I=()=>{j(""),c(""),i(!0),D(!0),O(!0),E(!0),L(!1),T(null)},B=l=>{f(l),l||I()};if(g)return e.jsx(ae,{});const _=async()=>{if(h.trim())try{await t.mutateAsync({host:h.trim(),name:S.trim()||h.trim()});const l={createPages:v,createPosts:w,createSettings:P,addSampleContent:F};if(N&&(v||w||P)){const A=Q(l);T({completed:0,total:A,label:"Setting up collections..."});const M=await be(p,h.trim(),l,T);M.errors.length>0&&console.warn("Scaffold warnings:",M.errors)}f(!1),I()}catch{T(null)}};return x.length===0?e.jsxs("div",{className:"flex h-dvh flex-col",children:[e.jsx(U,{}),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(G,{open:n,onOpenChange:B,children:[e.jsx(J,{asChild:!0,children:e.jsxs(k,{children:[e.jsx(Y,{className:"mr-2 h-4 w-4"}),"Create Site"]})}),e.jsx(q,{newHost:h,setNewHost:j,newName:S,setNewName:c,createDefaults:N,setCreateDefaults:i,createPages:v,setCreatePages:D,createPosts:w,setCreatePosts:O,createSettings:P,setCreateSettings:E,addSampleContent:F,setAddSampleContent:L,onSubmit:_,isPending:t.isPending,scaffoldProgress:H})]})]})]}):e.jsxs("div",{className:"flex h-dvh flex-col",children:[e.jsx(U,{}),e.jsxs("div",{className:"flex-1 p-4 sm:p-8",children:[e.jsxs("div",{className:"mb-6 flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[e.jsx("h1",{className:"text-2xl font-semibold",children:"Select a site"}),y&&e.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[e.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[e.jsx(b,{checked:s,onCheckedChange:l=>o(l===!0)}),"Show archived sites"]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(k,{variant:"outline",onClick:()=>r("/users"),children:[e.jsx(ne,{className:"mr-2 h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"All Users"})]}),e.jsxs(G,{open:n,onOpenChange:B,children:[e.jsx(J,{asChild:!0,children:e.jsxs(k,{children:[e.jsx(Y,{className:"mr-2 h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Create Site"})]})}),e.jsx(q,{newHost:h,setNewHost:j,newName:S,setNewName:c,createDefaults:N,setCreateDefaults:i,createPages:v,setCreatePages:D,createPosts:w,setCreatePosts:O,createSettings:P,setCreateSettings:E,addSampleContent:F,setAddSampleContent:L,onSubmit:_,isPending:t.isPending,scaffoldProgress:H})]})]})]})]}),e.jsx("div",{className:"grid gap-4 sm:grid-cols-2 lg:grid-cols-3",children:x.map(l=>e.jsx(de,{className:"cursor-pointer transition-shadow hover:shadow-md",onClick:()=>r(`/sites/${l.host}/content`),children:e.jsxs(me,{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(he,{children:l.name||l.host}),l.status==="archived"&&e.jsx(ge,{variant:"outline",children:"Archived"})]}),e.jsx(ue,{children:l.host})]})},l.host))})]})]})}function q({newHost:s,setNewHost:o,newName:d,setNewName:g,createDefaults:r,setCreateDefaults:x,createPages:a,setCreatePages:m,createPosts:y,setCreatePosts:p,createSettings:t,setCreateSettings:n,addSampleContent:f,setAddSampleContent:h,onSubmit:j,isPending:S,scaffoldProgress:c}){const N=S||!!c;return e.jsxs(oe,{children:[e.jsxs(ie,{children:[e.jsx(le,{children:"Create Site"}),e.jsx(re,{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(R,{htmlFor:"host",children:"Host"}),e.jsx(W,{id:"host",placeholder:"example.com",value:s,onChange:i=>o(i.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(R,{htmlFor:"name",children:"Display Name"}),e.jsx(W,{id:"name",placeholder:"My Site",value:d,onChange:i=>g(i.target.value)})]}),e.jsxs("div",{className:"border-t pt-4",children:[e.jsxs("label",{className:"flex items-center gap-2 text-sm font-medium",children:[e.jsx(b,{checked:r,onCheckedChange:i=>x(i===!0)}),"Create Default Collections"]}),r&&e.jsxs("div",{className:"ml-6 mt-3 space-y-2",children:[e.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[e.jsx(b,{checked:a,onCheckedChange:i=>m(i===!0)}),"Pages"]}),e.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[e.jsx(b,{checked:y,onCheckedChange:i=>p(i===!0)}),"Posts"]}),e.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[e.jsx(b,{checked:t,onCheckedChange:i=>n(i===!0)}),"Site Settings"]}),e.jsxs("label",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(b,{checked:f,onCheckedChange:i=>h(i===!0)}),"Add Sample Content"]})]})]})]}),c&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"h-2 w-full overflow-hidden rounded-full bg-muted",children:e.jsx("div",{className:"h-full rounded-full bg-primary transition-all duration-300",style:{width:`${c.total>0?c.completed/c.total*100:0}%`},role:"progressbar","aria-valuenow":c.completed,"aria-valuemin":0,"aria-valuemax":c.total})}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[c.label," ","(",c.completed,"/",c.total,")"]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Please wait while your site is being set up. Do not close this tab."})]}),e.jsx(ce,{children:e.jsx(k,{onClick:j,disabled:!s.trim()||N,children:c?c.label:S?"Creating...":"Create"})})]})}export{$e as SitesPage};
@@ -1 +0,0 @@
1
- import{j as e}from"./tanstack-oFmRhGwV.js";import{u as p,r as x}from"./react-vendor-B0Dih9Pj.js";import{u as b,a as D,b as y}from"./useTags-BuXf7_7H.js";import{I as w,B as c,S as v,t as d,D as N,j as C,k as P,l as S,m as k,n as A}from"./index-DX9xeoQx.js";import{T as E,a as B,b as j,c as m,d as F,e as h}from"./table-BjSue8Ev.js";import{P as H}from"./plus-HdRn2U0S.js";import{T as $}from"./trash-2-CWWRVuRB.js";import"./radix-lA_IxTIV.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 +0,0 @@
1
- import{j as e}from"./tanstack-oFmRhGwV.js";import{r as p}from"./react-vendor-B0Dih9Pj.js";import{o as H,u as L,p as P,d as z,q as O,r as _,s as q,H as R,I as G,S as J,B as t,D as g,i as K,j as v,k as A,l as D,m as C,n as y,t as n}from"./index-DX9xeoQx.js";import{C as Q}from"./checkbox-BV2kjQBe.js";import{B as V}from"./badge-B8OxObuF.js";import{T as W,a as X,b as N,c as r,d as Y,e as c}from"./table-BjSue8Ev.js";import{T as Z}from"./trash-2-CWWRVuRB.js";import"./radix-lA_IxTIV.js";import"./check-CxKAR64t.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-dvh 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 +0,0 @@
1
- import{j as e}from"./tanstack-oFmRhGwV.js";import{u as R,e as $,r as d}from"./react-vendor-B0Dih9Pj.js";import{a as U,b as _,c as q,d as z,e as K,f as M}from"./useWebhooks-Cx9tbBME.js";import{o as V,S as v,L as y,I as Y,B as l,a as G,D as J,i as Q,j as X,k as Z,l as ee,m as se,n as te,t as i}from"./index-DX9xeoQx.js";import{B as C}from"./badge-B8OxObuF.js";import{C as j,c as p,a as W,b as N}from"./card-C7fgQS_U.js";import{T as ae,a as ne,b as T,c as b,d as re,e as f}from"./table-BjSue8Ev.js";import{f as oe}from"./format-C88SDH8g.js";import{T as ie}from"./trash-2-CWWRVuRB.js";import"./radix-lA_IxTIV.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 +0,0 @@
1
- import{j as e}from"./tanstack-oFmRhGwV.js";import{u as m,e as x}from"./react-vendor-B0Dih9Pj.js";import{u as h}from"./useWebhooks-Cx9tbBME.js";import{B as j,S as b}from"./index-DX9xeoQx.js";import{B as l}from"./badge-B8OxObuF.js";import{T as u,a as f,b as c,c as r,d as p,e as t}from"./table-BjSue8Ev.js";import{P as N}from"./plus-HdRn2U0S.js";import"./radix-lA_IxTIV.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 +0,0 @@
1
- import{j as o}from"./tanstack-oFmRhGwV.js";import"./react-vendor-B0Dih9Pj.js";import{w as n,ag as s}from"./index-DX9xeoQx.js";import{S as d}from"./radix-lA_IxTIV.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 +0,0 @@
1
- import{o as c}from"./index-DX9xeoQx.js";const o=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],t=c("check",o);export{t as C};
@@ -1 +0,0 @@
1
- import{j as r}from"./tanstack-oFmRhGwV.js";import"./react-vendor-B0Dih9Pj.js";import{w as i}from"./index-DX9xeoQx.js";import{C as t}from"./check-CxKAR64t.js";import{U as o,W as s}from"./radix-lA_IxTIV.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 +0,0 @@
1
- import{j as C}from"./tanstack-oFmRhGwV.js";import{r as l,b as Re}from"./react-vendor-B0Dih9Pj.js";import{X as V,Y as L,c as Ae,h as je,O as $e,e as Pe}from"./radix-lA_IxTIV.js";import{w as K}from"./index-DX9xeoQx.js";import{S as Me}from"./search-C-3Q9nn7.js";var pe=1,Ne=.9,De=.8,Le=.17,te=.1,re=.999,Ve=.9999,_e=.99,Oe=/[\\\/_+.#"@\[\(\{&]/,Fe=/[\\\/_+.#"@\[\(\{&]/g,Ke=/[\s-]/,he=/[\s-]/g;function le(e,r,t,u,a,o,s){if(o===r.length)return a===e.length?pe:_e;var f=`${a},${o}`;if(s[f]!==void 0)return s[f];for(var p=u.charAt(o),c=t.indexOf(p,a),v=0,h,k,w,I;c>=0;)h=le(e,r,t,u,c+1,o+1,s),h>v&&(c===a?h*=pe:Oe.test(e.charAt(c-1))?(h*=De,w=e.slice(a,c-1).match(Fe),w&&a>0&&(h*=Math.pow(re,w.length))):Ke.test(e.charAt(c-1))?(h*=Ne,I=e.slice(a,c-1).match(he),I&&a>0&&(h*=Math.pow(re,I.length))):(h*=Le,a>0&&(h*=Math.pow(re,c-a))),e.charAt(c)!==r.charAt(o)&&(h*=Ve)),(h<te&&t.charAt(c-1)===u.charAt(o+1)||u.charAt(o+1)===u.charAt(o)&&t.charAt(c-1)!==u.charAt(o))&&(k=le(e,r,t,u,c+1,o+2,s),k*te>h&&(h=k*te)),h>v&&(v=h),c=t.indexOf(p,c+1);return s[f]=v,v}function ve(e){return e.toLowerCase().replace(he," ")}function ze(e,r,t){return e=t&&t.length>0?`${e+" "+t.join(" ")}`:e,le(e,r,ve(e),ve(r),0,0,{})}var qe=Symbol.for("react.lazy"),W=Re[" use ".trim().toString()];function Te(e){return typeof e=="object"&&e!==null&&"then"in e}function be(e){return e!=null&&typeof e=="object"&&"$$typeof"in e&&e.$$typeof===qe&&"_payload"in e&&Te(e._payload)}function ye(e){const r=We(e),t=l.forwardRef((u,a)=>{let{children:o,...s}=u;be(o)&&typeof W=="function"&&(o=W(o._payload));const f=l.Children.toArray(o),p=f.find(He);if(p){const c=p.props.children,v=f.map(h=>h===p?l.Children.count(c)>1?l.Children.only(null):l.isValidElement(c)?c.props.children:null:h);return C.jsx(r,{...s,ref:a,children:l.isValidElement(c)?l.cloneElement(c,void 0,v):null})}return C.jsx(r,{...s,ref:a,children:o})});return t.displayName=`${e}.Slot`,t}var gt=ye("Slot");function We(e){const r=l.forwardRef((t,u)=>{let{children:a,...o}=t;if(be(a)&&typeof W=="function"&&(a=W(a._payload)),l.isValidElement(a)){const s=Ge(a),f=Ye(o,a.props);return a.type!==l.Fragment&&(f.ref=u?V(u,s):s),l.cloneElement(a,f)}return l.Children.count(a)>1?l.Children.only(null):null});return r.displayName=`${e}.SlotClone`,r}var Be=Symbol("radix.slottable");function He(e){return l.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===Be}function Ye(e,r){const t={...r};for(const u in r){const a=e[u],o=r[u];/^on[A-Z]/.test(u)?a&&o?t[u]=(...f)=>{const p=o(...f);return a(...f),p}:a&&(t[u]=a):u==="style"?t[u]={...a,...o}:u==="className"&&(t[u]=[a,o].filter(Boolean).join(" "))}return{...e,...t}}function Ge(e){let r=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,t=r&&"isReactWarning"in r&&r.isReactWarning;return t?e.ref:(r=Object.getOwnPropertyDescriptor(e,"ref")?.get,t=r&&"isReactWarning"in r&&r.isReactWarning,t?e.props.ref:e.props.ref||e.ref)}var Ue=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],A=Ue.reduce((e,r)=>{const t=ye(`Primitive.${r}`),u=l.forwardRef((a,o)=>{const{asChild:s,...f}=a,p=s?t:r;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),C.jsx(p,{...f,ref:o})});return u.displayName=`Primitive.${r}`,{...e,[r]:u}},{}),F='[cmdk-group=""]',ne='[cmdk-group-items=""]',Xe='[cmdk-group-heading=""]',xe='[cmdk-item=""]',ge=`${xe}:not([aria-disabled="true"])`,ae="cmdk-item-select",N="data-value",Ze=(e,r,t)=>ze(e,r,t),we=l.createContext(void 0),z=()=>l.useContext(we),Ee=l.createContext(void 0),oe=()=>l.useContext(Ee),Se=l.createContext(void 0),ke=l.forwardRef((e,r)=>{let t=D(()=>{var n,d;return{search:"",value:(d=(n=e.value)!=null?n:e.defaultValue)!=null?d:"",selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}}}),u=D(()=>new Set),a=D(()=>new Map),o=D(()=>new Map),s=D(()=>new Set),f=Ce(e),{label:p,children:c,value:v,onValueChange:h,filter:k,shouldFilter:w,loop:I,disablePointerSelection:H=!1,vimBindings:j=!0,...q}=e,Y=L(),ie=L(),G=L(),$=l.useRef(null),y=ut();P(()=>{if(v!==void 0){let n=v.trim();t.current.value=n,E.emit()}},[v]),P(()=>{y(6,ce)},[]);let E=l.useMemo(()=>({subscribe:n=>(s.current.add(n),()=>s.current.delete(n)),snapshot:()=>t.current,setState:(n,d,m)=>{var i,g,b,S;if(!Object.is(t.current[n],d)){if(t.current[n]=d,n==="search")J(),X(),y(1,Z);else if(n==="value"){if(document.activeElement.hasAttribute("cmdk-input")||document.activeElement.hasAttribute("cmdk-root")){let x=document.getElementById(G);x?x.focus():(i=document.getElementById(Y))==null||i.focus()}if(y(7,()=>{var x;t.current.selectedItemId=(x=M())==null?void 0:x.id,E.emit()}),m||y(5,ce),((g=f.current)==null?void 0:g.value)!==void 0){let x=d??"";(S=(b=f.current).onValueChange)==null||S.call(b,x);return}}E.emit()}},emit:()=>{s.current.forEach(n=>n())}}),[]),U=l.useMemo(()=>({value:(n,d,m)=>{var i;d!==((i=o.current.get(n))==null?void 0:i.value)&&(o.current.set(n,{value:d,keywords:m}),t.current.filtered.items.set(n,ue(d,m)),y(2,()=>{X(),E.emit()}))},item:(n,d)=>(u.current.add(n),d&&(a.current.has(d)?a.current.get(d).add(n):a.current.set(d,new Set([n]))),y(3,()=>{J(),X(),t.current.value||Z(),E.emit()}),()=>{o.current.delete(n),u.current.delete(n),t.current.filtered.items.delete(n);let m=M();y(4,()=>{J(),m?.getAttribute("id")===n&&Z(),E.emit()})}),group:n=>(a.current.has(n)||a.current.set(n,new Set),()=>{o.current.delete(n),a.current.delete(n)}),filter:()=>f.current.shouldFilter,label:p||e["aria-label"],getDisablePointerSelection:()=>f.current.disablePointerSelection,listId:Y,inputId:G,labelId:ie,listInnerRef:$}),[]);function ue(n,d){var m,i;let g=(i=(m=f.current)==null?void 0:m.filter)!=null?i:Ze;return n?g(n,t.current.search,d):0}function X(){if(!t.current.search||f.current.shouldFilter===!1)return;let n=t.current.filtered.items,d=[];t.current.filtered.groups.forEach(i=>{let g=a.current.get(i),b=0;g.forEach(S=>{let x=n.get(S);b=Math.max(x,b)}),d.push([i,b])});let m=$.current;O().sort((i,g)=>{var b,S;let x=i.getAttribute("id"),T=g.getAttribute("id");return((b=n.get(T))!=null?b:0)-((S=n.get(x))!=null?S:0)}).forEach(i=>{let g=i.closest(ne);g?g.appendChild(i.parentElement===g?i:i.closest(`${ne} > *`)):m.appendChild(i.parentElement===m?i:i.closest(`${ne} > *`))}),d.sort((i,g)=>g[1]-i[1]).forEach(i=>{var g;let b=(g=$.current)==null?void 0:g.querySelector(`${F}[${N}="${encodeURIComponent(i[0])}"]`);b?.parentElement.appendChild(b)})}function Z(){let n=O().find(m=>m.getAttribute("aria-disabled")!=="true"),d=n?.getAttribute(N);E.setState("value",d||void 0)}function J(){var n,d,m,i;if(!t.current.search||f.current.shouldFilter===!1){t.current.filtered.count=u.current.size;return}t.current.filtered.groups=new Set;let g=0;for(let b of u.current){let S=(d=(n=o.current.get(b))==null?void 0:n.value)!=null?d:"",x=(i=(m=o.current.get(b))==null?void 0:m.keywords)!=null?i:[],T=ue(S,x);t.current.filtered.items.set(b,T),T>0&&g++}for(let[b,S]of a.current)for(let x of S)if(t.current.filtered.items.get(x)>0){t.current.filtered.groups.add(b);break}t.current.filtered.count=g}function ce(){var n,d,m;let i=M();i&&(((n=i.parentElement)==null?void 0:n.firstChild)===i&&((m=(d=i.closest(F))==null?void 0:d.querySelector(Xe))==null||m.scrollIntoView({block:"nearest"})),i.scrollIntoView({block:"nearest"}))}function M(){var n;return(n=$.current)==null?void 0:n.querySelector(`${xe}[aria-selected="true"]`)}function O(){var n;return Array.from(((n=$.current)==null?void 0:n.querySelectorAll(ge))||[])}function Q(n){let d=O()[n];d&&E.setState("value",d.getAttribute(N))}function ee(n){var d;let m=M(),i=O(),g=i.findIndex(S=>S===m),b=i[g+n];(d=f.current)!=null&&d.loop&&(b=g+n<0?i[i.length-1]:g+n===i.length?i[0]:i[g+n]),b&&E.setState("value",b.getAttribute(N))}function se(n){let d=M(),m=d?.closest(F),i;for(;m&&!i;)m=n>0?ot(m,F):it(m,F),i=m?.querySelector(ge);i?E.setState("value",i.getAttribute(N)):ee(n)}let de=()=>Q(O().length-1),fe=n=>{n.preventDefault(),n.metaKey?de():n.altKey?se(1):ee(1)},me=n=>{n.preventDefault(),n.metaKey?Q(0):n.altKey?se(-1):ee(-1)};return l.createElement(A.div,{ref:r,tabIndex:-1,...q,"cmdk-root":"",onKeyDown:n=>{var d;(d=q.onKeyDown)==null||d.call(q,n);let m=n.nativeEvent.isComposing||n.keyCode===229;if(!(n.defaultPrevented||m))switch(n.key){case"n":case"j":{j&&n.ctrlKey&&fe(n);break}case"ArrowDown":{fe(n);break}case"p":case"k":{j&&n.ctrlKey&&me(n);break}case"ArrowUp":{me(n);break}case"Home":{n.preventDefault(),Q(0);break}case"End":{n.preventDefault(),de();break}case"Enter":{n.preventDefault();let i=M();if(i){let g=new Event(ae);i.dispatchEvent(g)}}}}},l.createElement("label",{"cmdk-label":"",htmlFor:U.inputId,id:U.labelId,style:st},p),B(e,n=>l.createElement(Ee.Provider,{value:E},l.createElement(we.Provider,{value:U},n))))}),Je=l.forwardRef((e,r)=>{var t,u;let a=L(),o=l.useRef(null),s=l.useContext(Se),f=z(),p=Ce(e),c=(u=(t=p.current)==null?void 0:t.forceMount)!=null?u:s?.forceMount;P(()=>{if(!c)return f.item(a,s?.id)},[c]);let v=Ie(a,o,[e.value,e.children,o],e.keywords),h=oe(),k=R(y=>y.value&&y.value===v.current),w=R(y=>c||f.filter()===!1?!0:y.search?y.filtered.items.get(a)>0:!0);l.useEffect(()=>{let y=o.current;if(!(!y||e.disabled))return y.addEventListener(ae,I),()=>y.removeEventListener(ae,I)},[w,e.onSelect,e.disabled]);function I(){var y,E;H(),(E=(y=p.current).onSelect)==null||E.call(y,v.current)}function H(){h.setState("value",v.current,!0)}if(!w)return null;let{disabled:j,value:q,onSelect:Y,forceMount:ie,keywords:G,...$}=e;return l.createElement(A.div,{ref:V(o,r),...$,id:a,"cmdk-item":"",role:"option","aria-disabled":!!j,"aria-selected":!!k,"data-disabled":!!j,"data-selected":!!k,onPointerMove:j||f.getDisablePointerSelection()?void 0:H,onClick:j?void 0:I},e.children)}),Qe=l.forwardRef((e,r)=>{let{heading:t,children:u,forceMount:a,...o}=e,s=L(),f=l.useRef(null),p=l.useRef(null),c=L(),v=z(),h=R(w=>a||v.filter()===!1?!0:w.search?w.filtered.groups.has(s):!0);P(()=>v.group(s),[]),Ie(s,f,[e.value,e.heading,p]);let k=l.useMemo(()=>({id:s,forceMount:a}),[a]);return l.createElement(A.div,{ref:V(f,r),...o,"cmdk-group":"",role:"presentation",hidden:h?void 0:!0},t&&l.createElement("div",{ref:p,"cmdk-group-heading":"","aria-hidden":!0,id:c},t),B(e,w=>l.createElement("div",{"cmdk-group-items":"",role:"group","aria-labelledby":t?c:void 0},l.createElement(Se.Provider,{value:k},w))))}),et=l.forwardRef((e,r)=>{let{alwaysRender:t,...u}=e,a=l.useRef(null),o=R(s=>!s.search);return!t&&!o?null:l.createElement(A.div,{ref:V(a,r),...u,"cmdk-separator":"",role:"separator"})}),tt=l.forwardRef((e,r)=>{let{onValueChange:t,...u}=e,a=e.value!=null,o=oe(),s=R(c=>c.search),f=R(c=>c.selectedItemId),p=z();return l.useEffect(()=>{e.value!=null&&o.setState("search",e.value)},[e.value]),l.createElement(A.input,{ref:r,...u,"cmdk-input":"",autoComplete:"off",autoCorrect:"off",spellCheck:!1,"aria-autocomplete":"list",role:"combobox","aria-expanded":!0,"aria-controls":p.listId,"aria-labelledby":p.labelId,"aria-activedescendant":f,id:p.inputId,type:"text",value:a?e.value:s,onChange:c=>{a||o.setState("search",c.target.value),t?.(c.target.value)}})}),rt=l.forwardRef((e,r)=>{let{children:t,label:u="Suggestions",...a}=e,o=l.useRef(null),s=l.useRef(null),f=R(c=>c.selectedItemId),p=z();return l.useEffect(()=>{if(s.current&&o.current){let c=s.current,v=o.current,h,k=new ResizeObserver(()=>{h=requestAnimationFrame(()=>{let w=c.offsetHeight;v.style.setProperty("--cmdk-list-height",w.toFixed(1)+"px")})});return k.observe(c),()=>{cancelAnimationFrame(h),k.unobserve(c)}}},[]),l.createElement(A.div,{ref:V(o,r),...a,"cmdk-list":"",role:"listbox",tabIndex:-1,"aria-activedescendant":f,"aria-label":u,id:p.listId},B(e,c=>l.createElement("div",{ref:V(s,p.listInnerRef),"cmdk-list-sizer":""},c)))}),nt=l.forwardRef((e,r)=>{let{open:t,onOpenChange:u,overlayClassName:a,contentClassName:o,container:s,...f}=e;return l.createElement(Ae,{open:t,onOpenChange:u},l.createElement(je,{container:s},l.createElement($e,{"cmdk-overlay":"",className:a}),l.createElement(Pe,{"aria-label":e.label,"cmdk-dialog":"",className:o},l.createElement(ke,{ref:r,...f}))))}),lt=l.forwardRef((e,r)=>R(t=>t.filtered.count===0)?l.createElement(A.div,{ref:r,...e,"cmdk-empty":"",role:"presentation"}):null),at=l.forwardRef((e,r)=>{let{progress:t,children:u,label:a="Loading...",...o}=e;return l.createElement(A.div,{ref:r,...o,"cmdk-loading":"",role:"progressbar","aria-valuenow":t,"aria-valuemin":0,"aria-valuemax":100,"aria-label":a},B(e,s=>l.createElement("div",{"aria-hidden":!0},s)))}),_=Object.assign(ke,{List:rt,Item:Je,Input:tt,Group:Qe,Separator:et,Dialog:nt,Empty:lt,Loading:at});function ot(e,r){let t=e.nextElementSibling;for(;t;){if(t.matches(r))return t;t=t.nextElementSibling}}function it(e,r){let t=e.previousElementSibling;for(;t;){if(t.matches(r))return t;t=t.previousElementSibling}}function Ce(e){let r=l.useRef(e);return P(()=>{r.current=e}),r}var P=typeof window>"u"?l.useEffect:l.useLayoutEffect;function D(e){let r=l.useRef();return r.current===void 0&&(r.current=e()),r}function R(e){let r=oe(),t=()=>e(r.snapshot());return l.useSyncExternalStore(r.subscribe,t,t)}function Ie(e,r,t,u=[]){let a=l.useRef(),o=z();return P(()=>{var s;let f=(()=>{var c;for(let v of t){if(typeof v=="string")return v.trim();if(typeof v=="object"&&"current"in v)return v.current?(c=v.current.textContent)==null?void 0:c.trim():a.current}})(),p=u.map(c=>c.trim());o.value(e,f,p),(s=r.current)==null||s.setAttribute(N,f),a.current=f}),a}var ut=()=>{let[e,r]=l.useState(),t=D(()=>new Map);return P(()=>{t.current.forEach(u=>u()),t.current=new Map},[e]),(u,a)=>{t.current.set(u,a),r({})}};function ct(e){let r=e.type;return typeof r=="function"?r(e.props):"render"in r?r.render(e.props):e}function B({asChild:e,children:r},t){return e&&l.isValidElement(r)?l.cloneElement(ct(r),{ref:r.ref},t(r.props.children)):t(r)}var st={position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0"};function ht({className:e,...r}){return C.jsx(_,{"data-slot":"command",className:K("bg-popover text-popover-foreground flex h-full w-full flex-col overflow-hidden rounded-md",e),...r})}function bt({className:e,...r}){return C.jsxs("div",{"data-slot":"command-input-wrapper",className:"flex h-9 items-center gap-2 border-b px-3",children:[C.jsx(Me,{className:"size-4 shrink-0 opacity-50"}),C.jsx(_.Input,{"data-slot":"command-input",className:K("placeholder:text-muted-foreground flex h-10 w-full rounded-md bg-transparent py-3 text-sm outline-hidden disabled:cursor-not-allowed disabled:opacity-50",e),...r})]})}function yt({className:e,...r}){return C.jsx(_.List,{"data-slot":"command-list",className:K("max-h-[300px] scroll-py-1 overflow-x-hidden overflow-y-auto",e),...r})}function xt({...e}){return C.jsx(_.Empty,{"data-slot":"command-empty",className:"py-6 text-center text-sm",...e})}function wt({className:e,...r}){return C.jsx(_.Group,{"data-slot":"command-group",className:K("text-foreground [&_[cmdk-group-heading]]:text-muted-foreground overflow-hidden p-1 [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium",e),...r})}function Et({className:e,...r}){return C.jsx(_.Item,{"data-slot":"command-item",className:K("data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground [&_svg:not([class*='text-'])]:text-muted-foreground relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",e),...r})}export{ht as C,A as P,gt as S,bt as a,yt as b,xt as c,wt as d,Et as e};
@@ -1 +0,0 @@
1
- import{o as c}from"./index-DX9xeoQx.js";const o=[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]],t=c("copy",o);export{t as C};