headroom-cms 0.1.1

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 (237) hide show
  1. package/README.md +282 -0
  2. package/admin/assets/AdminsPage-CnrQqwKA.js +1 -0
  3. package/admin/assets/AllContentPage-ByN1h3PP.js +1 -0
  4. package/admin/assets/ApiKeysPage-FgNHZPBS.js +1 -0
  5. package/admin/assets/AuditPage-DAPpo-sj.js +1 -0
  6. package/admin/assets/BlockEditor-CZTwex-o.js +179 -0
  7. package/admin/assets/BlockEditor-Cp_wZ2xN.css +1 -0
  8. package/admin/assets/BlockTypeEditPage-Buuwbx1P.js +1 -0
  9. package/admin/assets/BlockTypesPage-Dj0qmsqX.js +1 -0
  10. package/admin/assets/BulkActionBar-BMcUBJSH.js +1 -0
  11. package/admin/assets/CollectionEditPage-CLgQu2HS.js +1 -0
  12. package/admin/assets/CollectionsPage-BnCaxALz.js +1 -0
  13. package/admin/assets/ContentCreatePage-CJI326o-.js +1 -0
  14. package/admin/assets/ContentEditPage-A4i8P2Jd.js +3 -0
  15. package/admin/assets/ContentListPage-Bc4mBIkB.js +1 -0
  16. package/admin/assets/CustomBlockPreview-CCssn6vF.js +479 -0
  17. package/admin/assets/FieldBuilder-YJGSk0nY.js +3 -0
  18. package/admin/assets/LoginPage-Jrne8-Wr.js +1 -0
  19. package/admin/assets/MediaPage-DfPQBmNf.css +1 -0
  20. package/admin/assets/MediaPage-_qNXqsZg.js +1 -0
  21. package/admin/assets/SiteSettingsPage-CoZnavij.js +1 -0
  22. package/admin/assets/SitesPage-ETqFT3nO.js +1 -0
  23. package/admin/assets/TagsPage-BGpp0XZM.js +1 -0
  24. package/admin/assets/UsersPage-CKRJpAb6.js +1 -0
  25. package/admin/assets/WebhookEditPage-BOcLe5OJ.js +1 -0
  26. package/admin/assets/WebhooksPage-Czco583Y.js +1 -0
  27. package/admin/assets/badge-0Z1nL6DI.js +1 -0
  28. package/admin/assets/card-D1-S-QZ6.js +1 -0
  29. package/admin/assets/check-BGA0ADyt.js +1 -0
  30. package/admin/assets/checkbox-BPqrj_XS.js +1 -0
  31. package/admin/assets/command-ChD319uJ.js +1 -0
  32. package/admin/assets/contentStatus-DfWHjFVB.js +1 -0
  33. package/admin/assets/copy-BqH9rXYM.js +1 -0
  34. package/admin/assets/core.esm-Csvubn5Q.js +5 -0
  35. package/admin/assets/format-CZ9bpk32.js +1 -0
  36. package/admin/assets/index-DOqKbrpW.css +1 -0
  37. package/admin/assets/index-Ds50UTAc.js +18 -0
  38. package/admin/assets/lib-BrI1UB_t.js +38 -0
  39. package/admin/assets/media-url-DIg_vSyf.js +1 -0
  40. package/admin/assets/module-RjUF93sV.js +716 -0
  41. package/admin/assets/native-48B9X9Wg.js +1 -0
  42. package/admin/assets/plus-BgHSYWJN.js +1 -0
  43. package/admin/assets/radix-DQ3amgxj.js +51 -0
  44. package/admin/assets/react-vendor-DNVhVxD7.js +4 -0
  45. package/admin/assets/search-DIzcfCVh.js +1 -0
  46. package/admin/assets/select-CJXZv4wv.js +1 -0
  47. package/admin/assets/sortable.esm-Zh-9QRSf.js +1 -0
  48. package/admin/assets/table-B3EHrN_H.js +1 -0
  49. package/admin/assets/tanstack-BO6c-AOu.js +1 -0
  50. package/admin/assets/trash-2-Gny2Upn-.js +1 -0
  51. package/admin/assets/useAdminResolver-BsQc_N4z.js +1 -0
  52. package/admin/assets/useContent-CSobIico.js +1 -0
  53. package/admin/assets/useDebouncedValue-Bf8UizjU.js +1 -0
  54. package/admin/assets/useMedia-CQnmMz4N.js +1 -0
  55. package/admin/assets/useTags-CYqbj5cK.js +1 -0
  56. package/admin/assets/useWebhooks-DXgtQ3aU.js +1 -0
  57. package/admin/index.html +21 -0
  58. package/admin/vite.svg +1 -0
  59. package/dist/admin-site.d.ts +30 -0
  60. package/dist/admin-site.d.ts.map +1 -0
  61. package/dist/admin-site.js +80 -0
  62. package/dist/admin-site.js.map +1 -0
  63. package/dist/api.d.ts +26 -0
  64. package/dist/api.d.ts.map +1 -0
  65. package/dist/api.js +91 -0
  66. package/dist/api.js.map +1 -0
  67. package/dist/auth.d.ts +27 -0
  68. package/dist/auth.d.ts.map +1 -0
  69. package/dist/auth.js +86 -0
  70. package/dist/auth.js.map +1 -0
  71. package/dist/cdn.d.ts +27 -0
  72. package/dist/cdn.d.ts.map +1 -0
  73. package/dist/cdn.js +382 -0
  74. package/dist/cdn.js.map +1 -0
  75. package/dist/image.d.ts +21 -0
  76. package/dist/image.d.ts.map +1 -0
  77. package/dist/image.js +48 -0
  78. package/dist/image.js.map +1 -0
  79. package/dist/index.d.ts +85 -0
  80. package/dist/index.d.ts.map +1 -0
  81. package/dist/index.js +124 -0
  82. package/dist/index.js.map +1 -0
  83. package/dist/storage.d.ts +21 -0
  84. package/dist/storage.d.ts.map +1 -0
  85. package/dist/storage.js +125 -0
  86. package/dist/storage.js.map +1 -0
  87. package/dist/webhooks.d.ts +23 -0
  88. package/dist/webhooks.d.ts.map +1 -0
  89. package/dist/webhooks.js +91 -0
  90. package/dist/webhooks.js.map +1 -0
  91. package/lambda/api/bootstrap +0 -0
  92. package/lambda/api/resource.enc +0 -0
  93. package/lambda/functions/custom-message/index.mjs +112 -0
  94. package/lambda/functions/custom-message/resource.enc +1 -0
  95. package/lambda/image-lambda/index.mjs +188 -0
  96. package/lambda/image-lambda/node_modules/.package-lock.json +160 -0
  97. package/lambda/image-lambda/node_modules/@img/sharp-libvips-linux-arm64/README.md +46 -0
  98. package/lambda/image-lambda/node_modules/@img/sharp-libvips-linux-arm64/lib/glib-2.0/include/glibconfig.h +220 -0
  99. package/lambda/image-lambda/node_modules/@img/sharp-libvips-linux-arm64/lib/index.js +1 -0
  100. package/lambda/image-lambda/node_modules/@img/sharp-libvips-linux-arm64/lib/libvips-cpp.so.42 +0 -0
  101. package/lambda/image-lambda/node_modules/@img/sharp-libvips-linux-arm64/package.json +42 -0
  102. package/lambda/image-lambda/node_modules/@img/sharp-libvips-linux-arm64/versions.json +30 -0
  103. package/lambda/image-lambda/node_modules/@img/sharp-linux-arm64/LICENSE +191 -0
  104. package/lambda/image-lambda/node_modules/@img/sharp-linux-arm64/README.md +18 -0
  105. package/lambda/image-lambda/node_modules/@img/sharp-linux-arm64/lib/sharp-linux-arm64.node +0 -0
  106. package/lambda/image-lambda/node_modules/@img/sharp-linux-arm64/package.json +46 -0
  107. package/lambda/image-lambda/node_modules/color/LICENSE +21 -0
  108. package/lambda/image-lambda/node_modules/color/README.md +123 -0
  109. package/lambda/image-lambda/node_modules/color/index.js +496 -0
  110. package/lambda/image-lambda/node_modules/color/package.json +47 -0
  111. package/lambda/image-lambda/node_modules/color-convert/CHANGELOG.md +54 -0
  112. package/lambda/image-lambda/node_modules/color-convert/LICENSE +21 -0
  113. package/lambda/image-lambda/node_modules/color-convert/README.md +68 -0
  114. package/lambda/image-lambda/node_modules/color-convert/conversions.js +839 -0
  115. package/lambda/image-lambda/node_modules/color-convert/index.js +81 -0
  116. package/lambda/image-lambda/node_modules/color-convert/package.json +48 -0
  117. package/lambda/image-lambda/node_modules/color-convert/route.js +97 -0
  118. package/lambda/image-lambda/node_modules/color-name/LICENSE +8 -0
  119. package/lambda/image-lambda/node_modules/color-name/README.md +11 -0
  120. package/lambda/image-lambda/node_modules/color-name/index.js +152 -0
  121. package/lambda/image-lambda/node_modules/color-name/package.json +28 -0
  122. package/lambda/image-lambda/node_modules/color-string/LICENSE +21 -0
  123. package/lambda/image-lambda/node_modules/color-string/README.md +62 -0
  124. package/lambda/image-lambda/node_modules/color-string/index.js +242 -0
  125. package/lambda/image-lambda/node_modules/color-string/package.json +39 -0
  126. package/lambda/image-lambda/node_modules/detect-libc/LICENSE +201 -0
  127. package/lambda/image-lambda/node_modules/detect-libc/README.md +163 -0
  128. package/lambda/image-lambda/node_modules/detect-libc/index.d.ts +14 -0
  129. package/lambda/image-lambda/node_modules/detect-libc/lib/detect-libc.js +313 -0
  130. package/lambda/image-lambda/node_modules/detect-libc/lib/elf.js +39 -0
  131. package/lambda/image-lambda/node_modules/detect-libc/lib/filesystem.js +51 -0
  132. package/lambda/image-lambda/node_modules/detect-libc/lib/process.js +24 -0
  133. package/lambda/image-lambda/node_modules/detect-libc/package.json +44 -0
  134. package/lambda/image-lambda/node_modules/is-arrayish/LICENSE +21 -0
  135. package/lambda/image-lambda/node_modules/is-arrayish/README.md +16 -0
  136. package/lambda/image-lambda/node_modules/is-arrayish/index.js +9 -0
  137. package/lambda/image-lambda/node_modules/is-arrayish/package.json +45 -0
  138. package/lambda/image-lambda/node_modules/semver/LICENSE +15 -0
  139. package/lambda/image-lambda/node_modules/semver/README.md +665 -0
  140. package/lambda/image-lambda/node_modules/semver/bin/semver.js +191 -0
  141. package/lambda/image-lambda/node_modules/semver/classes/comparator.js +143 -0
  142. package/lambda/image-lambda/node_modules/semver/classes/index.js +7 -0
  143. package/lambda/image-lambda/node_modules/semver/classes/range.js +557 -0
  144. package/lambda/image-lambda/node_modules/semver/classes/semver.js +333 -0
  145. package/lambda/image-lambda/node_modules/semver/functions/clean.js +8 -0
  146. package/lambda/image-lambda/node_modules/semver/functions/cmp.js +54 -0
  147. package/lambda/image-lambda/node_modules/semver/functions/coerce.js +62 -0
  148. package/lambda/image-lambda/node_modules/semver/functions/compare-build.js +9 -0
  149. package/lambda/image-lambda/node_modules/semver/functions/compare-loose.js +5 -0
  150. package/lambda/image-lambda/node_modules/semver/functions/compare.js +7 -0
  151. package/lambda/image-lambda/node_modules/semver/functions/diff.js +60 -0
  152. package/lambda/image-lambda/node_modules/semver/functions/eq.js +5 -0
  153. package/lambda/image-lambda/node_modules/semver/functions/gt.js +5 -0
  154. package/lambda/image-lambda/node_modules/semver/functions/gte.js +5 -0
  155. package/lambda/image-lambda/node_modules/semver/functions/inc.js +21 -0
  156. package/lambda/image-lambda/node_modules/semver/functions/lt.js +5 -0
  157. package/lambda/image-lambda/node_modules/semver/functions/lte.js +5 -0
  158. package/lambda/image-lambda/node_modules/semver/functions/major.js +5 -0
  159. package/lambda/image-lambda/node_modules/semver/functions/minor.js +5 -0
  160. package/lambda/image-lambda/node_modules/semver/functions/neq.js +5 -0
  161. package/lambda/image-lambda/node_modules/semver/functions/parse.js +18 -0
  162. package/lambda/image-lambda/node_modules/semver/functions/patch.js +5 -0
  163. package/lambda/image-lambda/node_modules/semver/functions/prerelease.js +8 -0
  164. package/lambda/image-lambda/node_modules/semver/functions/rcompare.js +5 -0
  165. package/lambda/image-lambda/node_modules/semver/functions/rsort.js +5 -0
  166. package/lambda/image-lambda/node_modules/semver/functions/satisfies.js +12 -0
  167. package/lambda/image-lambda/node_modules/semver/functions/sort.js +5 -0
  168. package/lambda/image-lambda/node_modules/semver/functions/valid.js +8 -0
  169. package/lambda/image-lambda/node_modules/semver/index.js +91 -0
  170. package/lambda/image-lambda/node_modules/semver/internal/constants.js +37 -0
  171. package/lambda/image-lambda/node_modules/semver/internal/debug.js +11 -0
  172. package/lambda/image-lambda/node_modules/semver/internal/identifiers.js +29 -0
  173. package/lambda/image-lambda/node_modules/semver/internal/lrucache.js +42 -0
  174. package/lambda/image-lambda/node_modules/semver/internal/parse-options.js +17 -0
  175. package/lambda/image-lambda/node_modules/semver/internal/re.js +223 -0
  176. package/lambda/image-lambda/node_modules/semver/package.json +78 -0
  177. package/lambda/image-lambda/node_modules/semver/preload.js +4 -0
  178. package/lambda/image-lambda/node_modules/semver/range.bnf +16 -0
  179. package/lambda/image-lambda/node_modules/semver/ranges/gtr.js +6 -0
  180. package/lambda/image-lambda/node_modules/semver/ranges/intersects.js +9 -0
  181. package/lambda/image-lambda/node_modules/semver/ranges/ltr.js +6 -0
  182. package/lambda/image-lambda/node_modules/semver/ranges/max-satisfying.js +27 -0
  183. package/lambda/image-lambda/node_modules/semver/ranges/min-satisfying.js +26 -0
  184. package/lambda/image-lambda/node_modules/semver/ranges/min-version.js +63 -0
  185. package/lambda/image-lambda/node_modules/semver/ranges/outside.js +82 -0
  186. package/lambda/image-lambda/node_modules/semver/ranges/simplify.js +49 -0
  187. package/lambda/image-lambda/node_modules/semver/ranges/subset.js +249 -0
  188. package/lambda/image-lambda/node_modules/semver/ranges/to-comparators.js +10 -0
  189. package/lambda/image-lambda/node_modules/semver/ranges/valid.js +13 -0
  190. package/lambda/image-lambda/node_modules/sharp/LICENSE +191 -0
  191. package/lambda/image-lambda/node_modules/sharp/README.md +118 -0
  192. package/lambda/image-lambda/node_modules/sharp/install/check.js +41 -0
  193. package/lambda/image-lambda/node_modules/sharp/lib/channel.js +174 -0
  194. package/lambda/image-lambda/node_modules/sharp/lib/colour.js +180 -0
  195. package/lambda/image-lambda/node_modules/sharp/lib/composite.js +210 -0
  196. package/lambda/image-lambda/node_modules/sharp/lib/constructor.js +452 -0
  197. package/lambda/image-lambda/node_modules/sharp/lib/index.d.ts +1754 -0
  198. package/lambda/image-lambda/node_modules/sharp/lib/index.js +16 -0
  199. package/lambda/image-lambda/node_modules/sharp/lib/input.js +658 -0
  200. package/lambda/image-lambda/node_modules/sharp/lib/is.js +169 -0
  201. package/lambda/image-lambda/node_modules/sharp/lib/libvips.js +203 -0
  202. package/lambda/image-lambda/node_modules/sharp/lib/operation.js +958 -0
  203. package/lambda/image-lambda/node_modules/sharp/lib/output.js +1587 -0
  204. package/lambda/image-lambda/node_modules/sharp/lib/resize.js +587 -0
  205. package/lambda/image-lambda/node_modules/sharp/lib/sharp.js +114 -0
  206. package/lambda/image-lambda/node_modules/sharp/lib/utility.js +296 -0
  207. package/lambda/image-lambda/node_modules/sharp/package.json +222 -0
  208. package/lambda/image-lambda/node_modules/sharp/src/binding.gyp +280 -0
  209. package/lambda/image-lambda/node_modules/sharp/src/common.cc +1091 -0
  210. package/lambda/image-lambda/node_modules/sharp/src/common.h +393 -0
  211. package/lambda/image-lambda/node_modules/sharp/src/metadata.cc +320 -0
  212. package/lambda/image-lambda/node_modules/sharp/src/metadata.h +85 -0
  213. package/lambda/image-lambda/node_modules/sharp/src/operations.cc +475 -0
  214. package/lambda/image-lambda/node_modules/sharp/src/operations.h +125 -0
  215. package/lambda/image-lambda/node_modules/sharp/src/pipeline.cc +1758 -0
  216. package/lambda/image-lambda/node_modules/sharp/src/pipeline.h +393 -0
  217. package/lambda/image-lambda/node_modules/sharp/src/sharp.cc +40 -0
  218. package/lambda/image-lambda/node_modules/sharp/src/stats.cc +183 -0
  219. package/lambda/image-lambda/node_modules/sharp/src/stats.h +59 -0
  220. package/lambda/image-lambda/node_modules/sharp/src/utilities.cc +269 -0
  221. package/lambda/image-lambda/node_modules/sharp/src/utilities.h +19 -0
  222. package/lambda/image-lambda/node_modules/simple-swizzle/LICENSE +21 -0
  223. package/lambda/image-lambda/node_modules/simple-swizzle/README.md +43 -0
  224. package/lambda/image-lambda/node_modules/simple-swizzle/index.js +29 -0
  225. package/lambda/image-lambda/node_modules/simple-swizzle/package.json +36 -0
  226. package/lambda/webhook-worker/bootstrap +0 -0
  227. package/lambda/webhook-worker/resource.enc +0 -0
  228. package/package.json +50 -0
  229. package/src/admin-site.ts +108 -0
  230. package/src/api.ts +113 -0
  231. package/src/auth.ts +110 -0
  232. package/src/cdn.ts +449 -0
  233. package/src/image.ts +62 -0
  234. package/src/index.ts +216 -0
  235. package/src/sst-env.d.ts +143 -0
  236. package/src/storage.ts +138 -0
  237. package/src/webhooks.ts +114 -0
@@ -0,0 +1,3 @@
1
+ import{j as e}from"./tanstack-BO6c-AOu.js";import{r as v}from"./react-vendor-DNVhVxD7.js";import{C as R,G as O,b as D,u as M,a as P,P as q,D as A,c as $}from"./core.esm-Csvubn5Q.js";import{T as z,u as V,C as G,b as _,c as U,S as Y,v as H,a as J}from"./sortable.esm-Zh-9QRSf.js";import{I as p,x as F,G as K,L as d,B as T}from"./index-Ds50UTAc.js";import{S as k,a as E,b as I,c as L,d as B}from"./select-CJXZv4wv.js";import{d as Q,i as W}from"./format-CZ9bpk32.js";import{C as w}from"./checkbox-BPqrj_XS.js";import{P as X}from"./plus-BgHSYWJN.js";import{T as Z}from"./trash-2-Gny2Upn-.js";function ee({value:l,onChange:a,onBlur:u,readOnly:h,className:t,...s}){const[n,x]=v.useState(!1),m=v.useRef(void 0);v.useEffect(()=>()=>{m.current&&clearTimeout(m.current)},[]);const j=v.useCallback(f=>{const g=f.target.value,b=Q(g);a(b),g!==b&&g.length>0?(x(!0),m.current&&clearTimeout(m.current),m.current=setTimeout(()=>x(!1),2e3)):x(!1)},[a]);return e.jsxs("div",{className:"space-y-1",children:[e.jsx(p,{value:l,onChange:j,onBlur:u,disabled:h,"aria-invalid":n||void 0,className:F("font-mono",t),...s}),n&&e.jsx("p",{className:"text-xs text-destructive",children:"Must start with a letter. Only lowercase letters, numbers, hyphens, and underscores."})]})}function se({type:l,options:a,onChange:u}){const h=K();function t(s,n){u({...a,[s]:n})}return e.jsxs("div",{className:"space-y-3",children:[!["boolean","blocks","array"].includes(l)&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(w,{id:"opt-required",checked:!!a.required,onCheckedChange:s=>t("required",!!s)}),e.jsx(d,{htmlFor:"opt-required",className:"text-sm",children:"Required"})]}),["text","textarea"].includes(l)&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(d,{className:"text-xs",children:"Placeholder"}),e.jsx(p,{value:a.placeholder??"",onChange:s=>t("placeholder",s.target.value),className:"h-8 text-sm"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(d,{className:"text-xs",children:"Max Length"}),e.jsx(p,{type:"number",value:a.maxLength??"",onChange:s=>t("maxLength",s.target.value?Number(s.target.value):void 0),className:"h-8 text-sm"})]})]}),l==="number"&&e.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(d,{className:"text-xs",children:"Min"}),e.jsx(p,{type:"number",value:a.min??"",onChange:s=>t("min",s.target.value?Number(s.target.value):void 0),className:"h-8 text-sm"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(d,{className:"text-xs",children:"Max"}),e.jsx(p,{type:"number",value:a.max??"",onChange:s=>t("max",s.target.value?Number(s.target.value):void 0),className:"h-8 text-sm"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(d,{className:"text-xs",children:"Step"}),e.jsx(p,{type:"number",value:a.step??"",onChange:s=>t("step",s.target.value?Number(s.target.value):void 0),className:"h-8 text-sm"})]})]}),l==="select"&&e.jsxs("div",{className:"space-y-1",children:[e.jsx(d,{className:"text-xs",children:"Choices (one per line)"}),e.jsx(z,{value:(a.choices??[]).join(`
2
+ `),onChange:s=>t("choices",s.target.value.split(`
3
+ `).map(n=>n.trim()).filter(Boolean)),rows:4,className:"text-sm"})]}),l==="media"&&e.jsxs("div",{className:"space-y-1",children:[e.jsx(d,{className:"text-xs",children:"Allowed Types (e.g., image/*, video/*)"}),e.jsx(p,{value:(a.allowedTypes??[]).join(", "),onChange:s=>t("allowedTypes",s.target.value.split(",").map(n=>n.trim()).filter(Boolean)),className:"h-8 text-sm"})]}),l==="content"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(d,{className:"text-xs",children:"Allowed Collections"}),h&&h.collections.length>0?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"flex flex-wrap gap-x-4 gap-y-1",children:h.collections.map(s=>{const n=a.collections??[],x=n.includes(s.name);return e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(w,{id:`col-${s.name}`,checked:x,onCheckedChange:m=>{m?t("collections",[...n,s.name]):t("collections",n.filter(j=>j!==s.name))}}),e.jsx(d,{htmlFor:`col-${s.name}`,className:"text-xs font-normal",children:s.label||s.name})]},s.name)})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Leave all unchecked to allow any collection"})]}):e.jsx(p,{value:(a.collections??[]).join(", "),onChange:s=>t("collections",s.target.value.split(",").map(n=>n.trim()).filter(Boolean)),placeholder:"Comma-separated, leave empty for all",className:"h-8 text-sm"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(w,{id:"opt-multiple",checked:!!a.multiple,onCheckedChange:s=>t("multiple",!!s)}),e.jsx(d,{htmlFor:"opt-multiple",className:"text-sm",children:"Allow multiple"})]})]}),l==="array"&&e.jsxs("div",{className:"space-y-1",children:[e.jsx(d,{className:"text-xs",children:"Item Fields"}),e.jsx(te,{fields:a.itemFields??[],onChange:s=>t("itemFields",s),excludeTypes:["array"]})]})]})}const y=[{value:"text",label:"Text"},{value:"textarea",label:"Textarea"},{value:"number",label:"Number"},{value:"boolean",label:"Boolean"},{value:"select",label:"Select"},{value:"url",label:"URL"},{value:"email",label:"Email"},{value:"date",label:"Date"},{value:"media",label:"Media"},{value:"content",label:"Content"},{value:"blocks",label:"Blocks"},{value:"array",label:"Array"}];function ae({id:l,field:a,onChange:u,onRemove:h,excludeTypes:t,readOnlyName:s,defaultExpanded:n}){const[x,m]=v.useState(n??!1),[j,f]=v.useState(!!a.label),{attributes:g,listeners:b,setNodeRef:C,transform:S,transition:r}=V({id:l}),i=t?y.filter(c=>!t.includes(c.value)):y,o={transform:R.Transform.toString(S),transition:r};function N(c){u({...a,...c})}return e.jsx("div",{ref:C,style:o,className:"rounded-md border bg-card",children:e.jsxs(G,{open:x,onOpenChange:m,children:[e.jsxs("div",{className:"flex items-center gap-2 p-2",children:[e.jsx("button",{type:"button",className:"cursor-grab touch-none text-muted-foreground hover:text-foreground",...g,...b,children:e.jsx(O,{className:"h-4 w-4"})}),e.jsx(_,{asChild:!0,children:e.jsx("button",{type:"button",className:"flex items-center",children:e.jsx(D,{className:F("h-4 w-4 transition-transform",x&&"rotate-90")})})}),e.jsx("span",{className:"min-w-[80px] text-sm font-mono",children:a.name||"unnamed"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:a.type}),e.jsx("span",{className:"flex-1 truncate text-sm text-muted-foreground",children:a.label}),e.jsx(T,{type:"button",variant:"ghost",size:"sm",onClick:h,className:"text-destructive",children:e.jsx(Z,{className:"h-3 w-3"})})]}),e.jsx(U,{children:e.jsxs("div",{className:"space-y-3 border-t p-3",children:[e.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"text-xs text-muted-foreground",children:"Name"}),e.jsx(ee,{value:a.name,onChange:c=>N({name:c}),onBlur:()=>{a.name&&!j&&N({label:W(a.name)})},readOnly:s,className:"h-8 text-sm"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"text-xs text-muted-foreground",children:"Label"}),e.jsx(p,{value:a.label,onChange:c=>{N({label:c.target.value}),f(!0)},className:"h-8 text-sm"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"text-xs text-muted-foreground",children:"Type"}),e.jsxs(k,{value:a.type,onValueChange:c=>N({type:c,options:{}}),children:[e.jsx(E,{className:"h-8 text-sm",children:e.jsx(I,{})}),e.jsx(L,{children:i.map(c=>e.jsx(B,{value:c.value,children:c.label},c.value))})]})]})]}),e.jsx(se,{type:a.type,options:a.options??{},onChange:c=>N({options:c})})]})})]})})}function te({fields:l,onChange:a,excludeTypes:u,existingFieldNames:h}){const t=M(P(q)),s=l.map((r,i)=>`field-${i}`),[n,x]=v.useState("text"),[m,j]=v.useState(null),f=u?y.filter(r=>!u.includes(r.value)):y;function g(){j(l.length),a([...l,{name:"",label:"",type:n,options:{}}])}function b(r,i){const o=[...l];o[r]=i,a(o)}function C(r){a(l.filter((i,o)=>o!==r))}function S(r){const{active:i,over:o}=r;if(o&&i.id!==o.id){const N=s.indexOf(String(i.id)),c=s.indexOf(String(o.id));a(J(l,N,c))}}return e.jsx(A,{sensors:t,collisionDetection:$,onDragEnd:S,children:e.jsx(Y,{items:s,strategy:H,children:e.jsxs("div",{className:"space-y-2",children:[l.map((r,i)=>e.jsx(ae,{id:`field-${i}`,field:r,onChange:o=>b(i,o),onRemove:()=>C(i),excludeTypes:u,readOnlyName:!!(h?.has(r.name)&&r.name),defaultExpanded:i===m},`field-${i}`)),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(k,{value:n,onValueChange:x,children:[e.jsx(E,{className:"h-8 w-[130px] text-sm",children:e.jsx(I,{})}),e.jsx(L,{children:f.map(r=>e.jsx(B,{value:r.value,children:r.label},r.value))})]}),e.jsxs(T,{type:"button",variant:"outline",size:"sm",onClick:g,children:[e.jsx(X,{className:"mr-2 h-3 w-3"})," Add Field"]})]})]})})})}export{te as F,ee as I};
@@ -0,0 +1 @@
1
+ import{j as e}from"./tanstack-BO6c-AOu.js";import{r as o,N as Y}from"./react-vendor-DNVhVxD7.js";import{u as z,L as c,I as d,B as m,a as x,f as _,c as G}from"./index-Ds50UTAc.js";import{C as J,a as X,b as Z,c as $}from"./card-D1-S-QZ6.js";import"./radix-DQ3amgxj.js";function oe(){const{status:T,login:D,completeNewPassword:L,respondToMfaChallenge:O}=z(),[g,W]=o.useState(""),[j,I]=o.useState(""),[N,q]=o.useState(""),[E,v]=o.useState(""),[i,a]=o.useState(""),[n,r]=o.useState(!1),[l,y]=o.useState(null),[u,f]=o.useState("login"),[h,C]=o.useState(""),[S,P]=o.useState(""),[w,b]=o.useState(""),[F,R]=o.useState("");if(T==="authenticated")return e.jsx(Y,{to:"/sites",replace:!0});async function M(t){t.preventDefault(),a(""),r(!0);try{const s=await D(g,j);s.challenge==="NEW_PASSWORD_REQUIRED"&&s.cognitoUser?y({type:"NEW_PASSWORD_REQUIRED",user:s.cognitoUser}):s.challenge==="SOFTWARE_TOKEN_MFA"&&s.cognitoUser&&y({type:"SOFTWARE_TOKEN_MFA",user:s.cognitoUser})}catch(s){a(s instanceof Error?s.message:"Login failed")}finally{r(!1)}}async function U(t){if(t.preventDefault(),!!l){a(""),r(!0);try{await L(l.user,N)}catch(s){a(s instanceof Error?s.message:"Password change failed")}finally{r(!1)}}}async function k(t){if(t.preventDefault(),!!l){a(""),r(!0);try{await O(l.user,E)}catch(s){s&&typeof s=="object"&&"name"in s&&s.name==="NotAuthorizedException"?(a("Your session has expired. Please sign in again."),y(null),v("")):a(s instanceof Error?s.message:"Invalid code")}finally{r(!1)}}}async function B(t){t.preventDefault(),a(""),r(!0);try{await _(h),f("forgot-confirm")}catch(s){(s&&typeof s=="object"&&"name"in s?s.name:"")==="LimitExceededException"?a("Too many attempts. Please try again later."):f("forgot-confirm")}finally{r(!1)}}async function K(){a(""),r(!0);try{await _(h)}catch{}finally{r(!1)}}async function Q(t){if(t.preventDefault(),a(""),w.length<12){a("Password must be at least 12 characters.");return}if(w!==F){a("Passwords do not match.");return}r(!0);try{await G(h,S,w),f("forgot-success")}catch(s){const p=s&&typeof s=="object"&&"name"in s?s.name:"";a(p==="CodeMismatchException"?"Invalid verification code.":p==="ExpiredCodeException"?"Verification code has expired. Please request a new one.":p==="InvalidPasswordException"?"New password does not meet requirements (min 12 chars, uppercase, lowercase, number, symbol).":p==="LimitExceededException"?"Too many attempts. Please try again later.":s instanceof Error?s.message:"Password reset failed")}finally{r(!1)}}function A(){f("login"),a(""),P(""),b(""),R("")}function V(){return u==="forgot-email"?e.jsxs("form",{onSubmit:B,className:"space-y-4",children:[e.jsx("p",{className:"text-muted-foreground text-sm",children:"Enter your email and we'll send a code to reset your password."}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(c,{htmlFor:"forgot-email",children:"Email"}),e.jsx(d,{id:"forgot-email",type:"email",value:h,onChange:t=>C(t.target.value),required:!0,autoFocus:!0,autoComplete:"email"})]}),i&&e.jsx("p",{className:"text-destructive text-sm",children:i}),e.jsxs(m,{type:"submit",className:"w-full",disabled:n,children:[n&&e.jsx(x,{className:"mr-2 h-4 w-4 animate-spin"}),"Send Reset Code"]}),e.jsx("button",{type:"button",className:"text-muted-foreground hover:text-foreground w-full text-center text-sm underline",onClick:A,children:"Back to sign in"})]}):u==="forgot-confirm"?e.jsxs("form",{onSubmit:Q,className:"space-y-4",children:[e.jsx("p",{className:"text-muted-foreground text-sm",children:"Enter the code sent to your email and choose a new password."}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(c,{htmlFor:"reset-code",children:"Verification Code"}),e.jsx(d,{id:"reset-code",type:"text",value:S,onChange:t=>P(t.target.value),required:!0,autoFocus:!0,autoComplete:"one-time-code"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(c,{htmlFor:"reset-password",children:"New Password"}),e.jsx(d,{id:"reset-password",type:"password",value:w,onChange:t=>b(t.target.value),required:!0,autoComplete:"new-password"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(c,{htmlFor:"reset-confirm-password",children:"Confirm Password"}),e.jsx(d,{id:"reset-confirm-password",type:"password",value:F,onChange:t=>R(t.target.value),required:!0,autoComplete:"new-password"})]}),i&&e.jsx("p",{className:"text-destructive text-sm",children:i}),e.jsxs(m,{type:"submit",className:"w-full",disabled:n,children:[n&&e.jsx(x,{className:"mr-2 h-4 w-4 animate-spin"}),"Reset Password"]}),e.jsxs("p",{className:"text-muted-foreground text-center text-sm",children:["Didn't receive a code?"," ",e.jsx("button",{type:"button",className:"text-foreground underline",onClick:K,disabled:n,children:"Resend code"})]})]}):u==="forgot-success"?e.jsxs("div",{className:"space-y-4",children:[e.jsx("p",{className:"text-muted-foreground text-sm",children:"Your password has been reset successfully."}),e.jsx(m,{className:"w-full",onClick:A,children:"Sign In"})]}):l?.type==="SOFTWARE_TOKEN_MFA"?e.jsxs("form",{onSubmit:k,className:"space-y-4",children:[e.jsx("p",{className:"text-muted-foreground text-sm",children:"Enter the 6-digit code from your authenticator app."}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(c,{htmlFor:"mfa-code",children:"Authentication Code"}),e.jsx(d,{id:"mfa-code",type:"text",inputMode:"numeric",pattern:"[0-9]{6}",maxLength:6,value:E,onChange:t=>v(t.target.value),required:!0,autoFocus:!0,autoComplete:"one-time-code"})]}),i&&e.jsx("p",{className:"text-destructive text-sm",children:i}),e.jsxs(m,{type:"submit",className:"w-full",disabled:n,children:[n&&e.jsx(x,{className:"mr-2 h-4 w-4 animate-spin"}),"Verify"]})]}):l?.type==="NEW_PASSWORD_REQUIRED"?e.jsxs("form",{onSubmit:U,className:"space-y-4",children:[e.jsx("p",{className:"text-muted-foreground text-sm",children:"Please set a new password to continue."}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(c,{htmlFor:"new-password",children:"New Password"}),e.jsx(d,{id:"new-password",type:"password",value:N,onChange:t=>q(t.target.value),required:!0,minLength:12,autoFocus:!0})]}),i&&e.jsx("p",{className:"text-destructive text-sm",children:i}),e.jsxs(m,{type:"submit",className:"w-full",disabled:n,children:[n&&e.jsx(x,{className:"mr-2 h-4 w-4 animate-spin"}),"Set Password"]})]}):e.jsxs("form",{onSubmit:M,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(c,{htmlFor:"email",children:"Email"}),e.jsx(d,{id:"email",type:"email",value:g,onChange:t=>W(t.target.value),required:!0,autoFocus:!0,autoComplete:"email"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(c,{htmlFor:"password",children:"Password"}),e.jsx(d,{id:"password",type:"password",value:j,onChange:t=>I(t.target.value),required:!0,autoComplete:"current-password"})]}),e.jsx("button",{type:"button",className:"text-muted-foreground hover:text-foreground text-sm underline",onClick:()=>{f("forgot-email"),C(g),a("")},children:"Forgot password?"}),i&&e.jsx("p",{className:"text-destructive text-sm",children:i}),e.jsxs(m,{type:"submit",className:"w-full",disabled:n,children:[n&&e.jsx(x,{className:"mr-2 h-4 w-4 animate-spin"}),"Sign In"]})]})}function H(){return u==="forgot-email"||u==="forgot-confirm"?"Reset Password":u==="forgot-success"?"Password Reset":l?.type==="SOFTWARE_TOKEN_MFA"?"Two-Factor Authentication":l?.type==="NEW_PASSWORD_REQUIRED"?"Set New Password":"Sign in to Headroom"}return e.jsx("div",{className:"flex h-screen items-center justify-center",children:e.jsxs(J,{className:"w-full max-w-sm",children:[e.jsx(X,{children:e.jsx(Z,{className:"text-center text-xl",children:H()})}),e.jsx($,{children:V()})]})})}export{oe as LoginPage};
@@ -0,0 +1 @@
1
+ @keyframes marching-ants{0%{background-position:0 0,0 100%,0 0,100% 0}to{background-position:20px 0,-20px 100%,0 -20px,100% 20px}}:root{--rc-drag-handle-size: 12px;--rc-drag-handle-mobile-size: 24px;--rc-drag-handle-bg-colour: rgba(0, 0, 0, .2);--rc-drag-bar-size: 6px;--rc-border-color: rgba(255, 255, 255, .7);--rc-focus-color: #0088ff}.ReactCrop{position:relative;display:inline-block;cursor:crosshair;max-width:100%}.ReactCrop *,.ReactCrop *:before,.ReactCrop *:after{box-sizing:border-box}.ReactCrop--disabled,.ReactCrop--locked{cursor:inherit}.ReactCrop__child-wrapper{overflow:hidden;max-height:inherit}.ReactCrop__child-wrapper>img,.ReactCrop__child-wrapper>video{display:block;max-width:100%;max-height:inherit}.ReactCrop:not(.ReactCrop--disabled) .ReactCrop__child-wrapper>img,.ReactCrop:not(.ReactCrop--disabled) .ReactCrop__child-wrapper>video{touch-action:none}.ReactCrop:not(.ReactCrop--disabled) .ReactCrop__crop-selection{touch-action:none}.ReactCrop__crop-mask{position:absolute;inset:0;pointer-events:none;width:calc(100% + .5px);height:calc(100% + .5px)}.ReactCrop__crop-selection{position:absolute;top:0;left:0;transform:translateZ(0);cursor:move}.ReactCrop--disabled .ReactCrop__crop-selection{cursor:inherit}.ReactCrop--circular-crop .ReactCrop__crop-selection{border-radius:50%}.ReactCrop--circular-crop .ReactCrop__crop-selection:after{pointer-events:none;content:"";position:absolute;inset:-1px;border:1px solid var(--rc-border-color);opacity:.3}.ReactCrop--no-animate .ReactCrop__crop-selection{outline:1px dashed white}.ReactCrop__crop-selection:not(.ReactCrop--no-animate .ReactCrop__crop-selection){animation:marching-ants 1s;background-image:linear-gradient(to right,#fff 50%,#444 50%),linear-gradient(to right,#fff 50%,#444 50%),linear-gradient(to bottom,#fff 50%,#444 50%),linear-gradient(to bottom,#fff 50%,#444 50%);background-size:10px 1px,10px 1px,1px 10px,1px 10px;background-position:0 0,0 100%,0 0,100% 0;background-repeat:repeat-x,repeat-x,repeat-y,repeat-y;color:#fff;animation-play-state:running;animation-timing-function:linear;animation-iteration-count:infinite}.ReactCrop__crop-selection:focus{outline:2px solid var(--rc-focus-color);outline-offset:-1px}.ReactCrop--invisible-crop .ReactCrop__crop-mask,.ReactCrop--invisible-crop .ReactCrop__crop-selection{display:none}.ReactCrop__rule-of-thirds-vt:before,.ReactCrop__rule-of-thirds-vt:after,.ReactCrop__rule-of-thirds-hz:before,.ReactCrop__rule-of-thirds-hz:after{content:"";display:block;position:absolute;background-color:#fff6}.ReactCrop__rule-of-thirds-vt:before,.ReactCrop__rule-of-thirds-vt:after{width:1px;height:100%}.ReactCrop__rule-of-thirds-vt:before{left:33.3333333333%}.ReactCrop__rule-of-thirds-vt:after{left:66.6666666667%}.ReactCrop__rule-of-thirds-hz:before,.ReactCrop__rule-of-thirds-hz:after{width:100%;height:1px}.ReactCrop__rule-of-thirds-hz:before{top:33.3333333333%}.ReactCrop__rule-of-thirds-hz:after{top:66.6666666667%}.ReactCrop__drag-handle{position:absolute;width:var(--rc-drag-handle-size);height:var(--rc-drag-handle-size);background-color:var(--rc-drag-handle-bg-colour);border:1px solid var(--rc-border-color)}.ReactCrop__drag-handle:focus{background:var(--rc-focus-color)}.ReactCrop .ord-nw{top:0;left:0;transform:translate(-50%,-50%);cursor:nw-resize}.ReactCrop .ord-n{top:0;left:50%;transform:translate(-50%,-50%);cursor:n-resize}.ReactCrop .ord-ne{top:0;right:0;transform:translate(50%,-50%);cursor:ne-resize}.ReactCrop .ord-e{top:50%;right:0;transform:translate(50%,-50%);cursor:e-resize}.ReactCrop .ord-se{bottom:0;right:0;transform:translate(50%,50%);cursor:se-resize}.ReactCrop .ord-s{bottom:0;left:50%;transform:translate(-50%,50%);cursor:s-resize}.ReactCrop .ord-sw{bottom:0;left:0;transform:translate(-50%,50%);cursor:sw-resize}.ReactCrop .ord-w{top:50%;left:0;transform:translate(-50%,-50%);cursor:w-resize}.ReactCrop__disabled .ReactCrop__drag-handle{cursor:inherit}.ReactCrop__drag-bar{position:absolute}.ReactCrop__drag-bar.ord-n{top:0;left:0;width:100%;height:var(--rc-drag-bar-size);transform:translateY(-50%)}.ReactCrop__drag-bar.ord-e{right:0;top:0;width:var(--rc-drag-bar-size);height:100%;transform:translate(50%)}.ReactCrop__drag-bar.ord-s{bottom:0;left:0;width:100%;height:var(--rc-drag-bar-size);transform:translateY(50%)}.ReactCrop__drag-bar.ord-w{top:0;left:0;width:var(--rc-drag-bar-size);height:100%;transform:translate(-50%)}.ReactCrop--new-crop .ReactCrop__drag-bar,.ReactCrop--new-crop .ReactCrop__drag-handle,.ReactCrop--fixed-aspect .ReactCrop__drag-bar,.ReactCrop--fixed-aspect .ReactCrop__drag-handle.ord-n,.ReactCrop--fixed-aspect .ReactCrop__drag-handle.ord-e,.ReactCrop--fixed-aspect .ReactCrop__drag-handle.ord-s,.ReactCrop--fixed-aspect .ReactCrop__drag-handle.ord-w{display:none}@media(pointer:coarse){.ReactCrop .ord-n,.ReactCrop .ord-e,.ReactCrop .ord-s,.ReactCrop .ord-w{display:none}.ReactCrop__drag-handle{width:var(--rc-drag-handle-mobile-size);height:var(--rc-drag-handle-mobile-size)}}
@@ -0,0 +1 @@
1
+ import{j as e}from"./tanstack-BO6c-AOu.js";import{r as x,R as D,L as yt,u as bt}from"./react-vendor-DNVhVxD7.js";import{F as Ct,l as Nt,m as kt,n as Dt,o as St,T as Fe,b as Ge,p as Mt,q as It,r as Tt,E as _t,A as Ze,e as Je,f as et,g as tt,h as st,i as at,j as nt,k as rt,U as ye,u as Rt,a as At,s as zt,t as $t,v as Et}from"./useMedia-CQnmMz4N.js";import{n as Y,x as P,F as it,B as C,s as S,D as ie,i as le,j as oe,k as ce,l as de,L as O,I as K,m as he,a as ee,X as xe,J as Ft,K as Pt,M as Ut,N as We,S as Ot}from"./index-Ds50UTAc.js";import{C as Lt,c as Ht}from"./card-D1-S-QZ6.js";import{C as Se}from"./checkbox-BPqrj_XS.js";import{S as pe,a as ge,b as fe,c as we,d as te,C as Xt,h as Yt}from"./select-CJXZv4wv.js";import{s as Bt,t as Kt,u as Wt,v as Vt,w as qt,A as Qt}from"./radix-DQ3amgxj.js";import{d as lt,G as Gt,e as Zt,b as Jt,u as es,a as ts,D as ss,f as as,P as ns}from"./core.esm-Csvubn5Q.js";import{b as je,a as Pe,f as Ue}from"./format-CZ9bpk32.js";import{m as W}from"./media-url-DIg_vSyf.js";import{T as rs,a as is,b as ot,c as H,d as ls,e as X}from"./table-B3EHrN_H.js";import{C as Oe}from"./copy-BqH9rXYM.js";import{B as ct}from"./badge-0Z1nL6DI.js";import{T as os}from"./trash-2-Gny2Upn-.js";import{P as cs}from"./plus-BgHSYWJN.js";import{C as ds}from"./check-BGA0ADyt.js";import{S as Ve}from"./search-DIzcfCVh.js";const hs=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],us=Y("chevron-left",hs);const ms=[["path",{d:"M6 2v14a2 2 0 0 0 2 2h14",key:"ron5a4"}],["path",{d:"M18 22V8a2 2 0 0 0-2-2H2",key:"7s9ehn"}]],xs=Y("crop",ms);const ps=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 12.5 8 15l2 2.5",key:"1tg20x"}],["path",{d:"m14 12.5 2 2.5-2 2.5",key:"yinavb"}]],gs=Y("file-code",ps);const fs=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M7 3v18",key:"bbkbws"}],["path",{d:"M3 7.5h4",key:"zfgn84"}],["path",{d:"M3 12h18",key:"1i2n21"}],["path",{d:"M3 16.5h4",key:"1230mu"}],["path",{d:"M17 3v18",key:"in4fa5"}],["path",{d:"M17 7.5h4",key:"myr1c1"}],["path",{d:"M17 16.5h4",key:"go4c1d"}]],ws=Y("film",fs);const js=[["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]],ue=Y("folder",js);const vs=[["rect",{width:"7",height:"7",x:"3",y:"3",rx:"1",key:"1g98yp"}],["rect",{width:"7",height:"7",x:"14",y:"3",rx:"1",key:"6d4xhi"}],["rect",{width:"7",height:"7",x:"14",y:"14",rx:"1",key:"nxv5o0"}],["rect",{width:"7",height:"7",x:"3",y:"14",rx:"1",key:"1bb6yr"}]],ys=Y("layout-grid",vs);const bs=[["path",{d:"M3 5h.01",key:"18ugdj"}],["path",{d:"M3 12h.01",key:"nlz23k"}],["path",{d:"M3 19h.01",key:"noohij"}],["path",{d:"M8 5h13",key:"1pao27"}],["path",{d:"M8 12h13",key:"1za7za"}],["path",{d:"M8 19h13",key:"m83p4d"}]],Cs=Y("list",bs);const Ns=[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"m21 3-7 7",key:"1l2asr"}],["path",{d:"m3 21 7-7",key:"tjx5ai"}],["path",{d:"M9 21H3v-6",key:"wtvkvv"}]],ks=Y("maximize-2",Ns);const Ds=[["path",{d:"M9 18V5l12-2v13",key:"1jmyc2"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["circle",{cx:"18",cy:"16",r:"3",key:"1hluhg"}]],Ss=Y("music",Ds);const Ms=[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]],Is=Y("refresh-cw",Ms);function be({delayDuration:a=0,...t}){return e.jsx(Bt,{"data-slot":"tooltip-provider",delayDuration:a,...t})}function Ce({...a}){return e.jsx(Kt,{"data-slot":"tooltip",...a})}function Ne({...a}){return e.jsx(Wt,{"data-slot":"tooltip-trigger",...a})}function ke({className:a,sideOffset:t=0,children:s,...l}){return e.jsx(Vt,{children:e.jsxs(qt,{"data-slot":"tooltip-content",sideOffset:t,className:P("bg-foreground text-background animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-fit origin-(--radix-tooltip-content-transform-origin) rounded-md px-3 py-1.5 text-xs text-balance",a),...l,children:[s,e.jsx(Qt,{className:"bg-foreground fill-foreground z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px]"})]})})}function Me({mimeType:a,className:t}){return a==="application/pdf"?e.jsx(it,{className:P("text-blue-500",t)}):a.startsWith("video/")?e.jsx(ws,{className:P("text-purple-500",t)}):a.startsWith("audio/")?e.jsx(Ss,{className:P("text-green-500",t)}):a==="image/svg+xml"?e.jsx(gs,{className:P("text-orange-500",t)}):e.jsx(Ct,{className:P("text-muted-foreground",t)})}function Ts(a){return a==="application/pdf"?"PDF":a==="image/svg+xml"?"SVG":a.startsWith("image/")?"Image":a.startsWith("video/")?"Video":a.startsWith("audio/")?"Audio":a.split("/")[1]?.toUpperCase()??"File"}function _s({item:a,selected:t,onToggle:s,onSelect:l,onLightbox:n,folderName:r}){const{attributes:u,listeners:h,setNodeRef:o,isDragging:i}=lt({id:a.mediaId,data:{type:"media",mediaId:a.mediaId}}),p=a.mimeType.startsWith("image/")&&a.mimeType!=="image/svg+xml";return e.jsxs(ot,{ref:o,className:P("cursor-pointer",i&&"opacity-50"),onClick:l,children:[e.jsx(X,{onPointerDown:m=>m.stopPropagation(),onClick:m=>m.stopPropagation(),children:e.jsx(Se,{checked:t,onCheckedChange:s,"aria-label":`Select ${a.filename}`})}),e.jsx(X,{className:"w-6 p-1",children:e.jsx("div",{className:"cursor-grab text-muted-foreground",...u,...h,children:e.jsx(Gt,{className:"h-4 w-4"})})}),e.jsx(X,{className:"p-1",children:p?e.jsx("img",{src:W(a.urls?.thumb_sm??a.url),alt:a.alt||a.filename,className:P("h-8 w-8 rounded object-cover",n&&"cursor-zoom-in"),onClick:n?m=>{m.stopPropagation(),n()}:void 0}):e.jsx("div",{className:"flex h-8 w-8 items-center justify-center",children:e.jsx(Me,{mimeType:a.mimeType,className:"h-5 w-5"})})}),e.jsxs(X,{className:"max-w-[200px]",children:[r&&e.jsx("span",{className:"text-muted-foreground block truncate text-xs",children:r}),e.jsx("span",{className:"block truncate text-sm font-medium",children:a.filename})]}),e.jsx(X,{children:e.jsx("span",{className:"text-muted-foreground text-xs",children:Ts(a.mimeType)})}),e.jsx(X,{className:"text-right",children:e.jsx("span",{className:"text-muted-foreground text-xs",children:je(a.size)})}),e.jsx(X,{children:e.jsx("span",{className:"text-muted-foreground text-xs",children:a.width&&a.height?`${a.width}×${a.height}`:"—"})}),e.jsx(X,{children:a.tags.length>0&&e.jsxs("div",{className:"flex flex-wrap gap-1",children:[a.tags.slice(0,3).map(m=>e.jsx("span",{className:"bg-muted text-muted-foreground rounded px-1.5 py-0.5 text-[10px]",children:m},m)),a.tags.length>3&&e.jsxs("span",{className:"text-muted-foreground text-[10px]",children:["+",a.tags.length-3]})]})}),e.jsx(X,{children:e.jsx(be,{children:e.jsxs(Ce,{children:[e.jsx(Ne,{asChild:!0,children:e.jsx("span",{className:"text-muted-foreground text-xs",children:Pe(a.uploadedAt)})}),e.jsx(ke,{children:Ue(a.uploadedAt)})]})})}),e.jsx(X,{onPointerDown:m=>m.stopPropagation(),onClick:m=>m.stopPropagation(),children:e.jsx(C,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>{navigator.clipboard.writeText(W(a.url)),S.success("URL copied to clipboard")},children:e.jsx(Oe,{className:"h-3.5 w-3.5"})})})]})}function Rs({items:a,host:t,onSelect:s,selectedIds:l,onToggle:n,onToggleAll:r,allSelected:u,onLightbox:h,folderMap:o}){return e.jsxs(rs,{children:[e.jsx(is,{children:e.jsxs(ot,{children:[e.jsx(H,{className:"w-10",children:e.jsx(Se,{checked:u,onCheckedChange:r,"aria-label":"Select all"})}),e.jsx(H,{className:"w-6"}),e.jsx(H,{className:"w-12"}),e.jsx(H,{children:"Filename"}),e.jsx(H,{className:"w-20",children:"Type"}),e.jsx(H,{className:"w-24 text-right",children:"Size"}),e.jsx(H,{className:"w-28",children:"Dimensions"}),e.jsx(H,{className:"w-40",children:"Tags"}),e.jsx(H,{className:"w-32",children:"Uploaded"}),e.jsx(H,{className:"w-10"})]})}),e.jsx(ls,{children:a.map(i=>e.jsx(_s,{item:i,host:t,selected:l.has(i.mediaId),onToggle:()=>n(i.mediaId),onSelect:()=>s(i),folderName:o?.get(i.folderId??""),onLightbox:h&&i.mimeType.startsWith("image/")&&i.mimeType!=="image/svg+xml"?()=>h(i):void 0},i.mediaId))})]})}var As=Object.defineProperty,zs=(a,t,s)=>t in a?As(a,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):a[t]=s,T=(a,t,s)=>zs(a,typeof t!="symbol"?t+"":t,s);const De={x:0,y:0,width:0,height:0,unit:"px"},ae=(a,t,s)=>Math.min(Math.max(a,t),s),$s=(...a)=>a.filter(t=>t&&typeof t=="string").join(" "),qe=(a,t)=>a===t||a.width===t.width&&a.height===t.height&&a.x===t.x&&a.y===t.y&&a.unit===t.unit;function ne(a,t,s){return a.unit==="%"?{...De,...a,unit:"%"}:{unit:"%",x:a.x?a.x/t*100:0,y:a.y?a.y/s*100:0,width:a.width?a.width/t*100:0,height:a.height?a.height/s*100:0}}function G(a,t,s){return a.unit?a.unit==="px"?{...De,...a,unit:"px"}:{unit:"px",x:a.x?a.x*t/100:0,y:a.y?a.y*s/100:0,width:a.width?a.width*t/100:0,height:a.height?a.height*s/100:0}:{...De,...a,unit:"px"}}function Qe(a,t,s,l,n,r=0,u=0,h=l,o=n){const i={...a};let p=Math.min(r,l),m=Math.min(u,n),w=Math.min(h,l),c=Math.min(o,n);t&&(t>1?(p=u?u*t:p,m=p/t,w=h*t):(m=r?r/t:m,p=m*t,c=o/t)),i.y<0&&(i.height=Math.max(i.height+i.y,m),i.y=0),i.x<0&&(i.width=Math.max(i.width+i.x,p),i.x=0);const y=l-(i.x+i.width);y<0&&(i.x=Math.min(i.x,l-p),i.width+=y);const d=n-(i.y+i.height);if(d<0&&(i.y=Math.min(i.y,n-m),i.height+=d),i.width<p&&((s==="sw"||s=="nw")&&(i.x-=p-i.width),i.width=p),i.height<m&&((s==="nw"||s=="ne")&&(i.y-=m-i.height),i.height=m),i.width>w&&((s==="sw"||s=="nw")&&(i.x-=w-i.width),i.width=w),i.height>c&&((s==="nw"||s=="ne")&&(i.y-=c-i.height),i.height=c),t){const j=i.width/i.height;if(j<t){const v=Math.max(i.width/t,m);(s==="nw"||s=="ne")&&(i.y-=v-i.height),i.height=v}else if(j>t){const v=Math.max(i.height*t,p);(s==="sw"||s=="nw")&&(i.x-=v-i.width),i.width=v}}return i}function Es(a,t,s,l){const n={...a};return t==="ArrowLeft"?l==="nw"?(n.x-=s,n.y-=s,n.width+=s,n.height+=s):l==="w"?(n.x-=s,n.width+=s):l==="sw"?(n.x-=s,n.width+=s,n.height+=s):l==="ne"?(n.y+=s,n.width-=s,n.height-=s):l==="e"?n.width-=s:l==="se"&&(n.width-=s,n.height-=s):t==="ArrowRight"&&(l==="nw"?(n.x+=s,n.y+=s,n.width-=s,n.height-=s):l==="w"?(n.x+=s,n.width-=s):l==="sw"?(n.x+=s,n.width-=s,n.height-=s):l==="ne"?(n.y-=s,n.width+=s,n.height+=s):l==="e"?n.width+=s:l==="se"&&(n.width+=s,n.height+=s)),t==="ArrowUp"?l==="nw"?(n.x-=s,n.y-=s,n.width+=s,n.height+=s):l==="n"?(n.y-=s,n.height+=s):l==="ne"?(n.y-=s,n.width+=s,n.height+=s):l==="sw"?(n.x+=s,n.width-=s,n.height-=s):l==="s"?n.height-=s:l==="se"&&(n.width-=s,n.height-=s):t==="ArrowDown"&&(l==="nw"?(n.x+=s,n.y+=s,n.width-=s,n.height-=s):l==="n"?(n.y+=s,n.height-=s):l==="ne"?(n.y+=s,n.width-=s,n.height-=s):l==="sw"?(n.x-=s,n.width+=s,n.height+=s):l==="s"?n.height+=s:l==="se"&&(n.width+=s,n.height+=s)),n}const re={capture:!0,passive:!1};let Fs=0;const Z=class U extends x.PureComponent{constructor(){super(...arguments),T(this,"docMoveBound",!1),T(this,"mouseDownOnCrop",!1),T(this,"dragStarted",!1),T(this,"evData",{startClientX:0,startClientY:0,startCropX:0,startCropY:0,clientX:0,clientY:0,isResize:!0}),T(this,"componentRef",x.createRef()),T(this,"mediaRef",x.createRef()),T(this,"resizeObserver"),T(this,"initChangeCalled",!1),T(this,"instanceId",`rc-${Fs++}`),T(this,"state",{cropIsActive:!1,newCropIsBeingDrawn:!1}),T(this,"onCropPointerDown",t=>{const{crop:s,disabled:l}=this.props,n=this.getBox();if(!s)return;const r=G(s,n.width,n.height);if(l)return;t.cancelable&&t.preventDefault(),this.bindDocMove(),this.componentRef.current.focus({preventScroll:!0});const u=t.target.dataset.ord,h=!!u;let o=t.clientX,i=t.clientY,p=r.x,m=r.y;if(u){const w=t.clientX-n.x,c=t.clientY-n.y;let y=0,d=0;u==="ne"||u=="e"?(y=w-(r.x+r.width),d=c-r.y,p=r.x,m=r.y+r.height):u==="se"||u==="s"?(y=w-(r.x+r.width),d=c-(r.y+r.height),p=r.x,m=r.y):u==="sw"||u=="w"?(y=w-r.x,d=c-(r.y+r.height),p=r.x+r.width,m=r.y):(u==="nw"||u=="n")&&(y=w-r.x,d=c-r.y,p=r.x+r.width,m=r.y+r.height),o=p+n.x+y,i=m+n.y+d}this.evData={startClientX:o,startClientY:i,startCropX:p,startCropY:m,clientX:t.clientX,clientY:t.clientY,isResize:h,ord:u},this.mouseDownOnCrop=!0,this.setState({cropIsActive:!0})}),T(this,"onComponentPointerDown",t=>{const{crop:s,disabled:l,locked:n,keepSelection:r,onChange:u}=this.props,h=this.getBox();if(l||n||r&&s)return;t.cancelable&&t.preventDefault(),this.bindDocMove(),this.componentRef.current.focus({preventScroll:!0});const o=t.clientX-h.x,i=t.clientY-h.y,p={unit:"px",x:o,y:i,width:0,height:0};this.evData={startClientX:t.clientX,startClientY:t.clientY,startCropX:o,startCropY:i,clientX:t.clientX,clientY:t.clientY,isResize:!0},this.mouseDownOnCrop=!0,u(G(p,h.width,h.height),ne(p,h.width,h.height)),this.setState({cropIsActive:!0,newCropIsBeingDrawn:!0})}),T(this,"onDocPointerMove",t=>{const{crop:s,disabled:l,onChange:n,onDragStart:r}=this.props,u=this.getBox();if(l||!s||!this.mouseDownOnCrop)return;t.cancelable&&t.preventDefault(),this.dragStarted||(this.dragStarted=!0,r&&r(t));const{evData:h}=this;h.clientX=t.clientX,h.clientY=t.clientY;let o;h.isResize?o=this.resizeCrop():o=this.dragCrop(),qe(s,o)||n(G(o,u.width,u.height),ne(o,u.width,u.height))}),T(this,"onComponentKeyDown",t=>{const{crop:s,disabled:l,onChange:n,onComplete:r}=this.props;if(l)return;const u=t.key;let h=!1;if(!s)return;const o=this.getBox(),i=this.makePixelCrop(o),p=(navigator.platform.match("Mac")?t.metaKey:t.ctrlKey)?U.nudgeStepLarge:t.shiftKey?U.nudgeStepMedium:U.nudgeStep;if(u==="ArrowLeft"?(i.x-=p,h=!0):u==="ArrowRight"?(i.x+=p,h=!0):u==="ArrowUp"?(i.y-=p,h=!0):u==="ArrowDown"&&(i.y+=p,h=!0),h){t.cancelable&&t.preventDefault(),i.x=ae(i.x,0,o.width-i.width),i.y=ae(i.y,0,o.height-i.height);const m=G(i,o.width,o.height),w=ne(i,o.width,o.height);n(m,w),r&&r(m,w)}}),T(this,"onHandlerKeyDown",(t,s)=>{const{aspect:l=0,crop:n,disabled:r,minWidth:u=0,minHeight:h=0,maxWidth:o,maxHeight:i,onChange:p,onComplete:m}=this.props,w=this.getBox();if(r||!n)return;if(t.key==="ArrowUp"||t.key==="ArrowDown"||t.key==="ArrowLeft"||t.key==="ArrowRight")t.stopPropagation(),t.preventDefault();else return;const c=(navigator.platform.match("Mac")?t.metaKey:t.ctrlKey)?U.nudgeStepLarge:t.shiftKey?U.nudgeStepMedium:U.nudgeStep,y=G(n,w.width,w.height),d=Es(y,t.key,c,s),j=Qe(d,l,s,w.width,w.height,u,h,o,i);if(!qe(n,j)){const v=ne(j,w.width,w.height);p(j,v),m&&m(j,v)}}),T(this,"onDocPointerDone",t=>{const{crop:s,disabled:l,onComplete:n,onDragEnd:r}=this.props,u=this.getBox();this.unbindDocMove(),!(l||!s)&&this.mouseDownOnCrop&&(this.mouseDownOnCrop=!1,this.dragStarted=!1,r&&r(t),n&&n(G(s,u.width,u.height),ne(s,u.width,u.height)),this.setState({cropIsActive:!1,newCropIsBeingDrawn:!1}))}),T(this,"onDragFocus",()=>{var t;(t=this.componentRef.current)==null||t.scrollTo(0,0)})}get document(){return document}getBox(){const t=this.mediaRef.current;if(!t)return{x:0,y:0,width:0,height:0};const{x:s,y:l,width:n,height:r}=t.getBoundingClientRect();return{x:s,y:l,width:n,height:r}}componentDidUpdate(t){const{crop:s,onComplete:l}=this.props;if(l&&!t.crop&&s){const{width:n,height:r}=this.getBox();n&&r&&l(G(s,n,r),ne(s,n,r))}}componentWillUnmount(){this.resizeObserver&&this.resizeObserver.disconnect(),this.unbindDocMove()}bindDocMove(){this.docMoveBound||(this.document.addEventListener("pointermove",this.onDocPointerMove,re),this.document.addEventListener("pointerup",this.onDocPointerDone,re),this.document.addEventListener("pointercancel",this.onDocPointerDone,re),this.docMoveBound=!0)}unbindDocMove(){this.docMoveBound&&(this.document.removeEventListener("pointermove",this.onDocPointerMove,re),this.document.removeEventListener("pointerup",this.onDocPointerDone,re),this.document.removeEventListener("pointercancel",this.onDocPointerDone,re),this.docMoveBound=!1)}getCropStyle(){const{crop:t}=this.props;if(t)return{top:`${t.y}${t.unit}`,left:`${t.x}${t.unit}`,width:`${t.width}${t.unit}`,height:`${t.height}${t.unit}`}}dragCrop(){const{evData:t}=this,s=this.getBox(),l=this.makePixelCrop(s),n=t.clientX-t.startClientX,r=t.clientY-t.startClientY;return l.x=ae(t.startCropX+n,0,s.width-l.width),l.y=ae(t.startCropY+r,0,s.height-l.height),l}getPointRegion(t,s,l,n){const{evData:r}=this,u=r.clientX-t.x,h=r.clientY-t.y;let o;n&&s?o=s==="nw"||s==="n"||s==="ne":o=h<r.startCropY;let i;return l&&s?i=s==="nw"||s==="w"||s==="sw":i=u<r.startCropX,i?o?"nw":"sw":o?"ne":"se"}resolveMinDimensions(t,s,l=0,n=0){const r=Math.min(l,t.width),u=Math.min(n,t.height);return!s||!r&&!u?[r,u]:s>1?r?[r,r/s]:[u*s,u]:u?[u*s,u]:[r,r/s]}resizeCrop(){const{evData:t}=this,{aspect:s=0,maxWidth:l,maxHeight:n}=this.props,r=this.getBox(),[u,h]=this.resolveMinDimensions(r,s,this.props.minWidth,this.props.minHeight);let o=this.makePixelCrop(r);const i=this.getPointRegion(r,t.ord,u,h),p=t.ord||i;let m=t.clientX-t.startClientX,w=t.clientY-t.startClientY;(u&&p==="nw"||p==="w"||p==="sw")&&(m=Math.min(m,-u)),(h&&p==="nw"||p==="n"||p==="ne")&&(w=Math.min(w,-h));const c={unit:"px",x:0,y:0,width:0,height:0};i==="ne"?(c.x=t.startCropX,c.width=m,s?(c.height=c.width/s,c.y=t.startCropY-c.height):(c.height=Math.abs(w),c.y=t.startCropY-c.height)):i==="se"?(c.x=t.startCropX,c.y=t.startCropY,c.width=m,s?c.height=c.width/s:c.height=w):i==="sw"?(c.x=t.startCropX+m,c.y=t.startCropY,c.width=Math.abs(m),s?c.height=c.width/s:c.height=w):i==="nw"&&(c.x=t.startCropX+m,c.width=Math.abs(m),s?(c.height=c.width/s,c.y=t.startCropY-c.height):(c.height=Math.abs(w),c.y=t.startCropY+w));const y=Qe(c,s,i,r.width,r.height,u,h,l,n);return s||U.xyOrds.indexOf(p)>-1?o=y:U.xOrds.indexOf(p)>-1?(o.x=y.x,o.width=y.width):U.yOrds.indexOf(p)>-1&&(o.y=y.y,o.height=y.height),o.x=ae(o.x,0,r.width-o.width),o.y=ae(o.y,0,r.height-o.height),o}renderCropSelection(){const{ariaLabels:t=U.defaultProps.ariaLabels,disabled:s,locked:l,renderSelectionAddon:n,ruleOfThirds:r,crop:u}=this.props,h=this.getCropStyle();if(u)return D.createElement("div",{style:h,className:"ReactCrop__crop-selection",onPointerDown:this.onCropPointerDown,"aria-label":t.cropArea,tabIndex:0,onKeyDown:this.onComponentKeyDown,role:"group"},!s&&!l&&D.createElement("div",{className:"ReactCrop__drag-elements",onFocus:this.onDragFocus},D.createElement("div",{className:"ReactCrop__drag-bar ord-n","data-ord":"n"}),D.createElement("div",{className:"ReactCrop__drag-bar ord-e","data-ord":"e"}),D.createElement("div",{className:"ReactCrop__drag-bar ord-s","data-ord":"s"}),D.createElement("div",{className:"ReactCrop__drag-bar ord-w","data-ord":"w"}),D.createElement("div",{className:"ReactCrop__drag-handle ord-nw","data-ord":"nw",tabIndex:0,"aria-label":t.nwDragHandle,onKeyDown:o=>this.onHandlerKeyDown(o,"nw"),role:"button"}),D.createElement("div",{className:"ReactCrop__drag-handle ord-n","data-ord":"n",tabIndex:0,"aria-label":t.nDragHandle,onKeyDown:o=>this.onHandlerKeyDown(o,"n"),role:"button"}),D.createElement("div",{className:"ReactCrop__drag-handle ord-ne","data-ord":"ne",tabIndex:0,"aria-label":t.neDragHandle,onKeyDown:o=>this.onHandlerKeyDown(o,"ne"),role:"button"}),D.createElement("div",{className:"ReactCrop__drag-handle ord-e","data-ord":"e",tabIndex:0,"aria-label":t.eDragHandle,onKeyDown:o=>this.onHandlerKeyDown(o,"e"),role:"button"}),D.createElement("div",{className:"ReactCrop__drag-handle ord-se","data-ord":"se",tabIndex:0,"aria-label":t.seDragHandle,onKeyDown:o=>this.onHandlerKeyDown(o,"se"),role:"button"}),D.createElement("div",{className:"ReactCrop__drag-handle ord-s","data-ord":"s",tabIndex:0,"aria-label":t.sDragHandle,onKeyDown:o=>this.onHandlerKeyDown(o,"s"),role:"button"}),D.createElement("div",{className:"ReactCrop__drag-handle ord-sw","data-ord":"sw",tabIndex:0,"aria-label":t.swDragHandle,onKeyDown:o=>this.onHandlerKeyDown(o,"sw"),role:"button"}),D.createElement("div",{className:"ReactCrop__drag-handle ord-w","data-ord":"w",tabIndex:0,"aria-label":t.wDragHandle,onKeyDown:o=>this.onHandlerKeyDown(o,"w"),role:"button"})),n&&D.createElement("div",{className:"ReactCrop__selection-addon",onPointerDown:o=>o.stopPropagation()},n(this.state)),r&&D.createElement(D.Fragment,null,D.createElement("div",{className:"ReactCrop__rule-of-thirds-hz"}),D.createElement("div",{className:"ReactCrop__rule-of-thirds-vt"})))}makePixelCrop(t){const s={...De,...this.props.crop||{}};return G(s,t.width,t.height)}render(){const{aspect:t,children:s,circularCrop:l,className:n,crop:r,disabled:u,locked:h,style:o,ruleOfThirds:i}=this.props,{cropIsActive:p,newCropIsBeingDrawn:m}=this.state,w=r?this.renderCropSelection():null,c=$s("ReactCrop",n,p&&"ReactCrop--active",u&&"ReactCrop--disabled",h&&"ReactCrop--locked",m&&"ReactCrop--new-crop",r&&t&&"ReactCrop--fixed-aspect",r&&l&&"ReactCrop--circular-crop",r&&i&&"ReactCrop--rule-of-thirds",!this.dragStarted&&r&&!r.width&&!r.height&&"ReactCrop--invisible-crop",l&&"ReactCrop--no-animate");return D.createElement("div",{ref:this.componentRef,className:c,style:o},D.createElement("div",{ref:this.mediaRef,className:"ReactCrop__child-wrapper",onPointerDown:this.onComponentPointerDown},s),r?D.createElement("svg",{className:"ReactCrop__crop-mask",width:"100%",height:"100%"},D.createElement("defs",null,D.createElement("mask",{id:`hole-${this.instanceId}`},D.createElement("rect",{width:"100%",height:"100%",fill:"white"}),l?D.createElement("ellipse",{cx:`${r.x+r.width/2}${r.unit}`,cy:`${r.y+r.height/2}${r.unit}`,rx:`${r.width/2}${r.unit}`,ry:`${r.height/2}${r.unit}`,fill:"black"}):D.createElement("rect",{x:`${r.x}${r.unit}`,y:`${r.y}${r.unit}`,width:`${r.width}${r.unit}`,height:`${r.height}${r.unit}`,fill:"black"}))),D.createElement("rect",{fill:"black",fillOpacity:.5,width:"100%",height:"100%",mask:`url(#hole-${this.instanceId})`})):void 0,w)}};T(Z,"xOrds",["e","w"]),T(Z,"yOrds",["n","s"]),T(Z,"xyOrds",["nw","ne","se","sw"]),T(Z,"nudgeStep",1),T(Z,"nudgeStepMedium",10),T(Z,"nudgeStepLarge",100),T(Z,"defaultProps",{ariaLabels:{cropArea:"Use the arrow keys to move the crop selection area",nwDragHandle:"Use the arrow keys to move the north west drag handle to change the crop selection area",nDragHandle:"Use the up and down arrow keys to move the north drag handle to change the crop selection area",neDragHandle:"Use the arrow keys to move the north east drag handle to change the crop selection area",eDragHandle:"Use the up and down arrow keys to move the east drag handle to change the crop selection area",seDragHandle:"Use the arrow keys to move the south east drag handle to change the crop selection area",sDragHandle:"Use the up and down arrow keys to move the south drag handle to change the crop selection area",swDragHandle:"Use the arrow keys to move the south west drag handle to change the crop selection area",wDragHandle:"Use the up and down arrow keys to move the west drag handle to change the crop selection area"}});let Ps=Z;const Us=[{label:"Free",value:""},{label:"1:1 Square",value:"1"},{label:"4:3",value:"4/3"},{label:"3:2",value:"3/2"},{label:"16:9",value:"16/9"},{label:"2:3",value:"2/3"},{label:"3:4",value:"3/4"}],dt=[{label:"Original",value:"",ext:""},{label:"JPEG",value:"jpeg",ext:".jpg"},{label:"PNG",value:"png",ext:".png"},{label:"WebP",value:"webp",ext:".webp"},{label:"AVIF",value:"avif",ext:".avif"}],Os={"image/jpeg":".jpg","image/png":".png","image/gif":".gif","image/webp":".webp","image/avif":".avif","image/tiff":".tiff"};function $e(a,t){return a?dt.find(s=>s.value===a)?.ext||`.${a}`:Os[t]||".jpg"}function Ls(a,t){const s=a.lastIndexOf(".");return(s>0?a.substring(0,s):a)+t}function Hs({host:a,media:t,onClose:s,onSaved:l}){const n=x.useRef(null),[r,u]=x.useState(),[h,o]=x.useState(),[i,p]=x.useState(""),[m,w]=x.useState(""),[c,y]=x.useState(""),[d,j]=x.useState(""),[v,_]=x.useState("80"),[R,I]=x.useState(()=>{const b=$e("",t.mimeType),k=t.filename.lastIndexOf(".");return`${k>0?t.filename.substring(0,k):t.filename}-transformed${b}`});function E(b){const k=b==="__original__"?"":b;j(k);const q=$e(k,t.mimeType);I(J=>Ls(J,q))}const F=Nt(a,t.mediaId),[g,A]=x.useState(null),$=x.useCallback(()=>{if(!h||!g)return null;const b=(t.width??g.width)/g.width,k=(t.height??g.height)/g.height;return{cropX:Math.round(h.x*b),cropY:Math.round(h.y*k),cropW:Math.round(h.width*b),cropH:Math.round(h.height*k)}},[h,t.width,t.height,g]),se=x.useMemo(()=>$(),[$]);async function me(){const b=se,k=m?parseInt(m):void 0,q=c?parseInt(c):void 0;if(!b&&!k&&!q&&!d){S.error("Please specify a crop, resize, or format change");return}if(!R.trim()){S.error("Filename is required");return}const J=$e(d,t.mimeType);if(!R.trim().toLowerCase().endsWith(J)){S.error(`Filename must end with ${J} to match the output format`);return}try{const B=await F.mutateAsync({...b??{},...k?{width:k}:{},...q?{height:q}:{},...d?{format:d}:{},...v?{quality:parseInt(v)}:{},filename:R.trim()});S.success("Transform saved as new media"),l?.(B),s()}catch(B){S.error("Transform failed",{description:B instanceof Error?B.message:void 0})}}function V(b){p(b==="__free__"?"":b),u(void 0),o(void 0)}function Ie(b){if(!b)return;const k=b.split("/");return k.length===2?Number(k[0])/Number(k[1]):Number(b)||void 0}const Te=Ie(i);return e.jsx(ie,{open:!0,onOpenChange:()=>s(),children:e.jsxs(le,{className:"max-w-4xl max-h-[90vh] overflow-y-auto",children:[e.jsxs(oe,{children:[e.jsx(ce,{children:"Transform Image"}),e.jsx(de,{className:"sr-only",children:"Crop, resize, or convert image format"})]}),e.jsxs("div",{className:"grid grid-cols-[1fr_280px] gap-6",children:[e.jsx("div",{className:"min-h-0 overflow-hidden rounded border bg-muted/30 flex items-center justify-center",children:e.jsx(Ps,{crop:r,onChange:b=>u(b),onComplete:b=>o(b),aspect:Te,children:e.jsx("img",{ref:n,src:W(t.url),alt:t.alt||t.filename,className:"max-h-[60vh] max-w-full object-contain",onLoad:b=>{const k=b.currentTarget;A({width:k.naturalWidth,height:k.naturalHeight})}})})}),e.jsxs("div",{className:"space-y-5",children:[e.jsxs("div",{className:"text-muted-foreground text-sm",children:["Original: ",t.width,"×",t.height]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(O,{children:"Crop aspect ratio"}),e.jsxs(pe,{value:i||"__free__",onValueChange:V,children:[e.jsx(ge,{children:e.jsx(fe,{placeholder:"Free"})}),e.jsx(we,{children:Us.map(b=>e.jsx(te,{value:b.value||"__free__",children:b.label},b.value||"__free__"))})]}),h&&e.jsxs("div",{className:"text-xs text-muted-foreground",children:["Crop: ",se?.cropW,"×",se?.cropH," at (",se?.cropX,", ",se?.cropY,")"]}),h&&e.jsx(C,{variant:"ghost",size:"sm",onClick:()=>{u(void 0),o(void 0)},children:"Clear crop"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(O,{children:"Resize (optional)"}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsx("div",{children:e.jsx(K,{type:"number",placeholder:"Width",value:m,onChange:b=>w(b.target.value),min:1,max:2048})}),e.jsx("div",{children:e.jsx(K,{type:"number",placeholder:"Height",value:c,onChange:b=>y(b.target.value),min:1,max:2048})})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(O,{children:"Output format"}),e.jsxs(pe,{value:d||"__original__",onValueChange:E,children:[e.jsx(ge,{children:e.jsx(fe,{placeholder:"Original"})}),e.jsx(we,{children:dt.map(b=>e.jsx(te,{value:b.value||"__original__",children:b.label},b.value||"__original__"))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(O,{children:"Quality (1-100)"}),e.jsx(K,{type:"number",value:v,onChange:b=>_(b.target.value),min:1,max:100})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(O,{children:"Save as filename"}),e.jsx(K,{value:R,onChange:b=>I(b.target.value)})]})]})]}),e.jsxs(he,{children:[e.jsx(C,{variant:"outline",onClick:s,children:"Cancel"}),e.jsxs(C,{onClick:me,disabled:F.isPending,children:[F.isPending&&e.jsx(ee,{className:"mr-2 h-4 w-4 animate-spin"}),"Save as New Image"]})]})]})})}const Xs=new Set(["image/jpeg","image/png","image/gif","image/webp","image/avif","image/tiff"]);function Ys({host:a,media:t,onClose:s,folders:l,tagSuggestions:n}){const[r,u]=x.useState(t.alt??""),[h,o]=x.useState(t.caption??""),[i,p]=x.useState(t.userTags??[]),[m,w]=x.useState(t.folderId||"__none__"),[c,y]=x.useState(!1),d=Xs.has(t.mimeType),j=kt(a,t.mediaId),v=Dt(a,t.mediaId),{data:_,isLoading:R}=St(a,t.mediaId),I=t.tags.filter(g=>!t.userTags?.includes(g));async function E(){try{await j.mutateAsync({alt:r,caption:h,userTags:i,folderId:m==="__none__"?"":m}),S.success("Media updated"),s()}catch(g){S.error("Failed to update",{description:g instanceof Error?g.message:void 0})}}async function F(){try{await v.mutateAsync(),S.success("Media deleted"),s()}catch(g){S.error("Failed to delete",{description:g instanceof Error?g.message:void 0})}}return e.jsxs(ie,{open:!0,onOpenChange:()=>s(),children:[e.jsxs(le,{children:[e.jsxs(oe,{children:[e.jsx(ce,{children:t.filename}),e.jsx(de,{className:"sr-only",children:"View and edit media details"})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"text-muted-foreground text-sm",children:[t.mimeType," · ",je(t.size),t.width&&t.height&&` · ${t.width}×${t.height}`," · ",Ue(t.uploadedAt)]}),e.jsxs("div",{className:"flex gap-2",children:[d&&e.jsxs(C,{variant:"outline",size:"sm",onClick:()=>y(!0),children:[e.jsx(xs,{className:"mr-1.5 h-3.5 w-3.5"}),"Transform"]}),e.jsxs(C,{variant:"outline",size:"sm",onClick:()=>{navigator.clipboard.writeText(W(t.url)),S.success("URL copied to clipboard")},children:[e.jsx(Oe,{className:"mr-1.5 h-3.5 w-3.5"}),"Copy URL"]})]})]}),I.length>0&&e.jsxs("div",{className:"space-y-1",children:[e.jsx(O,{className:"text-xs text-muted-foreground",children:"Auto-detected tags"}),e.jsx("div",{className:"flex flex-wrap gap-1",children:I.map(g=>e.jsx(ct,{variant:"outline",className:"text-xs",children:g},g))})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(O,{children:"Tags"}),e.jsx(Fe,{tags:i,onChange:p,placeholder:"Add tags...",suggestions:n})]}),l&&l.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(O,{children:"Folder"}),e.jsxs(pe,{value:m,onValueChange:w,children:[e.jsx(ge,{children:e.jsx(fe,{placeholder:"No folder"})}),e.jsxs(we,{children:[e.jsx(te,{value:"__none__",children:"No folder"}),l.map(g=>e.jsx(te,{value:g.folderId,children:g.name},g.folderId))]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(O,{htmlFor:"alt",children:"Alt text"}),e.jsx(K,{id:"alt",value:r,onChange:g=>u(g.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(O,{htmlFor:"caption",children:"Caption"}),e.jsx(K,{id:"caption",value:h,onChange:g=>o(g.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(O,{className:"text-xs text-muted-foreground",children:"Used in"}),R?e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground text-sm",children:[e.jsx(ee,{className:"h-3.5 w-3.5 animate-spin"}),"Checking usage..."]}):_?.references.length?e.jsxs("div",{className:"space-y-1",children:[_.references.map(g=>e.jsxs(yt,{to:`/sites/${a}/content/${g.collection}/${g.contentId}`,className:"flex items-center gap-2 rounded px-2 py-1 text-sm hover:bg-muted",onClick:s,children:[e.jsx(it,{className:"h-3.5 w-3.5 text-muted-foreground"}),e.jsx("span",{className:"truncate",children:g.title||g.contentId}),e.jsxs("span",{className:"text-muted-foreground text-xs",children:["(",g.collection,")"]})]},g.contentId)),_.note&&e.jsx("p",{className:"text-muted-foreground text-xs italic",children:_.note})]}):e.jsx("p",{className:"text-muted-foreground text-sm",children:"Not referenced in any content."})]})]}),e.jsxs(he,{className:"flex justify-between",children:[e.jsxs(C,{variant:"destructive",size:"sm",onClick:F,children:[e.jsx(os,{className:"mr-2 h-4 w-4"}),"Delete"]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(C,{variant:"outline",onClick:s,children:"Cancel"}),e.jsx(C,{onClick:E,children:"Save"})]})]})]}),c&&e.jsx(Hs,{host:a,media:t,onClose:()=>y(!1),onSaved:()=>s()})]})}function Bs({tags:a,activeTag:t,onTagChange:s}){return a.length===0?null:e.jsxs("div",{className:"mb-4 flex flex-wrap items-center gap-1.5",children:[a.map(l=>e.jsx(ct,{variant:t===l?"default":"secondary",className:"cursor-pointer select-none",onClick:()=>s(t===l?void 0:l),children:l},l)),t&&e.jsxs(C,{variant:"ghost",size:"sm",className:"h-6 px-2 text-xs",onClick:()=>s(void 0),children:[e.jsx(xe,{className:"mr-1 h-3 w-3"}),"Clear"]})]})}function Ee({id:a,children:t}){const{setNodeRef:s,isOver:l}=Zt({id:a,data:{type:"folder"}});return e.jsx("div",{ref:s,children:t(l)})}function Ks({host:a,selectedFolderId:t,onSelect:s}){const{data:l}=Ge(a),n=Mt(a),r=It(a),u=Tt(a),[h,o]=x.useState(!1),[i,p]=x.useState(""),[m,w]=x.useState(null),[c,y]=x.useState(""),[d,j]=x.useState(null),v=x.useRef(null),_=x.useRef(null),R=l?.items??[];x.useEffect(()=>{h&&v.current?.focus()},[h]),x.useEffect(()=>{m&&_.current?.focus()},[m]);async function I(){const g=i.trim();if(!g){o(!1),p("");return}try{await n.mutateAsync(g),S.success("Folder created")}catch(A){S.error("Failed to create folder",{description:A instanceof Error?A.message:void 0})}o(!1),p("")}async function E(g){const A=c.trim();if(!A){w(null);return}try{await r.mutateAsync({folderId:g,name:A}),S.success("Folder renamed")}catch($){S.error("Failed to rename folder",{description:$ instanceof Error?$.message:void 0})}w(null)}async function F(){if(d){try{await u.mutateAsync(d.folderId),S.success("Folder deleted"),t===d.folderId&&s(null)}catch(g){S.error("Failed to delete folder",{description:g instanceof Error?g.message:void 0})}j(null)}}return e.jsxs("div",{className:"flex w-48 shrink-0 flex-col border-r",children:[e.jsxs("div",{className:"flex items-center justify-between border-b px-3 py-2",children:[e.jsx("span",{className:"text-sm font-medium",children:"Folders"}),e.jsx(C,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0",onClick:()=>o(!0),children:e.jsx(cs,{className:"h-4 w-4"})})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto py-1",children:[e.jsx(Ee,{id:"all-media",children:g=>e.jsx("button",{className:P("flex w-full items-center justify-between px-3 py-1.5 text-left text-sm hover:bg-accent/50",t===null&&"bg-accent font-medium",g&&"ring-2 ring-primary bg-primary/10"),onClick:()=>s(null),children:e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(ue,{className:"h-4 w-4"}),"All Media"]})})}),R.map(g=>e.jsx(Ee,{id:g.folderId,children:A=>e.jsx("div",{className:P("group flex w-full items-center justify-between px-3 py-1.5 text-sm hover:bg-accent/50",t===g.folderId&&"bg-accent font-medium",A&&"ring-2 ring-primary bg-primary/10"),children:m===g.folderId?e.jsx(K,{ref:_,value:c,onChange:$=>y($.target.value),onKeyDown:$=>{$.key==="Enter"&&E(g.folderId),$.key==="Escape"&&w(null)},onBlur:()=>E(g.folderId),className:"h-6 text-sm"}):e.jsxs(e.Fragment,{children:[e.jsxs("button",{className:"flex flex-1 items-center gap-2 text-left",onClick:()=>s(g.folderId),children:[e.jsx(ue,{className:"h-4 w-4 shrink-0"}),e.jsx("span",{className:"truncate",children:g.name})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"text-muted-foreground text-xs",children:g.count}),e.jsxs(Ft,{children:[e.jsx(Pt,{asChild:!0,children:e.jsx(C,{variant:"ghost",size:"sm",className:"h-5 w-5 p-0 opacity-0 group-hover:opacity-100",children:e.jsx(_t,{className:"h-3.5 w-3.5"})})}),e.jsxs(Ut,{align:"end",children:[e.jsx(We,{onClick:()=>{w(g.folderId),y(g.name)},children:"Rename"}),e.jsx(We,{disabled:g.count>0,onClick:()=>j(g),children:"Delete"})]})]})]})]})})},g.folderId)),e.jsx(Ee,{id:"unfiled",children:g=>e.jsx("button",{className:P("flex w-full items-center justify-between px-3 py-1.5 text-left text-sm hover:bg-accent/50",t==="unfiled"&&"bg-accent font-medium",g&&"ring-2 ring-primary bg-primary/10"),onClick:()=>s("unfiled"),children:e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(ue,{className:"h-4 w-4"}),"Unfiled"]})})}),h&&e.jsx("div",{className:"px-3 py-1.5",children:e.jsx(K,{ref:v,value:i,onChange:g=>p(g.target.value),onKeyDown:g=>{g.key==="Enter"&&I(),g.key==="Escape"&&(o(!1),p(""))},onBlur:I,placeholder:"Folder name...",className:"h-7 text-sm"})})]}),e.jsx(Ze,{open:!!d,onOpenChange:()=>j(null),children:e.jsxs(Je,{children:[e.jsxs(et,{children:[e.jsx(tt,{children:"Delete folder?"}),e.jsxs(st,{children:["This will delete the folder “",d?.name,"”. Media items in this folder will become unfiled."]})]}),e.jsxs(at,{children:[e.jsx(nt,{children:"Cancel"}),e.jsx(rt,{onClick:F,children:"Delete"})]})]})})]})}function Ws({selectedCount:a,folders:t,onDelete:s,onMove:l,onAddTags:n,onRemoveTags:r,onClear:u,isPending:h}){const[o,i]=x.useState(null),[p,m]=x.useState(""),[w,c]=x.useState([]);function y(){i(null),m(""),c([])}return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"mb-4 flex items-center gap-3 rounded-md border bg-muted/50 px-4 py-2",children:[e.jsxs("span",{className:"text-sm font-medium",children:[a," selected"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(C,{size:"sm",variant:"destructive",onClick:()=>i("delete"),disabled:h,children:"Delete"}),e.jsx(C,{size:"sm",variant:"outline",onClick:()=>i("move"),disabled:h,children:"Move to…"}),e.jsx(C,{size:"sm",variant:"outline",onClick:()=>i("addTags"),disabled:h,children:"Add tags"}),e.jsx(C,{size:"sm",variant:"outline",onClick:()=>i("removeTags"),disabled:h,children:"Remove tags"})]}),e.jsx(C,{size:"sm",variant:"ghost",onClick:u,className:"ml-auto",disabled:h,children:e.jsx(xe,{className:"h-4 w-4"})})]}),e.jsx(ie,{open:o==="delete",onOpenChange:d=>!d&&y(),children:e.jsxs(le,{children:[e.jsxs(oe,{children:[e.jsxs(ce,{children:["Delete ",a," item",a!==1?"s":"","?"]}),e.jsx(de,{children:"This action cannot be undone. The selected media items will be permanently deleted."})]}),e.jsxs(he,{children:[e.jsx(C,{variant:"outline",onClick:y,children:"Cancel"}),e.jsxs(C,{variant:"destructive",onClick:async()=>{y(),await s()},disabled:h,children:[h&&e.jsx(ee,{className:"mr-1 h-3 w-3 animate-spin"}),"Delete"]})]})]})}),e.jsx(ie,{open:o==="move",onOpenChange:d=>!d&&y(),children:e.jsxs(le,{children:[e.jsxs(oe,{children:[e.jsxs(ce,{children:["Move ",a," item",a!==1?"s":""]}),e.jsx(de,{children:"Choose a destination folder."})]}),e.jsxs(pe,{value:p,onValueChange:m,children:[e.jsx(ge,{children:e.jsx(fe,{placeholder:"Select folder..."})}),e.jsxs(we,{children:[e.jsx(te,{value:"__unfiled__",children:"Unfiled"}),t.map(d=>e.jsx(te,{value:d.folderId,children:d.name},d.folderId))]})]}),e.jsxs(he,{children:[e.jsx(C,{variant:"outline",onClick:y,children:"Cancel"}),e.jsxs(C,{onClick:async()=>{const d=p==="__unfiled__"?"":p;y(),await l(d)},disabled:!p||h,children:[h&&e.jsx(ee,{className:"mr-1 h-3 w-3 animate-spin"}),"Move"]})]})]})}),e.jsx(ie,{open:o==="addTags",onOpenChange:d=>!d&&y(),children:e.jsxs(le,{children:[e.jsxs(oe,{children:[e.jsxs(ce,{children:["Add tags to ",a," item",a!==1?"s":""]}),e.jsx(de,{className:"sr-only",children:"Select tags to add to the selected items"})]}),e.jsx(Fe,{tags:w,onChange:c,placeholder:"Add tags..."}),e.jsxs(he,{children:[e.jsx(C,{variant:"outline",onClick:y,children:"Cancel"}),e.jsxs(C,{onClick:async()=>{const d=[...w];y(),await n(d)},disabled:w.length===0||h,children:[h&&e.jsx(ee,{className:"mr-1 h-3 w-3 animate-spin"}),"Add"]})]})]})}),e.jsx(ie,{open:o==="removeTags",onOpenChange:d=>!d&&y(),children:e.jsxs(le,{children:[e.jsxs(oe,{children:[e.jsxs(ce,{children:["Remove tags from ",a," item",a!==1?"s":""]}),e.jsx(de,{className:"sr-only",children:"Select tags to remove from the selected items"})]}),e.jsx(Fe,{tags:w,onChange:c,placeholder:"Tags to remove..."}),e.jsxs(he,{children:[e.jsx(C,{variant:"outline",onClick:y,children:"Cancel"}),e.jsxs(C,{onClick:async()=>{const d=[...w];y(),await r(d)},disabled:w.length===0||h,children:[h&&e.jsx(ee,{className:"mr-1 h-3 w-3 animate-spin"}),"Remove"]})]})]})})]})}function Vs({onFiles:a,children:t}){const[s,l]=x.useState(!1),n=x.useRef(0),r=x.useCallback(i=>{i.preventDefault(),i.dataTransfer.types.includes("Files")&&(n.current++,l(!0))},[]),u=x.useCallback(i=>{i.preventDefault(),n.current--,n.current===0&&l(!1)},[]),h=x.useCallback(i=>{i.preventDefault(),i.dataTransfer.dropEffect="copy"},[]),o=x.useCallback(i=>{i.preventDefault(),n.current=0,l(!1);const p=Array.from(i.dataTransfer.files);p.length>0&&a(p)},[a]);return e.jsxs("div",{className:"relative flex-1",onDragEnter:r,onDragLeave:u,onDragOver:h,onDrop:o,children:[t,s&&e.jsx("div",{className:"absolute inset-0 z-40 flex items-center justify-center rounded-lg border-2 border-dashed border-primary bg-primary/5",children:e.jsxs("div",{className:"flex flex-col items-center gap-2 rounded-lg bg-background/90 px-6 py-4 shadow-lg",children:[e.jsx(ye,{className:"h-8 w-8 text-primary"}),e.jsx("p",{className:"text-lg font-medium",children:"Drop files to upload"}),e.jsx("p",{className:"text-muted-foreground text-sm",children:"Files will be uploaded to the current folder"})]})})]})}function qs({queue:a}){const{items:t,retry:s,dismiss:l,clearCompleted:n}=a,[r,u]=x.useState(!1),h=t.filter(c=>c.status==="uploading").length,o=t.filter(c=>c.status==="pending").length,i=t.filter(c=>c.status==="complete").length,p=t.filter(c=>c.status==="error").length,m=h===0&&o===0;if(x.useEffect(()=>{if(m&&t.length>0){const c=setTimeout(()=>u(!0),2e3);return()=>clearTimeout(c)}},[m,t.length]),t.length===0)return null;const w=m?`${i} uploaded${p?`, ${p} failed`:""}`:`Uploading ${h+o} file${h+o!==1?"s":""}`;return e.jsxs("div",{className:"fixed bottom-4 right-4 z-50 w-80 rounded-lg border bg-background shadow-lg",children:[e.jsxs("div",{className:"flex items-center justify-between border-b px-3 py-2",children:[e.jsx("span",{className:"text-sm font-medium",children:w}),e.jsxs("div",{className:"flex items-center gap-1",children:[m&&e.jsx(C,{variant:"ghost",size:"sm",className:"h-6 px-2 text-xs",onClick:n,children:"Clear"}),e.jsx(C,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0",onClick:()=>u(!r),children:r?e.jsx(Xt,{className:"h-4 w-4"}):e.jsx(Yt,{className:"h-4 w-4"})})]})]}),!r&&e.jsx("div",{className:"max-h-60 overflow-y-auto",children:t.map(c=>e.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 text-sm",children:[c.status==="uploading"&&e.jsx(ee,{className:"h-4 w-4 shrink-0 animate-spin"}),c.status==="complete"&&e.jsx(ds,{className:"h-4 w-4 shrink-0 text-green-500"}),c.status==="error"&&e.jsx(xe,{className:"h-4 w-4 shrink-0 text-destructive"}),c.status==="pending"&&e.jsx("div",{className:"h-4 w-4 shrink-0"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"truncate",children:c.file.name}),c.status==="uploading"&&e.jsx("div",{className:"bg-muted mt-0.5 h-1 w-full rounded-full",children:e.jsx("div",{className:"bg-primary h-full rounded-full transition-all",style:{width:`${c.progress}%`}})}),c.status==="error"&&e.jsx("p",{className:"text-destructive truncate text-xs",children:c.error})]}),c.status==="error"&&e.jsx(C,{variant:"ghost",size:"sm",className:"h-6 w-6 shrink-0 p-0",onClick:()=>s(c.id),children:e.jsx(Is,{className:"h-3 w-3"})}),(c.status==="complete"||c.status==="error")&&e.jsx(C,{variant:"ghost",size:"sm",className:"h-6 w-6 shrink-0 p-0",onClick:()=>l(c.id),children:e.jsx(xe,{className:"h-3 w-3"})})]},c.id))})]})}const Qs=3;let Gs=0;function Zs(a,t){const[s,l]=x.useState([]),n=Rt(a),r=At(a),u=x.useRef(0),h=x.useRef(s);h.current=s;const o=x.useRef(new Map),i=x.useCallback(async d=>{u.current++,l(j=>j.map(v=>v.id===d.id?{...v,status:"uploading",progress:0}:v));try{const{uploadUrl:j,mediaId:v}=await n.mutateAsync({filename:d.file.name,contentType:d.file.type,size:d.file.size});await new Promise((_,R)=>{const I=new XMLHttpRequest;o.current.set(d.id,I),I.upload.onprogress=E=>{if(E.lengthComputable){const F=Math.round(E.loaded/E.total*100);l(g=>g.map(A=>A.id===d.id?{...A,progress:F}:A))}},I.onload=()=>{o.current.delete(d.id),I.status>=200&&I.status<300?_():R(new Error(`Upload failed: ${I.status}`))},I.onerror=()=>{o.current.delete(d.id),R(new Error("Network error"))},I.onabort=()=>{o.current.delete(d.id),R(new Error("Upload aborted"))},I.open("PUT",j),I.setRequestHeader("Content-Type",d.file.type),I.send(d.file)}),await r.mutateAsync({mediaId:v,filename:d.file.name,folderId:d.folderId}),l(_=>_.map(R=>R.id===d.id?{...R,status:"complete",progress:100}:R))}catch(j){l(v=>v.map(_=>_.id===d.id?{..._,status:"error",error:j instanceof Error?j.message:"Upload failed"}:_))}finally{u.current--}},[n,r]),p=x.useRef(i);p.current=i,x.useEffect(()=>{const d=s.filter(v=>v.status==="pending"),j=Qs-u.current;for(let v=0;v<Math.min(d.length,j);v++)p.current(d[v])},[s]),x.useEffect(()=>{const d=o.current;return()=>{d.forEach(j=>j.abort())}},[]);const m=x.useCallback(d=>{const j=Array.from(d).map(v=>({id:`upload-${Gs++}`,file:v,folderId:t||void 0,status:"pending",progress:0}));l(v=>[...v,...j])},[t]),w=x.useCallback(d=>{l(j=>j.map(v=>v.id===d?{...v,status:"pending",progress:0,error:void 0}:v))},[]),c=x.useCallback(d=>{l(j=>j.filter(v=>v.id!==d))},[]),y=x.useCallback(()=>{l(d=>d.filter(j=>j.status!=="complete"&&j.status!=="error"))},[]);return{items:s,addFiles:m,retry:w,dismiss:c,clearCompleted:y}}function Js({items:a,currentIndex:t,onClose:s,onNavigate:l}){const n=a[t],r=t>0,u=t<a.length-1,h=x.useCallback(o=>{o.key==="Escape"?s():o.key==="ArrowLeft"&&r?l(t-1):o.key==="ArrowRight"&&u&&l(t+1)},[s,l,t,r,u]);return x.useEffect(()=>(document.addEventListener("keydown",h),document.body.style.overflow="hidden",()=>{document.removeEventListener("keydown",h),document.body.style.overflow=""}),[h]),n?e.jsxs("div",{className:"fixed inset-0 z-50 flex flex-col bg-black/90",onClick:s,children:[e.jsxs("div",{className:"flex items-center justify-between px-4 py-3 text-white",onClick:o=>o.stopPropagation(),children:[e.jsxs("div",{className:"text-sm",children:[e.jsx("span",{className:"font-medium",children:n.filename}),e.jsxs("span",{className:"ml-3 opacity-70",children:[n.width&&n.height&&`${n.width}×${n.height} · `,je(n.size)]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("span",{className:"text-sm opacity-70",children:[t+1," / ",a.length]}),e.jsx(C,{variant:"ghost",size:"icon",className:"text-white hover:bg-white/20",onClick:s,children:e.jsx(xe,{className:"h-5 w-5"})})]})]}),e.jsxs("div",{className:"relative flex flex-1 items-center justify-center px-16",onClick:o=>o.stopPropagation(),children:[e.jsx("img",{src:W(n.url),alt:n.alt||n.filename,className:"max-h-full max-w-full object-contain"}),r&&e.jsx(C,{variant:"ghost",size:"icon",className:"absolute left-4 top-1/2 -translate-y-1/2 text-white hover:bg-white/20",onClick:()=>l(t-1),children:e.jsx(us,{className:"h-8 w-8"})}),u&&e.jsx(C,{variant:"ghost",size:"icon",className:"absolute right-4 top-1/2 -translate-y-1/2 text-white hover:bg-white/20",onClick:()=>l(t+1),children:e.jsx(Jt,{className:"h-8 w-8"})})]})]}):null}function ea({open:a,duplicates:t,fileCount:s,onContinue:l,onCancel:n}){return e.jsx(Ze,{open:a,onOpenChange:r=>!r&&n(),children:e.jsxs(Je,{children:[e.jsxs(et,{children:[e.jsx(tt,{children:"Possible duplicates found"}),e.jsx(st,{children:s===1?"A file with the same name and size already exists:":`${t.length} of ${s} files may already exist:`})]}),e.jsx("div",{className:"max-h-48 space-y-2 overflow-y-auto",children:t.map(r=>e.jsxs("div",{className:"flex items-center gap-3 rounded-md border p-2",children:[r.mimeType.startsWith("image/")&&r.mimeType!=="image/svg+xml"?e.jsx("img",{src:W(r.urls?.thumb_sm??r.url),alt:r.filename,className:"h-10 w-10 rounded object-cover"}):e.jsx("div",{className:"flex h-10 w-10 items-center justify-center",children:e.jsx(Me,{mimeType:r.mimeType,className:"h-6 w-6"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"truncate text-sm font-medium",children:r.filename}),e.jsxs("p",{className:"text-muted-foreground text-xs",children:[je(r.size)," ·"," ",Pe(r.uploadedAt)]})]})]},r.mediaId))}),e.jsxs(at,{children:[e.jsx(nt,{onClick:n,children:"Cancel"}),e.jsx(rt,{onClick:l,children:"Upload Anyway"})]})]})})}function ta(a){const[t,s]=x.useState(()=>{try{const n=localStorage.getItem(`viewMode:${a}`);if(n==="grid"||n==="list")return n}catch{}return"grid"}),l=x.useCallback(n=>{s(n);try{localStorage.setItem(`viewMode:${a}`,n)}catch{}},[a]);return[t,l]}const sa=({activatorEvent:a,draggingNodeRect:t,transform:s})=>{if(a&&t){const l=a;if(l.clientX!==void 0)return{...s,x:s.x+l.clientX-t.left-t.width/2,y:s.y+l.clientY-t.top-t.height/2}}return s},aa=[{value:"date_desc",label:"Newest first"},{value:"date_asc",label:"Oldest first"},{value:"name_asc",label:"Name A-Z"},{value:"name_desc",label:"Name Z-A"},{value:"size_desc",label:"Size (largest)"},{value:"size_asc",label:"Size (smallest)"}];function na({item:a,selected:t,onToggle:s,onClick:l,folderName:n,onLightbox:r}){const{attributes:u,listeners:h,setNodeRef:o,isDragging:i}=lt({id:a.mediaId,data:{type:"media",mediaId:a.mediaId}}),p=a.mimeType.startsWith("image/")&&a.mimeType!=="image/svg+xml";function m(w){w.stopPropagation(),navigator.clipboard.writeText(W(a.url)),S.success("URL copied to clipboard")}return e.jsx(Lt,{ref:o,...u,...h,className:P("group relative cursor-pointer overflow-hidden",i&&"opacity-50",t&&"ring-2 ring-primary"),onClick:l,children:e.jsxs(Ht,{className:"p-0",children:[e.jsx("div",{className:P("absolute left-2 top-2 z-10 opacity-0 group-hover:opacity-100",t&&"opacity-100"),onPointerDown:w=>w.stopPropagation(),onClick:w=>w.stopPropagation(),children:e.jsx(Se,{checked:t,onCheckedChange:s,"aria-label":`Select ${a.filename}`})}),e.jsxs("div",{className:"absolute right-2 top-2 z-10 flex gap-1 opacity-0 group-hover:opacity-100",onPointerDown:w=>w.stopPropagation(),onClick:w=>w.stopPropagation(),children:[e.jsx(be,{children:e.jsxs(Ce,{children:[e.jsx(Ne,{asChild:!0,children:e.jsx("button",{className:"rounded bg-black/50 p-1 text-white hover:bg-black/70",onClick:m,children:e.jsx(Oe,{className:"h-3.5 w-3.5"})})}),e.jsx(ke,{children:"Copy URL"})]})}),p&&r&&e.jsx(be,{children:e.jsxs(Ce,{children:[e.jsx(Ne,{asChild:!0,children:e.jsx("button",{className:"rounded bg-black/50 p-1 text-white hover:bg-black/70",onClick:w=>{w.stopPropagation(),r()},children:e.jsx(ks,{className:"h-3.5 w-3.5"})})}),e.jsx(ke,{children:"View full size"})]})})]}),p?e.jsx("div",{className:"bg-muted flex aspect-square items-center justify-center",children:e.jsx("img",{src:W(a.urls?.thumb_md??a.url),alt:a.alt||a.filename,className:"h-full w-full object-cover"})}):e.jsx("div",{className:"bg-muted flex aspect-square items-center justify-center",children:e.jsx(Me,{mimeType:a.mimeType,className:"h-12 w-12"})}),e.jsxs("div",{className:"p-2",children:[e.jsx("p",{className:"truncate text-sm font-medium",children:a.filename}),n&&e.jsxs("div",{className:"flex items-center gap-1 text-muted-foreground",children:[e.jsx(ue,{className:"h-3 w-3"}),e.jsx("span",{className:"truncate text-xs",children:n})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-muted-foreground text-xs",children:je(a.size)}),e.jsx(be,{children:e.jsxs(Ce,{children:[e.jsx(Ne,{asChild:!0,children:e.jsx("span",{className:"text-muted-foreground text-xs",children:Pe(a.uploadedAt)})}),e.jsx(ke,{children:Ue(a.uploadedAt)})]})})]}),a.tags.length>0&&e.jsxs("div",{className:"mt-1 flex flex-wrap gap-1",children:[a.tags.slice(0,3).map(w=>e.jsx("span",{className:"bg-muted text-muted-foreground rounded px-1 py-0.5 text-[10px]",children:w},w)),a.tags.length>3&&e.jsxs("span",{className:"text-muted-foreground text-[10px]",children:["+",a.tags.length-3]})]})]})]})})}function Ca(){const{host:a}=bt(),[t,s]=ta("media"),[l,n]=x.useState("date_desc"),[r,u]=x.useState(""),[h,o]=x.useState(""),[i,p]=x.useState(null),[m,w]=x.useState(null),[c,y]=x.useState(void 0),[d,j]=x.useState(new Set),[v,_]=x.useState(null),[R,I]=x.useState(null),[E,F]=x.useState(null),[g,A]=x.useState([]),$=x.useRef(null),me=Zs(a,m&&m!=="unfiled"?m:void 0),V=zt(a),Ie=$t(a),Te=es(ts(ns,{activationConstraint:{distance:8}}));x.useEffect(()=>{const f=setTimeout(()=>{o(N=>{const M=r;return N!==M&&j(new Set),M})},300);return()=>clearTimeout(f)},[r]);const b=m===null?void 0:m==="unfiled"?"":m,{data:k,isLoading:q}=Et(a,{sort:l,q:h||void 0,folderId:b,tag:c}),{data:J}=Ge(a),B=x.useMemo(()=>J?.items??[],[J?.items]),Le=x.useMemo(()=>{const f=new Map;for(const N of B)f.set(N.folderId,N.name);return f},[B]),ve=x.useMemo(()=>(k?.items??[]).filter(f=>f.mimeType.startsWith("image/")&&f.mimeType!=="image/svg+xml"),[k?.items]),_e=x.useMemo(()=>{const f=new Map;return ve.forEach((N,M)=>f.set(N.mediaId,M)),f},[ve]),{allTags:ht,allUserTags:ut}=x.useMemo(()=>{const f=k?.items??[],N=new Set,M=new Set;for(const z of f){for(const L of z.tags)N.add(L);for(const L of z.userTags??[])M.add(L)}return{allTags:Array.from(N).sort(),allUserTags:Array.from(M).sort()}},[k?.items]),Re=k?.items.map(f=>f.mediaId)??[],Ae=Re.length>0&&Re.every(f=>d.has(f));function He(f){j(N=>{const M=new Set(N);return M.has(f)?M.delete(f):M.add(f),M})}function Xe(){j(Ae?new Set:new Set(Re))}async function mt(){const f=[...d],M=(await V.mutateAsync({mediaIds:f,action:"delete"})).failed.length;M?S.error(`${M} of ${f.length} failed to delete`):S.success(`${f.length} item(s) deleted`),j(new Set)}async function xt(f){const N=[...d],z=(await V.mutateAsync({mediaIds:N,action:"move",folderId:f})).failed.length;z?S.error(`${z} of ${N.length} failed to move`):S.success(`${N.length} item(s) moved`),j(new Set)}async function pt(f){const N=[...d],z=(await V.mutateAsync({mediaIds:N,action:"addTags",tags:f})).failed.length;z?S.error(`${z} of ${N.length} failed`):S.success(`Tags added to ${N.length} item(s)`),j(new Set)}async function gt(f){const N=[...d],z=(await V.mutateAsync({mediaIds:N,action:"removeTags",tags:f})).failed.length;z?S.error(`${z} of ${N.length} failed`):S.success(`Tags removed from ${N.length} item(s)`),j(new Set)}async function Ye(f){const M=Array.from(f).slice(0,5),z=[];for(const L of M)try{const ze=await Ie.mutateAsync({filename:L.name,size:L.size});z.push(...ze.duplicates)}catch{}z.length>0?(F(f),A(z)):me.addFiles(f)}function ft(f){f.target.files&&Ye(f.target.files),$.current&&($.current.value="")}function wt(f){_(String(f.active.id))}function jt(f){_(null);const{active:N,over:M}=f;if(!M||M.data.current?.type!=="folder")return;const z=M.id==="unfiled"||M.id==="all-media"?"":String(M.id),L=d.has(String(N.id))?[...d]:[String(N.id)];V.mutateAsync({mediaIds:L,action:"move",folderId:z}).then(ze=>{const Ke=ze.failed.length;Ke?S.error(`${Ke} of ${L.length} failed to move`):S.success(`${L.length} item(s) moved`)})}function vt(){_(null)}const Q=v?k?.items.find(f=>f.mediaId===v):null,Be=v&&d.has(v)?d.size:1;return e.jsxs(ss,{sensors:Te,modifiers:[sa],onDragStart:wt,onDragEnd:jt,onDragCancel:vt,children:[e.jsxs("div",{className:"-m-6 flex h-[calc(100vh-3.5rem)]",children:[e.jsx(Ks,{host:a,selectedFolderId:m,onSelect:f=>{w(f),j(new Set)}}),e.jsxs(Vs,{onFiles:f=>Ye(f),children:[e.jsxs("div",{className:"flex-1 overflow-y-auto p-6",children:[e.jsxs("div",{className:"mb-6 flex items-center justify-between",children:[e.jsx("h1",{className:"text-2xl font-semibold",children:"Media"}),e.jsxs("div",{children:[e.jsx("input",{ref:$,type:"file",multiple:!0,className:"hidden",onChange:ft}),e.jsxs(C,{onClick:()=>$.current?.click(),children:[e.jsx(ye,{className:"mr-2 h-4 w-4"}),"Upload"]})]})]}),d.size>0?e.jsx(Ws,{selectedCount:d.size,folders:B,onDelete:mt,onMove:xt,onAddTags:pt,onRemoveTags:gt,onClear:()=>j(new Set),isPending:V.isPending}):e.jsxs("div",{className:"mb-4 flex flex-wrap items-center gap-3",children:[e.jsxs("div",{className:"relative min-w-[200px] max-w-sm flex-1",children:[e.jsx(Ve,{className:"text-muted-foreground absolute left-2.5 top-2.5 h-4 w-4"}),e.jsx(K,{placeholder:"Search media...",value:r,onChange:f=>u(f.target.value),className:"pl-9"})]}),e.jsxs(pe,{value:l,onValueChange:n,children:[e.jsx(ge,{className:"w-[160px]",children:e.jsx(fe,{})}),e.jsx(we,{children:aa.map(f=>e.jsx(te,{value:f.value,children:f.label},f.value))})]}),e.jsxs("div",{className:"flex rounded-md border",children:[e.jsx(C,{variant:t==="grid"?"secondary":"ghost",size:"sm",className:"rounded-r-none px-2",onClick:()=>s("grid"),children:e.jsx(ys,{className:"h-4 w-4"})}),e.jsx(C,{variant:t==="list"?"secondary":"ghost",size:"sm",className:"rounded-l-none px-2",onClick:()=>s("list"),children:e.jsx(Cs,{className:"h-4 w-4"})})]})]}),e.jsx(Bs,{tags:ht,activeTag:c,onTagChange:f=>{y(f),j(new Set)}}),t==="grid"&&(k?.items.length??0)>0&&e.jsxs("div",{className:"mb-2 flex items-center gap-2",children:[e.jsx(Se,{checked:Ae,onCheckedChange:Xe,"aria-label":"Select all"}),e.jsx("span",{className:"text-muted-foreground text-sm",children:d.size>0?`${d.size} of ${k.items.length} selected`:"Select all"})]}),q?e.jsx("div",{className:"grid gap-4 sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-4",children:Array.from({length:8}).map((f,N)=>e.jsx(Ot,{className:"aspect-square"},N))}):k?.items.length?t==="list"?e.jsx(Rs,{items:k.items,host:a,onSelect:p,selectedIds:d,onToggle:He,onToggleAll:Xe,allSelected:Ae,folderMap:m===null?Le:void 0,onLightbox:f=>{const N=_e.get(f.mediaId);N!==void 0&&I(N)}}):e.jsx("div",{className:"grid gap-4 sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-4",children:k.items.map(f=>e.jsx(na,{item:f,selected:d.has(f.mediaId),onToggle:()=>He(f.mediaId),onClick:()=>p(f),folderName:m===null?Le.get(f.folderId??""):void 0,onLightbox:_e.has(f.mediaId)?()=>I(_e.get(f.mediaId)):void 0},f.mediaId))}):e.jsx("div",{className:"flex flex-col items-center justify-center py-16 text-center",children:h||c?e.jsxs(e.Fragment,{children:[e.jsx(Ve,{className:"text-muted-foreground mb-3 h-10 w-10"}),e.jsx("p",{className:"text-muted-foreground text-lg font-medium",children:"No results found"}),e.jsx("p",{className:"text-muted-foreground mt-1 text-sm",children:"Try adjusting your search or filters."})]}):m==="unfiled"?e.jsxs(e.Fragment,{children:[e.jsx(ue,{className:"text-muted-foreground mb-3 h-10 w-10"}),e.jsx("p",{className:"text-muted-foreground text-lg font-medium",children:"No unfiled media"}),e.jsx("p",{className:"text-muted-foreground mt-1 text-sm",children:"All media items are organized in folders."})]}):m?e.jsxs(e.Fragment,{children:[e.jsx(ue,{className:"text-muted-foreground mb-3 h-10 w-10"}),e.jsx("p",{className:"text-muted-foreground text-lg font-medium",children:"This folder is empty"}),e.jsx("p",{className:"text-muted-foreground mt-1 text-sm",children:"Upload files or drag media into this folder."})]}):e.jsxs(e.Fragment,{children:[e.jsx(ye,{className:"text-muted-foreground mb-3 h-10 w-10"}),e.jsx("p",{className:"text-muted-foreground text-lg font-medium",children:"No media yet"}),e.jsx("p",{className:"text-muted-foreground mt-1 text-sm",children:"Upload your first file to get started."}),e.jsxs(C,{className:"mt-4",onClick:()=>$.current?.click(),children:[e.jsx(ye,{className:"mr-2 h-4 w-4"}),"Upload"]})]})}),i&&e.jsx(Ys,{host:a,media:i,onClose:()=>p(null),folders:B,tagSuggestions:ut})]}),e.jsx(qs,{queue:me})]})]}),R!==null&&ve.length>0&&e.jsx(Js,{items:ve,currentIndex:R,host:a,onClose:()=>I(null),onNavigate:I}),e.jsx(ea,{open:g.length>0,host:a,duplicates:g,fileCount:E?Array.from(E).length:0,onContinue:()=>{E&&me.addFiles(E),F(null),A([])},onCancel:()=>{F(null),A([])}}),e.jsx(as,{children:v&&Q&&e.jsxs("div",{className:"flex items-center gap-2 rounded-lg border bg-background p-2 shadow-lg",children:[Q.mimeType.startsWith("image/")&&Q.mimeType!=="image/svg+xml"?e.jsx("img",{src:W(Q.urls?.thumb_sm??Q.url),alt:Q.filename,className:"h-10 w-10 rounded object-cover"}):e.jsx("div",{className:"flex h-10 w-10 items-center justify-center",children:e.jsx(Me,{mimeType:Q.mimeType,className:"h-6 w-6"})}),e.jsx("span",{className:"text-sm font-medium",children:Be>1?`Moving ${Be} items`:Q.filename})]})})]})}export{Ca as MediaPage};
@@ -0,0 +1 @@
1
+ import{j as e,a as Q}from"./tanstack-BO6c-AOu.js";import{u as R,e as G,r as h}from"./react-vendor-DNVhVxD7.js";import{a3 as K,S as b,a7 as Z,a8 as z,a9 as J,a2 as M,L as m,I as c,B as i,a as u,aa as V,D as A,i as P,j as k,k as T,l as F,m as E,s as n}from"./index-Ds50UTAc.js";import{B as W}from"./badge-0Z1nL6DI.js";import{C as g,a as p,b as f,c as S}from"./card-D1-S-QZ6.js";import{f as X}from"./format-CZ9bpk32.js";import"./radix-DQ3amgxj.js";function re(){const{host:a}=R(),{data:r,isLoading:t}=K(a);return t?e.jsxs("div",{className:"space-y-4",children:[e.jsx(b,{className:"h-8 w-64"}),e.jsx(b,{className:"h-48 w-full"})]}):r?e.jsx(Y,{site:r},r.host):e.jsx("p",{className:"text-muted-foreground",children:"Site not found."})}function Y({site:a}){const r=Q(),t=Z(a.host),x=z(a.host),j=J(a.host),y=G(),C=M()==="admin",v=a.status==="archived",[N,O]=h.useState(a.name),[B,l]=h.useState(!1),[L,d]=h.useState(!1),[D,o]=h.useState("");async function U(s){s.preventDefault();try{await t.mutateAsync({name:N}),n.success("Site updated")}catch(w){n.error("Failed to update site",{description:w instanceof Error?w.message:void 0})}}async function q(){try{await t.mutateAsync({status:"archived"}),n.success("Site archived"),l(!1),y("/sites")}catch(s){n.error("Failed to archive site",{description:s instanceof Error?s.message:void 0})}}async function H(){try{await t.mutateAsync({status:"active"}),n.success("Site unarchived")}catch(s){n.error("Failed to unarchive site",{description:s instanceof Error?s.message:void 0})}}async function I(){try{await x.mutateAsync(),await j.mutateAsync(),await r.invalidateQueries({queryKey:["sites"]}),n.success("Site deleted"),d(!1),o(""),y("/sites")}catch(s){n.error("Failed to delete site",{description:s instanceof Error?s.message:void 0})}}return e.jsxs("div",{className:"mx-auto max-w-2xl",children:[e.jsx("h1",{className:"mb-6 text-2xl font-semibold",children:"Site Settings"}),e.jsxs(g,{children:[e.jsx(p,{children:e.jsx(f,{children:"General"})}),e.jsx(S,{children:e.jsxs("form",{onSubmit:U,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(m,{htmlFor:"name",children:"Site Name"}),e.jsx(c,{id:"name",value:N,onChange:s=>O(s.target.value),required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(m,{children:"Host"}),e.jsx(c,{value:a.host,disabled:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(m,{children:"Status"}),e.jsx("div",{className:"flex items-center gap-2",children:v?e.jsx(W,{variant:"outline",children:"Archived"}):e.jsx(c,{value:a.status,disabled:!0})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(m,{children:"Created"}),e.jsx(c,{value:X(a.createdAt),disabled:!0})]}),e.jsxs(i,{type:"submit",disabled:t.isPending,children:[t.isPending&&e.jsx(u,{className:"mr-2 h-4 w-4 animate-spin"}),"Save"]})]})})]}),C&&e.jsxs(g,{className:"mt-6",children:[e.jsx(p,{children:e.jsx(f,{children:"Site Status"})}),e.jsx(S,{className:"space-y-4",children:v?e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-muted-foreground text-sm",children:"This site is archived. Unarchive it to allow content changes."}),e.jsxs(i,{variant:"outline",onClick:H,disabled:t.isPending,children:[t.isPending&&e.jsx(u,{className:"mr-2 h-4 w-4 animate-spin"}),"Unarchive Site"]})]}):e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-muted-foreground text-sm",children:"Archiving a site makes it read-only. Content cannot be created or modified while archived."}),e.jsxs(i,{variant:"outline",onClick:()=>l(!0),children:[e.jsx(V,{className:"mr-2 h-4 w-4"}),"Archive Site"]}),e.jsx(A,{open:B,onOpenChange:l,children:e.jsxs(P,{children:[e.jsxs(k,{children:[e.jsx(T,{children:"Archive Site"}),e.jsxs(F,{children:["Are you sure you want to archive ",e.jsx("strong",{children:a.host}),"? The site will become read-only."]})]}),e.jsxs(E,{children:[e.jsx(i,{variant:"outline",onClick:()=>l(!1),children:"Cancel"}),e.jsxs(i,{onClick:q,disabled:t.isPending,children:[t.isPending&&e.jsx(u,{className:"mr-2 h-4 w-4 animate-spin"}),"Archive"]})]})]})})]})})]}),C&&v&&e.jsxs(g,{className:"border-destructive mt-6",children:[e.jsx(p,{children:e.jsx(f,{className:"text-destructive",children:"Danger Zone"})}),e.jsxs(S,{className:"space-y-4",children:[e.jsx("p",{className:"text-muted-foreground text-sm",children:"Permanently delete this site and all its content, media, collections, and block types. This action cannot be undone."}),e.jsx(i,{variant:"destructive",onClick:()=>d(!0),children:"Delete Site"}),e.jsx(A,{open:L,onOpenChange:s=>{d(s),s||o("")},children:e.jsxs(P,{children:[e.jsxs(k,{children:[e.jsx(T,{children:"Delete Site"}),e.jsxs(F,{children:["This will permanently delete this site and all its content. Type ",e.jsx("strong",{children:a.host})," to confirm."]})]}),e.jsx(c,{placeholder:a.host,value:D,onChange:s=>o(s.target.value)}),e.jsxs(E,{children:[e.jsx(i,{variant:"outline",onClick:()=>{d(!1),o("")},children:"Cancel"}),e.jsxs(i,{variant:"destructive",onClick:I,disabled:D!==a.host||x.isPending||j.isPending,children:[(x.isPending||j.isPending)&&e.jsx(u,{className:"mr-2 h-4 w-4 animate-spin"}),"Delete Everything"]})]})]})})]})]})]})}export{re as SiteSettingsPage};
@@ -0,0 +1 @@
1
+ import{j as e}from"./tanstack-BO6c-AOu.js";import{r as n,e as H}from"./react-vendor-DNVhVxD7.js";import{b as P,u as B,d as L,e as O,g as E,H as N,D as S,h as D,B as o,U as F,i as I,j as T,k as U,l as M,L as w,I as b,m as R}from"./index-Ds50UTAc.js";import{C as $,a as q,b as z,d as G}from"./card-D1-S-QZ6.js";import{B as J}from"./badge-0Z1nL6DI.js";import{C as K}from"./checkbox-BPqrj_XS.js";import{P as y}from"./plus-BgHSYWJN.js";import"./radix-DQ3amgxj.js";import"./check-BGA0ADyt.js";function ae(){const[t,d]=n.useState(!1),{data:l,isLoading:m}=P(t),c=H(),i=n.useMemo(()=>[...l?.items??[]].sort((s,v)=>(s.name||s.host).localeCompare(v.name||v.host)),[l]),{user:a}=B(),{data:k}=L(),g=a?(k?.superAdminIds??[]).includes(a.sub):!1,h=O(),[f,x]=n.useState(!1),[r,j]=n.useState(""),[u,p]=n.useState("");if(m)return e.jsx(E,{});const C=()=>{r.trim()&&h.mutate({host:r.trim(),name:u.trim()||r.trim()},{onSuccess:()=>{x(!1),j(""),p("")}})};return i.length===0?e.jsxs("div",{className:"flex h-screen flex-col",children:[e.jsx(N,{}),e.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center gap-4",children:[e.jsx("p",{className:"text-muted-foreground",children:"No sites available."}),g&&e.jsxs(S,{open:f,onOpenChange:x,children:[e.jsx(D,{asChild:!0,children:e.jsxs(o,{children:[e.jsx(y,{className:"mr-2 h-4 w-4"}),"Create Site"]})}),e.jsx(A,{newHost:r,setNewHost:j,newName:u,setNewName:p,onSubmit:C,isPending:h.isPending})]})]})]}):e.jsxs("div",{className:"flex h-screen flex-col",children:[e.jsx(N,{}),e.jsxs("div",{className:"flex-1 p-8",children:[e.jsxs("div",{className:"mb-6 flex items-center justify-between",children:[e.jsx("h1",{className:"text-2xl font-semibold",children:"Select a site"}),g&&e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[e.jsx(K,{checked:t,onCheckedChange:s=>d(s===!0)}),"Show archived sites"]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(o,{variant:"outline",onClick:()=>c("/users"),children:[e.jsx(F,{className:"mr-2 h-4 w-4"}),"All Users"]}),e.jsxs(S,{open:f,onOpenChange:x,children:[e.jsx(D,{asChild:!0,children:e.jsxs(o,{children:[e.jsx(y,{className:"mr-2 h-4 w-4"}),"Create Site"]})}),e.jsx(A,{newHost:r,setNewHost:j,newName:u,setNewName:p,onSubmit:C,isPending:h.isPending})]})]})]})]}),e.jsx("div",{className:"grid gap-4 sm:grid-cols-2 lg:grid-cols-3",children:i.map(s=>e.jsx($,{className:"cursor-pointer transition-shadow hover:shadow-md",onClick:()=>c(`/sites/${s.host}/content`),children:e.jsxs(q,{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(z,{children:s.name||s.host}),s.status==="archived"&&e.jsx(J,{variant:"outline",children:"Archived"})]}),e.jsx(G,{children:s.host})]})},s.host))})]})]})}function A({newHost:t,setNewHost:d,newName:l,setNewName:m,onSubmit:c,isPending:i}){return e.jsxs(I,{children:[e.jsxs(T,{children:[e.jsx(U,{children:"Create Site"}),e.jsx(M,{className:"sr-only",children:"Enter details for the new site"})]}),e.jsxs("div",{className:"space-y-4 py-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(w,{htmlFor:"host",children:"Host"}),e.jsx(b,{id:"host",placeholder:"example.com",value:t,onChange:a=>d(a.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(w,{htmlFor:"name",children:"Display Name"}),e.jsx(b,{id:"name",placeholder:"My Site",value:l,onChange:a=>m(a.target.value)})]})]}),e.jsx(R,{children:e.jsx(o,{onClick:c,disabled:!t.trim()||i,children:i?"Creating...":"Create"})})]})}export{ae as SitesPage};
@@ -0,0 +1 @@
1
+ import{j as e}from"./tanstack-BO6c-AOu.js";import{u as p,r as x}from"./react-vendor-DNVhVxD7.js";import{u as b,a as D,b as y}from"./useTags-CYqbj5cK.js";import{I as w,B as c,S as v,s as d,D as N,i as C,j as P,k as S,l as k,m as A}from"./index-Ds50UTAc.js";import{T as E,a as B,b as j,c as m,d as F,e as h}from"./table-B3EHrN_H.js";import{P as H}from"./plus-BgHSYWJN.js";import{T as $}from"./trash-2-Gny2Upn-.js";import"./radix-DQ3amgxj.js";function J(){const{host:t}=p(),{data:s,isLoading:n}=b(t),o=D(t),[r,l]=x.useState(""),[T,u]=x.useState(null);async function f(a){a.preventDefault();const i=r.trim().toLowerCase();if(i)try{await o.mutateAsync(i),l(""),d.success(`Tag "${i}" created`)}catch(g){d.error("Failed to create tag",{description:g instanceof Error?g.message:void 0})}}return e.jsxs("div",{children:[e.jsx("div",{className:"mb-6 flex items-center justify-between",children:e.jsxs("h1",{className:"text-2xl font-semibold",children:["Tags",s?` (${s.length})`:""]})}),e.jsxs("form",{onSubmit:f,className:"mb-6 flex gap-2",children:[e.jsx(w,{value:r,onChange:a=>l(a.target.value),placeholder:"New tag name...",className:"max-w-xs"}),e.jsxs(c,{type:"submit",disabled:o.isPending||!r.trim(),children:[e.jsx(H,{className:"mr-2 h-4 w-4"}),"Add Tag"]})]}),n?e.jsx("div",{className:"space-y-2",children:Array.from({length:3}).map((a,i)=>e.jsx(v,{className:"h-12 w-full"},i))}):s?.length?e.jsxs(E,{children:[e.jsx(B,{children:e.jsxs(j,{children:[e.jsx(m,{children:"Tag"}),e.jsx(m,{children:"Published Content"}),e.jsx(m,{})]})}),e.jsx(F,{children:s.map(a=>e.jsxs(j,{children:[e.jsx(h,{className:"font-medium",children:a.tag}),e.jsx(h,{className:"text-muted-foreground",children:a.count}),e.jsx(h,{children:e.jsx(c,{variant:"ghost",size:"sm",disabled:a.count>0,title:a.count>0?"Cannot delete a tag that is in use":"Delete tag",onClick:()=>u(a.tag),children:e.jsx($,{className:"h-4 w-4"})})})]},a.tag))})]}):e.jsx("p",{className:"text-muted-foreground",children:"No tags yet. Tags are created automatically when you publish content with tags, or you can create them manually above."}),e.jsx(I,{host:t,tag:T,onClose:()=>u(null)})]})}function I({host:t,tag:s,onClose:n}){const o=y(t);async function r(){if(s)try{await o.mutateAsync(s),d.success(`Tag "${s}" deleted`),n()}catch(l){d.error("Failed to delete tag",{description:l instanceof Error?l.message:void 0})}}return e.jsx(N,{open:!!s,onOpenChange:()=>n(),children:e.jsxs(C,{children:[e.jsxs(P,{children:[e.jsx(S,{children:"Delete tag?"}),e.jsxs(k,{children:["This will remove the tag “",s,"” from the tag list. This action cannot be undone."]})]}),e.jsxs(A,{children:[e.jsx(c,{variant:"outline",onClick:n,children:"Cancel"}),e.jsx(c,{variant:"destructive",onClick:r,children:"Delete"})]})]})})}export{J as TagsPage};
@@ -0,0 +1 @@
1
+ import{j as e}from"./tanstack-BO6c-AOu.js";import{r as p}from"./react-vendor-DNVhVxD7.js";import{n as H,u as L,o as P,d as z,p as O,q as _,r as q,H as R,I as G,S as J,B as t,D as g,h as K,i as v,j as A,k as D,l as C,m as y,s as n}from"./index-Ds50UTAc.js";import{C as Q}from"./checkbox-BPqrj_XS.js";import{B as V}from"./badge-0Z1nL6DI.js";import{T as W,a as X,b as N,c as r,d as Y,e as c}from"./table-B3EHrN_H.js";import{T as Z}from"./trash-2-Gny2Upn-.js";import"./radix-DQ3amgxj.js";import"./check-BGA0ADyt.js";const $=[["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M5 5a1 1 0 0 0-1 1v7c0 5 3.5 7.5 7.67 8.94a1 1 0 0 0 .67.01c2.35-.82 4.48-1.97 5.9-3.71",key:"1jlk70"}],["path",{d:"M9.309 3.652A12.252 12.252 0 0 0 11.24 2.28a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1v7a9.784 9.784 0 0 1-.08 1.264",key:"18rp1v"}]],ee=H("shield-off",$);function oe(){const{user:w}=L(),{data:S,isLoading:T}=P(),{data:k}=z(),U=O(),m=_(),h=q(),u=S?.items??[],x=k?.superAdminIds??[],[j,F]=p.useState(""),[E,f]=p.useState(null),[d,o]=p.useState(null),b=j?u.filter(s=>s.email.toLowerCase().includes(j.toLowerCase())):u;async function M(s){try{await m.mutateAsync(s),n.success("User deleted"),f(null)}catch(a){n.error("Failed to delete user",{description:a instanceof Error?a.message:void 0})}}async function I(s){try{await h.mutateAsync(s),n.success("Two-factor authentication disabled"),o(null)}catch(a){n.error("Failed to disable 2FA",{description:a instanceof Error?a.message:void 0})}}async function B(s,a){const l=a?x.filter(i=>i!==s):[...x,s];if(l.length===0){n.error("At least one super admin is required");return}try{await U.mutateAsync({superAdminIds:l}),n.success(a?"Super admin removed":"Super admin added")}catch(i){n.error("Failed to update super admins",{description:i instanceof Error?i.message:void 0})}}return e.jsxs("div",{className:"flex h-screen flex-col",children:[e.jsx(R,{}),e.jsxs("div",{className:"flex-1 p-8",children:[e.jsx("div",{className:"mb-6 flex items-center justify-between",children:e.jsx("h1",{className:"text-2xl font-semibold",children:"All Users"})}),e.jsx("div",{className:"mb-4",children:e.jsx(G,{placeholder:"Search by email...",value:j,onChange:s=>F(s.target.value),className:"max-w-sm"})}),T?e.jsx("div",{className:"space-y-2",children:Array.from({length:5}).map((s,a)=>e.jsx(J,{className:"h-12 w-full"},a))}):b.length===0?e.jsx("p",{className:"text-muted-foreground",children:"No users found."}):e.jsxs(W,{children:[e.jsx(X,{children:e.jsxs(N,{children:[e.jsx(r,{children:"Email"}),e.jsx(r,{children:"Status"}),e.jsx(r,{children:"2FA"}),e.jsx(r,{children:"Super Admin"}),e.jsx(r,{})]})}),e.jsx(Y,{children:b.map(s=>{const a=s.sub===w?.sub,l=x.includes(s.sub);return e.jsxs(N,{children:[e.jsxs(c,{className:"text-sm",children:[s.email,a&&e.jsx("span",{className:"text-muted-foreground ml-2",children:"(you)"})]}),e.jsx(c,{className:"text-sm capitalize",children:s.status}),e.jsx(c,{children:s.mfaEnabled?e.jsx(V,{variant:"outline",className:"border-green-500 text-green-700",children:"Enabled"}):e.jsx("span",{className:"text-muted-foreground",children:"—"})}),e.jsx(c,{children:e.jsx(Q,{checked:l,onCheckedChange:()=>B(s.sub,l)})}),e.jsx(c,{className:"text-right",children:e.jsxs("div",{className:"flex items-center justify-end gap-1",children:[!a&&s.mfaEnabled&&e.jsx(t,{variant:"ghost",size:"sm",title:"Disable 2FA",onClick:()=>o(s.sub),children:e.jsx(ee,{className:"h-4 w-4"})}),!a&&e.jsxs(g,{open:E===s.sub,onOpenChange:i=>f(i?s.sub:null),children:[e.jsx(K,{asChild:!0,children:e.jsx(t,{variant:"ghost",size:"sm",className:"text-destructive",title:"Delete account",children:e.jsx(Z,{className:"h-4 w-4"})})}),e.jsxs(v,{children:[e.jsxs(A,{children:[e.jsx(D,{children:"Delete User Account"}),e.jsx(C,{className:"sr-only",children:"Confirm permanent deletion of this user account"})]}),e.jsxs("p",{className:"text-muted-foreground text-sm",children:["This will permanently delete the account for"," ",e.jsx("strong",{children:s.email}),". They will lose access to all sites."]}),e.jsxs(y,{children:[e.jsx(t,{variant:"outline",onClick:()=>f(null),children:"Cancel"}),e.jsx(t,{variant:"destructive",onClick:()=>M(s.sub),disabled:m.isPending,children:m.isPending?"Deleting...":"Delete Account"})]})]})]})]})})]},s.sub)})})]}),e.jsx(g,{open:d!==null,onOpenChange:s=>{s||o(null)},children:e.jsxs(v,{children:[e.jsxs(A,{children:[e.jsx(D,{children:"Disable Two-Factor Authentication"}),e.jsxs(C,{children:["This will disable 2FA for"," ",e.jsx("strong",{children:u.find(s=>s.sub===d)?.email}),". They will be able to log in with just their password."]})]}),e.jsxs(y,{children:[e.jsx(t,{variant:"outline",onClick:()=>o(null),children:"Cancel"}),e.jsx(t,{variant:"destructive",onClick:()=>{d&&I(d)},disabled:h.isPending,children:h.isPending?"Disabling...":"Disable 2FA"})]})]})})]})]})}export{oe as UsersPage};
@@ -0,0 +1 @@
1
+ import{j as e}from"./tanstack-BO6c-AOu.js";import{u as R,e as $,r as d}from"./react-vendor-DNVhVxD7.js";import{a as U,b as _,c as q,d as z,e as K,f as M}from"./useWebhooks-DXgtQ3aU.js";import{n as V,S as v,L as y,I as Y,B as l,a as G,D as J,h as Q,i as X,j as Z,k as ee,l as se,m as te,s as i}from"./index-Ds50UTAc.js";import{B as C}from"./badge-0Z1nL6DI.js";import{C as j,c as p,a as W,b as N}from"./card-D1-S-QZ6.js";import{T as ae,a as ne,b as T,c as b,d as re,e as f}from"./table-B3EHrN_H.js";import{f as oe}from"./format-CZ9bpk32.js";import{T as ie}from"./trash-2-Gny2Upn-.js";import"./radix-DQ3amgxj.js";const le=[["path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",key:"1ffxy3"}],["path",{d:"m21.854 2.147-10.94 10.939",key:"12cjpa"}]],ce=V("send",le),de=["content.published","content.unpublished","content.deleted"];function ve(){const{host:t,id:a}=R(),n=a==="new",{data:o,isLoading:c}=U(t,n?"":a);return!n&&c?e.jsxs("div",{className:"space-y-4",children:[e.jsx(v,{className:"h-8 w-64"}),e.jsx(v,{className:"h-64 w-full"})]}):n?e.jsx(w,{host:t,isNew:!0}):o?e.jsx(w,{host:t,isNew:!1,webhook:o},o.webhookId):e.jsx("p",{className:"text-muted-foreground",children:"Webhook not found."})}function w({host:t,isNew:a,webhook:n}){const o=$(),c=_(t),h=q(t,n?.webhookId??""),D=z(t,n?.webhookId??""),S=K(t,n?.webhookId??""),{data:u}=M(t,a?"":n?.webhookId??""),[m,E]=d.useState(n?.url??""),[x,I]=d.useState(n?.events??[]),[g,B]=d.useState(null),[F,k]=d.useState(!1);function L(s){I(r=>r.includes(s)?r.filter(O=>O!==s):[...r,s])}async function P(s){s.preventDefault();try{if(a){const r=await c.mutateAsync({url:m,events:x,enabled:!0});B(r.secret??null),i.success("Webhook created"),o(`/sites/${t}/settings/webhooks/${r.webhookId}`,{replace:!0})}else await h.mutateAsync({url:m,events:x,enabled:n?.enabled}),i.success("Webhook updated")}catch(r){i.error(a?"Failed to create":"Failed to update",{description:r instanceof Error?r.message:void 0})}}async function A(){try{await S.mutateAsync(),i.success("Test webhook sent")}catch(s){i.error("Test failed",{description:s instanceof Error?s.message:void 0})}}async function H(){try{await D.mutateAsync(),i.success("Webhook deleted"),o(`/sites/${t}/settings/webhooks`)}catch(s){i.error("Failed to delete",{description:s instanceof Error?s.message:void 0})}}return e.jsxs("div",{className:"mx-auto max-w-2xl space-y-6",children:[e.jsx("h1",{className:"text-2xl font-semibold",children:a?"New Webhook":"Edit Webhook"}),g&&e.jsx(j,{className:"border-yellow-500",children:e.jsxs(p,{className:"pt-6",children:[e.jsx("p",{className:"mb-2 text-sm font-medium",children:"Webhook Secret"}),e.jsx("p",{className:"text-muted-foreground mb-2 text-sm",children:"Save this secret now. You won't see it again."}),e.jsx("code",{className:"bg-muted rounded px-2 py-1 text-sm",children:g})]})}),e.jsxs(j,{children:[e.jsx(W,{children:e.jsx(N,{children:"Webhook Settings"})}),e.jsx(p,{children:e.jsxs("form",{onSubmit:P,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(y,{htmlFor:"url",children:"URL"}),e.jsx(Y,{id:"url",type:"url",value:m,onChange:s=>E(s.target.value),required:!0,placeholder:"https://example.com/webhook"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(y,{children:"Events"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:de.map(s=>e.jsx(C,{variant:x.includes(s)?"default":"outline",className:"cursor-pointer",onClick:()=>L(s),children:s},s))})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(l,{type:"submit",disabled:c.isPending||h.isPending,children:[(c.isPending||h.isPending)&&e.jsx(G,{className:"mr-2 h-4 w-4 animate-spin"}),a?"Create":"Save"]}),!a&&e.jsxs(l,{type:"button",variant:"outline",onClick:A,children:[e.jsx(ce,{className:"mr-2 h-4 w-4"}),"Test"]}),e.jsx(l,{type:"button",variant:"outline",onClick:()=>o(`/sites/${t}/settings/webhooks`),children:"Cancel"})]})]})})]}),!a&&u?.items&&u.items.length>0&&e.jsxs(j,{children:[e.jsx(W,{children:e.jsx(N,{children:"Recent Deliveries"})}),e.jsx(p,{children:e.jsxs(ae,{children:[e.jsx(ne,{children:e.jsxs(T,{children:[e.jsx(b,{children:"Event"}),e.jsx(b,{children:"Status"}),e.jsx(b,{children:"Time"})]})}),e.jsx(re,{children:u.items.map(s=>e.jsxs(T,{children:[e.jsx(f,{children:s.event}),e.jsx(f,{children:e.jsx(C,{variant:s.status==="success"?"default":"destructive",children:s.responseStatus??"Error"})}),e.jsx(f,{className:"text-muted-foreground",children:oe(s.createdAt)})]},s.deliveryId))})]})})]}),!a&&e.jsxs(J,{open:F,onOpenChange:k,children:[e.jsx(Q,{asChild:!0,children:e.jsxs(l,{variant:"destructive",children:[e.jsx(ie,{className:"mr-2 h-4 w-4"}),"Delete Webhook"]})}),e.jsxs(X,{children:[e.jsxs(Z,{children:[e.jsx(ee,{children:"Delete webhook?"}),e.jsx(se,{children:"This action cannot be undone."})]}),e.jsxs(te,{children:[e.jsx(l,{variant:"outline",onClick:()=>k(!1),children:"Cancel"}),e.jsx(l,{variant:"destructive",onClick:H,children:"Delete"})]})]})]})]})}export{ve as WebhookEditPage};
@@ -0,0 +1 @@
1
+ import{j as e}from"./tanstack-BO6c-AOu.js";import{u as m,e as x}from"./react-vendor-DNVhVxD7.js";import{u as h}from"./useWebhooks-DXgtQ3aU.js";import{B as j,S as b}from"./index-Ds50UTAc.js";import{B as l}from"./badge-0Z1nL6DI.js";import{T as u,a as f,b as c,c as r,d as p,e as t}from"./table-B3EHrN_H.js";import{P as N}from"./plus-BgHSYWJN.js";import"./radix-DQ3amgxj.js";function W(){const{host:o}=m(),n=x(),{data:i,isLoading:d}=h(o);return e.jsxs("div",{children:[e.jsxs("div",{className:"mb-6 flex items-center justify-between",children:[e.jsx("h1",{className:"text-2xl font-semibold",children:"Webhooks"}),e.jsxs(j,{onClick:()=>n(`/sites/${o}/settings/webhooks/new`),children:[e.jsx(N,{className:"mr-2 h-4 w-4"}),"New Webhook"]})]}),d?e.jsx("div",{className:"space-y-2",children:Array.from({length:3}).map((s,a)=>e.jsx(b,{className:"h-12 w-full"},a))}):i?.items.length?e.jsxs(u,{children:[e.jsx(f,{children:e.jsxs(c,{children:[e.jsx(r,{children:"URL"}),e.jsx(r,{children:"Events"}),e.jsx(r,{children:"Status"})]})}),e.jsx(p,{children:i.items.map(s=>e.jsxs(c,{className:"cursor-pointer",onClick:()=>n(`/sites/${o}/settings/webhooks/${s.webhookId}`),children:[e.jsx(t,{className:"max-w-xs truncate font-mono text-sm",children:s.url}),e.jsx(t,{children:e.jsx("div",{className:"flex flex-wrap gap-1",children:s.events.map(a=>e.jsx(l,{variant:"secondary",className:"text-xs",children:a},a))})}),e.jsx(t,{children:e.jsx(l,{variant:s.enabled?"default":"secondary",children:s.enabled?"Active":"Inactive"})})]},s.webhookId))})]}):e.jsx("p",{className:"text-muted-foreground",children:"No webhooks configured."})]})}export{W as WebhooksPage};
@@ -0,0 +1 @@
1
+ import{j as o}from"./tanstack-BO6c-AOu.js";import"./react-vendor-DNVhVxD7.js";import{x as n,ab as s}from"./index-Ds50UTAc.js";import{S as d}from"./radix-DQ3amgxj.js";const c=s("inline-flex items-center justify-center rounded-full border border-transparent px-2 py-0.5 text-xs font-medium w-fit whitespace-nowrap shrink-0 [&>svg]:size-3 gap-1 [&>svg]:pointer-events-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive transition-[color,box-shadow] overflow-hidden",{variants:{variant:{default:"bg-primary text-primary-foreground [a&]:hover:bg-primary/90",secondary:"bg-secondary text-secondary-foreground [a&]:hover:bg-secondary/90",destructive:"bg-destructive text-white [a&]:hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",outline:"border-border text-foreground [a&]:hover:bg-accent [a&]:hover:text-accent-foreground",ghost:"[a&]:hover:bg-accent [a&]:hover:text-accent-foreground",link:"text-primary underline-offset-4 [a&]:hover:underline"}},defaultVariants:{variant:"default"}});function l({className:r,variant:e="default",asChild:t=!1,...a}){const i=t?d:"span";return o.jsx(i,{"data-slot":"badge","data-variant":e,className:n(c({variant:e}),r),...a})}export{l as B};
@@ -0,0 +1 @@
1
+ import{j as r}from"./tanstack-BO6c-AOu.js";import"./react-vendor-DNVhVxD7.js";import{x as d}from"./index-Ds50UTAc.js";function n({className:a,...t}){return r.jsx("div",{"data-slot":"card",className:d("bg-card text-card-foreground flex flex-col gap-6 rounded-xl border py-6 shadow-sm",a),...t})}function i({className:a,...t}){return r.jsx("div",{"data-slot":"card-header",className:d("@container/card-header grid auto-rows-min grid-rows-[auto_auto] items-start gap-2 px-6 has-data-[slot=card-action]:grid-cols-[1fr_auto] [.border-b]:pb-6",a),...t})}function c({className:a,...t}){return r.jsx("div",{"data-slot":"card-title",className:d("leading-none font-semibold",a),...t})}function l({className:a,...t}){return r.jsx("div",{"data-slot":"card-description",className:d("text-muted-foreground text-sm",a),...t})}function u({className:a,...t}){return r.jsx("div",{"data-slot":"card-content",className:d("px-6",a),...t})}export{n as C,i as a,c as b,u as c,l as d};
@@ -0,0 +1 @@
1
+ import{n as c}from"./index-Ds50UTAc.js";const e=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],t=c("check",e);export{t as C};
@@ -0,0 +1 @@
1
+ import{j as r}from"./tanstack-BO6c-AOu.js";import"./react-vendor-DNVhVxD7.js";import{x as i}from"./index-Ds50UTAc.js";import{C as t}from"./check-BGA0ADyt.js";import{Q as o,U as s}from"./radix-DQ3amgxj.js";function p({className:e,...a}){return r.jsx(o,{"data-slot":"checkbox",className:i("peer border-input dark:bg-input/30 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground dark:data-[state=checked]:bg-primary data-[state=checked]:border-primary focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive size-4 shrink-0 rounded-[4px] border shadow-xs transition-shadow outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50",e),...a,children:r.jsx(s,{"data-slot":"checkbox-indicator",className:"grid place-content-center text-current transition-none",children:r.jsx(t,{className:"size-3.5"})})})}export{p as C};
@@ -0,0 +1 @@
1
+ import{j as w}from"./tanstack-BO6c-AOu.js";import{r as l,b as Re}from"./react-vendor-DNVhVxD7.js";import{x as V}from"./index-Ds50UTAc.js";import{W as je,X as Ae,Y as $e,Z as Pe,_ as L,$ as _,c as Ne,h as Me,O as De,e as _e}from"./radix-DQ3amgxj.js";import{S as Le}from"./search-DIzcfCVh.js";function xt({...e}){return w.jsx(je,{"data-slot":"popover",...e})}function wt({...e}){return w.jsx(Ae,{"data-slot":"popover-trigger",...e})}function Et({className:e,align:r="center",sideOffset:t=4,...i}){return w.jsx($e,{children:w.jsx(Pe,{"data-slot":"popover-content",align:r,sideOffset:t,className:V("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 z-50 w-72 origin-(--radix-popover-content-transform-origin) rounded-md border p-4 shadow-md outline-hidden",e),...i})})}var pe=1,Ve=.9,Oe=.8,ze=.17,te=.1,re=.999,Fe=.9999,Ke=.99,Te=/[\\\/_+.#"@\[\(\{&]/,We=/[\\\/_+.#"@\[\(\{&]/g,qe=/[\s-]/,he=/[\s-]/g;function le(e,r,t,i,a,o,d){if(o===r.length)return a===e.length?pe:Ke;var f=`${a},${o}`;if(d[f]!==void 0)return d[f];for(var p=i.charAt(o),s=t.indexOf(p,a),v=0,h,k,E,I;s>=0;)h=le(e,r,t,i,s+1,o+1,d),h>v&&(s===a?h*=pe:Te.test(e.charAt(s-1))?(h*=Oe,E=e.slice(a,s-1).match(We),E&&a>0&&(h*=Math.pow(re,E.length))):qe.test(e.charAt(s-1))?(h*=Ve,I=e.slice(a,s-1).match(he),I&&a>0&&(h*=Math.pow(re,I.length))):(h*=ze,a>0&&(h*=Math.pow(re,s-a))),e.charAt(s)!==r.charAt(o)&&(h*=Fe)),(h<te&&t.charAt(s-1)===i.charAt(o+1)||i.charAt(o+1)===i.charAt(o)&&t.charAt(s-1)!==i.charAt(o))&&(k=le(e,r,t,i,s+1,o+2,d),k*te>h&&(h=k*te)),h>v&&(v=h),s=t.indexOf(p,s+1);return d[f]=v,v}function ve(e){return e.toLowerCase().replace(he," ")}function Be(e,r,t){return e=t&&t.length>0?`${e+" "+t.join(" ")}`:e,le(e,r,ve(e),ve(r),0,0,{})}var He=Symbol.for("react.lazy"),q=Re[" use ".trim().toString()];function Ye(e){return typeof e=="object"&&e!==null&&"then"in e}function be(e){return e!=null&&typeof e=="object"&&"$$typeof"in e&&e.$$typeof===He&&"_payload"in e&&Ye(e._payload)}function ye(e){const r=Ge(e),t=l.forwardRef((i,a)=>{let{children:o,...d}=i;be(o)&&typeof q=="function"&&(o=q(o._payload));const f=l.Children.toArray(o),p=f.find(Ze);if(p){const s=p.props.children,v=f.map(h=>h===p?l.Children.count(s)>1?l.Children.only(null):l.isValidElement(s)?s.props.children:null:h);return w.jsx(r,{...d,ref:a,children:l.isValidElement(s)?l.cloneElement(s,void 0,v):null})}return w.jsx(r,{...d,ref:a,children:o})});return t.displayName=`${e}.Slot`,t}var St=ye("Slot");function Ge(e){const r=l.forwardRef((t,i)=>{let{children:a,...o}=t;if(be(a)&&typeof q=="function"&&(a=q(a._payload)),l.isValidElement(a)){const d=Je(a),f=Xe(o,a.props);return a.type!==l.Fragment&&(f.ref=i?L(i,d):d),l.cloneElement(a,f)}return l.Children.count(a)>1?l.Children.only(null):null});return r.displayName=`${e}.SlotClone`,r}var Ue=Symbol("radix.slottable");function Ze(e){return l.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===Ue}function Xe(e,r){const t={...r};for(const i in r){const a=e[i],o=r[i];/^on[A-Z]/.test(i)?a&&o?t[i]=(...f)=>{const p=o(...f);return a(...f),p}:a&&(t[i]=a):i==="style"?t[i]={...a,...o}:i==="className"&&(t[i]=[a,o].filter(Boolean).join(" "))}return{...e,...t}}function Je(e){let r=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,t=r&&"isReactWarning"in r&&r.isReactWarning;return t?e.ref:(r=Object.getOwnPropertyDescriptor(e,"ref")?.get,t=r&&"isReactWarning"in r&&r.isReactWarning,t?e.props.ref:e.props.ref||e.ref)}var Qe=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],j=Qe.reduce((e,r)=>{const t=ye(`Primitive.${r}`),i=l.forwardRef((a,o)=>{const{asChild:d,...f}=a,p=d?t:r;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),w.jsx(p,{...f,ref:o})});return i.displayName=`Primitive.${r}`,{...e,[r]:i}},{}),F='[cmdk-group=""]',ne='[cmdk-group-items=""]',et='[cmdk-group-heading=""]',xe='[cmdk-item=""]',ge=`${xe}:not([aria-disabled="true"])`,ae="cmdk-item-select",M="data-value",tt=(e,r,t)=>Be(e,r,t),we=l.createContext(void 0),K=()=>l.useContext(we),Ee=l.createContext(void 0),oe=()=>l.useContext(Ee),Se=l.createContext(void 0),Ce=l.forwardRef((e,r)=>{let t=D(()=>{var n,c;return{search:"",value:(c=(n=e.value)!=null?n:e.defaultValue)!=null?c:"",selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}}}),i=D(()=>new Set),a=D(()=>new Map),o=D(()=>new Map),d=D(()=>new Set),f=ke(e),{label:p,children:s,value:v,onValueChange:h,filter:k,shouldFilter:E,loop:I,disablePointerSelection:H=!1,vimBindings:A=!0,...T}=e,Y=_(),ie=_(),G=_(),$=l.useRef(null),y=ft();P(()=>{if(v!==void 0){let n=v.trim();t.current.value=n,S.emit()}},[v]),P(()=>{y(6,se)},[]);let S=l.useMemo(()=>({subscribe:n=>(d.current.add(n),()=>d.current.delete(n)),snapshot:()=>t.current,setState:(n,c,m)=>{var u,g,b,C;if(!Object.is(t.current[n],c)){if(t.current[n]=c,n==="search")J(),Z(),y(1,X);else if(n==="value"){if(document.activeElement.hasAttribute("cmdk-input")||document.activeElement.hasAttribute("cmdk-root")){let x=document.getElementById(G);x?x.focus():(u=document.getElementById(Y))==null||u.focus()}if(y(7,()=>{var x;t.current.selectedItemId=(x=N())==null?void 0:x.id,S.emit()}),m||y(5,se),((g=f.current)==null?void 0:g.value)!==void 0){let x=c??"";(C=(b=f.current).onValueChange)==null||C.call(b,x);return}}S.emit()}},emit:()=>{d.current.forEach(n=>n())}}),[]),U=l.useMemo(()=>({value:(n,c,m)=>{var u;c!==((u=o.current.get(n))==null?void 0:u.value)&&(o.current.set(n,{value:c,keywords:m}),t.current.filtered.items.set(n,ue(c,m)),y(2,()=>{Z(),S.emit()}))},item:(n,c)=>(i.current.add(n),c&&(a.current.has(c)?a.current.get(c).add(n):a.current.set(c,new Set([n]))),y(3,()=>{J(),Z(),t.current.value||X(),S.emit()}),()=>{o.current.delete(n),i.current.delete(n),t.current.filtered.items.delete(n);let m=N();y(4,()=>{J(),m?.getAttribute("id")===n&&X(),S.emit()})}),group:n=>(a.current.has(n)||a.current.set(n,new Set),()=>{o.current.delete(n),a.current.delete(n)}),filter:()=>f.current.shouldFilter,label:p||e["aria-label"],getDisablePointerSelection:()=>f.current.disablePointerSelection,listId:Y,inputId:G,labelId:ie,listInnerRef:$}),[]);function ue(n,c){var m,u;let g=(u=(m=f.current)==null?void 0:m.filter)!=null?u:tt;return n?g(n,t.current.search,c):0}function Z(){if(!t.current.search||f.current.shouldFilter===!1)return;let n=t.current.filtered.items,c=[];t.current.filtered.groups.forEach(u=>{let g=a.current.get(u),b=0;g.forEach(C=>{let x=n.get(C);b=Math.max(x,b)}),c.push([u,b])});let m=$.current;z().sort((u,g)=>{var b,C;let x=u.getAttribute("id"),W=g.getAttribute("id");return((b=n.get(W))!=null?b:0)-((C=n.get(x))!=null?C:0)}).forEach(u=>{let g=u.closest(ne);g?g.appendChild(u.parentElement===g?u:u.closest(`${ne} > *`)):m.appendChild(u.parentElement===m?u:u.closest(`${ne} > *`))}),c.sort((u,g)=>g[1]-u[1]).forEach(u=>{var g;let b=(g=$.current)==null?void 0:g.querySelector(`${F}[${M}="${encodeURIComponent(u[0])}"]`);b?.parentElement.appendChild(b)})}function X(){let n=z().find(m=>m.getAttribute("aria-disabled")!=="true"),c=n?.getAttribute(M);S.setState("value",c||void 0)}function J(){var n,c,m,u;if(!t.current.search||f.current.shouldFilter===!1){t.current.filtered.count=i.current.size;return}t.current.filtered.groups=new Set;let g=0;for(let b of i.current){let C=(c=(n=o.current.get(b))==null?void 0:n.value)!=null?c:"",x=(u=(m=o.current.get(b))==null?void 0:m.keywords)!=null?u:[],W=ue(C,x);t.current.filtered.items.set(b,W),W>0&&g++}for(let[b,C]of a.current)for(let x of C)if(t.current.filtered.items.get(x)>0){t.current.filtered.groups.add(b);break}t.current.filtered.count=g}function se(){var n,c,m;let u=N();u&&(((n=u.parentElement)==null?void 0:n.firstChild)===u&&((m=(c=u.closest(F))==null?void 0:c.querySelector(et))==null||m.scrollIntoView({block:"nearest"})),u.scrollIntoView({block:"nearest"}))}function N(){var n;return(n=$.current)==null?void 0:n.querySelector(`${xe}[aria-selected="true"]`)}function z(){var n;return Array.from(((n=$.current)==null?void 0:n.querySelectorAll(ge))||[])}function Q(n){let c=z()[n];c&&S.setState("value",c.getAttribute(M))}function ee(n){var c;let m=N(),u=z(),g=u.findIndex(C=>C===m),b=u[g+n];(c=f.current)!=null&&c.loop&&(b=g+n<0?u[u.length-1]:g+n===u.length?u[0]:u[g+n]),b&&S.setState("value",b.getAttribute(M))}function de(n){let c=N(),m=c?.closest(F),u;for(;m&&!u;)m=n>0?dt(m,F):ct(m,F),u=m?.querySelector(ge);u?S.setState("value",u.getAttribute(M)):ee(n)}let ce=()=>Q(z().length-1),fe=n=>{n.preventDefault(),n.metaKey?ce():n.altKey?de(1):ee(1)},me=n=>{n.preventDefault(),n.metaKey?Q(0):n.altKey?de(-1):ee(-1)};return l.createElement(j.div,{ref:r,tabIndex:-1,...T,"cmdk-root":"",onKeyDown:n=>{var c;(c=T.onKeyDown)==null||c.call(T,n);let m=n.nativeEvent.isComposing||n.keyCode===229;if(!(n.defaultPrevented||m))switch(n.key){case"n":case"j":{A&&n.ctrlKey&&fe(n);break}case"ArrowDown":{fe(n);break}case"p":case"k":{A&&n.ctrlKey&&me(n);break}case"ArrowUp":{me(n);break}case"Home":{n.preventDefault(),Q(0);break}case"End":{n.preventDefault(),ce();break}case"Enter":{n.preventDefault();let u=N();if(u){let g=new Event(ae);u.dispatchEvent(g)}}}}},l.createElement("label",{"cmdk-label":"",htmlFor:U.inputId,id:U.labelId,style:pt},p),B(e,n=>l.createElement(Ee.Provider,{value:S},l.createElement(we.Provider,{value:U},n))))}),rt=l.forwardRef((e,r)=>{var t,i;let a=_(),o=l.useRef(null),d=l.useContext(Se),f=K(),p=ke(e),s=(i=(t=p.current)==null?void 0:t.forceMount)!=null?i:d?.forceMount;P(()=>{if(!s)return f.item(a,d?.id)},[s]);let v=Ie(a,o,[e.value,e.children,o],e.keywords),h=oe(),k=R(y=>y.value&&y.value===v.current),E=R(y=>s||f.filter()===!1?!0:y.search?y.filtered.items.get(a)>0:!0);l.useEffect(()=>{let y=o.current;if(!(!y||e.disabled))return y.addEventListener(ae,I),()=>y.removeEventListener(ae,I)},[E,e.onSelect,e.disabled]);function I(){var y,S;H(),(S=(y=p.current).onSelect)==null||S.call(y,v.current)}function H(){h.setState("value",v.current,!0)}if(!E)return null;let{disabled:A,value:T,onSelect:Y,forceMount:ie,keywords:G,...$}=e;return l.createElement(j.div,{ref:L(o,r),...$,id:a,"cmdk-item":"",role:"option","aria-disabled":!!A,"aria-selected":!!k,"data-disabled":!!A,"data-selected":!!k,onPointerMove:A||f.getDisablePointerSelection()?void 0:H,onClick:A?void 0:I},e.children)}),nt=l.forwardRef((e,r)=>{let{heading:t,children:i,forceMount:a,...o}=e,d=_(),f=l.useRef(null),p=l.useRef(null),s=_(),v=K(),h=R(E=>a||v.filter()===!1?!0:E.search?E.filtered.groups.has(d):!0);P(()=>v.group(d),[]),Ie(d,f,[e.value,e.heading,p]);let k=l.useMemo(()=>({id:d,forceMount:a}),[a]);return l.createElement(j.div,{ref:L(f,r),...o,"cmdk-group":"",role:"presentation",hidden:h?void 0:!0},t&&l.createElement("div",{ref:p,"cmdk-group-heading":"","aria-hidden":!0,id:s},t),B(e,E=>l.createElement("div",{"cmdk-group-items":"",role:"group","aria-labelledby":t?s:void 0},l.createElement(Se.Provider,{value:k},E))))}),lt=l.forwardRef((e,r)=>{let{alwaysRender:t,...i}=e,a=l.useRef(null),o=R(d=>!d.search);return!t&&!o?null:l.createElement(j.div,{ref:L(a,r),...i,"cmdk-separator":"",role:"separator"})}),at=l.forwardRef((e,r)=>{let{onValueChange:t,...i}=e,a=e.value!=null,o=oe(),d=R(s=>s.search),f=R(s=>s.selectedItemId),p=K();return l.useEffect(()=>{e.value!=null&&o.setState("search",e.value)},[e.value]),l.createElement(j.input,{ref:r,...i,"cmdk-input":"",autoComplete:"off",autoCorrect:"off",spellCheck:!1,"aria-autocomplete":"list",role:"combobox","aria-expanded":!0,"aria-controls":p.listId,"aria-labelledby":p.labelId,"aria-activedescendant":f,id:p.inputId,type:"text",value:a?e.value:d,onChange:s=>{a||o.setState("search",s.target.value),t?.(s.target.value)}})}),ot=l.forwardRef((e,r)=>{let{children:t,label:i="Suggestions",...a}=e,o=l.useRef(null),d=l.useRef(null),f=R(s=>s.selectedItemId),p=K();return l.useEffect(()=>{if(d.current&&o.current){let s=d.current,v=o.current,h,k=new ResizeObserver(()=>{h=requestAnimationFrame(()=>{let E=s.offsetHeight;v.style.setProperty("--cmdk-list-height",E.toFixed(1)+"px")})});return k.observe(s),()=>{cancelAnimationFrame(h),k.unobserve(s)}}},[]),l.createElement(j.div,{ref:L(o,r),...a,"cmdk-list":"",role:"listbox",tabIndex:-1,"aria-activedescendant":f,"aria-label":i,id:p.listId},B(e,s=>l.createElement("div",{ref:L(d,p.listInnerRef),"cmdk-list-sizer":""},s)))}),it=l.forwardRef((e,r)=>{let{open:t,onOpenChange:i,overlayClassName:a,contentClassName:o,container:d,...f}=e;return l.createElement(Ne,{open:t,onOpenChange:i},l.createElement(Me,{container:d},l.createElement(De,{"cmdk-overlay":"",className:a}),l.createElement(_e,{"aria-label":e.label,"cmdk-dialog":"",className:o},l.createElement(Ce,{ref:r,...f}))))}),ut=l.forwardRef((e,r)=>R(t=>t.filtered.count===0)?l.createElement(j.div,{ref:r,...e,"cmdk-empty":"",role:"presentation"}):null),st=l.forwardRef((e,r)=>{let{progress:t,children:i,label:a="Loading...",...o}=e;return l.createElement(j.div,{ref:r,...o,"cmdk-loading":"",role:"progressbar","aria-valuenow":t,"aria-valuemin":0,"aria-valuemax":100,"aria-label":a},B(e,d=>l.createElement("div",{"aria-hidden":!0},d)))}),O=Object.assign(Ce,{List:ot,Item:rt,Input:at,Group:nt,Separator:lt,Dialog:it,Empty:ut,Loading:st});function dt(e,r){let t=e.nextElementSibling;for(;t;){if(t.matches(r))return t;t=t.nextElementSibling}}function ct(e,r){let t=e.previousElementSibling;for(;t;){if(t.matches(r))return t;t=t.previousElementSibling}}function ke(e){let r=l.useRef(e);return P(()=>{r.current=e}),r}var P=typeof window>"u"?l.useEffect:l.useLayoutEffect;function D(e){let r=l.useRef();return r.current===void 0&&(r.current=e()),r}function R(e){let r=oe(),t=()=>e(r.snapshot());return l.useSyncExternalStore(r.subscribe,t,t)}function Ie(e,r,t,i=[]){let a=l.useRef(),o=K();return P(()=>{var d;let f=(()=>{var s;for(let v of t){if(typeof v=="string")return v.trim();if(typeof v=="object"&&"current"in v)return v.current?(s=v.current.textContent)==null?void 0:s.trim():a.current}})(),p=i.map(s=>s.trim());o.value(e,f,p),(d=r.current)==null||d.setAttribute(M,f),a.current=f}),a}var ft=()=>{let[e,r]=l.useState(),t=D(()=>new Map);return P(()=>{t.current.forEach(i=>i()),t.current=new Map},[e]),(i,a)=>{t.current.set(i,a),r({})}};function mt(e){let r=e.type;return typeof r=="function"?r(e.props):"render"in r?r.render(e.props):e}function B({asChild:e,children:r},t){return e&&l.isValidElement(r)?l.cloneElement(mt(r),{ref:r.ref},t(r.props.children)):t(r)}var pt={position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0"};function Ct({className:e,...r}){return w.jsx(O,{"data-slot":"command",className:V("bg-popover text-popover-foreground flex h-full w-full flex-col overflow-hidden rounded-md",e),...r})}function kt({className:e,...r}){return w.jsxs("div",{"data-slot":"command-input-wrapper",className:"flex h-9 items-center gap-2 border-b px-3",children:[w.jsx(Le,{className:"size-4 shrink-0 opacity-50"}),w.jsx(O.Input,{"data-slot":"command-input",className:V("placeholder:text-muted-foreground flex h-10 w-full rounded-md bg-transparent py-3 text-sm outline-hidden disabled:cursor-not-allowed disabled:opacity-50",e),...r})]})}function It({className:e,...r}){return w.jsx(O.List,{"data-slot":"command-list",className:V("max-h-[300px] scroll-py-1 overflow-x-hidden overflow-y-auto",e),...r})}function Rt({...e}){return w.jsx(O.Empty,{"data-slot":"command-empty",className:"py-6 text-center text-sm",...e})}function jt({className:e,...r}){return w.jsx(O.Group,{"data-slot":"command-group",className:V("text-foreground [&_[cmdk-group-heading]]:text-muted-foreground overflow-hidden p-1 [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium",e),...r})}function At({className:e,...r}){return w.jsx(O.Item,{"data-slot":"command-item",className:V("data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground [&_svg:not([class*='text-'])]:text-muted-foreground relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",e),...r})}export{Ct as C,xt as P,St as S,wt as a,Et as b,kt as c,It as d,Rt as e,jt as f,At as g,j as h};
@@ -0,0 +1 @@
1
+ function u(e,s,t,a){return e?!t||!a||t===a?"published":"published-changes":s?"unpublished":"draft"}function n(e){switch(e){case"draft":return"Publish";case"published":return"";case"published-changes":return"Publish Changes";case"unpublished":return"Republish"}}function r(e){switch(e){case"draft":return{label:"Draft",variant:"secondary"};case"published":return{label:"Published",variant:"default"};case"published-changes":return{label:"Unsaved changes",variant:"outline"};case"unpublished":return{label:"Unpublished",variant:"destructive"}}}export{r as a,n as b,u as g};
@@ -0,0 +1 @@
1
+ import{n as c}from"./index-Ds50UTAc.js";const e=[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]],t=c("copy",e);export{t as C};
@@ -0,0 +1,5 @@
1
+ import{n as Yt}from"./index-Ds50UTAc.js";import{r as l,R as M}from"./react-vendor-DNVhVxD7.js";import{N as we}from"./radix-DQ3amgxj.js";const mn=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],_r=Yt("chevron-right",mn);const yn=[["circle",{cx:"9",cy:"12",r:"1",key:"1vctgf"}],["circle",{cx:"9",cy:"5",r:"1",key:"hp0tcf"}],["circle",{cx:"9",cy:"19",r:"1",key:"fkjjf6"}],["circle",{cx:"15",cy:"12",r:"1",key:"1tmaij"}],["circle",{cx:"15",cy:"5",r:"1",key:"19l28e"}],["circle",{cx:"15",cy:"19",r:"1",key:"f4zoj3"}]],Qr=Yt("grip-vertical",yn);function Zr(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return l.useMemo(()=>r=>{t.forEach(o=>o(r))},t)}const Ye=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function ge(e){const t=Object.prototype.toString.call(e);return t==="[object Window]"||t==="[object global]"}function it(e){return"nodeType"in e}function P(e){var t,n;return e?ge(e)?e:it(e)&&(t=(n=e.ownerDocument)==null?void 0:n.defaultView)!=null?t:window:window}function st(e){const{Document:t}=P(e);return e instanceof t}function Me(e){return ge(e)?!1:e instanceof P(e).HTMLElement}function Kt(e){return e instanceof P(e).SVGElement}function ve(e){return e?ge(e)?e.document:it(e)?st(e)?e:Me(e)||Kt(e)?e.ownerDocument:document:document:document}const G=Ye?l.useLayoutEffect:l.useEffect;function Ke(e){const t=l.useRef(e);return G(()=>{t.current=e}),l.useCallback(function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return t.current==null?void 0:t.current(...r)},[])}function wn(){const e=l.useRef(null),t=l.useCallback((r,o)=>{e.current=setInterval(r,o)},[]),n=l.useCallback(()=>{e.current!==null&&(clearInterval(e.current),e.current=null)},[]);return[t,n]}function Se(e,t){t===void 0&&(t=[e]);const n=l.useRef(e);return G(()=>{n.current!==e&&(n.current=e)},t),n}function Ae(e,t){const n=l.useRef();return l.useMemo(()=>{const r=e(n.current);return n.current=r,r},[...t])}function ze(e){const t=Ke(e),n=l.useRef(null),r=l.useCallback(o=>{o!==n.current&&t?.(o,n.current),n.current=o},[]);return[n,r]}function Be(e){const t=l.useRef();return l.useEffect(()=>{t.current=e},[e]),t.current}let Qe={};function Ue(e,t){return l.useMemo(()=>{if(t)return t;const n=Qe[e]==null?0:Qe[e]+1;return Qe[e]=n,e+"-"+n},[e,t])}function Ut(e){return function(t){for(var n=arguments.length,r=new Array(n>1?n-1:0),o=1;o<n;o++)r[o-1]=arguments[o];return r.reduce((i,a)=>{const s=Object.entries(a);for(const[c,u]of s){const f=i[c];f!=null&&(i[c]=f+e*u)}return i},{...t})}}const he=Ut(1),je=Ut(-1);function xn(e){return"clientX"in e&&"clientY"in e}function at(e){if(!e)return!1;const{KeyboardEvent:t}=P(e.target);return t&&e instanceof t}function Cn(e){if(!e)return!1;const{TouchEvent:t}=P(e.target);return t&&e instanceof t}function Fe(e){if(Cn(e)){if(e.touches&&e.touches.length){const{clientX:t,clientY:n}=e.touches[0];return{x:t,y:n}}else if(e.changedTouches&&e.changedTouches.length){const{clientX:t,clientY:n}=e.changedTouches[0];return{x:t,y:n}}}return xn(e)?{x:e.clientX,y:e.clientY}:null}const Re=Object.freeze({Translate:{toString(e){if(!e)return;const{x:t,y:n}=e;return"translate3d("+(t?Math.round(t):0)+"px, "+(n?Math.round(n):0)+"px, 0)"}},Scale:{toString(e){if(!e)return;const{scaleX:t,scaleY:n}=e;return"scaleX("+t+") scaleY("+n+")"}},Transform:{toString(e){if(e)return[Re.Translate.toString(e),Re.Scale.toString(e)].join(" ")}},Transition:{toString(e){let{property:t,duration:n,easing:r}=e;return t+" "+n+"ms "+r}}}),Ot="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function Dn(e){return e.matches(Ot)?e:e.querySelector(Ot)}const Sn={display:"none"};function Rn(e){let{id:t,value:n}=e;return M.createElement("div",{id:t,style:Sn},n)}function En(e){let{id:t,announcement:n,ariaLiveType:r="assertive"}=e;const o={position:"fixed",top:0,left:0,width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0 0 0 0)",clipPath:"inset(100%)",whiteSpace:"nowrap"};return M.createElement("div",{id:t,style:o,role:"status","aria-live":r,"aria-atomic":!0},n)}function Mn(){const[e,t]=l.useState("");return{announce:l.useCallback(r=>{r!=null&&t(r)},[]),announcement:e}}const Wt=l.createContext(null);function An(e){const t=l.useContext(Wt);l.useEffect(()=>{if(!t)throw new Error("useDndMonitor must be used within a children of <DndContext>");return t(e)},[e,t])}function On(){const[e]=l.useState(()=>new Set),t=l.useCallback(r=>(e.add(r),()=>e.delete(r)),[e]);return[l.useCallback(r=>{let{type:o,event:i}=r;e.forEach(a=>{var s;return(s=a[o])==null?void 0:s.call(a,i)})},[e]),t]}const Nn={draggable:`
2
+ To pick up a draggable item, press the space bar.
3
+ While dragging, use the arrow keys to move the item.
4
+ Press space again to drop the item in its new position, or press escape to cancel.
5
+ `},Tn={onDragStart(e){let{active:t}=e;return"Picked up draggable item "+t.id+"."},onDragOver(e){let{active:t,over:n}=e;return n?"Draggable item "+t.id+" was moved over droppable area "+n.id+".":"Draggable item "+t.id+" is no longer over a droppable area."},onDragEnd(e){let{active:t,over:n}=e;return n?"Draggable item "+t.id+" was dropped over droppable area "+n.id:"Draggable item "+t.id+" was dropped."},onDragCancel(e){let{active:t}=e;return"Dragging was cancelled. Draggable item "+t.id+" was dropped."}};function kn(e){let{announcements:t=Tn,container:n,hiddenTextDescribedById:r,screenReaderInstructions:o=Nn}=e;const{announce:i,announcement:a}=Mn(),s=Ue("DndLiveRegion"),[c,u]=l.useState(!1);if(l.useEffect(()=>{u(!0)},[]),An(l.useMemo(()=>({onDragStart(d){let{active:v}=d;i(t.onDragStart({active:v}))},onDragMove(d){let{active:v,over:h}=d;t.onDragMove&&i(t.onDragMove({active:v,over:h}))},onDragOver(d){let{active:v,over:h}=d;i(t.onDragOver({active:v,over:h}))},onDragEnd(d){let{active:v,over:h}=d;i(t.onDragEnd({active:v,over:h}))},onDragCancel(d){let{active:v,over:h}=d;i(t.onDragCancel({active:v,over:h}))}}),[i,t])),!c)return null;const f=M.createElement(M.Fragment,null,M.createElement(Rn,{id:r,value:o.draggable}),M.createElement(En,{id:s,announcement:a}));return n?we.createPortal(f,n):f}var O;(function(e){e.DragStart="dragStart",e.DragMove="dragMove",e.DragEnd="dragEnd",e.DragCancel="dragCancel",e.DragOver="dragOver",e.RegisterDroppable="registerDroppable",e.SetDroppableDisabled="setDroppableDisabled",e.UnregisterDroppable="unregisterDroppable"})(O||(O={}));function Xe(){}function eo(e,t){return l.useMemo(()=>({sensor:e,options:t??{}}),[e,t])}function to(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return l.useMemo(()=>[...t].filter(r=>r!=null),[...t])}const K=Object.freeze({x:0,y:0});function Ln(e,t){return Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2))}function In(e,t){const n=Fe(e);if(!n)return"0 0";const r={x:(n.x-t.left)/t.width*100,y:(n.y-t.top)/t.height*100};return r.x+"% "+r.y+"%"}function Pn(e,t){let{data:{value:n}}=e,{data:{value:r}}=t;return n-r}function zn(e,t){let{data:{value:n}}=e,{data:{value:r}}=t;return r-n}function Bn(e,t){if(!e||e.length===0)return null;const[n]=e;return n[t]}function Nt(e,t,n){return t===void 0&&(t=e.left),n===void 0&&(n=e.top),{x:t+e.width*.5,y:n+e.height*.5}}const no=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:r}=e;const o=Nt(t,t.left,t.top),i=[];for(const a of r){const{id:s}=a,c=n.get(s);if(c){const u=Ln(Nt(c),o);i.push({id:s,data:{droppableContainer:a,value:u}})}}return i.sort(Pn)};function jn(e,t){const n=Math.max(t.top,e.top),r=Math.max(t.left,e.left),o=Math.min(t.left+t.width,e.left+e.width),i=Math.min(t.top+t.height,e.top+e.height),a=o-r,s=i-n;if(r<o&&n<i){const c=t.width*t.height,u=e.width*e.height,f=a*s,d=f/(c+u-f);return Number(d.toFixed(4))}return 0}const Fn=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:r}=e;const o=[];for(const i of r){const{id:a}=i,s=n.get(a);if(s){const c=jn(s,t);c>0&&o.push({id:a,data:{droppableContainer:i,value:c}})}}return o.sort(zn)};function Xn(e,t,n){return{...e,scaleX:t&&n?t.width/n.width:1,scaleY:t&&n?t.height/n.height:1}}function Ht(e,t){return e&&t?{x:e.left-t.left,y:e.top-t.top}:K}function $n(e){return function(n){for(var r=arguments.length,o=new Array(r>1?r-1:0),i=1;i<r;i++)o[i-1]=arguments[i];return o.reduce((a,s)=>({...a,top:a.top+e*s.y,bottom:a.bottom+e*s.y,left:a.left+e*s.x,right:a.right+e*s.x}),{...n})}}const Yn=$n(1);function Vt(e){if(e.startsWith("matrix3d(")){const t=e.slice(9,-1).split(/, /);return{x:+t[12],y:+t[13],scaleX:+t[0],scaleY:+t[5]}}else if(e.startsWith("matrix(")){const t=e.slice(7,-1).split(/, /);return{x:+t[4],y:+t[5],scaleX:+t[0],scaleY:+t[3]}}return null}function Kn(e,t,n){const r=Vt(t);if(!r)return e;const{scaleX:o,scaleY:i,x:a,y:s}=r,c=e.left-a-(1-o)*parseFloat(n),u=e.top-s-(1-i)*parseFloat(n.slice(n.indexOf(" ")+1)),f=o?e.width/o:e.width,d=i?e.height/i:e.height;return{width:f,height:d,top:u,right:c+f,bottom:u+d,left:c}}const Un={ignoreTransform:!1};function Oe(e,t){t===void 0&&(t=Un);let n=e.getBoundingClientRect();if(t.ignoreTransform){const{transform:u,transformOrigin:f}=P(e).getComputedStyle(e);u&&(n=Kn(n,u,f))}const{top:r,left:o,width:i,height:a,bottom:s,right:c}=n;return{top:r,left:o,width:i,height:a,bottom:s,right:c}}function Tt(e){return Oe(e,{ignoreTransform:!0})}function Wn(e){const t=e.innerWidth,n=e.innerHeight;return{top:0,left:0,right:t,bottom:n,width:t,height:n}}function Hn(e,t){return t===void 0&&(t=P(e).getComputedStyle(e)),t.position==="fixed"}function Vn(e,t){t===void 0&&(t=P(e).getComputedStyle(e));const n=/(auto|scroll|overlay)/;return["overflow","overflowX","overflowY"].some(o=>{const i=t[o];return typeof i=="string"?n.test(i):!1})}function lt(e,t){const n=[];function r(o){if(t!=null&&n.length>=t||!o)return n;if(st(o)&&o.scrollingElement!=null&&!n.includes(o.scrollingElement))return n.push(o.scrollingElement),n;if(!Me(o)||Kt(o)||n.includes(o))return n;const i=P(e).getComputedStyle(o);return o!==e&&Vn(o,i)&&n.push(o),Hn(o,i)?n:r(o.parentNode)}return e?r(e):n}function qt(e){const[t]=lt(e,1);return t??null}function Ze(e){return!Ye||!e?null:ge(e)?e:it(e)?st(e)||e===ve(e).scrollingElement?window:Me(e)?e:null:null}function Jt(e){return ge(e)?e.scrollX:e.scrollLeft}function Gt(e){return ge(e)?e.scrollY:e.scrollTop}function nt(e){return{x:Jt(e),y:Gt(e)}}var T;(function(e){e[e.Forward=1]="Forward",e[e.Backward=-1]="Backward"})(T||(T={}));function _t(e){return!Ye||!e?!1:e===document.scrollingElement}function Qt(e){const t={x:0,y:0},n=_t(e)?{height:window.innerHeight,width:window.innerWidth}:{height:e.clientHeight,width:e.clientWidth},r={x:e.scrollWidth-n.width,y:e.scrollHeight-n.height},o=e.scrollTop<=t.y,i=e.scrollLeft<=t.x,a=e.scrollTop>=r.y,s=e.scrollLeft>=r.x;return{isTop:o,isLeft:i,isBottom:a,isRight:s,maxScroll:r,minScroll:t}}const qn={x:.2,y:.2};function Jn(e,t,n,r,o){let{top:i,left:a,right:s,bottom:c}=n;r===void 0&&(r=10),o===void 0&&(o=qn);const{isTop:u,isBottom:f,isLeft:d,isRight:v}=Qt(e),h={x:0,y:0},D={x:0,y:0},g={height:t.height*o.y,width:t.width*o.x};return!u&&i<=t.top+g.height?(h.y=T.Backward,D.y=r*Math.abs((t.top+g.height-i)/g.height)):!f&&c>=t.bottom-g.height&&(h.y=T.Forward,D.y=r*Math.abs((t.bottom-g.height-c)/g.height)),!v&&s>=t.right-g.width?(h.x=T.Forward,D.x=r*Math.abs((t.right-g.width-s)/g.width)):!d&&a<=t.left+g.width&&(h.x=T.Backward,D.x=r*Math.abs((t.left+g.width-a)/g.width)),{direction:h,speed:D}}function Gn(e){if(e===document.scrollingElement){const{innerWidth:i,innerHeight:a}=window;return{top:0,left:0,right:i,bottom:a,width:i,height:a}}const{top:t,left:n,right:r,bottom:o}=e.getBoundingClientRect();return{top:t,left:n,right:r,bottom:o,width:e.clientWidth,height:e.clientHeight}}function Zt(e){return e.reduce((t,n)=>he(t,nt(n)),K)}function _n(e){return e.reduce((t,n)=>t+Jt(n),0)}function Qn(e){return e.reduce((t,n)=>t+Gt(n),0)}function en(e,t){if(t===void 0&&(t=Oe),!e)return;const{top:n,left:r,bottom:o,right:i}=t(e);qt(e)&&(o<=0||i<=0||n>=window.innerHeight||r>=window.innerWidth)&&e.scrollIntoView({block:"center",inline:"center"})}const Zn=[["x",["left","right"],_n],["y",["top","bottom"],Qn]];class ct{constructor(t,n){this.rect=void 0,this.width=void 0,this.height=void 0,this.top=void 0,this.bottom=void 0,this.right=void 0,this.left=void 0;const r=lt(n),o=Zt(r);this.rect={...t},this.width=t.width,this.height=t.height;for(const[i,a,s]of Zn)for(const c of a)Object.defineProperty(this,c,{get:()=>{const u=s(r),f=o[i]-u;return this.rect[c]+f},enumerable:!0});Object.defineProperty(this,"rect",{enumerable:!1})}}class xe{constructor(t){this.target=void 0,this.listeners=[],this.removeAll=()=>{this.listeners.forEach(n=>{var r;return(r=this.target)==null?void 0:r.removeEventListener(...n)})},this.target=t}add(t,n,r){var o;(o=this.target)==null||o.addEventListener(t,n,r),this.listeners.push([t,n,r])}}function er(e){const{EventTarget:t}=P(e);return e instanceof t?e:ve(e)}function et(e,t){const n=Math.abs(e.x),r=Math.abs(e.y);return typeof t=="number"?Math.sqrt(n**2+r**2)>t:"x"in t&&"y"in t?n>t.x&&r>t.y:"x"in t?n>t.x:"y"in t?r>t.y:!1}var X;(function(e){e.Click="click",e.DragStart="dragstart",e.Keydown="keydown",e.ContextMenu="contextmenu",e.Resize="resize",e.SelectionChange="selectionchange",e.VisibilityChange="visibilitychange"})(X||(X={}));function kt(e){e.preventDefault()}function tr(e){e.stopPropagation()}var C;(function(e){e.Space="Space",e.Down="ArrowDown",e.Right="ArrowRight",e.Left="ArrowLeft",e.Up="ArrowUp",e.Esc="Escape",e.Enter="Enter",e.Tab="Tab"})(C||(C={}));const tn={start:[C.Space,C.Enter],cancel:[C.Esc],end:[C.Space,C.Enter,C.Tab]},nr=(e,t)=>{let{currentCoordinates:n}=t;switch(e.code){case C.Right:return{...n,x:n.x+25};case C.Left:return{...n,x:n.x-25};case C.Down:return{...n,y:n.y+25};case C.Up:return{...n,y:n.y-25}}};class nn{constructor(t){this.props=void 0,this.autoScrollEnabled=!1,this.referenceCoordinates=void 0,this.listeners=void 0,this.windowListeners=void 0,this.props=t;const{event:{target:n}}=t;this.props=t,this.listeners=new xe(ve(n)),this.windowListeners=new xe(P(n)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(X.Resize,this.handleCancel),this.windowListeners.add(X.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(X.Keydown,this.handleKeyDown))}handleStart(){const{activeNode:t,onStart:n}=this.props,r=t.node.current;r&&en(r),n(K)}handleKeyDown(t){if(at(t)){const{active:n,context:r,options:o}=this.props,{keyboardCodes:i=tn,coordinateGetter:a=nr,scrollBehavior:s="smooth"}=o,{code:c}=t;if(i.end.includes(c)){this.handleEnd(t);return}if(i.cancel.includes(c)){this.handleCancel(t);return}const{collisionRect:u}=r.current,f=u?{x:u.left,y:u.top}:K;this.referenceCoordinates||(this.referenceCoordinates=f);const d=a(t,{active:n,context:r.current,currentCoordinates:f});if(d){const v=je(d,f),h={x:0,y:0},{scrollableAncestors:D}=r.current;for(const g of D){const p=t.code,{isTop:y,isRight:x,isLeft:w,isBottom:N,maxScroll:S,minScroll:R}=Qt(g),b=Gn(g),m={x:Math.min(p===C.Right?b.right-b.width/2:b.right,Math.max(p===C.Right?b.left:b.left+b.width/2,d.x)),y:Math.min(p===C.Down?b.bottom-b.height/2:b.bottom,Math.max(p===C.Down?b.top:b.top+b.height/2,d.y))},E=p===C.Right&&!x||p===C.Left&&!w,k=p===C.Down&&!N||p===C.Up&&!y;if(E&&m.x!==d.x){const A=g.scrollLeft+v.x,H=p===C.Right&&A<=S.x||p===C.Left&&A>=R.x;if(H&&!v.y){g.scrollTo({left:A,behavior:s});return}H?h.x=g.scrollLeft-A:h.x=p===C.Right?g.scrollLeft-S.x:g.scrollLeft-R.x,h.x&&g.scrollBy({left:-h.x,behavior:s});break}else if(k&&m.y!==d.y){const A=g.scrollTop+v.y,H=p===C.Down&&A<=S.y||p===C.Up&&A>=R.y;if(H&&!v.x){g.scrollTo({top:A,behavior:s});return}H?h.y=g.scrollTop-A:h.y=p===C.Down?g.scrollTop-S.y:g.scrollTop-R.y,h.y&&g.scrollBy({top:-h.y,behavior:s});break}}this.handleMove(t,he(je(d,this.referenceCoordinates),h))}}}handleMove(t,n){const{onMove:r}=this.props;t.preventDefault(),r(n)}handleEnd(t){const{onEnd:n}=this.props;t.preventDefault(),this.detach(),n()}handleCancel(t){const{onCancel:n}=this.props;t.preventDefault(),this.detach(),n()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll()}}nn.activators=[{eventName:"onKeyDown",handler:(e,t,n)=>{let{keyboardCodes:r=tn,onActivation:o}=t,{active:i}=n;const{code:a}=e.nativeEvent;if(r.start.includes(a)){const s=i.activatorNode.current;return s&&e.target!==s?!1:(e.preventDefault(),o?.({event:e.nativeEvent}),!0)}return!1}}];function Lt(e){return!!(e&&"distance"in e)}function It(e){return!!(e&&"delay"in e)}class ut{constructor(t,n,r){var o;r===void 0&&(r=er(t.event.target)),this.props=void 0,this.events=void 0,this.autoScrollEnabled=!0,this.document=void 0,this.activated=!1,this.initialCoordinates=void 0,this.timeoutId=null,this.listeners=void 0,this.documentListeners=void 0,this.windowListeners=void 0,this.props=t,this.events=n;const{event:i}=t,{target:a}=i;this.props=t,this.events=n,this.document=ve(a),this.documentListeners=new xe(this.document),this.listeners=new xe(r),this.windowListeners=new xe(P(a)),this.initialCoordinates=(o=Fe(i))!=null?o:K,this.handleStart=this.handleStart.bind(this),this.handleMove=this.handleMove.bind(this),this.handleEnd=this.handleEnd.bind(this),this.handleCancel=this.handleCancel.bind(this),this.handleKeydown=this.handleKeydown.bind(this),this.removeTextSelection=this.removeTextSelection.bind(this),this.attach()}attach(){const{events:t,props:{options:{activationConstraint:n,bypassActivationConstraint:r}}}=this;if(this.listeners.add(t.move.name,this.handleMove,{passive:!1}),this.listeners.add(t.end.name,this.handleEnd),t.cancel&&this.listeners.add(t.cancel.name,this.handleCancel),this.windowListeners.add(X.Resize,this.handleCancel),this.windowListeners.add(X.DragStart,kt),this.windowListeners.add(X.VisibilityChange,this.handleCancel),this.windowListeners.add(X.ContextMenu,kt),this.documentListeners.add(X.Keydown,this.handleKeydown),n){if(r!=null&&r({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(It(n)){this.timeoutId=setTimeout(this.handleStart,n.delay),this.handlePending(n);return}if(Lt(n)){this.handlePending(n);return}}this.handleStart()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll(),setTimeout(this.documentListeners.removeAll,50),this.timeoutId!==null&&(clearTimeout(this.timeoutId),this.timeoutId=null)}handlePending(t,n){const{active:r,onPending:o}=this.props;o(r,t,this.initialCoordinates,n)}handleStart(){const{initialCoordinates:t}=this,{onStart:n}=this.props;t&&(this.activated=!0,this.documentListeners.add(X.Click,tr,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(X.SelectionChange,this.removeTextSelection),n(t))}handleMove(t){var n;const{activated:r,initialCoordinates:o,props:i}=this,{onMove:a,options:{activationConstraint:s}}=i;if(!o)return;const c=(n=Fe(t))!=null?n:K,u=je(o,c);if(!r&&s){if(Lt(s)){if(s.tolerance!=null&&et(u,s.tolerance))return this.handleCancel();if(et(u,s.distance))return this.handleStart()}if(It(s)&&et(u,s.tolerance))return this.handleCancel();this.handlePending(s,u);return}t.cancelable&&t.preventDefault(),a(c)}handleEnd(){const{onAbort:t,onEnd:n}=this.props;this.detach(),this.activated||t(this.props.active),n()}handleCancel(){const{onAbort:t,onCancel:n}=this.props;this.detach(),this.activated||t(this.props.active),n()}handleKeydown(t){t.code===C.Esc&&this.handleCancel()}removeTextSelection(){var t;(t=this.document.getSelection())==null||t.removeAllRanges()}}const rr={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class rn extends ut{constructor(t){const{event:n}=t,r=ve(n.target);super(t,rr,r)}}rn.activators=[{eventName:"onPointerDown",handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;return!n.isPrimary||n.button!==0?!1:(r?.({event:n}),!0)}}];const or={move:{name:"mousemove"},end:{name:"mouseup"}};var rt;(function(e){e[e.RightClick=2]="RightClick"})(rt||(rt={}));class ir extends ut{constructor(t){super(t,or,ve(t.event.target))}}ir.activators=[{eventName:"onMouseDown",handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;return n.button===rt.RightClick?!1:(r?.({event:n}),!0)}}];const tt={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};class sr extends ut{constructor(t){super(t,tt)}static setup(){return window.addEventListener(tt.move.name,t,{capture:!1,passive:!1}),function(){window.removeEventListener(tt.move.name,t)};function t(){}}}sr.activators=[{eventName:"onTouchStart",handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;const{touches:o}=n;return o.length>1?!1:(r?.({event:n}),!0)}}];var Ce;(function(e){e[e.Pointer=0]="Pointer",e[e.DraggableRect=1]="DraggableRect"})(Ce||(Ce={}));var $e;(function(e){e[e.TreeOrder=0]="TreeOrder",e[e.ReversedTreeOrder=1]="ReversedTreeOrder"})($e||($e={}));function ar(e){let{acceleration:t,activator:n=Ce.Pointer,canScroll:r,draggingRect:o,enabled:i,interval:a=5,order:s=$e.TreeOrder,pointerCoordinates:c,scrollableAncestors:u,scrollableAncestorRects:f,delta:d,threshold:v}=e;const h=cr({delta:d,disabled:!i}),[D,g]=wn(),p=l.useRef({x:0,y:0}),y=l.useRef({x:0,y:0}),x=l.useMemo(()=>{switch(n){case Ce.Pointer:return c?{top:c.y,bottom:c.y,left:c.x,right:c.x}:null;case Ce.DraggableRect:return o}},[n,o,c]),w=l.useRef(null),N=l.useCallback(()=>{const R=w.current;if(!R)return;const b=p.current.x*y.current.x,m=p.current.y*y.current.y;R.scrollBy(b,m)},[]),S=l.useMemo(()=>s===$e.TreeOrder?[...u].reverse():u,[s,u]);l.useEffect(()=>{if(!i||!u.length||!x){g();return}for(const R of S){if(r?.(R)===!1)continue;const b=u.indexOf(R),m=f[b];if(!m)continue;const{direction:E,speed:k}=Jn(R,m,x,t,v);for(const A of["x","y"])h[A][E[A]]||(k[A]=0,E[A]=0);if(k.x>0||k.y>0){g(),w.current=R,D(N,a),p.current=k,y.current=E;return}}p.current={x:0,y:0},y.current={x:0,y:0},g()},[t,N,r,g,i,a,JSON.stringify(x),JSON.stringify(h),D,u,S,f,JSON.stringify(v)])}const lr={x:{[T.Backward]:!1,[T.Forward]:!1},y:{[T.Backward]:!1,[T.Forward]:!1}};function cr(e){let{delta:t,disabled:n}=e;const r=Be(t);return Ae(o=>{if(n||!r||!o)return lr;const i={x:Math.sign(t.x-r.x),y:Math.sign(t.y-r.y)};return{x:{[T.Backward]:o.x[T.Backward]||i.x===-1,[T.Forward]:o.x[T.Forward]||i.x===1},y:{[T.Backward]:o.y[T.Backward]||i.y===-1,[T.Forward]:o.y[T.Forward]||i.y===1}}},[n,t,r])}function ur(e,t){const n=t!=null?e.get(t):void 0,r=n?n.node.current:null;return Ae(o=>{var i;return t==null?null:(i=r??o)!=null?i:null},[r,t])}function dr(e,t){return l.useMemo(()=>e.reduce((n,r)=>{const{sensor:o}=r,i=o.activators.map(a=>({eventName:a.eventName,handler:t(a.handler,r)}));return[...n,...i]},[]),[e,t])}var Ee;(function(e){e[e.Always=0]="Always",e[e.BeforeDragging=1]="BeforeDragging",e[e.WhileDragging=2]="WhileDragging"})(Ee||(Ee={}));var ot;(function(e){e.Optimized="optimized"})(ot||(ot={}));const Pt=new Map;function fr(e,t){let{dragging:n,dependencies:r,config:o}=t;const[i,a]=l.useState(null),{frequency:s,measure:c,strategy:u}=o,f=l.useRef(e),d=p(),v=Se(d),h=l.useCallback(function(y){y===void 0&&(y=[]),!v.current&&a(x=>x===null?y:x.concat(y.filter(w=>!x.includes(w))))},[v]),D=l.useRef(null),g=Ae(y=>{if(d&&!n)return Pt;if(!y||y===Pt||f.current!==e||i!=null){const x=new Map;for(let w of e){if(!w)continue;if(i&&i.length>0&&!i.includes(w.id)&&w.rect.current){x.set(w.id,w.rect.current);continue}const N=w.node.current,S=N?new ct(c(N),N):null;w.rect.current=S,S&&x.set(w.id,S)}return x}return y},[e,i,n,d,c]);return l.useEffect(()=>{f.current=e},[e]),l.useEffect(()=>{d||h()},[n,d]),l.useEffect(()=>{i&&i.length>0&&a(null)},[JSON.stringify(i)]),l.useEffect(()=>{d||typeof s!="number"||D.current!==null||(D.current=setTimeout(()=>{h(),D.current=null},s))},[s,d,h,...r]),{droppableRects:g,measureDroppableContainers:h,measuringScheduled:i!=null};function p(){switch(u){case Ee.Always:return!1;case Ee.BeforeDragging:return n;default:return!n}}}function dt(e,t){return Ae(n=>e?n||(typeof t=="function"?t(e):e):null,[t,e])}function hr(e,t){return dt(e,t)}function gr(e){let{callback:t,disabled:n}=e;const r=Ke(t),o=l.useMemo(()=>{if(n||typeof window>"u"||typeof window.MutationObserver>"u")return;const{MutationObserver:i}=window;return new i(r)},[r,n]);return l.useEffect(()=>()=>o?.disconnect(),[o]),o}function We(e){let{callback:t,disabled:n}=e;const r=Ke(t),o=l.useMemo(()=>{if(n||typeof window>"u"||typeof window.ResizeObserver>"u")return;const{ResizeObserver:i}=window;return new i(r)},[n]);return l.useEffect(()=>()=>o?.disconnect(),[o]),o}function vr(e){return new ct(Oe(e),e)}function zt(e,t,n){t===void 0&&(t=vr);const[r,o]=l.useState(null);function i(){o(c=>{if(!e)return null;if(e.isConnected===!1){var u;return(u=c??n)!=null?u:null}const f=t(e);return JSON.stringify(c)===JSON.stringify(f)?c:f})}const a=gr({callback(c){if(e)for(const u of c){const{type:f,target:d}=u;if(f==="childList"&&d instanceof HTMLElement&&d.contains(e)){i();break}}}}),s=We({callback:i});return G(()=>{i(),e?(s?.observe(e),a?.observe(document.body,{childList:!0,subtree:!0})):(s?.disconnect(),a?.disconnect())},[e]),r}function pr(e){const t=dt(e);return Ht(e,t)}const Bt=[];function br(e){const t=l.useRef(e),n=Ae(r=>e?r&&r!==Bt&&e&&t.current&&e.parentNode===t.current.parentNode?r:lt(e):Bt,[e]);return l.useEffect(()=>{t.current=e},[e]),n}function mr(e){const[t,n]=l.useState(null),r=l.useRef(e),o=l.useCallback(i=>{const a=Ze(i.target);a&&n(s=>s?(s.set(a,nt(a)),new Map(s)):null)},[]);return l.useEffect(()=>{const i=r.current;if(e!==i){a(i);const s=e.map(c=>{const u=Ze(c);return u?(u.addEventListener("scroll",o,{passive:!0}),[u,nt(u)]):null}).filter(c=>c!=null);n(s.length?new Map(s):null),r.current=e}return()=>{a(e),a(i)};function a(s){s.forEach(c=>{const u=Ze(c);u?.removeEventListener("scroll",o)})}},[o,e]),l.useMemo(()=>e.length?t?Array.from(t.values()).reduce((i,a)=>he(i,a),K):Zt(e):K,[e,t])}function jt(e,t){t===void 0&&(t=[]);const n=l.useRef(null);return l.useEffect(()=>{n.current=null},t),l.useEffect(()=>{const r=e!==K;r&&!n.current&&(n.current=e),!r&&n.current&&(n.current=null)},[e]),n.current?je(e,n.current):K}function yr(e){l.useEffect(()=>{if(!Ye)return;const t=e.map(n=>{let{sensor:r}=n;return r.setup==null?void 0:r.setup()});return()=>{for(const n of t)n?.()}},e.map(t=>{let{sensor:n}=t;return n}))}function wr(e,t){return l.useMemo(()=>e.reduce((n,r)=>{let{eventName:o,handler:i}=r;return n[o]=a=>{i(a,t)},n},{}),[e,t])}function on(e){return l.useMemo(()=>e?Wn(e):null,[e])}const Ft=[];function xr(e,t){t===void 0&&(t=Oe);const[n]=e,r=on(n?P(n):null),[o,i]=l.useState(Ft);function a(){i(()=>e.length?e.map(c=>_t(c)?r:new ct(t(c),c)):Ft)}const s=We({callback:a});return G(()=>{s?.disconnect(),a(),e.forEach(c=>s?.observe(c))},[e]),o}function sn(e){if(!e)return null;if(e.children.length>1)return e;const t=e.children[0];return Me(t)?t:e}function Cr(e){let{measure:t}=e;const[n,r]=l.useState(null),o=l.useCallback(u=>{for(const{target:f}of u)if(Me(f)){r(d=>{const v=t(f);return d?{...d,width:v.width,height:v.height}:v});break}},[t]),i=We({callback:o}),a=l.useCallback(u=>{const f=sn(u);i?.disconnect(),f&&i?.observe(f),r(f?t(f):null)},[t,i]),[s,c]=ze(a);return l.useMemo(()=>({nodeRef:s,rect:n,setRef:c}),[n,s,c])}const Dr=[{sensor:rn,options:{}},{sensor:nn,options:{}}],Sr={current:{}},Pe={draggable:{measure:Tt},droppable:{measure:Tt,strategy:Ee.WhileDragging,frequency:ot.Optimized},dragOverlay:{measure:Oe}};class De extends Map{get(t){var n;return t!=null&&(n=super.get(t))!=null?n:void 0}toArray(){return Array.from(this.values())}getEnabled(){return this.toArray().filter(t=>{let{disabled:n}=t;return!n})}getNodeFor(t){var n,r;return(n=(r=this.get(t))==null?void 0:r.node.current)!=null?n:void 0}}const Rr={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new De,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:Xe},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:Pe,measureDroppableContainers:Xe,windowRect:null,measuringScheduled:!1},an={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:Xe,draggableNodes:new Map,over:null,measureDroppableContainers:Xe},Ne=l.createContext(an),ln=l.createContext(Rr);function Er(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new De}}}function Mr(e,t){switch(t.type){case O.DragStart:return{...e,draggable:{...e.draggable,initialCoordinates:t.initialCoordinates,active:t.active}};case O.DragMove:return e.draggable.active==null?e:{...e,draggable:{...e.draggable,translate:{x:t.coordinates.x-e.draggable.initialCoordinates.x,y:t.coordinates.y-e.draggable.initialCoordinates.y}}};case O.DragEnd:case O.DragCancel:return{...e,draggable:{...e.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case O.RegisterDroppable:{const{element:n}=t,{id:r}=n,o=new De(e.droppable.containers);return o.set(r,n),{...e,droppable:{...e.droppable,containers:o}}}case O.SetDroppableDisabled:{const{id:n,key:r,disabled:o}=t,i=e.droppable.containers.get(n);if(!i||r!==i.key)return e;const a=new De(e.droppable.containers);return a.set(n,{...i,disabled:o}),{...e,droppable:{...e.droppable,containers:a}}}case O.UnregisterDroppable:{const{id:n,key:r}=t,o=e.droppable.containers.get(n);if(!o||r!==o.key)return e;const i=new De(e.droppable.containers);return i.delete(n),{...e,droppable:{...e.droppable,containers:i}}}default:return e}}function Ar(e){let{disabled:t}=e;const{active:n,activatorEvent:r,draggableNodes:o}=l.useContext(Ne),i=Be(r),a=Be(n?.id);return l.useEffect(()=>{if(!t&&!r&&i&&a!=null){if(!at(i)||document.activeElement===i.target)return;const s=o.get(a);if(!s)return;const{activatorNode:c,node:u}=s;if(!c.current&&!u.current)return;requestAnimationFrame(()=>{for(const f of[c.current,u.current]){if(!f)continue;const d=Dn(f);if(d){d.focus();break}}})}},[r,t,o,a,i]),null}function cn(e,t){let{transform:n,...r}=t;return e!=null&&e.length?e.reduce((o,i)=>i({transform:o,...r}),n):n}function Or(e){return l.useMemo(()=>({draggable:{...Pe.draggable,...e?.draggable},droppable:{...Pe.droppable,...e?.droppable},dragOverlay:{...Pe.dragOverlay,...e?.dragOverlay}}),[e?.draggable,e?.droppable,e?.dragOverlay])}function Nr(e){let{activeNode:t,measure:n,initialRect:r,config:o=!0}=e;const i=l.useRef(!1),{x:a,y:s}=typeof o=="boolean"?{x:o,y:o}:o;G(()=>{if(!a&&!s||!t){i.current=!1;return}if(i.current||!r)return;const u=t?.node.current;if(!u||u.isConnected===!1)return;const f=n(u),d=Ht(f,r);if(a||(d.x=0),s||(d.y=0),i.current=!0,Math.abs(d.x)>0||Math.abs(d.y)>0){const v=qt(u);v&&v.scrollBy({top:d.y,left:d.x})}},[t,a,s,r,n])}const He=l.createContext({...K,scaleX:1,scaleY:1});var re;(function(e){e[e.Uninitialized=0]="Uninitialized",e[e.Initializing=1]="Initializing",e[e.Initialized=2]="Initialized"})(re||(re={}));const ro=l.memo(function(t){var n,r,o,i;let{id:a,accessibility:s,autoScroll:c=!0,children:u,sensors:f=Dr,collisionDetection:d=Fn,measuring:v,modifiers:h,...D}=t;const g=l.useReducer(Mr,void 0,Er),[p,y]=g,[x,w]=On(),[N,S]=l.useState(re.Uninitialized),R=N===re.Initialized,{draggable:{active:b,nodes:m,translate:E},droppable:{containers:k}}=p,A=b!=null?m.get(b):null,H=l.useRef({initial:null,translated:null}),V=l.useMemo(()=>{var I;return b!=null?{id:b,data:(I=A?.data)!=null?I:Sr,rect:H}:null},[b,A]),_=l.useRef(null),[ft,ht]=l.useState(null),[q,gt]=l.useState(null),oe=Se(D,Object.values(D)),Ve=Ue("DndDescribedBy",a),vt=l.useMemo(()=>k.getEnabled(),[k]),ie=Or(v),{droppableRects:le,measureDroppableContainers:Te,measuringScheduled:pt}=fr(vt,{dragging:R,dependencies:[E.x,E.y],config:ie.droppable}),$=ur(m,b),bt=l.useMemo(()=>q?Fe(q):null,[q]),mt=bn(),yt=hr($,ie.draggable.measure);Nr({activeNode:b!=null?m.get(b):null,config:mt.layoutShiftCompensation,initialRect:yt,measure:ie.draggable.measure});const Y=zt($,ie.draggable.measure,yt),qe=zt($?$.parentElement:null),se=l.useRef({activatorEvent:null,active:null,activeNode:$,collisionRect:null,collisions:null,droppableRects:le,draggableNodes:m,draggingNode:null,draggingNodeRect:null,droppableContainers:k,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),wt=k.getNodeFor((n=se.current.over)==null?void 0:n.id),ae=Cr({measure:ie.dragOverlay.measure}),ke=(r=ae.nodeRef.current)!=null?r:$,ce=R?(o=ae.rect)!=null?o:Y:null,xt=!!(ae.nodeRef.current&&ae.rect),Ct=pr(xt?null:Y),Je=on(ke?P(ke):null),Q=br(R?wt??$:null),Le=xr(Q),Ie=cn(h,{transform:{x:E.x-Ct.x,y:E.y-Ct.y,scaleX:1,scaleY:1},activatorEvent:q,active:V,activeNodeRect:Y,containerNodeRect:qe,draggingNodeRect:ce,over:se.current.over,overlayNodeRect:ae.rect,scrollableAncestors:Q,scrollableAncestorRects:Le,windowRect:Je}),Dt=bt?he(bt,E):null,St=mr(Q),un=jt(St),dn=jt(St,[Y]),ue=he(Ie,un),de=ce?Yn(ce,Ie):null,pe=V&&de?d({active:V,collisionRect:de,droppableRects:le,droppableContainers:vt,pointerCoordinates:Dt}):null,Rt=Bn(pe,"id"),[Z,Et]=l.useState(null),fn=xt?Ie:he(Ie,dn),hn=Xn(fn,(i=Z?.rect)!=null?i:null,Y),Ge=l.useRef(null),Mt=l.useCallback((I,z)=>{let{sensor:B,options:ee}=z;if(_.current==null)return;const F=m.get(_.current);if(!F)return;const j=I.nativeEvent,U=new B({active:_.current,activeNode:F,event:j,options:ee,context:se,onAbort(L){if(!m.get(L))return;const{onDragAbort:W}=oe.current,J={id:L};W?.(J),x({type:"onDragAbort",event:J})},onPending(L,te,W,J){if(!m.get(L))return;const{onDragPending:me}=oe.current,ne={id:L,constraint:te,initialCoordinates:W,offset:J};me?.(ne),x({type:"onDragPending",event:ne})},onStart(L){const te=_.current;if(te==null)return;const W=m.get(te);if(!W)return;const{onDragStart:J}=oe.current,be={activatorEvent:j,active:{id:te,data:W.data,rect:H}};we.unstable_batchedUpdates(()=>{J?.(be),S(re.Initializing),y({type:O.DragStart,initialCoordinates:L,active:te}),x({type:"onDragStart",event:be}),ht(Ge.current),gt(j)})},onMove(L){y({type:O.DragMove,coordinates:L})},onEnd:fe(O.DragEnd),onCancel:fe(O.DragCancel)});Ge.current=U;function fe(L){return async function(){const{active:W,collisions:J,over:be,scrollAdjustedTranslate:me}=se.current;let ne=null;if(W&&me){const{cancelDrop:ye}=oe.current;ne={activatorEvent:j,active:W,collisions:J,delta:me,over:be},L===O.DragEnd&&typeof ye=="function"&&await Promise.resolve(ye(ne))&&(L=O.DragCancel)}_.current=null,we.unstable_batchedUpdates(()=>{y({type:L}),S(re.Uninitialized),Et(null),ht(null),gt(null),Ge.current=null;const ye=L===O.DragEnd?"onDragEnd":"onDragCancel";if(ne){const _e=oe.current[ye];_e?.(ne),x({type:ye,event:ne})}})}}},[m]),gn=l.useCallback((I,z)=>(B,ee)=>{const F=B.nativeEvent,j=m.get(ee);if(_.current!==null||!j||F.dndKit||F.defaultPrevented)return;const U={active:j};I(B,z.options,U)===!0&&(F.dndKit={capturedBy:z.sensor},_.current=ee,Mt(B,z))},[m,Mt]),At=dr(f,gn);yr(f),G(()=>{Y&&N===re.Initializing&&S(re.Initialized)},[Y,N]),l.useEffect(()=>{const{onDragMove:I}=oe.current,{active:z,activatorEvent:B,collisions:ee,over:F}=se.current;if(!z||!B)return;const j={active:z,activatorEvent:B,collisions:ee,delta:{x:ue.x,y:ue.y},over:F};we.unstable_batchedUpdates(()=>{I?.(j),x({type:"onDragMove",event:j})})},[ue.x,ue.y]),l.useEffect(()=>{const{active:I,activatorEvent:z,collisions:B,droppableContainers:ee,scrollAdjustedTranslate:F}=se.current;if(!I||_.current==null||!z||!F)return;const{onDragOver:j}=oe.current,U=ee.get(Rt),fe=U&&U.rect.current?{id:U.id,rect:U.rect.current,data:U.data,disabled:U.disabled}:null,L={active:I,activatorEvent:z,collisions:B,delta:{x:F.x,y:F.y},over:fe};we.unstable_batchedUpdates(()=>{Et(fe),j?.(L),x({type:"onDragOver",event:L})})},[Rt]),G(()=>{se.current={activatorEvent:q,active:V,activeNode:$,collisionRect:de,collisions:pe,droppableRects:le,draggableNodes:m,draggingNode:ke,draggingNodeRect:ce,droppableContainers:k,over:Z,scrollableAncestors:Q,scrollAdjustedTranslate:ue},H.current={initial:ce,translated:de}},[V,$,pe,de,m,ke,ce,le,k,Z,Q,ue]),ar({...mt,delta:E,draggingRect:de,pointerCoordinates:Dt,scrollableAncestors:Q,scrollableAncestorRects:Le});const vn=l.useMemo(()=>({active:V,activeNode:$,activeNodeRect:Y,activatorEvent:q,collisions:pe,containerNodeRect:qe,dragOverlay:ae,draggableNodes:m,droppableContainers:k,droppableRects:le,over:Z,measureDroppableContainers:Te,scrollableAncestors:Q,scrollableAncestorRects:Le,measuringConfiguration:ie,measuringScheduled:pt,windowRect:Je}),[V,$,Y,q,pe,qe,ae,m,k,le,Z,Te,Q,Le,ie,pt,Je]),pn=l.useMemo(()=>({activatorEvent:q,activators:At,active:V,activeNodeRect:Y,ariaDescribedById:{draggable:Ve},dispatch:y,draggableNodes:m,over:Z,measureDroppableContainers:Te}),[q,At,V,Y,y,Ve,m,Z,Te]);return M.createElement(Wt.Provider,{value:w},M.createElement(Ne.Provider,{value:pn},M.createElement(ln.Provider,{value:vn},M.createElement(He.Provider,{value:hn},u)),M.createElement(Ar,{disabled:s?.restoreFocus===!1})),M.createElement(kn,{...s,hiddenTextDescribedById:Ve}));function bn(){const I=ft?.autoScrollEnabled===!1,z=typeof c=="object"?c.enabled===!1:c===!1,B=R&&!I&&!z;return typeof c=="object"?{...c,enabled:B}:{enabled:B}}}),Tr=l.createContext(null),Xt="button",kr="Draggable";function oo(e){let{id:t,data:n,disabled:r=!1,attributes:o}=e;const i=Ue(kr),{activators:a,activatorEvent:s,active:c,activeNodeRect:u,ariaDescribedById:f,draggableNodes:d,over:v}=l.useContext(Ne),{role:h=Xt,roleDescription:D="draggable",tabIndex:g=0}=o??{},p=c?.id===t,y=l.useContext(p?He:Tr),[x,w]=ze(),[N,S]=ze(),R=wr(a,t),b=Se(n);G(()=>(d.set(t,{id:t,key:i,node:x,activatorNode:N,data:b}),()=>{const E=d.get(t);E&&E.key===i&&d.delete(t)}),[d,t]);const m=l.useMemo(()=>({role:h,tabIndex:g,"aria-disabled":r,"aria-pressed":p&&h===Xt?!0:void 0,"aria-roledescription":D,"aria-describedby":f.draggable}),[r,h,g,p,D,f.draggable]);return{active:c,activatorEvent:s,activeNodeRect:u,attributes:m,isDragging:p,listeners:r?void 0:R,node:x,over:v,setNodeRef:w,setActivatorNodeRef:S,transform:y}}function Lr(){return l.useContext(ln)}const Ir="Droppable",Pr={timeout:25};function io(e){let{data:t,disabled:n=!1,id:r,resizeObserverConfig:o}=e;const i=Ue(Ir),{active:a,dispatch:s,over:c,measureDroppableContainers:u}=l.useContext(Ne),f=l.useRef({disabled:n}),d=l.useRef(!1),v=l.useRef(null),h=l.useRef(null),{disabled:D,updateMeasurementsFor:g,timeout:p}={...Pr,...o},y=Se(g??r),x=l.useCallback(()=>{if(!d.current){d.current=!0;return}h.current!=null&&clearTimeout(h.current),h.current=setTimeout(()=>{u(Array.isArray(y.current)?y.current:[y.current]),h.current=null},p)},[p]),w=We({callback:x,disabled:D||!a}),N=l.useCallback((m,E)=>{w&&(E&&(w.unobserve(E),d.current=!1),m&&w.observe(m))},[w]),[S,R]=ze(N),b=Se(t);return l.useEffect(()=>{!w||!S.current||(w.disconnect(),d.current=!1,w.observe(S.current))},[S,w]),l.useEffect(()=>(s({type:O.RegisterDroppable,element:{id:r,key:i,disabled:n,node:S,rect:v,data:b}}),()=>s({type:O.UnregisterDroppable,key:i,id:r})),[r]),l.useEffect(()=>{n!==f.current.disabled&&(s({type:O.SetDroppableDisabled,id:r,key:i,disabled:n}),f.current.disabled=n)},[r,i,n,s]),{active:a,rect:v,isOver:c?.id===r,node:S,over:c,setNodeRef:R}}function zr(e){let{animation:t,children:n}=e;const[r,o]=l.useState(null),[i,a]=l.useState(null),s=Be(n);return!n&&!r&&s&&o(s),G(()=>{if(!i)return;const c=r?.key,u=r?.props.id;if(c==null||u==null){o(null);return}Promise.resolve(t(u,i)).then(()=>{o(null)})},[t,r,i]),M.createElement(M.Fragment,null,n,r?l.cloneElement(r,{ref:a}):null)}const Br={x:0,y:0,scaleX:1,scaleY:1};function jr(e){let{children:t}=e;return M.createElement(Ne.Provider,{value:an},M.createElement(He.Provider,{value:Br},t))}const Fr={position:"fixed",touchAction:"none"},Xr=e=>at(e)?"transform 250ms ease":void 0,$r=l.forwardRef((e,t)=>{let{as:n,activatorEvent:r,adjustScale:o,children:i,className:a,rect:s,style:c,transform:u,transition:f=Xr}=e;if(!s)return null;const d=o?u:{...u,scaleX:1,scaleY:1},v={...Fr,width:s.width,height:s.height,top:s.top,left:s.left,transform:Re.Transform.toString(d),transformOrigin:o&&r?In(r,s):void 0,transition:typeof f=="function"?f(r):f,...c};return M.createElement(n,{className:a,style:v,ref:t},i)}),Yr=e=>t=>{let{active:n,dragOverlay:r}=t;const o={},{styles:i,className:a}=e;if(i!=null&&i.active)for(const[s,c]of Object.entries(i.active))c!==void 0&&(o[s]=n.node.style.getPropertyValue(s),n.node.style.setProperty(s,c));if(i!=null&&i.dragOverlay)for(const[s,c]of Object.entries(i.dragOverlay))c!==void 0&&r.node.style.setProperty(s,c);return a!=null&&a.active&&n.node.classList.add(a.active),a!=null&&a.dragOverlay&&r.node.classList.add(a.dragOverlay),function(){for(const[c,u]of Object.entries(o))n.node.style.setProperty(c,u);a!=null&&a.active&&n.node.classList.remove(a.active)}},Kr=e=>{let{transform:{initial:t,final:n}}=e;return[{transform:Re.Transform.toString(t)},{transform:Re.Transform.toString(n)}]},Ur={duration:250,easing:"ease",keyframes:Kr,sideEffects:Yr({styles:{active:{opacity:"0"}}})};function Wr(e){let{config:t,draggableNodes:n,droppableContainers:r,measuringConfiguration:o}=e;return Ke((i,a)=>{if(t===null)return;const s=n.get(i);if(!s)return;const c=s.node.current;if(!c)return;const u=sn(a);if(!u)return;const{transform:f}=P(a).getComputedStyle(a),d=Vt(f);if(!d)return;const v=typeof t=="function"?t:Hr(t);return en(c,o.draggable.measure),v({active:{id:i,data:s.data,node:c,rect:o.draggable.measure(c)},draggableNodes:n,dragOverlay:{node:a,rect:o.dragOverlay.measure(u)},droppableContainers:r,measuringConfiguration:o,transform:d})})}function Hr(e){const{duration:t,easing:n,sideEffects:r,keyframes:o}={...Ur,...e};return i=>{let{active:a,dragOverlay:s,transform:c,...u}=i;if(!t)return;const f={x:s.rect.left-a.rect.left,y:s.rect.top-a.rect.top},d={scaleX:c.scaleX!==1?a.rect.width*c.scaleX/s.rect.width:1,scaleY:c.scaleY!==1?a.rect.height*c.scaleY/s.rect.height:1},v={x:c.x-f.x,y:c.y-f.y,...d},h=o({...u,active:a,dragOverlay:s,transform:{initial:c,final:v}}),[D]=h,g=h[h.length-1];if(JSON.stringify(D)===JSON.stringify(g))return;const p=r?.({active:a,dragOverlay:s,...u}),y=s.node.animate(h,{duration:t,easing:n,fill:"forwards"});return new Promise(x=>{y.onfinish=()=>{p?.(),x()}})}}let $t=0;function Vr(e){return l.useMemo(()=>{if(e!=null)return $t++,$t},[e])}const so=M.memo(e=>{let{adjustScale:t=!1,children:n,dropAnimation:r,style:o,transition:i,modifiers:a,wrapperElement:s="div",className:c,zIndex:u=999}=e;const{activatorEvent:f,active:d,activeNodeRect:v,containerNodeRect:h,draggableNodes:D,droppableContainers:g,dragOverlay:p,over:y,measuringConfiguration:x,scrollableAncestors:w,scrollableAncestorRects:N,windowRect:S}=Lr(),R=l.useContext(He),b=Vr(d?.id),m=cn(a,{activatorEvent:f,active:d,activeNodeRect:v,containerNodeRect:h,draggingNodeRect:p.rect,over:y,overlayNodeRect:p.rect,scrollableAncestors:w,scrollableAncestorRects:N,transform:R,windowRect:S}),E=dt(v),k=Wr({config:r,draggableNodes:D,droppableContainers:g,measuringConfiguration:x}),A=E?p.setRef:void 0;return M.createElement(jr,null,M.createElement(zr,{animation:k},d&&b?M.createElement($r,{key:b,id:d.id,ref:A,as:s,activatorEvent:f,adjustScale:t,className:c,transition:i,rect:E,style:{zIndex:u,...o},transform:m},n):null))});export{Re as C,ro as D,Qr as G,C as K,rn as P,eo as a,_r as b,no as c,oo as d,io as e,so as f,Lr as g,Ue as h,G as i,Zr as j,at as k,Oe as l,to as u};
@@ -0,0 +1 @@
1
+ const s=new Intl.DateTimeFormat("en-US",{year:"numeric",month:"short",day:"numeric"}),c=new Intl.DateTimeFormat("en-US",{year:"numeric",month:"short",day:"numeric",hour:"numeric",minute:"2-digit"});function u(e){return s.format(new Date(e))}function f(e){return c.format(new Date(e))}function l(e){const n=Date.now()-e,a=Math.floor(n/1e3);if(a<60)return"just now";const r=Math.floor(a/60);if(r<60)return`${r}m ago`;const o=Math.floor(r/60);if(o<24)return`${o}h ago`;const i=Math.floor(o/24);return i<7?`${i}d ago`:u(e)}function m(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function h(e){return e.toLowerCase().replace(/[^\w\s-]/g,"").replace(/\s+/g,"-").replace(/-+/g,"-").trim()}function d(e){return e.toLowerCase().replace(/\s+/g,"-").replace(/[^a-z0-9_-]/g,"").replace(/[-_]{2,}/g,t=>t[0]).replace(/^[^a-z]+/,"").replace(/[-_]$/g,"")}function g(e){return e.split(/[-_]/).filter(Boolean).map(t=>t.charAt(0).toUpperCase()+t.slice(1)).join(" ")}function p(e){const t=e.split(" ");if(t.length===0)return e;const n=t[t.length-1];return n.length>2&&n.endsWith("s")&&!n.endsWith("ss")&&(t[t.length-1]=n.slice(0,-1)),t.join(" ")}export{l as a,m as b,p as c,d,f,g as i,h as s};