convex-cms 0.0.3 → 0.0.5-alpha.0

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 (142) hide show
  1. package/README.md +109 -13
  2. package/admin-dist/nitro.json +1 -1
  3. package/admin-dist/public/assets/{CmsEmptyState-CRswfTzk.js → CmsEmptyState-CiMQwSQV.js} +2 -2
  4. package/admin-dist/public/assets/{CmsPageHeader-CirpXndm.js → CmsPageHeader-ohOq0luT.js} +1 -1
  5. package/admin-dist/public/assets/{CmsStatusBadge-CbEUpQu-.js → CmsStatusBadge-BdNf0V9v.js} +1 -1
  6. package/admin-dist/public/assets/CmsSurface-CWup6Jh7.js +1 -0
  7. package/admin-dist/public/assets/{CmsToolbar-BI2nZOXp.js → CmsToolbar-cEBlCHa3.js} +1 -1
  8. package/admin-dist/public/assets/{ContentEntryEditor-CBeCyK_m.js → ContentEntryEditor-BY5ypfUs.js} +1 -1
  9. package/admin-dist/public/assets/{ErrorState-BIVaWmom.js → ErrorState-C4nJ-ml4.js} +1 -1
  10. package/admin-dist/public/assets/{TaxonomyFilter-ChaY6Y_x.js → TaxonomyFilter-BgE_SR_O.js} +1 -1
  11. package/admin-dist/public/assets/{_contentTypeId-DQ8k_Rvw.js → _contentTypeId-DtZectcC.js} +1 -1
  12. package/admin-dist/public/assets/{_entryId-CKU_glsK.js → _entryId-BpSmrfAm.js} +1 -1
  13. package/admin-dist/public/assets/alert-Bf2l8kxw.js +1 -0
  14. package/admin-dist/public/assets/{badge-hvUOzpVZ.js → badge-qPrc4AUM.js} +1 -1
  15. package/admin-dist/public/assets/{circle-check-big-CF_pR17r.js → circle-check-big-Dgozy3vV.js} +1 -1
  16. package/admin-dist/public/assets/{command-DU82cJlt.js → command-QOmNhlb0.js} +1 -1
  17. package/admin-dist/public/assets/content-OEBGlxg1.js +1 -0
  18. package/admin-dist/public/assets/content-types-CjQliqVV.js +2 -0
  19. package/admin-dist/public/assets/{globals-CS6BZ0zp.css → globals-hAmgC66w.css} +1 -1
  20. package/admin-dist/public/assets/index-BH_ECMhv.js +1 -0
  21. package/admin-dist/public/assets/{label-KNtpL71g.js → label-DCsUdvFh.js} +1 -1
  22. package/admin-dist/public/assets/{link-2-Bw2aI4V4.js → link-2-Czw1N61H.js} +1 -1
  23. package/admin-dist/public/assets/{list-sYepHjt_.js → list-DtCsXj8-.js} +1 -1
  24. package/admin-dist/public/assets/{main-CKj5yfEi.js → main-CXgkZMhe.js} +3 -3
  25. package/admin-dist/public/assets/{media-Bkrkffm7.js → media-DTJ3-ViE.js} +1 -1
  26. package/admin-dist/public/assets/{new._contentTypeId-C3LstjNs.js → new._contentTypeId-CoTDxKzf.js} +1 -1
  27. package/admin-dist/public/assets/{plus-DUn8v_Xf.js → plus-xCFJK0RC.js} +1 -1
  28. package/admin-dist/public/assets/{rotate-ccw-DJEoHcRI.js → rotate-ccw-DIqK63wY.js} +1 -1
  29. package/admin-dist/public/assets/scroll-area-B-yrE66a.js +1 -0
  30. package/admin-dist/public/assets/{search-MuAUDJKR.js → search-CbCbboeU.js} +1 -1
  31. package/admin-dist/public/assets/select-Co3TZFJb.js +1 -0
  32. package/admin-dist/public/assets/settings-BspTTv_o.js +1 -0
  33. package/admin-dist/public/assets/switch-CfavASmR.js +1 -0
  34. package/admin-dist/public/assets/tabs-CN5s5u2W.js +1 -0
  35. package/admin-dist/public/assets/tanstack-adapter-npeE3RdY.js +1 -0
  36. package/admin-dist/public/assets/taxonomies-CgG46fIF.js +1 -0
  37. package/admin-dist/public/assets/{textarea-BTy7nwzR.js → textarea-BJ0XFZpT.js} +1 -1
  38. package/admin-dist/public/assets/trash-B3daldm5.js +1 -0
  39. package/admin-dist/public/assets/{triangle-alert-E52Vfeuh.js → triangle-alert-BZRcqsUg.js} +1 -1
  40. package/admin-dist/public/assets/useBreadcrumbLabel-DwZlwvFF.js +1 -0
  41. package/admin-dist/public/assets/{usePermissions-Basjs9BT.js → usePermissions-C1JQhfqb.js} +1 -1
  42. package/admin-dist/server/_chunks/_libs/@tanstack/react-router.mjs +7 -0
  43. package/admin-dist/server/_ssr/{badge-6BsP37vG.mjs → CmsButton-B45JAKR1.mjs} +33 -33
  44. package/admin-dist/server/_ssr/{CmsEmptyState-DU7-7-mV.mjs → CmsEmptyState-D_BQFAVR.mjs} +2 -2
  45. package/admin-dist/server/_ssr/{CmsPageHeader-CseW0AHm.mjs → CmsPageHeader-CrUZA59A.mjs} +1 -1
  46. package/admin-dist/server/_ssr/{CmsStatusBadge-B_pi4KCp.mjs → CmsStatusBadge-B-sj6yaj.mjs} +2 -2
  47. package/admin-dist/server/_ssr/CmsSurface-DKJZhpjk.mjs +44 -0
  48. package/admin-dist/server/_ssr/{CmsToolbar-X75ex6ek.mjs → CmsToolbar-ByaW5iXf.mjs} +2 -2
  49. package/admin-dist/server/_ssr/{ContentEntryEditor-CepusRsA.mjs → ContentEntryEditor-D3_Jb1dq.mjs} +11 -11
  50. package/admin-dist/server/_ssr/{TaxonomyFilter-Bwrq0-cz.mjs → TaxonomyFilter-BRJkuCtA.mjs} +4 -4
  51. package/admin-dist/server/_ssr/{_contentTypeId-BqYKEcLr.mjs → _contentTypeId-B9kA6CaM.mjs} +11 -11
  52. package/admin-dist/server/_ssr/{_entryId-CRfnqeDf.mjs → _entryId-BddcMkZN.mjs} +14 -14
  53. package/admin-dist/server/_ssr/_tanstack-start-manifest_v-Dd7AmelK.mjs +4 -0
  54. package/admin-dist/server/_ssr/{command-fy8epIKf.mjs → command-CGtVr8Gb.mjs} +1 -1
  55. package/admin-dist/server/_ssr/{content-B5RhL7uW.mjs → content-D1tbeOd0.mjs} +201 -86
  56. package/admin-dist/server/_ssr/{content-types-BIOqCQYN.mjs → content-types-BZqY_BER.mjs} +279 -103
  57. package/admin-dist/server/_ssr/{index-DHSHDPt1.mjs → index-BIdq4xaC.mjs} +88 -17
  58. package/admin-dist/server/_ssr/index.mjs +2 -2
  59. package/admin-dist/server/_ssr/{label-C8Dko1j7.mjs → label-T-QNKAr6.mjs} +1 -1
  60. package/admin-dist/server/_ssr/{media-CSx3XttC.mjs → media-C-xqjBrl.mjs} +40 -40
  61. package/admin-dist/server/_ssr/{new._contentTypeId-DzanEZQM.mjs → new._contentTypeId-DWic9cRq.mjs} +13 -13
  62. package/admin-dist/server/_ssr/{router-DDWcF-kt.mjs → router-D1BMAMJT.mjs} +11 -11
  63. package/admin-dist/server/_ssr/{scroll-area-bjPYwhXN.mjs → scroll-area-C0pic_WA.mjs} +1 -1
  64. package/admin-dist/server/_ssr/{select-BUhDDf4T.mjs → select-CqmuN2F6.mjs} +1 -1
  65. package/admin-dist/server/_ssr/{settings-DAsxnw2q.mjs → settings-CAkncGGV.mjs} +211 -129
  66. package/admin-dist/server/_ssr/{switch-BgyRtQ1Z.mjs → switch-CgmuJkT9.mjs} +1 -1
  67. package/admin-dist/server/_ssr/{tabs-DzMdRB1A.mjs → tabs-CnMj0aRy.mjs} +5 -3
  68. package/admin-dist/server/_ssr/tanstack-adapter-BXZrMauE.mjs +119 -0
  69. package/admin-dist/server/_ssr/{taxonomies-C8j8g5Q5.mjs → taxonomies-thl3BfVm.mjs} +168 -68
  70. package/admin-dist/server/_ssr/{textarea-9jNeYJSc.mjs → textarea-4K5OJgeh.mjs} +1 -1
  71. package/admin-dist/server/_ssr/{trash-DYMxwhZB.mjs → trash-B40Gx5zP.mjs} +206 -86
  72. package/admin-dist/server/_ssr/{useBreadcrumbLabel-FNSAr2Ha.mjs → useBreadcrumbLabel-rn-fL4zV.mjs} +1 -1
  73. package/admin-dist/server/_ssr/{usePermissions-BJGGahrJ.mjs → usePermissions-CKeM6_Vw.mjs} +1 -1
  74. package/admin-dist/server/index.mjs +194 -180
  75. package/dist/cli/commands/init.d.ts +6 -0
  76. package/dist/cli/commands/init.d.ts.map +1 -0
  77. package/dist/cli/commands/init.js +156 -0
  78. package/dist/cli/commands/init.js.map +1 -0
  79. package/dist/cli/index.js +6 -0
  80. package/dist/cli/index.js.map +1 -1
  81. package/dist/client/admin-config.d.ts +2 -2
  82. package/dist/client/admin-config.js +2 -2
  83. package/dist/client/adminApi.d.ts +1877 -1851
  84. package/dist/client/adminApi.d.ts.map +1 -1
  85. package/dist/client/adminApi.js +649 -629
  86. package/dist/client/adminApi.js.map +1 -1
  87. package/dist/client/agentTools.d.ts +7 -17
  88. package/dist/client/agentTools.d.ts.map +1 -1
  89. package/dist/client/agentTools.js +4 -4
  90. package/dist/client/index.d.ts +4 -4
  91. package/dist/client/index.d.ts.map +1 -1
  92. package/dist/client/index.js +4 -4
  93. package/dist/client/index.js.map +1 -1
  94. package/dist/client/schema/codegen.d.ts +2 -2
  95. package/dist/client/schema/codegen.d.ts.map +1 -1
  96. package/dist/client/schema/codegen.js +3 -3
  97. package/dist/client/schema/codegen.js.map +1 -1
  98. package/dist/client/schema/defineContentType.d.ts +3 -3
  99. package/dist/client/schema/defineContentType.js +3 -3
  100. package/dist/client/schema/index.d.ts +7 -7
  101. package/dist/client/schema/index.d.ts.map +1 -1
  102. package/dist/client/schema/index.js +5 -5
  103. package/dist/client/schema/index.js.map +1 -1
  104. package/dist/client/schema/schemaDrift.d.ts +1 -1
  105. package/dist/client/schema/schemaDrift.js +1 -1
  106. package/dist/client/schema/typedClient.d.ts +2 -2
  107. package/dist/client/schema/typedClient.js +2 -2
  108. package/dist/client/schema/types.d.ts +1 -1
  109. package/dist/client/schema/types.js +1 -1
  110. package/dist/client/wrapper.d.ts +108 -65
  111. package/dist/client/wrapper.d.ts.map +1 -1
  112. package/dist/client/wrapper.js +22 -22
  113. package/dist/client/wrapper.js.map +1 -1
  114. package/dist/component/convex.config.d.ts +2 -2
  115. package/dist/component/convex.config.js +2 -2
  116. package/dist/component/index.d.ts +1 -1
  117. package/dist/component/index.js +1 -1
  118. package/dist/component/lib/ragContentChunker.d.ts +1 -1
  119. package/dist/component/lib/ragContentChunker.js +1 -1
  120. package/dist/component/roles.d.ts +1 -1
  121. package/dist/component/roles.js +1 -1
  122. package/dist/react/index.d.ts +2 -2
  123. package/dist/react/index.d.ts.map +1 -1
  124. package/dist/react/index.js +13 -7
  125. package/dist/react/index.js.map +1 -1
  126. package/dist/test.d.ts +2 -2
  127. package/dist/test.js +2 -2
  128. package/package.json +31 -11
  129. package/admin-dist/public/assets/alert-BXjTqrwQ.js +0 -1
  130. package/admin-dist/public/assets/content-_LXl3pp7.js +0 -1
  131. package/admin-dist/public/assets/content-types-KjxaXGxY.js +0 -2
  132. package/admin-dist/public/assets/index-DNGIZHL-.js +0 -1
  133. package/admin-dist/public/assets/scroll-area-DfIlT0in.js +0 -1
  134. package/admin-dist/public/assets/select-BD29IXCI.js +0 -1
  135. package/admin-dist/public/assets/settings-DmMyn_6A.js +0 -1
  136. package/admin-dist/public/assets/switch-h3Rrnl5i.js +0 -1
  137. package/admin-dist/public/assets/tabs-imc8h-Dp.js +0 -1
  138. package/admin-dist/public/assets/taxonomies-dAsrT65H.js +0 -1
  139. package/admin-dist/public/assets/trash-SAWKZZHv.js +0 -1
  140. package/admin-dist/public/assets/useBreadcrumbLabel-BECBMCzM.js +0 -1
  141. package/admin-dist/server/_ssr/_tanstack-start-manifest_v-BwDlABVk.mjs +0 -4
  142. package/admin-dist/server/_ssr/alert-CVt45UUP.mjs +0 -92
@@ -1 +1 @@
1
- import{d as se,r as a,j as e,T as Q,f as es,F as ss,I as de,c as P,u as A,a as y,b as E,B as As,L as Qe,D as ts,k as as,l as is,m as q,E as Es,n as ve,H as ls,o as be,g as Ps,p as Bs}from"./main-CKj5yfEi.js";import{C as rs,F as ns,M as os,V as cs,T as Is,a as Rs,b as Ge,U as Ls,c as $s}from"./tabs-imc8h-Dp.js";import{C as Us}from"./CmsPageHeader-CirpXndm.js";import{C as Vs}from"./CmsToolbar-BI2nZOXp.js";import{D as ye,d as Ne,e as Ce,I as O,c as ze,a as Xe,C as ge,f as Ye,g as Ze,b as je}from"./CmsEmptyState-CRswfTzk.js";import{C as h,X as ae,B as ds}from"./badge-hvUOzpVZ.js";import{T as qs}from"./TaxonomyFilter-ChaY6Y_x.js";import{L as ms}from"./label-KNtpL71g.js";import{V as Hs,S as Ws,a as Ks,b as Os,c as Qs,d as ee}from"./select-BD29IXCI.js";import{P as Fe,a as Gs,T as us}from"./textarea-BTy7nwzR.js";import{P as Xs}from"./plus-DUn8v_Xf.js";import{L as Ys}from"./link-2-Bw2aI4V4.js";import{R as ke}from"./rotate-ccw-DJEoHcRI.js";import{S as Je}from"./search-MuAUDJKR.js";import"./command-DU82cJlt.js";const Zs=[["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"}]],Js=se("copy",Zs);const et=[["path",{d:"M12 15V3",key:"m9g1x1"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["path",{d:"m7 10 5 5 5-5",key:"brsn70"}]],we=se("download",et);const st=[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"12",cy:"5",r:"1",key:"gxeob9"}],["circle",{cx:"12",cy:"19",r:"1",key:"lyex9k"}]],tt=se("ellipsis-vertical",st);const at=[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"19",cy:"12",r:"1",key:"1wjl8i"}],["circle",{cx:"5",cy:"12",r:"1",key:"1pcz8c"}]],it=se("ellipsis",at);const lt=[["path",{d:"M2 9V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2v-1",key:"fm4g5t"}],["path",{d:"M2 13h10",key:"pgb2dq"}],["path",{d:"m9 16 3-3-3-3",key:"6m91ic"}]],Se=se("folder-input",lt);const rt=[["path",{d:"M12 10v6",key:"1bos4e"}],["path",{d:"M9 13h6",key:"1uhe8q"}],["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"}]],nt=se("folder-plus",rt);function ot(s){return s?s.startsWith("image/")?"image":s.startsWith("video/")?"video":s.startsWith("audio/")?"audio":s==="application/pdf"||s.includes("document")||s.includes("sheet")||s.includes("presentation")||s.startsWith("text/")?"document":"other":"other"}function ct(s){if(!s||s===0)return"0 B";const l=1024,i=["B","KB","MB","GB"],c=Math.floor(Math.log(s)/Math.log(l));return`${parseFloat((s/Math.pow(l,c)).toFixed(1))} ${i[c]}`}function dt(s){return new Date(s).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric",hour:"numeric",minute:"2-digit"})}function mt(s,l="size-16"){const i={className:l};switch(s){case"image":return e.jsx(de,{...i});case"video":return e.jsx(cs,{...i});case"audio":return e.jsx(os,{...i});case"document":return e.jsx(ss,{...i});default:return e.jsx(ns,{...i})}}function ut({asset:s,assets:l,currentIndex:i,open:c,onOpenChange:r,onNavigate:p,onEdit:u,onDelete:g}){const j=i>0,N=i<l.length-1,o=a.useCallback(()=>{j&&p(i-1)},[j,i,p]),x=a.useCallback(()=>{N&&p(i+1)},[N,i,p]),v=a.useCallback(m=>{if(c)switch(m.key){case"ArrowLeft":m.preventDefault(),o();break;case"ArrowRight":m.preventDefault(),x();break;case"Escape":m.preventDefault(),r(!1);break}},[c,o,x,r]);a.useEffect(()=>(window.addEventListener("keydown",v),()=>window.removeEventListener("keydown",v)),[v]);const C=a.useCallback(()=>{if(!s?.url)return;const m=document.createElement("a");m.href=s.url,m.download=s.name,m.target="_blank",document.body.appendChild(m),m.click(),document.body.removeChild(m)},[s]),k=a.useCallback(async()=>{s?.url&&await navigator.clipboard.writeText(s.url)},[s]);if(!s)return null;const F=ot(s.mimeType),T=F==="image",d=!!s.url;return e.jsx(ye,{open:c,onOpenChange:r,children:e.jsxs(Ne,{className:"flex h-[90vh] w-[95vw] max-w-[1400px] flex-col gap-0 overflow-hidden p-0 sm:max-w-[1400px]",showCloseButton:!1,children:[e.jsx(Hs,{children:e.jsxs(Ce,{children:["Preview: ",s.name]})}),e.jsxs("div",{className:"flex items-center justify-between border-b px-4 py-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("h2",{className:"truncate text-lg font-semibold",title:s.name,children:s.name}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:[i+1," of ",l.length]})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(h,{variant:"ghost",size:"icon",onClick:k,disabled:!s.url,title:"Copy URL",children:e.jsx(Js,{className:"size-4"})}),e.jsx(h,{variant:"ghost",size:"icon",onClick:C,disabled:!s.url,title:"Download",children:e.jsx(we,{className:"size-4"})}),u&&e.jsx(h,{variant:"ghost",size:"icon",onClick:()=>u(s),title:"Edit",children:e.jsx(Fe,{className:"size-4"})}),g&&e.jsx(h,{variant:"ghost",size:"icon",onClick:()=>g(s),title:"Delete",className:"text-destructive hover:text-destructive",children:e.jsx(Q,{className:"size-4"})}),e.jsx(h,{variant:"ghost",size:"icon",onClick:()=>r(!1),title:"Close (Esc)",children:e.jsx(ae,{className:"size-4"})})]})]}),e.jsxs("div",{className:"flex min-h-0 flex-1",children:[e.jsxs("div",{className:"relative flex flex-1 items-center justify-center bg-zinc-950",children:[j&&e.jsx("button",{onClick:o,className:"absolute left-4 z-10 flex size-10 items-center justify-center rounded-full bg-black/50 text-white transition-colors hover:bg-black/70",title:"Previous (←)",children:e.jsx(rs,{className:"size-6"})}),N&&e.jsx("button",{onClick:x,className:"absolute right-4 z-10 flex size-10 items-center justify-center rounded-full bg-black/50 text-white transition-colors hover:bg-black/70",title:"Next (→)",children:e.jsx(es,{className:"size-6"})}),T&&d?e.jsx("img",{src:s.url,alt:s.altText||s.title||s.name,className:"max-h-full max-w-full object-contain"}):e.jsxs("div",{className:"flex flex-col items-center gap-4 text-zinc-400",children:[mt(F),e.jsx("p",{className:"text-sm",children:T&&!d?"Image URL not available":"Preview not available for this file type"}),d&&e.jsxs(h,{variant:"secondary",onClick:C,children:[e.jsx(we,{className:"mr-2 size-4"}),"Download to view"]})]})]}),e.jsx("div",{className:"w-72 shrink-0 overflow-y-auto border-l bg-background",children:e.jsxs("div",{className:"space-y-4 p-4",children:[e.jsx("h3",{className:"font-semibold",children:"File Information"}),e.jsx(V,{label:"Filename",value:s.name}),s.title&&e.jsx(V,{label:"Title",value:s.title}),s.description&&e.jsx(V,{label:"Description",value:s.description}),s.altText&&e.jsx(V,{label:"Alt Text",value:s.altText}),e.jsxs("div",{className:"border-t pt-4",children:[e.jsx(V,{label:"Type",value:F,capitalize:!0}),s.mimeType&&e.jsx(V,{label:"MIME Type",value:s.mimeType}),e.jsx(V,{label:"Size",value:ct(s.size)}),s.width&&s.height&&e.jsx(V,{label:"Dimensions",value:`${s.width} × ${s.height} px`})]}),e.jsx("div",{className:"border-t pt-4",children:e.jsx(V,{label:"Uploaded",value:dt(s._creationTime)})}),s.tags&&s.tags.length>0&&e.jsxs("div",{className:"border-t pt-4",children:[e.jsx("p",{className:"mb-2 text-xs font-medium text-muted-foreground",children:"Tags"}),e.jsx("div",{className:"flex flex-wrap gap-1",children:s.tags.map(m=>e.jsx("span",{className:"rounded-full bg-muted px-2 py-0.5 text-xs",children:m},m))})]})]})})]})]})})}function V({label:s,value:l,capitalize:i}){return e.jsxs("div",{className:"space-y-0.5",children:[e.jsx("p",{className:"text-xs font-medium text-muted-foreground",children:s}),e.jsx("p",{className:P("break-words text-sm",i&&"capitalize"),children:l})]})}function X({label:s,description:l,error:i,required:c,htmlFor:r,className:p,children:u}){return e.jsxs("div",{className:P("space-y-2",p),children:[s&&e.jsxs(ms,{htmlFor:r,className:P("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",i&&"text-destructive"),children:[s,c&&e.jsx("span",{className:"ml-1 text-destructive",children:"*"})]}),u,l&&!i&&e.jsx("p",{className:"text-[13px] text-muted-foreground",children:l}),i&&e.jsx("p",{className:"text-[13px] font-medium text-destructive",children:i})]})}function xt({mediaId:s,taxonomyId:l,taxonomyName:i="Tags",allowCreate:c=!0,disabled:r=!1,className:p=""}){const[u,g]=a.useState(""),[j,N]=a.useState(!1),[o,x]=a.useState(0),[v,C]=a.useState(!1),[k,F]=a.useState(!1),T=a.useRef(null),d=a.useRef(null),m=a.useRef(null),B=A(y.taxonomies.getTermsByMedia,{mediaId:s,taxonomyId:l}),w=B?.map(n=>n._id)??[],f=A(y.taxonomies.suggestTerms,{taxonomyId:l,query:u,limit:10,excludeIds:w})??[],I=E(y.taxonomies.setMediaTerms),H=E(y.taxonomies.createTermAndAddToMedia);a.useEffect(()=>{function n(z){m.current&&!m.current.contains(z.target)&&N(!1)}return document.addEventListener("mousedown",n),()=>document.removeEventListener("mousedown",n)},[]);const G=a.useCallback(async n=>{if(!w.includes(n)){F(!0);try{await I({mediaId:s,taxonomyId:l,termIds:[...w,n]})}catch(z){console.error("Failed to add tag:",z)}finally{F(!1),g(""),N(!1),x(0),T.current?.focus()}}},[s,l,w,I]),te=a.useCallback(async n=>{F(!0);try{await I({mediaId:s,taxonomyId:l,termIds:w.filter(z=>z!==n)})}catch(z){console.error("Failed to remove tag:",z)}finally{F(!1)}},[s,l,w,I]),Y=a.useCallback(async()=>{if(!(!u.trim()||!c)){C(!0);try{await H({taxonomyId:l,name:u.trim(),mediaId:s}),g(""),N(!1),x(0)}catch(n){console.error("Failed to create tag:",n)}finally{C(!1)}}},[u,c,l,s,H]),ie=n=>{if(!r)switch(n.key){case"ArrowDown":n.preventDefault(),x(z=>z<f.length-1?z+1:z);break;case"ArrowUp":n.preventDefault(),x(z=>z>0?z-1:0);break;case"Enter":n.preventDefault(),f.length>0&&o<f.length?G(f[o]._id):u.trim()&&c&&Y();break;case"Escape":N(!1);break;case"Backspace":u===""&&w.length>0&&te(w[w.length-1]);break}};a.useEffect(()=>{if(d.current&&j){const n=d.current.querySelector(`[data-index="${o}"]`);n&&n.scrollIntoView({block:"nearest"})}},[o,j]);const U=f.filter(n=>!w.includes(n._id)),M=c&&u.trim()&&!U.some(n=>n.name.toLowerCase()===u.trim().toLowerCase());return e.jsxs("div",{className:P("space-y-2",p),children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium text-muted-foreground",children:[e.jsx(Gs,{className:"size-4"}),i]}),e.jsxs("div",{ref:m,className:P("relative rounded-md border border-input bg-background",r&&"opacity-50"),children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 p-2",children:[(B??[]).map(n=>e.jsxs(ds,{variant:"secondary",className:"gap-1 pr-1",style:n.color?{backgroundColor:n.color,color:"#fff"}:void 0,children:[n.name,!r&&e.jsx(As,{type:"button",variant:"ghost",size:"icon",className:"size-4 hover:bg-transparent",onClick:()=>te(n._id),disabled:k,"aria-label":`Remove ${n.name}`,children:e.jsx(ae,{className:"size-3"})})]},n._id)),!r&&e.jsx(O,{ref:T,type:"text",className:"h-7 min-w-[120px] flex-1 border-0 bg-transparent px-1 shadow-none focus-visible:ring-0",value:u,onChange:n=>{g(n.target.value),N(!0),x(0)},onFocus:()=>N(!0),onKeyDown:ie,placeholder:w.length===0?"Add tags...":"",disabled:r||v||k})]}),j&&(U.length>0||M)&&e.jsxs("div",{ref:d,className:"absolute left-0 right-0 top-full z-50 mt-1 max-h-48 overflow-auto rounded-md border bg-popover shadow-lg",role:"listbox",children:[U.map((n,z)=>e.jsxs("div",{"data-index":z,className:P("flex cursor-pointer items-center gap-2 px-3 py-2 text-sm",z===o&&"bg-accent"),onClick:()=>G(n._id),role:"option","aria-selected":z===o,children:[n.color&&e.jsx("span",{className:"size-2.5 rounded-full",style:{backgroundColor:n.color}}),e.jsx("span",{className:"flex-1",children:n.name}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:[n.usageCount," uses"]})]},n._id)),M&&e.jsxs("div",{"data-index":U.length,className:P("flex cursor-pointer items-center gap-2 px-3 py-2 text-sm",U.length===o&&"bg-accent"),onClick:Y,role:"option","aria-selected":U.length===o,children:[v?e.jsx(Qe,{className:"size-4 animate-spin"}):e.jsx(Xs,{className:"size-4"}),e.jsxs("span",{children:['Create "',u.trim(),'"']})]})]}),(k||v)&&e.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-background/50",children:e.jsx(Qe,{className:"size-4 animate-spin"})})]})]})}function ht({asset:s,open:l,onOpenChange:i,onSaved:c}){const[r,p]=a.useState(""),[u,g]=a.useState(""),[j,N]=a.useState(""),[o,x]=a.useState(""),[v,C]=a.useState(""),[k,F]=a.useState(!1),[T,d]=a.useState(""),m=E(y.media.updateAsset),w=A(y.taxonomies.list,{isActive:!0,paginationOpts:{numItems:50,cursor:null}})?.page??[];a.useEffect(()=>{s&&(p(s.name),g(s.title||""),N(s.description||""),x(s.altText||""),C(s.tags?.join(", ")||""),d(""))},[s]);const L=a.useCallback(async()=>{if(s){if(!r.trim()){d("Filename is required");return}F(!0),d("");try{const f=v.split(",").map(I=>I.trim()).filter(Boolean);await m({id:s._id,name:r.trim(),title:u.trim()||void 0,description:j.trim()||void 0,altText:o.trim()||void 0,tags:f.length>0?f:void 0}),c?.(),i(!1)}catch(f){d(f instanceof Error?f.message:"Failed to update asset")}finally{F(!1)}}},[s,r,u,j,o,v,m,c,i]);return s?e.jsx(ze,{open:l,onOpenChange:i,title:"Edit File",size:"md",footer:e.jsxs(e.Fragment,{children:[e.jsx(h,{variant:"outline",onClick:()=>i(!1),disabled:k,children:"Cancel"}),e.jsx(h,{onClick:L,loading:k,children:"Save Changes"})]}),children:e.jsxs("div",{className:"space-y-4",children:[T&&e.jsx("div",{className:"rounded-md bg-destructive/10 p-3 text-sm text-destructive",children:T}),e.jsx(X,{label:"Filename",required:!0,htmlFor:"asset-name",children:e.jsx(O,{id:"asset-name",value:r,onChange:f=>p(f.target.value),placeholder:"Enter filename"})}),e.jsx(X,{label:"Title",description:"A human-readable title for the file",htmlFor:"asset-title",children:e.jsx(O,{id:"asset-title",value:u,onChange:f=>g(f.target.value),placeholder:"Enter title (optional)"})}),e.jsx(X,{label:"Description",description:"A brief description of the file",htmlFor:"asset-description",children:e.jsx(us,{id:"asset-description",value:j,onChange:f=>N(f.target.value),placeholder:"Enter description (optional)",rows:3})}),e.jsx(X,{label:"Alt Text",description:"Alternative text for accessibility (important for images)",htmlFor:"asset-alt",children:e.jsx(O,{id:"asset-alt",value:o,onChange:f=>x(f.target.value),placeholder:"Describe the image content"})}),e.jsx(X,{label:"Quick Tags",description:"Comma-separated tags for simple organization",htmlFor:"asset-tags",children:e.jsx(O,{id:"asset-tags",value:v,onChange:f=>C(f.target.value),placeholder:"e.g., hero, blog, product"})}),w.length>0&&s&&e.jsxs("div",{className:"space-y-4 pt-2 border-t",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Organize with taxonomy terms"}),w.map(f=>e.jsx(xt,{mediaId:s._id,taxonomyId:f._id,taxonomyName:f.displayName,allowCreate:f.allowInlineCreation,disabled:k},f._id))]})]})}):null}function pt({folder:s,open:l,onOpenChange:i,onSaved:c}){const[r,p]=a.useState(""),[u,g]=a.useState(""),[j,N]=a.useState(!1),[o,x]=a.useState(""),v=E(y.media.updateFolder);a.useEffect(()=>{s&&(p(s.name),g(s.description||""),x(""))},[s]);const C=a.useCallback(async()=>{if(s){if(!r.trim()){x("Folder name is required");return}N(!0),x("");try{await v({id:s._id,name:r.trim(),description:u.trim()||void 0}),c?.(),i(!1)}catch(k){x(k instanceof Error?k.message:"Failed to update folder")}finally{N(!1)}}},[s,r,u,v,c,i]);return s?e.jsx(ze,{open:l,onOpenChange:i,title:"Edit Folder",size:"sm",footer:e.jsxs(e.Fragment,{children:[e.jsx(h,{variant:"outline",onClick:()=>i(!1),disabled:j,children:"Cancel"}),e.jsx(h,{onClick:C,loading:j,children:"Save Changes"})]}),children:e.jsxs("div",{className:"space-y-4",children:[o&&e.jsx("div",{className:"rounded-md bg-destructive/10 p-3 text-sm text-destructive",children:o}),e.jsx(X,{label:"Folder Name",required:!0,htmlFor:"folder-name",children:e.jsx(O,{id:"folder-name",value:r,onChange:k=>p(k.target.value),placeholder:"Enter folder name"})}),e.jsx(X,{label:"Description",description:"A brief description of the folder contents",htmlFor:"folder-description",children:e.jsx(us,{id:"folder-description",value:u,onChange:k=>g(k.target.value),placeholder:"Enter description (optional)",rows:3})})]})}):null}function ft({asset:s,onView:l,onEdit:i,onMove:c,onDelete:r}){const p=()=>{if(!s.url)return;const g=document.createElement("a");g.href=s.url,g.download=s.name,g.target="_blank",document.body.appendChild(g),g.click(),document.body.removeChild(g)},u=async()=>{s.url&&await navigator.clipboard.writeText(s.url)};return e.jsxs(ts,{children:[e.jsx(as,{asChild:!0,children:e.jsx(h,{variant:"ghost",size:"icon-sm",className:"opacity-0 group-hover:opacity-100",onClick:g=>g.stopPropagation(),children:e.jsx(tt,{className:"size-4"})})}),e.jsxs(is,{side:"bottom",onClick:g=>g.stopPropagation(),children:[l&&e.jsxs(q,{onClick:l,children:[e.jsx(Es,{className:"mr-2 size-4"}),"View Details"]}),i&&e.jsxs(q,{onClick:i,children:[e.jsx(Fe,{className:"mr-2 size-4"}),"Edit"]}),c&&e.jsxs(q,{onClick:c,children:[e.jsx(Se,{className:"mr-2 size-4"}),"Move to..."]}),e.jsx(ve,{}),e.jsxs(q,{onClick:p,disabled:!s.url,children:[e.jsx(we,{className:"mr-2 size-4"}),"Download"]}),e.jsxs(q,{onClick:u,disabled:!s.url,children:[e.jsx(Ys,{className:"mr-2 size-4"}),"Copy URL"]}),r&&e.jsxs(e.Fragment,{children:[e.jsx(ve,{}),e.jsxs(q,{onClick:r,className:"text-destructive focus:text-destructive",children:[e.jsx(Q,{className:"mr-2 size-4"}),"Delete"]})]})]})]})}function gt({folder:s,onEdit:l,onMove:i,onDelete:c}){return e.jsxs(ts,{children:[e.jsx(as,{asChild:!0,children:e.jsx(h,{variant:"ghost",size:"icon-sm",className:"opacity-0 group-hover:opacity-100",onClick:r=>r.stopPropagation(),children:e.jsx(it,{className:"size-4"})})}),e.jsxs(is,{align:"end",onClick:r=>r.stopPropagation(),children:[l&&e.jsxs(q,{onClick:l,children:[e.jsx(Fe,{className:"mr-2 size-4"}),"Rename"]}),i&&e.jsxs(q,{onClick:i,children:[e.jsx(Se,{className:"mr-2 size-4"}),"Move to..."]}),c&&e.jsxs(e.Fragment,{children:[e.jsx(ve,{}),e.jsxs(q,{onClick:c,className:"text-destructive focus:text-destructive",children:[e.jsx(Q,{className:"mr-2 size-4"}),"Delete"]})]})]})]})}function jt({selectedCount:s,onClear:l,onMove:i,onDelete:c,isDeleting:r}){return s===0?null:e.jsx("div",{className:"fixed inset-x-0 bottom-0 z-50 border-t bg-background/95 backdrop-blur supports-[backdrop-filter]:bg-background/80",children:e.jsxs("div",{className:"mx-auto flex max-w-7xl items-center justify-between px-6 py-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("span",{className:"text-sm font-medium",children:[s," ",s===1?"file":"files"," selected"]}),e.jsxs(h,{variant:"ghost",size:"sm",onClick:l,children:[e.jsx(ae,{className:"mr-1 size-4"}),"Clear"]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(h,{variant:"secondary",onClick:i,disabled:r,children:[e.jsx(Se,{className:"mr-2 size-4"}),"Move to..."]}),e.jsxs(h,{variant:"destructive",onClick:c,loading:r,children:[e.jsx(Q,{className:"mr-2 size-4"}),"Delete"]})]})]})})}function vt({selectedCount:s,onClear:l,onRestore:i,onPermanentDelete:c,isRestoring:r,isDeleting:p}){return s===0?null:e.jsx("div",{className:"fixed inset-x-0 bottom-0 z-50 border-t bg-background/95 backdrop-blur supports-[backdrop-filter]:bg-background/80",children:e.jsxs("div",{className:"mx-auto flex max-w-7xl items-center justify-between px-6 py-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("span",{className:"text-sm font-medium",children:[s," ",s===1?"file":"files"," selected"]}),e.jsxs(h,{variant:"ghost",size:"sm",onClick:l,children:[e.jsx(ae,{className:"mr-1 size-4"}),"Clear"]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(h,{variant:"secondary",onClick:i,loading:r,disabled:p,children:[e.jsx(ke,{className:"mr-2 size-4"}),"Restore"]}),e.jsxs(h,{variant:"danger",onClick:c,loading:p,disabled:r,children:[e.jsx(Q,{className:"mr-2 size-4"}),"Delete Forever"]})]})]})})}function bt({open:s,onOpenChange:l,assetIds:i,currentFolderId:c,onMoved:r}){const[p,u]=a.useState(void 0),[g,j]=a.useState(!1),[N,o]=a.useState(""),x=A(y.media.getFolderTree,{}),v=E(y.media.moveAssets),C=a.useMemo(()=>{if(!x)return[];const d=(m,B)=>x.filter(L=>L.parentId===m).flatMap(L=>[{...L,depth:B},...d(L._id,B+1)]);return d(void 0,0)},[x]),k=async()=>{if(i.length!==0){j(!0),o("");try{await v({assetIds:i,targetFolderId:p}),r?.(),l(!1)}catch(d){o(d instanceof Error?d.message:"Failed to move files")}finally{j(!1)}}},F=p===c,T=p===void 0;return e.jsx(ze,{open:s,onOpenChange:l,title:"Move Files",description:`Select a destination folder for ${i.length} ${i.length===1?"file":"files"}`,size:"sm",footer:e.jsxs(e.Fragment,{children:[e.jsx(h,{variant:"outline",onClick:()=>l(!1),disabled:g,children:"Cancel"}),e.jsx(h,{onClick:k,loading:g,disabled:F,children:"Move Here"})]}),children:e.jsxs("div",{className:"space-y-2",children:[N&&e.jsx("div",{className:"rounded-md bg-destructive/10 p-3 text-sm text-destructive",children:N}),e.jsxs("div",{className:"max-h-[300px] overflow-y-auto rounded-md border",children:[e.jsxs("button",{type:"button",className:P("flex w-full items-center gap-2 px-3 py-2 text-left text-sm transition-colors hover:bg-muted",T&&"bg-primary/10 text-primary",c===void 0&&"opacity-50"),onClick:()=>u(void 0),children:[e.jsx(ls,{className:"size-4"}),e.jsx("span",{className:"font-medium",children:"Root (All Files)"}),c===void 0&&e.jsx("span",{className:"ml-auto text-xs text-muted-foreground",children:"Current"})]}),C.map(d=>{const m=d._id===c,B=d._id===p;return e.jsxs("button",{type:"button",className:P("flex w-full items-center gap-2 px-3 py-2 text-left text-sm transition-colors hover:bg-muted",B&&"bg-primary/10 text-primary",m&&"opacity-50"),style:{paddingLeft:`${12+d.depth*20}px`},onClick:()=>u(d._id),children:[d.depth>0&&e.jsx(es,{className:"size-3 text-muted-foreground"}),e.jsx(be,{className:"size-4 text-amber-500"}),e.jsx("span",{className:"truncate",children:d.name}),m&&e.jsx("span",{className:"ml-auto text-xs text-muted-foreground",children:"Current"})]},d._id)}),C.length===0&&e.jsx("div",{className:"px-3 py-6 text-center text-sm text-muted-foreground",children:"No folders yet. Create folders to organize your files."})]}),F&&e.jsx("p",{className:"text-xs text-muted-foreground",children:"Files are already in this folder"})]})})}function yt(s){if(s===0)return"0 B";const l=1024,i=["B","KB","MB","GB"],c=Math.floor(Math.log(s)/Math.log(l));return`${parseFloat((s/Math.pow(l,c)).toFixed(1))} ${i[c]}`}function Nt(s){return new Date(s).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})}function Ct(s,l="size-6"){const i={className:l};switch(s){case"image":return e.jsx(de,{...i});case"video":return e.jsx(cs,{...i});case"audio":return e.jsx(os,{...i});case"document":return e.jsx(ss,{...i});default:return e.jsx(ns,{...i})}}function kt(s){return s?s.startsWith("image/")?"image":s.startsWith("video/")?"video":s.startsWith("audio/")?"audio":s==="application/pdf"||s.includes("document")||s.includes("sheet")||s.includes("presentation")||s.startsWith("text/")?"document":"other":"other"}function $t(){const{settings:s}=Ps(),l=Bs();a.useEffect(()=>{s&&!s.features.mediaManagement&&l({to:"/"})},[s,l]);const[i,c]=a.useState(void 0),[r,p]=a.useState(""),[u,g]=a.useState(""),[j,N]=a.useState([]),[o,x]=a.useState(new Set),[v,C]=a.useState(!1),[k,F]=a.useState(!1),[T,d]=a.useState(!1),[m,B]=a.useState(""),[w,L]=a.useState(!1),[f,I]=a.useState(""),[H,G]=a.useState(null),[te,Y]=a.useState(null),[ie,U]=a.useState(null),[M,n]=a.useState(null),[z,De]=a.useState(!1),[xs,Te]=a.useState(!1),[hs,me]=a.useState(!1),[Me,_e]=a.useState(!1),[Ae,ps]=a.useState("library"),[Ee,Z]=a.useState(!1),[Pe,Be]=a.useState(!1),[fs,le]=a.useState(!1),[J,re]=a.useState(null),S=Ae==="trash",_=A(y.media.listAssets,{folderId:S?void 0:i,type:u||void 0,search:r||void 0,deletedOnly:S?!0:void 0,paginationOpts:{numItems:100,cursor:null}}),ue=A(y.media.getTrashCount,{}),Ie=A(y.taxonomies.getMediaByTerm,j[0]?{termId:j[0]}:"skip"),Re=A(y.taxonomies.getMediaByTerm,j[1]?{termId:j[1]}:"skip"),Le=A(y.taxonomies.getMediaByTerm,j[2]?{termId:j[2]}:"skip"),xe=a.useMemo(()=>{if(j.length===0)return null;const t=new Set,b=[Ie,Re,Le];for(let D=0;D<j.length&&D<3;D++){const K=b[D];if(K?.page)for(const $ of K.page)t.add($._id)}return t},[j,Ie,Re,Le]),R=A(y.media.listFolders,{parentId:S?void 0:i,deletedOnly:S||void 0}),he=A(y.media.getFolder,i?{id:i}:"skip"),ne=A(y.media.getFolderTree,{}),$e=E(y.media.createFolder),oe=E(y.media.deleteAsset),Ue=E(y.media.deleteFolder),ce=E(y.media.restoreAsset),Ve=E(y.media.restoreFolder),qe=E(y.media.permanentDeleteAsset),He=E(y.media.bulkPermanentDeleteAssets),We=a.useMemo(()=>{if(!i||!ne)return[];const t=[];let b=ne.find(D=>D._id===i);for(;b;){t.unshift(b);const D=b.parentId;b=D?ne.find(K=>K._id===D):void 0}return t},[i,ne]),Ke=a.useCallback(t=>{c(t),p("")},[]),gs=a.useCallback(()=>{he?.parentId?c(he.parentId):c(void 0)},[he]),js=a.useCallback(()=>{c(void 0),p("")},[]),pe=a.useCallback(t=>{x(b=>{const D=new Set(b);return D.has(t)?D.delete(t):D.add(t),D})},[]),vs=a.useCallback(()=>{_?.page&&x(new Set(_.page.map(t=>t._id)))},[_?.page]),fe=a.useCallback(()=>{x(new Set)},[]),bs=a.useCallback(t=>{ps(t),x(new Set),C(!1)},[]),ys=a.useCallback(t=>{if(v)pe(t);else{const b=_?.page?.findIndex(D=>D._id===t)??-1;b!==-1&&G(b)}},[v,pe,_?.page]),Ns=a.useCallback(t=>{G(t)},[]),Cs=a.useCallback(async()=>{if(M){De(!0);try{M.type==="asset"?await oe({id:M.id}):await Ue({id:M.id}),n(null)}catch(t){console.error("Delete failed:",t)}finally{De(!1)}}},[M,oe,Ue]),ks=a.useCallback(async()=>{if(o.size!==0){_e(!0);try{const t=Array.from(o).map(b=>oe({id:b}));await Promise.all(t),x(new Set),C(!1),me(!1)}catch(t){console.error("Bulk delete failed:",t)}finally{_e(!1)}}},[o,oe]),ws=a.useCallback(()=>{x(new Set),C(!1)},[]),zs=a.useCallback(async t=>{Z(!0);try{await ce({id:t})}catch(b){console.error("Restore failed:",b)}finally{Z(!1)}},[ce]),Fs=a.useCallback(async()=>{if(o.size!==0){Z(!0);try{const t=Array.from(o).map(b=>ce({id:b}));await Promise.all(t),x(new Set),C(!1)}catch(t){console.error("Bulk restore failed:",t)}finally{Z(!1)}}},[o,ce]),Ss=a.useCallback(async t=>{Z(!0);try{await Ve({id:t})}catch(b){console.error("Restore folder failed:",b)}finally{Z(!1)}},[Ve]),Ds=a.useCallback(async()=>{if(J){Be(!0);try{J==="bulk"?(await He({ids:Array.from(o)}),x(new Set),C(!1)):await qe({id:J}),le(!1),re(null)}catch(t){console.error("Permanent delete failed:",t)}finally{Be(!1)}}},[J,qe,He,o]),Oe=a.useCallback(async()=>{if(!m.trim()){I("Folder name is required");return}L(!0),I("");try{await $e({name:m.trim(),parentId:i}),F(!1),B("")}catch(t){I(t instanceof Error?t.message:"Failed to create folder")}finally{L(!1)}},[m,i,$e]),Ts=a.useCallback(t=>{d(!1)},[]),Ms=_===void 0||R===void 0,W=a.useMemo(()=>{const t=_?.page??[];return xe===null?t:t.filter(b=>xe.has(b._id))},[_?.page,xe]);return e.jsxs("div",{className:"space-y-6 p-6",children:[e.jsx(Us,{title:"Media Library",description:"Upload, organize, and manage media assets for your content."}),e.jsx(Is,{value:Ae,onValueChange:t=>bs(t),children:e.jsxs(Rs,{children:[e.jsxs(Ge,{value:"library",children:[e.jsx(de,{className:"mr-1.5 size-4"}),"Library"]}),e.jsxs(Ge,{value:"trash",children:[e.jsx(Q,{className:"mr-1.5 size-4"}),"Trash",ue&&ue.total>0&&e.jsx(ds,{variant:"secondary",className:"ml-1.5",children:ue.total})]})]})}),!S&&e.jsxs("nav",{className:"flex items-center gap-1","aria-label":"Folder navigation",children:[e.jsxs("button",{className:P("flex items-center gap-1.5 rounded-md px-2 py-1 text-sm transition-colors",i?"text-muted-foreground hover:bg-muted hover:text-foreground":"bg-primary/10 font-medium text-primary"),onClick:js,children:[e.jsx(ls,{className:"size-4"}),e.jsx("span",{children:"All Files"})]}),We.map((t,b)=>e.jsxs("span",{className:"flex items-center",children:[e.jsx("span",{className:"mx-1 text-muted-foreground",children:"/"}),e.jsx("button",{className:P("rounded-md px-2 py-1 text-sm transition-colors",b===We.length-1?"bg-primary/10 font-medium text-primary":"text-muted-foreground hover:bg-muted hover:text-foreground"),onClick:()=>Ke(t._id),children:t.name})]},t._id))]}),e.jsx(Vs,{left:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("div",{className:"relative",children:[e.jsx(Je,{className:"absolute left-3 top-1/2 size-4 -translate-y-1/2 text-muted-foreground"}),e.jsx(O,{type:"search",placeholder:"Search files...",value:r,onChange:t=>p(t.target.value),className:"w-64 pl-9"}),r&&e.jsx("button",{className:"absolute right-2 top-1/2 -translate-y-1/2 rounded p-0.5 hover:bg-muted",onClick:()=>p(""),"aria-label":"Clear search",children:e.jsx(ae,{className:"size-4 text-muted-foreground"})})]}),e.jsxs(Ws,{value:u||"all",onValueChange:t=>g(t==="all"?"":t),children:[e.jsx(Ks,{className:"w-36",children:e.jsx(Os,{placeholder:"All Types"})}),e.jsxs(Qs,{children:[e.jsx(ee,{value:"all",children:"All Types"}),e.jsx(ee,{value:"image",children:"Images"}),e.jsx(ee,{value:"video",children:"Videos"}),e.jsx(ee,{value:"audio",children:"Audio"}),e.jsx(ee,{value:"document",children:"Documents"}),e.jsx(ee,{value:"other",children:"Other"})]})]}),e.jsx(qs,{selectedTermIds:j,onChange:N,placeholder:"Tags"}),_?.page&&_.page.length>0&&e.jsxs("label",{className:"flex cursor-pointer items-center gap-2 text-sm",children:[e.jsx(Xe,{checked:v,onCheckedChange:t=>{C(t),t||x(new Set)}}),"Selection Mode"]})]}),right:e.jsxs("div",{className:"flex items-center gap-2",children:[v&&o.size>0&&e.jsxs("span",{className:"text-sm text-muted-foreground",children:[o.size," selected"]}),v&&e.jsxs(e.Fragment,{children:[e.jsx(h,{variant:"secondary",size:"sm",onClick:vs,children:"Select All"}),e.jsx(h,{variant:"secondary",size:"sm",onClick:fe,children:"Clear"})]}),i&&!S&&e.jsxs(h,{variant:"secondary",onClick:gs,children:[e.jsx(rs,{className:"size-4"}),"Up"]}),!S&&e.jsxs(e.Fragment,{children:[e.jsxs(h,{variant:"secondary",onClick:()=>F(!0),children:[e.jsx(nt,{className:"size-4"}),"New Folder"]}),e.jsxs(h,{onClick:()=>d(!0),children:[e.jsx(Ls,{className:"size-4"}),"Upload Files"]})]})]})}),Ms?e.jsxs("div",{className:"flex flex-col items-center justify-center py-12",children:[e.jsx("div",{className:"size-8 animate-spin rounded-full border-2 border-muted border-t-primary"}),e.jsx("p",{className:"mt-4 text-sm text-muted-foreground",children:"Loading media library..."})]}):e.jsxs(e.Fragment,{children:[!S&&R&&R.length>0&&!r&&e.jsxs("section",{children:[e.jsx("h3",{className:"mb-3 text-sm font-medium text-muted-foreground",children:"Folders"}),e.jsx("div",{className:"grid grid-cols-2 gap-3 sm:grid-cols-4 md:grid-cols-6",children:R.map(t=>e.jsxs("div",{className:"group relative flex flex-col items-center gap-2 rounded-lg border bg-card p-4 text-center transition-colors hover:border-primary/50 hover:bg-muted/50 cursor-pointer",onClick:()=>Ke(t._id),children:[e.jsx("div",{className:"absolute right-2 top-2",children:e.jsx(gt,{folder:{_id:t._id,name:t.name},onEdit:()=>U({_id:t._id,name:t.name,description:t.description}),onDelete:()=>n({type:"folder",id:t._id,name:t.name})})}),e.jsx(be,{className:"size-10 text-amber-500"}),e.jsx("span",{className:"truncate text-sm font-medium",children:t.name})]},t._id))})]}),S&&R&&R.length>0&&e.jsxs("section",{children:[e.jsxs("h3",{className:"mb-3 text-sm font-medium text-muted-foreground",children:["Deleted Folders (",R.length,")"]}),e.jsx("div",{className:"grid grid-cols-2 gap-3 sm:grid-cols-4 md:grid-cols-6",children:R.map(t=>e.jsxs("div",{className:"group relative flex flex-col items-center gap-2 rounded-lg border border-destructive/20 bg-card p-4 text-center opacity-60",children:[e.jsx(be,{className:"size-10 text-amber-500/50"}),e.jsx("span",{className:"truncate text-sm font-medium",children:t.name}),e.jsxs(h,{variant:"secondary",size:"sm",onClick:()=>Ss(t._id),disabled:Ee,children:[e.jsx(ke,{className:"mr-1 size-3"}),"Restore"]})]},t._id))})]}),W.length>0?e.jsxs("section",{children:[!S&&R&&R.length>0&&!r&&e.jsx("h3",{className:"mb-3 text-sm font-medium text-muted-foreground",children:"Files"}),S&&e.jsxs("h3",{className:"mb-3 text-sm font-medium text-muted-foreground",children:["Deleted Files (",W.length,")"]}),e.jsx("div",{className:"grid grid-cols-2 gap-3 sm:grid-cols-4 md:grid-cols-6",children:W.map(t=>{const b=t._id,D=o.has(b),K=kt(t.mimeType);return e.jsxs("div",{className:P("group relative flex flex-col overflow-hidden rounded-lg border bg-card transition-all cursor-pointer hover:border-primary/50",D&&"border-primary ring-2 ring-primary/20"),onClick:()=>ys(b),children:[v&&e.jsx("div",{className:"absolute left-2 top-2 z-10",children:e.jsx(Xe,{checked:D,onCheckedChange:()=>pe(b),onClick:$=>$.stopPropagation(),className:"bg-white/80"})}),!v&&!S&&e.jsx("div",{className:"absolute right-2 top-2 z-10",children:e.jsx(ft,{asset:{_id:t._id,name:t.name,url:t.url},onView:()=>{const $=W.findIndex(_s=>_s._id===t._id);$!==-1&&G($)},onEdit:()=>Y({_id:t._id,name:t.name,title:t.title,description:t.description,altText:t.altText,tags:t.tags}),onDelete:()=>n({type:"asset",id:t._id,name:t.name})})}),!v&&S&&e.jsxs("div",{className:"absolute right-2 top-2 z-10 flex gap-1 opacity-0 group-hover:opacity-100",children:[e.jsx(h,{variant:"secondary",size:"icon-sm",onClick:$=>{$.stopPropagation(),zs(t._id)},title:"Restore",children:e.jsx(ke,{className:"size-4"})}),e.jsx(h,{variant:"danger",size:"icon-sm",onClick:$=>{$.stopPropagation(),re(t._id),le(!0)},title:"Delete Forever",children:e.jsx(Q,{className:"size-4"})})]}),e.jsx("div",{className:"aspect-square overflow-hidden bg-muted",children:K==="image"&&t.url?e.jsx("img",{src:t.url,alt:t.title||t.name,className:"h-full w-full object-cover"}):e.jsx("div",{className:"flex size-full items-center justify-center text-muted-foreground",children:Ct(K,"size-10")})}),e.jsxs("div",{className:"p-2",children:[e.jsx("p",{className:"truncate text-sm font-medium",title:t.name,children:t.name}),e.jsxs("div",{className:"mt-0.5 flex items-center gap-1 text-xs text-muted-foreground",children:[e.jsx("span",{className:"capitalize",children:K}),e.jsx("span",{children:"•"}),e.jsx("span",{children:yt(t.size??0)})]}),e.jsx("p",{className:"mt-0.5 text-xs text-muted-foreground",children:Nt(t._creationTime)})]})]},t._id)})}),!_.isDone&&e.jsxs("p",{className:"mt-4 text-center text-sm text-muted-foreground",children:["Showing ",_.page.length," files. More files available."]})]}):S?e.jsx(ge,{icon:e.jsx(Q,{className:"size-8"}),title:"Trash is empty",description:"Deleted files will appear here. You can restore them or permanently delete them."}):!R?.length&&e.jsx(ge,{icon:e.jsx(de,{className:"size-8"}),title:"No media assets yet",description:"Upload images, videos, documents, and other files to use in your content.",action:{label:"Upload Files",onClick:()=>d(!0)}}),r&&W.length===0&&!S&&e.jsx(ge,{icon:e.jsx(Je,{className:"size-8"}),title:"No results found",description:`No files match "${r}". Try a different search term.`,action:{label:"Clear Search",onClick:()=>p(""),variant:"secondary"}})]}),e.jsx(ye,{open:k,onOpenChange:F,children:e.jsxs(Ne,{children:[e.jsx(Ye,{children:e.jsx(Ce,{children:"Create New Folder"})}),e.jsx("div",{className:"space-y-4 py-4",children:e.jsxs("div",{className:"space-y-2",children:[e.jsx(ms,{htmlFor:"folder-name",children:"Folder Name"}),e.jsx(O,{id:"folder-name",value:m,onChange:t=>{B(t.target.value),I("")},placeholder:"Enter folder name",autoFocus:!0,onKeyDown:t=>{t.key==="Enter"&&!w&&Oe()}}),f&&e.jsx("p",{className:"text-sm text-destructive",children:f})]})}),e.jsxs(Ze,{children:[e.jsx(h,{variant:"secondary",onClick:()=>F(!1),disabled:w,children:"Cancel"}),e.jsx(h,{onClick:Oe,disabled:w||!m.trim(),loading:w,children:"Create Folder"})]})]})}),e.jsx(ye,{open:T,onOpenChange:d,children:e.jsxs(Ne,{className:"max-w-lg",children:[e.jsx(Ye,{children:e.jsx(Ce,{children:"Upload Files"})}),e.jsx("div",{className:"py-4",children:e.jsx($s,{currentFolderId:i,generateUploadUrl:y.media.generateUploadUrl,createAsset:y.media.createAsset,onUploadComplete:Ts,maxFileSize:50*1024*1024,maxConcurrentUploads:3})}),e.jsx(Ze,{children:e.jsx(h,{variant:"secondary",onClick:()=>d(!1),children:"Close"})})]})}),e.jsx(ut,{asset:H!==null&&W[H]?W[H]:null,assets:W,currentIndex:H??0,open:H!==null,onOpenChange:t=>{t||G(null)},onNavigate:Ns,onEdit:S?void 0:t=>Y({_id:t._id,name:t.name,title:t.title,description:t.description,altText:t.altText,tags:t.tags}),onDelete:S?void 0:t=>n({type:"asset",id:t._id,name:t.name})}),e.jsx(ht,{asset:te,open:te!==null,onOpenChange:t=>{t||Y(null)}}),e.jsx(pt,{folder:ie,open:ie!==null,onOpenChange:t=>{t||U(null)}}),e.jsx(je,{open:M!==null,onOpenChange:t=>{t||n(null)},title:`Delete ${M?.type==="folder"?"Folder":"File"}?`,description:`Are you sure you want to delete "${M?.name}"? ${M?.type==="folder"?"This will also delete all files inside the folder.":"This action can be undone from the trash."}`,confirmLabel:"Delete",onConfirm:Cs,variant:"danger",loading:z}),e.jsx(je,{open:hs,onOpenChange:me,title:"Delete Selected Files?",description:`Are you sure you want to delete ${o.size} ${o.size===1?"file":"files"}? This action can be undone from the trash.`,confirmLabel:"Delete All",onConfirm:ks,variant:"danger",loading:Me}),e.jsx(je,{open:fs,onOpenChange:t=>{le(t),t||re(null)},title:J==="bulk"?`Delete ${o.size} ${o.size===1?"File":"Files"} Forever?`:"Delete Forever?",description:J==="bulk"?`This will permanently delete ${o.size} ${o.size===1?"file":"files"}. This action cannot be undone.`:"This will permanently delete this file. This action cannot be undone.",confirmLabel:"Delete Forever",onConfirm:Ds,variant:"danger",loading:Pe}),e.jsx(bt,{open:xs,onOpenChange:Te,assetIds:Array.from(o),currentFolderId:i,onMoved:ws}),v&&!S&&e.jsx(jt,{selectedCount:o.size,onClear:fe,onMove:()=>Te(!0),onDelete:()=>me(!0),isDeleting:Me}),v&&S&&e.jsx(vt,{selectedCount:o.size,onClear:fe,onRestore:Fs,onPermanentDelete:()=>{re("bulk"),le(!0)},isRestoring:Ee,isDeleting:Pe})]})}export{$t as component};
1
+ import{d as se,j as e,c as P,r as a,T as Q,f as es,F as ss,I as de,u as A,b as y,a as E,B as As,L as Qe,D as ts,k as as,l as is,m as q,E as Es,n as ve,H as ls,o as be,g as Ps,p as Bs}from"./main-CXgkZMhe.js";import{C as rs,F as ns,M as os,V as cs,T as Is,a as Rs,b as Ge,U as Ls,c as $s}from"./tabs-CN5s5u2W.js";import{C as Us}from"./CmsPageHeader-ohOq0luT.js";import{C as Vs}from"./CmsToolbar-cEBlCHa3.js";import{D as ye,d as Ne,e as Ce,I as O,c as ze,a as Xe,C as ge,f as Ye,g as Ze,b as je}from"./CmsEmptyState-CiMQwSQV.js";import{C as h,X as ae,B as ds}from"./badge-qPrc4AUM.js";import{T as qs}from"./TaxonomyFilter-BgE_SR_O.js";import{L as ms}from"./label-DCsUdvFh.js";import{V as Hs,S as Ws,a as Ks,b as Os,c as Qs,d as ee}from"./select-Co3TZFJb.js";import{P as Fe,a as Gs,T as us}from"./textarea-BJ0XFZpT.js";import{P as Xs}from"./plus-xCFJK0RC.js";import{L as Ys}from"./link-2-Czw1N61H.js";import{R as ke}from"./rotate-ccw-DIqK63wY.js";import{S as Je}from"./search-CbCbboeU.js";import"./command-QOmNhlb0.js";const Zs=[["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"}]],Js=se("copy",Zs);const et=[["path",{d:"M12 15V3",key:"m9g1x1"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["path",{d:"m7 10 5 5 5-5",key:"brsn70"}]],we=se("download",et);const st=[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"12",cy:"5",r:"1",key:"gxeob9"}],["circle",{cx:"12",cy:"19",r:"1",key:"lyex9k"}]],tt=se("ellipsis-vertical",st);const at=[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"19",cy:"12",r:"1",key:"1wjl8i"}],["circle",{cx:"5",cy:"12",r:"1",key:"1pcz8c"}]],it=se("ellipsis",at);const lt=[["path",{d:"M2 9V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2v-1",key:"fm4g5t"}],["path",{d:"M2 13h10",key:"pgb2dq"}],["path",{d:"m9 16 3-3-3-3",key:"6m91ic"}]],Se=se("folder-input",lt);const rt=[["path",{d:"M12 10v6",key:"1bos4e"}],["path",{d:"M9 13h6",key:"1uhe8q"}],["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"}]],nt=se("folder-plus",rt);function X({label:s,description:l,error:i,required:c,htmlFor:r,className:p,children:u}){return e.jsxs("div",{className:P("space-y-2",p),children:[s&&e.jsxs(ms,{htmlFor:r,className:P("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",i&&"text-destructive"),children:[s,c&&e.jsx("span",{className:"ml-1 text-destructive",children:"*"})]}),u,l&&!i&&e.jsx("p",{className:"text-[13px] text-muted-foreground",children:l}),i&&e.jsx("p",{className:"text-[13px] font-medium text-destructive",children:i})]})}function ot(s){return s?s.startsWith("image/")?"image":s.startsWith("video/")?"video":s.startsWith("audio/")?"audio":s==="application/pdf"||s.includes("document")||s.includes("sheet")||s.includes("presentation")||s.startsWith("text/")?"document":"other":"other"}function ct(s){if(!s||s===0)return"0 B";const l=1024,i=["B","KB","MB","GB"],c=Math.floor(Math.log(s)/Math.log(l));return`${parseFloat((s/Math.pow(l,c)).toFixed(1))} ${i[c]}`}function dt(s){return new Date(s).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric",hour:"numeric",minute:"2-digit"})}function mt(s,l="size-16"){const i={className:l};switch(s){case"image":return e.jsx(de,{...i});case"video":return e.jsx(cs,{...i});case"audio":return e.jsx(os,{...i});case"document":return e.jsx(ss,{...i});default:return e.jsx(ns,{...i})}}function ut({asset:s,assets:l,currentIndex:i,open:c,onOpenChange:r,onNavigate:p,onEdit:u,onDelete:g}){const j=i>0,N=i<l.length-1,o=a.useCallback(()=>{j&&p(i-1)},[j,i,p]),x=a.useCallback(()=>{N&&p(i+1)},[N,i,p]),v=a.useCallback(m=>{if(c)switch(m.key){case"ArrowLeft":m.preventDefault(),o();break;case"ArrowRight":m.preventDefault(),x();break;case"Escape":m.preventDefault(),r(!1);break}},[c,o,x,r]);a.useEffect(()=>(window.addEventListener("keydown",v),()=>window.removeEventListener("keydown",v)),[v]);const C=a.useCallback(()=>{if(!s?.url)return;const m=document.createElement("a");m.href=s.url,m.download=s.name,m.target="_blank",document.body.appendChild(m),m.click(),document.body.removeChild(m)},[s]),k=a.useCallback(async()=>{s?.url&&await navigator.clipboard.writeText(s.url)},[s]);if(!s)return null;const F=ot(s.mimeType),T=F==="image",d=!!s.url;return e.jsx(ye,{open:c,onOpenChange:r,children:e.jsxs(Ne,{className:"flex h-[90vh] w-[95vw] max-w-[1400px] flex-col gap-0 overflow-hidden p-0 sm:max-w-[1400px]",showCloseButton:!1,children:[e.jsx(Hs,{children:e.jsxs(Ce,{children:["Preview: ",s.name]})}),e.jsxs("div",{className:"flex items-center justify-between border-b px-4 py-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("h2",{className:"truncate text-lg font-semibold",title:s.name,children:s.name}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:[i+1," of ",l.length]})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(h,{variant:"ghost",size:"icon",onClick:k,disabled:!s.url,title:"Copy URL",children:e.jsx(Js,{className:"size-4"})}),e.jsx(h,{variant:"ghost",size:"icon",onClick:C,disabled:!s.url,title:"Download",children:e.jsx(we,{className:"size-4"})}),u&&e.jsx(h,{variant:"ghost",size:"icon",onClick:()=>u(s),title:"Edit",children:e.jsx(Fe,{className:"size-4"})}),g&&e.jsx(h,{variant:"ghost",size:"icon",onClick:()=>g(s),title:"Delete",className:"text-destructive hover:text-destructive",children:e.jsx(Q,{className:"size-4"})}),e.jsx(h,{variant:"ghost",size:"icon",onClick:()=>r(!1),title:"Close (Esc)",children:e.jsx(ae,{className:"size-4"})})]})]}),e.jsxs("div",{className:"flex min-h-0 flex-1",children:[e.jsxs("div",{className:"relative flex flex-1 items-center justify-center bg-zinc-950",children:[j&&e.jsx("button",{onClick:o,className:"absolute left-4 z-10 flex size-10 items-center justify-center rounded-full bg-black/50 text-white transition-colors hover:bg-black/70",title:"Previous (←)",children:e.jsx(rs,{className:"size-6"})}),N&&e.jsx("button",{onClick:x,className:"absolute right-4 z-10 flex size-10 items-center justify-center rounded-full bg-black/50 text-white transition-colors hover:bg-black/70",title:"Next (→)",children:e.jsx(es,{className:"size-6"})}),T&&d?e.jsx("img",{src:s.url,alt:s.altText||s.title||s.name,className:"max-h-full max-w-full object-contain"}):e.jsxs("div",{className:"flex flex-col items-center gap-4 text-zinc-400",children:[mt(F),e.jsx("p",{className:"text-sm",children:T&&!d?"Image URL not available":"Preview not available for this file type"}),d&&e.jsxs(h,{variant:"secondary",onClick:C,children:[e.jsx(we,{className:"mr-2 size-4"}),"Download to view"]})]})]}),e.jsx("div",{className:"w-72 shrink-0 overflow-y-auto border-l bg-background",children:e.jsxs("div",{className:"space-y-4 p-4",children:[e.jsx("h3",{className:"font-semibold",children:"File Information"}),e.jsx(V,{label:"Filename",value:s.name}),s.title&&e.jsx(V,{label:"Title",value:s.title}),s.description&&e.jsx(V,{label:"Description",value:s.description}),s.altText&&e.jsx(V,{label:"Alt Text",value:s.altText}),e.jsxs("div",{className:"border-t pt-4",children:[e.jsx(V,{label:"Type",value:F,capitalize:!0}),s.mimeType&&e.jsx(V,{label:"MIME Type",value:s.mimeType}),e.jsx(V,{label:"Size",value:ct(s.size)}),s.width&&s.height&&e.jsx(V,{label:"Dimensions",value:`${s.width} × ${s.height} px`})]}),e.jsx("div",{className:"border-t pt-4",children:e.jsx(V,{label:"Uploaded",value:dt(s._creationTime)})}),s.tags&&s.tags.length>0&&e.jsxs("div",{className:"border-t pt-4",children:[e.jsx("p",{className:"mb-2 text-xs font-medium text-muted-foreground",children:"Tags"}),e.jsx("div",{className:"flex flex-wrap gap-1",children:s.tags.map(m=>e.jsx("span",{className:"rounded-full bg-muted px-2 py-0.5 text-xs",children:m},m))})]})]})})]})]})})}function V({label:s,value:l,capitalize:i}){return e.jsxs("div",{className:"space-y-0.5",children:[e.jsx("p",{className:"text-xs font-medium text-muted-foreground",children:s}),e.jsx("p",{className:P("break-words text-sm",i&&"capitalize"),children:l})]})}function xt({mediaId:s,taxonomyId:l,taxonomyName:i="Tags",allowCreate:c=!0,disabled:r=!1,className:p=""}){const[u,g]=a.useState(""),[j,N]=a.useState(!1),[o,x]=a.useState(0),[v,C]=a.useState(!1),[k,F]=a.useState(!1),T=a.useRef(null),d=a.useRef(null),m=a.useRef(null),B=A(y.taxonomies.getTermsByMedia,{mediaId:s,taxonomyId:l}),w=B?.map(n=>n._id)??[],f=A(y.taxonomies.suggestTerms,{taxonomyId:l,query:u,limit:10,excludeIds:w})??[],I=E(y.taxonomies.setMediaTerms),H=E(y.taxonomies.createTermAndAddToMedia);a.useEffect(()=>{function n(z){m.current&&!m.current.contains(z.target)&&N(!1)}return document.addEventListener("mousedown",n),()=>document.removeEventListener("mousedown",n)},[]);const G=a.useCallback(async n=>{if(!w.includes(n)){F(!0);try{await I({mediaId:s,taxonomyId:l,termIds:[...w,n]})}catch(z){console.error("Failed to add tag:",z)}finally{F(!1),g(""),N(!1),x(0),T.current?.focus()}}},[s,l,w,I]),te=a.useCallback(async n=>{F(!0);try{await I({mediaId:s,taxonomyId:l,termIds:w.filter(z=>z!==n)})}catch(z){console.error("Failed to remove tag:",z)}finally{F(!1)}},[s,l,w,I]),Y=a.useCallback(async()=>{if(!(!u.trim()||!c)){C(!0);try{await H({taxonomyId:l,name:u.trim(),mediaId:s}),g(""),N(!1),x(0)}catch(n){console.error("Failed to create tag:",n)}finally{C(!1)}}},[u,c,l,s,H]),ie=n=>{if(!r)switch(n.key){case"ArrowDown":n.preventDefault(),x(z=>z<f.length-1?z+1:z);break;case"ArrowUp":n.preventDefault(),x(z=>z>0?z-1:0);break;case"Enter":n.preventDefault(),f.length>0&&o<f.length?G(f[o]._id):u.trim()&&c&&Y();break;case"Escape":N(!1);break;case"Backspace":u===""&&w.length>0&&te(w[w.length-1]);break}};a.useEffect(()=>{if(d.current&&j){const n=d.current.querySelector(`[data-index="${o}"]`);n&&n.scrollIntoView({block:"nearest"})}},[o,j]);const U=f.filter(n=>!w.includes(n._id)),M=c&&u.trim()&&!U.some(n=>n.name.toLowerCase()===u.trim().toLowerCase());return e.jsxs("div",{className:P("space-y-2",p),children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium text-muted-foreground",children:[e.jsx(Gs,{className:"size-4"}),i]}),e.jsxs("div",{ref:m,className:P("relative rounded-md border border-input bg-background",r&&"opacity-50"),children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 p-2",children:[(B??[]).map(n=>e.jsxs(ds,{variant:"secondary",className:"gap-1 pr-1",style:n.color?{backgroundColor:n.color,color:"#fff"}:void 0,children:[n.name,!r&&e.jsx(As,{type:"button",variant:"ghost",size:"icon",className:"size-4 hover:bg-transparent",onClick:()=>te(n._id),disabled:k,"aria-label":`Remove ${n.name}`,children:e.jsx(ae,{className:"size-3"})})]},n._id)),!r&&e.jsx(O,{ref:T,type:"text",className:"h-7 min-w-[120px] flex-1 border-0 bg-transparent px-1 shadow-none focus-visible:ring-0",value:u,onChange:n=>{g(n.target.value),N(!0),x(0)},onFocus:()=>N(!0),onKeyDown:ie,placeholder:w.length===0?"Add tags...":"",disabled:r||v||k})]}),j&&(U.length>0||M)&&e.jsxs("div",{ref:d,className:"absolute left-0 right-0 top-full z-50 mt-1 max-h-48 overflow-auto rounded-md border bg-popover shadow-lg",role:"listbox",children:[U.map((n,z)=>e.jsxs("div",{"data-index":z,className:P("flex cursor-pointer items-center gap-2 px-3 py-2 text-sm",z===o&&"bg-accent"),onClick:()=>G(n._id),role:"option","aria-selected":z===o,children:[n.color&&e.jsx("span",{className:"size-2.5 rounded-full",style:{backgroundColor:n.color}}),e.jsx("span",{className:"flex-1",children:n.name}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:[n.usageCount," uses"]})]},n._id)),M&&e.jsxs("div",{"data-index":U.length,className:P("flex cursor-pointer items-center gap-2 px-3 py-2 text-sm",U.length===o&&"bg-accent"),onClick:Y,role:"option","aria-selected":U.length===o,children:[v?e.jsx(Qe,{className:"size-4 animate-spin"}):e.jsx(Xs,{className:"size-4"}),e.jsxs("span",{children:['Create "',u.trim(),'"']})]})]}),(k||v)&&e.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-background/50",children:e.jsx(Qe,{className:"size-4 animate-spin"})})]})]})}function ht({asset:s,open:l,onOpenChange:i,onSaved:c}){const[r,p]=a.useState(""),[u,g]=a.useState(""),[j,N]=a.useState(""),[o,x]=a.useState(""),[v,C]=a.useState(""),[k,F]=a.useState(!1),[T,d]=a.useState(""),m=E(y.media.updateAsset),w=A(y.taxonomies.list,{isActive:!0,paginationOpts:{numItems:50,cursor:null}})?.page??[];a.useEffect(()=>{s&&(p(s.name),g(s.title||""),N(s.description||""),x(s.altText||""),C(s.tags?.join(", ")||""),d(""))},[s]);const L=a.useCallback(async()=>{if(s){if(!r.trim()){d("Filename is required");return}F(!0),d("");try{const f=v.split(",").map(I=>I.trim()).filter(Boolean);await m({id:s._id,name:r.trim(),title:u.trim()||void 0,description:j.trim()||void 0,altText:o.trim()||void 0,tags:f.length>0?f:void 0}),c?.(),i(!1)}catch(f){d(f instanceof Error?f.message:"Failed to update asset")}finally{F(!1)}}},[s,r,u,j,o,v,m,c,i]);return s?e.jsx(ze,{open:l,onOpenChange:i,title:"Edit File",size:"md",footer:e.jsxs(e.Fragment,{children:[e.jsx(h,{variant:"outline",onClick:()=>i(!1),disabled:k,children:"Cancel"}),e.jsx(h,{onClick:L,loading:k,children:"Save Changes"})]}),children:e.jsxs("div",{className:"space-y-4",children:[T&&e.jsx("div",{className:"rounded-md bg-destructive/10 p-3 text-sm text-destructive",children:T}),e.jsx(X,{label:"Filename",required:!0,htmlFor:"asset-name",children:e.jsx(O,{id:"asset-name",value:r,onChange:f=>p(f.target.value),placeholder:"Enter filename"})}),e.jsx(X,{label:"Title",description:"A human-readable title for the file",htmlFor:"asset-title",children:e.jsx(O,{id:"asset-title",value:u,onChange:f=>g(f.target.value),placeholder:"Enter title (optional)"})}),e.jsx(X,{label:"Description",description:"A brief description of the file",htmlFor:"asset-description",children:e.jsx(us,{id:"asset-description",value:j,onChange:f=>N(f.target.value),placeholder:"Enter description (optional)",rows:3})}),e.jsx(X,{label:"Alt Text",description:"Alternative text for accessibility (important for images)",htmlFor:"asset-alt",children:e.jsx(O,{id:"asset-alt",value:o,onChange:f=>x(f.target.value),placeholder:"Describe the image content"})}),e.jsx(X,{label:"Quick Tags",description:"Comma-separated tags for simple organization",htmlFor:"asset-tags",children:e.jsx(O,{id:"asset-tags",value:v,onChange:f=>C(f.target.value),placeholder:"e.g., hero, blog, product"})}),w.length>0&&s&&e.jsxs("div",{className:"space-y-4 pt-2 border-t",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Organize with taxonomy terms"}),w.map(f=>e.jsx(xt,{mediaId:s._id,taxonomyId:f._id,taxonomyName:f.displayName,allowCreate:f.allowInlineCreation,disabled:k},f._id))]})]})}):null}function pt({folder:s,open:l,onOpenChange:i,onSaved:c}){const[r,p]=a.useState(""),[u,g]=a.useState(""),[j,N]=a.useState(!1),[o,x]=a.useState(""),v=E(y.media.updateFolder);a.useEffect(()=>{s&&(p(s.name),g(s.description||""),x(""))},[s]);const C=a.useCallback(async()=>{if(s){if(!r.trim()){x("Folder name is required");return}N(!0),x("");try{await v({id:s._id,name:r.trim(),description:u.trim()||void 0}),c?.(),i(!1)}catch(k){x(k instanceof Error?k.message:"Failed to update folder")}finally{N(!1)}}},[s,r,u,v,c,i]);return s?e.jsx(ze,{open:l,onOpenChange:i,title:"Edit Folder",size:"sm",footer:e.jsxs(e.Fragment,{children:[e.jsx(h,{variant:"outline",onClick:()=>i(!1),disabled:j,children:"Cancel"}),e.jsx(h,{onClick:C,loading:j,children:"Save Changes"})]}),children:e.jsxs("div",{className:"space-y-4",children:[o&&e.jsx("div",{className:"rounded-md bg-destructive/10 p-3 text-sm text-destructive",children:o}),e.jsx(X,{label:"Folder Name",required:!0,htmlFor:"folder-name",children:e.jsx(O,{id:"folder-name",value:r,onChange:k=>p(k.target.value),placeholder:"Enter folder name"})}),e.jsx(X,{label:"Description",description:"A brief description of the folder contents",htmlFor:"folder-description",children:e.jsx(us,{id:"folder-description",value:u,onChange:k=>g(k.target.value),placeholder:"Enter description (optional)",rows:3})})]})}):null}function ft({asset:s,onView:l,onEdit:i,onMove:c,onDelete:r}){const p=()=>{if(!s.url)return;const g=document.createElement("a");g.href=s.url,g.download=s.name,g.target="_blank",document.body.appendChild(g),g.click(),document.body.removeChild(g)},u=async()=>{s.url&&await navigator.clipboard.writeText(s.url)};return e.jsxs(ts,{children:[e.jsx(as,{asChild:!0,children:e.jsx(h,{variant:"ghost",size:"icon-sm",className:"opacity-0 group-hover:opacity-100",onClick:g=>g.stopPropagation(),children:e.jsx(tt,{className:"size-4"})})}),e.jsxs(is,{side:"bottom",onClick:g=>g.stopPropagation(),children:[l&&e.jsxs(q,{onClick:l,children:[e.jsx(Es,{className:"mr-2 size-4"}),"View Details"]}),i&&e.jsxs(q,{onClick:i,children:[e.jsx(Fe,{className:"mr-2 size-4"}),"Edit"]}),c&&e.jsxs(q,{onClick:c,children:[e.jsx(Se,{className:"mr-2 size-4"}),"Move to..."]}),e.jsx(ve,{}),e.jsxs(q,{onClick:p,disabled:!s.url,children:[e.jsx(we,{className:"mr-2 size-4"}),"Download"]}),e.jsxs(q,{onClick:u,disabled:!s.url,children:[e.jsx(Ys,{className:"mr-2 size-4"}),"Copy URL"]}),r&&e.jsxs(e.Fragment,{children:[e.jsx(ve,{}),e.jsxs(q,{onClick:r,className:"text-destructive focus:text-destructive",children:[e.jsx(Q,{className:"mr-2 size-4"}),"Delete"]})]})]})]})}function gt({folder:s,onEdit:l,onMove:i,onDelete:c}){return e.jsxs(ts,{children:[e.jsx(as,{asChild:!0,children:e.jsx(h,{variant:"ghost",size:"icon-sm",className:"opacity-0 group-hover:opacity-100",onClick:r=>r.stopPropagation(),children:e.jsx(it,{className:"size-4"})})}),e.jsxs(is,{align:"end",onClick:r=>r.stopPropagation(),children:[l&&e.jsxs(q,{onClick:l,children:[e.jsx(Fe,{className:"mr-2 size-4"}),"Rename"]}),i&&e.jsxs(q,{onClick:i,children:[e.jsx(Se,{className:"mr-2 size-4"}),"Move to..."]}),c&&e.jsxs(e.Fragment,{children:[e.jsx(ve,{}),e.jsxs(q,{onClick:c,className:"text-destructive focus:text-destructive",children:[e.jsx(Q,{className:"mr-2 size-4"}),"Delete"]})]})]})]})}function jt({selectedCount:s,onClear:l,onMove:i,onDelete:c,isDeleting:r}){return s===0?null:e.jsx("div",{className:"fixed inset-x-0 bottom-0 z-50 border-t bg-background/95 backdrop-blur supports-[backdrop-filter]:bg-background/80",children:e.jsxs("div",{className:"mx-auto flex max-w-7xl items-center justify-between px-6 py-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("span",{className:"text-sm font-medium",children:[s," ",s===1?"file":"files"," selected"]}),e.jsxs(h,{variant:"ghost",size:"sm",onClick:l,children:[e.jsx(ae,{className:"mr-1 size-4"}),"Clear"]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(h,{variant:"secondary",onClick:i,disabled:r,children:[e.jsx(Se,{className:"mr-2 size-4"}),"Move to..."]}),e.jsxs(h,{variant:"destructive",onClick:c,loading:r,children:[e.jsx(Q,{className:"mr-2 size-4"}),"Delete"]})]})]})})}function vt({selectedCount:s,onClear:l,onRestore:i,onPermanentDelete:c,isRestoring:r,isDeleting:p}){return s===0?null:e.jsx("div",{className:"fixed inset-x-0 bottom-0 z-50 border-t bg-background/95 backdrop-blur supports-[backdrop-filter]:bg-background/80",children:e.jsxs("div",{className:"mx-auto flex max-w-7xl items-center justify-between px-6 py-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("span",{className:"text-sm font-medium",children:[s," ",s===1?"file":"files"," selected"]}),e.jsxs(h,{variant:"ghost",size:"sm",onClick:l,children:[e.jsx(ae,{className:"mr-1 size-4"}),"Clear"]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(h,{variant:"secondary",onClick:i,loading:r,disabled:p,children:[e.jsx(ke,{className:"mr-2 size-4"}),"Restore"]}),e.jsxs(h,{variant:"danger",onClick:c,loading:p,disabled:r,children:[e.jsx(Q,{className:"mr-2 size-4"}),"Delete Forever"]})]})]})})}function bt({open:s,onOpenChange:l,assetIds:i,currentFolderId:c,onMoved:r}){const[p,u]=a.useState(void 0),[g,j]=a.useState(!1),[N,o]=a.useState(""),x=A(y.media.getFolderTree,{}),v=E(y.media.moveAssets),C=a.useMemo(()=>{if(!x)return[];const d=(m,B)=>x.filter(L=>L.parentId===m).flatMap(L=>[{...L,depth:B},...d(L._id,B+1)]);return d(void 0,0)},[x]),k=async()=>{if(i.length!==0){j(!0),o("");try{await v({assetIds:i,targetFolderId:p}),r?.(),l(!1)}catch(d){o(d instanceof Error?d.message:"Failed to move files")}finally{j(!1)}}},F=p===c,T=p===void 0;return e.jsx(ze,{open:s,onOpenChange:l,title:"Move Files",description:`Select a destination folder for ${i.length} ${i.length===1?"file":"files"}`,size:"sm",footer:e.jsxs(e.Fragment,{children:[e.jsx(h,{variant:"outline",onClick:()=>l(!1),disabled:g,children:"Cancel"}),e.jsx(h,{onClick:k,loading:g,disabled:F,children:"Move Here"})]}),children:e.jsxs("div",{className:"space-y-2",children:[N&&e.jsx("div",{className:"rounded-md bg-destructive/10 p-3 text-sm text-destructive",children:N}),e.jsxs("div",{className:"max-h-[300px] overflow-y-auto rounded-md border",children:[e.jsxs("button",{type:"button",className:P("flex w-full items-center gap-2 px-3 py-2 text-left text-sm transition-colors hover:bg-muted",T&&"bg-primary/10 text-primary",c===void 0&&"opacity-50"),onClick:()=>u(void 0),children:[e.jsx(ls,{className:"size-4"}),e.jsx("span",{className:"font-medium",children:"Root (All Files)"}),c===void 0&&e.jsx("span",{className:"ml-auto text-xs text-muted-foreground",children:"Current"})]}),C.map(d=>{const m=d._id===c,B=d._id===p;return e.jsxs("button",{type:"button",className:P("flex w-full items-center gap-2 px-3 py-2 text-left text-sm transition-colors hover:bg-muted",B&&"bg-primary/10 text-primary",m&&"opacity-50"),style:{paddingLeft:`${12+d.depth*20}px`},onClick:()=>u(d._id),children:[d.depth>0&&e.jsx(es,{className:"size-3 text-muted-foreground"}),e.jsx(be,{className:"size-4 text-amber-500"}),e.jsx("span",{className:"truncate",children:d.name}),m&&e.jsx("span",{className:"ml-auto text-xs text-muted-foreground",children:"Current"})]},d._id)}),C.length===0&&e.jsx("div",{className:"px-3 py-6 text-center text-sm text-muted-foreground",children:"No folders yet. Create folders to organize your files."})]}),F&&e.jsx("p",{className:"text-xs text-muted-foreground",children:"Files are already in this folder"})]})})}function yt(s){if(s===0)return"0 B";const l=1024,i=["B","KB","MB","GB"],c=Math.floor(Math.log(s)/Math.log(l));return`${parseFloat((s/Math.pow(l,c)).toFixed(1))} ${i[c]}`}function Nt(s){return new Date(s).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})}function Ct(s,l="size-6"){const i={className:l};switch(s){case"image":return e.jsx(de,{...i});case"video":return e.jsx(cs,{...i});case"audio":return e.jsx(os,{...i});case"document":return e.jsx(ss,{...i});default:return e.jsx(ns,{...i})}}function kt(s){return s?s.startsWith("image/")?"image":s.startsWith("video/")?"video":s.startsWith("audio/")?"audio":s==="application/pdf"||s.includes("document")||s.includes("sheet")||s.includes("presentation")||s.startsWith("text/")?"document":"other":"other"}function $t(){const{settings:s}=Ps(),l=Bs();a.useEffect(()=>{s&&!s.features.mediaManagement&&l({to:"/"})},[s,l]);const[i,c]=a.useState(void 0),[r,p]=a.useState(""),[u,g]=a.useState(""),[j,N]=a.useState([]),[o,x]=a.useState(new Set),[v,C]=a.useState(!1),[k,F]=a.useState(!1),[T,d]=a.useState(!1),[m,B]=a.useState(""),[w,L]=a.useState(!1),[f,I]=a.useState(""),[H,G]=a.useState(null),[te,Y]=a.useState(null),[ie,U]=a.useState(null),[M,n]=a.useState(null),[z,De]=a.useState(!1),[xs,Te]=a.useState(!1),[hs,me]=a.useState(!1),[Me,_e]=a.useState(!1),[Ae,ps]=a.useState("library"),[Ee,Z]=a.useState(!1),[Pe,Be]=a.useState(!1),[fs,le]=a.useState(!1),[J,re]=a.useState(null),S=Ae==="trash",_=A(y.media.listAssets,{folderId:S?void 0:i,type:u||void 0,search:r||void 0,deletedOnly:S?!0:void 0,paginationOpts:{numItems:100,cursor:null}}),ue=A(y.media.getTrashCount,{}),Ie=A(y.taxonomies.getMediaByTerm,j[0]?{termId:j[0]}:"skip"),Re=A(y.taxonomies.getMediaByTerm,j[1]?{termId:j[1]}:"skip"),Le=A(y.taxonomies.getMediaByTerm,j[2]?{termId:j[2]}:"skip"),xe=a.useMemo(()=>{if(j.length===0)return null;const t=new Set,b=[Ie,Re,Le];for(let D=0;D<j.length&&D<3;D++){const K=b[D];if(K?.page)for(const $ of K.page)t.add($._id)}return t},[j,Ie,Re,Le]),R=A(y.media.listFolders,{parentId:S?void 0:i,deletedOnly:S||void 0}),he=A(y.media.getFolder,i?{id:i}:"skip"),ne=A(y.media.getFolderTree,{}),$e=E(y.media.createFolder),oe=E(y.media.deleteAsset),Ue=E(y.media.deleteFolder),ce=E(y.media.restoreAsset),Ve=E(y.media.restoreFolder),qe=E(y.media.permanentDeleteAsset),He=E(y.media.bulkPermanentDeleteAssets),We=a.useMemo(()=>{if(!i||!ne)return[];const t=[];let b=ne.find(D=>D._id===i);for(;b;){t.unshift(b);const D=b.parentId;b=D?ne.find(K=>K._id===D):void 0}return t},[i,ne]),Ke=a.useCallback(t=>{c(t),p("")},[]),gs=a.useCallback(()=>{he?.parentId?c(he.parentId):c(void 0)},[he]),js=a.useCallback(()=>{c(void 0),p("")},[]),pe=a.useCallback(t=>{x(b=>{const D=new Set(b);return D.has(t)?D.delete(t):D.add(t),D})},[]),vs=a.useCallback(()=>{_?.page&&x(new Set(_.page.map(t=>t._id)))},[_?.page]),fe=a.useCallback(()=>{x(new Set)},[]),bs=a.useCallback(t=>{ps(t),x(new Set),C(!1)},[]),ys=a.useCallback(t=>{if(v)pe(t);else{const b=_?.page?.findIndex(D=>D._id===t)??-1;b!==-1&&G(b)}},[v,pe,_?.page]),Ns=a.useCallback(t=>{G(t)},[]),Cs=a.useCallback(async()=>{if(M){De(!0);try{M.type==="asset"?await oe({id:M.id}):await Ue({id:M.id}),n(null)}catch(t){console.error("Delete failed:",t)}finally{De(!1)}}},[M,oe,Ue]),ks=a.useCallback(async()=>{if(o.size!==0){_e(!0);try{const t=Array.from(o).map(b=>oe({id:b}));await Promise.all(t),x(new Set),C(!1),me(!1)}catch(t){console.error("Bulk delete failed:",t)}finally{_e(!1)}}},[o,oe]),ws=a.useCallback(()=>{x(new Set),C(!1)},[]),zs=a.useCallback(async t=>{Z(!0);try{await ce({id:t})}catch(b){console.error("Restore failed:",b)}finally{Z(!1)}},[ce]),Fs=a.useCallback(async()=>{if(o.size!==0){Z(!0);try{const t=Array.from(o).map(b=>ce({id:b}));await Promise.all(t),x(new Set),C(!1)}catch(t){console.error("Bulk restore failed:",t)}finally{Z(!1)}}},[o,ce]),Ss=a.useCallback(async t=>{Z(!0);try{await Ve({id:t})}catch(b){console.error("Restore folder failed:",b)}finally{Z(!1)}},[Ve]),Ds=a.useCallback(async()=>{if(J){Be(!0);try{J==="bulk"?(await He({ids:Array.from(o)}),x(new Set),C(!1)):await qe({id:J}),le(!1),re(null)}catch(t){console.error("Permanent delete failed:",t)}finally{Be(!1)}}},[J,qe,He,o]),Oe=a.useCallback(async()=>{if(!m.trim()){I("Folder name is required");return}L(!0),I("");try{await $e({name:m.trim(),parentId:i}),F(!1),B("")}catch(t){I(t instanceof Error?t.message:"Failed to create folder")}finally{L(!1)}},[m,i,$e]),Ts=a.useCallback(t=>{d(!1)},[]),Ms=_===void 0||R===void 0,W=a.useMemo(()=>{const t=_?.page??[];return xe===null?t:t.filter(b=>xe.has(b._id))},[_?.page,xe]);return e.jsxs("div",{className:"space-y-6 p-6",children:[e.jsx(Us,{title:"Media Library",description:"Upload, organize, and manage media assets for your content."}),e.jsx(Is,{value:Ae,onValueChange:t=>bs(t),children:e.jsxs(Rs,{children:[e.jsxs(Ge,{value:"library",children:[e.jsx(de,{className:"mr-1.5 size-4"}),"Library"]}),e.jsxs(Ge,{value:"trash",children:[e.jsx(Q,{className:"mr-1.5 size-4"}),"Trash",ue&&ue.total>0&&e.jsx(ds,{variant:"secondary",className:"ml-1.5",children:ue.total})]})]})}),!S&&e.jsxs("nav",{className:"flex items-center gap-1","aria-label":"Folder navigation",children:[e.jsxs("button",{className:P("flex items-center gap-1.5 rounded-md px-2 py-1 text-sm transition-colors",i?"text-muted-foreground hover:bg-muted hover:text-foreground":"bg-primary/10 font-medium text-primary"),onClick:js,children:[e.jsx(ls,{className:"size-4"}),e.jsx("span",{children:"All Files"})]}),We.map((t,b)=>e.jsxs("span",{className:"flex items-center",children:[e.jsx("span",{className:"mx-1 text-muted-foreground",children:"/"}),e.jsx("button",{className:P("rounded-md px-2 py-1 text-sm transition-colors",b===We.length-1?"bg-primary/10 font-medium text-primary":"text-muted-foreground hover:bg-muted hover:text-foreground"),onClick:()=>Ke(t._id),children:t.name})]},t._id))]}),e.jsx(Vs,{left:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("div",{className:"relative",children:[e.jsx(Je,{className:"absolute left-3 top-1/2 size-4 -translate-y-1/2 text-muted-foreground"}),e.jsx(O,{type:"search",placeholder:"Search files...",value:r,onChange:t=>p(t.target.value),className:"w-64 pl-9"}),r&&e.jsx("button",{className:"absolute right-2 top-1/2 -translate-y-1/2 rounded p-0.5 hover:bg-muted",onClick:()=>p(""),"aria-label":"Clear search",children:e.jsx(ae,{className:"size-4 text-muted-foreground"})})]}),e.jsxs(Ws,{value:u||"all",onValueChange:t=>g(t==="all"?"":t),children:[e.jsx(Ks,{className:"w-36",children:e.jsx(Os,{placeholder:"All Types"})}),e.jsxs(Qs,{children:[e.jsx(ee,{value:"all",children:"All Types"}),e.jsx(ee,{value:"image",children:"Images"}),e.jsx(ee,{value:"video",children:"Videos"}),e.jsx(ee,{value:"audio",children:"Audio"}),e.jsx(ee,{value:"document",children:"Documents"}),e.jsx(ee,{value:"other",children:"Other"})]})]}),e.jsx(qs,{selectedTermIds:j,onChange:N,placeholder:"Tags"}),_?.page&&_.page.length>0&&e.jsxs("label",{className:"flex cursor-pointer items-center gap-2 text-sm",children:[e.jsx(Xe,{checked:v,onCheckedChange:t=>{C(t),t||x(new Set)}}),"Selection Mode"]})]}),right:e.jsxs("div",{className:"flex items-center gap-2",children:[v&&o.size>0&&e.jsxs("span",{className:"text-sm text-muted-foreground",children:[o.size," selected"]}),v&&e.jsxs(e.Fragment,{children:[e.jsx(h,{variant:"secondary",size:"sm",onClick:vs,children:"Select All"}),e.jsx(h,{variant:"secondary",size:"sm",onClick:fe,children:"Clear"})]}),i&&!S&&e.jsxs(h,{variant:"secondary",onClick:gs,children:[e.jsx(rs,{className:"size-4"}),"Up"]}),!S&&e.jsxs(e.Fragment,{children:[e.jsxs(h,{variant:"secondary",onClick:()=>F(!0),children:[e.jsx(nt,{className:"size-4"}),"New Folder"]}),e.jsxs(h,{onClick:()=>d(!0),children:[e.jsx(Ls,{className:"size-4"}),"Upload Files"]})]})]})}),Ms?e.jsxs("div",{className:"flex flex-col items-center justify-center py-12",children:[e.jsx("div",{className:"size-8 animate-spin rounded-full border-2 border-muted border-t-primary"}),e.jsx("p",{className:"mt-4 text-sm text-muted-foreground",children:"Loading media library..."})]}):e.jsxs(e.Fragment,{children:[!S&&R&&R.length>0&&!r&&e.jsxs("section",{children:[e.jsx("h3",{className:"mb-3 text-sm font-medium text-muted-foreground",children:"Folders"}),e.jsx("div",{className:"grid grid-cols-2 gap-3 sm:grid-cols-4 md:grid-cols-6",children:R.map(t=>e.jsxs("div",{className:"group relative flex flex-col items-center gap-2 rounded-lg border bg-card p-4 text-center transition-colors hover:border-primary/50 hover:bg-muted/50 cursor-pointer",onClick:()=>Ke(t._id),children:[e.jsx("div",{className:"absolute right-2 top-2",children:e.jsx(gt,{folder:{_id:t._id,name:t.name},onEdit:()=>U({_id:t._id,name:t.name,description:t.description}),onDelete:()=>n({type:"folder",id:t._id,name:t.name})})}),e.jsx(be,{className:"size-10 text-amber-500"}),e.jsx("span",{className:"truncate text-sm font-medium",children:t.name})]},t._id))})]}),S&&R&&R.length>0&&e.jsxs("section",{children:[e.jsxs("h3",{className:"mb-3 text-sm font-medium text-muted-foreground",children:["Deleted Folders (",R.length,")"]}),e.jsx("div",{className:"grid grid-cols-2 gap-3 sm:grid-cols-4 md:grid-cols-6",children:R.map(t=>e.jsxs("div",{className:"group relative flex flex-col items-center gap-2 rounded-lg border border-destructive/20 bg-card p-4 text-center opacity-60",children:[e.jsx(be,{className:"size-10 text-amber-500/50"}),e.jsx("span",{className:"truncate text-sm font-medium",children:t.name}),e.jsxs(h,{variant:"secondary",size:"sm",onClick:()=>Ss(t._id),disabled:Ee,children:[e.jsx(ke,{className:"mr-1 size-3"}),"Restore"]})]},t._id))})]}),W.length>0?e.jsxs("section",{children:[!S&&R&&R.length>0&&!r&&e.jsx("h3",{className:"mb-3 text-sm font-medium text-muted-foreground",children:"Files"}),S&&e.jsxs("h3",{className:"mb-3 text-sm font-medium text-muted-foreground",children:["Deleted Files (",W.length,")"]}),e.jsx("div",{className:"grid grid-cols-2 gap-3 sm:grid-cols-4 md:grid-cols-6",children:W.map(t=>{const b=t._id,D=o.has(b),K=kt(t.mimeType);return e.jsxs("div",{className:P("group relative flex flex-col overflow-hidden rounded-lg border bg-card transition-all cursor-pointer hover:border-primary/50",D&&"border-primary ring-2 ring-primary/20"),onClick:()=>ys(b),children:[v&&e.jsx("div",{className:"absolute left-2 top-2 z-10",children:e.jsx(Xe,{checked:D,onCheckedChange:()=>pe(b),onClick:$=>$.stopPropagation(),className:"bg-white/80"})}),!v&&!S&&e.jsx("div",{className:"absolute right-2 top-2 z-10",children:e.jsx(ft,{asset:{_id:t._id,name:t.name,url:t.url},onView:()=>{const $=W.findIndex(_s=>_s._id===t._id);$!==-1&&G($)},onEdit:()=>Y({_id:t._id,name:t.name,title:t.title,description:t.description,altText:t.altText,tags:t.tags}),onDelete:()=>n({type:"asset",id:t._id,name:t.name})})}),!v&&S&&e.jsxs("div",{className:"absolute right-2 top-2 z-10 flex gap-1 opacity-0 group-hover:opacity-100",children:[e.jsx(h,{variant:"secondary",size:"icon-sm",onClick:$=>{$.stopPropagation(),zs(t._id)},title:"Restore",children:e.jsx(ke,{className:"size-4"})}),e.jsx(h,{variant:"danger",size:"icon-sm",onClick:$=>{$.stopPropagation(),re(t._id),le(!0)},title:"Delete Forever",children:e.jsx(Q,{className:"size-4"})})]}),e.jsx("div",{className:"aspect-square overflow-hidden bg-muted",children:K==="image"&&t.url?e.jsx("img",{src:t.url,alt:t.title||t.name,className:"h-full w-full object-cover"}):e.jsx("div",{className:"flex size-full items-center justify-center text-muted-foreground",children:Ct(K,"size-10")})}),e.jsxs("div",{className:"p-2",children:[e.jsx("p",{className:"truncate text-sm font-medium",title:t.name,children:t.name}),e.jsxs("div",{className:"mt-0.5 flex items-center gap-1 text-xs text-muted-foreground",children:[e.jsx("span",{className:"capitalize",children:K}),e.jsx("span",{children:"•"}),e.jsx("span",{children:yt(t.size??0)})]}),e.jsx("p",{className:"mt-0.5 text-xs text-muted-foreground",children:Nt(t._creationTime)})]})]},t._id)})}),!_.isDone&&e.jsxs("p",{className:"mt-4 text-center text-sm text-muted-foreground",children:["Showing ",_.page.length," files. More files available."]})]}):S?e.jsx(ge,{icon:e.jsx(Q,{className:"size-8"}),title:"Trash is empty",description:"Deleted files will appear here. You can restore them or permanently delete them."}):!R?.length&&e.jsx(ge,{icon:e.jsx(de,{className:"size-8"}),title:"No media assets yet",description:"Upload images, videos, documents, and other files to use in your content.",action:{label:"Upload Files",onClick:()=>d(!0)}}),r&&W.length===0&&!S&&e.jsx(ge,{icon:e.jsx(Je,{className:"size-8"}),title:"No results found",description:`No files match "${r}". Try a different search term.`,action:{label:"Clear Search",onClick:()=>p(""),variant:"secondary"}})]}),e.jsx(ye,{open:k,onOpenChange:F,children:e.jsxs(Ne,{children:[e.jsx(Ye,{children:e.jsx(Ce,{children:"Create New Folder"})}),e.jsx("div",{className:"space-y-4 py-4",children:e.jsxs("div",{className:"space-y-2",children:[e.jsx(ms,{htmlFor:"folder-name",children:"Folder Name"}),e.jsx(O,{id:"folder-name",value:m,onChange:t=>{B(t.target.value),I("")},placeholder:"Enter folder name",autoFocus:!0,onKeyDown:t=>{t.key==="Enter"&&!w&&Oe()}}),f&&e.jsx("p",{className:"text-sm text-destructive",children:f})]})}),e.jsxs(Ze,{children:[e.jsx(h,{variant:"secondary",onClick:()=>F(!1),disabled:w,children:"Cancel"}),e.jsx(h,{onClick:Oe,disabled:w||!m.trim(),loading:w,children:"Create Folder"})]})]})}),e.jsx(ye,{open:T,onOpenChange:d,children:e.jsxs(Ne,{className:"max-w-lg",children:[e.jsx(Ye,{children:e.jsx(Ce,{children:"Upload Files"})}),e.jsx("div",{className:"py-4",children:e.jsx($s,{currentFolderId:i,generateUploadUrl:y.media.generateUploadUrl,createAsset:y.media.createAsset,onUploadComplete:Ts,maxFileSize:50*1024*1024,maxConcurrentUploads:3})}),e.jsx(Ze,{children:e.jsx(h,{variant:"secondary",onClick:()=>d(!1),children:"Close"})})]})}),e.jsx(ut,{asset:H!==null&&W[H]?W[H]:null,assets:W,currentIndex:H??0,open:H!==null,onOpenChange:t=>{t||G(null)},onNavigate:Ns,onEdit:S?void 0:t=>Y({_id:t._id,name:t.name,title:t.title,description:t.description,altText:t.altText,tags:t.tags}),onDelete:S?void 0:t=>n({type:"asset",id:t._id,name:t.name})}),e.jsx(ht,{asset:te,open:te!==null,onOpenChange:t=>{t||Y(null)}}),e.jsx(pt,{folder:ie,open:ie!==null,onOpenChange:t=>{t||U(null)}}),e.jsx(je,{open:M!==null,onOpenChange:t=>{t||n(null)},title:`Delete ${M?.type==="folder"?"Folder":"File"}?`,description:`Are you sure you want to delete "${M?.name}"? ${M?.type==="folder"?"This will also delete all files inside the folder.":"This action can be undone from the trash."}`,confirmLabel:"Delete",onConfirm:Cs,variant:"danger",loading:z}),e.jsx(je,{open:hs,onOpenChange:me,title:"Delete Selected Files?",description:`Are you sure you want to delete ${o.size} ${o.size===1?"file":"files"}? This action can be undone from the trash.`,confirmLabel:"Delete All",onConfirm:ks,variant:"danger",loading:Me}),e.jsx(je,{open:fs,onOpenChange:t=>{le(t),t||re(null)},title:J==="bulk"?`Delete ${o.size} ${o.size===1?"File":"Files"} Forever?`:"Delete Forever?",description:J==="bulk"?`This will permanently delete ${o.size} ${o.size===1?"file":"files"}. This action cannot be undone.`:"This will permanently delete this file. This action cannot be undone.",confirmLabel:"Delete Forever",onConfirm:Ds,variant:"danger",loading:Pe}),e.jsx(bt,{open:xs,onOpenChange:Te,assetIds:Array.from(o),currentFolderId:i,onMoved:ws}),v&&!S&&e.jsx(jt,{selectedCount:o.size,onClear:fe,onMove:()=>Te(!0),onDelete:()=>me(!0),isDeleting:Me}),v&&S&&e.jsx(vt,{selectedCount:o.size,onClear:fe,onRestore:Fs,onPermanentDelete:()=>{re("bulk"),le(!0)},isRestoring:Ee,isDeleting:Pe})]})}export{$t as component};
@@ -1 +1 @@
1
- import{O as a,p,u as m,a as c,j as e,F as d}from"./main-CKj5yfEi.js";import{C as l}from"./ContentEntryEditor-CBeCyK_m.js";import{u as y}from"./useBreadcrumbLabel-BECBMCzM.js";import{C as u}from"./CmsEmptyState-CRswfTzk.js";import"./label-KNtpL71g.js";import"./switch-h3Rrnl5i.js";import"./badge-hvUOzpVZ.js";import"./tabs-imc8h-Dp.js";import"./textarea-BTy7nwzR.js";import"./list-sYepHjt_.js";import"./select-BD29IXCI.js";import"./search-MuAUDJKR.js";import"./command-DU82cJlt.js";import"./CmsStatusBadge-CbEUpQu-.js";import"./plus-DUn8v_Xf.js";import"./link-2-Bw2aI4V4.js";import"./scroll-area-DfIlT0in.js";import"./triangle-alert-E52Vfeuh.js";import"./circle-check-big-CF_pR17r.js";function L(){const{contentTypeId:o}=a.useParams(),n=p(),t=m(c.contentTypes.get,{id:o});if(y(`/entries/new/${o}`,t?`New ${t.displayName}`:void 0),t===void 0)return e.jsx("div",{className:"space-y-6 p-6",children:e.jsxs("div",{className:"flex flex-col items-center justify-center py-12",children:[e.jsx("div",{className:"size-8 animate-spin rounded-full border-2 border-muted border-t-primary"}),e.jsx("p",{className:"mt-4 text-sm text-muted-foreground",children:"Loading content type..."})]})});if(t===null)return e.jsx("div",{className:"space-y-6 p-6",children:e.jsx(u,{icon:e.jsx(d,{className:"size-6"}),title:"Content Type Not Found",description:"The content type you're looking for doesn't exist or has been deleted.",action:{label:"Back to Content Types",onClick:()=>n({to:"/content-types"})}})});const s=i=>{n({to:"/entries/$entryId",params:{entryId:i._id}})},r=()=>{n({to:"/entries/type/$contentTypeId",params:{contentTypeId:o}})};return e.jsx("div",{className:"space-y-6 p-6",children:e.jsx(l,{contentType:t,onSave:s,onCancel:r})})}export{L as component};
1
+ import{U as a,p,u as m,b as c,j as e,F as d}from"./main-CXgkZMhe.js";import{C as l}from"./ContentEntryEditor-BY5ypfUs.js";import{u as y}from"./useBreadcrumbLabel-DwZlwvFF.js";import{C as u}from"./CmsEmptyState-CiMQwSQV.js";import"./label-DCsUdvFh.js";import"./switch-CfavASmR.js";import"./badge-qPrc4AUM.js";import"./tabs-CN5s5u2W.js";import"./textarea-BJ0XFZpT.js";import"./list-DtCsXj8-.js";import"./select-Co3TZFJb.js";import"./search-CbCbboeU.js";import"./command-QOmNhlb0.js";import"./CmsStatusBadge-BdNf0V9v.js";import"./plus-xCFJK0RC.js";import"./link-2-Czw1N61H.js";import"./scroll-area-B-yrE66a.js";import"./triangle-alert-BZRcqsUg.js";import"./circle-check-big-Dgozy3vV.js";function L(){const{contentTypeId:o}=a.useParams(),n=p(),t=m(c.contentTypes.get,{id:o});if(y(`/entries/new/${o}`,t?`New ${t.displayName}`:void 0),t===void 0)return e.jsx("div",{className:"space-y-6 p-6",children:e.jsxs("div",{className:"flex flex-col items-center justify-center py-12",children:[e.jsx("div",{className:"size-8 animate-spin rounded-full border-2 border-muted border-t-primary"}),e.jsx("p",{className:"mt-4 text-sm text-muted-foreground",children:"Loading content type..."})]})});if(t===null)return e.jsx("div",{className:"space-y-6 p-6",children:e.jsx(u,{icon:e.jsx(d,{className:"size-6"}),title:"Content Type Not Found",description:"The content type you're looking for doesn't exist or has been deleted.",action:{label:"Back to Content Types",onClick:()=>n({to:"/content-types"})}})});const s=i=>{n({to:"/entries/$entryId",params:{entryId:i._id}})},r=()=>{n({to:"/entries/type/$contentTypeId",params:{contentTypeId:o}})};return e.jsx("div",{className:"space-y-6 p-6",children:e.jsx(l,{contentType:t,onSave:s,onCancel:r})})}export{L as component};
@@ -1 +1 @@
1
- import{d as e}from"./main-CKj5yfEi.js";const o=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],t=e("plus",o);export{t as P};
1
+ import{d as e}from"./main-CXgkZMhe.js";const o=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],t=e("plus",o);export{t as P};
@@ -1 +1 @@
1
- import{d as t}from"./main-CKj5yfEi.js";const e=[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]],a=t("rotate-ccw",e);export{a as R};
1
+ import{d as t}from"./main-CXgkZMhe.js";const e=[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]],a=t("rotate-ccw",e);export{a as R};
@@ -0,0 +1 @@
1
+ import{r as s,a0 as T,a1 as se,j as f,a2 as L,a3 as O,a4 as ce,a5 as C,a6 as P,a7 as ae,c as F}from"./main-CXgkZMhe.js";import{c as ie}from"./badge-qPrc4AUM.js";function de(e,o){return s.useReducer((r,l)=>o[r][l]??r,e)}var U="ScrollArea",[$]=ce(U),[ue,m]=$(U),q=s.forwardRef((e,o)=>{const{__scopeScrollArea:r,type:l="hover",dir:t,scrollHideDelay:n=600,...c}=e,[a,i]=s.useState(null),[h,d]=s.useState(null),[b,u]=s.useState(null),[S,w]=s.useState(null),[A,Y]=s.useState(null),[x,_]=s.useState(0),[M,D]=s.useState(0),[j,y]=s.useState(!1),[N,W]=s.useState(!1),v=T(o,E=>i(E)),p=se(t);return f.jsx(ue,{scope:r,type:l,dir:p,scrollHideDelay:n,scrollArea:a,viewport:h,onViewportChange:d,content:b,onContentChange:u,scrollbarX:S,onScrollbarXChange:w,scrollbarXEnabled:j,onScrollbarXEnabledChange:y,scrollbarY:A,onScrollbarYChange:Y,scrollbarYEnabled:N,onScrollbarYEnabledChange:W,onCornerWidthChange:_,onCornerHeightChange:D,children:f.jsx(L.div,{dir:p,...c,ref:v,style:{position:"relative","--radix-scroll-area-corner-width":x+"px","--radix-scroll-area-corner-height":M+"px",...e.style}})})});q.displayName=U;var G="ScrollAreaViewport",J=s.forwardRef((e,o)=>{const{__scopeScrollArea:r,children:l,nonce:t,...n}=e,c=m(G,r),a=s.useRef(null),i=T(o,a,c.onViewportChange);return f.jsxs(f.Fragment,{children:[f.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-scroll-area-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-scroll-area-viewport]::-webkit-scrollbar{display:none}"},nonce:t}),f.jsx(L.div,{"data-radix-scroll-area-viewport":"",...n,ref:i,style:{overflowX:c.scrollbarXEnabled?"scroll":"hidden",overflowY:c.scrollbarYEnabled?"scroll":"hidden",...e.style},children:f.jsx("div",{ref:c.onContentChange,style:{minWidth:"100%",display:"table"},children:l})})]})});J.displayName=G;var g="ScrollAreaScrollbar",K=s.forwardRef((e,o)=>{const{forceMount:r,...l}=e,t=m(g,e.__scopeScrollArea),{onScrollbarXEnabledChange:n,onScrollbarYEnabledChange:c}=t,a=e.orientation==="horizontal";return s.useEffect(()=>(a?n(!0):c(!0),()=>{a?n(!1):c(!1)}),[a,n,c]),t.type==="hover"?f.jsx(he,{...l,ref:o,forceMount:r}):t.type==="scroll"?f.jsx(fe,{...l,ref:o,forceMount:r}):t.type==="auto"?f.jsx(Q,{...l,ref:o,forceMount:r}):t.type==="always"?f.jsx(V,{...l,ref:o}):null});K.displayName=g;var he=s.forwardRef((e,o)=>{const{forceMount:r,...l}=e,t=m(g,e.__scopeScrollArea),[n,c]=s.useState(!1);return s.useEffect(()=>{const a=t.scrollArea;let i=0;if(a){const h=()=>{window.clearTimeout(i),c(!0)},d=()=>{i=window.setTimeout(()=>c(!1),t.scrollHideDelay)};return a.addEventListener("pointerenter",h),a.addEventListener("pointerleave",d),()=>{window.clearTimeout(i),a.removeEventListener("pointerenter",h),a.removeEventListener("pointerleave",d)}}},[t.scrollArea,t.scrollHideDelay]),f.jsx(O,{present:r||n,children:f.jsx(Q,{"data-state":n?"visible":"hidden",...l,ref:o})})}),fe=s.forwardRef((e,o)=>{const{forceMount:r,...l}=e,t=m(g,e.__scopeScrollArea),n=e.orientation==="horizontal",c=X(()=>i("SCROLL_END"),100),[a,i]=de("hidden",{hidden:{SCROLL:"scrolling"},scrolling:{SCROLL_END:"idle",POINTER_ENTER:"interacting"},interacting:{SCROLL:"interacting",POINTER_LEAVE:"idle"},idle:{HIDE:"hidden",SCROLL:"scrolling",POINTER_ENTER:"interacting"}});return s.useEffect(()=>{if(a==="idle"){const h=window.setTimeout(()=>i("HIDE"),t.scrollHideDelay);return()=>window.clearTimeout(h)}},[a,t.scrollHideDelay,i]),s.useEffect(()=>{const h=t.viewport,d=n?"scrollLeft":"scrollTop";if(h){let b=h[d];const u=()=>{const S=h[d];b!==S&&(i("SCROLL"),c()),b=S};return h.addEventListener("scroll",u),()=>h.removeEventListener("scroll",u)}},[t.viewport,n,i,c]),f.jsx(O,{present:r||a!=="hidden",children:f.jsx(V,{"data-state":a==="hidden"?"hidden":"visible",...l,ref:o,onPointerEnter:C(e.onPointerEnter,()=>i("POINTER_ENTER")),onPointerLeave:C(e.onPointerLeave,()=>i("POINTER_LEAVE"))})})}),Q=s.forwardRef((e,o)=>{const r=m(g,e.__scopeScrollArea),{forceMount:l,...t}=e,[n,c]=s.useState(!1),a=e.orientation==="horizontal",i=X(()=>{if(r.viewport){const h=r.viewport.offsetWidth<r.viewport.scrollWidth,d=r.viewport.offsetHeight<r.viewport.scrollHeight;c(a?h:d)}},10);return R(r.viewport,i),R(r.content,i),f.jsx(O,{present:l||n,children:f.jsx(V,{"data-state":n?"visible":"hidden",...t,ref:o})})}),V=s.forwardRef((e,o)=>{const{orientation:r="vertical",...l}=e,t=m(g,e.__scopeScrollArea),n=s.useRef(null),c=s.useRef(0),[a,i]=s.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),h=te(a.viewport,a.content),d={...l,sizes:a,onSizesChange:i,hasThumb:h>0&&h<1,onThumbChange:u=>n.current=u,onThumbPointerUp:()=>c.current=0,onThumbPointerDown:u=>c.current=u};function b(u,S){return we(u,c.current,a,S)}return r==="horizontal"?f.jsx(be,{...d,ref:o,onThumbPositionChange:()=>{if(t.viewport&&n.current){const u=t.viewport.scrollLeft,S=k(u,a,t.dir);n.current.style.transform=`translate3d(${S}px, 0, 0)`}},onWheelScroll:u=>{t.viewport&&(t.viewport.scrollLeft=u)},onDragScroll:u=>{t.viewport&&(t.viewport.scrollLeft=b(u,t.dir))}}):r==="vertical"?f.jsx(Se,{...d,ref:o,onThumbPositionChange:()=>{if(t.viewport&&n.current){const u=t.viewport.scrollTop,S=k(u,a);n.current.style.transform=`translate3d(0, ${S}px, 0)`}},onWheelScroll:u=>{t.viewport&&(t.viewport.scrollTop=u)},onDragScroll:u=>{t.viewport&&(t.viewport.scrollTop=b(u))}}):null}),be=s.forwardRef((e,o)=>{const{sizes:r,onSizesChange:l,...t}=e,n=m(g,e.__scopeScrollArea),[c,a]=s.useState(),i=s.useRef(null),h=T(o,i,n.onScrollbarXChange);return s.useEffect(()=>{i.current&&a(getComputedStyle(i.current))},[i]),f.jsx(ee,{"data-orientation":"horizontal",...t,ref:h,sizes:r,style:{bottom:0,left:n.dir==="rtl"?"var(--radix-scroll-area-corner-width)":0,right:n.dir==="ltr"?"var(--radix-scroll-area-corner-width)":0,"--radix-scroll-area-thumb-width":I(r)+"px",...e.style},onThumbPointerDown:d=>e.onThumbPointerDown(d.x),onDragScroll:d=>e.onDragScroll(d.x),onWheelScroll:(d,b)=>{if(n.viewport){const u=n.viewport.scrollLeft+d.deltaX;e.onWheelScroll(u),le(u,b)&&d.preventDefault()}},onResize:()=>{i.current&&n.viewport&&c&&l({content:n.viewport.scrollWidth,viewport:n.viewport.offsetWidth,scrollbar:{size:i.current.clientWidth,paddingStart:z(c.paddingLeft),paddingEnd:z(c.paddingRight)}})}})}),Se=s.forwardRef((e,o)=>{const{sizes:r,onSizesChange:l,...t}=e,n=m(g,e.__scopeScrollArea),[c,a]=s.useState(),i=s.useRef(null),h=T(o,i,n.onScrollbarYChange);return s.useEffect(()=>{i.current&&a(getComputedStyle(i.current))},[i]),f.jsx(ee,{"data-orientation":"vertical",...t,ref:h,sizes:r,style:{top:0,right:n.dir==="ltr"?0:void 0,left:n.dir==="rtl"?0:void 0,bottom:"var(--radix-scroll-area-corner-height)","--radix-scroll-area-thumb-height":I(r)+"px",...e.style},onThumbPointerDown:d=>e.onThumbPointerDown(d.y),onDragScroll:d=>e.onDragScroll(d.y),onWheelScroll:(d,b)=>{if(n.viewport){const u=n.viewport.scrollTop+d.deltaY;e.onWheelScroll(u),le(u,b)&&d.preventDefault()}},onResize:()=>{i.current&&n.viewport&&c&&l({content:n.viewport.scrollHeight,viewport:n.viewport.offsetHeight,scrollbar:{size:i.current.clientHeight,paddingStart:z(c.paddingTop),paddingEnd:z(c.paddingBottom)}})}})}),[ve,Z]=$(g),ee=s.forwardRef((e,o)=>{const{__scopeScrollArea:r,sizes:l,hasThumb:t,onThumbChange:n,onThumbPointerUp:c,onThumbPointerDown:a,onThumbPositionChange:i,onDragScroll:h,onWheelScroll:d,onResize:b,...u}=e,S=m(g,r),[w,A]=s.useState(null),Y=T(o,v=>A(v)),x=s.useRef(null),_=s.useRef(""),M=S.viewport,D=l.content-l.viewport,j=P(d),y=P(i),N=X(b,10);function W(v){if(x.current){const p=v.clientX-x.current.left,E=v.clientY-x.current.top;h({x:p,y:E})}}return s.useEffect(()=>{const v=p=>{const E=p.target;w?.contains(E)&&j(p,D)};return document.addEventListener("wheel",v,{passive:!1}),()=>document.removeEventListener("wheel",v,{passive:!1})},[M,w,D,j]),s.useEffect(y,[l,y]),R(w,N),R(S.content,N),f.jsx(ve,{scope:r,scrollbar:w,hasThumb:t,onThumbChange:P(n),onThumbPointerUp:P(c),onThumbPositionChange:y,onThumbPointerDown:P(a),children:f.jsx(L.div,{...u,ref:Y,style:{position:"absolute",...u.style},onPointerDown:C(e.onPointerDown,v=>{v.button===0&&(v.target.setPointerCapture(v.pointerId),x.current=w.getBoundingClientRect(),_.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",S.viewport&&(S.viewport.style.scrollBehavior="auto"),W(v))}),onPointerMove:C(e.onPointerMove,W),onPointerUp:C(e.onPointerUp,v=>{const p=v.target;p.hasPointerCapture(v.pointerId)&&p.releasePointerCapture(v.pointerId),document.body.style.webkitUserSelect=_.current,S.viewport&&(S.viewport.style.scrollBehavior=""),x.current=null})})})}),H="ScrollAreaThumb",re=s.forwardRef((e,o)=>{const{forceMount:r,...l}=e,t=Z(H,e.__scopeScrollArea);return f.jsx(O,{present:r||t.hasThumb,children:f.jsx(me,{ref:o,...l})})}),me=s.forwardRef((e,o)=>{const{__scopeScrollArea:r,style:l,...t}=e,n=m(H,r),c=Z(H,r),{onThumbPositionChange:a}=c,i=T(o,b=>c.onThumbChange(b)),h=s.useRef(void 0),d=X(()=>{h.current&&(h.current(),h.current=void 0)},100);return s.useEffect(()=>{const b=n.viewport;if(b){const u=()=>{if(d(),!h.current){const S=ge(b,a);h.current=S,a()}};return a(),b.addEventListener("scroll",u),()=>b.removeEventListener("scroll",u)}},[n.viewport,d,a]),f.jsx(L.div,{"data-state":c.hasThumb?"visible":"hidden",...t,ref:i,style:{width:"var(--radix-scroll-area-thumb-width)",height:"var(--radix-scroll-area-thumb-height)",...l},onPointerDownCapture:C(e.onPointerDownCapture,b=>{const S=b.target.getBoundingClientRect(),w=b.clientX-S.left,A=b.clientY-S.top;c.onThumbPointerDown({x:w,y:A})}),onPointerUp:C(e.onPointerUp,c.onThumbPointerUp)})});re.displayName=H;var B="ScrollAreaCorner",oe=s.forwardRef((e,o)=>{const r=m(B,e.__scopeScrollArea),l=!!(r.scrollbarX&&r.scrollbarY);return r.type!=="scroll"&&l?f.jsx(pe,{...e,ref:o}):null});oe.displayName=B;var pe=s.forwardRef((e,o)=>{const{__scopeScrollArea:r,...l}=e,t=m(B,r),[n,c]=s.useState(0),[a,i]=s.useState(0),h=!!(n&&a);return R(t.scrollbarX,()=>{const d=t.scrollbarX?.offsetHeight||0;t.onCornerHeightChange(d),i(d)}),R(t.scrollbarY,()=>{const d=t.scrollbarY?.offsetWidth||0;t.onCornerWidthChange(d),c(d)}),h?f.jsx(L.div,{...l,ref:o,style:{width:n,height:a,position:"absolute",right:t.dir==="ltr"?0:void 0,left:t.dir==="rtl"?0:void 0,bottom:0,...e.style}}):null});function z(e){return e?parseInt(e,10):0}function te(e,o){const r=e/o;return isNaN(r)?0:r}function I(e){const o=te(e.viewport,e.content),r=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,l=(e.scrollbar.size-r)*o;return Math.max(l,18)}function we(e,o,r,l="ltr"){const t=I(r),n=t/2,c=o||n,a=t-c,i=r.scrollbar.paddingStart+c,h=r.scrollbar.size-r.scrollbar.paddingEnd-a,d=r.content-r.viewport,b=l==="ltr"?[0,d]:[d*-1,0];return ne([i,h],b)(e)}function k(e,o,r="ltr"){const l=I(o),t=o.scrollbar.paddingStart+o.scrollbar.paddingEnd,n=o.scrollbar.size-t,c=o.content-o.viewport,a=n-l,i=r==="ltr"?[0,c]:[c*-1,0],h=ie(e,i);return ne([0,c],[0,a])(h)}function ne(e,o){return r=>{if(e[0]===e[1]||o[0]===o[1])return o[0];const l=(o[1]-o[0])/(e[1]-e[0]);return o[0]+l*(r-e[0])}}function le(e,o){return e>0&&e<o}var ge=(e,o=()=>{})=>{let r={left:e.scrollLeft,top:e.scrollTop},l=0;return(function t(){const n={left:e.scrollLeft,top:e.scrollTop},c=r.left!==n.left,a=r.top!==n.top;(c||a)&&o(),r=n,l=window.requestAnimationFrame(t)})(),()=>window.cancelAnimationFrame(l)};function X(e,o){const r=P(e),l=s.useRef(0);return s.useEffect(()=>()=>window.clearTimeout(l.current),[]),s.useCallback(()=>{window.clearTimeout(l.current),l.current=window.setTimeout(r,o)},[r,o])}function R(e,o){const r=P(o);ae(()=>{let l=0;if(e){const t=new ResizeObserver(()=>{cancelAnimationFrame(l),l=window.requestAnimationFrame(r)});return t.observe(e),()=>{window.cancelAnimationFrame(l),t.unobserve(e)}}},[e,r])}var xe=q,Pe=J,Ce=oe;function ye({className:e,children:o,...r}){return f.jsxs(xe,{"data-slot":"scroll-area",className:F("relative",e),...r,children:[f.jsx(Pe,{"data-slot":"scroll-area-viewport",className:"focus-visible:ring-ring/50 size-full rounded-[inherit] transition-[color,box-shadow] outline-none focus-visible:ring-[3px] focus-visible:outline-1",children:o}),f.jsx(Ee,{}),f.jsx(Ce,{})]})}function Ee({className:e,orientation:o="vertical",...r}){return f.jsx(K,{"data-slot":"scroll-area-scrollbar",orientation:o,className:F("flex touch-none p-px transition-colors select-none",o==="vertical"&&"h-full w-2.5 border-l border-l-transparent",o==="horizontal"&&"h-2.5 flex-col border-t border-t-transparent",e),...r,children:f.jsx(re,{"data-slot":"scroll-area-thumb",className:"bg-border relative flex-1 rounded-full"})})}export{ye as S};
@@ -1 +1 @@
1
- import{d as c}from"./main-CKj5yfEi.js";const e=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],o=c("search",e);export{o as S};
1
+ import{d as c}from"./main-CXgkZMhe.js";const e=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],o=c("search",e);export{o as S};
@@ -0,0 +1 @@
1
+ import{d as nt,r as n,j as a,af as rt,a2 as _,a1 as st,a8 as Te,an as at,aa as Ie,a0 as L,ao as lt,a5 as E,a7 as $,ag as it,ap as Pe,aq as Ne,ar as ct,a6 as dt,ah as ut,aj as pt,ai as ft,ak as mt,al as ht,a4 as gt,as as vt,at as xt,C as Re,c as te}from"./main-CXgkZMhe.js";import{u as St,c as Ee,a as wt}from"./badge-qPrc4AUM.js";const yt=[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]],Ct=nt("chevron-up",yt);function It(t){const o=bt(t),e=n.forwardRef((s,r)=>{const{children:d,...l}=s,i=n.Children.toArray(d),c=i.find(Et);if(c){const p=c.props.children,g=i.map(x=>x===c?n.Children.count(p)>1?n.Children.only(null):n.isValidElement(p)?p.props.children:null:x);return a.jsx(o,{...l,ref:r,children:n.isValidElement(p)?n.cloneElement(p,void 0,g):null})}return a.jsx(o,{...l,ref:r,children:d})});return e.displayName=`${t}.Slot`,e}function bt(t){const o=n.forwardRef((e,s)=>{const{children:r,...d}=e;if(n.isValidElement(r)){const l=Nt(r),i=Pt(d,r.props);return r.type!==n.Fragment&&(i.ref=s?rt(s,l):l),n.cloneElement(r,i)}return n.Children.count(r)>1?n.Children.only(null):null});return o.displayName=`${t}.SlotClone`,o}var Tt=Symbol("radix.slottable");function Et(t){return n.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===Tt}function Pt(t,o){const e={...o};for(const s in o){const r=t[s],d=o[s];/^on[A-Z]/.test(s)?r&&d?e[s]=(...i)=>{const c=d(...i);return r(...i),c}:r&&(e[s]=r):s==="style"?e[s]={...r,...d}:s==="className"&&(e[s]=[r,d].filter(Boolean).join(" "))}return{...t,...e}}function Nt(t){let o=Object.getOwnPropertyDescriptor(t.props,"ref")?.get,e=o&&"isReactWarning"in o&&o.isReactWarning;return e?t.ref:(o=Object.getOwnPropertyDescriptor(t,"ref")?.get,e=o&&"isReactWarning"in o&&o.isReactWarning,e?t.props.ref:t.props.ref||t.ref)}var _e=Object.freeze({position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal"}),Rt="VisuallyHidden",_t=n.forwardRef((t,o)=>a.jsx(_.span,{...t,ref:o,style:{..._e,...t.style}}));_t.displayName=Rt;var jt=[" ","Enter","ArrowUp","ArrowDown"],Mt=[" ","Enter"],J="Select",[ce,de,At]=ct(J),[oe]=gt(J,[At,Ne]),ue=Ne(),[Ot,G]=oe(J),[Dt,Lt]=oe(J),je=t=>{const{__scopeSelect:o,children:e,open:s,defaultOpen:r,onOpenChange:d,value:l,defaultValue:i,onValueChange:c,dir:p,name:g,autoComplete:x,disabled:P,required:b,form:C}=t,u=ue(o),[h,S]=n.useState(null),[m,v]=n.useState(null),[F,M]=n.useState(!1),ne=st(p),[N,O]=Te({prop:s,defaultProp:r??!1,onChange:d,caller:J}),[U,q]=Te({prop:l,defaultProp:i,onChange:c,caller:J}),k=n.useRef(null),V=h?C||!!h.closest("form"):!0,[z,B]=n.useState(new Set),H=Array.from(z).map(R=>R.props.value).join(";");return a.jsx(at,{...u,children:a.jsxs(Ot,{required:b,scope:o,trigger:h,onTriggerChange:S,valueNode:m,onValueNodeChange:v,valueNodeHasChildren:F,onValueNodeHasChildrenChange:M,contentId:Ie(),value:U,onValueChange:q,open:N,onOpenChange:O,dir:ne,triggerPointerDownPosRef:k,disabled:P,children:[a.jsx(ce.Provider,{scope:o,children:a.jsx(Dt,{scope:t.__scopeSelect,onNativeOptionAdd:n.useCallback(R=>{B(D=>new Set(D).add(R))},[]),onNativeOptionRemove:n.useCallback(R=>{B(D=>{const W=new Set(D);return W.delete(R),W})},[]),children:e})}),V?a.jsxs(Qe,{"aria-hidden":!0,required:b,tabIndex:-1,name:g,autoComplete:x,value:U,onChange:R=>q(R.target.value),disabled:P,form:C,children:[U===void 0?a.jsx("option",{value:""}):null,Array.from(z)]},H):null]})})};je.displayName=J;var Me="SelectTrigger",Ae=n.forwardRef((t,o)=>{const{__scopeSelect:e,disabled:s=!1,...r}=t,d=ue(e),l=G(Me,e),i=l.disabled||s,c=L(o,l.onTriggerChange),p=de(e),g=n.useRef("touch"),[x,P,b]=tt(u=>{const h=p().filter(v=>!v.disabled),S=h.find(v=>v.value===l.value),m=ot(h,u,S);m!==void 0&&l.onValueChange(m.value)}),C=u=>{i||(l.onOpenChange(!0),b()),u&&(l.triggerPointerDownPosRef.current={x:Math.round(u.pageX),y:Math.round(u.pageY)})};return a.jsx(lt,{asChild:!0,...d,children:a.jsx(_.button,{type:"button",role:"combobox","aria-controls":l.contentId,"aria-expanded":l.open,"aria-required":l.required,"aria-autocomplete":"none",dir:l.dir,"data-state":l.open?"open":"closed",disabled:i,"data-disabled":i?"":void 0,"data-placeholder":et(l.value)?"":void 0,...r,ref:c,onClick:E(r.onClick,u=>{u.currentTarget.focus(),g.current!=="mouse"&&C(u)}),onPointerDown:E(r.onPointerDown,u=>{g.current=u.pointerType;const h=u.target;h.hasPointerCapture(u.pointerId)&&h.releasePointerCapture(u.pointerId),u.button===0&&u.ctrlKey===!1&&u.pointerType==="mouse"&&(C(u),u.preventDefault())}),onKeyDown:E(r.onKeyDown,u=>{const h=x.current!=="";!(u.ctrlKey||u.altKey||u.metaKey)&&u.key.length===1&&P(u.key),!(h&&u.key===" ")&&jt.includes(u.key)&&(C(),u.preventDefault())})})})});Ae.displayName=Me;var Oe="SelectValue",De=n.forwardRef((t,o)=>{const{__scopeSelect:e,className:s,style:r,children:d,placeholder:l="",...i}=t,c=G(Oe,e),{onValueNodeHasChildrenChange:p}=c,g=d!==void 0,x=L(o,c.onValueNodeChange);return $(()=>{p(g)},[p,g]),a.jsx(_.span,{...i,ref:x,style:{pointerEvents:"none"},children:et(c.value)?a.jsx(a.Fragment,{children:l}):d})});De.displayName=Oe;var kt="SelectIcon",Le=n.forwardRef((t,o)=>{const{__scopeSelect:e,children:s,...r}=t;return a.jsx(_.span,{"aria-hidden":!0,...r,ref:o,children:s||"▼"})});Le.displayName=kt;var Vt="SelectPortal",ke=t=>a.jsx(it,{asChild:!0,...t});ke.displayName=Vt;var Q="SelectContent",Ve=n.forwardRef((t,o)=>{const e=G(Q,t.__scopeSelect),[s,r]=n.useState();if($(()=>{r(new DocumentFragment)},[]),!e.open){const d=s;return d?Pe.createPortal(a.jsx(Be,{scope:t.__scopeSelect,children:a.jsx(ce.Slot,{scope:t.__scopeSelect,children:a.jsx("div",{children:t.children})})}),d):null}return a.jsx(He,{...t,ref:o})});Ve.displayName=Q;var A=10,[Be,Y]=oe(Q),Bt="SelectContentImpl",Ht=It("SelectContent.RemoveScroll"),He=n.forwardRef((t,o)=>{const{__scopeSelect:e,position:s="item-aligned",onCloseAutoFocus:r,onEscapeKeyDown:d,onPointerDownOutside:l,side:i,sideOffset:c,align:p,alignOffset:g,arrowPadding:x,collisionBoundary:P,collisionPadding:b,sticky:C,hideWhenDetached:u,avoidCollisions:h,...S}=t,m=G(Q,e),[v,F]=n.useState(null),[M,ne]=n.useState(null),N=L(o,f=>F(f)),[O,U]=n.useState(null),[q,k]=n.useState(null),V=de(e),[z,B]=n.useState(!1),H=n.useRef(!1);n.useEffect(()=>{if(v)return ut(v)},[v]),pt();const R=n.useCallback(f=>{const[I,...j]=V().map(T=>T.ref.current),[w]=j.slice(-1),y=document.activeElement;for(const T of f)if(T===y||(T?.scrollIntoView({block:"nearest"}),T===I&&M&&(M.scrollTop=0),T===w&&M&&(M.scrollTop=M.scrollHeight),T?.focus(),document.activeElement!==y))return},[V,M]),D=n.useCallback(()=>R([O,v]),[R,O,v]);n.useEffect(()=>{z&&D()},[z,D]);const{onOpenChange:W,triggerPointerDownPosRef:K}=m;n.useEffect(()=>{if(v){let f={x:0,y:0};const I=w=>{f={x:Math.abs(Math.round(w.pageX)-(K.current?.x??0)),y:Math.abs(Math.round(w.pageY)-(K.current?.y??0))}},j=w=>{f.x<=10&&f.y<=10?w.preventDefault():v.contains(w.target)||W(!1),document.removeEventListener("pointermove",I),K.current=null};return K.current!==null&&(document.addEventListener("pointermove",I),document.addEventListener("pointerup",j,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",I),document.removeEventListener("pointerup",j,{capture:!0})}}},[v,W,K]),n.useEffect(()=>{const f=()=>W(!1);return window.addEventListener("blur",f),window.addEventListener("resize",f),()=>{window.removeEventListener("blur",f),window.removeEventListener("resize",f)}},[W]);const[pe,ae]=tt(f=>{const I=V().filter(y=>!y.disabled),j=I.find(y=>y.ref.current===document.activeElement),w=ot(I,f,j);w&&setTimeout(()=>w.ref.current.focus())}),fe=n.useCallback((f,I,j)=>{const w=!H.current&&!j;(m.value!==void 0&&m.value===I||w)&&(U(f),w&&(H.current=!0))},[m.value]),me=n.useCallback(()=>v?.focus(),[v]),ee=n.useCallback((f,I,j)=>{const w=!H.current&&!j;(m.value!==void 0&&m.value===I||w)&&k(f)},[m.value]),le=s==="popper"?xe:We,re=le===xe?{side:i,sideOffset:c,align:p,alignOffset:g,arrowPadding:x,collisionBoundary:P,collisionPadding:b,sticky:C,hideWhenDetached:u,avoidCollisions:h}:{};return a.jsx(Be,{scope:e,content:v,viewport:M,onViewportChange:ne,itemRefCallback:fe,selectedItem:O,onItemLeave:me,itemTextRefCallback:ee,focusSelectedItem:D,selectedItemText:q,position:s,isPositioned:z,searchRef:pe,children:a.jsx(ft,{as:Ht,allowPinchZoom:!0,children:a.jsx(mt,{asChild:!0,trapped:m.open,onMountAutoFocus:f=>{f.preventDefault()},onUnmountAutoFocus:E(r,f=>{m.trigger?.focus({preventScroll:!0}),f.preventDefault()}),children:a.jsx(ht,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:d,onPointerDownOutside:l,onFocusOutside:f=>f.preventDefault(),onDismiss:()=>m.onOpenChange(!1),children:a.jsx(le,{role:"listbox",id:m.contentId,"data-state":m.open?"open":"closed",dir:m.dir,onContextMenu:f=>f.preventDefault(),...S,...re,onPlaced:()=>B(!0),ref:N,style:{display:"flex",flexDirection:"column",outline:"none",...S.style},onKeyDown:E(S.onKeyDown,f=>{const I=f.ctrlKey||f.altKey||f.metaKey;if(f.key==="Tab"&&f.preventDefault(),!I&&f.key.length===1&&ae(f.key),["ArrowUp","ArrowDown","Home","End"].includes(f.key)){let w=V().filter(y=>!y.disabled).map(y=>y.ref.current);if(["ArrowUp","End"].includes(f.key)&&(w=w.slice().reverse()),["ArrowUp","ArrowDown"].includes(f.key)){const y=f.target,T=w.indexOf(y);w=w.slice(T+1)}setTimeout(()=>R(w)),f.preventDefault()}})})})})})})});He.displayName=Bt;var Wt="SelectItemAlignedPosition",We=n.forwardRef((t,o)=>{const{__scopeSelect:e,onPlaced:s,...r}=t,d=G(Q,e),l=Y(Q,e),[i,c]=n.useState(null),[p,g]=n.useState(null),x=L(o,N=>g(N)),P=de(e),b=n.useRef(!1),C=n.useRef(!0),{viewport:u,selectedItem:h,selectedItemText:S,focusSelectedItem:m}=l,v=n.useCallback(()=>{if(d.trigger&&d.valueNode&&i&&p&&u&&h&&S){const N=d.trigger.getBoundingClientRect(),O=p.getBoundingClientRect(),U=d.valueNode.getBoundingClientRect(),q=S.getBoundingClientRect();if(d.dir!=="rtl"){const y=q.left-O.left,T=U.left-y,Z=N.left-T,X=N.width+Z,he=Math.max(X,O.width),ge=window.innerWidth-A,ve=Ee(T,[A,Math.max(A,ge-he)]);i.style.minWidth=X+"px",i.style.left=ve+"px"}else{const y=O.right-q.right,T=window.innerWidth-U.right-y,Z=window.innerWidth-N.right-T,X=N.width+Z,he=Math.max(X,O.width),ge=window.innerWidth-A,ve=Ee(T,[A,Math.max(A,ge-he)]);i.style.minWidth=X+"px",i.style.right=ve+"px"}const k=P(),V=window.innerHeight-A*2,z=u.scrollHeight,B=window.getComputedStyle(p),H=parseInt(B.borderTopWidth,10),R=parseInt(B.paddingTop,10),D=parseInt(B.borderBottomWidth,10),W=parseInt(B.paddingBottom,10),K=H+R+z+W+D,pe=Math.min(h.offsetHeight*5,K),ae=window.getComputedStyle(u),fe=parseInt(ae.paddingTop,10),me=parseInt(ae.paddingBottom,10),ee=N.top+N.height/2-A,le=V-ee,re=h.offsetHeight/2,f=h.offsetTop+re,I=H+R+f,j=K-I;if(I<=ee){const y=k.length>0&&h===k[k.length-1].ref.current;i.style.bottom="0px";const T=p.clientHeight-u.offsetTop-u.offsetHeight,Z=Math.max(le,re+(y?me:0)+T+D),X=I+Z;i.style.height=X+"px"}else{const y=k.length>0&&h===k[0].ref.current;i.style.top="0px";const Z=Math.max(ee,H+u.offsetTop+(y?fe:0)+re)+j;i.style.height=Z+"px",u.scrollTop=I-ee+u.offsetTop}i.style.margin=`${A}px 0`,i.style.minHeight=pe+"px",i.style.maxHeight=V+"px",s?.(),requestAnimationFrame(()=>b.current=!0)}},[P,d.trigger,d.valueNode,i,p,u,h,S,d.dir,s]);$(()=>v(),[v]);const[F,M]=n.useState();$(()=>{p&&M(window.getComputedStyle(p).zIndex)},[p]);const ne=n.useCallback(N=>{N&&C.current===!0&&(v(),m?.(),C.current=!1)},[v,m]);return a.jsx(Ut,{scope:e,contentWrapper:i,shouldExpandOnScrollRef:b,onScrollButtonChange:ne,children:a.jsx("div",{ref:c,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:F},children:a.jsx(_.div,{...r,ref:x,style:{boxSizing:"border-box",maxHeight:"100%",...r.style}})})})});We.displayName=Wt;var Ft="SelectPopperPosition",xe=n.forwardRef((t,o)=>{const{__scopeSelect:e,align:s="start",collisionPadding:r=A,...d}=t,l=ue(e);return a.jsx(vt,{...l,...d,ref:o,align:s,collisionPadding:r,style:{boxSizing:"border-box",...d.style,"--radix-select-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-select-content-available-width":"var(--radix-popper-available-width)","--radix-select-content-available-height":"var(--radix-popper-available-height)","--radix-select-trigger-width":"var(--radix-popper-anchor-width)","--radix-select-trigger-height":"var(--radix-popper-anchor-height)"}})});xe.displayName=Ft;var[Ut,be]=oe(Q,{}),Se="SelectViewport",Fe=n.forwardRef((t,o)=>{const{__scopeSelect:e,nonce:s,...r}=t,d=Y(Se,e),l=be(Se,e),i=L(o,d.onViewportChange),c=n.useRef(0);return a.jsxs(a.Fragment,{children:[a.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"},nonce:s}),a.jsx(ce.Slot,{scope:e,children:a.jsx(_.div,{"data-radix-select-viewport":"",role:"presentation",...r,ref:i,style:{position:"relative",flex:1,overflow:"hidden auto",...r.style},onScroll:E(r.onScroll,p=>{const g=p.currentTarget,{contentWrapper:x,shouldExpandOnScrollRef:P}=l;if(P?.current&&x){const b=Math.abs(c.current-g.scrollTop);if(b>0){const C=window.innerHeight-A*2,u=parseFloat(x.style.minHeight),h=parseFloat(x.style.height),S=Math.max(u,h);if(S<C){const m=S+b,v=Math.min(C,m),F=m-v;x.style.height=v+"px",x.style.bottom==="0px"&&(g.scrollTop=F>0?F:0,x.style.justifyContent="flex-end")}}}c.current=g.scrollTop})})})]})});Fe.displayName=Se;var Ue="SelectGroup",[zt,Kt]=oe(Ue),$t=n.forwardRef((t,o)=>{const{__scopeSelect:e,...s}=t,r=Ie();return a.jsx(zt,{scope:e,id:r,children:a.jsx(_.div,{role:"group","aria-labelledby":r,...s,ref:o})})});$t.displayName=Ue;var ze="SelectLabel",Gt=n.forwardRef((t,o)=>{const{__scopeSelect:e,...s}=t,r=Kt(ze,e);return a.jsx(_.div,{id:r.id,...s,ref:o})});Gt.displayName=ze;var ie="SelectItem",[Yt,Ke]=oe(ie),$e=n.forwardRef((t,o)=>{const{__scopeSelect:e,value:s,disabled:r=!1,textValue:d,...l}=t,i=G(ie,e),c=Y(ie,e),p=i.value===s,[g,x]=n.useState(d??""),[P,b]=n.useState(!1),C=L(o,m=>c.itemRefCallback?.(m,s,r)),u=Ie(),h=n.useRef("touch"),S=()=>{r||(i.onValueChange(s),i.onOpenChange(!1))};if(s==="")throw new Error("A <Select.Item /> must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder.");return a.jsx(Yt,{scope:e,value:s,disabled:r,textId:u,isSelected:p,onItemTextChange:n.useCallback(m=>{x(v=>v||(m?.textContent??"").trim())},[]),children:a.jsx(ce.ItemSlot,{scope:e,value:s,disabled:r,textValue:g,children:a.jsx(_.div,{role:"option","aria-labelledby":u,"data-highlighted":P?"":void 0,"aria-selected":p&&P,"data-state":p?"checked":"unchecked","aria-disabled":r||void 0,"data-disabled":r?"":void 0,tabIndex:r?void 0:-1,...l,ref:C,onFocus:E(l.onFocus,()=>b(!0)),onBlur:E(l.onBlur,()=>b(!1)),onClick:E(l.onClick,()=>{h.current!=="mouse"&&S()}),onPointerUp:E(l.onPointerUp,()=>{h.current==="mouse"&&S()}),onPointerDown:E(l.onPointerDown,m=>{h.current=m.pointerType}),onPointerMove:E(l.onPointerMove,m=>{h.current=m.pointerType,r?c.onItemLeave?.():h.current==="mouse"&&m.currentTarget.focus({preventScroll:!0})}),onPointerLeave:E(l.onPointerLeave,m=>{m.currentTarget===document.activeElement&&c.onItemLeave?.()}),onKeyDown:E(l.onKeyDown,m=>{c.searchRef?.current!==""&&m.key===" "||(Mt.includes(m.key)&&S(),m.key===" "&&m.preventDefault())})})})})});$e.displayName=ie;var se="SelectItemText",Ge=n.forwardRef((t,o)=>{const{__scopeSelect:e,className:s,style:r,...d}=t,l=G(se,e),i=Y(se,e),c=Ke(se,e),p=Lt(se,e),[g,x]=n.useState(null),P=L(o,S=>x(S),c.onItemTextChange,S=>i.itemTextRefCallback?.(S,c.value,c.disabled)),b=g?.textContent,C=n.useMemo(()=>a.jsx("option",{value:c.value,disabled:c.disabled,children:b},c.value),[c.disabled,c.value,b]),{onNativeOptionAdd:u,onNativeOptionRemove:h}=p;return $(()=>(u(C),()=>h(C)),[u,h,C]),a.jsxs(a.Fragment,{children:[a.jsx(_.span,{id:c.textId,...d,ref:P}),c.isSelected&&l.valueNode&&!l.valueNodeHasChildren?Pe.createPortal(d.children,l.valueNode):null]})});Ge.displayName=se;var Ye="SelectItemIndicator",qe=n.forwardRef((t,o)=>{const{__scopeSelect:e,...s}=t;return Ke(Ye,e).isSelected?a.jsx(_.span,{"aria-hidden":!0,...s,ref:o}):null});qe.displayName=Ye;var we="SelectScrollUpButton",Ze=n.forwardRef((t,o)=>{const e=Y(we,t.__scopeSelect),s=be(we,t.__scopeSelect),[r,d]=n.useState(!1),l=L(o,s.onScrollButtonChange);return $(()=>{if(e.viewport&&e.isPositioned){let i=function(){const p=c.scrollTop>0;d(p)};const c=e.viewport;return i(),c.addEventListener("scroll",i),()=>c.removeEventListener("scroll",i)}},[e.viewport,e.isPositioned]),r?a.jsx(Je,{...t,ref:l,onAutoScroll:()=>{const{viewport:i,selectedItem:c}=e;i&&c&&(i.scrollTop=i.scrollTop-c.offsetHeight)}}):null});Ze.displayName=we;var ye="SelectScrollDownButton",Xe=n.forwardRef((t,o)=>{const e=Y(ye,t.__scopeSelect),s=be(ye,t.__scopeSelect),[r,d]=n.useState(!1),l=L(o,s.onScrollButtonChange);return $(()=>{if(e.viewport&&e.isPositioned){let i=function(){const p=c.scrollHeight-c.clientHeight,g=Math.ceil(c.scrollTop)<p;d(g)};const c=e.viewport;return i(),c.addEventListener("scroll",i),()=>c.removeEventListener("scroll",i)}},[e.viewport,e.isPositioned]),r?a.jsx(Je,{...t,ref:l,onAutoScroll:()=>{const{viewport:i,selectedItem:c}=e;i&&c&&(i.scrollTop=i.scrollTop+c.offsetHeight)}}):null});Xe.displayName=ye;var Je=n.forwardRef((t,o)=>{const{__scopeSelect:e,onAutoScroll:s,...r}=t,d=Y("SelectScrollButton",e),l=n.useRef(null),i=de(e),c=n.useCallback(()=>{l.current!==null&&(window.clearInterval(l.current),l.current=null)},[]);return n.useEffect(()=>()=>c(),[c]),$(()=>{i().find(g=>g.ref.current===document.activeElement)?.ref.current?.scrollIntoView({block:"nearest"})},[i]),a.jsx(_.div,{"aria-hidden":!0,...r,ref:o,style:{flexShrink:0,...r.style},onPointerDown:E(r.onPointerDown,()=>{l.current===null&&(l.current=window.setInterval(s,50))}),onPointerMove:E(r.onPointerMove,()=>{d.onItemLeave?.(),l.current===null&&(l.current=window.setInterval(s,50))}),onPointerLeave:E(r.onPointerLeave,()=>{c()})})}),qt="SelectSeparator",Zt=n.forwardRef((t,o)=>{const{__scopeSelect:e,...s}=t;return a.jsx(_.div,{"aria-hidden":!0,...s,ref:o})});Zt.displayName=qt;var Ce="SelectArrow",Xt=n.forwardRef((t,o)=>{const{__scopeSelect:e,...s}=t,r=ue(e),d=G(Ce,e),l=Y(Ce,e);return d.open&&l.position==="popper"?a.jsx(xt,{...r,...s,ref:o}):null});Xt.displayName=Ce;var Jt="SelectBubbleInput",Qe=n.forwardRef(({__scopeSelect:t,value:o,...e},s)=>{const r=n.useRef(null),d=L(s,r),l=St(o);return n.useEffect(()=>{const i=r.current;if(!i)return;const c=window.HTMLSelectElement.prototype,g=Object.getOwnPropertyDescriptor(c,"value").set;if(l!==o&&g){const x=new Event("change",{bubbles:!0});g.call(i,o),i.dispatchEvent(x)}},[l,o]),a.jsx(_.select,{...e,style:{..._e,...e.style},ref:d,defaultValue:o})});Qe.displayName=Jt;function et(t){return t===""||t===void 0}function tt(t){const o=dt(t),e=n.useRef(""),s=n.useRef(0),r=n.useCallback(l=>{const i=e.current+l;o(i),(function c(p){e.current=p,window.clearTimeout(s.current),p!==""&&(s.current=window.setTimeout(()=>c(""),1e3))})(i)},[o]),d=n.useCallback(()=>{e.current="",window.clearTimeout(s.current)},[]);return n.useEffect(()=>()=>window.clearTimeout(s.current),[]),[e,r,d]}function ot(t,o,e){const r=o.length>1&&Array.from(o).every(p=>p===o[0])?o[0]:o,d=e?t.indexOf(e):-1;let l=Qt(t,Math.max(d,0));r.length===1&&(l=l.filter(p=>p!==e));const c=l.find(p=>p.textValue.toLowerCase().startsWith(r.toLowerCase()));return c!==e?c:void 0}function Qt(t,o){return t.map((e,s)=>t[(o+s)%t.length])}var eo=je,to=Ae,oo=De,no=Le,ro=ke,so=Ve,ao=Fe,lo=$e,io=Ge,co=qe,uo=Ze,po=Xe;function vo({...t}){return a.jsx(eo,{"data-slot":"select",...t})}function xo({...t}){return a.jsx(oo,{"data-slot":"select-value",...t})}function So({className:t,size:o="default",children:e,...s}){return a.jsxs(to,{"data-slot":"select-trigger","data-size":o,className:te("border-input data-[placeholder]:text-muted-foreground [&_svg:not([class*='text-'])]:text-muted-foreground focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:bg-input/30 dark:hover:bg-input/50 flex w-fit items-center justify-between gap-2 rounded-md border bg-transparent px-3 py-2 text-sm whitespace-nowrap shadow-xs transition-[color,box-shadow] outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 data-[size=default]:h-9 data-[size=sm]:h-8 *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-2 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",t),...s,children:[e,a.jsx(no,{asChild:!0,children:a.jsx(Re,{className:"size-4 opacity-50"})})]})}function wo({className:t,children:o,position:e="item-aligned",align:s="center",...r}){return a.jsx(ro,{children:a.jsxs(so,{"data-slot":"select-content",className:te("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 relative z-50 max-h-(--radix-select-content-available-height) min-w-[8rem] origin-(--radix-select-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border shadow-md",e==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",t),position:e,align:s,...r,children:[a.jsx(fo,{}),a.jsx(ao,{className:te("p-1",e==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)] scroll-my-1"),children:o}),a.jsx(mo,{})]})})}function yo({className:t,children:o,...e}){return a.jsxs(lo,{"data-slot":"select-item",className:te("focus:bg-accent focus:text-accent-foreground [&_svg:not([class*='text-'])]:text-muted-foreground relative flex w-full cursor-default items-center gap-2 rounded-sm py-1.5 pr-8 pl-2 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2",t),...e,children:[a.jsx("span",{"data-slot":"select-item-indicator",className:"absolute right-2 flex size-3.5 items-center justify-center",children:a.jsx(co,{children:a.jsx(wt,{className:"size-4"})})}),a.jsx(io,{children:o})]})}function fo({className:t,...o}){return a.jsx(uo,{"data-slot":"select-scroll-up-button",className:te("flex cursor-default items-center justify-center py-1",t),...o,children:a.jsx(Ct,{className:"size-4"})})}function mo({className:t,...o}){return a.jsx(po,{"data-slot":"select-scroll-down-button",className:te("flex cursor-default items-center justify-center py-1",t),...o,children:a.jsx(Re,{className:"size-4"})})}export{Ct as C,vo as S,_t as V,So as a,xo as b,wo as c,yo as d};
@@ -0,0 +1 @@
1
+ import{d as N,g as A,u as R,a as w,r as i,j as e,R as p,h as _,c as F,b as I}from"./main-CXgkZMhe.js";import{B as M,a as q,X as O,C as b}from"./badge-qPrc4AUM.js";import{L as l}from"./label-DCsUdvFh.js";import{S as B,a as G,b as V,c as H,d as U}from"./select-Co3TZFJb.js";import{u as $}from"./usePermissions-C1JQhfqb.js";import{C as y}from"./CmsPageHeader-ohOq0luT.js";import{C as f}from"./CmsSurface-CWup6Jh7.js";import{S as v}from"./switch-CfavASmR.js";import{A as J,a as Q}from"./alert-Bf2l8kxw.js";import{T as X}from"./triangle-alert-BZRcqsUg.js";import{u as Z}from"./tanstack-adapter-npeE3RdY.js";const K=[["rect",{width:"20",height:"14",x:"2",y:"3",rx:"2",key:"48i651"}],["line",{x1:"8",x2:"16",y1:"21",y2:"21",key:"1svkeh"}],["line",{x1:"12",x2:"12",y1:"17",y2:"21",key:"vw1qmm"}]],W=N("monitor",K);const Y=[["path",{d:"M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401",key:"kfwtm"}]],ee=N("moon",Y);const se=[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m4.93 4.93 1.41 1.41",key:"149t6j"}],["path",{d:"m17.66 17.66 1.41 1.41",key:"ptbguv"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m6.34 17.66-1.41 1.41",key:"1m8zz5"}],["path",{d:"m19.07 4.93-1.41 1.41",key:"1shlcs"}]],te=N("sun",se),ae=[{value:"en",label:"English (en)"},{value:"es",label:"Spanish (es)"},{value:"fr",label:"French (fr)"},{value:"de",label:"German (de)"},{value:"it",label:"Italian (it)"},{value:"pt",label:"Portuguese (pt)"},{value:"zh",label:"Chinese (zh)"},{value:"ja",label:"Japanese (ja)"}],ne=[{value:"light",label:"Light",icon:e.jsx(te,{className:"size-4"})},{value:"dark",label:"Dark",icon:e.jsx(ee,{className:"size-4"})},{value:"system",label:"System",icon:e.jsx(W,{className:"size-4"})}];function ie(){const{theme:c,setTheme:k}=_();return e.jsxs(f,{elevation:"base",className:"p-6",children:[e.jsx("h2",{className:"mb-4 text-lg font-semibold text-foreground",children:"Appearance"}),e.jsx("div",{className:"space-y-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(l,{className:"text-sm font-medium",children:"Theme"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Choose your preferred color theme for the admin interface."})]}),e.jsx("div",{className:"flex gap-1 rounded-lg border bg-muted/50 p-1",children:ne.map(d=>e.jsxs("button",{type:"button",onClick:()=>k(d.value),className:F("flex items-center gap-2 rounded-md px-3 py-1.5 text-sm font-medium transition-colors",c===d.value?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),children:[d.icon,d.label]},d.value))})]})})]})}function re({api:c,navigation:k}){const{canManageSettings:d}=$(),o=d(),{baseConfig:E}=A(),a=R(c.settings.get),C=w(c.settings.update),S=w(c.settings.reset),[s,m]=i.useState(null),[u,x]=i.useState(!1),[r,n]=i.useState("idle"),[T,h]=i.useState(null);i.useEffect(()=>{a&&!s&&m(a)},[a,s]),i.useEffect(()=>{a&&!u&&m(a)},[a,u]);const z=i.useCallback(t=>{s&&(m({...s,defaultLocale:t}),x(!0),n("idle"))},[s]),g=i.useCallback(t=>{s&&(m({...s,features:{...s.features,[t]:!s.features[t]}}),x(!0),n("idle"))},[s]),L=i.useCallback(async()=>{if(!(!s||!u)){n("saving"),h(null);try{await C({defaultLocale:s.defaultLocale,features:s.features}),n("saved"),x(!1),setTimeout(()=>{n("idle")},3e3)}catch(t){n("error"),h(t instanceof Error?t.message:"Failed to save settings")}}},[s,u,C]),D=i.useCallback(async()=>{if(window.confirm("Are you sure you want to reset all settings to their defaults? This action cannot be undone.")){n("saving"),h(null);try{const j=await S({});m(j),n("saved"),x(!1),setTimeout(()=>{n("idle")},3e3)}catch(j){n("error"),h(j instanceof Error?j.message:"Failed to reset settings")}}},[S]),P=i.useCallback(()=>{a&&(m(a),x(!1),n("idle"),h(null))},[a]);return a===void 0?e.jsx(p,{requiredPermission:{resource:"settings",action:"manage"},children:e.jsxs("div",{className:"space-y-6 p-6",children:[e.jsx(y,{title:"Settings",description:"Configure your CMS settings and preferences."}),e.jsxs("div",{className:"flex flex-col items-center justify-center py-12",children:[e.jsx("div",{className:"size-8 animate-spin rounded-full border-2 border-muted border-t-primary"}),e.jsx("p",{className:"mt-4 text-sm text-muted-foreground",children:"Loading settings..."})]})]})}):a===null&&!s?e.jsx(p,{requiredPermission:{resource:"settings",action:"manage"},children:e.jsxs("div",{className:"space-y-6 p-6",children:[e.jsx(y,{title:"Settings",description:"Configure your CMS settings and preferences."}),e.jsxs(J,{variant:"destructive",children:[e.jsx(X,{className:"size-4"}),e.jsx(Q,{children:"Failed to load settings. Please try refreshing the page."})]})]})}):e.jsx(p,{requiredPermission:{resource:"settings",action:"manage"},children:e.jsxs("div",{className:"space-y-6 p-6",children:[e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsx(y,{title:"Settings",description:"Configure your CMS settings and preferences."}),o&&e.jsxs("div",{className:"flex items-center gap-3",children:[r==="saved"&&e.jsxs(M,{variant:"secondary",className:"gap-1 bg-emerald-100 text-emerald-700",children:[e.jsx(q,{className:"size-3"}),"Settings saved successfully"]}),r==="error"&&e.jsxs(M,{variant:"destructive",className:"gap-1",children:[e.jsx(O,{className:"size-3"}),T||"An error occurred"]}),u&&e.jsx(b,{variant:"secondary",onClick:P,disabled:r==="saving",children:"Discard Changes"}),e.jsx(b,{onClick:L,disabled:!u,loading:r==="saving",children:"Save Changes"})]})]}),e.jsxs("div",{className:"space-y-6",children:[e.jsx(ie,{}),s?.features.localization&&e.jsxs(f,{elevation:"base",className:"p-6",children:[e.jsx("h2",{className:"mb-4 text-lg font-semibold text-foreground",children:"General"}),e.jsx("div",{className:"space-y-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(l,{className:"text-sm font-medium",children:"Default Locale"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"The default language for new content entries."})]}),e.jsxs(B,{value:s?.defaultLocale||"en",onValueChange:z,disabled:!o||r==="saving",children:[e.jsx(G,{className:"w-48",children:e.jsx(V,{})}),e.jsx(H,{children:ae.map(t=>e.jsx(U,{value:t.value,children:t.label},t.value))})]})]})})]}),e.jsxs(f,{elevation:"base",className:"p-6",children:[e.jsx("h2",{className:"mb-4 text-lg font-semibold text-foreground",children:"Features"}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(l,{className:"text-sm font-medium",children:"Enable Versioning"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Track content history and enable rollback to previous versions"})]}),e.jsx(v,{checked:s?.features.versioning??!0,onCheckedChange:()=>g("versioning"),disabled:!o||r==="saving"})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(l,{className:"text-sm font-medium",children:"Enable Scheduling"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Schedule content to publish at a future date and time"})]}),e.jsx(v,{checked:s?.features.scheduling??!0,onCheckedChange:()=>g("scheduling"),disabled:!o||r==="saving"})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(l,{className:"text-sm font-medium",children:"Enable Localization"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Support multiple languages for content entries"})]}),e.jsx(v,{checked:s?.features.localization??!1,onCheckedChange:()=>g("localization"),disabled:!o||r==="saving"})]}),E.navigation.showMedia&&e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(l,{className:"text-sm font-medium",children:"Enable Media Management"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Use the built-in media library for image and file uploads"})]}),e.jsx(v,{checked:s?.features.mediaManagement??!0,onCheckedChange:()=>g("mediaManagement"),disabled:!o||r==="saving"})]})]})]}),e.jsxs(f,{elevation:"base",className:"p-6",children:[e.jsx("h2",{className:"mb-4 text-lg font-semibold text-foreground",children:"API"}),e.jsx("div",{className:"space-y-4",children:e.jsxs("div",{children:[e.jsx(l,{className:"text-sm font-medium",children:"Convex Deployment URL"}),e.jsx("code",{className:"mt-1 block rounded-md bg-muted px-3 py-2 text-sm",children:"https://majestic-beagle-49.convex.cloud"})]})})]}),o&&e.jsxs(f,{elevation:"base",className:"border-red-200 p-6 dark:border-red-900",children:[e.jsx("h2",{className:"mb-4 text-lg font-semibold text-red-600",children:"Danger Zone"}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(l,{className:"text-sm font-medium",children:"Reset to Defaults"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Reset all settings to their default values. This cannot be undone."})]}),e.jsx(b,{variant:"danger",onClick:D,disabled:r==="saving",children:"Reset Settings"})]})]})]})]})})}function ve(){const c=Z();return e.jsx(re,{api:I,navigation:c})}export{ve as component};
@@ -0,0 +1 @@
1
+ import{r as s,a0 as C,a8 as T,j as o,a2 as y,a5 as I,a9 as M,a4 as H,c as g}from"./main-CXgkZMhe.js";import{u as z}from"./badge-qPrc4AUM.js";var b="Switch",[A]=H(b),[U,q]=A(b),P=s.forwardRef((e,a)=>{const{__scopeSwitch:t,name:n,checked:r,defaultChecked:m,required:d,disabled:c,value:u="on",onCheckedChange:k,form:i,...w}=e,[l,p]=s.useState(null),v=C(a,f=>p(f)),x=s.useRef(!1),S=l?i||!!l.closest("form"):!0,[h,N]=T({prop:r,defaultProp:m??!1,onChange:k,caller:b});return o.jsxs(U,{scope:t,checked:h,disabled:c,children:[o.jsx(y.button,{type:"button",role:"switch","aria-checked":h,"aria-required":d,"data-state":_(h),"data-disabled":c?"":void 0,disabled:c,value:u,...w,ref:v,onClick:I(e.onClick,f=>{N(B=>!B),S&&(x.current=f.isPropagationStopped(),x.current||f.stopPropagation())})}),S&&o.jsx(j,{control:l,bubbles:!x.current,name:n,value:u,checked:h,required:d,disabled:c,form:i,style:{transform:"translateX(-100%)"}})]})});P.displayName=b;var E="SwitchThumb",R=s.forwardRef((e,a)=>{const{__scopeSwitch:t,...n}=e,r=q(E,t);return o.jsx(y.span,{"data-state":_(r.checked),"data-disabled":r.disabled?"":void 0,...n,ref:a})});R.displayName=E;var L="SwitchBubbleInput",j=s.forwardRef(({__scopeSwitch:e,control:a,checked:t,bubbles:n=!0,...r},m)=>{const d=s.useRef(null),c=C(d,m),u=z(t),k=M(a);return s.useEffect(()=>{const i=d.current;if(!i)return;const w=window.HTMLInputElement.prototype,p=Object.getOwnPropertyDescriptor(w,"checked").set;if(u!==t&&p){const v=new Event("click",{bubbles:n});p.call(i,t),i.dispatchEvent(v)}},[u,t,n]),o.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:t,...r,tabIndex:-1,ref:c,style:{...r.style,...k,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});j.displayName=L;function _(e){return e?"checked":"unchecked"}var O=P,D=R;function X({className:e,...a}){return o.jsx(O,{"data-slot":"switch",className:g("peer data-[state=checked]:bg-primary data-[state=unchecked]:bg-input focus-visible:border-ring focus-visible:ring-ring/50 dark:data-[state=unchecked]:bg-input/80 inline-flex h-[1.15rem] w-8 shrink-0 items-center rounded-full border border-transparent shadow-xs transition-all outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50",e),...a,children:o.jsx(D,{"data-slot":"switch-thumb",className:g("bg-background dark:data-[state=unchecked]:bg-foreground dark:data-[state=checked]:bg-primary-foreground pointer-events-none block size-4 rounded-full ring-0 transition-transform data-[state=checked]:translate-x-[calc(100%-2px)] data-[state=unchecked]:translate-x-0")})})}export{X as S};
@@ -0,0 +1 @@
1
+ import{d as k,r as u,a as H,j as t,_ as ee,c as N,a1 as te,a8 as se,a2 as _,aa as re,ab as ae,ac as ne,a5 as z,ad as B,a4 as oe,a3 as ie}from"./main-CXgkZMhe.js";import{C as j,X as $,a as ce}from"./badge-qPrc4AUM.js";const le=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],Re=k("chevron-left",le);const de=[["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"}]],Ue=k("file",de);const ue=[["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"}]],De=k("music",ue);const pe=[["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"}]],me=k("refresh-cw",pe);const ge=[["path",{d:"M12 3v12",key:"1x0j5s"}],["path",{d:"m17 8-5-5-5 5",key:"7q97r8"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}]],fe=k("upload",ge);const he=[["path",{d:"m16 13 5.223 3.482a.5.5 0 0 0 .777-.416V7.87a.5.5 0 0 0-.752-.432L16 10.5",key:"ftymec"}],["rect",{x:"2",y:"6",width:"14",height:"12",rx:"2",key:"158x01"}]],Ie=k("video",he);function ve(){return`${Date.now()}-${Math.random().toString(36).substring(2,9)}`}function xe(r,a=5e3){return r.type.startsWith("image/")?new Promise(s=>{const c=new Image;let l=null;const i=setTimeout(()=>{l&&URL.revokeObjectURL(l),s(void 0)},a);c.onload=()=>{clearTimeout(i),l&&URL.revokeObjectURL(l),s({width:c.naturalWidth,height:c.naturalHeight})},c.onerror=()=>{clearTimeout(i),l&&URL.revokeObjectURL(l),s(void 0)},l=URL.createObjectURL(r),c.src=l}):Promise.resolve(void 0)}function be(r,a,s,c){return new Promise((l,i)=>{const n=new XMLHttpRequest,g=()=>{n.abort(),i(new DOMException("Upload aborted","AbortError"))};s.addEventListener("abort",g),n.upload.onprogress=h=>{if(h.lengthComputable){const v=Math.round(h.loaded/h.total*80);c(10+v)}},n.onload=()=>{if(s.removeEventListener("abort",g),n.status>=200&&n.status<300)try{const h=JSON.parse(n.responseText);l(h.storageId)}catch{i(new Error("Invalid response from upload server"))}else i(new Error(`Upload failed: ${n.statusText||`HTTP ${n.status}`}`))},n.onerror=()=>{s.removeEventListener("abort",g),i(new Error("Network error during upload"))},n.ontimeout=()=>{s.removeEventListener("abort",g),i(new Error("Upload timed out"))},n.open("POST",r),n.setRequestHeader("Content-Type",a.type),n.send(a)})}function Ce(r,a){switch(a.type){case"ADD_FILES":{const s=a.files.map(c=>({id:ve(),file:c,status:"pending",progress:0}));return[...r,...s]}case"UPDATE_FILE":return r.map(s=>s.id===a.id?{...s,...a.updates}:s);case"RETRY_FILE":return r.map(s=>s.id===a.id?{...s,status:"pending",progress:0,error:void 0}:s);case"REMOVE_FILE":return r.filter(s=>s.id!==a.id);case"CLEAR_COMPLETED":return r.filter(s=>s.status==="pending"||s.status==="uploading");case"CLEAR_ALL":return[];case"CANCEL_FILE":return r.map(s=>s.id===a.id&&(s.status==="pending"||s.status==="uploading")?{...s,status:"cancelled",error:"Upload cancelled"}:s);case"CANCEL_ALL":return r.map(s=>s.status==="pending"||s.status==="uploading"?{...s,status:"cancelled",error:"Upload cancelled"}:s);default:return r}}function ye(r){const{maxConcurrent:a=3,metadata:s,onComplete:c,onError:l}=r,[i,n]=u.useReducer(Ce,[]),g=H(r.getUploadUrl),h=H(r.createAsset),v=u.useRef(0),p=u.useRef(new Map),m=u.useRef(!1),x=u.useCallback(async o=>{const f=new AbortController;p.current.set(o.id,f),n({type:"UPDATE_FILE",id:o.id,updates:{status:"uploading",progress:0}});try{const y=await g({});n({type:"UPDATE_FILE",id:o.id,updates:{progress:5}});const e=await be(y,o.file,f.signal,L=>{n({type:"UPDATE_FILE",id:o.id,updates:{progress:L}})});n({type:"UPDATE_FILE",id:o.id,updates:{progress:90}});const C=await xe(o.file),b=await h({storageId:e,name:o.file.name,mimeType:o.file.type,size:o.file.size,...C,...s});n({type:"UPDATE_FILE",id:o.id,updates:{status:"complete",progress:100,result:b}})}catch(y){const e=y instanceof Error?y:new Error(String(y));if(e.name==="AbortError")n({type:"UPDATE_FILE",id:o.id,updates:{status:"cancelled",error:"Upload cancelled"}});else{const C={...o,status:"error",error:e.message};n({type:"UPDATE_FILE",id:o.id,updates:{status:"error",error:e.message}}),l?.(C)}}finally{p.current.delete(o.id),v.current--}},[g,h,s,l]),d=u.useCallback(()=>{if(m.current)return;m.current=!0;const o=i.filter(f=>f.status==="pending");for(;v.current<a&&o.length>0;){const f=o.shift();v.current++,x(f)}m.current=!1,v.current===0&&i.length>0&&i.every(f=>f.status!=="pending"&&f.status!=="uploading")&&c?.(i)},[i,a,x,c]);u.useEffect(()=>{i.some(o=>o.status==="pending")&&v.current<a&&d()},[i,a,d]);const A=u.useCallback(o=>{n({type:"ADD_FILES",files:o})},[]),E=u.useCallback(o=>{const f=p.current.get(o);f&&f.abort(),n({type:"CANCEL_FILE",id:o})},[]),w=u.useCallback(()=>{p.current.forEach(o=>o.abort()),n({type:"CANCEL_ALL"})},[]),R=u.useCallback(o=>{n({type:"RETRY_FILE",id:o})},[]),U=u.useCallback(()=>{n({type:"CLEAR_COMPLETED"})},[]),D=u.useCallback(()=>{p.current.forEach(o=>o.abort()),n({type:"CLEAR_ALL"})},[]),I=i.some(o=>o.status==="uploading"),M=i.length>0?Math.round(i.reduce((o,f)=>o+f.progress,0)/i.length):0;return{files:i,addFiles:A,cancelFile:E,cancelAll:w,retryFile:R,clearCompleted:U,clearAll:D,isUploading:I,overallProgress:M}}function S(r){if(r===0)return"0 B";const a=1024,s=["B","KB","MB","GB"],c=Math.floor(Math.log(r)/Math.log(a));return`${parseFloat((r/Math.pow(a,c)).toFixed(1))} ${s[c]}`}function je(r,a){return a.length===0?!0:a.some(s=>{if(s.endsWith("/*")){const c=s.slice(0,-2);return r.startsWith(c+"/")}return r===s})}function Me({onUploadComplete:r,currentFolderId:a,generateUploadUrl:s,createAsset:c,maxFileSize:l,allowedMimeTypes:i=[],maxConcurrentUploads:n=3,onError:g}){const[h,v]=u.useState(!1),[p,m]=u.useState(new Map),x=u.useRef(null),d=ye({getUploadUrl:s,createAsset:c,maxConcurrent:n,metadata:a?{parentId:a}:void 0,onComplete:e=>{const C=e.map(b=>({filename:b.file.name,storageId:b.result?String(b.result._id||""):"",success:b.status==="complete",error:b.error}));r(C)},onError:e=>{g?.(e.error||"Upload failed",e.file.name)}}),A=u.useCallback(e=>l&&e.size>l?`File exceeds maximum size of ${S(l)}`:i.length>0&&!je(e.type,i)?`File type ${e.type||"unknown"} is not allowed`:null,[l,i]),E=u.useCallback(e=>{const C=Array.from(e),b=new Map,L=[];for(const P of C){const V=A(P);V?b.set(P.name,V):L.push(P)}m(b),L.length>0&&d.addFiles(L)},[A,d]),w=u.useCallback(e=>{e.preventDefault(),e.stopPropagation(),v(!0)},[]),R=u.useCallback(e=>{e.preventDefault(),e.stopPropagation(),v(!1)},[]),U=u.useCallback(e=>{e.preventDefault(),e.stopPropagation()},[]),D=u.useCallback(e=>{e.preventDefault(),e.stopPropagation(),v(!1),e.dataTransfer.files?.length&&E(e.dataTransfer.files)},[E]),I=u.useCallback(e=>{e.target.files?.length&&(E(e.target.files),e.target.value="")},[E]),M=e=>{switch(e){case"complete":return t.jsx(ce,{className:"size-4 text-emerald-500"});case"error":case"cancelled":return t.jsx($,{className:"size-4 text-red-500"});case"uploading":return t.jsx("div",{className:"size-4 animate-spin rounded-full border-2 border-muted border-t-primary"});default:return t.jsx("div",{className:"size-4 rounded-full border-2 border-muted"})}},o=d.files.filter(e=>e.status==="complete").length,f=d.files.filter(e=>e.status==="error"||e.status==="cancelled").length,y=o>0||f>0;return t.jsxs("div",{className:"space-y-4",children:[p.size>0&&t.jsxs("div",{className:"rounded-md border border-destructive/50 bg-destructive/10 p-3",children:[t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsx(ee,{className:"mt-0.5 size-4 shrink-0 text-destructive"}),t.jsx("div",{className:"flex-1 space-y-1",children:Array.from(p.entries()).map(([e,C])=>t.jsxs("p",{className:"text-sm text-destructive",children:[t.jsxs("span",{className:"font-medium",children:[e,":"]})," ",C]},e))})]}),t.jsx(j,{variant:"ghost",size:"sm",className:"mt-2",onClick:()=>m(new Map),children:"Dismiss"})]}),!d.isUploading&&d.files.length===0&&t.jsxs("div",{className:N("flex cursor-pointer flex-col items-center justify-center gap-3 rounded-lg border-2 border-dashed p-8 text-center transition-colors",h?"border-primary bg-primary/5":"border-muted-foreground/25 hover:border-primary/50 hover:bg-muted/50"),onClick:()=>x.current?.click(),onDragEnter:w,onDragLeave:R,onDragOver:U,onDrop:D,children:[t.jsx("div",{className:"flex size-12 items-center justify-center rounded-full bg-muted",children:t.jsx(fe,{className:"size-6 text-muted-foreground"})}),t.jsxs("div",{children:[t.jsx("p",{className:"text-sm font-medium text-foreground",children:h?"Drop files here":"Drag and drop files here"}),t.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:"or click to browse"})]}),t.jsxs("p",{className:"text-xs text-muted-foreground",children:["Supports images, videos, documents, and more",l&&` (max ${S(l)} per file)`]})]}),d.files.length>0&&t.jsxs("div",{className:"space-y-3",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[t.jsxs("span",{className:"font-medium",children:[d.files.length," file",d.files.length!==1?"s":""]}),d.isUploading&&t.jsxs("span",{className:"text-muted-foreground",children:[d.overallProgress,"% complete"]}),!d.isUploading&&y&&t.jsxs("div",{className:"flex items-center gap-2",children:[o>0&&t.jsxs("span",{className:"text-emerald-600",children:[o," completed"]}),f>0&&t.jsxs("span",{className:"text-red-500",children:[f," failed"]})]})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[!d.isUploading&&t.jsx(j,{variant:"outline",size:"sm",onClick:()=>x.current?.click(),children:"Add More"}),d.isUploading&&t.jsx(j,{variant:"outline",size:"sm",onClick:d.cancelAll,children:"Cancel All"}),y&&!d.isUploading&&t.jsx(j,{variant:"ghost",size:"sm",onClick:d.clearCompleted,children:"Clear Done"})]})]}),d.isUploading&&t.jsx("div",{className:"h-1.5 overflow-hidden rounded-full bg-muted",children:t.jsx("div",{className:"h-full bg-primary transition-all duration-300",style:{width:`${d.overallProgress}%`}})}),t.jsx("div",{className:"space-y-2",children:d.files.map(e=>t.jsxs("div",{className:N("flex items-center gap-3 rounded-lg border bg-card p-3",e.status==="error"&&"border-red-200 bg-red-50 dark:border-red-900 dark:bg-red-950/20",e.status==="complete"&&"border-emerald-200 bg-emerald-50 dark:border-emerald-900 dark:bg-emerald-950/20"),children:[t.jsx("div",{className:"shrink-0",children:M(e.status)}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("p",{className:"truncate text-sm font-medium",title:e.file.name,children:e.file.name}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"text-xs text-muted-foreground",children:S(e.file.size)}),e.error&&t.jsx("span",{className:"text-xs text-red-500",children:e.error})]})]}),e.status==="uploading"&&t.jsxs("div",{className:"flex w-20 items-center gap-2",children:[t.jsx("div",{className:"h-1.5 flex-1 overflow-hidden rounded-full bg-muted",children:t.jsx("div",{className:"h-full bg-primary transition-all",style:{width:`${e.progress}%`}})}),t.jsxs("span",{className:"text-xs text-muted-foreground",children:[e.progress,"%"]})]}),t.jsxs("div",{className:"shrink-0",children:[e.status==="pending"&&!d.isUploading&&t.jsx(j,{variant:"ghost",size:"icon-sm",onClick:()=>d.cancelFile(e.id),title:"Remove",children:t.jsx($,{className:"size-4"})}),(e.status==="uploading"||e.status==="pending")&&d.isUploading&&t.jsx(j,{variant:"ghost",size:"icon-sm",onClick:()=>d.cancelFile(e.id),title:"Cancel",children:t.jsx($,{className:"size-4"})}),(e.status==="error"||e.status==="cancelled")&&!d.isUploading&&t.jsx(j,{variant:"ghost",size:"icon-sm",onClick:()=>d.retryFile(e.id),title:"Retry",children:t.jsx(me,{className:"size-4"})})]})]},e.id))})]}),t.jsx("input",{ref:x,type:"file",multiple:!0,onChange:I,className:"hidden",accept:i.length>0?i.join(","):void 0})]})}var T="Tabs",[Ee]=oe(T,[B]),F=B(),[Ne,O]=Ee(T),G=u.forwardRef((r,a)=>{const{__scopeTabs:s,value:c,onValueChange:l,defaultValue:i,orientation:n="horizontal",dir:g,activationMode:h="automatic",...v}=r,p=te(g),[m,x]=se({prop:c,onChange:l,defaultProp:i??"",caller:T});return t.jsx(Ne,{scope:s,baseId:re(),value:m,onValueChange:x,orientation:n,dir:p,activationMode:h,children:t.jsx(_.div,{dir:p,"data-orientation":n,...v,ref:a})})});G.displayName=T;var W="TabsList",K=u.forwardRef((r,a)=>{const{__scopeTabs:s,loop:c=!0,...l}=r,i=O(W,s),n=F(s);return t.jsx(ae,{asChild:!0,...n,orientation:i.orientation,dir:i.dir,loop:c,children:t.jsx(_.div,{role:"tablist","aria-orientation":i.orientation,...l,ref:a})})});K.displayName=W;var X="TabsTrigger",Q=u.forwardRef((r,a)=>{const{__scopeTabs:s,value:c,disabled:l=!1,...i}=r,n=O(X,s),g=F(s),h=Z(n.baseId,c),v=q(n.baseId,c),p=c===n.value;return t.jsx(ne,{asChild:!0,...g,focusable:!l,active:p,children:t.jsx(_.button,{type:"button",role:"tab","aria-selected":p,"aria-controls":v,"data-state":p?"active":"inactive","data-disabled":l?"":void 0,disabled:l,id:h,...i,ref:a,onMouseDown:z(r.onMouseDown,m=>{!l&&m.button===0&&m.ctrlKey===!1?n.onValueChange(c):m.preventDefault()}),onKeyDown:z(r.onKeyDown,m=>{[" ","Enter"].includes(m.key)&&n.onValueChange(c)}),onFocus:z(r.onFocus,()=>{const m=n.activationMode!=="manual";!p&&!l&&m&&n.onValueChange(c)})})})});Q.displayName=X;var Y="TabsContent",J=u.forwardRef((r,a)=>{const{__scopeTabs:s,value:c,forceMount:l,children:i,...n}=r,g=O(Y,s),h=Z(g.baseId,c),v=q(g.baseId,c),p=c===g.value,m=u.useRef(p);return u.useEffect(()=>{const x=requestAnimationFrame(()=>m.current=!1);return()=>cancelAnimationFrame(x)},[]),t.jsx(ie,{present:l||p,children:({present:x})=>t.jsx(_.div,{"data-state":p?"active":"inactive","data-orientation":g.orientation,role:"tabpanel","aria-labelledby":h,hidden:!x,id:v,tabIndex:0,...n,ref:a,style:{...r.style,animationDuration:m.current?"0s":void 0},children:x&&i})})});J.displayName=Y;function Z(r,a){return`${r}-trigger-${a}`}function q(r,a){return`${r}-content-${a}`}var ke=G,Le=K,Ae=Q,_e=J;function Pe({className:r,...a}){return t.jsx(ke,{"data-slot":"tabs",className:N("flex flex-col gap-2",r),...a})}function ze({className:r,...a}){return t.jsx(Le,{"data-slot":"tabs-list",className:N("bg-muted text-muted-foreground inline-flex h-9 w-fit items-center justify-center rounded-lg p-[3px]",r),...a})}function $e({className:r,...a}){return t.jsx(Ae,{"data-slot":"tabs-trigger",className:N("data-[state=active]:bg-background dark:data-[state=active]:text-foreground focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:outline-ring dark:data-[state=active]:border-input dark:data-[state=active]:bg-input/30 text-foreground dark:text-muted-foreground inline-flex h-[calc(100%-1px)] flex-1 items-center justify-center gap-1.5 rounded-md border border-transparent px-2 py-1 text-sm font-medium whitespace-nowrap transition-[color,box-shadow] focus-visible:ring-[3px] focus-visible:outline-1 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:shadow-sm [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",r),...a})}function Se({className:r,...a}){return t.jsx(_e,{"data-slot":"tabs-content",className:N("flex-1 outline-none",r),...a})}export{Re as C,Ue as F,De as M,me as R,Pe as T,fe as U,Ie as V,ze as a,$e as b,Me as c,Se as d};
@@ -0,0 +1 @@
1
+ import{x as k,p as m,y as v,r as e}from"./main-CXgkZMhe.js";function b(t){return k({select:n=>n.location})}function h(){const t=m(),n=b(),s=v({strict:!1}),c=e.useCallback((a,u)=>{let o=a;if(u)for(const[y,g]of Object.entries(u))o=o.replace(`:${y}`,g).replace(`$${y}`,g);t({to:o})},[t]),r=e.useCallback(a=>{t({to:"/entries/$entryId",params:{entryId:a}})},[t]),i=e.useCallback(a=>{t({to:"/entries/type/$contentTypeId",params:{contentTypeId:a}})},[t]),l=e.useCallback(a=>{t({to:"/entries/new/$contentTypeId",params:{contentTypeId:a}})},[t]),p=e.useCallback(()=>{window.history.back()},[]);return e.useMemo(()=>({navigate:c,currentRoute:n.pathname,params:s??{},canGoBack:window.history.length>1,goBack:p,navigateToEntry:r,navigateToContentType:i,navigateToNewEntry:l}),[c,n.pathname,s,p,r,i,l])}export{h as u};
@@ -0,0 +1 @@
1
+ import{d as K,r as t,a as I,b as F,j as e,u as L,e as W,C as X,f as Y,c as P,T as Q}from"./main-CXgkZMhe.js";import{c as R,I as D,a as H,C as Z,b as U}from"./CmsEmptyState-CiMQwSQV.js";import{C as N,B as q}from"./badge-qPrc4AUM.js";import{L as f}from"./label-DCsUdvFh.js";import{T as V,P as G,a as M}from"./textarea-BJ0XFZpT.js";import{P as _}from"./plus-xCFJK0RC.js";import{C as ee}from"./CmsPageHeader-ohOq0luT.js";import{C as B}from"./CmsSurface-CWup6Jh7.js";import{S as se}from"./scroll-area-B-yrE66a.js";import{u as ae}from"./tanstack-adapter-npeE3RdY.js";const te=[["path",{d:"M20 10a1 1 0 0 0 1-1V6a1 1 0 0 0-1-1h-2.5a1 1 0 0 1-.8-.4l-.9-1.2A1 1 0 0 0 15 3h-2a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z",key:"hod4my"}],["path",{d:"M20 21a1 1 0 0 0 1-1v-3a1 1 0 0 0-1-1h-2.9a1 1 0 0 1-.88-.55l-.42-.85a1 1 0 0 0-.92-.6H13a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z",key:"w4yl2u"}],["path",{d:"M3 5a2 2 0 0 0 2 2h3",key:"f2jnh7"}],["path",{d:"M3 3v13a2 2 0 0 0 2 2h3",key:"k8epm1"}]],re=K("folder-tree",te);function ie({taxonomy:r,onSave:o,onCancel:c}){const h=!!r,[n,b]=t.useState({name:r?.name??"",displayName:r?.displayName??"",description:r?.description??"",isHierarchical:r?.isHierarchical??!1,allowInlineCreation:r?.allowInlineCreation??!0,isActive:r?.isActive??!0,icon:r?.icon??"",sortOrder:r?.sortOrder??0}),[m,l]=t.useState({}),[d,v]=t.useState(!1),[T,u]=t.useState(null),[S,E]=t.useState(!1),w=I(F.taxonomies.createTaxonomy),z=I(F.taxonomies.updateTaxonomy);t.useEffect(()=>{r&&b({name:r.name,displayName:r.displayName,description:r.description??"",isHierarchical:r.isHierarchical,allowInlineCreation:r.allowInlineCreation,isActive:r.isActive,icon:r.icon??"",sortOrder:r.sortOrder??0})},[r]);const x=t.useCallback((s,p)=>{b(y=>({...y,[s]:p})),l(y=>{const{[s]:i,...a}=y;return a})},[]),C=t.useCallback(s=>s.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,""),[]),A=t.useCallback(s=>{x("displayName",s),!h&&!S&&x("name",C(s))},[x,h,S,C]),j=t.useCallback(()=>{const s={};return n.name.trim()?/^[a-z][a-z0-9-]*$/.test(n.name)||(s.name="Slug must start with a letter and contain only lowercase letters, numbers, and hyphens"):s.name="Slug is required",n.displayName.trim()||(s.displayName="Display name is required"),l(s),Object.keys(s).length===0},[n]),k=t.useCallback(async s=>{if(s.preventDefault(),!!j()){v(!0),u(null);try{h&&r?await z({id:r._id,displayName:n.displayName,description:n.description||void 0,allowInlineCreation:n.allowInlineCreation,icon:n.icon||void 0,sortOrder:n.sortOrder,isActive:n.isActive}):await w({name:n.name,displayName:n.displayName,description:n.description||void 0,isHierarchical:n.isHierarchical,allowInlineCreation:n.allowInlineCreation,icon:n.icon||void 0,sortOrder:n.sortOrder}),o()}catch(p){const y=p instanceof Error?p.message:"Failed to save taxonomy";u(y)}finally{v(!1)}}},[j,h,r,n,w,z,o]);return e.jsx(R,{open:!0,onOpenChange:s=>!s&&!d&&c(),title:h?"Edit Taxonomy":"Create Taxonomy",size:"lg",footer:e.jsxs(e.Fragment,{children:[e.jsx(N,{variant:"outline",onClick:c,disabled:d,children:"Cancel"}),e.jsx(N,{variant:"primary",onClick:k,loading:d,children:h?"Save Changes":"Create Taxonomy"})]}),children:e.jsxs("form",{onSubmit:k,className:"space-y-4",children:[T&&e.jsx("div",{className:"rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-sm text-red-800",children:T}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(f,{htmlFor:"displayName",children:["Display Name ",e.jsx("span",{className:"text-destructive",children:"*"})]}),e.jsx(D,{id:"displayName",value:n.displayName,onChange:s=>A(s.target.value),placeholder:"e.g., Categories, Tags",disabled:d,className:m.displayName?"border-destructive":""}),m.displayName&&e.jsx("p",{className:"text-xs text-destructive",children:m.displayName})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(f,{htmlFor:"name",children:["Slug ",e.jsx("span",{className:"text-destructive",children:"*"})]}),e.jsx(D,{id:"name",value:n.name,onChange:s=>{x("name",s.target.value.toLowerCase()),E(!0)},placeholder:"e.g., categories, tags",disabled:d||h,className:m.name?"border-destructive":""}),m.name&&e.jsx("p",{className:"text-xs text-destructive",children:m.name}),h&&e.jsx("p",{className:"text-xs text-muted-foreground",children:"Slug cannot be changed after creation"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(f,{htmlFor:"description",children:"Description"}),e.jsx(V,{id:"description",value:n.description,onChange:s=>x("description",s.target.value),placeholder:"Optional description",rows:2,disabled:d})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(f,{htmlFor:"icon",children:"Icon"}),e.jsx(D,{id:"icon",value:n.icon,onChange:s=>x("icon",s.target.value),placeholder:"e.g., 🏷️ or folder",disabled:d}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Emoji or icon name"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(f,{htmlFor:"sortOrder",children:"Sort Order"}),e.jsx(D,{id:"sortOrder",type:"number",value:n.sortOrder,onChange:s=>x("sortOrder",parseInt(s.target.value)||0),disabled:d})]})]}),e.jsxs("div",{className:"space-y-4 pt-2",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(H,{id:"isHierarchical",checked:n.isHierarchical,onCheckedChange:s=>x("isHierarchical",s),disabled:d||h}),e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(f,{htmlFor:"isHierarchical",className:"cursor-pointer font-medium",children:"Hierarchical"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Terms can have parent-child relationships (like categories)"}),h&&e.jsx("p",{className:"text-xs text-amber-600",children:"Hierarchy type cannot be changed after creation"})]})]}),e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(H,{id:"allowInlineCreation",checked:n.allowInlineCreation,onCheckedChange:s=>x("allowInlineCreation",s),disabled:d}),e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(f,{htmlFor:"allowInlineCreation",className:"cursor-pointer font-medium",children:"Allow inline creation"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Users can create new terms while editing content"})]})]}),e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(H,{id:"isActive",checked:n.isActive,onCheckedChange:s=>x("isActive",s),disabled:d}),e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(f,{htmlFor:"isActive",className:"cursor-pointer font-medium",children:"Active"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Inactive taxonomies are hidden from content editors"})]})]})]})]})})}function ne({taxonomyId:r,isHierarchical:o,allowInlineCreation:c}){const[h,n]=t.useState(new Set),[b,m]=t.useState(null),[l,d]=t.useState(!1),[v,T]=t.useState(),[u,S]=t.useState(null),[E,w]=t.useState(null),z=o?L(F.taxonomies.getTermsHierarchy,{taxonomyId:r}):L(F.taxonomies.listTerms,{taxonomyId:r}),x=I(F.taxonomies.deleteTerm),C=o?z:z?.page,A=C===void 0,j=t.useCallback(i=>{n(a=>{const g=new Set(a);return g.has(i)?g.delete(i):g.add(i),g})},[]),k=t.useCallback(i=>{T(i),m(null),d(!0)},[]),s=t.useCallback(i=>{m(i),d(!0)},[]),p=t.useCallback(async i=>{w(null);try{await x({id:i,cascade:!0}),S(null)}catch(a){const g=a instanceof Error?a.message:"Failed to delete term";w(g)}},[x]),y=(i,a=0)=>{const g=i.children&&i.children.length>0,O=h.has(i._id);return e.jsxs("div",{className:"border-b border-border/50 last:border-0",children:[e.jsxs("div",{className:P("group flex items-center gap-2 py-2 pr-2 transition-colors hover:bg-muted/50",a>0&&"border-l-2 border-muted"),style:{paddingLeft:`${a*24+8}px`},children:[o&&e.jsx("button",{type:"button",onClick:()=>j(i._id),disabled:!g,className:P("flex size-5 items-center justify-center rounded transition-colors",g?"text-muted-foreground hover:bg-muted hover:text-foreground":"invisible"),"aria-expanded":O,children:g&&(O?e.jsx(X,{className:"size-4"}):e.jsx(Y,{className:"size-4"}))}),e.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2",children:[i.color&&e.jsx("span",{className:"size-3 shrink-0 rounded-full",style:{backgroundColor:i.color}}),i.icon&&e.jsx("span",{className:"shrink-0 text-sm",children:i.icon}),e.jsx("span",{className:"truncate font-medium text-foreground",children:i.name}),e.jsxs("span",{className:"shrink-0 text-xs text-muted-foreground",children:["(",i.slug,")"]}),e.jsxs("span",{className:"ml-auto shrink-0 rounded bg-muted px-1.5 py-0.5 text-xs text-muted-foreground",children:[i.usageCount," ",i.usageCount===1?"use":"uses"]})]}),e.jsxs("div",{className:"flex shrink-0 items-center gap-1 opacity-0 transition-opacity group-hover:opacity-100",children:[o&&c&&e.jsx(N,{variant:"ghost",size:"sm",onClick:()=>k(i._id),title:"Add child term",className:"size-7 p-0",children:e.jsx(_,{className:"size-3.5"})}),e.jsx(N,{variant:"ghost",size:"sm",onClick:()=>s(i),title:"Edit term",className:"size-7 p-0",children:e.jsx(G,{className:"size-3.5"})}),e.jsx(N,{variant:"ghost",size:"sm",onClick:()=>S(i._id),title:"Delete term",className:"size-7 p-0 text-destructive hover:text-destructive",children:e.jsx(Q,{className:"size-3.5"})})]})]}),o&&g&&O&&e.jsx("div",{children:i.children.map($=>y($,a+1))})]},i._id)};return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h3",{className:"text-sm font-medium text-foreground",children:"Terms"}),e.jsxs(N,{variant:"secondary",size:"sm",onClick:()=>k(),children:[e.jsx(_,{className:"size-3.5"}),"Add Term"]})]}),E&&e.jsxs("div",{className:"flex items-center justify-between rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-sm text-red-800",children:[E,e.jsx("button",{type:"button",onClick:()=>w(null),className:"text-red-600 hover:text-red-800",children:"×"})]}),e.jsx("div",{className:"rounded-lg border bg-card",children:A?e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx("div",{className:"size-6 animate-spin rounded-full border-2 border-muted border-t-primary"})}):!C||C.length===0?e.jsx(Z,{icon:e.jsx(W,{className:"size-8"}),title:"No terms yet",description:"Add your first term to start organizing content.",action:c&&e.jsxs(N,{variant:"secondary",onClick:()=>k(),children:[e.jsx(_,{className:"size-4"}),"Add your first term"]})}):e.jsx("div",{className:"divide-y divide-border/50",children:C.map(i=>y(i))})}),l&&e.jsx(le,{taxonomyId:r,term:b,parentId:v,isHierarchical:o,onSave:()=>{d(!1),m(null),T(void 0)},onCancel:()=>{d(!1),m(null),T(void 0)}}),e.jsx(U,{open:!!u,onOpenChange:i=>!i&&S(null),title:"Delete Term",description:o?"Are you sure you want to delete this term? All child terms will also be deleted.":"Are you sure you want to delete this term?",confirmLabel:"Delete",variant:"danger",onConfirm:()=>u&&p(u)})]})}function le({taxonomyId:r,term:o,parentId:c,isHierarchical:h,onSave:n,onCancel:b}){const m=!!o,[l,d]=t.useState({name:o?.name??"",slug:o?.slug??"",description:o?.description??"",color:o?.color??"",icon:o?.icon??"",sortOrder:o?.sortOrder??0}),[v,T]=t.useState({}),[u,S]=t.useState(!1),[E,w]=t.useState(null),[z,x]=t.useState(!1),C=I(F.taxonomies.createTerm),A=I(F.taxonomies.updateTerm),j=t.useCallback((a,g)=>{d(O=>({...O,[a]:g})),T(O=>{const{[a]:$,...J}=O;return J})},[]),k=t.useCallback(a=>a.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,""),[]),s=t.useCallback(a=>{j("name",a),!m&&!z&&j("slug",k(a))},[j,m,z,k]),p=t.useCallback(()=>{const a={};return l.name.trim()||(a.name="Name is required"),l.slug.trim()?/^[a-z0-9-]+$/.test(l.slug)||(a.slug="Slug must contain only lowercase letters, numbers, and hyphens"):a.slug="Slug is required",T(a),Object.keys(a).length===0},[l]),y=t.useCallback(async a=>{if(a.preventDefault(),!!p()){S(!0),w(null);try{m&&o?await A({id:o._id,name:l.name,slug:l.slug,description:l.description||void 0,color:l.color||void 0,icon:l.icon||void 0,sortOrder:l.sortOrder}):await C({taxonomyId:r,name:l.name,slug:l.slug,description:l.description||void 0,parentId:c,color:l.color||void 0,icon:l.icon||void 0,sortOrder:l.sortOrder}),n()}catch(g){const O=g instanceof Error?g.message:"Failed to save term";w(O)}finally{S(!1)}}},[p,m,o,l,r,c,C,A,n]),i=m?"Edit Term":c?"Create Child Term":"Create Term";return e.jsx(R,{open:!0,onOpenChange:a=>!a&&!u&&b(),title:i,size:"md",footer:e.jsxs(e.Fragment,{children:[e.jsx(N,{variant:"outline",onClick:b,disabled:u,children:"Cancel"}),e.jsx(N,{variant:"primary",onClick:y,loading:u,children:m?"Save Changes":"Create Term"})]}),children:e.jsxs("form",{onSubmit:y,className:"space-y-4",children:[E&&e.jsx("div",{className:"rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-sm text-red-800",children:E}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(f,{htmlFor:"termName",children:["Name ",e.jsx("span",{className:"text-destructive",children:"*"})]}),e.jsx(D,{id:"termName",value:l.name,onChange:a=>s(a.target.value),placeholder:"e.g., Technology",disabled:u,className:v.name?"border-destructive":""}),v.name&&e.jsx("p",{className:"text-xs text-destructive",children:v.name})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(f,{htmlFor:"termSlug",children:["Slug ",e.jsx("span",{className:"text-destructive",children:"*"})]}),e.jsx(D,{id:"termSlug",value:l.slug,onChange:a=>{j("slug",a.target.value.toLowerCase()),x(!0)},placeholder:"e.g., technology",disabled:u,className:v.slug?"border-destructive":""}),v.slug&&e.jsx("p",{className:"text-xs text-destructive",children:v.slug})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(f,{htmlFor:"termDescription",children:"Description"}),e.jsx(V,{id:"termDescription",value:l.description,onChange:a=>j("description",a.target.value),placeholder:"Optional description",rows:2,disabled:u})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(f,{htmlFor:"termColor",children:"Color"}),e.jsx(D,{id:"termColor",type:"color",value:l.color||"#6b7280",onChange:a=>j("color",a.target.value),disabled:u,className:"h-9 p-1"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(f,{htmlFor:"termIcon",children:"Icon"}),e.jsx(D,{id:"termIcon",value:l.icon,onChange:a=>j("icon",a.target.value),placeholder:"e.g., 💻",disabled:u})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(f,{htmlFor:"termSortOrder",children:"Sort Order"}),e.jsx(D,{id:"termSortOrder",type:"number",value:l.sortOrder,onChange:a=>j("sortOrder",parseInt(a.target.value)||0),disabled:u})]})]})]})})}function oe({api:r,navigation:o}){const[c,h]=t.useState(null),[n,b]=t.useState(!1),[m,l]=t.useState(null),[d,v]=t.useState(null),[T,u]=t.useState(null),S=L(r.taxonomies.list,{isActive:void 0,includeDeleted:!1}),E=I(r.taxonomies.deleteTaxonomy),w=S?.page??[],z=S===void 0,x=t.useCallback(()=>{l(null),b(!0)},[]),C=t.useCallback(s=>{l(s),b(!0)},[]),A=t.useCallback(async s=>{u(null);try{await E({id:s}),v(null),c?._id===s&&h(null)}catch(p){const y=p instanceof Error?p.message:"Failed to delete taxonomy";u(y)}},[E,c]),j=t.useCallback(()=>{b(!1),l(null)},[]),k=s=>s.isHierarchical?e.jsx(re,{className:"size-5"}):e.jsx(M,{className:"size-5"});return e.jsxs("div",{className:"flex h-[calc(100vh-4rem)] flex-col p-6",children:[e.jsxs("div",{className:"mb-6 flex items-start justify-between",children:[e.jsx(ee,{title:"Taxonomies",description:"Manage tags, categories, and other classification systems"}),e.jsxs(N,{onClick:x,children:[e.jsx(_,{className:"size-4"}),"Create Taxonomy"]})]}),e.jsxs("div",{className:"flex min-h-0 flex-1 gap-6",children:[e.jsx(B,{elevation:"base",className:"w-80 shrink-0 overflow-hidden",children:z?e.jsxs("div",{className:"flex flex-col items-center justify-center py-12",children:[e.jsx("div",{className:"size-6 animate-spin rounded-full border-2 border-muted border-t-primary"}),e.jsx("p",{className:"mt-3 text-sm text-muted-foreground",children:"Loading taxonomies..."})]}):w.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center p-6 text-center",children:[e.jsx(M,{className:"mb-3 size-8 text-muted-foreground"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"No taxonomies created yet."}),e.jsx(N,{variant:"secondary",className:"mt-4",onClick:x,children:"Create your first taxonomy"})]}):e.jsx(se,{className:"h-full",children:e.jsx("div",{className:"divide-y",children:w.map(s=>e.jsxs("div",{className:P("group flex cursor-pointer items-center gap-3 p-3 transition-colors hover:bg-muted/50",c?._id===s._id&&"bg-primary/5",!s.isActive&&"opacity-60"),onClick:()=>h(s),children:[e.jsx("div",{className:"flex size-9 shrink-0 items-center justify-center rounded-md bg-muted text-muted-foreground",children:k(s)}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"truncate text-sm font-medium text-foreground",children:s.displayName}),e.jsx("p",{className:"truncate text-xs text-muted-foreground",children:s.name})]}),e.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[e.jsx(q,{variant:"secondary",className:"text-xs font-normal",children:s.isHierarchical?"Hierarchical":"Flat"}),!s.isActive&&e.jsx(q,{variant:"outline",className:"text-xs font-normal",children:"Inactive"})]}),e.jsxs("div",{className:"flex shrink-0 items-center gap-1 opacity-0 transition-opacity group-hover:opacity-100",children:[e.jsx(N,{variant:"ghost",size:"icon-sm",onClick:p=>{p.stopPropagation(),C(s)},title:"Edit taxonomy",children:e.jsx(G,{className:"size-4"})}),e.jsx(N,{variant:"ghost",size:"icon-sm",onClick:p=>{p.stopPropagation(),v(s._id)},title:"Delete taxonomy",className:"text-destructive hover:bg-destructive/10 hover:text-destructive",children:e.jsx(Q,{className:"size-4"})})]})]},s._id))})})}),e.jsx(B,{elevation:"base",className:"min-w-0 flex-1 overflow-hidden",children:c?e.jsxs("div",{className:"flex h-full flex-col",children:[e.jsxs("div",{className:"flex items-start justify-between border-b p-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"flex size-10 items-center justify-center rounded-md bg-muted text-muted-foreground",children:k(c)}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-semibold text-foreground",children:c.displayName}),c.description&&e.jsx("p",{className:"text-sm text-muted-foreground",children:c.description})]})]}),e.jsx(N,{variant:"secondary",onClick:()=>C(c),children:"Edit Taxonomy"})]}),e.jsx("div",{className:"flex-1 overflow-auto p-4",children:e.jsx(ne,{taxonomyId:c._id,isHierarchical:c.isHierarchical,allowInlineCreation:c.allowInlineCreation})})]}):e.jsx(Z,{icon:e.jsx(M,{className:"size-6"}),title:"Select a taxonomy",description:"Select a taxonomy to view and manage its terms",className:"h-full"})})]}),n&&e.jsx(ie,{taxonomy:m,onSave:j,onCancel:()=>{b(!1),l(null)}}),e.jsx(U,{open:d!==null,onOpenChange:s=>{s||(v(null),u(null))},title:"Delete Taxonomy",description:"Are you sure you want to delete this taxonomy? All associated terms will also be deleted.",confirmLabel:"Delete",onConfirm:()=>d&&A(d),variant:"danger",error:T})]})}function fe(){const r=ae();return e.jsx(oe,{api:F,navigation:r})}export{fe as component};
@@ -1 +1 @@
1
- import{d as a,j as r,c as i}from"./main-CKj5yfEi.js";const o=[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]],d=a("pencil",o);const n=[["path",{d:"M12.586 2.586A2 2 0 0 0 11.172 2H4a2 2 0 0 0-2 2v7.172a2 2 0 0 0 .586 1.414l8.704 8.704a2.426 2.426 0 0 0 3.42 0l6.58-6.58a2.426 2.426 0 0 0 0-3.42z",key:"vktsd0"}],["circle",{cx:"7.5",cy:"7.5",r:".5",fill:"currentColor",key:"kqv944"}]],c=a("tag",n);function l({className:e,...t}){return r.jsx("textarea",{"data-slot":"textarea",className:i("border-input placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:bg-input/30 flex field-sizing-content min-h-16 w-full rounded-md border bg-transparent px-3 py-2 text-base shadow-xs transition-[color,box-shadow] outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",e),...t})}export{d as P,l as T,c as a};
1
+ import{d as a,j as r,c as i}from"./main-CXgkZMhe.js";const o=[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]],d=a("pencil",o);const n=[["path",{d:"M12.586 2.586A2 2 0 0 0 11.172 2H4a2 2 0 0 0-2 2v7.172a2 2 0 0 0 .586 1.414l8.704 8.704a2.426 2.426 0 0 0 3.42 0l6.58-6.58a2.426 2.426 0 0 0 0-3.42z",key:"vktsd0"}],["circle",{cx:"7.5",cy:"7.5",r:".5",fill:"currentColor",key:"kqv944"}]],c=a("tag",n);function l({className:e,...t}){return r.jsx("textarea",{"data-slot":"textarea",className:i("border-input placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:bg-input/30 flex field-sizing-content min-h-16 w-full rounded-md border bg-transparent px-3 py-2 text-base shadow-xs transition-[color,box-shadow] outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",e),...t})}export{d as P,l as T,c as a};
@@ -0,0 +1 @@
1
+ import{r as a,u as m,a as E,j as e,T as D,c as Y,b as Z}from"./main-CXgkZMhe.js";import{C as ee}from"./CmsPageHeader-ohOq0luT.js";import{C as se}from"./CmsToolbar-cEBlCHa3.js";import{I as te,C as ae,a as I,b as ne}from"./CmsEmptyState-CiMQwSQV.js";import{C as A}from"./CmsSurface-CWup6Jh7.js";import{C as c,X as R,B as re}from"./badge-qPrc4AUM.js";import{S as le,a as oe,b as ie,c as ce,d as _}from"./select-Co3TZFJb.js";import{A as Q,a as L}from"./alert-Bf2l8kxw.js";import{S as de}from"./search-CbCbboeU.js";import{T as B}from"./triangle-alert-BZRcqsUg.js";import{R as M}from"./rotate-ccw-DIqK63wY.js";import{u as me}from"./tanstack-adapter-npeE3RdY.js";function xe({api:l,navigation:ue}){const[g,F]=a.useState(""),[j,O]=a.useState(""),[r,i]=a.useState(new Set),[y,x]=a.useState(null),[N,C]=a.useState(!1),[P,u]=a.useState(!1),[b,v]=a.useState(!1),[S,h]=a.useState(null),T=m(l.trash.list,{contentTypeId:g||void 0,search:j||void 0,paginationOpts:{numItems:50,cursor:null}}),U=m(l.trash.getConfig,{}),V=m(l.trash.getStats,{}),H=m(l.contentTypes.list,{})?.page??[],w=E(l.bulkOperations.bulkRestore),k=E(l.trash.empty),o=T?.page??[],X=T===void 0,p=U,f=V,$=a.useCallback((s,t)=>{i(n=>{const d=new Set(n);return t?d.add(s):d.delete(s),d})},[]),q=a.useCallback(()=>{r.size===o.length?i(new Set):i(new Set(o.map(s=>s._id)))},[r.size,o]),z=a.useCallback(async s=>{C(!0),x(null);try{await w({ids:s}),i(t=>{const n=new Set(t);return s.forEach(d=>n.delete(d)),n})}catch(t){const n=t instanceof Error?t.message:"Failed to restore";x(n)}finally{C(!1)}},[w]),G=a.useCallback(async()=>{v(!0),h(null);try{await k({}),u(!1),i(new Set)}catch(s){const t=s instanceof Error?s.message:"Failed to empty trash";h(t)}finally{v(!1)}},[k]),J=s=>new Date(s).toLocaleString(void 0,{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}),K=s=>{if(!p?.retentionDays)return null;const t=s+p.retentionDays*24*60*60*1e3,n=Math.ceil((t-Date.now())/(1440*60*1e3));return Math.max(0,n)},W=s=>{if(s.title)return s.title;if(s.name)return s.name;if(s.data){const t=s.data.title||s.data.name;if(t&&typeof t=="string")return t}return s.slug||s._id};return e.jsxs("div",{className:"space-y-6 p-6",children:[e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsx(ee,{title:"Trash",description:`Deleted items are kept for ${p?.retentionDays??30} days before permanent deletion`}),o.length>0&&e.jsxs(c,{variant:"danger",onClick:()=>u(!0),children:[e.jsx(D,{className:"size-4"}),"Empty Trash"]})]}),f&&e.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[e.jsxs(A,{elevation:"base",className:"p-4",children:[e.jsx("p",{className:"text-2xl font-semibold text-foreground",children:f.totalCount??0}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Items in Trash"})]}),e.jsxs(A,{elevation:"base",className:"p-4",children:[e.jsx("p",{className:"text-2xl font-semibold text-foreground",children:f.expiredCount??0}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Expired"})]})]}),e.jsx(se,{left:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("div",{className:"relative",children:[e.jsx(de,{className:"absolute left-3 top-1/2 size-4 -translate-y-1/2 text-muted-foreground"}),e.jsx(te,{type:"text",placeholder:"Search deleted items...",value:j,onChange:s=>O(s.target.value),className:"w-64 pl-9"})]}),e.jsxs(le,{value:g||"all",onValueChange:s=>F(s==="all"?"":s),children:[e.jsx(oe,{className:"w-48",children:e.jsx(ie,{placeholder:"All Content Types"})}),e.jsxs(ce,{children:[e.jsx(_,{value:"all",children:"All Content Types"}),H.map(s=>e.jsx(_,{value:s._id,children:s.displayName},s._id))]})]})]})}),y&&e.jsxs(Q,{variant:"destructive",children:[e.jsx(B,{className:"size-4"}),e.jsxs(L,{className:"flex items-center justify-between",children:[y,e.jsx(c,{variant:"ghost",size:"icon-sm",onClick:()=>x(null),children:e.jsx(R,{className:"size-4"})})]})]}),S&&e.jsxs(Q,{variant:"destructive",children:[e.jsx(B,{className:"size-4"}),e.jsxs(L,{className:"flex items-center justify-between",children:[S,e.jsx(c,{variant:"ghost",size:"icon-sm",onClick:()=>h(null),children:e.jsx(R,{className:"size-4"})})]})]}),r.size>0&&e.jsxs("div",{className:"flex items-center gap-3 rounded-lg border border-primary/20 bg-primary/5 p-3",children:[e.jsxs("span",{className:"text-sm font-medium",children:[r.size," ",r.size===1?"item":"items"," selected"]}),e.jsxs(c,{variant:"primary",size:"sm",onClick:()=>z(Array.from(r)),loading:N,children:[e.jsx(M,{className:"size-4"}),"Restore Selected"]}),e.jsx(c,{variant:"secondary",size:"sm",onClick:()=>i(new Set),children:"Clear Selection"})]}),X?e.jsxs("div",{className:"flex flex-col items-center justify-center py-12",children:[e.jsx("div",{className:"size-8 animate-spin rounded-full border-2 border-muted border-t-primary"}),e.jsx("p",{className:"mt-4 text-sm text-muted-foreground",children:"Loading trash..."})]}):o.length===0?e.jsx(ae,{icon:e.jsx(D,{className:"size-6"}),title:"Trash is empty",description:"Deleted items will appear here"}):e.jsx("div",{className:"rounded-lg border bg-card",children:e.jsxs("table",{className:"w-full",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b",children:[e.jsx("th",{className:"w-10 p-3 text-left",children:e.jsx(I,{checked:r.size===o.length&&o.length>0,onCheckedChange:q})}),e.jsx("th",{className:"p-3 text-left text-sm font-medium text-muted-foreground",children:"Name"}),e.jsx("th",{className:"p-3 text-left text-sm font-medium text-muted-foreground",children:"Type"}),e.jsx("th",{className:"p-3 text-left text-sm font-medium text-muted-foreground",children:"Deleted"}),e.jsx("th",{className:"p-3 text-left text-sm font-medium text-muted-foreground",children:"Expires In"}),e.jsx("th",{className:"p-3 text-left text-sm font-medium text-muted-foreground",children:"Actions"})]})}),e.jsx("tbody",{children:o.map(s=>{const t=K(s.deletedAt);return e.jsxs("tr",{className:Y("border-b last:border-0 transition-colors hover:bg-muted/50",r.has(s._id)&&"bg-primary/5"),children:[e.jsx("td",{className:"p-3",children:e.jsx(I,{checked:r.has(s._id),onCheckedChange:n=>$(s._id,n)})}),e.jsxs("td",{className:"p-3",children:[e.jsx("span",{className:"font-medium text-foreground",children:W(s)}),s.slug&&e.jsx("span",{className:"block text-xs text-muted-foreground",children:s.slug})]}),e.jsx("td",{className:"p-3 text-sm text-muted-foreground",children:s.contentTypeName||"Unknown"}),e.jsxs("td",{className:"p-3",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:J(s.deletedAt)}),s.deletedBy&&e.jsxs("span",{className:"block text-xs text-muted-foreground",children:["by ",s.deletedBy]})]}),e.jsx("td",{className:"p-3",children:t!==null&&e.jsxs(re,{variant:t<=3?"destructive":"secondary",className:"font-normal",children:[t," ",t===1?"day":"days"]})}),e.jsx("td",{className:"p-3",children:e.jsxs(c,{variant:"outline",size:"sm",onClick:()=>z([s._id]),loading:N,children:[e.jsx(M,{className:"size-4"}),"Restore"]})})]},s._id)})})]})}),e.jsx(ne,{open:P,onOpenChange:u,title:"Empty Trash",description:"This will permanently delete all items in the trash. This action cannot be undone.",confirmLabel:b?"Deleting...":"Empty Trash",onConfirm:G,variant:"danger",loading:b})]})}function ke(){const l=me();return e.jsx(xe,{api:Z,navigation:l})}export{ke as component};
@@ -1 +1 @@
1
- import{d as e}from"./main-CKj5yfEi.js";const a=[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]],o=e("triangle-alert",a);export{o as T};
1
+ import{d as e}from"./main-CXgkZMhe.js";const a=[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]],o=e("triangle-alert",a);export{o as T};
@@ -0,0 +1 @@
1
+ import{ae as u,r as c}from"./main-CXgkZMhe.js";function a(r,e){const{setOverride:s,clearOverride:t}=u();c.useEffect(()=>(e&&s(r,e),()=>{t(r)}),[r,e,s,t])}export{a as u};
@@ -1 +1 @@
1
- import{J as c,r as o,K as i,M as u,N as d}from"./main-CKj5yfEi.js";function C(){const{role:n}=c();return o.useMemo(()=>{const r=!!n,t=(e,s,a)=>n?d(n,{resource:e,action:s,scope:a}):!1;return{role:n,hasRole:r,check:t,canAccess:e=>n?u(n,e):!1,canCreate:e=>t(e,"create"),canRead:(e,s)=>t(e,"read",s),canUpdate:(e,s)=>t(e,"update",s),canDelete:(e,s)=>t(e,"delete",s),canPublish:e=>t("contentEntries","publish",e),canUnpublish:e=>t("contentEntries","unpublish",e),canManageSettings:()=>t("settings","manage"),canManageContentTypes:()=>t("contentTypes","create")||t("contentTypes","update")||t("contentTypes","delete"),getPermissions:e=>n?i(n,e):[],isAdmin:n==="admin",isEditor:n==="admin"||n==="editor",isAuthor:n==="admin"||n==="editor"||n==="author"}},[n])}export{C as u};
1
+ import{M as c,r as o,N as i,O as u,Q as d}from"./main-CXgkZMhe.js";function C(){const{role:n}=c();return o.useMemo(()=>{const r=!!n,t=(e,s,a)=>n?d(n,{resource:e,action:s,scope:a}):!1;return{role:n,hasRole:r,check:t,canAccess:e=>n?u(n,e):!1,canCreate:e=>t(e,"create"),canRead:(e,s)=>t(e,"read",s),canUpdate:(e,s)=>t(e,"update",s),canDelete:(e,s)=>t(e,"delete",s),canPublish:e=>t("contentEntries","publish",e),canUnpublish:e=>t("contentEntries","unpublish",e),canManageSettings:()=>t("settings","manage"),canManageContentTypes:()=>t("contentTypes","create")||t("contentTypes","update")||t("contentTypes","delete"),getPermissions:e=>n?i(n,e):[],isAdmin:n==="admin",isEditor:n==="admin"||n==="editor",isAuthor:n==="admin"||n==="editor"||n==="author"}},[n])}export{C as u};
@@ -1357,6 +1357,11 @@ if (typeof globalThis !== "undefined") {
1357
1357
  window.createFileRoute = createFileRoute;
1358
1358
  window.createLazyFileRoute = createLazyFileRoute;
1359
1359
  }
1360
+ function useLocation(opts) {
1361
+ return useRouterState({
1362
+ select: (state) => state.location
1363
+ });
1364
+ }
1360
1365
  function Asset({
1361
1366
  tag,
1362
1367
  attrs,
@@ -1705,6 +1710,8 @@ export {
1705
1710
  createFileRoute as b,
1706
1711
  createRouter as c,
1707
1712
  useNavigate as d,
1713
+ useLocation as e,
1714
+ useParams as f,
1708
1715
  lazyRouteComponent as l,
1709
1716
  renderRouterToStream as r,
1710
1717
  useRouterState as u