convex-cms 0.0.9-alpha.9 → 0.0.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/admin/src/components/Header.tsx +1 -1
- package/admin/src/components/RouteGuard.tsx +1 -1
- package/admin/src/components/UploadDropzone.tsx +1 -1
- package/admin/src/components/ui/sidebar.tsx +1 -1
- package/admin/src/contexts/AuthContext.tsx +1 -1
- package/admin/src/embed/components/EmbedSidebar.tsx +10 -10
- package/admin/src/embed/contexts/ApiContext.tsx +1 -1
- package/admin/src/hooks/usePermissions.ts +1 -1
- package/admin/src/index.css +432 -0
- package/admin/src/lib/cmsExports.ts +6 -0
- package/admin/src/pages/DashboardPage.tsx +2 -3
- package/admin/src/routes/__root.tsx +1 -1
- package/admin-dist/nitro.json +1 -1
- package/admin-dist/public/assets/{CmsEmptyState-DTlpzjOI.js → CmsEmptyState-BKeL4DBB.js} +1 -1
- package/admin-dist/public/assets/CmsFilterBar-CEpMHd_c.js +1 -0
- package/admin-dist/public/assets/{CmsPageHeader-0REGRH4X.js → CmsPageHeader-CIEkTbyH.js} +1 -1
- package/admin-dist/public/assets/{CmsStatusBadge-D_n8u8xa.js → CmsStatusBadge-BFMOsfMW.js} +1 -1
- package/admin-dist/public/assets/{CmsSurface-BHmvNai4.js → CmsSurface-kqqaFKUI.js} +1 -1
- package/admin-dist/public/assets/CmsTable-Db53Exq0.js +1 -0
- package/admin-dist/public/assets/ContentEntryEditor-Ct7cHayy.js +4 -0
- package/admin-dist/public/assets/TaxonomyFilter-Bm1DI1A7.js +1 -0
- package/admin-dist/public/assets/_contentTypeId-BekeCblX.js +1 -0
- package/admin-dist/public/assets/{_entryId-jPXz4z9T.js → _entryId-CoZDE0l0.js} +1 -1
- package/admin-dist/public/assets/{alert-CG97cMfC.js → alert-CpLdsTGU.js} +1 -1
- package/admin-dist/public/assets/{badge-C6qt24oj.js → badge-BQAotc5B.js} +1 -1
- package/admin-dist/public/assets/{circle-check-big-PltpxuB1.js → circle-check-big-BF3Y5nES.js} +1 -1
- package/admin-dist/public/assets/{command-CJ8i86fd.js → command-lEq6f_Ee.js} +1 -1
- package/admin-dist/public/assets/content-DH6k0dN6.js +1 -0
- package/admin-dist/public/assets/content-types-DHr9tc2V.js +1 -0
- package/admin-dist/public/assets/index-Cf0lbl0G.js +1 -0
- package/admin-dist/public/assets/index-D-4wFfgU.css +1 -0
- package/admin-dist/public/assets/inter-cyrillic-ext-wght-normal-BOeWTOD4.woff2 +0 -0
- package/admin-dist/public/assets/inter-cyrillic-wght-normal-DqGufNeO.woff2 +0 -0
- package/admin-dist/public/assets/inter-greek-ext-wght-normal-DlzME5K_.woff2 +0 -0
- package/admin-dist/public/assets/inter-greek-wght-normal-CkhJZR-_.woff2 +0 -0
- package/admin-dist/public/assets/inter-latin-ext-wght-normal-DO1Apj_S.woff2 +0 -0
- package/admin-dist/public/assets/inter-latin-wght-normal-Dx4kXJAl.woff2 +0 -0
- package/admin-dist/public/assets/inter-vietnamese-wght-normal-CBcvBZtf.woff2 +0 -0
- package/admin-dist/public/assets/jetbrains-mono-cyrillic-400-normal-BEIGL1Tu.woff2 +0 -0
- package/admin-dist/public/assets/jetbrains-mono-cyrillic-400-normal-ugxPyKxw.woff +0 -0
- package/admin-dist/public/assets/jetbrains-mono-greek-400-normal-B9oWc5Lo.woff +0 -0
- package/admin-dist/public/assets/jetbrains-mono-greek-400-normal-C190GLew.woff2 +0 -0
- package/admin-dist/public/assets/jetbrains-mono-latin-400-normal-6-qcROiO.woff +0 -0
- package/admin-dist/public/assets/jetbrains-mono-latin-400-normal-V6pRDFza.woff2 +0 -0
- package/admin-dist/public/assets/jetbrains-mono-latin-ext-400-normal-Bc8Ftmh3.woff2 +0 -0
- package/admin-dist/public/assets/jetbrains-mono-latin-ext-400-normal-fXTG6kC5.woff +0 -0
- package/admin-dist/public/assets/jetbrains-mono-vietnamese-400-normal-CqNFfHCs.woff +0 -0
- package/admin-dist/public/assets/main-B-6700eG.js +137 -0
- package/admin-dist/public/assets/media-DY5zD52L.js +1 -0
- package/admin-dist/public/assets/{new._contentTypeId-qsvo01mH.js → new._contentTypeId-Dq_NqTQV.js} +1 -1
- package/admin-dist/public/assets/{pencil-gAL0R34f.js → pencil-CI_KfxSx.js} +1 -1
- package/admin-dist/public/assets/refresh-cw-BrXg9a2r.js +1 -0
- package/admin-dist/public/assets/rotate-ccw-PwzxdPxd.js +1 -0
- package/admin-dist/public/assets/{scroll-area-CJBhf9pf.js → scroll-area-DX_nZYp8.js} +1 -1
- package/admin-dist/public/assets/{search-WXp6KxDJ.js → search-DlwBH4C5.js} +1 -1
- package/admin-dist/public/assets/settings-2mx3_ORG.js +1 -0
- package/admin-dist/public/assets/{switch-Ck9ecqEX.js → switch-CjPi4DKH.js} +1 -1
- package/admin-dist/public/assets/{tabs-vQYu8rjC.js → tabs-B5X37GEM.js} +1 -1
- package/admin-dist/public/assets/tanstack-adapter-KSm-nO5L.js +1 -0
- package/admin-dist/public/assets/{taxonomies-DvILUNvr.js → taxonomies-CHjJKNlR.js} +1 -1
- package/admin-dist/public/assets/trash-Cle-tcqq.js +1 -0
- package/admin-dist/public/assets/{useBreadcrumbLabel-tlSh7dtO.js → useBreadcrumbLabel-yZQG_N_3.js} +1 -1
- package/admin-dist/public/assets/{usePermissions-BTGdTOJS.js → usePermissions-D6vsoaJf.js} +1 -1
- package/admin-dist/server/_libs/convex-helpers.mjs +1077 -2
- package/admin-dist/server/_libs/convex.mjs +222 -13
- package/admin-dist/server/_libs/lucide-react.mjs +57 -51
- package/admin-dist/server/_ssr/{CmsEmptyState-CB6e53i5.mjs → CmsEmptyState-DzzuQG0S.mjs} +1 -1
- package/admin-dist/server/_ssr/CmsFilterBar-C5XADS12.mjs +81 -0
- package/admin-dist/server/_ssr/{CmsPageHeader-COUHuECp.mjs → CmsPageHeader-DZ6h7smh.mjs} +1 -1
- package/admin-dist/server/_ssr/{CmsStatusBadge-kMTL6koE.mjs → CmsStatusBadge-D-YFSAa1.mjs} +3 -3
- package/admin-dist/server/_ssr/{CmsSurface-D1HDYjRg.mjs → CmsSurface-Cv51NBLZ.mjs} +1 -1
- package/admin-dist/server/_ssr/CmsTable-DG88C5nO.mjs +189 -0
- package/admin-dist/server/_ssr/{ContentEntryEditor-Bq8FR_uK.mjs → ContentEntryEditor-CRjwXB17.mjs} +10 -10
- package/admin-dist/server/_ssr/{TaxonomyFilter-bm_p4ADg.mjs → TaxonomyFilter-xGwcgtjr.mjs} +3 -3
- package/admin-dist/server/_ssr/{_contentTypeId-B7obLmi_.mjs → _contentTypeId-DRCfeKkm.mjs} +53 -12
- package/admin-dist/server/_ssr/{_entryId-B4zhQqFg.mjs → _entryId-DULm2TDy.mjs} +11 -11
- package/admin-dist/server/_ssr/_tanstack-start-manifest_v-iX3K33p1.mjs +4 -0
- package/admin-dist/server/_ssr/{badge-NOEC9bkk.mjs → badge-CbjIvhb6.mjs} +1 -1
- package/admin-dist/server/_ssr/{command-h4-OYNBo.mjs → command-xB2uiYps.mjs} +2 -2
- package/admin-dist/server/_ssr/{content-CShtLuhK.mjs → content-BfLBaJCZ.mjs} +108 -138
- package/admin-dist/server/_ssr/{content-types-PeyRyfbc.mjs → content-types-DZbF6O2q.mjs} +130 -119
- package/admin-dist/server/_ssr/{index-CplFXpGg.mjs → index-Cfe8sZv5.mjs} +65 -39
- package/admin-dist/server/_ssr/index.mjs +2 -2
- package/admin-dist/server/_ssr/{media-QAkNdX54.mjs → media-Bds2AnPC.mjs} +36 -56
- package/admin-dist/server/_ssr/{new._contentTypeId-DEJyMphJ.mjs → new._contentTypeId-DGvz_tlW.mjs} +10 -10
- package/admin-dist/server/_ssr/{router-CQXMuGMF.mjs → router-DxF7GBcO.mjs} +8804 -4995
- package/admin-dist/server/_ssr/{scroll-area-B7zoNyWB.mjs → scroll-area-DLDlXI07.mjs} +1 -1
- package/admin-dist/server/_ssr/{settings-CNaqVa4D.mjs → settings-BbaiS6z9.mjs} +13 -10
- package/admin-dist/server/_ssr/{switch-BKZhvryc.mjs → switch-Bl89Pfxu.mjs} +1 -1
- package/admin-dist/server/_ssr/{tabs-DtIIQxiD.mjs → tabs-QkbR0iir.mjs} +3 -3
- package/admin-dist/server/_ssr/{tanstack-adapter-CLavdbUY.mjs → tanstack-adapter-CKknPtcU.mjs} +19 -1
- package/admin-dist/server/_ssr/{taxonomies-vIZYICzr.mjs → taxonomies-S_Ontd0z.mjs} +9 -9
- package/admin-dist/server/_ssr/{trash-7yGR4-dF.mjs → trash-BzAIsbbN.mjs} +109 -132
- package/admin-dist/server/_ssr/{useBreadcrumbLabel-DR5FaAMf.mjs → useBreadcrumbLabel-BjiR1fM_.mjs} +1 -1
- package/admin-dist/server/_ssr/{usePermissions-DKkpETj_.mjs → usePermissions-CDHN95Nz.mjs} +1 -1
- package/admin-dist/server/index.mjs +284 -165
- package/package.json +3 -2
- package/admin/src/styles/globals.css +0 -82
- package/admin/src/styles/tailwind-config.css +0 -111
- package/admin/src/styles/theme.css +0 -384
- package/admin-dist/public/assets/CmsToolbar-CY6GV2L8.js +0 -1
- package/admin-dist/public/assets/ContentEntryEditor-CRgcRkk5.js +0 -4
- package/admin-dist/public/assets/TaxonomyFilter-Ohv5Jg9c.js +0 -1
- package/admin-dist/public/assets/_contentTypeId-C_vJq22X.js +0 -1
- package/admin-dist/public/assets/content-pKaIL2ru.js +0 -1
- package/admin-dist/public/assets/content-types-Bl_8I1Re.js +0 -1
- package/admin-dist/public/assets/globals-CoCRjt0K.css +0 -1
- package/admin-dist/public/assets/index-CtHq_P5q.js +0 -1
- package/admin-dist/public/assets/main-CA-4LyFT.js +0 -107
- package/admin-dist/public/assets/media-Bl1tBbJQ.js +0 -1
- package/admin-dist/public/assets/refresh-cw-sdVUGJNs.js +0 -1
- package/admin-dist/public/assets/rotate-ccw-6OcXCcxb.js +0 -1
- package/admin-dist/public/assets/settings-D8crrFCn.js +0 -1
- package/admin-dist/public/assets/tanstack-adapter-BRt2CUCw.js +0 -1
- package/admin-dist/public/assets/trash-YyYaC3L9.js +0 -1
- package/admin-dist/server/_ssr/CmsToolbar-NB014hsd.mjs +0 -48
- package/admin-dist/server/_ssr/_tanstack-start-manifest_v-DndoqCo7.mjs +0 -4
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import{l as Ie,j as a,L as Vt,h as W,r as h,I as Ke,as as O,s as In,q as At,at as dn,G as Te,ak as Yn,al as zn,a6 as Os,am as An,X as Pe,z as Es,o as Lt,au as Ws,$ as Ts,av as _s,S as Gt,b as Ut,c as Qt,d as Jt,e as Ce,g as $n,a9 as Rn,w as xt,m as $e,u as be,C as X,E as $t,D as Bn,A as Hn,Y as qn,B as Vn,a4 as Fs,Z as Ln,F as Rt,P as Xt,U as un,a as Ne,H as Gn,t as Ps,n as Un,f as Is,_ as Ys,aw as zs,i as fn}from"./main-CA-4LyFT.js";import{S as As}from"./switch-Ck9ecqEX.js";import{C as $s,T as Rs,a as Bs,b as mn,U as Hs,d as hn,c as qs,F as Vs,M as Ls,V as Gs}from"./tabs-vQYu8rjC.js";import{C as Qn}from"./CmsEmptyState-DTlpzjOI.js";import{P as Us}from"./pencil-gAL0R34f.js";import{S as Qs}from"./search-WXp6KxDJ.js";import{C as Js,a as Xs,b as Ks,d as Zs,f as er,c as tr}from"./command-CJ8i86fd.js";import{B as We}from"./badge-C6qt24oj.js";import{C as Kt}from"./CmsStatusBadge-D_n8u8xa.js";import{S as Zt}from"./scroll-area-CJBhf9pf.js";import{R as Jn}from"./refresh-cw-sdVUGJNs.js";import{C as Bt}from"./circle-check-big-PltpxuB1.js";const nr=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]],sr=Ie("arrow-right",nr);const rr=[["path",{d:"M6 12h9a4 4 0 0 1 0 8H7a1 1 0 0 1-1-1V5a1 1 0 0 1 1-1h7a4 4 0 0 1 0 8",key:"mg9rjx"}]],ar=Ie("bold",rr);const or=[["circle",{cx:"18",cy:"18",r:"3",key:"1xkwt0"}],["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M13 6h3a2 2 0 0 1 2 2v7",key:"1yeb86"}],["path",{d:"M11 18H8a2 2 0 0 1-2-2V9",key:"19pyzm"}]],ir=Ie("git-compare",or);const lr=[["path",{d:"M4 12h8",key:"17cfdx"}],["path",{d:"M4 18V6",key:"1rz3zl"}],["path",{d:"M12 18V6",key:"zqpxq5"}],["path",{d:"M21 18h-4c0-4 4-3 4-6 0-1.5-2-2.5-4-1",key:"9jr5yi"}]],cr=Ie("heading-2",lr);const dr=[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]],Xn=Ie("history",dr);const ur=[["line",{x1:"19",x2:"10",y1:"4",y2:"4",key:"15jd3p"}],["line",{x1:"14",x2:"5",y1:"20",y2:"20",key:"bu0au3"}],["line",{x1:"15",x2:"9",y1:"4",y2:"20",key:"uljnxc"}]],fr=Ie("italic",ur);const mr=[["path",{d:"M5 12h14",key:"1ays0h"}]],hr=Ie("minus",mr);const pr=[["path",{d:"M16 3a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2 1 1 0 0 1 1 1v1a2 2 0 0 1-2 2 1 1 0 0 0-1 1v2a1 1 0 0 0 1 1 6 6 0 0 0 6-6V5a2 2 0 0 0-2-2z",key:"rib7q0"}],["path",{d:"M5 3a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2 1 1 0 0 1 1 1v1a2 2 0 0 1-2 2 1 1 0 0 0-1 1v2a1 1 0 0 0 1 1 6 6 0 0 0 6-6V5a2 2 0 0 0-2-2z",key:"1ymkrd"}]],gr=Ie("quote",pr);function he({field:e,children:t,error:n,className:s="",id:r,customLabel:i}){const l=!!n;return a.jsxs("div",{className:W("space-y-2",s),children:[a.jsxs(Vt,{htmlFor:r,className:W("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",l&&"text-destructive"),children:[i??e.label,e.required&&a.jsx("span",{className:"ml-1 text-destructive",children:"*"})]}),a.jsx("div",{className:"relative",children:t}),e.description&&!l&&a.jsx("p",{id:`${r}-description`,className:"text-[13px] text-muted-foreground",children:e.description}),l&&a.jsx("p",{id:`${r}-error`,className:"text-[13px] font-medium text-destructive",role:"alert",children:n.message})]})}function xr({field:e,value:t,onChange:n,error:s,disabled:r=!1,readOnly:i=!1,className:l="",id:o,placeholder:c,inputType:d="text"}){const f=h.useId(),u=o??`field-${e.name}-${f}`,m=k=>{n(k.target.value)},{minLength:x,maxLength:p,pattern:M}=e.options??{};return a.jsxs(he,{field:e,error:s,className:l,id:u,children:[a.jsx(Ke,{type:d,id:u,name:e.name,value:t??"",onChange:m,disabled:r,readOnly:i,required:e.required,minLength:x,maxLength:p,pattern:M,placeholder:c,className:W(s&&"border-destructive focus-visible:ring-destructive"),"aria-invalid":!!s,"aria-describedby":s?`${u}-error`:e.description?`${u}-description`:void 0}),p&&a.jsxs("span",{className:"mt-1 block text-right text-xs text-muted-foreground",children:[(t??"").length," / ",p]})]})}function br({field:e,value:t,onChange:n,error:s,disabled:r=!1,readOnly:i=!1,className:l="",id:o,placeholder:c}){const d=h.useId(),f=o??`field-${e.name}-${d}`,u=g=>{const S=g.target.value;if(S===""){n(null);return}const w=parseFloat(S);if(!isNaN(w)){const{precision:b}=e.options??{};if(b!==void 0&&b>=0){const v=Math.pow(10,b);n(Math.round(w*v)/v)}else n(w)}},{min:m,max:x,step:p,precision:M}=e.options??{},k=p??(M!==void 0?Math.pow(10,-M):"any");return a.jsxs(he,{field:e,error:s,className:l,id:f,children:[a.jsx(Ke,{type:"number",id:f,name:e.name,value:t??"",onChange:u,disabled:r,readOnly:i,required:e.required,min:m,max:x,step:k,placeholder:c,className:W(s&&"border-destructive focus-visible:ring-destructive"),"aria-invalid":!!s,"aria-describedby":s?`${f}-error`:e.description?`${f}-description`:void 0}),(m!==void 0||x!==void 0)&&a.jsx("span",{className:"mt-1 block text-xs text-muted-foreground",children:m!==void 0&&x!==void 0?`Range: ${m} - ${x}`:m!==void 0?`Min: ${m}`:`Max: ${x}`})]})}function yr({field:e,value:t,onChange:n,error:s,disabled:r=!1,readOnly:i=!1,className:l="",id:o,trueLabel:c="Yes",falseLabel:d="No"}){const f=h.useId(),u=o??`field-${e.name}-${f}`,m=p=>{i||n(p)},x=!!s;return a.jsxs("div",{className:W("space-y-2",l),children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs(Vt,{htmlFor:u,className:W("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",x&&"text-destructive"),children:[e.label,e.required&&a.jsx("span",{className:"ml-1 text-destructive",children:"*"})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(As,{id:u,checked:t??!1,onCheckedChange:m,disabled:r||i,"aria-invalid":x,"aria-describedby":s?`${u}-error`:e.description?`${u}-description`:void 0}),a.jsx("span",{className:"text-sm text-muted-foreground",children:t?c:d})]})]}),e.description&&!x&&a.jsx("p",{id:`${u}-description`,className:"text-[13px] text-muted-foreground",children:e.description}),x&&a.jsx("p",{id:`${u}-error`,className:"text-[13px] font-medium text-destructive",role:"alert",children:s.message})]})}function vr(e,t,n="long"){return new Intl.DateTimeFormat("en-US",{hour:"numeric",timeZone:e,timeZoneName:n}).format(t).split(/\s/g).slice(2).join(" ")}const wr={},ot={};function Ae(e,t){try{const s=(wr[e]||=new Intl.DateTimeFormat("en-US",{timeZone:e,timeZoneName:"longOffset"}).format)(t).split("GMT")[1];return s in ot?ot[s]:pn(s,s.split(":"))}catch{if(e in ot)return ot[e];const n=e?.match(kr);return n?pn(e,n.slice(1)):NaN}}const kr=/([+-]\d\d):?(\d\d)?/;function pn(e,t){const n=+(t[0]||0),s=+(t[1]||0),r=+(t[2]||0)/60;return ot[e]=n*60+s>0?n*60+s+r:n*60-s-r}class Me extends Date{constructor(...t){super(),t.length>1&&typeof t[t.length-1]=="string"&&(this.timeZone=t.pop()),this.internal=new Date,isNaN(Ae(this.timeZone,this))?this.setTime(NaN):t.length?typeof t[0]=="number"&&(t.length===1||t.length===2&&typeof t[1]!="number")?this.setTime(t[0]):typeof t[0]=="string"?this.setTime(+new Date(t[0])):t[0]instanceof Date?this.setTime(+t[0]):(this.setTime(+new Date(...t)),Kn(this),Ht(this)):this.setTime(Date.now())}static tz(t,...n){return n.length?new Me(...n,t):new Me(Date.now(),t)}withTimeZone(t){return new Me(+this,t)}getTimezoneOffset(){const t=-Ae(this.timeZone,this);return t>0?Math.floor(t):Math.ceil(t)}setTime(t){return Date.prototype.setTime.apply(this,arguments),Ht(this),+this}[Symbol.for("constructDateFrom")](t){return new Me(+new Date(t),this.timeZone)}}const gn=/^(get|set)(?!UTC)/;Object.getOwnPropertyNames(Date.prototype).forEach(e=>{if(!gn.test(e))return;const t=e.replace(gn,"$1UTC");Me.prototype[t]&&(e.startsWith("get")?Me.prototype[e]=function(){return this.internal[t]()}:(Me.prototype[e]=function(){return Date.prototype[t].apply(this.internal,arguments),Nr(this),+this},Me.prototype[t]=function(){return Date.prototype[t].apply(this,arguments),Ht(this),+this}))});function Ht(e){e.internal.setTime(+e),e.internal.setUTCSeconds(e.internal.getUTCSeconds()-Math.round(-Ae(e.timeZone,e)*60))}function Nr(e){Date.prototype.setFullYear.call(e,e.internal.getUTCFullYear(),e.internal.getUTCMonth(),e.internal.getUTCDate()),Date.prototype.setHours.call(e,e.internal.getUTCHours(),e.internal.getUTCMinutes(),e.internal.getUTCSeconds(),e.internal.getUTCMilliseconds()),Kn(e)}function Kn(e){const t=Ae(e.timeZone,e),n=t>0?Math.floor(t):Math.ceil(t),s=new Date(+e);s.setUTCHours(s.getUTCHours()-1);const r=-new Date(+e).getTimezoneOffset(),i=-new Date(+s).getTimezoneOffset(),l=r-i,o=Date.prototype.getHours.apply(e)!==e.internal.getUTCHours();l&&o&&e.internal.setUTCMinutes(e.internal.getUTCMinutes()+l);const c=r-n;c&&Date.prototype.setUTCMinutes.call(e,Date.prototype.getUTCMinutes.call(e)+c);const d=new Date(+e);d.setUTCSeconds(0);const f=r>0?d.getSeconds():(d.getSeconds()-60)%60,u=Math.round(-(Ae(e.timeZone,e)*60))%60;(u||f)&&(e.internal.setUTCSeconds(e.internal.getUTCSeconds()+u),Date.prototype.setUTCSeconds.call(e,Date.prototype.getUTCSeconds.call(e)+u+f));const m=Ae(e.timeZone,e),x=m>0?Math.floor(m):Math.ceil(m),M=-new Date(+e).getTimezoneOffset()-x,k=x!==n,g=M-c;if(k&&g){Date.prototype.setUTCMinutes.call(e,Date.prototype.getUTCMinutes.call(e)+g);const S=Ae(e.timeZone,e),w=S>0?Math.floor(S):Math.ceil(S),b=x-w;b&&(e.internal.setUTCMinutes(e.internal.getUTCMinutes()+b),Date.prototype.setUTCMinutes.call(e,Date.prototype.getUTCMinutes.call(e)+b))}}class le extends Me{static tz(t,...n){return n.length?new le(...n,t):new le(Date.now(),t)}toISOString(){const[t,n,s]=this.tzComponents(),r=`${t}${n}:${s}`;return this.internal.toISOString().slice(0,-1)+r}toString(){return`${this.toDateString()} ${this.toTimeString()}`}toDateString(){const[t,n,s,r]=this.internal.toUTCString().split(" ");return`${t?.slice(0,-1)} ${s} ${n} ${r}`}toTimeString(){const t=this.internal.toUTCString().split(" ")[4],[n,s,r]=this.tzComponents();return`${t} GMT${n}${s}${r} (${vr(this.timeZone,this)})`}toLocaleString(t,n){return Date.prototype.toLocaleString.call(this,t,{...n,timeZone:n?.timeZone||this.timeZone})}toLocaleDateString(t,n){return Date.prototype.toLocaleDateString.call(this,t,{...n,timeZone:n?.timeZone||this.timeZone})}toLocaleTimeString(t,n){return Date.prototype.toLocaleTimeString.call(this,t,{...n,timeZone:n?.timeZone||this.timeZone})}tzComponents(){const t=this.getTimezoneOffset(),n=t>0?"-":"+",s=String(Math.floor(Math.abs(t)/60)).padStart(2,"0"),r=String(Math.abs(t)%60).padStart(2,"0");return[n,s,r]}withTimeZone(t){return new le(+this,t)}[Symbol.for("constructDateFrom")](t){return new le(+new Date(t),this.timeZone)}}const Zn=6048e5,jr=864e5,xn=Symbol.for("constructDateFrom");function ae(e,t){return typeof e=="function"?e(t):e&&typeof e=="object"&&xn in e?e[xn](t):e instanceof Date?new e.constructor(t):new Date(t)}function U(e,t){return ae(t||e,e)}function es(e,t,n){const s=U(e,n?.in);return isNaN(t)?ae(e,NaN):(t&&s.setDate(s.getDate()+t),s)}function ts(e,t,n){const s=U(e,n?.in);if(isNaN(t))return ae(e,NaN);if(!t)return s;const r=s.getDate(),i=ae(e,s.getTime());i.setMonth(s.getMonth()+t+1,0);const l=i.getDate();return r>=l?i:(s.setFullYear(i.getFullYear(),i.getMonth(),r),s)}let Mr={};function dt(){return Mr}function Xe(e,t){const n=dt(),s=t?.weekStartsOn??t?.locale?.options?.weekStartsOn??n.weekStartsOn??n.locale?.options?.weekStartsOn??0,r=U(e,t?.in),i=r.getDay(),l=(i<s?7:0)+i-s;return r.setDate(r.getDate()-l),r.setHours(0,0,0,0),r}function lt(e,t){return Xe(e,{...t,weekStartsOn:1})}function ns(e,t){const n=U(e,t?.in),s=n.getFullYear(),r=ae(n,0);r.setFullYear(s+1,0,4),r.setHours(0,0,0,0);const i=lt(r),l=ae(n,0);l.setFullYear(s,0,4),l.setHours(0,0,0,0);const o=lt(l);return n.getTime()>=i.getTime()?s+1:n.getTime()>=o.getTime()?s:s-1}function bn(e){const t=U(e),n=new Date(Date.UTC(t.getFullYear(),t.getMonth(),t.getDate(),t.getHours(),t.getMinutes(),t.getSeconds(),t.getMilliseconds()));return n.setUTCFullYear(t.getFullYear()),+e-+n}function Ze(e,...t){const n=ae.bind(null,t.find(s=>typeof s=="object"));return t.map(n)}function ct(e,t){const n=U(e,t?.in);return n.setHours(0,0,0,0),n}function en(e,t,n){const[s,r]=Ze(n?.in,e,t),i=ct(s),l=ct(r),o=+i-bn(i),c=+l-bn(l);return Math.round((o-c)/jr)}function Dr(e,t){const n=ns(e,t),s=ae(e,0);return s.setFullYear(n,0,4),s.setHours(0,0,0,0),lt(s)}function Sr(e,t,n){return es(e,t*7,n)}function Cr(e,t,n){return ts(e,t*12,n)}function Or(e,t){let n,s=t?.in;return e.forEach(r=>{!s&&typeof r=="object"&&(s=ae.bind(null,r));const i=U(r,s);(!n||n<i||isNaN(+i))&&(n=i)}),ae(s,n||NaN)}function Er(e,t){let n,s=t?.in;return e.forEach(r=>{!s&&typeof r=="object"&&(s=ae.bind(null,r));const i=U(r,s);(!n||n>i||isNaN(+i))&&(n=i)}),ae(s,n||NaN)}function Wr(e,t,n){const[s,r]=Ze(n?.in,e,t);return+ct(s)==+ct(r)}function ss(e){return e instanceof Date||typeof e=="object"&&Object.prototype.toString.call(e)==="[object Date]"}function Tr(e){return!(!ss(e)&&typeof e!="number"||isNaN(+U(e)))}function rs(e,t,n){const[s,r]=Ze(n?.in,e,t),i=s.getFullYear()-r.getFullYear(),l=s.getMonth()-r.getMonth();return i*12+l}function _r(e,t){const n=U(e,t?.in),s=n.getMonth();return n.setFullYear(n.getFullYear(),s+1,0),n.setHours(23,59,59,999),n}function as(e,t){const[n,s]=Ze(e,t.start,t.end);return{start:n,end:s}}function Fr(e,t){const{start:n,end:s}=as(t?.in,e);let r=+n>+s;const i=r?+n:+s,l=r?s:n;l.setHours(0,0,0,0),l.setDate(1);let o=1;const c=[];for(;+l<=i;)c.push(ae(n,l)),l.setMonth(l.getMonth()+o);return r?c.reverse():c}function Pr(e,t){const n=U(e,t?.in);return n.setDate(1),n.setHours(0,0,0,0),n}function Ir(e,t){const n=U(e,t?.in),s=n.getFullYear();return n.setFullYear(s+1,0,0),n.setHours(23,59,59,999),n}function os(e,t){const n=U(e,t?.in);return n.setFullYear(n.getFullYear(),0,1),n.setHours(0,0,0,0),n}function Yr(e,t){const{start:n,end:s}=as(t?.in,e);let r=+n>+s;const i=r?+n:+s,l=r?s:n;l.setHours(0,0,0,0),l.setMonth(0,1);let o=1;const c=[];for(;+l<=i;)c.push(ae(n,l)),l.setFullYear(l.getFullYear()+o);return r?c.reverse():c}function is(e,t){const n=dt(),s=t?.weekStartsOn??t?.locale?.options?.weekStartsOn??n.weekStartsOn??n.locale?.options?.weekStartsOn??0,r=U(e,t?.in),i=r.getDay(),l=(i<s?-7:0)+6-(i-s);return r.setDate(r.getDate()+l),r.setHours(23,59,59,999),r}function zr(e,t){return is(e,{...t,weekStartsOn:1})}const Ar={lessThanXSeconds:{one:"less than a second",other:"less than {{count}} seconds"},xSeconds:{one:"1 second",other:"{{count}} seconds"},halfAMinute:"half a minute",lessThanXMinutes:{one:"less than a minute",other:"less than {{count}} minutes"},xMinutes:{one:"1 minute",other:"{{count}} minutes"},aboutXHours:{one:"about 1 hour",other:"about {{count}} hours"},xHours:{one:"1 hour",other:"{{count}} hours"},xDays:{one:"1 day",other:"{{count}} days"},aboutXWeeks:{one:"about 1 week",other:"about {{count}} weeks"},xWeeks:{one:"1 week",other:"{{count}} weeks"},aboutXMonths:{one:"about 1 month",other:"about {{count}} months"},xMonths:{one:"1 month",other:"{{count}} months"},aboutXYears:{one:"about 1 year",other:"about {{count}} years"},xYears:{one:"1 year",other:"{{count}} years"},overXYears:{one:"over 1 year",other:"over {{count}} years"},almostXYears:{one:"almost 1 year",other:"almost {{count}} years"}},$r=(e,t,n)=>{let s;const r=Ar[e];return typeof r=="string"?s=r:t===1?s=r.one:s=r.other.replace("{{count}}",t.toString()),n?.addSuffix?n.comparison&&n.comparison>0?"in "+s:s+" ago":s};function _t(e){return(t={})=>{const n=t.width?String(t.width):e.defaultWidth;return e.formats[n]||e.formats[e.defaultWidth]}}const Rr={full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},Br={full:"h:mm:ss a zzzz",long:"h:mm:ss a z",medium:"h:mm:ss a",short:"h:mm a"},Hr={full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},qr={date:_t({formats:Rr,defaultWidth:"full"}),time:_t({formats:Br,defaultWidth:"full"}),dateTime:_t({formats:Hr,defaultWidth:"full"})},Vr={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"},Lr=(e,t,n,s)=>Vr[e];function rt(e){return(t,n)=>{const s=n?.context?String(n.context):"standalone";let r;if(s==="formatting"&&e.formattingValues){const l=e.defaultFormattingWidth||e.defaultWidth,o=n?.width?String(n.width):l;r=e.formattingValues[o]||e.formattingValues[l]}else{const l=e.defaultWidth,o=n?.width?String(n.width):e.defaultWidth;r=e.values[o]||e.values[l]}const i=e.argumentCallback?e.argumentCallback(t):t;return r[i]}}const Gr={narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},Ur={narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1st quarter","2nd quarter","3rd quarter","4th quarter"]},Qr={narrow:["J","F","M","A","M","J","J","A","S","O","N","D"],abbreviated:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],wide:["January","February","March","April","May","June","July","August","September","October","November","December"]},Jr={narrow:["S","M","T","W","T","F","S"],short:["Su","Mo","Tu","We","Th","Fr","Sa"],abbreviated:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],wide:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]},Xr={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"}},Kr={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"}},Zr=(e,t)=>{const n=Number(e),s=n%100;if(s>20||s<10)switch(s%10){case 1:return n+"st";case 2:return n+"nd";case 3:return n+"rd"}return n+"th"},ea={ordinalNumber:Zr,era:rt({values:Gr,defaultWidth:"wide"}),quarter:rt({values:Ur,defaultWidth:"wide",argumentCallback:e=>e-1}),month:rt({values:Qr,defaultWidth:"wide"}),day:rt({values:Jr,defaultWidth:"wide"}),dayPeriod:rt({values:Xr,defaultWidth:"wide",formattingValues:Kr,defaultFormattingWidth:"wide"})};function at(e){return(t,n={})=>{const s=n.width,r=s&&e.matchPatterns[s]||e.matchPatterns[e.defaultMatchWidth],i=t.match(r);if(!i)return null;const l=i[0],o=s&&e.parsePatterns[s]||e.parsePatterns[e.defaultParseWidth],c=Array.isArray(o)?na(o,u=>u.test(l)):ta(o,u=>u.test(l));let d;d=e.valueCallback?e.valueCallback(c):c,d=n.valueCallback?n.valueCallback(d):d;const f=t.slice(l.length);return{value:d,rest:f}}}function ta(e,t){for(const n in e)if(Object.prototype.hasOwnProperty.call(e,n)&&t(e[n]))return n}function na(e,t){for(let n=0;n<e.length;n++)if(t(e[n]))return n}function sa(e){return(t,n={})=>{const s=t.match(e.matchPattern);if(!s)return null;const r=s[0],i=t.match(e.parsePattern);if(!i)return null;let l=e.valueCallback?e.valueCallback(i[0]):i[0];l=n.valueCallback?n.valueCallback(l):l;const o=t.slice(r.length);return{value:l,rest:o}}}const ra=/^(\d+)(th|st|nd|rd)?/i,aa=/\d+/i,oa={narrow:/^(b|a)/i,abbreviated:/^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,wide:/^(before christ|before common era|anno domini|common era)/i},ia={any:[/^b/i,/^(a|c)/i]},la={narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},ca={any:[/1/i,/2/i,/3/i,/4/i]},da={narrow:/^[jfmasond]/i,abbreviated:/^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,wide:/^(january|february|march|april|may|june|july|august|september|october|november|december)/i},ua={narrow:[/^j/i,/^f/i,/^m/i,/^a/i,/^m/i,/^j/i,/^j/i,/^a/i,/^s/i,/^o/i,/^n/i,/^d/i],any:[/^ja/i,/^f/i,/^mar/i,/^ap/i,/^may/i,/^jun/i,/^jul/i,/^au/i,/^s/i,/^o/i,/^n/i,/^d/i]},fa={narrow:/^[smtwf]/i,short:/^(su|mo|tu|we|th|fr|sa)/i,abbreviated:/^(sun|mon|tue|wed|thu|fri|sat)/i,wide:/^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i},ma={narrow:[/^s/i,/^m/i,/^t/i,/^w/i,/^t/i,/^f/i,/^s/i],any:[/^su/i,/^m/i,/^tu/i,/^w/i,/^th/i,/^f/i,/^sa/i]},ha={narrow:/^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,any:/^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i},pa={any:{am:/^a/i,pm:/^p/i,midnight:/^mi/i,noon:/^no/i,morning:/morning/i,afternoon:/afternoon/i,evening:/evening/i,night:/night/i}},ga={ordinalNumber:sa({matchPattern:ra,parsePattern:aa,valueCallback:e=>parseInt(e,10)}),era:at({matchPatterns:oa,defaultMatchWidth:"wide",parsePatterns:ia,defaultParseWidth:"any"}),quarter:at({matchPatterns:la,defaultMatchWidth:"wide",parsePatterns:ca,defaultParseWidth:"any",valueCallback:e=>e+1}),month:at({matchPatterns:da,defaultMatchWidth:"wide",parsePatterns:ua,defaultParseWidth:"any"}),day:at({matchPatterns:fa,defaultMatchWidth:"wide",parsePatterns:ma,defaultParseWidth:"any"}),dayPeriod:at({matchPatterns:ha,defaultMatchWidth:"any",parsePatterns:pa,defaultParseWidth:"any"})},Je={code:"en-US",formatDistance:$r,formatLong:qr,formatRelative:Lr,localize:ea,match:ga,options:{weekStartsOn:0,firstWeekContainsDate:1}};function xa(e,t){const n=U(e,t?.in);return en(n,os(n))+1}function tn(e,t){const n=U(e,t?.in),s=+lt(n)-+Dr(n);return Math.round(s/Zn)+1}function ls(e,t){const n=U(e,t?.in),s=n.getFullYear(),r=dt(),i=t?.firstWeekContainsDate??t?.locale?.options?.firstWeekContainsDate??r.firstWeekContainsDate??r.locale?.options?.firstWeekContainsDate??1,l=ae(t?.in||e,0);l.setFullYear(s+1,0,i),l.setHours(0,0,0,0);const o=Xe(l,t),c=ae(t?.in||e,0);c.setFullYear(s,0,i),c.setHours(0,0,0,0);const d=Xe(c,t);return+n>=+o?s+1:+n>=+d?s:s-1}function ba(e,t){const n=dt(),s=t?.firstWeekContainsDate??t?.locale?.options?.firstWeekContainsDate??n.firstWeekContainsDate??n.locale?.options?.firstWeekContainsDate??1,r=ls(e,t),i=ae(t?.in||e,0);return i.setFullYear(r,0,s),i.setHours(0,0,0,0),Xe(i,t)}function nn(e,t){const n=U(e,t?.in),s=+Xe(n,t)-+ba(n,t);return Math.round(s/Zn)+1}function G(e,t){const n=e<0?"-":"",s=Math.abs(e).toString().padStart(t,"0");return n+s}const Fe={y(e,t){const n=e.getFullYear(),s=n>0?n:1-n;return G(t==="yy"?s%100:s,t.length)},M(e,t){const n=e.getMonth();return t==="M"?String(n+1):G(n+1,2)},d(e,t){return G(e.getDate(),t.length)},a(e,t){const n=e.getHours()/12>=1?"pm":"am";switch(t){case"a":case"aa":return n.toUpperCase();case"aaa":return n;case"aaaaa":return n[0];default:return n==="am"?"a.m.":"p.m."}},h(e,t){return G(e.getHours()%12||12,t.length)},H(e,t){return G(e.getHours(),t.length)},m(e,t){return G(e.getMinutes(),t.length)},s(e,t){return G(e.getSeconds(),t.length)},S(e,t){const n=t.length,s=e.getMilliseconds(),r=Math.trunc(s*Math.pow(10,n-3));return G(r,t.length)}},Ue={midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},yn={G:function(e,t,n){const s=e.getFullYear()>0?1:0;switch(t){case"G":case"GG":case"GGG":return n.era(s,{width:"abbreviated"});case"GGGGG":return n.era(s,{width:"narrow"});default:return n.era(s,{width:"wide"})}},y:function(e,t,n){if(t==="yo"){const s=e.getFullYear(),r=s>0?s:1-s;return n.ordinalNumber(r,{unit:"year"})}return Fe.y(e,t)},Y:function(e,t,n,s){const r=ls(e,s),i=r>0?r:1-r;if(t==="YY"){const l=i%100;return G(l,2)}return t==="Yo"?n.ordinalNumber(i,{unit:"year"}):G(i,t.length)},R:function(e,t){const n=ns(e);return G(n,t.length)},u:function(e,t){const n=e.getFullYear();return G(n,t.length)},Q:function(e,t,n){const s=Math.ceil((e.getMonth()+1)/3);switch(t){case"Q":return String(s);case"QQ":return G(s,2);case"Qo":return n.ordinalNumber(s,{unit:"quarter"});case"QQQ":return n.quarter(s,{width:"abbreviated",context:"formatting"});case"QQQQQ":return n.quarter(s,{width:"narrow",context:"formatting"});default:return n.quarter(s,{width:"wide",context:"formatting"})}},q:function(e,t,n){const s=Math.ceil((e.getMonth()+1)/3);switch(t){case"q":return String(s);case"qq":return G(s,2);case"qo":return n.ordinalNumber(s,{unit:"quarter"});case"qqq":return n.quarter(s,{width:"abbreviated",context:"standalone"});case"qqqqq":return n.quarter(s,{width:"narrow",context:"standalone"});default:return n.quarter(s,{width:"wide",context:"standalone"})}},M:function(e,t,n){const s=e.getMonth();switch(t){case"M":case"MM":return Fe.M(e,t);case"Mo":return n.ordinalNumber(s+1,{unit:"month"});case"MMM":return n.month(s,{width:"abbreviated",context:"formatting"});case"MMMMM":return n.month(s,{width:"narrow",context:"formatting"});default:return n.month(s,{width:"wide",context:"formatting"})}},L:function(e,t,n){const s=e.getMonth();switch(t){case"L":return String(s+1);case"LL":return G(s+1,2);case"Lo":return n.ordinalNumber(s+1,{unit:"month"});case"LLL":return n.month(s,{width:"abbreviated",context:"standalone"});case"LLLLL":return n.month(s,{width:"narrow",context:"standalone"});default:return n.month(s,{width:"wide",context:"standalone"})}},w:function(e,t,n,s){const r=nn(e,s);return t==="wo"?n.ordinalNumber(r,{unit:"week"}):G(r,t.length)},I:function(e,t,n){const s=tn(e);return t==="Io"?n.ordinalNumber(s,{unit:"week"}):G(s,t.length)},d:function(e,t,n){return t==="do"?n.ordinalNumber(e.getDate(),{unit:"date"}):Fe.d(e,t)},D:function(e,t,n){const s=xa(e);return t==="Do"?n.ordinalNumber(s,{unit:"dayOfYear"}):G(s,t.length)},E:function(e,t,n){const s=e.getDay();switch(t){case"E":case"EE":case"EEE":return n.day(s,{width:"abbreviated",context:"formatting"});case"EEEEE":return n.day(s,{width:"narrow",context:"formatting"});case"EEEEEE":return n.day(s,{width:"short",context:"formatting"});default:return n.day(s,{width:"wide",context:"formatting"})}},e:function(e,t,n,s){const r=e.getDay(),i=(r-s.weekStartsOn+8)%7||7;switch(t){case"e":return String(i);case"ee":return G(i,2);case"eo":return n.ordinalNumber(i,{unit:"day"});case"eee":return n.day(r,{width:"abbreviated",context:"formatting"});case"eeeee":return n.day(r,{width:"narrow",context:"formatting"});case"eeeeee":return n.day(r,{width:"short",context:"formatting"});default:return n.day(r,{width:"wide",context:"formatting"})}},c:function(e,t,n,s){const r=e.getDay(),i=(r-s.weekStartsOn+8)%7||7;switch(t){case"c":return String(i);case"cc":return G(i,t.length);case"co":return n.ordinalNumber(i,{unit:"day"});case"ccc":return n.day(r,{width:"abbreviated",context:"standalone"});case"ccccc":return n.day(r,{width:"narrow",context:"standalone"});case"cccccc":return n.day(r,{width:"short",context:"standalone"});default:return n.day(r,{width:"wide",context:"standalone"})}},i:function(e,t,n){const s=e.getDay(),r=s===0?7:s;switch(t){case"i":return String(r);case"ii":return G(r,t.length);case"io":return n.ordinalNumber(r,{unit:"day"});case"iii":return n.day(s,{width:"abbreviated",context:"formatting"});case"iiiii":return n.day(s,{width:"narrow",context:"formatting"});case"iiiiii":return n.day(s,{width:"short",context:"formatting"});default:return n.day(s,{width:"wide",context:"formatting"})}},a:function(e,t,n){const r=e.getHours()/12>=1?"pm":"am";switch(t){case"a":case"aa":return n.dayPeriod(r,{width:"abbreviated",context:"formatting"});case"aaa":return n.dayPeriod(r,{width:"abbreviated",context:"formatting"}).toLowerCase();case"aaaaa":return n.dayPeriod(r,{width:"narrow",context:"formatting"});default:return n.dayPeriod(r,{width:"wide",context:"formatting"})}},b:function(e,t,n){const s=e.getHours();let r;switch(s===12?r=Ue.noon:s===0?r=Ue.midnight:r=s/12>=1?"pm":"am",t){case"b":case"bb":return n.dayPeriod(r,{width:"abbreviated",context:"formatting"});case"bbb":return n.dayPeriod(r,{width:"abbreviated",context:"formatting"}).toLowerCase();case"bbbbb":return n.dayPeriod(r,{width:"narrow",context:"formatting"});default:return n.dayPeriod(r,{width:"wide",context:"formatting"})}},B:function(e,t,n){const s=e.getHours();let r;switch(s>=17?r=Ue.evening:s>=12?r=Ue.afternoon:s>=4?r=Ue.morning:r=Ue.night,t){case"B":case"BB":case"BBB":return n.dayPeriod(r,{width:"abbreviated",context:"formatting"});case"BBBBB":return n.dayPeriod(r,{width:"narrow",context:"formatting"});default:return n.dayPeriod(r,{width:"wide",context:"formatting"})}},h:function(e,t,n){if(t==="ho"){let s=e.getHours()%12;return s===0&&(s=12),n.ordinalNumber(s,{unit:"hour"})}return Fe.h(e,t)},H:function(e,t,n){return t==="Ho"?n.ordinalNumber(e.getHours(),{unit:"hour"}):Fe.H(e,t)},K:function(e,t,n){const s=e.getHours()%12;return t==="Ko"?n.ordinalNumber(s,{unit:"hour"}):G(s,t.length)},k:function(e,t,n){let s=e.getHours();return s===0&&(s=24),t==="ko"?n.ordinalNumber(s,{unit:"hour"}):G(s,t.length)},m:function(e,t,n){return t==="mo"?n.ordinalNumber(e.getMinutes(),{unit:"minute"}):Fe.m(e,t)},s:function(e,t,n){return t==="so"?n.ordinalNumber(e.getSeconds(),{unit:"second"}):Fe.s(e,t)},S:function(e,t){return Fe.S(e,t)},X:function(e,t,n){const s=e.getTimezoneOffset();if(s===0)return"Z";switch(t){case"X":return wn(s);case"XXXX":case"XX":return ze(s);default:return ze(s,":")}},x:function(e,t,n){const s=e.getTimezoneOffset();switch(t){case"x":return wn(s);case"xxxx":case"xx":return ze(s);default:return ze(s,":")}},O:function(e,t,n){const s=e.getTimezoneOffset();switch(t){case"O":case"OO":case"OOO":return"GMT"+vn(s,":");default:return"GMT"+ze(s,":")}},z:function(e,t,n){const s=e.getTimezoneOffset();switch(t){case"z":case"zz":case"zzz":return"GMT"+vn(s,":");default:return"GMT"+ze(s,":")}},t:function(e,t,n){const s=Math.trunc(+e/1e3);return G(s,t.length)},T:function(e,t,n){return G(+e,t.length)}};function vn(e,t=""){const n=e>0?"-":"+",s=Math.abs(e),r=Math.trunc(s/60),i=s%60;return i===0?n+String(r):n+String(r)+t+G(i,2)}function wn(e,t){return e%60===0?(e>0?"-":"+")+G(Math.abs(e)/60,2):ze(e,t)}function ze(e,t=""){const n=e>0?"-":"+",s=Math.abs(e),r=G(Math.trunc(s/60),2),i=G(s%60,2);return n+r+t+i}const kn=(e,t)=>{switch(e){case"P":return t.date({width:"short"});case"PP":return t.date({width:"medium"});case"PPP":return t.date({width:"long"});default:return t.date({width:"full"})}},cs=(e,t)=>{switch(e){case"p":return t.time({width:"short"});case"pp":return t.time({width:"medium"});case"ppp":return t.time({width:"long"});default:return t.time({width:"full"})}},ya=(e,t)=>{const n=e.match(/(P+)(p+)?/)||[],s=n[1],r=n[2];if(!r)return kn(e,t);let i;switch(s){case"P":i=t.dateTime({width:"short"});break;case"PP":i=t.dateTime({width:"medium"});break;case"PPP":i=t.dateTime({width:"long"});break;default:i=t.dateTime({width:"full"});break}return i.replace("{{date}}",kn(s,t)).replace("{{time}}",cs(r,t))},va={p:cs,P:ya},wa=/^D+$/,ka=/^Y+$/,Na=["D","DD","YY","YYYY"];function ja(e){return wa.test(e)}function Ma(e){return ka.test(e)}function Da(e,t,n){const s=Sa(e,t,n);if(console.warn(s),Na.includes(e))throw new RangeError(s)}function Sa(e,t,n){const s=e[0]==="Y"?"years":"days of the month";return`Use \`${e.toLowerCase()}\` instead of \`${e}\` (in \`${t}\`) for formatting ${s} to the input \`${n}\`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md`}const Ca=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,Oa=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,Ea=/^'([^]*?)'?$/,Wa=/''/g,Ta=/[a-zA-Z]/;function it(e,t,n){const s=dt(),r=n?.locale??s.locale??Je,i=n?.firstWeekContainsDate??n?.locale?.options?.firstWeekContainsDate??s.firstWeekContainsDate??s.locale?.options?.firstWeekContainsDate??1,l=n?.weekStartsOn??n?.locale?.options?.weekStartsOn??s.weekStartsOn??s.locale?.options?.weekStartsOn??0,o=U(e,n?.in);if(!Tr(o))throw new RangeError("Invalid time value");let c=t.match(Oa).map(f=>{const u=f[0];if(u==="p"||u==="P"){const m=va[u];return m(f,r.formatLong)}return f}).join("").match(Ca).map(f=>{if(f==="''")return{isToken:!1,value:"'"};const u=f[0];if(u==="'")return{isToken:!1,value:_a(f)};if(yn[u])return{isToken:!0,value:f};if(u.match(Ta))throw new RangeError("Format string contains an unescaped latin alphabet character `"+u+"`");return{isToken:!1,value:f}});r.localize.preprocessor&&(c=r.localize.preprocessor(o,c));const d={firstWeekContainsDate:i,weekStartsOn:l,locale:r};return c.map(f=>{if(!f.isToken)return f.value;const u=f.value;(!n?.useAdditionalWeekYearTokens&&Ma(u)||!n?.useAdditionalDayOfYearTokens&&ja(u))&&Da(u,t,String(e));const m=yn[u[0]];return m(o,u,r.localize,d)}).join("")}function _a(e){const t=e.match(Ea);return t?t[1].replace(Wa,"'"):e}function Fa(e,t){const n=U(e,t?.in),s=n.getFullYear(),r=n.getMonth(),i=ae(n,0);return i.setFullYear(s,r+1,0),i.setHours(0,0,0,0),i.getDate()}function Pa(e,t){return U(e,t?.in).getMonth()}function Ia(e,t){return U(e,t?.in).getFullYear()}function Ya(e,t){return+U(e)>+U(t)}function za(e,t){return+U(e)<+U(t)}function Aa(e,t,n){const[s,r]=Ze(n?.in,e,t);return s.getFullYear()===r.getFullYear()&&s.getMonth()===r.getMonth()}function $a(e,t,n){const[s,r]=Ze(n?.in,e,t);return s.getFullYear()===r.getFullYear()}function Ra(e,t,n){const s=U(e,n?.in),r=s.getFullYear(),i=s.getDate(),l=ae(e,0);l.setFullYear(r,t,15),l.setHours(0,0,0,0);const o=Fa(l);return s.setMonth(t,Math.min(i,o)),s}function Ba(e,t,n){const s=U(e,n?.in);return isNaN(+s)?ae(e,NaN):(s.setFullYear(t),s)}const Nn=5,Ha=4;function qa(e,t){const n=t.startOfMonth(e),s=n.getDay()>0?n.getDay():7,r=t.addDays(e,-s+1),i=t.addDays(r,Nn*7-1);return t.getMonth(e)===t.getMonth(i)?Nn:Ha}function ds(e,t){const n=t.startOfMonth(e),s=n.getDay();return s===1?n:s===0?t.addDays(n,-6):t.addDays(n,-1*(s-1))}function Va(e,t){const n=ds(e,t),s=qa(e,t);return t.addDays(n,s*7-1)}const us={...Je,labels:{labelDayButton:(e,t,n,s)=>{let r;s&&typeof s.format=="function"?r=s.format.bind(s):r=(l,o)=>it(l,o,{locale:Je,...n});let i=r(e,"PPPP");return t.today&&(i=`Today, ${i}`),t.selected&&(i=`${i}, selected`),i},labelMonthDropdown:"Choose the Month",labelNext:"Go to the Next Month",labelPrevious:"Go to the Previous Month",labelWeekNumber:e=>`Week ${e}`,labelYearDropdown:"Choose the Year",labelGrid:(e,t,n)=>{let s;return n&&typeof n.format=="function"?s=n.format.bind(n):s=(r,i)=>it(r,i,{locale:Je,...t}),s(e,"LLLL yyyy")},labelGridcell:(e,t,n,s)=>{let r;s&&typeof s.format=="function"?r=s.format.bind(s):r=(l,o)=>it(l,o,{locale:Je,...n});let i=r(e,"PPPP");return t?.today&&(i=`Today, ${i}`),i},labelNav:"Navigation bar",labelWeekNumberHeader:"Week Number",labelWeekday:(e,t,n)=>{let s;return n&&typeof n.format=="function"?s=n.format.bind(n):s=(r,i)=>it(r,i,{locale:Je,...t}),s(e,"cccc")}}};class fe{constructor(t,n){this.Date=Date,this.today=()=>this.overrides?.today?this.overrides.today():this.options.timeZone?le.tz(this.options.timeZone):new this.Date,this.newDate=(s,r,i)=>this.overrides?.newDate?this.overrides.newDate(s,r,i):this.options.timeZone?new le(s,r,i,this.options.timeZone):new Date(s,r,i),this.addDays=(s,r)=>this.overrides?.addDays?this.overrides.addDays(s,r):es(s,r),this.addMonths=(s,r)=>this.overrides?.addMonths?this.overrides.addMonths(s,r):ts(s,r),this.addWeeks=(s,r)=>this.overrides?.addWeeks?this.overrides.addWeeks(s,r):Sr(s,r),this.addYears=(s,r)=>this.overrides?.addYears?this.overrides.addYears(s,r):Cr(s,r),this.differenceInCalendarDays=(s,r)=>this.overrides?.differenceInCalendarDays?this.overrides.differenceInCalendarDays(s,r):en(s,r),this.differenceInCalendarMonths=(s,r)=>this.overrides?.differenceInCalendarMonths?this.overrides.differenceInCalendarMonths(s,r):rs(s,r),this.eachMonthOfInterval=s=>this.overrides?.eachMonthOfInterval?this.overrides.eachMonthOfInterval(s):Fr(s),this.eachYearOfInterval=s=>{const r=this.overrides?.eachYearOfInterval?this.overrides.eachYearOfInterval(s):Yr(s),i=new Set(r.map(o=>this.getYear(o)));if(i.size===r.length)return r;const l=[];return i.forEach(o=>{l.push(new Date(o,0,1))}),l},this.endOfBroadcastWeek=s=>this.overrides?.endOfBroadcastWeek?this.overrides.endOfBroadcastWeek(s):Va(s,this),this.endOfISOWeek=s=>this.overrides?.endOfISOWeek?this.overrides.endOfISOWeek(s):zr(s),this.endOfMonth=s=>this.overrides?.endOfMonth?this.overrides.endOfMonth(s):_r(s),this.endOfWeek=(s,r)=>this.overrides?.endOfWeek?this.overrides.endOfWeek(s,r):is(s,this.options),this.endOfYear=s=>this.overrides?.endOfYear?this.overrides.endOfYear(s):Ir(s),this.format=(s,r,i)=>{const l=this.overrides?.format?this.overrides.format(s,r,this.options):it(s,r,this.options);return this.options.numerals&&this.options.numerals!=="latn"?this.replaceDigits(l):l},this.getISOWeek=s=>this.overrides?.getISOWeek?this.overrides.getISOWeek(s):tn(s),this.getMonth=(s,r)=>this.overrides?.getMonth?this.overrides.getMonth(s,this.options):Pa(s,this.options),this.getYear=(s,r)=>this.overrides?.getYear?this.overrides.getYear(s,this.options):Ia(s,this.options),this.getWeek=(s,r)=>this.overrides?.getWeek?this.overrides.getWeek(s,this.options):nn(s,this.options),this.isAfter=(s,r)=>this.overrides?.isAfter?this.overrides.isAfter(s,r):Ya(s,r),this.isBefore=(s,r)=>this.overrides?.isBefore?this.overrides.isBefore(s,r):za(s,r),this.isDate=s=>this.overrides?.isDate?this.overrides.isDate(s):ss(s),this.isSameDay=(s,r)=>this.overrides?.isSameDay?this.overrides.isSameDay(s,r):Wr(s,r),this.isSameMonth=(s,r)=>this.overrides?.isSameMonth?this.overrides.isSameMonth(s,r):Aa(s,r),this.isSameYear=(s,r)=>this.overrides?.isSameYear?this.overrides.isSameYear(s,r):$a(s,r),this.max=s=>this.overrides?.max?this.overrides.max(s):Or(s),this.min=s=>this.overrides?.min?this.overrides.min(s):Er(s),this.setMonth=(s,r)=>this.overrides?.setMonth?this.overrides.setMonth(s,r):Ra(s,r),this.setYear=(s,r)=>this.overrides?.setYear?this.overrides.setYear(s,r):Ba(s,r),this.startOfBroadcastWeek=(s,r)=>this.overrides?.startOfBroadcastWeek?this.overrides.startOfBroadcastWeek(s,this):ds(s,this),this.startOfDay=s=>this.overrides?.startOfDay?this.overrides.startOfDay(s):ct(s),this.startOfISOWeek=s=>this.overrides?.startOfISOWeek?this.overrides.startOfISOWeek(s):lt(s),this.startOfMonth=s=>this.overrides?.startOfMonth?this.overrides.startOfMonth(s):Pr(s),this.startOfWeek=(s,r)=>this.overrides?.startOfWeek?this.overrides.startOfWeek(s,this.options):Xe(s,this.options),this.startOfYear=s=>this.overrides?.startOfYear?this.overrides.startOfYear(s):os(s),this.options={locale:us,...t},this.overrides=n}getDigitMap(){const{numerals:t="latn"}=this.options,n=new Intl.NumberFormat("en-US",{numberingSystem:t}),s={};for(let r=0;r<10;r++)s[r.toString()]=n.format(r);return s}replaceDigits(t){const n=this.getDigitMap();return t.replace(/\d/g,s=>n[s]||s)}formatNumber(t){return this.replaceDigits(t.toString())}getMonthYearOrder(){const t=this.options.locale?.code;return t&&fe.yearFirstLocales.has(t)?"year-first":"month-first"}formatMonthYear(t){const{locale:n,timeZone:s,numerals:r}=this.options,i=n?.code;if(i&&fe.yearFirstLocales.has(i))try{return new Intl.DateTimeFormat(i,{month:"long",year:"numeric",timeZone:s,numberingSystem:r}).format(t)}catch{}const l=this.getMonthYearOrder()==="year-first"?"y LLLL":"LLLL y";return this.format(t,l)}}fe.yearFirstLocales=new Set(["eu","hu","ja","ja-Hira","ja-JP","ko","ko-KR","lt","lt-LT","lv","lv-LV","mn","mn-MN","zh","zh-CN","zh-HK","zh-TW"]);const De=new fe;class fs{constructor(t,n,s=De){this.date=t,this.displayMonth=n,this.outside=!!(n&&!s.isSameMonth(t,n)),this.dateLib=s,this.isoDate=s.format(t,"yyyy-MM-dd"),this.displayMonthId=s.format(n,"yyyy-MM"),this.dateMonthId=s.format(t,"yyyy-MM")}isEqualTo(t){return this.dateLib.isSameDay(t.date,this.date)&&this.dateLib.isSameMonth(t.displayMonth,this.displayMonth)}}class La{constructor(t,n){this.date=t,this.weeks=n}}class Ga{constructor(t,n){this.days=n,this.weekNumber=t}}function Ua(e){return O.createElement("button",{...e})}function Qa(e){return O.createElement("span",{...e})}function Ja(e){const{size:t=24,orientation:n="left",className:s}=e;return O.createElement("svg",{className:s,width:t,height:t,viewBox:"0 0 24 24"},n==="up"&&O.createElement("polygon",{points:"6.77 17 12.5 11.43 18.24 17 20 15.28 12.5 8 5 15.28"}),n==="down"&&O.createElement("polygon",{points:"6.77 8 12.5 13.57 18.24 8 20 9.72 12.5 17 5 9.72"}),n==="left"&&O.createElement("polygon",{points:"16 18.112 9.81111111 12 16 5.87733333 14.0888889 4 6 12 14.0888889 20"}),n==="right"&&O.createElement("polygon",{points:"8 18.112 14.18888889 12 8 5.87733333 9.91111111 4 18 12 9.91111111 20"}))}function Xa(e){const{day:t,modifiers:n,...s}=e;return O.createElement("td",{...s})}function Ka(e){const{day:t,modifiers:n,...s}=e,r=O.useRef(null);return O.useEffect(()=>{n.focused&&r.current?.focus()},[n.focused]),O.createElement("button",{ref:r,...s})}var F;(function(e){e.Root="root",e.Chevron="chevron",e.Day="day",e.DayButton="day_button",e.CaptionLabel="caption_label",e.Dropdowns="dropdowns",e.Dropdown="dropdown",e.DropdownRoot="dropdown_root",e.Footer="footer",e.MonthGrid="month_grid",e.MonthCaption="month_caption",e.MonthsDropdown="months_dropdown",e.Month="month",e.Months="months",e.Nav="nav",e.NextMonthButton="button_next",e.PreviousMonthButton="button_previous",e.Week="week",e.Weeks="weeks",e.Weekday="weekday",e.Weekdays="weekdays",e.WeekNumber="week_number",e.WeekNumberHeader="week_number_header",e.YearsDropdown="years_dropdown"})(F||(F={}));var ee;(function(e){e.disabled="disabled",e.hidden="hidden",e.outside="outside",e.focused="focused",e.today="today"})(ee||(ee={}));var ye;(function(e){e.range_end="range_end",e.range_middle="range_middle",e.range_start="range_start",e.selected="selected"})(ye||(ye={}));var ue;(function(e){e.weeks_before_enter="weeks_before_enter",e.weeks_before_exit="weeks_before_exit",e.weeks_after_enter="weeks_after_enter",e.weeks_after_exit="weeks_after_exit",e.caption_after_enter="caption_after_enter",e.caption_after_exit="caption_after_exit",e.caption_before_enter="caption_before_enter",e.caption_before_exit="caption_before_exit"})(ue||(ue={}));function Za(e){const{options:t,className:n,components:s,classNames:r,...i}=e,l=[r[F.Dropdown],n].join(" "),o=t?.find(({value:c})=>c===i.value);return O.createElement("span",{"data-disabled":i.disabled,className:r[F.DropdownRoot]},O.createElement(s.Select,{className:l,...i},t?.map(({value:c,label:d,disabled:f})=>O.createElement(s.Option,{key:c,value:c,disabled:f},d))),O.createElement("span",{className:r[F.CaptionLabel],"aria-hidden":!0},o?.label,O.createElement(s.Chevron,{orientation:"down",size:18,className:r[F.Chevron]})))}function eo(e){return O.createElement("div",{...e})}function to(e){return O.createElement("div",{...e})}function no(e){const{calendarMonth:t,displayIndex:n,...s}=e;return O.createElement("div",{...s},e.children)}function so(e){const{calendarMonth:t,displayIndex:n,...s}=e;return O.createElement("div",{...s})}function ro(e){return O.createElement("table",{...e})}function ao(e){return O.createElement("div",{...e})}const ms=h.createContext(void 0);function ut(){const e=h.useContext(ms);if(e===void 0)throw new Error("useDayPicker() must be used within a custom component.");return e}function oo(e){const{components:t}=ut();return O.createElement(t.Dropdown,{...e})}function io(e){const{onPreviousClick:t,onNextClick:n,previousMonth:s,nextMonth:r,...i}=e,{components:l,classNames:o,labels:{labelPrevious:c,labelNext:d}}=ut(),f=h.useCallback(m=>{r&&n?.(m)},[r,n]),u=h.useCallback(m=>{s&&t?.(m)},[s,t]);return O.createElement("nav",{...i},O.createElement(l.PreviousMonthButton,{type:"button",className:o[F.PreviousMonthButton],tabIndex:s?void 0:-1,"aria-disabled":s?void 0:!0,"aria-label":c(s),onClick:u},O.createElement(l.Chevron,{disabled:s?void 0:!0,className:o[F.Chevron],orientation:"left"})),O.createElement(l.NextMonthButton,{type:"button",className:o[F.NextMonthButton],tabIndex:r?void 0:-1,"aria-disabled":r?void 0:!0,"aria-label":d(r),onClick:f},O.createElement(l.Chevron,{disabled:r?void 0:!0,orientation:"right",className:o[F.Chevron]})))}function lo(e){const{components:t}=ut();return O.createElement(t.Button,{...e})}function co(e){return O.createElement("option",{...e})}function uo(e){const{components:t}=ut();return O.createElement(t.Button,{...e})}function fo(e){const{rootRef:t,...n}=e;return O.createElement("div",{...n,ref:t})}function mo(e){return O.createElement("select",{...e})}function ho(e){const{week:t,...n}=e;return O.createElement("tr",{...n})}function po(e){return O.createElement("th",{...e})}function go(e){return O.createElement("thead",{"aria-hidden":!0},O.createElement("tr",{...e}))}function xo(e){const{week:t,...n}=e;return O.createElement("th",{...n})}function bo(e){return O.createElement("th",{...e})}function yo(e){return O.createElement("tbody",{...e})}function vo(e){const{components:t}=ut();return O.createElement(t.Dropdown,{...e})}const wo=Object.freeze(Object.defineProperty({__proto__:null,Button:Ua,CaptionLabel:Qa,Chevron:Ja,Day:Xa,DayButton:Ka,Dropdown:Za,DropdownNav:eo,Footer:to,Month:no,MonthCaption:so,MonthGrid:ro,Months:ao,MonthsDropdown:oo,Nav:io,NextMonthButton:lo,Option:co,PreviousMonthButton:uo,Root:fo,Select:mo,Week:ho,WeekNumber:xo,WeekNumberHeader:bo,Weekday:po,Weekdays:go,Weeks:yo,YearsDropdown:vo},Symbol.toStringTag,{value:"Module"}));function Oe(e,t,n=!1,s=De){let{from:r,to:i}=e;const{differenceInCalendarDays:l,isSameDay:o}=s;return r&&i?(l(i,r)<0&&([r,i]=[i,r]),l(t,r)>=(n?1:0)&&l(i,t)>=(n?1:0)):!n&&i?o(i,t):!n&&r?o(r,t):!1}function sn(e){return!!(e&&typeof e=="object"&&"before"in e&&"after"in e)}function bt(e){return!!(e&&typeof e=="object"&&"from"in e)}function rn(e){return!!(e&&typeof e=="object"&&"after"in e)}function an(e){return!!(e&&typeof e=="object"&&"before"in e)}function hs(e){return!!(e&&typeof e=="object"&&"dayOfWeek"in e)}function ps(e,t){return Array.isArray(e)&&e.every(t.isDate)}function Ee(e,t,n=De){const s=Array.isArray(t)?t:[t],{isSameDay:r,differenceInCalendarDays:i,isAfter:l}=n;return s.some(o=>{if(typeof o=="boolean")return o;if(n.isDate(o))return r(e,o);if(ps(o,n))return o.some(c=>r(e,c));if(bt(o))return Oe(o,e,!1,n);if(hs(o))return Array.isArray(o.dayOfWeek)?o.dayOfWeek.includes(e.getDay()):o.dayOfWeek===e.getDay();if(sn(o)){const c=i(o.before,e),d=i(o.after,e),f=c>0,u=d<0;return l(o.before,o.after)?u&&f:f||u}return rn(o)?i(e,o.after)>0:an(o)?i(o.before,e)>0:typeof o=="function"?o(e):!1})}function ko(e,t,n,s,r){const{disabled:i,hidden:l,modifiers:o,showOutsideDays:c,broadcastCalendar:d,today:f=r.today()}=t,{isSameDay:u,isSameMonth:m,startOfMonth:x,isBefore:p,endOfMonth:M,isAfter:k}=r,g=n&&x(n),S=s&&M(s),w={[ee.focused]:[],[ee.outside]:[],[ee.disabled]:[],[ee.hidden]:[],[ee.today]:[]},b={};for(const v of e){const{date:N,displayMonth:y}=v,T=!!(y&&!m(N,y)),I=!!(g&&p(N,g)),C=!!(S&&k(N,S)),L=!!(i&&Ee(N,i,r)),K=!!(l&&Ee(N,l,r))||I||C||!d&&!c&&T||d&&c===!1&&T,se=u(N,f);T&&w.outside.push(v),L&&w.disabled.push(v),K&&w.hidden.push(v),se&&w.today.push(v),o&&Object.keys(o).forEach(Z=>{const ne=o?.[Z];ne&&Ee(N,ne,r)&&(b[Z]?b[Z].push(v):b[Z]=[v])})}return v=>{const N={[ee.focused]:!1,[ee.disabled]:!1,[ee.hidden]:!1,[ee.outside]:!1,[ee.today]:!1},y={};for(const T in w){const I=w[T];N[T]=I.some(C=>C===v)}for(const T in b)y[T]=b[T].some(I=>I===v);return{...N,...y}}}function No(e,t,n={}){return Object.entries(e).filter(([,r])=>r===!0).reduce((r,[i])=>(n[i]?r.push(n[i]):t[ee[i]]?r.push(t[ee[i]]):t[ye[i]]&&r.push(t[ye[i]]),r),[t[F.Day]])}function jo(e){return{...wo,...e}}function Mo(e){const t={"data-mode":e.mode??void 0,"data-required":"required"in e?e.required:void 0,"data-multiple-months":e.numberOfMonths&&e.numberOfMonths>1||void 0,"data-week-numbers":e.showWeekNumber||void 0,"data-broadcast-calendar":e.broadcastCalendar||void 0,"data-nav-layout":e.navLayout||void 0};return Object.entries(e).forEach(([n,s])=>{n.startsWith("data-")&&(t[n]=s)}),t}function on(){const e={};for(const t in F)e[F[t]]=`rdp-${F[t]}`;for(const t in ee)e[ee[t]]=`rdp-${ee[t]}`;for(const t in ye)e[ye[t]]=`rdp-${ye[t]}`;for(const t in ue)e[ue[t]]=`rdp-${ue[t]}`;return e}function gs(e,t,n){return(n??new fe(t)).formatMonthYear(e)}const Do=gs;function So(e,t,n){return(n??new fe(t)).format(e,"d")}function Co(e,t=De){return t.format(e,"LLLL")}function Oo(e,t,n){return(n??new fe(t)).format(e,"cccccc")}function Eo(e,t=De){return e<10?t.formatNumber(`0${e.toLocaleString()}`):t.formatNumber(`${e.toLocaleString()}`)}function Wo(){return""}function xs(e,t=De){return t.format(e,"yyyy")}const To=xs,_o=Object.freeze(Object.defineProperty({__proto__:null,formatCaption:gs,formatDay:So,formatMonthCaption:Do,formatMonthDropdown:Co,formatWeekNumber:Eo,formatWeekNumberHeader:Wo,formatWeekdayName:Oo,formatYearCaption:To,formatYearDropdown:xs},Symbol.toStringTag,{value:"Module"}));function Fo(e){return e?.formatMonthCaption&&!e.formatCaption&&(e.formatCaption=e.formatMonthCaption),e?.formatYearCaption&&!e.formatYearDropdown&&(e.formatYearDropdown=e.formatYearCaption),{..._o,...e}}function ln(e,t,n,s){let r=(s??new fe(n)).format(e,"PPPP");return t.today&&(r=`Today, ${r}`),t.selected&&(r=`${r}, selected`),r}const Po=ln;function cn(e,t,n){return(n??new fe(t)).formatMonthYear(e)}const Io=cn;function bs(e,t,n,s){let r=(s??new fe(n)).format(e,"PPPP");return t?.today&&(r=`Today, ${r}`),r}function ys(e){return"Choose the Month"}function vs(){return""}const Yo="Go to the Next Month";function ws(e,t){return Yo}function ks(e){return"Go to the Previous Month"}function Ns(e,t,n){return(n??new fe(t)).format(e,"cccc")}function js(e,t){return`Week ${e}`}function Ms(e){return"Week Number"}function Ds(e){return"Choose the Year"}const zo=Object.freeze(Object.defineProperty({__proto__:null,labelCaption:Io,labelDay:Po,labelDayButton:ln,labelGrid:cn,labelGridcell:bs,labelMonthDropdown:ys,labelNav:vs,labelNext:ws,labelPrevious:ks,labelWeekNumber:js,labelWeekNumberHeader:Ms,labelWeekday:Ns,labelYearDropdown:Ds},Symbol.toStringTag,{value:"Module"})),xe=(e,t,n)=>t||(n?typeof n=="function"?n:(...s)=>n:e);function Ao(e,t){const n=t.locale?.labels??{};return{...zo,...e??{},labelDayButton:xe(ln,e?.labelDayButton,n.labelDayButton),labelMonthDropdown:xe(ys,e?.labelMonthDropdown,n.labelMonthDropdown),labelNext:xe(ws,e?.labelNext,n.labelNext),labelPrevious:xe(ks,e?.labelPrevious,n.labelPrevious),labelWeekNumber:xe(js,e?.labelWeekNumber,n.labelWeekNumber),labelYearDropdown:xe(Ds,e?.labelYearDropdown,n.labelYearDropdown),labelGrid:xe(cn,e?.labelGrid,n.labelGrid),labelGridcell:xe(bs,e?.labelGridcell,n.labelGridcell),labelNav:xe(vs,e?.labelNav,n.labelNav),labelWeekNumberHeader:xe(Ms,e?.labelWeekNumberHeader,n.labelWeekNumberHeader),labelWeekday:xe(Ns,e?.labelWeekday,n.labelWeekday)}}function $o(e,t,n,s,r){const{startOfMonth:i,startOfYear:l,endOfYear:o,eachMonthOfInterval:c,getMonth:d}=r;return c({start:l(e),end:o(e)}).map(m=>{const x=s.formatMonthDropdown(m,r),p=d(m),M=t&&m<i(t)||n&&m>i(n)||!1;return{value:p,label:x,disabled:M}})}function Ro(e,t={},n={}){let s={...t?.[F.Day]};return Object.entries(e).filter(([,r])=>r===!0).forEach(([r])=>{s={...s,...n?.[r]}}),s}function Bo(e,t,n,s){const r=s??e.today(),i=n?e.startOfBroadcastWeek(r,e):t?e.startOfISOWeek(r):e.startOfWeek(r),l=[];for(let o=0;o<7;o++){const c=e.addDays(i,o);l.push(c)}return l}function Ho(e,t,n,s,r=!1){if(!e||!t)return;const{startOfYear:i,endOfYear:l,eachYearOfInterval:o,getYear:c}=s,d=i(e),f=l(t),u=o({start:d,end:f});return r&&u.reverse(),u.map(m=>{const x=n.formatYearDropdown(m,s);return{value:c(m),label:x,disabled:!1}})}function qo(e,t={}){const{weekStartsOn:n,locale:s}=t,r=n??s?.options?.weekStartsOn??0,i=o=>{const c=typeof o=="number"||typeof o=="string"?new Date(o):o;return new le(c.getFullYear(),c.getMonth(),c.getDate(),12,0,0,e)},l=o=>{const c=i(o);return new Date(c.getFullYear(),c.getMonth(),c.getDate(),0,0,0,0)};return{today:()=>i(le.tz(e)),newDate:(o,c,d)=>new le(o,c,d,12,0,0,e),startOfDay:o=>i(o),startOfWeek:(o,c)=>{const d=i(o),f=c?.weekStartsOn??r,u=(d.getDay()-f+7)%7;return d.setDate(d.getDate()-u),d},startOfISOWeek:o=>{const c=i(o),d=(c.getDay()-1+7)%7;return c.setDate(c.getDate()-d),c},startOfMonth:o=>{const c=i(o);return c.setDate(1),c},startOfYear:o=>{const c=i(o);return c.setMonth(0,1),c},endOfWeek:(o,c)=>{const d=i(o),m=(((c?.weekStartsOn??r)+6)%7-d.getDay()+7)%7;return d.setDate(d.getDate()+m),d},endOfISOWeek:o=>{const c=i(o),d=(7-c.getDay())%7;return c.setDate(c.getDate()+d),c},endOfMonth:o=>{const c=i(o);return c.setMonth(c.getMonth()+1,0),c},endOfYear:o=>{const c=i(o);return c.setMonth(11,31),c},eachMonthOfInterval:o=>{const c=i(o.start),d=i(o.end),f=[],u=new le(c.getFullYear(),c.getMonth(),1,12,0,0,e),m=d.getFullYear()*12+d.getMonth();for(;u.getFullYear()*12+u.getMonth()<=m;)f.push(new le(u,e)),u.setMonth(u.getMonth()+1,1);return f},addDays:(o,c)=>{const d=i(o);return d.setDate(d.getDate()+c),d},addWeeks:(o,c)=>{const d=i(o);return d.setDate(d.getDate()+c*7),d},addMonths:(o,c)=>{const d=i(o);return d.setMonth(d.getMonth()+c),d},addYears:(o,c)=>{const d=i(o);return d.setFullYear(d.getFullYear()+c),d},eachYearOfInterval:o=>{const c=i(o.start),d=i(o.end),f=[],u=new le(c.getFullYear(),0,1,12,0,0,e);for(;u.getFullYear()<=d.getFullYear();)f.push(new le(u,e)),u.setFullYear(u.getFullYear()+1,0,1);return f},getWeek:(o,c)=>{const d=l(o);return nn(d,{weekStartsOn:c?.weekStartsOn??r,firstWeekContainsDate:c?.firstWeekContainsDate??s?.options?.firstWeekContainsDate??1})},getISOWeek:o=>{const c=l(o);return tn(c)},differenceInCalendarDays:(o,c)=>{const d=l(o),f=l(c);return en(d,f)},differenceInCalendarMonths:(o,c)=>{const d=l(o),f=l(c);return rs(d,f)}}}const ft=e=>e instanceof HTMLElement?e:null,Ft=e=>[...e.querySelectorAll("[data-animated-month]")??[]],Vo=e=>ft(e.querySelector("[data-animated-month]")),Pt=e=>ft(e.querySelector("[data-animated-caption]")),It=e=>ft(e.querySelector("[data-animated-weeks]")),Lo=e=>ft(e.querySelector("[data-animated-nav]")),Go=e=>ft(e.querySelector("[data-animated-weekdays]"));function Uo(e,t,{classNames:n,months:s,focused:r,dateLib:i}){const l=h.useRef(null),o=h.useRef(s),c=h.useRef(!1);h.useLayoutEffect(()=>{const d=o.current;if(o.current=s,!t||!e.current||!(e.current instanceof HTMLElement)||s.length===0||d.length===0||s.length!==d.length)return;const f=i.isSameMonth(s[0].date,d[0].date),u=i.isAfter(s[0].date,d[0].date),m=u?n[ue.caption_after_enter]:n[ue.caption_before_enter],x=u?n[ue.weeks_after_enter]:n[ue.weeks_before_enter],p=l.current,M=e.current.cloneNode(!0);if(M instanceof HTMLElement?(Ft(M).forEach(w=>{if(!(w instanceof HTMLElement))return;const b=Vo(w);b&&w.contains(b)&&w.removeChild(b);const v=Pt(w);v&&v.classList.remove(m);const N=It(w);N&&N.classList.remove(x)}),l.current=M):l.current=null,c.current||f||r)return;const k=p instanceof HTMLElement?Ft(p):[],g=Ft(e.current);if(g?.every(S=>S instanceof HTMLElement)&&k&&k.every(S=>S instanceof HTMLElement)){c.current=!0,e.current.style.isolation="isolate";const S=Lo(e.current);S&&(S.style.zIndex="1"),g.forEach((w,b)=>{const v=k[b];if(!v)return;w.style.position="relative",w.style.overflow="hidden";const N=Pt(w);N&&N.classList.add(m);const y=It(w);y&&y.classList.add(x);const T=()=>{c.current=!1,e.current&&(e.current.style.isolation=""),S&&(S.style.zIndex=""),N&&N.classList.remove(m),y&&y.classList.remove(x),w.style.position="",w.style.overflow="",w.contains(v)&&w.removeChild(v)};v.style.pointerEvents="none",v.style.position="absolute",v.style.overflow="hidden",v.setAttribute("aria-hidden","true");const I=Go(v);I&&(I.style.opacity="0");const C=Pt(v);C&&(C.classList.add(u?n[ue.caption_before_exit]:n[ue.caption_after_exit]),C.addEventListener("animationend",T));const L=It(v);L&&L.classList.add(u?n[ue.weeks_before_exit]:n[ue.weeks_after_exit]),w.insertBefore(v,w.firstChild)})}})}function Qo(e,t,n,s){const r=e[0],i=e[e.length-1],{ISOWeek:l,fixedWeeks:o,broadcastCalendar:c}=n??{},{addDays:d,differenceInCalendarDays:f,differenceInCalendarMonths:u,endOfBroadcastWeek:m,endOfISOWeek:x,endOfMonth:p,endOfWeek:M,isAfter:k,startOfBroadcastWeek:g,startOfISOWeek:S,startOfWeek:w}=s,b=c?g(r,s):l?S(r):w(r),v=c?m(i):l?x(p(i)):M(p(i)),N=t&&(c?m(t):l?x(t):M(t)),y=N&&k(v,N)?N:v,T=f(y,b),I=u(i,r)+1,C=[];for(let se=0;se<=T;se++){const Z=d(b,se);C.push(Z)}const K=(c?35:42)*I;if(o&&C.length<K){const se=K-C.length;for(let Z=0;Z<se;Z++){const ne=d(C[C.length-1],1);C.push(ne)}}return C}function Jo(e){const t=[];return e.reduce((n,s)=>{const r=s.weeks.reduce((i,l)=>i.concat(l.days.slice()),t.slice());return n.concat(r.slice())},t.slice())}function Xo(e,t,n,s){const{numberOfMonths:r=1}=n,i=[];for(let l=0;l<r;l++){const o=s.addMonths(e,l);if(t&&o>t)break;i.push(o)}return i}function jn(e,t,n,s){const{month:r,defaultMonth:i,today:l=s.today(),numberOfMonths:o=1}=e;let c=r||i||l;const{differenceInCalendarMonths:d,addMonths:f,startOfMonth:u}=s;if(n&&d(n,c)<o-1){const m=-1*(o-1);c=f(n,m)}return t&&d(c,t)<0&&(c=t),u(c)}function Ko(e,t,n,s){const{addDays:r,endOfBroadcastWeek:i,endOfISOWeek:l,endOfMonth:o,endOfWeek:c,getISOWeek:d,getWeek:f,startOfBroadcastWeek:u,startOfISOWeek:m,startOfWeek:x}=s,p=e.reduce((M,k)=>{const g=n.broadcastCalendar?u(k,s):n.ISOWeek?m(k):x(k),S=n.broadcastCalendar?i(k):n.ISOWeek?l(o(k)):c(o(k)),w=t.filter(y=>y>=g&&y<=S),b=n.broadcastCalendar?35:42;if(n.fixedWeeks&&w.length<b){const y=t.filter(T=>{const I=b-w.length;return T>S&&T<=r(S,I)});w.push(...y)}const v=w.reduce((y,T)=>{const I=n.ISOWeek?d(T):f(T),C=y.find(K=>K.weekNumber===I),L=new fs(T,k,s);return C?C.days.push(L):y.push(new Ga(I,[L])),y},[]),N=new La(k,v);return M.push(N),M},[]);return n.reverseMonths?p.reverse():p}function Zo(e,t){let{startMonth:n,endMonth:s}=e;const{startOfYear:r,startOfDay:i,startOfMonth:l,endOfMonth:o,addYears:c,endOfYear:d,newDate:f,today:u}=t,{fromYear:m,toYear:x,fromMonth:p,toMonth:M}=e;!n&&p&&(n=p),!n&&m&&(n=t.newDate(m,0,1)),!s&&M&&(s=M),!s&&x&&(s=f(x,11,31));const k=e.captionLayout==="dropdown"||e.captionLayout==="dropdown-years";return n?n=l(n):m?n=f(m,0,1):!n&&k&&(n=r(c(e.today??u(),-100))),s?s=o(s):x?s=f(x,11,31):!s&&k&&(s=d(e.today??u())),[n&&i(n),s&&i(s)]}function ei(e,t,n,s){if(n.disableNavigation)return;const{pagedNavigation:r,numberOfMonths:i=1}=n,{startOfMonth:l,addMonths:o,differenceInCalendarMonths:c}=s,d=r?i:1,f=l(e);if(!t)return o(f,d);if(!(c(t,e)<i))return o(f,d)}function ti(e,t,n,s){if(n.disableNavigation)return;const{pagedNavigation:r,numberOfMonths:i}=n,{startOfMonth:l,addMonths:o,differenceInCalendarMonths:c}=s,d=r?i??1:1,f=l(e);if(!t)return o(f,-d);if(!(c(f,t)<=0))return o(f,-d)}function ni(e){const t=[];return e.reduce((n,s)=>n.concat(s.weeks.slice()),t.slice())}function yt(e,t){const[n,s]=h.useState(e);return[t===void 0?n:t,s]}function si(e,t){const[n,s]=Zo(e,t),{startOfMonth:r,endOfMonth:i}=t,l=jn(e,n,s,t),[o,c]=yt(l,e.month?l:void 0);h.useEffect(()=>{const b=jn(e,n,s,t);c(b)},[e.timeZone]);const{months:d,weeks:f,days:u,previousMonth:m,nextMonth:x}=h.useMemo(()=>{const b=Xo(o,s,{numberOfMonths:e.numberOfMonths},t),v=Qo(b,e.endMonth?i(e.endMonth):void 0,{ISOWeek:e.ISOWeek,fixedWeeks:e.fixedWeeks,broadcastCalendar:e.broadcastCalendar},t),N=Ko(b,v,{broadcastCalendar:e.broadcastCalendar,fixedWeeks:e.fixedWeeks,ISOWeek:e.ISOWeek,reverseMonths:e.reverseMonths},t),y=ni(N),T=Jo(N),I=ti(o,n,e,t),C=ei(o,s,e,t);return{months:N,weeks:y,days:T,previousMonth:I,nextMonth:C}},[t,o.getTime(),s?.getTime(),n?.getTime(),e.disableNavigation,e.broadcastCalendar,e.endMonth?.getTime(),e.fixedWeeks,e.ISOWeek,e.numberOfMonths,e.pagedNavigation,e.reverseMonths]),{disableNavigation:p,onMonthChange:M}=e,k=b=>f.some(v=>v.days.some(N=>N.isEqualTo(b))),g=b=>{if(p)return;let v=r(b);n&&v<r(n)&&(v=r(n)),s&&v>r(s)&&(v=r(s)),c(v),M?.(v)};return{months:d,weeks:f,days:u,navStart:n,navEnd:s,previousMonth:m,nextMonth:x,goToMonth:g,goToDay:b=>{k(b)||g(b.date)}}}var je;(function(e){e[e.Today=0]="Today",e[e.Selected=1]="Selected",e[e.LastFocused=2]="LastFocused",e[e.FocusedModifier=3]="FocusedModifier"})(je||(je={}));function Mn(e){return!e[ee.disabled]&&!e[ee.hidden]&&!e[ee.outside]}function ri(e,t,n,s){let r,i=-1;for(const l of e){const o=t(l);Mn(o)&&(o[ee.focused]&&i<je.FocusedModifier?(r=l,i=je.FocusedModifier):s?.isEqualTo(l)&&i<je.LastFocused?(r=l,i=je.LastFocused):n(l.date)&&i<je.Selected?(r=l,i=je.Selected):o[ee.today]&&i<je.Today&&(r=l,i=je.Today))}return r||(r=e.find(l=>Mn(t(l)))),r}function ai(e,t,n,s,r,i,l){const{ISOWeek:o,broadcastCalendar:c}=i,{addDays:d,addMonths:f,addWeeks:u,addYears:m,endOfBroadcastWeek:x,endOfISOWeek:p,endOfWeek:M,max:k,min:g,startOfBroadcastWeek:S,startOfISOWeek:w,startOfWeek:b}=l;let N={day:d,week:u,month:f,year:m,startOfWeek:y=>c?S(y,l):o?w(y):b(y),endOfWeek:y=>c?x(y):o?p(y):M(y)}[e](n,t==="after"?1:-1);return t==="before"&&s?N=k([s,N]):t==="after"&&r&&(N=g([r,N])),N}function Ss(e,t,n,s,r,i,l,o=0){if(o>365)return;const c=ai(e,t,n.date,s,r,i,l),d=!!(i.disabled&&Ee(c,i.disabled,l)),f=!!(i.hidden&&Ee(c,i.hidden,l)),u=c,m=new fs(c,u,l);return!d&&!f?m:Ss(e,t,m,s,r,i,l,o+1)}function oi(e,t,n,s,r){const{autoFocus:i}=e,[l,o]=h.useState(),c=ri(t.days,n,s||(()=>!1),l),[d,f]=h.useState(i?c:void 0);return{isFocusTarget:M=>!!c?.isEqualTo(M),setFocused:f,focused:d,blur:()=>{o(d),f(void 0)},moveFocus:(M,k)=>{if(!d)return;const g=Ss(M,k,d,t.navStart,t.navEnd,e,r);g&&(e.disableNavigation&&!t.days.some(w=>w.isEqualTo(g))||(t.goToDay(g),f(g)))}}}function ii(e,t){const{selected:n,required:s,onSelect:r}=e,[i,l]=yt(n,r?n:void 0),o=r?n:i,{isSameDay:c}=t,d=x=>o?.some(p=>c(p,x))??!1,{min:f,max:u}=e;return{selected:o,select:(x,p,M)=>{let k=[...o??[]];if(d(x)){if(o?.length===f||s&&o?.length===1)return;k=o?.filter(g=>!c(g,x))}else o?.length===u?k=[x]:k=[...k,x];return r||l(k),r?.(k,x,p,M),k},isSelected:d}}function li(e,t,n=0,s=0,r=!1,i=De){const{from:l,to:o}=t||{},{isSameDay:c,isAfter:d,isBefore:f}=i;let u;if(!l&&!o)u={from:e,to:n>0?void 0:e};else if(l&&!o)c(l,e)?n===0?u={from:l,to:e}:r?u={from:l,to:void 0}:u=void 0:f(e,l)?u={from:e,to:l}:u={from:l,to:e};else if(l&&o)if(c(l,e)&&c(o,e))r?u={from:l,to:o}:u=void 0;else if(c(l,e))u={from:l,to:n>0?void 0:e};else if(c(o,e))u={from:e,to:n>0?void 0:e};else if(f(e,l))u={from:e,to:o};else if(d(e,l))u={from:l,to:e};else if(d(e,o))u={from:l,to:e};else throw new Error("Invalid range");if(u?.from&&u?.to){const m=i.differenceInCalendarDays(u.to,u.from);s>0&&m>s?u={from:e,to:void 0}:n>1&&m<n&&(u={from:e,to:void 0})}return u}function ci(e,t,n=De){const s=Array.isArray(t)?t:[t];let r=e.from;const i=n.differenceInCalendarDays(e.to,e.from),l=Math.min(i,6);for(let o=0;o<=l;o++){if(s.includes(r.getDay()))return!0;r=n.addDays(r,1)}return!1}function Dn(e,t,n=De){return Oe(e,t.from,!1,n)||Oe(e,t.to,!1,n)||Oe(t,e.from,!1,n)||Oe(t,e.to,!1,n)}function di(e,t,n=De){const s=Array.isArray(t)?t:[t];if(s.filter(o=>typeof o!="function").some(o=>typeof o=="boolean"?o:n.isDate(o)?Oe(e,o,!1,n):ps(o,n)?o.some(c=>Oe(e,c,!1,n)):bt(o)?o.from&&o.to?Dn(e,{from:o.from,to:o.to},n):!1:hs(o)?ci(e,o.dayOfWeek,n):sn(o)?n.isAfter(o.before,o.after)?Dn(e,{from:n.addDays(o.after,1),to:n.addDays(o.before,-1)},n):Ee(e.from,o,n)||Ee(e.to,o,n):rn(o)||an(o)?Ee(e.from,o,n)||Ee(e.to,o,n):!1))return!0;const l=s.filter(o=>typeof o=="function");if(l.length){let o=e.from;const c=n.differenceInCalendarDays(e.to,e.from);for(let d=0;d<=c;d++){if(l.some(f=>f(o)))return!0;o=n.addDays(o,1)}}return!1}function ui(e,t){const{disabled:n,excludeDisabled:s,selected:r,required:i,onSelect:l}=e,[o,c]=yt(r,l?r:void 0),d=l?r:o;return{selected:d,select:(m,x,p)=>{const{min:M,max:k}=e,g=m?li(m,d,M,k,i,t):void 0;return s&&n&&g?.from&&g.to&&di({from:g.from,to:g.to},n,t)&&(g.from=m,g.to=void 0),l||c(g),l?.(g,m,x,p),g},isSelected:m=>d&&Oe(d,m,!1,t)}}function fi(e,t){const{selected:n,required:s,onSelect:r}=e,[i,l]=yt(n,r?n:void 0),o=r?n:i,{isSameDay:c}=t;return{selected:o,select:(u,m,x)=>{let p=u;return!s&&o&&o&&c(u,o)&&(p=void 0),r||l(p),r?.(p,u,m,x),p},isSelected:u=>o?c(o,u):!1}}function mi(e,t){const n=fi(e,t),s=ii(e,t),r=ui(e,t);switch(e.mode){case"single":return n;case"multiple":return s;case"range":return r;default:return}}function me(e,t){return e instanceof le&&e.timeZone===t?e:new le(e,t)}function Qe(e,t,n){return me(e,t)}function Sn(e,t,n){return typeof e=="boolean"||typeof e=="function"?e:e instanceof Date?Qe(e,t):Array.isArray(e)?e.map(s=>s instanceof Date?Qe(s,t):s):bt(e)?{...e,from:e.from?me(e.from,t):e.from,to:e.to?me(e.to,t):e.to}:sn(e)?{before:Qe(e.before,t),after:Qe(e.after,t)}:rn(e)?{after:Qe(e.after,t)}:an(e)?{before:Qe(e.before,t)}:e}function Yt(e,t,n){return e&&(Array.isArray(e)?e.map(s=>Sn(s,t)):Sn(e,t))}function hi(e){let t=e;const n=t.timeZone;if(n&&(t={...e,timeZone:n},t.today&&(t.today=me(t.today,n)),t.month&&(t.month=me(t.month,n)),t.defaultMonth&&(t.defaultMonth=me(t.defaultMonth,n)),t.startMonth&&(t.startMonth=me(t.startMonth,n)),t.endMonth&&(t.endMonth=me(t.endMonth,n)),t.mode==="single"&&t.selected?t.selected=me(t.selected,n):t.mode==="multiple"&&t.selected?t.selected=t.selected?.map($=>me($,n)):t.mode==="range"&&t.selected&&(t.selected={from:t.selected.from?me(t.selected.from,n):t.selected.from,to:t.selected.to?me(t.selected.to,n):t.selected.to}),t.disabled!==void 0&&(t.disabled=Yt(t.disabled,n)),t.hidden!==void 0&&(t.hidden=Yt(t.hidden,n)),t.modifiers)){const $={};Object.keys(t.modifiers).forEach(V=>{$[V]=Yt(t.modifiers?.[V],n)}),t.modifiers=$}const{components:s,formatters:r,labels:i,dateLib:l,locale:o,classNames:c}=h.useMemo(()=>{const $={...us,...t.locale},V=t.broadcastCalendar?1:t.weekStartsOn,A=t.noonSafe&&t.timeZone?qo(t.timeZone,{weekStartsOn:V,locale:$}):void 0,q=t.dateLib&&A?{...A,...t.dateLib}:t.dateLib??A,ce=new fe({locale:$,weekStartsOn:V,firstWeekContainsDate:t.firstWeekContainsDate,useAdditionalWeekYearTokens:t.useAdditionalWeekYearTokens,useAdditionalDayOfYearTokens:t.useAdditionalDayOfYearTokens,timeZone:t.timeZone,numerals:t.numerals},q);return{dateLib:ce,components:jo(t.components),formatters:Fo(t.formatters),labels:Ao(t.labels,ce.options),locale:$,classNames:{...on(),...t.classNames}}},[t.locale,t.broadcastCalendar,t.weekStartsOn,t.firstWeekContainsDate,t.useAdditionalWeekYearTokens,t.useAdditionalDayOfYearTokens,t.timeZone,t.numerals,t.dateLib,t.noonSafe,t.components,t.formatters,t.labels,t.classNames]);t.today||(t={...t,today:l.today()});const{captionLayout:d,mode:f,navLayout:u,numberOfMonths:m=1,onDayBlur:x,onDayClick:p,onDayFocus:M,onDayKeyDown:k,onDayMouseEnter:g,onDayMouseLeave:S,onNextClick:w,onPrevClick:b,showWeekNumber:v,styles:N}=t,{formatCaption:y,formatDay:T,formatMonthDropdown:I,formatWeekNumber:C,formatWeekNumberHeader:L,formatWeekdayName:K,formatYearDropdown:se}=r,Z=si(t,l),{days:ne,months:E,navStart:D,navEnd:P,previousMonth:z,nextMonth:H,goToMonth:oe}=Z,de=ko(ne,t,D,P,l),{isSelected:ie,select:Se,selected:Y}=mi(t,l)??{},{blur:te,focused:ve,isFocusTarget:_e,moveFocus:mt,setFocused:re}=oi(t,Z,de,ie??(()=>!1),l),{labelDayButton:we,labelGridcell:Re,labelGrid:pe,labelMonthDropdown:vt,labelNav:et,labelPrevious:Ye,labelNext:wt,labelWeekday:kt,labelWeekNumber:Be,labelWeekNumberHeader:ge,labelYearDropdown:He}=i,Nt=h.useMemo(()=>Bo(l,t.ISOWeek,t.broadcastCalendar,t.today),[l,t.ISOWeek,t.broadcastCalendar,t.today]),qe=f!==void 0||p!==void 0,ke=h.useCallback(()=>{z&&(oe(z),b?.(z))},[z,oe,b]),Ve=h.useCallback(()=>{H&&(oe(H),w?.(H))},[oe,H,w]),jt=h.useCallback(($,V)=>A=>{A.preventDefault(),A.stopPropagation(),re($),!V.disabled&&(Se?.($.date,V,A),p?.($.date,V,A))},[Se,p,re]),Le=h.useCallback(($,V)=>A=>{re($),M?.($.date,V,A)},[M,re]),Ge=h.useCallback(($,V)=>A=>{te(),x?.($.date,V,A)},[te,x]),ht=h.useCallback(($,V)=>A=>{const q={ArrowLeft:[A.shiftKey?"month":"day",t.dir==="rtl"?"after":"before"],ArrowRight:[A.shiftKey?"month":"day",t.dir==="rtl"?"before":"after"],ArrowDown:[A.shiftKey?"year":"week","after"],ArrowUp:[A.shiftKey?"year":"week","before"],PageUp:[A.shiftKey?"year":"month","before"],PageDown:[A.shiftKey?"year":"month","after"],Home:["startOfWeek","before"],End:["endOfWeek","after"]};if(q[A.key]){A.preventDefault(),A.stopPropagation();const[ce,B]=q[A.key];mt(ce,B)}k?.($.date,V,A)},[mt,k,t.dir]),tt=h.useCallback(($,V)=>A=>{g?.($.date,V,A)},[g]),pt=h.useCallback(($,V)=>A=>{S?.($.date,V,A)},[S]),Mt=h.useCallback($=>V=>{const A=Number(V.target.value),q=l.setMonth(l.startOfMonth($),A);oe(q)},[l,oe]),nt=h.useCallback($=>V=>{const A=Number(V.target.value),q=l.setYear(l.startOfMonth($),A);oe(q)},[l,oe]),{className:Dt,style:St}=h.useMemo(()=>({className:[c[F.Root],t.className].filter(Boolean).join(" "),style:{...N?.[F.Root],...t.style}}),[c,t.className,t.style,N]),Ct=Mo(t),gt=h.useRef(null);Uo(gt,!!t.animate,{classNames:c,months:E,focused:ve,dateLib:l});const Ot={dayPickerProps:t,selected:Y,select:Se,isSelected:ie,months:E,nextMonth:H,previousMonth:z,goToMonth:oe,getModifiers:de,components:s,classNames:c,styles:N,labels:i,formatters:r};return O.createElement(ms.Provider,{value:Ot},O.createElement(s.Root,{rootRef:t.animate?gt:void 0,className:Dt,style:St,dir:t.dir,id:t.id,lang:t.lang,nonce:t.nonce,title:t.title,role:t.role,"aria-label":t["aria-label"],"aria-labelledby":t["aria-labelledby"],...Ct},O.createElement(s.Months,{className:c[F.Months],style:N?.[F.Months]},!t.hideNavigation&&!u&&O.createElement(s.Nav,{"data-animated-nav":t.animate?"true":void 0,className:c[F.Nav],style:N?.[F.Nav],"aria-label":et(),onPreviousClick:ke,onNextClick:Ve,previousMonth:z,nextMonth:H}),E.map(($,V)=>O.createElement(s.Month,{"data-animated-month":t.animate?"true":void 0,className:c[F.Month],style:N?.[F.Month],key:V,displayIndex:V,calendarMonth:$},u==="around"&&!t.hideNavigation&&V===0&&O.createElement(s.PreviousMonthButton,{type:"button",className:c[F.PreviousMonthButton],tabIndex:z?void 0:-1,"aria-disabled":z?void 0:!0,"aria-label":Ye(z),onClick:ke,"data-animated-button":t.animate?"true":void 0},O.createElement(s.Chevron,{disabled:z?void 0:!0,className:c[F.Chevron],orientation:t.dir==="rtl"?"right":"left"})),O.createElement(s.MonthCaption,{"data-animated-caption":t.animate?"true":void 0,className:c[F.MonthCaption],style:N?.[F.MonthCaption],calendarMonth:$,displayIndex:V},d?.startsWith("dropdown")?O.createElement(s.DropdownNav,{className:c[F.Dropdowns],style:N?.[F.Dropdowns]},(()=>{const A=d==="dropdown"||d==="dropdown-months"?O.createElement(s.MonthsDropdown,{key:"month",className:c[F.MonthsDropdown],"aria-label":vt(),classNames:c,components:s,disabled:!!t.disableNavigation,onChange:Mt($.date),options:$o($.date,D,P,r,l),style:N?.[F.Dropdown],value:l.getMonth($.date)}):O.createElement("span",{key:"month"},I($.date,l)),q=d==="dropdown"||d==="dropdown-years"?O.createElement(s.YearsDropdown,{key:"year",className:c[F.YearsDropdown],"aria-label":He(l.options),classNames:c,components:s,disabled:!!t.disableNavigation,onChange:nt($.date),options:Ho(D,P,r,l,!!t.reverseYears),style:N?.[F.Dropdown],value:l.getYear($.date)}):O.createElement("span",{key:"year"},se($.date,l));return l.getMonthYearOrder()==="year-first"?[q,A]:[A,q]})(),O.createElement("span",{role:"status","aria-live":"polite",style:{border:0,clip:"rect(0 0 0 0)",height:"1px",margin:"-1px",overflow:"hidden",padding:0,position:"absolute",width:"1px",whiteSpace:"nowrap",wordWrap:"normal"}},y($.date,l.options,l))):O.createElement(s.CaptionLabel,{className:c[F.CaptionLabel],role:"status","aria-live":"polite"},y($.date,l.options,l))),u==="around"&&!t.hideNavigation&&V===m-1&&O.createElement(s.NextMonthButton,{type:"button",className:c[F.NextMonthButton],tabIndex:H?void 0:-1,"aria-disabled":H?void 0:!0,"aria-label":wt(H),onClick:Ve,"data-animated-button":t.animate?"true":void 0},O.createElement(s.Chevron,{disabled:H?void 0:!0,className:c[F.Chevron],orientation:t.dir==="rtl"?"left":"right"})),V===m-1&&u==="after"&&!t.hideNavigation&&O.createElement(s.Nav,{"data-animated-nav":t.animate?"true":void 0,className:c[F.Nav],style:N?.[F.Nav],"aria-label":et(),onPreviousClick:ke,onNextClick:Ve,previousMonth:z,nextMonth:H}),O.createElement(s.MonthGrid,{role:"grid","aria-multiselectable":f==="multiple"||f==="range","aria-label":pe($.date,l.options,l)||void 0,className:c[F.MonthGrid],style:N?.[F.MonthGrid]},!t.hideWeekdays&&O.createElement(s.Weekdays,{"data-animated-weekdays":t.animate?"true":void 0,className:c[F.Weekdays],style:N?.[F.Weekdays]},v&&O.createElement(s.WeekNumberHeader,{"aria-label":ge(l.options),className:c[F.WeekNumberHeader],style:N?.[F.WeekNumberHeader],scope:"col"},L()),Nt.map(A=>O.createElement(s.Weekday,{"aria-label":kt(A,l.options,l),className:c[F.Weekday],key:String(A),style:N?.[F.Weekday],scope:"col"},K(A,l.options,l)))),O.createElement(s.Weeks,{"data-animated-weeks":t.animate?"true":void 0,className:c[F.Weeks],style:N?.[F.Weeks]},$.weeks.map(A=>O.createElement(s.Week,{className:c[F.Week],key:A.weekNumber,style:N?.[F.Week],week:A},v&&O.createElement(s.WeekNumber,{week:A,style:N?.[F.WeekNumber],"aria-label":Be(A.weekNumber,{locale:o}),className:c[F.WeekNumber],scope:"row",role:"rowheader"},C(A.weekNumber,l)),A.days.map(q=>{const{date:ce}=q,B=de(q);if(B[ee.focused]=!B.hidden&&!!ve?.isEqualTo(q),B[ye.selected]=ie?.(ce)||B.selected,bt(Y)){const{from:_,to:R}=Y;B[ye.range_start]=!!(_&&R&&l.isSameDay(ce,_)),B[ye.range_end]=!!(_&&R&&l.isSameDay(ce,R)),B[ye.range_middle]=Oe(Y,ce,!0,l)}const Et=Ro(B,N,t.modifiersStyles),Wt=No(B,c,t.modifiersClassNames),j=!qe&&!B.hidden?Re(ce,B,l.options,l):void 0;return O.createElement(s.Day,{key:`${q.isoDate}_${q.displayMonthId}`,day:q,modifiers:B,className:Wt.join(" "),style:Et,role:"gridcell","aria-selected":B.selected||void 0,"aria-label":j,"data-day":q.isoDate,"data-month":q.outside?q.dateMonthId:void 0,"data-selected":B.selected||void 0,"data-disabled":B.disabled||void 0,"data-hidden":B.hidden||void 0,"data-outside":q.outside||void 0,"data-focused":B.focused||void 0,"data-today":B.today||void 0},!B.hidden&&qe?O.createElement(s.DayButton,{className:c[F.DayButton],style:N?.[F.DayButton],type:"button",day:q,modifiers:B,disabled:!B.focused&&B.disabled||void 0,"aria-disabled":B.focused&&B.disabled||void 0,tabIndex:_e(q)?0:-1,"aria-label":we(ce,B,l.options,l),onClick:jt(q,B),onBlur:Ge(q,B),onFocus:Le(q,B),onKeyDown:ht(q,B),onMouseEnter:tt(q,B),onMouseLeave:pt(q,B)},T(ce,l.options,l)):!B.hidden&&T(q.date,l.options,l))})))))))),t.footer&&O.createElement(s.Footer,{className:c[F.Footer],style:N?.[F.Footer],role:"status","aria-live":"polite"},t.footer)))}function pi({className:e,classNames:t,showOutsideDays:n=!0,captionLayout:s="label",buttonVariant:r="ghost",formatters:i,components:l,...o}){const c=on();return a.jsx(hi,{showOutsideDays:n,className:W("bg-background group/calendar p-3 [--cell-size:--spacing(8)] [[data-slot=card-content]_&]:bg-transparent [[data-slot=popover-content]_&]:bg-transparent",String.raw`rtl:**:[.rdp-button\_next>svg]:rotate-180`,String.raw`rtl:**:[.rdp-button\_previous>svg]:rotate-180`,e),captionLayout:s,formatters:{formatMonthDropdown:d=>d.toLocaleString("default",{month:"short"}),...i},classNames:{root:W("w-fit",c.root),months:W("flex gap-4 flex-col md:flex-row relative",c.months),month:W("flex flex-col w-full gap-4",c.month),nav:W("flex items-center gap-1 w-full absolute top-0 inset-x-0 justify-between",c.nav),button_previous:W(dn({variant:r}),"size-(--cell-size) aria-disabled:opacity-50 p-0 select-none",c.button_previous),button_next:W(dn({variant:r}),"size-(--cell-size) aria-disabled:opacity-50 p-0 select-none",c.button_next),month_caption:W("flex items-center justify-center h-(--cell-size) w-full px-(--cell-size)",c.month_caption),dropdowns:W("w-full flex items-center text-sm font-medium justify-center h-(--cell-size) gap-1.5",c.dropdowns),dropdown_root:W("relative has-focus:border-ring border border-input shadow-xs has-focus:ring-ring/50 has-focus:ring-[3px] rounded-md",c.dropdown_root),dropdown:W("absolute bg-popover inset-0 opacity-0",c.dropdown),caption_label:W("select-none font-medium",s==="label"?"text-sm":"rounded-md pl-2 pr-1 flex items-center gap-1 text-sm h-8 [&>svg]:text-muted-foreground [&>svg]:size-3.5",c.caption_label),table:"w-full border-collapse",weekdays:W("flex",c.weekdays),weekday:W("text-muted-foreground rounded-md flex-1 font-normal text-[0.8rem] select-none",c.weekday),week:W("flex w-full mt-2",c.week),week_number_header:W("select-none w-(--cell-size)",c.week_number_header),week_number:W("text-[0.8rem] select-none text-muted-foreground",c.week_number),day:W("relative w-full h-full p-0 text-center [&:last-child[data-selected=true]_button]:rounded-r-md group/day aspect-square select-none",o.showWeekNumber?"[&:nth-child(2)[data-selected=true]_button]:rounded-l-md":"[&:first-child[data-selected=true]_button]:rounded-l-md",c.day),range_start:W("rounded-l-md bg-accent",c.range_start),range_middle:W("rounded-none",c.range_middle),range_end:W("rounded-r-md bg-accent",c.range_end),today:W("bg-accent text-accent-foreground rounded-md data-[selected=true]:rounded-none",c.today),outside:W("text-muted-foreground aria-selected:text-muted-foreground",c.outside),disabled:W("text-muted-foreground opacity-50",c.disabled),hidden:W("invisible",c.hidden),...t},components:{Root:({className:d,rootRef:f,...u})=>a.jsx("div",{"data-slot":"calendar",ref:f,className:W(d),...u}),Chevron:({className:d,orientation:f,...u})=>f==="left"?a.jsx($s,{className:W("size-4",d),...u}):f==="right"?a.jsx(In,{className:W("size-4",d),...u}):a.jsx(At,{className:W("size-4",d),...u}),DayButton:gi,WeekNumber:({children:d,...f})=>a.jsx("td",{...f,children:a.jsx("div",{className:"flex size-(--cell-size) items-center justify-center text-center",children:d})}),...l},...o})}function gi({className:e,day:t,modifiers:n,...s}){const r=on(),i=h.useRef(null);return h.useEffect(()=>{n.focused&&i.current?.focus()},[n.focused]),a.jsx(Te,{ref:i,variant:"ghost",size:"icon","data-day":t.date.toLocaleDateString(),"data-selected-single":n.selected&&!n.range_start&&!n.range_end&&!n.range_middle,"data-range-start":n.range_start,"data-range-end":n.range_end,"data-range-middle":n.range_middle,className:W("data-[selected-single=true]:bg-primary data-[selected-single=true]:text-primary-foreground data-[range-middle=true]:bg-accent data-[range-middle=true]:text-accent-foreground data-[range-start=true]:bg-primary data-[range-start=true]:text-primary-foreground data-[range-end=true]:bg-primary data-[range-end=true]:text-primary-foreground group-data-[focused=true]/day:border-ring group-data-[focused=true]/day:ring-ring/50 dark:hover:text-accent-foreground flex aspect-square size-auto w-full min-w-(--cell-size) flex-col gap-1 leading-none font-normal group-data-[focused=true]/day:relative group-data-[focused=true]/day:z-10 group-data-[focused=true]/day:ring-[3px] data-[range-end=true]:rounded-md data-[range-end=true]:rounded-r-md data-[range-middle=true]:rounded-none data-[range-start=true]:rounded-md data-[range-start=true]:rounded-l-md [&>span]:text-xs [&>span]:opacity-70",r.day,e),...s})}function zt(e){const t=e.getFullYear(),n=String(e.getMonth()+1).padStart(2,"0"),s=String(e.getDate()).padStart(2,"0"),r=String(e.getHours()).padStart(2,"0"),i=String(e.getMinutes()).padStart(2,"0");return`${t}-${n}-${s}T${r}:${i}`}function xi(e){const t=e.getFullYear(),n=String(e.getMonth()+1).padStart(2,"0"),s=String(e.getDate()).padStart(2,"0");return`${t}-${n}-${s}`}function Cn({field:e,value:t,onChange:n,error:s,disabled:r=!1,readOnly:i=!1,className:l="",id:o,includeTime:c=!1}){const d=h.useId(),f=o??`field-${e.name}-${d}`,[u,m]=h.useState(!1),x=c||e.type==="datetime",p=t?new Date(t):void 0,M=p&&!isNaN(p.getTime()),k=t&&x&&t.includes("T")&&t.split("T")[1]?.substring(0,5)||"",g=b=>{if(!b){n(null),m(!1);return}if(x&&k){const[N,y]=k.split(":").map(Number);b.setHours(N||0,y||0)}const v=x?zt(b):xi(b);n(v),x||m(!1)},S=b=>{const v=b.target.value;if(!v)return;const[N,y]=v.split(":").map(Number);if(M&&p){const T=new Date(p);T.setHours(N||0,y||0),n(zt(T))}else{const T=new Date;T.setHours(N||0,y||0,0,0),n(zt(T))}},w=b=>b.toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"});return a.jsx(he,{field:e,error:s,className:l,id:f,children:a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsxs(Yn,{open:u,onOpenChange:m,children:[a.jsx(zn,{asChild:!0,children:a.jsxs(Te,{id:f,type:"button",variant:"outline",disabled:r||i,className:W("justify-between font-normal",x?"w-44":"flex-1",!t&&"text-muted-foreground",s&&"border-destructive focus-visible:ring-destructive"),"aria-invalid":!!s,"aria-describedby":s?`${f}-error`:e.description?`${f}-description`:void 0,children:[a.jsx("span",{children:M&&p?w(p):"Select date"}),a.jsx(Os,{className:"size-4 opacity-50"})]})}),a.jsx(An,{className:"w-auto p-0",align:"start",children:a.jsx(pi,{mode:"single",selected:p,onSelect:g,captionLayout:"dropdown",disabled:r||i})})]}),x&&a.jsx(Ke,{type:"time",value:k,onChange:S,disabled:r||i,className:W("w-28",s&&"border-destructive focus-visible:ring-destructive"),"aria-label":"Time"}),t&&!i&&!r&&a.jsx(Te,{type:"button",variant:"ghost",size:"icon",className:"size-9 shrink-0",onClick:()=>n(null),"aria-label":"Clear date",children:a.jsx(Pe,{className:"size-4"})})]})})}var bi="Separator",On="horizontal",yi=["horizontal","vertical"],Cs=h.forwardRef((e,t)=>{const{decorative:n,orientation:s=On,...r}=e,i=vi(s)?s:On,o=n?{role:"none"}:{"aria-orientation":i==="vertical"?i:void 0,role:"separator"};return a.jsx(Es.div,{"data-orientation":i,...o,...r,ref:t})});Cs.displayName=bi;function vi(e){return yi.includes(e)}var wi=Cs;function ki({className:e,orientation:t="horizontal",decorative:n=!0,...s}){return a.jsx(wi,{"data-slot":"separator",decorative:n,orientation:t,className:W("bg-border shrink-0 data-[orientation=horizontal]:h-px data-[orientation=horizontal]:w-full data-[orientation=vertical]:h-full data-[orientation=vertical]:w-px",e),...s})}const Ni=[{label:"Bold",icon:a.jsx(ar,{className:"size-4"}),prefix:"**",suffix:"**"},{label:"Italic",icon:a.jsx(fr,{className:"size-4"}),prefix:"_",suffix:"_"},{label:"Heading",icon:a.jsx(cr,{className:"size-4"}),prefix:"## ",suffix:"",block:!0},{label:"Link",icon:a.jsx(Ws,{className:"size-4"}),prefix:"[",suffix:"](url)"},{label:"List",icon:a.jsx(Ts,{className:"size-4"}),prefix:"- ",suffix:"",block:!0},{label:"Quote",icon:a.jsx(gr,{className:"size-4"}),prefix:"> ",suffix:"",block:!0},{label:"Code",icon:a.jsx(_s,{className:"size-4"}),prefix:"`",suffix:"`"}];function ji({field:e,value:t,onChange:n,error:s,disabled:r=!1,readOnly:i=!1,className:l="",id:o,placeholder:c="Write your content here... (Markdown supported)",minHeight:d=200}){const f=h.useId(),u=o??`field-${e.name}-${f}`,[m,x]=h.useState(null),p=g=>{n(g.target.value)},M=h.useCallback(g=>{if(!m||r||i)return;const S=m.selectionStart,w=m.selectionEnd,b=t.slice(S,w),v=t;let N,y;if(g.block){const T=v.lastIndexOf(`
|
|
2
|
-
`,S-1)+1,I=v.slice(0,T),C=v.slice(T);C.startsWith(g.prefix)?(N=I+C.slice(g.prefix.length),y=S-g.prefix.length):(N=I+g.prefix+C,y=S+g.prefix.length)}else if(b)N=v.slice(0,S)+g.prefix+b+g.suffix+v.slice(w),y=w+g.prefix.length+g.suffix.length;else{const T=g.label.toLowerCase();N=v.slice(0,S)+g.prefix+T+g.suffix+v.slice(w),y=S+g.prefix.length}n(N),requestAnimationFrame(()=>{m&&(m.focus(),m.setSelectionRange(y,y))})},[m,t,n,r,i]),{maxLength:k}=e.options??{};return a.jsx(he,{field:e,error:s,className:l,id:u,children:a.jsxs("div",{className:W("overflow-hidden rounded-md border border-input",s&&"border-destructive"),children:[!i&&!r&&a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"flex flex-wrap gap-1 bg-muted/50 p-1.5",role:"toolbar","aria-label":"Formatting options",children:Ni.map(g=>a.jsx(Te,{type:"button",variant:"ghost",size:"icon",className:"size-7",onClick:()=>M(g),title:g.label,"aria-label":g.label,children:g.icon},g.label))}),a.jsx(ki,{})]}),a.jsx(Lt,{ref:x,id:u,name:e.name,value:t??"",onChange:p,disabled:r,readOnly:i,required:e.required,maxLength:k,placeholder:c,className:"resize-none rounded-none border-0 focus-visible:ring-0",style:{minHeight:`${d}px`},"aria-invalid":!!s,"aria-describedby":s?`${u}-error`:e.description?`${u}-description`:void 0}),a.jsxs("div",{className:"flex items-center justify-between border-t bg-muted/30 px-3 py-1.5 text-xs text-muted-foreground",children:[a.jsx("span",{children:"Markdown supported"}),k&&a.jsxs("span",{children:[(t??"").length," / ",k]})]})]})})}function Mi({field:e,value:t,onChange:n,error:s,disabled:r=!1,readOnly:i=!1,className:l="",id:o,placeholder:c="Select an option..."}){const d=h.useId(),f=o??`field-${e.name}-${d}`,u=e.options?.options??[],m=x=>{n(x)};return a.jsx(he,{field:e,error:s,className:l,id:f,children:a.jsxs(Gt,{value:t??"",onValueChange:m,disabled:r||i,required:e.required,children:[a.jsx(Ut,{id:f,className:W(s&&"border-destructive focus:ring-destructive"),"aria-invalid":!!s,"aria-describedby":s?`${f}-error`:void 0,children:a.jsx(Qt,{placeholder:c})}),a.jsx(Jt,{children:u.map(x=>a.jsx(Ce,{value:x.value,children:x.label},x.value))})]})})}function Di({field:e,value:t,onChange:n,error:s,disabled:r=!1,readOnly:i=!1,className:l="",id:o}){const c=h.useId(),d=o??`field-${e.name}-${c}`,f=e.options?.options??[],u=t??[],m=(M,k)=>{n(k?[...u,M]:u.filter(g=>g!==M))},x=()=>{const M=f.map(k=>k.value);n(M)},p=()=>{n([])};return a.jsx(he,{field:e,error:s,className:l,id:d,children:a.jsxs("div",{className:W("rounded-md border border-input p-3",s&&"border-destructive"),role:"group","aria-labelledby":`${d}-label`,children:[f.length>3&&a.jsxs("div",{className:"mb-3 flex gap-2",children:[a.jsx(Te,{type:"button",variant:"outline",size:"sm",onClick:x,disabled:r||i,children:"Select all"}),a.jsx(Te,{type:"button",variant:"outline",size:"sm",onClick:p,disabled:r||i||u.length===0,children:"Clear"})]}),a.jsx("div",{className:"space-y-2",children:f.map(M=>{const k=`${d}-${M.value}`,g=u.includes(M.value);return a.jsxs("div",{className:W("flex items-center space-x-2 rounded-md p-2",g&&"bg-accent"),children:[a.jsx($n,{id:k,checked:g,onCheckedChange:S=>m(M.value,S===!0),disabled:r||i}),a.jsx(Vt,{htmlFor:k,className:"cursor-pointer text-sm font-normal",children:M.label})]},M.value)})}),u.length>0&&a.jsxs("div",{className:"mt-2 text-xs text-muted-foreground",children:[u.length," of ",f.length," selected"]})]})})}function Si({field:e,value:t,onChange:n,error:s,disabled:r=!1,readOnly:i=!1,className:l="",id:o,placeholder:c=`{
|
|
3
|
-
|
|
4
|
-
}`,rows:d=8}){const f=h.useId(),u=o??`field-${e.name}-${f}`,[m,x]=h.useState(()=>{if(t==null)return"";try{return JSON.stringify(t,null,2)}catch{return""}}),[p,M]=h.useState(null);h.useEffect(()=>{if(t==null){x("");return}try{const b=JSON.stringify(t,null,2),v=m?JSON.parse(m):null;JSON.stringify(v)!==JSON.stringify(t)&&x(b)}catch{}},[t]);const k=h.useCallback(b=>{const v=b.target.value;if(x(v),v.trim()===""){M(null),n(null);return}try{const N=JSON.parse(v);M(null),n(N)}catch(N){const y=N instanceof Error?N.message:"Invalid JSON";M(y)}},[n]),g=h.useCallback(()=>{if(m.trim()!=="")try{const b=JSON.parse(m),v=JSON.stringify(b,null,2);x(v),M(null)}catch{}},[m]),S=h.useCallback(()=>{if(m.trim()!=="")try{const b=JSON.parse(m),v=JSON.stringify(b);x(v),M(null)}catch{}},[m]),w=p?{message:`JSON syntax error: ${p}`,code:"SYNTAX_ERROR"}:s;return a.jsx(he,{field:e,error:w,className:l,id:u,children:a.jsxs("div",{className:W("overflow-hidden rounded-md border border-input",w&&"border-destructive"),children:[a.jsxs("div",{className:"flex items-center gap-1 border-b bg-muted/50 px-2 py-1.5",children:[a.jsx(Te,{type:"button",variant:"ghost",size:"sm",className:"h-7 px-2 text-xs",onClick:g,disabled:r||i||!!p,children:"Format"}),a.jsx(Te,{type:"button",variant:"ghost",size:"sm",className:"h-7 px-2 text-xs",onClick:S,disabled:r||i||!!p,children:"Minify"})]}),a.jsx(Lt,{id:u,name:e.name,value:m,onChange:k,placeholder:c,rows:d,disabled:r,readOnly:i,required:e.required,"aria-invalid":!!w,"aria-describedby":w?`${u}-error`:void 0,className:"resize-none rounded-none border-0 font-mono text-sm focus-visible:ring-0",spellCheck:!1}),a.jsxs("div",{className:"flex items-center justify-between border-t bg-muted/30 px-3 py-1.5 text-xs text-muted-foreground",children:[a.jsx("span",{children:"Enter valid JSON data"}),p&&a.jsxs("span",{className:"flex items-center gap-1 text-destructive",children:[a.jsx(Rn,{className:"size-3"}),"Invalid"]}),!p&&m.trim()!==""&&a.jsxs("span",{className:"flex items-center gap-1 text-success",children:[a.jsx(xt,{className:"size-3"}),"Valid JSON"]})]})]})})}function En(e,t="size-6"){const n={className:t};switch(e){case"image":return a.jsx($t,{...n});case"video":return a.jsx(Gs,{...n});case"audio":return a.jsx(Ls,{...n});case"document":return a.jsx(Rt,{...n});default:return a.jsx(Vs,{...n})}}function Wn(e){return e?e.startsWith("image/")?"image":e.startsWith("video/")?"video":e.startsWith("audio/")?"audio":e==="application/pdf"||e.includes("document")||e.includes("sheet")||e.includes("presentation")||e.startsWith("text/")?"document":"other":"other"}function Tn(e){if(e===0)return"0 B";const t=1024,n=["B","KB","MB","GB"],s=Math.floor(Math.log(e)/Math.log(t));return`${parseFloat((e/Math.pow(t,s)).toFixed(1))} ${n[s]}`}function Ci({field:e,value:t,onChange:n,error:s,disabled:r=!1,readOnly:i=!1,className:l="",id:o,placeholder:c="Select media..."}){const d=$e(),f=o||`field-${e.name}`,[u,m]=h.useState(!1),[x,p]=h.useState("browse"),[M,k]=h.useState(""),[g,S]=h.useState(""),w=e.options?.allowedMimeTypes??[],b=be(d.getMediaAsset,t?{id:t}:"skip"),v=be(d.listMediaAssets,u?{type:g||void 0,search:M||void 0,paginationOpts:{numItems:50,cursor:null}}:"skip"),N=h.useCallback(C=>{n(C),m(!1)},[n]),y=h.useCallback(()=>{n(null)},[n]),T=h.useCallback(C=>{p("browse")},[]),I=v?.page?.filter(C=>w.length===0?!0:w.some(L=>{if(L.endsWith("/*")){const K=L.slice(0,-1);return C.mimeType?.startsWith(K)}return C.mimeType===L}));return a.jsxs(he,{field:e,error:s,className:l,id:f,children:[a.jsx("div",{className:"space-y-2",children:t&&b?(()=>{const C=Wn(b.mimeType);return a.jsxs("div",{className:"flex items-center gap-3 rounded-lg border border-border bg-card p-3",children:[a.jsx("div",{className:"flex size-12 shrink-0 items-center justify-center overflow-hidden rounded-md bg-muted",children:C==="image"&&b.url?a.jsx("img",{src:b.url,alt:b.title||b.name,className:"size-full object-cover"}):a.jsx("div",{className:"text-muted-foreground",children:En(C)})}),a.jsxs("div",{className:"min-w-0 flex-1",children:[a.jsx("p",{className:"truncate text-sm font-medium text-foreground",title:b.name,children:b.name}),a.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[a.jsx("span",{className:"capitalize",children:C}),a.jsx("span",{children:"•"}),a.jsx("span",{children:Tn(b.size??0)})]})]}),!r&&!i&&a.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[a.jsx(X,{variant:"ghost",size:"icon-sm",onClick:()=>m(!0),title:"Change media",children:a.jsx(Us,{className:"size-4"})}),a.jsx(X,{variant:"ghost",size:"icon-sm",onClick:y,title:"Remove media",children:a.jsx(Pe,{className:"size-4"})})]})]})})():a.jsxs("button",{type:"button",className:W("flex w-full flex-col items-center justify-center gap-2 rounded-lg border-2 border-dashed border-border bg-muted/30 p-6 text-center transition-colors","hover:border-primary/50 hover:bg-muted/50","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",r&&"cursor-not-allowed opacity-50"),onClick:()=>m(!0),disabled:r||i,children:[a.jsx("div",{className:"flex size-10 items-center justify-center rounded-full bg-muted",children:a.jsx($t,{className:"size-5 text-muted-foreground"})}),a.jsx("span",{className:"text-sm font-medium text-foreground",children:c}),a.jsx("span",{className:"text-xs text-muted-foreground",children:"Click to browse or upload media"})]})}),a.jsx(Bn,{open:u,onOpenChange:m,children:a.jsxs(Hn,{className:"max-w-2xl",children:[a.jsx(qn,{children:a.jsx(Vn,{children:"Select Media"})}),a.jsxs(Rs,{value:x,onValueChange:p,children:[a.jsxs(Bs,{className:"w-full",children:[a.jsxs(mn,{value:"browse",className:"flex-1 gap-2",children:[a.jsx(Fs,{className:"size-4"}),"Browse Library"]}),a.jsxs(mn,{value:"upload",className:"flex-1 gap-2",children:[a.jsx(Hs,{className:"size-4"}),"Upload New"]})]}),a.jsxs(hn,{value:"browse",className:"mt-4 space-y-4",children:[a.jsxs("div",{className:"flex gap-2",children:[a.jsxs("div",{className:"relative flex-1",children:[a.jsx(Qs,{className:"absolute left-3 top-1/2 size-4 -translate-y-1/2 text-muted-foreground"}),a.jsx(Ke,{type:"search",placeholder:"Search files...",value:M,onChange:C=>k(C.target.value),className:"pl-9"})]}),a.jsxs(Gt,{value:g||"all",onValueChange:C=>S(C==="all"?"":C),children:[a.jsx(Ut,{className:"w-[140px]",children:a.jsx(Qt,{placeholder:"All Types"})}),a.jsxs(Jt,{children:[a.jsx(Ce,{value:"all",children:"All Types"}),a.jsx(Ce,{value:"image",children:"Images"}),a.jsx(Ce,{value:"video",children:"Videos"}),a.jsx(Ce,{value:"audio",children:"Audio"}),a.jsx(Ce,{value:"document",children:"Documents"}),a.jsx(Ce,{value:"other",children:"Other"})]})]})]}),v===void 0?a.jsxs("div",{className:"flex flex-col items-center justify-center py-12",children:[a.jsx("div",{className:"size-6 animate-spin rounded-full border-2 border-muted border-t-primary"}),a.jsx("p",{className:"mt-2 text-sm text-muted-foreground",children:"Loading media..."})]}):I&&I.length>0?a.jsx("div",{className:"grid max-h-[300px] grid-cols-4 gap-2 overflow-y-auto",children:I.map(C=>{const L=Wn(C.mimeType);return a.jsxs("button",{type:"button",className:W("group relative flex flex-col overflow-hidden rounded-lg border bg-card transition-all","hover:border-primary hover:shadow-sm",t===C._id&&"border-primary ring-2 ring-primary/20"),onClick:()=>N(C._id),children:[a.jsx("div",{className:"aspect-square bg-muted",children:L==="image"&&C.url?a.jsx("img",{src:C.url,alt:C.title||C.name,className:"size-full object-cover"}):a.jsx("div",{className:"flex size-full items-center justify-center text-muted-foreground",children:En(L)})}),a.jsxs("div",{className:"p-1.5",children:[a.jsx("p",{className:"truncate text-xs font-medium",title:C.name,children:C.name}),a.jsx("p",{className:"text-[10px] text-muted-foreground",children:Tn(C.size??0)})]}),t===C._id&&a.jsx("div",{className:"absolute right-1 top-1 flex size-5 items-center justify-center rounded-full bg-primary text-primary-foreground",children:a.jsx(xt,{className:"size-3"})})]},C._id)})}):a.jsx(Qn,{icon:a.jsx($t,{className:"size-6"}),title:"No media found",description:"Upload some media to get started",action:{label:"Upload Media",onClick:()=>p("upload")}})]}),a.jsx(hn,{value:"upload",className:"mt-4",children:a.jsx(qs,{generateUploadUrl:d.generateUploadUrl,createAsset:d.createMediaAsset,onUploadComplete:T,allowedMimeTypes:w,maxFileSize:e.options?.maxFileSize,maxConcurrentUploads:3})})]}),a.jsx(Ln,{children:a.jsx(X,{variant:"secondary",onClick:()=>m(!1),children:"Cancel"})})]})})]})}function _n(e){const t=["title","name","heading","label"];for(const n of t){const s=e.data?.[n];if(typeof s=="string"&&s.trim())return s}return e.slug||e._id}function Oi({field:e,value:t,onChange:n,error:s,disabled:r=!1,readOnly:i=!1,className:l="",id:o,placeholder:c="Select content..."}){const d=$e(),f=o||`field-${e.name}`,[u,m]=h.useState(!1),[x,p]=h.useState(""),[M,k]=h.useState(""),g=e.options?.allowedContentTypes??[],S=e.options?.multiple??!1,w=h.useMemo(()=>t?Array.isArray(t)?t:[t]:[],[t]),b=be(d.listContentTypes,{isActive:!0,includeEntryCounts:!1}),v=h.useMemo(()=>b?.page?g.length===0?b.page:b.page.filter(E=>g.includes(E.name)||g.includes(E._id)):[],[b?.page,g]),N=be(d.getEntry,w.length===1?{id:w[0]}:"skip"),y=be(d.listEntries,w.length>1?{paginationOpts:{numItems:100,cursor:null}}:"skip"),T=h.useMemo(()=>!y?.page||w.length<=1?[]:y.page.filter(E=>w.includes(E._id)),[y?.page,w]),I=be(d.listEntries,u?{contentTypeName:M||void 0,search:x||void 0,paginationOpts:{numItems:50,cursor:null}}:"skip"),C=h.useMemo(()=>{if(!I?.page)return[];if(g.length===0)return I.page;const E=v.map(D=>D.name);return I.page.filter(D=>E.includes(D.contentTypeName))},[I?.page,g,v]),L=h.useCallback(E=>{const D=b?.page?.find(P=>P.name===E);return D?.displayName||D?.name||"Unknown"},[b?.page]),K=h.useCallback(E=>{if(S)if(w.includes(E)){const D=w.filter(P=>P!==E);n(D.length>0?D:null)}else n([...w,E]);else n(E),m(!1)},[S,w,n]),se=h.useCallback(E=>{if(S){const D=w.filter(P=>P!==E);n(D.length>0?D:null)}else n(null)},[S,w,n]),Z=h.useCallback(()=>{n(null)},[n]),ne=(E,D=!0)=>a.jsxs("div",{className:"flex items-center gap-3 rounded-lg border border-border bg-card p-3",children:[a.jsx("div",{className:"flex size-9 shrink-0 items-center justify-center rounded-md bg-muted",children:a.jsx(Rt,{className:"size-4 text-muted-foreground"})}),a.jsxs("div",{className:"min-w-0 flex-1",children:[a.jsx("p",{className:"truncate text-sm font-medium text-foreground",children:_n(E)}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"text-xs text-muted-foreground",children:L(E.contentTypeName)}),a.jsx(Kt,{status:E.status})]})]}),D&&!r&&!i&&a.jsx(X,{variant:"ghost",size:"icon-sm",onClick:P=>{P.stopPropagation(),se(E._id)},title:"Remove reference",children:a.jsx(Pe,{className:"size-4"})})]},E._id);return a.jsxs(he,{field:e,error:s,className:l,id:f,children:[a.jsx("div",{className:"space-y-2",children:w.length>0?a.jsxs("div",{className:"space-y-2",children:[w.length===1&&N&&ne(N),w.length>1&&T.length>0&&a.jsx("div",{className:"space-y-2",children:T.map(E=>ne(E))}),!r&&!i&&a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsxs(X,{variant:"outline",size:"sm",onClick:()=>m(!0),children:[a.jsx(Xt,{className:"size-4"}),S?"Add more":"Change"]}),w.length>1&&a.jsx(X,{variant:"ghost",size:"sm",onClick:Z,children:"Clear all"})]})]}):a.jsxs("button",{type:"button",className:W("flex w-full flex-col items-center justify-center gap-2 rounded-lg border-2 border-dashed border-border bg-muted/30 p-6 text-center transition-colors","hover:border-primary/50 hover:bg-muted/50","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",r&&"cursor-not-allowed opacity-50"),onClick:()=>m(!0),disabled:r||i,children:[a.jsx("div",{className:"flex size-10 items-center justify-center rounded-full bg-muted",children:a.jsx(un,{className:"size-5 text-muted-foreground"})}),a.jsx("span",{className:"text-sm font-medium text-foreground",children:c}),a.jsxs("span",{className:"text-xs text-muted-foreground",children:["Click to select ",S?"content entries":"a content entry"]})]})}),a.jsx(Bn,{open:u,onOpenChange:m,children:a.jsxs(Hn,{className:"max-w-lg p-0",children:[a.jsx(qn,{className:"px-4 pt-4",children:a.jsx(Vn,{children:"Select Content"})}),a.jsxs(Js,{className:"border-none",children:[a.jsxs("div",{className:"flex items-center gap-2 border-b px-3 pb-2",children:[a.jsx(Xs,{placeholder:"Search entries...",value:x,onValueChange:p,className:"border-none shadow-none focus:ring-0"}),v.length>1&&a.jsxs(Gt,{value:M||"all",onValueChange:E=>k(E==="all"?"":E),children:[a.jsx(Ut,{className:"h-8 w-[120px] shrink-0",children:a.jsx(Qt,{placeholder:"All Types"})}),a.jsxs(Jt,{children:[a.jsx(Ce,{value:"all",children:"All Types"}),v.map(E=>a.jsx(Ce,{value:E._id,children:E.displayName||E.name},E._id))]})]})]}),a.jsx(Ks,{className:"max-h-[300px]",children:I===void 0?a.jsxs("div",{className:"flex flex-col items-center justify-center py-8",children:[a.jsx("div",{className:"size-5 animate-spin rounded-full border-2 border-muted border-t-primary"}),a.jsx("p",{className:"mt-2 text-sm text-muted-foreground",children:"Loading..."})]}):C.length>0?a.jsx(Zs,{children:C.map(E=>{const D=w.includes(E._id);return a.jsxs(er,{value:E._id,onSelect:()=>K(E._id),className:"cursor-pointer",children:[a.jsx("div",{className:"flex size-8 shrink-0 items-center justify-center rounded bg-muted",children:a.jsx(Rt,{className:"size-4 text-muted-foreground"})}),a.jsxs("div",{className:"min-w-0 flex-1",children:[a.jsx("p",{className:"truncate text-sm font-medium",children:_n(E)}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"text-xs text-muted-foreground",children:L(E.contentTypeName)}),a.jsx(We,{variant:"secondary",className:W("px-1.5 py-0 text-[10px]",E.status==="published"&&"status-published",E.status==="draft"&&"status-draft",E.status==="scheduled"&&"status-scheduled",E.status==="archived"&&"status-archived"),children:E.status})]})]}),D&&a.jsx(xt,{className:"size-4 shrink-0 text-primary"})]},E._id)})}):a.jsx(tr,{children:a.jsx(Qn,{icon:a.jsx(un,{className:"size-6"}),title:"No content found",description:x?"Try adjusting your search":"Create some content entries first",className:"py-6"})})})]}),a.jsxs(Ln,{className:"border-t px-4 py-3",children:[S&&w.length>0&&a.jsxs("span",{className:"mr-auto text-sm text-muted-foreground",children:[w.length," selected"]}),a.jsx(X,{variant:"secondary",onClick:()=>m(!1),children:S?"Done":"Cancel"})]})]})})]})}function Ei({field:e,value:t,onChange:n,error:s,disabled:r=!1,readOnly:i=!1,className:l="",id:o,placeholder:c="Add tags..."}){const d=$e(),f=h.useId(),u=o??`field-${e.name}-${f}`,m=e.options?.taxonomyId,x=e.options?.allowCreate??!1,p=e.options?.maxTags,M=e.options?.minTags,[k,g]=h.useState(""),[S,w]=h.useState(!1),[b,v]=h.useState(0),[N,y]=h.useState(!1),T=h.useRef(null),I=h.useRef(null),C=h.useRef(null),K=be(d.suggestTerms,m?{taxonomyId:m,query:k,limit:10,excludeIds:t||[]}:"skip")??[],se=be(d.listTerms,m&&t&&t.length>0?{taxonomyId:m,paginationOpts:{numItems:100,cursor:null}}:"skip"),Z=new Map;if(se?.page)for(const Y of se.page)t?.includes(Y._id)&&Z.set(Y._id,Y);const ne=Ne(d.createTerm);h.useEffect(()=>{function Y(te){C.current&&!C.current.contains(te.target)&&w(!1)}return document.addEventListener("mousedown",Y),()=>document.removeEventListener("mousedown",Y)},[]);const E=h.useCallback(Y=>{if(!t?.includes(Y)){if(p&&(t?.length??0)>=p)return;n([...t||[],Y])}g(""),w(!1),v(0),T.current?.focus()},[t,n,p]),D=h.useCallback(Y=>{n((t||[]).filter(te=>te!==Y))},[t,n]),P=h.useCallback(async()=>{if(!(!k.trim()||!m||!x)){y(!0);try{const Y=await ne({taxonomyId:m,name:k.trim()});E(Y)}catch(Y){console.error("Failed to create tag:",Y)}finally{y(!1)}}},[k,m,x,ne,E]),z=Y=>{g(Y.target.value),w(!0),v(0)},H=()=>{w(!0)},oe=Y=>{if(!(r||i))switch(Y.key){case"ArrowDown":Y.preventDefault(),v(te=>te<K.length-1?te+1:te);break;case"ArrowUp":Y.preventDefault(),v(te=>te>0?te-1:0);break;case"Enter":Y.preventDefault(),K.length>0&&b<K.length?E(K[b]._id):k.trim()&&x&&P();break;case"Escape":w(!1),v(0);break;case"Backspace":k===""&&t&&t.length>0&&D(t[t.length-1]);break;case"Tab":S&&K.length>0&&(Y.preventDefault(),E(K[b]._id));break}};h.useEffect(()=>{if(I.current&&S){const Y=I.current.querySelector(`[data-index="${b}"]`);Y&&Y.scrollIntoView({block:"nearest"})}},[b,S]);const de=!p||(t?.length??0)<p,ie=K.filter(Y=>!t?.includes(Y._id)),Se=x&&k.trim()&&!ie.some(Y=>Y.name.toLowerCase()===k.trim().toLowerCase());return a.jsx(he,{field:e,error:s,className:l,id:u,children:a.jsxs("div",{ref:C,className:W("relative rounded-md border border-input bg-background",s&&"border-destructive",r&&"opacity-50"),children:[a.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 p-2",children:[(t||[]).map(Y=>{const te=Z.get(Y),ve=te?.name??"Loading...",_e=te?.color;return a.jsxs(We,{variant:"secondary",className:"gap-1 pr-1",style:_e?{backgroundColor:_e,color:"#fff"}:void 0,children:[ve,!r&&!i&&a.jsx(Te,{type:"button",variant:"ghost",size:"icon",className:"size-4 hover:bg-transparent",onClick:()=>D(Y),"aria-label":`Remove ${ve}`,children:a.jsx(Pe,{className:"size-3"})})]},Y)}),de&&!r&&!i&&a.jsx(Ke,{ref:T,type:"text",id:u,className:"h-7 min-w-[120px] flex-1 border-0 bg-transparent px-1 shadow-none focus-visible:ring-0",value:k,onChange:z,onFocus:H,onKeyDown:oe,placeholder:t?.length===0?c:"",disabled:r||N,"aria-autocomplete":"list","aria-controls":`${u}-suggestions`,"aria-expanded":S})]}),S&&(ie.length>0||Se)&&a.jsxs("div",{ref:I,id:`${u}-suggestions`,className:"absolute left-0 right-0 top-full z-50 mt-1 max-h-60 overflow-auto rounded-md border bg-popover shadow-lg",role:"listbox",children:[ie.map((Y,te)=>a.jsxs("div",{"data-index":te,className:W("flex cursor-pointer items-center gap-2 px-3 py-2 text-sm",te===b&&"bg-accent"),onClick:()=>E(Y._id),role:"option","aria-selected":te===b,children:[Y.color&&a.jsx("span",{className:"size-2.5 rounded-full",style:{backgroundColor:Y.color}}),a.jsx("span",{className:"flex-1",children:Y.name}),a.jsxs("span",{className:"text-xs text-muted-foreground",children:[Y.usageCount," uses"]})]},Y._id)),Se&&a.jsxs("div",{"data-index":ie.length,className:W("flex cursor-pointer items-center gap-2 px-3 py-2 text-sm",ie.length===b&&"bg-accent"),onClick:P,role:"option","aria-selected":ie.length===b,children:[N?a.jsx(Gn,{className:"size-4 animate-spin"}):a.jsx(Xt,{className:"size-4"}),a.jsxs("span",{children:['Create "',k.trim(),'"']})]})]}),a.jsxs("div",{className:"border-t px-3 py-1.5 text-xs text-muted-foreground",children:[t?.length??0," tag",(t?.length??0)!==1?"s":"",M&&(t?.length??0)<M&&a.jsxs("span",{className:"text-warning",children:[" (minimum ",M,")"]}),p&&a.jsxs("span",{children:[" / ",p," max"]})]})]})})}function Wi({field:e,value:t,onChange:n,error:s,disabled:r=!1,readOnly:i=!1,className:l="",id:o,placeholder:c="Select category..."}){const d=$e(),f=o||`field-${e.name}`,u=e.options?.taxonomyId,m=e.options?.allowMultiple??!1,[x,p]=h.useState(!1),[M,k]=h.useState(new Set),[g,S]=h.useState(null),w=h.useRef(null),v=be(d.getTermsHierarchy,u?{taxonomyId:u}:"skip")??[],N=h.useCallback((D,P=[])=>{for(const z of D)P.push(z),M.has(z._id)&&z.children.length>0&&N(z.children,P);return P},[M]),y=N(v),T=h.useCallback(()=>{if(!t)return null;const D=Array.isArray(t)?t:[t];if(D.length===0)return null;const P=[];for(const z of D){const H=y.find(oe=>oe._id===z);H&&P.push(H.name)}return P.length===0?"Loading...":P.length===1?P[0]:`${P.length} categories selected`},[t,y]),I=h.useCallback(D=>{if(!(r||i))if(m){const P=Array.isArray(t)?t:t?[t]:[];P.includes(D)?n(P.filter(z=>z!==D)):n([...P,D])}else n(D),p(!1)},[r,i,m,t,n]),C=h.useCallback((D,P)=>{P.stopPropagation(),k(z=>{const H=new Set(z);return H.has(D)?H.delete(D):H.add(D),H})},[]),L=h.useCallback(D=>t?(Array.isArray(t)?t:[t]).includes(D):!1,[t]),K=D=>{if(!(r||i))switch(D.key){case"Enter":case" ":{D.preventDefault(),x?g&&I(g):(p(!0),y.length>0&&S(y[0]._id));break}case"Escape":{p(!1),S(null);break}case"ArrowDown":{if(D.preventDefault(),!x)p(!0),y.length>0&&S(y[0]._id);else{const P=y.findIndex(z=>z._id===g);P<y.length-1&&S(y[P+1]._id)}break}case"ArrowUp":{if(D.preventDefault(),x){const P=y.findIndex(z=>z._id===g);P>0&&S(y[P-1]._id)}break}case"ArrowRight":{if(D.preventDefault(),g){const P=y.find(z=>z._id===g);P&&P.children.length>0&&!M.has(g)&&k(z=>new Set([...z,g]))}break}case"ArrowLeft":{if(D.preventDefault(),g){const P=y.find(z=>z._id===g);P&&(M.has(g)?k(z=>{const H=new Set(z);return H.delete(g),H}):P.parentId&&S(P.parentId))}break}}};h.useEffect(()=>{if(w.current&&g){const D=w.current.querySelector(`[data-category-id="${g}"]`);D&&D.scrollIntoView({block:"nearest"})}},[g]);const se=(D,P=0)=>{const z=D.children&&D.children.length>0,H=M.has(D._id),oe=g===D._id,de=L(D._id);return a.jsxs("div",{children:[a.jsxs("div",{"data-category-id":D._id,className:W("flex cursor-pointer items-center gap-2 rounded-md px-2 py-1.5 text-sm transition-colors","hover:bg-accent",oe&&"bg-accent",de&&"font-medium"),style:{paddingLeft:`${P*16+8}px`},onClick:()=>I(D._id),onMouseEnter:()=>S(D._id),role:"option","aria-selected":de,children:[z?a.jsx("button",{type:"button",className:"flex size-4 items-center justify-center rounded hover:bg-muted",onClick:ie=>C(D._id,ie),"aria-label":H?"Collapse":"Expand",children:H?a.jsx(At,{className:"size-3"}):a.jsx(In,{className:"size-3"})}):a.jsx("span",{className:"size-4"}),m&&a.jsx($n,{checked:de,className:"pointer-events-none size-4"}),D.color&&a.jsx("span",{className:"size-2.5 shrink-0 rounded-full",style:{backgroundColor:D.color}}),a.jsx("span",{className:"flex-1 truncate",children:D.name}),!m&&de&&a.jsx(xt,{className:"size-4 text-primary"})]}),z&&H&&a.jsx("div",{children:D.children.map(ie=>se(ie,P+1))})]},D._id)},Z=D=>{D.stopPropagation(),n(m?[]:null)},ne=T(),E=ne!==null;return a.jsx(he,{field:e,error:s,className:l,id:f,children:a.jsxs("div",{ref:w,children:[a.jsxs(Yn,{open:x,onOpenChange:p,children:[a.jsx(zn,{asChild:!0,children:a.jsxs("button",{type:"button",id:f,className:W("flex w-full items-center justify-between rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","disabled:cursor-not-allowed disabled:opacity-50",s&&"border-destructive",!E&&"text-muted-foreground"),onKeyDown:K,disabled:r,"aria-haspopup":"listbox","aria-expanded":x,"data-testid":"category-trigger",children:[a.jsx("span",{className:"truncate",children:ne||c}),a.jsxs("div",{className:"flex items-center gap-1",children:[E&&!r&&!i&&a.jsx("button",{type:"button",className:"rounded p-0.5 hover:bg-muted",onClick:Z,"aria-label":"Clear selection",children:a.jsx(Pe,{className:"size-3"})}),a.jsx(At,{className:W("size-4 text-muted-foreground transition-transform",x&&"rotate-180")})]})]})}),a.jsx(An,{className:"w-[var(--radix-popover-trigger-width)] p-0",align:"start",children:a.jsx(Zt,{className:"max-h-[280px]",children:v.length===0?a.jsxs("div",{className:"flex flex-col items-center justify-center py-6 text-center",children:[a.jsx(Ps,{className:"mb-2 size-6 text-muted-foreground"}),a.jsx("p",{className:"text-sm text-muted-foreground",children:"No categories available"})]}):a.jsx("div",{className:"p-1",role:"listbox","aria-multiselectable":m,children:v.map(D=>se(D))})})})]}),m&&Array.isArray(t)&&t.length>0&&a.jsx("div",{className:"mt-2 flex flex-wrap gap-1",children:t.map(D=>{const P=y.find(z=>z._id===D);return a.jsxs(We,{variant:"secondary",className:"gap-1 pr-1",children:[P?.color&&a.jsx("span",{className:"size-2 rounded-full",style:{backgroundColor:P.color}}),P?.name??"Loading...",!r&&!i&&a.jsx("button",{type:"button",className:"ml-0.5 rounded-full p-0.5 hover:bg-muted",onClick:()=>I(D),"aria-label":`Remove ${P?.name}`,children:a.jsx(Pe,{className:"size-3"})})]},D)})})]})})}function Ti({field:e,value:t,onChange:n,error:s,disabled:r,readOnly:i,className:l}){const c=`field-${h.useId()}`,d=t==null?"":JSON.stringify(t,null,2),f=u=>{if(!i){if(u.trim()===""){n(null);return}try{const m=JSON.parse(u);n(m)}catch{n(u)}}};return a.jsx(he,{field:e,error:s,id:c,className:l,customLabel:a.jsxs("span",{children:[e.label,a.jsx("span",{className:"ml-2 rounded bg-muted px-1.5 py-0.5 text-xs font-normal text-muted-foreground",children:e.type})]}),children:a.jsx(Lt,{id:c,value:d,onChange:u=>f(u.target.value),disabled:r,readOnly:i,className:"font-mono text-sm",rows:6,placeholder:`Enter ${e.type} value as JSON...`,"aria-invalid":!!s,"aria-describedby":s?`${c}-error`:e.description?`${c}-desc`:void 0})})}const _i=new Map;function Fi(e){return _i.get(e)}function Pi({field:e,value:t,onChange:n,error:s,disabled:r=!1,readOnly:i=!1,className:l=""}){const o={field:e,error:s,disabled:r,readOnly:i,className:l};switch(e.type){case"text":return a.jsx(xr,{...o,value:t??"",onChange:n});case"richText":return a.jsx(ji,{...o,value:t??"",onChange:n});case"number":return a.jsx(br,{...o,value:t??null,onChange:n});case"boolean":return a.jsx(yr,{...o,value:t??!1,onChange:n});case"date":return a.jsx(Cn,{...o,value:t??null,onChange:n,includeTime:!1});case"datetime":return a.jsx(Cn,{...o,value:t??null,onChange:n,includeTime:!0});case"select":return a.jsx(Mi,{...o,value:t??"",onChange:n});case"multiSelect":return a.jsx(Di,{...o,value:t??[],onChange:n});case"json":return a.jsx(Si,{...o,value:t??null,onChange:n});case"media":return a.jsx(Ci,{...o,value:t??null,onChange:n});case"reference":return a.jsx(Oi,{...o,value:t??null,onChange:n});case"tags":return a.jsx(Ei,{...o,value:t??[],onChange:n});case"category":return a.jsx(Wi,{...o,value:t??null,onChange:n});default:{const c=Fi(e.type);return c?a.jsx(c,{...o,value:t,onChange:n}):a.jsx(Ti,{...o,value:t,onChange:n})}}}function Ii({entryId:e,fromVersion:t,toVersion:n,onClose:s,onRollback:r}){const i=$e(),l=be(i.compareVersions,{entryId:e,fromVersionNumber:t,toVersionNumber:n}),o=l===void 0,c=l,d=p=>p==null?"(empty)":typeof p=="object"?JSON.stringify(p,null,2):String(p),f=p=>{switch(p){case"added":return a.jsx(Xt,{className:"size-3"});case"removed":return a.jsx(hr,{className:"size-3"});case"modified":return a.jsx(Jn,{className:"size-3"});default:return null}},u=p=>{switch(p){case"added":return"diff-added border";case"removed":return"diff-removed border";case"modified":return"diff-modified border";default:return"border-border bg-card"}},m=p=>{switch(p){case"added":return"diff-icon-added";case"removed":return"diff-icon-removed";case"modified":return"diff-icon-modified";default:return"bg-muted text-muted-foreground"}},x=p=>new Date(p).toLocaleString(void 0,{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"});return a.jsxs("div",{className:"flex h-full flex-col bg-background",children:[a.jsxs("div",{className:"flex items-center justify-between border-b px-4 py-3",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(ir,{className:"size-4 text-muted-foreground"}),a.jsxs("h3",{className:"font-semibold",children:["Comparing v",t," → v",n]})]}),a.jsx("button",{type:"button",onClick:s,className:"rounded p-1 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground","aria-label":"Close comparison",children:a.jsx(Pe,{className:"size-4"})})]}),a.jsx(Zt,{className:"min-h-0 flex-1",children:a.jsx("div",{className:"p-4",children:o?a.jsxs("div",{className:"flex flex-col items-center justify-center py-8",children:[a.jsx("div",{className:"size-6 animate-spin rounded-full border-2 border-muted border-t-primary"}),a.jsx("p",{className:"mt-2 text-sm text-muted-foreground",children:"Loading comparison..."})]}):c?c.hasChanges?a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"mb-4 flex items-center justify-center gap-3 rounded-lg border bg-muted/30 p-3",children:[a.jsxs("div",{className:"text-center",children:[a.jsxs(We,{variant:"secondary",className:"font-mono",children:["v",c.fromVersion.versionNumber]}),a.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:x(c.fromVersion.createdAt)})]}),a.jsx(sr,{className:"size-4 text-muted-foreground"}),a.jsxs("div",{className:"text-center",children:[a.jsxs(We,{variant:"secondary",className:"font-mono",children:["v",c.toVersion.versionNumber]}),a.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:x(c.toVersion.createdAt)})]})]}),c.changeSummary&&a.jsx("p",{className:"mb-4 text-sm text-muted-foreground",children:c.changeSummary}),a.jsx("div",{className:"space-y-3",children:c.fieldDiffs.map((p,M)=>a.jsxs("div",{className:W("rounded-lg border p-3",u(p.changeType)),children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:W("flex size-5 items-center justify-center rounded",m(p.changeType)),children:f(p.changeType)}),a.jsx("span",{className:"font-medium text-foreground",children:p.field}),a.jsx(We,{variant:"outline",className:"text-xs capitalize",children:p.changeType})]}),a.jsxs("div",{className:"mt-2 space-y-2",children:[p.changeType!=="added"&&a.jsxs("div",{className:"rounded border border-diff-removed-border bg-card p-2",children:[a.jsx("p",{className:"mb-1 text-xs font-medium text-diff-removed",children:"Before:"}),a.jsx("pre",{className:"overflow-x-auto whitespace-pre-wrap break-words font-mono text-xs text-diff-removed-foreground",children:d(p.fromValue)})]}),p.changeType!=="removed"&&a.jsxs("div",{className:"rounded border border-diff-added-border bg-card p-2",children:[a.jsx("p",{className:"mb-1 text-xs font-medium text-diff-added",children:"After:"}),a.jsx("pre",{className:"overflow-x-auto whitespace-pre-wrap break-words font-mono text-xs text-diff-added-foreground",children:d(p.toValue)})]})]})]},M))})]}):a.jsx("div",{className:"py-8 text-center",children:a.jsx("p",{className:"text-sm text-muted-foreground",children:"No differences found between these versions"})}):a.jsx("div",{className:"diff-removed rounded-lg border px-4 py-3 text-sm",children:"Could not load version comparison"})})}),a.jsxs("div",{className:"flex items-center justify-between border-t px-4 py-3",children:[a.jsx(X,{variant:"outline",onClick:s,children:"Back to History"}),a.jsxs(X,{variant:"ghost",onClick:()=>r(t),children:["Rollback to v",t]})]})]})}function Fn({targetVersion:e,currentVersion:t,isLoading:n,error:s,onConfirm:r,onCancel:i}){return a.jsx(Un,{open:!0,onOpenChange:l=>!l&&!n&&i(),title:"Confirm Rollback",size:"sm",footer:a.jsxs(a.Fragment,{children:[a.jsx(X,{variant:"outline",onClick:i,disabled:n,children:"Cancel"}),a.jsxs(X,{variant:"warning",onClick:r,loading:n,children:["Rollback to v",e]})]}),children:a.jsxs("div",{className:"space-y-4",children:[a.jsxs("p",{className:"text-sm text-muted-foreground",children:["You are about to rollback from"," ",a.jsxs("span",{className:"font-semibold text-foreground",children:["version ",t]})," ","to"," ",a.jsxs("span",{className:"font-semibold text-foreground",children:["version ",e]}),"."]}),a.jsx("div",{className:"diff-modified rounded-lg border p-3",children:a.jsxs("div",{className:"flex gap-2",children:[a.jsx(Is,{className:"mt-0.5 size-4 shrink-0 text-diff-modified"}),a.jsxs("div",{className:"space-y-2",children:[a.jsx("p",{className:"text-sm font-medium text-diff-modified",children:"This action will:"}),a.jsxs("ul",{className:"space-y-1 text-sm text-diff-modified-foreground",children:[a.jsxs("li",{children:["• Create a new version with the content from version"," ",e]}),a.jsx("li",{children:"• The current version will be preserved in history"}),a.jsx("li",{children:"• Any unsaved changes will be lost"})]})]})]})}),s&&a.jsxs("div",{className:"diff-removed rounded-lg border px-3 py-2 text-sm",children:[a.jsx("span",{className:"font-medium",children:"Error:"})," ",s]})]})})}function Yi({entryId:e,currentVersion:t,onRollbackComplete:n,onClose:s}){const r=$e(),[i,l]=h.useState(null),[o,c]=h.useState(null),[d,f]=h.useState(!1),[u,m]=h.useState(null),[x,p]=h.useState(!1),M=be(r.getVersionHistory,{entryId:e,paginationOpts:{numItems:50,cursor:null}}),k=Ne(r.rollbackVersion),g=M?.page??[],S=M===void 0,w=h.useCallback((y,T)=>{l([y,T])},[]),b=h.useCallback(y=>{c(y),m(null)},[]),v=h.useCallback(async()=>{if(o!==null){f(!0),m(null);try{await k({entryId:e,versionNumber:o}),c(null),p(!0),setTimeout(()=>{p(!1),n?.()},1500)}catch(y){const T=y instanceof Error?y.message:"Failed to rollback";m(T)}finally{f(!1)}}},[e,o,k,n]),N=y=>new Date(y).toLocaleString(void 0,{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"});return i?a.jsxs("div",{className:"flex h-full flex-col border-l bg-background",children:[a.jsx(Ii,{entryId:e,fromVersion:i[0],toVersion:i[1],onClose:()=>l(null),onRollback:y=>{l(null),b(y)}}),o!==null&&a.jsx(Fn,{targetVersion:o,currentVersion:t,isLoading:d,error:u,onConfirm:v,onCancel:()=>{c(null),m(null)}})]}):a.jsxs("div",{className:"flex h-full flex-col border-l bg-background",children:[a.jsxs("div",{className:"flex items-center justify-between border-b px-4 py-3",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Xn,{className:"size-4 text-muted-foreground"}),a.jsx("h3",{className:"font-semibold",children:"Version History"})]}),a.jsx("button",{type:"button",onClick:s,className:"rounded p-1 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground","aria-label":"Close version history",children:a.jsx(Pe,{className:"size-4"})})]}),x&&a.jsxs("div",{className:"flex items-center gap-2 border-b bg-diff-added-bg px-4 py-2 text-sm text-diff-added-foreground",children:[a.jsx(Bt,{className:"size-4"}),"Successfully rolled back to previous version"]}),a.jsx(Zt,{className:"min-h-0 flex-1",children:a.jsx("div",{className:"p-4",children:S?a.jsxs("div",{className:"flex flex-col items-center justify-center py-8",children:[a.jsx("div",{className:"size-6 animate-spin rounded-full border-2 border-muted border-t-primary"}),a.jsx("p",{className:"mt-2 text-sm text-muted-foreground",children:"Loading versions..."})]}):g.length===0?a.jsx("div",{className:"py-8 text-center text-sm text-muted-foreground",children:"Save changes to start building version history"}):a.jsx("div",{className:"space-y-3",children:g.map((y,T)=>{const I=y.versionNumber===t,C=g[T+1];return a.jsxs("div",{className:W("rounded-lg border p-3 transition-colors",I?"border-primary/50 bg-primary/5":"bg-card"),children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsxs(We,{variant:"secondary",className:"font-mono",children:["v",y.versionNumber]}),I&&a.jsx(We,{variant:"outline",className:"border-primary/50 text-primary",children:"Current"}),y.wasPublished&&a.jsx(We,{variant:"outline",className:"border-success/50 text-success",children:"Published"})]}),a.jsx(Kt,{status:y.status})]}),a.jsxs("div",{className:"mt-2 text-xs text-muted-foreground",children:[a.jsx("span",{children:N(y._creationTime)}),y.createdBy&&a.jsxs("span",{className:"ml-2",children:["by ",y.createdBy]})]}),y.changeDescription&&a.jsx("p",{className:"mt-2 text-sm text-muted-foreground",children:y.changeDescription}),a.jsxs("div",{className:"mt-3 flex gap-2",children:[C&&a.jsxs(X,{variant:"outline",size:"sm",onClick:()=>w(C.versionNumber,y.versionNumber),children:["Compare with v",C.versionNumber]}),!I&&a.jsx(X,{variant:"ghost",size:"sm",onClick:()=>b(y.versionNumber),children:"Rollback"})]})]},y._id)})})})}),o!==null&&a.jsx(Fn,{targetVersion:o,currentVersion:t,isLoading:d,error:u,onConfirm:v,onCancel:()=>{c(null),m(null)}})]})}function zi(e){const t={fieldErrors:{},generalError:null};if(!e)return t;const n=e instanceof Error?e.message:String(e);try{const i=n.match(/\{[\s\S]*\}/);if(i){const l=JSON.parse(i[0]);if(Array.isArray(l.errors)){for(const o of l.errors)o.field&&o.message&&(t.fieldErrors[o.field]={message:o.message,code:o.code??"SERVER_ERROR"});if(Object.keys(t.fieldErrors).length>0)return t}if(l.field&&l.message)return t.fieldErrors[l.field]={message:l.message,code:l.code??"SERVER_ERROR"},t;if(typeof l=="object"&&!Array.isArray(l)){let o=!1;for(const[c,d]of Object.entries(l))typeof d=="string"&&c!=="message"&&c!=="code"&&(t.fieldErrors[c]={message:d,code:"SERVER_ERROR"},o=!0);if(o)return t}}}catch{}const s=/(?:Content validation failed|Validation error|Validation failed):\s*(.+)/i,r=n.match(s);if(r){const l=r[1].trim().split(/;\s*/);for(const o of l){const c=o.indexOf(":");if(c>0&&c<o.length-1){const d=o.substring(0,c).trim(),f=o.substring(c+1).trim();d&&!d.includes(" ")&&d.length<=50&&f&&(t.fieldErrors[d]={message:f,code:"SERVER_ERROR"})}}if(Object.keys(t.fieldErrors).length>0)return t}return t.generalError=n,t}function Ai(e){if(!e)return!1;const t=(e instanceof Error?e.message:String(e)).toLowerCase();return["network","timeout","timed out","connection","fetch failed","failed to fetch","offline","unavailable","rate limit","too many requests","503","504","429"].some(s=>t.includes(s))}function qt(e){const t=new Date(e),n=t.getFullYear(),s=String(t.getMonth()+1).padStart(2,"0"),r=String(t.getDate()).padStart(2,"0"),i=String(t.getHours()).padStart(2,"0"),l=String(t.getMinutes()).padStart(2,"0");return`${n}-${s}-${r}T${i}:${l}`}function $i(e){return new Date(e).getTime()}function Ri(e){const t=new Date(e),n=t.getFullYear(),s=String(t.getMonth()+1).padStart(2,"0"),r=String(t.getDate()).padStart(2,"0");return`${n}-${s}-${r}`}function Bi(e,t){const n={...e};for(const s of t){const r=e[s.name];(s.type==="date"||s.type==="datetime")&&typeof r=="number"&&(n[s.name]=s.type==="datetime"?qt(r):Ri(r))}return n}function Pn(e,t){const n={...e};for(const s of t){const r=e[s.name];(s.type==="date"||s.type==="datetime")&&(typeof r=="string"&&r?n[s.name]=new Date(r).getTime():r||(n[s.name]=null))}return n}function tl({contentType:e,entry:t,onSave:n,onCancel:s,onDelete:r,autosaveEnabled:i=!0,autosaveInterval:l=3e4,canDelete:o=!1}){const{settings:c}=Ys(),d=h.useCallback(()=>{if(t)return Bi({...t.data},e.fields);const j={};for(const _ of e.fields)if(_.defaultValue!==void 0)j[_.name]=_.defaultValue;else switch(_.type){case"text":case"richText":j[_.name]="";break;case"boolean":j[_.name]=!1;break;case"number":case"date":case"datetime":case"reference":case"media":case"json":j[_.name]=null;break;case"select":j[_.name]="";break;case"multiSelect":j[_.name]=[];break}return j},[e.fields,t]),[f,u]=h.useState(d),[m,x]=h.useState({}),[p,M]=h.useState(!1),[k,g]=h.useState(!1),[S,w]=h.useState(t?{...t.data}:null),[b,v]=h.useState("idle"),[N,y]=h.useState(null),[T,I]=h.useState(0),[C,L]=h.useState(null),[K,se]=h.useState(!1),Z=3,ne=h.useRef(null),E=h.useRef(f);E.current=f;const D=$e(),P=Ne(D.createEntry),z=Ne(D.updateEntry),H=Ne(D.publishEntry),oe=Ne(D.unpublishEntry),de=Ne(D.scheduleEntry),ie=Ne(D.cancelScheduledEntry),Se=Ne(D.deleteEntry),Y=Ne(D.duplicateEntry),[te,ve]=h.useState(!1),[_e,mt]=h.useState(()=>{const j=new Date;return j.setDate(j.getDate()+1),j.setHours(9,0,0,0),qt(j.getTime())}),[re,we]=h.useState(!1),[Re,pe]=h.useState(null);h.useEffect(()=>{const j=d();u(j),x({}),g(!1),w(t?{...t.data}:null),L(null)},[t?._id,d]);const vt=h.useCallback((j,_)=>{u(R=>({...R,[j]:_})),g(!0),x(R=>{if(R[j]){const{[j]:J,...Q}=R;return Q}return R})},[]),et=h.useCallback(async()=>{const j={};for(const _ of e.fields){const R=f[_.name];if(_.required&&(R==null||R===""||Array.isArray(R)&&R.length===0)){j[_.name]={message:`${_.label} is required`,code:"REQUIRED"};continue}if(R!=null&&R!=="")switch(_.type){case"text":{const J=String(R),Q=_.options;Q?.minLength&&J.length<Q.minLength?j[_.name]={message:`Minimum ${Q.minLength} characters required`,code:"MIN_LENGTH"}:Q?.maxLength&&J.length>Q.maxLength?j[_.name]={message:`Maximum ${Q.maxLength} characters allowed`,code:"MAX_LENGTH"}:Q?.pattern&&(new RegExp(Q.pattern).test(J)||(j[_.name]={message:"Value does not match the required format",code:"PATTERN_MISMATCH"}));break}case"number":{const J=Number(R),Q=_.options;isNaN(J)?j[_.name]={message:"Must be a valid number",code:"INVALID_TYPE"}:Q?.min!==void 0&&J<Q.min?j[_.name]={message:`Minimum value is ${Q.min}`,code:"MIN_VALUE"}:Q?.max!==void 0&&J>Q.max?j[_.name]={message:`Maximum value is ${Q.max}`,code:"MAX_VALUE"}:Q?.precision===0&&!Number.isInteger(J)&&(j[_.name]={message:"Must be a whole number",code:"NOT_INTEGER"});break}case"select":{const J=_.options;J?.options&&!J.options.some(Q=>Q.value===R)&&(j[_.name]={message:"Please select a valid option",code:"INVALID_OPTION"});break}case"multiSelect":{const J=_.options;if(Array.isArray(R)&&J?.options){const Q=J.options.map(st=>st.value);R.filter(st=>!Q.includes(String(st))).length>0&&(j[_.name]={message:"Contains invalid options",code:"INVALID_OPTION"})}break}}}return x(j),Object.keys(j).length===0},[e.fields,f]),Ye=h.useCallback(async(j=0)=>{if(!(!k||!t)&&t.status==="draft")try{v("saving"),y(null),await z({id:t._id,data:Pn(E.current,e.fields)}),w({...E.current}),v("saved"),g(!1),I(0),setTimeout(()=>{v("idle")},3e3)}catch(_){console.error("Autosave failed:",_);const R=_ instanceof Error?_.message:"Failed to save";if(Ai(_)&&j<Z){const Q=Math.min(1e3*Math.pow(2,j),1e4);v("error"),y(`Save failed, retrying in ${Math.round(Q/1e3)}s...`),I(j+1),setTimeout(()=>{Ye(j+1)},Q)}else v("error"),y(R),I(0)}},[k,t,z,Z]),wt=h.useCallback(()=>{I(0),Ye(0)},[Ye]);h.useEffect(()=>{if(!(!i||!t||t.status!=="draft"))return ne.current&&clearTimeout(ne.current),k&&(ne.current=setTimeout(()=>{Ye()},l)),()=>{ne.current&&clearTimeout(ne.current)}},[i,l,k,t,Ye]);const[kt,Be]=h.useState(!1),[ge,He]=h.useState(null),[Nt,qe]=h.useState(!1),[ke,Ve]=h.useState(!1),[jt,Le]=h.useState(null),[Ge,ht]=h.useState(!1),[tt,pt]=h.useState(!1),[Mt,nt]=h.useState(!1),Dt=h.useCallback(()=>{He("publish"),Be(!0)},[]),St=h.useCallback(()=>{He("unpublish"),Be(!0)},[]),Ct=h.useCallback(async()=>{if(!(!t||!ge)){Be(!1),we(!0),pe(null);try{if(ge==="publish"){const j=await H({id:t._id,changeDescription:"Published from editor"});n?.(j)}else{const j=await oe({id:t._id});n?.(j)}}catch(j){const _=j instanceof Error?j.message:`Failed to ${ge}`;pe(_)}finally{we(!1),He(null)}}},[t,ge,H,oe,n]),gt=h.useCallback(async()=>{if(t){we(!0),pe(null);try{const j=await H({id:t._id,changeDescription:"Published from editor"});n?.(j)}catch(j){const _=j instanceof Error?j.message:"Failed to publish";pe(_)}finally{we(!1)}}},[t,H,n]),Ot=h.useCallback(async()=>{if(!t)return;const j=$i(_e),_=Date.now()+60*1e3;if(j<_){pe("Schedule time must be at least 1 minute in the future");return}we(!0),pe(null);try{const R=await de({id:t._id,publishAt:j});ve(!1),n?.(R)}catch(R){const J=R instanceof Error?R.message:"Failed to schedule";pe(J)}finally{we(!1)}},[t,_e,de,n]),$=h.useCallback(async()=>{if(t){we(!0),pe(null);try{const j=await ie({id:t._id});n?.(j)}catch(j){const _=j instanceof Error?j.message:"Failed to cancel schedule";pe(_)}finally{we(!1)}}},[t,ie,n]),V=h.useCallback(()=>{Le(null),qe(!0)},[]),A=h.useCallback(async()=>{if(t){Ve(!0),Le(null);try{await Se({id:t._id,hardDelete:!1}),qe(!1),r?.()}catch(j){const _=j instanceof Error?j.message:"Failed to delete entry";Le(_)}finally{Ve(!1)}}},[t,Se,r]),q=h.useCallback(async()=>{if(t){ht(!0),L(null);try{const j=await Y({sourceEntryId:t._id});n?.(j)}catch(j){const _=j instanceof Error?j.message:"Failed to duplicate entry";L(_)}finally{ht(!1)}}},[t,Y,n]),ce=h.useCallback(async()=>{if(t){pt(!0),L(null);try{const j=await z({id:t._id,status:"archived"});n?.(j)}catch(j){const _=j instanceof Error?j.message:"Failed to archive entry";L(_)}finally{pt(!1)}}},[t,z,n]),B=h.useCallback(async j=>{if(j.preventDefault(),L(null),!!await et()){M(!0);try{let R;const J=Pn(f,e.fields);t?R=await z({id:t._id,data:J}):R=await P({contentTypeName:e.name,data:J}),g(!1),w({...f}),se(!0),setTimeout(()=>se(!1),3e3),n?.(R)}catch(R){const{fieldErrors:J,generalError:Q}=zi(R),Tt=Q??(R instanceof Error?R.message:"Failed to save entry");L(Tt),Object.keys(J).length>0&&x(st=>({...st,...J}))}finally{M(!1)}}},[et,t,f,e._id,P,z,n]),Et=h.useCallback(()=>{k&&!window.confirm("You have unsaved changes. Are you sure you want to leave?")||s?.()},[k,s]),Wt=()=>{switch(b){case"saving":return T>0?`Retrying (${T}/${Z})...`:"Saving...";case"saved":return"Draft saved";case"error":return N??"Autosave failed";default:return null}};return a.jsxs("form",{className:"space-y-6",onSubmit:B,children:[a.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-4",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsxs("h2",{className:"text-xl font-semibold",children:[t?"Edit":"Create"," ",e.displayName]}),t&&a.jsx(Kt,{status:t.status})]}),a.jsxs("div",{className:"flex items-center gap-3",children:[b!=="idle"&&a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsxs("span",{className:W("flex items-center gap-1.5 text-sm",b==="saving"&&"text-muted-foreground",b==="saved"&&"text-success",b==="error"&&"text-destructive"),"data-testid":"autosave-status",children:[b==="saving"&&a.jsx(Gn,{className:"size-3 animate-spin"}),b==="saved"&&a.jsx(Bt,{className:"size-3"}),b==="error"&&a.jsx(Rn,{className:"size-3"}),Wt()]}),b==="error"&&T===0&&a.jsx("button",{type:"button",onClick:wt,className:"text-sm text-primary hover:underline","data-testid":"autosave-retry-button",children:a.jsx(Jn,{className:"size-3"})})]}),k&&a.jsx("span",{className:"text-sm text-warning",children:"Unsaved changes"})]})]}),K&&a.jsxs("div",{className:"diff-added flex items-center gap-2 rounded-lg border px-4 py-3 text-sm",role:"status",children:[a.jsx(Bt,{className:"size-4"}),"Changes saved successfully"]}),(C||Re)&&a.jsxs("div",{className:"diff-removed rounded-lg border px-4 py-3 text-sm",role:"alert",children:[a.jsx("span",{className:"font-medium",children:"Error:"})," ",C||Re]}),a.jsx("div",{className:"space-y-4",children:e.fields.map(j=>a.jsx(Pi,{field:j,value:f[j.name],onChange:_=>vt(j.name,_),error:m[j.name],disabled:p},j.name))}),a.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-4 border-t pt-4",children:[a.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t&&o&&a.jsx(X,{type:"button",variant:"danger",onClick:V,disabled:p||re||ke||Ge,loading:ke,"data-testid":"delete-button",children:"Delete"}),t&&a.jsx(X,{type:"button",variant:"secondary",onClick:q,disabled:p||re||ke||Ge||tt,loading:Ge,"data-testid":"duplicate-button",children:"Duplicate"}),t&&(t.status==="draft"||t.status==="scheduled")&&a.jsx(X,{type:"button",variant:"secondary",onClick:ce,disabled:p||re||ke||Ge||tt,loading:tt,"data-testid":"archive-button",children:"Archive"}),t&&a.jsxs("div",{className:"flex items-center gap-4 text-sm text-muted-foreground",children:[c?.features.versioning&&a.jsxs("button",{type:"button",onClick:()=>nt(!0),className:"flex items-center gap-2 rounded-md border bg-muted/30 px-3 py-1.5 transition-colors hover:bg-muted/50",children:[a.jsx(Xn,{className:"size-4 text-muted-foreground"}),a.jsxs("span",{className:"text-xs font-medium text-foreground",children:["Version ",t.version]}),a.jsx("span",{className:"text-xs text-muted-foreground",children:"View history"})]}),t.lastPublishedAt&&a.jsxs("span",{className:"text-xs","data-testid":"last-published-time",children:["Last published:"," ",new Date(t.lastPublishedAt).toLocaleString()]}),c?.features.scheduling&&t.status==="scheduled"&&t.scheduledPublishAt&&a.jsxs("span",{className:"flex items-center gap-1 text-xs text-info","data-testid":"scheduled-time",children:[a.jsx(zs,{className:"size-3"}),"Scheduled:"," ",new Date(t.scheduledPublishAt).toLocaleString()]})]})]}),a.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[a.jsx(X,{type:"button",variant:"outline",onClick:Et,disabled:p||re,children:"Cancel"}),a.jsx(X,{type:"submit",variant:"primary",disabled:p||re,loading:p,children:t?"Save Changes":"Create Entry"}),t&&a.jsxs(a.Fragment,{children:[t.status==="draft"&&a.jsxs(a.Fragment,{children:[c?.features.scheduling&&a.jsx(X,{type:"button",variant:"secondary",onClick:()=>ve(!0),disabled:p||re,children:"Schedule"}),a.jsx(X,{type:"button",variant:"success",onClick:Dt,disabled:p||re,loading:re,"data-testid":"publish-button",children:"Publish Now"})]}),c?.features.scheduling&&t.status==="scheduled"&&a.jsxs(a.Fragment,{children:[a.jsx(X,{type:"button",variant:"secondary",onClick:$,disabled:p||re,children:"Cancel Schedule"}),a.jsx(X,{type:"button",variant:"success",onClick:gt,disabled:p||re,loading:re,children:"Publish Now"})]}),t.status==="published"&&a.jsx(X,{type:"button",variant:"warning",onClick:St,disabled:p||re,loading:re,"data-testid":"unpublish-button",children:"Unpublish"})]})]})]}),c?.features.scheduling&&a.jsx(Un,{open:te,onOpenChange:ve,title:"Schedule Publication",size:"sm",footer:a.jsxs(a.Fragment,{children:[a.jsx(X,{variant:"outline",onClick:()=>ve(!1),children:"Cancel"}),a.jsx(X,{variant:"primary",onClick:Ot,loading:re,children:"Schedule"})]}),children:a.jsxs("div",{className:"space-y-4",children:[a.jsx("p",{className:"text-sm text-muted-foreground",children:"Choose when this content should be automatically published:"}),a.jsx(Ke,{type:"datetime-local",value:_e,onChange:j=>mt(j.target.value),min:qt(Date.now()+60*1e3)}),Re&&a.jsx("p",{className:"text-sm text-destructive",children:Re})]})}),a.jsx(fn,{open:kt&&ge!==null,onOpenChange:j=>{j||(Be(!1),He(null))},title:ge==="publish"?"Confirm Publish":"Confirm Unpublish",description:ge==="publish"?"Are you sure you want to publish this entry? It will become publicly visible.":"Are you sure you want to unpublish this entry? It will no longer be publicly visible.",confirmLabel:ge==="publish"?"Publish":"Unpublish",variant:ge==="publish"?"primary":"warning",onConfirm:Ct,isLoading:re}),a.jsx(fn,{open:Nt,onOpenChange:j=>{!j&&!ke&&(qe(!1),Le(null))},title:"Delete Entry",description:"Are you sure you want to delete this entry? It will be moved to the trash and can be restored within the retention period.",confirmLabel:"Delete",variant:"danger",onConfirm:A,isLoading:ke,error:jt}),c?.features.versioning&&Mt&&t&&a.jsx("div",{className:"fixed inset-y-0 right-0 z-50 flex w-96 flex-col shadow-xl",children:a.jsx(Yi,{entryId:t._id,currentVersion:t.version,onRollbackComplete:()=>{nt(!1)},onClose:()=>nt(!1)})})]})}export{tl as C};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{m as F,r as o,u as N,j as s,ak as P,al as B,C,p as E,q as M,h as O,am as $,X as A,g as D,w as q}from"./main-CA-4LyFT.js";import{C as G,a as Q,b as V,c as X,d as H,e as J,f as K}from"./command-CJ8i86fd.js";import{B as v}from"./badge-C6qt24oj.js";function ss({selectedTermIds:e,onChange:n,taxonomyId:r,placeholder:b="Filter by tags...",disabled:y=!1,className:k}){const d=F(),[p,h]=o.useState(!1),[c,w]=o.useState(""),m=N(d.listTaxonomies,{isActive:!0}),i=m?.page??[],_=o.useMemo(()=>r?i.find(a=>a._id===r):null,[r,i]),u=r??i[0]?._id,g=N(d.listTerms,u?{taxonomyId:u,paginationOpts:{numItems:200,cursor:null}}:"skip"),t=g?.page??[],f=o.useMemo(()=>t.filter(a=>e.includes(a._id)),[t,e]),j=o.useMemo(()=>{if(!c.trim())return t;const a=c.toLowerCase();return t.filter(l=>l.name.toLowerCase().includes(a))},[t,c]),z=o.useCallback(a=>{e.includes(a)?n(e.filter(l=>l!==a)):n([...e,a])},[e,n]),S=o.useCallback(()=>{n([]),h(!1)},[n]),L=o.useCallback((a,l)=>{l.stopPropagation(),n(e.filter(T=>T!==a))},[e,n]),x=_?.displayName??i[0]?.displayName??"Tags",R=m===void 0||!!u&&g===void 0;return i.length===0&&m!==void 0?null:s.jsxs(P,{open:p,onOpenChange:h,children:[s.jsx(B,{asChild:!0,children:s.jsxs(C,{variant:"outline",role:"combobox","aria-expanded":p,disabled:y||R,className:O("h-9 min-w-[140px] justify-between gap-2",e.length>0&&"border-primary/50",k),children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(E,{className:"size-4 text-muted-foreground"}),e.length===0?s.jsx("span",{className:"text-muted-foreground",children:b}):e.length===1?s.jsx("span",{className:"max-w-[100px] truncate",children:f[0]?.name??"Tag"}):s.jsxs("span",{children:[e.length," tags"]})]}),s.jsxs("div",{className:"flex items-center gap-1",children:[e.length>0&&s.jsx(v,{variant:"secondary",className:"size-5 rounded-full p-0 text-xs",children:e.length}),s.jsx(M,{className:"size-4 text-muted-foreground"})]})]})}),s.jsx($,{className:"w-[280px] p-0",align:"start",children:s.jsxs(G,{shouldFilter:!1,children:[s.jsx(Q,{placeholder:`Search ${x.toLowerCase()}...`,value:c,onValueChange:w}),s.jsx(V,{children:j.length===0?s.jsx(X,{children:t.length===0?`No ${x.toLowerCase()} found`:"No matches"}):s.jsx(H,{heading:x,children:j.map(a=>s.jsx(U,{term:a,isSelected:e.includes(a._id),onToggle:()=>z(a._id)},a._id))})}),e.length>0&&s.jsxs(s.Fragment,{children:[s.jsx(J,{}),s.jsxs("div",{className:"p-2",children:[s.jsx("div",{className:"mb-2 flex flex-wrap gap-1",children:f.map(a=>s.jsxs(v,{variant:"secondary",className:"gap-1 pr-1",style:a.color?{backgroundColor:a.color,color:"#fff"}:void 0,children:[a.name,s.jsx("button",{type:"button",className:"ml-0.5 rounded-full p-0.5 hover:bg-black/10",onClick:l=>L(a._id,l),"aria-label":`Remove ${a.name}`,children:s.jsx(A,{className:"size-3"})})]},a._id))}),s.jsx(C,{variant:"ghost",size:"sm",className:"w-full",onClick:S,children:"Clear all filters"})]})]})]})})]})}function U({term:e,isSelected:n,onToggle:r}){return s.jsxs(K,{onSelect:r,className:"cursor-pointer",children:[s.jsx(D,{checked:n,className:"mr-2","aria-hidden":"true",tabIndex:-1}),e.color&&s.jsx("span",{className:"size-2.5 shrink-0 rounded-full",style:{backgroundColor:e.color}}),s.jsx("span",{className:"flex-1 truncate",children:e.name}),s.jsx("span",{className:"text-xs text-muted-foreground",children:e.usageCount}),n&&s.jsx(q,{className:"ml-1 size-4 text-primary"})]})}export{ss as T};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{l as ce,ah as de,ae as ue,r as s,a as me,k as x,u as g,j as e,F as J,C as u,ai as P,P as he,I as xe,S as pe,b as fe,c as ge,d as je,e as j,i as ye,aj as Ce,q as Ne}from"./main-CA-4LyFT.js";import{u as ve}from"./usePermissions-BTGdTOJS.js";import{u as be}from"./useBreadcrumbLabel-tlSh7dtO.js";import{C as Se}from"./CmsPageHeader-0REGRH4X.js";import{C as Te}from"./CmsToolbar-CY6GV2L8.js";import{C as ke}from"./CmsStatusBadge-D_n8u8xa.js";import{C as K}from"./CmsEmptyState-DTlpzjOI.js";import{T as Ee}from"./TaxonomyFilter-Ohv5Jg9c.js";import{S as De}from"./search-WXp6KxDJ.js";import"./badge-C6qt24oj.js";import"./command-CJ8i86fd.js";const we=[["path",{d:"m21 16-4 4-4-4",key:"f6ql7i"}],["path",{d:"M17 20V4",key:"1ejh1v"}],["path",{d:"m3 8 4-4 4 4",key:"11wl7u"}],["path",{d:"M7 4v16",key:"1glfcx"}]],Ie=ce("arrow-up-down",we);function Oe(){const{contentTypeId:T}=de.useParams(),W=ue(),[y,_]=s.useState("all"),[C,B]=s.useState(""),[X,M]=s.useState(""),[N,Y]=s.useState("updatedAt"),[v,L]=s.useState("desc"),[d,c]=s.useState(0),[n,$]=s.useState([]),b=25,{canCreate:Z,canUpdate:ee,canDelete:te}=ve(),R=me(x.admin.deleteEntry),[se,k]=s.useState(!1),[p,E]=s.useState(null),[D,U]=s.useState(!1),[ae,S]=s.useState(null);s.useEffect(()=>{const t=setTimeout(()=>{M(C),c(0)},300);return()=>clearTimeout(t)},[C]);const l=g(x.admin.getContentType,{id:T});be(`/entries/type/${T}`,l?.displayName);const O=g(x.admin.listEntries,{contentTypeName:l?.name,status:y==="all"?void 0:y,search:X||void 0,paginationOpts:{numItems:250,cursor:null}}),V=O?.page??[],Q=g(x.admin.getEntriesByTerm,n[0]?{termId:n[0]}:"skip"),q=g(x.admin.getEntriesByTerm,n[1]?{termId:n[1]}:"skip"),H=g(x.admin.getEntriesByTerm,n[2]?{termId:n[2]}:"skip"),w=s.useMemo(()=>{if(n.length===0)return null;const t=new Set,a=[Q,q,H];for(let r=0;r<n.length&&r<3;r++){const i=a[r];if(i?.page)for(const f of i.page)t.add(f)}return t},[n,Q,q,H]),m=s.useCallback(t=>{const a=l?.titleField??"title",r=t.data[a];return typeof r=="string"&&r?r:"Untitled"},[l?.titleField]),o=s.useMemo(()=>{let t=[...V];return w!==null&&(t=t.filter(a=>w.has(a._id))),t.sort((a,r)=>{let i=0;switch(N){case"title":{const f=m(a).toLowerCase(),z=m(r).toLowerCase();i=f.localeCompare(z);break}case"status":i=a.status.localeCompare(r.status);break;case"updatedAt":{const f=a.lastPublishedAt??a._creationTime??0,z=r.lastPublishedAt??r._creationTime??0;i=f-z;break}case"createdAt":i=(a._creationTime??0)-(r._creationTime??0);break;default:i=0}return v==="desc"?-i:i}),t},[V,N,v,m,w]),G=s.useMemo(()=>{const t=d*b;return o.slice(t,t+b)},[o,d,b]),h=Math.ceil(o.length/b),re=t=>new Date(t).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}),I=t=>{N===t?L(v==="asc"?"desc":"asc"):(Y(t),L("desc"))},A=t=>N!==t?e.jsx(Ie,{className:"size-3.5 text-muted-foreground/50"}):v==="asc"?e.jsx(Ce,{className:"size-3.5"}):e.jsx(Ne,{className:"size-3.5"}),ne=s.useCallback(t=>{const a=m(t);E({_id:t._id,title:a}),S(null),k(!0)},[m]),le=s.useCallback(async()=>{if(p){U(!0),S(null);try{await R({id:p._id,hardDelete:!1}),k(!1),E(null)}catch(t){const a=t instanceof Error?t.message:"Failed to delete entry";S(a)}finally{U(!1)}}},[p,R]),ie=s.useCallback(t=>{!t&&!D&&(k(!1),E(null),S(null))},[D]),oe=s.useCallback(()=>{B(""),M(""),_("all"),$([]),c(0)},[]);if(l===void 0||O===void 0)return e.jsx("div",{className:"space-y-6 p-6",children:e.jsxs("div",{className:"flex flex-col items-center justify-center py-12",children:[e.jsx("div",{className:"size-8 animate-spin rounded-full border-2 border-muted border-t-primary"}),e.jsx("p",{className:"mt-4 text-sm text-muted-foreground",children:"Loading entries..."})]})});if(l===null)return e.jsx("div",{className:"space-y-6 p-6",children:e.jsx(K,{icon:e.jsx(J,{className:"size-6"}),title:"Content Type Not Found",description:"The content type you're looking for doesn't exist or has been deleted.",action:{label:"Back to Content Types",onClick:()=>W({to:"/content-types"})}})});const F=C||y!=="all"||n.length>0;return e.jsxs("div",{className:"space-y-6 p-6",children:[e.jsx(Se,{title:l.displayName,description:l.description,actions:Z("contentEntries")&&e.jsx(u,{asChild:!0,children:e.jsxs(P,{to:"/entries/new/$contentTypeId",params:{contentTypeId:T},children:[e.jsx(he,{className:"size-4"}),"Create ",l.displayName]})})}),e.jsx(Te,{left:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("div",{className:"relative",children:[e.jsx(De,{className:"absolute left-3 top-1/2 size-4 -translate-y-1/2 text-muted-foreground"}),e.jsx(xe,{type:"search",placeholder:"Search entries...",value:C,onChange:t=>B(t.target.value),className:"w-64 pl-9"})]}),e.jsxs(pe,{value:y,onValueChange:t=>{_(t),c(0)},children:[e.jsx(fe,{className:"w-36",children:e.jsx(ge,{placeholder:"All Statuses"})}),e.jsxs(je,{children:[e.jsx(j,{value:"all",children:"All Statuses"}),e.jsx(j,{value:"draft",children:"Draft"}),e.jsx(j,{value:"published",children:"Published"}),e.jsx(j,{value:"scheduled",children:"Scheduled"}),e.jsx(j,{value:"archived",children:"Archived"})]})]}),e.jsx(Ee,{selectedTermIds:n,onChange:t=>{$(t),c(0)},placeholder:"Tags"})]}),right:e.jsxs("span",{className:"text-sm text-muted-foreground",children:[o.length," ",o.length===1?"entry":"entries"]})}),o.length===0?e.jsx(K,{icon:e.jsx(J,{className:"size-6"}),title:F?"No matching entries":`No ${l.displayName} entries yet`,description:F?"Try adjusting your search or filter criteria.":`Click "Create ${l.displayName}" to add your first entry.`,action:F?{label:"Clear Filters",onClick:oe,variant:"secondary"}:void 0}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"rounded-lg border bg-card",children:e.jsxs("table",{className:"w-full",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b",children:[e.jsx("th",{className:"p-3 text-left",children:e.jsxs("button",{className:"flex items-center gap-1.5 text-sm font-medium text-muted-foreground hover:text-foreground",onClick:()=>I("title"),children:["Title",A("title")]})}),e.jsx("th",{className:"p-3 text-left",children:e.jsxs("button",{className:"flex items-center gap-1.5 text-sm font-medium text-muted-foreground hover:text-foreground",onClick:()=>I("status"),children:["Status",A("status")]})}),e.jsx("th",{className:"p-3 text-left",children:e.jsxs("button",{className:"flex items-center gap-1.5 text-sm font-medium text-muted-foreground hover:text-foreground",onClick:()=>I("updatedAt"),children:["Updated",A("updatedAt")]})}),e.jsx("th",{className:"p-3 text-left text-sm font-medium text-muted-foreground",children:"Actions"})]})}),e.jsx("tbody",{children:G.map(t=>e.jsxs("tr",{className:"border-b last:border-0 transition-colors hover:bg-muted/50",children:[e.jsxs("td",{className:"p-3",children:[e.jsx(P,{to:"/entries/$entryId",params:{entryId:t._id},className:"font-medium text-foreground hover:text-primary hover:underline",children:m(t)}),e.jsx("p",{className:"text-xs text-muted-foreground",children:t.slug})]}),e.jsx("td",{className:"p-3",children:e.jsx(ke,{status:t.status})}),e.jsx("td",{className:"p-3 text-sm text-muted-foreground",children:re(t.lastPublishedAt??t._creationTime)}),e.jsx("td",{className:"p-3",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(u,{variant:"outline",size:"sm",asChild:!0,children:e.jsx(P,{to:"/entries/$entryId",params:{entryId:t._id},children:ee("contentEntries")?"Edit":"View"})}),te("contentEntries")&&e.jsx(u,{variant:"danger",size:"sm",onClick:()=>ne(t),"data-testid":`delete-entry-${t._id}`,children:"Delete"})]})})]},t._id))})]})}),h>1&&e.jsxs("div",{className:"flex items-center justify-center gap-2",children:[e.jsx(u,{variant:"outline",size:"sm",onClick:()=>c(0),disabled:d===0,children:"First"}),e.jsx(u,{variant:"outline",size:"sm",onClick:()=>c(t=>Math.max(0,t-1)),disabled:d===0,children:"Previous"}),e.jsxs("span",{className:"px-3 text-sm text-muted-foreground",children:["Page ",d+1," of ",h]}),e.jsx(u,{variant:"outline",size:"sm",onClick:()=>c(t=>Math.min(h-1,t+1)),disabled:d>=h-1,children:"Next"}),e.jsx(u,{variant:"outline",size:"sm",onClick:()=>c(h-1),disabled:d>=h-1,children:"Last"})]})]}),o.length>0&&e.jsxs("p",{className:"text-center text-sm text-muted-foreground",children:["Showing ",G.length," of ",o.length," ",o.length===1?"entry":"entries"]}),e.jsx(ye,{open:se,onOpenChange:ie,title:"Delete Entry",description:p?`Are you sure you want to delete "${p.title}"? It will be moved to the trash and can be restored within the retention period.`:"Are you sure you want to delete this entry?",confirmLabel:"Delete",variant:"danger",onConfirm:le,isLoading:D,error:ae})]})}export{Oe as component};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{j as e,n as Q,f as q,C as p,m as G,r as i,a as T,X as H,u as D,J,K,P as W,q as X,M as Y,N as Z,I as ee,S as _,b as I,c as U,d as B,e as j,F as se,g as L,h as te,k as ae}from"./main-CA-4LyFT.js";import{u as ne}from"./usePermissions-BTGdTOJS.js";import{C as ie}from"./circle-check-big-PltpxuB1.js";import{B as le}from"./badge-C6qt24oj.js";import{C as P}from"./CmsPageHeader-0REGRH4X.js";import{C as re}from"./CmsToolbar-CY6GV2L8.js";import{C as ce}from"./CmsEmptyState-DTlpzjOI.js";import{C as de}from"./CmsStatusBadge-D_n8u8xa.js";import{S as oe}from"./search-WXp6KxDJ.js";import{u as me}from"./tanstack-adapter-BRt2CUCw.js";const ue={publish:{title:"Publish Items",description:"This will publish all selected items, making them publicly visible.",confirmLabel:"Publish All",confirmVariant:"success"},unpublish:{title:"Unpublish Items",description:"This will unpublish all selected items, changing them back to draft status.",confirmLabel:"Unpublish All",confirmVariant:"warning"},delete:{title:"Delete Items",description:"This will move all selected items to trash.",warning:"Items in trash can be restored within the retention period.",confirmLabel:"Delete All",confirmVariant:"danger"},archive:{title:"Archive Items",description:"This will archive all selected items.",confirmLabel:"Archive All",confirmVariant:"secondary"}};function he({action:a,count:l,isProcessing:u,result:t,onConfirm:r,onCancel:h}){const c=ue[a];return e.jsx(Q,{open:!0,onOpenChange:f=>!f&&!u&&h(),title:c.title,size:"sm",footer:t?e.jsx(p,{variant:"primary",onClick:h,children:t.failed===0?"Done":"Close"}):e.jsxs(e.Fragment,{children:[e.jsx(p,{variant:"outline",onClick:h,disabled:u,children:"Cancel"}),e.jsx(p,{variant:c.confirmVariant,onClick:r,loading:u,children:c.confirmLabel})]}),children:t?e.jsx("div",{className:"space-y-4",children:t.failed===0?e.jsxs("div",{className:"flex flex-col items-center gap-3 py-4 text-center",children:[e.jsx("div",{className:"flex size-12 items-center justify-center rounded-full bg-diff-added-bg text-diff-added",children:e.jsx(ie,{className:"size-6"})}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Successfully processed"," ",e.jsx("span",{className:"font-semibold text-foreground",children:t.succeeded})," ",t.succeeded===1?"item":"items"]})]}):e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"diff-added rounded-lg border p-3 text-center",children:[e.jsx("p",{className:"text-2xl font-semibold text-diff-added",children:t.succeeded}),e.jsx("p",{className:"text-xs text-diff-added-foreground",children:"Succeeded"})]}),e.jsxs("div",{className:"diff-removed rounded-lg border p-3 text-center",children:[e.jsx("p",{className:"text-2xl font-semibold text-diff-removed",children:t.failed}),e.jsx("p",{className:"text-xs text-diff-removed-foreground",children:"Failed"})]})]}),t.errors&&t.errors.length>0&&e.jsxs("div",{className:"diff-modified rounded-lg border p-3",children:[e.jsx("p",{className:"mb-2 text-sm font-medium text-diff-modified",children:"Errors:"}),e.jsxs("ul",{className:"space-y-1 text-xs text-diff-modified-foreground",children:[t.errors.slice(0,5).map((f,d)=>e.jsxs("li",{className:"truncate",children:["• ",f]},d)),t.errors.length>5&&e.jsxs("li",{className:"text-diff-modified-foreground/80",children:["...and ",t.errors.length-5," more errors"]})]})]})]})}):e.jsxs("div",{className:"space-y-3",children:[e.jsxs("p",{className:"text-sm text-muted-foreground",children:["You are about to ",a," ",e.jsxs("span",{className:"font-semibold text-foreground",children:[l," ",l===1?"item":"items"]}),"."]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:c.description}),c.warning&&e.jsxs("div",{className:"diff-modified flex items-start gap-2 rounded-lg border p-3",children:[e.jsx(q,{className:"mt-0.5 size-4 shrink-0 text-diff-modified"}),e.jsxs("p",{className:"text-sm",children:[e.jsx("span",{className:"font-medium",children:"Note:"})," ",c.warning]})]})]})})}function xe({selectedIds:a,onClearSelection:l,onOperationComplete:u}){const t=G(),[r,h]=i.useState(null),[c,f]=i.useState(!1),[d,o]=i.useState(null),y=T(t.bulkPublish),k=T(t.bulkUnpublish),v=T(t.bulkDelete),x=T(t.bulkUpdate),b=i.useCallback(n=>{h(n),o(null)},[]),S=i.useCallback(async()=>{if(!(!r||a.length===0)){f(!0),o(null);try{let n;switch(r){case"publish":n=await y({ids:a,changeDescription:"Bulk published from admin"});break;case"unpublish":n=await k({ids:a});break;case"delete":n=await v({ids:a,hardDelete:!1});break;case"archive":n=await x({ids:a,status:"archived"});break;default:throw new Error(`Unknown action: ${r}`)}o({succeeded:n.succeeded,failed:n.failed,errors:n.errors?.map(N=>`${N.id}: ${N.error}`)}),n.failed===0&&setTimeout(()=>{h(null),l(),u?.()},1500)}catch(n){const N=n instanceof Error?n.message:"Operation failed";o({succeeded:0,failed:a.length,errors:[N]})}finally{f(!1)}}},[r,a,y,k,v,x,l,u]),m=i.useCallback(()=>{h(null),o(null)},[]);return a.length===0?null:e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"fixed inset-x-0 bottom-0 z-50 border-t bg-background/95 px-6 py-3 shadow-lg backdrop-blur supports-[backdrop-filter]:bg-background/80",children:e.jsxs("div",{className:"mx-auto flex max-w-7xl items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(le,{variant:"secondary",className:"text-sm font-semibold",children:a.length}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:[a.length===1?"item":"items"," selected"]}),e.jsxs("button",{type:"button",onClick:l,className:"flex items-center gap-1 text-sm text-muted-foreground transition-colors hover:text-foreground",children:[e.jsx(H,{className:"size-3"}),"Clear"]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(p,{variant:"success",size:"sm",onClick:()=>b("publish"),children:"Publish"}),e.jsx(p,{variant:"warning",size:"sm",onClick:()=>b("unpublish"),children:"Unpublish"}),e.jsx(p,{variant:"secondary",size:"sm",onClick:()=>b("archive"),children:"Archive"}),e.jsx(p,{variant:"danger",size:"sm",onClick:()=>b("delete"),children:"Delete"})]})]})}),r&&e.jsx(he,{action:r,count:a.length,isProcessing:c,result:d,onConfirm:S,onCancel:m})]})}function pe({api:a,navigation:l}){const[u,t]=i.useState(""),[r,h]=i.useState(""),[c,f]=i.useState(""),[d,o]=i.useState(new Set),{canCreate:y,canUpdate:k}=ne();i.useEffect(()=>{const s=l.params?.contentTypeId;if(s){const g=s.startsWith("code:")?s.slice(5):s;t(g)}else t("")},[l.params?.contentTypeId]);const v=D(a.listContentTypes,{isActive:!0}),x=v?.page??[],b=v===void 0,S=D(a.listEntries,{contentTypeName:u||void 0,status:r||void 0,search:c.trim()||void 0,paginationOpts:{numItems:50,cursor:null}}),m=S?.page??[],N=b||S===void 0,V=s=>{l.navigateToNewEntry(s)},F=s=>x.find(w=>w.name===s)?.displayName??s,E=(s,g)=>{const C=x.find($=>$.name===g)?.titleField??"title",A=s.data[C];return typeof A=="string"&&A?A:"Untitled"},M=s=>new Date(s).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric"}),O=i.useCallback((s,g)=>{o(w=>{const C=new Set(w);return g?C.add(s):C.delete(s),C})},[]),R=i.useCallback(()=>{d.size===m.length&&m.length>0?o(new Set):o(new Set(m.map(s=>s._id)))},[d.size,m]),z=i.useCallback(()=>{o(new Set)},[]);return N?e.jsxs("div",{className:"space-y-6 p-6",children:[e.jsx(P,{title:"Content",description:"Browse and manage content entries across all content types."}),e.jsxs("div",{className:"flex flex-col items-center justify-center py-12",children:[e.jsx("div",{className:"size-8 animate-spin rounded-full border-2 border-muted border-t-primary"}),e.jsx("p",{className:"mt-4 text-sm text-muted-foreground",children:"Loading content..."})]})]}):e.jsxs("div",{className:"space-y-6 p-6",children:[e.jsx(P,{title:"Content",description:"Browse and manage content entries across all content types."}),e.jsx(re,{left:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("div",{className:"relative",children:[e.jsx(oe,{className:"absolute left-3 top-1/2 size-4 -translate-y-1/2 text-muted-foreground"}),e.jsx(ee,{type:"text",placeholder:"Search content...",value:c,onChange:s=>f(s.target.value),className:"w-64 pl-9","data-testid":"content-search-input"})]}),e.jsxs(_,{value:u||"all",onValueChange:s=>t(s==="all"?"":s),children:[e.jsx(I,{className:"w-48",children:e.jsx(U,{placeholder:"All Content Types"})}),e.jsxs(B,{children:[e.jsx(j,{value:"all",children:"All Content Types"}),x.map(s=>e.jsx(j,{value:s._id,children:s.displayName},s._id))]})]}),e.jsxs(_,{value:r||"all",onValueChange:s=>h(s==="all"?"":s),children:[e.jsx(I,{className:"w-36",children:e.jsx(U,{placeholder:"All Statuses"})}),e.jsxs(B,{children:[e.jsx(j,{value:"all",children:"All Statuses"}),e.jsx(j,{value:"draft",children:"Draft"}),e.jsx(j,{value:"published",children:"Published"}),e.jsx(j,{value:"scheduled",children:"Scheduled"}),e.jsx(j,{value:"archived",children:"Archived"})]})]})]}),right:y("contentEntries")&&e.jsxs(J,{children:[e.jsx(K,{asChild:!0,children:e.jsxs(p,{disabled:x.length===0,children:[e.jsx(W,{className:"size-4"}),"Create Entry",e.jsx(X,{className:"size-4"})]})}),e.jsx(Y,{align:"end",children:x.map(s=>e.jsx(Z,{onClick:()=>V(s._id),children:s.displayName},s._id))})]})}),e.jsx(xe,{selectedIds:Array.from(d),onClearSelection:z,onOperationComplete:z}),m.length===0?e.jsx(ce,{icon:e.jsx(se,{className:"size-6"}),title:"No content entries yet",description:x.length===0?"Create a content type first, then start adding content entries.":'Click "Create Entry" to add your first content entry.'}):e.jsx("div",{className:"rounded-lg border bg-card",children:e.jsxs("table",{className:"w-full",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b",children:[e.jsx("th",{className:"w-10 p-3 text-left",children:e.jsx(L,{checked:d.size===m.length&&m.length>0,onCheckedChange:R,"aria-label":"Select all entries"})}),e.jsx("th",{className:"p-3 text-left text-sm font-medium text-muted-foreground",children:"Title"}),e.jsx("th",{className:"p-3 text-left text-sm font-medium text-muted-foreground",children:"Type"}),e.jsx("th",{className:"p-3 text-left text-sm font-medium text-muted-foreground",children:"Status"}),e.jsx("th",{className:"p-3 text-left text-sm font-medium text-muted-foreground",children:"Updated"}),e.jsx("th",{className:"p-3 text-left text-sm font-medium text-muted-foreground",children:"Actions"})]})}),e.jsx("tbody",{children:m.map(s=>e.jsxs("tr",{className:te("border-b last:border-0 transition-colors hover:bg-muted/50",d.has(s._id)&&"bg-primary/5"),children:[e.jsx("td",{className:"p-3",children:e.jsx(L,{checked:d.has(s._id),onCheckedChange:g=>O(s._id,g),"aria-label":`Select ${E(s,s.contentTypeName)}`})}),e.jsx("td",{className:"p-3",children:e.jsxs("button",{type:"button",onClick:()=>l.navigateToEntry(s._id),className:"block text-left",children:[e.jsx("span",{className:"font-medium text-foreground hover:text-primary",children:E(s,s.contentTypeName)}),e.jsx("span",{className:"block text-xs text-muted-foreground",children:s.slug})]})}),e.jsx("td",{className:"p-3 text-sm text-muted-foreground",children:F(s.contentTypeName)}),e.jsx("td",{className:"p-3",children:e.jsx(de,{status:s.status})}),e.jsx("td",{className:"p-3 text-sm text-muted-foreground",children:M(s._creationTime)}),e.jsx("td",{className:"p-3",children:e.jsx(p,{variant:"outline",size:"sm",onClick:()=>l.navigateToEntry(s._id),children:k("contentEntries")?"Edit":"View"})})]},s._id))})]})})]})}function we(){const a=me();return e.jsx(pe,{api:ae.admin,navigation:a})}export{we as component};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{l as V,r as a,u as q,j as e,h as g,$ as E,C as l,P as B,I as R,g as $,a0 as j,a1 as z,O as k,a2 as L,a3 as G,a4 as Q,t as H,q as J,a5 as X,E as K,U as W,a6 as S,a7 as Y,a8 as Z,k as T}from"./main-CA-4LyFT.js";import{C as ee}from"./CmsPageHeader-0REGRH4X.js";import{C as se}from"./CmsToolbar-CY6GV2L8.js";import{C as te}from"./CmsEmptyState-DTlpzjOI.js";import{B as d}from"./badge-C6qt24oj.js";import{S as ae}from"./search-WXp6KxDJ.js";import{P as M}from"./pencil-gAL0R34f.js";import{u as re}from"./tanstack-adapter-BRt2CUCw.js";const ie=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 9h18",key:"1pudct"}],["path",{d:"M3 15h18",key:"5xshup"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"M15 3v18",key:"14nvp0"}]],de=V("grid-3x3",ie),oe={text:e.jsx(L,{className:"size-3"}),richText:e.jsx(j,{className:"size-3"}),number:e.jsx(Z,{className:"size-3"}),boolean:e.jsx(Y,{className:"size-3"}),date:e.jsx(S,{className:"size-3"}),datetime:e.jsx(S,{className:"size-3"}),reference:e.jsx(W,{className:"size-3"}),media:e.jsx(K,{className:"size-3"}),json:e.jsx(X,{className:"size-3"}),select:e.jsx(J,{className:"size-3"}),multiSelect:e.jsx(E,{className:"size-3"}),tags:e.jsx(H,{className:"size-3"}),category:e.jsx(Q,{className:"size-3"})};function ne({api:c,navigation:p}){const[r,A]=a.useState(""),[m,N]=a.useState("grid"),[b,_]=a.useState(!0),[I,x]=a.useState(!1),[v,i]=a.useState(null),D=a.useCallback(()=>{x(!1)},[]),F=a.useCallback(()=>{i(null)},[]),y=q(c.listContentTypes,{isActive:b?!0:void 0,includeEntryCounts:!0}),o=y?.page??[],C=y===void 0,n=a.useMemo(()=>{if(!r.trim())return o;const s=r.toLowerCase();return o.filter(t=>t.name.toLowerCase().includes(s)||t.displayName.toLowerCase().includes(s))},[o,r]),w=s=>new Date(s).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric"}),O=s=>{const P=Date.now()-s,U=Math.floor(P/1e3),u=Math.floor(U/60),f=Math.floor(u/60),h=Math.floor(f/24);return h>30?w(s):h>0?`${h}d ago`:f>0?`${f}h ago`:u>0?`${u}m ago`:"Just now"};return e.jsxs("div",{className:"space-y-6 p-6",children:[e.jsx(ee,{title:"Content Types",description:"Define the structure of your content with custom fields and validation rules."}),e.jsx(se,{left:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("div",{className:"relative",children:[e.jsx(ae,{className:"absolute left-3 top-1/2 size-4 -translate-y-1/2 text-muted-foreground"}),e.jsx(R,{type:"search",placeholder:"Search content types...",value:r,onChange:s=>A(s.target.value),className:"w-64 pl-9"})]}),e.jsxs("label",{className:"flex cursor-pointer items-center gap-2 text-sm",children:[e.jsx($,{checked:b,onCheckedChange:s=>_(s)}),"Active only"]})]}),right:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("div",{className:"flex rounded-md border bg-muted/30",children:[e.jsx("button",{className:g("rounded-l-md p-2 transition-colors",m==="grid"?"bg-background shadow-sm":"hover:bg-muted/50"),onClick:()=>N("grid"),title:"Grid view","aria-label":"Grid view",children:e.jsx(de,{className:"size-4"})}),e.jsx("button",{className:g("rounded-r-md p-2 transition-colors",m==="list"?"bg-background shadow-sm":"hover:bg-muted/50"),onClick:()=>N("list"),title:"List view","aria-label":"List view",children:e.jsx(E,{className:"size-4"})})]}),e.jsxs(l,{onClick:()=>x(!0),"data-testid":"create-content-type-button",children:[e.jsx(B,{className:"size-4"}),"Create Content Type"]})]})}),C?e.jsxs("div",{className:"flex flex-col items-center justify-center py-12",children:[e.jsx("div",{className:"size-8 animate-spin rounded-full border-2 border-muted border-t-primary"}),e.jsx("p",{className:"mt-4 text-sm text-muted-foreground",children:"Loading content types..."})]}):n.length===0?e.jsx(te,{icon:e.jsx(j,{className:"size-6"}),title:r?"No content types match your search":"No content types defined",description:r?"Try adjusting your search query or filters.":"Content types define the schema for your content. Create one to get started."}):m==="grid"?e.jsx("div",{className:"grid gap-4 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4",children:n.map(s=>e.jsxs("div",{className:"group flex flex-col rounded-lg border bg-card p-4 transition-all hover:border-primary/50 hover:shadow-md",children:[e.jsxs("div",{className:"mb-3 flex items-center justify-between",children:[e.jsx("div",{className:"flex size-10 items-center justify-center rounded-md bg-muted text-muted-foreground",children:e.jsx(j,{className:"size-5"})}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[s.source==="code"&&e.jsxs(d,{variant:"secondary",className:"border-violet-200 bg-violet-50 text-xs font-normal text-violet-700",title:"Managed by code - edit in your codebase",children:[e.jsx(z,{className:"mr-1 size-3"}),"Code"]}),!s.isActive&&e.jsx(d,{variant:"secondary",className:"text-xs font-normal",children:"Inactive"}),s.singleton&&e.jsx(d,{variant:"secondary",className:"border-diff-modified-border bg-diff-modified-bg text-xs font-normal text-diff-modified-foreground",children:"Singleton"}),s.source==="code"?e.jsx("button",{className:"rounded p-1.5 text-muted-foreground opacity-0 transition-all hover:bg-muted hover:text-foreground group-hover:opacity-100",title:"View content type (managed by code)","aria-label":"View content type",onClick:()=>i(s),children:e.jsx(k,{className:"size-4"})}):e.jsx("button",{onClick:()=>i(s),className:"rounded p-1.5 text-muted-foreground opacity-0 transition-all hover:bg-muted hover:text-foreground group-hover:opacity-100",title:"Edit content type","aria-label":"Edit content type",children:e.jsx(M,{className:"size-4"})})]})]}),e.jsxs("button",{type:"button",onClick:()=>p.navigateToContentType(s._id),className:"flex flex-1 flex-col text-left",children:[e.jsx("h3",{className:"text-base font-semibold text-foreground",children:s.displayName}),e.jsx("p",{className:"mt-0.5 text-xs text-muted-foreground",children:s.name}),e.jsxs("div",{className:"mt-3 flex items-center gap-4",children:[e.jsxs("div",{className:"text-center",children:[e.jsx("p",{className:"text-lg font-semibold text-foreground",children:s.fields.length}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s.fields.length===1?"Field":"Fields"})]}),e.jsxs("div",{className:"text-center",children:[e.jsx("p",{className:"text-lg font-semibold text-foreground",children:s.entryCount??0}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s.entryCount===1?"Entry":"Entries"})]})]}),e.jsxs("div",{className:"mt-3 flex flex-wrap gap-1.5",children:[s.fields.slice(0,4).map(t=>e.jsxs("span",{className:"flex items-center gap-1 rounded-md bg-muted px-1.5 py-0.5 text-xs text-muted-foreground",title:t.label,children:[oe[t.type]||e.jsx(L,{className:"size-3"}),e.jsx("span",{className:"truncate",children:t.label})]},t.name)),s.fields.length>4&&e.jsxs("span",{className:"rounded-md bg-muted px-1.5 py-0.5 text-xs text-muted-foreground",children:["+",s.fields.length-4," more"]})]}),e.jsxs("p",{className:"mt-auto pt-3 text-xs text-muted-foreground",children:["Updated ",O(s._creationTime)]})]})]},s._id))}):e.jsx("div",{className:"rounded-lg border bg-card",children:e.jsxs("table",{className:"w-full",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b",children:[e.jsx("th",{className:"p-3 text-left text-sm font-medium text-muted-foreground",children:"Name"}),e.jsx("th",{className:"p-3 text-left text-sm font-medium text-muted-foreground",children:"Fields"}),e.jsx("th",{className:"p-3 text-left text-sm font-medium text-muted-foreground",children:"Entries"}),e.jsx("th",{className:"p-3 text-left text-sm font-medium text-muted-foreground",children:"Status"}),e.jsx("th",{className:"p-3 text-left text-sm font-medium text-muted-foreground",children:"Last Updated"}),e.jsx("th",{className:"p-3 text-left text-sm font-medium text-muted-foreground",children:"Actions"})]})}),e.jsx("tbody",{children:n.map(s=>e.jsxs("tr",{className:"border-b last:border-0 transition-colors hover:bg-muted/50",children:[e.jsxs("td",{className:"p-3",children:[e.jsx("p",{className:"font-medium text-foreground",children:s.displayName}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s.name})]}),e.jsx("td",{className:"p-3 text-sm text-muted-foreground",children:s.fields.length}),e.jsx("td",{className:"p-3 text-sm text-muted-foreground",children:s.entryCount??0}),e.jsx("td",{className:"p-3",children:e.jsxs("div",{className:"flex items-center gap-1.5",children:[s.source==="code"&&e.jsxs(d,{variant:"secondary",className:"border-violet-200 bg-violet-50 text-xs font-normal text-violet-700",title:"Managed by code",children:[e.jsx(z,{className:"mr-1 size-3"}),"Code"]}),e.jsx(d,{variant:s.isActive?"default":"secondary",className:g("text-xs font-normal",s.isActive&&"border-diff-added-border bg-diff-added-bg text-diff-added-foreground"),children:s.isActive?"Active":"Inactive"}),s.singleton&&e.jsx(d,{variant:"secondary",className:"border-diff-modified-border bg-diff-modified-bg text-xs font-normal text-diff-modified-foreground",children:"Singleton"})]})}),e.jsx("td",{className:"p-3 text-sm text-muted-foreground",children:w(s._creationTime)}),e.jsx("td",{className:"p-3",children:e.jsxs("div",{className:"flex items-center gap-2",children:[s.source==="code"?e.jsxs(l,{variant:"outline",size:"sm",onClick:()=>i(s),title:"View content type (managed by code)",children:[e.jsx(k,{className:"size-3.5"}),"View"]}):e.jsxs(l,{variant:"outline",size:"sm",onClick:()=>i(s),children:[e.jsx(M,{className:"size-3.5"}),"Edit"]}),e.jsx(l,{variant:"outline",size:"sm",onClick:()=>p.navigateToContentType(s._id),children:"View Entries"})]})})]},s._id))})]})}),!C&&n.length>0&&e.jsxs("p",{className:"text-center text-sm text-muted-foreground",children:["Showing ",n.length," of ",o.length," content type",o.length!==1?"s":""]}),e.jsx(G,{isOpen:I||!!v,onClose:()=>{x(!1),i(null)},contentType:v,onCreated:D,onUpdated:F})]})}function je(){const c=re();return e.jsx(ne,{api:T.admin,navigation:c})}export{je as component};
|