diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..7e34137 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,2 @@ +manager/dist/assets/*.js binary +manager/dist/assets/*.js linguist-generated=true \ No newline at end of file diff --git a/manager/dist/assets/index-LD46dRLh.js b/manager/dist/assets/index-LD46dRLh.js index 88252c6..4db5495 100644 --- a/manager/dist/assets/index-LD46dRLh.js +++ b/manager/dist/assets/index-LD46dRLh.js @@ -347,4 +347,4 @@ For more information, see https://radix-ui.com/primitives/docs/components/${n.do --nojs-bg: black !important; --nojs-fg: white !important; } -}`,TS="Popover",[OS]=Ts(TS,[Gu]),Wu=Gu(),[cL,Qr]=OS(TS),jS="PopoverAnchor",wz=b.forwardRef((t,n)=>{const{__scopePopover:r,...s}=t,i=Qr(jS,r),c=Wu(r),{onCustomAnchorAdd:u,onCustomAnchorRemove:f}=i;return b.useEffect(()=>(u(),()=>f()),[u,f]),h.jsx(Jh,{...c,...s,ref:n})});wz.displayName=jS;var kS="PopoverTrigger",Sz=b.forwardRef((t,n)=>{const{__scopePopover:r,...s}=t,i=Qr(kS,r),c=Wu(r),u=Wt(n,i.triggerRef),f=h.jsx(kt.button,{type:"button","aria-haspopup":"dialog","aria-expanded":i.open,"aria-controls":i.contentId,"data-state":US(i.open),...s,ref:u,onClick:qe(t.onClick,i.onOpenToggle)});return i.hasCustomAnchor?f:h.jsx(Jh,{asChild:!0,...c,children:f})});Sz.displayName=kS;var mp="PopoverPortal",[Ez,_z]=OS(mp,{forceMount:void 0}),MS=t=>{const{__scopePopover:n,forceMount:r,children:s,container:i}=t,c=Qr(mp,n);return h.jsx(Ez,{scope:n,forceMount:r,children:h.jsx(za,{present:r||c.open,children:h.jsx(Bu,{asChild:!0,container:i,children:s})})})};MS.displayName=mp;var Uo="PopoverContent",DS=b.forwardRef((t,n)=>{const r=_z(Uo,t.__scopePopover),{forceMount:s=r.forceMount,...i}=t,c=Qr(Uo,t.__scopePopover);return h.jsx(za,{present:s||c.open,children:c.modal?h.jsx(Nz,{...i,ref:n}):h.jsx(Rz,{...i,ref:n})})});DS.displayName=Uo;var Cz=Do("PopoverContent.RemoveScroll"),Nz=b.forwardRef((t,n)=>{const r=Qr(Uo,t.__scopePopover),s=b.useRef(null),i=Wt(n,s),c=b.useRef(!1);return b.useEffect(()=>{const u=s.current;if(u)return Vh(u)},[]),h.jsx(Hu,{as:Cz,allowPinchZoom:!0,children:h.jsx(zS,{...t,ref:i,trapFocus:r.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:qe(t.onCloseAutoFocus,u=>{var f;u.preventDefault(),c.current||(f=r.triggerRef.current)==null||f.focus()}),onPointerDownOutside:qe(t.onPointerDownOutside,u=>{const f=u.detail.originalEvent,g=f.button===0&&f.ctrlKey===!0,p=f.button===2||g;c.current=p},{checkForDefaultPrevented:!1}),onFocusOutside:qe(t.onFocusOutside,u=>u.preventDefault(),{checkForDefaultPrevented:!1})})})}),Rz=b.forwardRef((t,n)=>{const r=Qr(Uo,t.__scopePopover),s=b.useRef(!1),i=b.useRef(!1);return h.jsx(zS,{...t,ref:n,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:c=>{var u,f;(u=t.onCloseAutoFocus)==null||u.call(t,c),c.defaultPrevented||(s.current||(f=r.triggerRef.current)==null||f.focus(),c.preventDefault()),s.current=!1,i.current=!1},onInteractOutside:c=>{var g,p;(g=t.onInteractOutside)==null||g.call(t,c),c.defaultPrevented||(s.current=!0,c.detail.originalEvent.type==="pointerdown"&&(i.current=!0));const u=c.target;((p=r.triggerRef.current)==null?void 0:p.contains(u))&&c.preventDefault(),c.detail.originalEvent.type==="focusin"&&i.current&&c.preventDefault()}})}),zS=b.forwardRef((t,n)=>{const{__scopePopover:r,trapFocus:s,onOpenAutoFocus:i,onCloseAutoFocus:c,disableOutsidePointerEvents:u,onEscapeKeyDown:f,onPointerDownOutside:g,onFocusOutside:p,onInteractOutside:y,...v}=t,w=Qr(Uo,r),C=Wu(r);return Hh(),h.jsx(Uu,{asChild:!0,loop:!0,trapped:s,onMountAutoFocus:i,onUnmountAutoFocus:c,children:h.jsx(Lu,{asChild:!0,disableOutsidePointerEvents:u,onInteractOutside:y,onEscapeKeyDown:f,onPointerDownOutside:g,onFocusOutside:p,onDismiss:()=>w.onOpenChange(!1),children:h.jsx(Ow,{"data-state":US(w.open),role:"dialog",id:w.contentId,...C,...v,ref:n,style:{...v.style,"--radix-popover-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-popover-content-available-width":"var(--radix-popper-available-width)","--radix-popover-content-available-height":"var(--radix-popper-available-height)","--radix-popover-trigger-width":"var(--radix-popper-anchor-width)","--radix-popover-trigger-height":"var(--radix-popper-anchor-height)"}})})})}),LS="PopoverClose",Az=b.forwardRef((t,n)=>{const{__scopePopover:r,...s}=t,i=Qr(LS,r);return h.jsx(kt.button,{type:"button",...s,ref:n,onClick:qe(t.onClick,()=>i.onOpenChange(!1))})});Az.displayName=LS;var Tz="PopoverArrow",Oz=b.forwardRef((t,n)=>{const{__scopePopover:r,...s}=t,i=Wu(r);return h.jsx(jw,{...i,...s,ref:n})});Oz.displayName=Tz;function US(t){return t?"open":"closed"}var jz=MS,BS=DS;const hp=b.createContext(null);hp.displayName="PanelGroupContext";const qn={group:"data-panel-group",groupDirection:"data-panel-group-direction",groupId:"data-panel-group-id",panel:"data-panel",panelCollapsible:"data-panel-collapsible",panelId:"data-panel-id",panelSize:"data-panel-size",resizeHandleId:"data-panel-resize-handle-id"},pp=10,ko=b.useLayoutEffect,Yx=Nu.useId,kz=typeof Yx=="function"?Yx:()=>null;let Mz=0;function PS(t=null){const n=kz(),r=b.useRef(t||n||null);return r.current===null&&(r.current=""+Mz++),t??r.current}function HS({children:t,className:n="",collapsedSize:r,collapsible:s,defaultSize:i,forwardedRef:c,id:u,maxSize:f,minSize:g,onCollapse:p,onExpand:y,onResize:v,order:w,style:C,tagName:S="div",..._}){const E=b.useContext(hp);if(E===null)throw Error("Panel components must be rendered within a PanelGroup container");const{collapsePanel:R,expandPanel:k,getPanelSize:A,getPanelStyle:D,groupId:H,isPanelCollapsed:$,reevaluatePanelConstraints:U,registerPanel:F,resizePanel:de,unregisterPanel:fe}=E,me=PS(u),se=b.useRef({callbacks:{onCollapse:p,onExpand:y,onResize:v},constraints:{collapsedSize:r,collapsible:s,defaultSize:i,maxSize:f,minSize:g},id:me,idIsFromProps:u!==void 0,order:w});b.useRef({didLogMissingDefaultSizeWarning:!1}),ko(()=>{const{callbacks:he,constraints:ve}=se.current,T={...ve};se.current.id=me,se.current.idIsFromProps=u!==void 0,se.current.order=w,he.onCollapse=p,he.onExpand=y,he.onResize=v,ve.collapsedSize=r,ve.collapsible=s,ve.defaultSize=i,ve.maxSize=f,ve.minSize=g,(T.collapsedSize!==ve.collapsedSize||T.collapsible!==ve.collapsible||T.maxSize!==ve.maxSize||T.minSize!==ve.minSize)&&U(se.current,T)}),ko(()=>{const he=se.current;return F(he),()=>{fe(he)}},[w,me,F,fe]),b.useImperativeHandle(c,()=>({collapse:()=>{R(se.current)},expand:he=>{k(se.current,he)},getId(){return me},getSize(){return A(se.current)},isCollapsed(){return $(se.current)},isExpanded(){return!$(se.current)},resize:he=>{de(se.current,he)}}),[R,k,A,$,me,de]);const G=D(se.current,i);return b.createElement(S,{..._,children:t,className:n,id:me,style:{...G,...C},[qn.groupId]:H,[qn.panel]:"",[qn.panelCollapsible]:s||void 0,[qn.panelId]:me,[qn.panelSize]:parseFloat(""+G.flexGrow).toFixed(1)})}const Dz=b.forwardRef((t,n)=>b.createElement(HS,{...t,forwardedRef:n}));HS.displayName="Panel";Dz.displayName="forwardRef(Panel)";function VS(t){return t.type==="keydown"}function IS(t){return t.type.startsWith("pointer")}function qS(t){return t.type.startsWith("mouse")}function zz(t){if(IS(t)){if(t.isPrimary)return{x:t.clientX,y:t.clientY}}else if(qS(t))return{x:t.clientX,y:t.clientY};return{x:1/0,y:1/0}}function Lz(){if(typeof matchMedia=="function")return matchMedia("(pointer:coarse)").matches?"coarse":"fine"}const Uz=1,Bz=2,Pz=4,Hz=8;Lz();let Vz=new Map;function Hm(t,n){Vz.set(t,n)}function Iz(){const[t,n]=b.useState(0);return b.useCallback(()=>n(r=>r+1),[])}function ot(t,n){if(!t)throw console.error(n),Error(n)}function Ns(t,n,r=pp){return t.toFixed(r)===n.toFixed(r)?0:t>n?1:-1}function ar(t,n,r=pp){return Ns(t,n,r)===0}function Vn(t,n,r){return Ns(t,n,r)===0}function qz(t,n,r){if(t.length!==n.length)return!1;for(let s=0;s0&&(t=t<0?0-R:R)}}}{const v=t<0?f:g,w=r[v];ot(w,`No panel constraints found for index ${v}`);const{collapsedSize:C=0,collapsible:S,minSize:_=0}=w;if(S){const E=n[v];if(ot(E!=null,`Previous layout not found for panel index ${v}`),Vn(E,_)){const R=E-C;Ns(R,Math.abs(t))>0&&(t=t<0?0-R:R)}}}}{const v=t<0?1:-1;let w=t<0?g:f,C=0;for(;;){const _=n[w];ot(_!=null,`Previous layout not found for panel index ${w}`);const R=Ao({panelConstraints:r,panelIndex:w,size:100})-_;if(C+=R,w+=v,w<0||w>=r.length)break}const S=Math.min(Math.abs(t),Math.abs(C));t=t<0?0-S:S}{let w=t<0?f:g;for(;w>=0&&w=0))break;t<0?w--:w++}}if(qz(i,u))return i;{const v=t<0?g:f,w=n[v];ot(w!=null,`Previous layout not found for panel index ${v}`);const C=w+p,S=Ao({panelConstraints:r,panelIndex:v,size:C});if(u[v]=S,!Vn(S,C)){let _=C-S,R=t<0?g:f;for(;R>=0&&R0?R--:R++}}}const y=u.reduce((v,w)=>w+v,0);return Vn(y,100)?u:i}function Fz({layout:t,panelsArray:n,pivotIndices:r}){let s=0,i=100,c=0,u=0;const f=r[0];ot(f!=null,"No pivot index found"),n.forEach((v,w)=>{const{constraints:C}=v,{maxSize:S=100,minSize:_=0}=C;w===f?(s=_,i=S):(c+=_,u+=S)});const g=Math.min(i,100-c),p=Math.max(s,100-u),y=t[f];return{valueMax:g,valueMin:p,valueNow:y}}function hu(t,n=document){return Array.from(n.querySelectorAll(`[${qn.resizeHandleId}][data-panel-group-id="${t}"]`))}function $z(t,n,r=document){const i=hu(t,r).findIndex(c=>c.getAttribute(qn.resizeHandleId)===n);return i??null}function FS(t,n,r){const s=$z(t,n,r);return s!=null?[s,s+1]:[-1,-1]}function Gz(t){return t instanceof HTMLElement?!0:typeof t=="object"&&t!==null&&"tagName"in t&&"getAttribute"in t}function $S(t,n=document){if(Gz(n)&&n.dataset.panelGroupId==t)return n;const r=n.querySelector(`[data-panel-group][data-panel-group-id="${t}"]`);return r||null}function gp(t,n=document){const r=n.querySelector(`[${qn.resizeHandleId}="${t}"]`);return r||null}function Yz(t,n,r,s=document){var i,c,u,f;const g=gp(n,s),p=hu(t,s),y=g?p.indexOf(g):-1,v=(i=(c=r[y])===null||c===void 0?void 0:c.id)!==null&&i!==void 0?i:null,w=(u=(f=r[y+1])===null||f===void 0?void 0:f.id)!==null&&u!==void 0?u:null;return[v,w]}function Zz({committedValuesRef:t,eagerValuesRef:n,groupId:r,layout:s,panelDataArray:i,panelGroupElement:c,setLayout:u}){b.useRef({didWarnAboutMissingResizeHandle:!1}),ko(()=>{if(!c)return;const f=hu(r,c);for(let g=0;g{f.forEach((g,p)=>{g.removeAttribute("aria-controls"),g.removeAttribute("aria-valuemax"),g.removeAttribute("aria-valuemin"),g.removeAttribute("aria-valuenow")})}},[r,s,i,c]),b.useEffect(()=>{if(!c)return;const f=n.current;ot(f,"Eager values not found");const{panelDataArray:g}=f,p=$S(r,c);ot(p!=null,`No group found for id "${r}"`);const y=hu(r,c);ot(y,`No resize handles found for group id "${r}"`);const v=y.map(w=>{const C=w.getAttribute(qn.resizeHandleId);ot(C,"Resize handle element has no handle id attribute");const[S,_]=Yz(r,C,g,c);if(S==null||_==null)return()=>{};const E=R=>{if(!R.defaultPrevented)switch(R.key){case"Enter":{R.preventDefault();const k=g.findIndex(A=>A.id===S);if(k>=0){const A=g[k];ot(A,`No panel data found for index ${k}`);const D=s[k],{collapsedSize:H=0,collapsible:$,minSize:U=0}=A.constraints;if(D!=null&&$){const F=Zi({delta:Vn(D,H)?U-H:H-D,initialLayout:s,panelConstraints:g.map(de=>de.constraints),pivotIndices:FS(r,C,c),prevLayout:s,trigger:"keyboard"});s!==F&&u(F)}}break}}};return w.addEventListener("keydown",E),()=>{w.removeEventListener("keydown",E)}});return()=>{v.forEach(w=>w())}},[c,t,n,r,s,i,u])}function Zx(t,n){if(t.length!==n.length)return!1;for(let r=0;rc.constraints);let s=0,i=100;for(let c=0;c{const c=t[i];ot(c,`Panel data not found for index ${i}`);const{callbacks:u,constraints:f,id:g}=c,{collapsedSize:p=0,collapsible:y}=f,v=r[g];if(v==null||s!==v){r[g]=s;const{onCollapse:w,onExpand:C,onResize:S}=u;S&&S(s,v),y&&(w||C)&&(C&&(v==null||ar(v,p))&&!ar(s,p)&&C(),w&&(v==null||!ar(v,p))&&ar(s,p)&&w())}})}function qc(t,n){if(t.length!==n.length)return!1;for(let r=0;r{r!==null&&clearTimeout(r),r=setTimeout(()=>{t(...i)},n)}}function Xx(t){try{if(typeof localStorage<"u")t.getItem=n=>localStorage.getItem(n),t.setItem=(n,r)=>{localStorage.setItem(n,r)};else throw new Error("localStorage not supported in this environment")}catch(n){console.error(n),t.getItem=()=>null,t.setItem=()=>{}}}function YS(t){return`react-resizable-panels:${t}`}function ZS(t){return t.map(n=>{const{constraints:r,id:s,idIsFromProps:i,order:c}=n;return i?s:c?`${c}:${JSON.stringify(r)}`:JSON.stringify(r)}).sort((n,r)=>n.localeCompare(r)).join(",")}function XS(t,n){try{const r=YS(t),s=n.getItem(r);if(s){const i=JSON.parse(s);if(typeof i=="object"&&i!=null)return i}}catch{}return null}function e3(t,n,r){var s,i;const c=(s=XS(t,r))!==null&&s!==void 0?s:{},u=ZS(n);return(i=c[u])!==null&&i!==void 0?i:null}function t3(t,n,r,s,i){var c;const u=YS(t),f=ZS(n),g=(c=XS(t,i))!==null&&c!==void 0?c:{};g[f]={expandToSizes:Object.fromEntries(r.entries()),layout:s};try{i.setItem(u,JSON.stringify(g))}catch(p){console.error(p)}}function Kx({layout:t,panelConstraints:n}){const r=[...t],s=r.reduce((c,u)=>c+u,0);if(r.length!==n.length)throw Error(`Invalid ${n.length} panel layout: ${r.map(c=>`${c}%`).join(", ")}`);if(!Vn(s,100)&&r.length>0)for(let c=0;c(Xx(Xi),Xi.getItem(t)),setItem:(t,n)=>{Xx(Xi),Xi.setItem(t,n)}},Qx={};function KS({autoSaveId:t=null,children:n,className:r="",direction:s,forwardedRef:i,id:c=null,onLayout:u=null,keyboardResizeBy:f=null,storage:g=Xi,style:p,tagName:y="div",...v}){const w=PS(c),C=b.useRef(null),[S,_]=b.useState(null),[E,R]=b.useState([]),k=Iz(),A=b.useRef({}),D=b.useRef(new Map),H=b.useRef(0),$=b.useRef({autoSaveId:t,direction:s,dragState:S,id:w,keyboardResizeBy:f,onLayout:u,storage:g}),U=b.useRef({layout:E,panelDataArray:[],panelDataArrayChanged:!1});b.useRef({didLogIdAndOrderWarning:!1,didLogPanelConstraintsWarning:!1,prevPanelIds:[]}),b.useImperativeHandle(i,()=>({getId:()=>$.current.id,getLayout:()=>{const{layout:L}=U.current;return L},setLayout:L=>{const{onLayout:Y}=$.current,{layout:J,panelDataArray:ie}=U.current,pe=Kx({layout:L,panelConstraints:ie.map(Q=>Q.constraints)});Zx(J,pe)||(R(pe),U.current.layout=pe,Y&&Y(pe),_o(ie,pe,A.current))}}),[]),ko(()=>{$.current.autoSaveId=t,$.current.direction=s,$.current.dragState=S,$.current.id=w,$.current.onLayout=u,$.current.storage=g}),Zz({committedValuesRef:$,eagerValuesRef:U,groupId:w,layout:E,panelDataArray:U.current.panelDataArray,setLayout:R,panelGroupElement:C.current}),b.useEffect(()=>{const{panelDataArray:L}=U.current;if(t){if(E.length===0||E.length!==L.length)return;let Y=Qx[t];Y==null&&(Y=Jz(t3,n3),Qx[t]=Y);const J=[...L],ie=new Map(D.current);Y(t,J,ie,E,g)}},[t,E,g]),b.useEffect(()=>{});const F=b.useCallback(L=>{const{onLayout:Y}=$.current,{layout:J,panelDataArray:ie}=U.current;if(L.constraints.collapsible){const pe=ie.map(et=>et.constraints),{collapsedSize:Q=0,panelSize:oe,pivotIndices:Re}=bs(ie,L,J);if(ot(oe!=null,`Panel size not found for panel "${L.id}"`),!ar(oe,Q)){D.current.set(L.id,oe);const Me=No(ie,L)===ie.length-1?oe-Q:Q-oe,ze=Zi({delta:Me,initialLayout:J,panelConstraints:pe,pivotIndices:Re,prevLayout:J,trigger:"imperative-api"});qc(J,ze)||(R(ze),U.current.layout=ze,Y&&Y(ze),_o(ie,ze,A.current))}}},[]),de=b.useCallback((L,Y)=>{const{onLayout:J}=$.current,{layout:ie,panelDataArray:pe}=U.current;if(L.constraints.collapsible){const Q=pe.map(be=>be.constraints),{collapsedSize:oe=0,panelSize:Re=0,minSize:et=0,pivotIndices:Me}=bs(pe,L,ie),ze=Y??et;if(ar(Re,oe)){const be=D.current.get(L.id),je=be!=null&&be>=ze?be:ze,ht=No(pe,L)===pe.length-1?Re-je:je-Re,Qe=Zi({delta:ht,initialLayout:ie,panelConstraints:Q,pivotIndices:Me,prevLayout:ie,trigger:"imperative-api"});qc(ie,Qe)||(R(Qe),U.current.layout=Qe,J&&J(Qe),_o(pe,Qe,A.current))}}},[]),fe=b.useCallback(L=>{const{layout:Y,panelDataArray:J}=U.current,{panelSize:ie}=bs(J,L,Y);return ot(ie!=null,`Panel size not found for panel "${L.id}"`),ie},[]),me=b.useCallback((L,Y)=>{const{panelDataArray:J}=U.current,ie=No(J,L);return Wz({defaultSize:Y,dragState:S,layout:E,panelData:J,panelIndex:ie})},[S,E]),se=b.useCallback(L=>{const{layout:Y,panelDataArray:J}=U.current,{collapsedSize:ie=0,collapsible:pe,panelSize:Q}=bs(J,L,Y);return ot(Q!=null,`Panel size not found for panel "${L.id}"`),pe===!0&&ar(Q,ie)},[]),G=b.useCallback(L=>{const{layout:Y,panelDataArray:J}=U.current,{collapsedSize:ie=0,collapsible:pe,panelSize:Q}=bs(J,L,Y);return ot(Q!=null,`Panel size not found for panel "${L.id}"`),!pe||Ns(Q,ie)>0},[]),he=b.useCallback(L=>{const{panelDataArray:Y}=U.current;Y.push(L),Y.sort((J,ie)=>{const pe=J.order,Q=ie.order;return pe==null&&Q==null?0:pe==null?-1:Q==null?1:pe-Q}),U.current.panelDataArrayChanged=!0,k()},[k]);ko(()=>{if(U.current.panelDataArrayChanged){U.current.panelDataArrayChanged=!1;const{autoSaveId:L,onLayout:Y,storage:J}=$.current,{layout:ie,panelDataArray:pe}=U.current;let Q=null;if(L){const Re=e3(L,pe,J);Re&&(D.current=new Map(Object.entries(Re.expandToSizes)),Q=Re.layout)}Q==null&&(Q=Qz({panelDataArray:pe}));const oe=Kx({layout:Q,panelConstraints:pe.map(Re=>Re.constraints)});Zx(ie,oe)||(R(oe),U.current.layout=oe,Y&&Y(oe),_o(pe,oe,A.current))}}),ko(()=>{const L=U.current;return()=>{L.layout=[]}},[]);const ve=b.useCallback(L=>{let Y=!1;const J=C.current;return J&&window.getComputedStyle(J,null).getPropertyValue("direction")==="rtl"&&(Y=!0),function(pe){pe.preventDefault();const Q=C.current;if(!Q)return()=>null;const{direction:oe,dragState:Re,id:et,keyboardResizeBy:Me,onLayout:ze}=$.current,{layout:be,panelDataArray:je}=U.current,{initialLayout:at}=Re??{},ht=FS(et,L,Q);let Qe=Kz(pe,L,oe,Re,Me,Q);const Pe=oe==="horizontal";Pe&&Y&&(Qe=-Qe);const Tt=je.map(B=>B.constraints),Zt=Zi({delta:Qe,initialLayout:at??be,panelConstraints:Tt,pivotIndices:ht,prevLayout:be,trigger:VS(pe)?"keyboard":"mouse-or-touch"}),O=!qc(be,Zt);(IS(pe)||qS(pe))&&H.current!=Qe&&(H.current=Qe,!O&&Qe!==0?Pe?Hm(L,Qe<0?Uz:Bz):Hm(L,Qe<0?Pz:Hz):Hm(L,0)),O&&(R(Zt),U.current.layout=Zt,ze&&ze(Zt),_o(je,Zt,A.current))}},[]),T=b.useCallback((L,Y)=>{const{onLayout:J}=$.current,{layout:ie,panelDataArray:pe}=U.current,Q=pe.map(be=>be.constraints),{panelSize:oe,pivotIndices:Re}=bs(pe,L,ie);ot(oe!=null,`Panel size not found for panel "${L.id}"`);const Me=No(pe,L)===pe.length-1?oe-Y:Y-oe,ze=Zi({delta:Me,initialLayout:ie,panelConstraints:Q,pivotIndices:Re,prevLayout:ie,trigger:"imperative-api"});qc(ie,ze)||(R(ze),U.current.layout=ze,J&&J(ze),_o(pe,ze,A.current))},[]),K=b.useCallback((L,Y)=>{const{layout:J,panelDataArray:ie}=U.current,{collapsedSize:pe=0,collapsible:Q}=Y,{collapsedSize:oe=0,collapsible:Re,maxSize:et=100,minSize:Me=0}=L.constraints,{panelSize:ze}=bs(ie,L,J);ze!=null&&(Q&&Re&&ar(ze,pe)?ar(pe,oe)||T(L,oe):zeet&&T(L,et))},[T]),te=b.useCallback((L,Y)=>{const{direction:J}=$.current,{layout:ie}=U.current;if(!C.current)return;const pe=gp(L,C.current);ot(pe,`Drag handle element not found for id "${L}"`);const Q=GS(J,Y);_({dragHandleId:L,dragHandleRect:pe.getBoundingClientRect(),initialCursorPosition:Q,initialLayout:ie})},[]),le=b.useCallback(()=>{_(null)},[]),ne=b.useCallback(L=>{const{panelDataArray:Y}=U.current,J=No(Y,L);J>=0&&(Y.splice(J,1),delete A.current[L.id],U.current.panelDataArrayChanged=!0,k())},[k]),j=b.useMemo(()=>({collapsePanel:F,direction:s,dragState:S,expandPanel:de,getPanelSize:fe,getPanelStyle:me,groupId:w,isPanelCollapsed:se,isPanelExpanded:G,reevaluatePanelConstraints:K,registerPanel:he,registerResizeHandle:ve,resizePanel:T,startDragging:te,stopDragging:le,unregisterPanel:ne,panelGroupElement:C.current}),[F,S,s,de,fe,me,w,se,G,K,he,ve,T,te,le,ne]),X={display:"flex",flexDirection:s==="horizontal"?"row":"column",height:"100%",overflow:"hidden",width:"100%"};return b.createElement(hp.Provider,{value:j},b.createElement(y,{...v,children:n,className:r,id:c,ref:C,style:{...X,...p},[qn.group]:"",[qn.groupDirection]:s,[qn.groupId]:w}))}const a3=b.forwardRef((t,n)=>b.createElement(KS,{...t,forwardedRef:n}));KS.displayName="PanelGroup";a3.displayName="forwardRef(PanelGroup)";function No(t,n){return t.findIndex(r=>r===n||r.id===n.id)}function bs(t,n,r){const s=No(t,n),c=s===t.length-1?[s-1,s]:[s,s+1],u=r[s];return{...n.constraints,panelSize:u,pivotIndices:c}}var r3=(t,n,r,s,i,c,u,f)=>{let g=document.documentElement,p=["light","dark"];function y(C){(Array.isArray(t)?t:[t]).forEach(S=>{let _=S==="class",E=_&&c?i.map(R=>c[R]||R):i;_?(g.classList.remove(...E),g.classList.add(c&&c[C]?c[C]:C)):g.setAttribute(S,C)}),v(C)}function v(C){f&&p.includes(C)&&(g.style.colorScheme=C)}function w(){return window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}if(s)y(s);else try{let C=localStorage.getItem(n)||r,S=u&&C==="system"?w():C;y(S)}catch{}};b.createContext(void 0);b.memo(({forcedTheme:t,storageKey:n,attribute:r,enableSystem:s,enableColorScheme:i,defaultTheme:c,value:u,themes:f,nonce:g,scriptProps:p})=>{let y=JSON.stringify([r,n,c,t,f,u,s,i]).slice(1,-1);return b.createElement("script",{...p,suppressHydrationWarning:!0,nonce:typeof window>"u"?g:"",dangerouslySetInnerHTML:{__html:`(${r3.toString()})(${y})`}})});function Jt(...t){return a1(Oh(t))}var s3=Ph("relative w-full rounded-lg border px-4 py-3 text-sm grid has-[>svg]:grid-cols-[calc(var(--spacing)*4)_1fr] grid-cols-[0_1fr] has-[>svg]:gap-x-3 gap-y-0.5 items-start [&>svg]:size-4 [&>svg]:translate-y-0.5 [&>svg]:text-current",{variants:{variant:{default:"bg-card text-card-foreground",destructive:"text-destructive bg-card [&>svg]:text-current *:data-[slot=alert-description]:text-destructive/90"}},defaultVariants:{variant:"default"}});function o3({className:t,variant:n,...r}){return h.jsx("div",{"data-slot":"alert",role:"alert",className:Jt(s3({variant:n}),t),...r})}function i3({className:t,...n}){return h.jsx("div",{"data-slot":"alert-title",className:Jt("col-start-2 line-clamp-1 min-h-4 font-medium tracking-tight",t),...n})}function l3({className:t,...n}){return h.jsx("div",{"data-slot":"alert-description",className:Jt("text-muted-foreground col-start-2 grid justify-items-start gap-1 text-sm [&_p]:leading-relaxed",t),...n})}var c3=Ph("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",{variants:{variant:{default:"bg-primary text-primary-foreground shadow-xs hover:bg-primary/90",destructive:"bg-destructive text-white shadow-xs hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",outline:"border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:bg-input/30 dark:border-input dark:hover:bg-input/50",secondary:"bg-secondary text-secondary-foreground shadow-xs hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-9 px-4 py-2 has-[>svg]:px-3",sm:"h-8 rounded-md gap-1.5 px-3 has-[>svg]:px-2.5",lg:"h-10 rounded-md px-6 has-[>svg]:px-4",icon:"size-9"}},defaultVariants:{variant:"default",size:"default"}}),ut=b.forwardRef(({className:t,variant:n,size:r,asChild:s=!1,...i},c)=>{const u=s?lw:"button";return h.jsx(u,{className:Jt(c3({variant:n,size:r,className:t})),ref:c,...i})});ut.displayName="Button";var u3=Ph("inline-flex items-center justify-center rounded-md border px-2 py-0.5 text-xs font-medium w-fit whitespace-nowrap shrink-0 [&>svg]:size-3 gap-1 [&>svg]:pointer-events-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive transition-[color,box-shadow] overflow-hidden",{variants:{variant:{default:"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 [a&]:hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",outline:"text-foreground [a&]:hover:bg-accent [a&]:hover:text-accent-foreground"}},defaultVariants:{variant:"default"}});function pu({className:t,variant:n,asChild:r=!1,...s}){const i=r?lw:"span";return h.jsx(i,{"data-slot":"badge",className:Jt(u3({variant:n}),t),...s})}function d3({className:t,...n}){return h.jsx("div",{"data-slot":"card",className:Jt("bg-card text-card-foreground flex flex-col gap-6 rounded-xl border py-6 shadow-sm",t),...n})}function f3({className:t,...n}){return h.jsx("div",{"data-slot":"card-content",className:Jt("px-6",t),...n})}b.createContext(null);b.createContext(null);function gu({...t}){return h.jsx(yk,{"data-slot":"dialog",...t})}function m3({...t}){return h.jsx(bk,{"data-slot":"dialog-portal",...t})}function h3({className:t,...n}){return h.jsx(rw,{"data-slot":"dialog-overlay",className:Jt("data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50",t),...n})}function vu({className:t,children:n,showCloseButton:r=!0,...s}){return h.jsxs(m3,{"data-slot":"dialog-portal",children:[h.jsx(h3,{}),h.jsxs(sw,{"data-slot":"dialog-content",className:Jt("bg-background data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 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 p-6 shadow-lg duration-200 sm:max-w-lg",t),...s,children:[n,r&&h.jsxs(Sk,{"data-slot":"dialog-close",className:"ring-offset-background focus:ring-ring data-[state=open]:bg-accent data-[state=open]:text-muted-foreground absolute top-4 right-4 rounded-xs opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",children:[h.jsx(oj,{}),h.jsx("span",{className:"sr-only",children:"Close"})]})]})]})}function yu({className:t,...n}){return h.jsx("div",{"data-slot":"dialog-header",className:Jt("flex flex-col gap-2 text-center sm:text-left",t),...n})}function QS({className:t,...n}){return h.jsx("div",{"data-slot":"dialog-footer",className:Jt("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",t),...n})}function bu({className:t,...n}){return h.jsx(xk,{"data-slot":"dialog-title",className:Jt("text-lg leading-none font-semibold",t),...n})}function xu({className:t,...n}){return h.jsx(wk,{"data-slot":"dialog-description",className:Jt("text-muted-foreground text-sm",t),...n})}function p3({...t}){return h.jsx(j4,{"data-slot":"dropdown-menu",...t})}function g3({...t}){return h.jsx(k4,{"data-slot":"dropdown-menu-trigger",...t})}function v3({className:t,sideOffset:n=4,...r}){return h.jsx(M4,{children:h.jsx(D4,{"data-slot":"dropdown-menu-content",sideOffset:n,className:Jt("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 max-h-(--radix-dropdown-menu-content-available-height) min-w-[8rem] origin-(--radix-dropdown-menu-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border p-1 shadow-md",t),...r})})}function y3({className:t,inset:n,variant:r="default",...s}){return h.jsx(z4,{"data-slot":"dropdown-menu-item","data-inset":n,"data-variant":r,className:Jt("focus:bg-accent focus:text-accent-foreground data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 dark:data-[variant=destructive]:focus:bg-destructive/20 data-[variant=destructive]:focus:text-destructive data-[variant=destructive]:*:[svg]:!text-destructive [&_svg:not([class*='text-'])]:text-muted-foreground relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 data-[inset]:pl-8 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",t),...s})}function Pr({className:t,...n}){return h.jsx(sz,{"data-slot":"label",className:Jt("flex items-center gap-2 text-sm leading-none font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50",t),...n})}b.createContext({});b.createContext({});function Ra({className:t,type:n,...r}){return h.jsx("input",{type:n,"data-slot":"input",className:Jt("file:text-foreground placeholder:text-muted-foreground selection:bg-primary selection:text-primary-foreground dark:bg-input/30 border-input flex h-9 w-full min-w-0 rounded-md border bg-transparent px-3 py-1 text-base shadow-xs transition-[color,box-shadow] outline-none file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm","focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px]","aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",t),...r})}var b3=b.forwardRef(({className:t,align:n="center",sideOffset:r=4,...s},i)=>h.jsx(jz,{children:h.jsx(BS,{ref:i,align:n,sideOffset:r,className:Jt("z-50 w-72 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none",t),...s})}));b3.displayName=BS.displayName;function x3({className:t,...n}){return h.jsx("div",{"data-slot":"skeleton",className:Jt("bg-accent animate-pulse rounded-md",t),...n})}b.createContext(null);b.createContext({size:"default",variant:"default"});const w3=()=>{const t=Xr();return h.jsx("div",{className:"min-h-screen bg-gradient-to-br from-primary/10 via-background to-background",children:h.jsx("div",{className:"container mx-auto px-4 py-16",children:h.jsxs("div",{className:"max-w-4xl mx-auto text-center space-y-8",children:[h.jsxs("div",{className:"space-y-4",children:[h.jsx("h1",{className:"text-6xl font-bold text-primary animate-fadeIn",children:"Evolution GO"}),h.jsx("p",{className:"text-xl text-muted-foreground",children:"Interface moderna para gerenciamento de instâncias WhatsApp"})]}),h.jsxs("div",{className:"grid md:grid-cols-3 gap-6 mt-12",children:[h.jsxs("div",{className:"bg-card border rounded-lg p-6 space-y-3 hover:border-primary transition-colors",children:[h.jsx("div",{className:"w-12 h-12 bg-primary/10 rounded-lg flex items-center justify-center",children:h.jsx(QR,{className:"w-6 h-6 text-primary"})}),h.jsx("h3",{className:"text-lg font-semibold",children:"Rápido e Eficiente"}),h.jsx("p",{className:"text-sm text-muted-foreground",children:"Gerencie múltiplas instâncias WhatsApp com alta performance"})]}),h.jsxs("div",{className:"bg-card border rounded-lg p-6 space-y-3 hover:border-primary transition-colors",children:[h.jsx("div",{className:"w-12 h-12 bg-primary/10 rounded-lg flex items-center justify-center",children:h.jsx(VR,{className:"w-6 h-6 text-primary"})}),h.jsx("h3",{className:"text-lg font-semibold",children:"Seguro"}),h.jsx("p",{className:"text-sm text-muted-foreground",children:"Autenticação robusta e controle total sobre suas instâncias"})]}),h.jsxs("div",{className:"bg-card border rounded-lg p-6 space-y-3 hover:border-primary transition-colors",children:[h.jsx("div",{className:"w-12 h-12 bg-primary/10 rounded-lg flex items-center justify-center",children:h.jsx(vR,{className:"w-6 h-6 text-primary"})}),h.jsx("h3",{className:"text-lg font-semibold",children:"API Completa"}),h.jsx("p",{className:"text-sm text-muted-foreground",children:"Integração via API REST com Evolution GO"})]})]}),h.jsx("div",{className:"mt-12",children:h.jsxs(ut,{size:"lg",onClick:()=>t("/manager/login"),className:"text-lg px-8 py-6 group",children:["Acessar Manager",h.jsx(K2,{className:"ml-2 w-5 h-5 group-hover:translate-x-1 transition-transform"})]})}),h.jsxs("div",{className:"mt-16 pt-8 border-t",children:[h.jsx("p",{className:"text-sm text-muted-foreground",children:"Evolution GO Manager - Gerencie suas instâncias WhatsApp de forma simples e eficiente"}),h.jsxs("p",{className:"text-xs text-muted-foreground mt-2",children:["© ",new Date().getFullYear()," Evolution GO. Todos os direitos reservados."]})]})]})})})};var dt;(function(t){t.assertEqual=i=>{};function n(i){}t.assertIs=n;function r(i){throw new Error}t.assertNever=r,t.arrayToEnum=i=>{const c={};for(const u of i)c[u]=u;return c},t.getValidEnumValues=i=>{const c=t.objectKeys(i).filter(f=>typeof i[i[f]]!="number"),u={};for(const f of c)u[f]=i[f];return t.objectValues(u)},t.objectValues=i=>t.objectKeys(i).map(function(c){return i[c]}),t.objectKeys=typeof Object.keys=="function"?i=>Object.keys(i):i=>{const c=[];for(const u in i)Object.prototype.hasOwnProperty.call(i,u)&&c.push(u);return c},t.find=(i,c)=>{for(const u of i)if(c(u))return u},t.isInteger=typeof Number.isInteger=="function"?i=>Number.isInteger(i):i=>typeof i=="number"&&Number.isFinite(i)&&Math.floor(i)===i;function s(i,c=" | "){return i.map(u=>typeof u=="string"?`'${u}'`:u).join(c)}t.joinValues=s,t.jsonStringifyReplacer=(i,c)=>typeof c=="bigint"?c.toString():c})(dt||(dt={}));var Wx;(function(t){t.mergeShapes=(n,r)=>({...n,...r})})(Wx||(Wx={}));const Te=dt.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),Hr=t=>{switch(typeof t){case"undefined":return Te.undefined;case"string":return Te.string;case"number":return Number.isNaN(t)?Te.nan:Te.number;case"boolean":return Te.boolean;case"function":return Te.function;case"bigint":return Te.bigint;case"symbol":return Te.symbol;case"object":return Array.isArray(t)?Te.array:t===null?Te.null:t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?Te.promise:typeof Map<"u"&&t instanceof Map?Te.map:typeof Set<"u"&&t instanceof Set?Te.set:typeof Date<"u"&&t instanceof Date?Te.date:Te.object;default:return Te.unknown}},xe=dt.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]);class lr extends Error{get errors(){return this.issues}constructor(n){super(),this.issues=[],this.addIssue=s=>{this.issues=[...this.issues,s]},this.addIssues=(s=[])=>{this.issues=[...this.issues,...s]};const r=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,r):this.__proto__=r,this.name="ZodError",this.issues=n}format(n){const r=n||function(c){return c.message},s={_errors:[]},i=c=>{for(const u of c.issues)if(u.code==="invalid_union")u.unionErrors.map(i);else if(u.code==="invalid_return_type")i(u.returnTypeError);else if(u.code==="invalid_arguments")i(u.argumentsError);else if(u.path.length===0)s._errors.push(r(u));else{let f=s,g=0;for(;gr.message){const r={},s=[];for(const i of this.issues)if(i.path.length>0){const c=i.path[0];r[c]=r[c]||[],r[c].push(n(i))}else s.push(n(i));return{formErrors:s,fieldErrors:r}}get formErrors(){return this.flatten()}}lr.create=t=>new lr(t);const fh=(t,n)=>{let r;switch(t.code){case xe.invalid_type:t.received===Te.undefined?r="Required":r=`Expected ${t.expected}, received ${t.received}`;break;case xe.invalid_literal:r=`Invalid literal value, expected ${JSON.stringify(t.expected,dt.jsonStringifyReplacer)}`;break;case xe.unrecognized_keys:r=`Unrecognized key(s) in object: ${dt.joinValues(t.keys,", ")}`;break;case xe.invalid_union:r="Invalid input";break;case xe.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${dt.joinValues(t.options)}`;break;case xe.invalid_enum_value:r=`Invalid enum value. Expected ${dt.joinValues(t.options)}, received '${t.received}'`;break;case xe.invalid_arguments:r="Invalid function arguments";break;case xe.invalid_return_type:r="Invalid function return type";break;case xe.invalid_date:r="Invalid date";break;case xe.invalid_string:typeof t.validation=="object"?"includes"in t.validation?(r=`Invalid input: must include "${t.validation.includes}"`,typeof t.validation.position=="number"&&(r=`${r} at one or more positions greater than or equal to ${t.validation.position}`)):"startsWith"in t.validation?r=`Invalid input: must start with "${t.validation.startsWith}"`:"endsWith"in t.validation?r=`Invalid input: must end with "${t.validation.endsWith}"`:dt.assertNever(t.validation):t.validation!=="regex"?r=`Invalid ${t.validation}`:r="Invalid";break;case xe.too_small:t.type==="array"?r=`Array must contain ${t.exact?"exactly":t.inclusive?"at least":"more than"} ${t.minimum} element(s)`:t.type==="string"?r=`String must contain ${t.exact?"exactly":t.inclusive?"at least":"over"} ${t.minimum} character(s)`:t.type==="number"?r=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="bigint"?r=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="date"?r=`Date must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(t.minimum))}`:r="Invalid input";break;case xe.too_big:t.type==="array"?r=`Array must contain ${t.exact?"exactly":t.inclusive?"at most":"less than"} ${t.maximum} element(s)`:t.type==="string"?r=`String must contain ${t.exact?"exactly":t.inclusive?"at most":"under"} ${t.maximum} character(s)`:t.type==="number"?r=`Number must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="bigint"?r=`BigInt must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="date"?r=`Date must be ${t.exact?"exactly":t.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(t.maximum))}`:r="Invalid input";break;case xe.custom:r="Invalid input";break;case xe.invalid_intersection_types:r="Intersection results could not be merged";break;case xe.not_multiple_of:r=`Number must be a multiple of ${t.multipleOf}`;break;case xe.not_finite:r="Number must be finite";break;default:r=n.defaultError,dt.assertNever(t)}return{message:r}};let S3=fh;function E3(){return S3}const _3=t=>{const{data:n,path:r,errorMaps:s,issueData:i}=t,c=[...r,...i.path||[]],u={...i,path:c};if(i.message!==void 0)return{...i,path:c,message:i.message};let f="";const g=s.filter(p=>!!p).slice().reverse();for(const p of g)f=p(u,{data:n,defaultError:f}).message;return{...i,path:c,message:f}};function Ee(t,n){const r=E3(),s=_3({issueData:n,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,r,r===fh?void 0:fh].filter(i=>!!i)});t.common.issues.push(s)}class $n{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(n,r){const s=[];for(const i of r){if(i.status==="aborted")return Ie;i.status==="dirty"&&n.dirty(),s.push(i.value)}return{status:n.value,value:s}}static async mergeObjectAsync(n,r){const s=[];for(const i of r){const c=await i.key,u=await i.value;s.push({key:c,value:u})}return $n.mergeObjectSync(n,s)}static mergeObjectSync(n,r){const s={};for(const i of r){const{key:c,value:u}=i;if(c.status==="aborted"||u.status==="aborted")return Ie;c.status==="dirty"&&n.dirty(),u.status==="dirty"&&n.dirty(),c.value!=="__proto__"&&(typeof u.value<"u"||i.alwaysSet)&&(s[c.value]=u.value)}return{status:n.value,value:s}}}const Ie=Object.freeze({status:"aborted"}),Ki=t=>({status:"dirty",value:t}),la=t=>({status:"valid",value:t}),Jx=t=>t.status==="aborted",e0=t=>t.status==="dirty",Bo=t=>t.status==="valid",wu=t=>typeof Promise<"u"&&t instanceof Promise;var ke;(function(t){t.errToObj=n=>typeof n=="string"?{message:n}:n||{},t.toString=n=>typeof n=="string"?n:n==null?void 0:n.message})(ke||(ke={}));class Yr{constructor(n,r,s,i){this._cachedPath=[],this.parent=n,this.data=r,this._path=s,this._key=i}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const t0=(t,n)=>{if(Bo(n))return{success:!0,data:n.value};if(!t.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const r=new lr(t.common.issues);return this._error=r,this._error}}};function Ke(t){if(!t)return{};const{errorMap:n,invalid_type_error:r,required_error:s,description:i}=t;if(n&&(r||s))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return n?{errorMap:n,description:i}:{errorMap:(u,f)=>{const{message:g}=t;return u.code==="invalid_enum_value"?{message:g??f.defaultError}:typeof f.data>"u"?{message:g??s??f.defaultError}:u.code!=="invalid_type"?{message:f.defaultError}:{message:g??r??f.defaultError}},description:i}}class it{get description(){return this._def.description}_getType(n){return Hr(n.data)}_getOrReturnCtx(n,r){return r||{common:n.parent.common,data:n.data,parsedType:Hr(n.data),schemaErrorMap:this._def.errorMap,path:n.path,parent:n.parent}}_processInputParams(n){return{status:new $n,ctx:{common:n.parent.common,data:n.data,parsedType:Hr(n.data),schemaErrorMap:this._def.errorMap,path:n.path,parent:n.parent}}}_parseSync(n){const r=this._parse(n);if(wu(r))throw new Error("Synchronous parse encountered promise.");return r}_parseAsync(n){const r=this._parse(n);return Promise.resolve(r)}parse(n,r){const s=this.safeParse(n,r);if(s.success)return s.data;throw s.error}safeParse(n,r){const s={common:{issues:[],async:(r==null?void 0:r.async)??!1,contextualErrorMap:r==null?void 0:r.errorMap},path:(r==null?void 0:r.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:n,parsedType:Hr(n)},i=this._parseSync({data:n,path:s.path,parent:s});return t0(s,i)}"~validate"(n){var s,i;const r={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:n,parsedType:Hr(n)};if(!this["~standard"].async)try{const c=this._parseSync({data:n,path:[],parent:r});return Bo(c)?{value:c.value}:{issues:r.common.issues}}catch(c){(i=(s=c==null?void 0:c.message)==null?void 0:s.toLowerCase())!=null&&i.includes("encountered")&&(this["~standard"].async=!0),r.common={issues:[],async:!0}}return this._parseAsync({data:n,path:[],parent:r}).then(c=>Bo(c)?{value:c.value}:{issues:r.common.issues})}async parseAsync(n,r){const s=await this.safeParseAsync(n,r);if(s.success)return s.data;throw s.error}async safeParseAsync(n,r){const s={common:{issues:[],contextualErrorMap:r==null?void 0:r.errorMap,async:!0},path:(r==null?void 0:r.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:n,parsedType:Hr(n)},i=this._parse({data:n,path:s.path,parent:s}),c=await(wu(i)?i:Promise.resolve(i));return t0(s,c)}refine(n,r){const s=i=>typeof r=="string"||typeof r>"u"?{message:r}:typeof r=="function"?r(i):r;return this._refinement((i,c)=>{const u=n(i),f=()=>c.addIssue({code:xe.custom,...s(i)});return typeof Promise<"u"&&u instanceof Promise?u.then(g=>g?!0:(f(),!1)):u?!0:(f(),!1)})}refinement(n,r){return this._refinement((s,i)=>n(s)?!0:(i.addIssue(typeof r=="function"?r(s,i):r),!1))}_refinement(n){return new Ho({schema:this,typeName:Fe.ZodEffects,effect:{type:"refinement",refinement:n}})}superRefine(n){return this._refinement(n)}constructor(n){this.spa=this.safeParseAsync,this._def=n,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:r=>this["~validate"](r)}}optional(){return qr.create(this,this._def)}nullable(){return Vo.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Ma.create(this)}promise(){return Cu.create(this,this._def)}or(n){return Eu.create([this,n],this._def)}and(n){return _u.create(this,n,this._def)}transform(n){return new Ho({...Ke(this._def),schema:this,typeName:Fe.ZodEffects,effect:{type:"transform",transform:n}})}default(n){const r=typeof n=="function"?n:()=>n;return new gh({...Ke(this._def),innerType:this,defaultValue:r,typeName:Fe.ZodDefault})}brand(){return new Y3({typeName:Fe.ZodBranded,type:this,...Ke(this._def)})}catch(n){const r=typeof n=="function"?n:()=>n;return new vh({...Ke(this._def),innerType:this,catchValue:r,typeName:Fe.ZodCatch})}describe(n){const r=this.constructor;return new r({...this._def,description:n})}pipe(n){return vp.create(this,n)}readonly(){return yh.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const C3=/^c[^\s-]{8,}$/i,N3=/^[0-9a-z]+$/,R3=/^[0-9A-HJKMNP-TV-Z]{26}$/i,A3=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,T3=/^[a-z0-9_-]{21}$/i,O3=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,j3=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,k3=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,M3="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let Vm;const D3=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,z3=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,L3=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,U3=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,B3=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,P3=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,WS="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",H3=new RegExp(`^${WS}$`);function JS(t){let n="[0-5]\\d";t.precision?n=`${n}\\.\\d{${t.precision}}`:t.precision==null&&(n=`${n}(\\.\\d+)?`);const r=t.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${n})${r}`}function V3(t){return new RegExp(`^${JS(t)}$`)}function I3(t){let n=`${WS}T${JS(t)}`;const r=[];return r.push(t.local?"Z?":"Z"),t.offset&&r.push("([+-]\\d{2}:?\\d{2})"),n=`${n}(${r.join("|")})`,new RegExp(`^${n}$`)}function q3(t,n){return!!((n==="v4"||!n)&&D3.test(t)||(n==="v6"||!n)&&L3.test(t))}function F3(t,n){if(!O3.test(t))return!1;try{const[r]=t.split(".");if(!r)return!1;const s=r.replace(/-/g,"+").replace(/_/g,"/").padEnd(r.length+(4-r.length%4)%4,"="),i=JSON.parse(atob(s));return!(typeof i!="object"||i===null||"typ"in i&&(i==null?void 0:i.typ)!=="JWT"||!i.alg||n&&i.alg!==n)}catch{return!1}}function $3(t,n){return!!((n==="v4"||!n)&&z3.test(t)||(n==="v6"||!n)&&U3.test(t))}class Ir extends it{_parse(n){if(this._def.coerce&&(n.data=String(n.data)),this._getType(n)!==Te.string){const c=this._getOrReturnCtx(n);return Ee(c,{code:xe.invalid_type,expected:Te.string,received:c.parsedType}),Ie}const s=new $n;let i;for(const c of this._def.checks)if(c.kind==="min")n.data.lengthc.value&&(i=this._getOrReturnCtx(n,i),Ee(i,{code:xe.too_big,maximum:c.value,type:"string",inclusive:!0,exact:!1,message:c.message}),s.dirty());else if(c.kind==="length"){const u=n.data.length>c.value,f=n.data.lengthn.test(i),{validation:r,code:xe.invalid_string,...ke.errToObj(s)})}_addCheck(n){return new Ir({...this._def,checks:[...this._def.checks,n]})}email(n){return this._addCheck({kind:"email",...ke.errToObj(n)})}url(n){return this._addCheck({kind:"url",...ke.errToObj(n)})}emoji(n){return this._addCheck({kind:"emoji",...ke.errToObj(n)})}uuid(n){return this._addCheck({kind:"uuid",...ke.errToObj(n)})}nanoid(n){return this._addCheck({kind:"nanoid",...ke.errToObj(n)})}cuid(n){return this._addCheck({kind:"cuid",...ke.errToObj(n)})}cuid2(n){return this._addCheck({kind:"cuid2",...ke.errToObj(n)})}ulid(n){return this._addCheck({kind:"ulid",...ke.errToObj(n)})}base64(n){return this._addCheck({kind:"base64",...ke.errToObj(n)})}base64url(n){return this._addCheck({kind:"base64url",...ke.errToObj(n)})}jwt(n){return this._addCheck({kind:"jwt",...ke.errToObj(n)})}ip(n){return this._addCheck({kind:"ip",...ke.errToObj(n)})}cidr(n){return this._addCheck({kind:"cidr",...ke.errToObj(n)})}datetime(n){return typeof n=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:n}):this._addCheck({kind:"datetime",precision:typeof(n==null?void 0:n.precision)>"u"?null:n==null?void 0:n.precision,offset:(n==null?void 0:n.offset)??!1,local:(n==null?void 0:n.local)??!1,...ke.errToObj(n==null?void 0:n.message)})}date(n){return this._addCheck({kind:"date",message:n})}time(n){return typeof n=="string"?this._addCheck({kind:"time",precision:null,message:n}):this._addCheck({kind:"time",precision:typeof(n==null?void 0:n.precision)>"u"?null:n==null?void 0:n.precision,...ke.errToObj(n==null?void 0:n.message)})}duration(n){return this._addCheck({kind:"duration",...ke.errToObj(n)})}regex(n,r){return this._addCheck({kind:"regex",regex:n,...ke.errToObj(r)})}includes(n,r){return this._addCheck({kind:"includes",value:n,position:r==null?void 0:r.position,...ke.errToObj(r==null?void 0:r.message)})}startsWith(n,r){return this._addCheck({kind:"startsWith",value:n,...ke.errToObj(r)})}endsWith(n,r){return this._addCheck({kind:"endsWith",value:n,...ke.errToObj(r)})}min(n,r){return this._addCheck({kind:"min",value:n,...ke.errToObj(r)})}max(n,r){return this._addCheck({kind:"max",value:n,...ke.errToObj(r)})}length(n,r){return this._addCheck({kind:"length",value:n,...ke.errToObj(r)})}nonempty(n){return this.min(1,ke.errToObj(n))}trim(){return new Ir({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new Ir({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new Ir({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(n=>n.kind==="datetime")}get isDate(){return!!this._def.checks.find(n=>n.kind==="date")}get isTime(){return!!this._def.checks.find(n=>n.kind==="time")}get isDuration(){return!!this._def.checks.find(n=>n.kind==="duration")}get isEmail(){return!!this._def.checks.find(n=>n.kind==="email")}get isURL(){return!!this._def.checks.find(n=>n.kind==="url")}get isEmoji(){return!!this._def.checks.find(n=>n.kind==="emoji")}get isUUID(){return!!this._def.checks.find(n=>n.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(n=>n.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(n=>n.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(n=>n.kind==="cuid2")}get isULID(){return!!this._def.checks.find(n=>n.kind==="ulid")}get isIP(){return!!this._def.checks.find(n=>n.kind==="ip")}get isCIDR(){return!!this._def.checks.find(n=>n.kind==="cidr")}get isBase64(){return!!this._def.checks.find(n=>n.kind==="base64")}get isBase64url(){return!!this._def.checks.find(n=>n.kind==="base64url")}get minLength(){let n=null;for(const r of this._def.checks)r.kind==="min"&&(n===null||r.value>n)&&(n=r.value);return n}get maxLength(){let n=null;for(const r of this._def.checks)r.kind==="max"&&(n===null||r.valuenew Ir({checks:[],typeName:Fe.ZodString,coerce:(t==null?void 0:t.coerce)??!1,...Ke(t)});function G3(t,n){const r=(t.toString().split(".")[1]||"").length,s=(n.toString().split(".")[1]||"").length,i=r>s?r:s,c=Number.parseInt(t.toFixed(i).replace(".","")),u=Number.parseInt(n.toFixed(i).replace(".",""));return c%u/10**i}class rl extends it{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(n){if(this._def.coerce&&(n.data=Number(n.data)),this._getType(n)!==Te.number){const c=this._getOrReturnCtx(n);return Ee(c,{code:xe.invalid_type,expected:Te.number,received:c.parsedType}),Ie}let s;const i=new $n;for(const c of this._def.checks)c.kind==="int"?dt.isInteger(n.data)||(s=this._getOrReturnCtx(n,s),Ee(s,{code:xe.invalid_type,expected:"integer",received:"float",message:c.message}),i.dirty()):c.kind==="min"?(c.inclusive?n.datac.value:n.data>=c.value)&&(s=this._getOrReturnCtx(n,s),Ee(s,{code:xe.too_big,maximum:c.value,type:"number",inclusive:c.inclusive,exact:!1,message:c.message}),i.dirty()):c.kind==="multipleOf"?G3(n.data,c.value)!==0&&(s=this._getOrReturnCtx(n,s),Ee(s,{code:xe.not_multiple_of,multipleOf:c.value,message:c.message}),i.dirty()):c.kind==="finite"?Number.isFinite(n.data)||(s=this._getOrReturnCtx(n,s),Ee(s,{code:xe.not_finite,message:c.message}),i.dirty()):dt.assertNever(c);return{status:i.value,value:n.data}}gte(n,r){return this.setLimit("min",n,!0,ke.toString(r))}gt(n,r){return this.setLimit("min",n,!1,ke.toString(r))}lte(n,r){return this.setLimit("max",n,!0,ke.toString(r))}lt(n,r){return this.setLimit("max",n,!1,ke.toString(r))}setLimit(n,r,s,i){return new rl({...this._def,checks:[...this._def.checks,{kind:n,value:r,inclusive:s,message:ke.toString(i)}]})}_addCheck(n){return new rl({...this._def,checks:[...this._def.checks,n]})}int(n){return this._addCheck({kind:"int",message:ke.toString(n)})}positive(n){return this._addCheck({kind:"min",value:0,inclusive:!1,message:ke.toString(n)})}negative(n){return this._addCheck({kind:"max",value:0,inclusive:!1,message:ke.toString(n)})}nonpositive(n){return this._addCheck({kind:"max",value:0,inclusive:!0,message:ke.toString(n)})}nonnegative(n){return this._addCheck({kind:"min",value:0,inclusive:!0,message:ke.toString(n)})}multipleOf(n,r){return this._addCheck({kind:"multipleOf",value:n,message:ke.toString(r)})}finite(n){return this._addCheck({kind:"finite",message:ke.toString(n)})}safe(n){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:ke.toString(n)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:ke.toString(n)})}get minValue(){let n=null;for(const r of this._def.checks)r.kind==="min"&&(n===null||r.value>n)&&(n=r.value);return n}get maxValue(){let n=null;for(const r of this._def.checks)r.kind==="max"&&(n===null||r.valuen.kind==="int"||n.kind==="multipleOf"&&dt.isInteger(n.value))}get isFinite(){let n=null,r=null;for(const s of this._def.checks){if(s.kind==="finite"||s.kind==="int"||s.kind==="multipleOf")return!0;s.kind==="min"?(r===null||s.value>r)&&(r=s.value):s.kind==="max"&&(n===null||s.valuenew rl({checks:[],typeName:Fe.ZodNumber,coerce:(t==null?void 0:t.coerce)||!1,...Ke(t)});class sl extends it{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(n){if(this._def.coerce)try{n.data=BigInt(n.data)}catch{return this._getInvalidInput(n)}if(this._getType(n)!==Te.bigint)return this._getInvalidInput(n);let s;const i=new $n;for(const c of this._def.checks)c.kind==="min"?(c.inclusive?n.datac.value:n.data>=c.value)&&(s=this._getOrReturnCtx(n,s),Ee(s,{code:xe.too_big,type:"bigint",maximum:c.value,inclusive:c.inclusive,message:c.message}),i.dirty()):c.kind==="multipleOf"?n.data%c.value!==BigInt(0)&&(s=this._getOrReturnCtx(n,s),Ee(s,{code:xe.not_multiple_of,multipleOf:c.value,message:c.message}),i.dirty()):dt.assertNever(c);return{status:i.value,value:n.data}}_getInvalidInput(n){const r=this._getOrReturnCtx(n);return Ee(r,{code:xe.invalid_type,expected:Te.bigint,received:r.parsedType}),Ie}gte(n,r){return this.setLimit("min",n,!0,ke.toString(r))}gt(n,r){return this.setLimit("min",n,!1,ke.toString(r))}lte(n,r){return this.setLimit("max",n,!0,ke.toString(r))}lt(n,r){return this.setLimit("max",n,!1,ke.toString(r))}setLimit(n,r,s,i){return new sl({...this._def,checks:[...this._def.checks,{kind:n,value:r,inclusive:s,message:ke.toString(i)}]})}_addCheck(n){return new sl({...this._def,checks:[...this._def.checks,n]})}positive(n){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:ke.toString(n)})}negative(n){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:ke.toString(n)})}nonpositive(n){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:ke.toString(n)})}nonnegative(n){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:ke.toString(n)})}multipleOf(n,r){return this._addCheck({kind:"multipleOf",value:n,message:ke.toString(r)})}get minValue(){let n=null;for(const r of this._def.checks)r.kind==="min"&&(n===null||r.value>n)&&(n=r.value);return n}get maxValue(){let n=null;for(const r of this._def.checks)r.kind==="max"&&(n===null||r.valuenew sl({checks:[],typeName:Fe.ZodBigInt,coerce:(t==null?void 0:t.coerce)??!1,...Ke(t)});class mh extends it{_parse(n){if(this._def.coerce&&(n.data=!!n.data),this._getType(n)!==Te.boolean){const s=this._getOrReturnCtx(n);return Ee(s,{code:xe.invalid_type,expected:Te.boolean,received:s.parsedType}),Ie}return la(n.data)}}mh.create=t=>new mh({typeName:Fe.ZodBoolean,coerce:(t==null?void 0:t.coerce)||!1,...Ke(t)});class Su extends it{_parse(n){if(this._def.coerce&&(n.data=new Date(n.data)),this._getType(n)!==Te.date){const c=this._getOrReturnCtx(n);return Ee(c,{code:xe.invalid_type,expected:Te.date,received:c.parsedType}),Ie}if(Number.isNaN(n.data.getTime())){const c=this._getOrReturnCtx(n);return Ee(c,{code:xe.invalid_date}),Ie}const s=new $n;let i;for(const c of this._def.checks)c.kind==="min"?n.data.getTime()c.value&&(i=this._getOrReturnCtx(n,i),Ee(i,{code:xe.too_big,message:c.message,inclusive:!0,exact:!1,maximum:c.value,type:"date"}),s.dirty()):dt.assertNever(c);return{status:s.value,value:new Date(n.data.getTime())}}_addCheck(n){return new Su({...this._def,checks:[...this._def.checks,n]})}min(n,r){return this._addCheck({kind:"min",value:n.getTime(),message:ke.toString(r)})}max(n,r){return this._addCheck({kind:"max",value:n.getTime(),message:ke.toString(r)})}get minDate(){let n=null;for(const r of this._def.checks)r.kind==="min"&&(n===null||r.value>n)&&(n=r.value);return n!=null?new Date(n):null}get maxDate(){let n=null;for(const r of this._def.checks)r.kind==="max"&&(n===null||r.valuenew Su({checks:[],coerce:(t==null?void 0:t.coerce)||!1,typeName:Fe.ZodDate,...Ke(t)});class n0 extends it{_parse(n){if(this._getType(n)!==Te.symbol){const s=this._getOrReturnCtx(n);return Ee(s,{code:xe.invalid_type,expected:Te.symbol,received:s.parsedType}),Ie}return la(n.data)}}n0.create=t=>new n0({typeName:Fe.ZodSymbol,...Ke(t)});class a0 extends it{_parse(n){if(this._getType(n)!==Te.undefined){const s=this._getOrReturnCtx(n);return Ee(s,{code:xe.invalid_type,expected:Te.undefined,received:s.parsedType}),Ie}return la(n.data)}}a0.create=t=>new a0({typeName:Fe.ZodUndefined,...Ke(t)});class r0 extends it{_parse(n){if(this._getType(n)!==Te.null){const s=this._getOrReturnCtx(n);return Ee(s,{code:xe.invalid_type,expected:Te.null,received:s.parsedType}),Ie}return la(n.data)}}r0.create=t=>new r0({typeName:Fe.ZodNull,...Ke(t)});class s0 extends it{constructor(){super(...arguments),this._any=!0}_parse(n){return la(n.data)}}s0.create=t=>new s0({typeName:Fe.ZodAny,...Ke(t)});class o0 extends it{constructor(){super(...arguments),this._unknown=!0}_parse(n){return la(n.data)}}o0.create=t=>new o0({typeName:Fe.ZodUnknown,...Ke(t)});class Zr extends it{_parse(n){const r=this._getOrReturnCtx(n);return Ee(r,{code:xe.invalid_type,expected:Te.never,received:r.parsedType}),Ie}}Zr.create=t=>new Zr({typeName:Fe.ZodNever,...Ke(t)});class i0 extends it{_parse(n){if(this._getType(n)!==Te.undefined){const s=this._getOrReturnCtx(n);return Ee(s,{code:xe.invalid_type,expected:Te.void,received:s.parsedType}),Ie}return la(n.data)}}i0.create=t=>new i0({typeName:Fe.ZodVoid,...Ke(t)});class Ma extends it{_parse(n){const{ctx:r,status:s}=this._processInputParams(n),i=this._def;if(r.parsedType!==Te.array)return Ee(r,{code:xe.invalid_type,expected:Te.array,received:r.parsedType}),Ie;if(i.exactLength!==null){const u=r.data.length>i.exactLength.value,f=r.data.lengthi.maxLength.value&&(Ee(r,{code:xe.too_big,maximum:i.maxLength.value,type:"array",inclusive:!0,exact:!1,message:i.maxLength.message}),s.dirty()),r.common.async)return Promise.all([...r.data].map((u,f)=>i.type._parseAsync(new Yr(r,u,r.path,f)))).then(u=>$n.mergeArray(s,u));const c=[...r.data].map((u,f)=>i.type._parseSync(new Yr(r,u,r.path,f)));return $n.mergeArray(s,c)}get element(){return this._def.type}min(n,r){return new Ma({...this._def,minLength:{value:n,message:ke.toString(r)}})}max(n,r){return new Ma({...this._def,maxLength:{value:n,message:ke.toString(r)}})}length(n,r){return new Ma({...this._def,exactLength:{value:n,message:ke.toString(r)}})}nonempty(n){return this.min(1,n)}}Ma.create=(t,n)=>new Ma({type:t,minLength:null,maxLength:null,exactLength:null,typeName:Fe.ZodArray,...Ke(n)});function Ro(t){if(t instanceof Gt){const n={};for(const r in t.shape){const s=t.shape[r];n[r]=qr.create(Ro(s))}return new Gt({...t._def,shape:()=>n})}else return t instanceof Ma?new Ma({...t._def,type:Ro(t.element)}):t instanceof qr?qr.create(Ro(t.unwrap())):t instanceof Vo?Vo.create(Ro(t.unwrap())):t instanceof Rs?Rs.create(t.items.map(n=>Ro(n))):t}class Gt extends it{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const n=this._def.shape(),r=dt.objectKeys(n);return this._cached={shape:n,keys:r},this._cached}_parse(n){if(this._getType(n)!==Te.object){const p=this._getOrReturnCtx(n);return Ee(p,{code:xe.invalid_type,expected:Te.object,received:p.parsedType}),Ie}const{status:s,ctx:i}=this._processInputParams(n),{shape:c,keys:u}=this._getCached(),f=[];if(!(this._def.catchall instanceof Zr&&this._def.unknownKeys==="strip"))for(const p in i.data)u.includes(p)||f.push(p);const g=[];for(const p of u){const y=c[p],v=i.data[p];g.push({key:{status:"valid",value:p},value:y._parse(new Yr(i,v,i.path,p)),alwaysSet:p in i.data})}if(this._def.catchall instanceof Zr){const p=this._def.unknownKeys;if(p==="passthrough")for(const y of f)g.push({key:{status:"valid",value:y},value:{status:"valid",value:i.data[y]}});else if(p==="strict")f.length>0&&(Ee(i,{code:xe.unrecognized_keys,keys:f}),s.dirty());else if(p!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const p=this._def.catchall;for(const y of f){const v=i.data[y];g.push({key:{status:"valid",value:y},value:p._parse(new Yr(i,v,i.path,y)),alwaysSet:y in i.data})}}return i.common.async?Promise.resolve().then(async()=>{const p=[];for(const y of g){const v=await y.key,w=await y.value;p.push({key:v,value:w,alwaysSet:y.alwaysSet})}return p}).then(p=>$n.mergeObjectSync(s,p)):$n.mergeObjectSync(s,g)}get shape(){return this._def.shape()}strict(n){return ke.errToObj,new Gt({...this._def,unknownKeys:"strict",...n!==void 0?{errorMap:(r,s)=>{var c,u;const i=((u=(c=this._def).errorMap)==null?void 0:u.call(c,r,s).message)??s.defaultError;return r.code==="unrecognized_keys"?{message:ke.errToObj(n).message??i}:{message:i}}}:{}})}strip(){return new Gt({...this._def,unknownKeys:"strip"})}passthrough(){return new Gt({...this._def,unknownKeys:"passthrough"})}extend(n){return new Gt({...this._def,shape:()=>({...this._def.shape(),...n})})}merge(n){return new Gt({unknownKeys:n._def.unknownKeys,catchall:n._def.catchall,shape:()=>({...this._def.shape(),...n._def.shape()}),typeName:Fe.ZodObject})}setKey(n,r){return this.augment({[n]:r})}catchall(n){return new Gt({...this._def,catchall:n})}pick(n){const r={};for(const s of dt.objectKeys(n))n[s]&&this.shape[s]&&(r[s]=this.shape[s]);return new Gt({...this._def,shape:()=>r})}omit(n){const r={};for(const s of dt.objectKeys(this.shape))n[s]||(r[s]=this.shape[s]);return new Gt({...this._def,shape:()=>r})}deepPartial(){return Ro(this)}partial(n){const r={};for(const s of dt.objectKeys(this.shape)){const i=this.shape[s];n&&!n[s]?r[s]=i:r[s]=i.optional()}return new Gt({...this._def,shape:()=>r})}required(n){const r={};for(const s of dt.objectKeys(this.shape))if(n&&!n[s])r[s]=this.shape[s];else{let c=this.shape[s];for(;c instanceof qr;)c=c._def.innerType;r[s]=c}return new Gt({...this._def,shape:()=>r})}keyof(){return eE(dt.objectKeys(this.shape))}}Gt.create=(t,n)=>new Gt({shape:()=>t,unknownKeys:"strip",catchall:Zr.create(),typeName:Fe.ZodObject,...Ke(n)});Gt.strictCreate=(t,n)=>new Gt({shape:()=>t,unknownKeys:"strict",catchall:Zr.create(),typeName:Fe.ZodObject,...Ke(n)});Gt.lazycreate=(t,n)=>new Gt({shape:t,unknownKeys:"strip",catchall:Zr.create(),typeName:Fe.ZodObject,...Ke(n)});class Eu extends it{_parse(n){const{ctx:r}=this._processInputParams(n),s=this._def.options;function i(c){for(const f of c)if(f.result.status==="valid")return f.result;for(const f of c)if(f.result.status==="dirty")return r.common.issues.push(...f.ctx.common.issues),f.result;const u=c.map(f=>new lr(f.ctx.common.issues));return Ee(r,{code:xe.invalid_union,unionErrors:u}),Ie}if(r.common.async)return Promise.all(s.map(async c=>{const u={...r,common:{...r.common,issues:[]},parent:null};return{result:await c._parseAsync({data:r.data,path:r.path,parent:u}),ctx:u}})).then(i);{let c;const u=[];for(const g of s){const p={...r,common:{...r.common,issues:[]},parent:null},y=g._parseSync({data:r.data,path:r.path,parent:p});if(y.status==="valid")return y;y.status==="dirty"&&!c&&(c={result:y,ctx:p}),p.common.issues.length&&u.push(p.common.issues)}if(c)return r.common.issues.push(...c.ctx.common.issues),c.result;const f=u.map(g=>new lr(g));return Ee(r,{code:xe.invalid_union,unionErrors:f}),Ie}}get options(){return this._def.options}}Eu.create=(t,n)=>new Eu({options:t,typeName:Fe.ZodUnion,...Ke(n)});function hh(t,n){const r=Hr(t),s=Hr(n);if(t===n)return{valid:!0,data:t};if(r===Te.object&&s===Te.object){const i=dt.objectKeys(n),c=dt.objectKeys(t).filter(f=>i.indexOf(f)!==-1),u={...t,...n};for(const f of c){const g=hh(t[f],n[f]);if(!g.valid)return{valid:!1};u[f]=g.data}return{valid:!0,data:u}}else if(r===Te.array&&s===Te.array){if(t.length!==n.length)return{valid:!1};const i=[];for(let c=0;c{if(Jx(c)||Jx(u))return Ie;const f=hh(c.value,u.value);return f.valid?((e0(c)||e0(u))&&r.dirty(),{status:r.value,value:f.data}):(Ee(s,{code:xe.invalid_intersection_types}),Ie)};return s.common.async?Promise.all([this._def.left._parseAsync({data:s.data,path:s.path,parent:s}),this._def.right._parseAsync({data:s.data,path:s.path,parent:s})]).then(([c,u])=>i(c,u)):i(this._def.left._parseSync({data:s.data,path:s.path,parent:s}),this._def.right._parseSync({data:s.data,path:s.path,parent:s}))}}_u.create=(t,n,r)=>new _u({left:t,right:n,typeName:Fe.ZodIntersection,...Ke(r)});class Rs extends it{_parse(n){const{status:r,ctx:s}=this._processInputParams(n);if(s.parsedType!==Te.array)return Ee(s,{code:xe.invalid_type,expected:Te.array,received:s.parsedType}),Ie;if(s.data.lengththis._def.items.length&&(Ee(s,{code:xe.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),r.dirty());const c=[...s.data].map((u,f)=>{const g=this._def.items[f]||this._def.rest;return g?g._parse(new Yr(s,u,s.path,f)):null}).filter(u=>!!u);return s.common.async?Promise.all(c).then(u=>$n.mergeArray(r,u)):$n.mergeArray(r,c)}get items(){return this._def.items}rest(n){return new Rs({...this._def,rest:n})}}Rs.create=(t,n)=>{if(!Array.isArray(t))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new Rs({items:t,typeName:Fe.ZodTuple,rest:null,...Ke(n)})};class l0 extends it{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(n){const{status:r,ctx:s}=this._processInputParams(n);if(s.parsedType!==Te.map)return Ee(s,{code:xe.invalid_type,expected:Te.map,received:s.parsedType}),Ie;const i=this._def.keyType,c=this._def.valueType,u=[...s.data.entries()].map(([f,g],p)=>({key:i._parse(new Yr(s,f,s.path,[p,"key"])),value:c._parse(new Yr(s,g,s.path,[p,"value"]))}));if(s.common.async){const f=new Map;return Promise.resolve().then(async()=>{for(const g of u){const p=await g.key,y=await g.value;if(p.status==="aborted"||y.status==="aborted")return Ie;(p.status==="dirty"||y.status==="dirty")&&r.dirty(),f.set(p.value,y.value)}return{status:r.value,value:f}})}else{const f=new Map;for(const g of u){const p=g.key,y=g.value;if(p.status==="aborted"||y.status==="aborted")return Ie;(p.status==="dirty"||y.status==="dirty")&&r.dirty(),f.set(p.value,y.value)}return{status:r.value,value:f}}}}l0.create=(t,n,r)=>new l0({valueType:n,keyType:t,typeName:Fe.ZodMap,...Ke(r)});class ol extends it{_parse(n){const{status:r,ctx:s}=this._processInputParams(n);if(s.parsedType!==Te.set)return Ee(s,{code:xe.invalid_type,expected:Te.set,received:s.parsedType}),Ie;const i=this._def;i.minSize!==null&&s.data.sizei.maxSize.value&&(Ee(s,{code:xe.too_big,maximum:i.maxSize.value,type:"set",inclusive:!0,exact:!1,message:i.maxSize.message}),r.dirty());const c=this._def.valueType;function u(g){const p=new Set;for(const y of g){if(y.status==="aborted")return Ie;y.status==="dirty"&&r.dirty(),p.add(y.value)}return{status:r.value,value:p}}const f=[...s.data.values()].map((g,p)=>c._parse(new Yr(s,g,s.path,p)));return s.common.async?Promise.all(f).then(g=>u(g)):u(f)}min(n,r){return new ol({...this._def,minSize:{value:n,message:ke.toString(r)}})}max(n,r){return new ol({...this._def,maxSize:{value:n,message:ke.toString(r)}})}size(n,r){return this.min(n,r).max(n,r)}nonempty(n){return this.min(1,n)}}ol.create=(t,n)=>new ol({valueType:t,minSize:null,maxSize:null,typeName:Fe.ZodSet,...Ke(n)});class c0 extends it{get schema(){return this._def.getter()}_parse(n){const{ctx:r}=this._processInputParams(n);return this._def.getter()._parse({data:r.data,path:r.path,parent:r})}}c0.create=(t,n)=>new c0({getter:t,typeName:Fe.ZodLazy,...Ke(n)});class ph extends it{_parse(n){if(n.data!==this._def.value){const r=this._getOrReturnCtx(n);return Ee(r,{received:r.data,code:xe.invalid_literal,expected:this._def.value}),Ie}return{status:"valid",value:n.data}}get value(){return this._def.value}}ph.create=(t,n)=>new ph({value:t,typeName:Fe.ZodLiteral,...Ke(n)});function eE(t,n){return new Po({values:t,typeName:Fe.ZodEnum,...Ke(n)})}class Po extends it{_parse(n){if(typeof n.data!="string"){const r=this._getOrReturnCtx(n),s=this._def.values;return Ee(r,{expected:dt.joinValues(s),received:r.parsedType,code:xe.invalid_type}),Ie}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(n.data)){const r=this._getOrReturnCtx(n),s=this._def.values;return Ee(r,{received:r.data,code:xe.invalid_enum_value,options:s}),Ie}return la(n.data)}get options(){return this._def.values}get enum(){const n={};for(const r of this._def.values)n[r]=r;return n}get Values(){const n={};for(const r of this._def.values)n[r]=r;return n}get Enum(){const n={};for(const r of this._def.values)n[r]=r;return n}extract(n,r=this._def){return Po.create(n,{...this._def,...r})}exclude(n,r=this._def){return Po.create(this.options.filter(s=>!n.includes(s)),{...this._def,...r})}}Po.create=eE;class u0 extends it{_parse(n){const r=dt.getValidEnumValues(this._def.values),s=this._getOrReturnCtx(n);if(s.parsedType!==Te.string&&s.parsedType!==Te.number){const i=dt.objectValues(r);return Ee(s,{expected:dt.joinValues(i),received:s.parsedType,code:xe.invalid_type}),Ie}if(this._cache||(this._cache=new Set(dt.getValidEnumValues(this._def.values))),!this._cache.has(n.data)){const i=dt.objectValues(r);return Ee(s,{received:s.data,code:xe.invalid_enum_value,options:i}),Ie}return la(n.data)}get enum(){return this._def.values}}u0.create=(t,n)=>new u0({values:t,typeName:Fe.ZodNativeEnum,...Ke(n)});class Cu extends it{unwrap(){return this._def.type}_parse(n){const{ctx:r}=this._processInputParams(n);if(r.parsedType!==Te.promise&&r.common.async===!1)return Ee(r,{code:xe.invalid_type,expected:Te.promise,received:r.parsedType}),Ie;const s=r.parsedType===Te.promise?r.data:Promise.resolve(r.data);return la(s.then(i=>this._def.type.parseAsync(i,{path:r.path,errorMap:r.common.contextualErrorMap})))}}Cu.create=(t,n)=>new Cu({type:t,typeName:Fe.ZodPromise,...Ke(n)});class Ho extends it{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===Fe.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(n){const{status:r,ctx:s}=this._processInputParams(n),i=this._def.effect||null,c={addIssue:u=>{Ee(s,u),u.fatal?r.abort():r.dirty()},get path(){return s.path}};if(c.addIssue=c.addIssue.bind(c),i.type==="preprocess"){const u=i.transform(s.data,c);if(s.common.async)return Promise.resolve(u).then(async f=>{if(r.value==="aborted")return Ie;const g=await this._def.schema._parseAsync({data:f,path:s.path,parent:s});return g.status==="aborted"?Ie:g.status==="dirty"||r.value==="dirty"?Ki(g.value):g});{if(r.value==="aborted")return Ie;const f=this._def.schema._parseSync({data:u,path:s.path,parent:s});return f.status==="aborted"?Ie:f.status==="dirty"||r.value==="dirty"?Ki(f.value):f}}if(i.type==="refinement"){const u=f=>{const g=i.refinement(f,c);if(s.common.async)return Promise.resolve(g);if(g instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return f};if(s.common.async===!1){const f=this._def.schema._parseSync({data:s.data,path:s.path,parent:s});return f.status==="aborted"?Ie:(f.status==="dirty"&&r.dirty(),u(f.value),{status:r.value,value:f.value})}else return this._def.schema._parseAsync({data:s.data,path:s.path,parent:s}).then(f=>f.status==="aborted"?Ie:(f.status==="dirty"&&r.dirty(),u(f.value).then(()=>({status:r.value,value:f.value}))))}if(i.type==="transform")if(s.common.async===!1){const u=this._def.schema._parseSync({data:s.data,path:s.path,parent:s});if(!Bo(u))return Ie;const f=i.transform(u.value,c);if(f instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:r.value,value:f}}else return this._def.schema._parseAsync({data:s.data,path:s.path,parent:s}).then(u=>Bo(u)?Promise.resolve(i.transform(u.value,c)).then(f=>({status:r.value,value:f})):Ie);dt.assertNever(i)}}Ho.create=(t,n,r)=>new Ho({schema:t,typeName:Fe.ZodEffects,effect:n,...Ke(r)});Ho.createWithPreprocess=(t,n,r)=>new Ho({schema:n,effect:{type:"preprocess",transform:t},typeName:Fe.ZodEffects,...Ke(r)});class qr extends it{_parse(n){return this._getType(n)===Te.undefined?la(void 0):this._def.innerType._parse(n)}unwrap(){return this._def.innerType}}qr.create=(t,n)=>new qr({innerType:t,typeName:Fe.ZodOptional,...Ke(n)});class Vo extends it{_parse(n){return this._getType(n)===Te.null?la(null):this._def.innerType._parse(n)}unwrap(){return this._def.innerType}}Vo.create=(t,n)=>new Vo({innerType:t,typeName:Fe.ZodNullable,...Ke(n)});class gh extends it{_parse(n){const{ctx:r}=this._processInputParams(n);let s=r.data;return r.parsedType===Te.undefined&&(s=this._def.defaultValue()),this._def.innerType._parse({data:s,path:r.path,parent:r})}removeDefault(){return this._def.innerType}}gh.create=(t,n)=>new gh({innerType:t,typeName:Fe.ZodDefault,defaultValue:typeof n.default=="function"?n.default:()=>n.default,...Ke(n)});class vh extends it{_parse(n){const{ctx:r}=this._processInputParams(n),s={...r,common:{...r.common,issues:[]}},i=this._def.innerType._parse({data:s.data,path:s.path,parent:{...s}});return wu(i)?i.then(c=>({status:"valid",value:c.status==="valid"?c.value:this._def.catchValue({get error(){return new lr(s.common.issues)},input:s.data})})):{status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new lr(s.common.issues)},input:s.data})}}removeCatch(){return this._def.innerType}}vh.create=(t,n)=>new vh({innerType:t,typeName:Fe.ZodCatch,catchValue:typeof n.catch=="function"?n.catch:()=>n.catch,...Ke(n)});class d0 extends it{_parse(n){if(this._getType(n)!==Te.nan){const s=this._getOrReturnCtx(n);return Ee(s,{code:xe.invalid_type,expected:Te.nan,received:s.parsedType}),Ie}return{status:"valid",value:n.data}}}d0.create=t=>new d0({typeName:Fe.ZodNaN,...Ke(t)});class Y3 extends it{_parse(n){const{ctx:r}=this._processInputParams(n),s=r.data;return this._def.type._parse({data:s,path:r.path,parent:r})}unwrap(){return this._def.type}}class vp extends it{_parse(n){const{status:r,ctx:s}=this._processInputParams(n);if(s.common.async)return(async()=>{const c=await this._def.in._parseAsync({data:s.data,path:s.path,parent:s});return c.status==="aborted"?Ie:c.status==="dirty"?(r.dirty(),Ki(c.value)):this._def.out._parseAsync({data:c.value,path:s.path,parent:s})})();{const i=this._def.in._parseSync({data:s.data,path:s.path,parent:s});return i.status==="aborted"?Ie:i.status==="dirty"?(r.dirty(),{status:"dirty",value:i.value}):this._def.out._parseSync({data:i.value,path:s.path,parent:s})}}static create(n,r){return new vp({in:n,out:r,typeName:Fe.ZodPipeline})}}class yh extends it{_parse(n){const r=this._def.innerType._parse(n),s=i=>(Bo(i)&&(i.value=Object.freeze(i.value)),i);return wu(r)?r.then(i=>s(i)):s(r)}unwrap(){return this._def.innerType}}yh.create=(t,n)=>new yh({innerType:t,typeName:Fe.ZodReadonly,...Ke(n)});var Fe;(function(t){t.ZodString="ZodString",t.ZodNumber="ZodNumber",t.ZodNaN="ZodNaN",t.ZodBigInt="ZodBigInt",t.ZodBoolean="ZodBoolean",t.ZodDate="ZodDate",t.ZodSymbol="ZodSymbol",t.ZodUndefined="ZodUndefined",t.ZodNull="ZodNull",t.ZodAny="ZodAny",t.ZodUnknown="ZodUnknown",t.ZodNever="ZodNever",t.ZodVoid="ZodVoid",t.ZodArray="ZodArray",t.ZodObject="ZodObject",t.ZodUnion="ZodUnion",t.ZodDiscriminatedUnion="ZodDiscriminatedUnion",t.ZodIntersection="ZodIntersection",t.ZodTuple="ZodTuple",t.ZodRecord="ZodRecord",t.ZodMap="ZodMap",t.ZodSet="ZodSet",t.ZodFunction="ZodFunction",t.ZodLazy="ZodLazy",t.ZodLiteral="ZodLiteral",t.ZodEnum="ZodEnum",t.ZodEffects="ZodEffects",t.ZodNativeEnum="ZodNativeEnum",t.ZodOptional="ZodOptional",t.ZodNullable="ZodNullable",t.ZodDefault="ZodDefault",t.ZodCatch="ZodCatch",t.ZodPromise="ZodPromise",t.ZodBranded="ZodBranded",t.ZodPipeline="ZodPipeline",t.ZodReadonly="ZodReadonly"})(Fe||(Fe={}));const Yt=Ir.create,Ta=mh.create;Zr.create;const Z3=Ma.create,Xo=Gt.create;Eu.create;_u.create;Rs.create;const X3=ph.create;Po.create;Cu.create;qr.create;Vo.create;const f0=(t,n,r)=>{if(t&&"reportValidity"in t){const s=Ce(r,n);t.setCustomValidity(s&&s.message||""),t.reportValidity()}},bh=(t,n)=>{for(const r in n.fields){const s=n.fields[r];s&&s.ref&&"reportValidity"in s.ref?f0(s.ref,r,t):s&&s.refs&&s.refs.forEach(i=>f0(i,r,t))}},m0=(t,n)=>{n.shouldUseNativeValidation&&bh(t,n);const r={};for(const s in t){const i=Ce(n.fields,s),c=Object.assign(t[s]||{},{ref:i&&i.ref});if(K3(n.names||Object.keys(t),s)){const u=Object.assign({},Ce(r,s));xt(u,"root",c),xt(r,s,u)}else xt(r,s,c)}return r},K3=(t,n)=>{const r=h0(n);return t.some(s=>h0(s).match(`^${r}\\.\\d+`))};function h0(t){return t.replace(/\]|\[/g,"")}function tE(t,n,r){function s(f,g){var p;Object.defineProperty(f,"_zod",{value:f._zod??{},enumerable:!1}),(p=f._zod).traits??(p.traits=new Set),f._zod.traits.add(t),n(f,g);for(const y in u.prototype)y in f||Object.defineProperty(f,y,{value:u.prototype[y].bind(f)});f._zod.constr=u,f._zod.def=g}const i=(r==null?void 0:r.Parent)??Object;class c extends i{}Object.defineProperty(c,"name",{value:t});function u(f){var g;const p=r!=null&&r.Parent?new c:this;s(p,f),(g=p._zod).deferred??(g.deferred=[]);for(const y of p._zod.deferred)y();return p}return Object.defineProperty(u,"init",{value:s}),Object.defineProperty(u,Symbol.hasInstance,{value:f=>{var g,p;return r!=null&&r.Parent&&f instanceof r.Parent?!0:(p=(g=f==null?void 0:f._zod)==null?void 0:g.traits)==null?void 0:p.has(t)}}),Object.defineProperty(u,"name",{value:t}),u}class Q3 extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}const W3={};function nE(t){return W3}function J3(t,n){return typeof n=="bigint"?n.toString():n}const aE=Error.captureStackTrace?Error.captureStackTrace:(...t)=>{};function Fc(t){return typeof t=="string"?t:t==null?void 0:t.message}function rE(t,n,r){var i,c,u,f,g,p;const s={...t,path:t.path??[]};if(!t.message){const y=Fc((u=(c=(i=t.inst)==null?void 0:i._zod.def)==null?void 0:c.error)==null?void 0:u.call(c,t))??Fc((f=n==null?void 0:n.error)==null?void 0:f.call(n,t))??Fc((g=r.customError)==null?void 0:g.call(r,t))??Fc((p=r.localeError)==null?void 0:p.call(r,t))??"Invalid input";s.message=y}return delete s.inst,delete s.continue,n!=null&&n.reportInput||delete s.input,s}const sE=(t,n)=>{t.name="$ZodError",Object.defineProperty(t,"_zod",{value:t._zod,enumerable:!1}),Object.defineProperty(t,"issues",{value:n,enumerable:!1}),Object.defineProperty(t,"message",{get(){return JSON.stringify(n,J3,2)},enumerable:!0}),Object.defineProperty(t,"toString",{value:()=>t.message,enumerable:!1})},e5=tE("$ZodError",sE),oE=tE("$ZodError",sE,{Parent:Error}),t5=t=>(n,r,s,i)=>{const c=s?Object.assign(s,{async:!1}):{async:!1},u=n._zod.run({value:r,issues:[]},c);if(u instanceof Promise)throw new Q3;if(u.issues.length){const f=new((i==null?void 0:i.Err)??t)(u.issues.map(g=>rE(g,c,nE())));throw aE(f,i==null?void 0:i.callee),f}return u.value},n5=t5(oE),a5=t=>async(n,r,s,i)=>{const c=s?Object.assign(s,{async:!0}):{async:!0};let u=n._zod.run({value:r,issues:[]},c);if(u instanceof Promise&&(u=await u),u.issues.length){const f=new((i==null?void 0:i.Err)??t)(u.issues.map(g=>rE(g,c,nE())));throw aE(f,i==null?void 0:i.callee),f}return u.value},r5=a5(oE);function p0(t,n){try{var r=t()}catch(s){return n(s)}return r&&r.then?r.then(void 0,n):r}function s5(t,n){for(var r={};t.length;){var s=t[0],i=s.code,c=s.message,u=s.path.join(".");if(!r[u])if("unionErrors"in s){var f=s.unionErrors[0].errors[0];r[u]={message:f.message,type:f.code}}else r[u]={message:c,type:i};if("unionErrors"in s&&s.unionErrors.forEach(function(y){return y.errors.forEach(function(v){return t.push(v)})}),n){var g=r[u].types,p=g&&g[s.code];r[u]=up(u,n,r,i,p?[].concat(p,s.message):s.message)}t.shift()}return r}function o5(t,n){for(var r={};t.length;){var s=t[0],i=s.code,c=s.message,u=s.path.join(".");if(!r[u])if(s.code==="invalid_union"&&s.errors.length>0){var f=s.errors[0][0];r[u]={message:f.message,type:f.code}}else r[u]={message:c,type:i};if(s.code==="invalid_union"&&s.errors.forEach(function(y){return y.forEach(function(v){return t.push(v)})}),n){var g=r[u].types,p=g&&g[s.code];r[u]=up(u,n,r,i,p?[].concat(p,s.message):s.message)}t.shift()}return r}function Io(t,n,r){if(r===void 0&&(r={}),(function(s){return"_def"in s&&typeof s._def=="object"&&"typeName"in s._def})(t))return function(s,i,c){try{return Promise.resolve(p0(function(){return Promise.resolve(t[r.mode==="sync"?"parse":"parseAsync"](s,n)).then(function(u){return c.shouldUseNativeValidation&&bh({},c),{errors:{},values:r.raw?Object.assign({},s):u}})},function(u){if((function(f){return Array.isArray(f==null?void 0:f.issues)})(u))return{values:{},errors:m0(s5(u.errors,!c.shouldUseNativeValidation&&c.criteriaMode==="all"),c)};throw u}))}catch(u){return Promise.reject(u)}};if((function(s){return"_zod"in s&&typeof s._zod=="object"})(t))return function(s,i,c){try{return Promise.resolve(p0(function(){return Promise.resolve((r.mode==="sync"?n5:r5)(t,s,n)).then(function(u){return c.shouldUseNativeValidation&&bh({},c),{errors:{},values:r.raw?Object.assign({},s):u}})},function(u){if((function(f){return f instanceof e5})(u))return{values:{},errors:m0(o5(u.issues,!c.shouldUseNativeValidation&&c.criteriaMode==="all"),c)};throw u}))}catch(u){return Promise.reject(u)}};throw new Error("Invalid input: not a Zod schema")}const i5=()=>{const{login:t,checkLicense:n,setApiUrl:r,setApiKey:s,isAuthenticated:i,licenseState:c,apiUrl:u}=zu(),f=Xr(),[g,p]=b.useState(!1),[y,v]=b.useState("");b.useEffect(()=>{i&&c==="licensed"&&f("/manager",{replace:!0})},[i,c,f]);const w=window.location.origin,C=Xo({apiUrl:Yt().min(1,{message:"URL da API é obrigatória"}).url({message:`URL inválida. Use o formato: ${w}`}).refine(E=>E.startsWith("http://")||E.startsWith("https://"),{message:"URL deve começar com http:// ou https://"}),apiKey:Yt().min(1,{message:"API Key é obrigatória"}).min(10,{message:"API Key deve ter pelo menos 10 caracteres"})}),S=Lo({resolver:Io(C),defaultValues:{apiUrl:u,apiKey:""}}),_=async E=>{p(!0),v("");try{const R=E.apiUrl.replace(/\/$/,"");if(Ze.info("Verificando licenca..."),await n(R,E.apiKey)!=="licensed"){Ze.info("Licenca necessaria",{description:"Redirecionando para registro de licenca..."});const A=`${window.location.origin}/manager/license/callback`,D=await TO(A,R,E.apiKey);if(!D.register_url){Ze.error("Erro",{description:D.message||"Falha ao iniciar registro de licenca."}),v(D.message||"Falha ao iniciar registro.");return}r(R),s(E.apiKey),window.location.href=D.register_url;return}await t(E.apiUrl,E.apiKey),Ze.success("Conectado com sucesso!",{description:"Licenca valida. Bem-vindo!"}),f("/manager",{replace:!0})}catch(R){console.error("Erro ao fazer login:",R);const k=R instanceof Error?R.message:"Erro ao conectar. Verifique a URL e API Key.";Ze.error("Erro",{description:k}),v(k)}finally{p(!1)}};return h.jsx("div",{className:"min-h-screen flex items-center justify-center p-4 bg-gradient-to-t from-primary/20 via-background/95 to-background relative",children:h.jsxs("div",{className:"w-full max-w-md space-y-6",children:[h.jsx("div",{className:"text-center",children:h.jsx("h1",{className:"text-3xl font-bold text-primary",children:"Evolution GO"})}),h.jsxs("div",{className:"bg-background/80 backdrop-blur-sm border rounded-lg p-6 shadow-lg",children:[h.jsxs("div",{className:"space-y-2 mb-6",children:[h.jsx("h2",{className:"text-2xl font-bold",children:"Entrar na sua conta"}),h.jsx("p",{className:"text-muted-foreground",children:"Digite suas credenciais para acessar o sistema"})]}),y&&h.jsxs(o3,{variant:"destructive",className:"mb-4",children:[h.jsx(nR,{className:"h-4 w-4"}),h.jsx(i3,{children:"Erro"}),h.jsx(l3,{children:y})]}),h.jsxs("form",{onSubmit:S.handleSubmit(_),className:"space-y-4",children:[h.jsxs("div",{className:"space-y-2",children:[h.jsx(Pr,{htmlFor:"login-apiUrl",children:"URL da API Evolution GO"}),h.jsx(Ra,{id:"login-apiUrl",type:"text",placeholder:w,disabled:g,...S.register("apiUrl")}),S.formState.errors.apiUrl&&h.jsx("p",{className:"text-destructive text-sm",children:S.formState.errors.apiUrl.message})]}),h.jsxs("div",{className:"space-y-2",children:[h.jsx(Pr,{htmlFor:"login-apiKey",children:"API Key (GLOBAL_API_KEY)"}),h.jsx(Ra,{id:"login-apiKey",type:"password",placeholder:"Sua chave de API",disabled:g,...S.register("apiKey")}),S.formState.errors.apiKey&&h.jsx("p",{className:"text-destructive text-sm",children:S.formState.errors.apiKey.message})]}),h.jsx("div",{className:"text-xs text-muted-foreground",children:h.jsxs("p",{children:[h.jsx("strong",{children:"Dica:"})," A API Key é o valor da variável"," ",h.jsx("code",{className:"relative rounded bg-muted px-[0.3rem] py-[0.2rem] font-mono text-xs",children:"GLOBAL_API_KEY"})," ","configurada no arquivo .env do Evolution GO."]})}),h.jsx(ut,{type:"submit",disabled:g,className:"w-full",children:g?"Conectando...":"Entrar"})]})]}),h.jsx("div",{className:"text-center text-xs text-muted-foreground",children:h.jsxs("p",{children:["Ao continuar, você concorda com nossos"," ",h.jsx("a",{href:"#",className:"underline hover:text-primary",children:"Termos de Serviço"})," ","e"," ",h.jsx("a",{href:"#",className:"underline hover:text-primary",children:"Política de Privacidade"}),"."]})})]})})};function l5(){return h.jsxs("div",{className:"p-6",children:[h.jsx("h1",{className:"mb-4 text-2xl font-bold text-foreground",children:"Dashboard"}),h.jsx("p",{className:"text-muted-foreground",children:"Dashboard content will be implemented here..."})]})}const iE=t=>{const n=t.connected?"open":"close";let r;if(t.qrcode){const s=t.qrcode.split("|");r={base64:s[0]||void 0,code:s[1]||void 0}}return{id:t.id,instanceName:t.name,status:n,apikey:t.token,owner:t.jid?t.jid.split("@")[0]:"",profileName:t.name,connected:t.connected,qrcode:r,webhook:t.webhook||void 0,rabbitmqEnable:t.rabbitmqEnable||void 0,websocketEnable:t.websocketEnable||void 0,natsEnable:t.natsEnable||void 0,events:t.events||void 0,disconnectReason:t.disconnect_reason||void 0,createdAt:t.createdAt,alwaysOnline:t.alwaysOnline,rejectCall:t.rejectCall,readMessages:t.readMessages,ignoreGroups:t.ignoreGroups,ignoreStatus:t.ignoreStatus}},c5=async()=>(await hn.get("/instance/all")).data.data.map(iE),$c=async t=>{const n=await hn.get(`/instance/info/${t}`);return iE(n.data.data)},u5=async t=>(await hn.post("/instance/create",t)).data,xh=async(t,n)=>{const r={webhookUrl:(n==null?void 0:n.webhookUrl)||"",subscribe:(n==null?void 0:n.subscribe)||[],rabbitmqEnable:(n==null?void 0:n.rabbitmqEnable)||"",websocketEnable:(n==null?void 0:n.websocketEnable)||"",natsEnable:(n==null?void 0:n.natsEnable)||""};return(await hn.post("/instance/connect",r,{headers:{apikey:t}})).data.data},d5=async(t,n)=>({pairingCode:(await hn.post("/instance/pair",{subscribe:n.subscribe,phone:n.phone},{headers:{apikey:t}})).data.data.PairingCode}),lE=async(t,n,r)=>{await hn.put(`/instance/${t}/advanced-settings`,r,{headers:{apikey:n}})},Im=async t=>{const n=await hn.get("/instance/qr",{headers:{apikey:t}});return{qrcode:n.data.data.Qrcode,code:n.data.data.Code}},cE=async t=>{await hn.delete("/instance/logout",{headers:{apikey:t}})},uE=async t=>{await hn.delete(`/instance/delete/${t}`)},f5=async(t,n)=>(await hn.post("/send/text",n,{headers:{apikey:t}})).data,dE=r1()(t=>({instances:[],isLoading:!1,error:null,fetchInstances:async()=>{t({isLoading:!0,error:null});try{const n=await c5();t({instances:n,isLoading:!1})}catch(n){console.error("Failed to fetch instances:",n),t({error:n instanceof Error?n.message:"Erro ao buscar instâncias",isLoading:!1})}},addInstance:n=>{t(r=>({instances:[...r.instances,n]}))},updateInstance:(n,r)=>{t(s=>({instances:s.instances.map(i=>i.instanceName===n?{...i,...r}:i)}))},removeInstance:n=>{t(r=>({instances:r.instances.filter(s=>s.instanceName!==n)}))},setLoading:n=>{t({isLoading:n})},setError:n=>{t({error:n})},clearError:()=>{t({error:null})}})),m5=t=>t==="open"?h.jsx(pu,{className:"bg-green-500/10 text-green-500 hover:bg-green-500/20",children:"Conectado"}):h.jsx(pu,{className:"bg-red-500/10 text-red-500 hover:bg-red-500/20",children:"Desconectado"});function h5({instance:t,isDeleting:n,onSettings:r,onDelete:s,onConnect:i,onDisconnect:c,onSendMessage:u}){const f=t.status==="open";return h.jsx(d3,{className:"group relative bg-sidebar border-sidebar-border hover:bg-sidebar-accent/30 transition-all duration-300 hover:shadow-lg hover:shadow-black/10 overflow-hidden",children:h.jsxs(f3,{className:"p-0",children:[h.jsxs("div",{className:"flex items-center gap-3 p-4 border-b border-sidebar-border",children:[t.profilePicUrl&&h.jsx("div",{className:"flex-shrink-0 dark",children:h.jsx("div",{className:"rounded-lg bg-gray-900 flex items-center justify-center w-14 h-14 overflow-hidden",children:h.jsx("img",{src:t.profilePicUrl,alt:t.profileName||t.instanceName,className:"w-12 h-12 object-cover rounded-lg",onError:g=>{const p=g.target;p.style.display="none"}})})}),h.jsxs("div",{className:"flex-1 min-w-0",children:[h.jsx("h3",{className:"font-semibold text-base truncate text-sidebar-foreground",children:t.profileName||t.instanceName}),h.jsx("p",{className:"text-xs text-sidebar-foreground/60 truncate",children:t.instanceName})]}),h.jsx("div",{className:"flex-shrink-0",children:m5(t.status)})]}),h.jsxs("div",{className:"px-4 py-3 text-xs text-sidebar-foreground/70 space-y-1",children:[h.jsxs("div",{className:"flex items-center justify-between",children:[h.jsx("span",{children:"Status"}),h.jsx("span",{className:"font-mono",children:t.status})]}),t.profileStatus&&h.jsxs("div",{className:"flex items-center justify-between",children:[h.jsx("span",{children:"Recado"}),h.jsx("span",{className:"font-mono truncate ml-2 max-w-[150px]",children:t.profileStatus})]}),t.owner&&h.jsxs("div",{className:"flex items-center justify-between",children:[h.jsx("span",{children:"Proprietário"}),h.jsx("span",{className:"font-mono truncate ml-2 max-w-[150px]",children:t.owner})]})]}),h.jsxs("div",{className:"flex border-t border-sidebar-border opacity-0 group-hover:opacity-100 transition-opacity duration-200",children:[!f&&h.jsxs(ut,{variant:"ghost",className:"flex-1 rounded-none h-12 text-green-500 hover:text-green-400 hover:bg-green-500/10",onClick:()=>i(t),children:[h.jsx(V0,{className:"h-4 w-4 mr-2"}),"Conectar"]}),f&&h.jsxs(ut,{variant:"ghost",className:"flex-1 rounded-none h-12 text-yellow-500 hover:text-yellow-400 hover:bg-yellow-500/10",onClick:()=>c(t),children:[h.jsx(jR,{className:"h-4 w-4 mr-2"}),"Desconectar"]}),h.jsx("div",{className:"w-px bg-sidebar-border"}),f&&u&&h.jsxs(h.Fragment,{children:[h.jsx(ut,{variant:"ghost",className:"rounded-none h-12 px-4 text-blue-500 hover:text-blue-400 hover:bg-blue-500/10",onClick:()=>u(t),children:h.jsx(NR,{className:"h-4 w-4"})}),h.jsx("div",{className:"w-px bg-sidebar-border"})]}),h.jsx(ut,{variant:"ghost",className:"rounded-none h-12 px-4 text-gray-500 hover:text-gray-300 hover:bg-gray-500/10",onClick:()=>r(t),children:h.jsx(PR,{className:"h-4 w-4"})}),h.jsx("div",{className:"w-px bg-sidebar-border"}),h.jsx(ut,{variant:"ghost",className:"rounded-none h-12 px-4 text-red-500 hover:text-red-400 hover:bg-red-500/10",disabled:n===t.instanceName,onClick:()=>s(t),children:h.jsx(Th,{className:"h-4 w-4"})})]})]})})}function p5({title:t,subtitle:n,searchValue:r,onSearchChange:s,searchPlaceholder:i="Buscar...",primaryAction:c,secondaryActions:u=[],moreActions:f=[],filters:g=[],onFilterClick:p,showFilters:y=!1,selectedCount:v=0,onClearSelection:w,bulkActions:C=[],className:S="",children:_}){const E=v>0,R=u.filter(A=>A.show!==!1),k=f.filter(A=>A.show!==!1);return h.jsxs("div",{className:`space-y-6 ${S} mb-4`,children:[h.jsxs("div",{className:"flex flex-col gap-4 md:flex-row md:items-start md:justify-between",children:[h.jsxs("div",{className:"flex-1",children:[h.jsx("h1",{className:"text-2xl font-bold tracking-tight text-sidebar-foreground mb-2 dark:text-gray-200",children:t}),n&&h.jsx("p",{className:"text-sm text-sidebar-foreground/70 dark:text-gray-400",children:n})]}),c&&c.show!==!1&&h.jsx("div",{className:"flex-shrink-0",children:h.jsxs(ut,{onClick:c.onClick,variant:c.variant||"default",className:c.className,children:[c.icon&&h.jsx("span",{className:"mr-2",children:c.icon}),c.label]})})]}),h.jsxs("div",{className:"flex flex-col gap-3 md:flex-row md:items-center md:justify-between",children:[h.jsxs("div",{className:"flex items-center gap-3 flex-1",children:[s&&h.jsxs("div",{className:"relative flex-1 max-w-md",children:[h.jsx(UR,{className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-sidebar-foreground/60 dark:text-gray-200"}),h.jsx(Ra,{type:"search",placeholder:i,value:r,onChange:A=>s(A.target.value),className:"pl-9 bg-sidebar border-sidebar-border text-sidebar-foreground placeholder:text-sidebar-foreground/50 focus:border-sidebar-border dark:text-gray-400 dark:placeholder:text-gray-400"})]}),y&&p&&h.jsxs(ut,{variant:"outline",size:"sm",onClick:p,className:"bg-sidebar border-sidebar-border text-sidebar-foreground hover:bg-sidebar-accent whitespace-nowrap dark:text-gray-400 dark:hover:bg-sidebar-accent",children:[h.jsx(pR,{className:"h-4 w-4 mr-2"}),"Filtros",g.length>0&&h.jsx(pu,{variant:"secondary",className:"ml-2 h-5 px-1.5 text-xs bg-sidebar-accent",children:g.length})]})]}),h.jsxs("div",{className:"flex items-center gap-2",children:[R.map((A,D)=>h.jsxs(ut,{variant:A.variant||"outline",size:"sm",onClick:A.onClick,className:"bg-sidebar border-sidebar-border text-sidebar-foreground hover:bg-sidebar-accent dark:text-gray-400 dark:hover:bg-sidebar-accent",children:[A.icon&&h.jsx("span",{className:"mr-2",children:A.icon}),A.label]},D)),k.length>0&&h.jsxs(p3,{children:[h.jsx(g3,{asChild:!0,children:h.jsx(ut,{variant:"outline",size:"sm",className:"bg-sidebar border-sidebar-border text-sidebar-foreground hover:bg-sidebar-accent dark:text-gray-400 dark:hover:bg-sidebar-accent",children:h.jsx(cR,{className:"h-4 w-4"})})}),h.jsx(v3,{align:"end",className:"bg-sidebar border-sidebar-border text-sidebar-foreground dark:text-gray-400",children:k.map((A,D)=>h.jsxs(y3,{onClick:A.onClick,className:`hover:bg-sidebar-accent ${A.variant==="destructive"?"text-red-400":""} dark:text-gray-400`,children:[A.icon&&h.jsx("span",{className:"mr-2",children:A.icon}),A.label]},D))})]})]})]}),E&&h.jsxs("div",{className:"flex items-center justify-between rounded-lg bg-sidebar-accent/50 border border-sidebar-border px-4 py-2",children:[h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsxs("span",{className:"text-sm font-medium text-sidebar-foreground dark:text-gray-400",children:[v," selecionado",v>1?"s":""]}),w&&h.jsxs(ut,{variant:"ghost",size:"sm",onClick:w,className:"h-7 px-2 text-sidebar-foreground/70 hover:text-sidebar-foreground hover:bg-sidebar-accent dark:text-gray-400 dark:hover:text-gray-400 dark:hover:bg-sidebar-accent",children:[h.jsx(el,{className:"h-3 w-3 mr-1"}),"Limpar"]})]}),C.length>0&&h.jsx("div",{className:"flex items-center gap-2",children:C.map((A,D)=>h.jsxs(ut,{variant:A.variant||"outline",size:"sm",onClick:A.onClick,className:"h-7 bg-sidebar-accent border-sidebar-border text-sidebar-foreground hover:bg-sidebar dark:text-gray-400 dark:hover:bg-sidebar",children:[A.icon&&h.jsx("span",{className:"mr-1.5",children:A.icon}),A.label]},D))})]}),g.length>0&&h.jsx("div",{className:"flex flex-wrap gap-2",children:g.map((A,D)=>h.jsxs(pu,{variant:"secondary",className:"pl-2 pr-1 py-1 bg-sidebar-accent text-sidebar-foreground hover:bg-sidebar dark:text-gray-400 dark:hover:bg-sidebar dark:bg-sidebar-accent/50",children:[A.label,": ",A.value,h.jsx(ut,{variant:"ghost",size:"sm",onClick:A.onRemove,className:"ml-1 h-4 w-4 p-0 hover:bg-transparent text-sidebar-foreground/60 hover:text-sidebar-foreground dark:text-gray-400 dark:hover:text-gray-400",children:h.jsx(el,{className:"h-3 w-3"})})]},D))}),_]})}function g5({totalCount:t,selectedCount:n,searchValue:r,onSearchChange:s,onNewInstance:i,onClearSelection:c}){const u={label:"Nova Instância",icon:h.jsx(Xm,{className:"h-4 w-4"}),onClick:i};return h.jsx(p5,{title:"Instâncias",subtitle:"Gerencie suas instâncias WhatsApp do Evolution GO",totalCount:t,selectedCount:n,searchValue:r,onSearchChange:s,searchPlaceholder:"Buscar instâncias...",primaryAction:u,onClearSelection:c,showFilters:!1,className:"mb-4"})}const un=[];for(let t=0;t<256;++t)un.push((t+256).toString(16).slice(1));function v5(t,n=0){return(un[t[n+0]]+un[t[n+1]]+un[t[n+2]]+un[t[n+3]]+"-"+un[t[n+4]]+un[t[n+5]]+"-"+un[t[n+6]]+un[t[n+7]]+"-"+un[t[n+8]]+un[t[n+9]]+"-"+un[t[n+10]]+un[t[n+11]]+un[t[n+12]]+un[t[n+13]]+un[t[n+14]]+un[t[n+15]]).toLowerCase()}let qm;const y5=new Uint8Array(16);function b5(){if(!qm){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");qm=crypto.getRandomValues.bind(crypto)}return qm(y5)}const x5=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),g0={randomUUID:x5};function w5(t,n,r){var i;if(g0.randomUUID&&!t)return g0.randomUUID();t=t||{};const s=t.random??((i=t.rng)==null?void 0:i.call(t))??b5();if(s.length<16)throw new Error("Random bytes length must be >= 16");return s[6]=s[6]&15|64,s[8]=s[8]&63|128,v5(s)}const S5=Xo({instanceName:Yt().min(1,"Nome da instância é obrigatório").min(3,"Nome deve ter pelo menos 3 caracteres").max(50,"Nome deve ter no máximo 50 caracteres").regex(/^[a-zA-Z0-9-_]+$/,"Nome deve conter apenas letras, números, hífen e underscore"),token:Yt().optional(),proxyHost:Yt().optional(),proxyPort:Yt().optional(),proxyUsername:Yt().optional(),proxyPassword:Yt().optional()});function E5({open:t,onOpenChange:n}){const[r,s]=b.useState(!1),[i,c]=b.useState(!1),{addInstance:u,fetchInstances:f}=dE(),{register:g,handleSubmit:p,reset:y,formState:{errors:v}}=Lo({resolver:Io(S5),defaultValues:{instanceName:"",token:"",proxyHost:"",proxyPort:"",proxyUsername:"",proxyPassword:""}}),w=async S=>{s(!0);try{const _={name:S.instanceName,token:S.token||w5()};S.proxyHost&&S.proxyPort&&(_.proxy={host:S.proxyHost,port:S.proxyPort,username:S.proxyUsername,password:S.proxyPassword});const E=await u5(_);u(E),Ze.success("Instância criada com sucesso!",{description:`A instância "${S.instanceName}" foi criada.`}),await f(),n(!1),y()}catch(_){console.error("Erro ao criar instância:",_),Ze.error(_ instanceof Error?_.message:"Erro ao criar instância. Tente novamente.")}finally{s(!1)}},C=()=>{r||(n(!1),y(),c(!1))};return h.jsx(gu,{open:t,onOpenChange:C,children:h.jsxs(vu,{className:"sm:max-w-md",children:[h.jsxs(yu,{children:[h.jsxs(bu,{className:"flex items-center gap-2",children:[h.jsx(Xm,{className:"h-5 w-5 text-primary"}),"Nova Instância"]}),h.jsx(xu,{className:"text-sidebar-foreground/70",children:"Crie uma nova instância WhatsApp para gerenciar suas conversas"})]}),h.jsxs("form",{onSubmit:p(w),className:"space-y-4",children:[h.jsxs("div",{className:"space-y-2",children:[h.jsxs(Pr,{htmlFor:"instanceName",children:["Nome da Instância ",h.jsx("span",{className:"text-red-500",children:"*"})]}),h.jsx(Ra,{id:"instanceName",type:"text",placeholder:"ex: minha-instancia",disabled:r,...g("instanceName"),className:"bg-sidebar border-sidebar-border text-sidebar-foreground placeholder:text-sidebar-foreground/50"}),v.instanceName&&h.jsx("p",{className:"text-destructive text-sm",children:v.instanceName.message}),h.jsx("p",{className:"text-xs text-sidebar-foreground/60",children:"Use apenas letras, números, hífen (-) e underscore (_)"})]}),h.jsxs("div",{className:"space-y-2",children:[h.jsx(Pr,{htmlFor:"token",children:"Token (Opcional)"}),h.jsx(Ra,{id:"token",type:"text",placeholder:"Token personalizado (UUID)",disabled:r,...g("token"),className:"bg-sidebar border-sidebar-border text-sidebar-foreground placeholder:text-sidebar-foreground/50"}),v.token&&h.jsx("p",{className:"text-destructive text-sm",children:v.token.message}),h.jsx("p",{className:"text-xs text-sidebar-foreground/60",children:"Se não informado, será gerado um UUID automaticamente"})]}),h.jsxs("div",{className:"space-y-2",children:[h.jsxs(ut,{type:"button",variant:"outline",onClick:()=>c(!i),disabled:r,className:"w-full justify-between bg-sidebar border-sidebar-border text-sidebar-foreground hover:bg-sidebar-accent",children:[h.jsx("span",{children:"Configuração de Proxy (Opcional)"}),i?h.jsx(eR,{className:"h-4 w-4"}):h.jsx(Zm,{className:"h-4 w-4"})]}),i&&h.jsxs("div",{className:"space-y-4 pt-2 border-t border-sidebar-border",children:[h.jsxs("div",{className:"space-y-2",children:[h.jsx(Pr,{htmlFor:"proxyHost",children:"Host do Proxy"}),h.jsx(Ra,{id:"proxyHost",type:"text",placeholder:"ex: proxy.example.com",disabled:r,...g("proxyHost"),className:"bg-sidebar border-sidebar-border text-sidebar-foreground placeholder:text-sidebar-foreground/50"}),v.proxyHost&&h.jsx("p",{className:"text-destructive text-sm",children:v.proxyHost.message})]}),h.jsxs("div",{className:"space-y-2",children:[h.jsx(Pr,{htmlFor:"proxyPort",children:"Porta do Proxy"}),h.jsx(Ra,{id:"proxyPort",type:"text",placeholder:"ex: 8080",disabled:r,...g("proxyPort"),className:"bg-sidebar border-sidebar-border text-sidebar-foreground placeholder:text-sidebar-foreground/50"}),v.proxyPort&&h.jsx("p",{className:"text-destructive text-sm",children:v.proxyPort.message})]}),h.jsxs("div",{className:"space-y-2",children:[h.jsx(Pr,{htmlFor:"proxyUsername",children:"Usuário (Opcional)"}),h.jsx(Ra,{id:"proxyUsername",type:"text",placeholder:"Usuário do proxy",disabled:r,...g("proxyUsername"),className:"bg-sidebar border-sidebar-border text-sidebar-foreground placeholder:text-sidebar-foreground/50"}),v.proxyUsername&&h.jsx("p",{className:"text-destructive text-sm",children:v.proxyUsername.message})]}),h.jsxs("div",{className:"space-y-2",children:[h.jsx(Pr,{htmlFor:"proxyPassword",children:"Senha (Opcional)"}),h.jsx(Ra,{id:"proxyPassword",type:"password",placeholder:"Senha do proxy",disabled:r,...g("proxyPassword"),className:"bg-sidebar border-sidebar-border text-sidebar-foreground placeholder:text-sidebar-foreground/50"}),v.proxyPassword&&h.jsx("p",{className:"text-destructive text-sm",children:v.proxyPassword.message})]})]})]}),h.jsxs(QS,{className:"flex gap-2 sm:gap-0",children:[h.jsx(ut,{type:"button",variant:"outline",onClick:C,disabled:r,className:"bg-sidebar border-sidebar-border text-sidebar-foreground hover:bg-sidebar-accent",children:"Cancelar"}),h.jsx(ut,{type:"submit",disabled:r,children:r?h.jsxs(h.Fragment,{children:[h.jsx(H0,{className:"mr-2 h-4 w-4 animate-spin"}),"Criando..."]}):h.jsxs(h.Fragment,{children:[h.jsx(Xm,{className:"mr-2 h-4 w-4"}),"Criar Instância"]})})]})]})]})})}function _5({instance:t,open:n,onOpenChange:r,onRefresh:s}){var f,g;const[i,c]=b.useState(!1);b.useEffect(()=>{if(!n||!t||t.connected)return;const p=setInterval(()=>{s&&(console.log("Auto-refreshing QR Code and checking connection..."),s().catch(y=>{console.error("Auto-refresh failed:",y)}))},1e4);return()=>clearInterval(p)},[n,t,s]);const u=async()=>{if(s){c(!0);try{await s(),Ze.success("QR Code atualizado!")}catch(p){console.error("Erro ao atualizar QR Code:",p),Ze.error("Erro ao atualizar QR Code")}finally{c(!1)}}};return t?t.connected?h.jsx(gu,{open:n,onOpenChange:r,children:h.jsxs(vu,{className:"sm:max-w-md",children:[h.jsxs(yu,{children:[h.jsxs(bu,{className:"flex items-center gap-2 text-green-500",children:[h.jsx(kb,{className:"h-5 w-5"}),"Conectado com Sucesso!"]}),h.jsxs(xu,{className:"text-sidebar-foreground/70",children:["A instância ",t.instanceName," foi conectada ao WhatsApp."]})]}),h.jsxs("div",{className:"flex flex-col items-center gap-4 py-6",children:[h.jsx("div",{className:"rounded-full bg-green-500/10 p-4",children:h.jsx(kb,{className:"h-12 w-12 text-green-500"})}),t.profileName&&h.jsxs("div",{className:"text-center",children:[h.jsx("p",{className:"text-sm text-sidebar-foreground/60",children:"Conectado como"}),h.jsx("p",{className:"text-lg font-semibold text-sidebar-foreground",children:t.profileName})]})]}),h.jsx("div",{className:"flex justify-end",children:h.jsx(ut,{onClick:()=>r(!1),className:"w-full sm:w-auto",children:"Fechar"})})]})}):h.jsx(gu,{open:n,onOpenChange:r,children:h.jsxs(vu,{className:"sm:max-w-md",children:[h.jsxs(yu,{children:[h.jsxs(bu,{className:"flex items-center gap-2",children:[h.jsx(Mb,{className:"h-5 w-5 text-primary"}),"Conectar WhatsApp"]}),h.jsxs(xu,{className:"text-sidebar-foreground/70",children:["Escaneie o QR Code abaixo com seu WhatsApp para conectar a instância"," ",h.jsx("strong",{children:t.instanceName})]})]}),h.jsxs("div",{className:"space-y-4",children:[h.jsxs("div",{className:"flex flex-col items-center gap-4",children:[(f=t.qrcode)!=null&&f.base64?h.jsx("div",{className:"rounded-lg border-2 border-sidebar-border bg-white p-4",children:h.jsx("img",{src:t.qrcode.base64,alt:"QR Code",className:"h-64 w-64"})}):h.jsx("div",{className:"flex h-64 w-64 items-center justify-center rounded-lg border-2 border-dashed border-sidebar-border bg-sidebar",children:h.jsxs("div",{className:"text-center",children:[h.jsx(Mb,{className:"mx-auto h-12 w-12 text-sidebar-foreground/40"}),h.jsx("p",{className:"mt-2 text-sm text-sidebar-foreground/60",children:"Aguardando QR Code..."})]})}),((g=t.qrcode)==null?void 0:g.pairingCode)&&h.jsxs("div",{className:"w-full rounded-lg bg-sidebar-accent p-3 text-center",children:[h.jsx("p",{className:"text-xs text-sidebar-foreground/60",children:"Código de Pareamento"}),h.jsx("p",{className:"mt-1 font-mono text-lg font-semibold text-sidebar-foreground",children:t.qrcode.pairingCode})]})]}),h.jsxs("div",{className:"rounded-lg bg-sidebar-accent p-4",children:[h.jsx("p",{className:"text-sm font-medium text-sidebar-foreground",children:"Como conectar:"}),h.jsxs("ol",{className:"mt-2 space-y-1 text-sm text-sidebar-foreground/70",children:[h.jsx("li",{children:"1. Abra o WhatsApp no seu celular"}),h.jsx("li",{children:"2. Toque em Menu ou Configurações"}),h.jsx("li",{children:"3. Toque em Dispositivos conectados"}),h.jsx("li",{children:"4. Toque em Conectar um dispositivo"}),h.jsx("li",{children:"5. Aponte seu celular para esta tela para capturar o código"})]})]}),h.jsxs("div",{className:"flex gap-2",children:[h.jsx(ut,{variant:"outline",onClick:u,disabled:i,className:"flex-1 bg-sidebar border-sidebar-border text-sidebar-foreground hover:bg-sidebar-accent",children:i?h.jsxs(h.Fragment,{children:[h.jsx(Db,{className:"mr-2 h-4 w-4 animate-spin"}),"Atualizando..."]}):h.jsxs(h.Fragment,{children:[h.jsx(Db,{className:"mr-2 h-4 w-4"}),"Atualizar QR Code"]})}),h.jsx(ut,{variant:"outline",onClick:()=>r(!1),className:"bg-sidebar border-sidebar-border text-sidebar-foreground hover:bg-sidebar-accent",children:h.jsx(el,{className:"h-4 w-4"})})]})]})]})}):null}const C5=Xo({webhookUrl:Yt().optional(),phone:Yt().optional(),rabbitmqEnable:Yt().optional(),websocketEnable:Yt().optional(),natsEnable:Yt().optional(),alwaysOnline:Ta().optional(),rejectCall:Ta().optional(),readMessages:Ta().optional(),ignoreGroups:Ta().optional(),ignoreStatus:Ta().optional()}),N5=["ALL","MESSAGE","READ_RECEIPT","PRESENCE","HISTORY_SYNC","CHAT_PRESENCE","CALL","CONNECTION","QRCODE","LABEL","CONTACT","GROUP","NEWSLETTER"];function R5({open:t,onClose:n,instance:r,onConfirm:s}){const[i,c]=b.useState([]),[u,f]=b.useState(!1),[g,p]=b.useState(!1),{register:y,handleSubmit:v,formState:{errors:w},reset:C}=Lo({resolver:Io(C5)}),S=async A=>{const D={webhookUrl:A.webhookUrl||"",subscribe:i,phone:A.phone||"",rabbitmqEnable:A.rabbitmqEnable||"",websocketEnable:A.websocketEnable||"",natsEnable:A.natsEnable||"",alwaysOnline:A.alwaysOnline,rejectCall:A.rejectCall,readMessages:A.readMessages,ignoreGroups:A.ignoreGroups,ignoreStatus:A.ignoreStatus};s(D),_()},_=()=>{C(),c([]),f(!1),p(!1),n()},E=A=>{c(D=>A==="ALL"?D.includes("ALL")?[]:["ALL"]:D.includes("ALL")?[A]:D.includes(A)?D.filter(H=>H!==A):[...D,A])},R=()=>{c(["ALL"])},k=()=>{c([])};return!t||!r?null:h.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50",children:h.jsxs("div",{className:"w-full max-w-2xl rounded-lg bg-card p-6 shadow-lg max-h-[90vh] overflow-y-auto",children:[h.jsxs("div",{className:"mb-4 flex items-center justify-between",children:[h.jsxs("h2",{className:"text-xl font-semibold text-foreground",children:["Configurar Conexão - ",r.instanceName]}),h.jsx("button",{onClick:_,className:"rounded-md p-1 hover:bg-accent",children:h.jsx(el,{className:"h-5 w-5"})})]}),h.jsxs("form",{onSubmit:v(S),className:"space-y-4",children:[h.jsxs("div",{children:[h.jsx("label",{htmlFor:"webhookUrl",className:"mb-1 block text-sm font-medium text-foreground",children:"Webhook URL (opcional)"}),h.jsx("input",{id:"webhookUrl",type:"url",placeholder:"https://seu-servidor.com/webhook",...y("webhookUrl"),className:"w-full rounded-md border border-input bg-background px-3 py-2 text-foreground placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring"}),w.webhookUrl&&h.jsx("p",{className:"mt-1 text-sm text-destructive",children:w.webhookUrl.message})]}),h.jsxs("div",{children:[h.jsxs("button",{type:"button",onClick:()=>p(!g),className:"flex items-center gap-2 text-sm font-medium text-foreground hover:text-primary",children:[g?h.jsx(Zm,{className:"h-4 w-4"}):h.jsx(jb,{className:"h-4 w-4"}),"Eventos para Webhook (",i.length," selecionados)"]}),g&&h.jsxs("div",{className:"mt-2 space-y-2 rounded-md border border-input p-3",children:[h.jsxs("div",{className:"flex gap-2 mb-2",children:[h.jsx("button",{type:"button",onClick:R,className:"text-xs px-2 py-1 rounded bg-primary text-primary-foreground hover:bg-primary/90",children:"Selecionar ALL"}),h.jsx("button",{type:"button",onClick:k,className:"text-xs px-2 py-1 rounded border border-input hover:bg-accent",children:"Limpar"})]}),h.jsx("div",{className:"mb-3 p-3 rounded-md bg-primary/10 border border-primary/20",children:h.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[h.jsx("input",{type:"checkbox",checked:i.includes("ALL"),onChange:()=>E("ALL"),className:"rounded border-input w-4 h-4"}),h.jsxs("div",{className:"flex-1",children:[h.jsx("span",{className:"text-sm font-semibold text-primary",children:"ALL"}),h.jsx("p",{className:"text-xs text-muted-foreground mt-0.5",children:"Seleciona todos os eventos (recomendado)"})]})]})}),h.jsxs("div",{className:"space-y-1",children:[h.jsx("p",{className:"text-xs font-medium text-muted-foreground mb-2",children:"Eventos Individuais:"}),h.jsx("div",{className:"grid grid-cols-2 gap-2 max-h-48 overflow-y-auto",children:N5.filter(A=>A!=="ALL").map(A=>h.jsxs("label",{className:"flex items-center gap-2 text-sm cursor-pointer hover:bg-accent p-2 rounded",children:[h.jsx("input",{type:"checkbox",checked:i.includes(A)||i.includes("ALL"),onChange:()=>E(A),disabled:i.includes("ALL"),className:"rounded border-input"}),h.jsx("span",{className:i.includes("ALL")?"text-muted-foreground":"text-foreground",children:A})]},A))})]})]})]}),h.jsxs("div",{children:[h.jsx("label",{htmlFor:"phone",className:"mb-1 block text-sm font-medium text-foreground",children:"Telefone para Pairing Code (opcional)"}),h.jsx("input",{id:"phone",type:"tel",placeholder:"5511999999999",...y("phone"),className:"w-full rounded-md border border-input bg-background px-3 py-2 text-foreground placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring"}),h.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:"Se fornecido, será gerado um código de pareamento (pairing code)"})]}),h.jsxs("div",{children:[h.jsxs("button",{type:"button",onClick:()=>f(!u),className:"flex items-center gap-2 text-sm font-medium text-foreground hover:text-primary",children:[u?h.jsx(Zm,{className:"h-4 w-4"}):h.jsx(jb,{className:"h-4 w-4"}),"Configurações Avançadas"]}),u&&h.jsxs("div",{className:"mt-2 space-y-4 rounded-md border border-input p-4",children:[h.jsxs("div",{className:"space-y-3",children:[h.jsx("h3",{className:"text-sm font-semibold text-foreground",children:"Comportamento"}),h.jsxs("div",{className:"flex items-center justify-between",children:[h.jsxs("div",{children:[h.jsx("label",{htmlFor:"alwaysOnline",className:"text-sm font-medium text-foreground cursor-pointer",children:"Always Online"}),h.jsx("p",{className:"text-xs text-muted-foreground",children:"Manter sempre online no WhatsApp"})]}),h.jsx("input",{id:"alwaysOnline",type:"checkbox",...y("alwaysOnline"),className:"rounded border-input w-4 h-4"})]}),h.jsxs("div",{className:"flex items-center justify-between",children:[h.jsxs("div",{children:[h.jsx("label",{htmlFor:"rejectCall",className:"text-sm font-medium text-foreground cursor-pointer",children:"Reject Call"}),h.jsx("p",{className:"text-xs text-muted-foreground",children:"Rejeitar chamadas automaticamente"})]}),h.jsx("input",{id:"rejectCall",type:"checkbox",...y("rejectCall"),className:"rounded border-input w-4 h-4"})]}),h.jsxs("div",{className:"flex items-center justify-between",children:[h.jsxs("div",{children:[h.jsx("label",{htmlFor:"readMessages",className:"text-sm font-medium text-foreground cursor-pointer",children:"Read Messages"}),h.jsx("p",{className:"text-xs text-muted-foreground",children:"Marcar mensagens como lidas"})]}),h.jsx("input",{id:"readMessages",type:"checkbox",...y("readMessages"),className:"rounded border-input w-4 h-4"})]}),h.jsxs("div",{className:"flex items-center justify-between",children:[h.jsxs("div",{children:[h.jsx("label",{htmlFor:"ignoreGroups",className:"text-sm font-medium text-foreground cursor-pointer",children:"Ignore Groups"}),h.jsx("p",{className:"text-xs text-muted-foreground",children:"Ignorar mensagens de grupos"})]}),h.jsx("input",{id:"ignoreGroups",type:"checkbox",...y("ignoreGroups"),className:"rounded border-input w-4 h-4"})]}),h.jsxs("div",{className:"flex items-center justify-between",children:[h.jsxs("div",{children:[h.jsx("label",{htmlFor:"ignoreStatus",className:"text-sm font-medium text-foreground cursor-pointer",children:"Ignore Status"}),h.jsx("p",{className:"text-xs text-muted-foreground",children:"Ignorar atualizações de status"})]}),h.jsx("input",{id:"ignoreStatus",type:"checkbox",...y("ignoreStatus"),className:"rounded border-input w-4 h-4"})]})]}),h.jsxs("div",{className:"space-y-3 pt-3 border-t border-input",children:[h.jsx("h3",{className:"text-sm font-semibold text-foreground",children:"Produtores de Eventos"}),h.jsxs("div",{children:[h.jsx("label",{htmlFor:"rabbitmqEnable",className:"mb-1 block text-sm font-medium text-foreground",children:"RabbitMQ"}),h.jsxs("select",{id:"rabbitmqEnable",...y("rabbitmqEnable"),className:"w-full rounded-md border border-input bg-background px-3 py-2 text-sm text-foreground focus:outline-none focus:ring-2 focus:ring-ring",children:[h.jsx("option",{value:"",children:"Padrão"}),h.jsx("option",{value:"enabled",children:"Habilitado"}),h.jsx("option",{value:"disabled",children:"Desabilitado"})]})]}),h.jsxs("div",{children:[h.jsx("label",{htmlFor:"websocketEnable",className:"mb-1 block text-sm font-medium text-foreground",children:"WebSocket"}),h.jsxs("select",{id:"websocketEnable",...y("websocketEnable"),className:"w-full rounded-md border border-input bg-background px-3 py-2 text-sm text-foreground focus:outline-none focus:ring-2 focus:ring-ring",children:[h.jsx("option",{value:"",children:"Padrão"}),h.jsx("option",{value:"enabled",children:"Habilitado"}),h.jsx("option",{value:"disabled",children:"Desabilitado"})]})]}),h.jsxs("div",{children:[h.jsx("label",{htmlFor:"natsEnable",className:"mb-1 block text-sm font-medium text-foreground",children:"NATS"}),h.jsxs("select",{id:"natsEnable",...y("natsEnable"),className:"w-full rounded-md border border-input bg-background px-3 py-2 text-sm text-foreground focus:outline-none focus:ring-2 focus:ring-ring",children:[h.jsx("option",{value:"",children:"Padrão"}),h.jsx("option",{value:"enabled",children:"Habilitado"}),h.jsx("option",{value:"disabled",children:"Desabilitado"})]})]})]})]})]}),h.jsxs("div",{className:"flex gap-2 pt-4",children:[h.jsx("button",{type:"button",onClick:_,className:"flex-1 rounded-md border border-input px-4 py-2 text-sm font-medium text-foreground hover:bg-accent",children:"Cancelar"}),h.jsx("button",{type:"submit",className:"flex-1 rounded-md bg-primary px-4 py-2 text-sm font-medium text-primary-foreground hover:bg-primary/90",children:"Conectar"})]})]})]})})}const A5=Xo({number:Yt().min(1,"Número é obrigatório"),message:Yt().min(1,"Mensagem é obrigatória")});function T5({open:t,onClose:n,instance:r}){const{register:s,handleSubmit:i,formState:{errors:c,isSubmitting:u},reset:f}=Lo({resolver:Io(A5)}),g=async y=>{if(!(r!=null&&r.apikey)){Ze.error("Token da instância não encontrado");return}try{await f5(r.apikey,{number:y.number,text:y.message}),Ze.success("Mensagem enviada com sucesso!"),f(),n()}catch(v){console.error("Send message error:",v),Ze.error("Erro ao enviar mensagem")}},p=()=>{f(),n()};return!t||!r?null:h.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50",children:h.jsxs("div",{className:"w-full max-w-md rounded-lg bg-card p-6 shadow-lg",children:[h.jsxs("div",{className:"mb-4 flex items-center justify-between",children:[h.jsxs("h2",{className:"text-xl font-semibold text-foreground",children:["Enviar Mensagem - ",r.instanceName]}),h.jsx("button",{onClick:p,className:"rounded-md p-1 hover:bg-accent",children:h.jsx(el,{className:"h-5 w-5"})})]}),h.jsxs("form",{onSubmit:i(g),className:"space-y-4",children:[h.jsxs("div",{children:[h.jsx("label",{htmlFor:"number",className:"mb-1 block text-sm font-medium text-foreground",children:"Número (com DDI)"}),h.jsx("input",{id:"number",type:"text",placeholder:"5511999999999",...s("number"),className:"w-full rounded-md border border-input bg-background px-3 py-2 text-foreground placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring"}),c.number&&h.jsx("p",{className:"mt-1 text-sm text-destructive",children:c.number.message})]}),h.jsxs("div",{children:[h.jsx("label",{htmlFor:"message",className:"mb-1 block text-sm font-medium text-foreground",children:"Mensagem"}),h.jsx("textarea",{id:"message",rows:4,placeholder:"Digite sua mensagem...",...s("message"),className:"w-full rounded-md border border-input bg-background px-3 py-2 text-foreground placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring"}),c.message&&h.jsx("p",{className:"mt-1 text-sm text-destructive",children:c.message.message})]}),h.jsxs("div",{className:"flex gap-2",children:[h.jsx("button",{type:"button",onClick:p,disabled:u,className:"flex-1 rounded-md border border-input px-4 py-2 text-sm font-medium text-foreground hover:bg-accent disabled:opacity-50",children:"Cancelar"}),h.jsx("button",{type:"submit",disabled:u,className:"flex-1 rounded-md bg-primary px-4 py-2 text-sm font-medium text-primary-foreground hover:bg-primary/90 disabled:opacity-50",children:u?"Enviando...":"Enviar"})]})]})]})})}function O5({icon:t,title:n,description:r,action:s,className:i}){return h.jsxs("div",{className:Qm("flex flex-col items-center justify-center py-12 px-4 text-center",i),children:[h.jsx("div",{className:"rounded-full bg-sidebar-accent/50 p-6 mb-4 dark:bg-sidebar-accent/50 dark:text-gray-400",children:h.jsx(t,{className:"h-12 w-12 text-sidebar-foreground/60 dark:text-gray-400"})}),h.jsx("h3",{className:"text-lg font-semibold text-sidebar-foreground mb-2 dark:text-gray-400",children:n}),h.jsx("p",{className:"text-sm text-sidebar-foreground/60 mb-6 max-w-md dark:text-gray-400",children:r}),s&&h.jsx(ut,{onClick:s.onClick,children:s.label})]})}function j5(){var L,Y,J,ie,pe;const t=Xr(),{instances:n,isLoading:r,fetchInstances:s,removeInstance:i}=dE(),[c,u]=b.useState(""),[f,g]=b.useState(!1),[p,y]=b.useState({isOpen:!1,instance:null}),[v]=b.useState(1),[w]=b.useState(24),[C,S]=b.useState(null),[_,E]=b.useState({isOpen:!1,instance:null,confirmationText:""}),[R,k]=b.useState({isOpen:!1,instance:null}),[A,D]=b.useState({isOpen:!1,instance:null}),H=b.useRef(!1);b.useEffect(()=>{H.current||(s(),H.current=!0);const Q=setInterval(()=>{s()},5e3);return()=>clearInterval(Q)},[s]);const{paginatedInstances:$,totalCount:U}=b.useMemo(()=>{const Q=c?n.filter(Me=>{var be,je,at;const ze=c.toLowerCase();return((be=Me.instanceName)==null?void 0:be.toLowerCase().includes(ze))||((je=Me.profileName)==null?void 0:je.toLowerCase().includes(ze))||((at=Me.owner)==null?void 0:at.toLowerCase().includes(ze))}):n,oe=(v-1)*w,Re=oe+w;return{paginatedInstances:Q.slice(oe,Re),totalCount:Q.length}},[n,c,v,w]),F=b.useCallback(()=>{g(!0)},[]),de=b.useCallback(Q=>{t(`/manager/instances/${Q.id}/settings`)},[t]),fe=b.useCallback(Q=>{D({isOpen:!0,instance:Q})},[]),me=b.useCallback(async(Q,oe)=>{try{if(!Q.apikey){Ze.error("Token da instância não encontrado");return}if(Ze.info(`Conectando ${Q.instanceName}...`),oe.alwaysOnline!==void 0||oe.rejectCall!==void 0||oe.readMessages!==void 0||oe.ignoreGroups!==void 0||oe.ignoreStatus!==void 0){const Me={alwaysOnline:oe.alwaysOnline,rejectCall:oe.rejectCall,readMessages:oe.readMessages,ignoreGroups:oe.ignoreGroups,ignoreStatus:oe.ignoreStatus};await lE(Q.id,Q.apikey,Me)}if(oe.phone&&oe.phone.trim()!==""){let Me=oe.phone.trim();Me.startsWith("+")||(Me=`+${Me}`),await xh(Q.apikey,{...oe,phone:void 0}),await new Promise(be=>setTimeout(be,1e3));const ze=await d5(Q.apikey,{subscribe:oe.subscribe||[],phone:Me});try{const be=await Im(Q.apikey),je={...Q,qrcode:{base64:be.qrcode,code:be.code,pairingCode:ze.pairingCode}};y({isOpen:!0,instance:je}),Ze.success(`QR Code e Pairing Code gerados para ${Q.instanceName}!`)}catch{const be={...Q,qrcode:{pairingCode:ze.pairingCode}};y({isOpen:!0,instance:be}),Ze.success(`Pairing Code gerado para ${Q.instanceName}!`)}}else{await xh(Q.apikey,oe),await new Promise(Me=>setTimeout(Me,2e3));try{const Me=await Im(Q.apikey),ze={...Q,qrcode:{base64:Me.qrcode,code:Me.code}};y({isOpen:!0,instance:ze}),Ze.success(`QR Code gerado para ${Q.instanceName}!`)}catch(Me){console.error("Erro ao buscar QR Code:",Me),Ze.error("QR Code ainda não disponível, aguarde alguns segundos..."),await s();const ze=n.find(be=>be.instanceName===Q.instanceName);ze&&y({isOpen:!0,instance:ze})}}}catch(Re){console.error("Erro ao conectar instância:",Re),Ze.error(Re instanceof Error?Re.message:"Erro ao conectar instância")}},[s,n]),se=b.useCallback(async Q=>{try{if(!Q.apikey){Ze.error("Token da instância não encontrado");return}Ze.info(`Desconectando ${Q.instanceName}...`),await cE(Q.apikey),await s(),Ze.success(`${Q.instanceName} desconectada!`)}catch(oe){console.error("Erro ao desconectar instância:",oe),Ze.error(oe instanceof Error?oe.message:"Erro ao desconectar instância")}},[s]),G=Q=>{E({isOpen:!0,instance:Q,confirmationText:""})},he=()=>{E({isOpen:!1,instance:null,confirmationText:""})},ve=()=>{y({isOpen:!1,instance:null})},T=Q=>{k({isOpen:!0,instance:Q})},K=()=>{k({isOpen:!1,instance:null})},te=()=>{D({isOpen:!1,instance:null})},le=b.useCallback(Q=>{A.instance&&me(A.instance,Q)},[A.instance,me]),ne=b.useCallback(async()=>{if(!(!p.instance||!p.instance.apikey))try{await s();const Q=n.find(oe=>{var Re;return oe.id===((Re=p.instance)==null?void 0:Re.id)});if(!Q)return;if(Q.connected){y({isOpen:!0,instance:Q});return}try{const oe=await Im(p.instance.apikey),Re={...Q,qrcode:{base64:oe.qrcode,code:oe.code}};y({isOpen:!0,instance:Re})}catch{y({isOpen:!0,instance:Q})}}catch(Q){throw console.error("Erro ao atualizar QR Code:",Q),Q}},[p.instance,s,n]),j=async()=>{if(!_.instance)return;const Q=_.instance.instanceName,oe=_.instance.id;S(Q);try{await uE(oe),i(Q),Ze.success(`Instância ${Q} removida com sucesso!`),he()}catch(Re){console.error("Erro ao remover instância:",Re),Ze.error((Re==null?void 0:Re.message)||"Erro ao remover instância"),await s()}finally{S(null)}},X=_.confirmationText===((L=_.instance)==null?void 0:L.instanceName);return h.jsxs("div",{className:"h-full flex flex-col p-4",children:[h.jsx(g5,{totalCount:U,selectedCount:0,searchValue:c,onSearchChange:u,onNewInstance:F,onClearSelection:()=>{}}),h.jsx("div",{className:"flex-1 overflow-auto",children:r?h.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:Array.from({length:6}).map((Q,oe)=>h.jsx(x3,{className:"h-48"},oe))}):U===0?h.jsx(O5,{icon:bR,title:"Nenhuma instância encontrada",description:"Crie sua primeira instância para começar a usar o Evolution GO",action:{label:"Nova Instância",onClick:F},className:"h-full"}):h.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-6",children:$.map(Q=>h.jsx(h5,{instance:Q,isDeleting:C,onSettings:de,onDelete:G,onConnect:fe,onDisconnect:se,onSendMessage:T},Q.instanceName))})}),h.jsx(E5,{open:f,onOpenChange:g}),h.jsx(_5,{instance:p.instance,open:p.isOpen,onOpenChange:ve,onRefresh:ne}),h.jsx(R5,{instance:A.instance,open:A.isOpen,onClose:te,onConfirm:le}),h.jsx(T5,{instance:R.instance,open:R.isOpen,onClose:K}),h.jsx(gu,{open:_.isOpen,onOpenChange:he,children:h.jsxs(vu,{className:"sm:max-w-md",children:[h.jsxs(yu,{children:[h.jsxs(bu,{className:"flex items-center gap-2 text-red-400 dark:text-red-500",children:[h.jsx(Th,{className:"h-5 w-5"}),"Remover Instância"]}),h.jsxs(xu,{className:"text-sidebar-foreground/70 dark:text-gray-400",children:["Você está prestes a remover a instância"," ",h.jsx("strong",{children:(Y=_.instance)==null?void 0:Y.instanceName}),". Esta ação não pode ser desfeita."]})]}),h.jsx("div",{className:"space-y-4",children:h.jsxs("div",{children:[h.jsx("label",{className:"text-sm font-medium text-sidebar-foreground dark:text-gray-400",children:"Digite o nome da instância para confirmar:"}),h.jsx(Ra,{placeholder:((J=_.instance)==null?void 0:J.instanceName)||"",value:_.confirmationText,onChange:Q=>E(oe=>({...oe,confirmationText:Q.target.value})),className:"mt-2 bg-sidebar border-sidebar-border text-sidebar-foreground placeholder:text-sidebar-foreground/50 dark:text-gray-400 dark:placeholder:text-gray-400"})]})}),h.jsxs(QS,{className:"flex gap-2",children:[h.jsx(ut,{variant:"outline",onClick:he,className:"bg-sidebar border-sidebar-border text-sidebar-foreground hover:bg-sidebar-accent dark:text-gray-400 dark:hover:bg-sidebar-accent",children:"Cancelar"}),h.jsx(ut,{variant:"destructive",onClick:j,disabled:!X||C===((ie=_.instance)==null?void 0:ie.instanceName),className:"bg-red-600 hover:bg-red-700 text-white dark:bg-red-600 dark:hover:bg-red-700",children:C===((pe=_.instance)==null?void 0:pe.instanceName)?"Removendo...":"Remover Instância"})]})]})})]})}const k5=Xo({webhookUrl:Yt().url("URL inválida").optional().or(X3("")),subscribe:Z3(Yt()).optional(),rabbitmqEnable:Yt().optional(),websocketEnable:Yt().optional(),natsEnable:Yt().optional()}),M5=Xo({alwaysOnline:Ta().optional(),rejectCall:Ta().optional(),readMessages:Ta().optional(),ignoreGroups:Ta().optional(),ignoreStatus:Ta().optional()}),D5=["ALL","MESSAGE","READ_RECEIPT","PRESENCE","HISTORY_SYNC","CHAT_PRESENCE","CALL","CONNECTION","QRCODE","LABEL","CONTACT","GROUP","NEWSLETTER"];function z5(){const{instanceId:t}=bN(),n=Xr(),[r,s]=b.useState(null),[i,c]=b.useState([]),[u,f]=b.useState(!1),[g,p]=b.useState(!0),[y,v]=b.useState(!1),w=b.useRef(!1),C=b.useRef(!1),{register:S,handleSubmit:_,formState:{errors:E},reset:R}=Lo({resolver:Io(k5)}),{register:k,handleSubmit:A,reset:D}=Lo({resolver:Io(M5)});b.useEffect(()=>{(async()=>{if(!(!t||C.current)){C.current=!0;try{p(!0);const me=await $c(t);s(me)}catch(me){console.error("Erro ao buscar instância:",me),Ze.error("Erro ao carregar dados da instância")}finally{p(!1)}}})()},[t]),b.useEffect(()=>{if(!(!r||w.current)){if(R({webhookUrl:r.webhook||"",rabbitmqEnable:r.rabbitmqEnable||"",websocketEnable:r.websocketEnable||"",natsEnable:r.natsEnable||""}),D({alwaysOnline:r.alwaysOnline||!1,rejectCall:r.rejectCall||!1,readMessages:r.readMessages||!1,ignoreGroups:r.ignoreGroups||!1,ignoreStatus:r.ignoreStatus||!1}),r.events){const fe=r.events.split(",").map(me=>me.trim()).filter(Boolean);c(fe)}else c([]);w.current=!0}},[r,R,D]);const H=fe=>{c(me=>fe==="ALL"?me.includes("ALL")?[]:["ALL"]:me.includes("ALL")?[fe]:me.includes(fe)?me.filter(se=>se!==fe):[...me,fe])},$=async fe=>{if(!(r!=null&&r.apikey)||!t){Ze.error("Token da instância não encontrado");return}try{f(!0);const me={webhookUrl:fe.webhookUrl||"",subscribe:i,rabbitmqEnable:fe.rabbitmqEnable||"",websocketEnable:fe.websocketEnable||"",natsEnable:fe.natsEnable||""};await xh(r.apikey,me),Ze.success("Configurações de webhook atualizadas!");const se=await $c(t);s(se)}catch(me){console.error("Erro ao atualizar webhook:",me),Ze.error(me instanceof Error?me.message:"Erro ao atualizar webhook")}finally{f(!1)}},U=async fe=>{if(!(r!=null&&r.apikey)||!(r!=null&&r.id)||!t){Ze.error("Token da instância não encontrado");return}try{f(!0),await lE(r.id,r.apikey,fe),Ze.success("Configurações avançadas atualizadas!");const me=await $c(t);s(me)}catch(me){console.error("Erro ao atualizar configurações:",me),Ze.error(me instanceof Error?me.message:"Erro ao atualizar configurações")}finally{f(!1)}},F=async()=>{if(!(r!=null&&r.apikey)||!t){Ze.error("Token da instância não encontrado");return}try{Ze.info(`Desconectando ${r.instanceName}...`),await cE(r.apikey);const fe=await $c(t);s(fe),Ze.success(`${r.instanceName} desconectada!`)}catch(fe){console.error("Erro ao desconectar instância:",fe),Ze.error(fe instanceof Error?fe.message:"Erro ao desconectar instância")}},de=async()=>{if(!(r!=null&&r.id)){Ze.error("ID da instância não encontrado");return}if(window.confirm(`Tem certeza que deseja deletar a instância ${r.instanceName}? Esta ação não pode ser desfeita.`))try{Ze.info(`Deletando ${r.instanceName}...`),await uE(r.id),Ze.success(`${r.instanceName} deletada!`),n("/manager/instances")}catch(me){console.error("Erro ao deletar instância:",me),Ze.error(me instanceof Error?me.message:"Erro ao deletar instância")}};return g?h.jsx("div",{className:"flex h-full items-center justify-center",children:h.jsx("div",{className:"text-center",children:h.jsx("p",{className:"text-muted-foreground",children:"Carregando..."})})}):r?h.jsxs("div",{className:"h-full flex flex-col",children:[h.jsx("div",{className:"border-b border-sidebar-border bg-sidebar p-6",children:h.jsx("div",{className:"flex items-center justify-between",children:h.jsxs("div",{className:"flex items-center gap-4",children:[h.jsx(ut,{variant:"ghost",size:"icon",onClick:()=>n("/manager/instances"),className:"text-sidebar-foreground hover:bg-sidebar-accent",children:h.jsx(Ob,{className:"h-5 w-5"})}),h.jsxs("div",{children:[h.jsx("h1",{className:"text-2xl font-bold text-foreground",children:"Configurações"}),h.jsx("p",{className:"text-sm text-muted-foreground",children:r.instanceName})]})]})})}),h.jsx("div",{className:"flex-1 overflow-y-auto p-6",children:h.jsxs("div",{className:"max-w-4xl mx-auto space-y-6",children:[h.jsxs("div",{className:"rounded-lg border border-sidebar-border bg-card p-6",children:[h.jsx("h2",{className:"text-lg font-semibold text-foreground mb-4",children:"Informações da Instância"}),h.jsx("div",{className:"space-y-4",children:h.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[h.jsxs("div",{children:[h.jsx("label",{className:"text-sm font-medium text-foreground",children:"Nome da Instância"}),h.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:r.instanceName})]}),h.jsxs("div",{children:[h.jsx("label",{className:"text-sm font-medium text-foreground",children:"Token da Instância"}),h.jsxs("div",{className:"mt-1 flex items-center gap-2",children:[h.jsx("p",{className:"text-sm text-muted-foreground font-mono",children:y?r.apikey||"":"•".repeat((r.apikey||"").length)}),h.jsx("button",{type:"button",onClick:()=>v(!y),className:"text-muted-foreground hover:text-foreground transition-colors",title:y?"Ocultar token":"Mostrar token",children:y?h.jsx(dR,{size:18}):h.jsx(mR,{size:18})})]})]}),h.jsxs("div",{children:[h.jsx("label",{className:"text-sm font-medium text-foreground",children:"Status"}),h.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:r.status==="open"?"Conectado":"Desconectado"})]}),r.owner&&h.jsxs("div",{children:[h.jsx("label",{className:"text-sm font-medium text-foreground",children:"Número"}),h.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:r.owner})]}),r.profileName&&h.jsxs("div",{children:[h.jsx("label",{className:"text-sm font-medium text-foreground",children:"Nome do Perfil"}),h.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:r.profileName})]})]})})]}),h.jsx("form",{onSubmit:_($),children:h.jsxs("div",{className:"rounded-lg border border-sidebar-border bg-card p-6",children:[h.jsx("h2",{className:"text-lg font-semibold text-foreground mb-4",children:"Configurações de Webhook"}),h.jsxs("div",{className:"space-y-4",children:[h.jsxs("div",{children:[h.jsx("label",{htmlFor:"webhookUrl",className:"block text-sm font-medium text-foreground mb-1",children:"URL do Webhook"}),h.jsx("input",{id:"webhookUrl",type:"url",placeholder:"https://seu-servidor.com/webhook",...S("webhookUrl"),className:"w-full rounded-md border border-input bg-background px-3 py-2 text-foreground placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring"}),E.webhookUrl&&h.jsx("p",{className:"mt-1 text-sm text-destructive",children:E.webhookUrl.message}),h.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:"URL que receberá os eventos do WhatsApp"})]}),h.jsxs("div",{children:[h.jsx("label",{className:"block text-sm font-medium text-foreground mb-2",children:"Eventos para Webhook"}),h.jsxs("div",{className:"space-y-2 rounded-md border border-input p-3 max-h-60 overflow-y-auto",children:[h.jsx("div",{className:"p-2 rounded-md bg-primary/10 border border-primary/20",children:h.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[h.jsx("input",{type:"checkbox",checked:i.includes("ALL"),onChange:()=>H("ALL"),className:"rounded border-input w-4 h-4"}),h.jsx("span",{className:"text-sm font-semibold text-primary",children:"ALL"})]})}),h.jsx("div",{className:"grid grid-cols-2 gap-2",children:D5.filter(fe=>fe!=="ALL").map(fe=>h.jsxs("label",{className:"flex items-center gap-2 text-sm cursor-pointer hover:bg-accent p-2 rounded",children:[h.jsx("input",{type:"checkbox",checked:i.includes(fe)||i.includes("ALL"),onChange:()=>H(fe),disabled:i.includes("ALL"),className:"rounded border-input"}),h.jsx("span",{className:i.includes("ALL")?"text-muted-foreground":"text-foreground",children:fe})]},fe))})]})]}),h.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[h.jsxs("div",{children:[h.jsx("label",{htmlFor:"rabbitmqEnable",className:"block text-sm font-medium text-foreground mb-1",children:"RabbitMQ"}),h.jsxs("select",{id:"rabbitmqEnable",...S("rabbitmqEnable"),className:"w-full rounded-md border border-input bg-background px-3 py-2 text-sm text-foreground focus:outline-none focus:ring-2 focus:ring-ring",children:[h.jsx("option",{value:"",children:"Padrão"}),h.jsx("option",{value:"enabled",children:"Habilitado"}),h.jsx("option",{value:"disabled",children:"Desabilitado"})]})]}),h.jsxs("div",{children:[h.jsx("label",{htmlFor:"websocketEnable",className:"block text-sm font-medium text-foreground mb-1",children:"WebSocket"}),h.jsxs("select",{id:"websocketEnable",...S("websocketEnable"),className:"w-full rounded-md border border-input bg-background px-3 py-2 text-sm text-foreground focus:outline-none focus:ring-2 focus:ring-ring",children:[h.jsx("option",{value:"",children:"Padrão"}),h.jsx("option",{value:"enabled",children:"Habilitado"}),h.jsx("option",{value:"disabled",children:"Desabilitado"})]})]}),h.jsxs("div",{children:[h.jsx("label",{htmlFor:"natsEnable",className:"block text-sm font-medium text-foreground mb-1",children:"NATS"}),h.jsxs("select",{id:"natsEnable",...S("natsEnable"),className:"w-full rounded-md border border-input bg-background px-3 py-2 text-sm text-foreground focus:outline-none focus:ring-2 focus:ring-ring",children:[h.jsx("option",{value:"",children:"Padrão"}),h.jsx("option",{value:"enabled",children:"Habilitado"}),h.jsx("option",{value:"disabled",children:"Desabilitado"})]})]})]}),h.jsx("div",{className:"flex justify-end",children:h.jsxs(ut,{type:"submit",disabled:u,className:"gap-2",children:[h.jsx(zb,{className:"h-4 w-4"}),u?"Salvando...":"Salvar Webhook"]})})]})]})}),h.jsx("form",{onSubmit:A(U),children:h.jsxs("div",{className:"rounded-lg border border-sidebar-border bg-card p-6",children:[h.jsx("h2",{className:"text-lg font-semibold text-foreground mb-4",children:"Configurações Avançadas"}),h.jsxs("div",{className:"space-y-4",children:[h.jsxs("div",{className:"flex items-center justify-between",children:[h.jsxs("div",{children:[h.jsx("label",{htmlFor:"alwaysOnline",className:"text-sm font-medium text-foreground cursor-pointer",children:"Always Online"}),h.jsx("p",{className:"text-xs text-muted-foreground",children:"Manter sempre online no WhatsApp"})]}),h.jsx("input",{id:"alwaysOnline",type:"checkbox",...k("alwaysOnline"),className:"rounded border-input w-4 h-4"})]}),h.jsxs("div",{className:"flex items-center justify-between",children:[h.jsxs("div",{children:[h.jsx("label",{htmlFor:"rejectCall",className:"text-sm font-medium text-foreground cursor-pointer",children:"Reject Call"}),h.jsx("p",{className:"text-xs text-muted-foreground",children:"Rejeitar chamadas automaticamente"})]}),h.jsx("input",{id:"rejectCall",type:"checkbox",...k("rejectCall"),className:"rounded border-input w-4 h-4"})]}),h.jsxs("div",{className:"flex items-center justify-between",children:[h.jsxs("div",{children:[h.jsx("label",{htmlFor:"readMessages",className:"text-sm font-medium text-foreground cursor-pointer",children:"Read Messages"}),h.jsx("p",{className:"text-xs text-muted-foreground",children:"Marcar mensagens como lidas"})]}),h.jsx("input",{id:"readMessages",type:"checkbox",...k("readMessages"),className:"rounded border-input w-4 h-4"})]}),h.jsxs("div",{className:"flex items-center justify-between",children:[h.jsxs("div",{children:[h.jsx("label",{htmlFor:"ignoreGroups",className:"text-sm font-medium text-foreground cursor-pointer",children:"Ignore Groups"}),h.jsx("p",{className:"text-xs text-muted-foreground",children:"Ignorar mensagens de grupos"})]}),h.jsx("input",{id:"ignoreGroups",type:"checkbox",...k("ignoreGroups"),className:"rounded border-input w-4 h-4"})]}),h.jsxs("div",{className:"flex items-center justify-between",children:[h.jsxs("div",{children:[h.jsx("label",{htmlFor:"ignoreStatus",className:"text-sm font-medium text-foreground cursor-pointer",children:"Ignore Status"}),h.jsx("p",{className:"text-xs text-muted-foreground",children:"Ignorar atualizações de status"})]}),h.jsx("input",{id:"ignoreStatus",type:"checkbox",...k("ignoreStatus"),className:"rounded border-input w-4 h-4"})]}),h.jsx("div",{className:"flex justify-end",children:h.jsxs(ut,{type:"submit",disabled:u,className:"gap-2",children:[h.jsx(zb,{className:"h-4 w-4"}),u?"Salvando...":"Salvar Avançadas"]})})]})]})}),h.jsxs("div",{className:"rounded-lg border border-destructive/50 bg-destructive/10 p-6",children:[h.jsx("h2",{className:"text-lg font-semibold text-destructive mb-4",children:"Zona de Perigo"}),h.jsxs("div",{className:"space-y-4",children:[h.jsxs("div",{className:"flex items-center justify-between",children:[h.jsxs("div",{children:[h.jsx("h3",{className:"text-sm font-medium text-foreground",children:"Desconectar Instância"}),h.jsx("p",{className:"text-xs text-muted-foreground",children:"Desconecta a instância do WhatsApp"})]}),h.jsxs(ut,{variant:"destructive",onClick:F,className:"gap-2",children:[h.jsx(V0,{className:"h-4 w-4"}),"Desconectar"]})]}),h.jsxs("div",{className:"flex items-center justify-between",children:[h.jsxs("div",{children:[h.jsx("h3",{className:"text-sm font-medium text-foreground",children:"Deletar Instância"}),h.jsx("p",{className:"text-xs text-muted-foreground",children:"Remove permanentemente esta instância"})]}),h.jsxs(ut,{variant:"destructive",onClick:de,className:"gap-2",children:[h.jsx(Th,{className:"h-4 w-4"}),"Deletar"]})]})]})]})]})})]}):h.jsx("div",{className:"flex h-full items-center justify-center",children:h.jsxs("div",{className:"text-center",children:[h.jsx("h2",{className:"text-xl font-semibold text-foreground mb-2",children:"Instância não encontrada"}),h.jsxs("p",{className:"text-muted-foreground mb-4",children:['A instância "',t,'" não foi encontrada.']}),h.jsxs(ut,{onClick:()=>n("/manager/instances"),children:[h.jsx(Ob,{className:"h-4 w-4 mr-2"}),"Voltar para Instâncias"]})]})})}function L5(){return h.jsxs("div",{className:"p-6",children:[h.jsx("h1",{className:"mb-4 text-2xl font-bold text-gray-900",children:"Mensagens"}),h.jsx("p",{className:"text-gray-600",children:"Messages sending will be implemented here..."})]})}function U5(){return h.jsxs("div",{className:"p-6",children:[h.jsx("h1",{className:"mb-4 text-2xl font-bold text-foreground",children:"Eventos"}),h.jsx("p",{className:"text-muted-foreground",children:"Events monitor will be implemented here..."})]})}function B5(){return h.jsxs("div",{className:"p-6",children:[h.jsx("h1",{className:"mb-4 text-2xl font-bold text-gray-900",children:"Configurações"}),h.jsx("p",{className:"text-gray-600",children:"Settings will be implemented here..."})]})}const P5=()=>{const[t]=u2(),n=Xr(),{setLicenseState:r,apiUrl:s,apiKey:i}=zu(),[c,u]=b.useState("activating"),[f,g]=b.useState(""),p=t.get("code"),y=b.useCallback(async()=>{if(!p){u("error"),g("Codigo de autorizacao nao encontrado na URL.");return}u("activating"),g("");try{const v=await OO(p,s,i);v.status==="active"?(u("success"),r("licensed"),Ze.success("Licenca ativada com sucesso!"),setTimeout(()=>{n("/manager/login",{replace:!0})},2e3)):(u("error"),g(v.message||"Falha ao ativar licenca."))}catch(v){u("error");const w=v instanceof Error?v.message:v==null?void 0:v.message;g(w||"Erro ao ativar licenca.")}},[p,s,i,n,r]);return b.useEffect(()=>{y()},[y]),h.jsx("div",{className:"min-h-screen flex items-center justify-center p-4 bg-gradient-to-t from-primary/20 via-background/95 to-background",children:h.jsxs("div",{className:"w-full max-w-md space-y-6",children:[h.jsx("div",{className:"text-center",children:h.jsx("h1",{className:"text-3xl font-bold text-primary",children:"Evolution GO"})}),h.jsxs("div",{className:"bg-background/80 backdrop-blur-sm border rounded-lg p-8 shadow-lg text-center space-y-4",children:[c==="activating"&&h.jsxs(h.Fragment,{children:[h.jsx(H0,{className:"h-12 w-12 animate-spin text-primary mx-auto"}),h.jsx("h2",{className:"text-xl font-semibold",children:"Ativando licenca..."}),h.jsx("p",{className:"text-muted-foreground",children:"Aguarde enquanto ativamos sua licenca."})]}),c==="success"&&h.jsxs(h.Fragment,{children:[h.jsx(rR,{className:"h-12 w-12 text-green-500 mx-auto"}),h.jsx("h2",{className:"text-xl font-semibold",children:"Licenca ativada!"}),h.jsx("p",{className:"text-muted-foreground",children:"Redirecionando para o login..."})]}),c==="error"&&h.jsxs(h.Fragment,{children:[h.jsx(iR,{className:"h-12 w-12 text-destructive mx-auto"}),h.jsx("h2",{className:"text-xl font-semibold",children:"Erro na ativacao"}),h.jsx("p",{className:"text-muted-foreground",children:f}),h.jsxs("div",{className:"flex gap-2 justify-center pt-2",children:[h.jsx(ut,{variant:"outline",onClick:()=>n("/manager/login",{replace:!0}),children:"Voltar ao login"}),h.jsx(ut,{onClick:y,children:"Tentar novamente"})]})]})]})]})})};function H5(){const{isAuthenticated:t,licenseState:n}=zu(),r=t&&n==="licensed";return h.jsx(kO,{children:h.jsxs(WR,{children:[h.jsx(o2,{children:h.jsxs(zN,{children:[h.jsx(Hn,{path:"/",element:h.jsx(w3,{})}),h.jsx(Hn,{path:"/manager/login",element:r?h.jsx(ym,{to:"/manager",replace:!0}):h.jsx(i5,{})}),h.jsx(Hn,{path:"/manager/license/callback",element:h.jsx(P5,{})}),r?h.jsxs(Hn,{path:"/manager",element:h.jsx(zO,{}),children:[h.jsx(Hn,{index:!0,element:h.jsx(l5,{})}),h.jsx(Hn,{path:"instances",element:h.jsx(j5,{})}),h.jsx(Hn,{path:"instances/:instanceId/settings",element:h.jsx(z5,{})}),h.jsx(Hn,{path:"messages",element:h.jsx(L5,{})}),h.jsx(Hn,{path:"events",element:h.jsx(U5,{})}),h.jsx(Hn,{path:"settings",element:h.jsx(B5,{})})]}):h.jsx(Hn,{path:"/manager/*",element:h.jsx(ym,{to:"/manager/login",replace:!0})}),h.jsx(Hn,{path:"*",element:h.jsx(ym,{to:"/",replace:!0})})]})}),h.jsx(I2,{position:"top-right",richColors:!0})]})})}DC.createRoot(document.getElementById("root")).render(h.jsx(b.StrictMode,{children:h.jsx(H5,{})})); +}`,TS="Popover",[OS]=Ts(TS,[Gu]),Wu=Gu(),[cL,Qr]=OS(TS),jS="PopoverAnchor",wz=b.forwardRef((t,n)=>{const{__scopePopover:r,...s}=t,i=Qr(jS,r),c=Wu(r),{onCustomAnchorAdd:u,onCustomAnchorRemove:f}=i;return b.useEffect(()=>(u(),()=>f()),[u,f]),h.jsx(Jh,{...c,...s,ref:n})});wz.displayName=jS;var kS="PopoverTrigger",Sz=b.forwardRef((t,n)=>{const{__scopePopover:r,...s}=t,i=Qr(kS,r),c=Wu(r),u=Wt(n,i.triggerRef),f=h.jsx(kt.button,{type:"button","aria-haspopup":"dialog","aria-expanded":i.open,"aria-controls":i.contentId,"data-state":US(i.open),...s,ref:u,onClick:qe(t.onClick,i.onOpenToggle)});return i.hasCustomAnchor?f:h.jsx(Jh,{asChild:!0,...c,children:f})});Sz.displayName=kS;var mp="PopoverPortal",[Ez,_z]=OS(mp,{forceMount:void 0}),MS=t=>{const{__scopePopover:n,forceMount:r,children:s,container:i}=t,c=Qr(mp,n);return h.jsx(Ez,{scope:n,forceMount:r,children:h.jsx(za,{present:r||c.open,children:h.jsx(Bu,{asChild:!0,container:i,children:s})})})};MS.displayName=mp;var Uo="PopoverContent",DS=b.forwardRef((t,n)=>{const r=_z(Uo,t.__scopePopover),{forceMount:s=r.forceMount,...i}=t,c=Qr(Uo,t.__scopePopover);return h.jsx(za,{present:s||c.open,children:c.modal?h.jsx(Nz,{...i,ref:n}):h.jsx(Rz,{...i,ref:n})})});DS.displayName=Uo;var Cz=Do("PopoverContent.RemoveScroll"),Nz=b.forwardRef((t,n)=>{const r=Qr(Uo,t.__scopePopover),s=b.useRef(null),i=Wt(n,s),c=b.useRef(!1);return b.useEffect(()=>{const u=s.current;if(u)return Vh(u)},[]),h.jsx(Hu,{as:Cz,allowPinchZoom:!0,children:h.jsx(zS,{...t,ref:i,trapFocus:r.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:qe(t.onCloseAutoFocus,u=>{var f;u.preventDefault(),c.current||(f=r.triggerRef.current)==null||f.focus()}),onPointerDownOutside:qe(t.onPointerDownOutside,u=>{const f=u.detail.originalEvent,g=f.button===0&&f.ctrlKey===!0,p=f.button===2||g;c.current=p},{checkForDefaultPrevented:!1}),onFocusOutside:qe(t.onFocusOutside,u=>u.preventDefault(),{checkForDefaultPrevented:!1})})})}),Rz=b.forwardRef((t,n)=>{const r=Qr(Uo,t.__scopePopover),s=b.useRef(!1),i=b.useRef(!1);return h.jsx(zS,{...t,ref:n,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:c=>{var u,f;(u=t.onCloseAutoFocus)==null||u.call(t,c),c.defaultPrevented||(s.current||(f=r.triggerRef.current)==null||f.focus(),c.preventDefault()),s.current=!1,i.current=!1},onInteractOutside:c=>{var g,p;(g=t.onInteractOutside)==null||g.call(t,c),c.defaultPrevented||(s.current=!0,c.detail.originalEvent.type==="pointerdown"&&(i.current=!0));const u=c.target;((p=r.triggerRef.current)==null?void 0:p.contains(u))&&c.preventDefault(),c.detail.originalEvent.type==="focusin"&&i.current&&c.preventDefault()}})}),zS=b.forwardRef((t,n)=>{const{__scopePopover:r,trapFocus:s,onOpenAutoFocus:i,onCloseAutoFocus:c,disableOutsidePointerEvents:u,onEscapeKeyDown:f,onPointerDownOutside:g,onFocusOutside:p,onInteractOutside:y,...v}=t,w=Qr(Uo,r),C=Wu(r);return Hh(),h.jsx(Uu,{asChild:!0,loop:!0,trapped:s,onMountAutoFocus:i,onUnmountAutoFocus:c,children:h.jsx(Lu,{asChild:!0,disableOutsidePointerEvents:u,onInteractOutside:y,onEscapeKeyDown:f,onPointerDownOutside:g,onFocusOutside:p,onDismiss:()=>w.onOpenChange(!1),children:h.jsx(Ow,{"data-state":US(w.open),role:"dialog",id:w.contentId,...C,...v,ref:n,style:{...v.style,"--radix-popover-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-popover-content-available-width":"var(--radix-popper-available-width)","--radix-popover-content-available-height":"var(--radix-popper-available-height)","--radix-popover-trigger-width":"var(--radix-popper-anchor-width)","--radix-popover-trigger-height":"var(--radix-popper-anchor-height)"}})})})}),LS="PopoverClose",Az=b.forwardRef((t,n)=>{const{__scopePopover:r,...s}=t,i=Qr(LS,r);return h.jsx(kt.button,{type:"button",...s,ref:n,onClick:qe(t.onClick,()=>i.onOpenChange(!1))})});Az.displayName=LS;var Tz="PopoverArrow",Oz=b.forwardRef((t,n)=>{const{__scopePopover:r,...s}=t,i=Wu(r);return h.jsx(jw,{...i,...s,ref:n})});Oz.displayName=Tz;function US(t){return t?"open":"closed"}var jz=MS,BS=DS;const hp=b.createContext(null);hp.displayName="PanelGroupContext";const qn={group:"data-panel-group",groupDirection:"data-panel-group-direction",groupId:"data-panel-group-id",panel:"data-panel",panelCollapsible:"data-panel-collapsible",panelId:"data-panel-id",panelSize:"data-panel-size",resizeHandleId:"data-panel-resize-handle-id"},pp=10,ko=b.useLayoutEffect,Yx=Nu.useId,kz=typeof Yx=="function"?Yx:()=>null;let Mz=0;function PS(t=null){const n=kz(),r=b.useRef(t||n||null);return r.current===null&&(r.current=""+Mz++),t??r.current}function HS({children:t,className:n="",collapsedSize:r,collapsible:s,defaultSize:i,forwardedRef:c,id:u,maxSize:f,minSize:g,onCollapse:p,onExpand:y,onResize:v,order:w,style:C,tagName:S="div",..._}){const E=b.useContext(hp);if(E===null)throw Error("Panel components must be rendered within a PanelGroup container");const{collapsePanel:R,expandPanel:k,getPanelSize:A,getPanelStyle:D,groupId:H,isPanelCollapsed:$,reevaluatePanelConstraints:U,registerPanel:F,resizePanel:de,unregisterPanel:fe}=E,me=PS(u),se=b.useRef({callbacks:{onCollapse:p,onExpand:y,onResize:v},constraints:{collapsedSize:r,collapsible:s,defaultSize:i,maxSize:f,minSize:g},id:me,idIsFromProps:u!==void 0,order:w});b.useRef({didLogMissingDefaultSizeWarning:!1}),ko(()=>{const{callbacks:he,constraints:ve}=se.current,T={...ve};se.current.id=me,se.current.idIsFromProps=u!==void 0,se.current.order=w,he.onCollapse=p,he.onExpand=y,he.onResize=v,ve.collapsedSize=r,ve.collapsible=s,ve.defaultSize=i,ve.maxSize=f,ve.minSize=g,(T.collapsedSize!==ve.collapsedSize||T.collapsible!==ve.collapsible||T.maxSize!==ve.maxSize||T.minSize!==ve.minSize)&&U(se.current,T)}),ko(()=>{const he=se.current;return F(he),()=>{fe(he)}},[w,me,F,fe]),b.useImperativeHandle(c,()=>({collapse:()=>{R(se.current)},expand:he=>{k(se.current,he)},getId(){return me},getSize(){return A(se.current)},isCollapsed(){return $(se.current)},isExpanded(){return!$(se.current)},resize:he=>{de(se.current,he)}}),[R,k,A,$,me,de]);const G=D(se.current,i);return b.createElement(S,{..._,children:t,className:n,id:me,style:{...G,...C},[qn.groupId]:H,[qn.panel]:"",[qn.panelCollapsible]:s||void 0,[qn.panelId]:me,[qn.panelSize]:parseFloat(""+G.flexGrow).toFixed(1)})}const Dz=b.forwardRef((t,n)=>b.createElement(HS,{...t,forwardedRef:n}));HS.displayName="Panel";Dz.displayName="forwardRef(Panel)";function VS(t){return t.type==="keydown"}function IS(t){return t.type.startsWith("pointer")}function qS(t){return t.type.startsWith("mouse")}function zz(t){if(IS(t)){if(t.isPrimary)return{x:t.clientX,y:t.clientY}}else if(qS(t))return{x:t.clientX,y:t.clientY};return{x:1/0,y:1/0}}function Lz(){if(typeof matchMedia=="function")return matchMedia("(pointer:coarse)").matches?"coarse":"fine"}const Uz=1,Bz=2,Pz=4,Hz=8;Lz();let Vz=new Map;function Hm(t,n){Vz.set(t,n)}function Iz(){const[t,n]=b.useState(0);return b.useCallback(()=>n(r=>r+1),[])}function ot(t,n){if(!t)throw console.error(n),Error(n)}function Ns(t,n,r=pp){return t.toFixed(r)===n.toFixed(r)?0:t>n?1:-1}function ar(t,n,r=pp){return Ns(t,n,r)===0}function Vn(t,n,r){return Ns(t,n,r)===0}function qz(t,n,r){if(t.length!==n.length)return!1;for(let s=0;s0&&(t=t<0?0-R:R)}}}{const v=t<0?f:g,w=r[v];ot(w,`No panel constraints found for index ${v}`);const{collapsedSize:C=0,collapsible:S,minSize:_=0}=w;if(S){const E=n[v];if(ot(E!=null,`Previous layout not found for panel index ${v}`),Vn(E,_)){const R=E-C;Ns(R,Math.abs(t))>0&&(t=t<0?0-R:R)}}}}{const v=t<0?1:-1;let w=t<0?g:f,C=0;for(;;){const _=n[w];ot(_!=null,`Previous layout not found for panel index ${w}`);const R=Ao({panelConstraints:r,panelIndex:w,size:100})-_;if(C+=R,w+=v,w<0||w>=r.length)break}const S=Math.min(Math.abs(t),Math.abs(C));t=t<0?0-S:S}{let w=t<0?f:g;for(;w>=0&&w=0))break;t<0?w--:w++}}if(qz(i,u))return i;{const v=t<0?g:f,w=n[v];ot(w!=null,`Previous layout not found for panel index ${v}`);const C=w+p,S=Ao({panelConstraints:r,panelIndex:v,size:C});if(u[v]=S,!Vn(S,C)){let _=C-S,R=t<0?g:f;for(;R>=0&&R0?R--:R++}}}const y=u.reduce((v,w)=>w+v,0);return Vn(y,100)?u:i}function Fz({layout:t,panelsArray:n,pivotIndices:r}){let s=0,i=100,c=0,u=0;const f=r[0];ot(f!=null,"No pivot index found"),n.forEach((v,w)=>{const{constraints:C}=v,{maxSize:S=100,minSize:_=0}=C;w===f?(s=_,i=S):(c+=_,u+=S)});const g=Math.min(i,100-c),p=Math.max(s,100-u),y=t[f];return{valueMax:g,valueMin:p,valueNow:y}}function hu(t,n=document){return Array.from(n.querySelectorAll(`[${qn.resizeHandleId}][data-panel-group-id="${t}"]`))}function $z(t,n,r=document){const i=hu(t,r).findIndex(c=>c.getAttribute(qn.resizeHandleId)===n);return i??null}function FS(t,n,r){const s=$z(t,n,r);return s!=null?[s,s+1]:[-1,-1]}function Gz(t){return t instanceof HTMLElement?!0:typeof t=="object"&&t!==null&&"tagName"in t&&"getAttribute"in t}function $S(t,n=document){if(Gz(n)&&n.dataset.panelGroupId==t)return n;const r=n.querySelector(`[data-panel-group][data-panel-group-id="${t}"]`);return r||null}function gp(t,n=document){const r=n.querySelector(`[${qn.resizeHandleId}="${t}"]`);return r||null}function Yz(t,n,r,s=document){var i,c,u,f;const g=gp(n,s),p=hu(t,s),y=g?p.indexOf(g):-1,v=(i=(c=r[y])===null||c===void 0?void 0:c.id)!==null&&i!==void 0?i:null,w=(u=(f=r[y+1])===null||f===void 0?void 0:f.id)!==null&&u!==void 0?u:null;return[v,w]}function Zz({committedValuesRef:t,eagerValuesRef:n,groupId:r,layout:s,panelDataArray:i,panelGroupElement:c,setLayout:u}){b.useRef({didWarnAboutMissingResizeHandle:!1}),ko(()=>{if(!c)return;const f=hu(r,c);for(let g=0;g{f.forEach((g,p)=>{g.removeAttribute("aria-controls"),g.removeAttribute("aria-valuemax"),g.removeAttribute("aria-valuemin"),g.removeAttribute("aria-valuenow")})}},[r,s,i,c]),b.useEffect(()=>{if(!c)return;const f=n.current;ot(f,"Eager values not found");const{panelDataArray:g}=f,p=$S(r,c);ot(p!=null,`No group found for id "${r}"`);const y=hu(r,c);ot(y,`No resize handles found for group id "${r}"`);const v=y.map(w=>{const C=w.getAttribute(qn.resizeHandleId);ot(C,"Resize handle element has no handle id attribute");const[S,_]=Yz(r,C,g,c);if(S==null||_==null)return()=>{};const E=R=>{if(!R.defaultPrevented)switch(R.key){case"Enter":{R.preventDefault();const k=g.findIndex(A=>A.id===S);if(k>=0){const A=g[k];ot(A,`No panel data found for index ${k}`);const D=s[k],{collapsedSize:H=0,collapsible:$,minSize:U=0}=A.constraints;if(D!=null&&$){const F=Zi({delta:Vn(D,H)?U-H:H-D,initialLayout:s,panelConstraints:g.map(de=>de.constraints),pivotIndices:FS(r,C,c),prevLayout:s,trigger:"keyboard"});s!==F&&u(F)}}break}}};return w.addEventListener("keydown",E),()=>{w.removeEventListener("keydown",E)}});return()=>{v.forEach(w=>w())}},[c,t,n,r,s,i,u])}function Zx(t,n){if(t.length!==n.length)return!1;for(let r=0;rc.constraints);let s=0,i=100;for(let c=0;c{const c=t[i];ot(c,`Panel data not found for index ${i}`);const{callbacks:u,constraints:f,id:g}=c,{collapsedSize:p=0,collapsible:y}=f,v=r[g];if(v==null||s!==v){r[g]=s;const{onCollapse:w,onExpand:C,onResize:S}=u;S&&S(s,v),y&&(w||C)&&(C&&(v==null||ar(v,p))&&!ar(s,p)&&C(),w&&(v==null||!ar(v,p))&&ar(s,p)&&w())}})}function qc(t,n){if(t.length!==n.length)return!1;for(let r=0;r{r!==null&&clearTimeout(r),r=setTimeout(()=>{t(...i)},n)}}function Xx(t){try{if(typeof localStorage<"u")t.getItem=n=>localStorage.getItem(n),t.setItem=(n,r)=>{localStorage.setItem(n,r)};else throw new Error("localStorage not supported in this environment")}catch(n){console.error(n),t.getItem=()=>null,t.setItem=()=>{}}}function YS(t){return`react-resizable-panels:${t}`}function ZS(t){return t.map(n=>{const{constraints:r,id:s,idIsFromProps:i,order:c}=n;return i?s:c?`${c}:${JSON.stringify(r)}`:JSON.stringify(r)}).sort((n,r)=>n.localeCompare(r)).join(",")}function XS(t,n){try{const r=YS(t),s=n.getItem(r);if(s){const i=JSON.parse(s);if(typeof i=="object"&&i!=null)return i}}catch{}return null}function e3(t,n,r){var s,i;const c=(s=XS(t,r))!==null&&s!==void 0?s:{},u=ZS(n);return(i=c[u])!==null&&i!==void 0?i:null}function t3(t,n,r,s,i){var c;const u=YS(t),f=ZS(n),g=(c=XS(t,i))!==null&&c!==void 0?c:{};g[f]={expandToSizes:Object.fromEntries(r.entries()),layout:s};try{i.setItem(u,JSON.stringify(g))}catch(p){console.error(p)}}function Kx({layout:t,panelConstraints:n}){const r=[...t],s=r.reduce((c,u)=>c+u,0);if(r.length!==n.length)throw Error(`Invalid ${n.length} panel layout: ${r.map(c=>`${c}%`).join(", ")}`);if(!Vn(s,100)&&r.length>0)for(let c=0;c(Xx(Xi),Xi.getItem(t)),setItem:(t,n)=>{Xx(Xi),Xi.setItem(t,n)}},Qx={};function KS({autoSaveId:t=null,children:n,className:r="",direction:s,forwardedRef:i,id:c=null,onLayout:u=null,keyboardResizeBy:f=null,storage:g=Xi,style:p,tagName:y="div",...v}){const w=PS(c),C=b.useRef(null),[S,_]=b.useState(null),[E,R]=b.useState([]),k=Iz(),A=b.useRef({}),D=b.useRef(new Map),H=b.useRef(0),$=b.useRef({autoSaveId:t,direction:s,dragState:S,id:w,keyboardResizeBy:f,onLayout:u,storage:g}),U=b.useRef({layout:E,panelDataArray:[],panelDataArrayChanged:!1});b.useRef({didLogIdAndOrderWarning:!1,didLogPanelConstraintsWarning:!1,prevPanelIds:[]}),b.useImperativeHandle(i,()=>({getId:()=>$.current.id,getLayout:()=>{const{layout:L}=U.current;return L},setLayout:L=>{const{onLayout:Y}=$.current,{layout:J,panelDataArray:ie}=U.current,pe=Kx({layout:L,panelConstraints:ie.map(Q=>Q.constraints)});Zx(J,pe)||(R(pe),U.current.layout=pe,Y&&Y(pe),_o(ie,pe,A.current))}}),[]),ko(()=>{$.current.autoSaveId=t,$.current.direction=s,$.current.dragState=S,$.current.id=w,$.current.onLayout=u,$.current.storage=g}),Zz({committedValuesRef:$,eagerValuesRef:U,groupId:w,layout:E,panelDataArray:U.current.panelDataArray,setLayout:R,panelGroupElement:C.current}),b.useEffect(()=>{const{panelDataArray:L}=U.current;if(t){if(E.length===0||E.length!==L.length)return;let Y=Qx[t];Y==null&&(Y=Jz(t3,n3),Qx[t]=Y);const J=[...L],ie=new Map(D.current);Y(t,J,ie,E,g)}},[t,E,g]),b.useEffect(()=>{});const F=b.useCallback(L=>{const{onLayout:Y}=$.current,{layout:J,panelDataArray:ie}=U.current;if(L.constraints.collapsible){const pe=ie.map(et=>et.constraints),{collapsedSize:Q=0,panelSize:oe,pivotIndices:Re}=bs(ie,L,J);if(ot(oe!=null,`Panel size not found for panel "${L.id}"`),!ar(oe,Q)){D.current.set(L.id,oe);const Me=No(ie,L)===ie.length-1?oe-Q:Q-oe,ze=Zi({delta:Me,initialLayout:J,panelConstraints:pe,pivotIndices:Re,prevLayout:J,trigger:"imperative-api"});qc(J,ze)||(R(ze),U.current.layout=ze,Y&&Y(ze),_o(ie,ze,A.current))}}},[]),de=b.useCallback((L,Y)=>{const{onLayout:J}=$.current,{layout:ie,panelDataArray:pe}=U.current;if(L.constraints.collapsible){const Q=pe.map(be=>be.constraints),{collapsedSize:oe=0,panelSize:Re=0,minSize:et=0,pivotIndices:Me}=bs(pe,L,ie),ze=Y??et;if(ar(Re,oe)){const be=D.current.get(L.id),je=be!=null&&be>=ze?be:ze,ht=No(pe,L)===pe.length-1?Re-je:je-Re,Qe=Zi({delta:ht,initialLayout:ie,panelConstraints:Q,pivotIndices:Me,prevLayout:ie,trigger:"imperative-api"});qc(ie,Qe)||(R(Qe),U.current.layout=Qe,J&&J(Qe),_o(pe,Qe,A.current))}}},[]),fe=b.useCallback(L=>{const{layout:Y,panelDataArray:J}=U.current,{panelSize:ie}=bs(J,L,Y);return ot(ie!=null,`Panel size not found for panel "${L.id}"`),ie},[]),me=b.useCallback((L,Y)=>{const{panelDataArray:J}=U.current,ie=No(J,L);return Wz({defaultSize:Y,dragState:S,layout:E,panelData:J,panelIndex:ie})},[S,E]),se=b.useCallback(L=>{const{layout:Y,panelDataArray:J}=U.current,{collapsedSize:ie=0,collapsible:pe,panelSize:Q}=bs(J,L,Y);return ot(Q!=null,`Panel size not found for panel "${L.id}"`),pe===!0&&ar(Q,ie)},[]),G=b.useCallback(L=>{const{layout:Y,panelDataArray:J}=U.current,{collapsedSize:ie=0,collapsible:pe,panelSize:Q}=bs(J,L,Y);return ot(Q!=null,`Panel size not found for panel "${L.id}"`),!pe||Ns(Q,ie)>0},[]),he=b.useCallback(L=>{const{panelDataArray:Y}=U.current;Y.push(L),Y.sort((J,ie)=>{const pe=J.order,Q=ie.order;return pe==null&&Q==null?0:pe==null?-1:Q==null?1:pe-Q}),U.current.panelDataArrayChanged=!0,k()},[k]);ko(()=>{if(U.current.panelDataArrayChanged){U.current.panelDataArrayChanged=!1;const{autoSaveId:L,onLayout:Y,storage:J}=$.current,{layout:ie,panelDataArray:pe}=U.current;let Q=null;if(L){const Re=e3(L,pe,J);Re&&(D.current=new Map(Object.entries(Re.expandToSizes)),Q=Re.layout)}Q==null&&(Q=Qz({panelDataArray:pe}));const oe=Kx({layout:Q,panelConstraints:pe.map(Re=>Re.constraints)});Zx(ie,oe)||(R(oe),U.current.layout=oe,Y&&Y(oe),_o(pe,oe,A.current))}}),ko(()=>{const L=U.current;return()=>{L.layout=[]}},[]);const ve=b.useCallback(L=>{let Y=!1;const J=C.current;return J&&window.getComputedStyle(J,null).getPropertyValue("direction")==="rtl"&&(Y=!0),function(pe){pe.preventDefault();const Q=C.current;if(!Q)return()=>null;const{direction:oe,dragState:Re,id:et,keyboardResizeBy:Me,onLayout:ze}=$.current,{layout:be,panelDataArray:je}=U.current,{initialLayout:at}=Re??{},ht=FS(et,L,Q);let Qe=Kz(pe,L,oe,Re,Me,Q);const Pe=oe==="horizontal";Pe&&Y&&(Qe=-Qe);const Tt=je.map(B=>B.constraints),Zt=Zi({delta:Qe,initialLayout:at??be,panelConstraints:Tt,pivotIndices:ht,prevLayout:be,trigger:VS(pe)?"keyboard":"mouse-or-touch"}),O=!qc(be,Zt);(IS(pe)||qS(pe))&&H.current!=Qe&&(H.current=Qe,!O&&Qe!==0?Pe?Hm(L,Qe<0?Uz:Bz):Hm(L,Qe<0?Pz:Hz):Hm(L,0)),O&&(R(Zt),U.current.layout=Zt,ze&&ze(Zt),_o(je,Zt,A.current))}},[]),T=b.useCallback((L,Y)=>{const{onLayout:J}=$.current,{layout:ie,panelDataArray:pe}=U.current,Q=pe.map(be=>be.constraints),{panelSize:oe,pivotIndices:Re}=bs(pe,L,ie);ot(oe!=null,`Panel size not found for panel "${L.id}"`);const Me=No(pe,L)===pe.length-1?oe-Y:Y-oe,ze=Zi({delta:Me,initialLayout:ie,panelConstraints:Q,pivotIndices:Re,prevLayout:ie,trigger:"imperative-api"});qc(ie,ze)||(R(ze),U.current.layout=ze,J&&J(ze),_o(pe,ze,A.current))},[]),K=b.useCallback((L,Y)=>{const{layout:J,panelDataArray:ie}=U.current,{collapsedSize:pe=0,collapsible:Q}=Y,{collapsedSize:oe=0,collapsible:Re,maxSize:et=100,minSize:Me=0}=L.constraints,{panelSize:ze}=bs(ie,L,J);ze!=null&&(Q&&Re&&ar(ze,pe)?ar(pe,oe)||T(L,oe):zeet&&T(L,et))},[T]),te=b.useCallback((L,Y)=>{const{direction:J}=$.current,{layout:ie}=U.current;if(!C.current)return;const pe=gp(L,C.current);ot(pe,`Drag handle element not found for id "${L}"`);const Q=GS(J,Y);_({dragHandleId:L,dragHandleRect:pe.getBoundingClientRect(),initialCursorPosition:Q,initialLayout:ie})},[]),le=b.useCallback(()=>{_(null)},[]),ne=b.useCallback(L=>{const{panelDataArray:Y}=U.current,J=No(Y,L);J>=0&&(Y.splice(J,1),delete A.current[L.id],U.current.panelDataArrayChanged=!0,k())},[k]),j=b.useMemo(()=>({collapsePanel:F,direction:s,dragState:S,expandPanel:de,getPanelSize:fe,getPanelStyle:me,groupId:w,isPanelCollapsed:se,isPanelExpanded:G,reevaluatePanelConstraints:K,registerPanel:he,registerResizeHandle:ve,resizePanel:T,startDragging:te,stopDragging:le,unregisterPanel:ne,panelGroupElement:C.current}),[F,S,s,de,fe,me,w,se,G,K,he,ve,T,te,le,ne]),X={display:"flex",flexDirection:s==="horizontal"?"row":"column",height:"100%",overflow:"hidden",width:"100%"};return b.createElement(hp.Provider,{value:j},b.createElement(y,{...v,children:n,className:r,id:c,ref:C,style:{...X,...p},[qn.group]:"",[qn.groupDirection]:s,[qn.groupId]:w}))}const a3=b.forwardRef((t,n)=>b.createElement(KS,{...t,forwardedRef:n}));KS.displayName="PanelGroup";a3.displayName="forwardRef(PanelGroup)";function No(t,n){return t.findIndex(r=>r===n||r.id===n.id)}function bs(t,n,r){const s=No(t,n),c=s===t.length-1?[s-1,s]:[s,s+1],u=r[s];return{...n.constraints,panelSize:u,pivotIndices:c}}var r3=(t,n,r,s,i,c,u,f)=>{let g=document.documentElement,p=["light","dark"];function y(C){(Array.isArray(t)?t:[t]).forEach(S=>{let _=S==="class",E=_&&c?i.map(R=>c[R]||R):i;_?(g.classList.remove(...E),g.classList.add(c&&c[C]?c[C]:C)):g.setAttribute(S,C)}),v(C)}function v(C){f&&p.includes(C)&&(g.style.colorScheme=C)}function w(){return window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}if(s)y(s);else try{let C=localStorage.getItem(n)||r,S=u&&C==="system"?w():C;y(S)}catch{}};b.createContext(void 0);b.memo(({forcedTheme:t,storageKey:n,attribute:r,enableSystem:s,enableColorScheme:i,defaultTheme:c,value:u,themes:f,nonce:g,scriptProps:p})=>{let y=JSON.stringify([r,n,c,t,f,u,s,i]).slice(1,-1);return b.createElement("script",{...p,suppressHydrationWarning:!0,nonce:typeof window>"u"?g:"",dangerouslySetInnerHTML:{__html:`(${r3.toString()})(${y})`}})});function Jt(...t){return a1(Oh(t))}var s3=Ph("relative w-full rounded-lg border px-4 py-3 text-sm grid has-[>svg]:grid-cols-[calc(var(--spacing)*4)_1fr] grid-cols-[0_1fr] has-[>svg]:gap-x-3 gap-y-0.5 items-start [&>svg]:size-4 [&>svg]:translate-y-0.5 [&>svg]:text-current",{variants:{variant:{default:"bg-card text-card-foreground",destructive:"text-destructive bg-card [&>svg]:text-current *:data-[slot=alert-description]:text-destructive/90"}},defaultVariants:{variant:"default"}});function o3({className:t,variant:n,...r}){return h.jsx("div",{"data-slot":"alert",role:"alert",className:Jt(s3({variant:n}),t),...r})}function i3({className:t,...n}){return h.jsx("div",{"data-slot":"alert-title",className:Jt("col-start-2 line-clamp-1 min-h-4 font-medium tracking-tight",t),...n})}function l3({className:t,...n}){return h.jsx("div",{"data-slot":"alert-description",className:Jt("text-muted-foreground col-start-2 grid justify-items-start gap-1 text-sm [&_p]:leading-relaxed",t),...n})}var c3=Ph("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",{variants:{variant:{default:"bg-primary text-primary-foreground shadow-xs hover:bg-primary/90",destructive:"bg-destructive text-white shadow-xs hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",outline:"border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:bg-input/30 dark:border-input dark:hover:bg-input/50",secondary:"bg-secondary text-secondary-foreground shadow-xs hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-9 px-4 py-2 has-[>svg]:px-3",sm:"h-8 rounded-md gap-1.5 px-3 has-[>svg]:px-2.5",lg:"h-10 rounded-md px-6 has-[>svg]:px-4",icon:"size-9"}},defaultVariants:{variant:"default",size:"default"}}),ut=b.forwardRef(({className:t,variant:n,size:r,asChild:s=!1,...i},c)=>{const u=s?lw:"button";return h.jsx(u,{className:Jt(c3({variant:n,size:r,className:t})),ref:c,...i})});ut.displayName="Button";var u3=Ph("inline-flex items-center justify-center rounded-md border px-2 py-0.5 text-xs font-medium w-fit whitespace-nowrap shrink-0 [&>svg]:size-3 gap-1 [&>svg]:pointer-events-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive transition-[color,box-shadow] overflow-hidden",{variants:{variant:{default:"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 [a&]:hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",outline:"text-foreground [a&]:hover:bg-accent [a&]:hover:text-accent-foreground"}},defaultVariants:{variant:"default"}});function pu({className:t,variant:n,asChild:r=!1,...s}){const i=r?lw:"span";return h.jsx(i,{"data-slot":"badge",className:Jt(u3({variant:n}),t),...s})}function d3({className:t,...n}){return h.jsx("div",{"data-slot":"card",className:Jt("bg-card text-card-foreground flex flex-col gap-6 rounded-xl border py-6 shadow-sm",t),...n})}function f3({className:t,...n}){return h.jsx("div",{"data-slot":"card-content",className:Jt("px-6",t),...n})}b.createContext(null);b.createContext(null);function gu({...t}){return h.jsx(yk,{"data-slot":"dialog",...t})}function m3({...t}){return h.jsx(bk,{"data-slot":"dialog-portal",...t})}function h3({className:t,...n}){return h.jsx(rw,{"data-slot":"dialog-overlay",className:Jt("data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50",t),...n})}function vu({className:t,children:n,showCloseButton:r=!0,...s}){return h.jsxs(m3,{"data-slot":"dialog-portal",children:[h.jsx(h3,{}),h.jsxs(sw,{"data-slot":"dialog-content",className:Jt("bg-background data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 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 p-6 shadow-lg duration-200 sm:max-w-lg",t),...s,children:[n,r&&h.jsxs(Sk,{"data-slot":"dialog-close",className:"ring-offset-background focus:ring-ring data-[state=open]:bg-accent data-[state=open]:text-muted-foreground absolute top-4 right-4 rounded-xs opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",children:[h.jsx(oj,{}),h.jsx("span",{className:"sr-only",children:"Close"})]})]})]})}function yu({className:t,...n}){return h.jsx("div",{"data-slot":"dialog-header",className:Jt("flex flex-col gap-2 text-center sm:text-left",t),...n})}function QS({className:t,...n}){return h.jsx("div",{"data-slot":"dialog-footer",className:Jt("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",t),...n})}function bu({className:t,...n}){return h.jsx(xk,{"data-slot":"dialog-title",className:Jt("text-lg leading-none font-semibold",t),...n})}function xu({className:t,...n}){return h.jsx(wk,{"data-slot":"dialog-description",className:Jt("text-muted-foreground text-sm",t),...n})}function p3({...t}){return h.jsx(j4,{"data-slot":"dropdown-menu",...t})}function g3({...t}){return h.jsx(k4,{"data-slot":"dropdown-menu-trigger",...t})}function v3({className:t,sideOffset:n=4,...r}){return h.jsx(M4,{children:h.jsx(D4,{"data-slot":"dropdown-menu-content",sideOffset:n,className:Jt("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 max-h-(--radix-dropdown-menu-content-available-height) min-w-[8rem] origin-(--radix-dropdown-menu-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border p-1 shadow-md",t),...r})})}function y3({className:t,inset:n,variant:r="default",...s}){return h.jsx(z4,{"data-slot":"dropdown-menu-item","data-inset":n,"data-variant":r,className:Jt("focus:bg-accent focus:text-accent-foreground data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 dark:data-[variant=destructive]:focus:bg-destructive/20 data-[variant=destructive]:focus:text-destructive data-[variant=destructive]:*:[svg]:!text-destructive [&_svg:not([class*='text-'])]:text-muted-foreground relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 data-[inset]:pl-8 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",t),...s})}function Pr({className:t,...n}){return h.jsx(sz,{"data-slot":"label",className:Jt("flex items-center gap-2 text-sm leading-none font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50",t),...n})}b.createContext({});b.createContext({});function Ra({className:t,type:n,...r}){return h.jsx("input",{type:n,"data-slot":"input",className:Jt("file:text-foreground placeholder:text-muted-foreground selection:bg-primary selection:text-primary-foreground dark:bg-input/30 border-input flex h-9 w-full min-w-0 rounded-md border bg-transparent px-3 py-1 text-base shadow-xs transition-[color,box-shadow] outline-none file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm","focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px]","aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",t),...r})}var b3=b.forwardRef(({className:t,align:n="center",sideOffset:r=4,...s},i)=>h.jsx(jz,{children:h.jsx(BS,{ref:i,align:n,sideOffset:r,className:Jt("z-50 w-72 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none",t),...s})}));b3.displayName=BS.displayName;function x3({className:t,...n}){return h.jsx("div",{"data-slot":"skeleton",className:Jt("bg-accent animate-pulse rounded-md",t),...n})}b.createContext(null);b.createContext({size:"default",variant:"default"});const w3=()=>{const t=Xr();return h.jsx("div",{className:"min-h-screen bg-gradient-to-br from-primary/10 via-background to-background",children:h.jsx("div",{className:"container mx-auto px-4 py-16",children:h.jsxs("div",{className:"max-w-4xl mx-auto text-center space-y-8",children:[h.jsxs("div",{className:"space-y-4",children:[h.jsx("h1",{className:"text-6xl font-bold text-primary animate-fadeIn",children:"Evolution GO"}),h.jsx("p",{className:"text-xl text-muted-foreground",children:"Interface moderna para gerenciamento de instâncias WhatsApp"})]}),h.jsxs("div",{className:"grid md:grid-cols-3 gap-6 mt-12",children:[h.jsxs("div",{className:"bg-card border rounded-lg p-6 space-y-3 hover:border-primary transition-colors",children:[h.jsx("div",{className:"w-12 h-12 bg-primary/10 rounded-lg flex items-center justify-center",children:h.jsx(QR,{className:"w-6 h-6 text-primary"})}),h.jsx("h3",{className:"text-lg font-semibold",children:"Rápido e Eficiente"}),h.jsx("p",{className:"text-sm text-muted-foreground",children:"Gerencie múltiplas instâncias WhatsApp com alta performance"})]}),h.jsxs("div",{className:"bg-card border rounded-lg p-6 space-y-3 hover:border-primary transition-colors",children:[h.jsx("div",{className:"w-12 h-12 bg-primary/10 rounded-lg flex items-center justify-center",children:h.jsx(VR,{className:"w-6 h-6 text-primary"})}),h.jsx("h3",{className:"text-lg font-semibold",children:"Seguro"}),h.jsx("p",{className:"text-sm text-muted-foreground",children:"Autenticação robusta e controle total sobre suas instâncias"})]}),h.jsxs("div",{className:"bg-card border rounded-lg p-6 space-y-3 hover:border-primary transition-colors",children:[h.jsx("div",{className:"w-12 h-12 bg-primary/10 rounded-lg flex items-center justify-center",children:h.jsx(vR,{className:"w-6 h-6 text-primary"})}),h.jsx("h3",{className:"text-lg font-semibold",children:"API Completa"}),h.jsx("p",{className:"text-sm text-muted-foreground",children:"Integração via API REST com Evolution GO"})]})]}),h.jsx("div",{className:"mt-12",children:h.jsxs(ut,{size:"lg",onClick:()=>t("/manager/login"),className:"text-lg px-8 py-6 group",children:["Acessar Manager",h.jsx(K2,{className:"ml-2 w-5 h-5 group-hover:translate-x-1 transition-transform"})]})}),h.jsxs("div",{className:"mt-16 pt-8 border-t",children:[h.jsx("p",{className:"text-sm text-muted-foreground",children:"Evolution GO Manager - Gerencie suas instâncias WhatsApp de forma simples e eficiente"}),h.jsxs("p",{className:"text-xs text-muted-foreground mt-2",children:["© ",new Date().getFullYear()," Evolution GO. Todos os direitos reservados."]})]})]})})})};var dt;(function(t){t.assertEqual=i=>{};function n(i){}t.assertIs=n;function r(i){throw new Error}t.assertNever=r,t.arrayToEnum=i=>{const c={};for(const u of i)c[u]=u;return c},t.getValidEnumValues=i=>{const c=t.objectKeys(i).filter(f=>typeof i[i[f]]!="number"),u={};for(const f of c)u[f]=i[f];return t.objectValues(u)},t.objectValues=i=>t.objectKeys(i).map(function(c){return i[c]}),t.objectKeys=typeof Object.keys=="function"?i=>Object.keys(i):i=>{const c=[];for(const u in i)Object.prototype.hasOwnProperty.call(i,u)&&c.push(u);return c},t.find=(i,c)=>{for(const u of i)if(c(u))return u},t.isInteger=typeof Number.isInteger=="function"?i=>Number.isInteger(i):i=>typeof i=="number"&&Number.isFinite(i)&&Math.floor(i)===i;function s(i,c=" | "){return i.map(u=>typeof u=="string"?`'${u}'`:u).join(c)}t.joinValues=s,t.jsonStringifyReplacer=(i,c)=>typeof c=="bigint"?c.toString():c})(dt||(dt={}));var Wx;(function(t){t.mergeShapes=(n,r)=>({...n,...r})})(Wx||(Wx={}));const Te=dt.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),Hr=t=>{switch(typeof t){case"undefined":return Te.undefined;case"string":return Te.string;case"number":return Number.isNaN(t)?Te.nan:Te.number;case"boolean":return Te.boolean;case"function":return Te.function;case"bigint":return Te.bigint;case"symbol":return Te.symbol;case"object":return Array.isArray(t)?Te.array:t===null?Te.null:t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?Te.promise:typeof Map<"u"&&t instanceof Map?Te.map:typeof Set<"u"&&t instanceof Set?Te.set:typeof Date<"u"&&t instanceof Date?Te.date:Te.object;default:return Te.unknown}},xe=dt.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]);class lr extends Error{get errors(){return this.issues}constructor(n){super(),this.issues=[],this.addIssue=s=>{this.issues=[...this.issues,s]},this.addIssues=(s=[])=>{this.issues=[...this.issues,...s]};const r=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,r):this.__proto__=r,this.name="ZodError",this.issues=n}format(n){const r=n||function(c){return c.message},s={_errors:[]},i=c=>{for(const u of c.issues)if(u.code==="invalid_union")u.unionErrors.map(i);else if(u.code==="invalid_return_type")i(u.returnTypeError);else if(u.code==="invalid_arguments")i(u.argumentsError);else if(u.path.length===0)s._errors.push(r(u));else{let f=s,g=0;for(;gr.message){const r={},s=[];for(const i of this.issues)if(i.path.length>0){const c=i.path[0];r[c]=r[c]||[],r[c].push(n(i))}else s.push(n(i));return{formErrors:s,fieldErrors:r}}get formErrors(){return this.flatten()}}lr.create=t=>new lr(t);const fh=(t,n)=>{let r;switch(t.code){case xe.invalid_type:t.received===Te.undefined?r="Required":r=`Expected ${t.expected}, received ${t.received}`;break;case xe.invalid_literal:r=`Invalid literal value, expected ${JSON.stringify(t.expected,dt.jsonStringifyReplacer)}`;break;case xe.unrecognized_keys:r=`Unrecognized key(s) in object: ${dt.joinValues(t.keys,", ")}`;break;case xe.invalid_union:r="Invalid input";break;case xe.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${dt.joinValues(t.options)}`;break;case xe.invalid_enum_value:r=`Invalid enum value. Expected ${dt.joinValues(t.options)}, received '${t.received}'`;break;case xe.invalid_arguments:r="Invalid function arguments";break;case xe.invalid_return_type:r="Invalid function return type";break;case xe.invalid_date:r="Invalid date";break;case xe.invalid_string:typeof t.validation=="object"?"includes"in t.validation?(r=`Invalid input: must include "${t.validation.includes}"`,typeof t.validation.position=="number"&&(r=`${r} at one or more positions greater than or equal to ${t.validation.position}`)):"startsWith"in t.validation?r=`Invalid input: must start with "${t.validation.startsWith}"`:"endsWith"in t.validation?r=`Invalid input: must end with "${t.validation.endsWith}"`:dt.assertNever(t.validation):t.validation!=="regex"?r=`Invalid ${t.validation}`:r="Invalid";break;case xe.too_small:t.type==="array"?r=`Array must contain ${t.exact?"exactly":t.inclusive?"at least":"more than"} ${t.minimum} element(s)`:t.type==="string"?r=`String must contain ${t.exact?"exactly":t.inclusive?"at least":"over"} ${t.minimum} character(s)`:t.type==="number"?r=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="bigint"?r=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="date"?r=`Date must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(t.minimum))}`:r="Invalid input";break;case xe.too_big:t.type==="array"?r=`Array must contain ${t.exact?"exactly":t.inclusive?"at most":"less than"} ${t.maximum} element(s)`:t.type==="string"?r=`String must contain ${t.exact?"exactly":t.inclusive?"at most":"under"} ${t.maximum} character(s)`:t.type==="number"?r=`Number must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="bigint"?r=`BigInt must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="date"?r=`Date must be ${t.exact?"exactly":t.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(t.maximum))}`:r="Invalid input";break;case xe.custom:r="Invalid input";break;case xe.invalid_intersection_types:r="Intersection results could not be merged";break;case xe.not_multiple_of:r=`Number must be a multiple of ${t.multipleOf}`;break;case xe.not_finite:r="Number must be finite";break;default:r=n.defaultError,dt.assertNever(t)}return{message:r}};let S3=fh;function E3(){return S3}const _3=t=>{const{data:n,path:r,errorMaps:s,issueData:i}=t,c=[...r,...i.path||[]],u={...i,path:c};if(i.message!==void 0)return{...i,path:c,message:i.message};let f="";const g=s.filter(p=>!!p).slice().reverse();for(const p of g)f=p(u,{data:n,defaultError:f}).message;return{...i,path:c,message:f}};function Ee(t,n){const r=E3(),s=_3({issueData:n,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,r,r===fh?void 0:fh].filter(i=>!!i)});t.common.issues.push(s)}class $n{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(n,r){const s=[];for(const i of r){if(i.status==="aborted")return Ie;i.status==="dirty"&&n.dirty(),s.push(i.value)}return{status:n.value,value:s}}static async mergeObjectAsync(n,r){const s=[];for(const i of r){const c=await i.key,u=await i.value;s.push({key:c,value:u})}return $n.mergeObjectSync(n,s)}static mergeObjectSync(n,r){const s={};for(const i of r){const{key:c,value:u}=i;if(c.status==="aborted"||u.status==="aborted")return Ie;c.status==="dirty"&&n.dirty(),u.status==="dirty"&&n.dirty(),c.value!=="__proto__"&&(typeof u.value<"u"||i.alwaysSet)&&(s[c.value]=u.value)}return{status:n.value,value:s}}}const Ie=Object.freeze({status:"aborted"}),Ki=t=>({status:"dirty",value:t}),la=t=>({status:"valid",value:t}),Jx=t=>t.status==="aborted",e0=t=>t.status==="dirty",Bo=t=>t.status==="valid",wu=t=>typeof Promise<"u"&&t instanceof Promise;var ke;(function(t){t.errToObj=n=>typeof n=="string"?{message:n}:n||{},t.toString=n=>typeof n=="string"?n:n==null?void 0:n.message})(ke||(ke={}));class Yr{constructor(n,r,s,i){this._cachedPath=[],this.parent=n,this.data=r,this._path=s,this._key=i}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const t0=(t,n)=>{if(Bo(n))return{success:!0,data:n.value};if(!t.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const r=new lr(t.common.issues);return this._error=r,this._error}}};function Ke(t){if(!t)return{};const{errorMap:n,invalid_type_error:r,required_error:s,description:i}=t;if(n&&(r||s))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return n?{errorMap:n,description:i}:{errorMap:(u,f)=>{const{message:g}=t;return u.code==="invalid_enum_value"?{message:g??f.defaultError}:typeof f.data>"u"?{message:g??s??f.defaultError}:u.code!=="invalid_type"?{message:f.defaultError}:{message:g??r??f.defaultError}},description:i}}class it{get description(){return this._def.description}_getType(n){return Hr(n.data)}_getOrReturnCtx(n,r){return r||{common:n.parent.common,data:n.data,parsedType:Hr(n.data),schemaErrorMap:this._def.errorMap,path:n.path,parent:n.parent}}_processInputParams(n){return{status:new $n,ctx:{common:n.parent.common,data:n.data,parsedType:Hr(n.data),schemaErrorMap:this._def.errorMap,path:n.path,parent:n.parent}}}_parseSync(n){const r=this._parse(n);if(wu(r))throw new Error("Synchronous parse encountered promise.");return r}_parseAsync(n){const r=this._parse(n);return Promise.resolve(r)}parse(n,r){const s=this.safeParse(n,r);if(s.success)return s.data;throw s.error}safeParse(n,r){const s={common:{issues:[],async:(r==null?void 0:r.async)??!1,contextualErrorMap:r==null?void 0:r.errorMap},path:(r==null?void 0:r.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:n,parsedType:Hr(n)},i=this._parseSync({data:n,path:s.path,parent:s});return t0(s,i)}"~validate"(n){var s,i;const r={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:n,parsedType:Hr(n)};if(!this["~standard"].async)try{const c=this._parseSync({data:n,path:[],parent:r});return Bo(c)?{value:c.value}:{issues:r.common.issues}}catch(c){(i=(s=c==null?void 0:c.message)==null?void 0:s.toLowerCase())!=null&&i.includes("encountered")&&(this["~standard"].async=!0),r.common={issues:[],async:!0}}return this._parseAsync({data:n,path:[],parent:r}).then(c=>Bo(c)?{value:c.value}:{issues:r.common.issues})}async parseAsync(n,r){const s=await this.safeParseAsync(n,r);if(s.success)return s.data;throw s.error}async safeParseAsync(n,r){const s={common:{issues:[],contextualErrorMap:r==null?void 0:r.errorMap,async:!0},path:(r==null?void 0:r.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:n,parsedType:Hr(n)},i=this._parse({data:n,path:s.path,parent:s}),c=await(wu(i)?i:Promise.resolve(i));return t0(s,c)}refine(n,r){const s=i=>typeof r=="string"||typeof r>"u"?{message:r}:typeof r=="function"?r(i):r;return this._refinement((i,c)=>{const u=n(i),f=()=>c.addIssue({code:xe.custom,...s(i)});return typeof Promise<"u"&&u instanceof Promise?u.then(g=>g?!0:(f(),!1)):u?!0:(f(),!1)})}refinement(n,r){return this._refinement((s,i)=>n(s)?!0:(i.addIssue(typeof r=="function"?r(s,i):r),!1))}_refinement(n){return new Ho({schema:this,typeName:Fe.ZodEffects,effect:{type:"refinement",refinement:n}})}superRefine(n){return this._refinement(n)}constructor(n){this.spa=this.safeParseAsync,this._def=n,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:r=>this["~validate"](r)}}optional(){return qr.create(this,this._def)}nullable(){return Vo.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Ma.create(this)}promise(){return Cu.create(this,this._def)}or(n){return Eu.create([this,n],this._def)}and(n){return _u.create(this,n,this._def)}transform(n){return new Ho({...Ke(this._def),schema:this,typeName:Fe.ZodEffects,effect:{type:"transform",transform:n}})}default(n){const r=typeof n=="function"?n:()=>n;return new gh({...Ke(this._def),innerType:this,defaultValue:r,typeName:Fe.ZodDefault})}brand(){return new Y3({typeName:Fe.ZodBranded,type:this,...Ke(this._def)})}catch(n){const r=typeof n=="function"?n:()=>n;return new vh({...Ke(this._def),innerType:this,catchValue:r,typeName:Fe.ZodCatch})}describe(n){const r=this.constructor;return new r({...this._def,description:n})}pipe(n){return vp.create(this,n)}readonly(){return yh.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const C3=/^c[^\s-]{8,}$/i,N3=/^[0-9a-z]+$/,R3=/^[0-9A-HJKMNP-TV-Z]{26}$/i,A3=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,T3=/^[a-z0-9_-]{21}$/i,O3=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,j3=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,k3=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,M3="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let Vm;const D3=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,z3=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,L3=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,U3=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,B3=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,P3=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,WS="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",H3=new RegExp(`^${WS}$`);function JS(t){let n="[0-5]\\d";t.precision?n=`${n}\\.\\d{${t.precision}}`:t.precision==null&&(n=`${n}(\\.\\d+)?`);const r=t.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${n})${r}`}function V3(t){return new RegExp(`^${JS(t)}$`)}function I3(t){let n=`${WS}T${JS(t)}`;const r=[];return r.push(t.local?"Z?":"Z"),t.offset&&r.push("([+-]\\d{2}:?\\d{2})"),n=`${n}(${r.join("|")})`,new RegExp(`^${n}$`)}function q3(t,n){return!!((n==="v4"||!n)&&D3.test(t)||(n==="v6"||!n)&&L3.test(t))}function F3(t,n){if(!O3.test(t))return!1;try{const[r]=t.split(".");if(!r)return!1;const s=r.replace(/-/g,"+").replace(/_/g,"/").padEnd(r.length+(4-r.length%4)%4,"="),i=JSON.parse(atob(s));return!(typeof i!="object"||i===null||"typ"in i&&(i==null?void 0:i.typ)!=="JWT"||!i.alg||n&&i.alg!==n)}catch{return!1}}function $3(t,n){return!!((n==="v4"||!n)&&z3.test(t)||(n==="v6"||!n)&&U3.test(t))}class Ir extends it{_parse(n){if(this._def.coerce&&(n.data=String(n.data)),this._getType(n)!==Te.string){const c=this._getOrReturnCtx(n);return Ee(c,{code:xe.invalid_type,expected:Te.string,received:c.parsedType}),Ie}const s=new $n;let i;for(const c of this._def.checks)if(c.kind==="min")n.data.lengthc.value&&(i=this._getOrReturnCtx(n,i),Ee(i,{code:xe.too_big,maximum:c.value,type:"string",inclusive:!0,exact:!1,message:c.message}),s.dirty());else if(c.kind==="length"){const u=n.data.length>c.value,f=n.data.lengthn.test(i),{validation:r,code:xe.invalid_string,...ke.errToObj(s)})}_addCheck(n){return new Ir({...this._def,checks:[...this._def.checks,n]})}email(n){return this._addCheck({kind:"email",...ke.errToObj(n)})}url(n){return this._addCheck({kind:"url",...ke.errToObj(n)})}emoji(n){return this._addCheck({kind:"emoji",...ke.errToObj(n)})}uuid(n){return this._addCheck({kind:"uuid",...ke.errToObj(n)})}nanoid(n){return this._addCheck({kind:"nanoid",...ke.errToObj(n)})}cuid(n){return this._addCheck({kind:"cuid",...ke.errToObj(n)})}cuid2(n){return this._addCheck({kind:"cuid2",...ke.errToObj(n)})}ulid(n){return this._addCheck({kind:"ulid",...ke.errToObj(n)})}base64(n){return this._addCheck({kind:"base64",...ke.errToObj(n)})}base64url(n){return this._addCheck({kind:"base64url",...ke.errToObj(n)})}jwt(n){return this._addCheck({kind:"jwt",...ke.errToObj(n)})}ip(n){return this._addCheck({kind:"ip",...ke.errToObj(n)})}cidr(n){return this._addCheck({kind:"cidr",...ke.errToObj(n)})}datetime(n){return typeof n=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:n}):this._addCheck({kind:"datetime",precision:typeof(n==null?void 0:n.precision)>"u"?null:n==null?void 0:n.precision,offset:(n==null?void 0:n.offset)??!1,local:(n==null?void 0:n.local)??!1,...ke.errToObj(n==null?void 0:n.message)})}date(n){return this._addCheck({kind:"date",message:n})}time(n){return typeof n=="string"?this._addCheck({kind:"time",precision:null,message:n}):this._addCheck({kind:"time",precision:typeof(n==null?void 0:n.precision)>"u"?null:n==null?void 0:n.precision,...ke.errToObj(n==null?void 0:n.message)})}duration(n){return this._addCheck({kind:"duration",...ke.errToObj(n)})}regex(n,r){return this._addCheck({kind:"regex",regex:n,...ke.errToObj(r)})}includes(n,r){return this._addCheck({kind:"includes",value:n,position:r==null?void 0:r.position,...ke.errToObj(r==null?void 0:r.message)})}startsWith(n,r){return this._addCheck({kind:"startsWith",value:n,...ke.errToObj(r)})}endsWith(n,r){return this._addCheck({kind:"endsWith",value:n,...ke.errToObj(r)})}min(n,r){return this._addCheck({kind:"min",value:n,...ke.errToObj(r)})}max(n,r){return this._addCheck({kind:"max",value:n,...ke.errToObj(r)})}length(n,r){return this._addCheck({kind:"length",value:n,...ke.errToObj(r)})}nonempty(n){return this.min(1,ke.errToObj(n))}trim(){return new Ir({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new Ir({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new Ir({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(n=>n.kind==="datetime")}get isDate(){return!!this._def.checks.find(n=>n.kind==="date")}get isTime(){return!!this._def.checks.find(n=>n.kind==="time")}get isDuration(){return!!this._def.checks.find(n=>n.kind==="duration")}get isEmail(){return!!this._def.checks.find(n=>n.kind==="email")}get isURL(){return!!this._def.checks.find(n=>n.kind==="url")}get isEmoji(){return!!this._def.checks.find(n=>n.kind==="emoji")}get isUUID(){return!!this._def.checks.find(n=>n.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(n=>n.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(n=>n.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(n=>n.kind==="cuid2")}get isULID(){return!!this._def.checks.find(n=>n.kind==="ulid")}get isIP(){return!!this._def.checks.find(n=>n.kind==="ip")}get isCIDR(){return!!this._def.checks.find(n=>n.kind==="cidr")}get isBase64(){return!!this._def.checks.find(n=>n.kind==="base64")}get isBase64url(){return!!this._def.checks.find(n=>n.kind==="base64url")}get minLength(){let n=null;for(const r of this._def.checks)r.kind==="min"&&(n===null||r.value>n)&&(n=r.value);return n}get maxLength(){let n=null;for(const r of this._def.checks)r.kind==="max"&&(n===null||r.valuenew Ir({checks:[],typeName:Fe.ZodString,coerce:(t==null?void 0:t.coerce)??!1,...Ke(t)});function G3(t,n){const r=(t.toString().split(".")[1]||"").length,s=(n.toString().split(".")[1]||"").length,i=r>s?r:s,c=Number.parseInt(t.toFixed(i).replace(".","")),u=Number.parseInt(n.toFixed(i).replace(".",""));return c%u/10**i}class rl extends it{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(n){if(this._def.coerce&&(n.data=Number(n.data)),this._getType(n)!==Te.number){const c=this._getOrReturnCtx(n);return Ee(c,{code:xe.invalid_type,expected:Te.number,received:c.parsedType}),Ie}let s;const i=new $n;for(const c of this._def.checks)c.kind==="int"?dt.isInteger(n.data)||(s=this._getOrReturnCtx(n,s),Ee(s,{code:xe.invalid_type,expected:"integer",received:"float",message:c.message}),i.dirty()):c.kind==="min"?(c.inclusive?n.datac.value:n.data>=c.value)&&(s=this._getOrReturnCtx(n,s),Ee(s,{code:xe.too_big,maximum:c.value,type:"number",inclusive:c.inclusive,exact:!1,message:c.message}),i.dirty()):c.kind==="multipleOf"?G3(n.data,c.value)!==0&&(s=this._getOrReturnCtx(n,s),Ee(s,{code:xe.not_multiple_of,multipleOf:c.value,message:c.message}),i.dirty()):c.kind==="finite"?Number.isFinite(n.data)||(s=this._getOrReturnCtx(n,s),Ee(s,{code:xe.not_finite,message:c.message}),i.dirty()):dt.assertNever(c);return{status:i.value,value:n.data}}gte(n,r){return this.setLimit("min",n,!0,ke.toString(r))}gt(n,r){return this.setLimit("min",n,!1,ke.toString(r))}lte(n,r){return this.setLimit("max",n,!0,ke.toString(r))}lt(n,r){return this.setLimit("max",n,!1,ke.toString(r))}setLimit(n,r,s,i){return new rl({...this._def,checks:[...this._def.checks,{kind:n,value:r,inclusive:s,message:ke.toString(i)}]})}_addCheck(n){return new rl({...this._def,checks:[...this._def.checks,n]})}int(n){return this._addCheck({kind:"int",message:ke.toString(n)})}positive(n){return this._addCheck({kind:"min",value:0,inclusive:!1,message:ke.toString(n)})}negative(n){return this._addCheck({kind:"max",value:0,inclusive:!1,message:ke.toString(n)})}nonpositive(n){return this._addCheck({kind:"max",value:0,inclusive:!0,message:ke.toString(n)})}nonnegative(n){return this._addCheck({kind:"min",value:0,inclusive:!0,message:ke.toString(n)})}multipleOf(n,r){return this._addCheck({kind:"multipleOf",value:n,message:ke.toString(r)})}finite(n){return this._addCheck({kind:"finite",message:ke.toString(n)})}safe(n){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:ke.toString(n)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:ke.toString(n)})}get minValue(){let n=null;for(const r of this._def.checks)r.kind==="min"&&(n===null||r.value>n)&&(n=r.value);return n}get maxValue(){let n=null;for(const r of this._def.checks)r.kind==="max"&&(n===null||r.valuen.kind==="int"||n.kind==="multipleOf"&&dt.isInteger(n.value))}get isFinite(){let n=null,r=null;for(const s of this._def.checks){if(s.kind==="finite"||s.kind==="int"||s.kind==="multipleOf")return!0;s.kind==="min"?(r===null||s.value>r)&&(r=s.value):s.kind==="max"&&(n===null||s.valuenew rl({checks:[],typeName:Fe.ZodNumber,coerce:(t==null?void 0:t.coerce)||!1,...Ke(t)});class sl extends it{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(n){if(this._def.coerce)try{n.data=BigInt(n.data)}catch{return this._getInvalidInput(n)}if(this._getType(n)!==Te.bigint)return this._getInvalidInput(n);let s;const i=new $n;for(const c of this._def.checks)c.kind==="min"?(c.inclusive?n.datac.value:n.data>=c.value)&&(s=this._getOrReturnCtx(n,s),Ee(s,{code:xe.too_big,type:"bigint",maximum:c.value,inclusive:c.inclusive,message:c.message}),i.dirty()):c.kind==="multipleOf"?n.data%c.value!==BigInt(0)&&(s=this._getOrReturnCtx(n,s),Ee(s,{code:xe.not_multiple_of,multipleOf:c.value,message:c.message}),i.dirty()):dt.assertNever(c);return{status:i.value,value:n.data}}_getInvalidInput(n){const r=this._getOrReturnCtx(n);return Ee(r,{code:xe.invalid_type,expected:Te.bigint,received:r.parsedType}),Ie}gte(n,r){return this.setLimit("min",n,!0,ke.toString(r))}gt(n,r){return this.setLimit("min",n,!1,ke.toString(r))}lte(n,r){return this.setLimit("max",n,!0,ke.toString(r))}lt(n,r){return this.setLimit("max",n,!1,ke.toString(r))}setLimit(n,r,s,i){return new sl({...this._def,checks:[...this._def.checks,{kind:n,value:r,inclusive:s,message:ke.toString(i)}]})}_addCheck(n){return new sl({...this._def,checks:[...this._def.checks,n]})}positive(n){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:ke.toString(n)})}negative(n){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:ke.toString(n)})}nonpositive(n){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:ke.toString(n)})}nonnegative(n){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:ke.toString(n)})}multipleOf(n,r){return this._addCheck({kind:"multipleOf",value:n,message:ke.toString(r)})}get minValue(){let n=null;for(const r of this._def.checks)r.kind==="min"&&(n===null||r.value>n)&&(n=r.value);return n}get maxValue(){let n=null;for(const r of this._def.checks)r.kind==="max"&&(n===null||r.valuenew sl({checks:[],typeName:Fe.ZodBigInt,coerce:(t==null?void 0:t.coerce)??!1,...Ke(t)});class mh extends it{_parse(n){if(this._def.coerce&&(n.data=!!n.data),this._getType(n)!==Te.boolean){const s=this._getOrReturnCtx(n);return Ee(s,{code:xe.invalid_type,expected:Te.boolean,received:s.parsedType}),Ie}return la(n.data)}}mh.create=t=>new mh({typeName:Fe.ZodBoolean,coerce:(t==null?void 0:t.coerce)||!1,...Ke(t)});class Su extends it{_parse(n){if(this._def.coerce&&(n.data=new Date(n.data)),this._getType(n)!==Te.date){const c=this._getOrReturnCtx(n);return Ee(c,{code:xe.invalid_type,expected:Te.date,received:c.parsedType}),Ie}if(Number.isNaN(n.data.getTime())){const c=this._getOrReturnCtx(n);return Ee(c,{code:xe.invalid_date}),Ie}const s=new $n;let i;for(const c of this._def.checks)c.kind==="min"?n.data.getTime()c.value&&(i=this._getOrReturnCtx(n,i),Ee(i,{code:xe.too_big,message:c.message,inclusive:!0,exact:!1,maximum:c.value,type:"date"}),s.dirty()):dt.assertNever(c);return{status:s.value,value:new Date(n.data.getTime())}}_addCheck(n){return new Su({...this._def,checks:[...this._def.checks,n]})}min(n,r){return this._addCheck({kind:"min",value:n.getTime(),message:ke.toString(r)})}max(n,r){return this._addCheck({kind:"max",value:n.getTime(),message:ke.toString(r)})}get minDate(){let n=null;for(const r of this._def.checks)r.kind==="min"&&(n===null||r.value>n)&&(n=r.value);return n!=null?new Date(n):null}get maxDate(){let n=null;for(const r of this._def.checks)r.kind==="max"&&(n===null||r.valuenew Su({checks:[],coerce:(t==null?void 0:t.coerce)||!1,typeName:Fe.ZodDate,...Ke(t)});class n0 extends it{_parse(n){if(this._getType(n)!==Te.symbol){const s=this._getOrReturnCtx(n);return Ee(s,{code:xe.invalid_type,expected:Te.symbol,received:s.parsedType}),Ie}return la(n.data)}}n0.create=t=>new n0({typeName:Fe.ZodSymbol,...Ke(t)});class a0 extends it{_parse(n){if(this._getType(n)!==Te.undefined){const s=this._getOrReturnCtx(n);return Ee(s,{code:xe.invalid_type,expected:Te.undefined,received:s.parsedType}),Ie}return la(n.data)}}a0.create=t=>new a0({typeName:Fe.ZodUndefined,...Ke(t)});class r0 extends it{_parse(n){if(this._getType(n)!==Te.null){const s=this._getOrReturnCtx(n);return Ee(s,{code:xe.invalid_type,expected:Te.null,received:s.parsedType}),Ie}return la(n.data)}}r0.create=t=>new r0({typeName:Fe.ZodNull,...Ke(t)});class s0 extends it{constructor(){super(...arguments),this._any=!0}_parse(n){return la(n.data)}}s0.create=t=>new s0({typeName:Fe.ZodAny,...Ke(t)});class o0 extends it{constructor(){super(...arguments),this._unknown=!0}_parse(n){return la(n.data)}}o0.create=t=>new o0({typeName:Fe.ZodUnknown,...Ke(t)});class Zr extends it{_parse(n){const r=this._getOrReturnCtx(n);return Ee(r,{code:xe.invalid_type,expected:Te.never,received:r.parsedType}),Ie}}Zr.create=t=>new Zr({typeName:Fe.ZodNever,...Ke(t)});class i0 extends it{_parse(n){if(this._getType(n)!==Te.undefined){const s=this._getOrReturnCtx(n);return Ee(s,{code:xe.invalid_type,expected:Te.void,received:s.parsedType}),Ie}return la(n.data)}}i0.create=t=>new i0({typeName:Fe.ZodVoid,...Ke(t)});class Ma extends it{_parse(n){const{ctx:r,status:s}=this._processInputParams(n),i=this._def;if(r.parsedType!==Te.array)return Ee(r,{code:xe.invalid_type,expected:Te.array,received:r.parsedType}),Ie;if(i.exactLength!==null){const u=r.data.length>i.exactLength.value,f=r.data.lengthi.maxLength.value&&(Ee(r,{code:xe.too_big,maximum:i.maxLength.value,type:"array",inclusive:!0,exact:!1,message:i.maxLength.message}),s.dirty()),r.common.async)return Promise.all([...r.data].map((u,f)=>i.type._parseAsync(new Yr(r,u,r.path,f)))).then(u=>$n.mergeArray(s,u));const c=[...r.data].map((u,f)=>i.type._parseSync(new Yr(r,u,r.path,f)));return $n.mergeArray(s,c)}get element(){return this._def.type}min(n,r){return new Ma({...this._def,minLength:{value:n,message:ke.toString(r)}})}max(n,r){return new Ma({...this._def,maxLength:{value:n,message:ke.toString(r)}})}length(n,r){return new Ma({...this._def,exactLength:{value:n,message:ke.toString(r)}})}nonempty(n){return this.min(1,n)}}Ma.create=(t,n)=>new Ma({type:t,minLength:null,maxLength:null,exactLength:null,typeName:Fe.ZodArray,...Ke(n)});function Ro(t){if(t instanceof Gt){const n={};for(const r in t.shape){const s=t.shape[r];n[r]=qr.create(Ro(s))}return new Gt({...t._def,shape:()=>n})}else return t instanceof Ma?new Ma({...t._def,type:Ro(t.element)}):t instanceof qr?qr.create(Ro(t.unwrap())):t instanceof Vo?Vo.create(Ro(t.unwrap())):t instanceof Rs?Rs.create(t.items.map(n=>Ro(n))):t}class Gt extends it{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const n=this._def.shape(),r=dt.objectKeys(n);return this._cached={shape:n,keys:r},this._cached}_parse(n){if(this._getType(n)!==Te.object){const p=this._getOrReturnCtx(n);return Ee(p,{code:xe.invalid_type,expected:Te.object,received:p.parsedType}),Ie}const{status:s,ctx:i}=this._processInputParams(n),{shape:c,keys:u}=this._getCached(),f=[];if(!(this._def.catchall instanceof Zr&&this._def.unknownKeys==="strip"))for(const p in i.data)u.includes(p)||f.push(p);const g=[];for(const p of u){const y=c[p],v=i.data[p];g.push({key:{status:"valid",value:p},value:y._parse(new Yr(i,v,i.path,p)),alwaysSet:p in i.data})}if(this._def.catchall instanceof Zr){const p=this._def.unknownKeys;if(p==="passthrough")for(const y of f)g.push({key:{status:"valid",value:y},value:{status:"valid",value:i.data[y]}});else if(p==="strict")f.length>0&&(Ee(i,{code:xe.unrecognized_keys,keys:f}),s.dirty());else if(p!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const p=this._def.catchall;for(const y of f){const v=i.data[y];g.push({key:{status:"valid",value:y},value:p._parse(new Yr(i,v,i.path,y)),alwaysSet:y in i.data})}}return i.common.async?Promise.resolve().then(async()=>{const p=[];for(const y of g){const v=await y.key,w=await y.value;p.push({key:v,value:w,alwaysSet:y.alwaysSet})}return p}).then(p=>$n.mergeObjectSync(s,p)):$n.mergeObjectSync(s,g)}get shape(){return this._def.shape()}strict(n){return ke.errToObj,new Gt({...this._def,unknownKeys:"strict",...n!==void 0?{errorMap:(r,s)=>{var c,u;const i=((u=(c=this._def).errorMap)==null?void 0:u.call(c,r,s).message)??s.defaultError;return r.code==="unrecognized_keys"?{message:ke.errToObj(n).message??i}:{message:i}}}:{}})}strip(){return new Gt({...this._def,unknownKeys:"strip"})}passthrough(){return new Gt({...this._def,unknownKeys:"passthrough"})}extend(n){return new Gt({...this._def,shape:()=>({...this._def.shape(),...n})})}merge(n){return new Gt({unknownKeys:n._def.unknownKeys,catchall:n._def.catchall,shape:()=>({...this._def.shape(),...n._def.shape()}),typeName:Fe.ZodObject})}setKey(n,r){return this.augment({[n]:r})}catchall(n){return new Gt({...this._def,catchall:n})}pick(n){const r={};for(const s of dt.objectKeys(n))n[s]&&this.shape[s]&&(r[s]=this.shape[s]);return new Gt({...this._def,shape:()=>r})}omit(n){const r={};for(const s of dt.objectKeys(this.shape))n[s]||(r[s]=this.shape[s]);return new Gt({...this._def,shape:()=>r})}deepPartial(){return Ro(this)}partial(n){const r={};for(const s of dt.objectKeys(this.shape)){const i=this.shape[s];n&&!n[s]?r[s]=i:r[s]=i.optional()}return new Gt({...this._def,shape:()=>r})}required(n){const r={};for(const s of dt.objectKeys(this.shape))if(n&&!n[s])r[s]=this.shape[s];else{let c=this.shape[s];for(;c instanceof qr;)c=c._def.innerType;r[s]=c}return new Gt({...this._def,shape:()=>r})}keyof(){return eE(dt.objectKeys(this.shape))}}Gt.create=(t,n)=>new Gt({shape:()=>t,unknownKeys:"strip",catchall:Zr.create(),typeName:Fe.ZodObject,...Ke(n)});Gt.strictCreate=(t,n)=>new Gt({shape:()=>t,unknownKeys:"strict",catchall:Zr.create(),typeName:Fe.ZodObject,...Ke(n)});Gt.lazycreate=(t,n)=>new Gt({shape:t,unknownKeys:"strip",catchall:Zr.create(),typeName:Fe.ZodObject,...Ke(n)});class Eu extends it{_parse(n){const{ctx:r}=this._processInputParams(n),s=this._def.options;function i(c){for(const f of c)if(f.result.status==="valid")return f.result;for(const f of c)if(f.result.status==="dirty")return r.common.issues.push(...f.ctx.common.issues),f.result;const u=c.map(f=>new lr(f.ctx.common.issues));return Ee(r,{code:xe.invalid_union,unionErrors:u}),Ie}if(r.common.async)return Promise.all(s.map(async c=>{const u={...r,common:{...r.common,issues:[]},parent:null};return{result:await c._parseAsync({data:r.data,path:r.path,parent:u}),ctx:u}})).then(i);{let c;const u=[];for(const g of s){const p={...r,common:{...r.common,issues:[]},parent:null},y=g._parseSync({data:r.data,path:r.path,parent:p});if(y.status==="valid")return y;y.status==="dirty"&&!c&&(c={result:y,ctx:p}),p.common.issues.length&&u.push(p.common.issues)}if(c)return r.common.issues.push(...c.ctx.common.issues),c.result;const f=u.map(g=>new lr(g));return Ee(r,{code:xe.invalid_union,unionErrors:f}),Ie}}get options(){return this._def.options}}Eu.create=(t,n)=>new Eu({options:t,typeName:Fe.ZodUnion,...Ke(n)});function hh(t,n){const r=Hr(t),s=Hr(n);if(t===n)return{valid:!0,data:t};if(r===Te.object&&s===Te.object){const i=dt.objectKeys(n),c=dt.objectKeys(t).filter(f=>i.indexOf(f)!==-1),u={...t,...n};for(const f of c){const g=hh(t[f],n[f]);if(!g.valid)return{valid:!1};u[f]=g.data}return{valid:!0,data:u}}else if(r===Te.array&&s===Te.array){if(t.length!==n.length)return{valid:!1};const i=[];for(let c=0;c{if(Jx(c)||Jx(u))return Ie;const f=hh(c.value,u.value);return f.valid?((e0(c)||e0(u))&&r.dirty(),{status:r.value,value:f.data}):(Ee(s,{code:xe.invalid_intersection_types}),Ie)};return s.common.async?Promise.all([this._def.left._parseAsync({data:s.data,path:s.path,parent:s}),this._def.right._parseAsync({data:s.data,path:s.path,parent:s})]).then(([c,u])=>i(c,u)):i(this._def.left._parseSync({data:s.data,path:s.path,parent:s}),this._def.right._parseSync({data:s.data,path:s.path,parent:s}))}}_u.create=(t,n,r)=>new _u({left:t,right:n,typeName:Fe.ZodIntersection,...Ke(r)});class Rs extends it{_parse(n){const{status:r,ctx:s}=this._processInputParams(n);if(s.parsedType!==Te.array)return Ee(s,{code:xe.invalid_type,expected:Te.array,received:s.parsedType}),Ie;if(s.data.lengththis._def.items.length&&(Ee(s,{code:xe.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),r.dirty());const c=[...s.data].map((u,f)=>{const g=this._def.items[f]||this._def.rest;return g?g._parse(new Yr(s,u,s.path,f)):null}).filter(u=>!!u);return s.common.async?Promise.all(c).then(u=>$n.mergeArray(r,u)):$n.mergeArray(r,c)}get items(){return this._def.items}rest(n){return new Rs({...this._def,rest:n})}}Rs.create=(t,n)=>{if(!Array.isArray(t))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new Rs({items:t,typeName:Fe.ZodTuple,rest:null,...Ke(n)})};class l0 extends it{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(n){const{status:r,ctx:s}=this._processInputParams(n);if(s.parsedType!==Te.map)return Ee(s,{code:xe.invalid_type,expected:Te.map,received:s.parsedType}),Ie;const i=this._def.keyType,c=this._def.valueType,u=[...s.data.entries()].map(([f,g],p)=>({key:i._parse(new Yr(s,f,s.path,[p,"key"])),value:c._parse(new Yr(s,g,s.path,[p,"value"]))}));if(s.common.async){const f=new Map;return Promise.resolve().then(async()=>{for(const g of u){const p=await g.key,y=await g.value;if(p.status==="aborted"||y.status==="aborted")return Ie;(p.status==="dirty"||y.status==="dirty")&&r.dirty(),f.set(p.value,y.value)}return{status:r.value,value:f}})}else{const f=new Map;for(const g of u){const p=g.key,y=g.value;if(p.status==="aborted"||y.status==="aborted")return Ie;(p.status==="dirty"||y.status==="dirty")&&r.dirty(),f.set(p.value,y.value)}return{status:r.value,value:f}}}}l0.create=(t,n,r)=>new l0({valueType:n,keyType:t,typeName:Fe.ZodMap,...Ke(r)});class ol extends it{_parse(n){const{status:r,ctx:s}=this._processInputParams(n);if(s.parsedType!==Te.set)return Ee(s,{code:xe.invalid_type,expected:Te.set,received:s.parsedType}),Ie;const i=this._def;i.minSize!==null&&s.data.sizei.maxSize.value&&(Ee(s,{code:xe.too_big,maximum:i.maxSize.value,type:"set",inclusive:!0,exact:!1,message:i.maxSize.message}),r.dirty());const c=this._def.valueType;function u(g){const p=new Set;for(const y of g){if(y.status==="aborted")return Ie;y.status==="dirty"&&r.dirty(),p.add(y.value)}return{status:r.value,value:p}}const f=[...s.data.values()].map((g,p)=>c._parse(new Yr(s,g,s.path,p)));return s.common.async?Promise.all(f).then(g=>u(g)):u(f)}min(n,r){return new ol({...this._def,minSize:{value:n,message:ke.toString(r)}})}max(n,r){return new ol({...this._def,maxSize:{value:n,message:ke.toString(r)}})}size(n,r){return this.min(n,r).max(n,r)}nonempty(n){return this.min(1,n)}}ol.create=(t,n)=>new ol({valueType:t,minSize:null,maxSize:null,typeName:Fe.ZodSet,...Ke(n)});class c0 extends it{get schema(){return this._def.getter()}_parse(n){const{ctx:r}=this._processInputParams(n);return this._def.getter()._parse({data:r.data,path:r.path,parent:r})}}c0.create=(t,n)=>new c0({getter:t,typeName:Fe.ZodLazy,...Ke(n)});class ph extends it{_parse(n){if(n.data!==this._def.value){const r=this._getOrReturnCtx(n);return Ee(r,{received:r.data,code:xe.invalid_literal,expected:this._def.value}),Ie}return{status:"valid",value:n.data}}get value(){return this._def.value}}ph.create=(t,n)=>new ph({value:t,typeName:Fe.ZodLiteral,...Ke(n)});function eE(t,n){return new Po({values:t,typeName:Fe.ZodEnum,...Ke(n)})}class Po extends it{_parse(n){if(typeof n.data!="string"){const r=this._getOrReturnCtx(n),s=this._def.values;return Ee(r,{expected:dt.joinValues(s),received:r.parsedType,code:xe.invalid_type}),Ie}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(n.data)){const r=this._getOrReturnCtx(n),s=this._def.values;return Ee(r,{received:r.data,code:xe.invalid_enum_value,options:s}),Ie}return la(n.data)}get options(){return this._def.values}get enum(){const n={};for(const r of this._def.values)n[r]=r;return n}get Values(){const n={};for(const r of this._def.values)n[r]=r;return n}get Enum(){const n={};for(const r of this._def.values)n[r]=r;return n}extract(n,r=this._def){return Po.create(n,{...this._def,...r})}exclude(n,r=this._def){return Po.create(this.options.filter(s=>!n.includes(s)),{...this._def,...r})}}Po.create=eE;class u0 extends it{_parse(n){const r=dt.getValidEnumValues(this._def.values),s=this._getOrReturnCtx(n);if(s.parsedType!==Te.string&&s.parsedType!==Te.number){const i=dt.objectValues(r);return Ee(s,{expected:dt.joinValues(i),received:s.parsedType,code:xe.invalid_type}),Ie}if(this._cache||(this._cache=new Set(dt.getValidEnumValues(this._def.values))),!this._cache.has(n.data)){const i=dt.objectValues(r);return Ee(s,{received:s.data,code:xe.invalid_enum_value,options:i}),Ie}return la(n.data)}get enum(){return this._def.values}}u0.create=(t,n)=>new u0({values:t,typeName:Fe.ZodNativeEnum,...Ke(n)});class Cu extends it{unwrap(){return this._def.type}_parse(n){const{ctx:r}=this._processInputParams(n);if(r.parsedType!==Te.promise&&r.common.async===!1)return Ee(r,{code:xe.invalid_type,expected:Te.promise,received:r.parsedType}),Ie;const s=r.parsedType===Te.promise?r.data:Promise.resolve(r.data);return la(s.then(i=>this._def.type.parseAsync(i,{path:r.path,errorMap:r.common.contextualErrorMap})))}}Cu.create=(t,n)=>new Cu({type:t,typeName:Fe.ZodPromise,...Ke(n)});class Ho extends it{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===Fe.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(n){const{status:r,ctx:s}=this._processInputParams(n),i=this._def.effect||null,c={addIssue:u=>{Ee(s,u),u.fatal?r.abort():r.dirty()},get path(){return s.path}};if(c.addIssue=c.addIssue.bind(c),i.type==="preprocess"){const u=i.transform(s.data,c);if(s.common.async)return Promise.resolve(u).then(async f=>{if(r.value==="aborted")return Ie;const g=await this._def.schema._parseAsync({data:f,path:s.path,parent:s});return g.status==="aborted"?Ie:g.status==="dirty"||r.value==="dirty"?Ki(g.value):g});{if(r.value==="aborted")return Ie;const f=this._def.schema._parseSync({data:u,path:s.path,parent:s});return f.status==="aborted"?Ie:f.status==="dirty"||r.value==="dirty"?Ki(f.value):f}}if(i.type==="refinement"){const u=f=>{const g=i.refinement(f,c);if(s.common.async)return Promise.resolve(g);if(g instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return f};if(s.common.async===!1){const f=this._def.schema._parseSync({data:s.data,path:s.path,parent:s});return f.status==="aborted"?Ie:(f.status==="dirty"&&r.dirty(),u(f.value),{status:r.value,value:f.value})}else return this._def.schema._parseAsync({data:s.data,path:s.path,parent:s}).then(f=>f.status==="aborted"?Ie:(f.status==="dirty"&&r.dirty(),u(f.value).then(()=>({status:r.value,value:f.value}))))}if(i.type==="transform")if(s.common.async===!1){const u=this._def.schema._parseSync({data:s.data,path:s.path,parent:s});if(!Bo(u))return Ie;const f=i.transform(u.value,c);if(f instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:r.value,value:f}}else return this._def.schema._parseAsync({data:s.data,path:s.path,parent:s}).then(u=>Bo(u)?Promise.resolve(i.transform(u.value,c)).then(f=>({status:r.value,value:f})):Ie);dt.assertNever(i)}}Ho.create=(t,n,r)=>new Ho({schema:t,typeName:Fe.ZodEffects,effect:n,...Ke(r)});Ho.createWithPreprocess=(t,n,r)=>new Ho({schema:n,effect:{type:"preprocess",transform:t},typeName:Fe.ZodEffects,...Ke(r)});class qr extends it{_parse(n){return this._getType(n)===Te.undefined?la(void 0):this._def.innerType._parse(n)}unwrap(){return this._def.innerType}}qr.create=(t,n)=>new qr({innerType:t,typeName:Fe.ZodOptional,...Ke(n)});class Vo extends it{_parse(n){return this._getType(n)===Te.null?la(null):this._def.innerType._parse(n)}unwrap(){return this._def.innerType}}Vo.create=(t,n)=>new Vo({innerType:t,typeName:Fe.ZodNullable,...Ke(n)});class gh extends it{_parse(n){const{ctx:r}=this._processInputParams(n);let s=r.data;return r.parsedType===Te.undefined&&(s=this._def.defaultValue()),this._def.innerType._parse({data:s,path:r.path,parent:r})}removeDefault(){return this._def.innerType}}gh.create=(t,n)=>new gh({innerType:t,typeName:Fe.ZodDefault,defaultValue:typeof n.default=="function"?n.default:()=>n.default,...Ke(n)});class vh extends it{_parse(n){const{ctx:r}=this._processInputParams(n),s={...r,common:{...r.common,issues:[]}},i=this._def.innerType._parse({data:s.data,path:s.path,parent:{...s}});return wu(i)?i.then(c=>({status:"valid",value:c.status==="valid"?c.value:this._def.catchValue({get error(){return new lr(s.common.issues)},input:s.data})})):{status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new lr(s.common.issues)},input:s.data})}}removeCatch(){return this._def.innerType}}vh.create=(t,n)=>new vh({innerType:t,typeName:Fe.ZodCatch,catchValue:typeof n.catch=="function"?n.catch:()=>n.catch,...Ke(n)});class d0 extends it{_parse(n){if(this._getType(n)!==Te.nan){const s=this._getOrReturnCtx(n);return Ee(s,{code:xe.invalid_type,expected:Te.nan,received:s.parsedType}),Ie}return{status:"valid",value:n.data}}}d0.create=t=>new d0({typeName:Fe.ZodNaN,...Ke(t)});class Y3 extends it{_parse(n){const{ctx:r}=this._processInputParams(n),s=r.data;return this._def.type._parse({data:s,path:r.path,parent:r})}unwrap(){return this._def.type}}class vp extends it{_parse(n){const{status:r,ctx:s}=this._processInputParams(n);if(s.common.async)return(async()=>{const c=await this._def.in._parseAsync({data:s.data,path:s.path,parent:s});return c.status==="aborted"?Ie:c.status==="dirty"?(r.dirty(),Ki(c.value)):this._def.out._parseAsync({data:c.value,path:s.path,parent:s})})();{const i=this._def.in._parseSync({data:s.data,path:s.path,parent:s});return i.status==="aborted"?Ie:i.status==="dirty"?(r.dirty(),{status:"dirty",value:i.value}):this._def.out._parseSync({data:i.value,path:s.path,parent:s})}}static create(n,r){return new vp({in:n,out:r,typeName:Fe.ZodPipeline})}}class yh extends it{_parse(n){const r=this._def.innerType._parse(n),s=i=>(Bo(i)&&(i.value=Object.freeze(i.value)),i);return wu(r)?r.then(i=>s(i)):s(r)}unwrap(){return this._def.innerType}}yh.create=(t,n)=>new yh({innerType:t,typeName:Fe.ZodReadonly,...Ke(n)});var Fe;(function(t){t.ZodString="ZodString",t.ZodNumber="ZodNumber",t.ZodNaN="ZodNaN",t.ZodBigInt="ZodBigInt",t.ZodBoolean="ZodBoolean",t.ZodDate="ZodDate",t.ZodSymbol="ZodSymbol",t.ZodUndefined="ZodUndefined",t.ZodNull="ZodNull",t.ZodAny="ZodAny",t.ZodUnknown="ZodUnknown",t.ZodNever="ZodNever",t.ZodVoid="ZodVoid",t.ZodArray="ZodArray",t.ZodObject="ZodObject",t.ZodUnion="ZodUnion",t.ZodDiscriminatedUnion="ZodDiscriminatedUnion",t.ZodIntersection="ZodIntersection",t.ZodTuple="ZodTuple",t.ZodRecord="ZodRecord",t.ZodMap="ZodMap",t.ZodSet="ZodSet",t.ZodFunction="ZodFunction",t.ZodLazy="ZodLazy",t.ZodLiteral="ZodLiteral",t.ZodEnum="ZodEnum",t.ZodEffects="ZodEffects",t.ZodNativeEnum="ZodNativeEnum",t.ZodOptional="ZodOptional",t.ZodNullable="ZodNullable",t.ZodDefault="ZodDefault",t.ZodCatch="ZodCatch",t.ZodPromise="ZodPromise",t.ZodBranded="ZodBranded",t.ZodPipeline="ZodPipeline",t.ZodReadonly="ZodReadonly"})(Fe||(Fe={}));const Yt=Ir.create,Ta=mh.create;Zr.create;const Z3=Ma.create,Xo=Gt.create;Eu.create;_u.create;Rs.create;const X3=ph.create;Po.create;Cu.create;qr.create;Vo.create;const f0=(t,n,r)=>{if(t&&"reportValidity"in t){const s=Ce(r,n);t.setCustomValidity(s&&s.message||""),t.reportValidity()}},bh=(t,n)=>{for(const r in n.fields){const s=n.fields[r];s&&s.ref&&"reportValidity"in s.ref?f0(s.ref,r,t):s&&s.refs&&s.refs.forEach(i=>f0(i,r,t))}},m0=(t,n)=>{n.shouldUseNativeValidation&&bh(t,n);const r={};for(const s in t){const i=Ce(n.fields,s),c=Object.assign(t[s]||{},{ref:i&&i.ref});if(K3(n.names||Object.keys(t),s)){const u=Object.assign({},Ce(r,s));xt(u,"root",c),xt(r,s,u)}else xt(r,s,c)}return r},K3=(t,n)=>{const r=h0(n);return t.some(s=>h0(s).match(`^${r}\\.\\d+`))};function h0(t){return t.replace(/\]|\[/g,"")}function tE(t,n,r){function s(f,g){var p;Object.defineProperty(f,"_zod",{value:f._zod??{},enumerable:!1}),(p=f._zod).traits??(p.traits=new Set),f._zod.traits.add(t),n(f,g);for(const y in u.prototype)y in f||Object.defineProperty(f,y,{value:u.prototype[y].bind(f)});f._zod.constr=u,f._zod.def=g}const i=(r==null?void 0:r.Parent)??Object;class c extends i{}Object.defineProperty(c,"name",{value:t});function u(f){var g;const p=r!=null&&r.Parent?new c:this;s(p,f),(g=p._zod).deferred??(g.deferred=[]);for(const y of p._zod.deferred)y();return p}return Object.defineProperty(u,"init",{value:s}),Object.defineProperty(u,Symbol.hasInstance,{value:f=>{var g,p;return r!=null&&r.Parent&&f instanceof r.Parent?!0:(p=(g=f==null?void 0:f._zod)==null?void 0:g.traits)==null?void 0:p.has(t)}}),Object.defineProperty(u,"name",{value:t}),u}class Q3 extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}const W3={};function nE(t){return W3}function J3(t,n){return typeof n=="bigint"?n.toString():n}const aE=Error.captureStackTrace?Error.captureStackTrace:(...t)=>{};function Fc(t){return typeof t=="string"?t:t==null?void 0:t.message}function rE(t,n,r){var i,c,u,f,g,p;const s={...t,path:t.path??[]};if(!t.message){const y=Fc((u=(c=(i=t.inst)==null?void 0:i._zod.def)==null?void 0:c.error)==null?void 0:u.call(c,t))??Fc((f=n==null?void 0:n.error)==null?void 0:f.call(n,t))??Fc((g=r.customError)==null?void 0:g.call(r,t))??Fc((p=r.localeError)==null?void 0:p.call(r,t))??"Invalid input";s.message=y}return delete s.inst,delete s.continue,n!=null&&n.reportInput||delete s.input,s}const sE=(t,n)=>{t.name="$ZodError",Object.defineProperty(t,"_zod",{value:t._zod,enumerable:!1}),Object.defineProperty(t,"issues",{value:n,enumerable:!1}),Object.defineProperty(t,"message",{get(){return JSON.stringify(n,J3,2)},enumerable:!0}),Object.defineProperty(t,"toString",{value:()=>t.message,enumerable:!1})},e5=tE("$ZodError",sE),oE=tE("$ZodError",sE,{Parent:Error}),t5=t=>(n,r,s,i)=>{const c=s?Object.assign(s,{async:!1}):{async:!1},u=n._zod.run({value:r,issues:[]},c);if(u instanceof Promise)throw new Q3;if(u.issues.length){const f=new((i==null?void 0:i.Err)??t)(u.issues.map(g=>rE(g,c,nE())));throw aE(f,i==null?void 0:i.callee),f}return u.value},n5=t5(oE),a5=t=>async(n,r,s,i)=>{const c=s?Object.assign(s,{async:!0}):{async:!0};let u=n._zod.run({value:r,issues:[]},c);if(u instanceof Promise&&(u=await u),u.issues.length){const f=new((i==null?void 0:i.Err)??t)(u.issues.map(g=>rE(g,c,nE())));throw aE(f,i==null?void 0:i.callee),f}return u.value},r5=a5(oE);function p0(t,n){try{var r=t()}catch(s){return n(s)}return r&&r.then?r.then(void 0,n):r}function s5(t,n){for(var r={};t.length;){var s=t[0],i=s.code,c=s.message,u=s.path.join(".");if(!r[u])if("unionErrors"in s){var f=s.unionErrors[0].errors[0];r[u]={message:f.message,type:f.code}}else r[u]={message:c,type:i};if("unionErrors"in s&&s.unionErrors.forEach(function(y){return y.errors.forEach(function(v){return t.push(v)})}),n){var g=r[u].types,p=g&&g[s.code];r[u]=up(u,n,r,i,p?[].concat(p,s.message):s.message)}t.shift()}return r}function o5(t,n){for(var r={};t.length;){var s=t[0],i=s.code,c=s.message,u=s.path.join(".");if(!r[u])if(s.code==="invalid_union"&&s.errors.length>0){var f=s.errors[0][0];r[u]={message:f.message,type:f.code}}else r[u]={message:c,type:i};if(s.code==="invalid_union"&&s.errors.forEach(function(y){return y.forEach(function(v){return t.push(v)})}),n){var g=r[u].types,p=g&&g[s.code];r[u]=up(u,n,r,i,p?[].concat(p,s.message):s.message)}t.shift()}return r}function Io(t,n,r){if(r===void 0&&(r={}),(function(s){return"_def"in s&&typeof s._def=="object"&&"typeName"in s._def})(t))return function(s,i,c){try{return Promise.resolve(p0(function(){return Promise.resolve(t[r.mode==="sync"?"parse":"parseAsync"](s,n)).then(function(u){return c.shouldUseNativeValidation&&bh({},c),{errors:{},values:r.raw?Object.assign({},s):u}})},function(u){if((function(f){return Array.isArray(f==null?void 0:f.issues)})(u))return{values:{},errors:m0(s5(u.errors,!c.shouldUseNativeValidation&&c.criteriaMode==="all"),c)};throw u}))}catch(u){return Promise.reject(u)}};if((function(s){return"_zod"in s&&typeof s._zod=="object"})(t))return function(s,i,c){try{return Promise.resolve(p0(function(){return Promise.resolve((r.mode==="sync"?n5:r5)(t,s,n)).then(function(u){return c.shouldUseNativeValidation&&bh({},c),{errors:{},values:r.raw?Object.assign({},s):u}})},function(u){if((function(f){return f instanceof e5})(u))return{values:{},errors:m0(o5(u.issues,!c.shouldUseNativeValidation&&c.criteriaMode==="all"),c)};throw u}))}catch(u){return Promise.reject(u)}};throw new Error("Invalid input: not a Zod schema")}const i5=()=>{const{login:t,checkLicense:n,setApiUrl:r,setApiKey:s,isAuthenticated:i,licenseState:c,apiUrl:u}=zu(),f=Xr(),[g,p]=b.useState(!1),[y,v]=b.useState("");b.useEffect(()=>{i&&c==="licensed"&&f("/manager",{replace:!0})},[i,c,f]);const w=window.location.origin,C=Xo({apiUrl:Yt().min(1,{message:"URL da API é obrigatória"}).url({message:`URL inválida. Use o formato: ${w}`}).refine(E=>E.startsWith("http://")||E.startsWith("https://"),{message:"URL deve começar com http:// ou https://"}),apiKey:Yt().min(1,{message:"API Key é obrigatória"}).min(10,{message:"API Key deve ter pelo menos 10 caracteres"})}),S=Lo({resolver:Io(C),defaultValues:{apiUrl:u,apiKey:""}}),_=async E=>{p(!0),v("");try{const R=E.apiUrl.replace(/\/$/,"");if(Ze.info("Verificando licenca..."),await n(R,E.apiKey)!=="licensed"){Ze.info("Licenca necessaria",{description:"Redirecionando para registro de licenca..."});const A=`${window.location.origin}/manager/license/callback`,D=await TO(A,R,E.apiKey);if(!D.register_url){Ze.error("Erro",{description:D.message||"Falha ao iniciar registro de licenca."}),v(D.message||"Falha ao iniciar registro.");return}r(R),s(E.apiKey),window.location.href=D.register_url;return}await t(E.apiUrl,E.apiKey),Ze.success("Conectado com sucesso!",{description:"Licenca valida. Bem-vindo!"}),f("/manager",{replace:!0})}catch(R){console.error("Erro ao fazer login:",R);const k=R instanceof Error?R.message:"Erro ao conectar. Verifique a URL e API Key.";Ze.error("Erro",{description:k}),v(k)}finally{p(!1)}};return h.jsx("div",{className:"min-h-screen flex items-center justify-center p-4 bg-gradient-to-t from-primary/20 via-background/95 to-background relative",children:h.jsxs("div",{className:"w-full max-w-md space-y-6",children:[h.jsx("div",{className:"text-center",children:h.jsx("h1",{className:"text-3xl font-bold text-primary",children:"Evolution GO"})}),h.jsxs("div",{className:"bg-background/80 backdrop-blur-sm border rounded-lg p-6 shadow-lg",children:[h.jsxs("div",{className:"space-y-2 mb-6",children:[h.jsx("h2",{className:"text-2xl font-bold",children:"Entrar na sua conta"}),h.jsx("p",{className:"text-muted-foreground",children:"Digite suas credenciais para acessar o sistema"})]}),y&&h.jsxs(o3,{variant:"destructive",className:"mb-4",children:[h.jsx(nR,{className:"h-4 w-4"}),h.jsx(i3,{children:"Erro"}),h.jsx(l3,{children:y})]}),h.jsxs("form",{onSubmit:S.handleSubmit(_),className:"space-y-4",children:[h.jsxs("div",{className:"space-y-2",children:[h.jsx(Pr,{htmlFor:"login-apiUrl",children:"URL da API Evolution GO"}),h.jsx(Ra,{id:"login-apiUrl",type:"text",placeholder:w,disabled:g,...S.register("apiUrl")}),S.formState.errors.apiUrl&&h.jsx("p",{className:"text-destructive text-sm",children:S.formState.errors.apiUrl.message})]}),h.jsxs("div",{className:"space-y-2",children:[h.jsx(Pr,{htmlFor:"login-apiKey",children:"API Key (GLOBAL_API_KEY)"}),h.jsx(Ra,{id:"login-apiKey",type:"password",placeholder:"Sua chave de API",disabled:g,...S.register("apiKey")}),S.formState.errors.apiKey&&h.jsx("p",{className:"text-destructive text-sm",children:S.formState.errors.apiKey.message})]}),h.jsx("div",{className:"text-xs text-muted-foreground",children:h.jsxs("p",{children:[h.jsx("strong",{children:"Dica:"})," A API Key é o valor da variável"," ",h.jsx("code",{className:"relative rounded bg-muted px-[0.3rem] py-[0.2rem] font-mono text-xs",children:"GLOBAL_API_KEY"})," ","configurada no arquivo .env do Evolution GO."]})}),h.jsx(ut,{type:"submit",disabled:g,className:"w-full",children:g?"Conectando...":"Entrar"})]})]}),h.jsx("div",{className:"text-center text-xs text-muted-foreground",children:h.jsxs("p",{children:["Ao continuar, você concorda com nossos"," ",h.jsx("a",{href:"#",className:"underline hover:text-primary",children:"Termos de Serviço"})," ","e"," ",h.jsx("a",{href:"#",className:"underline hover:text-primary",children:"Política de Privacidade"}),"."]})})]})})};function l5(){return h.jsxs("div",{className:"p-6",children:[h.jsx("h1",{className:"mb-4 text-2xl font-bold text-foreground",children:"Dashboard"}),h.jsx("p",{className:"text-muted-foreground",children:"Dashboard content will be implemented here..."})]})}const iE=t=>{const n=t.connected?"open":"close";let r;if(t.qrcode){const s=t.qrcode.split("|");r={base64:s[0]||void 0,code:s[1]||void 0}}return{id:t.id,instanceName:t.name,status:n,apikey:t.token,owner:t.jid?t.jid.split("@")[0]:"",profileName:t.name,connected:t.connected,qrcode:r,webhook:t.webhook||void 0,rabbitmqEnable:t.rabbitmqEnable||void 0,websocketEnable:t.websocketEnable||void 0,natsEnable:t.natsEnable||void 0,events:t.events||void 0,disconnectReason:t.disconnect_reason||void 0,createdAt:t.createdAt,alwaysOnline:t.alwaysOnline,rejectCall:t.rejectCall,readMessages:t.readMessages,ignoreGroups:t.ignoreGroups,ignoreStatus:t.ignoreStatus}},c5=async()=>(await hn.get("/instance/all")).data.data.map(iE),$c=async t=>{const n=await hn.get(`/instance/info/${t}`);return iE(n.data.data)},u5=async t=>(await hn.post("/instance/create",t)).data,xh=async(t,n)=>{const r={webhookUrl:(n==null?void 0:n.webhookUrl)||"",subscribe:(n==null?void 0:n.subscribe)||[],rabbitmqEnable:(n==null?void 0:n.rabbitmqEnable)||"",websocketEnable:(n==null?void 0:n.websocketEnable)||"",natsEnable:(n==null?void 0:n.natsEnable)||""};return(await hn.post("/instance/connect",r,{headers:{apikey:t}})).data.data},d5=async(t,n)=>({pairingCode:(await hn.post("/instance/pair",{subscribe:n.subscribe,phone:n.phone},{headers:{apikey:t}})).data.data.PairingCode}),lE=async(t,n,r)=>{await hn.put(`/instance/${t}/advanced-settings`,r,{headers:{apikey:n}})},Im=async t=>{const n=await hn.get("/instance/qr",{headers:{apikey:t}});return{qrcode:n.data.data.Qrcode,code:n.data.data.Code}},cE=async t=>{await hn.delete("/instance/logout",{headers:{apikey:t}})},uE=async t=>{await hn.delete(`/instance/delete/${t}`)},f5=async(t,n)=>(await hn.post("/send/text",n,{headers:{apikey:t}})).data,dE=r1()(t=>({instances:[],isLoading:!1,error:null,hasLoaded:!1,fetchInstances:async()=>{t(n=>({isLoading:!n.hasLoaded,error:null}));try{const n=await c5();t({instances:n,isLoading:!1,hasLoaded:!0})}catch(n){console.error("Failed to fetch instances:",n),t({error:n instanceof Error?n.message:"Erro ao buscar instâncias",isLoading:!1,hasLoaded:!0})}},addInstance:n=>{t(r=>({instances:[...r.instances,n]}))},updateInstance:(n,r)=>{t(s=>({instances:s.instances.map(i=>i.instanceName===n?{...i,...r}:i)}))},removeInstance:n=>{t(r=>({instances:r.instances.filter(s=>s.instanceName!==n)}))},setLoading:n=>{t({isLoading:n})},setError:n=>{t({error:n})},clearError:()=>{t({error:null})}})),m5=t=>t==="open"?h.jsx(pu,{className:"bg-green-500/10 text-green-500 hover:bg-green-500/20",children:"Conectado"}):h.jsx(pu,{className:"bg-red-500/10 text-red-500 hover:bg-red-500/20",children:"Desconectado"});function h5({instance:t,isDeleting:n,onSettings:r,onDelete:s,onConnect:i,onDisconnect:c,onSendMessage:u}){const f=t.status==="open";return h.jsx(d3,{className:"group relative bg-sidebar border-sidebar-border hover:bg-sidebar-accent/30 transition-all duration-300 hover:shadow-lg hover:shadow-black/10 overflow-hidden",children:h.jsxs(f3,{className:"p-0",children:[h.jsxs("div",{className:"flex items-center gap-3 p-4 border-b border-sidebar-border",children:[t.profilePicUrl&&h.jsx("div",{className:"flex-shrink-0 dark",children:h.jsx("div",{className:"rounded-lg bg-gray-900 flex items-center justify-center w-14 h-14 overflow-hidden",children:h.jsx("img",{src:t.profilePicUrl,alt:t.profileName||t.instanceName,className:"w-12 h-12 object-cover rounded-lg",onError:g=>{const p=g.target;p.style.display="none"}})})}),h.jsxs("div",{className:"flex-1 min-w-0",children:[h.jsx("h3",{className:"font-semibold text-base truncate text-sidebar-foreground",children:t.profileName||t.instanceName}),h.jsx("p",{className:"text-xs text-sidebar-foreground/60 truncate",children:t.instanceName})]}),h.jsx("div",{className:"flex-shrink-0",children:m5(t.status)})]}),h.jsxs("div",{className:"px-4 py-3 text-xs text-sidebar-foreground/70 space-y-1",children:[h.jsxs("div",{className:"flex items-center justify-between",children:[h.jsx("span",{children:"Status"}),h.jsx("span",{className:"font-mono",children:t.status})]}),t.profileStatus&&h.jsxs("div",{className:"flex items-center justify-between",children:[h.jsx("span",{children:"Recado"}),h.jsx("span",{className:"font-mono truncate ml-2 max-w-[150px]",children:t.profileStatus})]}),t.owner&&h.jsxs("div",{className:"flex items-center justify-between",children:[h.jsx("span",{children:"Proprietário"}),h.jsx("span",{className:"font-mono truncate ml-2 max-w-[150px]",children:t.owner})]})]}),h.jsxs("div",{className:"flex border-t border-sidebar-border opacity-0 group-hover:opacity-100 transition-opacity duration-200",children:[!f&&h.jsxs(ut,{variant:"ghost",className:"flex-1 rounded-none h-12 text-green-500 hover:text-green-400 hover:bg-green-500/10",onClick:()=>i(t),children:[h.jsx(V0,{className:"h-4 w-4 mr-2"}),"Conectar"]}),f&&h.jsxs(ut,{variant:"ghost",className:"flex-1 rounded-none h-12 text-yellow-500 hover:text-yellow-400 hover:bg-yellow-500/10",onClick:()=>c(t),children:[h.jsx(jR,{className:"h-4 w-4 mr-2"}),"Desconectar"]}),h.jsx("div",{className:"w-px bg-sidebar-border"}),f&&u&&h.jsxs(h.Fragment,{children:[h.jsx(ut,{variant:"ghost",className:"rounded-none h-12 px-4 text-blue-500 hover:text-blue-400 hover:bg-blue-500/10",onClick:()=>u(t),children:h.jsx(NR,{className:"h-4 w-4"})}),h.jsx("div",{className:"w-px bg-sidebar-border"})]}),h.jsx(ut,{variant:"ghost",className:"rounded-none h-12 px-4 text-gray-500 hover:text-gray-300 hover:bg-gray-500/10",onClick:()=>r(t),children:h.jsx(PR,{className:"h-4 w-4"})}),h.jsx("div",{className:"w-px bg-sidebar-border"}),h.jsx(ut,{variant:"ghost",className:"rounded-none h-12 px-4 text-red-500 hover:text-red-400 hover:bg-red-500/10",disabled:n===t.instanceName,onClick:()=>s(t),children:h.jsx(Th,{className:"h-4 w-4"})})]})]})})}function p5({title:t,subtitle:n,searchValue:r,onSearchChange:s,searchPlaceholder:i="Buscar...",primaryAction:c,secondaryActions:u=[],moreActions:f=[],filters:g=[],onFilterClick:p,showFilters:y=!1,selectedCount:v=0,onClearSelection:w,bulkActions:C=[],className:S="",children:_}){const E=v>0,R=u.filter(A=>A.show!==!1),k=f.filter(A=>A.show!==!1);return h.jsxs("div",{className:`space-y-6 ${S} mb-4`,children:[h.jsxs("div",{className:"flex flex-col gap-4 md:flex-row md:items-start md:justify-between",children:[h.jsxs("div",{className:"flex-1",children:[h.jsx("h1",{className:"text-2xl font-bold tracking-tight text-sidebar-foreground mb-2 dark:text-gray-200",children:t}),n&&h.jsx("p",{className:"text-sm text-sidebar-foreground/70 dark:text-gray-400",children:n})]}),c&&c.show!==!1&&h.jsx("div",{className:"flex-shrink-0",children:h.jsxs(ut,{onClick:c.onClick,variant:c.variant||"default",className:c.className,children:[c.icon&&h.jsx("span",{className:"mr-2",children:c.icon}),c.label]})})]}),h.jsxs("div",{className:"flex flex-col gap-3 md:flex-row md:items-center md:justify-between",children:[h.jsxs("div",{className:"flex items-center gap-3 flex-1",children:[s&&h.jsxs("div",{className:"relative flex-1 max-w-md",children:[h.jsx(UR,{className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-sidebar-foreground/60 dark:text-gray-200"}),h.jsx(Ra,{type:"search",placeholder:i,value:r,onChange:A=>s(A.target.value),className:"pl-9 bg-sidebar border-sidebar-border text-sidebar-foreground placeholder:text-sidebar-foreground/50 focus:border-sidebar-border dark:text-gray-400 dark:placeholder:text-gray-400"})]}),y&&p&&h.jsxs(ut,{variant:"outline",size:"sm",onClick:p,className:"bg-sidebar border-sidebar-border text-sidebar-foreground hover:bg-sidebar-accent whitespace-nowrap dark:text-gray-400 dark:hover:bg-sidebar-accent",children:[h.jsx(pR,{className:"h-4 w-4 mr-2"}),"Filtros",g.length>0&&h.jsx(pu,{variant:"secondary",className:"ml-2 h-5 px-1.5 text-xs bg-sidebar-accent",children:g.length})]})]}),h.jsxs("div",{className:"flex items-center gap-2",children:[R.map((A,D)=>h.jsxs(ut,{variant:A.variant||"outline",size:"sm",onClick:A.onClick,className:"bg-sidebar border-sidebar-border text-sidebar-foreground hover:bg-sidebar-accent dark:text-gray-400 dark:hover:bg-sidebar-accent",children:[A.icon&&h.jsx("span",{className:"mr-2",children:A.icon}),A.label]},D)),k.length>0&&h.jsxs(p3,{children:[h.jsx(g3,{asChild:!0,children:h.jsx(ut,{variant:"outline",size:"sm",className:"bg-sidebar border-sidebar-border text-sidebar-foreground hover:bg-sidebar-accent dark:text-gray-400 dark:hover:bg-sidebar-accent",children:h.jsx(cR,{className:"h-4 w-4"})})}),h.jsx(v3,{align:"end",className:"bg-sidebar border-sidebar-border text-sidebar-foreground dark:text-gray-400",children:k.map((A,D)=>h.jsxs(y3,{onClick:A.onClick,className:`hover:bg-sidebar-accent ${A.variant==="destructive"?"text-red-400":""} dark:text-gray-400`,children:[A.icon&&h.jsx("span",{className:"mr-2",children:A.icon}),A.label]},D))})]})]})]}),E&&h.jsxs("div",{className:"flex items-center justify-between rounded-lg bg-sidebar-accent/50 border border-sidebar-border px-4 py-2",children:[h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsxs("span",{className:"text-sm font-medium text-sidebar-foreground dark:text-gray-400",children:[v," selecionado",v>1?"s":""]}),w&&h.jsxs(ut,{variant:"ghost",size:"sm",onClick:w,className:"h-7 px-2 text-sidebar-foreground/70 hover:text-sidebar-foreground hover:bg-sidebar-accent dark:text-gray-400 dark:hover:text-gray-400 dark:hover:bg-sidebar-accent",children:[h.jsx(el,{className:"h-3 w-3 mr-1"}),"Limpar"]})]}),C.length>0&&h.jsx("div",{className:"flex items-center gap-2",children:C.map((A,D)=>h.jsxs(ut,{variant:A.variant||"outline",size:"sm",onClick:A.onClick,className:"h-7 bg-sidebar-accent border-sidebar-border text-sidebar-foreground hover:bg-sidebar dark:text-gray-400 dark:hover:bg-sidebar",children:[A.icon&&h.jsx("span",{className:"mr-1.5",children:A.icon}),A.label]},D))})]}),g.length>0&&h.jsx("div",{className:"flex flex-wrap gap-2",children:g.map((A,D)=>h.jsxs(pu,{variant:"secondary",className:"pl-2 pr-1 py-1 bg-sidebar-accent text-sidebar-foreground hover:bg-sidebar dark:text-gray-400 dark:hover:bg-sidebar dark:bg-sidebar-accent/50",children:[A.label,": ",A.value,h.jsx(ut,{variant:"ghost",size:"sm",onClick:A.onRemove,className:"ml-1 h-4 w-4 p-0 hover:bg-transparent text-sidebar-foreground/60 hover:text-sidebar-foreground dark:text-gray-400 dark:hover:text-gray-400",children:h.jsx(el,{className:"h-3 w-3"})})]},D))}),_]})}function g5({totalCount:t,selectedCount:n,searchValue:r,onSearchChange:s,onNewInstance:i,onClearSelection:c}){const u={label:"Nova Instância",icon:h.jsx(Xm,{className:"h-4 w-4"}),onClick:i};return h.jsx(p5,{title:"Instâncias",subtitle:"Gerencie suas instâncias WhatsApp do Evolution GO",totalCount:t,selectedCount:n,searchValue:r,onSearchChange:s,searchPlaceholder:"Buscar instâncias...",primaryAction:u,onClearSelection:c,showFilters:!1,className:"mb-4"})}const un=[];for(let t=0;t<256;++t)un.push((t+256).toString(16).slice(1));function v5(t,n=0){return(un[t[n+0]]+un[t[n+1]]+un[t[n+2]]+un[t[n+3]]+"-"+un[t[n+4]]+un[t[n+5]]+"-"+un[t[n+6]]+un[t[n+7]]+"-"+un[t[n+8]]+un[t[n+9]]+"-"+un[t[n+10]]+un[t[n+11]]+un[t[n+12]]+un[t[n+13]]+un[t[n+14]]+un[t[n+15]]).toLowerCase()}let qm;const y5=new Uint8Array(16);function b5(){if(!qm){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");qm=crypto.getRandomValues.bind(crypto)}return qm(y5)}const x5=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),g0={randomUUID:x5};function w5(t,n,r){var i;if(g0.randomUUID&&!t)return g0.randomUUID();t=t||{};const s=t.random??((i=t.rng)==null?void 0:i.call(t))??b5();if(s.length<16)throw new Error("Random bytes length must be >= 16");return s[6]=s[6]&15|64,s[8]=s[8]&63|128,v5(s)}const S5=Xo({instanceName:Yt().min(1,"Nome da instância é obrigatório").min(3,"Nome deve ter pelo menos 3 caracteres").max(50,"Nome deve ter no máximo 50 caracteres").regex(/^[a-zA-Z0-9-_]+$/,"Nome deve conter apenas letras, números, hífen e underscore"),token:Yt().optional(),proxyHost:Yt().optional(),proxyPort:Yt().optional(),proxyUsername:Yt().optional(),proxyPassword:Yt().optional()});function E5({open:t,onOpenChange:n}){const[r,s]=b.useState(!1),[i,c]=b.useState(!1),{addInstance:u,fetchInstances:f}=dE(),{register:g,handleSubmit:p,reset:y,formState:{errors:v}}=Lo({resolver:Io(S5),defaultValues:{instanceName:"",token:"",proxyHost:"",proxyPort:"",proxyUsername:"",proxyPassword:""}}),w=async S=>{s(!0);try{const _={name:S.instanceName,token:S.token||w5()};S.proxyHost&&S.proxyPort&&(_.proxy={host:S.proxyHost,port:S.proxyPort,username:S.proxyUsername,password:S.proxyPassword});const E=await u5(_);u(E),Ze.success("Instância criada com sucesso!",{description:`A instância "${S.instanceName}" foi criada.`}),await f(),n(!1),y()}catch(_){console.error("Erro ao criar instância:",_),Ze.error(_ instanceof Error?_.message:"Erro ao criar instância. Tente novamente.")}finally{s(!1)}},C=()=>{r||(n(!1),y(),c(!1))};return h.jsx(gu,{open:t,onOpenChange:C,children:h.jsxs(vu,{className:"sm:max-w-md",children:[h.jsxs(yu,{children:[h.jsxs(bu,{className:"flex items-center gap-2",children:[h.jsx(Xm,{className:"h-5 w-5 text-primary"}),"Nova Instância"]}),h.jsx(xu,{className:"text-sidebar-foreground/70",children:"Crie uma nova instância WhatsApp para gerenciar suas conversas"})]}),h.jsxs("form",{onSubmit:p(w),className:"space-y-4",children:[h.jsxs("div",{className:"space-y-2",children:[h.jsxs(Pr,{htmlFor:"instanceName",children:["Nome da Instância ",h.jsx("span",{className:"text-red-500",children:"*"})]}),h.jsx(Ra,{id:"instanceName",type:"text",placeholder:"ex: minha-instancia",disabled:r,...g("instanceName"),className:"bg-sidebar border-sidebar-border text-sidebar-foreground placeholder:text-sidebar-foreground/50"}),v.instanceName&&h.jsx("p",{className:"text-destructive text-sm",children:v.instanceName.message}),h.jsx("p",{className:"text-xs text-sidebar-foreground/60",children:"Use apenas letras, números, hífen (-) e underscore (_)"})]}),h.jsxs("div",{className:"space-y-2",children:[h.jsx(Pr,{htmlFor:"token",children:"Token (Opcional)"}),h.jsx(Ra,{id:"token",type:"text",placeholder:"Token personalizado (UUID)",disabled:r,...g("token"),className:"bg-sidebar border-sidebar-border text-sidebar-foreground placeholder:text-sidebar-foreground/50"}),v.token&&h.jsx("p",{className:"text-destructive text-sm",children:v.token.message}),h.jsx("p",{className:"text-xs text-sidebar-foreground/60",children:"Se não informado, será gerado um UUID automaticamente"})]}),h.jsxs("div",{className:"space-y-2",children:[h.jsxs(ut,{type:"button",variant:"outline",onClick:()=>c(!i),disabled:r,className:"w-full justify-between bg-sidebar border-sidebar-border text-sidebar-foreground hover:bg-sidebar-accent",children:[h.jsx("span",{children:"Configuração de Proxy (Opcional)"}),i?h.jsx(eR,{className:"h-4 w-4"}):h.jsx(Zm,{className:"h-4 w-4"})]}),i&&h.jsxs("div",{className:"space-y-4 pt-2 border-t border-sidebar-border",children:[h.jsxs("div",{className:"space-y-2",children:[h.jsx(Pr,{htmlFor:"proxyHost",children:"Host do Proxy"}),h.jsx(Ra,{id:"proxyHost",type:"text",placeholder:"ex: proxy.example.com",disabled:r,...g("proxyHost"),className:"bg-sidebar border-sidebar-border text-sidebar-foreground placeholder:text-sidebar-foreground/50"}),v.proxyHost&&h.jsx("p",{className:"text-destructive text-sm",children:v.proxyHost.message})]}),h.jsxs("div",{className:"space-y-2",children:[h.jsx(Pr,{htmlFor:"proxyPort",children:"Porta do Proxy"}),h.jsx(Ra,{id:"proxyPort",type:"text",placeholder:"ex: 8080",disabled:r,...g("proxyPort"),className:"bg-sidebar border-sidebar-border text-sidebar-foreground placeholder:text-sidebar-foreground/50"}),v.proxyPort&&h.jsx("p",{className:"text-destructive text-sm",children:v.proxyPort.message})]}),h.jsxs("div",{className:"space-y-2",children:[h.jsx(Pr,{htmlFor:"proxyUsername",children:"Usuário (Opcional)"}),h.jsx(Ra,{id:"proxyUsername",type:"text",placeholder:"Usuário do proxy",disabled:r,...g("proxyUsername"),className:"bg-sidebar border-sidebar-border text-sidebar-foreground placeholder:text-sidebar-foreground/50"}),v.proxyUsername&&h.jsx("p",{className:"text-destructive text-sm",children:v.proxyUsername.message})]}),h.jsxs("div",{className:"space-y-2",children:[h.jsx(Pr,{htmlFor:"proxyPassword",children:"Senha (Opcional)"}),h.jsx(Ra,{id:"proxyPassword",type:"password",placeholder:"Senha do proxy",disabled:r,...g("proxyPassword"),className:"bg-sidebar border-sidebar-border text-sidebar-foreground placeholder:text-sidebar-foreground/50"}),v.proxyPassword&&h.jsx("p",{className:"text-destructive text-sm",children:v.proxyPassword.message})]})]})]}),h.jsxs(QS,{className:"flex gap-2 sm:gap-0",children:[h.jsx(ut,{type:"button",variant:"outline",onClick:C,disabled:r,className:"bg-sidebar border-sidebar-border text-sidebar-foreground hover:bg-sidebar-accent",children:"Cancelar"}),h.jsx(ut,{type:"submit",disabled:r,children:r?h.jsxs(h.Fragment,{children:[h.jsx(H0,{className:"mr-2 h-4 w-4 animate-spin"}),"Criando..."]}):h.jsxs(h.Fragment,{children:[h.jsx(Xm,{className:"mr-2 h-4 w-4"}),"Criar Instância"]})})]})]})]})})}function _5({instance:t,open:n,onOpenChange:r,onRefresh:s}){var f,g;const[i,c]=b.useState(!1);b.useEffect(()=>{if(!n||!t||t.connected)return;const p=setInterval(()=>{s&&(console.log("Auto-refreshing QR Code and checking connection..."),s().catch(y=>{console.error("Auto-refresh failed:",y)}))},1e4);return()=>clearInterval(p)},[n,t,s]);const u=async()=>{if(s){c(!0);try{await s(),Ze.success("QR Code atualizado!")}catch(p){console.error("Erro ao atualizar QR Code:",p),Ze.error("Erro ao atualizar QR Code")}finally{c(!1)}}};return t?t.connected?h.jsx(gu,{open:n,onOpenChange:r,children:h.jsxs(vu,{className:"sm:max-w-md",children:[h.jsxs(yu,{children:[h.jsxs(bu,{className:"flex items-center gap-2 text-green-500",children:[h.jsx(kb,{className:"h-5 w-5"}),"Conectado com Sucesso!"]}),h.jsxs(xu,{className:"text-sidebar-foreground/70",children:["A instância ",t.instanceName," foi conectada ao WhatsApp."]})]}),h.jsxs("div",{className:"flex flex-col items-center gap-4 py-6",children:[h.jsx("div",{className:"rounded-full bg-green-500/10 p-4",children:h.jsx(kb,{className:"h-12 w-12 text-green-500"})}),t.profileName&&h.jsxs("div",{className:"text-center",children:[h.jsx("p",{className:"text-sm text-sidebar-foreground/60",children:"Conectado como"}),h.jsx("p",{className:"text-lg font-semibold text-sidebar-foreground",children:t.profileName})]})]}),h.jsx("div",{className:"flex justify-end",children:h.jsx(ut,{onClick:()=>r(!1),className:"w-full sm:w-auto",children:"Fechar"})})]})}):h.jsx(gu,{open:n,onOpenChange:r,children:h.jsxs(vu,{className:"sm:max-w-md",children:[h.jsxs(yu,{children:[h.jsxs(bu,{className:"flex items-center gap-2",children:[h.jsx(Mb,{className:"h-5 w-5 text-primary"}),"Conectar WhatsApp"]}),h.jsxs(xu,{className:"text-sidebar-foreground/70",children:["Escaneie o QR Code abaixo com seu WhatsApp para conectar a instância"," ",h.jsx("strong",{children:t.instanceName})]})]}),h.jsxs("div",{className:"space-y-4",children:[h.jsxs("div",{className:"flex flex-col items-center gap-4",children:[(f=t.qrcode)!=null&&f.base64?h.jsx("div",{className:"rounded-lg border-2 border-sidebar-border bg-white p-4",children:h.jsx("img",{src:t.qrcode.base64,alt:"QR Code",className:"h-64 w-64"})}):h.jsx("div",{className:"flex h-64 w-64 items-center justify-center rounded-lg border-2 border-dashed border-sidebar-border bg-sidebar",children:h.jsxs("div",{className:"text-center",children:[h.jsx(Mb,{className:"mx-auto h-12 w-12 text-sidebar-foreground/40"}),h.jsx("p",{className:"mt-2 text-sm text-sidebar-foreground/60",children:"Aguardando QR Code..."})]})}),((g=t.qrcode)==null?void 0:g.pairingCode)&&h.jsxs("div",{className:"w-full rounded-lg bg-sidebar-accent p-3 text-center",children:[h.jsx("p",{className:"text-xs text-sidebar-foreground/60",children:"Código de Pareamento"}),h.jsx("p",{className:"mt-1 font-mono text-lg font-semibold text-sidebar-foreground",children:t.qrcode.pairingCode})]})]}),h.jsxs("div",{className:"rounded-lg bg-sidebar-accent p-4",children:[h.jsx("p",{className:"text-sm font-medium text-sidebar-foreground",children:"Como conectar:"}),h.jsxs("ol",{className:"mt-2 space-y-1 text-sm text-sidebar-foreground/70",children:[h.jsx("li",{children:"1. Abra o WhatsApp no seu celular"}),h.jsx("li",{children:"2. Toque em Menu ou Configurações"}),h.jsx("li",{children:"3. Toque em Dispositivos conectados"}),h.jsx("li",{children:"4. Toque em Conectar um dispositivo"}),h.jsx("li",{children:"5. Aponte seu celular para esta tela para capturar o código"})]})]}),h.jsxs("div",{className:"flex gap-2",children:[h.jsx(ut,{variant:"outline",onClick:u,disabled:i,className:"flex-1 bg-sidebar border-sidebar-border text-sidebar-foreground hover:bg-sidebar-accent",children:i?h.jsxs(h.Fragment,{children:[h.jsx(Db,{className:"mr-2 h-4 w-4 animate-spin"}),"Atualizando..."]}):h.jsxs(h.Fragment,{children:[h.jsx(Db,{className:"mr-2 h-4 w-4"}),"Atualizar QR Code"]})}),h.jsx(ut,{variant:"outline",onClick:()=>r(!1),className:"bg-sidebar border-sidebar-border text-sidebar-foreground hover:bg-sidebar-accent",children:h.jsx(el,{className:"h-4 w-4"})})]})]})]})}):null}const C5=Xo({webhookUrl:Yt().optional(),phone:Yt().optional(),rabbitmqEnable:Yt().optional(),websocketEnable:Yt().optional(),natsEnable:Yt().optional(),alwaysOnline:Ta().optional(),rejectCall:Ta().optional(),readMessages:Ta().optional(),ignoreGroups:Ta().optional(),ignoreStatus:Ta().optional()}),N5=["ALL","MESSAGE","READ_RECEIPT","PRESENCE","HISTORY_SYNC","CHAT_PRESENCE","CALL","CONNECTION","QRCODE","LABEL","CONTACT","GROUP","NEWSLETTER"];function R5({open:t,onClose:n,instance:r,onConfirm:s}){const[i,c]=b.useState([]),[u,f]=b.useState(!1),[g,p]=b.useState(!1),{register:y,handleSubmit:v,formState:{errors:w},reset:C}=Lo({resolver:Io(C5)}),S=async A=>{const D={webhookUrl:A.webhookUrl||"",subscribe:i,phone:A.phone||"",rabbitmqEnable:A.rabbitmqEnable||"",websocketEnable:A.websocketEnable||"",natsEnable:A.natsEnable||"",alwaysOnline:A.alwaysOnline,rejectCall:A.rejectCall,readMessages:A.readMessages,ignoreGroups:A.ignoreGroups,ignoreStatus:A.ignoreStatus};s(D),_()},_=()=>{C(),c([]),f(!1),p(!1),n()},E=A=>{c(D=>A==="ALL"?D.includes("ALL")?[]:["ALL"]:D.includes("ALL")?[A]:D.includes(A)?D.filter(H=>H!==A):[...D,A])},R=()=>{c(["ALL"])},k=()=>{c([])};return!t||!r?null:h.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50",children:h.jsxs("div",{className:"w-full max-w-2xl rounded-lg bg-card p-6 shadow-lg max-h-[90vh] overflow-y-auto",children:[h.jsxs("div",{className:"mb-4 flex items-center justify-between",children:[h.jsxs("h2",{className:"text-xl font-semibold text-foreground",children:["Configurar Conexão - ",r.instanceName]}),h.jsx("button",{onClick:_,className:"rounded-md p-1 hover:bg-accent",children:h.jsx(el,{className:"h-5 w-5"})})]}),h.jsxs("form",{onSubmit:v(S),className:"space-y-4",children:[h.jsxs("div",{children:[h.jsx("label",{htmlFor:"webhookUrl",className:"mb-1 block text-sm font-medium text-foreground",children:"Webhook URL (opcional)"}),h.jsx("input",{id:"webhookUrl",type:"url",placeholder:"https://seu-servidor.com/webhook",...y("webhookUrl"),className:"w-full rounded-md border border-input bg-background px-3 py-2 text-foreground placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring"}),w.webhookUrl&&h.jsx("p",{className:"mt-1 text-sm text-destructive",children:w.webhookUrl.message})]}),h.jsxs("div",{children:[h.jsxs("button",{type:"button",onClick:()=>p(!g),className:"flex items-center gap-2 text-sm font-medium text-foreground hover:text-primary",children:[g?h.jsx(Zm,{className:"h-4 w-4"}):h.jsx(jb,{className:"h-4 w-4"}),"Eventos para Webhook (",i.length," selecionados)"]}),g&&h.jsxs("div",{className:"mt-2 space-y-2 rounded-md border border-input p-3",children:[h.jsxs("div",{className:"flex gap-2 mb-2",children:[h.jsx("button",{type:"button",onClick:R,className:"text-xs px-2 py-1 rounded bg-primary text-primary-foreground hover:bg-primary/90",children:"Selecionar ALL"}),h.jsx("button",{type:"button",onClick:k,className:"text-xs px-2 py-1 rounded border border-input hover:bg-accent",children:"Limpar"})]}),h.jsx("div",{className:"mb-3 p-3 rounded-md bg-primary/10 border border-primary/20",children:h.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[h.jsx("input",{type:"checkbox",checked:i.includes("ALL"),onChange:()=>E("ALL"),className:"rounded border-input w-4 h-4"}),h.jsxs("div",{className:"flex-1",children:[h.jsx("span",{className:"text-sm font-semibold text-primary",children:"ALL"}),h.jsx("p",{className:"text-xs text-muted-foreground mt-0.5",children:"Seleciona todos os eventos (recomendado)"})]})]})}),h.jsxs("div",{className:"space-y-1",children:[h.jsx("p",{className:"text-xs font-medium text-muted-foreground mb-2",children:"Eventos Individuais:"}),h.jsx("div",{className:"grid grid-cols-2 gap-2 max-h-48 overflow-y-auto",children:N5.filter(A=>A!=="ALL").map(A=>h.jsxs("label",{className:"flex items-center gap-2 text-sm cursor-pointer hover:bg-accent p-2 rounded",children:[h.jsx("input",{type:"checkbox",checked:i.includes(A)||i.includes("ALL"),onChange:()=>E(A),disabled:i.includes("ALL"),className:"rounded border-input"}),h.jsx("span",{className:i.includes("ALL")?"text-muted-foreground":"text-foreground",children:A})]},A))})]})]})]}),h.jsxs("div",{children:[h.jsx("label",{htmlFor:"phone",className:"mb-1 block text-sm font-medium text-foreground",children:"Telefone para Pairing Code (opcional)"}),h.jsx("input",{id:"phone",type:"tel",placeholder:"5511999999999",...y("phone"),className:"w-full rounded-md border border-input bg-background px-3 py-2 text-foreground placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring"}),h.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:"Se fornecido, será gerado um código de pareamento (pairing code)"})]}),h.jsxs("div",{children:[h.jsxs("button",{type:"button",onClick:()=>f(!u),className:"flex items-center gap-2 text-sm font-medium text-foreground hover:text-primary",children:[u?h.jsx(Zm,{className:"h-4 w-4"}):h.jsx(jb,{className:"h-4 w-4"}),"Configurações Avançadas"]}),u&&h.jsxs("div",{className:"mt-2 space-y-4 rounded-md border border-input p-4",children:[h.jsxs("div",{className:"space-y-3",children:[h.jsx("h3",{className:"text-sm font-semibold text-foreground",children:"Comportamento"}),h.jsxs("div",{className:"flex items-center justify-between",children:[h.jsxs("div",{children:[h.jsx("label",{htmlFor:"alwaysOnline",className:"text-sm font-medium text-foreground cursor-pointer",children:"Always Online"}),h.jsx("p",{className:"text-xs text-muted-foreground",children:"Manter sempre online no WhatsApp"})]}),h.jsx("input",{id:"alwaysOnline",type:"checkbox",...y("alwaysOnline"),className:"rounded border-input w-4 h-4"})]}),h.jsxs("div",{className:"flex items-center justify-between",children:[h.jsxs("div",{children:[h.jsx("label",{htmlFor:"rejectCall",className:"text-sm font-medium text-foreground cursor-pointer",children:"Reject Call"}),h.jsx("p",{className:"text-xs text-muted-foreground",children:"Rejeitar chamadas automaticamente"})]}),h.jsx("input",{id:"rejectCall",type:"checkbox",...y("rejectCall"),className:"rounded border-input w-4 h-4"})]}),h.jsxs("div",{className:"flex items-center justify-between",children:[h.jsxs("div",{children:[h.jsx("label",{htmlFor:"readMessages",className:"text-sm font-medium text-foreground cursor-pointer",children:"Read Messages"}),h.jsx("p",{className:"text-xs text-muted-foreground",children:"Marcar mensagens como lidas"})]}),h.jsx("input",{id:"readMessages",type:"checkbox",...y("readMessages"),className:"rounded border-input w-4 h-4"})]}),h.jsxs("div",{className:"flex items-center justify-between",children:[h.jsxs("div",{children:[h.jsx("label",{htmlFor:"ignoreGroups",className:"text-sm font-medium text-foreground cursor-pointer",children:"Ignore Groups"}),h.jsx("p",{className:"text-xs text-muted-foreground",children:"Ignorar mensagens de grupos"})]}),h.jsx("input",{id:"ignoreGroups",type:"checkbox",...y("ignoreGroups"),className:"rounded border-input w-4 h-4"})]}),h.jsxs("div",{className:"flex items-center justify-between",children:[h.jsxs("div",{children:[h.jsx("label",{htmlFor:"ignoreStatus",className:"text-sm font-medium text-foreground cursor-pointer",children:"Ignore Status"}),h.jsx("p",{className:"text-xs text-muted-foreground",children:"Ignorar atualizações de status"})]}),h.jsx("input",{id:"ignoreStatus",type:"checkbox",...y("ignoreStatus"),className:"rounded border-input w-4 h-4"})]})]}),h.jsxs("div",{className:"space-y-3 pt-3 border-t border-input",children:[h.jsx("h3",{className:"text-sm font-semibold text-foreground",children:"Produtores de Eventos"}),h.jsxs("div",{children:[h.jsx("label",{htmlFor:"rabbitmqEnable",className:"mb-1 block text-sm font-medium text-foreground",children:"RabbitMQ"}),h.jsxs("select",{id:"rabbitmqEnable",...y("rabbitmqEnable"),className:"w-full rounded-md border border-input bg-background px-3 py-2 text-sm text-foreground focus:outline-none focus:ring-2 focus:ring-ring",children:[h.jsx("option",{value:"",children:"Padrão"}),h.jsx("option",{value:"enabled",children:"Habilitado"}),h.jsx("option",{value:"disabled",children:"Desabilitado"})]})]}),h.jsxs("div",{children:[h.jsx("label",{htmlFor:"websocketEnable",className:"mb-1 block text-sm font-medium text-foreground",children:"WebSocket"}),h.jsxs("select",{id:"websocketEnable",...y("websocketEnable"),className:"w-full rounded-md border border-input bg-background px-3 py-2 text-sm text-foreground focus:outline-none focus:ring-2 focus:ring-ring",children:[h.jsx("option",{value:"",children:"Padrão"}),h.jsx("option",{value:"enabled",children:"Habilitado"}),h.jsx("option",{value:"disabled",children:"Desabilitado"})]})]}),h.jsxs("div",{children:[h.jsx("label",{htmlFor:"natsEnable",className:"mb-1 block text-sm font-medium text-foreground",children:"NATS"}),h.jsxs("select",{id:"natsEnable",...y("natsEnable"),className:"w-full rounded-md border border-input bg-background px-3 py-2 text-sm text-foreground focus:outline-none focus:ring-2 focus:ring-ring",children:[h.jsx("option",{value:"",children:"Padrão"}),h.jsx("option",{value:"enabled",children:"Habilitado"}),h.jsx("option",{value:"disabled",children:"Desabilitado"})]})]})]})]})]}),h.jsxs("div",{className:"flex gap-2 pt-4",children:[h.jsx("button",{type:"button",onClick:_,className:"flex-1 rounded-md border border-input px-4 py-2 text-sm font-medium text-foreground hover:bg-accent",children:"Cancelar"}),h.jsx("button",{type:"submit",className:"flex-1 rounded-md bg-primary px-4 py-2 text-sm font-medium text-primary-foreground hover:bg-primary/90",children:"Conectar"})]})]})]})})}const A5=Xo({number:Yt().min(1,"Número é obrigatório"),message:Yt().min(1,"Mensagem é obrigatória")});function T5({open:t,onClose:n,instance:r}){const{register:s,handleSubmit:i,formState:{errors:c,isSubmitting:u},reset:f}=Lo({resolver:Io(A5)}),g=async y=>{if(!(r!=null&&r.apikey)){Ze.error("Token da instância não encontrado");return}try{await f5(r.apikey,{number:y.number,text:y.message}),Ze.success("Mensagem enviada com sucesso!"),f(),n()}catch(v){console.error("Send message error:",v),Ze.error("Erro ao enviar mensagem")}},p=()=>{f(),n()};return!t||!r?null:h.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50",children:h.jsxs("div",{className:"w-full max-w-md rounded-lg bg-card p-6 shadow-lg",children:[h.jsxs("div",{className:"mb-4 flex items-center justify-between",children:[h.jsxs("h2",{className:"text-xl font-semibold text-foreground",children:["Enviar Mensagem - ",r.instanceName]}),h.jsx("button",{onClick:p,className:"rounded-md p-1 hover:bg-accent",children:h.jsx(el,{className:"h-5 w-5"})})]}),h.jsxs("form",{onSubmit:i(g),className:"space-y-4",children:[h.jsxs("div",{children:[h.jsx("label",{htmlFor:"number",className:"mb-1 block text-sm font-medium text-foreground",children:"Número (com DDI)"}),h.jsx("input",{id:"number",type:"text",placeholder:"5511999999999",...s("number"),className:"w-full rounded-md border border-input bg-background px-3 py-2 text-foreground placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring"}),c.number&&h.jsx("p",{className:"mt-1 text-sm text-destructive",children:c.number.message})]}),h.jsxs("div",{children:[h.jsx("label",{htmlFor:"message",className:"mb-1 block text-sm font-medium text-foreground",children:"Mensagem"}),h.jsx("textarea",{id:"message",rows:4,placeholder:"Digite sua mensagem...",...s("message"),className:"w-full rounded-md border border-input bg-background px-3 py-2 text-foreground placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring"}),c.message&&h.jsx("p",{className:"mt-1 text-sm text-destructive",children:c.message.message})]}),h.jsxs("div",{className:"flex gap-2",children:[h.jsx("button",{type:"button",onClick:p,disabled:u,className:"flex-1 rounded-md border border-input px-4 py-2 text-sm font-medium text-foreground hover:bg-accent disabled:opacity-50",children:"Cancelar"}),h.jsx("button",{type:"submit",disabled:u,className:"flex-1 rounded-md bg-primary px-4 py-2 text-sm font-medium text-primary-foreground hover:bg-primary/90 disabled:opacity-50",children:u?"Enviando...":"Enviar"})]})]})]})})}function O5({icon:t,title:n,description:r,action:s,className:i}){return h.jsxs("div",{className:Qm("flex flex-col items-center justify-center py-12 px-4 text-center",i),children:[h.jsx("div",{className:"rounded-full bg-sidebar-accent/50 p-6 mb-4 dark:bg-sidebar-accent/50 dark:text-gray-400",children:h.jsx(t,{className:"h-12 w-12 text-sidebar-foreground/60 dark:text-gray-400"})}),h.jsx("h3",{className:"text-lg font-semibold text-sidebar-foreground mb-2 dark:text-gray-400",children:n}),h.jsx("p",{className:"text-sm text-sidebar-foreground/60 mb-6 max-w-md dark:text-gray-400",children:r}),s&&h.jsx(ut,{onClick:s.onClick,children:s.label})]})}function j5(){var L,Y,J,ie,pe;const t=Xr(),{instances:n,isLoading:r,fetchInstances:s,removeInstance:i}=dE(),[c,u]=b.useState(""),[f,g]=b.useState(!1),[p,y]=b.useState({isOpen:!1,instance:null}),[v]=b.useState(1),[w]=b.useState(24),[C,S]=b.useState(null),[_,E]=b.useState({isOpen:!1,instance:null,confirmationText:""}),[R,k]=b.useState({isOpen:!1,instance:null}),[A,D]=b.useState({isOpen:!1,instance:null}),H=b.useRef(!1);b.useEffect(()=>{H.current||(s(),H.current=!0);const Q=setInterval(()=>{s()},5e3);return()=>clearInterval(Q)},[s]);const{paginatedInstances:$,totalCount:U}=b.useMemo(()=>{const Q=c?n.filter(Me=>{var be,je,at;const ze=c.toLowerCase();return((be=Me.instanceName)==null?void 0:be.toLowerCase().includes(ze))||((je=Me.profileName)==null?void 0:je.toLowerCase().includes(ze))||((at=Me.owner)==null?void 0:at.toLowerCase().includes(ze))}):n,oe=(v-1)*w,Re=oe+w;return{paginatedInstances:Q.slice(oe,Re),totalCount:Q.length}},[n,c,v,w]),F=b.useCallback(()=>{g(!0)},[]),de=b.useCallback(Q=>{t(`/manager/instances/${Q.id}/settings`)},[t]),fe=b.useCallback(Q=>{D({isOpen:!0,instance:Q})},[]),me=b.useCallback(async(Q,oe)=>{try{if(!Q.apikey){Ze.error("Token da instância não encontrado");return}if(Ze.info(`Conectando ${Q.instanceName}...`),oe.alwaysOnline!==void 0||oe.rejectCall!==void 0||oe.readMessages!==void 0||oe.ignoreGroups!==void 0||oe.ignoreStatus!==void 0){const Me={alwaysOnline:oe.alwaysOnline,rejectCall:oe.rejectCall,readMessages:oe.readMessages,ignoreGroups:oe.ignoreGroups,ignoreStatus:oe.ignoreStatus};await lE(Q.id,Q.apikey,Me)}if(oe.phone&&oe.phone.trim()!==""){let Me=oe.phone.trim();Me.startsWith("+")||(Me=`+${Me}`),await xh(Q.apikey,{...oe,phone:void 0}),await new Promise(be=>setTimeout(be,1e3));const ze=await d5(Q.apikey,{subscribe:oe.subscribe||[],phone:Me});try{const be=await Im(Q.apikey),je={...Q,qrcode:{base64:be.qrcode,code:be.code,pairingCode:ze.pairingCode}};y({isOpen:!0,instance:je}),Ze.success(`QR Code e Pairing Code gerados para ${Q.instanceName}!`)}catch{const be={...Q,qrcode:{pairingCode:ze.pairingCode}};y({isOpen:!0,instance:be}),Ze.success(`Pairing Code gerado para ${Q.instanceName}!`)}}else{await xh(Q.apikey,oe),await new Promise(Me=>setTimeout(Me,2e3));try{const Me=await Im(Q.apikey),ze={...Q,qrcode:{base64:Me.qrcode,code:Me.code}};y({isOpen:!0,instance:ze}),Ze.success(`QR Code gerado para ${Q.instanceName}!`)}catch(Me){console.error("Erro ao buscar QR Code:",Me),Ze.error("QR Code ainda não disponível, aguarde alguns segundos..."),await s();const ze=n.find(be=>be.instanceName===Q.instanceName);ze&&y({isOpen:!0,instance:ze})}}}catch(Re){console.error("Erro ao conectar instância:",Re),Ze.error(Re instanceof Error?Re.message:"Erro ao conectar instância")}},[s,n]),se=b.useCallback(async Q=>{try{if(!Q.apikey){Ze.error("Token da instância não encontrado");return}Ze.info(`Desconectando ${Q.instanceName}...`),await cE(Q.apikey),await s(),Ze.success(`${Q.instanceName} desconectada!`)}catch(oe){console.error("Erro ao desconectar instância:",oe),Ze.error(oe instanceof Error?oe.message:"Erro ao desconectar instância")}},[s]),G=Q=>{E({isOpen:!0,instance:Q,confirmationText:""})},he=()=>{E({isOpen:!1,instance:null,confirmationText:""})},ve=()=>{y({isOpen:!1,instance:null})},T=Q=>{k({isOpen:!0,instance:Q})},K=()=>{k({isOpen:!1,instance:null})},te=()=>{D({isOpen:!1,instance:null})},le=b.useCallback(Q=>{A.instance&&me(A.instance,Q)},[A.instance,me]),ne=b.useCallback(async()=>{if(!(!p.instance||!p.instance.apikey))try{await s();const Q=n.find(oe=>{var Re;return oe.id===((Re=p.instance)==null?void 0:Re.id)});if(!Q)return;if(Q.connected){y({isOpen:!0,instance:Q});return}try{const oe=await Im(p.instance.apikey),Re={...Q,qrcode:{base64:oe.qrcode,code:oe.code}};y({isOpen:!0,instance:Re})}catch{y({isOpen:!0,instance:Q})}}catch(Q){throw console.error("Erro ao atualizar QR Code:",Q),Q}},[p.instance,s,n]),j=async()=>{if(!_.instance)return;const Q=_.instance.instanceName,oe=_.instance.id;S(Q);try{await uE(oe),i(Q),Ze.success(`Instância ${Q} removida com sucesso!`),he()}catch(Re){console.error("Erro ao remover instância:",Re),Ze.error((Re==null?void 0:Re.message)||"Erro ao remover instância"),await s()}finally{S(null)}},X=_.confirmationText===((L=_.instance)==null?void 0:L.instanceName);return h.jsxs("div",{className:"h-full flex flex-col p-4",children:[h.jsx(g5,{totalCount:U,selectedCount:0,searchValue:c,onSearchChange:u,onNewInstance:F,onClearSelection:()=>{}}),h.jsx("div",{className:"flex-1 overflow-auto",children:r?h.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:Array.from({length:6}).map((Q,oe)=>h.jsx(x3,{className:"h-48"},oe))}):U===0?h.jsx(O5,{icon:bR,title:"Nenhuma instância encontrada",description:"Crie sua primeira instância para começar a usar o Evolution GO",action:{label:"Nova Instância",onClick:F},className:"h-full"}):h.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-6",children:$.map(Q=>h.jsx(h5,{instance:Q,isDeleting:C,onSettings:de,onDelete:G,onConnect:fe,onDisconnect:se,onSendMessage:T},Q.instanceName))})}),h.jsx(E5,{open:f,onOpenChange:g}),h.jsx(_5,{instance:p.instance,open:p.isOpen,onOpenChange:ve,onRefresh:ne}),h.jsx(R5,{instance:A.instance,open:A.isOpen,onClose:te,onConfirm:le}),h.jsx(T5,{instance:R.instance,open:R.isOpen,onClose:K}),h.jsx(gu,{open:_.isOpen,onOpenChange:he,children:h.jsxs(vu,{className:"sm:max-w-md",children:[h.jsxs(yu,{children:[h.jsxs(bu,{className:"flex items-center gap-2 text-red-400 dark:text-red-500",children:[h.jsx(Th,{className:"h-5 w-5"}),"Remover Instância"]}),h.jsxs(xu,{className:"text-sidebar-foreground/70 dark:text-gray-400",children:["Você está prestes a remover a instância"," ",h.jsx("strong",{children:(Y=_.instance)==null?void 0:Y.instanceName}),". Esta ação não pode ser desfeita."]})]}),h.jsx("div",{className:"space-y-4",children:h.jsxs("div",{children:[h.jsx("label",{className:"text-sm font-medium text-sidebar-foreground dark:text-gray-400",children:"Digite o nome da instância para confirmar:"}),h.jsx(Ra,{placeholder:((J=_.instance)==null?void 0:J.instanceName)||"",value:_.confirmationText,onChange:Q=>E(oe=>({...oe,confirmationText:Q.target.value})),className:"mt-2 bg-sidebar border-sidebar-border text-sidebar-foreground placeholder:text-sidebar-foreground/50 dark:text-gray-400 dark:placeholder:text-gray-400"})]})}),h.jsxs(QS,{className:"flex gap-2",children:[h.jsx(ut,{variant:"outline",onClick:he,className:"bg-sidebar border-sidebar-border text-sidebar-foreground hover:bg-sidebar-accent dark:text-gray-400 dark:hover:bg-sidebar-accent",children:"Cancelar"}),h.jsx(ut,{variant:"destructive",onClick:j,disabled:!X||C===((ie=_.instance)==null?void 0:ie.instanceName),className:"bg-red-600 hover:bg-red-700 text-white dark:bg-red-600 dark:hover:bg-red-700",children:C===((pe=_.instance)==null?void 0:pe.instanceName)?"Removendo...":"Remover Instância"})]})]})})]})}const k5=Xo({webhookUrl:Yt().url("URL inválida").optional().or(X3("")),subscribe:Z3(Yt()).optional(),rabbitmqEnable:Yt().optional(),websocketEnable:Yt().optional(),natsEnable:Yt().optional()}),M5=Xo({alwaysOnline:Ta().optional(),rejectCall:Ta().optional(),readMessages:Ta().optional(),ignoreGroups:Ta().optional(),ignoreStatus:Ta().optional()}),D5=["ALL","MESSAGE","READ_RECEIPT","PRESENCE","HISTORY_SYNC","CHAT_PRESENCE","CALL","CONNECTION","QRCODE","LABEL","CONTACT","GROUP","NEWSLETTER"];function z5(){const{instanceId:t}=bN(),n=Xr(),[r,s]=b.useState(null),[i,c]=b.useState([]),[u,f]=b.useState(!1),[g,p]=b.useState(!0),[y,v]=b.useState(!1),w=b.useRef(!1),C=b.useRef(!1),{register:S,handleSubmit:_,formState:{errors:E},reset:R}=Lo({resolver:Io(k5)}),{register:k,handleSubmit:A,reset:D}=Lo({resolver:Io(M5)});b.useEffect(()=>{(async()=>{if(!(!t||C.current)){C.current=!0;try{p(!0);const me=await $c(t);s(me)}catch(me){console.error("Erro ao buscar instância:",me),Ze.error("Erro ao carregar dados da instância")}finally{p(!1)}}})()},[t]),b.useEffect(()=>{if(!(!r||w.current)){if(R({webhookUrl:r.webhook||"",rabbitmqEnable:r.rabbitmqEnable||"",websocketEnable:r.websocketEnable||"",natsEnable:r.natsEnable||""}),D({alwaysOnline:r.alwaysOnline||!1,rejectCall:r.rejectCall||!1,readMessages:r.readMessages||!1,ignoreGroups:r.ignoreGroups||!1,ignoreStatus:r.ignoreStatus||!1}),r.events){const fe=r.events.split(",").map(me=>me.trim()).filter(Boolean);c(fe)}else c([]);w.current=!0}},[r,R,D]);const H=fe=>{c(me=>fe==="ALL"?me.includes("ALL")?[]:["ALL"]:me.includes("ALL")?[fe]:me.includes(fe)?me.filter(se=>se!==fe):[...me,fe])},$=async fe=>{if(!(r!=null&&r.apikey)||!t){Ze.error("Token da instância não encontrado");return}try{f(!0);const me={webhookUrl:fe.webhookUrl||"",subscribe:i,rabbitmqEnable:fe.rabbitmqEnable||"",websocketEnable:fe.websocketEnable||"",natsEnable:fe.natsEnable||""};await xh(r.apikey,me),Ze.success("Configurações de webhook atualizadas!");const se=await $c(t);s(se)}catch(me){console.error("Erro ao atualizar webhook:",me),Ze.error(me instanceof Error?me.message:"Erro ao atualizar webhook")}finally{f(!1)}},U=async fe=>{if(!(r!=null&&r.apikey)||!(r!=null&&r.id)||!t){Ze.error("Token da instância não encontrado");return}try{f(!0),await lE(r.id,r.apikey,fe),Ze.success("Configurações avançadas atualizadas!");const me=await $c(t);s(me)}catch(me){console.error("Erro ao atualizar configurações:",me),Ze.error(me instanceof Error?me.message:"Erro ao atualizar configurações")}finally{f(!1)}},F=async()=>{if(!(r!=null&&r.apikey)||!t){Ze.error("Token da instância não encontrado");return}try{Ze.info(`Desconectando ${r.instanceName}...`),await cE(r.apikey);const fe=await $c(t);s(fe),Ze.success(`${r.instanceName} desconectada!`)}catch(fe){console.error("Erro ao desconectar instância:",fe),Ze.error(fe instanceof Error?fe.message:"Erro ao desconectar instância")}},de=async()=>{if(!(r!=null&&r.id)){Ze.error("ID da instância não encontrado");return}if(window.confirm(`Tem certeza que deseja deletar a instância ${r.instanceName}? Esta ação não pode ser desfeita.`))try{Ze.info(`Deletando ${r.instanceName}...`),await uE(r.id),Ze.success(`${r.instanceName} deletada!`),n("/manager/instances")}catch(me){console.error("Erro ao deletar instância:",me),Ze.error(me instanceof Error?me.message:"Erro ao deletar instância")}};return g?h.jsx("div",{className:"flex h-full items-center justify-center",children:h.jsx("div",{className:"text-center",children:h.jsx("p",{className:"text-muted-foreground",children:"Carregando..."})})}):r?h.jsxs("div",{className:"h-full flex flex-col",children:[h.jsx("div",{className:"border-b border-sidebar-border bg-sidebar p-6",children:h.jsx("div",{className:"flex items-center justify-between",children:h.jsxs("div",{className:"flex items-center gap-4",children:[h.jsx(ut,{variant:"ghost",size:"icon",onClick:()=>n("/manager/instances"),className:"text-sidebar-foreground hover:bg-sidebar-accent",children:h.jsx(Ob,{className:"h-5 w-5"})}),h.jsxs("div",{children:[h.jsx("h1",{className:"text-2xl font-bold text-foreground",children:"Configurações"}),h.jsx("p",{className:"text-sm text-muted-foreground",children:r.instanceName})]})]})})}),h.jsx("div",{className:"flex-1 overflow-y-auto p-6",children:h.jsxs("div",{className:"max-w-4xl mx-auto space-y-6",children:[h.jsxs("div",{className:"rounded-lg border border-sidebar-border bg-card p-6",children:[h.jsx("h2",{className:"text-lg font-semibold text-foreground mb-4",children:"Informações da Instância"}),h.jsx("div",{className:"space-y-4",children:h.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[h.jsxs("div",{children:[h.jsx("label",{className:"text-sm font-medium text-foreground",children:"Nome da Instância"}),h.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:r.instanceName})]}),h.jsxs("div",{children:[h.jsx("label",{className:"text-sm font-medium text-foreground",children:"Token da Instância"}),h.jsxs("div",{className:"mt-1 flex items-center gap-2",children:[h.jsx("p",{className:"text-sm text-muted-foreground font-mono",children:y?r.apikey||"":"•".repeat((r.apikey||"").length)}),h.jsx("button",{type:"button",onClick:()=>v(!y),className:"text-muted-foreground hover:text-foreground transition-colors",title:y?"Ocultar token":"Mostrar token",children:y?h.jsx(dR,{size:18}):h.jsx(mR,{size:18})})]})]}),h.jsxs("div",{children:[h.jsx("label",{className:"text-sm font-medium text-foreground",children:"Status"}),h.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:r.status==="open"?"Conectado":"Desconectado"})]}),r.owner&&h.jsxs("div",{children:[h.jsx("label",{className:"text-sm font-medium text-foreground",children:"Número"}),h.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:r.owner})]}),r.profileName&&h.jsxs("div",{children:[h.jsx("label",{className:"text-sm font-medium text-foreground",children:"Nome do Perfil"}),h.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:r.profileName})]})]})})]}),h.jsx("form",{onSubmit:_($),children:h.jsxs("div",{className:"rounded-lg border border-sidebar-border bg-card p-6",children:[h.jsx("h2",{className:"text-lg font-semibold text-foreground mb-4",children:"Configurações de Webhook"}),h.jsxs("div",{className:"space-y-4",children:[h.jsxs("div",{children:[h.jsx("label",{htmlFor:"webhookUrl",className:"block text-sm font-medium text-foreground mb-1",children:"URL do Webhook"}),h.jsx("input",{id:"webhookUrl",type:"url",placeholder:"https://seu-servidor.com/webhook",...S("webhookUrl"),className:"w-full rounded-md border border-input bg-background px-3 py-2 text-foreground placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring"}),E.webhookUrl&&h.jsx("p",{className:"mt-1 text-sm text-destructive",children:E.webhookUrl.message}),h.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:"URL que receberá os eventos do WhatsApp"})]}),h.jsxs("div",{children:[h.jsx("label",{className:"block text-sm font-medium text-foreground mb-2",children:"Eventos para Webhook"}),h.jsxs("div",{className:"space-y-2 rounded-md border border-input p-3 max-h-60 overflow-y-auto",children:[h.jsx("div",{className:"p-2 rounded-md bg-primary/10 border border-primary/20",children:h.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[h.jsx("input",{type:"checkbox",checked:i.includes("ALL"),onChange:()=>H("ALL"),className:"rounded border-input w-4 h-4"}),h.jsx("span",{className:"text-sm font-semibold text-primary",children:"ALL"})]})}),h.jsx("div",{className:"grid grid-cols-2 gap-2",children:D5.filter(fe=>fe!=="ALL").map(fe=>h.jsxs("label",{className:"flex items-center gap-2 text-sm cursor-pointer hover:bg-accent p-2 rounded",children:[h.jsx("input",{type:"checkbox",checked:i.includes(fe)||i.includes("ALL"),onChange:()=>H(fe),disabled:i.includes("ALL"),className:"rounded border-input"}),h.jsx("span",{className:i.includes("ALL")?"text-muted-foreground":"text-foreground",children:fe})]},fe))})]})]}),h.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[h.jsxs("div",{children:[h.jsx("label",{htmlFor:"rabbitmqEnable",className:"block text-sm font-medium text-foreground mb-1",children:"RabbitMQ"}),h.jsxs("select",{id:"rabbitmqEnable",...S("rabbitmqEnable"),className:"w-full rounded-md border border-input bg-background px-3 py-2 text-sm text-foreground focus:outline-none focus:ring-2 focus:ring-ring",children:[h.jsx("option",{value:"",children:"Padrão"}),h.jsx("option",{value:"enabled",children:"Habilitado"}),h.jsx("option",{value:"disabled",children:"Desabilitado"})]})]}),h.jsxs("div",{children:[h.jsx("label",{htmlFor:"websocketEnable",className:"block text-sm font-medium text-foreground mb-1",children:"WebSocket"}),h.jsxs("select",{id:"websocketEnable",...S("websocketEnable"),className:"w-full rounded-md border border-input bg-background px-3 py-2 text-sm text-foreground focus:outline-none focus:ring-2 focus:ring-ring",children:[h.jsx("option",{value:"",children:"Padrão"}),h.jsx("option",{value:"enabled",children:"Habilitado"}),h.jsx("option",{value:"disabled",children:"Desabilitado"})]})]}),h.jsxs("div",{children:[h.jsx("label",{htmlFor:"natsEnable",className:"block text-sm font-medium text-foreground mb-1",children:"NATS"}),h.jsxs("select",{id:"natsEnable",...S("natsEnable"),className:"w-full rounded-md border border-input bg-background px-3 py-2 text-sm text-foreground focus:outline-none focus:ring-2 focus:ring-ring",children:[h.jsx("option",{value:"",children:"Padrão"}),h.jsx("option",{value:"enabled",children:"Habilitado"}),h.jsx("option",{value:"disabled",children:"Desabilitado"})]})]})]}),h.jsx("div",{className:"flex justify-end",children:h.jsxs(ut,{type:"submit",disabled:u,className:"gap-2",children:[h.jsx(zb,{className:"h-4 w-4"}),u?"Salvando...":"Salvar Webhook"]})})]})]})}),h.jsx("form",{onSubmit:A(U),children:h.jsxs("div",{className:"rounded-lg border border-sidebar-border bg-card p-6",children:[h.jsx("h2",{className:"text-lg font-semibold text-foreground mb-4",children:"Configurações Avançadas"}),h.jsxs("div",{className:"space-y-4",children:[h.jsxs("div",{className:"flex items-center justify-between",children:[h.jsxs("div",{children:[h.jsx("label",{htmlFor:"alwaysOnline",className:"text-sm font-medium text-foreground cursor-pointer",children:"Always Online"}),h.jsx("p",{className:"text-xs text-muted-foreground",children:"Manter sempre online no WhatsApp"})]}),h.jsx("input",{id:"alwaysOnline",type:"checkbox",...k("alwaysOnline"),className:"rounded border-input w-4 h-4"})]}),h.jsxs("div",{className:"flex items-center justify-between",children:[h.jsxs("div",{children:[h.jsx("label",{htmlFor:"rejectCall",className:"text-sm font-medium text-foreground cursor-pointer",children:"Reject Call"}),h.jsx("p",{className:"text-xs text-muted-foreground",children:"Rejeitar chamadas automaticamente"})]}),h.jsx("input",{id:"rejectCall",type:"checkbox",...k("rejectCall"),className:"rounded border-input w-4 h-4"})]}),h.jsxs("div",{className:"flex items-center justify-between",children:[h.jsxs("div",{children:[h.jsx("label",{htmlFor:"readMessages",className:"text-sm font-medium text-foreground cursor-pointer",children:"Read Messages"}),h.jsx("p",{className:"text-xs text-muted-foreground",children:"Marcar mensagens como lidas"})]}),h.jsx("input",{id:"readMessages",type:"checkbox",...k("readMessages"),className:"rounded border-input w-4 h-4"})]}),h.jsxs("div",{className:"flex items-center justify-between",children:[h.jsxs("div",{children:[h.jsx("label",{htmlFor:"ignoreGroups",className:"text-sm font-medium text-foreground cursor-pointer",children:"Ignore Groups"}),h.jsx("p",{className:"text-xs text-muted-foreground",children:"Ignorar mensagens de grupos"})]}),h.jsx("input",{id:"ignoreGroups",type:"checkbox",...k("ignoreGroups"),className:"rounded border-input w-4 h-4"})]}),h.jsxs("div",{className:"flex items-center justify-between",children:[h.jsxs("div",{children:[h.jsx("label",{htmlFor:"ignoreStatus",className:"text-sm font-medium text-foreground cursor-pointer",children:"Ignore Status"}),h.jsx("p",{className:"text-xs text-muted-foreground",children:"Ignorar atualizações de status"})]}),h.jsx("input",{id:"ignoreStatus",type:"checkbox",...k("ignoreStatus"),className:"rounded border-input w-4 h-4"})]}),h.jsx("div",{className:"flex justify-end",children:h.jsxs(ut,{type:"submit",disabled:u,className:"gap-2",children:[h.jsx(zb,{className:"h-4 w-4"}),u?"Salvando...":"Salvar Avançadas"]})})]})]})}),h.jsxs("div",{className:"rounded-lg border border-destructive/50 bg-destructive/10 p-6",children:[h.jsx("h2",{className:"text-lg font-semibold text-destructive mb-4",children:"Zona de Perigo"}),h.jsxs("div",{className:"space-y-4",children:[h.jsxs("div",{className:"flex items-center justify-between",children:[h.jsxs("div",{children:[h.jsx("h3",{className:"text-sm font-medium text-foreground",children:"Desconectar Instância"}),h.jsx("p",{className:"text-xs text-muted-foreground",children:"Desconecta a instância do WhatsApp"})]}),h.jsxs(ut,{variant:"destructive",onClick:F,className:"gap-2",children:[h.jsx(V0,{className:"h-4 w-4"}),"Desconectar"]})]}),h.jsxs("div",{className:"flex items-center justify-between",children:[h.jsxs("div",{children:[h.jsx("h3",{className:"text-sm font-medium text-foreground",children:"Deletar Instância"}),h.jsx("p",{className:"text-xs text-muted-foreground",children:"Remove permanentemente esta instância"})]}),h.jsxs(ut,{variant:"destructive",onClick:de,className:"gap-2",children:[h.jsx(Th,{className:"h-4 w-4"}),"Deletar"]})]})]})]})]})})]}):h.jsx("div",{className:"flex h-full items-center justify-center",children:h.jsxs("div",{className:"text-center",children:[h.jsx("h2",{className:"text-xl font-semibold text-foreground mb-2",children:"Instância não encontrada"}),h.jsxs("p",{className:"text-muted-foreground mb-4",children:['A instância "',t,'" não foi encontrada.']}),h.jsxs(ut,{onClick:()=>n("/manager/instances"),children:[h.jsx(Ob,{className:"h-4 w-4 mr-2"}),"Voltar para Instâncias"]})]})})}function L5(){return h.jsxs("div",{className:"p-6",children:[h.jsx("h1",{className:"mb-4 text-2xl font-bold text-gray-900",children:"Mensagens"}),h.jsx("p",{className:"text-gray-600",children:"Messages sending will be implemented here..."})]})}function U5(){return h.jsxs("div",{className:"p-6",children:[h.jsx("h1",{className:"mb-4 text-2xl font-bold text-foreground",children:"Eventos"}),h.jsx("p",{className:"text-muted-foreground",children:"Events monitor will be implemented here..."})]})}function B5(){return h.jsxs("div",{className:"p-6",children:[h.jsx("h1",{className:"mb-4 text-2xl font-bold text-gray-900",children:"Configurações"}),h.jsx("p",{className:"text-gray-600",children:"Settings will be implemented here..."})]})}const P5=()=>{const[t]=u2(),n=Xr(),{setLicenseState:r,apiUrl:s,apiKey:i}=zu(),[c,u]=b.useState("activating"),[f,g]=b.useState(""),p=t.get("code"),y=b.useCallback(async()=>{if(!p){u("error"),g("Codigo de autorizacao nao encontrado na URL.");return}u("activating"),g("");try{const v=await OO(p,s,i);v.status==="active"?(u("success"),r("licensed"),Ze.success("Licenca ativada com sucesso!"),setTimeout(()=>{n("/manager/login",{replace:!0})},2e3)):(u("error"),g(v.message||"Falha ao ativar licenca."))}catch(v){u("error");const w=v instanceof Error?v.message:v==null?void 0:v.message;g(w||"Erro ao ativar licenca.")}},[p,s,i,n,r]);return b.useEffect(()=>{y()},[y]),h.jsx("div",{className:"min-h-screen flex items-center justify-center p-4 bg-gradient-to-t from-primary/20 via-background/95 to-background",children:h.jsxs("div",{className:"w-full max-w-md space-y-6",children:[h.jsx("div",{className:"text-center",children:h.jsx("h1",{className:"text-3xl font-bold text-primary",children:"Evolution GO"})}),h.jsxs("div",{className:"bg-background/80 backdrop-blur-sm border rounded-lg p-8 shadow-lg text-center space-y-4",children:[c==="activating"&&h.jsxs(h.Fragment,{children:[h.jsx(H0,{className:"h-12 w-12 animate-spin text-primary mx-auto"}),h.jsx("h2",{className:"text-xl font-semibold",children:"Ativando licenca..."}),h.jsx("p",{className:"text-muted-foreground",children:"Aguarde enquanto ativamos sua licenca."})]}),c==="success"&&h.jsxs(h.Fragment,{children:[h.jsx(rR,{className:"h-12 w-12 text-green-500 mx-auto"}),h.jsx("h2",{className:"text-xl font-semibold",children:"Licenca ativada!"}),h.jsx("p",{className:"text-muted-foreground",children:"Redirecionando para o login..."})]}),c==="error"&&h.jsxs(h.Fragment,{children:[h.jsx(iR,{className:"h-12 w-12 text-destructive mx-auto"}),h.jsx("h2",{className:"text-xl font-semibold",children:"Erro na ativacao"}),h.jsx("p",{className:"text-muted-foreground",children:f}),h.jsxs("div",{className:"flex gap-2 justify-center pt-2",children:[h.jsx(ut,{variant:"outline",onClick:()=>n("/manager/login",{replace:!0}),children:"Voltar ao login"}),h.jsx(ut,{onClick:y,children:"Tentar novamente"})]})]})]})]})})};function H5(){const{isAuthenticated:t,licenseState:n}=zu(),r=t&&n==="licensed";return h.jsx(kO,{children:h.jsxs(WR,{children:[h.jsx(o2,{children:h.jsxs(zN,{children:[h.jsx(Hn,{path:"/",element:h.jsx(w3,{})}),h.jsx(Hn,{path:"/manager/login",element:r?h.jsx(ym,{to:"/manager",replace:!0}):h.jsx(i5,{})}),h.jsx(Hn,{path:"/manager/license/callback",element:h.jsx(P5,{})}),r?h.jsxs(Hn,{path:"/manager",element:h.jsx(zO,{}),children:[h.jsx(Hn,{index:!0,element:h.jsx(l5,{})}),h.jsx(Hn,{path:"instances",element:h.jsx(j5,{})}),h.jsx(Hn,{path:"instances/:instanceId/settings",element:h.jsx(z5,{})}),h.jsx(Hn,{path:"messages",element:h.jsx(L5,{})}),h.jsx(Hn,{path:"events",element:h.jsx(U5,{})}),h.jsx(Hn,{path:"settings",element:h.jsx(B5,{})})]}):h.jsx(Hn,{path:"/manager/*",element:h.jsx(ym,{to:"/manager/login",replace:!0})}),h.jsx(Hn,{path:"*",element:h.jsx(ym,{to:"/",replace:!0})})]})}),h.jsx(I2,{position:"top-right",richColors:!0})]})})}DC.createRoot(document.getElementById("root")).render(h.jsx(b.StrictMode,{children:h.jsx(H5,{})}));