@wraps.dev/cli 2.1.0 → 2.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +36 -0
- package/dist/cli.js +700 -437
- package/dist/cli.js.map +1 -1
- package/dist/console/assets/{index-C2_7RIq3.js → index-JCrXm_D5.js} +2 -2
- package/dist/console/index.html +1 -1
- package/dist/lambda/event-processor/.bundled +1 -1
- package/dist/lambda/sms-event-processor/.bundled +1 -1
- package/package.json +1 -1
|
@@ -389,7 +389,7 @@ Please change the parent <Route path="${_}"> to <Route path="${_==="/"?"*":`${_}
|
|
|
389
389
|
|
|
390
390
|
If you want to hide the \`${t.titleName}\`, you can wrap it with our VisuallyHidden component.
|
|
391
391
|
|
|
392
|
-
For more information, see https://radix-ui.com/primitives/docs/components/${t.docsSlug}`;return j.useEffect(()=>{e&&(document.getElementById(e)||console.error(n))},[n,e]),null},AY="DialogDescriptionWarning",NY=({contentRef:e,descriptionId:t})=>{const r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${iI(AY).contentName}}.`;return j.useEffect(()=>{var s;const i=(s=e.current)==null?void 0:s.getAttribute("aria-describedby");t&&i&&(document.getElementById(t)||console.warn(r))},[r,e,t]),null},nO=GL,TY=YL,rO=KL,aO=XL,iO=QL,oO=JL,sO=tI,zp=rI;function CY({...e}){return c.jsx(nO,{"data-slot":"sheet",...e})}function MY({...e}){return c.jsx(rO,{"data-slot":"sheet-portal",...e})}function RY({className:e,...t}){return c.jsx(aO,{className:ve("data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50 data-[state=closed]:animate-out data-[state=open]:animate-in",e),"data-slot":"sheet-overlay",...t})}function DY({className:e,children:t,side:n="right",...r}){return c.jsxs(MY,{children:[c.jsx(RY,{}),c.jsxs(iO,{className:ve("fixed z-50 flex flex-col gap-4 bg-background shadow-lg transition ease-in-out data-[state=closed]:animate-out data-[state=open]:animate-in data-[state=closed]:duration-300 data-[state=open]:duration-500",n==="right"&&"data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right inset-y-0 right-0 h-full w-3/4 border-l sm:max-w-sm",n==="left"&&"data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left inset-y-0 left-0 h-full w-3/4 border-r sm:max-w-sm",n==="top"&&"data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top inset-x-0 top-0 h-auto border-b",n==="bottom"&&"data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom inset-x-0 bottom-0 h-auto border-t",e),"data-slot":"sheet-content",...r,children:[t,c.jsxs(zp,{className:"absolute top-4 right-4 rounded-xs opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-hidden focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-secondary",children:[c.jsx(rr,{className:"size-4"}),c.jsx("span",{className:"sr-only",children:"Close"})]})]})]})}function PY({className:e,...t}){return c.jsx("div",{className:ve("flex flex-col gap-1.5 p-4",e),"data-slot":"sheet-header",...t})}function kY({className:e,...t}){return c.jsx(oO,{className:ve("font-semibold text-foreground",e),"data-slot":"sheet-title",...t})}function $Y({className:e,...t}){return c.jsx(sO,{className:ve("text-muted-foreground text-sm",e),"data-slot":"sheet-description",...t})}function Re({className:e,...t}){return c.jsx("div",{className:ve("animate-pulse rounded-md bg-accent",e),"data-slot":"skeleton",...t})}var oI=Object.freeze({position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal"}),LY="VisuallyHidden",sI=j.forwardRef((e,t)=>c.jsx(Ce.span,{...e,ref:t,style:{...oI,...e.style}}));sI.displayName=LY;var IY=sI,[Bp]=qn("Tooltip",[Jl]),qp=Jl(),lI="TooltipProvider",zY=700,k1="tooltip.open",[BY,lO]=Bp(lI),cI=e=>{const{__scopeTooltip:t,delayDuration:n=zY,skipDelayDuration:r=300,disableHoverableContent:i=!1,children:s}=e,l=j.useRef(!0),f=j.useRef(!1),d=j.useRef(0);return j.useEffect(()=>{const h=d.current;return()=>window.clearTimeout(h)},[]),c.jsx(BY,{scope:t,isOpenDelayedRef:l,delayDuration:n,onOpen:j.useCallback(()=>{window.clearTimeout(d.current),l.current=!1},[]),onClose:j.useCallback(()=>{window.clearTimeout(d.current),d.current=window.setTimeout(()=>l.current=!0,r)},[r]),isPointerInTransitRef:f,onPointerInTransitChange:j.useCallback(h=>{f.current=h},[]),disableHoverableContent:i,children:s})};cI.displayName=lI;var qu="Tooltip",[qY,Bf]=Bp(qu),uI=e=>{const{__scopeTooltip:t,children:n,open:r,defaultOpen:i,onOpenChange:s,disableHoverableContent:l,delayDuration:f}=e,d=lO(qu,e.__scopeTooltip),h=qp(t),[v,p]=j.useState(null),g=_r(),b=j.useRef(0),O=l??d.disableHoverableContent,S=f??d.delayDuration,x=j.useRef(!1),[E,A]=Vr({prop:r,defaultProp:i??!1,onChange:R=>{R?(d.onOpen(),document.dispatchEvent(new CustomEvent(k1))):d.onClose(),s==null||s(R)},caller:qu}),_=j.useMemo(()=>E?x.current?"delayed-open":"instant-open":"closed",[E]),T=j.useCallback(()=>{window.clearTimeout(b.current),b.current=0,x.current=!1,A(!0)},[A]),N=j.useCallback(()=>{window.clearTimeout(b.current),b.current=0,A(!1)},[A]),M=j.useCallback(()=>{window.clearTimeout(b.current),b.current=window.setTimeout(()=>{x.current=!0,A(!0),b.current=0},S)},[S,A]);return j.useEffect(()=>()=>{b.current&&(window.clearTimeout(b.current),b.current=0)},[]),c.jsx(Bj,{...h,children:c.jsx(qY,{scope:t,contentId:g,open:E,stateAttribute:_,trigger:v,onTriggerChange:p,onTriggerEnter:j.useCallback(()=>{d.isOpenDelayedRef.current?M():T()},[d.isOpenDelayedRef,M,T]),onTriggerLeave:j.useCallback(()=>{O?N():(window.clearTimeout(b.current),b.current=0)},[N,O]),onOpen:T,onClose:N,disableHoverableContent:O,children:n})})};uI.displayName=qu;var $1="TooltipTrigger",fI=j.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,i=Bf($1,n),s=lO($1,n),l=qp(n),f=j.useRef(null),d=Be(t,f,i.onTriggerChange),h=j.useRef(!1),v=j.useRef(!1),p=j.useCallback(()=>h.current=!1,[]);return j.useEffect(()=>()=>document.removeEventListener("pointerup",p),[p]),c.jsx(qj,{asChild:!0,...l,children:c.jsx(Ce.button,{"aria-describedby":i.open?i.contentId:void 0,"data-state":i.stateAttribute,...r,ref:d,onPointerMove:be(e.onPointerMove,g=>{g.pointerType!=="touch"&&!v.current&&!s.isPointerInTransitRef.current&&(i.onTriggerEnter(),v.current=!0)}),onPointerLeave:be(e.onPointerLeave,()=>{i.onTriggerLeave(),v.current=!1}),onPointerDown:be(e.onPointerDown,()=>{i.open&&i.onClose(),h.current=!0,document.addEventListener("pointerup",p,{once:!0})}),onFocus:be(e.onFocus,()=>{h.current||i.onOpen()}),onBlur:be(e.onBlur,i.onClose),onClick:be(e.onClick,i.onClose)})})});fI.displayName=$1;var cO="TooltipPortal",[UY,HY]=Bp(cO,{forceMount:void 0}),dI=e=>{const{__scopeTooltip:t,forceMount:n,children:r,container:i}=e,s=Bf(cO,t);return c.jsx(UY,{scope:t,forceMount:n,children:c.jsx(lr,{present:n||s.open,children:c.jsx($f,{asChild:!0,container:i,children:r})})})};dI.displayName=cO;var Sl="TooltipContent",hI=j.forwardRef((e,t)=>{const n=HY(Sl,e.__scopeTooltip),{forceMount:r=n.forceMount,side:i="top",...s}=e,l=Bf(Sl,e.__scopeTooltip);return c.jsx(lr,{present:r||l.open,children:l.disableHoverableContent?c.jsx(mI,{side:i,...s,ref:t}):c.jsx(FY,{side:i,...s,ref:t})})}),FY=j.forwardRef((e,t)=>{const n=Bf(Sl,e.__scopeTooltip),r=lO(Sl,e.__scopeTooltip),i=j.useRef(null),s=Be(t,i),[l,f]=j.useState(null),{trigger:d,onClose:h}=n,v=i.current,{onPointerInTransitChange:p}=r,g=j.useCallback(()=>{f(null),p(!1)},[p]),b=j.useCallback((O,S)=>{const x=O.currentTarget,E={x:O.clientX,y:O.clientY},A=WY(E,x.getBoundingClientRect()),_=KY(E,A),T=XY(S.getBoundingClientRect()),N=ZY([..._,...T]);f(N),p(!0)},[p]);return j.useEffect(()=>()=>g(),[g]),j.useEffect(()=>{if(d&&v){const O=x=>b(x,v),S=x=>b(x,d);return d.addEventListener("pointerleave",O),v.addEventListener("pointerleave",S),()=>{d.removeEventListener("pointerleave",O),v.removeEventListener("pointerleave",S)}}},[d,v,b,g]),j.useEffect(()=>{if(l){const O=S=>{const x=S.target,E={x:S.clientX,y:S.clientY},A=(d==null?void 0:d.contains(x))||(v==null?void 0:v.contains(x)),_=!QY(E,l);A?g():_&&(g(),h())};return document.addEventListener("pointermove",O),()=>document.removeEventListener("pointermove",O)}},[d,v,l,h,g]),c.jsx(mI,{...e,ref:s})}),[GY,VY]=Bp(qu,{isInside:!1}),YY=v$("TooltipContent"),mI=j.forwardRef((e,t)=>{const{__scopeTooltip:n,children:r,"aria-label":i,onEscapeKeyDown:s,onPointerDownOutside:l,...f}=e,d=Bf(Sl,n),h=qp(n),{onClose:v}=d;return j.useEffect(()=>(document.addEventListener(k1,v),()=>document.removeEventListener(k1,v)),[v]),j.useEffect(()=>{if(d.trigger){const p=g=>{const b=g.target;b!=null&&b.contains(d.trigger)&&v()};return window.addEventListener("scroll",p,{capture:!0}),()=>window.removeEventListener("scroll",p,{capture:!0})}},[d.trigger,v]),c.jsx(Pf,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:s,onPointerDownOutside:l,onFocusOutside:p=>p.preventDefault(),onDismiss:v,children:c.jsxs(Uj,{"data-state":d.stateAttribute,...h,...f,ref:t,style:{...f.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-tooltip-content-available-width":"var(--radix-popper-available-width)","--radix-tooltip-content-available-height":"var(--radix-popper-available-height)","--radix-tooltip-trigger-width":"var(--radix-popper-anchor-width)","--radix-tooltip-trigger-height":"var(--radix-popper-anchor-height)"},children:[c.jsx(YY,{children:r}),c.jsx(GY,{scope:n,isInside:!0,children:c.jsx(IY,{id:d.contentId,role:"tooltip",children:i||r})})]})})});hI.displayName=Sl;var pI="TooltipArrow",vI=j.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,i=qp(n);return VY(pI,n).isInside?null:c.jsx(Hj,{...i,...r,ref:t})});vI.displayName=pI;function WY(e,t){const n=Math.abs(t.top-e.y),r=Math.abs(t.bottom-e.y),i=Math.abs(t.right-e.x),s=Math.abs(t.left-e.x);switch(Math.min(n,r,i,s)){case s:return"left";case i:return"right";case n:return"top";case r:return"bottom";default:throw new Error("unreachable")}}function KY(e,t,n=5){const r=[];switch(t){case"top":r.push({x:e.x-n,y:e.y+n},{x:e.x+n,y:e.y+n});break;case"bottom":r.push({x:e.x-n,y:e.y-n},{x:e.x+n,y:e.y-n});break;case"left":r.push({x:e.x+n,y:e.y-n},{x:e.x+n,y:e.y+n});break;case"right":r.push({x:e.x-n,y:e.y-n},{x:e.x-n,y:e.y+n});break}return r}function XY(e){const{top:t,right:n,bottom:r,left:i}=e;return[{x:i,y:t},{x:n,y:t},{x:n,y:r},{x:i,y:r}]}function QY(e,t){const{x:n,y:r}=e;let i=!1;for(let s=0,l=t.length-1;s<t.length;l=s++){const f=t[s],d=t[l],h=f.x,v=f.y,p=d.x,g=d.y;v>r!=g>r&&n<(p-h)*(r-v)/(g-v)+h&&(i=!i)}return i}function ZY(e){const t=e.slice();return t.sort((n,r)=>n.x<r.x?-1:n.x>r.x?1:n.y<r.y?-1:n.y>r.y?1:0),JY(t)}function JY(e){if(e.length<=1)return e.slice();const t=[];for(let r=0;r<e.length;r++){const i=e[r];for(;t.length>=2;){const s=t[t.length-1],l=t[t.length-2];if((s.x-l.x)*(i.y-l.y)>=(s.y-l.y)*(i.x-l.x))t.pop();else break}t.push(i)}t.pop();const n=[];for(let r=e.length-1;r>=0;r--){const i=e[r];for(;n.length>=2;){const s=n[n.length-1],l=n[n.length-2];if((s.x-l.x)*(i.y-l.y)>=(s.y-l.y)*(i.x-l.x))n.pop();else break}n.push(i)}return n.pop(),t.length===1&&n.length===1&&t[0].x===n[0].x&&t[0].y===n[0].y?t:t.concat(n)}var eW=cI,tW=uI,nW=fI,rW=dI,aW=hI,iW=vI;function gI({delayDuration:e=0,...t}){return c.jsx(eW,{"data-slot":"tooltip-provider",delayDuration:e,...t})}function Up({...e}){return c.jsx(gI,{children:c.jsx(tW,{"data-slot":"tooltip",...e})})}function Hp({...e}){return c.jsx(nW,{"data-slot":"tooltip-trigger",...e})}function Fp({className:e,sideOffset:t=0,children:n,...r}){return c.jsx(rW,{children:c.jsxs(aW,{className:ve("fade-in-0 zoom-in-95 data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-fit origin-[--radix-tooltip-content-transform-origin] animate-in text-balance rounded-md bg-foreground px-3 py-1.5 text-background text-xs data-[state=closed]:animate-out",e),"data-slot":"tooltip-content",sideOffset:t,...r,children:[n,c.jsx(iW,{className:"z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px] bg-foreground fill-foreground"})]})})}const yb=768;function oW(){const[e,t]=j.useState(void 0);return j.useEffect(()=>{const n=window.matchMedia(`(max-width: ${yb-1}px)`),r=()=>{t(window.innerWidth<yb)};return n.addEventListener("change",r),t(window.innerWidth<yb),()=>n.removeEventListener("change",r)},[]),!!e}const sW="sidebar_state",lW=3600*24*7,cW="16rem",uW="18rem",fW="3rem",dW="b",yI=j.createContext(null);function tc(){const e=j.useContext(yI);if(!e)throw new Error("useSidebar must be used within a SidebarProvider.");return e}const bI=j.forwardRef(({defaultOpen:e=!0,open:t,onOpenChange:n,className:r,style:i,children:s,...l},f)=>{const d=oW(),[h,v]=j.useState(!1),[p,g]=j.useState(e),b=t??p,O=j.useCallback(A=>{const _=typeof A=="function"?A(b):A;n?n(_):g(_),document.cookie=`${sW}=${_}; path=/; max-age=${lW}`},[n,b]),S=j.useCallback(()=>d?v(A=>!A):O(A=>!A),[d,O]);j.useEffect(()=>{const A=_=>{_.key===dW&&(_.metaKey||_.ctrlKey)&&(_.preventDefault(),S())};return window.addEventListener("keydown",A),()=>window.removeEventListener("keydown",A)},[S]);const x=b?"expanded":"collapsed",E=j.useMemo(()=>({state:x,open:b,setOpen:O,isMobile:d,openMobile:h,setOpenMobile:v,toggleSidebar:S}),[x,b,O,d,h,S]);return c.jsx(yI.Provider,{value:E,children:c.jsx(gI,{delayDuration:0,children:c.jsx("div",{className:ve("group/sidebar-wrapper flex min-h-svh w-full has-[[data-variant=inset]]:bg-sidebar",r),ref:f,style:{"--sidebar-width":cW,"--sidebar-width-icon":fW,...i},...l,children:s})})})});bI.displayName="SidebarProvider";const Fh=j.forwardRef(({side:e="left",variant:t="sidebar",collapsible:n="offcanvas",className:r,children:i,...s},l)=>{const{isMobile:f,state:d,openMobile:h,setOpenMobile:v}=tc();return n==="none"?c.jsx("div",{className:ve("flex h-full w-[calc(var(--sidebar-width)-var(--sidebar-width-icon)+1px)]! flex-col bg-sidebar text-sidebar-foreground",r),ref:l,...s,children:i}):f?c.jsx(CY,{onOpenChange:v,open:h,...s,children:c.jsxs(DY,{className:"w-[--sidebar-width] bg-sidebar p-0 text-sidebar-foreground [&>button]:hidden","data-mobile":"true","data-sidebar":"sidebar",side:e,style:{"--sidebar-width":uW},children:[c.jsxs(PY,{className:"sr-only",children:[c.jsx(kY,{children:"Sidebar"}),c.jsx($Y,{children:"Displays the mobile sidebar."})]}),c.jsx("div",{className:"flex h-full w-full flex-col",children:i})]})}):c.jsxs("div",{className:"group peer hidden text-sidebar-foreground md:block","data-collapsible":d==="collapsed"?n:"","data-side":e,"data-state":d,"data-variant":t,ref:l,children:[c.jsx("div",{className:ve("relative w-[--sidebar-width] bg-transparent transition-[width] duration-200 ease-linear","group-data-[collapsible=offcanvas]:w-0","group-data-[side=right]:rotate-180",t==="floating"||t==="inset"?"group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)_+_theme(spacing.4))]":"group-data-[collapsible=icon]:w-[--sidebar-width-icon]")}),c.jsx("div",{className:ve("fixed inset-y-0 z-10 hidden h-svh w-[--sidebar-width] transition-[left,right,width] duration-200 ease-linear md:flex",e==="left"?"left-0 group-data-[collapsible=offcanvas]:left-[calc(var(--sidebar-width)*-1)]":"right-0 group-data-[collapsible=offcanvas]:right-[calc(var(--sidebar-width)*-1)]",t==="floating"||t==="inset"?"p-2 group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)_+_theme(spacing.4)_+2px)]":"group-data-[collapsible=icon]:w-[--sidebar-width-icon] group-data-[side=left]:border-r group-data-[side=right]:border-l",r),...s,children:c.jsx("div",{className:"flex h-full w-full flex-col bg-sidebar group-data-[variant=floating]:rounded-lg group-data-[variant=floating]:border group-data-[variant=floating]:border-sidebar-border group-data-[variant=floating]:shadow","data-sidebar":"sidebar",children:i})})]})});Fh.displayName="Sidebar";const xI=j.forwardRef(({className:e,onClick:t,...n},r)=>{const{toggleSidebar:i}=tc();return c.jsxs(Ee,{className:ve("h-7 w-7",e),"data-sidebar":"trigger",onClick:s=>{t==null||t(s),i()},ref:r,size:"icon",variant:"ghost",...n,children:[c.jsx(FH,{}),c.jsx("span",{className:"sr-only",children:"Toggle Sidebar"})]})});xI.displayName="SidebarTrigger";const hW=j.forwardRef(({className:e,...t},n)=>{const{toggleSidebar:r}=tc();return c.jsx("button",{"aria-label":"Toggle Sidebar",className:ve("absolute inset-y-0 z-20 hidden w-4 -translate-x-1/2 transition-all ease-linear after:absolute after:inset-y-0 after:left-1/2 after:w-[2px] hover:after:bg-sidebar-border group-data-[side=left]:-right-4 group-data-[side=right]:left-0 sm:flex","[[data-side=left]_&]:cursor-w-resize [[data-side=right]_&]:cursor-e-resize","[[data-side=left][data-state=collapsed]_&]:cursor-e-resize [[data-side=right][data-state=collapsed]_&]:cursor-w-resize","group-data-[collapsible=offcanvas]:translate-x-0 group-data-[collapsible=offcanvas]:hover:bg-sidebar group-data-[collapsible=offcanvas]:after:left-full","[[data-side=left][data-collapsible=offcanvas]_&]:-right-2","[[data-side=right][data-collapsible=offcanvas]_&]:-left-2",e),"data-sidebar":"rail",onClick:r,ref:n,tabIndex:-1,title:"Toggle Sidebar",...t})});hW.displayName="SidebarRail";const wI=j.forwardRef(({className:e,...t},n)=>c.jsx("main",{className:ve("relative flex w-full flex-1 flex-col bg-background","md:peer-data-[state=collapsed]:peer-data-[variant=inset]:ml-2 md:peer-data-[variant=inset]:m-2 md:peer-data-[variant=inset]:ml-0 md:peer-data-[variant=inset]:rounded-xl md:peer-data-[variant=inset]:shadow",e),ref:n,...t}));wI.displayName="SidebarInset";const SI=j.forwardRef(({className:e,...t},n)=>c.jsx(ec,{className:ve("h-8 w-full bg-background shadow-none focus-visible:ring-2 focus-visible:ring-sidebar-ring",e),"data-sidebar":"input",ref:n,...t}));SI.displayName="SidebarInput";const L1=j.forwardRef(({className:e,...t},n)=>c.jsx("div",{className:ve("flex flex-col gap-2 p-2",e),"data-sidebar":"header",ref:n,...t}));L1.displayName="SidebarHeader";const jI=j.forwardRef(({className:e,...t},n)=>c.jsx("div",{className:ve("flex flex-col gap-2 p-2",e),"data-sidebar":"footer",ref:n,...t}));jI.displayName="SidebarFooter";const mW=j.forwardRef(({className:e,...t},n)=>c.jsx(Bt,{className:ve("mx-2 w-auto bg-sidebar-border",e),"data-sidebar":"separator",ref:n,...t}));mW.displayName="SidebarSeparator";const I1=j.forwardRef(({className:e,...t},n)=>c.jsx("div",{className:ve("flex min-h-0 flex-1 flex-col gap-2 overflow-auto group-data-[collapsible=icon]:overflow-hidden",e),"data-sidebar":"content",ref:n,...t}));I1.displayName="SidebarContent";const z1=j.forwardRef(({className:e,...t},n)=>c.jsx("div",{className:ve("relative flex w-full min-w-0 flex-col p-2",e),"data-sidebar":"group",ref:n,...t}));z1.displayName="SidebarGroup";const pW=j.forwardRef(({className:e,asChild:t=!1,...n},r)=>{const i=t?es:"div";return c.jsx(i,{className:ve("flex h-8 shrink-0 items-center rounded-md px-2 font-medium text-sidebar-foreground/70 text-xs outline-none ring-sidebar-ring transition-[margin,opacity] duration-200 ease-linear focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0","group-data-[collapsible=icon]:-mt-8 group-data-[collapsible=icon]:opacity-0",e),"data-sidebar":"group-label",ref:r,...n})});pW.displayName="SidebarGroupLabel";const vW=j.forwardRef(({className:e,asChild:t=!1,...n},r)=>{const i=t?es:"button";return c.jsx(i,{className:ve("absolute top-3.5 right-3 flex aspect-square w-5 items-center justify-center rounded-md p-0 text-sidebar-foreground outline-none ring-sidebar-ring transition-transform hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0","after:absolute after:-inset-2 after:md:hidden","group-data-[collapsible=icon]:hidden",e),"data-sidebar":"group-action",ref:r,...n})});vW.displayName="SidebarGroupAction";const B1=j.forwardRef(({className:e,...t},n)=>c.jsx("div",{className:ve("w-full text-sm",e),"data-sidebar":"group-content",ref:n,...t}));B1.displayName="SidebarGroupContent";const im=j.forwardRef(({className:e,...t},n)=>c.jsx("ul",{className:ve("flex w-full min-w-0 flex-col gap-1",e),"data-sidebar":"menu",ref:n,...t}));im.displayName="SidebarMenu";const om=j.forwardRef(({className:e,...t},n)=>c.jsx("li",{className:ve("group/menu-item relative",e),"data-sidebar":"menu-item",ref:n,...t}));om.displayName="SidebarMenuItem";const gW=Lp("peer/menu-button group-data-[collapsible=icon]:!size-8 group-data-[collapsible=icon]:!p-2 flex w-full items-center gap-2 overflow-hidden rounded-md p-2 text-left text-sm outline-none ring-sidebar-ring transition-[width,height,padding] hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 active:bg-sidebar-accent active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 group-has-[[data-sidebar=menu-action]]/menu-item:pr-8 aria-disabled:pointer-events-none aria-disabled:opacity-50 data-[active=true]:bg-sidebar-accent data-[active=true]:font-medium data-[active=true]:text-sidebar-accent-foreground data-[state=open]:hover:bg-sidebar-accent data-[state=open]:hover:text-sidebar-accent-foreground [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0",{variants:{variant:{default:"hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",outline:"bg-background shadow-[0_0_0_1px_hsl(var(--sidebar-border))] hover:bg-sidebar-accent hover:text-sidebar-accent-foreground hover:shadow-[0_0_0_1px_hsl(var(--sidebar-accent))]"},size:{default:"h-8 text-sm",sm:"h-7 text-xs",lg:"group-data-[collapsible=icon]:!p-0 h-12 text-sm"}},defaultVariants:{variant:"default",size:"default"}}),sm=j.forwardRef(({asChild:e=!1,isActive:t=!1,variant:n="default",size:r="default",tooltip:i,className:s,...l},f)=>{const d=e?es:"button",{isMobile:h,state:v}=tc(),p=c.jsx(d,{className:ve(gW({variant:n,size:r}),s),"data-active":t,"data-sidebar":"menu-button","data-size":r,ref:f,...l});return i?(typeof i=="string"&&(i={children:i}),c.jsxs(Up,{children:[c.jsx(Hp,{asChild:!0,children:p}),c.jsx(Fp,{align:"center",hidden:v!=="collapsed"||h,side:"right",...i})]})):p});sm.displayName="SidebarMenuButton";const yW=j.forwardRef(({className:e,asChild:t=!1,showOnHover:n=!1,...r},i)=>{const s=t?es:"button";return c.jsx(s,{className:ve("absolute top-1.5 right-1 flex aspect-square w-5 items-center justify-center rounded-md p-0 text-sidebar-foreground outline-none ring-sidebar-ring transition-transform hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 peer-hover/menu-button:text-sidebar-accent-foreground [&>svg]:size-4 [&>svg]:shrink-0","after:absolute after:-inset-2 after:md:hidden","peer-data-[size=sm]/menu-button:top-1","peer-data-[size=default]/menu-button:top-1.5","peer-data-[size=lg]/menu-button:top-2.5","group-data-[collapsible=icon]:hidden",n&&"group-focus-within/menu-item:opacity-100 group-hover/menu-item:opacity-100 data-[state=open]:opacity-100 peer-data-[active=true]/menu-button:text-sidebar-accent-foreground md:opacity-0",e),"data-sidebar":"menu-action",ref:i,...r})});yW.displayName="SidebarMenuAction";const bW=j.forwardRef(({className:e,...t},n)=>c.jsx("div",{className:ve("pointer-events-none absolute right-1 flex h-5 min-w-5 select-none items-center justify-center rounded-md px-1 font-medium text-sidebar-foreground text-xs tabular-nums","peer-hover/menu-button:text-sidebar-accent-foreground peer-data-[active=true]/menu-button:text-sidebar-accent-foreground","peer-data-[size=sm]/menu-button:top-1","peer-data-[size=default]/menu-button:top-1.5","peer-data-[size=lg]/menu-button:top-2.5","group-data-[collapsible=icon]:hidden",e),"data-sidebar":"menu-badge",ref:n,...t}));bW.displayName="SidebarMenuBadge";const xW=j.forwardRef(({className:e,showIcon:t=!1,...n},r)=>{const i=j.useMemo(()=>`${Math.floor(Math.random()*40)+50}%`,[]);return c.jsxs("div",{className:ve("flex h-8 items-center gap-2 rounded-md px-2",e),"data-sidebar":"menu-skeleton",ref:r,...n,children:[t&&c.jsx(Re,{className:"size-4 rounded-md","data-sidebar":"menu-skeleton-icon"}),c.jsx(Re,{className:"h-4 max-w-[--skeleton-width] flex-1","data-sidebar":"menu-skeleton-text",style:{"--skeleton-width":i}})]})});xW.displayName="SidebarMenuSkeleton";const wW=j.forwardRef(({className:e,...t},n)=>c.jsx("ul",{className:ve("mx-3.5 flex min-w-0 translate-x-px flex-col gap-1 border-sidebar-border border-l px-2.5 py-0.5","group-data-[collapsible=icon]:hidden",e),"data-sidebar":"menu-sub",ref:n,...t}));wW.displayName="SidebarMenuSub";const SW=j.forwardRef(({...e},t)=>c.jsx("li",{ref:t,...e}));SW.displayName="SidebarMenuSubItem";const jW=j.forwardRef(({asChild:e=!1,size:t="md",isActive:n,className:r,...i},s)=>{const l=e?es:"a";return c.jsx(l,{className:ve("flex h-7 min-w-0 -translate-x-px items-center gap-2 overflow-hidden rounded-md px-2 text-sidebar-foreground outline-none ring-sidebar-ring hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 active:bg-sidebar-accent active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0 [&>svg]:text-sidebar-accent-foreground","data-[active=true]:bg-sidebar-accent data-[active=true]:text-sidebar-accent-foreground",t==="sm"&&"text-xs",t==="md"&&"text-sm","group-data-[collapsible=icon]:hidden",r),"data-active":n,"data-sidebar":"menu-sub-button","data-size":t,ref:s,...i})});jW.displayName="SidebarMenuSubButton";const OW={theme:"system",setTheme:()=>null},OI=j.createContext(OW),EI=()=>{const e=j.useContext(OI);if(e===void 0)throw new Error("useTheme must be used within a ThemeProvider");return e};function EW({user:e}){const{isMobile:t}=tc(),{theme:n,setTheme:r}=EI(),[i,s]=j.useState(null),[l,f]=j.useState(0);j.useEffect(()=>{(async()=>{try{const g=sessionStorage.getItem("wraps-auth-token");if(!g){console.log("No auth token found yet, will retry..."),l<5&&setTimeout(()=>{f(O=>O+1)},200);return}console.log("Fetching user info from /api/user");const b=await fetch(`/api/user?token=${g}`);if(console.log("User API response status:",b.status),b.ok){const O=await b.json();console.log("User info received:",O),s(O)}else{const O=await b.text();console.error("Failed to fetch user info:",b.status,O)}}catch(g){console.error("Error fetching user info:",g)}})().catch(g=>{console.error("Failed to fetch user info:",g)})},[l]);const d=()=>{window.confirm("Are you sure you want to close the console?")&&window.close()},h=(i==null?void 0:i.accountAlias)||(i==null?void 0:i.accountId)||"Loading...",v=(i==null?void 0:i.region)||"...";return c.jsx(im,{children:c.jsx(om,{children:c.jsxs(IL,{children:[c.jsx(zL,{asChild:!0,children:c.jsxs(sm,{className:"data-[state=open]:bg-sidebar-accent data-[state=open]:text-sidebar-accent-foreground md:h-8 md:p-0",size:"lg",children:[c.jsxs(Y2,{className:"h-8 w-8 rounded-lg",children:[c.jsx(W2,{alt:h,src:e.avatar}),c.jsx(K2,{className:"rounded-lg bg-orange-500 text-white",children:"AWS"})]}),c.jsxs("div",{className:"grid flex-1 text-left text-sm leading-tight",children:[c.jsx("span",{className:"truncate font-medium",children:h}),c.jsx("span",{className:"truncate text-xs",children:v})]}),c.jsx(PH,{className:"ml-auto size-4"})]})}),c.jsxs(BL,{align:"end",className:"w-(--radix-dropdown-menu-trigger-width) min-w-56 rounded-lg",side:t?"bottom":"right",sideOffset:4,children:[c.jsx(qL,{className:"p-0 font-normal",children:c.jsxs("div",{className:"flex items-center gap-2 px-1 py-1.5 text-left text-sm",children:[c.jsxs(Y2,{className:"h-8 w-8 rounded-lg",children:[c.jsx(W2,{alt:h,src:e.avatar}),c.jsx(K2,{className:"rounded-lg bg-orange-500 text-white",children:"AWS"})]}),c.jsxs("div",{className:"grid flex-1 text-left text-sm leading-tight",children:[c.jsx("span",{className:"truncate font-medium",children:h}),c.jsx("span",{className:"truncate text-xs",children:v}),(i==null?void 0:i.accountId)&&i.accountId!==i.accountAlias&&c.jsx("span",{className:"truncate font-mono text-[10px] text-muted-foreground",children:i.accountId})]})]})}),c.jsx(P1,{}),c.jsxs(xT,{onClick:()=>r(n==="dark"?"light":"dark"),children:[n==="dark"?c.jsx(VH,{}):c.jsx(UH,{}),n==="dark"?"Light Mode":"Dark Mode"]}),c.jsx(P1,{}),c.jsxs(xT,{onClick:d,children:[c.jsx(rr,{}),"Close Console"]})]})]})})})}const Li={user:{name:"Wraps Console",email:"admin@wraps.dev",avatar:"/avatars/wraps.jpg"},navMain:[{title:"Dashboard",url:"/",icon:jp,isActive:!0,isDashboard:!0},{title:"Email",url:"#",icon:dl,isActive:!1,subItems:[{title:"Emails",icon:dl,url:"/email"},{title:"Metrics",icon:tb,url:"/email/metrics"},{title:"Settings",icon:rb,url:"/email/settings"}]},{title:"SMS",url:"#",icon:Yi,isActive:!1,subItems:[{title:"Messages",icon:Yi,url:"/sms"},{title:"Metrics",icon:tb,url:"/sms/metrics"},{title:"Settings",icon:rb,url:"/sms/settings"}]},{title:"Storage",url:"#",icon:Tf,isActive:!1,subItems:[{title:"Library",icon:G4,url:"/storage"},{title:"Metrics",icon:tb,url:"/storage/metrics"},{title:"Settings",icon:rb,url:"/storage/settings"}]}]};function _W({...e}){const t=ba(),n=Zo(),{setOpen:r,state:i}=tc(),{theme:s}=EI(),l=j.useCallback(()=>t.pathname==="/"?Li.navMain[0]:t.pathname.startsWith("/email")?Li.navMain[1]:t.pathname.startsWith("/sms")?Li.navMain[2]:t.pathname.startsWith("/storage")?Li.navMain[3]:Li.navMain[0],[t.pathname]),[f,d]=j.useState(l());return j.useEffect(()=>{d(l())},[l]),c.jsxs(Fh,{className:"overflow-hidden *:data-[sidebar=sidebar]:flex-row",collapsible:"icon",...e,children:[c.jsxs(Fh,{className:"w-[calc(var(--sidebar-width-icon)+1px)]! border-r",collapsible:"none",children:[c.jsx(L1,{children:c.jsx(im,{children:c.jsx(om,{children:c.jsx(sm,{asChild:!0,className:"md:h-8 md:p-0",onClick:()=>{d(Li.navMain[0]),r(!1)},size:"lg",children:c.jsxs(Yh,{to:"/",children:[c.jsx("div",{className:"flex aspect-square size-8 items-center justify-center rounded-lg",children:c.jsx("img",{alt:"Wraps",className:"size-8 object-contain",src:s==="dark"?"/wraps-dark.png":"/wraps-light.png"})}),c.jsxs("div",{className:"grid flex-1 text-left text-sm leading-tight",children:[c.jsx("span",{className:"truncate font-semibold",children:"Wraps"}),c.jsx("span",{className:"truncate text-xs",children:"Console"})]})]})})})})}),c.jsx(I1,{children:c.jsx(z1,{children:c.jsx(B1,{className:"px-1.5 md:px-0",children:c.jsx(im,{children:Li.navMain.filter(h=>!h.isDashboard).map(h=>c.jsx(om,{children:c.jsxs(sm,{className:"px-2.5 md:px-2",isActive:(f==null?void 0:f.title)===h.title,onClick:()=>{d(h),r(!0),h.subItems&&h.subItems.length>0&&n(h.subItems[0].url)},tooltip:{children:h.title,hidden:!1},children:[c.jsx(h.icon,{}),c.jsx("span",{children:h.title})]})},h.title))})})})}),c.jsx(jI,{children:c.jsx(EW,{user:Li.user})})]}),i==="expanded"&&c.jsx(Fh,{className:"hidden flex-1 md:flex",collapsible:"none",children:f&&!f.isDashboard&&f.subItems?c.jsxs(c.Fragment,{children:[c.jsxs(L1,{className:"gap-3.5 border-b p-4",children:[c.jsx("div",{className:"flex w-full items-center justify-between",children:c.jsxs("div",{className:"flex items-center gap-2 font-medium text-base text-foreground",children:[c.jsx(f.icon,{className:"size-4"}),f.title]})}),c.jsx(SI,{placeholder:"Search..."})]}),c.jsx(I1,{children:c.jsx(z1,{className:"px-0",children:c.jsx(B1,{children:f.subItems.map(h=>{const v=t.pathname===h.url||h.url==="/email"&&t.pathname.startsWith("/email/")&&t.pathname!=="/email/metrics"&&t.pathname!=="/email/settings"||h.url==="/sms"&&t.pathname.startsWith("/sms/")&&t.pathname!=="/sms/metrics"&&t.pathname!=="/sms/settings"||h.url==="/storage"&&t.pathname.startsWith("/storage/")&&t.pathname!=="/storage/metrics"&&t.pathname!=="/storage/settings";return c.jsxs(Yh,{className:`flex items-center gap-3 border-b p-4 text-sm leading-tight transition-colors last:border-b-0 hover:bg-sidebar-accent hover:text-sidebar-accent-foreground ${v?"bg-sidebar-accent font-semibold text-sidebar-accent-foreground":""}`,to:h.url,children:[c.jsx(h.icon,{className:"size-4 shrink-0"}),c.jsx("span",{className:"font-medium",children:h.title})]},h.title)})})})})]}):c.jsx("div",{className:"flex h-full items-center justify-center p-8 text-center",children:c.jsxs("div",{className:"text-muted-foreground",children:[c.jsx(jp,{className:"mx-auto mb-4 size-12 opacity-50"}),c.jsx("p",{className:"text-sm",children:"Select a product to view options"})]})})})]})}const AW=Lp("inline-flex w-fit shrink-0 items-center justify-center gap-1 overflow-hidden whitespace-nowrap rounded-full border px-2 py-0.5 font-medium text-xs transition-[color,box-shadow] focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 [&>svg]:pointer-events-none [&>svg]:size-3",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground [a&]:hover:bg-primary/90",secondary:"border-transparent bg-secondary text-secondary-foreground [a&]:hover:bg-secondary/90",destructive:"border-transparent bg-destructive text-white focus-visible:ring-destructive/20 dark:bg-destructive/60 dark:focus-visible:ring-destructive/40 [a&]:hover:bg-destructive/90",outline:"text-foreground [a&]:hover:bg-accent [a&]:hover:text-accent-foreground"}},defaultVariants:{variant:"default"}});function He({className:e,variant:t,asChild:n=!1,...r}){const i=n?es:"span";return c.jsx(i,{className:ve(AW({variant:t}),e),"data-slot":"badge",...r})}function Ne({className:e,...t}){return c.jsx("div",{className:ve("flex flex-col gap-6 rounded-xl border bg-card py-6 text-card-foreground shadow-sm",e),"data-slot":"card",...t})}function De({className:e,...t}){return c.jsx("div",{className:ve("@container/card-header grid auto-rows-min grid-rows-[auto_auto] items-start gap-2 px-6 has-data-[slot=card-action]:grid-cols-[1fr_auto] [.border-b]:pb-6",e),"data-slot":"card-header",...t})}function Fe({className:e,...t}){return c.jsx("div",{className:ve("font-semibold leading-none",e),"data-slot":"card-title",...t})}function Ye({className:e,...t}){return c.jsx("div",{className:ve("text-muted-foreground text-sm",e),"data-slot":"card-description",...t})}function Le({className:e,...t}){return c.jsx("div",{className:ve("px-6",e),"data-slot":"card-content",...t})}const NW=Lp("relative grid w-full grid-cols-[0_1fr] items-start gap-y-0.5 rounded-lg border px-4 py-3 text-sm has-[>svg]:grid-cols-[1rem_1fr] has-[>svg]:gap-x-3 [&>svg]:size-4 [&>svg]:translate-y-0.5 [&>svg]:text-current",{variants:{variant:{default:"bg-card text-card-foreground",destructive:"bg-card text-destructive *:data-[slot=alert-description]:text-destructive/90 [&>svg]:text-current"}},defaultVariants:{variant:"default"}});function In({className:e,variant:t,...n}){return c.jsx("div",{className:ve(NW({variant:t}),e),"data-slot":"alert",role:"alert",...n})}function Xi({className:e,...t}){return c.jsx("div",{className:ve("col-start-2 line-clamp-1 min-h-4 font-medium tracking-tight",e),"data-slot":"alert-title",...t})}function zn({className:e,...t}){return c.jsx("div",{className:ve("col-start-2 grid justify-items-start gap-1 text-muted-foreground text-sm [&_p]:leading-relaxed",e),"data-slot":"alert-description",...t})}var Gp="Tabs",[TW]=qn(Gp,[Mp]),_I=Mp(),[CW,uO]=TW(Gp),AI=j.forwardRef((e,t)=>{const{__scopeTabs:n,value:r,onValueChange:i,defaultValue:s,orientation:l="horizontal",dir:f,activationMode:d="automatic",...h}=e,v=Df(f),[p,g]=Vr({prop:r,onChange:i,defaultProp:s??"",caller:Gp});return c.jsx(CW,{scope:n,baseId:_r(),value:p,onValueChange:g,orientation:l,dir:v,activationMode:d,children:c.jsx(Ce.div,{dir:v,"data-orientation":l,...h,ref:t})})});AI.displayName=Gp;var NI="TabsList",TI=j.forwardRef((e,t)=>{const{__scopeTabs:n,loop:r=!0,...i}=e,s=uO(NI,n),l=_I(n);return c.jsx(Y$,{asChild:!0,...l,orientation:s.orientation,dir:s.dir,loop:r,children:c.jsx(Ce.div,{role:"tablist","aria-orientation":s.orientation,...i,ref:t})})});TI.displayName=NI;var CI="TabsTrigger",MI=j.forwardRef((e,t)=>{const{__scopeTabs:n,value:r,disabled:i=!1,...s}=e,l=uO(CI,n),f=_I(n),d=PI(l.baseId,r),h=kI(l.baseId,r),v=r===l.value;return c.jsx(W$,{asChild:!0,...f,focusable:!i,active:v,children:c.jsx(Ce.button,{type:"button",role:"tab","aria-selected":v,"aria-controls":h,"data-state":v?"active":"inactive","data-disabled":i?"":void 0,disabled:i,id:d,...s,ref:t,onMouseDown:be(e.onMouseDown,p=>{!i&&p.button===0&&p.ctrlKey===!1?l.onValueChange(r):p.preventDefault()}),onKeyDown:be(e.onKeyDown,p=>{[" ","Enter"].includes(p.key)&&l.onValueChange(r)}),onFocus:be(e.onFocus,()=>{const p=l.activationMode!=="manual";!v&&!i&&p&&l.onValueChange(r)})})})});MI.displayName=CI;var RI="TabsContent",DI=j.forwardRef((e,t)=>{const{__scopeTabs:n,value:r,forceMount:i,children:s,...l}=e,f=uO(RI,n),d=PI(f.baseId,r),h=kI(f.baseId,r),v=r===f.value,p=j.useRef(v);return j.useEffect(()=>{const g=requestAnimationFrame(()=>p.current=!1);return()=>cancelAnimationFrame(g)},[]),c.jsx(lr,{present:i||v,children:({present:g})=>c.jsx(Ce.div,{"data-state":v?"active":"inactive","data-orientation":f.orientation,role:"tabpanel","aria-labelledby":d,hidden:!g,id:h,tabIndex:0,...l,ref:t,style:{...e.style,animationDuration:p.current?"0s":void 0},children:g&&s})})});DI.displayName=RI;function PI(e,t){return`${e}-trigger-${t}`}function kI(e,t){return`${e}-content-${t}`}var MW=AI,RW=TI,DW=MI,PW=DI;function $I({className:e,...t}){return c.jsx(MW,{className:ve("flex flex-col gap-2",e),"data-slot":"tabs",...t})}function LI({className:e,...t}){return c.jsx(RW,{className:ve("inline-flex h-9 w-fit items-center justify-center rounded-lg bg-muted p-[3px] text-muted-foreground",e),"data-slot":"tabs-list",...t})}function _u({className:e,...t}){return c.jsx(DW,{className:ve("inline-flex h-[calc(100%-1px)] flex-1 items-center justify-center gap-1.5 whitespace-nowrap rounded-md border border-transparent px-2 py-1 font-medium text-foreground text-sm transition-[color,box-shadow] focus-visible:border-ring focus-visible:outline-1 focus-visible:outline-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-background data-[state=active]:shadow-sm dark:text-muted-foreground dark:data-[state=active]:border-input dark:data-[state=active]:bg-input/30 dark:data-[state=active]:text-foreground [&_svg:not([class*='size-'])]:size-4 [&_svg]:pointer-events-none [&_svg]:shrink-0",e),"data-slot":"tabs-trigger",...t})}function Au({className:e,...t}){return c.jsx(PW,{className:ve("flex-1 outline-none",e),"data-slot":"tabs-content",...t})}function kW({messageId:e,archivingEnabled:t}){const[n,r]=j.useState(null),[i,s]=j.useState(!0),[l,f]=j.useState(null);return j.useEffect(()=>{async function d(){if(!t){s(!1);return}try{s(!0),f(null);const h=sessionStorage.getItem("wraps-auth-token");if(!h)throw new Error("Authentication token not found");const v=encodeURIComponent(e),p=await fetch(`/api/emails/${v}/archive?token=${h}`);if(!p.ok){if(p.status===404){r(null),s(!1);return}throw new Error(`Failed to fetch archived email: ${p.statusText}`)}const g=await p.json();r({...g,timestamp:new Date(g.timestamp)})}catch(h){const v=h instanceof Error?h.message:"Unknown error";f(v),console.error("Error fetching archived email:",h)}finally{s(!1)}}d()},[e,t]),t?i?c.jsxs(Ne,{children:[c.jsxs(De,{children:[c.jsx(Fe,{children:"Email Archive"}),c.jsx(Ye,{children:"Loading archived email content..."})]}),c.jsx(Le,{className:"space-y-4",children:c.jsx(Re,{className:"h-[400px] w-full"})})]}):l?c.jsxs(Ne,{children:[c.jsxs(De,{children:[c.jsx(Fe,{children:"Email Archive"}),c.jsx(Ye,{children:"Failed to load archived email"})]}),c.jsx(Le,{children:c.jsx(In,{variant:"destructive",children:c.jsx(zn,{children:l})})})]}):n?c.jsxs(Ne,{children:[c.jsx(De,{children:c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{children:[c.jsx(Fe,{children:"Email Archive"}),c.jsx(Ye,{children:"Full email content stored in AWS SES Mail Manager"})]}),n.attachments.length>0&&c.jsxs(He,{variant:"secondary",children:[n.attachments.length," attachment",n.attachments.length>1?"s":""]})]})}),c.jsxs(Le,{children:[c.jsxs($I,{className:"w-full",defaultValue:"rendered",children:[c.jsxs(LI,{className:"grid w-full grid-cols-3",children:[c.jsxs(_u,{className:"gap-2",value:"rendered",children:[c.jsx(ku,{className:"h-4 w-4"}),"Rendered Email"]}),c.jsxs(_u,{className:"gap-2",value:"text",children:[c.jsx(IH,{className:"h-4 w-4"}),"Plain Text"]}),c.jsxs(_u,{className:"gap-2",value:"html",children:[c.jsx(kH,{className:"h-4 w-4"}),"HTML Source"]})]}),c.jsxs(Au,{className:"space-y-4",value:"rendered",children:[n.html?c.jsx("div",{className:"rounded-md border",children:c.jsx("iframe",{className:"h-[600px] w-full rounded-md",sandbox:"allow-same-origin",srcDoc:n.html,title:"Email preview"})}):c.jsx(In,{children:c.jsx(zn,{children:"No HTML content available for this email. View the plain text tab instead."})}),n.attachments.length>0&&c.jsxs("div",{className:"space-y-2",children:[c.jsx("div",{className:"font-medium text-sm",children:"Attachments"}),c.jsx("div",{className:"space-y-2",children:n.attachments.map((d,h)=>c.jsx("div",{className:"flex items-center justify-between rounded-md border p-3",children:c.jsxs("div",{className:"space-y-1",children:[c.jsx("div",{className:"font-mono text-sm",children:d.filename||`Attachment ${h+1}`}),c.jsxs("div",{className:"text-muted-foreground text-xs",children:[d.contentType," •"," ",(d.size/1024).toFixed(2)," KB"]})]})},d.filename||`attachment-${h}`))})]})]}),c.jsx(Au,{className:"space-y-4",value:"text",children:n.text?c.jsx("div",{className:"rounded-md border bg-muted p-4",children:c.jsx("pre",{className:"whitespace-pre-wrap font-mono text-sm",children:n.text})}):c.jsx(In,{children:c.jsx(zn,{children:"No plain text content available for this email."})})}),c.jsx(Au,{className:"space-y-4",value:"html",children:n.html?c.jsx("div",{className:"rounded-md border bg-muted p-4",children:c.jsx("pre",{className:"overflow-x-auto whitespace-pre-wrap font-mono text-xs",children:n.html})}):c.jsx(In,{children:c.jsx(zn,{children:"No HTML content available for this email."})})})]}),n.metadata&&c.jsxs("div",{className:"mt-6 space-y-3 rounded-md border p-4",children:[c.jsx("div",{className:"font-medium text-sm",children:"SMTP Metadata"}),c.jsxs("div",{className:"grid gap-3 md:grid-cols-2",children:[n.metadata.senderIp&&c.jsxs("div",{className:"space-y-1",children:[c.jsx("div",{className:"text-muted-foreground text-xs",children:"Sender IP"}),c.jsx("div",{className:"font-mono text-sm",children:n.metadata.senderIp})]}),n.metadata.tlsProtocol&&c.jsxs("div",{className:"space-y-1",children:[c.jsx("div",{className:"text-muted-foreground text-xs",children:"TLS Protocol"}),c.jsx("div",{className:"font-mono text-sm",children:n.metadata.tlsProtocol})]}),n.metadata.senderHostname&&c.jsxs("div",{className:"space-y-1",children:[c.jsx("div",{className:"text-muted-foreground text-xs",children:"Sender Hostname"}),c.jsx("div",{className:"font-mono text-sm",children:n.metadata.senderHostname})]})]})]})]})]}):c.jsxs(Ne,{children:[c.jsxs(De,{children:[c.jsx(Fe,{children:"Email Archive"}),c.jsx(Ye,{children:"Email content not available"})]}),c.jsx(Le,{children:c.jsx(In,{children:c.jsx(zn,{children:"This email was not archived. It may have been sent before email archiving was enabled for this deployment."})})})]}):c.jsxs(Ne,{children:[c.jsxs(De,{children:[c.jsx(Fe,{children:"Email Archive"}),c.jsx(Ye,{children:"Enable email archiving to view full email content"})]}),c.jsx(Le,{children:c.jsx(In,{children:c.jsxs(zn,{children:["Email archiving is not enabled for this deployment. Run"," ",c.jsx("code",{className:"rounded bg-muted px-1.5 py-0.5 font-mono text-xs",children:"wraps upgrade"})," ","to enable archiving and view full email content with HTML rendering."]})})})]})}const $W={sent:dl,delivered:Vi,bounced:rr,complained:rr,opened:dl,clicked:dl,failed:rr},LW={sent:"text-blue-500",delivered:"text-green-500",bounced:"text-red-500",complained:"text-red-500",opened:"text-purple-500",clicked:"text-indigo-500",failed:"text-red-500"},IW={delivered:"default",sent:"secondary",bounced:"destructive",complained:"destructive",failed:"destructive",opened:"default",clicked:"default"};function zW(){const{id:e}=P4(),t=Zo(),[n,r]=j.useState(null),[i,s]=j.useState(!0),[l,f]=j.useState(null),[d,h]=j.useState(!1);j.useEffect(()=>{async function g(){var b,O,S;try{s(!0),f(null);const x=sessionStorage.getItem("wraps-auth-token");if(!x)throw new Error("Authentication token not found");try{const N=await fetch(`/api/settings/deployment?token=${x}`);if(N.ok){const M=await N.json();h(M.archivingEnabled??!1)}}catch(N){console.warn("Failed to fetch deployment config:",N)}const E=encodeURIComponent(e||"");console.log("Fetching email with ID:",e),console.log("Encoded ID:",E),console.log("Full URL:",`/api/emails/${E}?token=${x.substring(0,8)}...`);const A=await fetch(`/api/emails/${E}?token=${x}`);if(!A.ok){let N="Failed to fetch email details";try{N=(await A.json()).error||N}catch{N=`${A.status}: ${A.statusText}`}throw new Error(N)}const _=A.headers.get("content-type");if(!(_!=null&&_.includes("application/json"))){const N=await A.text();throw console.error("Non-JSON response:",N),new Error("Server returned non-JSON response")}const T=await A.json();console.log("Email data received:",{id:T.id,hasHtmlBody:!!T.htmlBody,hasTextBody:!!T.textBody,htmlBodyLength:((b=T.htmlBody)==null?void 0:b.length)||0,textBodyLength:((O=T.textBody)==null?void 0:O.length)||0,events:((S=T.events)==null?void 0:S.length)||0}),r(T)}catch(x){const E=x instanceof Error?x.message:"Unknown error";f(E),console.error("Error fetching email details:",x)}finally{s(!1)}}e&&g()},[e]);const v=g=>new Date(g).toLocaleString("en-US",{month:"short",day:"numeric",hour:"numeric",minute:"2-digit",hour12:!0}),p=g=>new Date(g).toLocaleString("en-US",{weekday:"short",month:"short",day:"numeric",year:"numeric",hour:"numeric",minute:"2-digit",second:"2-digit",hour12:!0});return i?c.jsx("div",{className:"flex h-[600px] items-center justify-center",children:c.jsx("div",{className:"text-muted-foreground",children:"Loading email details..."})}):l?c.jsxs("div",{className:"space-y-4",children:[c.jsxs(Ee,{onClick:()=>t("/email"),size:"sm",variant:"ghost",children:[c.jsx(fl,{className:"mr-2 h-4 w-4"}),"Back to emails"]}),c.jsx("div",{className:"rounded-md border border-destructive bg-destructive/10 p-4 text-destructive text-sm",children:l})]}):n?c.jsxs("div",{className:"space-y-6",children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs(Ee,{onClick:()=>t("/email"),size:"sm",variant:"ghost",children:[c.jsx(fl,{className:"mr-2 h-4 w-4"}),"Back to emails"]}),c.jsx(He,{variant:IW[n.status],children:n.status.charAt(0).toUpperCase()+n.status.slice(1)})]}),c.jsxs(Ne,{children:[c.jsx(De,{children:c.jsx("div",{className:"flex items-start justify-between",children:c.jsxs("div",{className:"space-y-1.5",children:[c.jsx(Fe,{className:"text-2xl",children:n.subject}),c.jsx(Ye,{className:"font-mono text-xs",children:n.messageId})]})})}),c.jsx(Le,{className:"space-y-4",children:c.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[c.jsxs("div",{className:"space-y-1",children:[c.jsx("div",{className:"text-muted-foreground text-sm",children:"FROM"}),c.jsx("div",{className:"font-mono text-sm",children:n.from})]}),c.jsxs("div",{className:"space-y-1",children:[c.jsx("div",{className:"text-muted-foreground text-sm",children:"TO"}),c.jsx("div",{className:"font-mono text-sm",children:n.to.length>0?n.to.join(", "):"(no recipients)"})]}),n.replyTo&&c.jsxs("div",{className:"space-y-1",children:[c.jsx("div",{className:"text-muted-foreground text-sm",children:"REPLY-TO"}),c.jsx("div",{className:"font-mono text-sm",children:n.replyTo})]}),c.jsxs("div",{className:"space-y-1",children:[c.jsx("div",{className:"text-muted-foreground text-sm",children:"ID"}),c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("code",{className:"rounded bg-muted px-2 py-1 font-mono text-xs",children:n.id}),c.jsxs(Ee,{className:"h-6 w-6",onClick:()=>navigator.clipboard.writeText(n.id),size:"icon",variant:"ghost",children:[c.jsx("span",{className:"sr-only",children:"Copy ID"}),"📋"]})]})]})]})})]}),d&&c.jsx(kW,{archivingEnabled:d,messageId:n.messageId}),c.jsxs(Ne,{children:[c.jsxs(De,{children:[c.jsx(Fe,{children:"Email Events"}),c.jsx(Ye,{children:"Lifecycle of this email from send to delivery"})]}),c.jsx(Le,{children:c.jsx("div",{className:"space-y-4",children:n.events.length===0?c.jsx("div",{className:"text-muted-foreground text-sm",children:"No events recorded yet"}):n.events.map((g,b)=>{const O=$W[g.type]||Uo,S=b===n.events.length-1;return c.jsx("div",{children:c.jsxs("div",{className:"flex gap-4",children:[c.jsxs("div",{className:"flex flex-col items-center",children:[c.jsx("div",{className:`rounded-full border-2 border-background bg-muted p-2 ${LW[g.type]}`,children:c.jsx(O,{className:"h-4 w-4"})}),!S&&c.jsx("div",{className:"my-1 w-px flex-1 bg-border"})]}),c.jsxs("div",{className:"flex-1 pb-6",children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx("div",{className:"font-medium capitalize",children:g.type}),c.jsx("div",{className:"text-muted-foreground text-sm",children:v(g.timestamp)})]}),c.jsx("div",{className:"text-muted-foreground text-sm",children:p(g.timestamp)}),g.metadata&&Object.keys(g.metadata).length>0&&c.jsx("div",{className:"mt-2 rounded-md border bg-muted/50 p-2 font-mono text-xs",children:c.jsx("pre",{className:"overflow-x-auto",children:JSON.stringify(g.metadata,null,2)})})]})]})},`${g.type}-${g.timestamp}`)})})})]})]}):c.jsxs("div",{className:"space-y-4",children:[c.jsxs(Ee,{onClick:()=>t("/email"),size:"sm",variant:"ghost",children:[c.jsx(fl,{className:"mr-2 h-4 w-4"}),"Back to emails"]}),c.jsx("div",{className:"rounded-md border p-4 text-muted-foreground text-sm",children:"Email not found"})]})}function lm(e,[t,n]){return Math.min(n,Math.max(t,e))}function Vp(e){const t=j.useRef({value:e,previous:e});return j.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}var BW=[" ","Enter","ArrowUp","ArrowDown"],qW=[" ","Enter"],Go="Select",[Yp,Wp,UW]=Op(Go),[nc]=qn(Go,[UW,Jl]),Kp=Jl(),[HW,Ji]=nc(Go),[FW,GW]=nc(Go),II=e=>{const{__scopeSelect:t,children:n,open:r,defaultOpen:i,onOpenChange:s,value:l,defaultValue:f,onValueChange:d,dir:h,name:v,autoComplete:p,disabled:g,required:b,form:O}=e,S=Kp(t),[x,E]=j.useState(null),[A,_]=j.useState(null),[T,N]=j.useState(!1),M=Df(h),[R,D]=Vr({prop:r,defaultProp:i??!1,onChange:s,caller:Go}),[L,Y]=Vr({prop:l,defaultProp:f,onChange:d,caller:Go}),I=j.useRef(null),H=x?O||!!x.closest("form"):!0,[W,Z]=j.useState(new Set),X=Array.from(W).map(k=>k.props.value).join(";");return c.jsx(Bj,{...S,children:c.jsxs(HW,{required:b,scope:t,trigger:x,onTriggerChange:E,valueNode:A,onValueNodeChange:_,valueNodeHasChildren:T,onValueNodeHasChildrenChange:N,contentId:_r(),value:L,onValueChange:Y,open:R,onOpenChange:D,dir:M,triggerPointerDownPosRef:I,disabled:g,children:[c.jsx(Yp.Provider,{scope:t,children:c.jsx(FW,{scope:e.__scopeSelect,onNativeOptionAdd:j.useCallback(k=>{Z(U=>new Set(U).add(k))},[]),onNativeOptionRemove:j.useCallback(k=>{Z(U=>{const q=new Set(U);return q.delete(k),q})},[]),children:n})}),H?c.jsxs(o3,{"aria-hidden":!0,required:b,tabIndex:-1,name:v,autoComplete:p,value:L,onChange:k=>Y(k.target.value),disabled:g,form:O,children:[L===void 0?c.jsx("option",{value:""}):null,Array.from(W)]},X):null]})})};II.displayName=Go;var zI="SelectTrigger",BI=j.forwardRef((e,t)=>{const{__scopeSelect:n,disabled:r=!1,...i}=e,s=Kp(n),l=Ji(zI,n),f=l.disabled||r,d=Be(t,l.onTriggerChange),h=Wp(n),v=j.useRef("touch"),[p,g,b]=l3(S=>{const x=h().filter(_=>!_.disabled),E=x.find(_=>_.value===l.value),A=c3(x,S,E);A!==void 0&&l.onValueChange(A.value)}),O=S=>{f||(l.onOpenChange(!0),b()),S&&(l.triggerPointerDownPosRef.current={x:Math.round(S.pageX),y:Math.round(S.pageY)})};return c.jsx(qj,{asChild:!0,...s,children:c.jsx(Ce.button,{type:"button",role:"combobox","aria-controls":l.contentId,"aria-expanded":l.open,"aria-required":l.required,"aria-autocomplete":"none",dir:l.dir,"data-state":l.open?"open":"closed",disabled:f,"data-disabled":f?"":void 0,"data-placeholder":s3(l.value)?"":void 0,...i,ref:d,onClick:be(i.onClick,S=>{S.currentTarget.focus(),v.current!=="mouse"&&O(S)}),onPointerDown:be(i.onPointerDown,S=>{v.current=S.pointerType;const x=S.target;x.hasPointerCapture(S.pointerId)&&x.releasePointerCapture(S.pointerId),S.button===0&&S.ctrlKey===!1&&S.pointerType==="mouse"&&(O(S),S.preventDefault())}),onKeyDown:be(i.onKeyDown,S=>{const x=p.current!=="";!(S.ctrlKey||S.altKey||S.metaKey)&&S.key.length===1&&g(S.key),!(x&&S.key===" ")&&BW.includes(S.key)&&(O(),S.preventDefault())})})})});BI.displayName=zI;var qI="SelectValue",UI=j.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:i,children:s,placeholder:l="",...f}=e,d=Ji(qI,n),{onValueNodeHasChildrenChange:h}=d,v=s!==void 0,p=Be(t,d.onValueNodeChange);return Yt(()=>{h(v)},[h,v]),c.jsx(Ce.span,{...f,ref:p,style:{pointerEvents:"none"},children:s3(d.value)?c.jsx(c.Fragment,{children:l}):s})});UI.displayName=qI;var VW="SelectIcon",HI=j.forwardRef((e,t)=>{const{__scopeSelect:n,children:r,...i}=e;return c.jsx(Ce.span,{"aria-hidden":!0,...i,ref:t,children:r||"▼"})});HI.displayName=VW;var YW="SelectPortal",FI=e=>c.jsx($f,{asChild:!0,...e});FI.displayName=YW;var Vo="SelectContent",GI=j.forwardRef((e,t)=>{const n=Ji(Vo,e.__scopeSelect),[r,i]=j.useState();if(Yt(()=>{i(new DocumentFragment)},[]),!n.open){const s=r;return s?Af.createPortal(c.jsx(VI,{scope:e.__scopeSelect,children:c.jsx(Yp.Slot,{scope:e.__scopeSelect,children:c.jsx("div",{children:e.children})})}),s):null}return c.jsx(YI,{...e,ref:t})});GI.displayName=Vo;var zr=10,[VI,eo]=nc(Vo),WW="SelectContentImpl",KW=xl("SelectContent.RemoveScroll"),YI=j.forwardRef((e,t)=>{const{__scopeSelect:n,position:r="item-aligned",onCloseAutoFocus:i,onEscapeKeyDown:s,onPointerDownOutside:l,side:f,sideOffset:d,align:h,alignOffset:v,arrowPadding:p,collisionBoundary:g,collisionPadding:b,sticky:O,hideWhenDetached:S,avoidCollisions:x,...E}=e,A=Ji(Vo,n),[_,T]=j.useState(null),[N,M]=j.useState(null),R=Be(t,oe=>T(oe)),[D,L]=j.useState(null),[Y,I]=j.useState(null),H=Wp(n),[W,Z]=j.useState(!1),X=j.useRef(!1);j.useEffect(()=>{if(_)return Fj(_)},[_]),Mj();const k=j.useCallback(oe=>{const[me,...ae]=H().map(ie=>ie.ref.current),[pe]=ae.slice(-1),ge=document.activeElement;for(const ie of oe)if(ie===ge||(ie==null||ie.scrollIntoView({block:"nearest"}),ie===me&&N&&(N.scrollTop=0),ie===pe&&N&&(N.scrollTop=N.scrollHeight),ie==null||ie.focus(),document.activeElement!==ge))return},[H,N]),U=j.useCallback(()=>k([D,_]),[k,D,_]);j.useEffect(()=>{W&&U()},[W,U]);const{onOpenChange:q,triggerPointerDownPosRef:Q}=A;j.useEffect(()=>{if(_){let oe={x:0,y:0};const me=pe=>{var ge,ie;oe={x:Math.abs(Math.round(pe.pageX)-(((ge=Q.current)==null?void 0:ge.x)??0)),y:Math.abs(Math.round(pe.pageY)-(((ie=Q.current)==null?void 0:ie.y)??0))}},ae=pe=>{oe.x<=10&&oe.y<=10?pe.preventDefault():_.contains(pe.target)||q(!1),document.removeEventListener("pointermove",me),Q.current=null};return Q.current!==null&&(document.addEventListener("pointermove",me),document.addEventListener("pointerup",ae,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",me),document.removeEventListener("pointerup",ae,{capture:!0})}}},[_,q,Q]),j.useEffect(()=>{const oe=()=>q(!1);return window.addEventListener("blur",oe),window.addEventListener("resize",oe),()=>{window.removeEventListener("blur",oe),window.removeEventListener("resize",oe)}},[q]);const[le,$]=l3(oe=>{const me=H().filter(ge=>!ge.disabled),ae=me.find(ge=>ge.ref.current===document.activeElement),pe=c3(me,oe,ae);pe&&setTimeout(()=>pe.ref.current.focus())}),B=j.useCallback((oe,me,ae)=>{const pe=!X.current&&!ae;(A.value!==void 0&&A.value===me||pe)&&(L(oe),pe&&(X.current=!0))},[A.value]),V=j.useCallback(()=>_==null?void 0:_.focus(),[_]),F=j.useCallback((oe,me,ae)=>{const pe=!X.current&&!ae;(A.value!==void 0&&A.value===me||pe)&&I(oe)},[A.value]),ne=r==="popper"?q1:WI,fe=ne===q1?{side:f,sideOffset:d,align:h,alignOffset:v,arrowPadding:p,collisionBoundary:g,collisionPadding:b,sticky:O,hideWhenDetached:S,avoidCollisions:x}:{};return c.jsx(VI,{scope:n,content:_,viewport:N,onViewportChange:M,itemRefCallback:B,selectedItem:D,onItemLeave:V,itemTextRefCallback:F,focusSelectedItem:U,selectedItemText:Y,position:r,isPositioned:W,searchRef:le,children:c.jsx(Dp,{as:KW,allowPinchZoom:!0,children:c.jsx(Ep,{asChild:!0,trapped:A.open,onMountAutoFocus:oe=>{oe.preventDefault()},onUnmountAutoFocus:be(i,oe=>{var me;(me=A.trigger)==null||me.focus({preventScroll:!0}),oe.preventDefault()}),children:c.jsx(Pf,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:s,onPointerDownOutside:l,onFocusOutside:oe=>oe.preventDefault(),onDismiss:()=>A.onOpenChange(!1),children:c.jsx(ne,{role:"listbox",id:A.contentId,"data-state":A.open?"open":"closed",dir:A.dir,onContextMenu:oe=>oe.preventDefault(),...E,...fe,onPlaced:()=>Z(!0),ref:R,style:{display:"flex",flexDirection:"column",outline:"none",...E.style},onKeyDown:be(E.onKeyDown,oe=>{const me=oe.ctrlKey||oe.altKey||oe.metaKey;if(oe.key==="Tab"&&oe.preventDefault(),!me&&oe.key.length===1&&$(oe.key),["ArrowUp","ArrowDown","Home","End"].includes(oe.key)){let pe=H().filter(ge=>!ge.disabled).map(ge=>ge.ref.current);if(["ArrowUp","End"].includes(oe.key)&&(pe=pe.slice().reverse()),["ArrowUp","ArrowDown"].includes(oe.key)){const ge=oe.target,ie=pe.indexOf(ge);pe=pe.slice(ie+1)}setTimeout(()=>k(pe)),oe.preventDefault()}})})})})})})});YI.displayName=WW;var XW="SelectItemAlignedPosition",WI=j.forwardRef((e,t)=>{const{__scopeSelect:n,onPlaced:r,...i}=e,s=Ji(Vo,n),l=eo(Vo,n),[f,d]=j.useState(null),[h,v]=j.useState(null),p=Be(t,R=>v(R)),g=Wp(n),b=j.useRef(!1),O=j.useRef(!0),{viewport:S,selectedItem:x,selectedItemText:E,focusSelectedItem:A}=l,_=j.useCallback(()=>{if(s.trigger&&s.valueNode&&f&&h&&S&&x&&E){const R=s.trigger.getBoundingClientRect(),D=h.getBoundingClientRect(),L=s.valueNode.getBoundingClientRect(),Y=E.getBoundingClientRect();if(s.dir!=="rtl"){const ge=Y.left-D.left,ie=L.left-ge,Pe=R.left-ie,xe=R.width+Pe,Je=Math.max(xe,D.width),rt=window.innerWidth-zr,lt=lm(ie,[zr,Math.max(zr,rt-Je)]);f.style.minWidth=xe+"px",f.style.left=lt+"px"}else{const ge=D.right-Y.right,ie=window.innerWidth-L.right-ge,Pe=window.innerWidth-R.right-ie,xe=R.width+Pe,Je=Math.max(xe,D.width),rt=window.innerWidth-zr,lt=lm(ie,[zr,Math.max(zr,rt-Je)]);f.style.minWidth=xe+"px",f.style.right=lt+"px"}const I=g(),H=window.innerHeight-zr*2,W=S.scrollHeight,Z=window.getComputedStyle(h),X=parseInt(Z.borderTopWidth,10),k=parseInt(Z.paddingTop,10),U=parseInt(Z.borderBottomWidth,10),q=parseInt(Z.paddingBottom,10),Q=X+k+W+q+U,le=Math.min(x.offsetHeight*5,Q),$=window.getComputedStyle(S),B=parseInt($.paddingTop,10),V=parseInt($.paddingBottom,10),F=R.top+R.height/2-zr,ne=H-F,fe=x.offsetHeight/2,oe=x.offsetTop+fe,me=X+k+oe,ae=Q-me;if(me<=F){const ge=I.length>0&&x===I[I.length-1].ref.current;f.style.bottom="0px";const ie=h.clientHeight-S.offsetTop-S.offsetHeight,Pe=Math.max(ne,fe+(ge?V:0)+ie+U),xe=me+Pe;f.style.height=xe+"px"}else{const ge=I.length>0&&x===I[0].ref.current;f.style.top="0px";const Pe=Math.max(F,X+S.offsetTop+(ge?B:0)+fe)+ae;f.style.height=Pe+"px",S.scrollTop=me-F+S.offsetTop}f.style.margin=`${zr}px 0`,f.style.minHeight=le+"px",f.style.maxHeight=H+"px",r==null||r(),requestAnimationFrame(()=>b.current=!0)}},[g,s.trigger,s.valueNode,f,h,S,x,E,s.dir,r]);Yt(()=>_(),[_]);const[T,N]=j.useState();Yt(()=>{h&&N(window.getComputedStyle(h).zIndex)},[h]);const M=j.useCallback(R=>{R&&O.current===!0&&(_(),A==null||A(),O.current=!1)},[_,A]);return c.jsx(ZW,{scope:n,contentWrapper:f,shouldExpandOnScrollRef:b,onScrollButtonChange:M,children:c.jsx("div",{ref:d,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:T},children:c.jsx(Ce.div,{...i,ref:p,style:{boxSizing:"border-box",maxHeight:"100%",...i.style}})})})});WI.displayName=XW;var QW="SelectPopperPosition",q1=j.forwardRef((e,t)=>{const{__scopeSelect:n,align:r="start",collisionPadding:i=zr,...s}=e,l=Kp(n);return c.jsx(Uj,{...l,...s,ref:t,align:r,collisionPadding:i,style:{boxSizing:"border-box",...s.style,"--radix-select-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-select-content-available-width":"var(--radix-popper-available-width)","--radix-select-content-available-height":"var(--radix-popper-available-height)","--radix-select-trigger-width":"var(--radix-popper-anchor-width)","--radix-select-trigger-height":"var(--radix-popper-anchor-height)"}})});q1.displayName=QW;var[ZW,fO]=nc(Vo,{}),U1="SelectViewport",KI=j.forwardRef((e,t)=>{const{__scopeSelect:n,nonce:r,...i}=e,s=eo(U1,n),l=fO(U1,n),f=Be(t,s.onViewportChange),d=j.useRef(0);return c.jsxs(c.Fragment,{children:[c.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"},nonce:r}),c.jsx(Yp.Slot,{scope:n,children:c.jsx(Ce.div,{"data-radix-select-viewport":"",role:"presentation",...i,ref:f,style:{position:"relative",flex:1,overflow:"hidden auto",...i.style},onScroll:be(i.onScroll,h=>{const v=h.currentTarget,{contentWrapper:p,shouldExpandOnScrollRef:g}=l;if(g!=null&&g.current&&p){const b=Math.abs(d.current-v.scrollTop);if(b>0){const O=window.innerHeight-zr*2,S=parseFloat(p.style.minHeight),x=parseFloat(p.style.height),E=Math.max(S,x);if(E<O){const A=E+b,_=Math.min(O,A),T=A-_;p.style.height=_+"px",p.style.bottom==="0px"&&(v.scrollTop=T>0?T:0,p.style.justifyContent="flex-end")}}}d.current=v.scrollTop})})})]})});KI.displayName=U1;var XI="SelectGroup",[JW,eK]=nc(XI),tK=j.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,i=_r();return c.jsx(JW,{scope:n,id:i,children:c.jsx(Ce.div,{role:"group","aria-labelledby":i,...r,ref:t})})});tK.displayName=XI;var QI="SelectLabel",nK=j.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,i=eK(QI,n);return c.jsx(Ce.div,{id:i.id,...r,ref:t})});nK.displayName=QI;var cm="SelectItem",[rK,ZI]=nc(cm),JI=j.forwardRef((e,t)=>{const{__scopeSelect:n,value:r,disabled:i=!1,textValue:s,...l}=e,f=Ji(cm,n),d=eo(cm,n),h=f.value===r,[v,p]=j.useState(s??""),[g,b]=j.useState(!1),O=Be(t,A=>{var _;return(_=d.itemRefCallback)==null?void 0:_.call(d,A,r,i)}),S=_r(),x=j.useRef("touch"),E=()=>{i||(f.onValueChange(r),f.onOpenChange(!1))};if(r==="")throw new Error("A <Select.Item /> must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder.");return c.jsx(rK,{scope:n,value:r,disabled:i,textId:S,isSelected:h,onItemTextChange:j.useCallback(A=>{p(_=>_||((A==null?void 0:A.textContent)??"").trim())},[]),children:c.jsx(Yp.ItemSlot,{scope:n,value:r,disabled:i,textValue:v,children:c.jsx(Ce.div,{role:"option","aria-labelledby":S,"data-highlighted":g?"":void 0,"aria-selected":h&&g,"data-state":h?"checked":"unchecked","aria-disabled":i||void 0,"data-disabled":i?"":void 0,tabIndex:i?void 0:-1,...l,ref:O,onFocus:be(l.onFocus,()=>b(!0)),onBlur:be(l.onBlur,()=>b(!1)),onClick:be(l.onClick,()=>{x.current!=="mouse"&&E()}),onPointerUp:be(l.onPointerUp,()=>{x.current==="mouse"&&E()}),onPointerDown:be(l.onPointerDown,A=>{x.current=A.pointerType}),onPointerMove:be(l.onPointerMove,A=>{var _;x.current=A.pointerType,i?(_=d.onItemLeave)==null||_.call(d):x.current==="mouse"&&A.currentTarget.focus({preventScroll:!0})}),onPointerLeave:be(l.onPointerLeave,A=>{var _;A.currentTarget===document.activeElement&&((_=d.onItemLeave)==null||_.call(d))}),onKeyDown:be(l.onKeyDown,A=>{var T;((T=d.searchRef)==null?void 0:T.current)!==""&&A.key===" "||(qW.includes(A.key)&&E(),A.key===" "&&A.preventDefault())})})})})});JI.displayName=cm;var Su="SelectItemText",e3=j.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:i,...s}=e,l=Ji(Su,n),f=eo(Su,n),d=ZI(Su,n),h=GW(Su,n),[v,p]=j.useState(null),g=Be(t,E=>p(E),d.onItemTextChange,E=>{var A;return(A=f.itemTextRefCallback)==null?void 0:A.call(f,E,d.value,d.disabled)}),b=v==null?void 0:v.textContent,O=j.useMemo(()=>c.jsx("option",{value:d.value,disabled:d.disabled,children:b},d.value),[d.disabled,d.value,b]),{onNativeOptionAdd:S,onNativeOptionRemove:x}=h;return Yt(()=>(S(O),()=>x(O)),[S,x,O]),c.jsxs(c.Fragment,{children:[c.jsx(Ce.span,{id:d.textId,...s,ref:g}),d.isSelected&&l.valueNode&&!l.valueNodeHasChildren?Af.createPortal(s.children,l.valueNode):null]})});e3.displayName=Su;var t3="SelectItemIndicator",n3=j.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return ZI(t3,n).isSelected?c.jsx(Ce.span,{"aria-hidden":!0,...r,ref:t}):null});n3.displayName=t3;var H1="SelectScrollUpButton",r3=j.forwardRef((e,t)=>{const n=eo(H1,e.__scopeSelect),r=fO(H1,e.__scopeSelect),[i,s]=j.useState(!1),l=Be(t,r.onScrollButtonChange);return Yt(()=>{if(n.viewport&&n.isPositioned){let f=function(){const h=d.scrollTop>0;s(h)};const d=n.viewport;return f(),d.addEventListener("scroll",f),()=>d.removeEventListener("scroll",f)}},[n.viewport,n.isPositioned]),i?c.jsx(i3,{...e,ref:l,onAutoScroll:()=>{const{viewport:f,selectedItem:d}=n;f&&d&&(f.scrollTop=f.scrollTop-d.offsetHeight)}}):null});r3.displayName=H1;var F1="SelectScrollDownButton",a3=j.forwardRef((e,t)=>{const n=eo(F1,e.__scopeSelect),r=fO(F1,e.__scopeSelect),[i,s]=j.useState(!1),l=Be(t,r.onScrollButtonChange);return Yt(()=>{if(n.viewport&&n.isPositioned){let f=function(){const h=d.scrollHeight-d.clientHeight,v=Math.ceil(d.scrollTop)<h;s(v)};const d=n.viewport;return f(),d.addEventListener("scroll",f),()=>d.removeEventListener("scroll",f)}},[n.viewport,n.isPositioned]),i?c.jsx(i3,{...e,ref:l,onAutoScroll:()=>{const{viewport:f,selectedItem:d}=n;f&&d&&(f.scrollTop=f.scrollTop+d.offsetHeight)}}):null});a3.displayName=F1;var i3=j.forwardRef((e,t)=>{const{__scopeSelect:n,onAutoScroll:r,...i}=e,s=eo("SelectScrollButton",n),l=j.useRef(null),f=Wp(n),d=j.useCallback(()=>{l.current!==null&&(window.clearInterval(l.current),l.current=null)},[]);return j.useEffect(()=>()=>d(),[d]),Yt(()=>{var v;const h=f().find(p=>p.ref.current===document.activeElement);(v=h==null?void 0:h.ref.current)==null||v.scrollIntoView({block:"nearest"})},[f]),c.jsx(Ce.div,{"aria-hidden":!0,...i,ref:t,style:{flexShrink:0,...i.style},onPointerDown:be(i.onPointerDown,()=>{l.current===null&&(l.current=window.setInterval(r,50))}),onPointerMove:be(i.onPointerMove,()=>{var h;(h=s.onItemLeave)==null||h.call(s),l.current===null&&(l.current=window.setInterval(r,50))}),onPointerLeave:be(i.onPointerLeave,()=>{d()})})}),aK="SelectSeparator",iK=j.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return c.jsx(Ce.div,{"aria-hidden":!0,...r,ref:t})});iK.displayName=aK;var G1="SelectArrow",oK=j.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,i=Kp(n),s=Ji(G1,n),l=eo(G1,n);return s.open&&l.position==="popper"?c.jsx(Hj,{...i,...r,ref:t}):null});oK.displayName=G1;var sK="SelectBubbleInput",o3=j.forwardRef(({__scopeSelect:e,value:t,...n},r)=>{const i=j.useRef(null),s=Be(r,i),l=Vp(t);return j.useEffect(()=>{const f=i.current;if(!f)return;const d=window.HTMLSelectElement.prototype,v=Object.getOwnPropertyDescriptor(d,"value").set;if(l!==t&&v){const p=new Event("change",{bubbles:!0});v.call(f,t),f.dispatchEvent(p)}},[l,t]),c.jsx(Ce.select,{...n,style:{...oI,...n.style},ref:s,defaultValue:t})});o3.displayName=sK;function s3(e){return e===""||e===void 0}function l3(e){const t=Gr(e),n=j.useRef(""),r=j.useRef(0),i=j.useCallback(l=>{const f=n.current+l;t(f),(function d(h){n.current=h,window.clearTimeout(r.current),h!==""&&(r.current=window.setTimeout(()=>d(""),1e3))})(f)},[t]),s=j.useCallback(()=>{n.current="",window.clearTimeout(r.current)},[]);return j.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,i,s]}function c3(e,t,n){const i=t.length>1&&Array.from(t).every(h=>h===t[0])?t[0]:t,s=n?e.indexOf(n):-1;let l=lK(e,Math.max(s,0));i.length===1&&(l=l.filter(h=>h!==n));const d=l.find(h=>h.textValue.toLowerCase().startsWith(i.toLowerCase()));return d!==n?d:void 0}function lK(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var cK=II,uK=BI,fK=UI,dK=HI,hK=FI,mK=GI,pK=KI,vK=JI,gK=e3,yK=n3,bK=r3,xK=a3;function fa({...e}){return c.jsx(cK,{"data-slot":"select",...e})}function da({...e}){return c.jsx(fK,{"data-slot":"select-value",...e})}function ha({className:e,size:t="default",children:n,...r}){return c.jsxs(uK,{className:ve("flex w-fit items-center justify-between gap-2 whitespace-nowrap rounded-md border border-input bg-transparent px-3 py-2 text-sm shadow-xs outline-none transition-[color,box-shadow] focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 data-[size=default]:h-9 data-[size=sm]:h-8 data-[placeholder]:text-muted-foreground *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-2 dark:bg-input/30 dark:aria-invalid:ring-destructive/40 dark:hover:bg-input/50 [&_svg:not([class*='size-'])]:size-4 [&_svg:not([class*='text-'])]:text-muted-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0",e),"data-size":t,"data-slot":"select-trigger",...r,children:[n,c.jsx(dK,{asChild:!0,children:c.jsx(Jo,{className:"size-4 opacity-50"})})]})}function ma({className:e,children:t,position:n="popper",align:r="center",...i}){return c.jsx(hK,{children:c.jsxs(mK,{align:r,className:ve("data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 relative z-50 max-h-[--radix-select-content-available-height] min-w-[8rem] origin-[--radix-select-content-transform-origin] overflow-y-auto overflow-x-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=closed]:animate-out data-[state=open]:animate-in",n==="popper"&&"data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=bottom]:translate-y-1 data-[side=top]:-translate-y-1",e),"data-slot":"select-content",position:n,...i,children:[c.jsx(wK,{}),c.jsx(pK,{className:ve("p-1",n==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)] scroll-my-1"),children:t}),c.jsx(SK,{})]})})}function Ue({className:e,children:t,...n}){return c.jsxs(vK,{className:ve("relative flex w-full cursor-default select-none items-center gap-2 rounded-sm py-1.5 pr-8 pl-2 text-sm outline-hidden focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg:not([class*='size-'])]:size-4 [&_svg:not([class*='text-'])]:text-muted-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2",e),"data-slot":"select-item",...n,children:[c.jsx("span",{className:"absolute right-2 flex size-3.5 items-center justify-center",children:c.jsx(yK,{children:c.jsx(Vi,{className:"size-4"})})}),c.jsx(gK,{children:t})]})}function wK({className:e,...t}){return c.jsx(bK,{className:ve("flex cursor-default items-center justify-center py-1",e),"data-slot":"select-scroll-up-button",...t,children:c.jsx(Nf,{className:"size-4"})})}function SK({className:e,...t}){return c.jsx(xK,{className:ve("flex cursor-default items-center justify-center py-1",e),"data-slot":"select-scroll-down-button",...t,children:c.jsx(Jo,{className:"size-4"})})}function dO({className:e,...t}){return c.jsx("div",{className:"relative w-full overflow-x-auto","data-slot":"table-container",children:c.jsx("table",{className:ve("w-full caption-bottom text-sm",e),"data-slot":"table",...t})})}function hO({className:e,...t}){return c.jsx("thead",{className:ve("[&_tr]:border-b",e),"data-slot":"table-header",...t})}function mO({className:e,...t}){return c.jsx("tbody",{className:ve("[&_tr:last-child]:border-0",e),"data-slot":"table-body",...t})}function la({className:e,...t}){return c.jsx("tr",{className:ve("border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted",e),"data-slot":"table-row",...t})}function pn({className:e,...t}){return c.jsx("th",{className:ve("h-10 whitespace-nowrap px-2 text-left align-middle font-medium text-foreground [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]",e),"data-slot":"table-head",...t})}function It({className:e,...t}){return c.jsx("td",{className:ve("whitespace-nowrap p-2 align-middle [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]",e),"data-slot":"table-cell",...t})}const bb={clicked:{variant:"default",description:"Recipient clicked a link in the email",className:"bg-purple-500/10 text-purple-700 dark:text-purple-400 hover:bg-purple-500/20 border-purple-500/20"},opened:{variant:"default",description:"Recipient opened the email",className:"bg-blue-500/10 text-blue-700 dark:text-blue-400 hover:bg-blue-500/20 border-blue-500/20"},delivered:{variant:"default",description:"Email was successfully delivered to recipient's mailbox",className:"bg-green-500/10 text-green-700 dark:text-green-400 hover:bg-green-500/20 border-green-500/20"},sent:{variant:"secondary",description:"Email was sent but delivery not yet confirmed",className:"bg-gray-500/10 text-gray-700 dark:text-gray-400 hover:bg-gray-500/20 border-gray-500/20"},bounced:{variant:"default",description:"Email bounced - recipient's mailbox may not exist or be full",className:"bg-orange-500/10 text-orange-700 dark:text-orange-400 hover:bg-orange-500/20 border-orange-500/20"},complained:{variant:"default",description:"Recipient marked this email as spam",className:"bg-red-500/10 text-red-700 dark:text-red-400 hover:bg-red-500/20 border-red-500/20"},failed:{variant:"default",description:"Email failed to send due to an error",className:"bg-red-500/10 text-red-700 dark:text-red-400 hover:bg-red-500/20 border-red-500/20"}};function jK(){const e=Zo(),[t,n]=j.useState(""),[r,i]=j.useState("15"),[s,l]=j.useState("all"),[f,d]=j.useState("sending"),[h,v]=j.useState([]),[p,g]=j.useState(!0),[b,O]=j.useState(null);j.useEffect(()=>{async function E(){try{g(!0),O(null);let A=sessionStorage.getItem("wraps-auth-token");if(A||(A=new URLSearchParams(window.location.search).get("token"),A&&sessionStorage.setItem("wraps-auth-token",A)),!A)throw new Error("Authentication token not found. Please use the URL provided by 'wraps console' command.");const _=Number.parseInt(r,10),T=Date.now()-_*24*60*60*1e3,N=Date.now(),M=await fetch(`/api/emails?startTime=${T}&endTime=${N}&limit=100&token=${A}`);if(!M.ok){let D="Failed to fetch email logs";try{D=(await M.json()).error||D}catch{D=`${M.status}: ${M.statusText}`}throw new Error(D)}const R=await M.json();v(R.logs.map(D=>({id:D.messageId,to:D.to,from:D.from,subject:D.subject,status:D.status,timestamp:D.sentAt,messageId:D.messageId})))}catch(A){const _=A instanceof Error?A.message:"Unknown error";O(_),console.error("Error fetching email logs:",A)}finally{g(!1)}}E()},[r]);const S=h.filter(E=>{if(t){const A=t.toLowerCase(),_=E.to.some(N=>N.toLowerCase().includes(A)),T=E.subject.toLowerCase().includes(A);if(!(_||T))return!1}return!(s!=="all"&&E.status!==s)}),x=E=>{const A=new Date(E),T=Math.floor((new Date().getTime()-A.getTime())/(1e3*60*60*24));return T===0?"Today":T===1?"Yesterday":T<7?`${T} days ago`:A.toLocaleDateString()};return c.jsxs(Ne,{children:[c.jsxs(De,{children:[c.jsx(Fe,{children:"Emails"}),c.jsx(Ye,{children:"View and manage your email sending history"})]}),c.jsx(Le,{children:c.jsxs($I,{onValueChange:d,value:f,children:[c.jsxs(LI,{children:[c.jsx(_u,{value:"sending",children:"Sending"}),c.jsx(_u,{value:"receiving",children:"Receiving"})]}),c.jsxs(Au,{className:"space-y-4",value:"sending",children:[b&&c.jsx("div",{className:"rounded-md border border-destructive bg-destructive/10 p-4 text-destructive text-sm",children:b}),c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsxs("div",{className:"relative flex-1",children:[c.jsx(Aj,{className:"absolute top-2.5 left-2.5 h-4 w-4 text-muted-foreground"}),c.jsx(ec,{className:"pl-8",onChange:E=>n(E.target.value),placeholder:"Search...",value:t})]}),c.jsxs(fa,{onValueChange:i,value:r,children:[c.jsx(ha,{className:"w-[180px]",children:c.jsx(da,{})}),c.jsxs(ma,{children:[c.jsx(Ue,{value:"1",children:"Last 24 hours"}),c.jsx(Ue,{value:"7",children:"Last 7 days"}),c.jsx(Ue,{value:"15",children:"Last 15 days"}),c.jsx(Ue,{value:"30",children:"Last 30 days"}),c.jsx(Ue,{value:"90",children:"Last 90 days"})]})]}),c.jsxs(fa,{onValueChange:l,value:s,children:[c.jsx(ha,{className:"w-[180px]",children:c.jsx(da,{})}),c.jsxs(ma,{children:[c.jsx(Ue,{value:"all",children:"All Statuses"}),c.jsx(Ue,{value:"clicked",children:"Clicked"}),c.jsx(Ue,{value:"opened",children:"Opened"}),c.jsx(Ue,{value:"delivered",children:"Delivered"}),c.jsx(Ue,{value:"sent",children:"Sent"}),c.jsx(Ue,{value:"bounced",children:"Bounced"}),c.jsx(Ue,{value:"complained",children:"Complained"}),c.jsx(Ue,{value:"failed",children:"Failed"})]})]}),c.jsxs(Ee,{size:"icon",variant:"outline",children:[c.jsx("span",{className:"sr-only",children:"Download"}),"↓"]})]}),c.jsx("div",{className:"rounded-md border",children:c.jsxs(dO,{children:[c.jsx(hO,{children:c.jsxs(la,{children:[c.jsx(pn,{children:"To"}),c.jsx(pn,{children:"Status"}),c.jsx(pn,{children:"Subject"}),c.jsx(pn,{children:"Sent"}),c.jsx(pn,{className:"w-[50px]"})]})}),c.jsx(mO,{children:p?c.jsx(la,{children:c.jsx(It,{className:"h-24 text-center text-muted-foreground",colSpan:5,children:"Loading email logs..."})}):S.length===0?c.jsx(la,{children:c.jsx(It,{className:"h-24 text-center text-muted-foreground",colSpan:5,children:"No emails found"})}):S.map(E=>{var A,_,T;return c.jsxs(la,{className:"cursor-pointer hover:bg-muted/50",onClick:()=>e(`/email/${E.id}`),children:[c.jsx(It,{className:"font-mono text-sm",children:E.to.length>0?c.jsxs(c.Fragment,{children:[E.to[0],E.to.length>1&&c.jsxs("span",{className:"ml-1 text-muted-foreground text-xs",children:["+",E.to.length-1," more"]})]}):c.jsx("span",{className:"text-muted-foreground",children:"(no recipients)"})}),c.jsx(It,{children:c.jsxs(Up,{children:[c.jsx(Hp,{asChild:!0,children:c.jsx(He,{className:(A=bb[E.status])==null?void 0:A.className,variant:((_=bb[E.status])==null?void 0:_.variant)??"default",children:E.status.charAt(0).toUpperCase()+E.status.slice(1)})}),c.jsx(Fp,{children:c.jsx("p",{children:((T=bb[E.status])==null?void 0:T.description)??"Unknown status"})})]})}),c.jsx(It,{className:"max-w-[400px] truncate",children:E.subject}),c.jsx(It,{className:"text-muted-foreground",children:x(E.timestamp)}),c.jsx(It,{children:c.jsxs(Ee,{onClick:N=>{N.stopPropagation()},size:"icon",variant:"ghost",children:[c.jsx("span",{className:"sr-only",children:"More options"}),"⋯"]})})]},E.id)})})]})}),S.length>0&&!p&&c.jsx("div",{className:"flex items-center justify-between text-muted-foreground text-sm",children:c.jsxs("div",{children:["Showing ",S.length," of ",h.length," emails"]})})]}),c.jsx(Au,{value:"receiving",children:c.jsx("div",{className:"flex h-[400px] items-center justify-center text-muted-foreground",children:"Receiving emails coming soon"})})]})})]})}const u3=6048e5,OK=864e5,wh=43200,OT=1440,ET=Symbol.for("constructDateFrom");function ei(e,t){return typeof e=="function"?e(t):e&&typeof e=="object"&&ET in e?e[ET](t):e instanceof Date?new e.constructor(t):new Date(t)}function sn(e,t){return ei(t||e,e)}let EK={};function qf(){return EK}function Uu(e,t){var f,d,h,v;const n=qf(),r=(t==null?void 0:t.weekStartsOn)??((d=(f=t==null?void 0:t.locale)==null?void 0:f.options)==null?void 0:d.weekStartsOn)??n.weekStartsOn??((v=(h=n.locale)==null?void 0:h.options)==null?void 0:v.weekStartsOn)??0,i=sn(e,t==null?void 0:t.in),s=i.getDay(),l=(s<r?7:0)+s-r;return i.setDate(i.getDate()-l),i.setHours(0,0,0,0),i}function um(e,t){return Uu(e,{...t,weekStartsOn:1})}function f3(e,t){const n=sn(e,t==null?void 0:t.in),r=n.getFullYear(),i=ei(n,0);i.setFullYear(r+1,0,4),i.setHours(0,0,0,0);const s=um(i),l=ei(n,0);l.setFullYear(r,0,4),l.setHours(0,0,0,0);const f=um(l);return n.getTime()>=s.getTime()?r+1:n.getTime()>=f.getTime()?r:r-1}function fm(e){const t=sn(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 Xp(e,...t){const n=ei.bind(null,e||t.find(r=>typeof r=="object"));return t.map(n)}function _T(e,t){const n=sn(e,t==null?void 0:t.in);return n.setHours(0,0,0,0),n}function _K(e,t,n){const[r,i]=Xp(n==null?void 0:n.in,e,t),s=_T(r),l=_T(i),f=+s-fm(s),d=+l-fm(l);return Math.round((f-d)/OK)}function AK(e,t){const n=f3(e,t),r=ei(e,0);return r.setFullYear(n,0,4),r.setHours(0,0,0,0),um(r)}function Gh(e,t){const n=+sn(e)-+sn(t);return n<0?-1:n>0?1:n}function NK(e){return ei(e,Date.now())}function TK(e){return e instanceof Date||typeof e=="object"&&Object.prototype.toString.call(e)==="[object Date]"}function CK(e){return!(!TK(e)&&typeof e!="number"||isNaN(+sn(e)))}function MK(e,t,n){const[r,i]=Xp(n==null?void 0:n.in,e,t),s=r.getFullYear()-i.getFullYear(),l=r.getMonth()-i.getMonth();return s*12+l}function RK(e){return t=>{const r=(e?Math[e]:Math.trunc)(t);return r===0?0:r}}function DK(e,t){return+sn(e)-+sn(t)}function PK(e,t){const n=sn(e,t==null?void 0:t.in);return n.setHours(23,59,59,999),n}function kK(e,t){const n=sn(e,t==null?void 0:t.in),r=n.getMonth();return n.setFullYear(n.getFullYear(),r+1,0),n.setHours(23,59,59,999),n}function $K(e,t){const n=sn(e,t==null?void 0:t.in);return+PK(n,t)==+kK(n,t)}function LK(e,t,n){const[r,i,s]=Xp(n==null?void 0:n.in,e,e,t),l=Gh(i,s),f=Math.abs(MK(i,s));if(f<1)return 0;i.getMonth()===1&&i.getDate()>27&&i.setDate(30),i.setMonth(i.getMonth()-l*f);let d=Gh(i,s)===-l;$K(r)&&f===1&&Gh(r,s)===1&&(d=!1);const h=l*(f-+d);return h===0?0:h}function IK(e,t,n){const r=DK(e,t)/1e3;return RK(n==null?void 0:n.roundingMethod)(r)}function zK(e,t){const n=sn(e,t==null?void 0:t.in);return n.setFullYear(n.getFullYear(),0,1),n.setHours(0,0,0,0),n}const BK={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"}},qK=(e,t,n)=>{let r;const i=BK[e];return typeof i=="string"?r=i:t===1?r=i.one:r=i.other.replace("{{count}}",t.toString()),n!=null&&n.addSuffix?n.comparison&&n.comparison>0?"in "+r:r+" ago":r};function xb(e){return(t={})=>{const n=t.width?String(t.width):e.defaultWidth;return e.formats[n]||e.formats[e.defaultWidth]}}const UK={full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},HK={full:"h:mm:ss a zzzz",long:"h:mm:ss a z",medium:"h:mm:ss a",short:"h:mm a"},FK={full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},GK={date:xb({formats:UK,defaultWidth:"full"}),time:xb({formats:HK,defaultWidth:"full"}),dateTime:xb({formats:FK,defaultWidth:"full"})},VK={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"},YK=(e,t,n,r)=>VK[e];function uu(e){return(t,n)=>{const r=n!=null&&n.context?String(n.context):"standalone";let i;if(r==="formatting"&&e.formattingValues){const l=e.defaultFormattingWidth||e.defaultWidth,f=n!=null&&n.width?String(n.width):l;i=e.formattingValues[f]||e.formattingValues[l]}else{const l=e.defaultWidth,f=n!=null&&n.width?String(n.width):e.defaultWidth;i=e.values[f]||e.values[l]}const s=e.argumentCallback?e.argumentCallback(t):t;return i[s]}}const WK={narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},KK={narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1st quarter","2nd quarter","3rd quarter","4th quarter"]},XK={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"]},QK={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"]},ZK={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"}},JK={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"}},eX=(e,t)=>{const n=Number(e),r=n%100;if(r>20||r<10)switch(r%10){case 1:return n+"st";case 2:return n+"nd";case 3:return n+"rd"}return n+"th"},tX={ordinalNumber:eX,era:uu({values:WK,defaultWidth:"wide"}),quarter:uu({values:KK,defaultWidth:"wide",argumentCallback:e=>e-1}),month:uu({values:XK,defaultWidth:"wide"}),day:uu({values:QK,defaultWidth:"wide"}),dayPeriod:uu({values:ZK,defaultWidth:"wide",formattingValues:JK,defaultFormattingWidth:"wide"})};function fu(e){return(t,n={})=>{const r=n.width,i=r&&e.matchPatterns[r]||e.matchPatterns[e.defaultMatchWidth],s=t.match(i);if(!s)return null;const l=s[0],f=r&&e.parsePatterns[r]||e.parsePatterns[e.defaultParseWidth],d=Array.isArray(f)?rX(f,p=>p.test(l)):nX(f,p=>p.test(l));let h;h=e.valueCallback?e.valueCallback(d):d,h=n.valueCallback?n.valueCallback(h):h;const v=t.slice(l.length);return{value:h,rest:v}}}function nX(e,t){for(const n in e)if(Object.prototype.hasOwnProperty.call(e,n)&&t(e[n]))return n}function rX(e,t){for(let n=0;n<e.length;n++)if(t(e[n]))return n}function aX(e){return(t,n={})=>{const r=t.match(e.matchPattern);if(!r)return null;const i=r[0],s=t.match(e.parsePattern);if(!s)return null;let l=e.valueCallback?e.valueCallback(s[0]):s[0];l=n.valueCallback?n.valueCallback(l):l;const f=t.slice(i.length);return{value:l,rest:f}}}const iX=/^(\d+)(th|st|nd|rd)?/i,oX=/\d+/i,sX={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},lX={any:[/^b/i,/^(a|c)/i]},cX={narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},uX={any:[/1/i,/2/i,/3/i,/4/i]},fX={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},dX={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]},hX={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},mX={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]},pX={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},vX={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}},gX={ordinalNumber:aX({matchPattern:iX,parsePattern:oX,valueCallback:e=>parseInt(e,10)}),era:fu({matchPatterns:sX,defaultMatchWidth:"wide",parsePatterns:lX,defaultParseWidth:"any"}),quarter:fu({matchPatterns:cX,defaultMatchWidth:"wide",parsePatterns:uX,defaultParseWidth:"any",valueCallback:e=>e+1}),month:fu({matchPatterns:fX,defaultMatchWidth:"wide",parsePatterns:dX,defaultParseWidth:"any"}),day:fu({matchPatterns:hX,defaultMatchWidth:"wide",parsePatterns:mX,defaultParseWidth:"any"}),dayPeriod:fu({matchPatterns:pX,defaultMatchWidth:"any",parsePatterns:vX,defaultParseWidth:"any"})},d3={code:"en-US",formatDistance:qK,formatLong:GK,formatRelative:YK,localize:tX,match:gX,options:{weekStartsOn:0,firstWeekContainsDate:1}};function yX(e,t){const n=sn(e,t==null?void 0:t.in);return _K(n,zK(n))+1}function bX(e,t){const n=sn(e,t==null?void 0:t.in),r=+um(n)-+AK(n);return Math.round(r/u3)+1}function h3(e,t){var v,p,g,b;const n=sn(e,t==null?void 0:t.in),r=n.getFullYear(),i=qf(),s=(t==null?void 0:t.firstWeekContainsDate)??((p=(v=t==null?void 0:t.locale)==null?void 0:v.options)==null?void 0:p.firstWeekContainsDate)??i.firstWeekContainsDate??((b=(g=i.locale)==null?void 0:g.options)==null?void 0:b.firstWeekContainsDate)??1,l=ei((t==null?void 0:t.in)||e,0);l.setFullYear(r+1,0,s),l.setHours(0,0,0,0);const f=Uu(l,t),d=ei((t==null?void 0:t.in)||e,0);d.setFullYear(r,0,s),d.setHours(0,0,0,0);const h=Uu(d,t);return+n>=+f?r+1:+n>=+h?r:r-1}function xX(e,t){var f,d,h,v;const n=qf(),r=(t==null?void 0:t.firstWeekContainsDate)??((d=(f=t==null?void 0:t.locale)==null?void 0:f.options)==null?void 0:d.firstWeekContainsDate)??n.firstWeekContainsDate??((v=(h=n.locale)==null?void 0:h.options)==null?void 0:v.firstWeekContainsDate)??1,i=h3(e,t),s=ei((t==null?void 0:t.in)||e,0);return s.setFullYear(i,0,r),s.setHours(0,0,0,0),Uu(s,t)}function wX(e,t){const n=sn(e,t==null?void 0:t.in),r=+Uu(n,t)-+xX(n,t);return Math.round(r/u3)+1}function ht(e,t){const n=e<0?"-":"",r=Math.abs(e).toString().padStart(t,"0");return n+r}const Ii={y(e,t){const n=e.getFullYear(),r=n>0?n:1-n;return ht(t==="yy"?r%100:r,t.length)},M(e,t){const n=e.getMonth();return t==="M"?String(n+1):ht(n+1,2)},d(e,t){return ht(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];case"aaaa":default:return n==="am"?"a.m.":"p.m."}},h(e,t){return ht(e.getHours()%12||12,t.length)},H(e,t){return ht(e.getHours(),t.length)},m(e,t){return ht(e.getMinutes(),t.length)},s(e,t){return ht(e.getSeconds(),t.length)},S(e,t){const n=t.length,r=e.getMilliseconds(),i=Math.trunc(r*Math.pow(10,n-3));return ht(i,t.length)}},tl={midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},AT={G:function(e,t,n){const r=e.getFullYear()>0?1:0;switch(t){case"G":case"GG":case"GGG":return n.era(r,{width:"abbreviated"});case"GGGGG":return n.era(r,{width:"narrow"});case"GGGG":default:return n.era(r,{width:"wide"})}},y:function(e,t,n){if(t==="yo"){const r=e.getFullYear(),i=r>0?r:1-r;return n.ordinalNumber(i,{unit:"year"})}return Ii.y(e,t)},Y:function(e,t,n,r){const i=h3(e,r),s=i>0?i:1-i;if(t==="YY"){const l=s%100;return ht(l,2)}return t==="Yo"?n.ordinalNumber(s,{unit:"year"}):ht(s,t.length)},R:function(e,t){const n=f3(e);return ht(n,t.length)},u:function(e,t){const n=e.getFullYear();return ht(n,t.length)},Q:function(e,t,n){const r=Math.ceil((e.getMonth()+1)/3);switch(t){case"Q":return String(r);case"QQ":return ht(r,2);case"Qo":return n.ordinalNumber(r,{unit:"quarter"});case"QQQ":return n.quarter(r,{width:"abbreviated",context:"formatting"});case"QQQQQ":return n.quarter(r,{width:"narrow",context:"formatting"});case"QQQQ":default:return n.quarter(r,{width:"wide",context:"formatting"})}},q:function(e,t,n){const r=Math.ceil((e.getMonth()+1)/3);switch(t){case"q":return String(r);case"qq":return ht(r,2);case"qo":return n.ordinalNumber(r,{unit:"quarter"});case"qqq":return n.quarter(r,{width:"abbreviated",context:"standalone"});case"qqqqq":return n.quarter(r,{width:"narrow",context:"standalone"});case"qqqq":default:return n.quarter(r,{width:"wide",context:"standalone"})}},M:function(e,t,n){const r=e.getMonth();switch(t){case"M":case"MM":return Ii.M(e,t);case"Mo":return n.ordinalNumber(r+1,{unit:"month"});case"MMM":return n.month(r,{width:"abbreviated",context:"formatting"});case"MMMMM":return n.month(r,{width:"narrow",context:"formatting"});case"MMMM":default:return n.month(r,{width:"wide",context:"formatting"})}},L:function(e,t,n){const r=e.getMonth();switch(t){case"L":return String(r+1);case"LL":return ht(r+1,2);case"Lo":return n.ordinalNumber(r+1,{unit:"month"});case"LLL":return n.month(r,{width:"abbreviated",context:"standalone"});case"LLLLL":return n.month(r,{width:"narrow",context:"standalone"});case"LLLL":default:return n.month(r,{width:"wide",context:"standalone"})}},w:function(e,t,n,r){const i=wX(e,r);return t==="wo"?n.ordinalNumber(i,{unit:"week"}):ht(i,t.length)},I:function(e,t,n){const r=bX(e);return t==="Io"?n.ordinalNumber(r,{unit:"week"}):ht(r,t.length)},d:function(e,t,n){return t==="do"?n.ordinalNumber(e.getDate(),{unit:"date"}):Ii.d(e,t)},D:function(e,t,n){const r=yX(e);return t==="Do"?n.ordinalNumber(r,{unit:"dayOfYear"}):ht(r,t.length)},E:function(e,t,n){const r=e.getDay();switch(t){case"E":case"EE":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"});case"EEEE":default:return n.day(r,{width:"wide",context:"formatting"})}},e:function(e,t,n,r){const i=e.getDay(),s=(i-r.weekStartsOn+8)%7||7;switch(t){case"e":return String(s);case"ee":return ht(s,2);case"eo":return n.ordinalNumber(s,{unit:"day"});case"eee":return n.day(i,{width:"abbreviated",context:"formatting"});case"eeeee":return n.day(i,{width:"narrow",context:"formatting"});case"eeeeee":return n.day(i,{width:"short",context:"formatting"});case"eeee":default:return n.day(i,{width:"wide",context:"formatting"})}},c:function(e,t,n,r){const i=e.getDay(),s=(i-r.weekStartsOn+8)%7||7;switch(t){case"c":return String(s);case"cc":return ht(s,t.length);case"co":return n.ordinalNumber(s,{unit:"day"});case"ccc":return n.day(i,{width:"abbreviated",context:"standalone"});case"ccccc":return n.day(i,{width:"narrow",context:"standalone"});case"cccccc":return n.day(i,{width:"short",context:"standalone"});case"cccc":default:return n.day(i,{width:"wide",context:"standalone"})}},i:function(e,t,n){const r=e.getDay(),i=r===0?7:r;switch(t){case"i":return String(i);case"ii":return ht(i,t.length);case"io":return n.ordinalNumber(i,{unit:"day"});case"iii":return n.day(r,{width:"abbreviated",context:"formatting"});case"iiiii":return n.day(r,{width:"narrow",context:"formatting"});case"iiiiii":return n.day(r,{width:"short",context:"formatting"});case"iiii":default:return n.day(r,{width:"wide",context:"formatting"})}},a:function(e,t,n){const i=e.getHours()/12>=1?"pm":"am";switch(t){case"a":case"aa":return n.dayPeriod(i,{width:"abbreviated",context:"formatting"});case"aaa":return n.dayPeriod(i,{width:"abbreviated",context:"formatting"}).toLowerCase();case"aaaaa":return n.dayPeriod(i,{width:"narrow",context:"formatting"});case"aaaa":default:return n.dayPeriod(i,{width:"wide",context:"formatting"})}},b:function(e,t,n){const r=e.getHours();let i;switch(r===12?i=tl.noon:r===0?i=tl.midnight:i=r/12>=1?"pm":"am",t){case"b":case"bb":return n.dayPeriod(i,{width:"abbreviated",context:"formatting"});case"bbb":return n.dayPeriod(i,{width:"abbreviated",context:"formatting"}).toLowerCase();case"bbbbb":return n.dayPeriod(i,{width:"narrow",context:"formatting"});case"bbbb":default:return n.dayPeriod(i,{width:"wide",context:"formatting"})}},B:function(e,t,n){const r=e.getHours();let i;switch(r>=17?i=tl.evening:r>=12?i=tl.afternoon:r>=4?i=tl.morning:i=tl.night,t){case"B":case"BB":case"BBB":return n.dayPeriod(i,{width:"abbreviated",context:"formatting"});case"BBBBB":return n.dayPeriod(i,{width:"narrow",context:"formatting"});case"BBBB":default:return n.dayPeriod(i,{width:"wide",context:"formatting"})}},h:function(e,t,n){if(t==="ho"){let r=e.getHours()%12;return r===0&&(r=12),n.ordinalNumber(r,{unit:"hour"})}return Ii.h(e,t)},H:function(e,t,n){return t==="Ho"?n.ordinalNumber(e.getHours(),{unit:"hour"}):Ii.H(e,t)},K:function(e,t,n){const r=e.getHours()%12;return t==="Ko"?n.ordinalNumber(r,{unit:"hour"}):ht(r,t.length)},k:function(e,t,n){let r=e.getHours();return r===0&&(r=24),t==="ko"?n.ordinalNumber(r,{unit:"hour"}):ht(r,t.length)},m:function(e,t,n){return t==="mo"?n.ordinalNumber(e.getMinutes(),{unit:"minute"}):Ii.m(e,t)},s:function(e,t,n){return t==="so"?n.ordinalNumber(e.getSeconds(),{unit:"second"}):Ii.s(e,t)},S:function(e,t){return Ii.S(e,t)},X:function(e,t,n){const r=e.getTimezoneOffset();if(r===0)return"Z";switch(t){case"X":return TT(r);case"XXXX":case"XX":return Mo(r);case"XXXXX":case"XXX":default:return Mo(r,":")}},x:function(e,t,n){const r=e.getTimezoneOffset();switch(t){case"x":return TT(r);case"xxxx":case"xx":return Mo(r);case"xxxxx":case"xxx":default:return Mo(r,":")}},O:function(e,t,n){const r=e.getTimezoneOffset();switch(t){case"O":case"OO":case"OOO":return"GMT"+NT(r,":");case"OOOO":default:return"GMT"+Mo(r,":")}},z:function(e,t,n){const r=e.getTimezoneOffset();switch(t){case"z":case"zz":case"zzz":return"GMT"+NT(r,":");case"zzzz":default:return"GMT"+Mo(r,":")}},t:function(e,t,n){const r=Math.trunc(+e/1e3);return ht(r,t.length)},T:function(e,t,n){return ht(+e,t.length)}};function NT(e,t=""){const n=e>0?"-":"+",r=Math.abs(e),i=Math.trunc(r/60),s=r%60;return s===0?n+String(i):n+String(i)+t+ht(s,2)}function TT(e,t){return e%60===0?(e>0?"-":"+")+ht(Math.abs(e)/60,2):Mo(e,t)}function Mo(e,t=""){const n=e>0?"-":"+",r=Math.abs(e),i=ht(Math.trunc(r/60),2),s=ht(r%60,2);return n+i+t+s}const CT=(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"});case"PPPP":default:return t.date({width:"full"})}},m3=(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"});case"pppp":default:return t.time({width:"full"})}},SX=(e,t)=>{const n=e.match(/(P+)(p+)?/)||[],r=n[1],i=n[2];if(!i)return CT(e,t);let s;switch(r){case"P":s=t.dateTime({width:"short"});break;case"PP":s=t.dateTime({width:"medium"});break;case"PPP":s=t.dateTime({width:"long"});break;case"PPPP":default:s=t.dateTime({width:"full"});break}return s.replace("{{date}}",CT(r,t)).replace("{{time}}",m3(i,t))},jX={p:m3,P:SX},OX=/^D+$/,EX=/^Y+$/,_X=["D","DD","YY","YYYY"];function AX(e){return OX.test(e)}function NX(e){return EX.test(e)}function TX(e,t,n){const r=CX(e,t,n);if(console.warn(r),_X.includes(e))throw new RangeError(r)}function CX(e,t,n){const r=e[0]==="Y"?"years":"days of the month";return`Use \`${e.toLowerCase()}\` instead of \`${e}\` (in \`${t}\`) for formatting ${r} to the input \`${n}\`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md`}const MX=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,RX=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,DX=/^'([^]*?)'?$/,PX=/''/g,kX=/[a-zA-Z]/;function V1(e,t,n){var v,p,g,b;const r=qf(),i=r.locale??d3,s=r.firstWeekContainsDate??((p=(v=r.locale)==null?void 0:v.options)==null?void 0:p.firstWeekContainsDate)??1,l=r.weekStartsOn??((b=(g=r.locale)==null?void 0:g.options)==null?void 0:b.weekStartsOn)??0,f=sn(e,n==null?void 0:n.in);if(!CK(f))throw new RangeError("Invalid time value");let d=t.match(RX).map(O=>{const S=O[0];if(S==="p"||S==="P"){const x=jX[S];return x(O,i.formatLong)}return O}).join("").match(MX).map(O=>{if(O==="''")return{isToken:!1,value:"'"};const S=O[0];if(S==="'")return{isToken:!1,value:$X(O)};if(AT[S])return{isToken:!0,value:O};if(S.match(kX))throw new RangeError("Format string contains an unescaped latin alphabet character `"+S+"`");return{isToken:!1,value:O}});i.localize.preprocessor&&(d=i.localize.preprocessor(f,d));const h={firstWeekContainsDate:s,weekStartsOn:l,locale:i};return d.map(O=>{if(!O.isToken)return O.value;const S=O.value;(NX(S)||AX(S))&&TX(S,t,String(e));const x=AT[S[0]];return x(f,S,i.localize,h)}).join("")}function $X(e){const t=e.match(DX);return t?t[1].replace(PX,"'"):e}function LX(e,t,n){const r=qf(),i=(n==null?void 0:n.locale)??r.locale??d3,s=2520,l=Gh(e,t);if(isNaN(l))throw new RangeError("Invalid time value");const f=Object.assign({},n,{addSuffix:n==null?void 0:n.addSuffix,comparison:l}),[d,h]=Xp(n==null?void 0:n.in,...l>0?[t,e]:[e,t]),v=IK(h,d),p=(fm(h)-fm(d))/1e3,g=Math.round((v-p)/60);let b;if(g<2)return n!=null&&n.includeSeconds?v<5?i.formatDistance("lessThanXSeconds",5,f):v<10?i.formatDistance("lessThanXSeconds",10,f):v<20?i.formatDistance("lessThanXSeconds",20,f):v<40?i.formatDistance("halfAMinute",0,f):v<60?i.formatDistance("lessThanXMinutes",1,f):i.formatDistance("xMinutes",1,f):g===0?i.formatDistance("lessThanXMinutes",1,f):i.formatDistance("xMinutes",g,f);if(g<45)return i.formatDistance("xMinutes",g,f);if(g<90)return i.formatDistance("aboutXHours",1,f);if(g<OT){const O=Math.round(g/60);return i.formatDistance("aboutXHours",O,f)}else{if(g<s)return i.formatDistance("xDays",1,f);if(g<wh){const O=Math.round(g/OT);return i.formatDistance("xDays",O,f)}else if(g<wh*2)return b=Math.round(g/wh),i.formatDistance("aboutXMonths",b,f)}if(b=LK(h,d),b<12){const O=Math.round(g/wh);return i.formatDistance("xMonths",O,f)}else{const O=b%12,S=Math.trunc(b/12);return O<3?i.formatDistance("aboutXYears",S,f):O<9?i.formatDistance("overXYears",S,f):i.formatDistance("almostXYears",S+1,f)}}function IX(e,t){return LX(e,NK(e),t)}var wb,MT;function Un(){if(MT)return wb;MT=1;var e=Array.isArray;return wb=e,wb}var Sb,RT;function p3(){if(RT)return Sb;RT=1;var e=typeof fh=="object"&&fh&&fh.Object===Object&&fh;return Sb=e,Sb}var jb,DT;function wa(){if(DT)return jb;DT=1;var e=p3(),t=typeof self=="object"&&self&&self.Object===Object&&self,n=e||t||Function("return this")();return jb=n,jb}var Ob,PT;function Uf(){if(PT)return Ob;PT=1;var e=wa(),t=e.Symbol;return Ob=t,Ob}var Eb,kT;function zX(){if(kT)return Eb;kT=1;var e=Uf(),t=Object.prototype,n=t.hasOwnProperty,r=t.toString,i=e?e.toStringTag:void 0;function s(l){var f=n.call(l,i),d=l[i];try{l[i]=void 0;var h=!0}catch{}var v=r.call(l);return h&&(f?l[i]=d:delete l[i]),v}return Eb=s,Eb}var _b,$T;function BX(){if($T)return _b;$T=1;var e=Object.prototype,t=e.toString;function n(r){return t.call(r)}return _b=n,_b}var Ab,LT;function oi(){if(LT)return Ab;LT=1;var e=Uf(),t=zX(),n=BX(),r="[object Null]",i="[object Undefined]",s=e?e.toStringTag:void 0;function l(f){return f==null?f===void 0?i:r:s&&s in Object(f)?t(f):n(f)}return Ab=l,Ab}var Nb,IT;function si(){if(IT)return Nb;IT=1;function e(t){return t!=null&&typeof t=="object"}return Nb=e,Nb}var Tb,zT;function rc(){if(zT)return Tb;zT=1;var e=oi(),t=si(),n="[object Symbol]";function r(i){return typeof i=="symbol"||t(i)&&e(i)==n}return Tb=r,Tb}var Cb,BT;function pO(){if(BT)return Cb;BT=1;var e=Un(),t=rc(),n=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,r=/^\w*$/;function i(s,l){if(e(s))return!1;var f=typeof s;return f=="number"||f=="symbol"||f=="boolean"||s==null||t(s)?!0:r.test(s)||!n.test(s)||l!=null&&s in Object(l)}return Cb=i,Cb}var Mb,qT;function to(){if(qT)return Mb;qT=1;function e(t){var n=typeof t;return t!=null&&(n=="object"||n=="function")}return Mb=e,Mb}var Rb,UT;function vO(){if(UT)return Rb;UT=1;var e=oi(),t=to(),n="[object AsyncFunction]",r="[object Function]",i="[object GeneratorFunction]",s="[object Proxy]";function l(f){if(!t(f))return!1;var d=e(f);return d==r||d==i||d==n||d==s}return Rb=l,Rb}var Db,HT;function qX(){if(HT)return Db;HT=1;var e=wa(),t=e["__core-js_shared__"];return Db=t,Db}var Pb,FT;function UX(){if(FT)return Pb;FT=1;var e=qX(),t=(function(){var r=/[^.]+$/.exec(e&&e.keys&&e.keys.IE_PROTO||"");return r?"Symbol(src)_1."+r:""})();function n(r){return!!t&&t in r}return Pb=n,Pb}var kb,GT;function v3(){if(GT)return kb;GT=1;var e=Function.prototype,t=e.toString;function n(r){if(r!=null){try{return t.call(r)}catch{}try{return r+""}catch{}}return""}return kb=n,kb}var $b,VT;function HX(){if(VT)return $b;VT=1;var e=vO(),t=UX(),n=to(),r=v3(),i=/[\\^$.*+?()[\]{}|]/g,s=/^\[object .+?Constructor\]$/,l=Function.prototype,f=Object.prototype,d=l.toString,h=f.hasOwnProperty,v=RegExp("^"+d.call(h).replace(i,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function p(g){if(!n(g)||t(g))return!1;var b=e(g)?v:s;return b.test(r(g))}return $b=p,$b}var Lb,YT;function FX(){if(YT)return Lb;YT=1;function e(t,n){return t==null?void 0:t[n]}return Lb=e,Lb}var Ib,WT;function as(){if(WT)return Ib;WT=1;var e=HX(),t=FX();function n(r,i){var s=t(r,i);return e(s)?s:void 0}return Ib=n,Ib}var zb,KT;function Qp(){if(KT)return zb;KT=1;var e=as(),t=e(Object,"create");return zb=t,zb}var Bb,XT;function GX(){if(XT)return Bb;XT=1;var e=Qp();function t(){this.__data__=e?e(null):{},this.size=0}return Bb=t,Bb}var qb,QT;function VX(){if(QT)return qb;QT=1;function e(t){var n=this.has(t)&&delete this.__data__[t];return this.size-=n?1:0,n}return qb=e,qb}var Ub,ZT;function YX(){if(ZT)return Ub;ZT=1;var e=Qp(),t="__lodash_hash_undefined__",n=Object.prototype,r=n.hasOwnProperty;function i(s){var l=this.__data__;if(e){var f=l[s];return f===t?void 0:f}return r.call(l,s)?l[s]:void 0}return Ub=i,Ub}var Hb,JT;function WX(){if(JT)return Hb;JT=1;var e=Qp(),t=Object.prototype,n=t.hasOwnProperty;function r(i){var s=this.__data__;return e?s[i]!==void 0:n.call(s,i)}return Hb=r,Hb}var Fb,eC;function KX(){if(eC)return Fb;eC=1;var e=Qp(),t="__lodash_hash_undefined__";function n(r,i){var s=this.__data__;return this.size+=this.has(r)?0:1,s[r]=e&&i===void 0?t:i,this}return Fb=n,Fb}var Gb,tC;function XX(){if(tC)return Gb;tC=1;var e=GX(),t=VX(),n=YX(),r=WX(),i=KX();function s(l){var f=-1,d=l==null?0:l.length;for(this.clear();++f<d;){var h=l[f];this.set(h[0],h[1])}}return s.prototype.clear=e,s.prototype.delete=t,s.prototype.get=n,s.prototype.has=r,s.prototype.set=i,Gb=s,Gb}var Vb,nC;function QX(){if(nC)return Vb;nC=1;function e(){this.__data__=[],this.size=0}return Vb=e,Vb}var Yb,rC;function gO(){if(rC)return Yb;rC=1;function e(t,n){return t===n||t!==t&&n!==n}return Yb=e,Yb}var Wb,aC;function Zp(){if(aC)return Wb;aC=1;var e=gO();function t(n,r){for(var i=n.length;i--;)if(e(n[i][0],r))return i;return-1}return Wb=t,Wb}var Kb,iC;function ZX(){if(iC)return Kb;iC=1;var e=Zp(),t=Array.prototype,n=t.splice;function r(i){var s=this.__data__,l=e(s,i);if(l<0)return!1;var f=s.length-1;return l==f?s.pop():n.call(s,l,1),--this.size,!0}return Kb=r,Kb}var Xb,oC;function JX(){if(oC)return Xb;oC=1;var e=Zp();function t(n){var r=this.__data__,i=e(r,n);return i<0?void 0:r[i][1]}return Xb=t,Xb}var Qb,sC;function eQ(){if(sC)return Qb;sC=1;var e=Zp();function t(n){return e(this.__data__,n)>-1}return Qb=t,Qb}var Zb,lC;function tQ(){if(lC)return Zb;lC=1;var e=Zp();function t(n,r){var i=this.__data__,s=e(i,n);return s<0?(++this.size,i.push([n,r])):i[s][1]=r,this}return Zb=t,Zb}var Jb,cC;function Jp(){if(cC)return Jb;cC=1;var e=QX(),t=ZX(),n=JX(),r=eQ(),i=tQ();function s(l){var f=-1,d=l==null?0:l.length;for(this.clear();++f<d;){var h=l[f];this.set(h[0],h[1])}}return s.prototype.clear=e,s.prototype.delete=t,s.prototype.get=n,s.prototype.has=r,s.prototype.set=i,Jb=s,Jb}var ex,uC;function yO(){if(uC)return ex;uC=1;var e=as(),t=wa(),n=e(t,"Map");return ex=n,ex}var tx,fC;function nQ(){if(fC)return tx;fC=1;var e=XX(),t=Jp(),n=yO();function r(){this.size=0,this.__data__={hash:new e,map:new(n||t),string:new e}}return tx=r,tx}var nx,dC;function rQ(){if(dC)return nx;dC=1;function e(t){var n=typeof t;return n=="string"||n=="number"||n=="symbol"||n=="boolean"?t!=="__proto__":t===null}return nx=e,nx}var rx,hC;function ev(){if(hC)return rx;hC=1;var e=rQ();function t(n,r){var i=n.__data__;return e(r)?i[typeof r=="string"?"string":"hash"]:i.map}return rx=t,rx}var ax,mC;function aQ(){if(mC)return ax;mC=1;var e=ev();function t(n){var r=e(this,n).delete(n);return this.size-=r?1:0,r}return ax=t,ax}var ix,pC;function iQ(){if(pC)return ix;pC=1;var e=ev();function t(n){return e(this,n).get(n)}return ix=t,ix}var ox,vC;function oQ(){if(vC)return ox;vC=1;var e=ev();function t(n){return e(this,n).has(n)}return ox=t,ox}var sx,gC;function sQ(){if(gC)return sx;gC=1;var e=ev();function t(n,r){var i=e(this,n),s=i.size;return i.set(n,r),this.size+=i.size==s?0:1,this}return sx=t,sx}var lx,yC;function bO(){if(yC)return lx;yC=1;var e=nQ(),t=aQ(),n=iQ(),r=oQ(),i=sQ();function s(l){var f=-1,d=l==null?0:l.length;for(this.clear();++f<d;){var h=l[f];this.set(h[0],h[1])}}return s.prototype.clear=e,s.prototype.delete=t,s.prototype.get=n,s.prototype.has=r,s.prototype.set=i,lx=s,lx}var cx,bC;function g3(){if(bC)return cx;bC=1;var e=bO(),t="Expected a function";function n(r,i){if(typeof r!="function"||i!=null&&typeof i!="function")throw new TypeError(t);var s=function(){var l=arguments,f=i?i.apply(this,l):l[0],d=s.cache;if(d.has(f))return d.get(f);var h=r.apply(this,l);return s.cache=d.set(f,h)||d,h};return s.cache=new(n.Cache||e),s}return n.Cache=e,cx=n,cx}var ux,xC;function lQ(){if(xC)return ux;xC=1;var e=g3(),t=500;function n(r){var i=e(r,function(l){return s.size===t&&s.clear(),l}),s=i.cache;return i}return ux=n,ux}var fx,wC;function cQ(){if(wC)return fx;wC=1;var e=lQ(),t=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,n=/\\(\\)?/g,r=e(function(i){var s=[];return i.charCodeAt(0)===46&&s.push(""),i.replace(t,function(l,f,d,h){s.push(d?h.replace(n,"$1"):f||l)}),s});return fx=r,fx}var dx,SC;function xO(){if(SC)return dx;SC=1;function e(t,n){for(var r=-1,i=t==null?0:t.length,s=Array(i);++r<i;)s[r]=n(t[r],r,t);return s}return dx=e,dx}var hx,jC;function uQ(){if(jC)return hx;jC=1;var e=Uf(),t=xO(),n=Un(),r=rc(),i=e?e.prototype:void 0,s=i?i.toString:void 0;function l(f){if(typeof f=="string")return f;if(n(f))return t(f,l)+"";if(r(f))return s?s.call(f):"";var d=f+"";return d=="0"&&1/f==-1/0?"-0":d}return hx=l,hx}var mx,OC;function y3(){if(OC)return mx;OC=1;var e=uQ();function t(n){return n==null?"":e(n)}return mx=t,mx}var px,EC;function b3(){if(EC)return px;EC=1;var e=Un(),t=pO(),n=cQ(),r=y3();function i(s,l){return e(s)?s:t(s,l)?[s]:n(r(s))}return px=i,px}var vx,_C;function tv(){if(_C)return vx;_C=1;var e=rc();function t(n){if(typeof n=="string"||e(n))return n;var r=n+"";return r=="0"&&1/n==-1/0?"-0":r}return vx=t,vx}var gx,AC;function wO(){if(AC)return gx;AC=1;var e=b3(),t=tv();function n(r,i){i=e(i,r);for(var s=0,l=i.length;r!=null&&s<l;)r=r[t(i[s++])];return s&&s==l?r:void 0}return gx=n,gx}var yx,NC;function x3(){if(NC)return yx;NC=1;var e=wO();function t(n,r,i){var s=n==null?void 0:e(n,r);return s===void 0?i:s}return yx=t,yx}var fQ=x3();const Nr=yt(fQ);var bx,TC;function dQ(){if(TC)return bx;TC=1;function e(t){return t==null}return bx=e,bx}var hQ=dQ();const Xe=yt(hQ);var xx,CC;function mQ(){if(CC)return xx;CC=1;var e=oi(),t=Un(),n=si(),r="[object String]";function i(s){return typeof s=="string"||!t(s)&&n(s)&&e(s)==r}return xx=i,xx}var pQ=mQ();const Yo=yt(pQ);var vQ=vO();const Ve=yt(vQ);var gQ=to();const ac=yt(gQ);var wx={exports:{}},ct={};/**
|
|
392
|
+
For more information, see https://radix-ui.com/primitives/docs/components/${t.docsSlug}`;return j.useEffect(()=>{e&&(document.getElementById(e)||console.error(n))},[n,e]),null},AY="DialogDescriptionWarning",NY=({contentRef:e,descriptionId:t})=>{const r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${iI(AY).contentName}}.`;return j.useEffect(()=>{var s;const i=(s=e.current)==null?void 0:s.getAttribute("aria-describedby");t&&i&&(document.getElementById(t)||console.warn(r))},[r,e,t]),null},nO=GL,TY=YL,rO=KL,aO=XL,iO=QL,oO=JL,sO=tI,zp=rI;function CY({...e}){return c.jsx(nO,{"data-slot":"sheet",...e})}function MY({...e}){return c.jsx(rO,{"data-slot":"sheet-portal",...e})}function RY({className:e,...t}){return c.jsx(aO,{className:ve("data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50 data-[state=closed]:animate-out data-[state=open]:animate-in",e),"data-slot":"sheet-overlay",...t})}function DY({className:e,children:t,side:n="right",...r}){return c.jsxs(MY,{children:[c.jsx(RY,{}),c.jsxs(iO,{className:ve("fixed z-50 flex flex-col gap-4 bg-background shadow-lg transition ease-in-out data-[state=closed]:animate-out data-[state=open]:animate-in data-[state=closed]:duration-300 data-[state=open]:duration-500",n==="right"&&"data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right inset-y-0 right-0 h-full w-3/4 border-l sm:max-w-sm",n==="left"&&"data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left inset-y-0 left-0 h-full w-3/4 border-r sm:max-w-sm",n==="top"&&"data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top inset-x-0 top-0 h-auto border-b",n==="bottom"&&"data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom inset-x-0 bottom-0 h-auto border-t",e),"data-slot":"sheet-content",...r,children:[t,c.jsxs(zp,{className:"absolute top-4 right-4 rounded-xs opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-hidden focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-secondary",children:[c.jsx(rr,{className:"size-4"}),c.jsx("span",{className:"sr-only",children:"Close"})]})]})]})}function PY({className:e,...t}){return c.jsx("div",{className:ve("flex flex-col gap-1.5 p-4",e),"data-slot":"sheet-header",...t})}function kY({className:e,...t}){return c.jsx(oO,{className:ve("font-semibold text-foreground",e),"data-slot":"sheet-title",...t})}function $Y({className:e,...t}){return c.jsx(sO,{className:ve("text-muted-foreground text-sm",e),"data-slot":"sheet-description",...t})}function Re({className:e,...t}){return c.jsx("div",{className:ve("animate-pulse rounded-md bg-accent",e),"data-slot":"skeleton",...t})}var oI=Object.freeze({position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal"}),LY="VisuallyHidden",sI=j.forwardRef((e,t)=>c.jsx(Ce.span,{...e,ref:t,style:{...oI,...e.style}}));sI.displayName=LY;var IY=sI,[Bp]=qn("Tooltip",[Jl]),qp=Jl(),lI="TooltipProvider",zY=700,k1="tooltip.open",[BY,lO]=Bp(lI),cI=e=>{const{__scopeTooltip:t,delayDuration:n=zY,skipDelayDuration:r=300,disableHoverableContent:i=!1,children:s}=e,l=j.useRef(!0),f=j.useRef(!1),d=j.useRef(0);return j.useEffect(()=>{const h=d.current;return()=>window.clearTimeout(h)},[]),c.jsx(BY,{scope:t,isOpenDelayedRef:l,delayDuration:n,onOpen:j.useCallback(()=>{window.clearTimeout(d.current),l.current=!1},[]),onClose:j.useCallback(()=>{window.clearTimeout(d.current),d.current=window.setTimeout(()=>l.current=!0,r)},[r]),isPointerInTransitRef:f,onPointerInTransitChange:j.useCallback(h=>{f.current=h},[]),disableHoverableContent:i,children:s})};cI.displayName=lI;var qu="Tooltip",[qY,Bf]=Bp(qu),uI=e=>{const{__scopeTooltip:t,children:n,open:r,defaultOpen:i,onOpenChange:s,disableHoverableContent:l,delayDuration:f}=e,d=lO(qu,e.__scopeTooltip),h=qp(t),[v,p]=j.useState(null),g=_r(),b=j.useRef(0),O=l??d.disableHoverableContent,S=f??d.delayDuration,x=j.useRef(!1),[E,A]=Vr({prop:r,defaultProp:i??!1,onChange:R=>{R?(d.onOpen(),document.dispatchEvent(new CustomEvent(k1))):d.onClose(),s==null||s(R)},caller:qu}),_=j.useMemo(()=>E?x.current?"delayed-open":"instant-open":"closed",[E]),T=j.useCallback(()=>{window.clearTimeout(b.current),b.current=0,x.current=!1,A(!0)},[A]),N=j.useCallback(()=>{window.clearTimeout(b.current),b.current=0,A(!1)},[A]),M=j.useCallback(()=>{window.clearTimeout(b.current),b.current=window.setTimeout(()=>{x.current=!0,A(!0),b.current=0},S)},[S,A]);return j.useEffect(()=>()=>{b.current&&(window.clearTimeout(b.current),b.current=0)},[]),c.jsx(Bj,{...h,children:c.jsx(qY,{scope:t,contentId:g,open:E,stateAttribute:_,trigger:v,onTriggerChange:p,onTriggerEnter:j.useCallback(()=>{d.isOpenDelayedRef.current?M():T()},[d.isOpenDelayedRef,M,T]),onTriggerLeave:j.useCallback(()=>{O?N():(window.clearTimeout(b.current),b.current=0)},[N,O]),onOpen:T,onClose:N,disableHoverableContent:O,children:n})})};uI.displayName=qu;var $1="TooltipTrigger",fI=j.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,i=Bf($1,n),s=lO($1,n),l=qp(n),f=j.useRef(null),d=Be(t,f,i.onTriggerChange),h=j.useRef(!1),v=j.useRef(!1),p=j.useCallback(()=>h.current=!1,[]);return j.useEffect(()=>()=>document.removeEventListener("pointerup",p),[p]),c.jsx(qj,{asChild:!0,...l,children:c.jsx(Ce.button,{"aria-describedby":i.open?i.contentId:void 0,"data-state":i.stateAttribute,...r,ref:d,onPointerMove:be(e.onPointerMove,g=>{g.pointerType!=="touch"&&!v.current&&!s.isPointerInTransitRef.current&&(i.onTriggerEnter(),v.current=!0)}),onPointerLeave:be(e.onPointerLeave,()=>{i.onTriggerLeave(),v.current=!1}),onPointerDown:be(e.onPointerDown,()=>{i.open&&i.onClose(),h.current=!0,document.addEventListener("pointerup",p,{once:!0})}),onFocus:be(e.onFocus,()=>{h.current||i.onOpen()}),onBlur:be(e.onBlur,i.onClose),onClick:be(e.onClick,i.onClose)})})});fI.displayName=$1;var cO="TooltipPortal",[UY,HY]=Bp(cO,{forceMount:void 0}),dI=e=>{const{__scopeTooltip:t,forceMount:n,children:r,container:i}=e,s=Bf(cO,t);return c.jsx(UY,{scope:t,forceMount:n,children:c.jsx(lr,{present:n||s.open,children:c.jsx($f,{asChild:!0,container:i,children:r})})})};dI.displayName=cO;var Sl="TooltipContent",hI=j.forwardRef((e,t)=>{const n=HY(Sl,e.__scopeTooltip),{forceMount:r=n.forceMount,side:i="top",...s}=e,l=Bf(Sl,e.__scopeTooltip);return c.jsx(lr,{present:r||l.open,children:l.disableHoverableContent?c.jsx(mI,{side:i,...s,ref:t}):c.jsx(FY,{side:i,...s,ref:t})})}),FY=j.forwardRef((e,t)=>{const n=Bf(Sl,e.__scopeTooltip),r=lO(Sl,e.__scopeTooltip),i=j.useRef(null),s=Be(t,i),[l,f]=j.useState(null),{trigger:d,onClose:h}=n,v=i.current,{onPointerInTransitChange:p}=r,g=j.useCallback(()=>{f(null),p(!1)},[p]),b=j.useCallback((O,S)=>{const x=O.currentTarget,E={x:O.clientX,y:O.clientY},A=WY(E,x.getBoundingClientRect()),_=KY(E,A),T=XY(S.getBoundingClientRect()),N=ZY([..._,...T]);f(N),p(!0)},[p]);return j.useEffect(()=>()=>g(),[g]),j.useEffect(()=>{if(d&&v){const O=x=>b(x,v),S=x=>b(x,d);return d.addEventListener("pointerleave",O),v.addEventListener("pointerleave",S),()=>{d.removeEventListener("pointerleave",O),v.removeEventListener("pointerleave",S)}}},[d,v,b,g]),j.useEffect(()=>{if(l){const O=S=>{const x=S.target,E={x:S.clientX,y:S.clientY},A=(d==null?void 0:d.contains(x))||(v==null?void 0:v.contains(x)),_=!QY(E,l);A?g():_&&(g(),h())};return document.addEventListener("pointermove",O),()=>document.removeEventListener("pointermove",O)}},[d,v,l,h,g]),c.jsx(mI,{...e,ref:s})}),[GY,VY]=Bp(qu,{isInside:!1}),YY=v$("TooltipContent"),mI=j.forwardRef((e,t)=>{const{__scopeTooltip:n,children:r,"aria-label":i,onEscapeKeyDown:s,onPointerDownOutside:l,...f}=e,d=Bf(Sl,n),h=qp(n),{onClose:v}=d;return j.useEffect(()=>(document.addEventListener(k1,v),()=>document.removeEventListener(k1,v)),[v]),j.useEffect(()=>{if(d.trigger){const p=g=>{const b=g.target;b!=null&&b.contains(d.trigger)&&v()};return window.addEventListener("scroll",p,{capture:!0}),()=>window.removeEventListener("scroll",p,{capture:!0})}},[d.trigger,v]),c.jsx(Pf,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:s,onPointerDownOutside:l,onFocusOutside:p=>p.preventDefault(),onDismiss:v,children:c.jsxs(Uj,{"data-state":d.stateAttribute,...h,...f,ref:t,style:{...f.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-tooltip-content-available-width":"var(--radix-popper-available-width)","--radix-tooltip-content-available-height":"var(--radix-popper-available-height)","--radix-tooltip-trigger-width":"var(--radix-popper-anchor-width)","--radix-tooltip-trigger-height":"var(--radix-popper-anchor-height)"},children:[c.jsx(YY,{children:r}),c.jsx(GY,{scope:n,isInside:!0,children:c.jsx(IY,{id:d.contentId,role:"tooltip",children:i||r})})]})})});hI.displayName=Sl;var pI="TooltipArrow",vI=j.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,i=qp(n);return VY(pI,n).isInside?null:c.jsx(Hj,{...i,...r,ref:t})});vI.displayName=pI;function WY(e,t){const n=Math.abs(t.top-e.y),r=Math.abs(t.bottom-e.y),i=Math.abs(t.right-e.x),s=Math.abs(t.left-e.x);switch(Math.min(n,r,i,s)){case s:return"left";case i:return"right";case n:return"top";case r:return"bottom";default:throw new Error("unreachable")}}function KY(e,t,n=5){const r=[];switch(t){case"top":r.push({x:e.x-n,y:e.y+n},{x:e.x+n,y:e.y+n});break;case"bottom":r.push({x:e.x-n,y:e.y-n},{x:e.x+n,y:e.y-n});break;case"left":r.push({x:e.x+n,y:e.y-n},{x:e.x+n,y:e.y+n});break;case"right":r.push({x:e.x-n,y:e.y-n},{x:e.x-n,y:e.y+n});break}return r}function XY(e){const{top:t,right:n,bottom:r,left:i}=e;return[{x:i,y:t},{x:n,y:t},{x:n,y:r},{x:i,y:r}]}function QY(e,t){const{x:n,y:r}=e;let i=!1;for(let s=0,l=t.length-1;s<t.length;l=s++){const f=t[s],d=t[l],h=f.x,v=f.y,p=d.x,g=d.y;v>r!=g>r&&n<(p-h)*(r-v)/(g-v)+h&&(i=!i)}return i}function ZY(e){const t=e.slice();return t.sort((n,r)=>n.x<r.x?-1:n.x>r.x?1:n.y<r.y?-1:n.y>r.y?1:0),JY(t)}function JY(e){if(e.length<=1)return e.slice();const t=[];for(let r=0;r<e.length;r++){const i=e[r];for(;t.length>=2;){const s=t[t.length-1],l=t[t.length-2];if((s.x-l.x)*(i.y-l.y)>=(s.y-l.y)*(i.x-l.x))t.pop();else break}t.push(i)}t.pop();const n=[];for(let r=e.length-1;r>=0;r--){const i=e[r];for(;n.length>=2;){const s=n[n.length-1],l=n[n.length-2];if((s.x-l.x)*(i.y-l.y)>=(s.y-l.y)*(i.x-l.x))n.pop();else break}n.push(i)}return n.pop(),t.length===1&&n.length===1&&t[0].x===n[0].x&&t[0].y===n[0].y?t:t.concat(n)}var eW=cI,tW=uI,nW=fI,rW=dI,aW=hI,iW=vI;function gI({delayDuration:e=0,...t}){return c.jsx(eW,{"data-slot":"tooltip-provider",delayDuration:e,...t})}function Up({...e}){return c.jsx(gI,{children:c.jsx(tW,{"data-slot":"tooltip",...e})})}function Hp({...e}){return c.jsx(nW,{"data-slot":"tooltip-trigger",...e})}function Fp({className:e,sideOffset:t=0,children:n,...r}){return c.jsx(rW,{children:c.jsxs(aW,{className:ve("fade-in-0 zoom-in-95 data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-fit origin-[--radix-tooltip-content-transform-origin] animate-in text-balance rounded-md bg-foreground px-3 py-1.5 text-background text-xs data-[state=closed]:animate-out",e),"data-slot":"tooltip-content",sideOffset:t,...r,children:[n,c.jsx(iW,{className:"z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px] bg-foreground fill-foreground"})]})})}const yb=768;function oW(){const[e,t]=j.useState(void 0);return j.useEffect(()=>{const n=window.matchMedia(`(max-width: ${yb-1}px)`),r=()=>{t(window.innerWidth<yb)};return n.addEventListener("change",r),t(window.innerWidth<yb),()=>n.removeEventListener("change",r)},[]),!!e}const sW="sidebar_state",lW=3600*24*7,cW="16rem",uW="18rem",fW="3rem",dW="b",yI=j.createContext(null);function tc(){const e=j.useContext(yI);if(!e)throw new Error("useSidebar must be used within a SidebarProvider.");return e}const bI=j.forwardRef(({defaultOpen:e=!0,open:t,onOpenChange:n,className:r,style:i,children:s,...l},f)=>{const d=oW(),[h,v]=j.useState(!1),[p,g]=j.useState(e),b=t??p,O=j.useCallback(A=>{const _=typeof A=="function"?A(b):A;n?n(_):g(_),document.cookie=`${sW}=${_}; path=/; max-age=${lW}`},[n,b]),S=j.useCallback(()=>d?v(A=>!A):O(A=>!A),[d,O]);j.useEffect(()=>{const A=_=>{_.key===dW&&(_.metaKey||_.ctrlKey)&&(_.preventDefault(),S())};return window.addEventListener("keydown",A),()=>window.removeEventListener("keydown",A)},[S]);const x=b?"expanded":"collapsed",E=j.useMemo(()=>({state:x,open:b,setOpen:O,isMobile:d,openMobile:h,setOpenMobile:v,toggleSidebar:S}),[x,b,O,d,h,S]);return c.jsx(yI.Provider,{value:E,children:c.jsx(gI,{delayDuration:0,children:c.jsx("div",{className:ve("group/sidebar-wrapper flex min-h-svh w-full has-[[data-variant=inset]]:bg-sidebar",r),ref:f,style:{"--sidebar-width":cW,"--sidebar-width-icon":fW,...i},...l,children:s})})})});bI.displayName="SidebarProvider";const Fh=j.forwardRef(({side:e="left",variant:t="sidebar",collapsible:n="offcanvas",className:r,children:i,...s},l)=>{const{isMobile:f,state:d,openMobile:h,setOpenMobile:v}=tc();return n==="none"?c.jsx("div",{className:ve("flex h-full w-[calc(var(--sidebar-width)-var(--sidebar-width-icon)+1px)]! flex-col bg-sidebar text-sidebar-foreground",r),ref:l,...s,children:i}):f?c.jsx(CY,{onOpenChange:v,open:h,...s,children:c.jsxs(DY,{className:"w-[--sidebar-width] bg-sidebar p-0 text-sidebar-foreground [&>button]:hidden","data-mobile":"true","data-sidebar":"sidebar",side:e,style:{"--sidebar-width":uW},children:[c.jsxs(PY,{className:"sr-only",children:[c.jsx(kY,{children:"Sidebar"}),c.jsx($Y,{children:"Displays the mobile sidebar."})]}),c.jsx("div",{className:"flex h-full w-full flex-col",children:i})]})}):c.jsxs("div",{className:"group peer hidden text-sidebar-foreground md:block","data-collapsible":d==="collapsed"?n:"","data-side":e,"data-state":d,"data-variant":t,ref:l,children:[c.jsx("div",{className:ve("relative w-[--sidebar-width] bg-transparent transition-[width] duration-200 ease-linear","group-data-[collapsible=offcanvas]:w-0","group-data-[side=right]:rotate-180",t==="floating"||t==="inset"?"group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)_+_theme(spacing.4))]":"group-data-[collapsible=icon]:w-[--sidebar-width-icon]")}),c.jsx("div",{className:ve("fixed inset-y-0 z-10 hidden h-svh w-[--sidebar-width] transition-[left,right,width] duration-200 ease-linear md:flex",e==="left"?"left-0 group-data-[collapsible=offcanvas]:left-[calc(var(--sidebar-width)*-1)]":"right-0 group-data-[collapsible=offcanvas]:right-[calc(var(--sidebar-width)*-1)]",t==="floating"||t==="inset"?"p-2 group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)_+_theme(spacing.4)_+2px)]":"group-data-[collapsible=icon]:w-[--sidebar-width-icon] group-data-[side=left]:border-r group-data-[side=right]:border-l",r),...s,children:c.jsx("div",{className:"flex h-full w-full flex-col bg-sidebar group-data-[variant=floating]:rounded-lg group-data-[variant=floating]:border group-data-[variant=floating]:border-sidebar-border group-data-[variant=floating]:shadow","data-sidebar":"sidebar",children:i})})]})});Fh.displayName="Sidebar";const xI=j.forwardRef(({className:e,onClick:t,...n},r)=>{const{toggleSidebar:i}=tc();return c.jsxs(Ee,{className:ve("h-7 w-7",e),"data-sidebar":"trigger",onClick:s=>{t==null||t(s),i()},ref:r,size:"icon",variant:"ghost",...n,children:[c.jsx(FH,{}),c.jsx("span",{className:"sr-only",children:"Toggle Sidebar"})]})});xI.displayName="SidebarTrigger";const hW=j.forwardRef(({className:e,...t},n)=>{const{toggleSidebar:r}=tc();return c.jsx("button",{"aria-label":"Toggle Sidebar",className:ve("absolute inset-y-0 z-20 hidden w-4 -translate-x-1/2 transition-all ease-linear after:absolute after:inset-y-0 after:left-1/2 after:w-[2px] hover:after:bg-sidebar-border group-data-[side=left]:-right-4 group-data-[side=right]:left-0 sm:flex","[[data-side=left]_&]:cursor-w-resize [[data-side=right]_&]:cursor-e-resize","[[data-side=left][data-state=collapsed]_&]:cursor-e-resize [[data-side=right][data-state=collapsed]_&]:cursor-w-resize","group-data-[collapsible=offcanvas]:translate-x-0 group-data-[collapsible=offcanvas]:hover:bg-sidebar group-data-[collapsible=offcanvas]:after:left-full","[[data-side=left][data-collapsible=offcanvas]_&]:-right-2","[[data-side=right][data-collapsible=offcanvas]_&]:-left-2",e),"data-sidebar":"rail",onClick:r,ref:n,tabIndex:-1,title:"Toggle Sidebar",...t})});hW.displayName="SidebarRail";const wI=j.forwardRef(({className:e,...t},n)=>c.jsx("main",{className:ve("relative flex w-full flex-1 flex-col bg-background","md:peer-data-[state=collapsed]:peer-data-[variant=inset]:ml-2 md:peer-data-[variant=inset]:m-2 md:peer-data-[variant=inset]:ml-0 md:peer-data-[variant=inset]:rounded-xl md:peer-data-[variant=inset]:shadow",e),ref:n,...t}));wI.displayName="SidebarInset";const SI=j.forwardRef(({className:e,...t},n)=>c.jsx(ec,{className:ve("h-8 w-full bg-background shadow-none focus-visible:ring-2 focus-visible:ring-sidebar-ring",e),"data-sidebar":"input",ref:n,...t}));SI.displayName="SidebarInput";const L1=j.forwardRef(({className:e,...t},n)=>c.jsx("div",{className:ve("flex flex-col gap-2 p-2",e),"data-sidebar":"header",ref:n,...t}));L1.displayName="SidebarHeader";const jI=j.forwardRef(({className:e,...t},n)=>c.jsx("div",{className:ve("flex flex-col gap-2 p-2",e),"data-sidebar":"footer",ref:n,...t}));jI.displayName="SidebarFooter";const mW=j.forwardRef(({className:e,...t},n)=>c.jsx(Bt,{className:ve("mx-2 w-auto bg-sidebar-border",e),"data-sidebar":"separator",ref:n,...t}));mW.displayName="SidebarSeparator";const I1=j.forwardRef(({className:e,...t},n)=>c.jsx("div",{className:ve("flex min-h-0 flex-1 flex-col gap-2 overflow-auto group-data-[collapsible=icon]:overflow-hidden",e),"data-sidebar":"content",ref:n,...t}));I1.displayName="SidebarContent";const z1=j.forwardRef(({className:e,...t},n)=>c.jsx("div",{className:ve("relative flex w-full min-w-0 flex-col p-2",e),"data-sidebar":"group",ref:n,...t}));z1.displayName="SidebarGroup";const pW=j.forwardRef(({className:e,asChild:t=!1,...n},r)=>{const i=t?es:"div";return c.jsx(i,{className:ve("flex h-8 shrink-0 items-center rounded-md px-2 font-medium text-sidebar-foreground/70 text-xs outline-none ring-sidebar-ring transition-[margin,opacity] duration-200 ease-linear focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0","group-data-[collapsible=icon]:-mt-8 group-data-[collapsible=icon]:opacity-0",e),"data-sidebar":"group-label",ref:r,...n})});pW.displayName="SidebarGroupLabel";const vW=j.forwardRef(({className:e,asChild:t=!1,...n},r)=>{const i=t?es:"button";return c.jsx(i,{className:ve("absolute top-3.5 right-3 flex aspect-square w-5 items-center justify-center rounded-md p-0 text-sidebar-foreground outline-none ring-sidebar-ring transition-transform hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0","after:absolute after:-inset-2 after:md:hidden","group-data-[collapsible=icon]:hidden",e),"data-sidebar":"group-action",ref:r,...n})});vW.displayName="SidebarGroupAction";const B1=j.forwardRef(({className:e,...t},n)=>c.jsx("div",{className:ve("w-full text-sm",e),"data-sidebar":"group-content",ref:n,...t}));B1.displayName="SidebarGroupContent";const im=j.forwardRef(({className:e,...t},n)=>c.jsx("ul",{className:ve("flex w-full min-w-0 flex-col gap-1",e),"data-sidebar":"menu",ref:n,...t}));im.displayName="SidebarMenu";const om=j.forwardRef(({className:e,...t},n)=>c.jsx("li",{className:ve("group/menu-item relative",e),"data-sidebar":"menu-item",ref:n,...t}));om.displayName="SidebarMenuItem";const gW=Lp("peer/menu-button group-data-[collapsible=icon]:!size-8 group-data-[collapsible=icon]:!p-2 flex w-full items-center gap-2 overflow-hidden rounded-md p-2 text-left text-sm outline-none ring-sidebar-ring transition-[width,height,padding] hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 active:bg-sidebar-accent active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 group-has-[[data-sidebar=menu-action]]/menu-item:pr-8 aria-disabled:pointer-events-none aria-disabled:opacity-50 data-[active=true]:bg-sidebar-accent data-[active=true]:font-medium data-[active=true]:text-sidebar-accent-foreground data-[state=open]:hover:bg-sidebar-accent data-[state=open]:hover:text-sidebar-accent-foreground [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0",{variants:{variant:{default:"hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",outline:"bg-background shadow-[0_0_0_1px_hsl(var(--sidebar-border))] hover:bg-sidebar-accent hover:text-sidebar-accent-foreground hover:shadow-[0_0_0_1px_hsl(var(--sidebar-accent))]"},size:{default:"h-8 text-sm",sm:"h-7 text-xs",lg:"group-data-[collapsible=icon]:!p-0 h-12 text-sm"}},defaultVariants:{variant:"default",size:"default"}}),sm=j.forwardRef(({asChild:e=!1,isActive:t=!1,variant:n="default",size:r="default",tooltip:i,className:s,...l},f)=>{const d=e?es:"button",{isMobile:h,state:v}=tc(),p=c.jsx(d,{className:ve(gW({variant:n,size:r}),s),"data-active":t,"data-sidebar":"menu-button","data-size":r,ref:f,...l});return i?(typeof i=="string"&&(i={children:i}),c.jsxs(Up,{children:[c.jsx(Hp,{asChild:!0,children:p}),c.jsx(Fp,{align:"center",hidden:v!=="collapsed"||h,side:"right",...i})]})):p});sm.displayName="SidebarMenuButton";const yW=j.forwardRef(({className:e,asChild:t=!1,showOnHover:n=!1,...r},i)=>{const s=t?es:"button";return c.jsx(s,{className:ve("absolute top-1.5 right-1 flex aspect-square w-5 items-center justify-center rounded-md p-0 text-sidebar-foreground outline-none ring-sidebar-ring transition-transform hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 peer-hover/menu-button:text-sidebar-accent-foreground [&>svg]:size-4 [&>svg]:shrink-0","after:absolute after:-inset-2 after:md:hidden","peer-data-[size=sm]/menu-button:top-1","peer-data-[size=default]/menu-button:top-1.5","peer-data-[size=lg]/menu-button:top-2.5","group-data-[collapsible=icon]:hidden",n&&"group-focus-within/menu-item:opacity-100 group-hover/menu-item:opacity-100 data-[state=open]:opacity-100 peer-data-[active=true]/menu-button:text-sidebar-accent-foreground md:opacity-0",e),"data-sidebar":"menu-action",ref:i,...r})});yW.displayName="SidebarMenuAction";const bW=j.forwardRef(({className:e,...t},n)=>c.jsx("div",{className:ve("pointer-events-none absolute right-1 flex h-5 min-w-5 select-none items-center justify-center rounded-md px-1 font-medium text-sidebar-foreground text-xs tabular-nums","peer-hover/menu-button:text-sidebar-accent-foreground peer-data-[active=true]/menu-button:text-sidebar-accent-foreground","peer-data-[size=sm]/menu-button:top-1","peer-data-[size=default]/menu-button:top-1.5","peer-data-[size=lg]/menu-button:top-2.5","group-data-[collapsible=icon]:hidden",e),"data-sidebar":"menu-badge",ref:n,...t}));bW.displayName="SidebarMenuBadge";const xW=j.forwardRef(({className:e,showIcon:t=!1,...n},r)=>{const i=j.useMemo(()=>`${Math.floor(Math.random()*40)+50}%`,[]);return c.jsxs("div",{className:ve("flex h-8 items-center gap-2 rounded-md px-2",e),"data-sidebar":"menu-skeleton",ref:r,...n,children:[t&&c.jsx(Re,{className:"size-4 rounded-md","data-sidebar":"menu-skeleton-icon"}),c.jsx(Re,{className:"h-4 max-w-[--skeleton-width] flex-1","data-sidebar":"menu-skeleton-text",style:{"--skeleton-width":i}})]})});xW.displayName="SidebarMenuSkeleton";const wW=j.forwardRef(({className:e,...t},n)=>c.jsx("ul",{className:ve("mx-3.5 flex min-w-0 translate-x-px flex-col gap-1 border-sidebar-border border-l px-2.5 py-0.5","group-data-[collapsible=icon]:hidden",e),"data-sidebar":"menu-sub",ref:n,...t}));wW.displayName="SidebarMenuSub";const SW=j.forwardRef(({...e},t)=>c.jsx("li",{ref:t,...e}));SW.displayName="SidebarMenuSubItem";const jW=j.forwardRef(({asChild:e=!1,size:t="md",isActive:n,className:r,...i},s)=>{const l=e?es:"a";return c.jsx(l,{className:ve("flex h-7 min-w-0 -translate-x-px items-center gap-2 overflow-hidden rounded-md px-2 text-sidebar-foreground outline-none ring-sidebar-ring hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 active:bg-sidebar-accent active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0 [&>svg]:text-sidebar-accent-foreground","data-[active=true]:bg-sidebar-accent data-[active=true]:text-sidebar-accent-foreground",t==="sm"&&"text-xs",t==="md"&&"text-sm","group-data-[collapsible=icon]:hidden",r),"data-active":n,"data-sidebar":"menu-sub-button","data-size":t,ref:s,...i})});jW.displayName="SidebarMenuSubButton";const OW={theme:"system",setTheme:()=>null},OI=j.createContext(OW),EI=()=>{const e=j.useContext(OI);if(e===void 0)throw new Error("useTheme must be used within a ThemeProvider");return e};function EW({user:e}){const{isMobile:t}=tc(),{theme:n,setTheme:r}=EI(),[i,s]=j.useState(null),[l,f]=j.useState(0);j.useEffect(()=>{(async()=>{try{const g=sessionStorage.getItem("wraps-auth-token");if(!g){console.log("No auth token found yet, will retry..."),l<5&&setTimeout(()=>{f(O=>O+1)},200);return}console.log("Fetching user info from /api/user");const b=await fetch(`/api/user?token=${g}`);if(console.log("User API response status:",b.status),b.ok){const O=await b.json();console.log("User info received:",O),s(O)}else{const O=await b.text();console.error("Failed to fetch user info:",b.status,O)}}catch(g){console.error("Error fetching user info:",g)}})().catch(g=>{console.error("Failed to fetch user info:",g)})},[l]);const d=()=>{window.confirm("Are you sure you want to close the console?")&&window.close()},h=(i==null?void 0:i.accountAlias)||(i==null?void 0:i.accountId)||"Loading...",v=(i==null?void 0:i.region)||"...";return c.jsx(im,{children:c.jsx(om,{children:c.jsxs(IL,{children:[c.jsx(zL,{asChild:!0,children:c.jsxs(sm,{className:"data-[state=open]:bg-sidebar-accent data-[state=open]:text-sidebar-accent-foreground md:h-8 md:p-0",size:"lg",children:[c.jsxs(Y2,{className:"h-8 w-8 rounded-lg",children:[c.jsx(W2,{alt:h,src:e.avatar}),c.jsx(K2,{className:"rounded-lg bg-orange-500 text-white",children:"AWS"})]}),c.jsxs("div",{className:"grid flex-1 text-left text-sm leading-tight",children:[c.jsx("span",{className:"truncate font-medium",children:h}),c.jsx("span",{className:"truncate text-xs",children:v})]}),c.jsx(PH,{className:"ml-auto size-4"})]})}),c.jsxs(BL,{align:"end",className:"w-(--radix-dropdown-menu-trigger-width) min-w-56 rounded-lg",side:t?"bottom":"right",sideOffset:4,children:[c.jsx(qL,{className:"p-0 font-normal",children:c.jsxs("div",{className:"flex items-center gap-2 px-1 py-1.5 text-left text-sm",children:[c.jsxs(Y2,{className:"h-8 w-8 rounded-lg",children:[c.jsx(W2,{alt:h,src:e.avatar}),c.jsx(K2,{className:"rounded-lg bg-orange-500 text-white",children:"AWS"})]}),c.jsxs("div",{className:"grid flex-1 text-left text-sm leading-tight",children:[c.jsx("span",{className:"truncate font-medium",children:h}),c.jsx("span",{className:"truncate text-xs",children:v}),(i==null?void 0:i.accountId)&&i.accountId!==i.accountAlias&&c.jsx("span",{className:"truncate font-mono text-[10px] text-muted-foreground",children:i.accountId})]})]})}),c.jsx(P1,{}),c.jsxs(xT,{onClick:()=>r(n==="dark"?"light":"dark"),children:[n==="dark"?c.jsx(VH,{}):c.jsx(UH,{}),n==="dark"?"Light Mode":"Dark Mode"]}),c.jsx(P1,{}),c.jsxs(xT,{onClick:d,children:[c.jsx(rr,{}),"Close Console"]})]})]})})})}const Li={user:{name:"Wraps Console",email:"admin@wraps.dev",avatar:"/avatars/wraps.jpg"},navMain:[{title:"Dashboard",url:"/",icon:jp,isActive:!0,isDashboard:!0},{title:"Email",url:"#",icon:dl,isActive:!1,subItems:[{title:"Emails",icon:dl,url:"/email"},{title:"Metrics",icon:tb,url:"/email/metrics"},{title:"Settings",icon:rb,url:"/email/settings"}]},{title:"SMS",url:"#",icon:Yi,isActive:!1,subItems:[{title:"Messages",icon:Yi,url:"/sms"},{title:"Metrics",icon:tb,url:"/sms/metrics"},{title:"Settings",icon:rb,url:"/sms/settings"}]},{title:"CDN",url:"#",icon:Tf,isActive:!1,subItems:[{title:"Library",icon:G4,url:"/cdn"},{title:"Metrics",icon:tb,url:"/cdn/metrics"},{title:"Settings",icon:rb,url:"/cdn/settings"}]}]};function _W({...e}){const t=ba(),n=Zo(),{setOpen:r,state:i}=tc(),{theme:s}=EI(),l=j.useCallback(()=>t.pathname==="/"?Li.navMain[0]:t.pathname.startsWith("/email")?Li.navMain[1]:t.pathname.startsWith("/sms")?Li.navMain[2]:t.pathname.startsWith("/cdn")?Li.navMain[3]:Li.navMain[0],[t.pathname]),[f,d]=j.useState(l());return j.useEffect(()=>{d(l())},[l]),c.jsxs(Fh,{className:"overflow-hidden *:data-[sidebar=sidebar]:flex-row",collapsible:"icon",...e,children:[c.jsxs(Fh,{className:"w-[calc(var(--sidebar-width-icon)+1px)]! border-r",collapsible:"none",children:[c.jsx(L1,{children:c.jsx(im,{children:c.jsx(om,{children:c.jsx(sm,{asChild:!0,className:"md:h-8 md:p-0",onClick:()=>{d(Li.navMain[0]),r(!1)},size:"lg",children:c.jsxs(Yh,{to:"/",children:[c.jsx("div",{className:"flex aspect-square size-8 items-center justify-center rounded-lg",children:c.jsx("img",{alt:"Wraps",className:"size-8 object-contain",src:s==="dark"?"/wraps-dark.png":"/wraps-light.png"})}),c.jsxs("div",{className:"grid flex-1 text-left text-sm leading-tight",children:[c.jsx("span",{className:"truncate font-semibold",children:"Wraps"}),c.jsx("span",{className:"truncate text-xs",children:"Console"})]})]})})})})}),c.jsx(I1,{children:c.jsx(z1,{children:c.jsx(B1,{className:"px-1.5 md:px-0",children:c.jsx(im,{children:Li.navMain.filter(h=>!h.isDashboard).map(h=>c.jsx(om,{children:c.jsxs(sm,{className:"px-2.5 md:px-2",isActive:(f==null?void 0:f.title)===h.title,onClick:()=>{d(h),r(!0),h.subItems&&h.subItems.length>0&&n(h.subItems[0].url)},tooltip:{children:h.title,hidden:!1},children:[c.jsx(h.icon,{}),c.jsx("span",{children:h.title})]})},h.title))})})})}),c.jsx(jI,{children:c.jsx(EW,{user:Li.user})})]}),i==="expanded"&&c.jsx(Fh,{className:"hidden flex-1 md:flex",collapsible:"none",children:f&&!f.isDashboard&&f.subItems?c.jsxs(c.Fragment,{children:[c.jsxs(L1,{className:"gap-3.5 border-b p-4",children:[c.jsx("div",{className:"flex w-full items-center justify-between",children:c.jsxs("div",{className:"flex items-center gap-2 font-medium text-base text-foreground",children:[c.jsx(f.icon,{className:"size-4"}),f.title]})}),c.jsx(SI,{placeholder:"Search..."})]}),c.jsx(I1,{children:c.jsx(z1,{className:"px-0",children:c.jsx(B1,{children:f.subItems.map(h=>{const v=t.pathname===h.url||h.url==="/email"&&t.pathname.startsWith("/email/")&&t.pathname!=="/email/metrics"&&t.pathname!=="/email/settings"||h.url==="/sms"&&t.pathname.startsWith("/sms/")&&t.pathname!=="/sms/metrics"&&t.pathname!=="/sms/settings"||h.url==="/cdn"&&t.pathname.startsWith("/cdn/")&&t.pathname!=="/cdn/metrics"&&t.pathname!=="/cdn/settings";return c.jsxs(Yh,{className:`flex items-center gap-3 border-b p-4 text-sm leading-tight transition-colors last:border-b-0 hover:bg-sidebar-accent hover:text-sidebar-accent-foreground ${v?"bg-sidebar-accent font-semibold text-sidebar-accent-foreground":""}`,to:h.url,children:[c.jsx(h.icon,{className:"size-4 shrink-0"}),c.jsx("span",{className:"font-medium",children:h.title})]},h.title)})})})})]}):c.jsx("div",{className:"flex h-full items-center justify-center p-8 text-center",children:c.jsxs("div",{className:"text-muted-foreground",children:[c.jsx(jp,{className:"mx-auto mb-4 size-12 opacity-50"}),c.jsx("p",{className:"text-sm",children:"Select a product to view options"})]})})})]})}const AW=Lp("inline-flex w-fit shrink-0 items-center justify-center gap-1 overflow-hidden whitespace-nowrap rounded-full border px-2 py-0.5 font-medium text-xs transition-[color,box-shadow] focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 [&>svg]:pointer-events-none [&>svg]:size-3",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground [a&]:hover:bg-primary/90",secondary:"border-transparent bg-secondary text-secondary-foreground [a&]:hover:bg-secondary/90",destructive:"border-transparent bg-destructive text-white focus-visible:ring-destructive/20 dark:bg-destructive/60 dark:focus-visible:ring-destructive/40 [a&]:hover:bg-destructive/90",outline:"text-foreground [a&]:hover:bg-accent [a&]:hover:text-accent-foreground"}},defaultVariants:{variant:"default"}});function He({className:e,variant:t,asChild:n=!1,...r}){const i=n?es:"span";return c.jsx(i,{className:ve(AW({variant:t}),e),"data-slot":"badge",...r})}function Ne({className:e,...t}){return c.jsx("div",{className:ve("flex flex-col gap-6 rounded-xl border bg-card py-6 text-card-foreground shadow-sm",e),"data-slot":"card",...t})}function De({className:e,...t}){return c.jsx("div",{className:ve("@container/card-header grid auto-rows-min grid-rows-[auto_auto] items-start gap-2 px-6 has-data-[slot=card-action]:grid-cols-[1fr_auto] [.border-b]:pb-6",e),"data-slot":"card-header",...t})}function Fe({className:e,...t}){return c.jsx("div",{className:ve("font-semibold leading-none",e),"data-slot":"card-title",...t})}function Ye({className:e,...t}){return c.jsx("div",{className:ve("text-muted-foreground text-sm",e),"data-slot":"card-description",...t})}function Le({className:e,...t}){return c.jsx("div",{className:ve("px-6",e),"data-slot":"card-content",...t})}const NW=Lp("relative grid w-full grid-cols-[0_1fr] items-start gap-y-0.5 rounded-lg border px-4 py-3 text-sm has-[>svg]:grid-cols-[1rem_1fr] has-[>svg]:gap-x-3 [&>svg]:size-4 [&>svg]:translate-y-0.5 [&>svg]:text-current",{variants:{variant:{default:"bg-card text-card-foreground",destructive:"bg-card text-destructive *:data-[slot=alert-description]:text-destructive/90 [&>svg]:text-current"}},defaultVariants:{variant:"default"}});function In({className:e,variant:t,...n}){return c.jsx("div",{className:ve(NW({variant:t}),e),"data-slot":"alert",role:"alert",...n})}function Xi({className:e,...t}){return c.jsx("div",{className:ve("col-start-2 line-clamp-1 min-h-4 font-medium tracking-tight",e),"data-slot":"alert-title",...t})}function zn({className:e,...t}){return c.jsx("div",{className:ve("col-start-2 grid justify-items-start gap-1 text-muted-foreground text-sm [&_p]:leading-relaxed",e),"data-slot":"alert-description",...t})}var Gp="Tabs",[TW]=qn(Gp,[Mp]),_I=Mp(),[CW,uO]=TW(Gp),AI=j.forwardRef((e,t)=>{const{__scopeTabs:n,value:r,onValueChange:i,defaultValue:s,orientation:l="horizontal",dir:f,activationMode:d="automatic",...h}=e,v=Df(f),[p,g]=Vr({prop:r,onChange:i,defaultProp:s??"",caller:Gp});return c.jsx(CW,{scope:n,baseId:_r(),value:p,onValueChange:g,orientation:l,dir:v,activationMode:d,children:c.jsx(Ce.div,{dir:v,"data-orientation":l,...h,ref:t})})});AI.displayName=Gp;var NI="TabsList",TI=j.forwardRef((e,t)=>{const{__scopeTabs:n,loop:r=!0,...i}=e,s=uO(NI,n),l=_I(n);return c.jsx(Y$,{asChild:!0,...l,orientation:s.orientation,dir:s.dir,loop:r,children:c.jsx(Ce.div,{role:"tablist","aria-orientation":s.orientation,...i,ref:t})})});TI.displayName=NI;var CI="TabsTrigger",MI=j.forwardRef((e,t)=>{const{__scopeTabs:n,value:r,disabled:i=!1,...s}=e,l=uO(CI,n),f=_I(n),d=PI(l.baseId,r),h=kI(l.baseId,r),v=r===l.value;return c.jsx(W$,{asChild:!0,...f,focusable:!i,active:v,children:c.jsx(Ce.button,{type:"button",role:"tab","aria-selected":v,"aria-controls":h,"data-state":v?"active":"inactive","data-disabled":i?"":void 0,disabled:i,id:d,...s,ref:t,onMouseDown:be(e.onMouseDown,p=>{!i&&p.button===0&&p.ctrlKey===!1?l.onValueChange(r):p.preventDefault()}),onKeyDown:be(e.onKeyDown,p=>{[" ","Enter"].includes(p.key)&&l.onValueChange(r)}),onFocus:be(e.onFocus,()=>{const p=l.activationMode!=="manual";!v&&!i&&p&&l.onValueChange(r)})})})});MI.displayName=CI;var RI="TabsContent",DI=j.forwardRef((e,t)=>{const{__scopeTabs:n,value:r,forceMount:i,children:s,...l}=e,f=uO(RI,n),d=PI(f.baseId,r),h=kI(f.baseId,r),v=r===f.value,p=j.useRef(v);return j.useEffect(()=>{const g=requestAnimationFrame(()=>p.current=!1);return()=>cancelAnimationFrame(g)},[]),c.jsx(lr,{present:i||v,children:({present:g})=>c.jsx(Ce.div,{"data-state":v?"active":"inactive","data-orientation":f.orientation,role:"tabpanel","aria-labelledby":d,hidden:!g,id:h,tabIndex:0,...l,ref:t,style:{...e.style,animationDuration:p.current?"0s":void 0},children:g&&s})})});DI.displayName=RI;function PI(e,t){return`${e}-trigger-${t}`}function kI(e,t){return`${e}-content-${t}`}var MW=AI,RW=TI,DW=MI,PW=DI;function $I({className:e,...t}){return c.jsx(MW,{className:ve("flex flex-col gap-2",e),"data-slot":"tabs",...t})}function LI({className:e,...t}){return c.jsx(RW,{className:ve("inline-flex h-9 w-fit items-center justify-center rounded-lg bg-muted p-[3px] text-muted-foreground",e),"data-slot":"tabs-list",...t})}function _u({className:e,...t}){return c.jsx(DW,{className:ve("inline-flex h-[calc(100%-1px)] flex-1 items-center justify-center gap-1.5 whitespace-nowrap rounded-md border border-transparent px-2 py-1 font-medium text-foreground text-sm transition-[color,box-shadow] focus-visible:border-ring focus-visible:outline-1 focus-visible:outline-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-background data-[state=active]:shadow-sm dark:text-muted-foreground dark:data-[state=active]:border-input dark:data-[state=active]:bg-input/30 dark:data-[state=active]:text-foreground [&_svg:not([class*='size-'])]:size-4 [&_svg]:pointer-events-none [&_svg]:shrink-0",e),"data-slot":"tabs-trigger",...t})}function Au({className:e,...t}){return c.jsx(PW,{className:ve("flex-1 outline-none",e),"data-slot":"tabs-content",...t})}function kW({messageId:e,archivingEnabled:t}){const[n,r]=j.useState(null),[i,s]=j.useState(!0),[l,f]=j.useState(null);return j.useEffect(()=>{async function d(){if(!t){s(!1);return}try{s(!0),f(null);const h=sessionStorage.getItem("wraps-auth-token");if(!h)throw new Error("Authentication token not found");const v=encodeURIComponent(e),p=await fetch(`/api/emails/${v}/archive?token=${h}`);if(!p.ok){if(p.status===404){r(null),s(!1);return}throw new Error(`Failed to fetch archived email: ${p.statusText}`)}const g=await p.json();r({...g,timestamp:new Date(g.timestamp)})}catch(h){const v=h instanceof Error?h.message:"Unknown error";f(v),console.error("Error fetching archived email:",h)}finally{s(!1)}}d()},[e,t]),t?i?c.jsxs(Ne,{children:[c.jsxs(De,{children:[c.jsx(Fe,{children:"Email Archive"}),c.jsx(Ye,{children:"Loading archived email content..."})]}),c.jsx(Le,{className:"space-y-4",children:c.jsx(Re,{className:"h-[400px] w-full"})})]}):l?c.jsxs(Ne,{children:[c.jsxs(De,{children:[c.jsx(Fe,{children:"Email Archive"}),c.jsx(Ye,{children:"Failed to load archived email"})]}),c.jsx(Le,{children:c.jsx(In,{variant:"destructive",children:c.jsx(zn,{children:l})})})]}):n?c.jsxs(Ne,{children:[c.jsx(De,{children:c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{children:[c.jsx(Fe,{children:"Email Archive"}),c.jsx(Ye,{children:"Full email content stored in AWS SES Mail Manager"})]}),n.attachments.length>0&&c.jsxs(He,{variant:"secondary",children:[n.attachments.length," attachment",n.attachments.length>1?"s":""]})]})}),c.jsxs(Le,{children:[c.jsxs($I,{className:"w-full",defaultValue:"rendered",children:[c.jsxs(LI,{className:"grid w-full grid-cols-3",children:[c.jsxs(_u,{className:"gap-2",value:"rendered",children:[c.jsx(ku,{className:"h-4 w-4"}),"Rendered Email"]}),c.jsxs(_u,{className:"gap-2",value:"text",children:[c.jsx(IH,{className:"h-4 w-4"}),"Plain Text"]}),c.jsxs(_u,{className:"gap-2",value:"html",children:[c.jsx(kH,{className:"h-4 w-4"}),"HTML Source"]})]}),c.jsxs(Au,{className:"space-y-4",value:"rendered",children:[n.html?c.jsx("div",{className:"rounded-md border",children:c.jsx("iframe",{className:"h-[600px] w-full rounded-md",sandbox:"allow-same-origin",srcDoc:n.html,title:"Email preview"})}):c.jsx(In,{children:c.jsx(zn,{children:"No HTML content available for this email. View the plain text tab instead."})}),n.attachments.length>0&&c.jsxs("div",{className:"space-y-2",children:[c.jsx("div",{className:"font-medium text-sm",children:"Attachments"}),c.jsx("div",{className:"space-y-2",children:n.attachments.map((d,h)=>c.jsx("div",{className:"flex items-center justify-between rounded-md border p-3",children:c.jsxs("div",{className:"space-y-1",children:[c.jsx("div",{className:"font-mono text-sm",children:d.filename||`Attachment ${h+1}`}),c.jsxs("div",{className:"text-muted-foreground text-xs",children:[d.contentType," •"," ",(d.size/1024).toFixed(2)," KB"]})]})},d.filename||`attachment-${h}`))})]})]}),c.jsx(Au,{className:"space-y-4",value:"text",children:n.text?c.jsx("div",{className:"rounded-md border bg-muted p-4",children:c.jsx("pre",{className:"whitespace-pre-wrap font-mono text-sm",children:n.text})}):c.jsx(In,{children:c.jsx(zn,{children:"No plain text content available for this email."})})}),c.jsx(Au,{className:"space-y-4",value:"html",children:n.html?c.jsx("div",{className:"rounded-md border bg-muted p-4",children:c.jsx("pre",{className:"overflow-x-auto whitespace-pre-wrap font-mono text-xs",children:n.html})}):c.jsx(In,{children:c.jsx(zn,{children:"No HTML content available for this email."})})})]}),n.metadata&&c.jsxs("div",{className:"mt-6 space-y-3 rounded-md border p-4",children:[c.jsx("div",{className:"font-medium text-sm",children:"SMTP Metadata"}),c.jsxs("div",{className:"grid gap-3 md:grid-cols-2",children:[n.metadata.senderIp&&c.jsxs("div",{className:"space-y-1",children:[c.jsx("div",{className:"text-muted-foreground text-xs",children:"Sender IP"}),c.jsx("div",{className:"font-mono text-sm",children:n.metadata.senderIp})]}),n.metadata.tlsProtocol&&c.jsxs("div",{className:"space-y-1",children:[c.jsx("div",{className:"text-muted-foreground text-xs",children:"TLS Protocol"}),c.jsx("div",{className:"font-mono text-sm",children:n.metadata.tlsProtocol})]}),n.metadata.senderHostname&&c.jsxs("div",{className:"space-y-1",children:[c.jsx("div",{className:"text-muted-foreground text-xs",children:"Sender Hostname"}),c.jsx("div",{className:"font-mono text-sm",children:n.metadata.senderHostname})]})]})]})]})]}):c.jsxs(Ne,{children:[c.jsxs(De,{children:[c.jsx(Fe,{children:"Email Archive"}),c.jsx(Ye,{children:"Email content not available"})]}),c.jsx(Le,{children:c.jsx(In,{children:c.jsx(zn,{children:"This email was not archived. It may have been sent before email archiving was enabled for this deployment."})})})]}):c.jsxs(Ne,{children:[c.jsxs(De,{children:[c.jsx(Fe,{children:"Email Archive"}),c.jsx(Ye,{children:"Enable email archiving to view full email content"})]}),c.jsx(Le,{children:c.jsx(In,{children:c.jsxs(zn,{children:["Email archiving is not enabled for this deployment. Run"," ",c.jsx("code",{className:"rounded bg-muted px-1.5 py-0.5 font-mono text-xs",children:"wraps upgrade"})," ","to enable archiving and view full email content with HTML rendering."]})})})]})}const $W={sent:dl,delivered:Vi,bounced:rr,complained:rr,opened:dl,clicked:dl,failed:rr},LW={sent:"text-blue-500",delivered:"text-green-500",bounced:"text-red-500",complained:"text-red-500",opened:"text-purple-500",clicked:"text-indigo-500",failed:"text-red-500"},IW={delivered:"default",sent:"secondary",bounced:"destructive",complained:"destructive",failed:"destructive",opened:"default",clicked:"default"};function zW(){const{id:e}=P4(),t=Zo(),[n,r]=j.useState(null),[i,s]=j.useState(!0),[l,f]=j.useState(null),[d,h]=j.useState(!1);j.useEffect(()=>{async function g(){var b,O,S;try{s(!0),f(null);const x=sessionStorage.getItem("wraps-auth-token");if(!x)throw new Error("Authentication token not found");try{const N=await fetch(`/api/settings/deployment?token=${x}`);if(N.ok){const M=await N.json();h(M.archivingEnabled??!1)}}catch(N){console.warn("Failed to fetch deployment config:",N)}const E=encodeURIComponent(e||"");console.log("Fetching email with ID:",e),console.log("Encoded ID:",E),console.log("Full URL:",`/api/emails/${E}?token=${x.substring(0,8)}...`);const A=await fetch(`/api/emails/${E}?token=${x}`);if(!A.ok){let N="Failed to fetch email details";try{N=(await A.json()).error||N}catch{N=`${A.status}: ${A.statusText}`}throw new Error(N)}const _=A.headers.get("content-type");if(!(_!=null&&_.includes("application/json"))){const N=await A.text();throw console.error("Non-JSON response:",N),new Error("Server returned non-JSON response")}const T=await A.json();console.log("Email data received:",{id:T.id,hasHtmlBody:!!T.htmlBody,hasTextBody:!!T.textBody,htmlBodyLength:((b=T.htmlBody)==null?void 0:b.length)||0,textBodyLength:((O=T.textBody)==null?void 0:O.length)||0,events:((S=T.events)==null?void 0:S.length)||0}),r(T)}catch(x){const E=x instanceof Error?x.message:"Unknown error";f(E),console.error("Error fetching email details:",x)}finally{s(!1)}}e&&g()},[e]);const v=g=>new Date(g).toLocaleString("en-US",{month:"short",day:"numeric",hour:"numeric",minute:"2-digit",hour12:!0}),p=g=>new Date(g).toLocaleString("en-US",{weekday:"short",month:"short",day:"numeric",year:"numeric",hour:"numeric",minute:"2-digit",second:"2-digit",hour12:!0});return i?c.jsx("div",{className:"flex h-[600px] items-center justify-center",children:c.jsx("div",{className:"text-muted-foreground",children:"Loading email details..."})}):l?c.jsxs("div",{className:"space-y-4",children:[c.jsxs(Ee,{onClick:()=>t("/email"),size:"sm",variant:"ghost",children:[c.jsx(fl,{className:"mr-2 h-4 w-4"}),"Back to emails"]}),c.jsx("div",{className:"rounded-md border border-destructive bg-destructive/10 p-4 text-destructive text-sm",children:l})]}):n?c.jsxs("div",{className:"space-y-6",children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs(Ee,{onClick:()=>t("/email"),size:"sm",variant:"ghost",children:[c.jsx(fl,{className:"mr-2 h-4 w-4"}),"Back to emails"]}),c.jsx(He,{variant:IW[n.status],children:n.status.charAt(0).toUpperCase()+n.status.slice(1)})]}),c.jsxs(Ne,{children:[c.jsx(De,{children:c.jsx("div",{className:"flex items-start justify-between",children:c.jsxs("div",{className:"space-y-1.5",children:[c.jsx(Fe,{className:"text-2xl",children:n.subject}),c.jsx(Ye,{className:"font-mono text-xs",children:n.messageId})]})})}),c.jsx(Le,{className:"space-y-4",children:c.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[c.jsxs("div",{className:"space-y-1",children:[c.jsx("div",{className:"text-muted-foreground text-sm",children:"FROM"}),c.jsx("div",{className:"font-mono text-sm",children:n.from})]}),c.jsxs("div",{className:"space-y-1",children:[c.jsx("div",{className:"text-muted-foreground text-sm",children:"TO"}),c.jsx("div",{className:"font-mono text-sm",children:n.to.length>0?n.to.join(", "):"(no recipients)"})]}),n.replyTo&&c.jsxs("div",{className:"space-y-1",children:[c.jsx("div",{className:"text-muted-foreground text-sm",children:"REPLY-TO"}),c.jsx("div",{className:"font-mono text-sm",children:n.replyTo})]}),c.jsxs("div",{className:"space-y-1",children:[c.jsx("div",{className:"text-muted-foreground text-sm",children:"ID"}),c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("code",{className:"rounded bg-muted px-2 py-1 font-mono text-xs",children:n.id}),c.jsxs(Ee,{className:"h-6 w-6",onClick:()=>navigator.clipboard.writeText(n.id),size:"icon",variant:"ghost",children:[c.jsx("span",{className:"sr-only",children:"Copy ID"}),"📋"]})]})]})]})})]}),d&&c.jsx(kW,{archivingEnabled:d,messageId:n.messageId}),c.jsxs(Ne,{children:[c.jsxs(De,{children:[c.jsx(Fe,{children:"Email Events"}),c.jsx(Ye,{children:"Lifecycle of this email from send to delivery"})]}),c.jsx(Le,{children:c.jsx("div",{className:"space-y-4",children:n.events.length===0?c.jsx("div",{className:"text-muted-foreground text-sm",children:"No events recorded yet"}):n.events.map((g,b)=>{const O=$W[g.type]||Uo,S=b===n.events.length-1;return c.jsx("div",{children:c.jsxs("div",{className:"flex gap-4",children:[c.jsxs("div",{className:"flex flex-col items-center",children:[c.jsx("div",{className:`rounded-full border-2 border-background bg-muted p-2 ${LW[g.type]}`,children:c.jsx(O,{className:"h-4 w-4"})}),!S&&c.jsx("div",{className:"my-1 w-px flex-1 bg-border"})]}),c.jsxs("div",{className:"flex-1 pb-6",children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx("div",{className:"font-medium capitalize",children:g.type}),c.jsx("div",{className:"text-muted-foreground text-sm",children:v(g.timestamp)})]}),c.jsx("div",{className:"text-muted-foreground text-sm",children:p(g.timestamp)}),g.metadata&&Object.keys(g.metadata).length>0&&c.jsx("div",{className:"mt-2 rounded-md border bg-muted/50 p-2 font-mono text-xs",children:c.jsx("pre",{className:"overflow-x-auto",children:JSON.stringify(g.metadata,null,2)})})]})]})},`${g.type}-${g.timestamp}`)})})})]})]}):c.jsxs("div",{className:"space-y-4",children:[c.jsxs(Ee,{onClick:()=>t("/email"),size:"sm",variant:"ghost",children:[c.jsx(fl,{className:"mr-2 h-4 w-4"}),"Back to emails"]}),c.jsx("div",{className:"rounded-md border p-4 text-muted-foreground text-sm",children:"Email not found"})]})}function lm(e,[t,n]){return Math.min(n,Math.max(t,e))}function Vp(e){const t=j.useRef({value:e,previous:e});return j.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}var BW=[" ","Enter","ArrowUp","ArrowDown"],qW=[" ","Enter"],Go="Select",[Yp,Wp,UW]=Op(Go),[nc]=qn(Go,[UW,Jl]),Kp=Jl(),[HW,Ji]=nc(Go),[FW,GW]=nc(Go),II=e=>{const{__scopeSelect:t,children:n,open:r,defaultOpen:i,onOpenChange:s,value:l,defaultValue:f,onValueChange:d,dir:h,name:v,autoComplete:p,disabled:g,required:b,form:O}=e,S=Kp(t),[x,E]=j.useState(null),[A,_]=j.useState(null),[T,N]=j.useState(!1),M=Df(h),[R,D]=Vr({prop:r,defaultProp:i??!1,onChange:s,caller:Go}),[L,Y]=Vr({prop:l,defaultProp:f,onChange:d,caller:Go}),I=j.useRef(null),H=x?O||!!x.closest("form"):!0,[W,Z]=j.useState(new Set),X=Array.from(W).map(k=>k.props.value).join(";");return c.jsx(Bj,{...S,children:c.jsxs(HW,{required:b,scope:t,trigger:x,onTriggerChange:E,valueNode:A,onValueNodeChange:_,valueNodeHasChildren:T,onValueNodeHasChildrenChange:N,contentId:_r(),value:L,onValueChange:Y,open:R,onOpenChange:D,dir:M,triggerPointerDownPosRef:I,disabled:g,children:[c.jsx(Yp.Provider,{scope:t,children:c.jsx(FW,{scope:e.__scopeSelect,onNativeOptionAdd:j.useCallback(k=>{Z(U=>new Set(U).add(k))},[]),onNativeOptionRemove:j.useCallback(k=>{Z(U=>{const q=new Set(U);return q.delete(k),q})},[]),children:n})}),H?c.jsxs(o3,{"aria-hidden":!0,required:b,tabIndex:-1,name:v,autoComplete:p,value:L,onChange:k=>Y(k.target.value),disabled:g,form:O,children:[L===void 0?c.jsx("option",{value:""}):null,Array.from(W)]},X):null]})})};II.displayName=Go;var zI="SelectTrigger",BI=j.forwardRef((e,t)=>{const{__scopeSelect:n,disabled:r=!1,...i}=e,s=Kp(n),l=Ji(zI,n),f=l.disabled||r,d=Be(t,l.onTriggerChange),h=Wp(n),v=j.useRef("touch"),[p,g,b]=l3(S=>{const x=h().filter(_=>!_.disabled),E=x.find(_=>_.value===l.value),A=c3(x,S,E);A!==void 0&&l.onValueChange(A.value)}),O=S=>{f||(l.onOpenChange(!0),b()),S&&(l.triggerPointerDownPosRef.current={x:Math.round(S.pageX),y:Math.round(S.pageY)})};return c.jsx(qj,{asChild:!0,...s,children:c.jsx(Ce.button,{type:"button",role:"combobox","aria-controls":l.contentId,"aria-expanded":l.open,"aria-required":l.required,"aria-autocomplete":"none",dir:l.dir,"data-state":l.open?"open":"closed",disabled:f,"data-disabled":f?"":void 0,"data-placeholder":s3(l.value)?"":void 0,...i,ref:d,onClick:be(i.onClick,S=>{S.currentTarget.focus(),v.current!=="mouse"&&O(S)}),onPointerDown:be(i.onPointerDown,S=>{v.current=S.pointerType;const x=S.target;x.hasPointerCapture(S.pointerId)&&x.releasePointerCapture(S.pointerId),S.button===0&&S.ctrlKey===!1&&S.pointerType==="mouse"&&(O(S),S.preventDefault())}),onKeyDown:be(i.onKeyDown,S=>{const x=p.current!=="";!(S.ctrlKey||S.altKey||S.metaKey)&&S.key.length===1&&g(S.key),!(x&&S.key===" ")&&BW.includes(S.key)&&(O(),S.preventDefault())})})})});BI.displayName=zI;var qI="SelectValue",UI=j.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:i,children:s,placeholder:l="",...f}=e,d=Ji(qI,n),{onValueNodeHasChildrenChange:h}=d,v=s!==void 0,p=Be(t,d.onValueNodeChange);return Yt(()=>{h(v)},[h,v]),c.jsx(Ce.span,{...f,ref:p,style:{pointerEvents:"none"},children:s3(d.value)?c.jsx(c.Fragment,{children:l}):s})});UI.displayName=qI;var VW="SelectIcon",HI=j.forwardRef((e,t)=>{const{__scopeSelect:n,children:r,...i}=e;return c.jsx(Ce.span,{"aria-hidden":!0,...i,ref:t,children:r||"▼"})});HI.displayName=VW;var YW="SelectPortal",FI=e=>c.jsx($f,{asChild:!0,...e});FI.displayName=YW;var Vo="SelectContent",GI=j.forwardRef((e,t)=>{const n=Ji(Vo,e.__scopeSelect),[r,i]=j.useState();if(Yt(()=>{i(new DocumentFragment)},[]),!n.open){const s=r;return s?Af.createPortal(c.jsx(VI,{scope:e.__scopeSelect,children:c.jsx(Yp.Slot,{scope:e.__scopeSelect,children:c.jsx("div",{children:e.children})})}),s):null}return c.jsx(YI,{...e,ref:t})});GI.displayName=Vo;var zr=10,[VI,eo]=nc(Vo),WW="SelectContentImpl",KW=xl("SelectContent.RemoveScroll"),YI=j.forwardRef((e,t)=>{const{__scopeSelect:n,position:r="item-aligned",onCloseAutoFocus:i,onEscapeKeyDown:s,onPointerDownOutside:l,side:f,sideOffset:d,align:h,alignOffset:v,arrowPadding:p,collisionBoundary:g,collisionPadding:b,sticky:O,hideWhenDetached:S,avoidCollisions:x,...E}=e,A=Ji(Vo,n),[_,T]=j.useState(null),[N,M]=j.useState(null),R=Be(t,oe=>T(oe)),[D,L]=j.useState(null),[Y,I]=j.useState(null),H=Wp(n),[W,Z]=j.useState(!1),X=j.useRef(!1);j.useEffect(()=>{if(_)return Fj(_)},[_]),Mj();const k=j.useCallback(oe=>{const[me,...ae]=H().map(ie=>ie.ref.current),[pe]=ae.slice(-1),ge=document.activeElement;for(const ie of oe)if(ie===ge||(ie==null||ie.scrollIntoView({block:"nearest"}),ie===me&&N&&(N.scrollTop=0),ie===pe&&N&&(N.scrollTop=N.scrollHeight),ie==null||ie.focus(),document.activeElement!==ge))return},[H,N]),U=j.useCallback(()=>k([D,_]),[k,D,_]);j.useEffect(()=>{W&&U()},[W,U]);const{onOpenChange:q,triggerPointerDownPosRef:Q}=A;j.useEffect(()=>{if(_){let oe={x:0,y:0};const me=pe=>{var ge,ie;oe={x:Math.abs(Math.round(pe.pageX)-(((ge=Q.current)==null?void 0:ge.x)??0)),y:Math.abs(Math.round(pe.pageY)-(((ie=Q.current)==null?void 0:ie.y)??0))}},ae=pe=>{oe.x<=10&&oe.y<=10?pe.preventDefault():_.contains(pe.target)||q(!1),document.removeEventListener("pointermove",me),Q.current=null};return Q.current!==null&&(document.addEventListener("pointermove",me),document.addEventListener("pointerup",ae,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",me),document.removeEventListener("pointerup",ae,{capture:!0})}}},[_,q,Q]),j.useEffect(()=>{const oe=()=>q(!1);return window.addEventListener("blur",oe),window.addEventListener("resize",oe),()=>{window.removeEventListener("blur",oe),window.removeEventListener("resize",oe)}},[q]);const[le,$]=l3(oe=>{const me=H().filter(ge=>!ge.disabled),ae=me.find(ge=>ge.ref.current===document.activeElement),pe=c3(me,oe,ae);pe&&setTimeout(()=>pe.ref.current.focus())}),B=j.useCallback((oe,me,ae)=>{const pe=!X.current&&!ae;(A.value!==void 0&&A.value===me||pe)&&(L(oe),pe&&(X.current=!0))},[A.value]),V=j.useCallback(()=>_==null?void 0:_.focus(),[_]),F=j.useCallback((oe,me,ae)=>{const pe=!X.current&&!ae;(A.value!==void 0&&A.value===me||pe)&&I(oe)},[A.value]),ne=r==="popper"?q1:WI,fe=ne===q1?{side:f,sideOffset:d,align:h,alignOffset:v,arrowPadding:p,collisionBoundary:g,collisionPadding:b,sticky:O,hideWhenDetached:S,avoidCollisions:x}:{};return c.jsx(VI,{scope:n,content:_,viewport:N,onViewportChange:M,itemRefCallback:B,selectedItem:D,onItemLeave:V,itemTextRefCallback:F,focusSelectedItem:U,selectedItemText:Y,position:r,isPositioned:W,searchRef:le,children:c.jsx(Dp,{as:KW,allowPinchZoom:!0,children:c.jsx(Ep,{asChild:!0,trapped:A.open,onMountAutoFocus:oe=>{oe.preventDefault()},onUnmountAutoFocus:be(i,oe=>{var me;(me=A.trigger)==null||me.focus({preventScroll:!0}),oe.preventDefault()}),children:c.jsx(Pf,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:s,onPointerDownOutside:l,onFocusOutside:oe=>oe.preventDefault(),onDismiss:()=>A.onOpenChange(!1),children:c.jsx(ne,{role:"listbox",id:A.contentId,"data-state":A.open?"open":"closed",dir:A.dir,onContextMenu:oe=>oe.preventDefault(),...E,...fe,onPlaced:()=>Z(!0),ref:R,style:{display:"flex",flexDirection:"column",outline:"none",...E.style},onKeyDown:be(E.onKeyDown,oe=>{const me=oe.ctrlKey||oe.altKey||oe.metaKey;if(oe.key==="Tab"&&oe.preventDefault(),!me&&oe.key.length===1&&$(oe.key),["ArrowUp","ArrowDown","Home","End"].includes(oe.key)){let pe=H().filter(ge=>!ge.disabled).map(ge=>ge.ref.current);if(["ArrowUp","End"].includes(oe.key)&&(pe=pe.slice().reverse()),["ArrowUp","ArrowDown"].includes(oe.key)){const ge=oe.target,ie=pe.indexOf(ge);pe=pe.slice(ie+1)}setTimeout(()=>k(pe)),oe.preventDefault()}})})})})})})});YI.displayName=WW;var XW="SelectItemAlignedPosition",WI=j.forwardRef((e,t)=>{const{__scopeSelect:n,onPlaced:r,...i}=e,s=Ji(Vo,n),l=eo(Vo,n),[f,d]=j.useState(null),[h,v]=j.useState(null),p=Be(t,R=>v(R)),g=Wp(n),b=j.useRef(!1),O=j.useRef(!0),{viewport:S,selectedItem:x,selectedItemText:E,focusSelectedItem:A}=l,_=j.useCallback(()=>{if(s.trigger&&s.valueNode&&f&&h&&S&&x&&E){const R=s.trigger.getBoundingClientRect(),D=h.getBoundingClientRect(),L=s.valueNode.getBoundingClientRect(),Y=E.getBoundingClientRect();if(s.dir!=="rtl"){const ge=Y.left-D.left,ie=L.left-ge,Pe=R.left-ie,xe=R.width+Pe,Je=Math.max(xe,D.width),rt=window.innerWidth-zr,lt=lm(ie,[zr,Math.max(zr,rt-Je)]);f.style.minWidth=xe+"px",f.style.left=lt+"px"}else{const ge=D.right-Y.right,ie=window.innerWidth-L.right-ge,Pe=window.innerWidth-R.right-ie,xe=R.width+Pe,Je=Math.max(xe,D.width),rt=window.innerWidth-zr,lt=lm(ie,[zr,Math.max(zr,rt-Je)]);f.style.minWidth=xe+"px",f.style.right=lt+"px"}const I=g(),H=window.innerHeight-zr*2,W=S.scrollHeight,Z=window.getComputedStyle(h),X=parseInt(Z.borderTopWidth,10),k=parseInt(Z.paddingTop,10),U=parseInt(Z.borderBottomWidth,10),q=parseInt(Z.paddingBottom,10),Q=X+k+W+q+U,le=Math.min(x.offsetHeight*5,Q),$=window.getComputedStyle(S),B=parseInt($.paddingTop,10),V=parseInt($.paddingBottom,10),F=R.top+R.height/2-zr,ne=H-F,fe=x.offsetHeight/2,oe=x.offsetTop+fe,me=X+k+oe,ae=Q-me;if(me<=F){const ge=I.length>0&&x===I[I.length-1].ref.current;f.style.bottom="0px";const ie=h.clientHeight-S.offsetTop-S.offsetHeight,Pe=Math.max(ne,fe+(ge?V:0)+ie+U),xe=me+Pe;f.style.height=xe+"px"}else{const ge=I.length>0&&x===I[0].ref.current;f.style.top="0px";const Pe=Math.max(F,X+S.offsetTop+(ge?B:0)+fe)+ae;f.style.height=Pe+"px",S.scrollTop=me-F+S.offsetTop}f.style.margin=`${zr}px 0`,f.style.minHeight=le+"px",f.style.maxHeight=H+"px",r==null||r(),requestAnimationFrame(()=>b.current=!0)}},[g,s.trigger,s.valueNode,f,h,S,x,E,s.dir,r]);Yt(()=>_(),[_]);const[T,N]=j.useState();Yt(()=>{h&&N(window.getComputedStyle(h).zIndex)},[h]);const M=j.useCallback(R=>{R&&O.current===!0&&(_(),A==null||A(),O.current=!1)},[_,A]);return c.jsx(ZW,{scope:n,contentWrapper:f,shouldExpandOnScrollRef:b,onScrollButtonChange:M,children:c.jsx("div",{ref:d,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:T},children:c.jsx(Ce.div,{...i,ref:p,style:{boxSizing:"border-box",maxHeight:"100%",...i.style}})})})});WI.displayName=XW;var QW="SelectPopperPosition",q1=j.forwardRef((e,t)=>{const{__scopeSelect:n,align:r="start",collisionPadding:i=zr,...s}=e,l=Kp(n);return c.jsx(Uj,{...l,...s,ref:t,align:r,collisionPadding:i,style:{boxSizing:"border-box",...s.style,"--radix-select-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-select-content-available-width":"var(--radix-popper-available-width)","--radix-select-content-available-height":"var(--radix-popper-available-height)","--radix-select-trigger-width":"var(--radix-popper-anchor-width)","--radix-select-trigger-height":"var(--radix-popper-anchor-height)"}})});q1.displayName=QW;var[ZW,fO]=nc(Vo,{}),U1="SelectViewport",KI=j.forwardRef((e,t)=>{const{__scopeSelect:n,nonce:r,...i}=e,s=eo(U1,n),l=fO(U1,n),f=Be(t,s.onViewportChange),d=j.useRef(0);return c.jsxs(c.Fragment,{children:[c.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"},nonce:r}),c.jsx(Yp.Slot,{scope:n,children:c.jsx(Ce.div,{"data-radix-select-viewport":"",role:"presentation",...i,ref:f,style:{position:"relative",flex:1,overflow:"hidden auto",...i.style},onScroll:be(i.onScroll,h=>{const v=h.currentTarget,{contentWrapper:p,shouldExpandOnScrollRef:g}=l;if(g!=null&&g.current&&p){const b=Math.abs(d.current-v.scrollTop);if(b>0){const O=window.innerHeight-zr*2,S=parseFloat(p.style.minHeight),x=parseFloat(p.style.height),E=Math.max(S,x);if(E<O){const A=E+b,_=Math.min(O,A),T=A-_;p.style.height=_+"px",p.style.bottom==="0px"&&(v.scrollTop=T>0?T:0,p.style.justifyContent="flex-end")}}}d.current=v.scrollTop})})})]})});KI.displayName=U1;var XI="SelectGroup",[JW,eK]=nc(XI),tK=j.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,i=_r();return c.jsx(JW,{scope:n,id:i,children:c.jsx(Ce.div,{role:"group","aria-labelledby":i,...r,ref:t})})});tK.displayName=XI;var QI="SelectLabel",nK=j.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,i=eK(QI,n);return c.jsx(Ce.div,{id:i.id,...r,ref:t})});nK.displayName=QI;var cm="SelectItem",[rK,ZI]=nc(cm),JI=j.forwardRef((e,t)=>{const{__scopeSelect:n,value:r,disabled:i=!1,textValue:s,...l}=e,f=Ji(cm,n),d=eo(cm,n),h=f.value===r,[v,p]=j.useState(s??""),[g,b]=j.useState(!1),O=Be(t,A=>{var _;return(_=d.itemRefCallback)==null?void 0:_.call(d,A,r,i)}),S=_r(),x=j.useRef("touch"),E=()=>{i||(f.onValueChange(r),f.onOpenChange(!1))};if(r==="")throw new Error("A <Select.Item /> must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder.");return c.jsx(rK,{scope:n,value:r,disabled:i,textId:S,isSelected:h,onItemTextChange:j.useCallback(A=>{p(_=>_||((A==null?void 0:A.textContent)??"").trim())},[]),children:c.jsx(Yp.ItemSlot,{scope:n,value:r,disabled:i,textValue:v,children:c.jsx(Ce.div,{role:"option","aria-labelledby":S,"data-highlighted":g?"":void 0,"aria-selected":h&&g,"data-state":h?"checked":"unchecked","aria-disabled":i||void 0,"data-disabled":i?"":void 0,tabIndex:i?void 0:-1,...l,ref:O,onFocus:be(l.onFocus,()=>b(!0)),onBlur:be(l.onBlur,()=>b(!1)),onClick:be(l.onClick,()=>{x.current!=="mouse"&&E()}),onPointerUp:be(l.onPointerUp,()=>{x.current==="mouse"&&E()}),onPointerDown:be(l.onPointerDown,A=>{x.current=A.pointerType}),onPointerMove:be(l.onPointerMove,A=>{var _;x.current=A.pointerType,i?(_=d.onItemLeave)==null||_.call(d):x.current==="mouse"&&A.currentTarget.focus({preventScroll:!0})}),onPointerLeave:be(l.onPointerLeave,A=>{var _;A.currentTarget===document.activeElement&&((_=d.onItemLeave)==null||_.call(d))}),onKeyDown:be(l.onKeyDown,A=>{var T;((T=d.searchRef)==null?void 0:T.current)!==""&&A.key===" "||(qW.includes(A.key)&&E(),A.key===" "&&A.preventDefault())})})})})});JI.displayName=cm;var Su="SelectItemText",e3=j.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:i,...s}=e,l=Ji(Su,n),f=eo(Su,n),d=ZI(Su,n),h=GW(Su,n),[v,p]=j.useState(null),g=Be(t,E=>p(E),d.onItemTextChange,E=>{var A;return(A=f.itemTextRefCallback)==null?void 0:A.call(f,E,d.value,d.disabled)}),b=v==null?void 0:v.textContent,O=j.useMemo(()=>c.jsx("option",{value:d.value,disabled:d.disabled,children:b},d.value),[d.disabled,d.value,b]),{onNativeOptionAdd:S,onNativeOptionRemove:x}=h;return Yt(()=>(S(O),()=>x(O)),[S,x,O]),c.jsxs(c.Fragment,{children:[c.jsx(Ce.span,{id:d.textId,...s,ref:g}),d.isSelected&&l.valueNode&&!l.valueNodeHasChildren?Af.createPortal(s.children,l.valueNode):null]})});e3.displayName=Su;var t3="SelectItemIndicator",n3=j.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return ZI(t3,n).isSelected?c.jsx(Ce.span,{"aria-hidden":!0,...r,ref:t}):null});n3.displayName=t3;var H1="SelectScrollUpButton",r3=j.forwardRef((e,t)=>{const n=eo(H1,e.__scopeSelect),r=fO(H1,e.__scopeSelect),[i,s]=j.useState(!1),l=Be(t,r.onScrollButtonChange);return Yt(()=>{if(n.viewport&&n.isPositioned){let f=function(){const h=d.scrollTop>0;s(h)};const d=n.viewport;return f(),d.addEventListener("scroll",f),()=>d.removeEventListener("scroll",f)}},[n.viewport,n.isPositioned]),i?c.jsx(i3,{...e,ref:l,onAutoScroll:()=>{const{viewport:f,selectedItem:d}=n;f&&d&&(f.scrollTop=f.scrollTop-d.offsetHeight)}}):null});r3.displayName=H1;var F1="SelectScrollDownButton",a3=j.forwardRef((e,t)=>{const n=eo(F1,e.__scopeSelect),r=fO(F1,e.__scopeSelect),[i,s]=j.useState(!1),l=Be(t,r.onScrollButtonChange);return Yt(()=>{if(n.viewport&&n.isPositioned){let f=function(){const h=d.scrollHeight-d.clientHeight,v=Math.ceil(d.scrollTop)<h;s(v)};const d=n.viewport;return f(),d.addEventListener("scroll",f),()=>d.removeEventListener("scroll",f)}},[n.viewport,n.isPositioned]),i?c.jsx(i3,{...e,ref:l,onAutoScroll:()=>{const{viewport:f,selectedItem:d}=n;f&&d&&(f.scrollTop=f.scrollTop+d.offsetHeight)}}):null});a3.displayName=F1;var i3=j.forwardRef((e,t)=>{const{__scopeSelect:n,onAutoScroll:r,...i}=e,s=eo("SelectScrollButton",n),l=j.useRef(null),f=Wp(n),d=j.useCallback(()=>{l.current!==null&&(window.clearInterval(l.current),l.current=null)},[]);return j.useEffect(()=>()=>d(),[d]),Yt(()=>{var v;const h=f().find(p=>p.ref.current===document.activeElement);(v=h==null?void 0:h.ref.current)==null||v.scrollIntoView({block:"nearest"})},[f]),c.jsx(Ce.div,{"aria-hidden":!0,...i,ref:t,style:{flexShrink:0,...i.style},onPointerDown:be(i.onPointerDown,()=>{l.current===null&&(l.current=window.setInterval(r,50))}),onPointerMove:be(i.onPointerMove,()=>{var h;(h=s.onItemLeave)==null||h.call(s),l.current===null&&(l.current=window.setInterval(r,50))}),onPointerLeave:be(i.onPointerLeave,()=>{d()})})}),aK="SelectSeparator",iK=j.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return c.jsx(Ce.div,{"aria-hidden":!0,...r,ref:t})});iK.displayName=aK;var G1="SelectArrow",oK=j.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,i=Kp(n),s=Ji(G1,n),l=eo(G1,n);return s.open&&l.position==="popper"?c.jsx(Hj,{...i,...r,ref:t}):null});oK.displayName=G1;var sK="SelectBubbleInput",o3=j.forwardRef(({__scopeSelect:e,value:t,...n},r)=>{const i=j.useRef(null),s=Be(r,i),l=Vp(t);return j.useEffect(()=>{const f=i.current;if(!f)return;const d=window.HTMLSelectElement.prototype,v=Object.getOwnPropertyDescriptor(d,"value").set;if(l!==t&&v){const p=new Event("change",{bubbles:!0});v.call(f,t),f.dispatchEvent(p)}},[l,t]),c.jsx(Ce.select,{...n,style:{...oI,...n.style},ref:s,defaultValue:t})});o3.displayName=sK;function s3(e){return e===""||e===void 0}function l3(e){const t=Gr(e),n=j.useRef(""),r=j.useRef(0),i=j.useCallback(l=>{const f=n.current+l;t(f),(function d(h){n.current=h,window.clearTimeout(r.current),h!==""&&(r.current=window.setTimeout(()=>d(""),1e3))})(f)},[t]),s=j.useCallback(()=>{n.current="",window.clearTimeout(r.current)},[]);return j.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,i,s]}function c3(e,t,n){const i=t.length>1&&Array.from(t).every(h=>h===t[0])?t[0]:t,s=n?e.indexOf(n):-1;let l=lK(e,Math.max(s,0));i.length===1&&(l=l.filter(h=>h!==n));const d=l.find(h=>h.textValue.toLowerCase().startsWith(i.toLowerCase()));return d!==n?d:void 0}function lK(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var cK=II,uK=BI,fK=UI,dK=HI,hK=FI,mK=GI,pK=KI,vK=JI,gK=e3,yK=n3,bK=r3,xK=a3;function fa({...e}){return c.jsx(cK,{"data-slot":"select",...e})}function da({...e}){return c.jsx(fK,{"data-slot":"select-value",...e})}function ha({className:e,size:t="default",children:n,...r}){return c.jsxs(uK,{className:ve("flex w-fit items-center justify-between gap-2 whitespace-nowrap rounded-md border border-input bg-transparent px-3 py-2 text-sm shadow-xs outline-none transition-[color,box-shadow] focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 data-[size=default]:h-9 data-[size=sm]:h-8 data-[placeholder]:text-muted-foreground *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-2 dark:bg-input/30 dark:aria-invalid:ring-destructive/40 dark:hover:bg-input/50 [&_svg:not([class*='size-'])]:size-4 [&_svg:not([class*='text-'])]:text-muted-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0",e),"data-size":t,"data-slot":"select-trigger",...r,children:[n,c.jsx(dK,{asChild:!0,children:c.jsx(Jo,{className:"size-4 opacity-50"})})]})}function ma({className:e,children:t,position:n="popper",align:r="center",...i}){return c.jsx(hK,{children:c.jsxs(mK,{align:r,className:ve("data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 relative z-50 max-h-[--radix-select-content-available-height] min-w-[8rem] origin-[--radix-select-content-transform-origin] overflow-y-auto overflow-x-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=closed]:animate-out data-[state=open]:animate-in",n==="popper"&&"data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=bottom]:translate-y-1 data-[side=top]:-translate-y-1",e),"data-slot":"select-content",position:n,...i,children:[c.jsx(wK,{}),c.jsx(pK,{className:ve("p-1",n==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)] scroll-my-1"),children:t}),c.jsx(SK,{})]})})}function Ue({className:e,children:t,...n}){return c.jsxs(vK,{className:ve("relative flex w-full cursor-default select-none items-center gap-2 rounded-sm py-1.5 pr-8 pl-2 text-sm outline-hidden focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg:not([class*='size-'])]:size-4 [&_svg:not([class*='text-'])]:text-muted-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2",e),"data-slot":"select-item",...n,children:[c.jsx("span",{className:"absolute right-2 flex size-3.5 items-center justify-center",children:c.jsx(yK,{children:c.jsx(Vi,{className:"size-4"})})}),c.jsx(gK,{children:t})]})}function wK({className:e,...t}){return c.jsx(bK,{className:ve("flex cursor-default items-center justify-center py-1",e),"data-slot":"select-scroll-up-button",...t,children:c.jsx(Nf,{className:"size-4"})})}function SK({className:e,...t}){return c.jsx(xK,{className:ve("flex cursor-default items-center justify-center py-1",e),"data-slot":"select-scroll-down-button",...t,children:c.jsx(Jo,{className:"size-4"})})}function dO({className:e,...t}){return c.jsx("div",{className:"relative w-full overflow-x-auto","data-slot":"table-container",children:c.jsx("table",{className:ve("w-full caption-bottom text-sm",e),"data-slot":"table",...t})})}function hO({className:e,...t}){return c.jsx("thead",{className:ve("[&_tr]:border-b",e),"data-slot":"table-header",...t})}function mO({className:e,...t}){return c.jsx("tbody",{className:ve("[&_tr:last-child]:border-0",e),"data-slot":"table-body",...t})}function la({className:e,...t}){return c.jsx("tr",{className:ve("border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted",e),"data-slot":"table-row",...t})}function pn({className:e,...t}){return c.jsx("th",{className:ve("h-10 whitespace-nowrap px-2 text-left align-middle font-medium text-foreground [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]",e),"data-slot":"table-head",...t})}function It({className:e,...t}){return c.jsx("td",{className:ve("whitespace-nowrap p-2 align-middle [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]",e),"data-slot":"table-cell",...t})}const bb={clicked:{variant:"default",description:"Recipient clicked a link in the email",className:"bg-purple-500/10 text-purple-700 dark:text-purple-400 hover:bg-purple-500/20 border-purple-500/20"},opened:{variant:"default",description:"Recipient opened the email",className:"bg-blue-500/10 text-blue-700 dark:text-blue-400 hover:bg-blue-500/20 border-blue-500/20"},delivered:{variant:"default",description:"Email was successfully delivered to recipient's mailbox",className:"bg-green-500/10 text-green-700 dark:text-green-400 hover:bg-green-500/20 border-green-500/20"},sent:{variant:"secondary",description:"Email was sent but delivery not yet confirmed",className:"bg-gray-500/10 text-gray-700 dark:text-gray-400 hover:bg-gray-500/20 border-gray-500/20"},bounced:{variant:"default",description:"Email bounced - recipient's mailbox may not exist or be full",className:"bg-orange-500/10 text-orange-700 dark:text-orange-400 hover:bg-orange-500/20 border-orange-500/20"},complained:{variant:"default",description:"Recipient marked this email as spam",className:"bg-red-500/10 text-red-700 dark:text-red-400 hover:bg-red-500/20 border-red-500/20"},failed:{variant:"default",description:"Email failed to send due to an error",className:"bg-red-500/10 text-red-700 dark:text-red-400 hover:bg-red-500/20 border-red-500/20"}};function jK(){const e=Zo(),[t,n]=j.useState(""),[r,i]=j.useState("15"),[s,l]=j.useState("all"),[f,d]=j.useState("sending"),[h,v]=j.useState([]),[p,g]=j.useState(!0),[b,O]=j.useState(null);j.useEffect(()=>{async function E(){try{g(!0),O(null);let A=sessionStorage.getItem("wraps-auth-token");if(A||(A=new URLSearchParams(window.location.search).get("token"),A&&sessionStorage.setItem("wraps-auth-token",A)),!A)throw new Error("Authentication token not found. Please use the URL provided by 'wraps console' command.");const _=Number.parseInt(r,10),T=Date.now()-_*24*60*60*1e3,N=Date.now(),M=await fetch(`/api/emails?startTime=${T}&endTime=${N}&limit=100&token=${A}`);if(!M.ok){let D="Failed to fetch email logs";try{D=(await M.json()).error||D}catch{D=`${M.status}: ${M.statusText}`}throw new Error(D)}const R=await M.json();v(R.logs.map(D=>({id:D.messageId,to:D.to,from:D.from,subject:D.subject,status:D.status,timestamp:D.sentAt,messageId:D.messageId})))}catch(A){const _=A instanceof Error?A.message:"Unknown error";O(_),console.error("Error fetching email logs:",A)}finally{g(!1)}}E()},[r]);const S=h.filter(E=>{if(t){const A=t.toLowerCase(),_=E.to.some(N=>N.toLowerCase().includes(A)),T=E.subject.toLowerCase().includes(A);if(!(_||T))return!1}return!(s!=="all"&&E.status!==s)}),x=E=>{const A=new Date(E),T=Math.floor((new Date().getTime()-A.getTime())/(1e3*60*60*24));return T===0?"Today":T===1?"Yesterday":T<7?`${T} days ago`:A.toLocaleDateString()};return c.jsxs(Ne,{children:[c.jsxs(De,{children:[c.jsx(Fe,{children:"Emails"}),c.jsx(Ye,{children:"View and manage your email sending history"})]}),c.jsx(Le,{children:c.jsxs($I,{onValueChange:d,value:f,children:[c.jsxs(LI,{children:[c.jsx(_u,{value:"sending",children:"Sending"}),c.jsx(_u,{value:"receiving",children:"Receiving"})]}),c.jsxs(Au,{className:"space-y-4",value:"sending",children:[b&&c.jsx("div",{className:"rounded-md border border-destructive bg-destructive/10 p-4 text-destructive text-sm",children:b}),c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsxs("div",{className:"relative flex-1",children:[c.jsx(Aj,{className:"absolute top-2.5 left-2.5 h-4 w-4 text-muted-foreground"}),c.jsx(ec,{className:"pl-8",onChange:E=>n(E.target.value),placeholder:"Search...",value:t})]}),c.jsxs(fa,{onValueChange:i,value:r,children:[c.jsx(ha,{className:"w-[180px]",children:c.jsx(da,{})}),c.jsxs(ma,{children:[c.jsx(Ue,{value:"1",children:"Last 24 hours"}),c.jsx(Ue,{value:"7",children:"Last 7 days"}),c.jsx(Ue,{value:"15",children:"Last 15 days"}),c.jsx(Ue,{value:"30",children:"Last 30 days"}),c.jsx(Ue,{value:"90",children:"Last 90 days"})]})]}),c.jsxs(fa,{onValueChange:l,value:s,children:[c.jsx(ha,{className:"w-[180px]",children:c.jsx(da,{})}),c.jsxs(ma,{children:[c.jsx(Ue,{value:"all",children:"All Statuses"}),c.jsx(Ue,{value:"clicked",children:"Clicked"}),c.jsx(Ue,{value:"opened",children:"Opened"}),c.jsx(Ue,{value:"delivered",children:"Delivered"}),c.jsx(Ue,{value:"sent",children:"Sent"}),c.jsx(Ue,{value:"bounced",children:"Bounced"}),c.jsx(Ue,{value:"complained",children:"Complained"}),c.jsx(Ue,{value:"failed",children:"Failed"})]})]}),c.jsxs(Ee,{size:"icon",variant:"outline",children:[c.jsx("span",{className:"sr-only",children:"Download"}),"↓"]})]}),c.jsx("div",{className:"rounded-md border",children:c.jsxs(dO,{children:[c.jsx(hO,{children:c.jsxs(la,{children:[c.jsx(pn,{children:"To"}),c.jsx(pn,{children:"Status"}),c.jsx(pn,{children:"Subject"}),c.jsx(pn,{children:"Sent"}),c.jsx(pn,{className:"w-[50px]"})]})}),c.jsx(mO,{children:p?c.jsx(la,{children:c.jsx(It,{className:"h-24 text-center text-muted-foreground",colSpan:5,children:"Loading email logs..."})}):S.length===0?c.jsx(la,{children:c.jsx(It,{className:"h-24 text-center text-muted-foreground",colSpan:5,children:"No emails found"})}):S.map(E=>{var A,_,T;return c.jsxs(la,{className:"cursor-pointer hover:bg-muted/50",onClick:()=>e(`/email/${E.id}`),children:[c.jsx(It,{className:"font-mono text-sm",children:E.to.length>0?c.jsxs(c.Fragment,{children:[E.to[0],E.to.length>1&&c.jsxs("span",{className:"ml-1 text-muted-foreground text-xs",children:["+",E.to.length-1," more"]})]}):c.jsx("span",{className:"text-muted-foreground",children:"(no recipients)"})}),c.jsx(It,{children:c.jsxs(Up,{children:[c.jsx(Hp,{asChild:!0,children:c.jsx(He,{className:(A=bb[E.status])==null?void 0:A.className,variant:((_=bb[E.status])==null?void 0:_.variant)??"default",children:E.status.charAt(0).toUpperCase()+E.status.slice(1)})}),c.jsx(Fp,{children:c.jsx("p",{children:((T=bb[E.status])==null?void 0:T.description)??"Unknown status"})})]})}),c.jsx(It,{className:"max-w-[400px] truncate",children:E.subject}),c.jsx(It,{className:"text-muted-foreground",children:x(E.timestamp)}),c.jsx(It,{children:c.jsxs(Ee,{onClick:N=>{N.stopPropagation()},size:"icon",variant:"ghost",children:[c.jsx("span",{className:"sr-only",children:"More options"}),"⋯"]})})]},E.id)})})]})}),S.length>0&&!p&&c.jsx("div",{className:"flex items-center justify-between text-muted-foreground text-sm",children:c.jsxs("div",{children:["Showing ",S.length," of ",h.length," emails"]})})]}),c.jsx(Au,{value:"receiving",children:c.jsx("div",{className:"flex h-[400px] items-center justify-center text-muted-foreground",children:"Receiving emails coming soon"})})]})})]})}const u3=6048e5,OK=864e5,wh=43200,OT=1440,ET=Symbol.for("constructDateFrom");function ei(e,t){return typeof e=="function"?e(t):e&&typeof e=="object"&&ET in e?e[ET](t):e instanceof Date?new e.constructor(t):new Date(t)}function sn(e,t){return ei(t||e,e)}let EK={};function qf(){return EK}function Uu(e,t){var f,d,h,v;const n=qf(),r=(t==null?void 0:t.weekStartsOn)??((d=(f=t==null?void 0:t.locale)==null?void 0:f.options)==null?void 0:d.weekStartsOn)??n.weekStartsOn??((v=(h=n.locale)==null?void 0:h.options)==null?void 0:v.weekStartsOn)??0,i=sn(e,t==null?void 0:t.in),s=i.getDay(),l=(s<r?7:0)+s-r;return i.setDate(i.getDate()-l),i.setHours(0,0,0,0),i}function um(e,t){return Uu(e,{...t,weekStartsOn:1})}function f3(e,t){const n=sn(e,t==null?void 0:t.in),r=n.getFullYear(),i=ei(n,0);i.setFullYear(r+1,0,4),i.setHours(0,0,0,0);const s=um(i),l=ei(n,0);l.setFullYear(r,0,4),l.setHours(0,0,0,0);const f=um(l);return n.getTime()>=s.getTime()?r+1:n.getTime()>=f.getTime()?r:r-1}function fm(e){const t=sn(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 Xp(e,...t){const n=ei.bind(null,e||t.find(r=>typeof r=="object"));return t.map(n)}function _T(e,t){const n=sn(e,t==null?void 0:t.in);return n.setHours(0,0,0,0),n}function _K(e,t,n){const[r,i]=Xp(n==null?void 0:n.in,e,t),s=_T(r),l=_T(i),f=+s-fm(s),d=+l-fm(l);return Math.round((f-d)/OK)}function AK(e,t){const n=f3(e,t),r=ei(e,0);return r.setFullYear(n,0,4),r.setHours(0,0,0,0),um(r)}function Gh(e,t){const n=+sn(e)-+sn(t);return n<0?-1:n>0?1:n}function NK(e){return ei(e,Date.now())}function TK(e){return e instanceof Date||typeof e=="object"&&Object.prototype.toString.call(e)==="[object Date]"}function CK(e){return!(!TK(e)&&typeof e!="number"||isNaN(+sn(e)))}function MK(e,t,n){const[r,i]=Xp(n==null?void 0:n.in,e,t),s=r.getFullYear()-i.getFullYear(),l=r.getMonth()-i.getMonth();return s*12+l}function RK(e){return t=>{const r=(e?Math[e]:Math.trunc)(t);return r===0?0:r}}function DK(e,t){return+sn(e)-+sn(t)}function PK(e,t){const n=sn(e,t==null?void 0:t.in);return n.setHours(23,59,59,999),n}function kK(e,t){const n=sn(e,t==null?void 0:t.in),r=n.getMonth();return n.setFullYear(n.getFullYear(),r+1,0),n.setHours(23,59,59,999),n}function $K(e,t){const n=sn(e,t==null?void 0:t.in);return+PK(n,t)==+kK(n,t)}function LK(e,t,n){const[r,i,s]=Xp(n==null?void 0:n.in,e,e,t),l=Gh(i,s),f=Math.abs(MK(i,s));if(f<1)return 0;i.getMonth()===1&&i.getDate()>27&&i.setDate(30),i.setMonth(i.getMonth()-l*f);let d=Gh(i,s)===-l;$K(r)&&f===1&&Gh(r,s)===1&&(d=!1);const h=l*(f-+d);return h===0?0:h}function IK(e,t,n){const r=DK(e,t)/1e3;return RK(n==null?void 0:n.roundingMethod)(r)}function zK(e,t){const n=sn(e,t==null?void 0:t.in);return n.setFullYear(n.getFullYear(),0,1),n.setHours(0,0,0,0),n}const BK={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"}},qK=(e,t,n)=>{let r;const i=BK[e];return typeof i=="string"?r=i:t===1?r=i.one:r=i.other.replace("{{count}}",t.toString()),n!=null&&n.addSuffix?n.comparison&&n.comparison>0?"in "+r:r+" ago":r};function xb(e){return(t={})=>{const n=t.width?String(t.width):e.defaultWidth;return e.formats[n]||e.formats[e.defaultWidth]}}const UK={full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},HK={full:"h:mm:ss a zzzz",long:"h:mm:ss a z",medium:"h:mm:ss a",short:"h:mm a"},FK={full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},GK={date:xb({formats:UK,defaultWidth:"full"}),time:xb({formats:HK,defaultWidth:"full"}),dateTime:xb({formats:FK,defaultWidth:"full"})},VK={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"},YK=(e,t,n,r)=>VK[e];function uu(e){return(t,n)=>{const r=n!=null&&n.context?String(n.context):"standalone";let i;if(r==="formatting"&&e.formattingValues){const l=e.defaultFormattingWidth||e.defaultWidth,f=n!=null&&n.width?String(n.width):l;i=e.formattingValues[f]||e.formattingValues[l]}else{const l=e.defaultWidth,f=n!=null&&n.width?String(n.width):e.defaultWidth;i=e.values[f]||e.values[l]}const s=e.argumentCallback?e.argumentCallback(t):t;return i[s]}}const WK={narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},KK={narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1st quarter","2nd quarter","3rd quarter","4th quarter"]},XK={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"]},QK={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"]},ZK={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"}},JK={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"}},eX=(e,t)=>{const n=Number(e),r=n%100;if(r>20||r<10)switch(r%10){case 1:return n+"st";case 2:return n+"nd";case 3:return n+"rd"}return n+"th"},tX={ordinalNumber:eX,era:uu({values:WK,defaultWidth:"wide"}),quarter:uu({values:KK,defaultWidth:"wide",argumentCallback:e=>e-1}),month:uu({values:XK,defaultWidth:"wide"}),day:uu({values:QK,defaultWidth:"wide"}),dayPeriod:uu({values:ZK,defaultWidth:"wide",formattingValues:JK,defaultFormattingWidth:"wide"})};function fu(e){return(t,n={})=>{const r=n.width,i=r&&e.matchPatterns[r]||e.matchPatterns[e.defaultMatchWidth],s=t.match(i);if(!s)return null;const l=s[0],f=r&&e.parsePatterns[r]||e.parsePatterns[e.defaultParseWidth],d=Array.isArray(f)?rX(f,p=>p.test(l)):nX(f,p=>p.test(l));let h;h=e.valueCallback?e.valueCallback(d):d,h=n.valueCallback?n.valueCallback(h):h;const v=t.slice(l.length);return{value:h,rest:v}}}function nX(e,t){for(const n in e)if(Object.prototype.hasOwnProperty.call(e,n)&&t(e[n]))return n}function rX(e,t){for(let n=0;n<e.length;n++)if(t(e[n]))return n}function aX(e){return(t,n={})=>{const r=t.match(e.matchPattern);if(!r)return null;const i=r[0],s=t.match(e.parsePattern);if(!s)return null;let l=e.valueCallback?e.valueCallback(s[0]):s[0];l=n.valueCallback?n.valueCallback(l):l;const f=t.slice(i.length);return{value:l,rest:f}}}const iX=/^(\d+)(th|st|nd|rd)?/i,oX=/\d+/i,sX={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},lX={any:[/^b/i,/^(a|c)/i]},cX={narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},uX={any:[/1/i,/2/i,/3/i,/4/i]},fX={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},dX={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]},hX={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},mX={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]},pX={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},vX={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}},gX={ordinalNumber:aX({matchPattern:iX,parsePattern:oX,valueCallback:e=>parseInt(e,10)}),era:fu({matchPatterns:sX,defaultMatchWidth:"wide",parsePatterns:lX,defaultParseWidth:"any"}),quarter:fu({matchPatterns:cX,defaultMatchWidth:"wide",parsePatterns:uX,defaultParseWidth:"any",valueCallback:e=>e+1}),month:fu({matchPatterns:fX,defaultMatchWidth:"wide",parsePatterns:dX,defaultParseWidth:"any"}),day:fu({matchPatterns:hX,defaultMatchWidth:"wide",parsePatterns:mX,defaultParseWidth:"any"}),dayPeriod:fu({matchPatterns:pX,defaultMatchWidth:"any",parsePatterns:vX,defaultParseWidth:"any"})},d3={code:"en-US",formatDistance:qK,formatLong:GK,formatRelative:YK,localize:tX,match:gX,options:{weekStartsOn:0,firstWeekContainsDate:1}};function yX(e,t){const n=sn(e,t==null?void 0:t.in);return _K(n,zK(n))+1}function bX(e,t){const n=sn(e,t==null?void 0:t.in),r=+um(n)-+AK(n);return Math.round(r/u3)+1}function h3(e,t){var v,p,g,b;const n=sn(e,t==null?void 0:t.in),r=n.getFullYear(),i=qf(),s=(t==null?void 0:t.firstWeekContainsDate)??((p=(v=t==null?void 0:t.locale)==null?void 0:v.options)==null?void 0:p.firstWeekContainsDate)??i.firstWeekContainsDate??((b=(g=i.locale)==null?void 0:g.options)==null?void 0:b.firstWeekContainsDate)??1,l=ei((t==null?void 0:t.in)||e,0);l.setFullYear(r+1,0,s),l.setHours(0,0,0,0);const f=Uu(l,t),d=ei((t==null?void 0:t.in)||e,0);d.setFullYear(r,0,s),d.setHours(0,0,0,0);const h=Uu(d,t);return+n>=+f?r+1:+n>=+h?r:r-1}function xX(e,t){var f,d,h,v;const n=qf(),r=(t==null?void 0:t.firstWeekContainsDate)??((d=(f=t==null?void 0:t.locale)==null?void 0:f.options)==null?void 0:d.firstWeekContainsDate)??n.firstWeekContainsDate??((v=(h=n.locale)==null?void 0:h.options)==null?void 0:v.firstWeekContainsDate)??1,i=h3(e,t),s=ei((t==null?void 0:t.in)||e,0);return s.setFullYear(i,0,r),s.setHours(0,0,0,0),Uu(s,t)}function wX(e,t){const n=sn(e,t==null?void 0:t.in),r=+Uu(n,t)-+xX(n,t);return Math.round(r/u3)+1}function ht(e,t){const n=e<0?"-":"",r=Math.abs(e).toString().padStart(t,"0");return n+r}const Ii={y(e,t){const n=e.getFullYear(),r=n>0?n:1-n;return ht(t==="yy"?r%100:r,t.length)},M(e,t){const n=e.getMonth();return t==="M"?String(n+1):ht(n+1,2)},d(e,t){return ht(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];case"aaaa":default:return n==="am"?"a.m.":"p.m."}},h(e,t){return ht(e.getHours()%12||12,t.length)},H(e,t){return ht(e.getHours(),t.length)},m(e,t){return ht(e.getMinutes(),t.length)},s(e,t){return ht(e.getSeconds(),t.length)},S(e,t){const n=t.length,r=e.getMilliseconds(),i=Math.trunc(r*Math.pow(10,n-3));return ht(i,t.length)}},tl={midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},AT={G:function(e,t,n){const r=e.getFullYear()>0?1:0;switch(t){case"G":case"GG":case"GGG":return n.era(r,{width:"abbreviated"});case"GGGGG":return n.era(r,{width:"narrow"});case"GGGG":default:return n.era(r,{width:"wide"})}},y:function(e,t,n){if(t==="yo"){const r=e.getFullYear(),i=r>0?r:1-r;return n.ordinalNumber(i,{unit:"year"})}return Ii.y(e,t)},Y:function(e,t,n,r){const i=h3(e,r),s=i>0?i:1-i;if(t==="YY"){const l=s%100;return ht(l,2)}return t==="Yo"?n.ordinalNumber(s,{unit:"year"}):ht(s,t.length)},R:function(e,t){const n=f3(e);return ht(n,t.length)},u:function(e,t){const n=e.getFullYear();return ht(n,t.length)},Q:function(e,t,n){const r=Math.ceil((e.getMonth()+1)/3);switch(t){case"Q":return String(r);case"QQ":return ht(r,2);case"Qo":return n.ordinalNumber(r,{unit:"quarter"});case"QQQ":return n.quarter(r,{width:"abbreviated",context:"formatting"});case"QQQQQ":return n.quarter(r,{width:"narrow",context:"formatting"});case"QQQQ":default:return n.quarter(r,{width:"wide",context:"formatting"})}},q:function(e,t,n){const r=Math.ceil((e.getMonth()+1)/3);switch(t){case"q":return String(r);case"qq":return ht(r,2);case"qo":return n.ordinalNumber(r,{unit:"quarter"});case"qqq":return n.quarter(r,{width:"abbreviated",context:"standalone"});case"qqqqq":return n.quarter(r,{width:"narrow",context:"standalone"});case"qqqq":default:return n.quarter(r,{width:"wide",context:"standalone"})}},M:function(e,t,n){const r=e.getMonth();switch(t){case"M":case"MM":return Ii.M(e,t);case"Mo":return n.ordinalNumber(r+1,{unit:"month"});case"MMM":return n.month(r,{width:"abbreviated",context:"formatting"});case"MMMMM":return n.month(r,{width:"narrow",context:"formatting"});case"MMMM":default:return n.month(r,{width:"wide",context:"formatting"})}},L:function(e,t,n){const r=e.getMonth();switch(t){case"L":return String(r+1);case"LL":return ht(r+1,2);case"Lo":return n.ordinalNumber(r+1,{unit:"month"});case"LLL":return n.month(r,{width:"abbreviated",context:"standalone"});case"LLLLL":return n.month(r,{width:"narrow",context:"standalone"});case"LLLL":default:return n.month(r,{width:"wide",context:"standalone"})}},w:function(e,t,n,r){const i=wX(e,r);return t==="wo"?n.ordinalNumber(i,{unit:"week"}):ht(i,t.length)},I:function(e,t,n){const r=bX(e);return t==="Io"?n.ordinalNumber(r,{unit:"week"}):ht(r,t.length)},d:function(e,t,n){return t==="do"?n.ordinalNumber(e.getDate(),{unit:"date"}):Ii.d(e,t)},D:function(e,t,n){const r=yX(e);return t==="Do"?n.ordinalNumber(r,{unit:"dayOfYear"}):ht(r,t.length)},E:function(e,t,n){const r=e.getDay();switch(t){case"E":case"EE":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"});case"EEEE":default:return n.day(r,{width:"wide",context:"formatting"})}},e:function(e,t,n,r){const i=e.getDay(),s=(i-r.weekStartsOn+8)%7||7;switch(t){case"e":return String(s);case"ee":return ht(s,2);case"eo":return n.ordinalNumber(s,{unit:"day"});case"eee":return n.day(i,{width:"abbreviated",context:"formatting"});case"eeeee":return n.day(i,{width:"narrow",context:"formatting"});case"eeeeee":return n.day(i,{width:"short",context:"formatting"});case"eeee":default:return n.day(i,{width:"wide",context:"formatting"})}},c:function(e,t,n,r){const i=e.getDay(),s=(i-r.weekStartsOn+8)%7||7;switch(t){case"c":return String(s);case"cc":return ht(s,t.length);case"co":return n.ordinalNumber(s,{unit:"day"});case"ccc":return n.day(i,{width:"abbreviated",context:"standalone"});case"ccccc":return n.day(i,{width:"narrow",context:"standalone"});case"cccccc":return n.day(i,{width:"short",context:"standalone"});case"cccc":default:return n.day(i,{width:"wide",context:"standalone"})}},i:function(e,t,n){const r=e.getDay(),i=r===0?7:r;switch(t){case"i":return String(i);case"ii":return ht(i,t.length);case"io":return n.ordinalNumber(i,{unit:"day"});case"iii":return n.day(r,{width:"abbreviated",context:"formatting"});case"iiiii":return n.day(r,{width:"narrow",context:"formatting"});case"iiiiii":return n.day(r,{width:"short",context:"formatting"});case"iiii":default:return n.day(r,{width:"wide",context:"formatting"})}},a:function(e,t,n){const i=e.getHours()/12>=1?"pm":"am";switch(t){case"a":case"aa":return n.dayPeriod(i,{width:"abbreviated",context:"formatting"});case"aaa":return n.dayPeriod(i,{width:"abbreviated",context:"formatting"}).toLowerCase();case"aaaaa":return n.dayPeriod(i,{width:"narrow",context:"formatting"});case"aaaa":default:return n.dayPeriod(i,{width:"wide",context:"formatting"})}},b:function(e,t,n){const r=e.getHours();let i;switch(r===12?i=tl.noon:r===0?i=tl.midnight:i=r/12>=1?"pm":"am",t){case"b":case"bb":return n.dayPeriod(i,{width:"abbreviated",context:"formatting"});case"bbb":return n.dayPeriod(i,{width:"abbreviated",context:"formatting"}).toLowerCase();case"bbbbb":return n.dayPeriod(i,{width:"narrow",context:"formatting"});case"bbbb":default:return n.dayPeriod(i,{width:"wide",context:"formatting"})}},B:function(e,t,n){const r=e.getHours();let i;switch(r>=17?i=tl.evening:r>=12?i=tl.afternoon:r>=4?i=tl.morning:i=tl.night,t){case"B":case"BB":case"BBB":return n.dayPeriod(i,{width:"abbreviated",context:"formatting"});case"BBBBB":return n.dayPeriod(i,{width:"narrow",context:"formatting"});case"BBBB":default:return n.dayPeriod(i,{width:"wide",context:"formatting"})}},h:function(e,t,n){if(t==="ho"){let r=e.getHours()%12;return r===0&&(r=12),n.ordinalNumber(r,{unit:"hour"})}return Ii.h(e,t)},H:function(e,t,n){return t==="Ho"?n.ordinalNumber(e.getHours(),{unit:"hour"}):Ii.H(e,t)},K:function(e,t,n){const r=e.getHours()%12;return t==="Ko"?n.ordinalNumber(r,{unit:"hour"}):ht(r,t.length)},k:function(e,t,n){let r=e.getHours();return r===0&&(r=24),t==="ko"?n.ordinalNumber(r,{unit:"hour"}):ht(r,t.length)},m:function(e,t,n){return t==="mo"?n.ordinalNumber(e.getMinutes(),{unit:"minute"}):Ii.m(e,t)},s:function(e,t,n){return t==="so"?n.ordinalNumber(e.getSeconds(),{unit:"second"}):Ii.s(e,t)},S:function(e,t){return Ii.S(e,t)},X:function(e,t,n){const r=e.getTimezoneOffset();if(r===0)return"Z";switch(t){case"X":return TT(r);case"XXXX":case"XX":return Mo(r);case"XXXXX":case"XXX":default:return Mo(r,":")}},x:function(e,t,n){const r=e.getTimezoneOffset();switch(t){case"x":return TT(r);case"xxxx":case"xx":return Mo(r);case"xxxxx":case"xxx":default:return Mo(r,":")}},O:function(e,t,n){const r=e.getTimezoneOffset();switch(t){case"O":case"OO":case"OOO":return"GMT"+NT(r,":");case"OOOO":default:return"GMT"+Mo(r,":")}},z:function(e,t,n){const r=e.getTimezoneOffset();switch(t){case"z":case"zz":case"zzz":return"GMT"+NT(r,":");case"zzzz":default:return"GMT"+Mo(r,":")}},t:function(e,t,n){const r=Math.trunc(+e/1e3);return ht(r,t.length)},T:function(e,t,n){return ht(+e,t.length)}};function NT(e,t=""){const n=e>0?"-":"+",r=Math.abs(e),i=Math.trunc(r/60),s=r%60;return s===0?n+String(i):n+String(i)+t+ht(s,2)}function TT(e,t){return e%60===0?(e>0?"-":"+")+ht(Math.abs(e)/60,2):Mo(e,t)}function Mo(e,t=""){const n=e>0?"-":"+",r=Math.abs(e),i=ht(Math.trunc(r/60),2),s=ht(r%60,2);return n+i+t+s}const CT=(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"});case"PPPP":default:return t.date({width:"full"})}},m3=(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"});case"pppp":default:return t.time({width:"full"})}},SX=(e,t)=>{const n=e.match(/(P+)(p+)?/)||[],r=n[1],i=n[2];if(!i)return CT(e,t);let s;switch(r){case"P":s=t.dateTime({width:"short"});break;case"PP":s=t.dateTime({width:"medium"});break;case"PPP":s=t.dateTime({width:"long"});break;case"PPPP":default:s=t.dateTime({width:"full"});break}return s.replace("{{date}}",CT(r,t)).replace("{{time}}",m3(i,t))},jX={p:m3,P:SX},OX=/^D+$/,EX=/^Y+$/,_X=["D","DD","YY","YYYY"];function AX(e){return OX.test(e)}function NX(e){return EX.test(e)}function TX(e,t,n){const r=CX(e,t,n);if(console.warn(r),_X.includes(e))throw new RangeError(r)}function CX(e,t,n){const r=e[0]==="Y"?"years":"days of the month";return`Use \`${e.toLowerCase()}\` instead of \`${e}\` (in \`${t}\`) for formatting ${r} to the input \`${n}\`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md`}const MX=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,RX=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,DX=/^'([^]*?)'?$/,PX=/''/g,kX=/[a-zA-Z]/;function V1(e,t,n){var v,p,g,b;const r=qf(),i=r.locale??d3,s=r.firstWeekContainsDate??((p=(v=r.locale)==null?void 0:v.options)==null?void 0:p.firstWeekContainsDate)??1,l=r.weekStartsOn??((b=(g=r.locale)==null?void 0:g.options)==null?void 0:b.weekStartsOn)??0,f=sn(e,n==null?void 0:n.in);if(!CK(f))throw new RangeError("Invalid time value");let d=t.match(RX).map(O=>{const S=O[0];if(S==="p"||S==="P"){const x=jX[S];return x(O,i.formatLong)}return O}).join("").match(MX).map(O=>{if(O==="''")return{isToken:!1,value:"'"};const S=O[0];if(S==="'")return{isToken:!1,value:$X(O)};if(AT[S])return{isToken:!0,value:O};if(S.match(kX))throw new RangeError("Format string contains an unescaped latin alphabet character `"+S+"`");return{isToken:!1,value:O}});i.localize.preprocessor&&(d=i.localize.preprocessor(f,d));const h={firstWeekContainsDate:s,weekStartsOn:l,locale:i};return d.map(O=>{if(!O.isToken)return O.value;const S=O.value;(NX(S)||AX(S))&&TX(S,t,String(e));const x=AT[S[0]];return x(f,S,i.localize,h)}).join("")}function $X(e){const t=e.match(DX);return t?t[1].replace(PX,"'"):e}function LX(e,t,n){const r=qf(),i=(n==null?void 0:n.locale)??r.locale??d3,s=2520,l=Gh(e,t);if(isNaN(l))throw new RangeError("Invalid time value");const f=Object.assign({},n,{addSuffix:n==null?void 0:n.addSuffix,comparison:l}),[d,h]=Xp(n==null?void 0:n.in,...l>0?[t,e]:[e,t]),v=IK(h,d),p=(fm(h)-fm(d))/1e3,g=Math.round((v-p)/60);let b;if(g<2)return n!=null&&n.includeSeconds?v<5?i.formatDistance("lessThanXSeconds",5,f):v<10?i.formatDistance("lessThanXSeconds",10,f):v<20?i.formatDistance("lessThanXSeconds",20,f):v<40?i.formatDistance("halfAMinute",0,f):v<60?i.formatDistance("lessThanXMinutes",1,f):i.formatDistance("xMinutes",1,f):g===0?i.formatDistance("lessThanXMinutes",1,f):i.formatDistance("xMinutes",g,f);if(g<45)return i.formatDistance("xMinutes",g,f);if(g<90)return i.formatDistance("aboutXHours",1,f);if(g<OT){const O=Math.round(g/60);return i.formatDistance("aboutXHours",O,f)}else{if(g<s)return i.formatDistance("xDays",1,f);if(g<wh){const O=Math.round(g/OT);return i.formatDistance("xDays",O,f)}else if(g<wh*2)return b=Math.round(g/wh),i.formatDistance("aboutXMonths",b,f)}if(b=LK(h,d),b<12){const O=Math.round(g/wh);return i.formatDistance("xMonths",O,f)}else{const O=b%12,S=Math.trunc(b/12);return O<3?i.formatDistance("aboutXYears",S,f):O<9?i.formatDistance("overXYears",S,f):i.formatDistance("almostXYears",S+1,f)}}function IX(e,t){return LX(e,NK(e),t)}var wb,MT;function Un(){if(MT)return wb;MT=1;var e=Array.isArray;return wb=e,wb}var Sb,RT;function p3(){if(RT)return Sb;RT=1;var e=typeof fh=="object"&&fh&&fh.Object===Object&&fh;return Sb=e,Sb}var jb,DT;function wa(){if(DT)return jb;DT=1;var e=p3(),t=typeof self=="object"&&self&&self.Object===Object&&self,n=e||t||Function("return this")();return jb=n,jb}var Ob,PT;function Uf(){if(PT)return Ob;PT=1;var e=wa(),t=e.Symbol;return Ob=t,Ob}var Eb,kT;function zX(){if(kT)return Eb;kT=1;var e=Uf(),t=Object.prototype,n=t.hasOwnProperty,r=t.toString,i=e?e.toStringTag:void 0;function s(l){var f=n.call(l,i),d=l[i];try{l[i]=void 0;var h=!0}catch{}var v=r.call(l);return h&&(f?l[i]=d:delete l[i]),v}return Eb=s,Eb}var _b,$T;function BX(){if($T)return _b;$T=1;var e=Object.prototype,t=e.toString;function n(r){return t.call(r)}return _b=n,_b}var Ab,LT;function oi(){if(LT)return Ab;LT=1;var e=Uf(),t=zX(),n=BX(),r="[object Null]",i="[object Undefined]",s=e?e.toStringTag:void 0;function l(f){return f==null?f===void 0?i:r:s&&s in Object(f)?t(f):n(f)}return Ab=l,Ab}var Nb,IT;function si(){if(IT)return Nb;IT=1;function e(t){return t!=null&&typeof t=="object"}return Nb=e,Nb}var Tb,zT;function rc(){if(zT)return Tb;zT=1;var e=oi(),t=si(),n="[object Symbol]";function r(i){return typeof i=="symbol"||t(i)&&e(i)==n}return Tb=r,Tb}var Cb,BT;function pO(){if(BT)return Cb;BT=1;var e=Un(),t=rc(),n=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,r=/^\w*$/;function i(s,l){if(e(s))return!1;var f=typeof s;return f=="number"||f=="symbol"||f=="boolean"||s==null||t(s)?!0:r.test(s)||!n.test(s)||l!=null&&s in Object(l)}return Cb=i,Cb}var Mb,qT;function to(){if(qT)return Mb;qT=1;function e(t){var n=typeof t;return t!=null&&(n=="object"||n=="function")}return Mb=e,Mb}var Rb,UT;function vO(){if(UT)return Rb;UT=1;var e=oi(),t=to(),n="[object AsyncFunction]",r="[object Function]",i="[object GeneratorFunction]",s="[object Proxy]";function l(f){if(!t(f))return!1;var d=e(f);return d==r||d==i||d==n||d==s}return Rb=l,Rb}var Db,HT;function qX(){if(HT)return Db;HT=1;var e=wa(),t=e["__core-js_shared__"];return Db=t,Db}var Pb,FT;function UX(){if(FT)return Pb;FT=1;var e=qX(),t=(function(){var r=/[^.]+$/.exec(e&&e.keys&&e.keys.IE_PROTO||"");return r?"Symbol(src)_1."+r:""})();function n(r){return!!t&&t in r}return Pb=n,Pb}var kb,GT;function v3(){if(GT)return kb;GT=1;var e=Function.prototype,t=e.toString;function n(r){if(r!=null){try{return t.call(r)}catch{}try{return r+""}catch{}}return""}return kb=n,kb}var $b,VT;function HX(){if(VT)return $b;VT=1;var e=vO(),t=UX(),n=to(),r=v3(),i=/[\\^$.*+?()[\]{}|]/g,s=/^\[object .+?Constructor\]$/,l=Function.prototype,f=Object.prototype,d=l.toString,h=f.hasOwnProperty,v=RegExp("^"+d.call(h).replace(i,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function p(g){if(!n(g)||t(g))return!1;var b=e(g)?v:s;return b.test(r(g))}return $b=p,$b}var Lb,YT;function FX(){if(YT)return Lb;YT=1;function e(t,n){return t==null?void 0:t[n]}return Lb=e,Lb}var Ib,WT;function as(){if(WT)return Ib;WT=1;var e=HX(),t=FX();function n(r,i){var s=t(r,i);return e(s)?s:void 0}return Ib=n,Ib}var zb,KT;function Qp(){if(KT)return zb;KT=1;var e=as(),t=e(Object,"create");return zb=t,zb}var Bb,XT;function GX(){if(XT)return Bb;XT=1;var e=Qp();function t(){this.__data__=e?e(null):{},this.size=0}return Bb=t,Bb}var qb,QT;function VX(){if(QT)return qb;QT=1;function e(t){var n=this.has(t)&&delete this.__data__[t];return this.size-=n?1:0,n}return qb=e,qb}var Ub,ZT;function YX(){if(ZT)return Ub;ZT=1;var e=Qp(),t="__lodash_hash_undefined__",n=Object.prototype,r=n.hasOwnProperty;function i(s){var l=this.__data__;if(e){var f=l[s];return f===t?void 0:f}return r.call(l,s)?l[s]:void 0}return Ub=i,Ub}var Hb,JT;function WX(){if(JT)return Hb;JT=1;var e=Qp(),t=Object.prototype,n=t.hasOwnProperty;function r(i){var s=this.__data__;return e?s[i]!==void 0:n.call(s,i)}return Hb=r,Hb}var Fb,eC;function KX(){if(eC)return Fb;eC=1;var e=Qp(),t="__lodash_hash_undefined__";function n(r,i){var s=this.__data__;return this.size+=this.has(r)?0:1,s[r]=e&&i===void 0?t:i,this}return Fb=n,Fb}var Gb,tC;function XX(){if(tC)return Gb;tC=1;var e=GX(),t=VX(),n=YX(),r=WX(),i=KX();function s(l){var f=-1,d=l==null?0:l.length;for(this.clear();++f<d;){var h=l[f];this.set(h[0],h[1])}}return s.prototype.clear=e,s.prototype.delete=t,s.prototype.get=n,s.prototype.has=r,s.prototype.set=i,Gb=s,Gb}var Vb,nC;function QX(){if(nC)return Vb;nC=1;function e(){this.__data__=[],this.size=0}return Vb=e,Vb}var Yb,rC;function gO(){if(rC)return Yb;rC=1;function e(t,n){return t===n||t!==t&&n!==n}return Yb=e,Yb}var Wb,aC;function Zp(){if(aC)return Wb;aC=1;var e=gO();function t(n,r){for(var i=n.length;i--;)if(e(n[i][0],r))return i;return-1}return Wb=t,Wb}var Kb,iC;function ZX(){if(iC)return Kb;iC=1;var e=Zp(),t=Array.prototype,n=t.splice;function r(i){var s=this.__data__,l=e(s,i);if(l<0)return!1;var f=s.length-1;return l==f?s.pop():n.call(s,l,1),--this.size,!0}return Kb=r,Kb}var Xb,oC;function JX(){if(oC)return Xb;oC=1;var e=Zp();function t(n){var r=this.__data__,i=e(r,n);return i<0?void 0:r[i][1]}return Xb=t,Xb}var Qb,sC;function eQ(){if(sC)return Qb;sC=1;var e=Zp();function t(n){return e(this.__data__,n)>-1}return Qb=t,Qb}var Zb,lC;function tQ(){if(lC)return Zb;lC=1;var e=Zp();function t(n,r){var i=this.__data__,s=e(i,n);return s<0?(++this.size,i.push([n,r])):i[s][1]=r,this}return Zb=t,Zb}var Jb,cC;function Jp(){if(cC)return Jb;cC=1;var e=QX(),t=ZX(),n=JX(),r=eQ(),i=tQ();function s(l){var f=-1,d=l==null?0:l.length;for(this.clear();++f<d;){var h=l[f];this.set(h[0],h[1])}}return s.prototype.clear=e,s.prototype.delete=t,s.prototype.get=n,s.prototype.has=r,s.prototype.set=i,Jb=s,Jb}var ex,uC;function yO(){if(uC)return ex;uC=1;var e=as(),t=wa(),n=e(t,"Map");return ex=n,ex}var tx,fC;function nQ(){if(fC)return tx;fC=1;var e=XX(),t=Jp(),n=yO();function r(){this.size=0,this.__data__={hash:new e,map:new(n||t),string:new e}}return tx=r,tx}var nx,dC;function rQ(){if(dC)return nx;dC=1;function e(t){var n=typeof t;return n=="string"||n=="number"||n=="symbol"||n=="boolean"?t!=="__proto__":t===null}return nx=e,nx}var rx,hC;function ev(){if(hC)return rx;hC=1;var e=rQ();function t(n,r){var i=n.__data__;return e(r)?i[typeof r=="string"?"string":"hash"]:i.map}return rx=t,rx}var ax,mC;function aQ(){if(mC)return ax;mC=1;var e=ev();function t(n){var r=e(this,n).delete(n);return this.size-=r?1:0,r}return ax=t,ax}var ix,pC;function iQ(){if(pC)return ix;pC=1;var e=ev();function t(n){return e(this,n).get(n)}return ix=t,ix}var ox,vC;function oQ(){if(vC)return ox;vC=1;var e=ev();function t(n){return e(this,n).has(n)}return ox=t,ox}var sx,gC;function sQ(){if(gC)return sx;gC=1;var e=ev();function t(n,r){var i=e(this,n),s=i.size;return i.set(n,r),this.size+=i.size==s?0:1,this}return sx=t,sx}var lx,yC;function bO(){if(yC)return lx;yC=1;var e=nQ(),t=aQ(),n=iQ(),r=oQ(),i=sQ();function s(l){var f=-1,d=l==null?0:l.length;for(this.clear();++f<d;){var h=l[f];this.set(h[0],h[1])}}return s.prototype.clear=e,s.prototype.delete=t,s.prototype.get=n,s.prototype.has=r,s.prototype.set=i,lx=s,lx}var cx,bC;function g3(){if(bC)return cx;bC=1;var e=bO(),t="Expected a function";function n(r,i){if(typeof r!="function"||i!=null&&typeof i!="function")throw new TypeError(t);var s=function(){var l=arguments,f=i?i.apply(this,l):l[0],d=s.cache;if(d.has(f))return d.get(f);var h=r.apply(this,l);return s.cache=d.set(f,h)||d,h};return s.cache=new(n.Cache||e),s}return n.Cache=e,cx=n,cx}var ux,xC;function lQ(){if(xC)return ux;xC=1;var e=g3(),t=500;function n(r){var i=e(r,function(l){return s.size===t&&s.clear(),l}),s=i.cache;return i}return ux=n,ux}var fx,wC;function cQ(){if(wC)return fx;wC=1;var e=lQ(),t=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,n=/\\(\\)?/g,r=e(function(i){var s=[];return i.charCodeAt(0)===46&&s.push(""),i.replace(t,function(l,f,d,h){s.push(d?h.replace(n,"$1"):f||l)}),s});return fx=r,fx}var dx,SC;function xO(){if(SC)return dx;SC=1;function e(t,n){for(var r=-1,i=t==null?0:t.length,s=Array(i);++r<i;)s[r]=n(t[r],r,t);return s}return dx=e,dx}var hx,jC;function uQ(){if(jC)return hx;jC=1;var e=Uf(),t=xO(),n=Un(),r=rc(),i=e?e.prototype:void 0,s=i?i.toString:void 0;function l(f){if(typeof f=="string")return f;if(n(f))return t(f,l)+"";if(r(f))return s?s.call(f):"";var d=f+"";return d=="0"&&1/f==-1/0?"-0":d}return hx=l,hx}var mx,OC;function y3(){if(OC)return mx;OC=1;var e=uQ();function t(n){return n==null?"":e(n)}return mx=t,mx}var px,EC;function b3(){if(EC)return px;EC=1;var e=Un(),t=pO(),n=cQ(),r=y3();function i(s,l){return e(s)?s:t(s,l)?[s]:n(r(s))}return px=i,px}var vx,_C;function tv(){if(_C)return vx;_C=1;var e=rc();function t(n){if(typeof n=="string"||e(n))return n;var r=n+"";return r=="0"&&1/n==-1/0?"-0":r}return vx=t,vx}var gx,AC;function wO(){if(AC)return gx;AC=1;var e=b3(),t=tv();function n(r,i){i=e(i,r);for(var s=0,l=i.length;r!=null&&s<l;)r=r[t(i[s++])];return s&&s==l?r:void 0}return gx=n,gx}var yx,NC;function x3(){if(NC)return yx;NC=1;var e=wO();function t(n,r,i){var s=n==null?void 0:e(n,r);return s===void 0?i:s}return yx=t,yx}var fQ=x3();const Nr=yt(fQ);var bx,TC;function dQ(){if(TC)return bx;TC=1;function e(t){return t==null}return bx=e,bx}var hQ=dQ();const Xe=yt(hQ);var xx,CC;function mQ(){if(CC)return xx;CC=1;var e=oi(),t=Un(),n=si(),r="[object String]";function i(s){return typeof s=="string"||!t(s)&&n(s)&&e(s)==r}return xx=i,xx}var pQ=mQ();const Yo=yt(pQ);var vQ=vO();const Ve=yt(vQ);var gQ=to();const ac=yt(gQ);var wx={exports:{}},ct={};/**
|
|
393
393
|
* @license React
|
|
394
394
|
* react-is.production.min.js
|
|
395
395
|
*
|
|
@@ -468,4 +468,4 @@ You can add a description to the \`${yl}\` by passing a \`${kB}\` component as a
|
|
|
468
468
|
|
|
469
469
|
Alternatively, you can use your own component as a description by assigning it an \`id\` and passing the same value to the \`aria-describedby\` prop in \`${yl}\`. If the description is confusing or duplicative for sighted users, you can use the \`@radix-ui/react-visually-hidden\` primitive as a wrapper around your description component.
|
|
470
470
|
|
|
471
|
-
For more information, see https://radix-ui.com/primitives/docs/components/alert-dialog`;return j.useEffect(()=>{var r;document.getElementById((r=e.current)==null?void 0:r.getAttribute("aria-describedby"))||console.warn(t)},[t,e]),null},Cme=TB,Mme=CB,Rme=MB,Dme=RB,Pme=LB,kme=zB,$me=PB,Lme=$B;function up({...e}){return c.jsx(Cme,{"data-slot":"alert-dialog",...e})}function Ime({...e}){return c.jsx(Mme,{"data-slot":"alert-dialog-portal",...e})}function zme({className:e,...t}){return c.jsx(Rme,{className:ve("data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50 data-[state=closed]:animate-out data-[state=open]:animate-in",e),"data-slot":"alert-dialog-overlay",...t})}function fp({className:e,...t}){return c.jsxs(Ime,{children:[c.jsx(zme,{}),c.jsx(Dme,{className:ve("data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border bg-background p-6 shadow-lg duration-200 data-[state=closed]:animate-out data-[state=open]:animate-in sm:max-w-lg",e),"data-slot":"alert-dialog-content",...t})]})}function dp({className:e,...t}){return c.jsx("div",{className:ve("flex flex-col gap-2 text-center sm:text-left",e),"data-slot":"alert-dialog-header",...t})}function hp({className:e,...t}){return c.jsx("div",{className:ve("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",e),"data-slot":"alert-dialog-footer",...t})}function mp({className:e,...t}){return c.jsx($me,{className:ve("font-semibold text-lg",e),"data-slot":"alert-dialog-title",...t})}function pp({className:e,...t}){return c.jsx(Lme,{className:ve("text-muted-foreground text-sm",e),"data-slot":"alert-dialog-description",...t})}function vp({className:e,...t}){return c.jsx(Pme,{className:ve(Zj(),e),...t})}function gp({className:e,...t}){return c.jsx(kme,{className:ve(Zj({variant:"outline"}),e),...t})}var Cv="Collapsible",[Bme]=qn(Cv),[qme,SE]=Bme(Cv),BB=j.forwardRef((e,t)=>{const{__scopeCollapsible:n,open:r,defaultOpen:i,disabled:s,onOpenChange:l,...f}=e,[d,h]=Vr({prop:r,defaultProp:i??!1,onChange:l,caller:Cv});return c.jsx(qme,{scope:n,disabled:s,contentId:_r(),open:d,onOpenToggle:j.useCallback(()=>h(v=>!v),[h]),children:c.jsx(Ce.div,{"data-state":OE(d),"data-disabled":s?"":void 0,...f,ref:t})})});BB.displayName=Cv;var qB="CollapsibleTrigger",UB=j.forwardRef((e,t)=>{const{__scopeCollapsible:n,...r}=e,i=SE(qB,n);return c.jsx(Ce.button,{type:"button","aria-controls":i.contentId,"aria-expanded":i.open||!1,"data-state":OE(i.open),"data-disabled":i.disabled?"":void 0,disabled:i.disabled,...r,ref:t,onClick:be(e.onClick,i.onOpenToggle)})});UB.displayName=qB;var jE="CollapsibleContent",HB=j.forwardRef((e,t)=>{const{forceMount:n,...r}=e,i=SE(jE,e.__scopeCollapsible);return c.jsx(lr,{present:n||i.open,children:({present:s})=>c.jsx(Ume,{...r,ref:t,present:s})})});HB.displayName=jE;var Ume=j.forwardRef((e,t)=>{const{__scopeCollapsible:n,present:r,children:i,...s}=e,l=SE(jE,n),[f,d]=j.useState(r),h=j.useRef(null),v=Be(t,h),p=j.useRef(0),g=p.current,b=j.useRef(0),O=b.current,S=l.open||f,x=j.useRef(S),E=j.useRef(void 0);return j.useEffect(()=>{const A=requestAnimationFrame(()=>x.current=!1);return()=>cancelAnimationFrame(A)},[]),Yt(()=>{const A=h.current;if(A){E.current=E.current||{transitionDuration:A.style.transitionDuration,animationName:A.style.animationName},A.style.transitionDuration="0s",A.style.animationName="none";const _=A.getBoundingClientRect();p.current=_.height,b.current=_.width,x.current||(A.style.transitionDuration=E.current.transitionDuration,A.style.animationName=E.current.animationName),d(r)}},[l.open,r]),c.jsx(Ce.div,{"data-state":OE(l.open),"data-disabled":l.disabled?"":void 0,id:l.contentId,hidden:!S,...s,ref:v,style:{"--radix-collapsible-content-height":g?`${g}px`:void 0,"--radix-collapsible-content-width":O?`${O}px`:void 0,...e.style},children:S&&i})});function OE(e){return e?"open":"closed"}var Hme=BB;const fc=Hme,dc=UB,hc=HB;function EE({...e}){return c.jsx(nO,{"data-slot":"dialog",...e})}function Fme({...e}){return c.jsx(rO,{"data-slot":"dialog-portal",...e})}function Gme({className:e,...t}){return c.jsx(aO,{className:ve("data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50 data-[state=closed]:animate-out data-[state=open]:animate-in",e),"data-slot":"dialog-overlay",...t})}function _E({className:e,children:t,showCloseButton:n=!0,...r}){return c.jsxs(Fme,{"data-slot":"dialog-portal",children:[c.jsx(Gme,{}),c.jsxs(iO,{className:ve("data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border bg-background p-6 shadow-lg duration-200 data-[state=closed]:animate-out data-[state=open]:animate-in sm:max-w-lg",e),"data-slot":"dialog-content",...r,children:[t,n&&c.jsxs(zp,{className:"absolute top-4 right-4 rounded-xs opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-hidden focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground [&_svg:not([class*='size-'])]:size-4 [&_svg]:pointer-events-none [&_svg]:shrink-0","data-slot":"dialog-close",children:[c.jsx(rr,{}),c.jsx("span",{className:"sr-only",children:"Close"})]})]})]})}function FB({className:e,...t}){return c.jsx("div",{className:ve("flex flex-col gap-2 text-center sm:text-left",e),"data-slot":"dialog-header",...t})}function GB({className:e,...t}){return c.jsx("div",{className:ve("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",e),"data-slot":"dialog-footer",...t})}function VB({className:e,...t}){return c.jsx(oO,{className:ve("font-semibold text-lg leading-none",e),"data-slot":"dialog-title",...t})}function Vme({className:e,...t}){return c.jsx(sO,{className:ve("text-muted-foreground text-sm",e),"data-slot":"dialog-description",...t})}var Yme="Label",YB=j.forwardRef((e,t)=>c.jsx(ts.label,{...e,ref:t,onMouseDown:n=>{var i;n.target.closest("button, input, select, textarea")||((i=e.onMouseDown)==null||i.call(e,n),!n.defaultPrevented&&n.detail>1&&n.preventDefault())}}));YB.displayName=Yme;var Wme=YB;function Po({className:e,...t}){return c.jsx(Wme,{className:ve("flex select-none items-center gap-2 font-medium text-sm leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-50 group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50",e),"data-slot":"label",...t})}async function Kme(){const e=sessionStorage.getItem("wraps-auth-token");if(!e)throw new Error("Authentication token not found");const t=await fetch(`/api/settings?token=${e}`);if(!t.ok)throw new Error(`Failed to fetch settings: ${t.statusText}`);return await t.json()}const WB="wraps-dns-verification",Xme=1e3*60*60;function KB(){try{const e=localStorage.getItem(WB);return e?JSON.parse(e):{}}catch{return{}}}function yp(e){try{localStorage.setItem(WB,JSON.stringify(e))}catch(t){console.error("Failed to save DNS verification cache:",t)}}function XB(e){return e?Date.now()-e.lastChecked<Xme:!1}async function y4(e,t){var i;console.log("[DNS Verify] verifyTrackingDomain called",{domain:e,expectedTarget:t});const n=KB(),r=`${e}->${t}`;if((i=n.trackingDomain)!=null&&i[r]&&XB(n.trackingDomain[r]))return console.log("[DNS Verify] Returning cached result"),n.trackingDomain[r];try{const l=`/api/settings/verify-tracking-domain?token=${sessionStorage.getItem("wraps-auth-token")}&domain=${encodeURIComponent(e)}&expectedTarget=${encodeURIComponent(t)}`;console.log("[DNS Verify] Fetching:",l);const f=await fetch(l);if(console.log("[DNS Verify] Response status:",f.status),!f.ok)throw new Error(`HTTP ${f.status}: ${f.statusText}`);const d=await f.json();console.log("[DNS Verify] Response data:",d);const h={verified:d.verified,lastChecked:Date.now(),error:d.error};return n.trackingDomain||(n.trackingDomain={}),n.trackingDomain[r]=h,yp(n),h}catch(s){console.error("Tracking domain verification request failed:",s);const l={verified:!1,lastChecked:Date.now(),error:s instanceof Error?s.message:"Failed to verify"};return n.trackingDomain||(n.trackingDomain={}),n.trackingDomain[r]=l,yp(n),l}}async function b4(e){var r;console.log("[DNS Verify] verifyDmarc called",{domain:e});const t=KB(),n=`_dmarc.${e}`;if((r=t.dmarc)!=null&&r[n]&&XB(t.dmarc[n]))return console.log("[DNS Verify] Returning cached DMARC result"),t.dmarc[n];try{const s=`/api/settings/verify-dmarc?token=${sessionStorage.getItem("wraps-auth-token")}&domain=${encodeURIComponent(e)}`;console.log("[DNS Verify] Fetching:",s);const l=await fetch(s);if(console.log("[DNS Verify] Response status:",l.status),!l.ok)throw new Error(`HTTP ${l.status}: ${l.statusText}`);const f=await l.json();console.log("[DNS Verify] Response data:",f);const d={verified:f.verified,lastChecked:Date.now(),error:f.error};return t.dmarc||(t.dmarc={}),t.dmarc[n]=d,yp(t),d}catch(i){console.error("DMARC verification request failed:",i);const s={verified:!1,lastChecked:Date.now(),error:i instanceof Error?i.message:"Failed to verify"};return t.dmarc||(t.dmarc={}),t.dmarc[n]=s,yp(t),s}}function AE({status:e}){const t={SUCCESS:{icon:Zi,label:"Verified",variant:"default",className:"bg-green-500/10 text-green-700 dark:text-green-400 border-green-500/20"},PENDING:{icon:Uo,label:"Pending",variant:"secondary",className:"bg-yellow-500/10 text-yellow-700 dark:text-yellow-400 border-yellow-500/20"},FAILED:{icon:F4,label:"Failed",variant:"destructive",className:"bg-red-500/10 text-red-700 dark:text-red-400 border-red-500/20"},TEMPORARY_FAILURE:{icon:ir,label:"Temporary Failure",variant:"secondary",className:"bg-orange-500/10 text-orange-700 dark:text-orange-400 border-orange-500/20"},NOT_STARTED:{icon:Uo,label:"Not Started",variant:"outline",className:"bg-gray-500/10 text-gray-700 dark:text-gray-400 border-gray-500/20"}},{icon:n,label:r,className:i}=t[e];return c.jsxs(He,{className:i,variant:"outline",children:[c.jsx(n,{className:"mr-1 h-3 w-3"}),r]})}function Gl({text:e}){const t=async()=>{await navigator.clipboard.writeText(e),wt.success("Copied to clipboard",{description:"DNS record value copied successfully"})};return c.jsx(Ee,{onClick:t,size:"sm",variant:"ghost",children:c.jsx(bl,{className:"h-3 w-3"})})}function Qme({identity:e}){const t=e==null?void 0:e.dkimAttributes,n=(t==null?void 0:t.status)==="SUCCESS",[r,i]=j.useState(!n);return t?c.jsxs("div",{className:"space-y-4",children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{children:[c.jsx("p",{className:"font-medium",children:"DKIM Authentication"}),c.jsxs("p",{className:"text-muted-foreground text-sm",children:[t.signingEnabled?"Enabled":"Disabled",t.signingKeyLength&&` · ${t.signingKeyLength}`]})]}),c.jsx(AE,{status:t.status})]}),t.tokens&&t.tokens.length>0&&c.jsxs(fc,{onOpenChange:i,open:r,children:[c.jsx(dc,{asChild:!0,children:c.jsxs(Ee,{className:"h-auto w-full justify-between p-0",size:"sm",variant:"ghost",children:[c.jsx("p",{className:"font-medium text-sm",children:"DNS Records (CNAME)"}),r?c.jsx(Nf,{className:"h-4 w-4"}):c.jsx(Jo,{className:"h-4 w-4"})]})}),c.jsx(hc,{className:"mt-2 space-y-2",children:t.tokens.map(s=>c.jsxs("div",{className:"rounded-md border bg-muted/50 p-3",children:[c.jsxs("div",{className:"mb-1 flex items-center justify-between",children:[c.jsxs("p",{className:"font-mono text-xs",children:[s,"._domainkey.",e.identityName]}),c.jsx(Gl,{text:`${s}._domainkey.${e.identityName}`})]}),c.jsxs("p",{className:"font-mono text-muted-foreground text-xs",children:["CNAME → ",s,".dkim.amazonses.com"]})]},s))})]})]}):c.jsx("div",{className:"space-y-4",children:c.jsx("div",{className:"flex items-center justify-between",children:c.jsxs("div",{children:[c.jsx("p",{className:"font-medium",children:"DKIM Authentication"}),c.jsx("p",{className:"text-muted-foreground text-sm",children:"Not configured"})]})})})}function Zme({identity:e}){const t=e==null?void 0:e.mailFromAttributes,n=(t==null?void 0:t.mailFromDomainStatus)==="SUCCESS",[r,i]=j.useState(!n);return c.jsx("div",{className:"space-y-4",children:t!=null&&t.mailFromDomain?c.jsxs(c.Fragment,{children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{children:[c.jsx("p",{className:"font-medium",children:"Mail-From Domain"}),c.jsxs("p",{className:"text-muted-foreground text-sm",children:[t.mailFromDomain,t.behaviorOnMxFailure&&` · ${t.behaviorOnMxFailure==="USE_DEFAULT_VALUE"?"Fallback enabled":"Reject on failure"}`]})]}),t.mailFromDomainStatus&&c.jsx(AE,{status:t.mailFromDomainStatus})]}),c.jsxs(fc,{onOpenChange:i,open:r,children:[c.jsx(dc,{asChild:!0,children:c.jsxs(Ee,{className:"h-auto w-full justify-between p-0",size:"sm",variant:"ghost",children:[c.jsx("p",{className:"font-medium text-sm",children:"DNS Record (MX)"}),r?c.jsx(Nf,{className:"h-4 w-4"}):c.jsx(Jo,{className:"h-4 w-4"})]})}),c.jsx(hc,{className:"mt-2",children:c.jsx("div",{className:"rounded-md border bg-muted/50 p-3",children:c.jsxs("div",{className:"space-y-1",children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("p",{className:"font-mono text-xs",children:["MX ",t.mailFromDomain]}),c.jsx(Gl,{text:`10 feedback-smtp.${e==null?void 0:e.identityName.split(".")[0]}.amazonses.com`})]}),c.jsxs("p",{className:"font-mono text-muted-foreground text-xs",children:["Priority 10 → feedback-smtp.",e==null?void 0:e.identityName.split(".")[0],".amazonses.com"]})]})})})]})]}):c.jsx("div",{className:"flex items-center justify-between",children:c.jsxs("div",{children:[c.jsx("p",{className:"font-medium",children:"Mail-From Domain"}),c.jsx("p",{className:"text-muted-foreground text-sm",children:"Using default amazonses.com domain"})]})})})}function Jme({identity:e}){const[t,n]=j.useState(null),[r,i]=j.useState(!1),[s,l]=j.useState(!(t!=null&&t.verified));j.useEffect(()=>{e!=null&&e.identityName&&b4(e.identityName).then(n)},[e==null?void 0:e.identityName]),j.useEffect(()=>{t&&l(!t.verified)},[t]);const f=async()=>{if(e!=null&&e.identityName){i(!0);try{const d=await b4(e.identityName);n(d),d.verified?wt.success("DMARC record verified",{description:"DNS TXT record found and configured correctly"}):(console.error("DMARC verification failed:",d.error),wt.error("Verification failed",{description:d.error||"DMARC record not found"}))}catch(d){console.error("DMARC verification error:",d),wt.error("Verification error",{description:d instanceof Error?d.message:"Unknown error"})}finally{i(!1)}}};return c.jsxs("div",{className:"space-y-4",children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{children:[c.jsx("p",{className:"font-medium",children:"DMARC Policy"}),c.jsx("p",{className:"text-muted-foreground text-sm",children:t!=null&&t.verified?"Configured":"Recommended for better deliverability"})]}),c.jsxs("div",{className:"flex items-center gap-2",children:[(t==null?void 0:t.verified)&&c.jsxs(He,{className:"border-green-500/20 bg-green-500/10 text-green-700 dark:text-green-400",variant:"outline",children:[c.jsx(Zi,{className:"mr-1 h-3 w-3"}),"Verified by Wraps"]}),c.jsx(Ee,{className:"h-8 w-8 p-0",disabled:r,onClick:f,size:"sm",variant:"ghost",children:c.jsx(Cf,{className:`h-4 w-4 ${r?"animate-spin":""}`})})]})]}),c.jsxs(fc,{onOpenChange:l,open:s,children:[c.jsx(dc,{asChild:!0,children:c.jsxs(Ee,{className:"h-auto w-full justify-between p-0",size:"sm",variant:"ghost",children:[c.jsx("p",{className:"font-medium text-sm",children:"DNS Record (TXT)"}),s?c.jsx(Nf,{className:"h-4 w-4"}):c.jsx(Jo,{className:"h-4 w-4"})]})}),c.jsx(hc,{className:"mt-2",children:c.jsxs("div",{className:"rounded-md border bg-muted/50 p-3",children:[c.jsxs("div",{className:"mb-2 flex items-center justify-between",children:[c.jsxs("p",{className:"font-mono text-xs",children:["_dmarc.",(e==null?void 0:e.identityName)||"yourdomain.com"]}),c.jsx(Gl,{text:`_dmarc.${(e==null?void 0:e.identityName)||"yourdomain.com"}`})]}),c.jsxs("div",{className:"flex items-start justify-between gap-2",children:[c.jsxs("p",{className:"font-mono text-muted-foreground text-xs",children:["v=DMARC1; p=quarantine; rua=mailto:dmarc@",(e==null?void 0:e.identityName)||"yourdomain.com"]}),c.jsx(Gl,{text:`v=DMARC1; p=quarantine; rua=mailto:dmarc@${(e==null?void 0:e.identityName)||"yourdomain.com"}`})]})]})})]})]})}function epe({configSet:e,region:t,onRefresh:n}){const r=e==null?void 0:e.trackingOptions,[i,s]=j.useState(null),[l,f]=j.useState(!1),[d,h]=j.useState(!1),[v,p]=j.useState(""),[g,b]=j.useState(!1),[O,S]=j.useState(!(i!=null&&i.verified));j.useEffect(()=>{if(r!=null&&r.customRedirectDomain&&t){const _=`r.${t}.awstrack.me`;y4(r.customRedirectDomain,_).then(s)}},[r==null?void 0:r.customRedirectDomain,t]),j.useEffect(()=>{i&&S(!i.verified)},[i]);const x=async()=>{if(r!=null&&r.customRedirectDomain&&t){f(!0);try{const _=`r.${t}.awstrack.me`,T=await y4(r.customRedirectDomain,_);s(T),T.verified?wt.success("Tracking domain verified",{description:"DNS records are configured correctly"}):(console.error("Tracking domain verification failed:",T.error),wt.error("Verification failed",{description:T.error||"DNS records not found"}))}catch(_){console.error("Tracking domain verification error:",_),wt.error("Verification error",{description:_ instanceof Error?_.message:"Unknown error"})}finally{f(!1)}}},E=()=>{p((r==null?void 0:r.customRedirectDomain)||""),h(!0)},A=async()=>{if(!v.trim()){wt.error("Invalid domain",{description:"Please enter a valid domain name"});return}b(!0);try{const _=sessionStorage.getItem("wraps-auth-token"),T=await fetch(`/api/settings/config-set/tracking-domain?token=${_}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({domain:v})});if(!T.ok){const N=await T.json();throw new Error(N.error||`Failed to update: ${T.statusText}`)}h(!1),wt.success("Tracking domain updated",{description:"Don't forget to configure the DNS records"}),n&&await n()}catch(_){console.error("Failed to update tracking domain:",_),wt.error("Failed to update tracking domain",{description:_ instanceof Error?_.message:"Unknown error"})}finally{b(!1)}};return c.jsxs(Ne,{children:[c.jsxs(De,{children:[c.jsx(Fe,{children:"Tracking Domain"}),c.jsx(Ye,{children:"Custom domain for open and click tracking links"})]}),c.jsx(Le,{className:"space-y-4",children:r!=null&&r.customRedirectDomain?c.jsxs(c.Fragment,{children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{className:"flex-1",children:[c.jsx("p",{className:"font-medium",children:r.customRedirectDomain}),c.jsx("p",{className:"text-muted-foreground text-sm",children:"Custom Tracking Domain"})]}),c.jsxs("div",{className:"flex items-center gap-2",children:[(i==null?void 0:i.verified)&&c.jsxs(He,{className:"border-green-500/20 bg-green-500/10 text-green-700 dark:text-green-400",variant:"outline",children:[c.jsx(Zi,{className:"mr-1 h-3 w-3"}),"Verified by Wraps"]}),c.jsx(He,{variant:"outline",children:r.httpsPolicy==="REQUIRE"?"HTTPS Only":"HTTPS Optional"}),c.jsx(Ee,{className:"h-8 w-8 p-0",disabled:l,onClick:x,size:"sm",variant:"ghost",children:c.jsx(Cf,{className:`h-4 w-4 ${l?"animate-spin":""}`})}),c.jsx(Ee,{className:"h-8 w-8 p-0",onClick:E,size:"sm",variant:"ghost",children:c.jsx(L2,{className:"h-4 w-4"})})]})]}),c.jsxs(fc,{onOpenChange:S,open:O,children:[c.jsx(dc,{asChild:!0,children:c.jsxs(Ee,{className:"h-auto w-full justify-between p-0",size:"sm",variant:"ghost",children:[c.jsx("p",{className:"font-medium text-sm",children:"Required DNS Record (CNAME)"}),O?c.jsx(Nf,{className:"h-4 w-4"}):c.jsx(Jo,{className:"h-4 w-4"})]})}),c.jsx(hc,{className:"mt-2",children:c.jsxs("div",{className:"rounded-md border bg-muted/50 p-3",children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx("p",{className:"font-mono text-xs",children:r.customRedirectDomain}),c.jsx(Gl,{text:r.customRedirectDomain})]}),c.jsxs("div",{className:"mt-1 flex items-start justify-between gap-2",children:[c.jsxs("p",{className:"font-mono text-muted-foreground text-xs",children:["CNAME → r.",(e==null?void 0:e.name)||"region",".awstrack.me"]}),c.jsx(Gl,{text:`r.${(e==null?void 0:e.name)||"region"}.awstrack.me`})]})]})})]})]}):c.jsxs("div",{className:"space-y-4",children:[c.jsx("p",{className:"text-muted-foreground text-sm",children:"No custom tracking domain configured. Using default awstrack.me domain."}),c.jsxs(Ee,{onClick:E,size:"sm",variant:"outline",children:[c.jsx(L2,{className:"mr-2 h-4 w-4"}),"Configure Tracking Domain"]})]})}),c.jsx(EE,{onOpenChange:h,open:d,children:c.jsxs(_E,{children:[c.jsxs(FB,{children:[c.jsx(VB,{children:"Update Tracking Domain"}),c.jsx(Vme,{children:"Enter the custom domain you want to use for email tracking links. You'll need to configure DNS records after saving."})]}),c.jsx("div",{className:"space-y-4 py-4",children:c.jsxs("div",{className:"space-y-2",children:[c.jsx(Po,{htmlFor:"domain",children:"Tracking Domain"}),c.jsx(ec,{disabled:g,id:"domain",onChange:_=>p(_.target.value),placeholder:"track.example.com",value:v}),c.jsx("p",{className:"text-muted-foreground text-xs",children:"Example: track.yourdomain.com or email.yourdomain.com"})]})}),c.jsxs(GB,{children:[c.jsx(Ee,{disabled:g,onClick:()=>h(!1),variant:"outline",children:"Cancel"}),c.jsx(Ee,{disabled:g,onClick:A,children:g?"Updating...":"Update Domain"})]})]})})]})}function tpe({configSet:e,onRefresh:t}){var v,p;const[n,r]=j.useState(!1),[i,s]=j.useState(!1),[l,f]=j.useState(!1);if(!e)return c.jsx(Ne,{children:c.jsxs(De,{children:[c.jsx(Fe,{children:"Configuration Set"}),c.jsx(Ye,{children:"No configuration set found"})]})});const d=async()=>{var g;f(!0);try{const b=sessionStorage.getItem("wraps-auth-token"),O=!((g=e.sendingOptions)!=null&&g.sendingEnabled),S=await fetch(`/api/settings/config-set/sending?token=${b}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({enabled:O})});if(!S.ok)throw new Error(`Failed to update: ${S.statusText}`);r(!1),wt.success(O?"Email sending enabled":"Email sending disabled"),t&&await t()}catch(b){console.error("Failed to toggle sending:",b),wt.error("Failed to update setting",{description:b instanceof Error?b.message:"Unknown error"})}finally{f(!1)}},h=async()=>{var g;f(!0);try{const b=sessionStorage.getItem("wraps-auth-token"),O=!((g=e.reputationOptions)!=null&&g.reputationMetricsEnabled),S=await fetch(`/api/settings/config-set/reputation?token=${b}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({enabled:O})});if(!S.ok)throw new Error(`Failed to update: ${S.statusText}`);s(!1),wt.success(O?"Reputation metrics enabled":"Reputation metrics disabled"),t&&await t()}catch(b){console.error("Failed to toggle reputation:",b),wt.error("Failed to update setting",{description:b instanceof Error?b.message:"Unknown error"})}finally{f(!1)}};return c.jsxs(Ne,{children:[c.jsxs(De,{children:[c.jsx(Fe,{children:"Configuration Set"}),c.jsx(Ye,{children:"Email sending and tracking configuration"})]}),c.jsxs(Le,{className:"space-y-6",children:[c.jsxs("div",{children:[c.jsx("p",{className:"font-medium",children:e.name}),c.jsx("p",{className:"text-muted-foreground text-sm",children:"Configuration Set Name"})]}),c.jsx(Bt,{}),e.sendingOptions&&c.jsxs(c.Fragment,{children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{className:"flex-1 space-y-0.5",children:[c.jsx("p",{className:"font-medium text-sm",children:"Email Sending"}),c.jsx("p",{className:"text-muted-foreground text-sm",children:e.sendingOptions.sendingEnabled?"Emails can be sent":"Email sending is disabled"})]}),c.jsx(Ee,{onClick:()=>r(!0),size:"sm",variant:e.sendingOptions.sendingEnabled?"destructive":"default",children:e.sendingOptions.sendingEnabled?"Disable":"Enable"})]}),c.jsx(up,{onOpenChange:r,open:n,children:c.jsxs(fp,{children:[c.jsxs(dp,{children:[c.jsx(mp,{children:e.sendingOptions.sendingEnabled?"Disable email sending?":"Enable email sending?"}),c.jsx(pp,{children:e.sendingOptions.sendingEnabled?"All outgoing emails will be blocked until you re-enable sending. Emails in the queue will not be sent.":"This will allow emails to be sent through this configuration set. Make sure your domain is verified before enabling."})]}),c.jsxs(hp,{children:[c.jsx(gp,{disabled:l,children:"Cancel"}),c.jsx(vp,{disabled:l,onClick:d,children:l?"Updating...":e.sendingOptions.sendingEnabled?"Disable sending":"Enable sending"})]})]})})]}),e.reputationOptions&&c.jsxs(c.Fragment,{children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{className:"flex-1 space-y-0.5",children:[c.jsx("p",{className:"font-medium text-sm",children:"Reputation Metrics"}),c.jsx("p",{className:"text-muted-foreground text-sm",children:e.reputationOptions.reputationMetricsEnabled?"Tracking bounce and complaint rates":"Reputation tracking disabled"})]}),c.jsx(Ee,{onClick:()=>s(!0),size:"sm",variant:"outline",children:e.reputationOptions.reputationMetricsEnabled?"Disable":"Enable"})]}),c.jsx(up,{onOpenChange:s,open:i,children:c.jsxs(fp,{children:[c.jsxs(dp,{children:[c.jsx(mp,{children:e.reputationOptions.reputationMetricsEnabled?"Disable reputation metrics?":"Enable reputation metrics?"}),c.jsx(pp,{children:e.reputationOptions.reputationMetricsEnabled?"You will stop collecting bounce and complaint rate data. Historical data will be preserved but no new metrics will be tracked.":"This will start tracking bounce and complaint rates for your sending domain. This helps monitor your email reputation and deliverability."})]}),c.jsxs(hp,{children:[c.jsx(gp,{disabled:l,children:"Cancel"}),c.jsx(vp,{disabled:l,onClick:h,children:l?"Updating...":e.reputationOptions.reputationMetricsEnabled?"Disable metrics":"Enable metrics"})]})]})})]}),((v=e.deliveryOptions)==null?void 0:v.tlsPolicy)&&c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{className:"space-y-0.5",children:[c.jsx("p",{className:"font-medium text-sm",children:"TLS Encryption"}),c.jsx("p",{className:"text-muted-foreground text-sm",children:e.deliveryOptions.tlsPolicy==="REQUIRE"?"Required for all connections":"Optional (opportunistic)"})]}),c.jsx(He,{variant:"outline",children:e.deliveryOptions.tlsPolicy==="REQUIRE"?"Required":"Optional"})]}),e.suppressionOptions&&c.jsxs("div",{className:"space-y-2",children:[c.jsxs("div",{className:"space-y-0.5",children:[c.jsx("p",{className:"font-medium text-sm",children:"Suppression List"}),c.jsx("p",{className:"text-muted-foreground text-sm",children:"Automatically suppress emails to addresses that bounced or complained"})]}),e.suppressionOptions.suppressedReasons&&e.suppressionOptions.suppressedReasons.length>0?c.jsx("div",{className:"flex gap-2",children:e.suppressionOptions.suppressedReasons.map(g=>c.jsx(He,{variant:"secondary",children:g},g))}):c.jsx("p",{className:"text-muted-foreground text-sm",children:"Not configured"})]}),((p=e.deliveryOptions)==null?void 0:p.sendingPoolName)&&c.jsxs("div",{children:[c.jsx("p",{className:"font-medium text-sm",children:"IP Pool"}),c.jsx("p",{className:"text-muted-foreground text-sm",children:e.deliveryOptions.sendingPoolName})]})]})]})}function npe(){var f,d;const[e,t]=j.useState(null),[n,r]=j.useState(!0),[i,s]=j.useState(null),l=j.useCallback(async()=>{try{r(!0);const h=await Kme();t(h),s(null)}catch(h){console.error("Failed to fetch email settings:",h),s(h instanceof Error?h.message:"Failed to load settings")}finally{r(!1)}},[]);return j.useEffect(()=>{l()},[l]),n?c.jsxs(c.Fragment,{children:[c.jsxs("div",{children:[c.jsx("h1",{className:"font-semibold text-3xl tracking-tight",children:"Email Settings"}),c.jsx("p",{className:"mt-2 text-muted-foreground",children:"Configure your email settings and preferences"})]}),c.jsxs("div",{className:"mt-6 grid gap-6 md:grid-cols-2",children:[c.jsxs(Ne,{className:"md:row-span-2",children:[c.jsxs(De,{children:[c.jsx(Re,{className:"h-6 w-48"}),c.jsx(Re,{className:"mt-2 h-4 w-64"})]}),c.jsxs(Le,{className:"space-y-6",children:[c.jsxs("div",{className:"space-y-2",children:[c.jsx(Re,{className:"h-4 w-32"}),c.jsx(Re,{className:"h-4 w-24"})]}),c.jsx(Re,{className:"h-px w-full"}),c.jsxs("div",{className:"space-y-2",children:[c.jsx(Re,{className:"h-4 w-40"}),c.jsx(Re,{className:"h-4 w-28"})]}),c.jsx(Re,{className:"h-px w-full"}),c.jsxs("div",{className:"space-y-2",children:[c.jsx(Re,{className:"h-4 w-36"}),c.jsx(Re,{className:"h-4 w-32"})]}),c.jsx(Re,{className:"h-px w-full"}),c.jsxs("div",{className:"space-y-2",children:[c.jsx(Re,{className:"h-4 w-32"}),c.jsx(Re,{className:"h-4 w-44"})]})]})]}),c.jsxs(Ne,{children:[c.jsxs(De,{children:[c.jsx(Re,{className:"h-6 w-48"}),c.jsx(Re,{className:"mt-2 h-4 w-64"})]}),c.jsx(Le,{children:c.jsx(Re,{className:"h-20 w-full"})})]}),c.jsxs(Ne,{children:[c.jsxs(De,{children:[c.jsx(Re,{className:"h-6 w-48"}),c.jsx(Re,{className:"mt-2 h-4 w-64"})]}),c.jsx(Le,{children:c.jsx(Re,{className:"h-20 w-full"})})]})]})]}):i?c.jsxs(c.Fragment,{children:[c.jsxs("div",{children:[c.jsx("h1",{className:"font-semibold text-3xl tracking-tight",children:"Email Settings"}),c.jsx("p",{className:"mt-2 text-muted-foreground",children:"Configure your email settings and preferences"})]}),c.jsxs(In,{className:"mt-6",variant:"destructive",children:[c.jsx(ir,{className:"h-4 w-4"}),c.jsx(Xi,{children:"Error Loading Settings"}),c.jsx(zn,{children:i})]})]}):c.jsxs(c.Fragment,{children:[c.jsxs("div",{children:[c.jsx("h1",{className:"font-semibold text-3xl tracking-tight",children:"Email Settings"}),c.jsx("p",{className:"mt-2 text-muted-foreground",children:"Configure your email settings and preferences"})]}),c.jsxs("div",{className:"mt-6 grid gap-6 md:grid-cols-2",children:[c.jsxs(Ne,{className:"md:row-span-2",children:[c.jsxs(De,{children:[c.jsx(Fe,{children:"Sending Domain"}),c.jsx(Ye,{children:"Email domain configuration and authentication"})]}),c.jsxs(Le,{className:"space-y-6",children:[c.jsx("div",{className:"space-y-4",children:c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{className:"flex-1",children:[c.jsx("p",{className:"font-medium",children:(f=e==null?void 0:e.identity)==null?void 0:f.identityName}),c.jsx("p",{className:"text-muted-foreground text-sm",children:"Domain Identity"})]}),c.jsx(AE,{status:((d=e==null?void 0:e.identity)==null?void 0:d.verificationStatus)||"NOT_STARTED"})]})}),c.jsx(Bt,{}),c.jsx(Qme,{identity:e==null?void 0:e.identity}),c.jsx(Bt,{}),c.jsx(Zme,{identity:e==null?void 0:e.identity}),c.jsx(Bt,{}),c.jsx(Jme,{identity:e==null?void 0:e.identity})]})]}),c.jsx(tpe,{configSet:e==null?void 0:e.configurationSet,onRefresh:l}),c.jsx(epe,{configSet:e==null?void 0:e.configurationSet,onRefresh:l,region:e==null?void 0:e.region})]})]})}const rpe={sent:Yi,delivered:Vi,failed:rr,queued:Uo,blocked:rr,carrier_unreachable:Wh,invalid:rr,opted_out:rr,ttl_expired:Uo},ape={sent:"text-blue-500",delivered:"text-green-500",failed:"text-red-500",queued:"text-gray-500",blocked:"text-orange-500",carrier_unreachable:"text-red-500",invalid:"text-red-500",opted_out:"text-yellow-500",ttl_expired:"text-gray-500"},ipe={delivered:"default",sent:"secondary",queued:"secondary",failed:"destructive",blocked:"destructive",invalid:"destructive",opted_out:"default"};function ope(){const{id:e}=P4(),t=Zo(),[n,r]=j.useState(null),[i,s]=j.useState(!0),[l,f]=j.useState(null);j.useEffect(()=>{async function p(){try{s(!0),f(null);const g=sessionStorage.getItem("wraps-auth-token");if(!g)throw new Error("Authentication token not found");const b=encodeURIComponent(e||""),O=await fetch(`/api/sms/${b}?token=${g}`);if(!O.ok){let E="Failed to fetch SMS details";try{E=(await O.json()).error||E}catch{E=`${O.status}: ${O.statusText}`}throw new Error(E)}const S=O.headers.get("content-type");if(!(S!=null&&S.includes("application/json"))){const E=await O.text();throw console.error("Non-JSON response:",E),new Error("Server returned non-JSON response")}const x=await O.json();r(x)}catch(g){const b=g instanceof Error?g.message:"Unknown error";f(b),console.error("Error fetching SMS details:",g)}finally{s(!1)}}e&&p()},[e]);const d=p=>new Date(p).toLocaleString("en-US",{month:"short",day:"numeric",hour:"numeric",minute:"2-digit",hour12:!0}),h=p=>new Date(p).toLocaleString("en-US",{weekday:"short",month:"short",day:"numeric",year:"numeric",hour:"numeric",minute:"2-digit",second:"2-digit",hour12:!0}),v=p=>p.startsWith("+1")&&p.length===12?`(${p.slice(2,5)}) ${p.slice(5,8)}-${p.slice(8)}`:p;return i?c.jsx("div",{className:"flex h-[600px] items-center justify-center",children:c.jsx("div",{className:"text-muted-foreground",children:"Loading SMS details..."})}):l?c.jsxs("div",{className:"space-y-4",children:[c.jsxs(Ee,{onClick:()=>t("/sms"),size:"sm",variant:"ghost",children:[c.jsx(fl,{className:"mr-2 h-4 w-4"}),"Back to messages"]}),c.jsx("div",{className:"rounded-md border border-destructive bg-destructive/10 p-4 text-destructive text-sm",children:l})]}):n?c.jsxs("div",{className:"space-y-6",children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs(Ee,{onClick:()=>t("/sms"),size:"sm",variant:"ghost",children:[c.jsx(fl,{className:"mr-2 h-4 w-4"}),"Back to messages"]}),c.jsx(He,{variant:ipe[n.status],children:n.status.charAt(0).toUpperCase()+n.status.slice(1).replace("_"," ")})]}),c.jsxs(Ne,{children:[c.jsx(De,{children:c.jsx("div",{className:"flex items-start justify-between",children:c.jsxs("div",{className:"space-y-1.5",children:[c.jsxs(Fe,{className:"flex items-center gap-2 text-2xl",children:[c.jsx(Yi,{className:"h-6 w-6"}),"SMS Message"]}),c.jsx(Ye,{className:"font-mono text-xs",children:n.messageId})]})})}),c.jsx(Le,{className:"space-y-4",children:c.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[c.jsxs("div",{className:"space-y-1",children:[c.jsx("div",{className:"text-muted-foreground text-sm",children:"FROM"}),c.jsx("div",{className:"font-mono text-sm",children:v(n.from)})]}),c.jsxs("div",{className:"space-y-1",children:[c.jsx("div",{className:"text-muted-foreground text-sm",children:"TO"}),c.jsx("div",{className:"font-mono text-sm",children:v(n.to)})]}),c.jsxs("div",{className:"space-y-1",children:[c.jsx("div",{className:"text-muted-foreground text-sm",children:"SEGMENTS"}),c.jsx("div",{className:"font-mono text-sm",children:n.segments})]}),c.jsxs("div",{className:"space-y-1",children:[c.jsx("div",{className:"text-muted-foreground text-sm",children:"ID"}),c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("code",{className:"rounded bg-muted px-2 py-1 font-mono text-xs",children:n.id}),c.jsx(Ee,{className:"h-6 w-6",onClick:()=>navigator.clipboard.writeText(n.id),size:"icon",variant:"ghost",children:c.jsx("span",{className:"sr-only",children:"Copy ID"})})]})]})]})})]}),c.jsxs(Ne,{children:[c.jsxs(De,{children:[c.jsx(Fe,{children:"Message Content"}),c.jsx(Ye,{children:"The SMS message body"})]}),c.jsx(Le,{children:c.jsx("div",{className:"rounded-md border bg-muted/50 p-4",children:c.jsx("p",{className:"whitespace-pre-wrap text-sm",children:n.body})})})]}),c.jsxs(Ne,{children:[c.jsxs(De,{children:[c.jsx(Fe,{children:"Message Events"}),c.jsx(Ye,{children:"Lifecycle of this message from send to delivery"})]}),c.jsx(Le,{children:c.jsx("div",{className:"space-y-4",children:n.events.length===0?c.jsx("div",{className:"text-muted-foreground text-sm",children:"No events recorded yet"}):n.events.map((p,g)=>{const b=rpe[p.type]||Uo,O=g===n.events.length-1;return c.jsx("div",{children:c.jsxs("div",{className:"flex gap-4",children:[c.jsxs("div",{className:"flex flex-col items-center",children:[c.jsx("div",{className:`rounded-full border-2 border-background bg-muted p-2 ${ape[p.type]}`,children:c.jsx(b,{className:"h-4 w-4"})}),!O&&c.jsx("div",{className:"my-1 w-px flex-1 bg-border"})]}),c.jsxs("div",{className:"flex-1 pb-6",children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx("div",{className:"font-medium capitalize",children:p.type.replace("_"," ")}),c.jsx("div",{className:"text-muted-foreground text-sm",children:d(p.timestamp)})]}),c.jsx("div",{className:"text-muted-foreground text-sm",children:h(p.timestamp)}),p.metadata&&Object.keys(p.metadata).length>0&&c.jsx("div",{className:"mt-2 rounded-md border bg-muted/50 p-2 font-mono text-xs",children:c.jsx("pre",{className:"overflow-x-auto",children:JSON.stringify(p.metadata,null,2)})})]})]})},`${p.type}-${p.timestamp}`)})})})]})]}):c.jsxs("div",{className:"space-y-4",children:[c.jsxs(Ee,{onClick:()=>t("/sms"),size:"sm",variant:"ghost",children:[c.jsx(fl,{className:"mr-2 h-4 w-4"}),"Back to messages"]}),c.jsx("div",{className:"rounded-md border p-4 text-muted-foreground text-sm",children:"SMS message not found"})]})}const w1={delivered:{variant:"default",description:"Message was delivered to recipient's device",className:"bg-green-500/10 text-green-700 dark:text-green-400 hover:bg-green-500/20 border-green-500/20"},sent:{variant:"secondary",description:"Message was sent but delivery not yet confirmed",className:"bg-blue-500/10 text-blue-700 dark:text-blue-400 hover:bg-blue-500/20 border-blue-500/20"},queued:{variant:"secondary",description:"Message is queued for delivery",className:"bg-gray-500/10 text-gray-700 dark:text-gray-400 hover:bg-gray-500/20 border-gray-500/20"},failed:{variant:"destructive",description:"Message failed to deliver",className:"bg-red-500/10 text-red-700 dark:text-red-400 hover:bg-red-500/20 border-red-500/20"},blocked:{variant:"destructive",description:"Message was blocked by carrier or filter",className:"bg-orange-500/10 text-orange-700 dark:text-orange-400 hover:bg-orange-500/20 border-orange-500/20"},invalid:{variant:"destructive",description:"Invalid phone number or message format",className:"bg-red-500/10 text-red-700 dark:text-red-400 hover:bg-red-500/20 border-red-500/20"},opted_out:{variant:"default",description:"Recipient has opted out of receiving messages",className:"bg-yellow-500/10 text-yellow-700 dark:text-yellow-400 hover:bg-yellow-500/20 border-yellow-500/20"}};function spe(){const e=Zo(),[t,n]=j.useState(""),[r,i]=j.useState("15"),[s,l]=j.useState("all"),[f,d]=j.useState([]),[h,v]=j.useState(!0),[p,g]=j.useState(null);j.useEffect(()=>{async function x(){try{v(!0),g(null);let E=sessionStorage.getItem("wraps-auth-token");if(E||(E=new URLSearchParams(window.location.search).get("token"),E&&sessionStorage.setItem("wraps-auth-token",E)),!E)throw new Error("Authentication token not found. Please use the URL provided by 'wraps console' command.");const A=Number.parseInt(r,10),_=Date.now()-A*24*60*60*1e3,T=Date.now(),N=await fetch(`/api/sms?startTime=${_}&endTime=${T}&limit=100&token=${E}`);if(!N.ok){let R="Failed to fetch SMS logs";try{R=(await N.json()).error||R}catch{R=`${N.status}: ${N.statusText}`}throw new Error(R)}const M=await N.json();d(M.logs.map(R=>({id:R.messageId,to:R.to,from:R.from,body:R.body,status:R.status,timestamp:R.sentAt,messageId:R.messageId,segments:R.segments})))}catch(E){const A=E instanceof Error?E.message:"Unknown error";g(A),console.error("Error fetching SMS logs:",E)}finally{v(!1)}}x()},[r]);const b=f.filter(x=>{if(t){const E=t.toLowerCase(),A=x.to.toLowerCase().includes(E),_=x.body.toLowerCase().includes(E);if(!(A||_))return!1}return!(s!=="all"&&x.status!==s)}),O=x=>{const E=new Date(x),_=Math.floor((new Date().getTime()-E.getTime())/(1e3*60*60*24));return _===0?"Today":_===1?"Yesterday":_<7?`${_} days ago`:E.toLocaleDateString()},S=x=>x.startsWith("+1")&&x.length===12?`(${x.slice(2,5)}) ${x.slice(5,8)}-${x.slice(8)}`:x;return c.jsxs(Ne,{children:[c.jsxs(De,{children:[c.jsxs(Fe,{className:"flex items-center gap-2",children:[c.jsx(Yi,{className:"h-5 w-5"}),"SMS Messages"]}),c.jsx(Ye,{children:"View and manage your SMS sending history"})]}),c.jsxs(Le,{children:[p&&c.jsx("div",{className:"mb-4 rounded-md border border-destructive bg-destructive/10 p-4 text-destructive text-sm",children:p}),c.jsxs("div",{className:"mb-4 flex items-center gap-2",children:[c.jsxs("div",{className:"relative flex-1",children:[c.jsx(Aj,{className:"absolute top-2.5 left-2.5 h-4 w-4 text-muted-foreground"}),c.jsx(ec,{className:"pl-8",onChange:x=>n(x.target.value),placeholder:"Search by phone or message...",value:t})]}),c.jsxs(fa,{onValueChange:i,value:r,children:[c.jsx(ha,{className:"w-[180px]",children:c.jsx(da,{})}),c.jsxs(ma,{children:[c.jsx(Ue,{value:"1",children:"Last 24 hours"}),c.jsx(Ue,{value:"7",children:"Last 7 days"}),c.jsx(Ue,{value:"15",children:"Last 15 days"}),c.jsx(Ue,{value:"30",children:"Last 30 days"}),c.jsx(Ue,{value:"90",children:"Last 90 days"})]})]}),c.jsxs(fa,{onValueChange:l,value:s,children:[c.jsx(ha,{className:"w-[180px]",children:c.jsx(da,{})}),c.jsxs(ma,{children:[c.jsx(Ue,{value:"all",children:"All Statuses"}),c.jsx(Ue,{value:"delivered",children:"Delivered"}),c.jsx(Ue,{value:"sent",children:"Sent"}),c.jsx(Ue,{value:"queued",children:"Queued"}),c.jsx(Ue,{value:"failed",children:"Failed"}),c.jsx(Ue,{value:"blocked",children:"Blocked"}),c.jsx(Ue,{value:"opted_out",children:"Opted Out"})]})]}),c.jsx(Ee,{size:"icon",variant:"outline",children:c.jsx("span",{className:"sr-only",children:"Download"})})]}),c.jsx("div",{className:"rounded-md border",children:c.jsxs(dO,{children:[c.jsx(hO,{children:c.jsxs(la,{children:[c.jsx(pn,{children:"To"}),c.jsx(pn,{children:"Status"}),c.jsx(pn,{children:"Message"}),c.jsx(pn,{children:"Sent"}),c.jsx(pn,{className:"w-[50px]"})]})}),c.jsx(mO,{children:h?c.jsx(la,{children:c.jsx(It,{className:"h-24 text-center text-muted-foreground",colSpan:5,children:"Loading SMS logs..."})}):b.length===0?c.jsx(la,{children:c.jsx(It,{className:"h-24 text-center text-muted-foreground",colSpan:5,children:"No SMS messages found"})}):b.map(x=>{var E,A,_;return c.jsxs(la,{className:"cursor-pointer hover:bg-muted/50",onClick:()=>e(`/sms/${x.id}`),children:[c.jsx(It,{className:"font-mono text-sm",children:S(x.to)}),c.jsx(It,{children:c.jsxs(Up,{children:[c.jsx(Hp,{asChild:!0,children:c.jsx(He,{className:(E=w1[x.status])==null?void 0:E.className,variant:((A=w1[x.status])==null?void 0:A.variant)??"default",children:x.status.charAt(0).toUpperCase()+x.status.slice(1).replace("_"," ")})}),c.jsx(Fp,{children:c.jsx("p",{children:((_=w1[x.status])==null?void 0:_.description)??"Unknown status"})})]})}),c.jsx(It,{className:"max-w-[400px] truncate",children:x.body}),c.jsx(It,{className:"text-muted-foreground",children:O(x.timestamp)}),c.jsx(It,{children:c.jsx(Ee,{onClick:T=>{T.stopPropagation()},size:"icon",variant:"ghost",children:c.jsx("span",{className:"sr-only",children:"More options"})})})]},x.id)})})]})}),b.length>0&&!h&&c.jsx("div",{className:"mt-4 flex items-center justify-between text-muted-foreground text-sm",children:c.jsxs("div",{children:["Showing ",b.length," of ",f.length," messages"]})})]})]})}function lpe(){const[e,t]=j.useState("7"),[n,r]=j.useState(null),[i,s]=j.useState(!0),[l,f]=j.useState(null);if(j.useEffect(()=>{async function S(){try{s(!0),f(null);let x=sessionStorage.getItem("wraps-auth-token");if(x||(x=new URLSearchParams(window.location.search).get("token"),x&&sessionStorage.setItem("wraps-auth-token",x)),!x)throw new Error("Authentication token not found. Please use the URL provided by 'wraps console' command.");const E=Number.parseInt(e,10),A=Date.now()-E*24*60*60*1e3,_=Date.now(),T=await fetch(`/api/sms/metrics?startTime=${A}&endTime=${_}&token=${x}`);if(!T.ok){let M="Failed to fetch SMS metrics";try{M=(await T.json()).error||M}catch{M=`${T.status}: ${T.statusText}`}throw new Error(M)}const N=await T.json();r(N)}catch(x){const E=x instanceof Error?x.message:"Unknown error";f(E),console.error("Error fetching SMS metrics:",x)}finally{s(!1)}}S()},[e]),l)return c.jsxs(c.Fragment,{children:[c.jsxs("div",{children:[c.jsx("h1",{className:"font-semibold text-3xl tracking-tight",children:"SMS Metrics"}),c.jsx("p",{className:"mt-2 text-muted-foreground",children:"View detailed metrics and analytics for your SMS messaging"})]}),c.jsx("div",{className:"mt-4 rounded-md border border-destructive bg-destructive/10 p-4 text-destructive text-sm",children:l})]});if(i||!n)return c.jsxs(c.Fragment,{children:[c.jsxs("div",{children:[c.jsx("h1",{className:"font-semibold text-3xl tracking-tight",children:"SMS Metrics"}),c.jsx("p",{className:"mt-2 text-muted-foreground",children:"View detailed metrics and analytics for your SMS messaging"})]}),c.jsx("div",{className:"mt-4 flex h-[400px] items-center justify-center text-muted-foreground",children:"Loading metrics..."})]});const d=n.metrics.sends.reduce((S,x)=>S+x.value,0)||0,h=n.metrics.deliveries.reduce((S,x)=>S+x.value,0)||0,v=n.metrics.failures.reduce((S,x)=>S+x.value,0)||0,p=n.metrics.optOuts.reduce((S,x)=>S+x.value,0)||0,g=d>0?h/d*100:0,b=d>0?v/d*100:0,O=[{title:"Messages Sent",value:d.toLocaleString(),description:`${e==="1"?"Last 24 hours":`Last ${e} days`}`,icon:Yi},{title:"Delivery Rate",value:`${g.toFixed(1)}%`,description:`${h.toLocaleString()} delivered`,icon:Nj},{title:"Failure Rate",value:`${b.toFixed(1)}%`,description:`${v.toLocaleString()} failed`,icon:jp},{title:"Opt Outs",value:p.toLocaleString(),description:"Recipients unsubscribed",icon:Wh}];return c.jsxs(c.Fragment,{children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{children:[c.jsx("h1",{className:"font-semibold text-3xl tracking-tight",children:"SMS Metrics"}),c.jsx("p",{className:"mt-2 text-muted-foreground",children:"View detailed metrics and analytics for your SMS messaging"})]}),c.jsxs(fa,{onValueChange:t,value:e,children:[c.jsx(ha,{className:"w-[180px]",children:c.jsx(da,{})}),c.jsxs(ma,{children:[c.jsx(Ue,{value:"1",children:"Last 24 hours"}),c.jsx(Ue,{value:"7",children:"Last 7 days"}),c.jsx(Ue,{value:"15",children:"Last 15 days"}),c.jsx(Ue,{value:"30",children:"Last 30 days"}),c.jsx(Ue,{value:"90",children:"Last 90 days"})]})]})]}),c.jsx("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-4",children:O.map(S=>c.jsxs(Ne,{children:[c.jsxs(De,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[c.jsx(Fe,{className:"font-medium text-sm",children:S.title}),c.jsx(S.icon,{className:"h-4 w-4 text-muted-foreground"})]}),c.jsxs(Le,{children:[c.jsx("div",{className:"font-bold text-2xl",children:S.value}),c.jsx("p",{className:"text-muted-foreground text-xs",children:S.description})]})]},S.title))}),n.phoneNumber&&c.jsxs(Ne,{children:[c.jsxs(De,{children:[c.jsx(Fe,{children:"Phone Number"}),c.jsx(Ye,{children:"Your SMS sending number"})]}),c.jsxs(Le,{className:"space-y-4",children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx("span",{className:"text-sm",children:"Number"}),c.jsx("span",{className:"font-mono text-sm",children:n.phoneNumber.number})]}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx("span",{className:"text-sm",children:"Type"}),c.jsx(He,{variant:"outline",children:n.phoneNumber.type})]}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx("span",{className:"text-sm",children:"Status"}),c.jsx(He,{variant:n.phoneNumber.status==="ACTIVE"?"default":"secondary",children:n.phoneNumber.status})]}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx("span",{className:"text-sm",children:"Throughput"}),c.jsx("span",{className:"text-muted-foreground text-sm",children:n.phoneNumber.throughput})]})]})]}),n.quota&&c.jsxs(Ne,{children:[c.jsxs(De,{children:[c.jsx(Fe,{children:"Spend Limits"}),c.jsx(Ye,{children:"Your AWS SMS spending limits"})]}),c.jsxs(Le,{className:"space-y-4",children:[c.jsxs("div",{className:"space-y-2",children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx("span",{className:"text-sm",children:"Monthly Spend"}),c.jsxs("span",{className:"font-medium",children:["$",n.quota.spentThisMonth.toFixed(2)," / $",n.quota.spendLimitMonthly.toFixed(2)]})]}),c.jsx("div",{className:"h-2 w-full overflow-hidden rounded-full bg-secondary",children:c.jsx("div",{className:"h-full bg-primary transition-all",style:{width:`${Math.min(n.quota.spentThisMonth/n.quota.spendLimitMonthly*100,100)}%`}})})]}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx("span",{className:"text-sm",children:"Daily Limit"}),c.jsxs("span",{className:"text-muted-foreground text-sm",children:["$",n.quota.spendLimitDaily.toFixed(2)]})]})]})]}),c.jsxs(Ne,{children:[c.jsxs(De,{children:[c.jsx(Fe,{children:"Metrics Summary"}),c.jsx(Ye,{children:"Detailed breakdown of your SMS performance"})]}),c.jsxs(Le,{className:"space-y-4",children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx("span",{className:"text-sm",children:"Total Messages Sent"}),c.jsx(He,{variant:"outline",children:d.toLocaleString()})]}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx("span",{className:"text-sm",children:"Successfully Delivered"}),c.jsx(He,{variant:"default",children:h.toLocaleString()})]}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx("span",{className:"text-sm",children:"Failed"}),c.jsx(He,{variant:"destructive",children:v.toLocaleString()})]}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx("span",{className:"text-sm",children:"Opt Outs"}),c.jsx(He,{variant:"secondary",children:p.toLocaleString()})]})]})]})]})}function x4({status:e}){const t=e==="ACTIVE"||e==="SUCCESS";return c.jsxs(He,{className:t?"border-green-500/20 bg-green-500/10 text-green-700 dark:text-green-400":"border-yellow-500/20 bg-yellow-500/10 text-yellow-700 dark:text-yellow-400",variant:"outline",children:[t?c.jsx(Zi,{className:"mr-1 h-3 w-3"}):c.jsx(ir,{className:"mr-1 h-3 w-3"}),e]})}function cpe({phoneNumber:e}){if(!e)return c.jsx(Ne,{children:c.jsxs(De,{children:[c.jsxs(Fe,{className:"flex items-center gap-2",children:[c.jsx(Wh,{className:"h-5 w-5"}),"Phone Number"]}),c.jsx(Ye,{children:"No phone number configured"})]})});const t=r=>r.startsWith("+1")&&r.length===12?`(${r.slice(2,5)}) ${r.slice(5,8)}-${r.slice(8)}`:r,n=r=>{switch(r){case"simulator":return"Simulator";case"toll-free":return"Toll-Free";case"10dlc":return"10DLC";case"short-code":return"Short Code";default:return r}};return c.jsxs(Ne,{children:[c.jsxs(De,{children:[c.jsxs(Fe,{className:"flex items-center gap-2",children:[c.jsx(Wh,{className:"h-5 w-5"}),"Phone Number"]}),c.jsx(Ye,{children:"Your SMS sending number"})]}),c.jsxs(Le,{className:"space-y-4",children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{children:[c.jsx("p",{className:"font-medium font-mono text-lg",children:t(e.number)}),c.jsx("p",{className:"text-muted-foreground text-sm",children:n(e.type)})]}),c.jsx(x4,{status:e.status})]}),e.registrationStatus&&c.jsxs(c.Fragment,{children:[c.jsx(Bt,{}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{children:[c.jsx("p",{className:"font-medium text-sm",children:"Registration Status"}),c.jsx("p",{className:"text-muted-foreground text-sm",children:e.type==="toll-free"?"Toll-free verification":"Campaign registration"})]}),c.jsx(x4,{status:e.registrationStatus})]})]}),e.capabilities.length>0&&c.jsxs(c.Fragment,{children:[c.jsx(Bt,{}),c.jsxs("div",{className:"space-y-2",children:[c.jsx("p",{className:"font-medium text-sm",children:"Capabilities"}),c.jsx("div",{className:"flex flex-wrap gap-2",children:e.capabilities.map(r=>c.jsx(He,{variant:"secondary",children:r},r))})]})]}),e.monthlyLeasingPrice&&c.jsxs(c.Fragment,{children:[c.jsx(Bt,{}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{children:[c.jsx("p",{className:"font-medium text-sm",children:"Monthly Cost"}),c.jsx("p",{className:"text-muted-foreground text-sm",children:"Phone number lease"})]}),c.jsxs("span",{className:"font-mono text-sm",children:["$",e.monthlyLeasingPrice,"/mo"]})]})]}),e.type==="simulator"&&c.jsxs(In,{children:[c.jsx(ir,{className:"h-4 w-4"}),c.jsx(Xi,{children:"Simulator Mode"}),c.jsx(zn,{children:"This number is for testing only. Messages are simulated and not actually sent. Upgrade to a toll-free number for production use."})]}),e.type==="toll-free"&&e.registrationStatus!=="VERIFIED"&&c.jsxs(In,{children:[c.jsx(ir,{className:"h-4 w-4"}),c.jsx(Xi,{children:"Registration Required"}),c.jsxs(zn,{children:["Toll-free numbers require registration before they can send messages. Run ",c.jsx("code",{children:"wraps sms register"})," to complete registration."]})]})]})]})}function upe({protectConfig:e}){return e!=null&&e.enabled?c.jsxs(Ne,{children:[c.jsxs(De,{children:[c.jsxs(Fe,{className:"flex items-center gap-2",children:[c.jsx(Kh,{className:"h-5 w-5"}),"Fraud Protection"]}),c.jsx(Ye,{children:"Country restrictions and AIT filtering"})]}),c.jsxs(Le,{className:"space-y-4",children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{children:[c.jsx("p",{className:"font-medium text-sm",children:"Status"}),c.jsx("p",{className:"text-muted-foreground text-sm",children:"Protect configuration active"})]}),c.jsxs(He,{className:"border-green-500/20 bg-green-500/10 text-green-700 dark:text-green-400",variant:"outline",children:[c.jsx(Zi,{className:"mr-1 h-3 w-3"}),"Enabled"]})]}),c.jsx(Bt,{}),c.jsxs("div",{className:"space-y-2",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(ku,{className:"h-4 w-4 text-muted-foreground"}),c.jsx("p",{className:"font-medium text-sm",children:"Allowed Countries"})]}),c.jsx("div",{className:"flex flex-wrap gap-2",children:e.allowedCountries.map(t=>c.jsx(He,{variant:"secondary",children:t},t))}),c.jsx("p",{className:"text-muted-foreground text-xs",children:"Messages can only be sent to these countries. All others are blocked."})]}),c.jsx(Bt,{}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{children:[c.jsx("p",{className:"font-medium text-sm",children:"AIT Filtering"}),c.jsx("p",{className:"text-muted-foreground text-sm",children:e.aitFiltering?"Enabled - adds per-message cost":"Disabled - no extra cost"})]}),c.jsx(He,{variant:e.aitFiltering?"default":"secondary",children:e.aitFiltering?"Enabled":"Disabled"})]})]})]}):c.jsx(Ne,{children:c.jsxs(De,{children:[c.jsxs(Fe,{className:"flex items-center gap-2",children:[c.jsx(Kh,{className:"h-5 w-5"}),"Fraud Protection"]}),c.jsx(Ye,{children:"Not configured"})]})})}function fpe({configSet:e,onRefresh:t}){const[n,r]=j.useState(!1),[i,s]=j.useState(!1);if(!e)return c.jsx(Ne,{children:c.jsxs(De,{children:[c.jsxs(Fe,{className:"flex items-center gap-2",children:[c.jsx(Yi,{className:"h-5 w-5"}),"Configuration Set"]}),c.jsx(Ye,{children:"No configuration set found"})]})});const l=async()=>{s(!0);try{const f=sessionStorage.getItem("wraps-auth-token"),d=!e.sendingEnabled,h=await fetch(`/api/sms/settings/sending?token=${f}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({enabled:d})});if(!h.ok)throw new Error(`Failed to update: ${h.statusText}`);r(!1),wt.success(d?"SMS sending enabled":"SMS sending disabled"),t&&await t()}catch(f){console.error("Failed to toggle sending:",f),wt.error("Failed to update setting",{description:f instanceof Error?f.message:"Unknown error"})}finally{s(!1)}};return c.jsxs(Ne,{children:[c.jsxs(De,{children:[c.jsxs(Fe,{className:"flex items-center gap-2",children:[c.jsx(Yi,{className:"h-5 w-5"}),"Configuration Set"]}),c.jsx(Ye,{children:"SMS sending configuration"})]}),c.jsxs(Le,{className:"space-y-4",children:[c.jsxs("div",{children:[c.jsx("p",{className:"font-medium",children:e.name}),c.jsx("p",{className:"text-muted-foreground text-sm",children:"Configuration Set Name"})]}),c.jsx(Bt,{}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{className:"flex-1 space-y-0.5",children:[c.jsx("p",{className:"font-medium text-sm",children:"SMS Sending"}),c.jsx("p",{className:"text-muted-foreground text-sm",children:e.sendingEnabled?"Messages can be sent":"Message sending is disabled"})]}),c.jsx(Ee,{onClick:()=>r(!0),size:"sm",variant:e.sendingEnabled?"destructive":"default",children:e.sendingEnabled?"Disable":"Enable"})]}),c.jsx(up,{onOpenChange:r,open:n,children:c.jsxs(fp,{children:[c.jsxs(dp,{children:[c.jsx(mp,{children:e.sendingEnabled?"Disable SMS sending?":"Enable SMS sending?"}),c.jsx(pp,{children:e.sendingEnabled?"All outgoing SMS messages will be blocked until you re-enable sending.":"This will allow SMS messages to be sent through this configuration set."})]}),c.jsxs(hp,{children:[c.jsx(gp,{disabled:i,children:"Cancel"}),c.jsx(vp,{disabled:i,onClick:l,children:i?"Updating...":e.sendingEnabled?"Disable sending":"Enable sending"})]})]})})]})]})}function dpe({eventTracking:e}){return c.jsxs(Ne,{children:[c.jsxs(De,{children:[c.jsx(Fe,{children:"Event Tracking"}),c.jsx(Ye,{children:"Message history and event storage"})]}),c.jsxs(Le,{className:"space-y-4",children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{children:[c.jsx("p",{className:"font-medium text-sm",children:"Event Tracking"}),c.jsx("p",{className:"text-muted-foreground text-sm",children:e!=null&&e.enabled?"Tracking delivery events":"Event tracking disabled"})]}),c.jsx(He,{variant:e!=null&&e.enabled?"default":"secondary",children:e!=null&&e.enabled?"Enabled":"Disabled"})]}),(e==null?void 0:e.enabled)&&c.jsxs(c.Fragment,{children:[c.jsx(Bt,{}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{children:[c.jsx("p",{className:"font-medium text-sm",children:"Message History"}),c.jsx("p",{className:"text-muted-foreground text-sm",children:e.dynamoDBHistory?"Stored in DynamoDB":"Not stored"})]}),c.jsx(He,{variant:e.dynamoDBHistory?"default":"secondary",children:e.dynamoDBHistory?"Enabled":"Disabled"})]}),e.archiveRetention&&c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{children:[c.jsx("p",{className:"font-medium text-sm",children:"Retention Period"}),c.jsx("p",{className:"text-muted-foreground text-sm",children:"How long message history is kept"})]}),c.jsx(He,{variant:"outline",children:e.archiveRetention})]})]})]})]})}function hpe(){const[e,t]=j.useState(null),[n,r]=j.useState(!0),[i,s]=j.useState(null),l=j.useCallback(async()=>{try{r(!0);const f=sessionStorage.getItem("wraps-auth-token");if(!f)throw new Error("Authentication token not found");const d=await fetch(`/api/sms/settings?token=${f}`);if(!d.ok)throw new Error(`Failed to fetch settings: ${d.statusText}`);const h=await d.json();t(h),s(null)}catch(f){console.error("Failed to fetch SMS settings:",f),s(f instanceof Error?f.message:"Failed to load settings")}finally{r(!1)}},[]);return j.useEffect(()=>{l()},[l]),n?c.jsxs(c.Fragment,{children:[c.jsxs("div",{children:[c.jsx("h1",{className:"font-semibold text-3xl tracking-tight",children:"SMS Settings"}),c.jsx("p",{className:"mt-2 text-muted-foreground",children:"Configure your SMS settings and preferences"})]}),c.jsxs("div",{className:"mt-6 grid gap-6 md:grid-cols-2",children:[c.jsxs(Ne,{children:[c.jsxs(De,{children:[c.jsx(Re,{className:"h-6 w-48"}),c.jsx(Re,{className:"mt-2 h-4 w-64"})]}),c.jsx(Le,{children:c.jsx(Re,{className:"h-20 w-full"})})]}),c.jsxs(Ne,{children:[c.jsxs(De,{children:[c.jsx(Re,{className:"h-6 w-48"}),c.jsx(Re,{className:"mt-2 h-4 w-64"})]}),c.jsx(Le,{children:c.jsx(Re,{className:"h-20 w-full"})})]})]})]}):i?c.jsxs(c.Fragment,{children:[c.jsxs("div",{children:[c.jsx("h1",{className:"font-semibold text-3xl tracking-tight",children:"SMS Settings"}),c.jsx("p",{className:"mt-2 text-muted-foreground",children:"Configure your SMS settings and preferences"})]}),c.jsxs(In,{className:"mt-6",variant:"destructive",children:[c.jsx(ir,{className:"h-4 w-4"}),c.jsx(Xi,{children:"Error Loading Settings"}),c.jsx(zn,{children:i})]})]}):c.jsxs(c.Fragment,{children:[c.jsxs("div",{children:[c.jsx("h1",{className:"font-semibold text-3xl tracking-tight",children:"SMS Settings"}),c.jsx("p",{className:"mt-2 text-muted-foreground",children:"Configure your SMS settings and preferences"})]}),c.jsxs("div",{className:"mt-6 grid gap-6 md:grid-cols-2",children:[c.jsx(cpe,{phoneNumber:e==null?void 0:e.phoneNumber}),c.jsx(fpe,{configSet:e==null?void 0:e.configurationSet,onRefresh:l}),c.jsx(upe,{protectConfig:e==null?void 0:e.protectConfiguration}),c.jsx(dpe,{eventTracking:e==null?void 0:e.eventTracking})]})]})}var QB=["PageUp","PageDown"],ZB=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],JB={"from-left":["Home","PageDown","ArrowDown","ArrowLeft"],"from-right":["Home","PageDown","ArrowDown","ArrowRight"],"from-bottom":["Home","PageDown","ArrowDown","ArrowLeft"],"from-top":["Home","PageDown","ArrowUp","ArrowLeft"]},mc="Slider",[dj,mpe,ppe]=Op(mc),[e6]=qn(mc,[ppe]),[vpe,Mv]=e6(mc),t6=j.forwardRef((e,t)=>{const{name:n,min:r=0,max:i=100,step:s=1,orientation:l="horizontal",disabled:f=!1,minStepsBetweenThumbs:d=0,defaultValue:h=[r],value:v,onValueChange:p=()=>{},onValueCommit:g=()=>{},inverted:b=!1,form:O,...S}=e,x=j.useRef(new Set),E=j.useRef(0),_=l==="horizontal"?gpe:ype,[T=[],N]=Vr({prop:v,defaultProp:h,onChange:I=>{var W;(W=[...x.current][E.current])==null||W.focus(),p(I)}}),M=j.useRef(T);function R(I){const H=jpe(T,I);Y(I,H)}function D(I){Y(I,E.current)}function L(){const I=M.current[E.current];T[E.current]!==I&&g(T)}function Y(I,H,{commit:W}={commit:!1}){const Z=Ape(s),X=Npe(Math.round((I-r)/s)*s+r,Z),k=lm(X,[r,i]);N((U=[])=>{const q=wpe(U,k,H);if(_pe(q,d*s)){E.current=q.indexOf(k);const Q=String(q)!==String(U);return Q&&W&&g(q),Q?q:U}else return U})}return c.jsx(vpe,{scope:e.__scopeSlider,name:n,disabled:f,min:r,max:i,valueIndexToChangeRef:E,thumbs:x.current,values:T,orientation:l,form:O,children:c.jsx(dj.Provider,{scope:e.__scopeSlider,children:c.jsx(dj.Slot,{scope:e.__scopeSlider,children:c.jsx(_,{"aria-disabled":f,"data-disabled":f?"":void 0,...S,ref:t,onPointerDown:be(S.onPointerDown,()=>{f||(M.current=T)}),min:r,max:i,inverted:b,onSlideStart:f?void 0:R,onSlideMove:f?void 0:D,onSlideEnd:f?void 0:L,onHomeKeyDown:()=>!f&&Y(r,0,{commit:!0}),onEndKeyDown:()=>!f&&Y(i,T.length-1,{commit:!0}),onStepKeyDown:({event:I,direction:H})=>{if(!f){const X=QB.includes(I.key)||I.shiftKey&&ZB.includes(I.key)?10:1,k=E.current,U=T[k],q=s*X*H;Y(U+q,k,{commit:!0})}}})})})})});t6.displayName=mc;var[n6,r6]=e6(mc,{startEdge:"left",endEdge:"right",size:"width",direction:1}),gpe=j.forwardRef((e,t)=>{const{min:n,max:r,dir:i,inverted:s,onSlideStart:l,onSlideMove:f,onSlideEnd:d,onStepKeyDown:h,...v}=e,[p,g]=j.useState(null),b=Be(t,_=>g(_)),O=j.useRef(void 0),S=Df(i),x=S==="ltr",E=x&&!s||!x&&s;function A(_){const T=O.current||p.getBoundingClientRect(),N=[0,T.width],R=NE(N,E?[n,r]:[r,n]);return O.current=T,R(_-T.left)}return c.jsx(n6,{scope:e.__scopeSlider,startEdge:E?"left":"right",endEdge:E?"right":"left",direction:E?1:-1,size:"width",children:c.jsx(a6,{dir:S,"data-orientation":"horizontal",...v,ref:b,style:{...v.style,"--radix-slider-thumb-transform":"translateX(-50%)"},onSlideStart:_=>{const T=A(_.clientX);l==null||l(T)},onSlideMove:_=>{const T=A(_.clientX);f==null||f(T)},onSlideEnd:()=>{O.current=void 0,d==null||d()},onStepKeyDown:_=>{const N=JB[E?"from-left":"from-right"].includes(_.key);h==null||h({event:_,direction:N?-1:1})}})})}),ype=j.forwardRef((e,t)=>{const{min:n,max:r,inverted:i,onSlideStart:s,onSlideMove:l,onSlideEnd:f,onStepKeyDown:d,...h}=e,v=j.useRef(null),p=Be(t,v),g=j.useRef(void 0),b=!i;function O(S){const x=g.current||v.current.getBoundingClientRect(),E=[0,x.height],_=NE(E,b?[r,n]:[n,r]);return g.current=x,_(S-x.top)}return c.jsx(n6,{scope:e.__scopeSlider,startEdge:b?"bottom":"top",endEdge:b?"top":"bottom",size:"height",direction:b?1:-1,children:c.jsx(a6,{"data-orientation":"vertical",...h,ref:p,style:{...h.style,"--radix-slider-thumb-transform":"translateY(50%)"},onSlideStart:S=>{const x=O(S.clientY);s==null||s(x)},onSlideMove:S=>{const x=O(S.clientY);l==null||l(x)},onSlideEnd:()=>{g.current=void 0,f==null||f()},onStepKeyDown:S=>{const E=JB[b?"from-bottom":"from-top"].includes(S.key);d==null||d({event:S,direction:E?-1:1})}})})}),a6=j.forwardRef((e,t)=>{const{__scopeSlider:n,onSlideStart:r,onSlideMove:i,onSlideEnd:s,onHomeKeyDown:l,onEndKeyDown:f,onStepKeyDown:d,...h}=e,v=Mv(mc,n);return c.jsx(Ce.span,{...h,ref:t,onKeyDown:be(e.onKeyDown,p=>{p.key==="Home"?(l(p),p.preventDefault()):p.key==="End"?(f(p),p.preventDefault()):QB.concat(ZB).includes(p.key)&&(d(p),p.preventDefault())}),onPointerDown:be(e.onPointerDown,p=>{const g=p.target;g.setPointerCapture(p.pointerId),p.preventDefault(),v.thumbs.has(g)?g.focus():r(p)}),onPointerMove:be(e.onPointerMove,p=>{p.target.hasPointerCapture(p.pointerId)&&i(p)}),onPointerUp:be(e.onPointerUp,p=>{const g=p.target;g.hasPointerCapture(p.pointerId)&&(g.releasePointerCapture(p.pointerId),s(p))})})}),i6="SliderTrack",o6=j.forwardRef((e,t)=>{const{__scopeSlider:n,...r}=e,i=Mv(i6,n);return c.jsx(Ce.span,{"data-disabled":i.disabled?"":void 0,"data-orientation":i.orientation,...r,ref:t})});o6.displayName=i6;var hj="SliderRange",s6=j.forwardRef((e,t)=>{const{__scopeSlider:n,...r}=e,i=Mv(hj,n),s=r6(hj,n),l=j.useRef(null),f=Be(t,l),d=i.values.length,h=i.values.map(g=>u6(g,i.min,i.max)),v=d>1?Math.min(...h):0,p=100-Math.max(...h);return c.jsx(Ce.span,{"data-orientation":i.orientation,"data-disabled":i.disabled?"":void 0,...r,ref:f,style:{...e.style,[s.startEdge]:v+"%",[s.endEdge]:p+"%"}})});s6.displayName=hj;var mj="SliderThumb",l6=j.forwardRef((e,t)=>{const n=mpe(e.__scopeSlider),[r,i]=j.useState(null),s=Be(t,f=>i(f)),l=j.useMemo(()=>r?n().findIndex(f=>f.ref.current===r):-1,[n,r]);return c.jsx(bpe,{...e,ref:s,index:l})}),bpe=j.forwardRef((e,t)=>{const{__scopeSlider:n,index:r,name:i,...s}=e,l=Mv(mj,n),f=r6(mj,n),[d,h]=j.useState(null),v=Be(t,A=>h(A)),p=d?l.form||!!d.closest("form"):!0,g=Cp(d),b=l.values[r],O=b===void 0?0:u6(b,l.min,l.max),S=Spe(r,l.values.length),x=g==null?void 0:g[f.size],E=x?Ope(x,O,f.direction):0;return j.useEffect(()=>{if(d)return l.thumbs.add(d),()=>{l.thumbs.delete(d)}},[d,l.thumbs]),c.jsxs("span",{style:{transform:"var(--radix-slider-thumb-transform)",position:"absolute",[f.startEdge]:`calc(${O}% + ${E}px)`},children:[c.jsx(dj.ItemSlot,{scope:e.__scopeSlider,children:c.jsx(Ce.span,{role:"slider","aria-label":e["aria-label"]||S,"aria-valuemin":l.min,"aria-valuenow":b,"aria-valuemax":l.max,"aria-orientation":l.orientation,"data-orientation":l.orientation,"data-disabled":l.disabled?"":void 0,tabIndex:l.disabled?void 0:0,...s,ref:v,style:b===void 0?{display:"none"}:e.style,onFocus:be(e.onFocus,()=>{l.valueIndexToChangeRef.current=r})})}),p&&c.jsx(c6,{name:i??(l.name?l.name+(l.values.length>1?"[]":""):void 0),form:l.form,value:b},r)]})});l6.displayName=mj;var xpe="RadioBubbleInput",c6=j.forwardRef(({__scopeSlider:e,value:t,...n},r)=>{const i=j.useRef(null),s=Be(i,r),l=Vp(t);return j.useEffect(()=>{const f=i.current;if(!f)return;const d=window.HTMLInputElement.prototype,v=Object.getOwnPropertyDescriptor(d,"value").set;if(l!==t&&v){const p=new Event("input",{bubbles:!0});v.call(f,t),f.dispatchEvent(p)}},[l,t]),c.jsx(Ce.input,{style:{display:"none"},...n,ref:s,defaultValue:t})});c6.displayName=xpe;function wpe(e=[],t,n){const r=[...e];return r[n]=t,r.sort((i,s)=>i-s)}function u6(e,t,n){const s=100/(n-t)*(e-t);return lm(s,[0,100])}function Spe(e,t){return t>2?`Value ${e+1} of ${t}`:t===2?["Minimum","Maximum"][e]:void 0}function jpe(e,t){if(e.length===1)return 0;const n=e.map(i=>Math.abs(i-t)),r=Math.min(...n);return n.indexOf(r)}function Ope(e,t,n){const r=e/2,s=NE([0,50],[0,r]);return(r-s(t)*n)*n}function Epe(e){return e.slice(0,-1).map((t,n)=>e[n+1]-t)}function _pe(e,t){if(t>0){const n=Epe(e);return Math.min(...n)>=t}return!0}function NE(e,t){return n=>{if(e[0]===e[1]||t[0]===t[1])return t[0];const r=(t[1]-t[0])/(e[1]-e[0]);return t[0]+r*(n-e[0])}}function Ape(e){return(String(e).split(".")[1]||"").length}function Npe(e,t){const n=Math.pow(10,t);return Math.round(e*n)/n}var Tpe=t6,Cpe=o6,Mpe=s6,Rpe=l6;function Dpe({className:e,defaultValue:t,value:n,min:r=0,max:i=100,...s}){const l=j.useMemo(()=>Array.isArray(n)?n:Array.isArray(t)?t:[r,i],[n,t,r,i]);return c.jsxs(Tpe,{className:ve("relative flex w-full touch-none select-none items-center data-[orientation=vertical]:h-full data-[orientation=vertical]:min-h-44 data-[orientation=vertical]:w-auto data-[orientation=vertical]:flex-col data-[disabled]:opacity-50",e),"data-slot":"slider",defaultValue:t,max:i,min:r,value:n,...s,children:[c.jsx(Cpe,{className:ve("relative grow overflow-hidden rounded-full bg-muted data-[orientation=horizontal]:h-1.5 data-[orientation=vertical]:h-full data-[orientation=horizontal]:w-full data-[orientation=vertical]:w-1.5"),"data-slot":"slider-track",children:c.jsx(Mpe,{className:ve("absolute bg-primary data-[orientation=horizontal]:h-full data-[orientation=vertical]:w-full"),"data-slot":"slider-range"})}),Array.from({length:l.length},(f,d)=>c.jsx(Rpe,{className:"block size-4 shrink-0 rounded-full border border-primary bg-white shadow-sm ring-ring/50 transition-[color,box-shadow] hover:ring-4 focus-visible:outline-hidden focus-visible:ring-4 disabled:pointer-events-none disabled:opacity-50","data-slot":"slider-thumb"},`thumb-${l[d]}-${d}`))]})}var Rv="Switch",[Ppe]=qn(Rv),[kpe,$pe]=Ppe(Rv),f6=j.forwardRef((e,t)=>{const{__scopeSwitch:n,name:r,checked:i,defaultChecked:s,required:l,disabled:f,value:d="on",onCheckedChange:h,form:v,...p}=e,[g,b]=j.useState(null),O=Be(t,_=>b(_)),S=j.useRef(!1),x=g?v||!!g.closest("form"):!0,[E,A]=Vr({prop:i,defaultProp:s??!1,onChange:h,caller:Rv});return c.jsxs(kpe,{scope:n,checked:E,disabled:f,children:[c.jsx(Ce.button,{type:"button",role:"switch","aria-checked":E,"aria-required":l,"data-state":p6(E),"data-disabled":f?"":void 0,disabled:f,value:d,...p,ref:O,onClick:be(e.onClick,_=>{A(T=>!T),x&&(S.current=_.isPropagationStopped(),S.current||_.stopPropagation())})}),x&&c.jsx(m6,{control:g,bubbles:!S.current,name:r,value:d,checked:E,required:l,disabled:f,form:v,style:{transform:"translateX(-100%)"}})]})});f6.displayName=Rv;var d6="SwitchThumb",h6=j.forwardRef((e,t)=>{const{__scopeSwitch:n,...r}=e,i=$pe(d6,n);return c.jsx(Ce.span,{"data-state":p6(i.checked),"data-disabled":i.disabled?"":void 0,...r,ref:t})});h6.displayName=d6;var Lpe="SwitchBubbleInput",m6=j.forwardRef(({__scopeSwitch:e,control:t,checked:n,bubbles:r=!0,...i},s)=>{const l=j.useRef(null),f=Be(l,s),d=Vp(n),h=Cp(t);return j.useEffect(()=>{const v=l.current;if(!v)return;const p=window.HTMLInputElement.prototype,b=Object.getOwnPropertyDescriptor(p,"checked").set;if(d!==n&&b){const O=new Event("click",{bubbles:r});b.call(v,n),v.dispatchEvent(O)}},[d,n,r]),c.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:n,...i,tabIndex:-1,ref:f,style:{...i.style,...h,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});m6.displayName=Lpe;function p6(e){return e?"checked":"unchecked"}var Ipe=f6,zpe=h6;function Bpe({className:e,...t}){return c.jsx(Ipe,{className:ve("peer inline-flex h-[1.15rem] w-8 shrink-0 items-center rounded-full border border-transparent shadow-xs outline-none transition-all focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input dark:data-[state=unchecked]:bg-input/80",e),"data-slot":"switch",...t,children:c.jsx(zpe,{className:ve("pointer-events-none block size-4 rounded-full bg-background ring-0 transition-transform data-[state=checked]:translate-x-[calc(100%-2px)] data-[state=unchecked]:translate-x-0 dark:data-[state=checked]:bg-primary-foreground dark:data-[state=unchecked]:bg-foreground"),"data-slot":"switch-thumb"})})}async function w4(e){try{const t=document.createElement("canvas");return t.width=1,t.height=1,t.toDataURL(e).startsWith(`data:${e}`)}catch{return!1}}async function qpe(){const[e,t]=await Promise.all([w4("image/webp"),w4("image/avif")]);return{webp:e,avif:t,offscreenCanvas:typeof OffscreenCanvas<"u",webWorker:typeof Worker<"u",wasm:typeof WebAssembly<"u"}}let $h=null;async function Upe(){return $h||($h=await qpe(),$h)}async function Hpe(e){if(e.type!=="image/gif")return{isAnimated:!1,frameCount:1,size:e.size};try{const t=await e.arrayBuffer(),n=new Uint8Array(t);let r=0;for(let i=0;i<n.length-2;i++)n[i]===33&&n[i+1]===249&&r++;return{isAnimated:r>1,frameCount:Math.max(1,r),size:e.size}}catch{return{isAnimated:!1,frameCount:1,size:e.size}}}function Fpe(e){return e.type==="image/gif"}function Gpe(e){return new Promise((t,n)=>{const r=new FileReader;r.onload=()=>t(r.result),r.onerror=()=>n(new Error("Failed to read blob")),r.readAsDataURL(e)})}function v6(e){return Gpe(e)}function Lh(e){if(e===0)return"0 B";const t=1024,n=["B","KB","MB","GB"],r=Math.floor(Math.log(e)/Math.log(t));return`${Number.parseFloat((e/t**r).toFixed(1))} ${n[r]}`}function Vpe(e){return new Promise((t,n)=>{const r=new Image,i=URL.createObjectURL(e);r.onload=()=>{URL.revokeObjectURL(i),t({width:r.naturalWidth,height:r.naturalHeight})},r.onerror=()=>{URL.revokeObjectURL(i),n(new Error("Failed to load image"))},r.src=i})}class Ype{constructor(){Gy(this,"worker",null);Gy(this,"pending",new Map)}getWorker(){return this.worker||(this.worker=new Worker(new URL("/assets/optimizer.worker-CeufIUo5.js",import.meta.url),{type:"module"}),this.worker.onmessage=this.handleMessage.bind(this),this.worker.onerror=this.handleError.bind(this)),this.worker}handleMessage(t){const{id:n,result:r,error:i,progress:s}=t.data,l=this.pending.get(n);if(l){if(s!==void 0&&s<100&&l.onProgress){l.onProgress(s);return}if(i){l.reject(new Error(i)),this.pending.delete(n);return}r&&(l.resolve(r),this.pending.delete(n))}}handleError(t){console.error("Image optimizer worker error:",t);for(const[n,r]of this.pending)r.reject(new Error(`Worker error: ${t.message}`)),this.pending.delete(n);this.terminate()}generateId(){return crypto.randomUUID()}async optimize(t,n,r){const i=this.generateId();return new Promise((s,l)=>{this.pending.set(i,{resolve:s,reject:l,onProgress:r}),this.getWorker().postMessage({id:i,type:"optimize",file:t,options:n})})}async preview(t,n,r){const i=await v6(t);return{...await this.optimize(t,n,r),originalDataUrl:i}}cancelAll(){for(const[t,n]of this.pending)n.reject(new Error("Operation cancelled")),this.pending.delete(t)}terminate(){this.cancelAll(),this.worker&&(this.worker.terminate(),this.worker=null)}get isActive(){return this.worker!==null}get pendingCount(){return this.pending.size}}const Wpe=new Ype;async function Kpe(e,t,n){return Wpe.preview(e,t,n)}const Xpe=[{value:"webp",label:"WebP",description:"Best balance of size and quality"},{value:"avif",label:"AVIF",description:"Best compression"},{value:"jpeg",label:"JPEG",description:"Universal compatibility"},{value:"png",label:"PNG",description:"Lossless, supports transparency"},{value:"original",label:"Original",description:"Keep original format"}],Qpe=[{value:1,label:"1x",description:"Standard displays"},{value:2,label:"2x",description:"Retina / HiDPI (recommended)"},{value:3,label:"3x",description:"iPhone Pro / flagship phones"}];function pj(e){const t=e/1024,n=t/1024;return n>2?{level:"error",message:"This image will cause delivery issues (>2MB)",suggestion:"Reduce dimensions or increase compression to under 1MB"}:n>1?{level:"warning",message:"Most email clients struggle with images >1MB",suggestion:"Consider reducing to under 500KB for best deliverability"}:t>500?{level:"info",message:"Larger than recommended for email (>500KB)",suggestion:"This may slow load times on mobile devices"}:null}function S1(e){const t=pj(e);if(!t)return{label:"Good",color:"text-green-600"};switch(t.level){case"info":return{label:"OK",color:"text-yellow-600"};case"warning":return{label:"Large",color:"text-orange-600"};case"error":return{label:"Too Large",color:"text-red-600"};default:return{label:"Unknown",color:"text-muted-foreground"}}}const Zpe=[{value:"none",label:"Original size",description:"Keep original dimensions"},{value:"600",label:"Email (600px)",description:"Standard email width"},{value:"800",label:"Medium (800px)",description:"Blog posts, cards"},{value:"1200",label:"Large (1200px)",description:"Full-width content"},{value:"1440",label:"Hero (1440px)",description:"Banner images"},{value:"1920",label:"Full HD (1920px)",description:"Desktop screens"}];function Jpe({files:e,onComplete:t,onClose:n,open:r}){var V;const[i,s]=j.useState([]),[l,f]=j.useState(null),[d,h]=j.useState(!1),v=i.reduce((F,ne)=>F+ne.file.size,0),p=i.reduce((F,ne)=>{var fe;return F+(((fe=ne.preview)==null?void 0:fe.optimizedSize)??ne.file.size)},0),g=v>0?Math.round((1-p/v)*100):0,b=i.length>0&&i.every(F=>F.status==="ready"||F.status==="done"||F.isAnimatedGif),O=i.some(F=>F.status==="pending"&&!F.isAnimatedGif),S=i.some(F=>F.status==="processing"),[x,E]=j.useState(!0),[A,_]=j.useState(!1),[T,N]=j.useState({format:"webp",quality:85}),[M,R]=j.useState(85),[D,L]=j.useState("none"),[Y,I]=j.useState(2),[H,W]=j.useState(!0);j.useEffect(()=>{Upe().then(F=>{W(F.wasm&&F.webWorker&&F.offscreenCanvas)})},[]),j.useEffect(()=>{var ne;if(!r||e.length===0)return;const F=e.map((fe,oe)=>({id:`${fe.name}-${oe}-${Date.now()}`,file:fe,status:"pending"}));s(F),f(((ne=F[0])==null?void 0:ne.id)??null),_(!1),h(!1);for(const fe of F)v6(fe.file).then(oe=>{s(me=>me.map(ae=>ae.id===fe.id?{...ae,thumbnailUrl:oe}:ae))}),Fpe(fe.file)&&Hpe(fe.file).then(oe=>{oe.isAnimated&&s(me=>me.map(ae=>ae.id===fe.id?{...ae,isAnimatedGif:!0,status:"ready"}:ae))})},[r,e]);const Z=j.useCallback(async()=>{const F=i.filter(ne=>ne.status==="pending"&&!ne.isAnimatedGif);if(F.length===0){h(!1);return}for(const ne of F){s(fe=>fe.map(oe=>oe.id===ne.id?{...oe,status:"processing"}:oe));try{let fe;if(D==="none"){if(Y>1){const ae=await Vpe(ne.file);fe=Math.round(ae.width/Y)}}else fe=Number(D)*Y;const oe={...T,maxWidth:fe},me=await Kpe(ne.file,oe);s(ae=>ae.map(pe=>pe.id===ne.id?{...pe,status:"ready",preview:me}:pe))}catch{s(fe=>fe.map(oe=>oe.id===ne.id?{...oe,status:"ready"}:oe))}}h(!1)},[i,T,D,Y]),X=`${T.format}-${T.quality}-${D}-${Y}`,k=j.useRef(X);j.useEffect(()=>{k.current!==X&&(k.current=X,s(F=>F.map(ne=>ne.isAnimatedGif?ne:{...ne,status:"pending",preview:void 0})),h(!1))},[X]);const U=F=>{const ne=F.name.replace(/\.[^/.]+$/,""),fe=T.format==="original"?F.name.split(".").pop():T.format;return`${ne}.${fe}`},q=()=>{h(!0),Z()},Q=()=>{const F=i.map(ne=>!x||ne.isAnimatedGif||!ne.preview?{file:ne.file,cdnFilename:ne.file.name}:{file:ne.preview.blob,cdnFilename:U(ne.file)});t(F),n()},le=()=>{const F=i.map(ne=>({file:ne.file,cdnFilename:ne.file.name}));t(F),n()};if(!r)return null;const $=i.length===1,B=$?i[0]:null;return c.jsx(EE,{onOpenChange:F=>!F&&n(),open:r,children:c.jsxs(_E,{className:"max-w-lg",children:[c.jsx(FB,{children:c.jsx(VB,{className:"flex items-center gap-2",children:$?c.jsxs(c.Fragment,{children:[c.jsx(nb,{className:"h-5 w-5 text-muted-foreground"}),c.jsx("span",{className:"truncate",children:B==null?void 0:B.file.name})]}):c.jsxs(c.Fragment,{children:[c.jsx(nb,{className:"h-5 w-5 text-muted-foreground"}),i.length," images selected"]})})}),c.jsxs("div",{className:"space-y-4",children:[!$&&c.jsxs("div",{className:"grid grid-cols-6 gap-2",children:[i.slice(0,11).map(F=>c.jsxs(Up,{children:[c.jsx(Hp,{asChild:!0,children:c.jsxs("div",{className:`relative aspect-square overflow-hidden rounded-md border bg-muted ${F.id===l?"ring-2 ring-primary":""}`,children:[F.thumbnailUrl?c.jsx("img",{alt:F.file.name,className:"h-full w-full object-cover",src:F.thumbnailUrl}):c.jsx("div",{className:"flex h-full items-center justify-center",children:c.jsx(nb,{className:"h-4 w-4 text-muted-foreground"})}),F.status==="processing"&&c.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-background/50",children:c.jsx(ol,{className:"h-3 w-3 animate-spin"})}),F.status==="ready"&&F.preview&&c.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-green-500/20",children:c.jsx(Vi,{className:"h-4 w-4 text-green-600"})}),F.isAnimatedGif&&c.jsx(He,{className:"absolute right-0.5 bottom-0.5 h-4 px-1 text-[10px]",children:"GIF"})]})}),c.jsxs(Fp,{side:"bottom",children:[c.jsx("p",{className:"font-medium text-xs",children:F.file.name}),c.jsxs("p",{className:"text-muted-foreground text-xs",children:[Lh(F.file.size),F.preview&&` → ${Lh(F.preview.optimizedSize)}`]})]})]},F.id)),i.length>11&&c.jsxs("div",{className:"flex aspect-square items-center justify-center rounded-md border bg-muted text-muted-foreground text-xs",children:["+",i.length-11]})]}),$&&B&&c.jsxs("div",{className:"relative aspect-video overflow-hidden rounded-lg border bg-muted",children:[B.thumbnailUrl?c.jsx("img",{alt:B.file.name,className:"h-full w-full object-contain",src:B.thumbnailUrl}):c.jsx("div",{className:"flex h-full items-center justify-center",children:c.jsx(ol,{className:"h-6 w-6 animate-spin text-muted-foreground"})}),B.status==="processing"&&c.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-background/50",children:c.jsx(ol,{className:"h-6 w-6 animate-spin"})}),B.status==="ready"&&B.preview&&c.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-green-500/10",children:c.jsx(Vi,{className:"h-8 w-8 text-green-600"})})]}),c.jsxs("div",{className:"rounded-lg border bg-muted/30 p-4",children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{children:[c.jsxs("p",{className:"text-muted-foreground text-sm",children:[c.jsx("span",{className:S1(v).color,children:Lh(v)}),x&&b&&g>0&&c.jsxs(c.Fragment,{children:[c.jsx("span",{className:"mx-2",children:"→"}),c.jsx("span",{className:`font-medium ${S1(p).color}`,children:Lh(p)})]})]}),S&&c.jsx("p",{className:"text-muted-foreground text-xs",children:"Optimizing..."}),!S&&pj(b?p:v)&&c.jsx("p",{className:`text-xs ${S1(b?p:v).color}`,children:(V=pj(b?p:v))==null?void 0:V.suggestion})]}),x&&b&&g>0&&c.jsxs(He,{className:"bg-green-100 text-green-700 dark:bg-green-900 dark:text-green-300",variant:"secondary",children:[c.jsx(GH,{className:"mr-1 h-3 w-3"}),"Save ",g,"%"]})]}),S&&c.jsx(Tv,{className:"mt-3 h-1",value:i.filter(F=>F.status==="ready"||F.isAnimatedGif).length/i.length*100})]}),H&&c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx(Po,{className:"cursor-pointer",htmlFor:"optimize-toggle",children:"Optimize before uploading"}),c.jsx(Bpe,{checked:x,id:"optimize-toggle",onCheckedChange:E})]}),x&&H&&c.jsxs(fc,{onOpenChange:_,open:A,children:[c.jsx(dc,{asChild:!0,children:c.jsxs(Ee,{className:"w-full justify-start text-muted-foreground",size:"sm",variant:"ghost",children:[A?c.jsx(Jo,{className:"mr-2 h-4 w-4"}):c.jsx(DH,{className:"mr-2 h-4 w-4"}),"Options"]})}),c.jsxs(hc,{className:"space-y-4 pt-2",children:[c.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[c.jsxs("div",{className:"space-y-2",children:[c.jsx(Po,{className:"text-muted-foreground text-xs",children:"Format"}),c.jsxs(fa,{onValueChange:F=>N({...T,format:F}),value:T.format||"webp",children:[c.jsx(ha,{className:"h-9",children:c.jsx(da,{})}),c.jsx(ma,{children:Xpe.map(F=>c.jsx(Ue,{value:F.value,children:F.label},F.value))})]})]}),c.jsxs("div",{className:"space-y-2",children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx(Po,{className:"text-muted-foreground text-xs",children:"Quality"}),c.jsxs("span",{className:"text-muted-foreground text-xs",children:[M,"%"]})]}),c.jsx(Dpe,{className:"mt-2",max:100,min:50,onValueChange:([F])=>R(F),onValueCommit:([F])=>N({...T,quality:F}),step:5,value:[M]})]})]}),c.jsxs("div",{className:"space-y-3 rounded-lg border bg-muted/20 p-3",children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx(Po,{className:"font-medium text-xs",children:"Resize Image"}),c.jsx("span",{className:"text-muted-foreground text-xs",children:"Maintains aspect ratio"})]}),c.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[c.jsxs("div",{className:"space-y-2",children:[c.jsx(Po,{className:"text-muted-foreground text-xs",children:"Max Width"}),c.jsxs(fa,{onValueChange:L,value:D,children:[c.jsx(ha,{className:"h-9",children:c.jsx(da,{})}),c.jsx(ma,{children:Zpe.map(F=>c.jsx(Ue,{value:F.value,children:c.jsxs("div",{className:"flex flex-col",children:[c.jsx("span",{children:F.label}),c.jsx("span",{className:"text-muted-foreground text-xs",children:F.description})]})},F.value))})]})]}),c.jsxs("div",{className:"space-y-2",children:[c.jsx(Po,{className:"text-muted-foreground text-xs",children:"Pixel Density"}),c.jsxs(fa,{onValueChange:F=>I(Number(F)),value:String(Y),children:[c.jsx(ha,{className:"h-9",children:c.jsx(da,{})}),c.jsx(ma,{children:Qpe.map(F=>c.jsx(Ue,{value:String(F.value),children:c.jsxs("div",{className:"flex flex-col",children:[c.jsx("span",{children:F.label}),c.jsx("span",{className:"text-muted-foreground text-xs",children:F.description})]})},F.value))})]})]})]}),c.jsx("p",{className:"text-muted-foreground text-xs",children:D==="none"?Y===1?"Original dimensions preserved":`Scales to 1/${Y} original size`:`Output: ${Number(D)*Y}px actual width`})]})]})]})]}),c.jsxs(GB,{className:"gap-2 sm:gap-0",children:[c.jsx(Ee,{onClick:n,variant:"ghost",children:"Cancel"}),x&&H?c.jsxs(c.Fragment,{children:[c.jsx(Ee,{onClick:le,variant:"outline",children:"Upload originals"}),b?c.jsxs(Ee,{onClick:Q,children:[c.jsx($u,{className:"mr-2 h-4 w-4"}),"Upload",g>0&&` (save ${g}%)`]}):c.jsxs(Ee,{disabled:d||!O,onClick:q,children:[d?c.jsx(ol,{className:"mr-2 h-4 w-4 animate-spin"}):c.jsx(XH,{className:"mr-2 h-4 w-4"}),d?"Optimizing...":"Optimize"]})]}):c.jsxs(Ee,{onClick:le,children:[c.jsx($u,{className:"mr-2 h-4 w-4"}),"Upload"]})]})]})})}function eve(e){return e===0?"0 B":e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(2)} KB`:`${(e/(1024*1024)).toFixed(2)} MB`}function g6(e){var t;return((t=e.split(".").pop())==null?void 0:t.toLowerCase())||""}function tve(e,t){if(e!=null&&e.startsWith("image/"))return!0;const n=t?g6(t):"";return["jpg","jpeg","png","gif","webp","avif","svg","bmp","ico"].includes(n)}function nve({file:e,onClose:t,onToggleStar:n,onDelete:r}){const i=e.key.split("/").pop()||e.key,s=g6(i),l=tve(e.contentType,i),f=()=>{navigator.clipboard.writeText(e.url),wt.success("URL copied to clipboard")},d=()=>{const h=document.createElement("a");h.href=e.url,h.download=i,h.target="_blank",h.click()};return c.jsx(EE,{onOpenChange:h=>!h&&t(),open:!0,children:c.jsx(_E,{className:"max-h-[90vh] max-w-4xl overflow-y-auto",children:c.jsxs("div",{className:"space-y-6",children:[c.jsxs("div",{className:"flex items-start justify-between",children:[c.jsxs("div",{className:"flex-1",children:[c.jsx("h2",{className:"font-bold text-2xl",children:i}),e.key!==i&&c.jsx("p",{className:"mt-1 text-muted-foreground text-sm",children:e.key})]}),c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(Ee,{onClick:()=>n(e.key,!e.starred),size:"icon",variant:"outline",children:c.jsx(Mf,{className:`h-4 w-4 ${e.starred?"fill-yellow-500 text-yellow-500":""}`})}),c.jsx(Ee,{className:"text-destructive hover:text-destructive",onClick:()=>r(e.key),size:"icon",variant:"outline",children:c.jsx(V4,{className:"h-4 w-4"})}),c.jsx(Ee,{onClick:t,size:"icon",variant:"ghost",children:c.jsx(rr,{className:"h-4 w-4"})})]})]}),c.jsx("div",{className:"aspect-video overflow-hidden rounded-lg bg-muted",children:l&&e.url.startsWith("https://")?c.jsx("img",{alt:i,className:"h-full w-full object-contain",src:e.url}):c.jsxs("div",{className:"flex h-full w-full flex-col items-center justify-center gap-2",children:[l?c.jsx(Ej,{className:"h-16 w-16 text-muted-foreground/50"}):c.jsx(_j,{className:"h-16 w-16 text-muted-foreground/50"}),c.jsx("p",{className:"text-muted-foreground text-sm",children:"Preview not available"})]})}),c.jsxs("div",{className:"flex gap-2",children:[c.jsxs(Ee,{className:"flex-1 gap-2",onClick:f,children:[c.jsx(bl,{className:"h-4 w-4"}),"Copy CDN URL"]}),c.jsxs(Ee,{className:"flex-1 gap-2 bg-transparent",onClick:()=>window.open(e.url,"_blank"),variant:"outline",children:[c.jsx(Pu,{className:"h-4 w-4"}),"Open in New Tab"]}),c.jsxs(Ee,{className:"flex-1 gap-2 bg-transparent",onClick:d,variant:"outline",children:[c.jsx(LH,{className:"h-4 w-4"}),"Download"]})]}),c.jsx(Bt,{}),c.jsxs("div",{className:"grid grid-cols-2 gap-6",children:[c.jsx("div",{className:"space-y-4",children:c.jsxs("div",{children:[c.jsx("h3",{className:"mb-2 font-semibold text-sm",children:"File Information"}),c.jsxs("dl",{className:"space-y-2 text-sm",children:[c.jsxs("div",{className:"flex justify-between",children:[c.jsx("dt",{className:"text-muted-foreground",children:"Format"}),c.jsx("dd",{className:"font-medium",children:c.jsx(He,{variant:"secondary",children:s.toUpperCase()})})]}),c.jsxs("div",{className:"flex justify-between",children:[c.jsx("dt",{className:"text-muted-foreground",children:"Size"}),c.jsx("dd",{className:"font-medium",children:eve(e.size)})]}),c.jsxs("div",{className:"flex justify-between",children:[c.jsx("dt",{className:"text-muted-foreground",children:"Content Type"}),c.jsx("dd",{className:"font-medium",children:e.contentType||"Unknown"})]})]})]})}),c.jsx("div",{className:"space-y-4",children:c.jsxs("div",{children:[c.jsx("h3",{className:"mb-2 font-semibold text-sm",children:"Metadata"}),c.jsxs("dl",{className:"space-y-2 text-sm",children:[c.jsxs("div",{className:"flex justify-between",children:[c.jsx("dt",{className:"text-muted-foreground",children:"Last Modified"}),c.jsx("dd",{className:"font-medium",children:V1(new Date(e.lastModified),"MMM d, yyyy 'at' h:mm a")})]}),c.jsxs("div",{className:"flex justify-between",children:[c.jsx("dt",{className:"text-muted-foreground",children:"Starred"}),c.jsx("dd",{className:"font-medium",children:e.starred?"Yes":"No"})]}),e.tags.length>0&&c.jsxs("div",{children:[c.jsx("dt",{className:"mb-1 text-muted-foreground",children:"Tags"}),c.jsx("dd",{className:"flex flex-wrap gap-1",children:e.tags.filter(h=>h.key!=="starred").map(h=>c.jsxs(He,{variant:"secondary",children:[h.key,": ",h.value]},h.key))})]})]})]})})]}),c.jsx(Bt,{}),c.jsxs("div",{children:[c.jsx("h3",{className:"mb-2 font-semibold text-sm",children:"CDN URL"}),c.jsxs("div",{className:"flex gap-2",children:[c.jsx("code",{className:"flex-1 break-all rounded bg-muted px-3 py-2 text-sm",children:e.url}),c.jsx(Ee,{onClick:f,size:"sm",variant:"outline",children:c.jsx(bl,{className:"h-4 w-4"})})]})]})]})})})}function rve({selectedCount:e,onStar:t,onDelete:n,onClearSelection:r}){return c.jsxs("div",{className:"flex items-center justify-between rounded-lg border border-primary/20 bg-primary/5 p-3",children:[c.jsxs("div",{className:"flex items-center gap-3",children:[c.jsxs("span",{className:"font-medium text-sm",children:[e," selected"]}),c.jsxs(Ee,{className:"gap-2 bg-transparent",onClick:t,size:"sm",variant:"outline",children:[c.jsx(Mf,{className:"h-4 w-4"}),"Star"]}),c.jsxs(Ee,{className:"gap-2 bg-transparent text-destructive hover:text-destructive",onClick:n,size:"sm",variant:"outline",children:[c.jsx(V4,{className:"h-4 w-4"}),"Delete"]})]}),c.jsxs(Ee,{className:"gap-2",onClick:r,size:"sm",variant:"ghost",children:[c.jsx(rr,{className:"h-4 w-4"}),"Clear"]})]})}function ave({filters:e,onFiltersChange:t,availableFormats:n}){const r=(e.starred?1:0)+e.formats.length;return c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsxs(Ee,{className:"gap-2",onClick:()=>t({...e,starred:!e.starred}),size:"sm",variant:e.starred?"secondary":"outline",children:[c.jsx(Mf,{className:`h-4 w-4 ${e.starred?"fill-current":""}`}),"Starred"]}),n.length>0&&c.jsxs(IL,{children:[c.jsx(zL,{asChild:!0,children:c.jsxs(Ee,{className:"gap-2 bg-transparent",size:"sm",variant:"outline",children:[c.jsx(zH,{className:"h-4 w-4"}),"Formats",r>0&&c.jsx(He,{className:"ml-1 px-1.5 py-0 text-xs",variant:"secondary",children:r})]})}),c.jsxs(BL,{align:"end",className:"w-48",children:[c.jsx(qL,{children:"File Format"}),c.jsx(P1,{}),n.map(i=>c.jsx(mY,{checked:e.formats.includes(i),onCheckedChange:s=>{t({...e,formats:s?[...e.formats,i]:e.formats.filter(l=>l!==i)})},children:i.toUpperCase()},i))]})]})]})}var Dv="Checkbox",[ive]=qn(Dv),[ove,TE]=ive(Dv);function sve(e){const{__scopeCheckbox:t,checked:n,children:r,defaultChecked:i,disabled:s,form:l,name:f,onCheckedChange:d,required:h,value:v="on",internal_do_not_use_render:p}=e,[g,b]=Vr({prop:n,defaultProp:i??!1,onChange:d,caller:Dv}),[O,S]=j.useState(null),[x,E]=j.useState(null),A=j.useRef(!1),_=O?!!l||!!O.closest("form"):!0,T={checked:g,disabled:s,setChecked:b,control:O,setControl:S,name:f,form:l,value:v,hasConsumerStoppedPropagationRef:A,required:h,defaultChecked:Gi(i)?!1:i,isFormControl:_,bubbleInput:x,setBubbleInput:E};return c.jsx(ove,{scope:t,...T,children:lve(p)?p(T):r})}var y6="CheckboxTrigger",b6=j.forwardRef(({__scopeCheckbox:e,onKeyDown:t,onClick:n,...r},i)=>{const{control:s,value:l,disabled:f,checked:d,required:h,setControl:v,setChecked:p,hasConsumerStoppedPropagationRef:g,isFormControl:b,bubbleInput:O}=TE(y6,e),S=Be(i,v),x=j.useRef(d);return j.useEffect(()=>{const E=s==null?void 0:s.form;if(E){const A=()=>p(x.current);return E.addEventListener("reset",A),()=>E.removeEventListener("reset",A)}},[s,p]),c.jsx(Ce.button,{type:"button",role:"checkbox","aria-checked":Gi(d)?"mixed":d,"aria-required":h,"data-state":E6(d),"data-disabled":f?"":void 0,disabled:f,value:l,...r,ref:S,onKeyDown:be(t,E=>{E.key==="Enter"&&E.preventDefault()}),onClick:be(n,E=>{p(A=>Gi(A)?!0:!A),O&&b&&(g.current=E.isPropagationStopped(),g.current||E.stopPropagation())})})});b6.displayName=y6;var x6=j.forwardRef((e,t)=>{const{__scopeCheckbox:n,name:r,checked:i,defaultChecked:s,required:l,disabled:f,value:d,onCheckedChange:h,form:v,...p}=e;return c.jsx(sve,{__scopeCheckbox:n,checked:i,defaultChecked:s,disabled:f,required:l,onCheckedChange:h,name:r,form:v,value:d,internal_do_not_use_render:({isFormControl:g})=>c.jsxs(c.Fragment,{children:[c.jsx(b6,{...p,ref:t,__scopeCheckbox:n}),g&&c.jsx(O6,{__scopeCheckbox:n})]})})});x6.displayName=Dv;var w6="CheckboxIndicator",S6=j.forwardRef((e,t)=>{const{__scopeCheckbox:n,forceMount:r,...i}=e,s=TE(w6,n);return c.jsx(lr,{present:r||Gi(s.checked)||s.checked===!0,children:c.jsx(Ce.span,{"data-state":E6(s.checked),"data-disabled":s.disabled?"":void 0,...i,ref:t,style:{pointerEvents:"none",...e.style}})})});S6.displayName=w6;var j6="CheckboxBubbleInput",O6=j.forwardRef(({__scopeCheckbox:e,...t},n)=>{const{control:r,hasConsumerStoppedPropagationRef:i,checked:s,defaultChecked:l,required:f,disabled:d,name:h,value:v,form:p,bubbleInput:g,setBubbleInput:b}=TE(j6,e),O=Be(n,b),S=Vp(s),x=Cp(r);j.useEffect(()=>{const A=g;if(!A)return;const _=window.HTMLInputElement.prototype,N=Object.getOwnPropertyDescriptor(_,"checked").set,M=!i.current;if(S!==s&&N){const R=new Event("click",{bubbles:M});A.indeterminate=Gi(s),N.call(A,Gi(s)?!1:s),A.dispatchEvent(R)}},[g,S,s,i]);const E=j.useRef(Gi(s)?!1:s);return c.jsx(Ce.input,{type:"checkbox","aria-hidden":!0,defaultChecked:l??E.current,required:f,disabled:d,name:h,value:v,form:p,...t,tabIndex:-1,ref:O,style:{...t.style,...x,position:"absolute",pointerEvents:"none",opacity:0,margin:0,transform:"translateX(-100%)"}})});O6.displayName=j6;function lve(e){return typeof e=="function"}function Gi(e){return e==="indeterminate"}function E6(e){return Gi(e)?"indeterminate":e?"checked":"unchecked"}function vj({className:e,...t}){return c.jsx(x6,{className:ve("peer size-4 shrink-0 rounded-[4px] border border-input shadow-xs outline-none transition-shadow focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 data-[state=checked]:border-primary data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground dark:bg-input/30 dark:data-[state=checked]:bg-primary dark:aria-invalid:ring-destructive/40",e),"data-slot":"checkbox",...t,children:c.jsx(S6,{className:"grid place-content-center text-current transition-none","data-slot":"checkbox-indicator",children:c.jsx(Vi,{className:"size-3.5"})})})}function cve(e){return e===0?"0 B":e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(0)} KB`:`${(e/(1024*1024)).toFixed(2)} MB`}function _6(e){var t;return((t=e.split(".").pop())==null?void 0:t.toLowerCase())||""}function uve(e,t){if(e!=null&&e.startsWith("image/"))return!0;const n=t?_6(t):"";return["jpg","jpeg","png","gif","webp","avif","svg","bmp","ico"].includes(n)}function fve({files:e,selectedFiles:t,onSelectFile:n,onToggleStar:r,onFileClick:i}){const s=(f,d)=>{f.stopPropagation(),navigator.clipboard.writeText(d),wt.success("URL copied to clipboard")},l=(f,d)=>{f.stopPropagation(),window.open(d,"_blank")};return c.jsx("div",{className:"grid grid-cols-1 gap-4 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4",children:e.map(f=>{const d=f.key.split("/").pop()||f.key,h=_6(d),v=uve(f.contentType,d);return c.jsxs(Ne,{className:"group relative cursor-pointer overflow-hidden transition-colors hover:border-primary/50",onClick:()=>i(f),children:[c.jsxs("div",{className:"relative aspect-video overflow-hidden bg-muted",children:[v&&f.url.startsWith("https://")?c.jsx("img",{alt:d,className:"h-full w-full object-cover",src:f.url}):c.jsx("div",{className:"flex h-full w-full items-center justify-center",children:v?c.jsx(Ej,{className:"h-12 w-12 text-muted-foreground/50"}):c.jsx(_j,{className:"h-12 w-12 text-muted-foreground/50"})}),c.jsx("div",{className:"absolute top-2 left-2 z-10",onClick:p=>p.stopPropagation(),children:c.jsx(vj,{checked:t.includes(f.key),className:"bg-background/80 backdrop-blur-sm",onCheckedChange:()=>n(f.key)})}),c.jsx(Ee,{className:"absolute top-2 right-2 z-10 bg-background/80 backdrop-blur-sm hover:bg-background/90",onClick:p=>{p.stopPropagation(),r(f.key,!f.starred)},size:"icon",variant:"ghost",children:c.jsx(Mf,{className:`h-4 w-4 ${f.starred?"fill-yellow-500 text-yellow-500":""}`})}),c.jsxs("div",{className:"absolute right-2 bottom-2 z-10 flex gap-1 opacity-0 transition-opacity group-hover:opacity-100",children:[c.jsx(Ee,{className:"h-8 w-8",onClick:p=>s(p,f.url),size:"icon",variant:"secondary",children:c.jsx(bl,{className:"h-3.5 w-3.5"})}),c.jsx(Ee,{className:"h-8 w-8",onClick:p=>l(p,f.url),size:"icon",variant:"secondary",children:c.jsx(Pu,{className:"h-3.5 w-3.5"})})]})]}),c.jsxs("div",{className:"space-y-2 p-3",children:[c.jsxs("div",{className:"flex items-start justify-between gap-2",children:[c.jsx("p",{className:"flex-1 truncate font-medium text-sm",children:d}),c.jsx(He,{className:"shrink-0 text-xs",variant:"secondary",children:h.toUpperCase()})]}),c.jsx("div",{className:"flex items-center gap-2 text-muted-foreground text-xs",children:c.jsx("span",{children:cve(f.size)})})]})]},f.key)})})}function dve({value:e,onChange:t}){return c.jsxs("div",{className:"relative",children:[c.jsx(Aj,{className:"absolute top-1/2 left-3 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),c.jsx(ec,{className:"pl-9",onChange:n=>t(n.target.value),placeholder:"Search files by name...",type:"search",value:e})]})}function hve(e){return e===0?"0 B":e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(0)} KB`:`${(e/(1024*1024)).toFixed(2)} MB`}function A6(e){var t;return((t=e.split(".").pop())==null?void 0:t.toLowerCase())||""}function mve(e,t){if(e!=null&&e.startsWith("image/"))return!0;const n=t?A6(t):"";return["jpg","jpeg","png","gif","webp","avif","svg","bmp","ico"].includes(n)}function pve({files:e,selectedFiles:t,onSelectFile:n,onSelectAll:r,onToggleStar:i,onFileClick:s}){const l=(d,h)=>{d.stopPropagation(),navigator.clipboard.writeText(h),wt.success("URL copied to clipboard")},f=(d,h)=>{d.stopPropagation(),window.open(h,"_blank")};return c.jsx("div",{className:"overflow-hidden rounded-lg border border-border",children:c.jsxs(dO,{children:[c.jsx(hO,{children:c.jsxs(la,{className:"bg-muted/50",children:[c.jsx(pn,{className:"w-12",children:c.jsx(vj,{checked:t.length===e.length&&e.length>0,onCheckedChange:r})}),c.jsx(pn,{className:"w-12"}),c.jsx(pn,{children:"Name"}),c.jsx(pn,{children:"Format"}),c.jsx(pn,{children:"Size"}),c.jsx(pn,{children:"Modified"}),c.jsx(pn,{className:"w-24",children:"Actions"})]})}),c.jsx(mO,{children:e.map(d=>{const h=d.key.split("/").pop()||d.key,v=A6(h),p=mve(d.contentType,h);return c.jsxs(la,{className:"cursor-pointer hover:bg-muted/50",onClick:()=>s(d),children:[c.jsx(It,{onClick:g=>g.stopPropagation(),children:c.jsx(vj,{checked:t.includes(d.key),onCheckedChange:()=>n(d.key)})}),c.jsx(It,{onClick:g=>g.stopPropagation(),children:c.jsx(Ee,{className:"h-8 w-8",onClick:g=>{g.stopPropagation(),i(d.key,!d.starred)},size:"icon",variant:"ghost",children:c.jsx(Mf,{className:`h-4 w-4 ${d.starred?"fill-yellow-500 text-yellow-500":""}`})})}),c.jsx(It,{children:c.jsxs("div",{className:"flex items-center gap-3",children:[c.jsx("div",{className:"h-10 w-14 shrink-0 overflow-hidden rounded border bg-muted",children:p&&d.url.startsWith("https://")?c.jsx("img",{alt:h,className:"h-full w-full object-cover",src:d.url}):c.jsx("div",{className:"flex h-full w-full items-center justify-center",children:p?c.jsx(Ej,{className:"h-4 w-4 text-muted-foreground"}):c.jsx(_j,{className:"h-4 w-4 text-muted-foreground"})})}),c.jsx("span",{className:"truncate font-medium",children:h})]})}),c.jsx(It,{children:c.jsx(He,{variant:"secondary",children:v.toUpperCase()})}),c.jsx(It,{className:"text-muted-foreground",children:hve(d.size)}),c.jsx(It,{className:"text-muted-foreground text-xs",children:IX(new Date(d.lastModified),{addSuffix:!0})}),c.jsx(It,{onClick:g=>g.stopPropagation(),children:c.jsxs("div",{className:"flex gap-1",children:[c.jsx(Ee,{className:"h-8 w-8",onClick:g=>l(g,d.url),size:"icon",variant:"ghost",children:c.jsx(bl,{className:"h-3.5 w-3.5"})}),c.jsx(Ee,{className:"h-8 w-8",onClick:g=>f(g,d.url),size:"icon",variant:"ghost",children:c.jsx(Pu,{className:"h-3.5 w-3.5"})})]})})]},d.key)})})]})})}function vve({viewMode:e,onViewModeChange:t}){return c.jsxs("div",{className:"flex items-center gap-1 rounded-lg border border-border bg-muted/50 p-1",children:[c.jsxs(Ee,{className:"gap-2",onClick:()=>t("grid"),size:"sm",variant:e==="grid"?"secondary":"ghost",children:[c.jsx(qH,{className:"h-4 w-4"}),"Grid"]}),c.jsxs(Ee,{className:"gap-2",onClick:()=>t("table"),size:"sm",variant:e==="table"?"secondary":"ghost",children:[c.jsx(YH,{className:"h-4 w-4"}),"Table"]})]})}function gve(e){return e===0?"0 B":e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:e<1024*1024*1024?`${(e/(1024*1024)).toFixed(1)} MB`:`${(e/(1024*1024*1024)).toFixed(2)} GB`}function yve({url:e}){const[t,n]=j.useState(!1),r=async()=>{await navigator.clipboard.writeText(e),n(!0),wt.success("URL copied to clipboard"),setTimeout(()=>n(!1),2e3)};return c.jsx(Ee,{onClick:r,size:"sm",variant:"outline",children:t?c.jsx(Vi,{className:"h-3 w-3 text-green-500"}):c.jsx("span",{className:"text-xs",children:"Copy"})})}function bve(){return c.jsxs("div",{className:"space-y-6",children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{children:[c.jsx(Re,{className:"mb-2 h-8 w-48"}),c.jsx(Re,{className:"h-4 w-64"})]}),c.jsxs("div",{className:"flex gap-2",children:[c.jsx(Re,{className:"h-9 w-24"}),c.jsx(Re,{className:"h-9 w-24"})]})]}),c.jsx("div",{className:"grid gap-4 md:grid-cols-4",children:[1,2,3,4].map(e=>c.jsx(Ne,{children:c.jsxs(De,{className:"pb-2",children:[c.jsx(Re,{className:"h-4 w-20"}),c.jsx(Re,{className:"h-8 w-16"})]})},e))}),c.jsx("div",{className:"grid gap-4 md:grid-cols-4",children:[1,2,3,4].map(e=>c.jsxs(Ne,{className:"overflow-hidden",children:[c.jsx(Re,{className:"aspect-video w-full"}),c.jsxs("div",{className:"p-3",children:[c.jsx(Re,{className:"mb-2 h-4 w-full"}),c.jsx(Re,{className:"h-3 w-20"})]})]},e))})]})}function xve(){return c.jsxs("div",{className:"flex flex-col items-center justify-center py-12",children:[c.jsx(Tf,{className:"mb-4 h-16 w-16 text-muted-foreground opacity-50"}),c.jsx("h2",{className:"mb-2 font-semibold text-xl",children:"No Storage Configured"}),c.jsxs("p",{className:"mb-6 max-w-md text-center text-muted-foreground",children:["Storage infrastructure has not been deployed yet. Run"," ",c.jsx("code",{className:"rounded bg-muted px-2 py-1 font-mono text-sm",children:"wraps storage init"})," ","to get started."]})]})}function wve({onUploadClick:e}){return c.jsxs("div",{className:"flex flex-col items-center justify-center py-16",children:[c.jsx(G4,{className:"mb-4 h-16 w-16 text-muted-foreground opacity-50"}),c.jsx("h3",{className:"mb-2 font-semibold text-lg",children:"No Files Yet"}),c.jsx("p",{className:"mb-6 max-w-md text-center text-muted-foreground",children:"Upload your first file to get started with your CDN library"}),c.jsxs(Ee,{onClick:e,children:[c.jsx($u,{className:"mr-2 h-4 w-4"}),"Upload Files"]})]})}function Sve({upload:e,onRemove:t}){return c.jsx("div",{className:"flex items-center gap-3 rounded-lg border bg-muted/30 p-3",children:c.jsxs("div",{className:"min-w-0 flex-1",children:[c.jsxs("div",{className:"mb-1 flex items-center justify-between",children:[c.jsx("span",{className:"truncate font-medium text-sm",children:e.filename}),c.jsxs("div",{className:"flex items-center gap-2",children:[e.status==="uploading"&&c.jsx(ol,{className:"h-4 w-4 animate-spin text-primary"}),e.status==="success"&&c.jsx(Zi,{className:"h-4 w-4 text-green-500"}),e.status==="error"&&c.jsx(ir,{className:"h-4 w-4 text-red-500"}),c.jsx(Ee,{className:"h-6 w-6",onClick:t,size:"icon",variant:"ghost",children:c.jsx(rr,{className:"h-3 w-3"})})]})]}),e.status==="uploading"&&c.jsx(Tv,{className:"h-1",value:e.progress}),e.status==="success"&&e.cdnUrl&&c.jsxs("div",{className:"mt-1 flex items-center gap-2",children:[c.jsx("span",{className:"truncate text-muted-foreground text-xs",children:e.cdnUrl}),c.jsx(yve,{url:e.cdnUrl})]}),e.status==="error"&&c.jsx("span",{className:"text-red-500 text-xs",children:e.error})]})})}function jve({uploads:e,onFilesSelected:t,onRemoveUpload:n}){const[r,i]=j.useState(!1),s=j.useRef(null),l=v=>{v.preventDefault(),i(!0)},f=v=>{v.preventDefault(),i(!1)},d=v=>{v.preventDefault(),i(!1),v.dataTransfer.files.length>0&&t(v.dataTransfer.files)},h=v=>{v.target.files&&v.target.files.length>0&&t(v.target.files)};return c.jsxs(Ne,{children:[c.jsxs(De,{children:[c.jsx(Fe,{children:"Upload Files"}),c.jsx(Ye,{children:"Drag and drop files or click to browse"})]}),c.jsxs(Le,{className:"space-y-4",children:[c.jsxs("div",{className:`cursor-pointer rounded-lg border-2 border-dashed p-8 text-center transition-colors ${r?"border-primary bg-primary/5":"border-muted-foreground/25 hover:border-primary/50"}`,onClick:()=>{var v;return(v=s.current)==null?void 0:v.click()},onDragLeave:f,onDragOver:l,onDrop:d,children:[c.jsx($u,{className:"mx-auto mb-4 h-10 w-10 text-muted-foreground"}),c.jsx("p",{className:"mb-1 font-medium text-sm",children:"Drop files here or click to upload"}),c.jsx("p",{className:"text-muted-foreground text-xs",children:"Images will be optimized before uploading"}),c.jsx("input",{accept:"*/*",className:"hidden",multiple:!0,onChange:h,ref:s,type:"file"})]}),e.length>0&&c.jsx("div",{className:"space-y-2",children:e.map((v,p)=>c.jsx(Sve,{onRemove:()=>n(p),upload:v},`${v.filename}-${p}`))})]})]})}function Ove(){const[e,t]=j.useState(null),[n,r]=j.useState(!0),[i,s]=j.useState(null),[l,f]=j.useState("grid"),[d,h]=j.useState(""),[v,p]=j.useState({starred:!1,formats:[]}),[g,b]=j.useState([]),[O,S]=j.useState(null),[x,E]=j.useState(!1),[A,_]=j.useState([]),[T,N]=j.useState({keys:[],isOpen:!1}),[M,R]=j.useState([]),[D,L]=j.useState(!1),Y=j.useCallback(async()=>{try{r(!0),s(null);const B=sessionStorage.getItem("wraps-auth-token"),V=await fetch(`/api/storage/files?token=${B}`);if(!V.ok){if(V.status===404){t(null);return}throw new Error("Failed to fetch storage files")}const F=await V.json();t(F)}catch(B){s(B instanceof Error?B.message:"An error occurred")}finally{r(!1)}},[]);j.useEffect(()=>{Y()},[Y]);const I=j.useCallback(async(B,V)=>{const F=sessionStorage.getItem("wraps-auth-token");try{if(!(await fetch(`/api/storage/files/${encodeURIComponent(B)}/star?token=${F}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({starred:V})})).ok)throw new Error("Failed to update star status");t(fe=>fe&&{...fe,files:fe.files.map(oe=>oe.key===B?{...oe,starred:V}:oe)}),(O==null?void 0:O.key)===B&&S(fe=>fe?{...fe,starred:V}:null),wt.success(V?"File starred":"Star removed")}catch{wt.error("Failed to update star status")}},[O]),H=j.useCallback(async B=>{const V=sessionStorage.getItem("wraps-auth-token");try{await Promise.all(B.map(F=>fetch(`/api/storage/files/${encodeURIComponent(F)}?token=${V}`,{method:"DELETE"}))),wt.success(B.length===1?"File deleted":`${B.length} files deleted`),b([]),S(null),Y()}catch{wt.error("Failed to delete file(s)")}},[Y]),W=j.useCallback(async(B,V,F)=>{const ne=sessionStorage.getItem("wraps-auth-token"),fe=B instanceof File,oe=F||(fe?B.name:"file"),me=B.type||"application/octet-stream";try{_(ie=>ie.map((Pe,xe)=>xe===V?{...Pe,status:"uploading",progress:0}:Pe));const ae=await fetch(`/api/storage/upload-url?token=${ne}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({filename:oe,contentType:me})});if(!ae.ok)throw new Error("Failed to get upload URL");const{uploadUrl:pe,cdnUrl:ge}=await ae.json();await new Promise((ie,Pe)=>{const xe=new XMLHttpRequest;xe.upload.addEventListener("progress",Je=>{if(Je.lengthComputable){const rt=Math.round(Je.loaded/Je.total*100);_(lt=>lt.map((Wt,bt)=>bt===V?{...Wt,progress:rt}:Wt))}}),xe.addEventListener("load",()=>{xe.status>=200&&xe.status<300?ie():Pe(new Error(`Upload failed with status ${xe.status}`))}),xe.addEventListener("error",()=>Pe(new Error("Upload failed"))),xe.open("PUT",pe),xe.setRequestHeader("Content-Type",me),xe.send(B)}),_(ie=>ie.map((Pe,xe)=>xe===V?{...Pe,status:"success",progress:100,cdnUrl:ge}:Pe)),wt.success(`Uploaded ${oe}`),Y()}catch(ae){_(pe=>pe.map((ge,ie)=>ie===V?{...ge,status:"error",error:ae instanceof Error?ae.message:"Upload failed"}:ge)),wt.error(`Failed to upload ${oe}`)}},[Y]),Z=j.useCallback(B=>{const V=Array.from(B),F=V.filter(fe=>fe.type.startsWith("image/")),ne=V.filter(fe=>!fe.type.startsWith("image/"));if(ne.length>0){const fe=ne.map(me=>({file:me,filename:me.name,progress:0,status:"pending"}));_(me=>[...me,...fe]),E(!0);const oe=A.length;ne.forEach((me,ae)=>{W(me,oe+ae,me.name)})}F.length>0&&(R(F),L(!0))},[A.length,W]),X=j.useCallback(B=>{if(!B||B.length===0)return;const V=A.length,F=B.map(ne=>({file:ne.file,filename:ne.cdnFilename,progress:0,status:"pending"}));_(ne=>[...ne,...F]),E(!0),B.forEach((ne,fe)=>{W(ne.file,V+fe,ne.cdnFilename)})},[A.length,W]),k=j.useCallback(B=>{b(V=>V.includes(B)?V.filter(F=>F!==B):[...V,B])},[]),U=j.useCallback(()=>{if(!(e!=null&&e.files))return;const B=le.map(V=>V.key);g.length===B.length?b([]):b(B)},[e==null?void 0:e.files,g.length]),q=j.useCallback(async()=>{await Promise.all(g.map(B=>I(B,!0))),b([])},[g,I]),Q=j.useCallback(()=>{N({keys:g,isOpen:!0})},[g]),le=j.useMemo(()=>e!=null&&e.files?e.files.filter(B=>{var V;if(d&&!B.key.toLowerCase().includes(d.toLowerCase())||v.starred&&!B.starred)return!1;if(v.formats.length>0){const F=((V=B.key.split(".").pop())==null?void 0:V.toLowerCase())||"";if(!v.formats.includes(F))return!1}return!0}):[],[e==null?void 0:e.files,d,v]),$=j.useMemo(()=>{if(!(e!=null&&e.files))return[];const B=new Set;return e.files.forEach(V=>{var ne;const F=(ne=V.key.split(".").pop())==null?void 0:ne.toLowerCase();F&&B.add(F)}),Array.from(B).sort()},[e==null?void 0:e.files]);return n?c.jsx(bve,{}):i?c.jsxs(In,{variant:"destructive",children:[c.jsx(ir,{className:"h-4 w-4"}),c.jsx(Xi,{children:"Error"}),c.jsx(zn,{children:i})]}):e?c.jsxs("div",{className:"space-y-6",children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{children:[c.jsx("h1",{className:"font-bold text-2xl",children:"CDN Library"}),c.jsx("p",{className:"text-muted-foreground",children:e.fileCount>0?c.jsxs(c.Fragment,{children:[c.jsx("span",{className:"text-foreground",children:e.fileCount})," File",e.fileCount!==1?"s":""," · Total"," ",c.jsx("span",{className:"text-foreground",children:gve(e.totalSize)})]}):"Manage and organize your files"})]}),c.jsxs("div",{className:"flex items-center gap-3",children:[c.jsxs(Ee,{onClick:()=>E(!x),children:[c.jsx($u,{className:"mr-2 h-4 w-4"}),"Upload Files"]}),c.jsx(Ee,{onClick:Y,size:"icon",variant:"outline",children:c.jsx(Cf,{className:"h-4 w-4"})}),c.jsx(vve,{onViewModeChange:f,viewMode:l})]})]}),x&&c.jsx(jve,{onFilesSelected:Z,onRemoveUpload:B=>_(V=>V.filter((F,ne)=>ne!==B)),uploads:A}),e.files.length>0&&c.jsxs("div",{className:"flex flex-col gap-4 md:flex-row",children:[c.jsx("div",{className:"flex-1",children:c.jsx(dve,{onChange:h,value:d})}),c.jsx(ave,{availableFormats:$,filters:v,onFiltersChange:p})]}),g.length>0&&c.jsx(rve,{onClearSelection:()=>b([]),onDelete:Q,onStar:q,selectedCount:g.length}),e.files.length===0?c.jsx(wve,{onUploadClick:()=>E(!0)}):le.length===0?c.jsx("div",{className:"py-12 text-center text-muted-foreground",children:"No files match your search or filters"}):l==="grid"?c.jsx(fve,{files:le,onFileClick:S,onSelectFile:k,onToggleStar:I,selectedFiles:g}):c.jsx(pve,{files:le,onFileClick:S,onSelectAll:U,onSelectFile:k,onToggleStar:I,selectedFiles:g}),O&&c.jsx(nve,{file:O,onClose:()=>S(null),onDelete:B=>{N({keys:[B],isOpen:!0})},onToggleStar:I}),c.jsx(up,{onOpenChange:B=>N(V=>({...V,isOpen:B})),open:T.isOpen,children:c.jsxs(fp,{children:[c.jsxs(dp,{children:[c.jsxs(mp,{children:["Delete File",T.keys.length>1?"s":""]}),c.jsxs(pp,{children:["Are you sure you want to delete"," ",T.keys.length===1?c.jsx("strong",{children:T.keys[0].split("/").pop()}):c.jsxs("strong",{children:[T.keys.length," files"]}),"? This action cannot be undone."]})]}),c.jsxs(hp,{children:[c.jsx(gp,{children:"Cancel"}),c.jsx(vp,{className:"bg-red-600 hover:bg-red-700",onClick:()=>{H(T.keys),N({keys:[],isOpen:!1})},children:"Delete"})]})]})}),c.jsx(Jpe,{files:M,onClose:()=>{L(!1),R([])},onComplete:X,open:D})]}):c.jsx(xve,{})}function j1(e){if(e===0)return"0 B";const t=1024,n=["B","KB","MB","GB","TB"],r=Math.floor(Math.log(e)/Math.log(t));return`${Number.parseFloat((e/t**r).toFixed(1))} ${n[r]}`}function zo(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}K`:e.toString()}function Ih({title:e,value:t,description:n,icon:r,trend:i}){return c.jsxs(Ne,{children:[c.jsxs(De,{className:"flex flex-row items-center justify-between pb-2",children:[c.jsx(Fe,{className:"font-medium text-muted-foreground text-sm",children:e}),c.jsx(r,{className:"h-4 w-4 text-muted-foreground"})]}),c.jsxs(Le,{children:[c.jsx("div",{className:"font-bold text-2xl",children:t}),c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("p",{className:"text-muted-foreground text-xs",children:n}),i!==void 0&&i!==0&&c.jsxs("span",{className:`flex items-center text-xs ${i>0?"text-green-500":"text-red-500"}`,children:[c.jsx(Nj,{className:`h-3 w-3 ${i<0?"rotate-180":""}`}),Math.abs(i),"%"]})]})]})]})}function Eve({data:e}){const t=e.map(n=>({date:new Date(n.date).toLocaleDateString("en-US",{month:"short",day:"numeric"}),size:n.size/1073741824,files:n.files}));return c.jsxs(Ne,{children:[c.jsxs(De,{children:[c.jsx(Fe,{children:"Storage Usage"}),c.jsx(Ye,{children:"Storage size and file count over time"})]}),c.jsx(Le,{children:c.jsx(LO,{height:300,width:"100%",children:c.jsxs(jB,{data:t,children:[c.jsx(Av,{className:"stroke-muted",strokeDasharray:"3 3"}),c.jsx(ls,{className:"text-xs",dataKey:"date",stroke:"currentColor",tick:{fill:"currentColor"}}),c.jsx(ii,{className:"text-xs",stroke:"currentColor",tick:{fill:"currentColor"},tickFormatter:n=>`${n} GB`,yAxisId:"left"}),c.jsx(ii,{className:"text-xs",orientation:"right",stroke:"currentColor",tick:{fill:"currentColor"},yAxisId:"right"}),c.jsx(jr,{contentStyle:{backgroundColor:"hsl(var(--card))",border:"1px solid hsl(var(--border))",borderRadius:"var(--radius)"},formatter:(n,r)=>[r==="size"?`${n.toFixed(2)} GB`:n,r==="size"?"Storage":"Files"]}),c.jsx(Ka,{}),c.jsx(Or,{dataKey:"size",dot:!1,name:"Storage (GB)",stroke:"hsl(var(--primary))",strokeWidth:2,type:"monotone",yAxisId:"left"}),c.jsx(Or,{dataKey:"files",dot:!1,name:"File Count",stroke:"hsl(var(--chart-2))",strokeWidth:2,type:"monotone",yAxisId:"right"})]})})})]})}function _ve({data:e}){const t=e.map(n=>({date:new Date(n.date).toLocaleDateString("en-US",{month:"short",day:"numeric"}),bandwidth:n.bytes/1048576,requests:n.requests}));return c.jsxs(Ne,{children:[c.jsxs(De,{children:[c.jsx(Fe,{children:"CDN Traffic"}),c.jsx(Ye,{children:"Bandwidth and requests over time"})]}),c.jsx(Le,{children:c.jsx(LO,{height:300,width:"100%",children:c.jsxs(Phe,{data:t,children:[c.jsx(Av,{className:"stroke-muted",strokeDasharray:"3 3"}),c.jsx(ls,{className:"text-xs",dataKey:"date",stroke:"currentColor",tick:{fill:"currentColor"}}),c.jsx(ii,{className:"text-xs",stroke:"currentColor",tick:{fill:"currentColor"},tickFormatter:n=>`${n} MB`,yAxisId:"left"}),c.jsx(ii,{className:"text-xs",orientation:"right",stroke:"currentColor",tick:{fill:"currentColor"},tickFormatter:n=>zo(n),yAxisId:"right"}),c.jsx(jr,{contentStyle:{backgroundColor:"hsl(var(--card))",border:"1px solid hsl(var(--border))",borderRadius:"var(--radius)"},formatter:(n,r)=>[r==="bandwidth"?`${n.toFixed(1)} MB`:zo(n),r==="bandwidth"?"Bandwidth":"Requests"]}),c.jsx(Ka,{}),c.jsx(Qi,{dataKey:"bandwidth",fill:"hsl(var(--primary))",name:"Bandwidth (MB)",radius:[4,4,0,0],yAxisId:"left"}),c.jsx(Qi,{dataKey:"requests",fill:"hsl(var(--chart-3))",name:"Requests",radius:[4,4,0,0],yAxisId:"right"})]})})})]})}function Ave({files:e}){return c.jsxs(Ne,{children:[c.jsxs(De,{children:[c.jsx(Fe,{children:"Top Files"}),c.jsx(Ye,{children:"Most requested files this month"})]}),c.jsx(Le,{children:e.length===0?c.jsx("div",{className:"py-4 text-center text-muted-foreground",children:"No data available"}):c.jsx("div",{className:"space-y-4",children:e.map((t,n)=>{const r=t.key.split("/").pop()||t.key,i=Math.max(...e.map(l=>l.requests)),s=t.requests/i*100;return c.jsxs("div",{children:[c.jsxs("div",{className:"mb-1 flex items-center justify-between text-sm",children:[c.jsxs("span",{className:"flex items-center gap-2",children:[c.jsxs("span",{className:"text-muted-foreground",children:[n+1,"."]}),c.jsx("span",{className:"max-w-[200px] truncate font-medium",children:r})]}),c.jsxs("span",{className:"text-muted-foreground",children:[zo(t.requests)," requests"]})]}),c.jsx(Tv,{className:"h-2",value:s})]},t.key)})})})]})}function Nve(){return c.jsxs("div",{className:"space-y-6",children:[c.jsx("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-4",children:Array.from({length:4}).map((e,t)=>c.jsxs(Ne,{children:[c.jsx(De,{className:"pb-2",children:c.jsx(Re,{className:"h-4 w-20"})}),c.jsxs(Le,{children:[c.jsx(Re,{className:"h-8 w-24"}),c.jsx(Re,{className:"mt-2 h-3 w-32"})]})]},t))}),c.jsxs(Ne,{children:[c.jsx(De,{children:c.jsx(Re,{className:"h-6 w-32"})}),c.jsx(Le,{children:c.jsx(Re,{className:"h-[300px] w-full"})})]})]})}function Tve(){return c.jsxs("div",{className:"flex flex-col items-center justify-center py-12",children:[c.jsx(Tf,{className:"mb-4 h-16 w-16 text-muted-foreground opacity-50"}),c.jsx("h2",{className:"mb-2 font-semibold text-xl",children:"No Storage Configured"}),c.jsxs("p",{className:"mb-6 max-w-md text-center text-muted-foreground",children:["Storage infrastructure has not been deployed yet. Run"," ",c.jsx("code",{className:"rounded bg-muted px-2 py-1 font-mono text-sm",children:"wraps storage init"})," ","to get started."]})]})}function Cve(){const[e,t]=j.useState(null),[n,r]=j.useState(!0),[i,s]=j.useState(null),[l,f]=j.useState("7d"),d=j.useCallback(async()=>{try{r(!0),s(null);const h=sessionStorage.getItem("wraps-auth-token"),v=await fetch(`/api/storage/metrics?token=${h}&range=${l}`);if(!v.ok){if(v.status===404){t(null);return}throw new Error("Failed to fetch storage metrics")}const p=await v.json();t(p)}catch(h){s(h instanceof Error?h.message:"An error occurred")}finally{r(!1)}},[l]);return j.useEffect(()=>{d()},[d]),n?c.jsx(Nve,{}):i?c.jsxs(In,{variant:"destructive",children:[c.jsx(ir,{className:"h-4 w-4"}),c.jsx(Xi,{children:"Error"}),c.jsx(zn,{children:i})]}):e?c.jsxs("div",{className:"space-y-6",children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{children:[c.jsx("h1",{className:"font-bold text-2xl",children:"Storage Metrics"}),c.jsx("p",{className:"text-muted-foreground",children:"Monitor your storage usage and CDN traffic"})]}),c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsxs(fa,{onValueChange:f,value:l,children:[c.jsx(ha,{className:"w-32",children:c.jsx(da,{})}),c.jsxs(ma,{children:[c.jsx(Ue,{value:"7d",children:"Last 7 days"}),c.jsx(Ue,{value:"30d",children:"Last 30 days"}),c.jsx(Ue,{value:"90d",children:"Last 90 days"})]})]}),c.jsxs(Ee,{onClick:d,size:"sm",variant:"outline",children:[c.jsx(Cf,{className:"mr-2 h-4 w-4"}),"Refresh"]})]})]}),c.jsxs("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-4",children:[c.jsx(Ih,{description:`${zo(e.summary.fileCount)} files`,icon:$H,title:"Storage Used",value:j1(e.summary.totalSize)}),c.jsx(Ih,{description:`${j1(e.summary.bandwidth.thisMonth)} this month`,icon:MH,title:"Bandwidth Today",value:j1(e.summary.bandwidth.today)}),c.jsx(Ih,{description:`${zo(e.summary.requests.thisMonth)} this month`,icon:ku,title:"Requests Today",value:zo(e.summary.requests.today)}),c.jsx(Ih,{description:"Files in storage",icon:RH,title:"Total Files",value:zo(e.summary.fileCount)})]}),c.jsxs("div",{className:"grid gap-6 lg:grid-cols-2",children:[c.jsx(Eve,{data:e.usage}),c.jsx(_ve,{data:e.bandwidth})]}),c.jsx(Ave,{files:e.topFiles})]}):c.jsx(Tve,{})}function bp({status:e}){const t={SUCCESS:{icon:Zi,label:"Active",className:"bg-green-500/10 text-green-700 dark:text-green-400 border-green-500/20"},PENDING:{icon:Uo,label:"Pending",className:"bg-yellow-500/10 text-yellow-700 dark:text-yellow-400 border-yellow-500/20"},FAILED:{icon:F4,label:"Failed",className:"bg-red-500/10 text-red-700 dark:text-red-400 border-red-500/20"},DISABLED:{icon:ir,label:"Disabled",className:"bg-gray-500/10 text-gray-700 dark:text-gray-400 border-gray-500/20"}},{icon:n,label:r,className:i}=t[e];return c.jsxs(He,{className:i,variant:"outline",children:[c.jsx(n,{className:"mr-1 h-3 w-3"}),r]})}function ul({text:e}){const t=async()=>{await navigator.clipboard.writeText(e),wt.success("Copied to clipboard")};return c.jsx(Ee,{onClick:t,size:"sm",variant:"ghost",children:c.jsx(bl,{className:"h-3 w-3"})})}function Mve({settings:e}){return c.jsxs(Ne,{children:[c.jsxs(De,{children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(Tf,{className:"h-5 w-5"}),c.jsx(Fe,{children:"S3 Bucket"})]}),c.jsx(bp,{status:"SUCCESS"})]}),c.jsx(Ye,{children:"Your storage bucket for uploading files"})]}),c.jsx(Le,{className:"space-y-4",children:c.jsxs("div",{className:"grid gap-4",children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx("span",{className:"text-muted-foreground text-sm",children:"Bucket Name"}),c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("code",{className:"rounded bg-muted px-2 py-1 font-mono text-sm",children:e.bucketName}),c.jsx(ul,{text:e.bucketName})]})]}),c.jsx(Bt,{}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx("span",{className:"text-muted-foreground text-sm",children:"Region"}),c.jsx("code",{className:"rounded bg-muted px-2 py-1 font-mono text-sm",children:e.region})]}),c.jsx(Bt,{}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx("span",{className:"text-muted-foreground text-sm",children:"Versioning"}),c.jsx(He,{variant:e.versioning?"default":"secondary",children:e.versioning?"Enabled":"Disabled"})]}),c.jsx(Bt,{}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx("span",{className:"text-muted-foreground text-sm",children:"Encryption"}),c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(Kh,{className:"h-4 w-4 text-green-500"}),c.jsx("span",{className:"text-sm",children:"AES-256"})]})]}),e.retention&&e.retention!=="none"&&c.jsxs(c.Fragment,{children:[c.jsx(Bt,{}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx("span",{className:"text-muted-foreground text-sm",children:"Auto-Cleanup"}),c.jsx("span",{className:"text-sm",children:e.retention})]})]})]})})]})}function Rve({settings:e}){var i,s;const[t,n]=j.useState(!1);if(!((i=e.cdn)!=null&&i.enabled))return c.jsx(Ne,{children:c.jsxs(De,{children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(ku,{className:"h-5 w-5"}),c.jsx(Fe,{children:"CloudFront CDN"})]}),c.jsx(bp,{status:"DISABLED"})]}),c.jsx(Ye,{children:"CDN is not enabled for this storage bucket"})]})});const r=e.cdn.status==="Deployed"?"SUCCESS":e.cdn.status==="InProgress"?"PENDING":"FAILED";return c.jsxs(Ne,{children:[c.jsxs(De,{children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(ku,{className:"h-5 w-5"}),c.jsx(Fe,{children:"CloudFront CDN"})]}),c.jsx(bp,{status:r})]}),c.jsx(Ye,{children:"Global content delivery network for fast file access"})]}),c.jsxs(Le,{className:"space-y-4",children:[c.jsxs("div",{className:"grid gap-4",children:[e.cdn.distributionId&&c.jsxs(c.Fragment,{children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx("span",{className:"text-muted-foreground text-sm",children:"Distribution ID"}),c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("code",{className:"rounded bg-muted px-2 py-1 font-mono text-sm",children:e.cdn.distributionId}),c.jsx(ul,{text:e.cdn.distributionId})]})]}),c.jsx(Bt,{})]}),e.cdn.distributionDomain&&c.jsxs(c.Fragment,{children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx("span",{className:"text-muted-foreground text-sm",children:"CloudFront URL"}),c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsxs("a",{className:"text-blue-600 text-sm hover:underline dark:text-blue-400",href:`https://${e.cdn.distributionDomain}`,rel:"noopener noreferrer",target:"_blank",children:[e.cdn.distributionDomain,c.jsx(Pu,{className:"ml-1 inline h-3 w-3"})]}),c.jsx(ul,{text:`https://${e.cdn.distributionDomain}`})]})]}),c.jsx(Bt,{})]}),e.cdn.customDomain&&c.jsx(c.Fragment,{children:c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx("span",{className:"text-muted-foreground text-sm",children:"Custom Domain"}),c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsxs("a",{className:"text-blue-600 text-sm hover:underline dark:text-blue-400",href:`https://${e.cdn.customDomain}`,rel:"noopener noreferrer",target:"_blank",children:[e.cdn.customDomain,c.jsx(Pu,{className:"ml-1 inline h-3 w-3"})]}),c.jsx(ul,{text:`https://${e.cdn.customDomain}`})]})]})})]}),((s=e.certificate)==null?void 0:s.validationRecords)&&e.certificate.validationRecords.length>0&&e.certificate.status==="PENDING_VALIDATION"&&c.jsxs(fc,{onOpenChange:n,open:t,children:[c.jsx(dc,{asChild:!0,children:c.jsxs(Ee,{className:"w-full justify-between",variant:"ghost",children:[c.jsxs("span",{className:"flex items-center gap-2",children:[c.jsx(ir,{className:"h-4 w-4 text-yellow-500"}),"Certificate DNS Records Required"]}),t?c.jsx("span",{className:"text-xs",children:"Hide"}):c.jsx("span",{className:"text-xs",children:"Show"})]})}),c.jsxs(hc,{className:"mt-2 space-y-2",children:[c.jsxs(In,{children:[c.jsx(ir,{className:"h-4 w-4"}),c.jsx(Xi,{children:"Action Required"}),c.jsx(zn,{children:"Add these DNS records to verify your custom domain certificate"})]}),e.certificate.validationRecords.map((l,f)=>c.jsxs("div",{className:"rounded-lg border bg-muted/50 p-3 font-mono text-xs",children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx("span",{className:"text-muted-foreground",children:l.type}),c.jsx(ul,{text:l.value})]}),c.jsx("div",{className:"mt-1 break-all",children:l.name}),c.jsxs("div",{className:"mt-1 break-all text-muted-foreground",children:["→ ",l.value]})]},f))]})]})]})]})}function Dve({settings:e}){return c.jsxs(Ne,{children:[c.jsxs(De,{children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(Kh,{className:"h-5 w-5"}),c.jsx(Fe,{children:"IAM Role"})]}),c.jsx(bp,{status:"SUCCESS"})]}),c.jsx(Ye,{children:"Role used by your application to access storage"})]}),c.jsx(Le,{children:c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx("span",{className:"text-muted-foreground text-sm",children:"Role ARN"}),c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("code",{className:"max-w-[300px] truncate rounded bg-muted px-2 py-1 font-mono text-xs",children:e.roleArn}),c.jsx(ul,{text:e.roleArn})]})]})})]})}function Pve(){return c.jsxs("div",{className:"space-y-6",children:[c.jsxs(Ne,{children:[c.jsxs(De,{children:[c.jsx(Re,{className:"h-6 w-32"}),c.jsx(Re,{className:"h-4 w-64"})]}),c.jsx(Le,{children:c.jsxs("div",{className:"space-y-4",children:[c.jsx(Re,{className:"h-8 w-full"}),c.jsx(Re,{className:"h-8 w-full"}),c.jsx(Re,{className:"h-8 w-full"})]})})]}),c.jsxs(Ne,{children:[c.jsxs(De,{children:[c.jsx(Re,{className:"h-6 w-32"}),c.jsx(Re,{className:"h-4 w-64"})]}),c.jsx(Le,{children:c.jsxs("div",{className:"space-y-4",children:[c.jsx(Re,{className:"h-8 w-full"}),c.jsx(Re,{className:"h-8 w-full"})]})})]})]})}function kve(){return c.jsxs("div",{className:"flex flex-col items-center justify-center py-12",children:[c.jsx(Tf,{className:"mb-4 h-16 w-16 text-muted-foreground opacity-50"}),c.jsx("h2",{className:"mb-2 font-semibold text-xl",children:"No Storage Configured"}),c.jsxs("p",{className:"mb-6 max-w-md text-center text-muted-foreground",children:["Storage infrastructure has not been deployed yet. Run"," ",c.jsx("code",{className:"rounded bg-muted px-2 py-1 font-mono text-sm",children:"wraps storage init"})," ","to get started."]})]})}function $ve(){const[e,t]=j.useState(null),[n,r]=j.useState(!0),[i,s]=j.useState(null),l=j.useCallback(async()=>{try{r(!0),s(null);const f=sessionStorage.getItem("wraps-auth-token"),d=await fetch(`/api/storage/settings?token=${f}`);if(!d.ok){if(d.status===404){t(null);return}throw new Error("Failed to fetch storage settings")}const h=await d.json();t(h)}catch(f){s(f instanceof Error?f.message:"An error occurred")}finally{r(!1)}},[]);return j.useEffect(()=>{l()},[l]),n?c.jsx(Pve,{}):i?c.jsxs(In,{variant:"destructive",children:[c.jsx(ir,{className:"h-4 w-4"}),c.jsx(Xi,{children:"Error"}),c.jsx(zn,{children:i})]}):e?c.jsxs("div",{className:"space-y-6",children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{children:[c.jsx("h1",{className:"font-bold text-2xl",children:"Storage Settings"}),c.jsx("p",{className:"text-muted-foreground",children:"Manage your S3 bucket and CloudFront CDN configuration"})]}),c.jsxs(Ee,{onClick:l,size:"sm",variant:"outline",children:[c.jsx(Cf,{className:"mr-2 h-4 w-4"}),"Refresh"]})]}),c.jsx(Mve,{settings:e}),c.jsx(Rve,{settings:e}),c.jsx(Dve,{settings:e})]}):c.jsx(kve,{})}function Lve({children:e,defaultTheme:t="system",storageKey:n="vite-ui-theme",...r}){const[i,s]=j.useState(()=>localStorage.getItem(n)||t);j.useEffect(()=>{const f=window.document.documentElement;if(f.classList.remove("light","dark"),i==="system"){const d=window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light";f.classList.add(d),f.style.colorScheme=d;return}f.classList.add(i),f.style.colorScheme=i},[i]);const l={theme:i,setTheme:f=>{localStorage.setItem(n,f),s(f)}};return c.jsx(OI.Provider,{...r,value:l,children:e})}function Ive({...e}){return c.jsx("nav",{"aria-label":"breadcrumb","data-slot":"breadcrumb",...e})}function zve({className:e,...t}){return c.jsx("ol",{className:ve("flex flex-wrap items-center gap-1.5 break-words text-muted-foreground text-sm sm:gap-2.5",e),"data-slot":"breadcrumb-list",...t})}function Bve({className:e,...t}){return c.jsx("li",{className:ve("inline-flex items-center gap-1.5",e),"data-slot":"breadcrumb-item",...t})}function qve({className:e,...t}){return c.jsx("span",{"aria-current":"page","aria-disabled":"true",className:ve("font-normal text-foreground",e),"data-slot":"breadcrumb-page",role:"link",...t})}var Uve=(e,t,n,r,i,s,l,f)=>{let d=document.documentElement,h=["light","dark"];function v(b){(Array.isArray(e)?e:[e]).forEach(O=>{let S=O==="class",x=S&&s?i.map(E=>s[E]||E):i;S?(d.classList.remove(...x),d.classList.add(s&&s[b]?s[b]:b)):d.setAttribute(O,b)}),p(b)}function p(b){f&&h.includes(b)&&(d.style.colorScheme=b)}function g(){return window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}if(r)v(r);else try{let b=localStorage.getItem(t)||n,O=l&&b==="system"?g():b;v(O)}catch{}},Hve=j.createContext(void 0),Fve={setTheme:e=>{},themes:[]},Gve=()=>{var e;return(e=j.useContext(Hve))!=null?e:Fve};j.memo(({forcedTheme:e,storageKey:t,attribute:n,enableSystem:r,enableColorScheme:i,defaultTheme:s,value:l,themes:f,nonce:d,scriptProps:h})=>{let v=JSON.stringify([n,t,s,e,f,l,r,i]).slice(1,-1);return j.createElement("script",{...h,suppressHydrationWarning:!0,nonce:typeof window>"u"?d:"",dangerouslySetInnerHTML:{__html:`(${Uve.toString()})(${v})`}})});const Vve=({...e})=>{const{theme:t="system"}=Gve();return c.jsx(bme,{className:"toaster group",icons:{success:c.jsx(Zi,{className:"size-4"}),info:c.jsx(BH,{className:"size-4"}),warning:c.jsx(WH,{className:"size-4"}),error:c.jsx(HH,{className:"size-4"}),loading:c.jsx(ol,{className:"size-4 animate-spin"})},style:{"--normal-bg":"var(--popover)","--normal-text":"var(--popover-foreground)","--normal-border":"var(--border)","--border-radius":"var(--radius)"},theme:t,...e})};function Yve(){const e=ba(),[t,n]=j.useState(!1);j.useEffect(()=>{let i=sessionStorage.getItem("wraps-auth-token");i||(i=new URLSearchParams(window.location.search).get("token"),i&&sessionStorage.setItem("wraps-auth-token",i)),n(!0)},[]),j.useEffect(()=>{document.cookie="sidebar_state=; path=/; max-age=0"},[]);const r=()=>{if(e.pathname.startsWith("/email/")&&e.pathname!=="/email/metrics"&&e.pathname!=="/email/settings")return"Email Details";if(e.pathname.startsWith("/sms/")&&e.pathname!=="/sms/metrics"&&e.pathname!=="/sms/settings")return"SMS Details";if(e.pathname.startsWith("/storage/")&&e.pathname!=="/storage/metrics"&&e.pathname!=="/storage/settings")return"File Details";switch(e.pathname){case"/":case"/email":return"Emails";case"/email/metrics":return"Email Metrics";case"/email/settings":return"Email Settings";case"/sms":return"SMS Messages";case"/sms/metrics":return"SMS Metrics";case"/sms/settings":return"SMS Settings";case"/storage":return"Storage";case"/storage/metrics":return"Storage Metrics";case"/storage/settings":return"Storage Settings";default:return"Emails"}};return c.jsxs(bI,{defaultOpen:!1,children:[c.jsx(_W,{}),c.jsxs(wI,{children:[c.jsxs("header",{className:"sticky top-0 flex shrink-0 items-center gap-2 border-b bg-background p-4",children:[c.jsx(xI,{className:"-ml-1"}),c.jsx(Bt,{className:"mr-2 data-[orientation=vertical]:h-4",orientation:"vertical"}),c.jsx(Ive,{children:c.jsx(zve,{children:c.jsx(Bve,{children:c.jsx(qve,{children:r()})})})})]}),c.jsx("div",{className:"flex flex-1 flex-col gap-6 p-6",children:t?c.jsxs(WU,{children:[c.jsx(Qn,{element:c.jsx(VU,{replace:!0,to:"/email"}),path:"/"}),c.jsx(Qn,{element:c.jsx(jK,{}),path:"/email"}),c.jsx(Qn,{element:c.jsx(zW,{}),path:"/email/:id"}),c.jsx(Qn,{element:c.jsx(Vhe,{}),path:"/email/metrics"}),c.jsx(Qn,{element:c.jsx(npe,{}),path:"/email/settings"}),c.jsx(Qn,{element:c.jsx(spe,{}),path:"/sms"}),c.jsx(Qn,{element:c.jsx(ope,{}),path:"/sms/:id"}),c.jsx(Qn,{element:c.jsx(lpe,{}),path:"/sms/metrics"}),c.jsx(Qn,{element:c.jsx(hpe,{}),path:"/sms/settings"}),c.jsx(Qn,{element:c.jsx(Ove,{}),path:"/storage"}),c.jsx(Qn,{element:c.jsx(Cve,{}),path:"/storage/metrics"}),c.jsx(Qn,{element:c.jsx($ve,{}),path:"/storage/settings"})]}):c.jsx("div",{className:"flex items-center justify-center p-8",children:c.jsx("div",{className:"text-muted-foreground",children:"Loading..."})})})]})]})}function Wve(){return c.jsx(Lve,{defaultTheme:"system",storageKey:"console-ui-theme",children:c.jsxs(yH,{children:[c.jsx(Yve,{}),c.jsx(Vve,{})]})})}Xq.createRoot(document.getElementById("root")).render(c.jsx(j.StrictMode,{children:c.jsx(Wve,{})}));
|
|
471
|
+
For more information, see https://radix-ui.com/primitives/docs/components/alert-dialog`;return j.useEffect(()=>{var r;document.getElementById((r=e.current)==null?void 0:r.getAttribute("aria-describedby"))||console.warn(t)},[t,e]),null},Cme=TB,Mme=CB,Rme=MB,Dme=RB,Pme=LB,kme=zB,$me=PB,Lme=$B;function up({...e}){return c.jsx(Cme,{"data-slot":"alert-dialog",...e})}function Ime({...e}){return c.jsx(Mme,{"data-slot":"alert-dialog-portal",...e})}function zme({className:e,...t}){return c.jsx(Rme,{className:ve("data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50 data-[state=closed]:animate-out data-[state=open]:animate-in",e),"data-slot":"alert-dialog-overlay",...t})}function fp({className:e,...t}){return c.jsxs(Ime,{children:[c.jsx(zme,{}),c.jsx(Dme,{className:ve("data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border bg-background p-6 shadow-lg duration-200 data-[state=closed]:animate-out data-[state=open]:animate-in sm:max-w-lg",e),"data-slot":"alert-dialog-content",...t})]})}function dp({className:e,...t}){return c.jsx("div",{className:ve("flex flex-col gap-2 text-center sm:text-left",e),"data-slot":"alert-dialog-header",...t})}function hp({className:e,...t}){return c.jsx("div",{className:ve("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",e),"data-slot":"alert-dialog-footer",...t})}function mp({className:e,...t}){return c.jsx($me,{className:ve("font-semibold text-lg",e),"data-slot":"alert-dialog-title",...t})}function pp({className:e,...t}){return c.jsx(Lme,{className:ve("text-muted-foreground text-sm",e),"data-slot":"alert-dialog-description",...t})}function vp({className:e,...t}){return c.jsx(Pme,{className:ve(Zj(),e),...t})}function gp({className:e,...t}){return c.jsx(kme,{className:ve(Zj({variant:"outline"}),e),...t})}var Cv="Collapsible",[Bme]=qn(Cv),[qme,SE]=Bme(Cv),BB=j.forwardRef((e,t)=>{const{__scopeCollapsible:n,open:r,defaultOpen:i,disabled:s,onOpenChange:l,...f}=e,[d,h]=Vr({prop:r,defaultProp:i??!1,onChange:l,caller:Cv});return c.jsx(qme,{scope:n,disabled:s,contentId:_r(),open:d,onOpenToggle:j.useCallback(()=>h(v=>!v),[h]),children:c.jsx(Ce.div,{"data-state":OE(d),"data-disabled":s?"":void 0,...f,ref:t})})});BB.displayName=Cv;var qB="CollapsibleTrigger",UB=j.forwardRef((e,t)=>{const{__scopeCollapsible:n,...r}=e,i=SE(qB,n);return c.jsx(Ce.button,{type:"button","aria-controls":i.contentId,"aria-expanded":i.open||!1,"data-state":OE(i.open),"data-disabled":i.disabled?"":void 0,disabled:i.disabled,...r,ref:t,onClick:be(e.onClick,i.onOpenToggle)})});UB.displayName=qB;var jE="CollapsibleContent",HB=j.forwardRef((e,t)=>{const{forceMount:n,...r}=e,i=SE(jE,e.__scopeCollapsible);return c.jsx(lr,{present:n||i.open,children:({present:s})=>c.jsx(Ume,{...r,ref:t,present:s})})});HB.displayName=jE;var Ume=j.forwardRef((e,t)=>{const{__scopeCollapsible:n,present:r,children:i,...s}=e,l=SE(jE,n),[f,d]=j.useState(r),h=j.useRef(null),v=Be(t,h),p=j.useRef(0),g=p.current,b=j.useRef(0),O=b.current,S=l.open||f,x=j.useRef(S),E=j.useRef(void 0);return j.useEffect(()=>{const A=requestAnimationFrame(()=>x.current=!1);return()=>cancelAnimationFrame(A)},[]),Yt(()=>{const A=h.current;if(A){E.current=E.current||{transitionDuration:A.style.transitionDuration,animationName:A.style.animationName},A.style.transitionDuration="0s",A.style.animationName="none";const _=A.getBoundingClientRect();p.current=_.height,b.current=_.width,x.current||(A.style.transitionDuration=E.current.transitionDuration,A.style.animationName=E.current.animationName),d(r)}},[l.open,r]),c.jsx(Ce.div,{"data-state":OE(l.open),"data-disabled":l.disabled?"":void 0,id:l.contentId,hidden:!S,...s,ref:v,style:{"--radix-collapsible-content-height":g?`${g}px`:void 0,"--radix-collapsible-content-width":O?`${O}px`:void 0,...e.style},children:S&&i})});function OE(e){return e?"open":"closed"}var Hme=BB;const fc=Hme,dc=UB,hc=HB;function EE({...e}){return c.jsx(nO,{"data-slot":"dialog",...e})}function Fme({...e}){return c.jsx(rO,{"data-slot":"dialog-portal",...e})}function Gme({className:e,...t}){return c.jsx(aO,{className:ve("data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50 data-[state=closed]:animate-out data-[state=open]:animate-in",e),"data-slot":"dialog-overlay",...t})}function _E({className:e,children:t,showCloseButton:n=!0,...r}){return c.jsxs(Fme,{"data-slot":"dialog-portal",children:[c.jsx(Gme,{}),c.jsxs(iO,{className:ve("data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border bg-background p-6 shadow-lg duration-200 data-[state=closed]:animate-out data-[state=open]:animate-in sm:max-w-lg",e),"data-slot":"dialog-content",...r,children:[t,n&&c.jsxs(zp,{className:"absolute top-4 right-4 rounded-xs opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-hidden focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground [&_svg:not([class*='size-'])]:size-4 [&_svg]:pointer-events-none [&_svg]:shrink-0","data-slot":"dialog-close",children:[c.jsx(rr,{}),c.jsx("span",{className:"sr-only",children:"Close"})]})]})]})}function FB({className:e,...t}){return c.jsx("div",{className:ve("flex flex-col gap-2 text-center sm:text-left",e),"data-slot":"dialog-header",...t})}function GB({className:e,...t}){return c.jsx("div",{className:ve("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",e),"data-slot":"dialog-footer",...t})}function VB({className:e,...t}){return c.jsx(oO,{className:ve("font-semibold text-lg leading-none",e),"data-slot":"dialog-title",...t})}function Vme({className:e,...t}){return c.jsx(sO,{className:ve("text-muted-foreground text-sm",e),"data-slot":"dialog-description",...t})}var Yme="Label",YB=j.forwardRef((e,t)=>c.jsx(ts.label,{...e,ref:t,onMouseDown:n=>{var i;n.target.closest("button, input, select, textarea")||((i=e.onMouseDown)==null||i.call(e,n),!n.defaultPrevented&&n.detail>1&&n.preventDefault())}}));YB.displayName=Yme;var Wme=YB;function Po({className:e,...t}){return c.jsx(Wme,{className:ve("flex select-none items-center gap-2 font-medium text-sm leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-50 group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50",e),"data-slot":"label",...t})}async function Kme(){const e=sessionStorage.getItem("wraps-auth-token");if(!e)throw new Error("Authentication token not found");const t=await fetch(`/api/settings?token=${e}`);if(!t.ok)throw new Error(`Failed to fetch settings: ${t.statusText}`);return await t.json()}const WB="wraps-dns-verification",Xme=1e3*60*60;function KB(){try{const e=localStorage.getItem(WB);return e?JSON.parse(e):{}}catch{return{}}}function yp(e){try{localStorage.setItem(WB,JSON.stringify(e))}catch(t){console.error("Failed to save DNS verification cache:",t)}}function XB(e){return e?Date.now()-e.lastChecked<Xme:!1}async function y4(e,t){var i;console.log("[DNS Verify] verifyTrackingDomain called",{domain:e,expectedTarget:t});const n=KB(),r=`${e}->${t}`;if((i=n.trackingDomain)!=null&&i[r]&&XB(n.trackingDomain[r]))return console.log("[DNS Verify] Returning cached result"),n.trackingDomain[r];try{const l=`/api/settings/verify-tracking-domain?token=${sessionStorage.getItem("wraps-auth-token")}&domain=${encodeURIComponent(e)}&expectedTarget=${encodeURIComponent(t)}`;console.log("[DNS Verify] Fetching:",l);const f=await fetch(l);if(console.log("[DNS Verify] Response status:",f.status),!f.ok)throw new Error(`HTTP ${f.status}: ${f.statusText}`);const d=await f.json();console.log("[DNS Verify] Response data:",d);const h={verified:d.verified,lastChecked:Date.now(),error:d.error};return n.trackingDomain||(n.trackingDomain={}),n.trackingDomain[r]=h,yp(n),h}catch(s){console.error("Tracking domain verification request failed:",s);const l={verified:!1,lastChecked:Date.now(),error:s instanceof Error?s.message:"Failed to verify"};return n.trackingDomain||(n.trackingDomain={}),n.trackingDomain[r]=l,yp(n),l}}async function b4(e){var r;console.log("[DNS Verify] verifyDmarc called",{domain:e});const t=KB(),n=`_dmarc.${e}`;if((r=t.dmarc)!=null&&r[n]&&XB(t.dmarc[n]))return console.log("[DNS Verify] Returning cached DMARC result"),t.dmarc[n];try{const s=`/api/settings/verify-dmarc?token=${sessionStorage.getItem("wraps-auth-token")}&domain=${encodeURIComponent(e)}`;console.log("[DNS Verify] Fetching:",s);const l=await fetch(s);if(console.log("[DNS Verify] Response status:",l.status),!l.ok)throw new Error(`HTTP ${l.status}: ${l.statusText}`);const f=await l.json();console.log("[DNS Verify] Response data:",f);const d={verified:f.verified,lastChecked:Date.now(),error:f.error};return t.dmarc||(t.dmarc={}),t.dmarc[n]=d,yp(t),d}catch(i){console.error("DMARC verification request failed:",i);const s={verified:!1,lastChecked:Date.now(),error:i instanceof Error?i.message:"Failed to verify"};return t.dmarc||(t.dmarc={}),t.dmarc[n]=s,yp(t),s}}function AE({status:e}){const t={SUCCESS:{icon:Zi,label:"Verified",variant:"default",className:"bg-green-500/10 text-green-700 dark:text-green-400 border-green-500/20"},PENDING:{icon:Uo,label:"Pending",variant:"secondary",className:"bg-yellow-500/10 text-yellow-700 dark:text-yellow-400 border-yellow-500/20"},FAILED:{icon:F4,label:"Failed",variant:"destructive",className:"bg-red-500/10 text-red-700 dark:text-red-400 border-red-500/20"},TEMPORARY_FAILURE:{icon:ir,label:"Temporary Failure",variant:"secondary",className:"bg-orange-500/10 text-orange-700 dark:text-orange-400 border-orange-500/20"},NOT_STARTED:{icon:Uo,label:"Not Started",variant:"outline",className:"bg-gray-500/10 text-gray-700 dark:text-gray-400 border-gray-500/20"}},{icon:n,label:r,className:i}=t[e];return c.jsxs(He,{className:i,variant:"outline",children:[c.jsx(n,{className:"mr-1 h-3 w-3"}),r]})}function Gl({text:e}){const t=async()=>{await navigator.clipboard.writeText(e),wt.success("Copied to clipboard",{description:"DNS record value copied successfully"})};return c.jsx(Ee,{onClick:t,size:"sm",variant:"ghost",children:c.jsx(bl,{className:"h-3 w-3"})})}function Qme({identity:e}){const t=e==null?void 0:e.dkimAttributes,n=(t==null?void 0:t.status)==="SUCCESS",[r,i]=j.useState(!n);return t?c.jsxs("div",{className:"space-y-4",children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{children:[c.jsx("p",{className:"font-medium",children:"DKIM Authentication"}),c.jsxs("p",{className:"text-muted-foreground text-sm",children:[t.signingEnabled?"Enabled":"Disabled",t.signingKeyLength&&` · ${t.signingKeyLength}`]})]}),c.jsx(AE,{status:t.status})]}),t.tokens&&t.tokens.length>0&&c.jsxs(fc,{onOpenChange:i,open:r,children:[c.jsx(dc,{asChild:!0,children:c.jsxs(Ee,{className:"h-auto w-full justify-between p-0",size:"sm",variant:"ghost",children:[c.jsx("p",{className:"font-medium text-sm",children:"DNS Records (CNAME)"}),r?c.jsx(Nf,{className:"h-4 w-4"}):c.jsx(Jo,{className:"h-4 w-4"})]})}),c.jsx(hc,{className:"mt-2 space-y-2",children:t.tokens.map(s=>c.jsxs("div",{className:"rounded-md border bg-muted/50 p-3",children:[c.jsxs("div",{className:"mb-1 flex items-center justify-between",children:[c.jsxs("p",{className:"font-mono text-xs",children:[s,"._domainkey.",e.identityName]}),c.jsx(Gl,{text:`${s}._domainkey.${e.identityName}`})]}),c.jsxs("p",{className:"font-mono text-muted-foreground text-xs",children:["CNAME → ",s,".dkim.amazonses.com"]})]},s))})]})]}):c.jsx("div",{className:"space-y-4",children:c.jsx("div",{className:"flex items-center justify-between",children:c.jsxs("div",{children:[c.jsx("p",{className:"font-medium",children:"DKIM Authentication"}),c.jsx("p",{className:"text-muted-foreground text-sm",children:"Not configured"})]})})})}function Zme({identity:e}){const t=e==null?void 0:e.mailFromAttributes,n=(t==null?void 0:t.mailFromDomainStatus)==="SUCCESS",[r,i]=j.useState(!n);return c.jsx("div",{className:"space-y-4",children:t!=null&&t.mailFromDomain?c.jsxs(c.Fragment,{children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{children:[c.jsx("p",{className:"font-medium",children:"Mail-From Domain"}),c.jsxs("p",{className:"text-muted-foreground text-sm",children:[t.mailFromDomain,t.behaviorOnMxFailure&&` · ${t.behaviorOnMxFailure==="USE_DEFAULT_VALUE"?"Fallback enabled":"Reject on failure"}`]})]}),t.mailFromDomainStatus&&c.jsx(AE,{status:t.mailFromDomainStatus})]}),c.jsxs(fc,{onOpenChange:i,open:r,children:[c.jsx(dc,{asChild:!0,children:c.jsxs(Ee,{className:"h-auto w-full justify-between p-0",size:"sm",variant:"ghost",children:[c.jsx("p",{className:"font-medium text-sm",children:"DNS Record (MX)"}),r?c.jsx(Nf,{className:"h-4 w-4"}):c.jsx(Jo,{className:"h-4 w-4"})]})}),c.jsx(hc,{className:"mt-2",children:c.jsx("div",{className:"rounded-md border bg-muted/50 p-3",children:c.jsxs("div",{className:"space-y-1",children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("p",{className:"font-mono text-xs",children:["MX ",t.mailFromDomain]}),c.jsx(Gl,{text:`10 feedback-smtp.${e==null?void 0:e.identityName.split(".")[0]}.amazonses.com`})]}),c.jsxs("p",{className:"font-mono text-muted-foreground text-xs",children:["Priority 10 → feedback-smtp.",e==null?void 0:e.identityName.split(".")[0],".amazonses.com"]})]})})})]})]}):c.jsx("div",{className:"flex items-center justify-between",children:c.jsxs("div",{children:[c.jsx("p",{className:"font-medium",children:"Mail-From Domain"}),c.jsx("p",{className:"text-muted-foreground text-sm",children:"Using default amazonses.com domain"})]})})})}function Jme({identity:e}){const[t,n]=j.useState(null),[r,i]=j.useState(!1),[s,l]=j.useState(!(t!=null&&t.verified));j.useEffect(()=>{e!=null&&e.identityName&&b4(e.identityName).then(n)},[e==null?void 0:e.identityName]),j.useEffect(()=>{t&&l(!t.verified)},[t]);const f=async()=>{if(e!=null&&e.identityName){i(!0);try{const d=await b4(e.identityName);n(d),d.verified?wt.success("DMARC record verified",{description:"DNS TXT record found and configured correctly"}):(console.error("DMARC verification failed:",d.error),wt.error("Verification failed",{description:d.error||"DMARC record not found"}))}catch(d){console.error("DMARC verification error:",d),wt.error("Verification error",{description:d instanceof Error?d.message:"Unknown error"})}finally{i(!1)}}};return c.jsxs("div",{className:"space-y-4",children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{children:[c.jsx("p",{className:"font-medium",children:"DMARC Policy"}),c.jsx("p",{className:"text-muted-foreground text-sm",children:t!=null&&t.verified?"Configured":"Recommended for better deliverability"})]}),c.jsxs("div",{className:"flex items-center gap-2",children:[(t==null?void 0:t.verified)&&c.jsxs(He,{className:"border-green-500/20 bg-green-500/10 text-green-700 dark:text-green-400",variant:"outline",children:[c.jsx(Zi,{className:"mr-1 h-3 w-3"}),"Verified by Wraps"]}),c.jsx(Ee,{className:"h-8 w-8 p-0",disabled:r,onClick:f,size:"sm",variant:"ghost",children:c.jsx(Cf,{className:`h-4 w-4 ${r?"animate-spin":""}`})})]})]}),c.jsxs(fc,{onOpenChange:l,open:s,children:[c.jsx(dc,{asChild:!0,children:c.jsxs(Ee,{className:"h-auto w-full justify-between p-0",size:"sm",variant:"ghost",children:[c.jsx("p",{className:"font-medium text-sm",children:"DNS Record (TXT)"}),s?c.jsx(Nf,{className:"h-4 w-4"}):c.jsx(Jo,{className:"h-4 w-4"})]})}),c.jsx(hc,{className:"mt-2",children:c.jsxs("div",{className:"rounded-md border bg-muted/50 p-3",children:[c.jsxs("div",{className:"mb-2 flex items-center justify-between",children:[c.jsxs("p",{className:"font-mono text-xs",children:["_dmarc.",(e==null?void 0:e.identityName)||"yourdomain.com"]}),c.jsx(Gl,{text:`_dmarc.${(e==null?void 0:e.identityName)||"yourdomain.com"}`})]}),c.jsxs("div",{className:"flex items-start justify-between gap-2",children:[c.jsxs("p",{className:"font-mono text-muted-foreground text-xs",children:["v=DMARC1; p=quarantine; rua=mailto:dmarc@",(e==null?void 0:e.identityName)||"yourdomain.com"]}),c.jsx(Gl,{text:`v=DMARC1; p=quarantine; rua=mailto:dmarc@${(e==null?void 0:e.identityName)||"yourdomain.com"}`})]})]})})]})]})}function epe({configSet:e,region:t,onRefresh:n}){const r=e==null?void 0:e.trackingOptions,[i,s]=j.useState(null),[l,f]=j.useState(!1),[d,h]=j.useState(!1),[v,p]=j.useState(""),[g,b]=j.useState(!1),[O,S]=j.useState(!(i!=null&&i.verified));j.useEffect(()=>{if(r!=null&&r.customRedirectDomain&&t){const _=`r.${t}.awstrack.me`;y4(r.customRedirectDomain,_).then(s)}},[r==null?void 0:r.customRedirectDomain,t]),j.useEffect(()=>{i&&S(!i.verified)},[i]);const x=async()=>{if(r!=null&&r.customRedirectDomain&&t){f(!0);try{const _=`r.${t}.awstrack.me`,T=await y4(r.customRedirectDomain,_);s(T),T.verified?wt.success("Tracking domain verified",{description:"DNS records are configured correctly"}):(console.error("Tracking domain verification failed:",T.error),wt.error("Verification failed",{description:T.error||"DNS records not found"}))}catch(_){console.error("Tracking domain verification error:",_),wt.error("Verification error",{description:_ instanceof Error?_.message:"Unknown error"})}finally{f(!1)}}},E=()=>{p((r==null?void 0:r.customRedirectDomain)||""),h(!0)},A=async()=>{if(!v.trim()){wt.error("Invalid domain",{description:"Please enter a valid domain name"});return}b(!0);try{const _=sessionStorage.getItem("wraps-auth-token"),T=await fetch(`/api/settings/config-set/tracking-domain?token=${_}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({domain:v})});if(!T.ok){const N=await T.json();throw new Error(N.error||`Failed to update: ${T.statusText}`)}h(!1),wt.success("Tracking domain updated",{description:"Don't forget to configure the DNS records"}),n&&await n()}catch(_){console.error("Failed to update tracking domain:",_),wt.error("Failed to update tracking domain",{description:_ instanceof Error?_.message:"Unknown error"})}finally{b(!1)}};return c.jsxs(Ne,{children:[c.jsxs(De,{children:[c.jsx(Fe,{children:"Tracking Domain"}),c.jsx(Ye,{children:"Custom domain for open and click tracking links"})]}),c.jsx(Le,{className:"space-y-4",children:r!=null&&r.customRedirectDomain?c.jsxs(c.Fragment,{children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{className:"flex-1",children:[c.jsx("p",{className:"font-medium",children:r.customRedirectDomain}),c.jsx("p",{className:"text-muted-foreground text-sm",children:"Custom Tracking Domain"})]}),c.jsxs("div",{className:"flex items-center gap-2",children:[(i==null?void 0:i.verified)&&c.jsxs(He,{className:"border-green-500/20 bg-green-500/10 text-green-700 dark:text-green-400",variant:"outline",children:[c.jsx(Zi,{className:"mr-1 h-3 w-3"}),"Verified by Wraps"]}),c.jsx(He,{variant:"outline",children:r.httpsPolicy==="REQUIRE"?"HTTPS Only":"HTTPS Optional"}),c.jsx(Ee,{className:"h-8 w-8 p-0",disabled:l,onClick:x,size:"sm",variant:"ghost",children:c.jsx(Cf,{className:`h-4 w-4 ${l?"animate-spin":""}`})}),c.jsx(Ee,{className:"h-8 w-8 p-0",onClick:E,size:"sm",variant:"ghost",children:c.jsx(L2,{className:"h-4 w-4"})})]})]}),c.jsxs(fc,{onOpenChange:S,open:O,children:[c.jsx(dc,{asChild:!0,children:c.jsxs(Ee,{className:"h-auto w-full justify-between p-0",size:"sm",variant:"ghost",children:[c.jsx("p",{className:"font-medium text-sm",children:"Required DNS Record (CNAME)"}),O?c.jsx(Nf,{className:"h-4 w-4"}):c.jsx(Jo,{className:"h-4 w-4"})]})}),c.jsx(hc,{className:"mt-2",children:c.jsxs("div",{className:"rounded-md border bg-muted/50 p-3",children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx("p",{className:"font-mono text-xs",children:r.customRedirectDomain}),c.jsx(Gl,{text:r.customRedirectDomain})]}),c.jsxs("div",{className:"mt-1 flex items-start justify-between gap-2",children:[c.jsxs("p",{className:"font-mono text-muted-foreground text-xs",children:["CNAME → r.",(e==null?void 0:e.name)||"region",".awstrack.me"]}),c.jsx(Gl,{text:`r.${(e==null?void 0:e.name)||"region"}.awstrack.me`})]})]})})]})]}):c.jsxs("div",{className:"space-y-4",children:[c.jsx("p",{className:"text-muted-foreground text-sm",children:"No custom tracking domain configured. Using default awstrack.me domain."}),c.jsxs(Ee,{onClick:E,size:"sm",variant:"outline",children:[c.jsx(L2,{className:"mr-2 h-4 w-4"}),"Configure Tracking Domain"]})]})}),c.jsx(EE,{onOpenChange:h,open:d,children:c.jsxs(_E,{children:[c.jsxs(FB,{children:[c.jsx(VB,{children:"Update Tracking Domain"}),c.jsx(Vme,{children:"Enter the custom domain you want to use for email tracking links. You'll need to configure DNS records after saving."})]}),c.jsx("div",{className:"space-y-4 py-4",children:c.jsxs("div",{className:"space-y-2",children:[c.jsx(Po,{htmlFor:"domain",children:"Tracking Domain"}),c.jsx(ec,{disabled:g,id:"domain",onChange:_=>p(_.target.value),placeholder:"track.example.com",value:v}),c.jsx("p",{className:"text-muted-foreground text-xs",children:"Example: track.yourdomain.com or email.yourdomain.com"})]})}),c.jsxs(GB,{children:[c.jsx(Ee,{disabled:g,onClick:()=>h(!1),variant:"outline",children:"Cancel"}),c.jsx(Ee,{disabled:g,onClick:A,children:g?"Updating...":"Update Domain"})]})]})})]})}function tpe({configSet:e,onRefresh:t}){var v,p;const[n,r]=j.useState(!1),[i,s]=j.useState(!1),[l,f]=j.useState(!1);if(!e)return c.jsx(Ne,{children:c.jsxs(De,{children:[c.jsx(Fe,{children:"Configuration Set"}),c.jsx(Ye,{children:"No configuration set found"})]})});const d=async()=>{var g;f(!0);try{const b=sessionStorage.getItem("wraps-auth-token"),O=!((g=e.sendingOptions)!=null&&g.sendingEnabled),S=await fetch(`/api/settings/config-set/sending?token=${b}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({enabled:O})});if(!S.ok)throw new Error(`Failed to update: ${S.statusText}`);r(!1),wt.success(O?"Email sending enabled":"Email sending disabled"),t&&await t()}catch(b){console.error("Failed to toggle sending:",b),wt.error("Failed to update setting",{description:b instanceof Error?b.message:"Unknown error"})}finally{f(!1)}},h=async()=>{var g;f(!0);try{const b=sessionStorage.getItem("wraps-auth-token"),O=!((g=e.reputationOptions)!=null&&g.reputationMetricsEnabled),S=await fetch(`/api/settings/config-set/reputation?token=${b}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({enabled:O})});if(!S.ok)throw new Error(`Failed to update: ${S.statusText}`);s(!1),wt.success(O?"Reputation metrics enabled":"Reputation metrics disabled"),t&&await t()}catch(b){console.error("Failed to toggle reputation:",b),wt.error("Failed to update setting",{description:b instanceof Error?b.message:"Unknown error"})}finally{f(!1)}};return c.jsxs(Ne,{children:[c.jsxs(De,{children:[c.jsx(Fe,{children:"Configuration Set"}),c.jsx(Ye,{children:"Email sending and tracking configuration"})]}),c.jsxs(Le,{className:"space-y-6",children:[c.jsxs("div",{children:[c.jsx("p",{className:"font-medium",children:e.name}),c.jsx("p",{className:"text-muted-foreground text-sm",children:"Configuration Set Name"})]}),c.jsx(Bt,{}),e.sendingOptions&&c.jsxs(c.Fragment,{children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{className:"flex-1 space-y-0.5",children:[c.jsx("p",{className:"font-medium text-sm",children:"Email Sending"}),c.jsx("p",{className:"text-muted-foreground text-sm",children:e.sendingOptions.sendingEnabled?"Emails can be sent":"Email sending is disabled"})]}),c.jsx(Ee,{onClick:()=>r(!0),size:"sm",variant:e.sendingOptions.sendingEnabled?"destructive":"default",children:e.sendingOptions.sendingEnabled?"Disable":"Enable"})]}),c.jsx(up,{onOpenChange:r,open:n,children:c.jsxs(fp,{children:[c.jsxs(dp,{children:[c.jsx(mp,{children:e.sendingOptions.sendingEnabled?"Disable email sending?":"Enable email sending?"}),c.jsx(pp,{children:e.sendingOptions.sendingEnabled?"All outgoing emails will be blocked until you re-enable sending. Emails in the queue will not be sent.":"This will allow emails to be sent through this configuration set. Make sure your domain is verified before enabling."})]}),c.jsxs(hp,{children:[c.jsx(gp,{disabled:l,children:"Cancel"}),c.jsx(vp,{disabled:l,onClick:d,children:l?"Updating...":e.sendingOptions.sendingEnabled?"Disable sending":"Enable sending"})]})]})})]}),e.reputationOptions&&c.jsxs(c.Fragment,{children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{className:"flex-1 space-y-0.5",children:[c.jsx("p",{className:"font-medium text-sm",children:"Reputation Metrics"}),c.jsx("p",{className:"text-muted-foreground text-sm",children:e.reputationOptions.reputationMetricsEnabled?"Tracking bounce and complaint rates":"Reputation tracking disabled"})]}),c.jsx(Ee,{onClick:()=>s(!0),size:"sm",variant:"outline",children:e.reputationOptions.reputationMetricsEnabled?"Disable":"Enable"})]}),c.jsx(up,{onOpenChange:s,open:i,children:c.jsxs(fp,{children:[c.jsxs(dp,{children:[c.jsx(mp,{children:e.reputationOptions.reputationMetricsEnabled?"Disable reputation metrics?":"Enable reputation metrics?"}),c.jsx(pp,{children:e.reputationOptions.reputationMetricsEnabled?"You will stop collecting bounce and complaint rate data. Historical data will be preserved but no new metrics will be tracked.":"This will start tracking bounce and complaint rates for your sending domain. This helps monitor your email reputation and deliverability."})]}),c.jsxs(hp,{children:[c.jsx(gp,{disabled:l,children:"Cancel"}),c.jsx(vp,{disabled:l,onClick:h,children:l?"Updating...":e.reputationOptions.reputationMetricsEnabled?"Disable metrics":"Enable metrics"})]})]})})]}),((v=e.deliveryOptions)==null?void 0:v.tlsPolicy)&&c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{className:"space-y-0.5",children:[c.jsx("p",{className:"font-medium text-sm",children:"TLS Encryption"}),c.jsx("p",{className:"text-muted-foreground text-sm",children:e.deliveryOptions.tlsPolicy==="REQUIRE"?"Required for all connections":"Optional (opportunistic)"})]}),c.jsx(He,{variant:"outline",children:e.deliveryOptions.tlsPolicy==="REQUIRE"?"Required":"Optional"})]}),e.suppressionOptions&&c.jsxs("div",{className:"space-y-2",children:[c.jsxs("div",{className:"space-y-0.5",children:[c.jsx("p",{className:"font-medium text-sm",children:"Suppression List"}),c.jsx("p",{className:"text-muted-foreground text-sm",children:"Automatically suppress emails to addresses that bounced or complained"})]}),e.suppressionOptions.suppressedReasons&&e.suppressionOptions.suppressedReasons.length>0?c.jsx("div",{className:"flex gap-2",children:e.suppressionOptions.suppressedReasons.map(g=>c.jsx(He,{variant:"secondary",children:g},g))}):c.jsx("p",{className:"text-muted-foreground text-sm",children:"Not configured"})]}),((p=e.deliveryOptions)==null?void 0:p.sendingPoolName)&&c.jsxs("div",{children:[c.jsx("p",{className:"font-medium text-sm",children:"IP Pool"}),c.jsx("p",{className:"text-muted-foreground text-sm",children:e.deliveryOptions.sendingPoolName})]})]})]})}function npe(){var f,d;const[e,t]=j.useState(null),[n,r]=j.useState(!0),[i,s]=j.useState(null),l=j.useCallback(async()=>{try{r(!0);const h=await Kme();t(h),s(null)}catch(h){console.error("Failed to fetch email settings:",h),s(h instanceof Error?h.message:"Failed to load settings")}finally{r(!1)}},[]);return j.useEffect(()=>{l()},[l]),n?c.jsxs(c.Fragment,{children:[c.jsxs("div",{children:[c.jsx("h1",{className:"font-semibold text-3xl tracking-tight",children:"Email Settings"}),c.jsx("p",{className:"mt-2 text-muted-foreground",children:"Configure your email settings and preferences"})]}),c.jsxs("div",{className:"mt-6 grid gap-6 md:grid-cols-2",children:[c.jsxs(Ne,{className:"md:row-span-2",children:[c.jsxs(De,{children:[c.jsx(Re,{className:"h-6 w-48"}),c.jsx(Re,{className:"mt-2 h-4 w-64"})]}),c.jsxs(Le,{className:"space-y-6",children:[c.jsxs("div",{className:"space-y-2",children:[c.jsx(Re,{className:"h-4 w-32"}),c.jsx(Re,{className:"h-4 w-24"})]}),c.jsx(Re,{className:"h-px w-full"}),c.jsxs("div",{className:"space-y-2",children:[c.jsx(Re,{className:"h-4 w-40"}),c.jsx(Re,{className:"h-4 w-28"})]}),c.jsx(Re,{className:"h-px w-full"}),c.jsxs("div",{className:"space-y-2",children:[c.jsx(Re,{className:"h-4 w-36"}),c.jsx(Re,{className:"h-4 w-32"})]}),c.jsx(Re,{className:"h-px w-full"}),c.jsxs("div",{className:"space-y-2",children:[c.jsx(Re,{className:"h-4 w-32"}),c.jsx(Re,{className:"h-4 w-44"})]})]})]}),c.jsxs(Ne,{children:[c.jsxs(De,{children:[c.jsx(Re,{className:"h-6 w-48"}),c.jsx(Re,{className:"mt-2 h-4 w-64"})]}),c.jsx(Le,{children:c.jsx(Re,{className:"h-20 w-full"})})]}),c.jsxs(Ne,{children:[c.jsxs(De,{children:[c.jsx(Re,{className:"h-6 w-48"}),c.jsx(Re,{className:"mt-2 h-4 w-64"})]}),c.jsx(Le,{children:c.jsx(Re,{className:"h-20 w-full"})})]})]})]}):i?c.jsxs(c.Fragment,{children:[c.jsxs("div",{children:[c.jsx("h1",{className:"font-semibold text-3xl tracking-tight",children:"Email Settings"}),c.jsx("p",{className:"mt-2 text-muted-foreground",children:"Configure your email settings and preferences"})]}),c.jsxs(In,{className:"mt-6",variant:"destructive",children:[c.jsx(ir,{className:"h-4 w-4"}),c.jsx(Xi,{children:"Error Loading Settings"}),c.jsx(zn,{children:i})]})]}):c.jsxs(c.Fragment,{children:[c.jsxs("div",{children:[c.jsx("h1",{className:"font-semibold text-3xl tracking-tight",children:"Email Settings"}),c.jsx("p",{className:"mt-2 text-muted-foreground",children:"Configure your email settings and preferences"})]}),c.jsxs("div",{className:"mt-6 grid gap-6 md:grid-cols-2",children:[c.jsxs(Ne,{className:"md:row-span-2",children:[c.jsxs(De,{children:[c.jsx(Fe,{children:"Sending Domain"}),c.jsx(Ye,{children:"Email domain configuration and authentication"})]}),c.jsxs(Le,{className:"space-y-6",children:[c.jsx("div",{className:"space-y-4",children:c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{className:"flex-1",children:[c.jsx("p",{className:"font-medium",children:(f=e==null?void 0:e.identity)==null?void 0:f.identityName}),c.jsx("p",{className:"text-muted-foreground text-sm",children:"Domain Identity"})]}),c.jsx(AE,{status:((d=e==null?void 0:e.identity)==null?void 0:d.verificationStatus)||"NOT_STARTED"})]})}),c.jsx(Bt,{}),c.jsx(Qme,{identity:e==null?void 0:e.identity}),c.jsx(Bt,{}),c.jsx(Zme,{identity:e==null?void 0:e.identity}),c.jsx(Bt,{}),c.jsx(Jme,{identity:e==null?void 0:e.identity})]})]}),c.jsx(tpe,{configSet:e==null?void 0:e.configurationSet,onRefresh:l}),c.jsx(epe,{configSet:e==null?void 0:e.configurationSet,onRefresh:l,region:e==null?void 0:e.region})]})]})}const rpe={sent:Yi,delivered:Vi,failed:rr,queued:Uo,blocked:rr,carrier_unreachable:Wh,invalid:rr,opted_out:rr,ttl_expired:Uo},ape={sent:"text-blue-500",delivered:"text-green-500",failed:"text-red-500",queued:"text-gray-500",blocked:"text-orange-500",carrier_unreachable:"text-red-500",invalid:"text-red-500",opted_out:"text-yellow-500",ttl_expired:"text-gray-500"},ipe={delivered:"default",sent:"secondary",queued:"secondary",failed:"destructive",blocked:"destructive",invalid:"destructive",opted_out:"default"};function ope(){const{id:e}=P4(),t=Zo(),[n,r]=j.useState(null),[i,s]=j.useState(!0),[l,f]=j.useState(null);j.useEffect(()=>{async function p(){try{s(!0),f(null);const g=sessionStorage.getItem("wraps-auth-token");if(!g)throw new Error("Authentication token not found");const b=encodeURIComponent(e||""),O=await fetch(`/api/sms/${b}?token=${g}`);if(!O.ok){let E="Failed to fetch SMS details";try{E=(await O.json()).error||E}catch{E=`${O.status}: ${O.statusText}`}throw new Error(E)}const S=O.headers.get("content-type");if(!(S!=null&&S.includes("application/json"))){const E=await O.text();throw console.error("Non-JSON response:",E),new Error("Server returned non-JSON response")}const x=await O.json();r(x)}catch(g){const b=g instanceof Error?g.message:"Unknown error";f(b),console.error("Error fetching SMS details:",g)}finally{s(!1)}}e&&p()},[e]);const d=p=>new Date(p).toLocaleString("en-US",{month:"short",day:"numeric",hour:"numeric",minute:"2-digit",hour12:!0}),h=p=>new Date(p).toLocaleString("en-US",{weekday:"short",month:"short",day:"numeric",year:"numeric",hour:"numeric",minute:"2-digit",second:"2-digit",hour12:!0}),v=p=>p.startsWith("+1")&&p.length===12?`(${p.slice(2,5)}) ${p.slice(5,8)}-${p.slice(8)}`:p;return i?c.jsx("div",{className:"flex h-[600px] items-center justify-center",children:c.jsx("div",{className:"text-muted-foreground",children:"Loading SMS details..."})}):l?c.jsxs("div",{className:"space-y-4",children:[c.jsxs(Ee,{onClick:()=>t("/sms"),size:"sm",variant:"ghost",children:[c.jsx(fl,{className:"mr-2 h-4 w-4"}),"Back to messages"]}),c.jsx("div",{className:"rounded-md border border-destructive bg-destructive/10 p-4 text-destructive text-sm",children:l})]}):n?c.jsxs("div",{className:"space-y-6",children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs(Ee,{onClick:()=>t("/sms"),size:"sm",variant:"ghost",children:[c.jsx(fl,{className:"mr-2 h-4 w-4"}),"Back to messages"]}),c.jsx(He,{variant:ipe[n.status],children:n.status.charAt(0).toUpperCase()+n.status.slice(1).replace("_"," ")})]}),c.jsxs(Ne,{children:[c.jsx(De,{children:c.jsx("div",{className:"flex items-start justify-between",children:c.jsxs("div",{className:"space-y-1.5",children:[c.jsxs(Fe,{className:"flex items-center gap-2 text-2xl",children:[c.jsx(Yi,{className:"h-6 w-6"}),"SMS Message"]}),c.jsx(Ye,{className:"font-mono text-xs",children:n.messageId})]})})}),c.jsx(Le,{className:"space-y-4",children:c.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[c.jsxs("div",{className:"space-y-1",children:[c.jsx("div",{className:"text-muted-foreground text-sm",children:"FROM"}),c.jsx("div",{className:"font-mono text-sm",children:v(n.from)})]}),c.jsxs("div",{className:"space-y-1",children:[c.jsx("div",{className:"text-muted-foreground text-sm",children:"TO"}),c.jsx("div",{className:"font-mono text-sm",children:v(n.to)})]}),c.jsxs("div",{className:"space-y-1",children:[c.jsx("div",{className:"text-muted-foreground text-sm",children:"SEGMENTS"}),c.jsx("div",{className:"font-mono text-sm",children:n.segments})]}),c.jsxs("div",{className:"space-y-1",children:[c.jsx("div",{className:"text-muted-foreground text-sm",children:"ID"}),c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("code",{className:"rounded bg-muted px-2 py-1 font-mono text-xs",children:n.id}),c.jsx(Ee,{className:"h-6 w-6",onClick:()=>navigator.clipboard.writeText(n.id),size:"icon",variant:"ghost",children:c.jsx("span",{className:"sr-only",children:"Copy ID"})})]})]})]})})]}),c.jsxs(Ne,{children:[c.jsxs(De,{children:[c.jsx(Fe,{children:"Message Content"}),c.jsx(Ye,{children:"The SMS message body"})]}),c.jsx(Le,{children:c.jsx("div",{className:"rounded-md border bg-muted/50 p-4",children:c.jsx("p",{className:"whitespace-pre-wrap text-sm",children:n.body})})})]}),c.jsxs(Ne,{children:[c.jsxs(De,{children:[c.jsx(Fe,{children:"Message Events"}),c.jsx(Ye,{children:"Lifecycle of this message from send to delivery"})]}),c.jsx(Le,{children:c.jsx("div",{className:"space-y-4",children:n.events.length===0?c.jsx("div",{className:"text-muted-foreground text-sm",children:"No events recorded yet"}):n.events.map((p,g)=>{const b=rpe[p.type]||Uo,O=g===n.events.length-1;return c.jsx("div",{children:c.jsxs("div",{className:"flex gap-4",children:[c.jsxs("div",{className:"flex flex-col items-center",children:[c.jsx("div",{className:`rounded-full border-2 border-background bg-muted p-2 ${ape[p.type]}`,children:c.jsx(b,{className:"h-4 w-4"})}),!O&&c.jsx("div",{className:"my-1 w-px flex-1 bg-border"})]}),c.jsxs("div",{className:"flex-1 pb-6",children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx("div",{className:"font-medium capitalize",children:p.type.replace("_"," ")}),c.jsx("div",{className:"text-muted-foreground text-sm",children:d(p.timestamp)})]}),c.jsx("div",{className:"text-muted-foreground text-sm",children:h(p.timestamp)}),p.metadata&&Object.keys(p.metadata).length>0&&c.jsx("div",{className:"mt-2 rounded-md border bg-muted/50 p-2 font-mono text-xs",children:c.jsx("pre",{className:"overflow-x-auto",children:JSON.stringify(p.metadata,null,2)})})]})]})},`${p.type}-${p.timestamp}`)})})})]})]}):c.jsxs("div",{className:"space-y-4",children:[c.jsxs(Ee,{onClick:()=>t("/sms"),size:"sm",variant:"ghost",children:[c.jsx(fl,{className:"mr-2 h-4 w-4"}),"Back to messages"]}),c.jsx("div",{className:"rounded-md border p-4 text-muted-foreground text-sm",children:"SMS message not found"})]})}const w1={delivered:{variant:"default",description:"Message was delivered to recipient's device",className:"bg-green-500/10 text-green-700 dark:text-green-400 hover:bg-green-500/20 border-green-500/20"},sent:{variant:"secondary",description:"Message was sent but delivery not yet confirmed",className:"bg-blue-500/10 text-blue-700 dark:text-blue-400 hover:bg-blue-500/20 border-blue-500/20"},queued:{variant:"secondary",description:"Message is queued for delivery",className:"bg-gray-500/10 text-gray-700 dark:text-gray-400 hover:bg-gray-500/20 border-gray-500/20"},failed:{variant:"destructive",description:"Message failed to deliver",className:"bg-red-500/10 text-red-700 dark:text-red-400 hover:bg-red-500/20 border-red-500/20"},blocked:{variant:"destructive",description:"Message was blocked by carrier or filter",className:"bg-orange-500/10 text-orange-700 dark:text-orange-400 hover:bg-orange-500/20 border-orange-500/20"},invalid:{variant:"destructive",description:"Invalid phone number or message format",className:"bg-red-500/10 text-red-700 dark:text-red-400 hover:bg-red-500/20 border-red-500/20"},opted_out:{variant:"default",description:"Recipient has opted out of receiving messages",className:"bg-yellow-500/10 text-yellow-700 dark:text-yellow-400 hover:bg-yellow-500/20 border-yellow-500/20"}};function spe(){const e=Zo(),[t,n]=j.useState(""),[r,i]=j.useState("15"),[s,l]=j.useState("all"),[f,d]=j.useState([]),[h,v]=j.useState(!0),[p,g]=j.useState(null);j.useEffect(()=>{async function x(){try{v(!0),g(null);let E=sessionStorage.getItem("wraps-auth-token");if(E||(E=new URLSearchParams(window.location.search).get("token"),E&&sessionStorage.setItem("wraps-auth-token",E)),!E)throw new Error("Authentication token not found. Please use the URL provided by 'wraps console' command.");const A=Number.parseInt(r,10),_=Date.now()-A*24*60*60*1e3,T=Date.now(),N=await fetch(`/api/sms?startTime=${_}&endTime=${T}&limit=100&token=${E}`);if(!N.ok){let R="Failed to fetch SMS logs";try{R=(await N.json()).error||R}catch{R=`${N.status}: ${N.statusText}`}throw new Error(R)}const M=await N.json();d(M.logs.map(R=>({id:R.messageId,to:R.to,from:R.from,body:R.body,status:R.status,timestamp:R.sentAt,messageId:R.messageId,segments:R.segments})))}catch(E){const A=E instanceof Error?E.message:"Unknown error";g(A),console.error("Error fetching SMS logs:",E)}finally{v(!1)}}x()},[r]);const b=f.filter(x=>{if(t){const E=t.toLowerCase(),A=x.to.toLowerCase().includes(E),_=x.body.toLowerCase().includes(E);if(!(A||_))return!1}return!(s!=="all"&&x.status!==s)}),O=x=>{const E=new Date(x),_=Math.floor((new Date().getTime()-E.getTime())/(1e3*60*60*24));return _===0?"Today":_===1?"Yesterday":_<7?`${_} days ago`:E.toLocaleDateString()},S=x=>x.startsWith("+1")&&x.length===12?`(${x.slice(2,5)}) ${x.slice(5,8)}-${x.slice(8)}`:x;return c.jsxs(Ne,{children:[c.jsxs(De,{children:[c.jsxs(Fe,{className:"flex items-center gap-2",children:[c.jsx(Yi,{className:"h-5 w-5"}),"SMS Messages"]}),c.jsx(Ye,{children:"View and manage your SMS sending history"})]}),c.jsxs(Le,{children:[p&&c.jsx("div",{className:"mb-4 rounded-md border border-destructive bg-destructive/10 p-4 text-destructive text-sm",children:p}),c.jsxs("div",{className:"mb-4 flex items-center gap-2",children:[c.jsxs("div",{className:"relative flex-1",children:[c.jsx(Aj,{className:"absolute top-2.5 left-2.5 h-4 w-4 text-muted-foreground"}),c.jsx(ec,{className:"pl-8",onChange:x=>n(x.target.value),placeholder:"Search by phone or message...",value:t})]}),c.jsxs(fa,{onValueChange:i,value:r,children:[c.jsx(ha,{className:"w-[180px]",children:c.jsx(da,{})}),c.jsxs(ma,{children:[c.jsx(Ue,{value:"1",children:"Last 24 hours"}),c.jsx(Ue,{value:"7",children:"Last 7 days"}),c.jsx(Ue,{value:"15",children:"Last 15 days"}),c.jsx(Ue,{value:"30",children:"Last 30 days"}),c.jsx(Ue,{value:"90",children:"Last 90 days"})]})]}),c.jsxs(fa,{onValueChange:l,value:s,children:[c.jsx(ha,{className:"w-[180px]",children:c.jsx(da,{})}),c.jsxs(ma,{children:[c.jsx(Ue,{value:"all",children:"All Statuses"}),c.jsx(Ue,{value:"delivered",children:"Delivered"}),c.jsx(Ue,{value:"sent",children:"Sent"}),c.jsx(Ue,{value:"queued",children:"Queued"}),c.jsx(Ue,{value:"failed",children:"Failed"}),c.jsx(Ue,{value:"blocked",children:"Blocked"}),c.jsx(Ue,{value:"opted_out",children:"Opted Out"})]})]}),c.jsx(Ee,{size:"icon",variant:"outline",children:c.jsx("span",{className:"sr-only",children:"Download"})})]}),c.jsx("div",{className:"rounded-md border",children:c.jsxs(dO,{children:[c.jsx(hO,{children:c.jsxs(la,{children:[c.jsx(pn,{children:"To"}),c.jsx(pn,{children:"Status"}),c.jsx(pn,{children:"Message"}),c.jsx(pn,{children:"Sent"}),c.jsx(pn,{className:"w-[50px]"})]})}),c.jsx(mO,{children:h?c.jsx(la,{children:c.jsx(It,{className:"h-24 text-center text-muted-foreground",colSpan:5,children:"Loading SMS logs..."})}):b.length===0?c.jsx(la,{children:c.jsx(It,{className:"h-24 text-center text-muted-foreground",colSpan:5,children:"No SMS messages found"})}):b.map(x=>{var E,A,_;return c.jsxs(la,{className:"cursor-pointer hover:bg-muted/50",onClick:()=>e(`/sms/${x.id}`),children:[c.jsx(It,{className:"font-mono text-sm",children:S(x.to)}),c.jsx(It,{children:c.jsxs(Up,{children:[c.jsx(Hp,{asChild:!0,children:c.jsx(He,{className:(E=w1[x.status])==null?void 0:E.className,variant:((A=w1[x.status])==null?void 0:A.variant)??"default",children:x.status.charAt(0).toUpperCase()+x.status.slice(1).replace("_"," ")})}),c.jsx(Fp,{children:c.jsx("p",{children:((_=w1[x.status])==null?void 0:_.description)??"Unknown status"})})]})}),c.jsx(It,{className:"max-w-[400px] truncate",children:x.body}),c.jsx(It,{className:"text-muted-foreground",children:O(x.timestamp)}),c.jsx(It,{children:c.jsx(Ee,{onClick:T=>{T.stopPropagation()},size:"icon",variant:"ghost",children:c.jsx("span",{className:"sr-only",children:"More options"})})})]},x.id)})})]})}),b.length>0&&!h&&c.jsx("div",{className:"mt-4 flex items-center justify-between text-muted-foreground text-sm",children:c.jsxs("div",{children:["Showing ",b.length," of ",f.length," messages"]})})]})]})}function lpe(){const[e,t]=j.useState("7"),[n,r]=j.useState(null),[i,s]=j.useState(!0),[l,f]=j.useState(null);if(j.useEffect(()=>{async function S(){try{s(!0),f(null);let x=sessionStorage.getItem("wraps-auth-token");if(x||(x=new URLSearchParams(window.location.search).get("token"),x&&sessionStorage.setItem("wraps-auth-token",x)),!x)throw new Error("Authentication token not found. Please use the URL provided by 'wraps console' command.");const E=Number.parseInt(e,10),A=Date.now()-E*24*60*60*1e3,_=Date.now(),T=await fetch(`/api/sms/metrics?startTime=${A}&endTime=${_}&token=${x}`);if(!T.ok){let M="Failed to fetch SMS metrics";try{M=(await T.json()).error||M}catch{M=`${T.status}: ${T.statusText}`}throw new Error(M)}const N=await T.json();r(N)}catch(x){const E=x instanceof Error?x.message:"Unknown error";f(E),console.error("Error fetching SMS metrics:",x)}finally{s(!1)}}S()},[e]),l)return c.jsxs(c.Fragment,{children:[c.jsxs("div",{children:[c.jsx("h1",{className:"font-semibold text-3xl tracking-tight",children:"SMS Metrics"}),c.jsx("p",{className:"mt-2 text-muted-foreground",children:"View detailed metrics and analytics for your SMS messaging"})]}),c.jsx("div",{className:"mt-4 rounded-md border border-destructive bg-destructive/10 p-4 text-destructive text-sm",children:l})]});if(i||!n)return c.jsxs(c.Fragment,{children:[c.jsxs("div",{children:[c.jsx("h1",{className:"font-semibold text-3xl tracking-tight",children:"SMS Metrics"}),c.jsx("p",{className:"mt-2 text-muted-foreground",children:"View detailed metrics and analytics for your SMS messaging"})]}),c.jsx("div",{className:"mt-4 flex h-[400px] items-center justify-center text-muted-foreground",children:"Loading metrics..."})]});const d=n.metrics.sends.reduce((S,x)=>S+x.value,0)||0,h=n.metrics.deliveries.reduce((S,x)=>S+x.value,0)||0,v=n.metrics.failures.reduce((S,x)=>S+x.value,0)||0,p=n.metrics.optOuts.reduce((S,x)=>S+x.value,0)||0,g=d>0?h/d*100:0,b=d>0?v/d*100:0,O=[{title:"Messages Sent",value:d.toLocaleString(),description:`${e==="1"?"Last 24 hours":`Last ${e} days`}`,icon:Yi},{title:"Delivery Rate",value:`${g.toFixed(1)}%`,description:`${h.toLocaleString()} delivered`,icon:Nj},{title:"Failure Rate",value:`${b.toFixed(1)}%`,description:`${v.toLocaleString()} failed`,icon:jp},{title:"Opt Outs",value:p.toLocaleString(),description:"Recipients unsubscribed",icon:Wh}];return c.jsxs(c.Fragment,{children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{children:[c.jsx("h1",{className:"font-semibold text-3xl tracking-tight",children:"SMS Metrics"}),c.jsx("p",{className:"mt-2 text-muted-foreground",children:"View detailed metrics and analytics for your SMS messaging"})]}),c.jsxs(fa,{onValueChange:t,value:e,children:[c.jsx(ha,{className:"w-[180px]",children:c.jsx(da,{})}),c.jsxs(ma,{children:[c.jsx(Ue,{value:"1",children:"Last 24 hours"}),c.jsx(Ue,{value:"7",children:"Last 7 days"}),c.jsx(Ue,{value:"15",children:"Last 15 days"}),c.jsx(Ue,{value:"30",children:"Last 30 days"}),c.jsx(Ue,{value:"90",children:"Last 90 days"})]})]})]}),c.jsx("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-4",children:O.map(S=>c.jsxs(Ne,{children:[c.jsxs(De,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[c.jsx(Fe,{className:"font-medium text-sm",children:S.title}),c.jsx(S.icon,{className:"h-4 w-4 text-muted-foreground"})]}),c.jsxs(Le,{children:[c.jsx("div",{className:"font-bold text-2xl",children:S.value}),c.jsx("p",{className:"text-muted-foreground text-xs",children:S.description})]})]},S.title))}),n.phoneNumber&&c.jsxs(Ne,{children:[c.jsxs(De,{children:[c.jsx(Fe,{children:"Phone Number"}),c.jsx(Ye,{children:"Your SMS sending number"})]}),c.jsxs(Le,{className:"space-y-4",children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx("span",{className:"text-sm",children:"Number"}),c.jsx("span",{className:"font-mono text-sm",children:n.phoneNumber.number})]}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx("span",{className:"text-sm",children:"Type"}),c.jsx(He,{variant:"outline",children:n.phoneNumber.type})]}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx("span",{className:"text-sm",children:"Status"}),c.jsx(He,{variant:n.phoneNumber.status==="ACTIVE"?"default":"secondary",children:n.phoneNumber.status})]}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx("span",{className:"text-sm",children:"Throughput"}),c.jsx("span",{className:"text-muted-foreground text-sm",children:n.phoneNumber.throughput})]})]})]}),n.quota&&c.jsxs(Ne,{children:[c.jsxs(De,{children:[c.jsx(Fe,{children:"Spend Limits"}),c.jsx(Ye,{children:"Your AWS SMS spending limits"})]}),c.jsxs(Le,{className:"space-y-4",children:[c.jsxs("div",{className:"space-y-2",children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx("span",{className:"text-sm",children:"Monthly Spend"}),c.jsxs("span",{className:"font-medium",children:["$",n.quota.spentThisMonth.toFixed(2)," / $",n.quota.spendLimitMonthly.toFixed(2)]})]}),c.jsx("div",{className:"h-2 w-full overflow-hidden rounded-full bg-secondary",children:c.jsx("div",{className:"h-full bg-primary transition-all",style:{width:`${Math.min(n.quota.spentThisMonth/n.quota.spendLimitMonthly*100,100)}%`}})})]}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx("span",{className:"text-sm",children:"Daily Limit"}),c.jsxs("span",{className:"text-muted-foreground text-sm",children:["$",n.quota.spendLimitDaily.toFixed(2)]})]})]})]}),c.jsxs(Ne,{children:[c.jsxs(De,{children:[c.jsx(Fe,{children:"Metrics Summary"}),c.jsx(Ye,{children:"Detailed breakdown of your SMS performance"})]}),c.jsxs(Le,{className:"space-y-4",children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx("span",{className:"text-sm",children:"Total Messages Sent"}),c.jsx(He,{variant:"outline",children:d.toLocaleString()})]}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx("span",{className:"text-sm",children:"Successfully Delivered"}),c.jsx(He,{variant:"default",children:h.toLocaleString()})]}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx("span",{className:"text-sm",children:"Failed"}),c.jsx(He,{variant:"destructive",children:v.toLocaleString()})]}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx("span",{className:"text-sm",children:"Opt Outs"}),c.jsx(He,{variant:"secondary",children:p.toLocaleString()})]})]})]})]})}function x4({status:e}){const t=e==="ACTIVE"||e==="SUCCESS";return c.jsxs(He,{className:t?"border-green-500/20 bg-green-500/10 text-green-700 dark:text-green-400":"border-yellow-500/20 bg-yellow-500/10 text-yellow-700 dark:text-yellow-400",variant:"outline",children:[t?c.jsx(Zi,{className:"mr-1 h-3 w-3"}):c.jsx(ir,{className:"mr-1 h-3 w-3"}),e]})}function cpe({phoneNumber:e}){if(!e)return c.jsx(Ne,{children:c.jsxs(De,{children:[c.jsxs(Fe,{className:"flex items-center gap-2",children:[c.jsx(Wh,{className:"h-5 w-5"}),"Phone Number"]}),c.jsx(Ye,{children:"No phone number configured"})]})});const t=r=>r.startsWith("+1")&&r.length===12?`(${r.slice(2,5)}) ${r.slice(5,8)}-${r.slice(8)}`:r,n=r=>{switch(r){case"simulator":return"Simulator";case"toll-free":return"Toll-Free";case"10dlc":return"10DLC";case"short-code":return"Short Code";default:return r}};return c.jsxs(Ne,{children:[c.jsxs(De,{children:[c.jsxs(Fe,{className:"flex items-center gap-2",children:[c.jsx(Wh,{className:"h-5 w-5"}),"Phone Number"]}),c.jsx(Ye,{children:"Your SMS sending number"})]}),c.jsxs(Le,{className:"space-y-4",children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{children:[c.jsx("p",{className:"font-medium font-mono text-lg",children:t(e.number)}),c.jsx("p",{className:"text-muted-foreground text-sm",children:n(e.type)})]}),c.jsx(x4,{status:e.status})]}),e.registrationStatus&&c.jsxs(c.Fragment,{children:[c.jsx(Bt,{}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{children:[c.jsx("p",{className:"font-medium text-sm",children:"Registration Status"}),c.jsx("p",{className:"text-muted-foreground text-sm",children:e.type==="toll-free"?"Toll-free verification":"Campaign registration"})]}),c.jsx(x4,{status:e.registrationStatus})]})]}),e.capabilities.length>0&&c.jsxs(c.Fragment,{children:[c.jsx(Bt,{}),c.jsxs("div",{className:"space-y-2",children:[c.jsx("p",{className:"font-medium text-sm",children:"Capabilities"}),c.jsx("div",{className:"flex flex-wrap gap-2",children:e.capabilities.map(r=>c.jsx(He,{variant:"secondary",children:r},r))})]})]}),e.monthlyLeasingPrice&&c.jsxs(c.Fragment,{children:[c.jsx(Bt,{}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{children:[c.jsx("p",{className:"font-medium text-sm",children:"Monthly Cost"}),c.jsx("p",{className:"text-muted-foreground text-sm",children:"Phone number lease"})]}),c.jsxs("span",{className:"font-mono text-sm",children:["$",e.monthlyLeasingPrice,"/mo"]})]})]}),e.type==="simulator"&&c.jsxs(In,{children:[c.jsx(ir,{className:"h-4 w-4"}),c.jsx(Xi,{children:"Simulator Mode"}),c.jsx(zn,{children:"This number is for testing only. Messages are simulated and not actually sent. Upgrade to a toll-free number for production use."})]}),e.type==="toll-free"&&e.registrationStatus!=="VERIFIED"&&c.jsxs(In,{children:[c.jsx(ir,{className:"h-4 w-4"}),c.jsx(Xi,{children:"Registration Required"}),c.jsxs(zn,{children:["Toll-free numbers require registration before they can send messages. Run ",c.jsx("code",{children:"wraps sms register"})," to complete registration."]})]})]})]})}function upe({protectConfig:e}){return e!=null&&e.enabled?c.jsxs(Ne,{children:[c.jsxs(De,{children:[c.jsxs(Fe,{className:"flex items-center gap-2",children:[c.jsx(Kh,{className:"h-5 w-5"}),"Fraud Protection"]}),c.jsx(Ye,{children:"Country restrictions and AIT filtering"})]}),c.jsxs(Le,{className:"space-y-4",children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{children:[c.jsx("p",{className:"font-medium text-sm",children:"Status"}),c.jsx("p",{className:"text-muted-foreground text-sm",children:"Protect configuration active"})]}),c.jsxs(He,{className:"border-green-500/20 bg-green-500/10 text-green-700 dark:text-green-400",variant:"outline",children:[c.jsx(Zi,{className:"mr-1 h-3 w-3"}),"Enabled"]})]}),c.jsx(Bt,{}),c.jsxs("div",{className:"space-y-2",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(ku,{className:"h-4 w-4 text-muted-foreground"}),c.jsx("p",{className:"font-medium text-sm",children:"Allowed Countries"})]}),c.jsx("div",{className:"flex flex-wrap gap-2",children:e.allowedCountries.map(t=>c.jsx(He,{variant:"secondary",children:t},t))}),c.jsx("p",{className:"text-muted-foreground text-xs",children:"Messages can only be sent to these countries. All others are blocked."})]}),c.jsx(Bt,{}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{children:[c.jsx("p",{className:"font-medium text-sm",children:"AIT Filtering"}),c.jsx("p",{className:"text-muted-foreground text-sm",children:e.aitFiltering?"Enabled - adds per-message cost":"Disabled - no extra cost"})]}),c.jsx(He,{variant:e.aitFiltering?"default":"secondary",children:e.aitFiltering?"Enabled":"Disabled"})]})]})]}):c.jsx(Ne,{children:c.jsxs(De,{children:[c.jsxs(Fe,{className:"flex items-center gap-2",children:[c.jsx(Kh,{className:"h-5 w-5"}),"Fraud Protection"]}),c.jsx(Ye,{children:"Not configured"})]})})}function fpe({configSet:e,onRefresh:t}){const[n,r]=j.useState(!1),[i,s]=j.useState(!1);if(!e)return c.jsx(Ne,{children:c.jsxs(De,{children:[c.jsxs(Fe,{className:"flex items-center gap-2",children:[c.jsx(Yi,{className:"h-5 w-5"}),"Configuration Set"]}),c.jsx(Ye,{children:"No configuration set found"})]})});const l=async()=>{s(!0);try{const f=sessionStorage.getItem("wraps-auth-token"),d=!e.sendingEnabled,h=await fetch(`/api/sms/settings/sending?token=${f}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({enabled:d})});if(!h.ok)throw new Error(`Failed to update: ${h.statusText}`);r(!1),wt.success(d?"SMS sending enabled":"SMS sending disabled"),t&&await t()}catch(f){console.error("Failed to toggle sending:",f),wt.error("Failed to update setting",{description:f instanceof Error?f.message:"Unknown error"})}finally{s(!1)}};return c.jsxs(Ne,{children:[c.jsxs(De,{children:[c.jsxs(Fe,{className:"flex items-center gap-2",children:[c.jsx(Yi,{className:"h-5 w-5"}),"Configuration Set"]}),c.jsx(Ye,{children:"SMS sending configuration"})]}),c.jsxs(Le,{className:"space-y-4",children:[c.jsxs("div",{children:[c.jsx("p",{className:"font-medium",children:e.name}),c.jsx("p",{className:"text-muted-foreground text-sm",children:"Configuration Set Name"})]}),c.jsx(Bt,{}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{className:"flex-1 space-y-0.5",children:[c.jsx("p",{className:"font-medium text-sm",children:"SMS Sending"}),c.jsx("p",{className:"text-muted-foreground text-sm",children:e.sendingEnabled?"Messages can be sent":"Message sending is disabled"})]}),c.jsx(Ee,{onClick:()=>r(!0),size:"sm",variant:e.sendingEnabled?"destructive":"default",children:e.sendingEnabled?"Disable":"Enable"})]}),c.jsx(up,{onOpenChange:r,open:n,children:c.jsxs(fp,{children:[c.jsxs(dp,{children:[c.jsx(mp,{children:e.sendingEnabled?"Disable SMS sending?":"Enable SMS sending?"}),c.jsx(pp,{children:e.sendingEnabled?"All outgoing SMS messages will be blocked until you re-enable sending.":"This will allow SMS messages to be sent through this configuration set."})]}),c.jsxs(hp,{children:[c.jsx(gp,{disabled:i,children:"Cancel"}),c.jsx(vp,{disabled:i,onClick:l,children:i?"Updating...":e.sendingEnabled?"Disable sending":"Enable sending"})]})]})})]})]})}function dpe({eventTracking:e}){return c.jsxs(Ne,{children:[c.jsxs(De,{children:[c.jsx(Fe,{children:"Event Tracking"}),c.jsx(Ye,{children:"Message history and event storage"})]}),c.jsxs(Le,{className:"space-y-4",children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{children:[c.jsx("p",{className:"font-medium text-sm",children:"Event Tracking"}),c.jsx("p",{className:"text-muted-foreground text-sm",children:e!=null&&e.enabled?"Tracking delivery events":"Event tracking disabled"})]}),c.jsx(He,{variant:e!=null&&e.enabled?"default":"secondary",children:e!=null&&e.enabled?"Enabled":"Disabled"})]}),(e==null?void 0:e.enabled)&&c.jsxs(c.Fragment,{children:[c.jsx(Bt,{}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{children:[c.jsx("p",{className:"font-medium text-sm",children:"Message History"}),c.jsx("p",{className:"text-muted-foreground text-sm",children:e.dynamoDBHistory?"Stored in DynamoDB":"Not stored"})]}),c.jsx(He,{variant:e.dynamoDBHistory?"default":"secondary",children:e.dynamoDBHistory?"Enabled":"Disabled"})]}),e.archiveRetention&&c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{children:[c.jsx("p",{className:"font-medium text-sm",children:"Retention Period"}),c.jsx("p",{className:"text-muted-foreground text-sm",children:"How long message history is kept"})]}),c.jsx(He,{variant:"outline",children:e.archiveRetention})]})]})]})]})}function hpe(){const[e,t]=j.useState(null),[n,r]=j.useState(!0),[i,s]=j.useState(null),l=j.useCallback(async()=>{try{r(!0);const f=sessionStorage.getItem("wraps-auth-token");if(!f)throw new Error("Authentication token not found");const d=await fetch(`/api/sms/settings?token=${f}`);if(!d.ok)throw new Error(`Failed to fetch settings: ${d.statusText}`);const h=await d.json();t(h),s(null)}catch(f){console.error("Failed to fetch SMS settings:",f),s(f instanceof Error?f.message:"Failed to load settings")}finally{r(!1)}},[]);return j.useEffect(()=>{l()},[l]),n?c.jsxs(c.Fragment,{children:[c.jsxs("div",{children:[c.jsx("h1",{className:"font-semibold text-3xl tracking-tight",children:"SMS Settings"}),c.jsx("p",{className:"mt-2 text-muted-foreground",children:"Configure your SMS settings and preferences"})]}),c.jsxs("div",{className:"mt-6 grid gap-6 md:grid-cols-2",children:[c.jsxs(Ne,{children:[c.jsxs(De,{children:[c.jsx(Re,{className:"h-6 w-48"}),c.jsx(Re,{className:"mt-2 h-4 w-64"})]}),c.jsx(Le,{children:c.jsx(Re,{className:"h-20 w-full"})})]}),c.jsxs(Ne,{children:[c.jsxs(De,{children:[c.jsx(Re,{className:"h-6 w-48"}),c.jsx(Re,{className:"mt-2 h-4 w-64"})]}),c.jsx(Le,{children:c.jsx(Re,{className:"h-20 w-full"})})]})]})]}):i?c.jsxs(c.Fragment,{children:[c.jsxs("div",{children:[c.jsx("h1",{className:"font-semibold text-3xl tracking-tight",children:"SMS Settings"}),c.jsx("p",{className:"mt-2 text-muted-foreground",children:"Configure your SMS settings and preferences"})]}),c.jsxs(In,{className:"mt-6",variant:"destructive",children:[c.jsx(ir,{className:"h-4 w-4"}),c.jsx(Xi,{children:"Error Loading Settings"}),c.jsx(zn,{children:i})]})]}):c.jsxs(c.Fragment,{children:[c.jsxs("div",{children:[c.jsx("h1",{className:"font-semibold text-3xl tracking-tight",children:"SMS Settings"}),c.jsx("p",{className:"mt-2 text-muted-foreground",children:"Configure your SMS settings and preferences"})]}),c.jsxs("div",{className:"mt-6 grid gap-6 md:grid-cols-2",children:[c.jsx(cpe,{phoneNumber:e==null?void 0:e.phoneNumber}),c.jsx(fpe,{configSet:e==null?void 0:e.configurationSet,onRefresh:l}),c.jsx(upe,{protectConfig:e==null?void 0:e.protectConfiguration}),c.jsx(dpe,{eventTracking:e==null?void 0:e.eventTracking})]})]})}var QB=["PageUp","PageDown"],ZB=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],JB={"from-left":["Home","PageDown","ArrowDown","ArrowLeft"],"from-right":["Home","PageDown","ArrowDown","ArrowRight"],"from-bottom":["Home","PageDown","ArrowDown","ArrowLeft"],"from-top":["Home","PageDown","ArrowUp","ArrowLeft"]},mc="Slider",[dj,mpe,ppe]=Op(mc),[e6]=qn(mc,[ppe]),[vpe,Mv]=e6(mc),t6=j.forwardRef((e,t)=>{const{name:n,min:r=0,max:i=100,step:s=1,orientation:l="horizontal",disabled:f=!1,minStepsBetweenThumbs:d=0,defaultValue:h=[r],value:v,onValueChange:p=()=>{},onValueCommit:g=()=>{},inverted:b=!1,form:O,...S}=e,x=j.useRef(new Set),E=j.useRef(0),_=l==="horizontal"?gpe:ype,[T=[],N]=Vr({prop:v,defaultProp:h,onChange:I=>{var W;(W=[...x.current][E.current])==null||W.focus(),p(I)}}),M=j.useRef(T);function R(I){const H=jpe(T,I);Y(I,H)}function D(I){Y(I,E.current)}function L(){const I=M.current[E.current];T[E.current]!==I&&g(T)}function Y(I,H,{commit:W}={commit:!1}){const Z=Ape(s),X=Npe(Math.round((I-r)/s)*s+r,Z),k=lm(X,[r,i]);N((U=[])=>{const q=wpe(U,k,H);if(_pe(q,d*s)){E.current=q.indexOf(k);const Q=String(q)!==String(U);return Q&&W&&g(q),Q?q:U}else return U})}return c.jsx(vpe,{scope:e.__scopeSlider,name:n,disabled:f,min:r,max:i,valueIndexToChangeRef:E,thumbs:x.current,values:T,orientation:l,form:O,children:c.jsx(dj.Provider,{scope:e.__scopeSlider,children:c.jsx(dj.Slot,{scope:e.__scopeSlider,children:c.jsx(_,{"aria-disabled":f,"data-disabled":f?"":void 0,...S,ref:t,onPointerDown:be(S.onPointerDown,()=>{f||(M.current=T)}),min:r,max:i,inverted:b,onSlideStart:f?void 0:R,onSlideMove:f?void 0:D,onSlideEnd:f?void 0:L,onHomeKeyDown:()=>!f&&Y(r,0,{commit:!0}),onEndKeyDown:()=>!f&&Y(i,T.length-1,{commit:!0}),onStepKeyDown:({event:I,direction:H})=>{if(!f){const X=QB.includes(I.key)||I.shiftKey&&ZB.includes(I.key)?10:1,k=E.current,U=T[k],q=s*X*H;Y(U+q,k,{commit:!0})}}})})})})});t6.displayName=mc;var[n6,r6]=e6(mc,{startEdge:"left",endEdge:"right",size:"width",direction:1}),gpe=j.forwardRef((e,t)=>{const{min:n,max:r,dir:i,inverted:s,onSlideStart:l,onSlideMove:f,onSlideEnd:d,onStepKeyDown:h,...v}=e,[p,g]=j.useState(null),b=Be(t,_=>g(_)),O=j.useRef(void 0),S=Df(i),x=S==="ltr",E=x&&!s||!x&&s;function A(_){const T=O.current||p.getBoundingClientRect(),N=[0,T.width],R=NE(N,E?[n,r]:[r,n]);return O.current=T,R(_-T.left)}return c.jsx(n6,{scope:e.__scopeSlider,startEdge:E?"left":"right",endEdge:E?"right":"left",direction:E?1:-1,size:"width",children:c.jsx(a6,{dir:S,"data-orientation":"horizontal",...v,ref:b,style:{...v.style,"--radix-slider-thumb-transform":"translateX(-50%)"},onSlideStart:_=>{const T=A(_.clientX);l==null||l(T)},onSlideMove:_=>{const T=A(_.clientX);f==null||f(T)},onSlideEnd:()=>{O.current=void 0,d==null||d()},onStepKeyDown:_=>{const N=JB[E?"from-left":"from-right"].includes(_.key);h==null||h({event:_,direction:N?-1:1})}})})}),ype=j.forwardRef((e,t)=>{const{min:n,max:r,inverted:i,onSlideStart:s,onSlideMove:l,onSlideEnd:f,onStepKeyDown:d,...h}=e,v=j.useRef(null),p=Be(t,v),g=j.useRef(void 0),b=!i;function O(S){const x=g.current||v.current.getBoundingClientRect(),E=[0,x.height],_=NE(E,b?[r,n]:[n,r]);return g.current=x,_(S-x.top)}return c.jsx(n6,{scope:e.__scopeSlider,startEdge:b?"bottom":"top",endEdge:b?"top":"bottom",size:"height",direction:b?1:-1,children:c.jsx(a6,{"data-orientation":"vertical",...h,ref:p,style:{...h.style,"--radix-slider-thumb-transform":"translateY(50%)"},onSlideStart:S=>{const x=O(S.clientY);s==null||s(x)},onSlideMove:S=>{const x=O(S.clientY);l==null||l(x)},onSlideEnd:()=>{g.current=void 0,f==null||f()},onStepKeyDown:S=>{const E=JB[b?"from-bottom":"from-top"].includes(S.key);d==null||d({event:S,direction:E?-1:1})}})})}),a6=j.forwardRef((e,t)=>{const{__scopeSlider:n,onSlideStart:r,onSlideMove:i,onSlideEnd:s,onHomeKeyDown:l,onEndKeyDown:f,onStepKeyDown:d,...h}=e,v=Mv(mc,n);return c.jsx(Ce.span,{...h,ref:t,onKeyDown:be(e.onKeyDown,p=>{p.key==="Home"?(l(p),p.preventDefault()):p.key==="End"?(f(p),p.preventDefault()):QB.concat(ZB).includes(p.key)&&(d(p),p.preventDefault())}),onPointerDown:be(e.onPointerDown,p=>{const g=p.target;g.setPointerCapture(p.pointerId),p.preventDefault(),v.thumbs.has(g)?g.focus():r(p)}),onPointerMove:be(e.onPointerMove,p=>{p.target.hasPointerCapture(p.pointerId)&&i(p)}),onPointerUp:be(e.onPointerUp,p=>{const g=p.target;g.hasPointerCapture(p.pointerId)&&(g.releasePointerCapture(p.pointerId),s(p))})})}),i6="SliderTrack",o6=j.forwardRef((e,t)=>{const{__scopeSlider:n,...r}=e,i=Mv(i6,n);return c.jsx(Ce.span,{"data-disabled":i.disabled?"":void 0,"data-orientation":i.orientation,...r,ref:t})});o6.displayName=i6;var hj="SliderRange",s6=j.forwardRef((e,t)=>{const{__scopeSlider:n,...r}=e,i=Mv(hj,n),s=r6(hj,n),l=j.useRef(null),f=Be(t,l),d=i.values.length,h=i.values.map(g=>u6(g,i.min,i.max)),v=d>1?Math.min(...h):0,p=100-Math.max(...h);return c.jsx(Ce.span,{"data-orientation":i.orientation,"data-disabled":i.disabled?"":void 0,...r,ref:f,style:{...e.style,[s.startEdge]:v+"%",[s.endEdge]:p+"%"}})});s6.displayName=hj;var mj="SliderThumb",l6=j.forwardRef((e,t)=>{const n=mpe(e.__scopeSlider),[r,i]=j.useState(null),s=Be(t,f=>i(f)),l=j.useMemo(()=>r?n().findIndex(f=>f.ref.current===r):-1,[n,r]);return c.jsx(bpe,{...e,ref:s,index:l})}),bpe=j.forwardRef((e,t)=>{const{__scopeSlider:n,index:r,name:i,...s}=e,l=Mv(mj,n),f=r6(mj,n),[d,h]=j.useState(null),v=Be(t,A=>h(A)),p=d?l.form||!!d.closest("form"):!0,g=Cp(d),b=l.values[r],O=b===void 0?0:u6(b,l.min,l.max),S=Spe(r,l.values.length),x=g==null?void 0:g[f.size],E=x?Ope(x,O,f.direction):0;return j.useEffect(()=>{if(d)return l.thumbs.add(d),()=>{l.thumbs.delete(d)}},[d,l.thumbs]),c.jsxs("span",{style:{transform:"var(--radix-slider-thumb-transform)",position:"absolute",[f.startEdge]:`calc(${O}% + ${E}px)`},children:[c.jsx(dj.ItemSlot,{scope:e.__scopeSlider,children:c.jsx(Ce.span,{role:"slider","aria-label":e["aria-label"]||S,"aria-valuemin":l.min,"aria-valuenow":b,"aria-valuemax":l.max,"aria-orientation":l.orientation,"data-orientation":l.orientation,"data-disabled":l.disabled?"":void 0,tabIndex:l.disabled?void 0:0,...s,ref:v,style:b===void 0?{display:"none"}:e.style,onFocus:be(e.onFocus,()=>{l.valueIndexToChangeRef.current=r})})}),p&&c.jsx(c6,{name:i??(l.name?l.name+(l.values.length>1?"[]":""):void 0),form:l.form,value:b},r)]})});l6.displayName=mj;var xpe="RadioBubbleInput",c6=j.forwardRef(({__scopeSlider:e,value:t,...n},r)=>{const i=j.useRef(null),s=Be(i,r),l=Vp(t);return j.useEffect(()=>{const f=i.current;if(!f)return;const d=window.HTMLInputElement.prototype,v=Object.getOwnPropertyDescriptor(d,"value").set;if(l!==t&&v){const p=new Event("input",{bubbles:!0});v.call(f,t),f.dispatchEvent(p)}},[l,t]),c.jsx(Ce.input,{style:{display:"none"},...n,ref:s,defaultValue:t})});c6.displayName=xpe;function wpe(e=[],t,n){const r=[...e];return r[n]=t,r.sort((i,s)=>i-s)}function u6(e,t,n){const s=100/(n-t)*(e-t);return lm(s,[0,100])}function Spe(e,t){return t>2?`Value ${e+1} of ${t}`:t===2?["Minimum","Maximum"][e]:void 0}function jpe(e,t){if(e.length===1)return 0;const n=e.map(i=>Math.abs(i-t)),r=Math.min(...n);return n.indexOf(r)}function Ope(e,t,n){const r=e/2,s=NE([0,50],[0,r]);return(r-s(t)*n)*n}function Epe(e){return e.slice(0,-1).map((t,n)=>e[n+1]-t)}function _pe(e,t){if(t>0){const n=Epe(e);return Math.min(...n)>=t}return!0}function NE(e,t){return n=>{if(e[0]===e[1]||t[0]===t[1])return t[0];const r=(t[1]-t[0])/(e[1]-e[0]);return t[0]+r*(n-e[0])}}function Ape(e){return(String(e).split(".")[1]||"").length}function Npe(e,t){const n=Math.pow(10,t);return Math.round(e*n)/n}var Tpe=t6,Cpe=o6,Mpe=s6,Rpe=l6;function Dpe({className:e,defaultValue:t,value:n,min:r=0,max:i=100,...s}){const l=j.useMemo(()=>Array.isArray(n)?n:Array.isArray(t)?t:[r,i],[n,t,r,i]);return c.jsxs(Tpe,{className:ve("relative flex w-full touch-none select-none items-center data-[orientation=vertical]:h-full data-[orientation=vertical]:min-h-44 data-[orientation=vertical]:w-auto data-[orientation=vertical]:flex-col data-[disabled]:opacity-50",e),"data-slot":"slider",defaultValue:t,max:i,min:r,value:n,...s,children:[c.jsx(Cpe,{className:ve("relative grow overflow-hidden rounded-full bg-muted data-[orientation=horizontal]:h-1.5 data-[orientation=vertical]:h-full data-[orientation=horizontal]:w-full data-[orientation=vertical]:w-1.5"),"data-slot":"slider-track",children:c.jsx(Mpe,{className:ve("absolute bg-primary data-[orientation=horizontal]:h-full data-[orientation=vertical]:w-full"),"data-slot":"slider-range"})}),Array.from({length:l.length},(f,d)=>c.jsx(Rpe,{className:"block size-4 shrink-0 rounded-full border border-primary bg-white shadow-sm ring-ring/50 transition-[color,box-shadow] hover:ring-4 focus-visible:outline-hidden focus-visible:ring-4 disabled:pointer-events-none disabled:opacity-50","data-slot":"slider-thumb"},`thumb-${l[d]}-${d}`))]})}var Rv="Switch",[Ppe]=qn(Rv),[kpe,$pe]=Ppe(Rv),f6=j.forwardRef((e,t)=>{const{__scopeSwitch:n,name:r,checked:i,defaultChecked:s,required:l,disabled:f,value:d="on",onCheckedChange:h,form:v,...p}=e,[g,b]=j.useState(null),O=Be(t,_=>b(_)),S=j.useRef(!1),x=g?v||!!g.closest("form"):!0,[E,A]=Vr({prop:i,defaultProp:s??!1,onChange:h,caller:Rv});return c.jsxs(kpe,{scope:n,checked:E,disabled:f,children:[c.jsx(Ce.button,{type:"button",role:"switch","aria-checked":E,"aria-required":l,"data-state":p6(E),"data-disabled":f?"":void 0,disabled:f,value:d,...p,ref:O,onClick:be(e.onClick,_=>{A(T=>!T),x&&(S.current=_.isPropagationStopped(),S.current||_.stopPropagation())})}),x&&c.jsx(m6,{control:g,bubbles:!S.current,name:r,value:d,checked:E,required:l,disabled:f,form:v,style:{transform:"translateX(-100%)"}})]})});f6.displayName=Rv;var d6="SwitchThumb",h6=j.forwardRef((e,t)=>{const{__scopeSwitch:n,...r}=e,i=$pe(d6,n);return c.jsx(Ce.span,{"data-state":p6(i.checked),"data-disabled":i.disabled?"":void 0,...r,ref:t})});h6.displayName=d6;var Lpe="SwitchBubbleInput",m6=j.forwardRef(({__scopeSwitch:e,control:t,checked:n,bubbles:r=!0,...i},s)=>{const l=j.useRef(null),f=Be(l,s),d=Vp(n),h=Cp(t);return j.useEffect(()=>{const v=l.current;if(!v)return;const p=window.HTMLInputElement.prototype,b=Object.getOwnPropertyDescriptor(p,"checked").set;if(d!==n&&b){const O=new Event("click",{bubbles:r});b.call(v,n),v.dispatchEvent(O)}},[d,n,r]),c.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:n,...i,tabIndex:-1,ref:f,style:{...i.style,...h,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});m6.displayName=Lpe;function p6(e){return e?"checked":"unchecked"}var Ipe=f6,zpe=h6;function Bpe({className:e,...t}){return c.jsx(Ipe,{className:ve("peer inline-flex h-[1.15rem] w-8 shrink-0 items-center rounded-full border border-transparent shadow-xs outline-none transition-all focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input dark:data-[state=unchecked]:bg-input/80",e),"data-slot":"switch",...t,children:c.jsx(zpe,{className:ve("pointer-events-none block size-4 rounded-full bg-background ring-0 transition-transform data-[state=checked]:translate-x-[calc(100%-2px)] data-[state=unchecked]:translate-x-0 dark:data-[state=checked]:bg-primary-foreground dark:data-[state=unchecked]:bg-foreground"),"data-slot":"switch-thumb"})})}async function w4(e){try{const t=document.createElement("canvas");return t.width=1,t.height=1,t.toDataURL(e).startsWith(`data:${e}`)}catch{return!1}}async function qpe(){const[e,t]=await Promise.all([w4("image/webp"),w4("image/avif")]);return{webp:e,avif:t,offscreenCanvas:typeof OffscreenCanvas<"u",webWorker:typeof Worker<"u",wasm:typeof WebAssembly<"u"}}let $h=null;async function Upe(){return $h||($h=await qpe(),$h)}async function Hpe(e){if(e.type!=="image/gif")return{isAnimated:!1,frameCount:1,size:e.size};try{const t=await e.arrayBuffer(),n=new Uint8Array(t);let r=0;for(let i=0;i<n.length-2;i++)n[i]===33&&n[i+1]===249&&r++;return{isAnimated:r>1,frameCount:Math.max(1,r),size:e.size}}catch{return{isAnimated:!1,frameCount:1,size:e.size}}}function Fpe(e){return e.type==="image/gif"}function Gpe(e){return new Promise((t,n)=>{const r=new FileReader;r.onload=()=>t(r.result),r.onerror=()=>n(new Error("Failed to read blob")),r.readAsDataURL(e)})}function v6(e){return Gpe(e)}function Lh(e){if(e===0)return"0 B";const t=1024,n=["B","KB","MB","GB"],r=Math.floor(Math.log(e)/Math.log(t));return`${Number.parseFloat((e/t**r).toFixed(1))} ${n[r]}`}function Vpe(e){return new Promise((t,n)=>{const r=new Image,i=URL.createObjectURL(e);r.onload=()=>{URL.revokeObjectURL(i),t({width:r.naturalWidth,height:r.naturalHeight})},r.onerror=()=>{URL.revokeObjectURL(i),n(new Error("Failed to load image"))},r.src=i})}class Ype{constructor(){Gy(this,"worker",null);Gy(this,"pending",new Map)}getWorker(){return this.worker||(this.worker=new Worker(new URL("/assets/optimizer.worker-CeufIUo5.js",import.meta.url),{type:"module"}),this.worker.onmessage=this.handleMessage.bind(this),this.worker.onerror=this.handleError.bind(this)),this.worker}handleMessage(t){const{id:n,result:r,error:i,progress:s}=t.data,l=this.pending.get(n);if(l){if(s!==void 0&&s<100&&l.onProgress){l.onProgress(s);return}if(i){l.reject(new Error(i)),this.pending.delete(n);return}r&&(l.resolve(r),this.pending.delete(n))}}handleError(t){console.error("Image optimizer worker error:",t);for(const[n,r]of this.pending)r.reject(new Error(`Worker error: ${t.message}`)),this.pending.delete(n);this.terminate()}generateId(){return crypto.randomUUID()}async optimize(t,n,r){const i=this.generateId();return new Promise((s,l)=>{this.pending.set(i,{resolve:s,reject:l,onProgress:r}),this.getWorker().postMessage({id:i,type:"optimize",file:t,options:n})})}async preview(t,n,r){const i=await v6(t);return{...await this.optimize(t,n,r),originalDataUrl:i}}cancelAll(){for(const[t,n]of this.pending)n.reject(new Error("Operation cancelled")),this.pending.delete(t)}terminate(){this.cancelAll(),this.worker&&(this.worker.terminate(),this.worker=null)}get isActive(){return this.worker!==null}get pendingCount(){return this.pending.size}}const Wpe=new Ype;async function Kpe(e,t,n){return Wpe.preview(e,t,n)}const Xpe=[{value:"webp",label:"WebP",description:"Best balance of size and quality"},{value:"avif",label:"AVIF",description:"Best compression"},{value:"jpeg",label:"JPEG",description:"Universal compatibility"},{value:"png",label:"PNG",description:"Lossless, supports transparency"},{value:"original",label:"Original",description:"Keep original format"}],Qpe=[{value:1,label:"1x",description:"Standard displays"},{value:2,label:"2x",description:"Retina / HiDPI (recommended)"},{value:3,label:"3x",description:"iPhone Pro / flagship phones"}];function pj(e){const t=e/1024,n=t/1024;return n>2?{level:"error",message:"This image will cause delivery issues (>2MB)",suggestion:"Reduce dimensions or increase compression to under 1MB"}:n>1?{level:"warning",message:"Most email clients struggle with images >1MB",suggestion:"Consider reducing to under 500KB for best deliverability"}:t>500?{level:"info",message:"Larger than recommended for email (>500KB)",suggestion:"This may slow load times on mobile devices"}:null}function S1(e){const t=pj(e);if(!t)return{label:"Good",color:"text-green-600"};switch(t.level){case"info":return{label:"OK",color:"text-yellow-600"};case"warning":return{label:"Large",color:"text-orange-600"};case"error":return{label:"Too Large",color:"text-red-600"};default:return{label:"Unknown",color:"text-muted-foreground"}}}const Zpe=[{value:"none",label:"Original size",description:"Keep original dimensions"},{value:"600",label:"Email (600px)",description:"Standard email width"},{value:"800",label:"Medium (800px)",description:"Blog posts, cards"},{value:"1200",label:"Large (1200px)",description:"Full-width content"},{value:"1440",label:"Hero (1440px)",description:"Banner images"},{value:"1920",label:"Full HD (1920px)",description:"Desktop screens"}];function Jpe({files:e,onComplete:t,onClose:n,open:r}){var V;const[i,s]=j.useState([]),[l,f]=j.useState(null),[d,h]=j.useState(!1),v=i.reduce((F,ne)=>F+ne.file.size,0),p=i.reduce((F,ne)=>{var fe;return F+(((fe=ne.preview)==null?void 0:fe.optimizedSize)??ne.file.size)},0),g=v>0?Math.round((1-p/v)*100):0,b=i.length>0&&i.every(F=>F.status==="ready"||F.status==="done"||F.isAnimatedGif),O=i.some(F=>F.status==="pending"&&!F.isAnimatedGif),S=i.some(F=>F.status==="processing"),[x,E]=j.useState(!0),[A,_]=j.useState(!1),[T,N]=j.useState({format:"webp",quality:85}),[M,R]=j.useState(85),[D,L]=j.useState("none"),[Y,I]=j.useState(2),[H,W]=j.useState(!0);j.useEffect(()=>{Upe().then(F=>{W(F.wasm&&F.webWorker&&F.offscreenCanvas)})},[]),j.useEffect(()=>{var ne;if(!r||e.length===0)return;const F=e.map((fe,oe)=>({id:`${fe.name}-${oe}-${Date.now()}`,file:fe,status:"pending"}));s(F),f(((ne=F[0])==null?void 0:ne.id)??null),_(!1),h(!1);for(const fe of F)v6(fe.file).then(oe=>{s(me=>me.map(ae=>ae.id===fe.id?{...ae,thumbnailUrl:oe}:ae))}),Fpe(fe.file)&&Hpe(fe.file).then(oe=>{oe.isAnimated&&s(me=>me.map(ae=>ae.id===fe.id?{...ae,isAnimatedGif:!0,status:"ready"}:ae))})},[r,e]);const Z=j.useCallback(async()=>{const F=i.filter(ne=>ne.status==="pending"&&!ne.isAnimatedGif);if(F.length===0){h(!1);return}for(const ne of F){s(fe=>fe.map(oe=>oe.id===ne.id?{...oe,status:"processing"}:oe));try{let fe;if(D==="none"){if(Y>1){const ae=await Vpe(ne.file);fe=Math.round(ae.width/Y)}}else fe=Number(D)*Y;const oe={...T,maxWidth:fe},me=await Kpe(ne.file,oe);s(ae=>ae.map(pe=>pe.id===ne.id?{...pe,status:"ready",preview:me}:pe))}catch{s(fe=>fe.map(oe=>oe.id===ne.id?{...oe,status:"ready"}:oe))}}h(!1)},[i,T,D,Y]),X=`${T.format}-${T.quality}-${D}-${Y}`,k=j.useRef(X);j.useEffect(()=>{k.current!==X&&(k.current=X,s(F=>F.map(ne=>ne.isAnimatedGif?ne:{...ne,status:"pending",preview:void 0})),h(!1))},[X]);const U=F=>{const ne=F.name.replace(/\.[^/.]+$/,""),fe=T.format==="original"?F.name.split(".").pop():T.format;return`${ne}.${fe}`},q=()=>{h(!0),Z()},Q=()=>{const F=i.map(ne=>!x||ne.isAnimatedGif||!ne.preview?{file:ne.file,cdnFilename:ne.file.name}:{file:ne.preview.blob,cdnFilename:U(ne.file)});t(F),n()},le=()=>{const F=i.map(ne=>({file:ne.file,cdnFilename:ne.file.name}));t(F),n()};if(!r)return null;const $=i.length===1,B=$?i[0]:null;return c.jsx(EE,{onOpenChange:F=>!F&&n(),open:r,children:c.jsxs(_E,{className:"max-w-lg",children:[c.jsx(FB,{children:c.jsx(VB,{className:"flex items-center gap-2",children:$?c.jsxs(c.Fragment,{children:[c.jsx(nb,{className:"h-5 w-5 text-muted-foreground"}),c.jsx("span",{className:"truncate",children:B==null?void 0:B.file.name})]}):c.jsxs(c.Fragment,{children:[c.jsx(nb,{className:"h-5 w-5 text-muted-foreground"}),i.length," images selected"]})})}),c.jsxs("div",{className:"space-y-4",children:[!$&&c.jsxs("div",{className:"grid grid-cols-6 gap-2",children:[i.slice(0,11).map(F=>c.jsxs(Up,{children:[c.jsx(Hp,{asChild:!0,children:c.jsxs("div",{className:`relative aspect-square overflow-hidden rounded-md border bg-muted ${F.id===l?"ring-2 ring-primary":""}`,children:[F.thumbnailUrl?c.jsx("img",{alt:F.file.name,className:"h-full w-full object-cover",src:F.thumbnailUrl}):c.jsx("div",{className:"flex h-full items-center justify-center",children:c.jsx(nb,{className:"h-4 w-4 text-muted-foreground"})}),F.status==="processing"&&c.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-background/50",children:c.jsx(ol,{className:"h-3 w-3 animate-spin"})}),F.status==="ready"&&F.preview&&c.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-green-500/20",children:c.jsx(Vi,{className:"h-4 w-4 text-green-600"})}),F.isAnimatedGif&&c.jsx(He,{className:"absolute right-0.5 bottom-0.5 h-4 px-1 text-[10px]",children:"GIF"})]})}),c.jsxs(Fp,{side:"bottom",children:[c.jsx("p",{className:"font-medium text-xs",children:F.file.name}),c.jsxs("p",{className:"text-muted-foreground text-xs",children:[Lh(F.file.size),F.preview&&` → ${Lh(F.preview.optimizedSize)}`]})]})]},F.id)),i.length>11&&c.jsxs("div",{className:"flex aspect-square items-center justify-center rounded-md border bg-muted text-muted-foreground text-xs",children:["+",i.length-11]})]}),$&&B&&c.jsxs("div",{className:"relative aspect-video overflow-hidden rounded-lg border bg-muted",children:[B.thumbnailUrl?c.jsx("img",{alt:B.file.name,className:"h-full w-full object-contain",src:B.thumbnailUrl}):c.jsx("div",{className:"flex h-full items-center justify-center",children:c.jsx(ol,{className:"h-6 w-6 animate-spin text-muted-foreground"})}),B.status==="processing"&&c.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-background/50",children:c.jsx(ol,{className:"h-6 w-6 animate-spin"})}),B.status==="ready"&&B.preview&&c.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-green-500/10",children:c.jsx(Vi,{className:"h-8 w-8 text-green-600"})})]}),c.jsxs("div",{className:"rounded-lg border bg-muted/30 p-4",children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{children:[c.jsxs("p",{className:"text-muted-foreground text-sm",children:[c.jsx("span",{className:S1(v).color,children:Lh(v)}),x&&b&&g>0&&c.jsxs(c.Fragment,{children:[c.jsx("span",{className:"mx-2",children:"→"}),c.jsx("span",{className:`font-medium ${S1(p).color}`,children:Lh(p)})]})]}),S&&c.jsx("p",{className:"text-muted-foreground text-xs",children:"Optimizing..."}),!S&&pj(b?p:v)&&c.jsx("p",{className:`text-xs ${S1(b?p:v).color}`,children:(V=pj(b?p:v))==null?void 0:V.suggestion})]}),x&&b&&g>0&&c.jsxs(He,{className:"bg-green-100 text-green-700 dark:bg-green-900 dark:text-green-300",variant:"secondary",children:[c.jsx(GH,{className:"mr-1 h-3 w-3"}),"Save ",g,"%"]})]}),S&&c.jsx(Tv,{className:"mt-3 h-1",value:i.filter(F=>F.status==="ready"||F.isAnimatedGif).length/i.length*100})]}),H&&c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx(Po,{className:"cursor-pointer",htmlFor:"optimize-toggle",children:"Optimize before uploading"}),c.jsx(Bpe,{checked:x,id:"optimize-toggle",onCheckedChange:E})]}),x&&H&&c.jsxs(fc,{onOpenChange:_,open:A,children:[c.jsx(dc,{asChild:!0,children:c.jsxs(Ee,{className:"w-full justify-start text-muted-foreground",size:"sm",variant:"ghost",children:[A?c.jsx(Jo,{className:"mr-2 h-4 w-4"}):c.jsx(DH,{className:"mr-2 h-4 w-4"}),"Options"]})}),c.jsxs(hc,{className:"space-y-4 pt-2",children:[c.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[c.jsxs("div",{className:"space-y-2",children:[c.jsx(Po,{className:"text-muted-foreground text-xs",children:"Format"}),c.jsxs(fa,{onValueChange:F=>N({...T,format:F}),value:T.format||"webp",children:[c.jsx(ha,{className:"h-9",children:c.jsx(da,{})}),c.jsx(ma,{children:Xpe.map(F=>c.jsx(Ue,{value:F.value,children:F.label},F.value))})]})]}),c.jsxs("div",{className:"space-y-2",children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx(Po,{className:"text-muted-foreground text-xs",children:"Quality"}),c.jsxs("span",{className:"text-muted-foreground text-xs",children:[M,"%"]})]}),c.jsx(Dpe,{className:"mt-2",max:100,min:50,onValueChange:([F])=>R(F),onValueCommit:([F])=>N({...T,quality:F}),step:5,value:[M]})]})]}),c.jsxs("div",{className:"space-y-3 rounded-lg border bg-muted/20 p-3",children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx(Po,{className:"font-medium text-xs",children:"Resize Image"}),c.jsx("span",{className:"text-muted-foreground text-xs",children:"Maintains aspect ratio"})]}),c.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[c.jsxs("div",{className:"space-y-2",children:[c.jsx(Po,{className:"text-muted-foreground text-xs",children:"Max Width"}),c.jsxs(fa,{onValueChange:L,value:D,children:[c.jsx(ha,{className:"h-9",children:c.jsx(da,{})}),c.jsx(ma,{children:Zpe.map(F=>c.jsx(Ue,{value:F.value,children:c.jsxs("div",{className:"flex flex-col",children:[c.jsx("span",{children:F.label}),c.jsx("span",{className:"text-muted-foreground text-xs",children:F.description})]})},F.value))})]})]}),c.jsxs("div",{className:"space-y-2",children:[c.jsx(Po,{className:"text-muted-foreground text-xs",children:"Pixel Density"}),c.jsxs(fa,{onValueChange:F=>I(Number(F)),value:String(Y),children:[c.jsx(ha,{className:"h-9",children:c.jsx(da,{})}),c.jsx(ma,{children:Qpe.map(F=>c.jsx(Ue,{value:String(F.value),children:c.jsxs("div",{className:"flex flex-col",children:[c.jsx("span",{children:F.label}),c.jsx("span",{className:"text-muted-foreground text-xs",children:F.description})]})},F.value))})]})]})]}),c.jsx("p",{className:"text-muted-foreground text-xs",children:D==="none"?Y===1?"Original dimensions preserved":`Scales to 1/${Y} original size`:`Output: ${Number(D)*Y}px actual width`})]})]})]})]}),c.jsxs(GB,{className:"gap-2 sm:gap-0",children:[c.jsx(Ee,{onClick:n,variant:"ghost",children:"Cancel"}),x&&H?c.jsxs(c.Fragment,{children:[c.jsx(Ee,{onClick:le,variant:"outline",children:"Upload originals"}),b?c.jsxs(Ee,{onClick:Q,children:[c.jsx($u,{className:"mr-2 h-4 w-4"}),"Upload",g>0&&` (save ${g}%)`]}):c.jsxs(Ee,{disabled:d||!O,onClick:q,children:[d?c.jsx(ol,{className:"mr-2 h-4 w-4 animate-spin"}):c.jsx(XH,{className:"mr-2 h-4 w-4"}),d?"Optimizing...":"Optimize"]})]}):c.jsxs(Ee,{onClick:le,children:[c.jsx($u,{className:"mr-2 h-4 w-4"}),"Upload"]})]})]})})}function eve(e){return e===0?"0 B":e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(2)} KB`:`${(e/(1024*1024)).toFixed(2)} MB`}function g6(e){var t;return((t=e.split(".").pop())==null?void 0:t.toLowerCase())||""}function tve(e,t){if(e!=null&&e.startsWith("image/"))return!0;const n=t?g6(t):"";return["jpg","jpeg","png","gif","webp","avif","svg","bmp","ico"].includes(n)}function nve({file:e,onClose:t,onToggleStar:n,onDelete:r}){const i=e.key.split("/").pop()||e.key,s=g6(i),l=tve(e.contentType,i),f=()=>{navigator.clipboard.writeText(e.url),wt.success("URL copied to clipboard")},d=()=>{const h=document.createElement("a");h.href=e.url,h.download=i,h.target="_blank",h.click()};return c.jsx(EE,{onOpenChange:h=>!h&&t(),open:!0,children:c.jsx(_E,{className:"max-h-[90vh] max-w-4xl overflow-y-auto",children:c.jsxs("div",{className:"space-y-6",children:[c.jsxs("div",{className:"flex items-start justify-between",children:[c.jsxs("div",{className:"flex-1",children:[c.jsx("h2",{className:"font-bold text-2xl",children:i}),e.key!==i&&c.jsx("p",{className:"mt-1 text-muted-foreground text-sm",children:e.key})]}),c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(Ee,{onClick:()=>n(e.key,!e.starred),size:"icon",variant:"outline",children:c.jsx(Mf,{className:`h-4 w-4 ${e.starred?"fill-yellow-500 text-yellow-500":""}`})}),c.jsx(Ee,{className:"text-destructive hover:text-destructive",onClick:()=>r(e.key),size:"icon",variant:"outline",children:c.jsx(V4,{className:"h-4 w-4"})}),c.jsx(Ee,{onClick:t,size:"icon",variant:"ghost",children:c.jsx(rr,{className:"h-4 w-4"})})]})]}),c.jsx("div",{className:"aspect-video overflow-hidden rounded-lg bg-muted",children:l&&e.url.startsWith("https://")?c.jsx("img",{alt:i,className:"h-full w-full object-contain",src:e.url}):c.jsxs("div",{className:"flex h-full w-full flex-col items-center justify-center gap-2",children:[l?c.jsx(Ej,{className:"h-16 w-16 text-muted-foreground/50"}):c.jsx(_j,{className:"h-16 w-16 text-muted-foreground/50"}),c.jsx("p",{className:"text-muted-foreground text-sm",children:"Preview not available"})]})}),c.jsxs("div",{className:"flex gap-2",children:[c.jsxs(Ee,{className:"flex-1 gap-2",onClick:f,children:[c.jsx(bl,{className:"h-4 w-4"}),"Copy CDN URL"]}),c.jsxs(Ee,{className:"flex-1 gap-2 bg-transparent",onClick:()=>window.open(e.url,"_blank"),variant:"outline",children:[c.jsx(Pu,{className:"h-4 w-4"}),"Open in New Tab"]}),c.jsxs(Ee,{className:"flex-1 gap-2 bg-transparent",onClick:d,variant:"outline",children:[c.jsx(LH,{className:"h-4 w-4"}),"Download"]})]}),c.jsx(Bt,{}),c.jsxs("div",{className:"grid grid-cols-2 gap-6",children:[c.jsx("div",{className:"space-y-4",children:c.jsxs("div",{children:[c.jsx("h3",{className:"mb-2 font-semibold text-sm",children:"File Information"}),c.jsxs("dl",{className:"space-y-2 text-sm",children:[c.jsxs("div",{className:"flex justify-between",children:[c.jsx("dt",{className:"text-muted-foreground",children:"Format"}),c.jsx("dd",{className:"font-medium",children:c.jsx(He,{variant:"secondary",children:s.toUpperCase()})})]}),c.jsxs("div",{className:"flex justify-between",children:[c.jsx("dt",{className:"text-muted-foreground",children:"Size"}),c.jsx("dd",{className:"font-medium",children:eve(e.size)})]}),c.jsxs("div",{className:"flex justify-between",children:[c.jsx("dt",{className:"text-muted-foreground",children:"Content Type"}),c.jsx("dd",{className:"font-medium",children:e.contentType||"Unknown"})]})]})]})}),c.jsx("div",{className:"space-y-4",children:c.jsxs("div",{children:[c.jsx("h3",{className:"mb-2 font-semibold text-sm",children:"Metadata"}),c.jsxs("dl",{className:"space-y-2 text-sm",children:[c.jsxs("div",{className:"flex justify-between",children:[c.jsx("dt",{className:"text-muted-foreground",children:"Last Modified"}),c.jsx("dd",{className:"font-medium",children:V1(new Date(e.lastModified),"MMM d, yyyy 'at' h:mm a")})]}),c.jsxs("div",{className:"flex justify-between",children:[c.jsx("dt",{className:"text-muted-foreground",children:"Starred"}),c.jsx("dd",{className:"font-medium",children:e.starred?"Yes":"No"})]}),e.tags.length>0&&c.jsxs("div",{children:[c.jsx("dt",{className:"mb-1 text-muted-foreground",children:"Tags"}),c.jsx("dd",{className:"flex flex-wrap gap-1",children:e.tags.filter(h=>h.key!=="starred").map(h=>c.jsxs(He,{variant:"secondary",children:[h.key,": ",h.value]},h.key))})]})]})]})})]}),c.jsx(Bt,{}),c.jsxs("div",{children:[c.jsx("h3",{className:"mb-2 font-semibold text-sm",children:"CDN URL"}),c.jsxs("div",{className:"flex gap-2",children:[c.jsx("code",{className:"flex-1 break-all rounded bg-muted px-3 py-2 text-sm",children:e.url}),c.jsx(Ee,{onClick:f,size:"sm",variant:"outline",children:c.jsx(bl,{className:"h-4 w-4"})})]})]})]})})})}function rve({selectedCount:e,onStar:t,onDelete:n,onClearSelection:r}){return c.jsxs("div",{className:"flex items-center justify-between rounded-lg border border-primary/20 bg-primary/5 p-3",children:[c.jsxs("div",{className:"flex items-center gap-3",children:[c.jsxs("span",{className:"font-medium text-sm",children:[e," selected"]}),c.jsxs(Ee,{className:"gap-2 bg-transparent",onClick:t,size:"sm",variant:"outline",children:[c.jsx(Mf,{className:"h-4 w-4"}),"Star"]}),c.jsxs(Ee,{className:"gap-2 bg-transparent text-destructive hover:text-destructive",onClick:n,size:"sm",variant:"outline",children:[c.jsx(V4,{className:"h-4 w-4"}),"Delete"]})]}),c.jsxs(Ee,{className:"gap-2",onClick:r,size:"sm",variant:"ghost",children:[c.jsx(rr,{className:"h-4 w-4"}),"Clear"]})]})}function ave({filters:e,onFiltersChange:t,availableFormats:n}){const r=(e.starred?1:0)+e.formats.length;return c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsxs(Ee,{className:"gap-2",onClick:()=>t({...e,starred:!e.starred}),size:"sm",variant:e.starred?"secondary":"outline",children:[c.jsx(Mf,{className:`h-4 w-4 ${e.starred?"fill-current":""}`}),"Starred"]}),n.length>0&&c.jsxs(IL,{children:[c.jsx(zL,{asChild:!0,children:c.jsxs(Ee,{className:"gap-2 bg-transparent",size:"sm",variant:"outline",children:[c.jsx(zH,{className:"h-4 w-4"}),"Formats",r>0&&c.jsx(He,{className:"ml-1 px-1.5 py-0 text-xs",variant:"secondary",children:r})]})}),c.jsxs(BL,{align:"end",className:"w-48",children:[c.jsx(qL,{children:"File Format"}),c.jsx(P1,{}),n.map(i=>c.jsx(mY,{checked:e.formats.includes(i),onCheckedChange:s=>{t({...e,formats:s?[...e.formats,i]:e.formats.filter(l=>l!==i)})},children:i.toUpperCase()},i))]})]})]})}var Dv="Checkbox",[ive]=qn(Dv),[ove,TE]=ive(Dv);function sve(e){const{__scopeCheckbox:t,checked:n,children:r,defaultChecked:i,disabled:s,form:l,name:f,onCheckedChange:d,required:h,value:v="on",internal_do_not_use_render:p}=e,[g,b]=Vr({prop:n,defaultProp:i??!1,onChange:d,caller:Dv}),[O,S]=j.useState(null),[x,E]=j.useState(null),A=j.useRef(!1),_=O?!!l||!!O.closest("form"):!0,T={checked:g,disabled:s,setChecked:b,control:O,setControl:S,name:f,form:l,value:v,hasConsumerStoppedPropagationRef:A,required:h,defaultChecked:Gi(i)?!1:i,isFormControl:_,bubbleInput:x,setBubbleInput:E};return c.jsx(ove,{scope:t,...T,children:lve(p)?p(T):r})}var y6="CheckboxTrigger",b6=j.forwardRef(({__scopeCheckbox:e,onKeyDown:t,onClick:n,...r},i)=>{const{control:s,value:l,disabled:f,checked:d,required:h,setControl:v,setChecked:p,hasConsumerStoppedPropagationRef:g,isFormControl:b,bubbleInput:O}=TE(y6,e),S=Be(i,v),x=j.useRef(d);return j.useEffect(()=>{const E=s==null?void 0:s.form;if(E){const A=()=>p(x.current);return E.addEventListener("reset",A),()=>E.removeEventListener("reset",A)}},[s,p]),c.jsx(Ce.button,{type:"button",role:"checkbox","aria-checked":Gi(d)?"mixed":d,"aria-required":h,"data-state":E6(d),"data-disabled":f?"":void 0,disabled:f,value:l,...r,ref:S,onKeyDown:be(t,E=>{E.key==="Enter"&&E.preventDefault()}),onClick:be(n,E=>{p(A=>Gi(A)?!0:!A),O&&b&&(g.current=E.isPropagationStopped(),g.current||E.stopPropagation())})})});b6.displayName=y6;var x6=j.forwardRef((e,t)=>{const{__scopeCheckbox:n,name:r,checked:i,defaultChecked:s,required:l,disabled:f,value:d,onCheckedChange:h,form:v,...p}=e;return c.jsx(sve,{__scopeCheckbox:n,checked:i,defaultChecked:s,disabled:f,required:l,onCheckedChange:h,name:r,form:v,value:d,internal_do_not_use_render:({isFormControl:g})=>c.jsxs(c.Fragment,{children:[c.jsx(b6,{...p,ref:t,__scopeCheckbox:n}),g&&c.jsx(O6,{__scopeCheckbox:n})]})})});x6.displayName=Dv;var w6="CheckboxIndicator",S6=j.forwardRef((e,t)=>{const{__scopeCheckbox:n,forceMount:r,...i}=e,s=TE(w6,n);return c.jsx(lr,{present:r||Gi(s.checked)||s.checked===!0,children:c.jsx(Ce.span,{"data-state":E6(s.checked),"data-disabled":s.disabled?"":void 0,...i,ref:t,style:{pointerEvents:"none",...e.style}})})});S6.displayName=w6;var j6="CheckboxBubbleInput",O6=j.forwardRef(({__scopeCheckbox:e,...t},n)=>{const{control:r,hasConsumerStoppedPropagationRef:i,checked:s,defaultChecked:l,required:f,disabled:d,name:h,value:v,form:p,bubbleInput:g,setBubbleInput:b}=TE(j6,e),O=Be(n,b),S=Vp(s),x=Cp(r);j.useEffect(()=>{const A=g;if(!A)return;const _=window.HTMLInputElement.prototype,N=Object.getOwnPropertyDescriptor(_,"checked").set,M=!i.current;if(S!==s&&N){const R=new Event("click",{bubbles:M});A.indeterminate=Gi(s),N.call(A,Gi(s)?!1:s),A.dispatchEvent(R)}},[g,S,s,i]);const E=j.useRef(Gi(s)?!1:s);return c.jsx(Ce.input,{type:"checkbox","aria-hidden":!0,defaultChecked:l??E.current,required:f,disabled:d,name:h,value:v,form:p,...t,tabIndex:-1,ref:O,style:{...t.style,...x,position:"absolute",pointerEvents:"none",opacity:0,margin:0,transform:"translateX(-100%)"}})});O6.displayName=j6;function lve(e){return typeof e=="function"}function Gi(e){return e==="indeterminate"}function E6(e){return Gi(e)?"indeterminate":e?"checked":"unchecked"}function vj({className:e,...t}){return c.jsx(x6,{className:ve("peer size-4 shrink-0 rounded-[4px] border border-input shadow-xs outline-none transition-shadow focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 data-[state=checked]:border-primary data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground dark:bg-input/30 dark:data-[state=checked]:bg-primary dark:aria-invalid:ring-destructive/40",e),"data-slot":"checkbox",...t,children:c.jsx(S6,{className:"grid place-content-center text-current transition-none","data-slot":"checkbox-indicator",children:c.jsx(Vi,{className:"size-3.5"})})})}function cve(e){return e===0?"0 B":e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(0)} KB`:`${(e/(1024*1024)).toFixed(2)} MB`}function _6(e){var t;return((t=e.split(".").pop())==null?void 0:t.toLowerCase())||""}function uve(e,t){if(e!=null&&e.startsWith("image/"))return!0;const n=t?_6(t):"";return["jpg","jpeg","png","gif","webp","avif","svg","bmp","ico"].includes(n)}function fve({files:e,selectedFiles:t,onSelectFile:n,onToggleStar:r,onFileClick:i}){const s=(f,d)=>{f.stopPropagation(),navigator.clipboard.writeText(d),wt.success("URL copied to clipboard")},l=(f,d)=>{f.stopPropagation(),window.open(d,"_blank")};return c.jsx("div",{className:"grid grid-cols-1 gap-4 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4",children:e.map(f=>{const d=f.key.split("/").pop()||f.key,h=_6(d),v=uve(f.contentType,d);return c.jsxs(Ne,{className:"group relative cursor-pointer overflow-hidden transition-colors hover:border-primary/50",onClick:()=>i(f),children:[c.jsxs("div",{className:"relative aspect-video overflow-hidden bg-muted",children:[v&&f.url.startsWith("https://")?c.jsx("img",{alt:d,className:"h-full w-full object-cover",src:f.url}):c.jsx("div",{className:"flex h-full w-full items-center justify-center",children:v?c.jsx(Ej,{className:"h-12 w-12 text-muted-foreground/50"}):c.jsx(_j,{className:"h-12 w-12 text-muted-foreground/50"})}),c.jsx("div",{className:"absolute top-2 left-2 z-10",onClick:p=>p.stopPropagation(),children:c.jsx(vj,{checked:t.includes(f.key),className:"bg-background/80 backdrop-blur-sm",onCheckedChange:()=>n(f.key)})}),c.jsx(Ee,{className:"absolute top-2 right-2 z-10 bg-background/80 backdrop-blur-sm hover:bg-background/90",onClick:p=>{p.stopPropagation(),r(f.key,!f.starred)},size:"icon",variant:"ghost",children:c.jsx(Mf,{className:`h-4 w-4 ${f.starred?"fill-yellow-500 text-yellow-500":""}`})}),c.jsxs("div",{className:"absolute right-2 bottom-2 z-10 flex gap-1 opacity-0 transition-opacity group-hover:opacity-100",children:[c.jsx(Ee,{className:"h-8 w-8",onClick:p=>s(p,f.url),size:"icon",variant:"secondary",children:c.jsx(bl,{className:"h-3.5 w-3.5"})}),c.jsx(Ee,{className:"h-8 w-8",onClick:p=>l(p,f.url),size:"icon",variant:"secondary",children:c.jsx(Pu,{className:"h-3.5 w-3.5"})})]})]}),c.jsxs("div",{className:"space-y-2 p-3",children:[c.jsxs("div",{className:"flex items-start justify-between gap-2",children:[c.jsx("p",{className:"flex-1 truncate font-medium text-sm",children:d}),c.jsx(He,{className:"shrink-0 text-xs",variant:"secondary",children:h.toUpperCase()})]}),c.jsx("div",{className:"flex items-center gap-2 text-muted-foreground text-xs",children:c.jsx("span",{children:cve(f.size)})})]})]},f.key)})})}function dve({value:e,onChange:t}){return c.jsxs("div",{className:"relative",children:[c.jsx(Aj,{className:"absolute top-1/2 left-3 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),c.jsx(ec,{className:"pl-9",onChange:n=>t(n.target.value),placeholder:"Search files by name...",type:"search",value:e})]})}function hve(e){return e===0?"0 B":e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(0)} KB`:`${(e/(1024*1024)).toFixed(2)} MB`}function A6(e){var t;return((t=e.split(".").pop())==null?void 0:t.toLowerCase())||""}function mve(e,t){if(e!=null&&e.startsWith("image/"))return!0;const n=t?A6(t):"";return["jpg","jpeg","png","gif","webp","avif","svg","bmp","ico"].includes(n)}function pve({files:e,selectedFiles:t,onSelectFile:n,onSelectAll:r,onToggleStar:i,onFileClick:s}){const l=(d,h)=>{d.stopPropagation(),navigator.clipboard.writeText(h),wt.success("URL copied to clipboard")},f=(d,h)=>{d.stopPropagation(),window.open(h,"_blank")};return c.jsx("div",{className:"overflow-hidden rounded-lg border border-border",children:c.jsxs(dO,{children:[c.jsx(hO,{children:c.jsxs(la,{className:"bg-muted/50",children:[c.jsx(pn,{className:"w-12",children:c.jsx(vj,{checked:t.length===e.length&&e.length>0,onCheckedChange:r})}),c.jsx(pn,{className:"w-12"}),c.jsx(pn,{children:"Name"}),c.jsx(pn,{children:"Format"}),c.jsx(pn,{children:"Size"}),c.jsx(pn,{children:"Modified"}),c.jsx(pn,{className:"w-24",children:"Actions"})]})}),c.jsx(mO,{children:e.map(d=>{const h=d.key.split("/").pop()||d.key,v=A6(h),p=mve(d.contentType,h);return c.jsxs(la,{className:"cursor-pointer hover:bg-muted/50",onClick:()=>s(d),children:[c.jsx(It,{onClick:g=>g.stopPropagation(),children:c.jsx(vj,{checked:t.includes(d.key),onCheckedChange:()=>n(d.key)})}),c.jsx(It,{onClick:g=>g.stopPropagation(),children:c.jsx(Ee,{className:"h-8 w-8",onClick:g=>{g.stopPropagation(),i(d.key,!d.starred)},size:"icon",variant:"ghost",children:c.jsx(Mf,{className:`h-4 w-4 ${d.starred?"fill-yellow-500 text-yellow-500":""}`})})}),c.jsx(It,{children:c.jsxs("div",{className:"flex items-center gap-3",children:[c.jsx("div",{className:"h-10 w-14 shrink-0 overflow-hidden rounded border bg-muted",children:p&&d.url.startsWith("https://")?c.jsx("img",{alt:h,className:"h-full w-full object-cover",src:d.url}):c.jsx("div",{className:"flex h-full w-full items-center justify-center",children:p?c.jsx(Ej,{className:"h-4 w-4 text-muted-foreground"}):c.jsx(_j,{className:"h-4 w-4 text-muted-foreground"})})}),c.jsx("span",{className:"truncate font-medium",children:h})]})}),c.jsx(It,{children:c.jsx(He,{variant:"secondary",children:v.toUpperCase()})}),c.jsx(It,{className:"text-muted-foreground",children:hve(d.size)}),c.jsx(It,{className:"text-muted-foreground text-xs",children:IX(new Date(d.lastModified),{addSuffix:!0})}),c.jsx(It,{onClick:g=>g.stopPropagation(),children:c.jsxs("div",{className:"flex gap-1",children:[c.jsx(Ee,{className:"h-8 w-8",onClick:g=>l(g,d.url),size:"icon",variant:"ghost",children:c.jsx(bl,{className:"h-3.5 w-3.5"})}),c.jsx(Ee,{className:"h-8 w-8",onClick:g=>f(g,d.url),size:"icon",variant:"ghost",children:c.jsx(Pu,{className:"h-3.5 w-3.5"})})]})})]},d.key)})})]})})}function vve({viewMode:e,onViewModeChange:t}){return c.jsxs("div",{className:"flex items-center gap-1 rounded-lg border border-border bg-muted/50 p-1",children:[c.jsxs(Ee,{className:"gap-2",onClick:()=>t("grid"),size:"sm",variant:e==="grid"?"secondary":"ghost",children:[c.jsx(qH,{className:"h-4 w-4"}),"Grid"]}),c.jsxs(Ee,{className:"gap-2",onClick:()=>t("table"),size:"sm",variant:e==="table"?"secondary":"ghost",children:[c.jsx(YH,{className:"h-4 w-4"}),"Table"]})]})}function gve(e){return e===0?"0 B":e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:e<1024*1024*1024?`${(e/(1024*1024)).toFixed(1)} MB`:`${(e/(1024*1024*1024)).toFixed(2)} GB`}function yve({url:e}){const[t,n]=j.useState(!1),r=async()=>{await navigator.clipboard.writeText(e),n(!0),wt.success("URL copied to clipboard"),setTimeout(()=>n(!1),2e3)};return c.jsx(Ee,{onClick:r,size:"sm",variant:"outline",children:t?c.jsx(Vi,{className:"h-3 w-3 text-green-500"}):c.jsx("span",{className:"text-xs",children:"Copy"})})}function bve(){return c.jsxs("div",{className:"space-y-6",children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{children:[c.jsx(Re,{className:"mb-2 h-8 w-48"}),c.jsx(Re,{className:"h-4 w-64"})]}),c.jsxs("div",{className:"flex gap-2",children:[c.jsx(Re,{className:"h-9 w-24"}),c.jsx(Re,{className:"h-9 w-24"})]})]}),c.jsx("div",{className:"grid gap-4 md:grid-cols-4",children:[1,2,3,4].map(e=>c.jsx(Ne,{children:c.jsxs(De,{className:"pb-2",children:[c.jsx(Re,{className:"h-4 w-20"}),c.jsx(Re,{className:"h-8 w-16"})]})},e))}),c.jsx("div",{className:"grid gap-4 md:grid-cols-4",children:[1,2,3,4].map(e=>c.jsxs(Ne,{className:"overflow-hidden",children:[c.jsx(Re,{className:"aspect-video w-full"}),c.jsxs("div",{className:"p-3",children:[c.jsx(Re,{className:"mb-2 h-4 w-full"}),c.jsx(Re,{className:"h-3 w-20"})]})]},e))})]})}function xve(){return c.jsxs("div",{className:"flex flex-col items-center justify-center py-12",children:[c.jsx(Tf,{className:"mb-4 h-16 w-16 text-muted-foreground opacity-50"}),c.jsx("h2",{className:"mb-2 font-semibold text-xl",children:"No Storage Configured"}),c.jsxs("p",{className:"mb-6 max-w-md text-center text-muted-foreground",children:["Storage infrastructure has not been deployed yet. Run"," ",c.jsx("code",{className:"rounded bg-muted px-2 py-1 font-mono text-sm",children:"wraps storage init"})," ","to get started."]})]})}function wve({onUploadClick:e}){return c.jsxs("div",{className:"flex flex-col items-center justify-center py-16",children:[c.jsx(G4,{className:"mb-4 h-16 w-16 text-muted-foreground opacity-50"}),c.jsx("h3",{className:"mb-2 font-semibold text-lg",children:"No Files Yet"}),c.jsx("p",{className:"mb-6 max-w-md text-center text-muted-foreground",children:"Upload your first file to get started with your CDN library"}),c.jsxs(Ee,{onClick:e,children:[c.jsx($u,{className:"mr-2 h-4 w-4"}),"Upload Files"]})]})}function Sve({upload:e,onRemove:t}){return c.jsx("div",{className:"flex items-center gap-3 rounded-lg border bg-muted/30 p-3",children:c.jsxs("div",{className:"min-w-0 flex-1",children:[c.jsxs("div",{className:"mb-1 flex items-center justify-between",children:[c.jsx("span",{className:"truncate font-medium text-sm",children:e.filename}),c.jsxs("div",{className:"flex items-center gap-2",children:[e.status==="uploading"&&c.jsx(ol,{className:"h-4 w-4 animate-spin text-primary"}),e.status==="success"&&c.jsx(Zi,{className:"h-4 w-4 text-green-500"}),e.status==="error"&&c.jsx(ir,{className:"h-4 w-4 text-red-500"}),c.jsx(Ee,{className:"h-6 w-6",onClick:t,size:"icon",variant:"ghost",children:c.jsx(rr,{className:"h-3 w-3"})})]})]}),e.status==="uploading"&&c.jsx(Tv,{className:"h-1",value:e.progress}),e.status==="success"&&e.cdnUrl&&c.jsxs("div",{className:"mt-1 flex items-center gap-2",children:[c.jsx("span",{className:"truncate text-muted-foreground text-xs",children:e.cdnUrl}),c.jsx(yve,{url:e.cdnUrl})]}),e.status==="error"&&c.jsx("span",{className:"text-red-500 text-xs",children:e.error})]})})}function jve({uploads:e,onFilesSelected:t,onRemoveUpload:n}){const[r,i]=j.useState(!1),s=j.useRef(null),l=v=>{v.preventDefault(),i(!0)},f=v=>{v.preventDefault(),i(!1)},d=v=>{v.preventDefault(),i(!1),v.dataTransfer.files.length>0&&t(v.dataTransfer.files)},h=v=>{v.target.files&&v.target.files.length>0&&t(v.target.files)};return c.jsxs(Ne,{children:[c.jsxs(De,{children:[c.jsx(Fe,{children:"Upload Files"}),c.jsx(Ye,{children:"Drag and drop files or click to browse"})]}),c.jsxs(Le,{className:"space-y-4",children:[c.jsxs("div",{className:`cursor-pointer rounded-lg border-2 border-dashed p-8 text-center transition-colors ${r?"border-primary bg-primary/5":"border-muted-foreground/25 hover:border-primary/50"}`,onClick:()=>{var v;return(v=s.current)==null?void 0:v.click()},onDragLeave:f,onDragOver:l,onDrop:d,children:[c.jsx($u,{className:"mx-auto mb-4 h-10 w-10 text-muted-foreground"}),c.jsx("p",{className:"mb-1 font-medium text-sm",children:"Drop files here or click to upload"}),c.jsx("p",{className:"text-muted-foreground text-xs",children:"Images will be optimized before uploading"}),c.jsx("input",{accept:"*/*",className:"hidden",multiple:!0,onChange:h,ref:s,type:"file"})]}),e.length>0&&c.jsx("div",{className:"space-y-2",children:e.map((v,p)=>c.jsx(Sve,{onRemove:()=>n(p),upload:v},`${v.filename}-${p}`))})]})]})}function Ove(){const[e,t]=j.useState(null),[n,r]=j.useState(!0),[i,s]=j.useState(null),[l,f]=j.useState("grid"),[d,h]=j.useState(""),[v,p]=j.useState({starred:!1,formats:[]}),[g,b]=j.useState([]),[O,S]=j.useState(null),[x,E]=j.useState(!1),[A,_]=j.useState([]),[T,N]=j.useState({keys:[],isOpen:!1}),[M,R]=j.useState([]),[D,L]=j.useState(!1),Y=j.useCallback(async()=>{try{r(!0),s(null);const B=sessionStorage.getItem("wraps-auth-token"),V=await fetch(`/api/cdn/files?token=${B}`);if(!V.ok){if(V.status===404){t(null);return}throw new Error("Failed to fetch storage files")}const F=await V.json();t(F)}catch(B){s(B instanceof Error?B.message:"An error occurred")}finally{r(!1)}},[]);j.useEffect(()=>{Y()},[Y]);const I=j.useCallback(async(B,V)=>{const F=sessionStorage.getItem("wraps-auth-token");try{if(!(await fetch(`/api/cdn/files/${encodeURIComponent(B)}/star?token=${F}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({starred:V})})).ok)throw new Error("Failed to update star status");t(fe=>fe&&{...fe,files:fe.files.map(oe=>oe.key===B?{...oe,starred:V}:oe)}),(O==null?void 0:O.key)===B&&S(fe=>fe?{...fe,starred:V}:null),wt.success(V?"File starred":"Star removed")}catch{wt.error("Failed to update star status")}},[O]),H=j.useCallback(async B=>{const V=sessionStorage.getItem("wraps-auth-token");try{await Promise.all(B.map(F=>fetch(`/api/cdn/files/${encodeURIComponent(F)}?token=${V}`,{method:"DELETE"}))),wt.success(B.length===1?"File deleted":`${B.length} files deleted`),b([]),S(null),Y()}catch{wt.error("Failed to delete file(s)")}},[Y]),W=j.useCallback(async(B,V,F)=>{const ne=sessionStorage.getItem("wraps-auth-token"),fe=B instanceof File,oe=F||(fe?B.name:"file"),me=B.type||"application/octet-stream";try{_(ie=>ie.map((Pe,xe)=>xe===V?{...Pe,status:"uploading",progress:0}:Pe));const ae=await fetch(`/api/cdn/upload-url?token=${ne}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({filename:oe,contentType:me})});if(!ae.ok)throw new Error("Failed to get upload URL");const{uploadUrl:pe,cdnUrl:ge}=await ae.json();await new Promise((ie,Pe)=>{const xe=new XMLHttpRequest;xe.upload.addEventListener("progress",Je=>{if(Je.lengthComputable){const rt=Math.round(Je.loaded/Je.total*100);_(lt=>lt.map((Wt,bt)=>bt===V?{...Wt,progress:rt}:Wt))}}),xe.addEventListener("load",()=>{xe.status>=200&&xe.status<300?ie():Pe(new Error(`Upload failed with status ${xe.status}`))}),xe.addEventListener("error",()=>Pe(new Error("Upload failed"))),xe.open("PUT",pe),xe.setRequestHeader("Content-Type",me),xe.send(B)}),_(ie=>ie.map((Pe,xe)=>xe===V?{...Pe,status:"success",progress:100,cdnUrl:ge}:Pe)),wt.success(`Uploaded ${oe}`),Y()}catch(ae){_(pe=>pe.map((ge,ie)=>ie===V?{...ge,status:"error",error:ae instanceof Error?ae.message:"Upload failed"}:ge)),wt.error(`Failed to upload ${oe}`)}},[Y]),Z=j.useCallback(B=>{const V=Array.from(B),F=V.filter(fe=>fe.type.startsWith("image/")),ne=V.filter(fe=>!fe.type.startsWith("image/"));if(ne.length>0){const fe=ne.map(me=>({file:me,filename:me.name,progress:0,status:"pending"}));_(me=>[...me,...fe]),E(!0);const oe=A.length;ne.forEach((me,ae)=>{W(me,oe+ae,me.name)})}F.length>0&&(R(F),L(!0))},[A.length,W]),X=j.useCallback(B=>{if(!B||B.length===0)return;const V=A.length,F=B.map(ne=>({file:ne.file,filename:ne.cdnFilename,progress:0,status:"pending"}));_(ne=>[...ne,...F]),E(!0),B.forEach((ne,fe)=>{W(ne.file,V+fe,ne.cdnFilename)})},[A.length,W]),k=j.useCallback(B=>{b(V=>V.includes(B)?V.filter(F=>F!==B):[...V,B])},[]),U=j.useCallback(()=>{if(!(e!=null&&e.files))return;const B=le.map(V=>V.key);g.length===B.length?b([]):b(B)},[e==null?void 0:e.files,g.length]),q=j.useCallback(async()=>{await Promise.all(g.map(B=>I(B,!0))),b([])},[g,I]),Q=j.useCallback(()=>{N({keys:g,isOpen:!0})},[g]),le=j.useMemo(()=>e!=null&&e.files?e.files.filter(B=>{var V;if(d&&!B.key.toLowerCase().includes(d.toLowerCase())||v.starred&&!B.starred)return!1;if(v.formats.length>0){const F=((V=B.key.split(".").pop())==null?void 0:V.toLowerCase())||"";if(!v.formats.includes(F))return!1}return!0}):[],[e==null?void 0:e.files,d,v]),$=j.useMemo(()=>{if(!(e!=null&&e.files))return[];const B=new Set;return e.files.forEach(V=>{var ne;const F=(ne=V.key.split(".").pop())==null?void 0:ne.toLowerCase();F&&B.add(F)}),Array.from(B).sort()},[e==null?void 0:e.files]);return n?c.jsx(bve,{}):i?c.jsxs(In,{variant:"destructive",children:[c.jsx(ir,{className:"h-4 w-4"}),c.jsx(Xi,{children:"Error"}),c.jsx(zn,{children:i})]}):e?c.jsxs("div",{className:"space-y-6",children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{children:[c.jsx("h1",{className:"font-bold text-2xl",children:"CDN Library"}),c.jsx("p",{className:"text-muted-foreground",children:e.fileCount>0?c.jsxs(c.Fragment,{children:[c.jsx("span",{className:"text-foreground",children:e.fileCount})," File",e.fileCount!==1?"s":""," · Total"," ",c.jsx("span",{className:"text-foreground",children:gve(e.totalSize)})]}):"Manage and organize your files"})]}),c.jsxs("div",{className:"flex items-center gap-3",children:[c.jsxs(Ee,{onClick:()=>E(!x),children:[c.jsx($u,{className:"mr-2 h-4 w-4"}),"Upload Files"]}),c.jsx(Ee,{onClick:Y,size:"icon",variant:"outline",children:c.jsx(Cf,{className:"h-4 w-4"})}),c.jsx(vve,{onViewModeChange:f,viewMode:l})]})]}),x&&c.jsx(jve,{onFilesSelected:Z,onRemoveUpload:B=>_(V=>V.filter((F,ne)=>ne!==B)),uploads:A}),e.files.length>0&&c.jsxs("div",{className:"flex flex-col gap-4 md:flex-row",children:[c.jsx("div",{className:"flex-1",children:c.jsx(dve,{onChange:h,value:d})}),c.jsx(ave,{availableFormats:$,filters:v,onFiltersChange:p})]}),g.length>0&&c.jsx(rve,{onClearSelection:()=>b([]),onDelete:Q,onStar:q,selectedCount:g.length}),e.files.length===0?c.jsx(wve,{onUploadClick:()=>E(!0)}):le.length===0?c.jsx("div",{className:"py-12 text-center text-muted-foreground",children:"No files match your search or filters"}):l==="grid"?c.jsx(fve,{files:le,onFileClick:S,onSelectFile:k,onToggleStar:I,selectedFiles:g}):c.jsx(pve,{files:le,onFileClick:S,onSelectAll:U,onSelectFile:k,onToggleStar:I,selectedFiles:g}),O&&c.jsx(nve,{file:O,onClose:()=>S(null),onDelete:B=>{N({keys:[B],isOpen:!0})},onToggleStar:I}),c.jsx(up,{onOpenChange:B=>N(V=>({...V,isOpen:B})),open:T.isOpen,children:c.jsxs(fp,{children:[c.jsxs(dp,{children:[c.jsxs(mp,{children:["Delete File",T.keys.length>1?"s":""]}),c.jsxs(pp,{children:["Are you sure you want to delete"," ",T.keys.length===1?c.jsx("strong",{children:T.keys[0].split("/").pop()}):c.jsxs("strong",{children:[T.keys.length," files"]}),"? This action cannot be undone."]})]}),c.jsxs(hp,{children:[c.jsx(gp,{children:"Cancel"}),c.jsx(vp,{className:"bg-red-600 hover:bg-red-700",onClick:()=>{H(T.keys),N({keys:[],isOpen:!1})},children:"Delete"})]})]})}),c.jsx(Jpe,{files:M,onClose:()=>{L(!1),R([])},onComplete:X,open:D})]}):c.jsx(xve,{})}function j1(e){if(e===0)return"0 B";const t=1024,n=["B","KB","MB","GB","TB"],r=Math.floor(Math.log(e)/Math.log(t));return`${Number.parseFloat((e/t**r).toFixed(1))} ${n[r]}`}function zo(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}K`:e.toString()}function Ih({title:e,value:t,description:n,icon:r,trend:i}){return c.jsxs(Ne,{children:[c.jsxs(De,{className:"flex flex-row items-center justify-between pb-2",children:[c.jsx(Fe,{className:"font-medium text-muted-foreground text-sm",children:e}),c.jsx(r,{className:"h-4 w-4 text-muted-foreground"})]}),c.jsxs(Le,{children:[c.jsx("div",{className:"font-bold text-2xl",children:t}),c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("p",{className:"text-muted-foreground text-xs",children:n}),i!==void 0&&i!==0&&c.jsxs("span",{className:`flex items-center text-xs ${i>0?"text-green-500":"text-red-500"}`,children:[c.jsx(Nj,{className:`h-3 w-3 ${i<0?"rotate-180":""}`}),Math.abs(i),"%"]})]})]})]})}function Eve({data:e}){const t=e.map(n=>({date:new Date(n.date).toLocaleDateString("en-US",{month:"short",day:"numeric"}),size:n.size/1073741824,files:n.files}));return c.jsxs(Ne,{children:[c.jsxs(De,{children:[c.jsx(Fe,{children:"Storage Usage"}),c.jsx(Ye,{children:"Storage size and file count over time"})]}),c.jsx(Le,{children:c.jsx(LO,{height:300,width:"100%",children:c.jsxs(jB,{data:t,children:[c.jsx(Av,{className:"stroke-muted",strokeDasharray:"3 3"}),c.jsx(ls,{className:"text-xs",dataKey:"date",stroke:"currentColor",tick:{fill:"currentColor"}}),c.jsx(ii,{className:"text-xs",stroke:"currentColor",tick:{fill:"currentColor"},tickFormatter:n=>`${n} GB`,yAxisId:"left"}),c.jsx(ii,{className:"text-xs",orientation:"right",stroke:"currentColor",tick:{fill:"currentColor"},yAxisId:"right"}),c.jsx(jr,{contentStyle:{backgroundColor:"hsl(var(--card))",border:"1px solid hsl(var(--border))",borderRadius:"var(--radius)"},formatter:(n,r)=>[r==="size"?`${n.toFixed(2)} GB`:n,r==="size"?"Storage":"Files"]}),c.jsx(Ka,{}),c.jsx(Or,{dataKey:"size",dot:!1,name:"Storage (GB)",stroke:"hsl(var(--primary))",strokeWidth:2,type:"monotone",yAxisId:"left"}),c.jsx(Or,{dataKey:"files",dot:!1,name:"File Count",stroke:"hsl(var(--chart-2))",strokeWidth:2,type:"monotone",yAxisId:"right"})]})})})]})}function _ve({data:e}){const t=e.map(n=>({date:new Date(n.date).toLocaleDateString("en-US",{month:"short",day:"numeric"}),bandwidth:n.bytes/1048576,requests:n.requests}));return c.jsxs(Ne,{children:[c.jsxs(De,{children:[c.jsx(Fe,{children:"CDN Traffic"}),c.jsx(Ye,{children:"Bandwidth and requests over time"})]}),c.jsx(Le,{children:c.jsx(LO,{height:300,width:"100%",children:c.jsxs(Phe,{data:t,children:[c.jsx(Av,{className:"stroke-muted",strokeDasharray:"3 3"}),c.jsx(ls,{className:"text-xs",dataKey:"date",stroke:"currentColor",tick:{fill:"currentColor"}}),c.jsx(ii,{className:"text-xs",stroke:"currentColor",tick:{fill:"currentColor"},tickFormatter:n=>`${n} MB`,yAxisId:"left"}),c.jsx(ii,{className:"text-xs",orientation:"right",stroke:"currentColor",tick:{fill:"currentColor"},tickFormatter:n=>zo(n),yAxisId:"right"}),c.jsx(jr,{contentStyle:{backgroundColor:"hsl(var(--card))",border:"1px solid hsl(var(--border))",borderRadius:"var(--radius)"},formatter:(n,r)=>[r==="bandwidth"?`${n.toFixed(1)} MB`:zo(n),r==="bandwidth"?"Bandwidth":"Requests"]}),c.jsx(Ka,{}),c.jsx(Qi,{dataKey:"bandwidth",fill:"hsl(var(--primary))",name:"Bandwidth (MB)",radius:[4,4,0,0],yAxisId:"left"}),c.jsx(Qi,{dataKey:"requests",fill:"hsl(var(--chart-3))",name:"Requests",radius:[4,4,0,0],yAxisId:"right"})]})})})]})}function Ave({files:e}){return c.jsxs(Ne,{children:[c.jsxs(De,{children:[c.jsx(Fe,{children:"Top Files"}),c.jsx(Ye,{children:"Most requested files this month"})]}),c.jsx(Le,{children:e.length===0?c.jsx("div",{className:"py-4 text-center text-muted-foreground",children:"No data available"}):c.jsx("div",{className:"space-y-4",children:e.map((t,n)=>{const r=t.key.split("/").pop()||t.key,i=Math.max(...e.map(l=>l.requests)),s=t.requests/i*100;return c.jsxs("div",{children:[c.jsxs("div",{className:"mb-1 flex items-center justify-between text-sm",children:[c.jsxs("span",{className:"flex items-center gap-2",children:[c.jsxs("span",{className:"text-muted-foreground",children:[n+1,"."]}),c.jsx("span",{className:"max-w-[200px] truncate font-medium",children:r})]}),c.jsxs("span",{className:"text-muted-foreground",children:[zo(t.requests)," requests"]})]}),c.jsx(Tv,{className:"h-2",value:s})]},t.key)})})})]})}function Nve(){return c.jsxs("div",{className:"space-y-6",children:[c.jsx("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-4",children:Array.from({length:4}).map((e,t)=>c.jsxs(Ne,{children:[c.jsx(De,{className:"pb-2",children:c.jsx(Re,{className:"h-4 w-20"})}),c.jsxs(Le,{children:[c.jsx(Re,{className:"h-8 w-24"}),c.jsx(Re,{className:"mt-2 h-3 w-32"})]})]},t))}),c.jsxs(Ne,{children:[c.jsx(De,{children:c.jsx(Re,{className:"h-6 w-32"})}),c.jsx(Le,{children:c.jsx(Re,{className:"h-[300px] w-full"})})]})]})}function Tve(){return c.jsxs("div",{className:"flex flex-col items-center justify-center py-12",children:[c.jsx(Tf,{className:"mb-4 h-16 w-16 text-muted-foreground opacity-50"}),c.jsx("h2",{className:"mb-2 font-semibold text-xl",children:"No Storage Configured"}),c.jsxs("p",{className:"mb-6 max-w-md text-center text-muted-foreground",children:["Storage infrastructure has not been deployed yet. Run"," ",c.jsx("code",{className:"rounded bg-muted px-2 py-1 font-mono text-sm",children:"wraps storage init"})," ","to get started."]})]})}function Cve(){const[e,t]=j.useState(null),[n,r]=j.useState(!0),[i,s]=j.useState(null),[l,f]=j.useState("7d"),d=j.useCallback(async()=>{try{r(!0),s(null);const h=sessionStorage.getItem("wraps-auth-token"),v=await fetch(`/api/cdn/metrics?token=${h}&range=${l}`);if(!v.ok){if(v.status===404){t(null);return}throw new Error("Failed to fetch storage metrics")}const p=await v.json();t(p)}catch(h){s(h instanceof Error?h.message:"An error occurred")}finally{r(!1)}},[l]);return j.useEffect(()=>{d()},[d]),n?c.jsx(Nve,{}):i?c.jsxs(In,{variant:"destructive",children:[c.jsx(ir,{className:"h-4 w-4"}),c.jsx(Xi,{children:"Error"}),c.jsx(zn,{children:i})]}):e?c.jsxs("div",{className:"space-y-6",children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{children:[c.jsx("h1",{className:"font-bold text-2xl",children:"Storage Metrics"}),c.jsx("p",{className:"text-muted-foreground",children:"Monitor your storage usage and CDN traffic"})]}),c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsxs(fa,{onValueChange:f,value:l,children:[c.jsx(ha,{className:"w-32",children:c.jsx(da,{})}),c.jsxs(ma,{children:[c.jsx(Ue,{value:"7d",children:"Last 7 days"}),c.jsx(Ue,{value:"30d",children:"Last 30 days"}),c.jsx(Ue,{value:"90d",children:"Last 90 days"})]})]}),c.jsxs(Ee,{onClick:d,size:"sm",variant:"outline",children:[c.jsx(Cf,{className:"mr-2 h-4 w-4"}),"Refresh"]})]})]}),c.jsxs("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-4",children:[c.jsx(Ih,{description:`${zo(e.summary.fileCount)} files`,icon:$H,title:"Storage Used",value:j1(e.summary.totalSize)}),c.jsx(Ih,{description:`${j1(e.summary.bandwidth.thisMonth)} this month`,icon:MH,title:"Bandwidth Today",value:j1(e.summary.bandwidth.today)}),c.jsx(Ih,{description:`${zo(e.summary.requests.thisMonth)} this month`,icon:ku,title:"Requests Today",value:zo(e.summary.requests.today)}),c.jsx(Ih,{description:"Files in storage",icon:RH,title:"Total Files",value:zo(e.summary.fileCount)})]}),c.jsxs("div",{className:"grid gap-6 lg:grid-cols-2",children:[c.jsx(Eve,{data:e.usage}),c.jsx(_ve,{data:e.bandwidth})]}),c.jsx(Ave,{files:e.topFiles})]}):c.jsx(Tve,{})}function bp({status:e}){const t={SUCCESS:{icon:Zi,label:"Active",className:"bg-green-500/10 text-green-700 dark:text-green-400 border-green-500/20"},PENDING:{icon:Uo,label:"Pending",className:"bg-yellow-500/10 text-yellow-700 dark:text-yellow-400 border-yellow-500/20"},FAILED:{icon:F4,label:"Failed",className:"bg-red-500/10 text-red-700 dark:text-red-400 border-red-500/20"},DISABLED:{icon:ir,label:"Disabled",className:"bg-gray-500/10 text-gray-700 dark:text-gray-400 border-gray-500/20"}},{icon:n,label:r,className:i}=t[e];return c.jsxs(He,{className:i,variant:"outline",children:[c.jsx(n,{className:"mr-1 h-3 w-3"}),r]})}function ul({text:e}){const t=async()=>{await navigator.clipboard.writeText(e),wt.success("Copied to clipboard")};return c.jsx(Ee,{onClick:t,size:"sm",variant:"ghost",children:c.jsx(bl,{className:"h-3 w-3"})})}function Mve({settings:e}){return c.jsxs(Ne,{children:[c.jsxs(De,{children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(Tf,{className:"h-5 w-5"}),c.jsx(Fe,{children:"S3 Bucket"})]}),c.jsx(bp,{status:"SUCCESS"})]}),c.jsx(Ye,{children:"Your storage bucket for uploading files"})]}),c.jsx(Le,{className:"space-y-4",children:c.jsxs("div",{className:"grid gap-4",children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx("span",{className:"text-muted-foreground text-sm",children:"Bucket Name"}),c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("code",{className:"rounded bg-muted px-2 py-1 font-mono text-sm",children:e.bucketName}),c.jsx(ul,{text:e.bucketName})]})]}),c.jsx(Bt,{}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx("span",{className:"text-muted-foreground text-sm",children:"Region"}),c.jsx("code",{className:"rounded bg-muted px-2 py-1 font-mono text-sm",children:e.region})]}),c.jsx(Bt,{}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx("span",{className:"text-muted-foreground text-sm",children:"Versioning"}),c.jsx(He,{variant:e.versioning?"default":"secondary",children:e.versioning?"Enabled":"Disabled"})]}),c.jsx(Bt,{}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx("span",{className:"text-muted-foreground text-sm",children:"Encryption"}),c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(Kh,{className:"h-4 w-4 text-green-500"}),c.jsx("span",{className:"text-sm",children:"AES-256"})]})]}),e.retention&&e.retention!=="none"&&c.jsxs(c.Fragment,{children:[c.jsx(Bt,{}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx("span",{className:"text-muted-foreground text-sm",children:"Auto-Cleanup"}),c.jsx("span",{className:"text-sm",children:e.retention})]})]})]})})]})}function Rve({settings:e}){var i,s;const[t,n]=j.useState(!1);if(!((i=e.cdn)!=null&&i.enabled))return c.jsx(Ne,{children:c.jsxs(De,{children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(ku,{className:"h-5 w-5"}),c.jsx(Fe,{children:"CloudFront CDN"})]}),c.jsx(bp,{status:"DISABLED"})]}),c.jsx(Ye,{children:"CDN is not enabled for this storage bucket"})]})});const r=e.cdn.status==="Deployed"?"SUCCESS":e.cdn.status==="InProgress"?"PENDING":"FAILED";return c.jsxs(Ne,{children:[c.jsxs(De,{children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(ku,{className:"h-5 w-5"}),c.jsx(Fe,{children:"CloudFront CDN"})]}),c.jsx(bp,{status:r})]}),c.jsx(Ye,{children:"Global content delivery network for fast file access"})]}),c.jsxs(Le,{className:"space-y-4",children:[c.jsxs("div",{className:"grid gap-4",children:[e.cdn.distributionId&&c.jsxs(c.Fragment,{children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx("span",{className:"text-muted-foreground text-sm",children:"Distribution ID"}),c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("code",{className:"rounded bg-muted px-2 py-1 font-mono text-sm",children:e.cdn.distributionId}),c.jsx(ul,{text:e.cdn.distributionId})]})]}),c.jsx(Bt,{})]}),e.cdn.distributionDomain&&c.jsxs(c.Fragment,{children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx("span",{className:"text-muted-foreground text-sm",children:"CloudFront URL"}),c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsxs("a",{className:"text-blue-600 text-sm hover:underline dark:text-blue-400",href:`https://${e.cdn.distributionDomain}`,rel:"noopener noreferrer",target:"_blank",children:[e.cdn.distributionDomain,c.jsx(Pu,{className:"ml-1 inline h-3 w-3"})]}),c.jsx(ul,{text:`https://${e.cdn.distributionDomain}`})]})]}),c.jsx(Bt,{})]}),e.cdn.customDomain&&c.jsx(c.Fragment,{children:c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx("span",{className:"text-muted-foreground text-sm",children:"Custom Domain"}),c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsxs("a",{className:"text-blue-600 text-sm hover:underline dark:text-blue-400",href:`https://${e.cdn.customDomain}`,rel:"noopener noreferrer",target:"_blank",children:[e.cdn.customDomain,c.jsx(Pu,{className:"ml-1 inline h-3 w-3"})]}),c.jsx(ul,{text:`https://${e.cdn.customDomain}`})]})]})})]}),((s=e.certificate)==null?void 0:s.validationRecords)&&e.certificate.validationRecords.length>0&&e.certificate.status==="PENDING_VALIDATION"&&c.jsxs(fc,{onOpenChange:n,open:t,children:[c.jsx(dc,{asChild:!0,children:c.jsxs(Ee,{className:"w-full justify-between",variant:"ghost",children:[c.jsxs("span",{className:"flex items-center gap-2",children:[c.jsx(ir,{className:"h-4 w-4 text-yellow-500"}),"Certificate DNS Records Required"]}),t?c.jsx("span",{className:"text-xs",children:"Hide"}):c.jsx("span",{className:"text-xs",children:"Show"})]})}),c.jsxs(hc,{className:"mt-2 space-y-2",children:[c.jsxs(In,{children:[c.jsx(ir,{className:"h-4 w-4"}),c.jsx(Xi,{children:"Action Required"}),c.jsx(zn,{children:"Add these DNS records to verify your custom domain certificate"})]}),e.certificate.validationRecords.map((l,f)=>c.jsxs("div",{className:"rounded-lg border bg-muted/50 p-3 font-mono text-xs",children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx("span",{className:"text-muted-foreground",children:l.type}),c.jsx(ul,{text:l.value})]}),c.jsx("div",{className:"mt-1 break-all",children:l.name}),c.jsxs("div",{className:"mt-1 break-all text-muted-foreground",children:["→ ",l.value]})]},f))]})]})]})]})}function Dve({settings:e}){return c.jsxs(Ne,{children:[c.jsxs(De,{children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(Kh,{className:"h-5 w-5"}),c.jsx(Fe,{children:"IAM Role"})]}),c.jsx(bp,{status:"SUCCESS"})]}),c.jsx(Ye,{children:"Role used by your application to access storage"})]}),c.jsx(Le,{children:c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx("span",{className:"text-muted-foreground text-sm",children:"Role ARN"}),c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("code",{className:"max-w-[300px] truncate rounded bg-muted px-2 py-1 font-mono text-xs",children:e.roleArn}),c.jsx(ul,{text:e.roleArn})]})]})})]})}function Pve(){return c.jsxs("div",{className:"space-y-6",children:[c.jsxs(Ne,{children:[c.jsxs(De,{children:[c.jsx(Re,{className:"h-6 w-32"}),c.jsx(Re,{className:"h-4 w-64"})]}),c.jsx(Le,{children:c.jsxs("div",{className:"space-y-4",children:[c.jsx(Re,{className:"h-8 w-full"}),c.jsx(Re,{className:"h-8 w-full"}),c.jsx(Re,{className:"h-8 w-full"})]})})]}),c.jsxs(Ne,{children:[c.jsxs(De,{children:[c.jsx(Re,{className:"h-6 w-32"}),c.jsx(Re,{className:"h-4 w-64"})]}),c.jsx(Le,{children:c.jsxs("div",{className:"space-y-4",children:[c.jsx(Re,{className:"h-8 w-full"}),c.jsx(Re,{className:"h-8 w-full"})]})})]})]})}function kve(){return c.jsxs("div",{className:"flex flex-col items-center justify-center py-12",children:[c.jsx(Tf,{className:"mb-4 h-16 w-16 text-muted-foreground opacity-50"}),c.jsx("h2",{className:"mb-2 font-semibold text-xl",children:"No Storage Configured"}),c.jsxs("p",{className:"mb-6 max-w-md text-center text-muted-foreground",children:["Storage infrastructure has not been deployed yet. Run"," ",c.jsx("code",{className:"rounded bg-muted px-2 py-1 font-mono text-sm",children:"wraps storage init"})," ","to get started."]})]})}function $ve(){const[e,t]=j.useState(null),[n,r]=j.useState(!0),[i,s]=j.useState(null),l=j.useCallback(async()=>{try{r(!0),s(null);const f=sessionStorage.getItem("wraps-auth-token"),d=await fetch(`/api/cdn/settings?token=${f}`);if(!d.ok){if(d.status===404){t(null);return}throw new Error("Failed to fetch storage settings")}const h=await d.json();t(h)}catch(f){s(f instanceof Error?f.message:"An error occurred")}finally{r(!1)}},[]);return j.useEffect(()=>{l()},[l]),n?c.jsx(Pve,{}):i?c.jsxs(In,{variant:"destructive",children:[c.jsx(ir,{className:"h-4 w-4"}),c.jsx(Xi,{children:"Error"}),c.jsx(zn,{children:i})]}):e?c.jsxs("div",{className:"space-y-6",children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{children:[c.jsx("h1",{className:"font-bold text-2xl",children:"Storage Settings"}),c.jsx("p",{className:"text-muted-foreground",children:"Manage your S3 bucket and CloudFront CDN configuration"})]}),c.jsxs(Ee,{onClick:l,size:"sm",variant:"outline",children:[c.jsx(Cf,{className:"mr-2 h-4 w-4"}),"Refresh"]})]}),c.jsx(Mve,{settings:e}),c.jsx(Rve,{settings:e}),c.jsx(Dve,{settings:e})]}):c.jsx(kve,{})}function Lve({children:e,defaultTheme:t="system",storageKey:n="vite-ui-theme",...r}){const[i,s]=j.useState(()=>localStorage.getItem(n)||t);j.useEffect(()=>{const f=window.document.documentElement;if(f.classList.remove("light","dark"),i==="system"){const d=window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light";f.classList.add(d),f.style.colorScheme=d;return}f.classList.add(i),f.style.colorScheme=i},[i]);const l={theme:i,setTheme:f=>{localStorage.setItem(n,f),s(f)}};return c.jsx(OI.Provider,{...r,value:l,children:e})}function Ive({...e}){return c.jsx("nav",{"aria-label":"breadcrumb","data-slot":"breadcrumb",...e})}function zve({className:e,...t}){return c.jsx("ol",{className:ve("flex flex-wrap items-center gap-1.5 break-words text-muted-foreground text-sm sm:gap-2.5",e),"data-slot":"breadcrumb-list",...t})}function Bve({className:e,...t}){return c.jsx("li",{className:ve("inline-flex items-center gap-1.5",e),"data-slot":"breadcrumb-item",...t})}function qve({className:e,...t}){return c.jsx("span",{"aria-current":"page","aria-disabled":"true",className:ve("font-normal text-foreground",e),"data-slot":"breadcrumb-page",role:"link",...t})}var Uve=(e,t,n,r,i,s,l,f)=>{let d=document.documentElement,h=["light","dark"];function v(b){(Array.isArray(e)?e:[e]).forEach(O=>{let S=O==="class",x=S&&s?i.map(E=>s[E]||E):i;S?(d.classList.remove(...x),d.classList.add(s&&s[b]?s[b]:b)):d.setAttribute(O,b)}),p(b)}function p(b){f&&h.includes(b)&&(d.style.colorScheme=b)}function g(){return window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}if(r)v(r);else try{let b=localStorage.getItem(t)||n,O=l&&b==="system"?g():b;v(O)}catch{}},Hve=j.createContext(void 0),Fve={setTheme:e=>{},themes:[]},Gve=()=>{var e;return(e=j.useContext(Hve))!=null?e:Fve};j.memo(({forcedTheme:e,storageKey:t,attribute:n,enableSystem:r,enableColorScheme:i,defaultTheme:s,value:l,themes:f,nonce:d,scriptProps:h})=>{let v=JSON.stringify([n,t,s,e,f,l,r,i]).slice(1,-1);return j.createElement("script",{...h,suppressHydrationWarning:!0,nonce:typeof window>"u"?d:"",dangerouslySetInnerHTML:{__html:`(${Uve.toString()})(${v})`}})});const Vve=({...e})=>{const{theme:t="system"}=Gve();return c.jsx(bme,{className:"toaster group",icons:{success:c.jsx(Zi,{className:"size-4"}),info:c.jsx(BH,{className:"size-4"}),warning:c.jsx(WH,{className:"size-4"}),error:c.jsx(HH,{className:"size-4"}),loading:c.jsx(ol,{className:"size-4 animate-spin"})},style:{"--normal-bg":"var(--popover)","--normal-text":"var(--popover-foreground)","--normal-border":"var(--border)","--border-radius":"var(--radius)"},theme:t,...e})};function Yve(){const e=ba(),[t,n]=j.useState(!1);j.useEffect(()=>{let i=sessionStorage.getItem("wraps-auth-token");i||(i=new URLSearchParams(window.location.search).get("token"),i&&sessionStorage.setItem("wraps-auth-token",i)),n(!0)},[]),j.useEffect(()=>{document.cookie="sidebar_state=; path=/; max-age=0"},[]);const r=()=>{if(e.pathname.startsWith("/email/")&&e.pathname!=="/email/metrics"&&e.pathname!=="/email/settings")return"Email Details";if(e.pathname.startsWith("/sms/")&&e.pathname!=="/sms/metrics"&&e.pathname!=="/sms/settings")return"SMS Details";if(e.pathname.startsWith("/cdn/")&&e.pathname!=="/cdn/metrics"&&e.pathname!=="/cdn/settings")return"File Details";switch(e.pathname){case"/":case"/email":return"Emails";case"/email/metrics":return"Email Metrics";case"/email/settings":return"Email Settings";case"/sms":return"SMS Messages";case"/sms/metrics":return"SMS Metrics";case"/sms/settings":return"SMS Settings";case"/cdn":return"CDN";case"/cdn/metrics":return"CDN Metrics";case"/cdn/settings":return"CDN Settings";default:return"Emails"}};return c.jsxs(bI,{defaultOpen:!1,children:[c.jsx(_W,{}),c.jsxs(wI,{children:[c.jsxs("header",{className:"sticky top-0 flex shrink-0 items-center gap-2 border-b bg-background p-4",children:[c.jsx(xI,{className:"-ml-1"}),c.jsx(Bt,{className:"mr-2 data-[orientation=vertical]:h-4",orientation:"vertical"}),c.jsx(Ive,{children:c.jsx(zve,{children:c.jsx(Bve,{children:c.jsx(qve,{children:r()})})})})]}),c.jsx("div",{className:"flex flex-1 flex-col gap-6 p-6",children:t?c.jsxs(WU,{children:[c.jsx(Qn,{element:c.jsx(VU,{replace:!0,to:"/email"}),path:"/"}),c.jsx(Qn,{element:c.jsx(jK,{}),path:"/email"}),c.jsx(Qn,{element:c.jsx(zW,{}),path:"/email/:id"}),c.jsx(Qn,{element:c.jsx(Vhe,{}),path:"/email/metrics"}),c.jsx(Qn,{element:c.jsx(npe,{}),path:"/email/settings"}),c.jsx(Qn,{element:c.jsx(spe,{}),path:"/sms"}),c.jsx(Qn,{element:c.jsx(ope,{}),path:"/sms/:id"}),c.jsx(Qn,{element:c.jsx(lpe,{}),path:"/sms/metrics"}),c.jsx(Qn,{element:c.jsx(hpe,{}),path:"/sms/settings"}),c.jsx(Qn,{element:c.jsx(Ove,{}),path:"/cdn"}),c.jsx(Qn,{element:c.jsx(Cve,{}),path:"/cdn/metrics"}),c.jsx(Qn,{element:c.jsx($ve,{}),path:"/cdn/settings"})]}):c.jsx("div",{className:"flex items-center justify-center p-8",children:c.jsx("div",{className:"text-muted-foreground",children:"Loading..."})})})]})]})}function Wve(){return c.jsx(Lve,{defaultTheme:"system",storageKey:"console-ui-theme",children:c.jsxs(yH,{children:[c.jsx(Yve,{}),c.jsx(Vve,{})]})})}Xq.createRoot(document.getElementById("root")).render(c.jsx(j.StrictMode,{children:c.jsx(Wve,{})}));
|