import{r as Mm,a as Em,b as v,u as _s,L as J0,R as Cm,c as qt,N as ws,O as Os,d as ei,B as Am}from"./vendor-BI0H_s0W.js";import{s as Us,e as Hs,a as qa,b as Un,c as W0,i as $0,d as ii,f as _e,p as tt,g as Dl,h as F0,j as I0,k as ni,l as P0,m as ef,n as Dm,o as _m,q as wm}from"./date-huy51PAD.js";(function(){const x=document.createElement("link").relList;if(x&&x.supports&&x.supports("modulepreload"))return;for(const T of document.querySelectorAll('link[rel="modulepreload"]'))d(T);new MutationObserver(T=>{for(const C of T)if(C.type==="childList")for(const H of C.addedNodes)H.tagName==="LINK"&&H.rel==="modulepreload"&&d(H)}).observe(document,{childList:!0,subtree:!0});function w(T){const C={};return T.integrity&&(C.integrity=T.integrity),T.referrerPolicy&&(C.referrerPolicy=T.referrerPolicy),T.crossOrigin==="use-credentials"?C.credentials="include":T.crossOrigin==="anonymous"?C.credentials="omit":C.credentials="same-origin",C}function d(T){if(T.ep)return;T.ep=!0;const C=w(T);fetch(T.href,C)}})();var zs={exports:{}},wn={};/** * @license React * react-jsx-runtime.production.js * * Copyright (c) Meta Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */var q0;function Om(){if(q0)return wn;q0=1;var r=Symbol.for("react.transitional.element"),x=Symbol.for("react.fragment");function w(d,T,C){var H=null;if(C!==void 0&&(H=""+C),T.key!==void 0&&(H=""+T.key),"key"in T){C={};for(var q in T)q!=="key"&&(C[q]=T[q])}else C=T;return T=C.ref,{$$typeof:r,type:d,key:H,ref:T!==void 0?T:null,props:C}}return wn.Fragment=x,wn.jsx=w,wn.jsxs=w,wn}var Y0;function Um(){return Y0||(Y0=1,zs.exports=Om()),zs.exports}var i=Um(),Ts={exports:{}},On={},Ms={exports:{}},Es={};/** * @license React * scheduler.production.js * * Copyright (c) Meta Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */var L0;function Hm(){return L0||(L0=1,(function(r){function x(p,O){var V=p.length;p.push(O);e:for(;0>>1,oe=p[me];if(0>>1;meT(M,V))AT(ve,M)?(p[me]=ve,p[A]=V,me=A):(p[me]=M,p[ne]=V,me=ne);else if(AT(ve,V))p[me]=ve,p[A]=V,me=A;else break e}}return O}function T(p,O){var V=p.sortIndex-O.sortIndex;return V!==0?V:p.id-O.id}if(r.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var C=performance;r.unstable_now=function(){return C.now()}}else{var H=Date,q=H.now();r.unstable_now=function(){return H.now()-q}}var Y=[],B=[],R=1,D=null,j=3,U=!1,E=!1,z=!1,_=!1,X=typeof setTimeout=="function"?setTimeout:null,I=typeof clearTimeout=="function"?clearTimeout:null,te=typeof setImmediate<"u"?setImmediate:null;function J(p){for(var O=w(B);O!==null;){if(O.callback===null)d(B);else if(O.startTime<=p)d(B),O.sortIndex=O.expirationTime,x(Y,O);else break;O=w(B)}}function ge(p){if(z=!1,J(p),!E)if(w(Y)!==null)E=!0,ce||(ce=!0,pe());else{var O=w(B);O!==null&&Re(ge,O.startTime-p)}}var ce=!1,be=-1,P=5,Z=-1;function Ne(){return _?!0:!(r.unstable_now()-Zp&&Ne());){var me=D.callback;if(typeof me=="function"){D.callback=null,j=D.priorityLevel;var oe=me(D.expirationTime<=p);if(p=r.unstable_now(),typeof oe=="function"){D.callback=oe,J(p),O=!0;break t}D===w(Y)&&d(Y),J(p)}else d(Y);D=w(Y)}if(D!==null)O=!0;else{var Q=w(B);Q!==null&&Re(ge,Q.startTime-p),O=!1}}break e}finally{D=null,j=V,U=!1}O=void 0}}finally{O?pe():ce=!1}}}var pe;if(typeof te=="function")pe=function(){te(ee)};else if(typeof MessageChannel<"u"){var Qe=new MessageChannel,Ve=Qe.port2;Qe.port1.onmessage=ee,pe=function(){Ve.postMessage(null)}}else pe=function(){X(ee,0)};function Re(p,O){be=X(function(){p(r.unstable_now())},O)}r.unstable_IdlePriority=5,r.unstable_ImmediatePriority=1,r.unstable_LowPriority=4,r.unstable_NormalPriority=3,r.unstable_Profiling=null,r.unstable_UserBlockingPriority=2,r.unstable_cancelCallback=function(p){p.callback=null},r.unstable_forceFrameRate=function(p){0>p||125me?(p.sortIndex=V,x(B,p),w(Y)===null&&p===w(B)&&(z?(I(be),be=-1):z=!0,Re(ge,V-me))):(p.sortIndex=oe,x(Y,p),E||U||(E=!0,ce||(ce=!0,pe()))),p},r.unstable_shouldYield=Ne,r.unstable_wrapCallback=function(p){var O=j;return function(){var V=j;j=O;try{return p.apply(this,arguments)}finally{j=V}}}})(Es)),Es}var R0;function Bm(){return R0||(R0=1,Ms.exports=Hm()),Ms.exports}/** * @license React * react-dom-client.production.js * * Copyright (c) Meta Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */var G0;function qm(){if(G0)return On;G0=1;var r=Bm(),x=Mm(),w=Em();function d(e){var t="https://react.dev/errors/"+e;if(1oe||(e.current=me[oe],me[oe]=null,oe--)}function M(e,t){oe++,me[oe]=e.current,e.current=t}var A=Q(null),ve=Q(null),Ke=Q(null),ul=Q(null);function Yt(e,t){switch(M(Ke,t),M(ve,e),M(A,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?c0(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=c0(t),e=s0(t,e);else switch(e){case"svg":e=1;break;case"math":e=2;break;default:e=0}}ne(A),M(A,e)}function At(){ne(A),ne(ve),ne(Ke)}function W(e){e.memoizedState!==null&&M(ul,e);var t=A.current,l=s0(t,e.type);t!==l&&(M(ve,e),M(A,l))}function Ee(e){ve.current===e&&(ne(A),ne(ve)),ul.current===e&&(ne(ul),Cn._currentValue=V)}var Pe,Lt;function lt(e){if(Pe===void 0)try{throw Error()}catch(l){var t=l.stack.trim().match(/\n( *(at )?)/);Pe=t&&t[1]||"",Lt=-1)":-1n||o[a]!==h[n]){var S=` `+o[a].replace(" at new "," at ");return e.displayName&&S.includes("")&&(S=S.replace("",e.displayName)),S}while(1<=a&&0<=n);break}}}finally{si=!1,Error.prepareStackTrace=l}return(l=e?e.displayName||e.name:"")?lt(l):""}function af(e,t){switch(e.tag){case 26:case 27:case 5:return lt(e.type);case 16:return lt("Lazy");case 13:return e.child!==t&&t!==null?lt("Suspense Fallback"):lt("Suspense");case 19:return lt("SuspenseList");case 0:case 15:return ri(e.type,!1);case 11:return ri(e.type.render,!1);case 1:return ri(e.type,!0);case 31:return lt("Activity");default:return""}}function Bs(e){try{var t="",l=null;do t+=af(e,l),l=e,e=e.return;while(e);return t}catch(a){return` Error generating stack: `+a.message+` `+a.stack}}var di=Object.prototype.hasOwnProperty,oi=r.unstable_scheduleCallback,fi=r.unstable_cancelCallback,nf=r.unstable_shouldYield,uf=r.unstable_requestPaint,dt=r.unstable_now,cf=r.unstable_getCurrentPriorityLevel,qs=r.unstable_ImmediatePriority,Ys=r.unstable_UserBlockingPriority,Bn=r.unstable_NormalPriority,sf=r.unstable_LowPriority,Ls=r.unstable_IdlePriority,rf=r.log,df=r.unstable_setDisableYieldValue,La=null,ot=null;function il(e){if(typeof rf=="function"&&df(e),ot&&typeof ot.setStrictMode=="function")try{ot.setStrictMode(La,e)}catch{}}var ft=Math.clz32?Math.clz32:gf,of=Math.log,ff=Math.LN2;function gf(e){return e>>>=0,e===0?32:31-(of(e)/ff|0)|0}var qn=256,Yn=262144,Ln=4194304;function wl(e){var t=e&42;if(t!==0)return t;switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return e&261888;case 262144:case 524288:case 1048576:case 2097152:return e&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return e&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return e}}function Rn(e,t,l){var a=e.pendingLanes;if(a===0)return 0;var n=0,u=e.suspendedLanes,c=e.pingedLanes;e=e.warmLanes;var s=a&134217727;return s!==0?(a=s&~u,a!==0?n=wl(a):(c&=s,c!==0?n=wl(c):l||(l=s&~e,l!==0&&(n=wl(l))))):(s=a&~u,s!==0?n=wl(s):c!==0?n=wl(c):l||(l=a&~e,l!==0&&(n=wl(l)))),n===0?0:t!==0&&t!==n&&(t&u)===0&&(u=n&-n,l=t&-t,u>=l||u===32&&(l&4194048)!==0)?t:n}function Ra(e,t){return(e.pendingLanes&~(e.suspendedLanes&~e.pingedLanes)&t)===0}function mf(e,t){switch(e){case 1:case 2:case 4:case 8:case 64:return t+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return t+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function Rs(){var e=Ln;return Ln<<=1,(Ln&62914560)===0&&(Ln=4194304),e}function gi(e){for(var t=[],l=0;31>l;l++)t.push(e);return t}function Ga(e,t){e.pendingLanes|=t,t!==268435456&&(e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0)}function hf(e,t,l,a,n,u){var c=e.pendingLanes;e.pendingLanes=l,e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0,e.expiredLanes&=l,e.entangledLanes&=l,e.errorRecoveryDisabledLanes&=l,e.shellSuspendCounter=0;var s=e.entanglements,o=e.expirationTimes,h=e.hiddenUpdates;for(l=c&~l;0"u")return null;try{return e.activeElement||e.body}catch{return e.body}}var Sf=/[\n"\\]/g;function St(e){return e.replace(Sf,function(t){return"\\"+t.charCodeAt(0).toString(16)+" "})}function vi(e,t,l,a,n,u,c,s){e.name="",c!=null&&typeof c!="function"&&typeof c!="symbol"&&typeof c!="boolean"?e.type=c:e.removeAttribute("type"),t!=null?c==="number"?(t===0&&e.value===""||e.value!=t)&&(e.value=""+pt(t)):e.value!==""+pt(t)&&(e.value=""+pt(t)):c!=="submit"&&c!=="reset"||e.removeAttribute("value"),t!=null?pi(e,c,pt(t)):l!=null?pi(e,c,pt(l)):a!=null&&e.removeAttribute("value"),n==null&&u!=null&&(e.defaultChecked=!!u),n!=null&&(e.checked=n&&typeof n!="function"&&typeof n!="symbol"),s!=null&&typeof s!="function"&&typeof s!="symbol"&&typeof s!="boolean"?e.name=""+pt(s):e.removeAttribute("name")}function er(e,t,l,a,n,u,c,s){if(u!=null&&typeof u!="function"&&typeof u!="symbol"&&typeof u!="boolean"&&(e.type=u),t!=null||l!=null){if(!(u!=="submit"&&u!=="reset"||t!=null)){bi(e);return}l=l!=null?""+pt(l):"",t=t!=null?""+pt(t):l,s||t===e.value||(e.value=t),e.defaultValue=t}a=a??n,a=typeof a!="function"&&typeof a!="symbol"&&!!a,e.checked=s?e.checked:!!a,e.defaultChecked=!!a,c!=null&&typeof c!="function"&&typeof c!="symbol"&&typeof c!="boolean"&&(e.name=c),bi(e)}function pi(e,t,l){t==="number"&&Xn(e.ownerDocument)===e||e.defaultValue===""+l||(e.defaultValue=""+l)}function na(e,t,l,a){if(e=e.options,t){t={};for(var n=0;n"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),zi=!1;if(Qt)try{var Va={};Object.defineProperty(Va,"passive",{get:function(){zi=!0}}),window.addEventListener("test",Va,Va),window.removeEventListener("test",Va,Va)}catch{zi=!1}var sl=null,Ti=null,Vn=null;function cr(){if(Vn)return Vn;var e,t=Ti,l=t.length,a,n="value"in sl?sl.value:sl.textContent,u=n.length;for(e=0;e=Wa),gr=" ",mr=!1;function hr(e,t){switch(e){case"keyup":return Wf.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function yr(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var sa=!1;function Ff(e,t){switch(e){case"compositionend":return yr(t);case"keypress":return t.which!==32?null:(mr=!0,gr);case"textInput":return e=t.data,e===gr&&mr?null:e;default:return null}}function If(e,t){if(sa)return e==="compositionend"||!Di&&hr(e,t)?(e=cr(),Vn=Ti=sl=null,sa=!1,e):null;switch(e){case"paste":return null;case"keypress":if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1=t)return{node:l,offset:t-e};e=a}e:{for(;l;){if(l.nextSibling){l=l.nextSibling;break e}l=l.parentNode}l=void 0}l=kr(l)}}function Tr(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?Tr(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function Mr(e){e=e!=null&&e.ownerDocument!=null&&e.ownerDocument.defaultView!=null?e.ownerDocument.defaultView:window;for(var t=Xn(e.document);t instanceof e.HTMLIFrameElement;){try{var l=typeof t.contentWindow.location.href=="string"}catch{l=!1}if(l)e=t.contentWindow;else break;t=Xn(e.document)}return t}function Oi(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&(t==="input"&&(e.type==="text"||e.type==="search"||e.type==="tel"||e.type==="url"||e.type==="password")||t==="textarea"||e.contentEditable==="true")}var ig=Qt&&"documentMode"in document&&11>=document.documentMode,ra=null,Ui=null,Pa=null,Hi=!1;function Er(e,t,l){var a=l.window===l?l.document:l.nodeType===9?l:l.ownerDocument;Hi||ra==null||ra!==Xn(a)||(a=ra,"selectionStart"in a&&Oi(a)?a={start:a.selectionStart,end:a.selectionEnd}:(a=(a.ownerDocument&&a.ownerDocument.defaultView||window).getSelection(),a={anchorNode:a.anchorNode,anchorOffset:a.anchorOffset,focusNode:a.focusNode,focusOffset:a.focusOffset}),Pa&&Ia(Pa,a)||(Pa=a,a=Yu(Ui,"onSelect"),0>=c,n-=c,Ot=1<<32-ft(t)+n|l<ae?(re=G,G=null):re=G.sibling;var ye=y(g,G,m[ae],N);if(ye===null){G===null&&(G=re);break}e&&G&&ye.alternate===null&&t(g,G),f=u(ye,f,ae),he===null?K=ye:he.sibling=ye,he=ye,G=re}if(ae===m.length)return l(g,G),fe&&Zt(g,ae),K;if(G===null){for(;aeae?(re=G,G=null):re=G.sibling;var Al=y(g,G,ye.value,N);if(Al===null){G===null&&(G=re);break}e&&G&&Al.alternate===null&&t(g,G),f=u(Al,f,ae),he===null?K=Al:he.sibling=Al,he=Al,G=re}if(ye.done)return l(g,G),fe&&Zt(g,ae),K;if(G===null){for(;!ye.done;ae++,ye=m.next())ye=k(g,ye.value,N),ye!==null&&(f=u(ye,f,ae),he===null?K=ye:he.sibling=ye,he=ye);return fe&&Zt(g,ae),K}for(G=a(G);!ye.done;ae++,ye=m.next())ye=b(G,g,ae,ye.value,N),ye!==null&&(e&&ye.alternate!==null&&G.delete(ye.key===null?ae:ye.key),f=u(ye,f,ae),he===null?K=ye:he.sibling=ye,he=ye);return e&&G.forEach(function(Tm){return t(g,Tm)}),fe&&Zt(g,ae),K}function Te(g,f,m,N){if(typeof m=="object"&&m!==null&&m.type===z&&m.key===null&&(m=m.props.children),typeof m=="object"&&m!==null){switch(m.$$typeof){case U:e:{for(var K=m.key;f!==null;){if(f.key===K){if(K=m.type,K===z){if(f.tag===7){l(g,f.sibling),N=n(f,m.props.children),N.return=g,g=N;break e}}else if(f.elementType===K||typeof K=="object"&&K!==null&&K.$$typeof===P&&Xl(K)===f.type){l(g,f.sibling),N=n(f,m.props),un(N,m),N.return=g,g=N;break e}l(g,f);break}else t(g,f);f=f.sibling}m.type===z?(N=Yl(m.props.children,g.mode,N,m.key),N.return=g,g=N):(N=lu(m.type,m.key,m.props,null,g.mode,N),un(N,m),N.return=g,g=N)}return c(g);case E:e:{for(K=m.key;f!==null;){if(f.key===K)if(f.tag===4&&f.stateNode.containerInfo===m.containerInfo&&f.stateNode.implementation===m.implementation){l(g,f.sibling),N=n(f,m.children||[]),N.return=g,g=N;break e}else{l(g,f);break}else t(g,f);f=f.sibling}N=Qi(m,g.mode,N),N.return=g,g=N}return c(g);case P:return m=Xl(m),Te(g,f,m,N)}if(Re(m))return L(g,f,m,N);if(pe(m)){if(K=pe(m),typeof K!="function")throw Error(d(150));return m=K.call(m),$(g,f,m,N)}if(typeof m.then=="function")return Te(g,f,ru(m),N);if(m.$$typeof===te)return Te(g,f,uu(g,m),N);du(g,m)}return typeof m=="string"&&m!==""||typeof m=="number"||typeof m=="bigint"?(m=""+m,f!==null&&f.tag===6?(l(g,f.sibling),N=n(f,m),N.return=g,g=N):(l(g,f),N=Gi(m,g.mode,N),N.return=g,g=N),c(g)):l(g,f)}return function(g,f,m,N){try{nn=0;var K=Te(g,f,m,N);return pa=null,K}catch(G){if(G===va||G===cu)throw G;var he=mt(29,G,null,g.mode);return he.lanes=N,he.return=g,he}finally{}}}var Vl=Fr(!0),Ir=Fr(!1),gl=!1;function tc(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function lc(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,callbacks:null})}function ml(e){return{lane:e,tag:0,payload:null,callback:null,next:null}}function hl(e,t,l){var a=e.updateQueue;if(a===null)return null;if(a=a.shared,(xe&2)!==0){var n=a.pending;return n===null?t.next=t:(t.next=n.next,n.next=t),a.pending=t,t=tu(e),Ur(e,null,l),t}return eu(e,a,t,l),tu(e)}function cn(e,t,l){if(t=t.updateQueue,t!==null&&(t=t.shared,(l&4194048)!==0)){var a=t.lanes;a&=e.pendingLanes,l|=a,t.lanes=l,Qs(e,l)}}function ac(e,t){var l=e.updateQueue,a=e.alternate;if(a!==null&&(a=a.updateQueue,l===a)){var n=null,u=null;if(l=l.firstBaseUpdate,l!==null){do{var c={lane:l.lane,tag:l.tag,payload:l.payload,callback:null,next:null};u===null?n=u=c:u=u.next=c,l=l.next}while(l!==null);u===null?n=u=t:u=u.next=t}else n=u=t;l={baseState:a.baseState,firstBaseUpdate:n,lastBaseUpdate:u,shared:a.shared,callbacks:a.callbacks},e.updateQueue=l;return}e=l.lastBaseUpdate,e===null?l.firstBaseUpdate=t:e.next=t,l.lastBaseUpdate=t}var nc=!1;function sn(){if(nc){var e=ba;if(e!==null)throw e}}function rn(e,t,l,a){nc=!1;var n=e.updateQueue;gl=!1;var u=n.firstBaseUpdate,c=n.lastBaseUpdate,s=n.shared.pending;if(s!==null){n.shared.pending=null;var o=s,h=o.next;o.next=null,c===null?u=h:c.next=h,c=o;var S=e.alternate;S!==null&&(S=S.updateQueue,s=S.lastBaseUpdate,s!==c&&(s===null?S.firstBaseUpdate=h:s.next=h,S.lastBaseUpdate=o))}if(u!==null){var k=n.baseState;c=0,S=h=o=null,s=u;do{var y=s.lane&-536870913,b=y!==s.lane;if(b?(se&y)===y:(a&y)===y){y!==0&&y===xa&&(nc=!0),S!==null&&(S=S.next={lane:0,tag:s.tag,payload:s.payload,callback:null,next:null});e:{var L=e,$=s;y=t;var Te=l;switch($.tag){case 1:if(L=$.payload,typeof L=="function"){k=L.call(Te,k,y);break e}k=L;break e;case 3:L.flags=L.flags&-65537|128;case 0:if(L=$.payload,y=typeof L=="function"?L.call(Te,k,y):L,y==null)break e;k=D({},k,y);break e;case 2:gl=!0}}y=s.callback,y!==null&&(e.flags|=64,b&&(e.flags|=8192),b=n.callbacks,b===null?n.callbacks=[y]:b.push(y))}else b={lane:y,tag:s.tag,payload:s.payload,callback:s.callback,next:null},S===null?(h=S=b,o=k):S=S.next=b,c|=y;if(s=s.next,s===null){if(s=n.shared.pending,s===null)break;b=s,s=b.next,b.next=null,n.lastBaseUpdate=b,n.shared.pending=null}}while(!0);S===null&&(o=k),n.baseState=o,n.firstBaseUpdate=h,n.lastBaseUpdate=S,u===null&&(n.shared.lanes=0),pl|=c,e.lanes=c,e.memoizedState=k}}function Pr(e,t){if(typeof e!="function")throw Error(d(191,e));e.call(t)}function ed(e,t){var l=e.callbacks;if(l!==null)for(e.callbacks=null,e=0;eu?u:8;var c=p.T,s={};p.T=s,Nc(e,!1,t,l);try{var o=n(),h=p.S;if(h!==null&&h(s,o),o!==null&&typeof o=="object"&&typeof o.then=="function"){var S=hg(o,a);fn(e,t,S,vt(e))}else fn(e,t,a,vt(e))}catch(k){fn(e,t,{then:function(){},status:"rejected",reason:k},vt())}finally{O.p=u,c!==null&&s.types!==null&&(c.types=s.types),p.T=c}}function Sg(){}function Sc(e,t,l,a){if(e.tag!==5)throw Error(d(476));var n=_d(e).queue;Dd(e,n,t,V,l===null?Sg:function(){return wd(e),l(a)})}function _d(e){var t=e.memoizedState;if(t!==null)return t;t={memoizedState:V,baseState:V,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Wt,lastRenderedState:V},next:null};var l={};return t.next={memoizedState:l,baseState:l,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Wt,lastRenderedState:l},next:null},e.memoizedState=t,e=e.alternate,e!==null&&(e.memoizedState=t),t}function wd(e){var t=_d(e);t.next===null&&(t=e.alternate.memoizedState),fn(e,t.next.queue,{},vt())}function jc(){return $e(Cn)}function Od(){return He().memoizedState}function Ud(){return He().memoizedState}function jg(e){for(var t=e.return;t!==null;){switch(t.tag){case 24:case 3:var l=vt();e=ml(l);var a=hl(t,e,l);a!==null&&(rt(a,t,l),cn(a,t,l)),t={cache:Fi()},e.payload=t;return}t=t.return}}function Ng(e,t,l){var a=vt();l={lane:a,revertLane:0,gesture:null,action:l,hasEagerState:!1,eagerState:null,next:null},pu(e)?Bd(t,l):(l=Li(e,t,l,a),l!==null&&(rt(l,e,a),qd(l,t,a)))}function Hd(e,t,l){var a=vt();fn(e,t,l,a)}function fn(e,t,l,a){var n={lane:a,revertLane:0,gesture:null,action:l,hasEagerState:!1,eagerState:null,next:null};if(pu(e))Bd(t,n);else{var u=e.alternate;if(e.lanes===0&&(u===null||u.lanes===0)&&(u=t.lastRenderedReducer,u!==null))try{var c=t.lastRenderedState,s=u(c,l);if(n.hasEagerState=!0,n.eagerState=s,gt(s,c))return eu(e,t,n,0),Me===null&&Pn(),!1}catch{}finally{}if(l=Li(e,t,n,a),l!==null)return rt(l,e,a),qd(l,t,a),!0}return!1}function Nc(e,t,l,a){if(a={lane:2,revertLane:ts(),gesture:null,action:a,hasEagerState:!1,eagerState:null,next:null},pu(e)){if(t)throw Error(d(479))}else t=Li(e,l,a,2),t!==null&&rt(t,e,2)}function pu(e){var t=e.alternate;return e===le||t!==null&&t===le}function Bd(e,t){ja=gu=!0;var l=e.pending;l===null?t.next=t:(t.next=l.next,l.next=t),e.pending=t}function qd(e,t,l){if((l&4194048)!==0){var a=t.lanes;a&=e.pendingLanes,l|=a,t.lanes=l,Qs(e,l)}}var gn={readContext:$e,use:yu,useCallback:we,useContext:we,useEffect:we,useImperativeHandle:we,useLayoutEffect:we,useInsertionEffect:we,useMemo:we,useReducer:we,useRef:we,useState:we,useDebugValue:we,useDeferredValue:we,useTransition:we,useSyncExternalStore:we,useId:we,useHostTransitionStatus:we,useFormState:we,useActionState:we,useOptimistic:we,useMemoCache:we,useCacheRefresh:we};gn.useEffectEvent=we;var Yd={readContext:$e,use:yu,useCallback:function(e,t){return et().memoizedState=[e,t===void 0?null:t],e},useContext:$e,useEffect:jd,useImperativeHandle:function(e,t,l){l=l!=null?l.concat([e]):null,bu(4194308,4,Td.bind(null,t,e),l)},useLayoutEffect:function(e,t){return bu(4194308,4,e,t)},useInsertionEffect:function(e,t){bu(4,2,e,t)},useMemo:function(e,t){var l=et();t=t===void 0?null:t;var a=e();if(Kl){il(!0);try{e()}finally{il(!1)}}return l.memoizedState=[a,t],a},useReducer:function(e,t,l){var a=et();if(l!==void 0){var n=l(t);if(Kl){il(!0);try{l(t)}finally{il(!1)}}}else n=t;return a.memoizedState=a.baseState=n,e={pending:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:n},a.queue=e,e=e.dispatch=Ng.bind(null,le,e),[a.memoizedState,e]},useRef:function(e){var t=et();return e={current:e},t.memoizedState=e},useState:function(e){e=yc(e);var t=e.queue,l=Hd.bind(null,le,t);return t.dispatch=l,[e.memoizedState,l]},useDebugValue:vc,useDeferredValue:function(e,t){var l=et();return pc(l,e,t)},useTransition:function(){var e=yc(!1);return e=Dd.bind(null,le,e.queue,!0,!1),et().memoizedState=e,[!1,e]},useSyncExternalStore:function(e,t,l){var a=le,n=et();if(fe){if(l===void 0)throw Error(d(407));l=l()}else{if(l=t(),Me===null)throw Error(d(349));(se&127)!==0||id(a,t,l)}n.memoizedState=l;var u={value:l,getSnapshot:t};return n.queue=u,jd(sd.bind(null,a,u,e),[e]),a.flags|=2048,ka(9,{destroy:void 0},cd.bind(null,a,u,l,t),null),l},useId:function(){var e=et(),t=Me.identifierPrefix;if(fe){var l=Ut,a=Ot;l=(a&~(1<<32-ft(a)-1)).toString(32)+l,t="_"+t+"R_"+l,l=mu++,0<\/script>",u=u.removeChild(u.firstChild);break;case"select":u=typeof a.is=="string"?c.createElement("select",{is:a.is}):c.createElement("select"),a.multiple?u.multiple=!0:a.size&&(u.size=a.size);break;default:u=typeof a.is=="string"?c.createElement(n,{is:a.is}):c.createElement(n)}}u[Je]=t,u[at]=a;e:for(c=t.child;c!==null;){if(c.tag===5||c.tag===6)u.appendChild(c.stateNode);else if(c.tag!==4&&c.tag!==27&&c.child!==null){c.child.return=c,c=c.child;continue}if(c===t)break e;for(;c.sibling===null;){if(c.return===null||c.return===t)break e;c=c.return}c.sibling.return=c.return,c=c.sibling}t.stateNode=u;e:switch(Ie(u,n,a),n){case"button":case"input":case"select":case"textarea":a=!!a.autoFocus;break e;case"img":a=!0;break e;default:a=!1}a&&Ft(t)}}return Ae(t),Bc(t,t.type,e===null?null:e.memoizedProps,t.pendingProps,l),null;case 6:if(e&&t.stateNode!=null)e.memoizedProps!==a&&Ft(t);else{if(typeof a!="string"&&t.stateNode===null)throw Error(d(166));if(e=Ke.current,ha(t)){if(e=t.stateNode,l=t.memoizedProps,a=null,n=We,n!==null)switch(n.tag){case 27:case 5:a=n.memoizedProps}e[Je]=t,e=!!(e.nodeValue===l||a!==null&&a.suppressHydrationWarning===!0||u0(e.nodeValue,l)),e||ol(t,!0)}else e=Lu(e).createTextNode(a),e[Je]=t,t.stateNode=e}return Ae(t),null;case 31:if(l=t.memoizedState,e===null||e.memoizedState!==null){if(a=ha(t),l!==null){if(e===null){if(!a)throw Error(d(318));if(e=t.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(d(557));e[Je]=t}else Ll(),(t.flags&128)===0&&(t.memoizedState=null),t.flags|=4;Ae(t),e=!1}else l=Ki(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=l),e=!0;if(!e)return t.flags&256?(yt(t),t):(yt(t),null);if((t.flags&128)!==0)throw Error(d(558))}return Ae(t),null;case 13:if(a=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(n=ha(t),a!==null&&a.dehydrated!==null){if(e===null){if(!n)throw Error(d(318));if(n=t.memoizedState,n=n!==null?n.dehydrated:null,!n)throw Error(d(317));n[Je]=t}else Ll(),(t.flags&128)===0&&(t.memoizedState=null),t.flags|=4;Ae(t),n=!1}else n=Ki(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=n),n=!0;if(!n)return t.flags&256?(yt(t),t):(yt(t),null)}return yt(t),(t.flags&128)!==0?(t.lanes=l,t):(l=a!==null,e=e!==null&&e.memoizedState!==null,l&&(a=t.child,n=null,a.alternate!==null&&a.alternate.memoizedState!==null&&a.alternate.memoizedState.cachePool!==null&&(n=a.alternate.memoizedState.cachePool.pool),u=null,a.memoizedState!==null&&a.memoizedState.cachePool!==null&&(u=a.memoizedState.cachePool.pool),u!==n&&(a.flags|=2048)),l!==e&&l&&(t.child.flags|=8192),zu(t,t.updateQueue),Ae(t),null);case 4:return At(),e===null&&us(t.stateNode.containerInfo),Ae(t),null;case 10:return Kt(t.type),Ae(t),null;case 19:if(ne(Ue),a=t.memoizedState,a===null)return Ae(t),null;if(n=(t.flags&128)!==0,u=a.rendering,u===null)if(n)hn(a,!1);else{if(Oe!==0||e!==null&&(e.flags&128)!==0)for(e=t.child;e!==null;){if(u=fu(e),u!==null){for(t.flags|=128,hn(a,!1),e=u.updateQueue,t.updateQueue=e,zu(t,e),t.subtreeFlags=0,e=l,l=t.child;l!==null;)Hr(l,e),l=l.sibling;return M(Ue,Ue.current&1|2),fe&&Zt(t,a.treeForkCount),t.child}e=e.sibling}a.tail!==null&&dt()>Au&&(t.flags|=128,n=!0,hn(a,!1),t.lanes=4194304)}else{if(!n)if(e=fu(u),e!==null){if(t.flags|=128,n=!0,e=e.updateQueue,t.updateQueue=e,zu(t,e),hn(a,!0),a.tail===null&&a.tailMode==="hidden"&&!u.alternate&&!fe)return Ae(t),null}else 2*dt()-a.renderingStartTime>Au&&l!==536870912&&(t.flags|=128,n=!0,hn(a,!1),t.lanes=4194304);a.isBackwards?(u.sibling=t.child,t.child=u):(e=a.last,e!==null?e.sibling=u:t.child=u,a.last=u)}return a.tail!==null?(e=a.tail,a.rendering=e,a.tail=e.sibling,a.renderingStartTime=dt(),e.sibling=null,l=Ue.current,M(Ue,n?l&1|2:l&1),fe&&Zt(t,a.treeForkCount),e):(Ae(t),null);case 22:case 23:return yt(t),ic(),a=t.memoizedState!==null,e!==null?e.memoizedState!==null!==a&&(t.flags|=8192):a&&(t.flags|=8192),a?(l&536870912)!==0&&(t.flags&128)===0&&(Ae(t),t.subtreeFlags&6&&(t.flags|=8192)):Ae(t),l=t.updateQueue,l!==null&&zu(t,l.retryQueue),l=null,e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(l=e.memoizedState.cachePool.pool),a=null,t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(a=t.memoizedState.cachePool.pool),a!==l&&(t.flags|=2048),e!==null&&ne(Ql),null;case 24:return l=null,e!==null&&(l=e.memoizedState.cache),t.memoizedState.cache!==l&&(t.flags|=2048),Kt(Be),Ae(t),null;case 25:return null;case 30:return null}throw Error(d(156,t.tag))}function Eg(e,t){switch(Zi(t),t.tag){case 1:return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return Kt(Be),At(),e=t.flags,(e&65536)!==0&&(e&128)===0?(t.flags=e&-65537|128,t):null;case 26:case 27:case 5:return Ee(t),null;case 31:if(t.memoizedState!==null){if(yt(t),t.alternate===null)throw Error(d(340));Ll()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 13:if(yt(t),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(d(340));Ll()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return ne(Ue),null;case 4:return At(),null;case 10:return Kt(t.type),null;case 22:case 23:return yt(t),ic(),e!==null&&ne(Ql),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 24:return Kt(Be),null;case 25:return null;default:return null}}function ro(e,t){switch(Zi(t),t.tag){case 3:Kt(Be),At();break;case 26:case 27:case 5:Ee(t);break;case 4:At();break;case 31:t.memoizedState!==null&&yt(t);break;case 13:yt(t);break;case 19:ne(Ue);break;case 10:Kt(t.type);break;case 22:case 23:yt(t),ic(),e!==null&&ne(Ql);break;case 24:Kt(Be)}}function yn(e,t){try{var l=t.updateQueue,a=l!==null?l.lastEffect:null;if(a!==null){var n=a.next;l=n;do{if((l.tag&e)===e){a=void 0;var u=l.create,c=l.inst;a=u(),c.destroy=a}l=l.next}while(l!==n)}}catch(s){je(t,t.return,s)}}function bl(e,t,l){try{var a=t.updateQueue,n=a!==null?a.lastEffect:null;if(n!==null){var u=n.next;a=u;do{if((a.tag&e)===e){var c=a.inst,s=c.destroy;if(s!==void 0){c.destroy=void 0,n=t;var o=l,h=s;try{h()}catch(S){je(n,o,S)}}}a=a.next}while(a!==u)}}catch(S){je(t,t.return,S)}}function oo(e){var t=e.updateQueue;if(t!==null){var l=e.stateNode;try{ed(t,l)}catch(a){je(e,e.return,a)}}}function fo(e,t,l){l.props=Jl(e.type,e.memoizedProps),l.state=e.memoizedState;try{l.componentWillUnmount()}catch(a){je(e,t,a)}}function xn(e,t){try{var l=e.ref;if(l!==null){switch(e.tag){case 26:case 27:case 5:var a=e.stateNode;break;case 30:a=e.stateNode;break;default:a=e.stateNode}typeof l=="function"?e.refCleanup=l(a):l.current=a}}catch(n){je(e,t,n)}}function Ht(e,t){var l=e.ref,a=e.refCleanup;if(l!==null)if(typeof a=="function")try{a()}catch(n){je(e,t,n)}finally{e.refCleanup=null,e=e.alternate,e!=null&&(e.refCleanup=null)}else if(typeof l=="function")try{l(null)}catch(n){je(e,t,n)}else l.current=null}function go(e){var t=e.type,l=e.memoizedProps,a=e.stateNode;try{e:switch(t){case"button":case"input":case"select":case"textarea":l.autoFocus&&a.focus();break e;case"img":l.src?a.src=l.src:l.srcSet&&(a.srcset=l.srcSet)}}catch(n){je(e,e.return,n)}}function qc(e,t,l){try{var a=e.stateNode;$g(a,e.type,l,t),a[at]=t}catch(n){je(e,e.return,n)}}function mo(e){return e.tag===5||e.tag===3||e.tag===26||e.tag===27&&zl(e.type)||e.tag===4}function Yc(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||mo(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.tag===27&&zl(e.type)||e.flags&2||e.child===null||e.tag===4)continue e;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function Lc(e,t,l){var a=e.tag;if(a===5||a===6)e=e.stateNode,t?(l.nodeType===9?l.body:l.nodeName==="HTML"?l.ownerDocument.body:l).insertBefore(e,t):(t=l.nodeType===9?l.body:l.nodeName==="HTML"?l.ownerDocument.body:l,t.appendChild(e),l=l._reactRootContainer,l!=null||t.onclick!==null||(t.onclick=Gt));else if(a!==4&&(a===27&&zl(e.type)&&(l=e.stateNode,t=null),e=e.child,e!==null))for(Lc(e,t,l),e=e.sibling;e!==null;)Lc(e,t,l),e=e.sibling}function Tu(e,t,l){var a=e.tag;if(a===5||a===6)e=e.stateNode,t?l.insertBefore(e,t):l.appendChild(e);else if(a!==4&&(a===27&&zl(e.type)&&(l=e.stateNode),e=e.child,e!==null))for(Tu(e,t,l),e=e.sibling;e!==null;)Tu(e,t,l),e=e.sibling}function ho(e){var t=e.stateNode,l=e.memoizedProps;try{for(var a=e.type,n=t.attributes;n.length;)t.removeAttributeNode(n[0]);Ie(t,a,l),t[Je]=e,t[at]=l}catch(u){je(e,e.return,u)}}var It=!1,Le=!1,Rc=!1,yo=typeof WeakSet=="function"?WeakSet:Set,Ze=null;function Cg(e,t){if(e=e.containerInfo,ss=Ku,e=Mr(e),Oi(e)){if("selectionStart"in e)var l={start:e.selectionStart,end:e.selectionEnd};else e:{l=(l=e.ownerDocument)&&l.defaultView||window;var a=l.getSelection&&l.getSelection();if(a&&a.rangeCount!==0){l=a.anchorNode;var n=a.anchorOffset,u=a.focusNode;a=a.focusOffset;try{l.nodeType,u.nodeType}catch{l=null;break e}var c=0,s=-1,o=-1,h=0,S=0,k=e,y=null;t:for(;;){for(var b;k!==l||n!==0&&k.nodeType!==3||(s=c+n),k!==u||a!==0&&k.nodeType!==3||(o=c+a),k.nodeType===3&&(c+=k.nodeValue.length),(b=k.firstChild)!==null;)y=k,k=b;for(;;){if(k===e)break t;if(y===l&&++h===n&&(s=c),y===u&&++S===a&&(o=c),(b=k.nextSibling)!==null)break;k=y,y=k.parentNode}k=b}l=s===-1||o===-1?null:{start:s,end:o}}else l=null}l=l||{start:0,end:0}}else l=null;for(rs={focusedElem:e,selectionRange:l},Ku=!1,Ze=t;Ze!==null;)if(t=Ze,e=t.child,(t.subtreeFlags&1028)!==0&&e!==null)e.return=t,Ze=e;else for(;Ze!==null;){switch(t=Ze,u=t.alternate,e=t.flags,t.tag){case 0:if((e&4)!==0&&(e=t.updateQueue,e=e!==null?e.events:null,e!==null))for(l=0;l title"))),Ie(u,a,l),u[Je]=e,Xe(u),a=u;break e;case"link":var c=j0("link","href",n).get(a+(l.href||""));if(c){for(var s=0;sTe&&(c=Te,Te=$,$=c);var g=zr(s,$),f=zr(s,Te);if(g&&f&&(b.rangeCount!==1||b.anchorNode!==g.node||b.anchorOffset!==g.offset||b.focusNode!==f.node||b.focusOffset!==f.offset)){var m=k.createRange();m.setStart(g.node,g.offset),b.removeAllRanges(),$>Te?(b.addRange(m),b.extend(f.node,f.offset)):(m.setEnd(f.node,f.offset),b.addRange(m))}}}}for(k=[],b=s;b=b.parentNode;)b.nodeType===1&&k.push({element:b,left:b.scrollLeft,top:b.scrollTop});for(typeof s.focus=="function"&&s.focus(),s=0;sl?32:l,p.T=null,l=Jc,Jc=null;var u=jl,c=al;if(Ge=0,Ca=jl=null,al=0,(xe&6)!==0)throw Error(d(331));var s=xe;if(xe|=4,Mo(u.current),ko(u,u.current,c,l),xe=s,Nn(0,!1),ot&&typeof ot.onPostCommitFiberRoot=="function")try{ot.onPostCommitFiberRoot(La,u)}catch{}return!0}finally{O.p=n,p.T=a,Zo(e,t)}}function Ko(e,t,l){t=Nt(l,t),t=Mc(e.stateNode,t,2),e=hl(e,t,2),e!==null&&(Ga(e,2),Bt(e))}function je(e,t,l){if(e.tag===3)Ko(e,e,l);else for(;t!==null;){if(t.tag===3){Ko(t,e,l);break}else if(t.tag===1){var a=t.stateNode;if(typeof t.type.getDerivedStateFromError=="function"||typeof a.componentDidCatch=="function"&&(Sl===null||!Sl.has(a))){e=Nt(l,e),l=Kd(2),a=hl(t,l,2),a!==null&&(Jd(l,a,t,e),Ga(a,2),Bt(a));break}}t=t.return}}function Ic(e,t,l){var a=e.pingCache;if(a===null){a=e.pingCache=new _g;var n=new Set;a.set(t,n)}else n=a.get(t),n===void 0&&(n=new Set,a.set(t,n));n.has(l)||(Xc=!0,n.add(l),e=Bg.bind(null,e,t,l),t.then(e,e))}function Bg(e,t,l){var a=e.pingCache;a!==null&&a.delete(t),e.pingedLanes|=e.suspendedLanes&l,e.warmLanes&=~l,Me===e&&(se&l)===l&&(Oe===4||Oe===3&&(se&62914560)===se&&300>dt()-Cu?(xe&2)===0&&Aa(e,0):Zc|=l,Ea===se&&(Ea=0)),Bt(e)}function Jo(e,t){t===0&&(t=Rs()),e=ql(e,t),e!==null&&(Ga(e,t),Bt(e))}function qg(e){var t=e.memoizedState,l=0;t!==null&&(l=t.retryLane),Jo(e,l)}function Yg(e,t){var l=0;switch(e.tag){case 31:case 13:var a=e.stateNode,n=e.memoizedState;n!==null&&(l=n.retryLane);break;case 19:a=e.stateNode;break;case 22:a=e.stateNode._retryCache;break;default:throw Error(d(314))}a!==null&&a.delete(t),Jo(e,l)}function Lg(e,t){return oi(e,t)}var Hu=null,_a=null,Pc=!1,Bu=!1,es=!1,kl=0;function Bt(e){e!==_a&&e.next===null&&(_a===null?Hu=_a=e:_a=_a.next=e),Bu=!0,Pc||(Pc=!0,Gg())}function Nn(e,t){if(!es&&Bu){es=!0;do for(var l=!1,a=Hu;a!==null;){if(e!==0){var n=a.pendingLanes;if(n===0)var u=0;else{var c=a.suspendedLanes,s=a.pingedLanes;u=(1<<31-ft(42|e)+1)-1,u&=n&~(c&~s),u=u&201326741?u&201326741|1:u?u|2:0}u!==0&&(l=!0,Io(a,u))}else u=se,u=Rn(a,a===Me?u:0,a.cancelPendingCommit!==null||a.timeoutHandle!==-1),(u&3)===0||Ra(a,u)||(l=!0,Io(a,u));a=a.next}while(l);es=!1}}function Rg(){Wo()}function Wo(){Bu=Pc=!1;var e=0;kl!==0&&Ig()&&(e=kl);for(var t=dt(),l=null,a=Hu;a!==null;){var n=a.next,u=$o(a,t);u===0?(a.next=null,l===null?Hu=n:l.next=n,n===null&&(_a=l)):(l=a,(e!==0||(u&3)!==0)&&(Bu=!0)),a=n}Ge!==0&&Ge!==5||Nn(e),kl!==0&&(kl=0)}function $o(e,t){for(var l=e.suspendedLanes,a=e.pingedLanes,n=e.expirationTimes,u=e.pendingLanes&-62914561;0s)break;var S=o.transferSize,k=o.initiatorType;S&&i0(k)&&(o=o.responseEnd,c+=S*(o"u"?null:document;function b0(e,t,l){var a=wa;if(a&&typeof t=="string"&&t){var n=St(t);n='link[rel="'+e+'"][href="'+n+'"]',typeof l=="string"&&(n+='[crossorigin="'+l+'"]'),x0.has(n)||(x0.add(n),e={rel:e,crossOrigin:l,href:t},a.querySelector(n)===null&&(t=a.createElement("link"),Ie(t,"link",e),Xe(t),a.head.appendChild(t)))}}function cm(e){nl.D(e),b0("dns-prefetch",e,null)}function sm(e,t){nl.C(e,t),b0("preconnect",e,t)}function rm(e,t,l){nl.L(e,t,l);var a=wa;if(a&&e&&t){var n='link[rel="preload"][as="'+St(t)+'"]';t==="image"&&l&&l.imageSrcSet?(n+='[imagesrcset="'+St(l.imageSrcSet)+'"]',typeof l.imageSizes=="string"&&(n+='[imagesizes="'+St(l.imageSizes)+'"]')):n+='[href="'+St(e)+'"]';var u=n;switch(t){case"style":u=Oa(e);break;case"script":u=Ua(e)}Ct.has(u)||(e=D({rel:"preload",href:t==="image"&&l&&l.imageSrcSet?void 0:e,as:t},l),Ct.set(u,e),a.querySelector(n)!==null||t==="style"&&a.querySelector(Mn(u))||t==="script"&&a.querySelector(En(u))||(t=a.createElement("link"),Ie(t,"link",e),Xe(t),a.head.appendChild(t)))}}function dm(e,t){nl.m(e,t);var l=wa;if(l&&e){var a=t&&typeof t.as=="string"?t.as:"script",n='link[rel="modulepreload"][as="'+St(a)+'"][href="'+St(e)+'"]',u=n;switch(a){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":u=Ua(e)}if(!Ct.has(u)&&(e=D({rel:"modulepreload",href:e},t),Ct.set(u,e),l.querySelector(n)===null)){switch(a){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(l.querySelector(En(u)))return}a=l.createElement("link"),Ie(a,"link",e),Xe(a),l.head.appendChild(a)}}}function om(e,t,l){nl.S(e,t,l);var a=wa;if(a&&e){var n=la(a).hoistableStyles,u=Oa(e);t=t||"default";var c=n.get(u);if(!c){var s={loading:0,preload:null};if(c=a.querySelector(Mn(u)))s.loading=5;else{e=D({rel:"stylesheet",href:e,"data-precedence":t},l),(l=Ct.get(u))&&ys(e,l);var o=c=a.createElement("link");Xe(o),Ie(o,"link",e),o._p=new Promise(function(h,S){o.onload=h,o.onerror=S}),o.addEventListener("load",function(){s.loading|=1}),o.addEventListener("error",function(){s.loading|=2}),s.loading|=4,Gu(c,t,a)}c={type:"stylesheet",instance:c,count:1,state:s},n.set(u,c)}}}function fm(e,t){nl.X(e,t);var l=wa;if(l&&e){var a=la(l).hoistableScripts,n=Ua(e),u=a.get(n);u||(u=l.querySelector(En(n)),u||(e=D({src:e,async:!0},t),(t=Ct.get(n))&&xs(e,t),u=l.createElement("script"),Xe(u),Ie(u,"link",e),l.head.appendChild(u)),u={type:"script",instance:u,count:1,state:null},a.set(n,u))}}function gm(e,t){nl.M(e,t);var l=wa;if(l&&e){var a=la(l).hoistableScripts,n=Ua(e),u=a.get(n);u||(u=l.querySelector(En(n)),u||(e=D({src:e,async:!0,type:"module"},t),(t=Ct.get(n))&&xs(e,t),u=l.createElement("script"),Xe(u),Ie(u,"link",e),l.head.appendChild(u)),u={type:"script",instance:u,count:1,state:null},a.set(n,u))}}function v0(e,t,l,a){var n=(n=Ke.current)?Ru(n):null;if(!n)throw Error(d(446));switch(e){case"meta":case"title":return null;case"style":return typeof l.precedence=="string"&&typeof l.href=="string"?(t=Oa(l.href),l=la(n).hoistableStyles,a=l.get(t),a||(a={type:"style",instance:null,count:0,state:null},l.set(t,a)),a):{type:"void",instance:null,count:0,state:null};case"link":if(l.rel==="stylesheet"&&typeof l.href=="string"&&typeof l.precedence=="string"){e=Oa(l.href);var u=la(n).hoistableStyles,c=u.get(e);if(c||(n=n.ownerDocument||n,c={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},u.set(e,c),(u=n.querySelector(Mn(e)))&&!u._p&&(c.instance=u,c.state.loading=5),Ct.has(e)||(l={rel:"preload",as:"style",href:l.href,crossOrigin:l.crossOrigin,integrity:l.integrity,media:l.media,hrefLang:l.hrefLang,referrerPolicy:l.referrerPolicy},Ct.set(e,l),u||mm(n,e,l,c.state))),t&&a===null)throw Error(d(528,""));return c}if(t&&a!==null)throw Error(d(529,""));return null;case"script":return t=l.async,l=l.src,typeof l=="string"&&t&&typeof t!="function"&&typeof t!="symbol"?(t=Ua(l),l=la(n).hoistableScripts,a=l.get(t),a||(a={type:"script",instance:null,count:0,state:null},l.set(t,a)),a):{type:"void",instance:null,count:0,state:null};default:throw Error(d(444,e))}}function Oa(e){return'href="'+St(e)+'"'}function Mn(e){return'link[rel="stylesheet"]['+e+"]"}function p0(e){return D({},e,{"data-precedence":e.precedence,precedence:null})}function mm(e,t,l,a){e.querySelector('link[rel="preload"][as="style"]['+t+"]")?a.loading=1:(t=e.createElement("link"),a.preload=t,t.addEventListener("load",function(){return a.loading|=1}),t.addEventListener("error",function(){return a.loading|=2}),Ie(t,"link",l),Xe(t),e.head.appendChild(t))}function Ua(e){return'[src="'+St(e)+'"]'}function En(e){return"script[async]"+e}function S0(e,t,l){if(t.count++,t.instance===null)switch(t.type){case"style":var a=e.querySelector('style[data-href~="'+St(l.href)+'"]');if(a)return t.instance=a,Xe(a),a;var n=D({},l,{"data-href":l.href,"data-precedence":l.precedence,href:null,precedence:null});return a=(e.ownerDocument||e).createElement("style"),Xe(a),Ie(a,"style",n),Gu(a,l.precedence,e),t.instance=a;case"stylesheet":n=Oa(l.href);var u=e.querySelector(Mn(n));if(u)return t.state.loading|=4,t.instance=u,Xe(u),u;a=p0(l),(n=Ct.get(n))&&ys(a,n),u=(e.ownerDocument||e).createElement("link"),Xe(u);var c=u;return c._p=new Promise(function(s,o){c.onload=s,c.onerror=o}),Ie(u,"link",a),t.state.loading|=4,Gu(u,l.precedence,e),t.instance=u;case"script":return u=Ua(l.src),(n=e.querySelector(En(u)))?(t.instance=n,Xe(n),n):(a=l,(n=Ct.get(u))&&(a=D({},l),xs(a,n)),e=e.ownerDocument||e,n=e.createElement("script"),Xe(n),Ie(n,"link",a),e.head.appendChild(n),t.instance=n);case"void":return null;default:throw Error(d(443,t.type))}else t.type==="stylesheet"&&(t.state.loading&4)===0&&(a=t.instance,t.state.loading|=4,Gu(a,l.precedence,e));return t.instance}function Gu(e,t,l){for(var a=l.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),n=a.length?a[a.length-1]:null,u=n,c=0;c title"):null)}function hm(e,t,l){if(l===1||t.itemProp!=null)return!1;switch(e){case"meta":case"title":return!0;case"style":if(typeof t.precedence!="string"||typeof t.href!="string"||t.href==="")break;return!0;case"link":if(typeof t.rel!="string"||typeof t.href!="string"||t.href===""||t.onLoad||t.onError)break;switch(t.rel){case"stylesheet":return e=t.disabled,typeof t.precedence=="string"&&e==null;default:return!0}case"script":if(t.async&&typeof t.async!="function"&&typeof t.async!="symbol"&&!t.onLoad&&!t.onError&&t.src&&typeof t.src=="string")return!0}return!1}function k0(e){return!(e.type==="stylesheet"&&(e.state.loading&3)===0)}function ym(e,t,l,a){if(l.type==="stylesheet"&&(typeof a.media!="string"||matchMedia(a.media).matches!==!1)&&(l.state.loading&4)===0){if(l.instance===null){var n=Oa(a.href),u=t.querySelector(Mn(n));if(u){t=u._p,t!==null&&typeof t=="object"&&typeof t.then=="function"&&(e.count++,e=Xu.bind(e),t.then(e,e)),l.state.loading|=4,l.instance=u,Xe(u);return}u=t.ownerDocument||t,a=p0(a),(n=Ct.get(n))&&ys(a,n),u=u.createElement("link"),Xe(u);var c=u;c._p=new Promise(function(s,o){c.onload=s,c.onerror=o}),Ie(u,"link",a),l.instance=u}e.stylesheets===null&&(e.stylesheets=new Map),e.stylesheets.set(l,t),(t=l.state.preload)&&(l.state.loading&3)===0&&(e.count++,l=Xu.bind(e),t.addEventListener("load",l),t.addEventListener("error",l))}}var bs=0;function xm(e,t){return e.stylesheets&&e.count===0&&Vu(e,e.stylesheets),0bs?50:800)+t);return e.unsuspend=l,function(){e.unsuspend=null,clearTimeout(a),clearTimeout(n)}}:null}function Xu(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)Vu(this,this.stylesheets);else if(this.unsuspend){var e=this.unsuspend;this.unsuspend=null,e()}}}var Zu=null;function Vu(e,t){e.stylesheets=null,e.unsuspend!==null&&(e.count++,Zu=new Map,t.forEach(bm,e),Zu=null,Xu.call(e))}function bm(e,t){if(!(t.state.loading&4)){var l=Zu.get(e);if(l)var a=l.get(null);else{l=new Map,Zu.set(e,l);for(var n=e.querySelectorAll("link[data-precedence],style[data-precedence]"),u=0;u"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(r)}catch(x){console.error(x)}}return r(),Ts.exports=qm(),Ts.exports}var Lm=Ym();const X0="".replace(/\/$/,"");let Hn=localStorage.getItem("access_token"),Fl=localStorage.getItem("refresh_token"),ti=null;function Cs(r){return X0?`${X0}${r.startsWith("/")?r:`/${r}`}`:r}function As(r,x){Hn=r,Fl=x,localStorage.setItem("access_token",r),localStorage.setItem("refresh_token",x)}function Ds(){Hn=null,Fl=null,localStorage.removeItem("access_token"),localStorage.removeItem("refresh_token")}function Rm(){return Fl}async function Gm(){if(!Fl)throw new Error("No refresh token");const r=await fetch(Cs("/auth/refresh"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({refresh_token:Fl})});if(!r.ok)throw Ds(),window.dispatchEvent(new CustomEvent("auth:logout")),new Error("Refresh failed");const x=await r.json();As(x.access_token,x.refresh_token)}async function F(r,x={}){var T;const w={...x.headers};Hn&&(w.Authorization=`Bearer ${Hn}`),x.body instanceof FormData||(w["Content-Type"]="application/json");let d=await fetch(Cs(r),{...x,headers:w});if(d.status===401&&Fl&&(ti||(ti=Gm().finally(()=>{ti=null})),await ti,w.Authorization=`Bearer ${Hn}`,d=await fetch(Cs(r),{...x,headers:w})),!d.ok){const C=await d.json().catch(()=>({}));throw{status:d.status,...C}}return(T=d.headers.get("content-type"))!=null&&T.includes("text/calendar")?await d.text():d.json()}const de={register:(r,x,w)=>F("/auth/register",{method:"POST",body:JSON.stringify({email:r,password:x,timezone:w})}),login:(r,x)=>F("/auth/login",{method:"POST",body:JSON.stringify({email:r,password:x})}),logout:()=>F("/auth/logout",{method:"POST",body:JSON.stringify({refresh_token:Fl})}),me:()=>F("/auth/me"),updateMe:r=>F("/users/me",{method:"PUT",body:JSON.stringify(r)}),deleteMe:()=>F("/users/me",{method:"DELETE"}),listApiKeys:()=>F("/api-keys"),createApiKey:r=>F("/api-keys",{method:"POST",body:JSON.stringify(r)}),revokeApiKey:r=>F(`/api-keys/${r}`,{method:"DELETE"}),listCalendars:()=>F("/calendars?limit=100"),createCalendar:r=>F("/calendars",{method:"POST",body:JSON.stringify(r)}),getCalendar:r=>F(`/calendars/${r}`),updateCalendar:(r,x)=>F(`/calendars/${r}`,{method:"PUT",body:JSON.stringify(x)}),deleteCalendar:r=>F(`/calendars/${r}`,{method:"DELETE"}),shareCalendar:(r,x)=>F(`/calendars/${r}/share`,{method:"POST",body:JSON.stringify(x)}),listMembers:r=>F(`/calendars/${r}/members`),removeMember:(r,x)=>F(`/calendars/${r}/members/${x}`,{method:"DELETE"}),addCalendarFromUrl:r=>F("/calendars/add-from-url",{method:"POST",body:JSON.stringify(r)}),importCalendarUrl:r=>F("/calendars/import-url",{method:"POST",body:JSON.stringify(r)}),listSubscriptions:r=>F(`/calendars/${r}/subscriptions`),addSubscription:(r,x)=>F(`/calendars/${r}/subscriptions`,{method:"POST",body:JSON.stringify(x)}),deleteSubscription:(r,x)=>F(`/calendars/${r}/subscriptions/${x}`,{method:"DELETE"}),syncSubscription:(r,x)=>F(`/calendars/${r}/subscriptions/${x}/sync`,{method:"POST"}),listEvents:r=>{const x=new URLSearchParams({start:r.start,end:r.end});return r.calendar_id&&x.set("calendar_id",r.calendar_id),r.search&&x.set("search",r.search),x.set("limit","500"),F(`/events?${x}`)},createEvent:r=>F("/events",{method:"POST",body:JSON.stringify(r)}),getEvent:r=>F(`/events/${r}`),updateEvent:(r,x)=>F(`/events/${r}`,{method:"PUT",body:JSON.stringify(x)}),deleteEvent:r=>F(`/events/${r}`,{method:"DELETE"}),listContacts:r=>{const x=new URLSearchParams({limit:"200"});return r&&x.set("search",r),F(`/contacts?${x}`)},createContact:r=>F("/contacts",{method:"POST",body:JSON.stringify(r)}),getContact:r=>F(`/contacts/${r}`),updateContact:(r,x)=>F(`/contacts/${r}`,{method:"PUT",body:JSON.stringify(x)}),deleteContact:r=>F(`/contacts/${r}`,{method:"DELETE"}),listTasks:r=>{const x=new URLSearchParams({limit:"100"});return r!=null&&r.status&&x.set("status",r.status),r!=null&&r.priority&&x.set("priority",r.priority),r!=null&&r.project_id&&x.set("project_id",r.project_id),r!=null&&r.due_from&&x.set("due_from",r.due_from),r!=null&&r.due_to&&x.set("due_to",r.due_to),r!=null&&r.limit&&x.set("limit",String(r.limit)),r!=null&&r.cursor&&x.set("cursor",r.cursor),F(`/tasks?${x}`)},createTask:r=>F("/tasks",{method:"POST",body:JSON.stringify(r)}),getTask:r=>F(`/tasks/${r}`),updateTask:(r,x)=>F(`/tasks/${r}`,{method:"PUT",body:JSON.stringify(x)}),deleteTask:(r,x)=>F(`/tasks/${r}${x?"?permanent=true":""}`,{method:"DELETE"}),markTaskComplete:r=>F(`/tasks/${r}/complete`,{method:"POST"}),markTaskUncomplete:(r,x)=>F(`/tasks/${r}/uncomplete`,{method:"POST",body:JSON.stringify(x?{status:x}:{})}),listTaskSubtasks:r=>F(`/tasks/${r}/subtasks`),listProjects:()=>F("/projects"),createProject:r=>F("/projects",{method:"POST",body:JSON.stringify(r)}),getProject:r=>F(`/projects/${r}`),updateProject:(r,x)=>F(`/projects/${r}`,{method:"PUT",body:JSON.stringify(x)}),deleteProject:r=>F(`/projects/${r}`,{method:"DELETE"}),listTags:()=>F("/tags"),createTag:r=>F("/tags",{method:"POST",body:JSON.stringify(r)})},tf=v.createContext(null);function Qm({children:r}){const[x,w]=v.useState(null),[d,T]=v.useState(!0);v.useEffect(()=>{localStorage.getItem("access_token")?de.me().then(D=>w(D.user)).catch(()=>{Ds(),w(null)}).finally(()=>T(!1)):T(!1);const R=()=>{w(null)};return window.addEventListener("auth:logout",R),()=>window.removeEventListener("auth:logout",R)},[]);const C=v.useCallback(async(B,R)=>{const D=await de.login(B,R);As(D.access_token,D.refresh_token),w(D.user)},[]),H=v.useCallback(async(B,R,D)=>{const j=await de.register(B,R,D);As(j.access_token,j.refresh_token),w(j.user)},[]),q=v.useCallback(async()=>{try{Rm()&&await de.logout()}finally{Ds(),w(null)}},[]),Y=v.useCallback(async()=>{const B=await de.me();w(B.user)},[]);return i.jsx(tf.Provider,{value:{user:x,loading:d,login:C,register:H,logout:q,refreshUser:Y},children:r})}function Ya(){const r=v.useContext(tf);if(!r)throw new Error("useAuth must be used within AuthProvider");return r}const lf=v.createContext(null);function Xm(){const r=localStorage.getItem("theme");return r||(window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light")}function Zm({children:r}){const[x,w]=v.useState(Xm);v.useEffect(()=>{document.documentElement.classList.toggle("dark",x==="dark"),localStorage.setItem("theme",x)},[x]);const d=v.useCallback(()=>{w(T=>T==="light"?"dark":"light")},[]);return i.jsx(lf.Provider,{value:{theme:x,toggle:d},children:r})}function ci(){const r=v.useContext(lf);if(!r)throw new Error("useTheme must be used within ThemeProvider");return r}class Vm extends v.Component{constructor(x){super(x),this.state={hasError:!1}}static getDerivedStateFromError(x){return{hasError:!0,error:x}}render(){return this.state.hasError?this.props.fallback?this.props.fallback:i.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gray-50 dark:bg-gray-900 p-4",children:i.jsxs("div",{className:"max-w-md w-full text-center",children:[i.jsx("div",{className:"w-16 h-16 mx-auto mb-4 rounded-full bg-red-100 dark:bg-red-900/30 flex items-center justify-center",children:i.jsx("svg",{className:"w-8 h-8 text-red-600 dark:text-red-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"})})}),i.jsx("h1",{className:"text-xl font-semibold text-gray-900 dark:text-white mb-2",children:"Something went wrong"}),i.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400 mb-6",children:"An unexpected error occurred. Please refresh the page to try again."}),i.jsx("button",{onClick:()=>window.location.reload(),className:"px-4 py-2 bg-blue-600 hover:bg-blue-700 text-white text-sm font-medium rounded-lg transition-colors",children:"Refresh page"})]})}):this.props.children}}function Km(){const{login:r}=Ya(),{theme:x,toggle:w}=ci(),d=_s(),[T,C]=v.useState(""),[H,q]=v.useState(""),[Y,B]=v.useState(""),[R,D]=v.useState(!1),j=async U=>{U.preventDefault(),B(""),D(!0);try{await r(T,H),d("/")}catch(E){B(E.error||"Invalid credentials")}finally{D(!1)}};return i.jsxs("div",{className:"min-h-screen flex items-center justify-center bg-gray-50 dark:bg-gray-900 px-4 transition-colors",children:[i.jsx("div",{className:"absolute top-4 right-4",children:i.jsx("button",{onClick:w,className:"p-2 rounded-xl bg-white dark:bg-gray-800 shadow-sm border border-gray-200 dark:border-gray-700 text-gray-600 dark:text-gray-400 hover:bg-gray-50 dark:hover:bg-gray-700 transition-colors",children:x==="dark"?i.jsx("svg",{className:"w-5 h-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 3v1m0 16v1m9-9h-1M4 12H3m15.364 6.364l-.707-.707M6.343 6.343l-.707-.707m12.728 0l-.707.707M6.343 17.657l-.707.707M16 12a4 4 0 11-8 0 4 4 0 018 0z"})}):i.jsx("svg",{className:"w-5 h-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M20.354 15.354A9 9 0 018.646 3.646 9.003 9.003 0 0012 21a9.003 9.003 0 008.354-5.646z"})})})}),i.jsxs("div",{className:"w-full max-w-sm",children:[i.jsxs("div",{className:"text-center mb-8",children:[i.jsx("div",{className:"inline-flex items-center justify-center w-14 h-14 bg-blue-600 rounded-2xl mb-4 shadow-lg shadow-blue-600/20",children:i.jsx("svg",{className:"w-8 h-8 text-white",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M8 7V3m8 4V3m-9 8h10M5 21h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z"})})}),i.jsx("h1",{className:"text-2xl font-bold text-gray-900 dark:text-white",children:"Welcome back"}),i.jsx("p",{className:"text-gray-500 dark:text-gray-400 mt-1 text-sm",children:"Sign in to your calendar"})]}),i.jsx("div",{className:"bg-white dark:bg-gray-800 rounded-2xl shadow-xl shadow-gray-200/50 dark:shadow-black/20 border border-gray-100 dark:border-gray-700 p-6",children:i.jsxs("form",{onSubmit:j,className:"space-y-4",children:[Y&&i.jsx("div",{className:"text-sm text-red-600 dark:text-red-400 bg-red-50 dark:bg-red-900/20 px-3 py-2.5 rounded-xl",children:Y}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1.5",children:"Email"}),i.jsx("input",{type:"email",value:T,onChange:U=>C(U.target.value),className:"w-full px-3.5 py-2.5 rounded-xl border border-gray-200 dark:border-gray-600 bg-gray-50 dark:bg-gray-700/50 text-gray-900 dark:text-white focus:ring-2 focus:ring-blue-500 focus:border-transparent outline-none transition-all text-sm",placeholder:"you@example.com",required:!0,autoFocus:!0})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1.5",children:"Password"}),i.jsx("input",{type:"password",value:H,onChange:U=>q(U.target.value),className:"w-full px-3.5 py-2.5 rounded-xl border border-gray-200 dark:border-gray-600 bg-gray-50 dark:bg-gray-700/50 text-gray-900 dark:text-white focus:ring-2 focus:ring-blue-500 focus:border-transparent outline-none transition-all text-sm",placeholder:"Min. 10 characters",required:!0,minLength:10})]}),i.jsx("button",{type:"submit",disabled:R,className:"w-full py-2.5 bg-blue-600 hover:bg-blue-700 disabled:opacity-50 text-white rounded-xl font-medium transition-colors text-sm",children:R?"Signing in...":"Sign in"})]})}),i.jsxs("p",{className:"text-center mt-6 text-sm text-gray-500 dark:text-gray-400",children:["Don't have an account?"," ",i.jsx(J0,{to:"/register",className:"text-blue-600 dark:text-blue-400 hover:underline font-medium",children:"Create one"})]})]})]})}function Jm(){const{register:r}=Ya(),{theme:x,toggle:w}=ci(),d=_s(),[T,C]=v.useState(""),[H,q]=v.useState(""),[Y,B]=v.useState(""),[R,D]=v.useState(""),[j,U]=v.useState(!1),E=async z=>{if(z.preventDefault(),D(""),H!==Y){D("Passwords don't match");return}U(!0);try{const _=Intl.DateTimeFormat().resolvedOptions().timeZone;await r(T,H,_),d("/")}catch(_){D(_.error||"Registration failed")}finally{U(!1)}};return i.jsxs("div",{className:"min-h-screen flex items-center justify-center bg-gray-50 dark:bg-gray-900 px-4 transition-colors",children:[i.jsx("div",{className:"absolute top-4 right-4",children:i.jsx("button",{onClick:w,className:"p-2 rounded-xl bg-white dark:bg-gray-800 shadow-sm border border-gray-200 dark:border-gray-700 text-gray-600 dark:text-gray-400 hover:bg-gray-50 dark:hover:bg-gray-700 transition-colors",children:x==="dark"?i.jsx("svg",{className:"w-5 h-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 3v1m0 16v1m9-9h-1M4 12H3m15.364 6.364l-.707-.707M6.343 6.343l-.707-.707m12.728 0l-.707.707M6.343 17.657l-.707.707M16 12a4 4 0 11-8 0 4 4 0 018 0z"})}):i.jsx("svg",{className:"w-5 h-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M20.354 15.354A9 9 0 018.646 3.646 9.003 9.003 0 0012 21a9.003 9.003 0 008.354-5.646z"})})})}),i.jsxs("div",{className:"w-full max-w-sm",children:[i.jsxs("div",{className:"text-center mb-8",children:[i.jsx("div",{className:"inline-flex items-center justify-center w-14 h-14 bg-blue-600 rounded-2xl mb-4 shadow-lg shadow-blue-600/20",children:i.jsx("svg",{className:"w-8 h-8 text-white",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M8 7V3m8 4V3m-9 8h10M5 21h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z"})})}),i.jsx("h1",{className:"text-2xl font-bold text-gray-900 dark:text-white",children:"Create account"}),i.jsx("p",{className:"text-gray-500 dark:text-gray-400 mt-1 text-sm",children:"Get started with your calendar"})]}),i.jsx("div",{className:"bg-white dark:bg-gray-800 rounded-2xl shadow-xl shadow-gray-200/50 dark:shadow-black/20 border border-gray-100 dark:border-gray-700 p-6",children:i.jsxs("form",{onSubmit:E,className:"space-y-4",children:[R&&i.jsx("div",{className:"text-sm text-red-600 dark:text-red-400 bg-red-50 dark:bg-red-900/20 px-3 py-2.5 rounded-xl",children:R}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1.5",children:"Email"}),i.jsx("input",{type:"email",value:T,onChange:z=>C(z.target.value),className:"w-full px-3.5 py-2.5 rounded-xl border border-gray-200 dark:border-gray-600 bg-gray-50 dark:bg-gray-700/50 text-gray-900 dark:text-white focus:ring-2 focus:ring-blue-500 focus:border-transparent outline-none transition-all text-sm",placeholder:"you@example.com",required:!0,autoFocus:!0})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1.5",children:"Password"}),i.jsx("input",{type:"password",value:H,onChange:z=>q(z.target.value),className:"w-full px-3.5 py-2.5 rounded-xl border border-gray-200 dark:border-gray-600 bg-gray-50 dark:bg-gray-700/50 text-gray-900 dark:text-white focus:ring-2 focus:ring-blue-500 focus:border-transparent outline-none transition-all text-sm",placeholder:"Min. 10 characters",required:!0,minLength:10})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1.5",children:"Confirm password"}),i.jsx("input",{type:"password",value:Y,onChange:z=>B(z.target.value),className:"w-full px-3.5 py-2.5 rounded-xl border border-gray-200 dark:border-gray-600 bg-gray-50 dark:bg-gray-700/50 text-gray-900 dark:text-white focus:ring-2 focus:ring-blue-500 focus:border-transparent outline-none transition-all text-sm",placeholder:"Repeat your password",required:!0,minLength:10})]}),i.jsx("button",{type:"submit",disabled:j,className:"w-full py-2.5 bg-blue-600 hover:bg-blue-700 disabled:opacity-50 text-white rounded-xl font-medium transition-colors text-sm",children:j?"Creating account...":"Create account"})]})}),i.jsxs("p",{className:"text-center mt-6 text-sm text-gray-500 dark:text-gray-400",children:["Already have an account?"," ",i.jsx(J0,{to:"/login",className:"text-blue-600 dark:text-blue-400 hover:underline font-medium",children:"Sign in"})]})]})]})}function _l(r){return r.is_occurrence&&r.occurrence_start_time?r.occurrence_start_time:r.start_time}function ui(r){return r.is_occurrence&&r.occurrence_end_time?r.occurrence_end_time:r.end_time}function Wm({currentDate:r,events:x,calendars:w,visibleCalendarIds:d,onDateClick:T,onEventClick:C}){const H=Us(r),q=Hs(r),Y=qa(H),B=Un(q),R=W0({start:Y,end:B}),D=new Map(w.map(E=>[E.id,E.color])),j=x.filter(E=>d.has(E.calendar_id)),U=E=>j.filter(z=>{const _=tt(_l(z)),X=tt(ui(z));return Dl(_,E)||Dl(X,E)||_E});return i.jsxs("div",{className:"flex flex-col h-full",children:[i.jsx("div",{className:"grid grid-cols-7 border-b border-gray-200 dark:border-gray-700",children:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"].map(E=>i.jsx("div",{className:"py-2 text-center text-xs font-semibold text-gray-500 dark:text-gray-400 uppercase tracking-wide",children:E},E))}),i.jsx("div",{className:"grid grid-cols-7 flex-1 auto-rows-fr",children:R.map((E,z)=>{const _=$0(E,r),X=ii(E),I=U(E);return i.jsxs("div",{className:`min-h-[80px] border-b border-r border-gray-100 dark:border-gray-700/50 p-1 cursor-pointer transition-colors hover:bg-gray-50 dark:hover:bg-gray-800/50 ${z%7===0?"border-l":""} ${_?"":"bg-gray-50/50 dark:bg-gray-900/30"}`,onClick:()=>T(E),children:[i.jsx("div",{className:"flex justify-center mb-1",children:i.jsx("span",{className:`text-xs w-6 h-6 flex items-center justify-center rounded-full font-medium ${X?"bg-blue-600 text-white":""} ${!X&&_?"text-gray-700 dark:text-gray-300":""} ${!X&&!_?"text-gray-400 dark:text-gray-600":""}`,children:_e(E,"d")})}),i.jsxs("div",{className:"space-y-0.5 overflow-hidden",children:[I.slice(0,3).map(te=>i.jsxs("button",{onClick:J=>{J.stopPropagation(),C(te)},className:"w-full text-left text-[10px] leading-tight px-1.5 py-0.5 rounded truncate text-white font-medium transition-opacity hover:opacity-80",style:{backgroundColor:D.get(te.calendar_id)||"#3B82F6"},children:[!te.all_day&&i.jsxs("span",{className:"opacity-80",children:[_e(tt(_l(te)),"h:mm")," "]}),te.title]},te.id+E.toISOString())),I.length>3&&i.jsxs("div",{className:"text-[10px] text-gray-500 dark:text-gray-400 text-center font-medium",children:["+",I.length-3," more"]})]})]},E.toISOString())})})]})}const Z0=Array.from({length:24},(r,x)=>x),li=60;function $m({currentDate:r,events:x,calendars:w,visibleCalendarIds:d,onTimeClick:T,onEventClick:C}){const H=qa(r),q=Array.from({length:7},(z,_)=>F0(H,_)),Y=new Map(w.map(z=>[z.id,z.color])),B=x.filter(z=>d.has(z.calendar_id)),R=B.filter(z=>z.all_day),D=B.filter(z=>!z.all_day),j=z=>D.filter(_=>Dl(tt(_l(_)),z)),U=z=>R.filter(_=>{const X=tt(_l(_)),I=tt(ui(_));return Dl(X,z)||Dl(I,z)||Xz}),E=z=>{const _=tt(_l(z)),X=I0(_),I=ni(_,X),te=tt(ui(z)),J=Math.max(ni(te,_),15);return{top:`${I}px`,height:`${J}px`,minHeight:"20px"}};return i.jsxs("div",{className:"flex flex-col h-full overflow-hidden",children:[i.jsxs("div",{className:"flex border-b border-gray-200 dark:border-gray-700 flex-shrink-0",children:[i.jsx("div",{className:"w-16 flex-shrink-0"}),q.map(z=>{const _=ii(z);return i.jsxs("div",{className:"flex-1 text-center py-2 border-l border-gray-100 dark:border-gray-700/50",children:[i.jsx("div",{className:"text-[10px] font-semibold text-gray-500 dark:text-gray-400 uppercase",children:_e(z,"EEE")}),i.jsx("div",{className:`text-lg font-semibold mt-0.5 ${_?"bg-blue-600 text-white w-8 h-8 rounded-full flex items-center justify-center mx-auto":"text-gray-700 dark:text-gray-300"}`,children:_e(z,"d")})]},z.toISOString())})]}),R.length>0&&i.jsxs("div",{className:"flex border-b border-gray-200 dark:border-gray-700 flex-shrink-0",children:[i.jsx("div",{className:"w-16 flex-shrink-0 text-[10px] text-gray-400 dark:text-gray-500 text-right pr-2 py-1",children:"all-day"}),q.map(z=>i.jsx("div",{className:"flex-1 border-l border-gray-100 dark:border-gray-700/50 p-0.5 space-y-0.5",children:U(z).map(_=>i.jsx("button",{onClick:()=>C(_),className:"w-full text-left text-[10px] px-1.5 py-0.5 rounded text-white font-medium truncate hover:opacity-80",style:{backgroundColor:Y.get(_.calendar_id)||"#3B82F6"},children:_.title},_.id))},z.toISOString()))]}),i.jsx("div",{className:"flex-1 overflow-y-auto",children:i.jsxs("div",{className:"flex relative",style:{height:`${24*li}px`},children:[i.jsx("div",{className:"w-16 flex-shrink-0 relative",children:Z0.map(z=>i.jsx("div",{className:"absolute w-full text-right pr-2 text-[10px] text-gray-400 dark:text-gray-500 -mt-2",style:{top:`${z*li}px`},children:z===0?"":_e(new Date(2e3,0,1,z),"h a")},z))}),q.map(z=>i.jsxs("div",{className:"flex-1 relative border-l border-gray-100 dark:border-gray-700/50",children:[Z0.map(_=>i.jsx("div",{className:"absolute w-full border-t border-gray-100 dark:border-gray-700/30 cursor-pointer hover:bg-blue-50/50 dark:hover:bg-blue-900/10",style:{top:`${_*li}px`,height:`${li}px`},onClick:()=>{const X=new Date(z);X.setHours(_,0,0,0),T(X)}},_)),j(z).map(_=>{const X=E(_);return i.jsxs("button",{onClick:I=>{I.stopPropagation(),C(_)},className:"absolute left-0.5 right-1 rounded-md px-1.5 py-0.5 text-[11px] text-white font-medium overflow-hidden hover:opacity-90 z-10 shadow-sm",style:{...X,backgroundColor:Y.get(_.calendar_id)||"#3B82F6"},children:[i.jsx("div",{className:"truncate",children:_.title}),i.jsx("div",{className:"opacity-75 truncate text-[10px]",children:_e(tt(_.start_time),"h:mm a")})]},_.id)})]},z.toISOString()))]})})]})}const V0=Array.from({length:24},(r,x)=>x),Ba=64;function Fm({currentDate:r,events:x,calendars:w,visibleCalendarIds:d,onTimeClick:T,onEventClick:C}){const H=new Map(w.map(j=>[j.id,j.color])),q=x.filter(j=>d.has(j.calendar_id)),Y=q.filter(j=>j.all_day&&Dl(tt(_l(j)),r)),B=q.filter(j=>!j.all_day&&Dl(tt(_l(j)),r)),R=ii(r),D=j=>{const U=tt(_l(j)),E=I0(U),z=ni(U,E),_=tt(ui(j)),X=Math.max(ni(_,U),15);return{top:`${z*(Ba/60)}px`,height:`${X*(Ba/60)}px`,minHeight:"24px"}};return i.jsxs("div",{className:"flex flex-col h-full overflow-hidden",children:[i.jsxs("div",{className:"text-center py-3 border-b border-gray-200 dark:border-gray-700 flex-shrink-0",children:[i.jsx("div",{className:"text-xs font-semibold text-gray-500 dark:text-gray-400 uppercase",children:_e(r,"EEEE")}),i.jsx("div",{className:`text-2xl font-bold mt-1 ${R?"bg-blue-600 text-white w-10 h-10 rounded-full flex items-center justify-center mx-auto":"text-gray-800 dark:text-gray-200"}`,children:_e(r,"d")})]}),Y.length>0&&i.jsx("div",{className:"px-4 py-2 border-b border-gray-200 dark:border-gray-700 space-y-1 flex-shrink-0",children:Y.map(j=>i.jsx("button",{onClick:()=>C(j),className:"block w-full text-left text-sm px-3 py-1.5 rounded-lg text-white font-medium hover:opacity-80",style:{backgroundColor:H.get(j.calendar_id)||"#3B82F6"},children:j.title},j.id))}),i.jsx("div",{className:"flex-1 overflow-y-auto",children:i.jsxs("div",{className:"flex relative",style:{height:`${24*Ba}px`},children:[i.jsx("div",{className:"w-20 flex-shrink-0 relative",children:V0.map(j=>i.jsx("div",{className:"absolute w-full text-right pr-3 text-xs text-gray-400 dark:text-gray-500 -mt-2",style:{top:`${j*Ba}px`},children:j===0?"":_e(new Date(2e3,0,1,j),"h a")},j))}),i.jsxs("div",{className:"flex-1 relative border-l border-gray-200 dark:border-gray-700",children:[V0.map(j=>i.jsx("div",{className:"absolute w-full border-t border-gray-100 dark:border-gray-700/30 cursor-pointer hover:bg-blue-50/50 dark:hover:bg-blue-900/10",style:{top:`${j*Ba}px`,height:`${Ba}px`},onClick:()=>{const U=new Date(r);U.setHours(j,0,0,0),T(U)}},j)),B.map(j=>{const U=D(j);return i.jsxs("button",{onClick:E=>{E.stopPropagation(),C(j)},className:"absolute left-1 right-4 rounded-lg px-3 py-1.5 text-white font-medium overflow-hidden hover:opacity-90 z-10 shadow-sm",style:{...U,backgroundColor:H.get(j.calendar_id)||"#3B82F6"},children:[i.jsx("div",{className:"text-sm truncate",children:j.title}),i.jsxs("div",{className:"text-xs opacity-80",children:[_e(tt(j.start_time),"h:mm a")," -"," ",_e(tt(j.end_time),"h:mm a")]}),j.location&&i.jsx("div",{className:"text-xs opacity-70 truncate",children:j.location})]},j.id)})]})]})})]})}function Il({open:r,onClose:x,title:w,children:d,wide:T}){return v.useEffect(()=>{if(!r)return;const C=H=>{H.key==="Escape"&&x()};return window.addEventListener("keydown",C),()=>window.removeEventListener("keydown",C)},[r,x]),r?i.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center animate-fade-in",onClick:x,children:[i.jsx("div",{className:"absolute inset-0 bg-black/40 dark:bg-black/60"}),i.jsxs("div",{className:`relative bg-white dark:bg-gray-800 rounded-2xl shadow-2xl animate-slide-up ${T?"w-full max-w-2xl":"w-full max-w-md"} max-h-[90vh] overflow-y-auto mx-4`,onClick:C=>C.stopPropagation(),children:[i.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-gray-100 dark:border-gray-700",children:[i.jsx("h2",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:w}),i.jsx("button",{onClick:x,className:"p-1 rounded-lg hover:bg-gray-100 dark:hover:bg-gray-700 text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 transition-colors",children:i.jsx("svg",{className:"w-5 h-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),i.jsx("div",{className:"p-6",children:d})]})]}):null}function Im({open:r,onClose:x,onSaved:w,event:d,calendars:T,defaultDate:C,defaultCalendarId:H}){var oe;const q=!!d,Y=T.filter(Q=>Q.role!=="viewer"),[B,R]=v.useState(""),[D,j]=v.useState(""),[U,E]=v.useState(""),[z,_]=v.useState(""),[X,I]=v.useState(""),[te,J]=v.useState("09:00"),[ge,ce]=v.useState(""),[be,P]=v.useState("10:00"),[Z,Ne]=v.useState(!1),[ee,pe]=v.useState(!1),[Qe,Ve]=v.useState(""),[Re,p]=v.useState(!1);v.useEffect(()=>{var Q;if(r)if(Ve(""),p(!1),d){R(d.title),j(d.description||""),E(d.location||""),_(d.calendar_id),Ne(d.all_day);const ne=new Date(d.start_time),M=new Date(d.end_time);I(_e(ne,"yyyy-MM-dd")),J(_e(ne,"HH:mm")),ce(_e(M,"yyyy-MM-dd")),P(_e(M,"HH:mm"))}else{R(""),j(""),E(""),_(H||((Q=Y[0])==null?void 0:Q.id)||""),Ne(!1);const M=_e(C||new Date,"yyyy-MM-dd");I(M),ce(M),J("09:00"),P("10:00")}},[r,d,C,H]);const O=async Q=>{if(Q.preventDefault(),!(!B.trim()||!z)){pe(!0),Ve("");try{const ne=Intl.DateTimeFormat().resolvedOptions().timeZone,M=Z?`${X}T00:00:00`:`${X}T${te}:00`,A=Z?`${ge}T23:59:59`:`${ge}T${be}:00`,ve={title:B.trim(),description:D.trim()||void 0,location:U.trim()||void 0,start_time:new Date(M).toISOString(),end_time:new Date(A).toISOString(),timezone:ne,all_day:Z};q?await de.updateEvent(d.id,ve):await de.createEvent({...ve,calendar_id:z}),w(),x()}catch(ne){Ve(ne.error||"Failed to save event")}finally{pe(!1)}}},V=async()=>{if(d){pe(!0);try{await de.deleteEvent(d.id),w(),x()}catch(Q){Ve(Q.error||"Failed to delete event")}finally{pe(!1)}}},me=((oe=T.find(Q=>Q.id===z))==null?void 0:oe.color)||"#3B82F6";return i.jsx(Il,{open:r,onClose:x,title:q?"Edit Event":"New Event",children:i.jsxs("form",{onSubmit:O,className:"space-y-4",children:[Qe&&i.jsx("div",{className:"text-sm text-red-600 dark:text-red-400 bg-red-50 dark:bg-red-900/20 px-3 py-2 rounded-lg",children:Qe}),i.jsx("div",{children:i.jsx("input",{type:"text",placeholder:"Event title",value:B,onChange:Q=>R(Q.target.value),className:"w-full text-lg font-medium bg-transparent border-0 border-b-2 border-gray-200 dark:border-gray-600 focus:border-blue-500 dark:focus:border-blue-400 focus:ring-0 px-0 py-2 text-gray-900 dark:text-white placeholder-gray-400 outline-none transition-colors",autoFocus:!0,required:!0})}),!q&&i.jsxs("div",{children:[i.jsx("label",{className:"block text-xs font-medium text-gray-500 dark:text-gray-400 mb-1",children:"Calendar"}),i.jsxs("div",{className:"relative",children:[i.jsx("div",{className:"absolute left-3 top-1/2 -translate-y-1/2 w-3 h-3 rounded-full",style:{backgroundColor:me}}),i.jsx("select",{value:z,onChange:Q=>_(Q.target.value),className:"w-full pl-8 pr-3 py-2 rounded-lg border border-gray-200 dark:border-gray-600 bg-gray-50 dark:bg-gray-700 text-sm text-gray-900 dark:text-white focus:ring-2 focus:ring-blue-500 outline-none",children:Y.map(Q=>i.jsx("option",{value:Q.id,children:Q.name},Q.id))})]})]}),i.jsx("div",{className:"flex items-center gap-3",children:i.jsxs("label",{className:"flex items-center gap-2 text-sm text-gray-700 dark:text-gray-300 cursor-pointer",children:[i.jsx("input",{type:"checkbox",checked:Z,onChange:Q=>Ne(Q.target.checked),className:"rounded border-gray-300 dark:border-gray-600 text-blue-600 focus:ring-blue-500"}),"All day"]})}),i.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[i.jsxs("div",{children:[i.jsx("label",{className:"block text-xs font-medium text-gray-500 dark:text-gray-400 mb-1",children:"Start"}),i.jsx("input",{type:"date",value:X,onChange:Q=>{I(Q.target.value),Q.target.value>ge&&ce(Q.target.value)},className:"w-full px-3 py-2 rounded-lg border border-gray-200 dark:border-gray-600 bg-gray-50 dark:bg-gray-700 text-sm text-gray-900 dark:text-white focus:ring-2 focus:ring-blue-500 outline-none",required:!0}),!Z&&i.jsx("input",{type:"time",value:te,onChange:Q=>J(Q.target.value),className:"w-full mt-2 px-3 py-2 rounded-lg border border-gray-200 dark:border-gray-600 bg-gray-50 dark:bg-gray-700 text-sm text-gray-900 dark:text-white focus:ring-2 focus:ring-blue-500 outline-none",required:!0})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-xs font-medium text-gray-500 dark:text-gray-400 mb-1",children:"End"}),i.jsx("input",{type:"date",value:ge,onChange:Q=>ce(Q.target.value),min:X,className:"w-full px-3 py-2 rounded-lg border border-gray-200 dark:border-gray-600 bg-gray-50 dark:bg-gray-700 text-sm text-gray-900 dark:text-white focus:ring-2 focus:ring-blue-500 outline-none",required:!0}),!Z&&i.jsx("input",{type:"time",value:be,onChange:Q=>P(Q.target.value),className:"w-full mt-2 px-3 py-2 rounded-lg border border-gray-200 dark:border-gray-600 bg-gray-50 dark:bg-gray-700 text-sm text-gray-900 dark:text-white focus:ring-2 focus:ring-blue-500 outline-none",required:!0})]})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-xs font-medium text-gray-500 dark:text-gray-400 mb-1",children:"Location"}),i.jsx("input",{type:"text",placeholder:"Add location",value:U,onChange:Q=>E(Q.target.value),className:"w-full px-3 py-2 rounded-lg border border-gray-200 dark:border-gray-600 bg-gray-50 dark:bg-gray-700 text-sm text-gray-900 dark:text-white focus:ring-2 focus:ring-blue-500 outline-none placeholder-gray-400"})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-xs font-medium text-gray-500 dark:text-gray-400 mb-1",children:"Description"}),i.jsx("textarea",{placeholder:"Add description",value:D,onChange:Q=>j(Q.target.value),rows:3,className:"w-full px-3 py-2 rounded-lg border border-gray-200 dark:border-gray-600 bg-gray-50 dark:bg-gray-700 text-sm text-gray-900 dark:text-white focus:ring-2 focus:ring-blue-500 outline-none resize-none placeholder-gray-400"})]}),i.jsxs("div",{className:"flex items-center justify-between pt-2",children:[i.jsxs("div",{children:[q&&!Re&&i.jsx("button",{type:"button",onClick:()=>p(!0),className:"text-sm text-red-500 hover:text-red-700 dark:hover:text-red-400 transition-colors",children:"Delete event"}),q&&Re&&i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{className:"text-sm text-red-500",children:"Delete?"}),i.jsx("button",{type:"button",onClick:V,className:"text-sm text-white bg-red-500 hover:bg-red-600 px-3 py-1 rounded-lg transition-colors",disabled:ee,children:"Yes"}),i.jsx("button",{type:"button",onClick:()=>p(!1),className:"text-sm text-gray-500 hover:text-gray-700 dark:text-gray-400 transition-colors",children:"No"})]})]}),i.jsxs("div",{className:"flex gap-2",children:[i.jsx("button",{type:"button",onClick:x,className:"px-4 py-2 text-sm text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-lg transition-colors",children:"Cancel"}),i.jsx("button",{type:"submit",disabled:ee||!B.trim(),className:"px-4 py-2 text-sm text-white bg-blue-600 hover:bg-blue-700 disabled:opacity-50 rounded-lg transition-colors font-medium",children:ee?"Saving...":q?"Update":"Create"})]})]})]})})}const ai=["#3B82F6","#EF4444","#10B981","#F59E0B","#8B5CF6","#EC4899","#06B6D4","#F97316","#6366F1","#14B8A6","#84CC16","#A855F7"];function Pm(r){navigator.clipboard.writeText(r)}function eh({open:r,onClose:x,onSaved:w,calendar:d}){const T=!!d,[C,H]=v.useState(""),[q,Y]=v.useState(ai[0]),[B,R]=v.useState(!0),[D,j]=v.useState(10),[U,E]=v.useState(0),[z,_]=v.useState(!1),[X,I]=v.useState(""),[te,J]=v.useState(!1),[ge,ce]=v.useState([]),[be,P]=v.useState(!1),[Z,Ne]=v.useState(""),[ee,pe]=v.useState(!1),[Qe,Ve]=v.useState(null),[Re,p]=v.useState(!1),O=v.useCallback(async()=>{if(d!=null&&d.id){P(!0);try{const A=await de.listSubscriptions(d.id);ce(A.items||[])}catch{ce([])}finally{P(!1)}}},[d==null?void 0:d.id]);v.useEffect(()=>{r&&(I(""),J(!1),Ne(""),d?(H(d.name),Y(d.color),R(d.count_for_availability??!0),j(d.default_reminder_minutes??10),E(d.sort_order??0),O()):(H(""),Y(ai[Math.floor(Math.random()*ai.length)]),R(!0),j(10),E(0),ce([])))},[r,d,O]);const V=async A=>{if(A.preventDefault(),!!C.trim()){_(!0),I("");try{T?await de.updateCalendar(d.id,{name:C.trim(),color:q,count_for_availability:B,default_reminder_minutes:D===""?void 0:D,sort_order:U===""?void 0:U}):await de.createCalendar({name:C.trim(),color:q}),w(),x()}catch(ve){I(ve.error||"Failed to save calendar")}finally{_(!1)}}},me=async()=>{if(d){_(!0);try{await de.deleteCalendar(d.id),w(),x()}catch(A){I(A.error||"Failed to delete calendar")}finally{_(!1)}}},oe=async A=>{if(A.preventDefault(),!(!(d!=null&&d.id)||!Z.trim())){pe(!0);try{await de.addSubscription(d.id,{url:Z.trim()}),Ne(""),O(),w()}catch(ve){I(ve.error||"Failed to add subscription")}finally{pe(!1)}}},Q=async A=>{if(d!=null&&d.id)try{await de.deleteSubscription(d.id,A),O(),w()}catch(ve){I(ve.error||"Failed to remove subscription")}},ne=async A=>{if(d!=null&&d.id){Ve(A);try{await de.syncSubscription(d.id,A),O(),w()}catch(ve){I(ve.error||"Failed to sync")}finally{Ve(null)}}},M=A=>{Pm(A),p(!0),setTimeout(()=>p(!1),1500)};return i.jsx(Il,{open:r,onClose:x,title:T?"Edit Calendar":"New Calendar",children:i.jsxs("form",{onSubmit:V,className:"space-y-5",children:[X&&i.jsx("div",{className:"text-sm text-red-600 dark:text-red-400 bg-red-50 dark:bg-red-900/20 px-3 py-2 rounded-lg",children:X}),i.jsx("div",{children:i.jsx("input",{type:"text",placeholder:"Calendar name",value:C,onChange:A=>H(A.target.value),className:"w-full text-lg font-medium bg-transparent border-0 border-b-2 border-gray-200 dark:border-gray-600 focus:border-blue-500 dark:focus:border-blue-400 focus:ring-0 px-0 py-2 text-gray-900 dark:text-white placeholder-gray-400 outline-none transition-colors",autoFocus:!0,required:!0,maxLength:80})}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-xs font-medium text-gray-500 dark:text-gray-400 mb-2",children:"Color"}),i.jsx("div",{className:"flex flex-wrap gap-2",children:ai.map(A=>i.jsx("button",{type:"button",onClick:()=>Y(A),className:`w-8 h-8 rounded-full transition-all ${q===A?"ring-2 ring-offset-2 ring-offset-white dark:ring-offset-gray-800 scale-110":"hover:scale-110"}`,style:{backgroundColor:A,outlineColor:q===A?A:void 0}},A))})]}),T&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("input",{type:"checkbox",id:"count_for_availability",checked:B,onChange:A=>R(A.target.checked),className:"rounded border-gray-300 dark:border-gray-600 text-blue-600 focus:ring-blue-500"}),i.jsx("label",{htmlFor:"count_for_availability",className:"text-sm text-gray-700 dark:text-gray-300",children:"Include in availability / Count as busy"})]}),(d==null?void 0:d.availability_url)&&i.jsxs("div",{children:[i.jsx("label",{className:"block text-xs font-medium text-gray-500 dark:text-gray-400 mb-1",children:"Availability URL"}),i.jsxs("div",{className:"flex gap-2",children:[i.jsx("input",{type:"text",readOnly:!0,value:d.availability_url,className:"flex-1 px-3 py-2 rounded-lg border border-gray-200 dark:border-gray-600 bg-gray-50 dark:bg-gray-800 text-sm text-gray-600 dark:text-gray-400 truncate"}),i.jsx("button",{type:"button",onClick:()=>M(d.availability_url),className:"px-3 py-2 text-sm text-blue-600 dark:text-blue-400 hover:bg-blue-50 dark:hover:bg-blue-900/20 rounded-lg transition-colors",children:Re?"Copied!":"Copy"})]}),i.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mt-1",children:"Share with Calendly, Cal.com, etc. to block busy times"})]}),i.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[i.jsxs("div",{children:[i.jsx("label",{className:"block text-xs font-medium text-gray-500 dark:text-gray-400 mb-1",children:"Default reminder (min)"}),i.jsx("input",{type:"number",min:0,max:10080,value:D,onChange:A=>j(A.target.value===""?"":parseInt(A.target.value,10)||0),className:"w-full px-3 py-2 rounded-lg border border-gray-200 dark:border-gray-600 bg-gray-50 dark:bg-gray-700 text-sm text-gray-900 dark:text-white focus:ring-2 focus:ring-blue-500 outline-none"})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-xs font-medium text-gray-500 dark:text-gray-400 mb-1",children:"Sort order"}),i.jsx("input",{type:"number",value:U,onChange:A=>E(A.target.value===""?"":parseInt(A.target.value,10)||0),className:"w-full px-3 py-2 rounded-lg border border-gray-200 dark:border-gray-600 bg-gray-50 dark:bg-gray-700 text-sm text-gray-900 dark:text-white focus:ring-2 focus:ring-blue-500 outline-none"})]})]}),(d==null?void 0:d.role)==="owner"||(d==null?void 0:d.role)==="editor"?i.jsxs("div",{children:[i.jsx("label",{className:"block text-xs font-medium text-gray-500 dark:text-gray-400 mb-2",children:"Subscribed URLs"}),be?i.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:"Loading..."}):ge.length===0?i.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:"No subscriptions. Add a URL to import events from an external calendar."}):i.jsx("ul",{className:"space-y-2 mb-2",children:ge.map(A=>i.jsxs("li",{className:"flex items-center justify-between gap-2 p-2 rounded-lg bg-gray-50 dark:bg-gray-800 text-sm",children:[i.jsx("span",{className:"truncate text-gray-700 dark:text-gray-300",title:A.source_url,children:A.source_url}),i.jsxs("div",{className:"flex gap-1 flex-shrink-0",children:[i.jsx("button",{type:"button",onClick:()=>ne(A.id),disabled:Qe===A.id,className:"px-2 py-1 text-xs text-blue-600 dark:text-blue-400 hover:bg-blue-50 dark:hover:bg-blue-900/20 rounded transition-colors disabled:opacity-50",children:Qe===A.id?"Syncing...":"Sync"}),i.jsx("button",{type:"button",onClick:()=>Q(A.id),className:"px-2 py-1 text-xs text-red-500 hover:bg-red-50 dark:hover:bg-red-900/20 rounded transition-colors",children:"Remove"})]})]},A.id))}),i.jsxs("div",{className:"flex gap-2",children:[i.jsx("input",{type:"url",placeholder:"https://... or webcal://...",value:Z,onChange:A=>Ne(A.target.value),onKeyDown:A=>{A.key==="Enter"&&(A.preventDefault(),oe(A))},className:"flex-1 px-3 py-2 rounded-lg border border-gray-200 dark:border-gray-600 bg-gray-50 dark:bg-gray-700 text-sm text-gray-900 dark:text-white focus:ring-2 focus:ring-blue-500 outline-none placeholder-gray-400"}),i.jsx("button",{type:"button",onClick:oe,disabled:ee||!Z.trim(),className:"px-3 py-2 text-sm text-blue-600 dark:text-blue-400 hover:bg-blue-50 dark:hover:bg-blue-900/20 rounded-lg transition-colors font-medium disabled:opacity-50",children:ee?"Adding...":"Add"})]})]}):null]}),i.jsxs("div",{className:"flex items-center justify-between pt-2",children:[i.jsxs("div",{children:[T&&(d==null?void 0:d.role)==="owner"&&!te&&i.jsx("button",{type:"button",onClick:()=>J(!0),className:"text-sm text-red-500 hover:text-red-700 dark:hover:text-red-400 transition-colors",children:"Delete calendar"}),T&&te&&i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{className:"text-sm text-red-500",children:"Delete?"}),i.jsx("button",{type:"button",onClick:me,className:"text-sm text-white bg-red-500 hover:bg-red-600 px-3 py-1 rounded-lg transition-colors",disabled:z,children:"Yes"}),i.jsx("button",{type:"button",onClick:()=>J(!1),className:"text-sm text-gray-500 hover:text-gray-700 dark:text-gray-400 transition-colors",children:"No"})]})]}),i.jsxs("div",{className:"flex gap-2",children:[i.jsx("button",{type:"button",onClick:x,className:"px-4 py-2 text-sm text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-lg transition-colors",children:"Cancel"}),i.jsx("button",{type:"submit",disabled:z||!C.trim(),className:"px-4 py-2 text-sm text-white bg-blue-600 hover:bg-blue-700 disabled:opacity-50 rounded-lg transition-colors font-medium",children:z?"Saving...":T?"Update":"Create"})]})]})]})})}function th({open:r,onClose:x,onSaved:w,targetCalendarId:d,calendars:T}){var te;const C=!d,[H,q]=v.useState(""),[Y,B]=v.useState(""),[R,D]=v.useState("#3B82F6"),[j,U]=v.useState(d||((te=T[0])==null?void 0:te.id)||""),[E,z]=v.useState(!1),[_,X]=v.useState(""),I=async J=>{if(J.preventDefault(),!!H.trim()){z(!0),X("");try{C?await de.addCalendarFromUrl({url:H.trim(),name:Y.trim()||void 0,color:R||void 0}):await de.importCalendarUrl({calendar_id:j,url:H.trim()}),w(),x(),q(""),B("")}catch(ge){X(ge.error||"Failed to add calendar")}finally{z(!1)}}};return i.jsx(Il,{open:r,onClose:x,title:C?"Add calendar from URL":"Import from URL",children:i.jsxs("form",{onSubmit:I,className:"space-y-4",children:[_&&i.jsx("div",{className:"text-sm text-red-600 dark:text-red-400 bg-red-50 dark:bg-red-900/20 px-3 py-2 rounded-lg break-words",children:_}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-xs font-medium text-gray-500 dark:text-gray-400 mb-1",children:"Calendar URL"}),i.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mb-1.5",children:'Google Calendar: Settings → your calendar → Integrate calendar → copy "Secret address in iCal format"'}),i.jsx("input",{type:"text",placeholder:"https://... or webcal://...",value:H,onChange:J=>q(J.target.value),className:"w-full px-3 py-2 rounded-lg border border-gray-200 dark:border-gray-600 bg-gray-50 dark:bg-gray-700 text-sm text-gray-900 dark:text-white focus:ring-2 focus:ring-blue-500 outline-none placeholder-gray-400",required:!0})]}),C&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{children:[i.jsx("label",{className:"block text-xs font-medium text-gray-500 dark:text-gray-400 mb-1",children:"Calendar name"}),i.jsx("input",{type:"text",placeholder:"Imported Calendar",value:Y,onChange:J=>B(J.target.value),className:"w-full px-3 py-2 rounded-lg border border-gray-200 dark:border-gray-600 bg-gray-50 dark:bg-gray-700 text-sm text-gray-900 dark:text-white focus:ring-2 focus:ring-blue-500 outline-none placeholder-gray-400"})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-xs font-medium text-gray-500 dark:text-gray-400 mb-1",children:"Color"}),i.jsx("input",{type:"color",value:R,onChange:J=>D(J.target.value),className:"w-full h-10 rounded-lg border border-gray-200 dark:border-gray-600 cursor-pointer"})]})]}),!C&&T.length>1&&i.jsxs("div",{children:[i.jsx("label",{className:"block text-xs font-medium text-gray-500 dark:text-gray-400 mb-1",children:"Import into"}),i.jsx("select",{value:j,onChange:J=>U(J.target.value),className:"w-full px-3 py-2 rounded-lg border border-gray-200 dark:border-gray-600 bg-gray-50 dark:bg-gray-700 text-sm text-gray-900 dark:text-white focus:ring-2 focus:ring-blue-500 outline-none",children:T.map(J=>i.jsx("option",{value:J.id,children:J.name},J.id))})]}),i.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[i.jsx("button",{type:"button",onClick:x,className:"px-4 py-2 text-sm text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-lg transition-colors",children:"Cancel"}),i.jsx("button",{type:"submit",disabled:E||!H.trim(),className:"px-4 py-2 text-sm text-white bg-blue-600 hover:bg-blue-700 disabled:opacity-50 rounded-lg transition-colors font-medium",children:E?"Adding...":C?"Create calendar":"Import"})]})]})})}function lh({selectedDate:r,onDateSelect:x}){const[w,d]=v.useState(r),T=Us(w),C=Hs(w),H=qa(T),q=Un(C),Y=W0({start:H,end:q});return i.jsxs("div",{className:"select-none",children:[i.jsxs("div",{className:"flex items-center justify-between mb-2",children:[i.jsx("button",{onClick:()=>d(B=>P0(B)),className:"p-1 rounded-md hover:bg-gray-100 dark:hover:bg-gray-700 text-gray-500 dark:text-gray-400 transition-colors",children:i.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 19l-7-7 7-7"})})}),i.jsx("span",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:_e(w,"MMMM yyyy")}),i.jsx("button",{onClick:()=>d(B=>ef(B,1)),className:"p-1 rounded-md hover:bg-gray-100 dark:hover:bg-gray-700 text-gray-500 dark:text-gray-400 transition-colors",children:i.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})})})]}),i.jsxs("div",{className:"grid grid-cols-7 gap-0",children:[["Su","Mo","Tu","We","Th","Fr","Sa"].map(B=>i.jsx("div",{className:"text-center text-[10px] font-medium text-gray-400 dark:text-gray-500 py-1",children:B},B)),Y.map(B=>{const R=$0(B,w),D=Dl(B,r),j=ii(B);return i.jsx("button",{onClick:()=>x(B),className:`text-[11px] w-7 h-7 rounded-full flex items-center justify-center mx-auto transition-colors ${R?"text-gray-700 dark:text-gray-300":"text-gray-300 dark:text-gray-600"} ${D?"bg-blue-600 text-white! font-semibold":""} ${j&&!D?"bg-blue-100 dark:bg-blue-900/40 text-blue-600 dark:text-blue-400 font-semibold":""} ${D?"":"hover:bg-gray-100 dark:hover:bg-gray-700"}`,children:_e(B,"d")},B.toISOString())})]})]})}function ah(){var ul,Yt,At;const{user:r,logout:x}=Ya(),{theme:w,toggle:d}=ci(),[T,C]=v.useState(new Date),[H,q]=v.useState("month"),[Y,B]=v.useState([]),[R,D]=v.useState([]),[j,U]=v.useState(new Set),[E,z]=v.useState(!0),[_,X]=v.useState(!1),[I,te]=v.useState(!1),[J,ge]=v.useState(!1),[ce,be]=v.useState(null),[P,Z]=v.useState(null),[Ne,ee]=v.useState(),[pe,Qe]=v.useState(!1),[Ve,Re]=v.useState(!0),p=v.useCallback(async()=>{try{const Ee=(await de.listCalendars()).items||[];B(Ee),U(Pe=>{if(Pe.size===0)return new Set(Ee.map(lt=>lt.id));const Lt=new Set(Pe);for(const lt of Ee)Pe.has(lt.id)||Lt.add(lt.id);return Lt})}catch{}},[]),O=v.useCallback(async()=>{const W=H==="month"?qa(Us(T)):H==="week"?qa(T):T,Ee=H==="month"?Un(Hs(T)):H==="week"?Un(T):T,Pe=new Date(W);Pe.setDate(Pe.getDate()-1);const Lt=new Date(Ee);Lt.setDate(Lt.getDate()+1);try{const lt=await de.listEvents({start:Pe.toISOString(),end:Lt.toISOString()});D(lt.items||[])}catch{}Re(!1)},[T,H]);v.useEffect(()=>{p()},[p]),v.useEffect(()=>{Y.length>0&&O()},[O,Y]);const V=W=>{C(H==="month"?Ee=>W===1?ef(Ee,1):P0(Ee):H==="week"?Ee=>W===1?Dm(Ee,1):_m(Ee):Ee=>W===1?F0(Ee,1):wm(Ee))},me=()=>C(new Date),oe=W=>{U(Ee=>{const Pe=new Set(Ee);return Pe.has(W)?Pe.delete(W):Pe.add(W),Pe})},Q=W=>{H==="month"?(C(W),q("day")):(ee(W),be(null),X(!0))},ne=W=>{ee(W),be(null),X(!0)},M=W=>{be(W),X(!0)},A=()=>{O()},ve=()=>{p().then(O)},Ke=H==="month"?_e(T,"MMMM yyyy"):H==="week"?`${_e(qa(T),"MMM d")} - ${_e(Un(T),"MMM d, yyyy")}`:_e(T,"EEEE, MMMM d, yyyy");return i.jsxs("div",{className:"h-full flex flex-col bg-white dark:bg-gray-900 transition-colors",children:[i.jsxs("header",{className:"flex items-center justify-between px-4 py-2.5 border-b border-gray-200 dark:border-gray-700 flex-shrink-0 bg-white dark:bg-gray-900",children:[i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx("button",{onClick:()=>z(W=>!W),className:"p-2 rounded-xl hover:bg-gray-100 dark:hover:bg-gray-800 text-gray-600 dark:text-gray-400 transition-colors lg:hidden",children:i.jsx("svg",{className:"w-5 h-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 6h16M4 12h16M4 18h16"})})}),i.jsx("button",{onClick:()=>z(W=>!W),className:"p-2 rounded-xl hover:bg-gray-100 dark:hover:bg-gray-800 text-gray-600 dark:text-gray-400 transition-colors hidden lg:block",children:i.jsx("svg",{className:"w-5 h-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 6h16M4 12h16M4 18h16"})})}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("div",{className:"w-8 h-8 bg-blue-600 rounded-lg flex items-center justify-center",children:i.jsx("svg",{className:"w-5 h-5 text-white",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M8 7V3m8 4V3m-9 8h10M5 21h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z"})})}),i.jsx("span",{className:"text-lg font-bold text-gray-900 dark:text-white hidden sm:block",children:"Calendar"})]})]}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("button",{onClick:me,className:"px-3 py-1.5 text-sm font-medium border border-gray-300 dark:border-gray-600 rounded-lg text-gray-700 dark:text-gray-300 hover:bg-gray-50 dark:hover:bg-gray-800 transition-colors",children:"Today"}),i.jsxs("div",{className:"flex items-center",children:[i.jsx("button",{onClick:()=>V(-1),className:"p-1.5 rounded-lg hover:bg-gray-100 dark:hover:bg-gray-800 text-gray-600 dark:text-gray-400 transition-colors",children:i.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 19l-7-7 7-7"})})}),i.jsx("button",{onClick:()=>V(1),className:"p-1.5 rounded-lg hover:bg-gray-100 dark:hover:bg-gray-800 text-gray-600 dark:text-gray-400 transition-colors",children:i.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})})})]}),i.jsx("h2",{className:"text-base font-semibold text-gray-900 dark:text-white min-w-[180px] text-center hidden sm:block",children:Ke})]}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("div",{className:"hidden sm:flex items-center bg-gray-100 dark:bg-gray-800 rounded-lg p-0.5",children:["month","week","day"].map(W=>i.jsx("button",{onClick:()=>q(W),className:`px-3 py-1 text-xs font-medium rounded-md transition-colors capitalize ${H===W?"bg-white dark:bg-gray-700 text-gray-900 dark:text-white shadow-sm":"text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white"}`,children:W},W))}),i.jsx("button",{onClick:d,className:"p-2 rounded-xl hover:bg-gray-100 dark:hover:bg-gray-800 text-gray-600 dark:text-gray-400 transition-colors",children:w==="dark"?i.jsx("svg",{className:"w-5 h-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 3v1m0 16v1m9-9h-1M4 12H3m15.364 6.364l-.707-.707M6.343 6.343l-.707-.707m12.728 0l-.707.707M6.343 17.657l-.707.707M16 12a4 4 0 11-8 0 4 4 0 018 0z"})}):i.jsx("svg",{className:"w-5 h-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M20.354 15.354A9 9 0 018.646 3.646 9.003 9.003 0 0012 21a9.003 9.003 0 008.354-5.646z"})})}),i.jsxs("div",{className:"relative",children:[i.jsx("button",{onClick:()=>Qe(W=>!W),className:"w-8 h-8 rounded-full bg-gradient-to-br from-blue-500 to-purple-600 flex items-center justify-center text-white text-sm font-semibold",children:((Yt=(ul=r==null?void 0:r.email)==null?void 0:ul[0])==null?void 0:Yt.toUpperCase())||"U"}),pe&&i.jsxs(i.Fragment,{children:[i.jsx("div",{className:"fixed inset-0 z-40",onClick:()=>Qe(!1)}),i.jsxs("div",{className:"absolute right-0 mt-2 w-56 bg-white dark:bg-gray-800 rounded-xl shadow-lg border border-gray-200 dark:border-gray-700 py-1 z-50 animate-scale-in",children:[i.jsxs("div",{className:"px-4 py-2.5 border-b border-gray-100 dark:border-gray-700",children:[i.jsx("p",{className:"text-sm font-medium text-gray-900 dark:text-white truncate",children:r==null?void 0:r.email}),i.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:r==null?void 0:r.timezone})]}),i.jsx("button",{onClick:()=>{Qe(!1),x()},className:"w-full text-left px-4 py-2 text-sm text-red-600 dark:text-red-400 hover:bg-gray-50 dark:hover:bg-gray-700/50 transition-colors",children:"Sign out"})]})]})]})]})]}),i.jsxs("div",{className:"sm:hidden text-center py-2 border-b border-gray-100 dark:border-gray-800 flex-shrink-0",children:[i.jsx("span",{className:"text-sm font-semibold text-gray-900 dark:text-white",children:Ke}),i.jsx("div",{className:"flex items-center justify-center gap-1 mt-1",children:["month","week","day"].map(W=>i.jsx("button",{onClick:()=>q(W),className:`px-2.5 py-0.5 text-xs font-medium rounded-md transition-colors capitalize ${H===W?"bg-blue-100 dark:bg-blue-900/30 text-blue-700 dark:text-blue-400":"text-gray-500 dark:text-gray-400"}`,children:W},W))})]}),i.jsxs("div",{className:"flex flex-1 overflow-hidden",children:[E&&i.jsxs("aside",{className:"w-64 border-r border-gray-200 dark:border-gray-700 flex-shrink-0 overflow-y-auto bg-white dark:bg-gray-900 flex flex-col",children:[i.jsx("div",{className:"p-4",children:i.jsxs("button",{onClick:()=>{be(null),ee(new Date),X(!0)},className:"w-full flex items-center justify-center gap-2 px-4 py-2.5 bg-blue-600 hover:bg-blue-700 text-white rounded-xl font-medium text-sm shadow-lg shadow-blue-600/20 transition-all hover:shadow-blue-600/30",children:[i.jsx("svg",{className:"w-5 h-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 4v16m8-8H4"})}),"New Event"]})}),i.jsx("div",{className:"px-4 pb-4",children:i.jsx(lh,{selectedDate:T,onDateSelect:W=>C(W)})}),i.jsxs("div",{className:"px-4 pb-4 flex-1",children:[i.jsxs("div",{className:"flex items-center justify-between mb-2",children:[i.jsx("h3",{className:"text-xs font-semibold text-gray-500 dark:text-gray-400 uppercase tracking-wider",children:"My Calendars"}),i.jsxs("div",{className:"flex gap-0.5",children:[i.jsx("button",{onClick:()=>ge(!0),className:"p-1 rounded-md hover:bg-gray-100 dark:hover:bg-gray-700 text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 transition-colors",title:"Add from URL",children:i.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13.828 10.172a4 4 0 00-5.656 0l-4 4a4 4 0 105.656 5.656l1.102-1.101m-.758-4.899a4 4 0 005.656 0l4-4a4 4 0 00-5.656-5.656l-1.1 1.1"})})}),i.jsx("button",{onClick:()=>{Z(null),te(!0)},className:"p-1 rounded-md hover:bg-gray-100 dark:hover:bg-gray-700 text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 transition-colors",title:"New calendar",children:i.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 4v16m8-8H4"})})})]})]}),i.jsx("div",{className:"space-y-0.5",children:Y.map(W=>i.jsxs("div",{className:"flex items-center gap-2 py-1.5 px-1 rounded-lg group hover:bg-gray-50 dark:hover:bg-gray-800/50",children:[i.jsx("button",{onClick:()=>oe(W.id),className:"flex-shrink-0",children:i.jsx("div",{className:"w-4 h-4 rounded border-2 transition-colors flex items-center justify-center",style:{borderColor:W.color,backgroundColor:j.has(W.id)?W.color:"transparent"},children:j.has(W.id)&&i.jsx("svg",{className:"w-3 h-3 text-white",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:3,d:"M5 13l4 4L19 7"})})})}),i.jsx("span",{className:"text-sm text-gray-700 dark:text-gray-300 flex-1 truncate",children:W.name}),W.role==="owner"&&i.jsx("button",{onClick:()=>{Z(W),te(!0)},className:"p-0.5 rounded opacity-0 group-hover:opacity-100 hover:bg-gray-200 dark:hover:bg-gray-700 text-gray-400 transition-all",children:i.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 5v.01M12 12v.01M12 19v.01M12 6a1 1 0 110-2 1 1 0 010 2zm0 7a1 1 0 110-2 1 1 0 010 2zm0 7a1 1 0 110-2 1 1 0 010 2z"})})})]},W.id))})]})]}),i.jsx("main",{className:"flex-1 overflow-hidden",children:Ve?i.jsx("div",{className:"flex items-center justify-center h-full",children:i.jsx("div",{className:"w-8 h-8 border-2 border-blue-600 border-t-transparent rounded-full animate-spin"})}):H==="month"?i.jsx(Wm,{currentDate:T,events:R,calendars:Y,visibleCalendarIds:j,onDateClick:Q,onEventClick:M}):H==="week"?i.jsx($m,{currentDate:T,events:R,calendars:Y,visibleCalendarIds:j,onTimeClick:ne,onEventClick:M}):i.jsx(Fm,{currentDate:T,events:R,calendars:Y,visibleCalendarIds:j,onTimeClick:ne,onEventClick:M})})]}),i.jsx(Im,{open:_,onClose:()=>X(!1),onSaved:A,event:ce,calendars:Y,defaultDate:Ne,defaultCalendarId:(At=Y.find(W=>W.role==="owner"))==null?void 0:At.id}),i.jsx(eh,{open:I,onClose:()=>te(!1),onSaved:ve,calendar:P}),i.jsx(th,{open:J,onClose:()=>ge(!1),onSaved:ve,targetCalendarId:null,calendars:Y})]})}function nh(){const[r,x]=v.useState([]),[w,d]=v.useState(""),[T,C]=v.useState(!0),[H,q]=v.useState(!1),[Y,B]=v.useState(null),R=v.useCallback(async()=>{try{const U=await de.listContacts(w||void 0);x(U.items||[])}finally{C(!1)}},[w]);v.useEffect(()=>{R()},[R]);const D=()=>{B(null),q(!0)},j=U=>{B(U),q(!0)};return i.jsxs("div",{className:"h-full flex flex-col",children:[i.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-gray-200 dark:border-gray-700 flex-shrink-0",children:[i.jsx("h1",{className:"text-xl font-bold text-gray-900 dark:text-white",children:"Contacts"}),i.jsxs("button",{onClick:D,className:"flex items-center gap-2 px-4 py-2 bg-blue-600 hover:bg-blue-700 text-white text-sm font-medium rounded-xl transition-colors",children:[i.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 4v16m8-8H4"})}),"Add contact"]})]}),i.jsx("div",{className:"px-6 py-3 border-b border-gray-100 dark:border-gray-700/50 flex-shrink-0",children:i.jsxs("div",{className:"relative",children:[i.jsx("svg",{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"})}),i.jsx("input",{type:"text",placeholder:"Search contacts...",value:w,onChange:U=>d(U.target.value),className:"w-full pl-10 pr-4 py-2 rounded-xl border border-gray-200 dark:border-gray-600 bg-gray-50 dark:bg-gray-700/50 text-sm text-gray-900 dark:text-white focus:ring-2 focus:ring-blue-500 outline-none"})]})}),i.jsx("div",{className:"flex-1 overflow-y-auto",children:T?i.jsx("div",{className:"flex items-center justify-center h-40",children:i.jsx("div",{className:"w-6 h-6 border-2 border-blue-600 border-t-transparent rounded-full animate-spin"})}):r.length===0?i.jsxs("div",{className:"flex flex-col items-center justify-center h-40 text-gray-400 dark:text-gray-500",children:[i.jsx("svg",{className:"w-12 h-12 mb-2",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M17 20h5v-2a3 3 0 00-5.356-1.857M17 20H7m10 0v-2c0-.656-.126-1.283-.356-1.857M7 20H2v-2a3 3 0 015.356-1.857M7 20v-2c0-.656.126-1.283.356-1.857m0 0a5.002 5.002 0 019.288 0M15 7a3 3 0 11-6 0 3 3 0 016 0z"})}),i.jsx("span",{className:"text-sm",children:"No contacts yet"})]}):i.jsx("div",{className:"divide-y divide-gray-100 dark:divide-gray-700/50",children:r.map(U=>{var E,z;return i.jsxs("button",{onClick:()=>j(U),className:"w-full flex items-center gap-4 px-6 py-3.5 hover:bg-gray-50 dark:hover:bg-gray-800/50 transition-colors text-left",children:[i.jsx("div",{className:"w-10 h-10 rounded-full bg-gradient-to-br from-blue-500 to-purple-600 flex items-center justify-center text-white font-semibold text-sm flex-shrink-0",children:(((E=U.first_name)==null?void 0:E[0])||((z=U.email)==null?void 0:z[0])||"?").toUpperCase()}),i.jsxs("div",{className:"flex-1 min-w-0",children:[i.jsx("div",{className:"text-sm font-medium text-gray-900 dark:text-white truncate",children:[U.first_name,U.last_name].filter(Boolean).join(" ")||U.email||"Unnamed"}),i.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400 truncate",children:[U.email,U.company].filter(Boolean).join(" - ")})]}),U.phone&&i.jsx("span",{className:"text-xs text-gray-400 dark:text-gray-500 flex-shrink-0",children:U.phone})]},U.id)})})}),i.jsx(uh,{open:H,onClose:()=>q(!1),onSaved:R,contact:Y})]})}function uh({open:r,onClose:x,onSaved:w,contact:d}){const T=!!d,[C,H]=v.useState(""),[q,Y]=v.useState(""),[B,R]=v.useState(""),[D,j]=v.useState(""),[U,E]=v.useState(""),[z,_]=v.useState(""),[X,I]=v.useState(!1),[te,J]=v.useState(""),[ge,ce]=v.useState(!1);v.useEffect(()=>{r&&(J(""),ce(!1),d?(H(d.first_name||""),Y(d.last_name||""),R(d.email||""),j(d.phone||""),E(d.company||""),_(d.notes||"")):(H(""),Y(""),R(""),j(""),E(""),_("")))},[r,d]);const be=async Z=>{Z.preventDefault(),I(!0),J("");try{const Ne={first_name:C.trim()||void 0,last_name:q.trim()||void 0,email:B.trim()||void 0,phone:D.trim()||void 0,company:U.trim()||void 0,notes:z.trim()||void 0};T?await de.updateContact(d.id,Ne):await de.createContact(Ne),w(),x()}catch(Ne){J(Ne.error||"Failed to save contact")}finally{I(!1)}},P=async()=>{if(d){I(!0);try{await de.deleteContact(d.id),w(),x()}catch(Z){J(Z.error||"Failed to delete")}finally{I(!1)}}};return i.jsx(Il,{open:r,onClose:x,title:T?"Edit Contact":"New Contact",children:i.jsxs("form",{onSubmit:be,className:"space-y-4",children:[te&&i.jsx("div",{className:"text-sm text-red-600 dark:text-red-400 bg-red-50 dark:bg-red-900/20 px-3 py-2 rounded-lg",children:te}),i.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[i.jsxs("div",{children:[i.jsx("label",{className:"block text-xs font-medium text-gray-500 dark:text-gray-400 mb-1",children:"First name"}),i.jsx("input",{type:"text",value:C,onChange:Z=>H(Z.target.value),className:"w-full px-3 py-2 rounded-lg border border-gray-200 dark:border-gray-600 bg-gray-50 dark:bg-gray-700 text-sm text-gray-900 dark:text-white focus:ring-2 focus:ring-blue-500 outline-none",autoFocus:!0})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-xs font-medium text-gray-500 dark:text-gray-400 mb-1",children:"Last name"}),i.jsx("input",{type:"text",value:q,onChange:Z=>Y(Z.target.value),className:"w-full px-3 py-2 rounded-lg border border-gray-200 dark:border-gray-600 bg-gray-50 dark:bg-gray-700 text-sm text-gray-900 dark:text-white focus:ring-2 focus:ring-blue-500 outline-none"})]})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-xs font-medium text-gray-500 dark:text-gray-400 mb-1",children:"Email"}),i.jsx("input",{type:"email",value:B,onChange:Z=>R(Z.target.value),className:"w-full px-3 py-2 rounded-lg border border-gray-200 dark:border-gray-600 bg-gray-50 dark:bg-gray-700 text-sm text-gray-900 dark:text-white focus:ring-2 focus:ring-blue-500 outline-none"})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-xs font-medium text-gray-500 dark:text-gray-400 mb-1",children:"Phone"}),i.jsx("input",{type:"tel",value:D,onChange:Z=>j(Z.target.value),className:"w-full px-3 py-2 rounded-lg border border-gray-200 dark:border-gray-600 bg-gray-50 dark:bg-gray-700 text-sm text-gray-900 dark:text-white focus:ring-2 focus:ring-blue-500 outline-none"})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-xs font-medium text-gray-500 dark:text-gray-400 mb-1",children:"Company"}),i.jsx("input",{type:"text",value:U,onChange:Z=>E(Z.target.value),className:"w-full px-3 py-2 rounded-lg border border-gray-200 dark:border-gray-600 bg-gray-50 dark:bg-gray-700 text-sm text-gray-900 dark:text-white focus:ring-2 focus:ring-blue-500 outline-none"})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-xs font-medium text-gray-500 dark:text-gray-400 mb-1",children:"Notes"}),i.jsx("textarea",{value:z,onChange:Z=>_(Z.target.value),rows:2,className:"w-full px-3 py-2 rounded-lg border border-gray-200 dark:border-gray-600 bg-gray-50 dark:bg-gray-700 text-sm text-gray-900 dark:text-white focus:ring-2 focus:ring-blue-500 outline-none resize-none"})]}),i.jsxs("div",{className:"flex items-center justify-between pt-2",children:[i.jsxs("div",{children:[T&&!ge&&i.jsx("button",{type:"button",onClick:()=>ce(!0),className:"text-sm text-red-500 hover:text-red-700 dark:hover:text-red-400 transition-colors",children:"Delete"}),T&&ge&&i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{className:"text-sm text-red-500",children:"Delete?"}),i.jsx("button",{type:"button",onClick:P,className:"text-sm text-white bg-red-500 hover:bg-red-600 px-3 py-1 rounded-lg transition-colors",disabled:X,children:"Yes"}),i.jsx("button",{type:"button",onClick:()=>ce(!1),className:"text-sm text-gray-500 hover:text-gray-700 dark:text-gray-400 transition-colors",children:"No"})]})]}),i.jsxs("div",{className:"flex gap-2",children:[i.jsx("button",{type:"button",onClick:x,className:"px-4 py-2 text-sm text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-lg transition-colors",children:"Cancel"}),i.jsx("button",{type:"submit",disabled:X,className:"px-4 py-2 text-sm text-white bg-blue-600 hover:bg-blue-700 disabled:opacity-50 rounded-lg transition-colors font-medium",children:X?"Saving...":T?"Update":"Create"})]})]})]})})}const K0={low:"bg-gray-100 dark:bg-gray-700 text-gray-600 dark:text-gray-400",medium:"bg-blue-100 dark:bg-blue-900/40 text-blue-700 dark:text-blue-300",high:"bg-amber-100 dark:bg-amber-900/40 text-amber-700 dark:text-amber-300",critical:"bg-red-100 dark:bg-red-900/40 text-red-700 dark:text-red-300"};function ih({task:r,onDragStart:x,onClick:w}){var T;const d=K0[r.priority]||K0.medium;return i.jsx("div",{draggable:!!x,onDragStart:C=>x==null?void 0:x(C,r),onClick:w,className:"group cursor-pointer rounded-lg border border-gray-200 dark:border-gray-600 bg-white dark:bg-gray-800 p-3 shadow-sm hover:shadow-md transition-shadow",children:i.jsxs("div",{className:"flex items-start gap-2",children:[i.jsx("div",{className:"mt-0.5 cursor-grab active:cursor-grabbing text-gray-400 dark:text-gray-500 group-hover:text-gray-600 dark:group-hover:text-gray-400",children:i.jsx("svg",{className:"w-4 h-4",fill:"currentColor",viewBox:"0 0 20 20",children:i.jsx("path",{d:"M7 2a2 2 0 012 2v12a2 2 0 01-2 2h6a2 2 0 01-2-2V4a2 2 0 012-2h6z"})})}),i.jsxs("div",{className:"flex-1 min-w-0",children:[i.jsx("p",{className:"font-medium text-gray-900 dark:text-gray-100 truncate",children:r.title}),r.due_date&&i.jsxs("p",{className:"text-xs text-gray-500 dark:text-gray-400 mt-1",children:["Due ",_e(new Date(r.due_date),"MMM d, yyyy")]}),i.jsxs("div",{className:"flex flex-wrap gap-1 mt-2",children:[i.jsx("span",{className:`text-xs px-2 py-0.5 rounded ${d}`,children:r.priority}),(T=r.tags)==null?void 0:T.map(C=>i.jsx("span",{className:"text-xs px-2 py-0.5 rounded",style:{backgroundColor:`${C.color}20`,color:C.color},children:C.name},C.id))]})]})]})})}const ch=[{id:"todo",title:"To Do",status:"todo"},{id:"in_progress",title:"In Progress",status:"in_progress"},{id:"done",title:"Done",status:"done"}],sh={id:"archived",title:"Archived",status:"archived"};function rh({tasks:r,onTaskClick:x,onStatusChange:w,showArchived:d=!1}){const[T,C]=v.useState(null),[H,q]=v.useState(null),Y=d?[sh]:ch,B=Y.reduce((E,z)=>(E[z.status]=r.filter(_=>_.status===z.status),E),{}),R=(E,z)=>{C(z),E.dataTransfer.setData("text/plain",z.id),E.dataTransfer.effectAllowed="move"},D=(E,z)=>{E.preventDefault(),E.dataTransfer.dropEffect="move",q(z)},j=()=>{q(null)},U=(E,z)=>{E.preventDefault(),q(null);const _=E.dataTransfer.getData("text/plain");_&&T&&T.status!==z&&w(_,z),C(null)};return i.jsx("div",{className:"flex gap-4 overflow-x-auto pb-4 flex-1 min-h-0",children:Y.map(E=>{var z;return i.jsxs("div",{onDragOver:_=>D(_,E.status),onDragLeave:j,onDrop:_=>U(_,E.status),className:`flex-shrink-0 w-72 flex flex-col rounded-lg border-2 transition-colors ${H===E.status?"border-blue-400 dark:border-blue-500 bg-blue-50/50 dark:bg-blue-900/20":"border-gray-200 dark:border-gray-600"}`,children:[i.jsxs("div",{className:"p-3 border-b border-gray-200 dark:border-gray-600",children:[i.jsx("h3",{className:"font-semibold text-gray-900 dark:text-gray-100",children:E.title}),i.jsxs("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:[((z=B[E.status])==null?void 0:z.length)??0," tasks"]})]}),i.jsx("div",{className:"flex-1 p-3 overflow-y-auto space-y-2 min-h-[200px]",children:(B[E.status]??[]).map(_=>i.jsx(ih,{task:_,onDragStart:R,onClick:()=>x(_)},_.id))})]},E.id)})})}const dh=["todo","in_progress","done"],oh=["low","medium","high","critical"];function fh({open:r,onClose:x,onSaved:w,task:d,projects:T,tags:C}){const H=!!d,[q,Y]=v.useState(""),[B,R]=v.useState(""),[D,j]=v.useState("todo"),[U,E]=v.useState("medium"),[z,_]=v.useState(""),[X,I]=v.useState(""),[te,J]=v.useState(!1),[ge,ce]=v.useState(""),[be,P]=v.useState(!1);v.useEffect(()=>{r&&(ce(""),P(!1),d?(Y(d.title),R(d.description||""),j(d.status),E(d.priority),_(d.due_date?_e(new Date(d.due_date),"yyyy-MM-dd"):""),I(d.project_id||"")):(Y(""),R(""),j("todo"),E("medium"),_(""),I("")))},[r,d]);const Z=async ee=>{if(ee.preventDefault(),!!q.trim()){J(!0),ce("");try{H?await de.updateTask(d.id,{title:q.trim(),description:B||void 0,status:D,priority:U,due_date:z||void 0,project_id:X||void 0}):await de.createTask({title:q.trim(),description:B||void 0,status:D,priority:U,due_date:z||void 0,project_id:X||void 0}),w(),x()}catch(pe){ce((pe==null?void 0:pe.error)||"Failed to save task")}finally{J(!1)}}},Ne=async()=>{if(d){J(!0);try{await de.deleteTask(d.id),w(),x()}catch{ce("Failed to delete task")}finally{J(!1)}}};return i.jsx(Il,{open:r,onClose:x,title:H?"Edit Task":"New Task",wide:!0,children:i.jsxs("form",{onSubmit:Z,className:"space-y-4",children:[ge&&i.jsx("div",{className:"p-3 rounded-lg bg-red-50 dark:bg-red-900/20 text-red-600 dark:text-red-400 text-sm",children:ge}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Title"}),i.jsx("input",{type:"text",value:q,onChange:ee=>Y(ee.target.value),className:"w-full px-3 py-2 rounded-lg border border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-700 text-gray-900 dark:text-gray-100",placeholder:"Task title",required:!0})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Description"}),i.jsx("textarea",{value:B,onChange:ee=>R(ee.target.value),rows:3,className:"w-full px-3 py-2 rounded-lg border border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-700 text-gray-900 dark:text-gray-100",placeholder:"Markdown supported"})]}),i.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Status"}),i.jsx("select",{value:D,onChange:ee=>j(ee.target.value),className:"w-full px-3 py-2 rounded-lg border border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-700 text-gray-900 dark:text-gray-100",children:dh.map(ee=>i.jsx("option",{value:ee,children:ee.replace("_"," ")},ee))})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Priority"}),i.jsx("select",{value:U,onChange:ee=>E(ee.target.value),className:"w-full px-3 py-2 rounded-lg border border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-700 text-gray-900 dark:text-gray-100",children:oh.map(ee=>i.jsx("option",{value:ee,children:ee},ee))})]})]}),i.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Due Date"}),i.jsx("input",{type:"date",value:z,onChange:ee=>_(ee.target.value),className:"w-full px-3 py-2 rounded-lg border border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-700 text-gray-900 dark:text-gray-100"})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Project"}),i.jsxs("select",{value:X,onChange:ee=>I(ee.target.value),className:"w-full px-3 py-2 rounded-lg border border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-700 text-gray-900 dark:text-gray-100",children:[i.jsx("option",{value:"",children:"None"}),T.map(ee=>i.jsx("option",{value:ee.id,children:ee.name},ee.id))]})]})]}),i.jsxs("div",{className:"flex justify-between pt-4",children:[i.jsx("div",{children:H&&i.jsx("button",{type:"button",onClick:()=>P(!0),className:"text-red-600 dark:text-red-400 hover:underline text-sm",children:"Delete task"})}),i.jsxs("div",{className:"flex gap-2",children:[i.jsx("button",{type:"button",onClick:x,className:"px-4 py-2 rounded-lg border border-gray-300 dark:border-gray-600 text-gray-700 dark:text-gray-300 hover:bg-gray-50 dark:hover:bg-gray-700",children:"Cancel"}),i.jsx("button",{type:"submit",disabled:te||!q.trim(),className:"px-4 py-2 rounded-lg bg-blue-600 text-white hover:bg-blue-700 disabled:opacity-50",children:te?"Saving...":H?"Save":"Create"})]})]}),be&&i.jsxs("div",{className:"mt-4 p-4 rounded-lg bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800",children:[i.jsx("p",{className:"text-red-700 dark:text-red-300 text-sm mb-2",children:"Delete this task? This cannot be undone."}),i.jsxs("div",{className:"flex gap-2",children:[i.jsx("button",{type:"button",onClick:()=>P(!1),className:"px-3 py-1 rounded bg-gray-200 dark:bg-gray-600 text-sm",children:"Cancel"}),i.jsx("button",{type:"button",onClick:Ne,disabled:te,className:"px-3 py-1 rounded bg-red-600 text-white text-sm hover:bg-red-700 disabled:opacity-50",children:"Delete"})]})]})]})})}function gh({projects:r,selectedProjectId:x,onSelectProject:w,showArchived:d,onToggleArchived:T}){return i.jsxs("div",{className:"w-56 flex-shrink-0 border-r border-gray-200 dark:border-gray-700 flex flex-col",children:[i.jsx("div",{className:"p-3 border-b border-gray-200 dark:border-gray-700",children:i.jsx("h3",{className:"font-semibold text-gray-900 dark:text-gray-100 text-sm",children:"Projects"})}),i.jsxs("div",{className:"flex-1 overflow-y-auto p-2",children:[i.jsx("button",{onClick:()=>w(null),className:`w-full text-left px-3 py-2 rounded-lg text-sm transition-colors ${x===null?"bg-blue-100 dark:bg-blue-900/30 text-blue-700 dark:text-blue-300":"text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700"}`,children:"All Tasks"}),r.map(C=>i.jsxs("button",{onClick:()=>w(C.id),className:`w-full text-left px-3 py-2 rounded-lg text-sm transition-colors flex items-center gap-2 ${x===C.id?"bg-blue-100 dark:bg-blue-900/30 text-blue-700 dark:text-blue-300":"text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700"}`,children:[i.jsx("span",{className:"w-3 h-3 rounded-full flex-shrink-0",style:{backgroundColor:C.color}}),C.name]},C.id)),i.jsx("div",{className:"mt-2 pt-2 border-t border-gray-200 dark:border-gray-700",children:i.jsxs("label",{className:"flex items-center gap-2 px-3 py-2 cursor-pointer text-sm text-gray-600 dark:text-gray-400",children:[i.jsx("input",{type:"checkbox",checked:d,onChange:T,className:"rounded border-gray-300 dark:border-gray-600"}),"Show archived"]})})]})]})}function mh(){const[r,x]=v.useState([]),[w,d]=v.useState([]),[T,C]=v.useState([]),[H,q]=v.useState(!0),[Y,B]=v.useState(!1),[R,D]=v.useState(null),[j,U]=v.useState(null),[E,z]=v.useState(!1),_=v.useCallback(async()=>{try{const P={};j&&(P.project_id=j);const Z=await de.listTasks(P);x(Z.items||[])}catch{x([])}},[j]),X=v.useCallback(async()=>{try{const P=await de.listProjects();d(P.items||[])}catch{d([])}},[]),I=v.useCallback(async()=>{try{const P=await de.listTags();C(P.items||[])}catch{C([])}},[]);v.useEffect(()=>{q(!0),Promise.all([_(),X(),I()]).finally(()=>q(!1))},[_,X,I]);const te=P=>{D(P),B(!0)},J=async(P,Z)=>{try{Z==="done"?await de.markTaskComplete(P):await de.markTaskUncomplete(P,Z),_()}catch{x(Ne=>Ne)}},ge=()=>{_()},ce=()=>{B(!1),D(null)},be=E?r.filter(P=>P.status==="archived"):r.filter(P=>P.status!=="archived");return i.jsxs("div",{className:"h-full flex flex-col bg-gray-50 dark:bg-gray-900",children:[i.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-gray-200 dark:border-gray-700",children:[i.jsx("h1",{className:"text-xl font-semibold text-gray-900 dark:text-gray-100",children:"To-do List"}),i.jsx("button",{onClick:()=>{D(null),B(!0)},className:"px-4 py-2 rounded-lg bg-blue-600 text-white hover:bg-blue-700 transition-colors",children:"New Task"})]}),i.jsxs("div",{className:"flex-1 flex overflow-hidden",children:[i.jsx(gh,{projects:w,selectedProjectId:j,onSelectProject:U,showArchived:E,onToggleArchived:()=>z(P=>!P)}),i.jsx("div",{className:"flex-1 overflow-hidden p-4",children:H?i.jsx("div",{className:"flex items-center justify-center h-64",children:i.jsx("div",{className:"w-8 h-8 border-2 border-blue-600 border-t-transparent rounded-full animate-spin"})}):i.jsx(rh,{tasks:be,onTaskClick:te,onStatusChange:J,showArchived:E})})]}),i.jsx(fh,{open:Y,onClose:ce,onSaved:ge,task:R,projects:w,tags:T})]})}const hh=[{key:"calendars",label:"Calendars",permissions:["read","write"]},{key:"events",label:"Events",permissions:["read","write"]},{key:"contacts",label:"Contacts",permissions:["read","write"]},{key:"availability",label:"Availability",permissions:["read"]},{key:"booking",label:"Booking",permissions:["write"]}];function yh(){const{user:r,loading:x,refreshUser:w,logout:d}=Ya(),{theme:T,toggle:C}=ci(),H=_s(),[q,Y]=v.useState("general"),[B,R]=v.useState(!1),[D,j]=v.useState(""),[U,E]=v.useState({}),[z,_]=v.useState([]),[X,I]=v.useState(!1),[te,J]=v.useState(!1),[ge,ce]=v.useState(""),[be,P]=v.useState({calendars:["read","write"],events:["read","write"],contacts:["read","write"],availability:["read"],booking:["write"]}),[Z,Ne]=v.useState(null),[ee,pe]=v.useState(null),[Qe,Ve]=v.useState(""),[Re,p]=v.useState(!1);v.useEffect(()=>{r&&E({timezone:r.timezone,week_start_day:r.week_start_day,date_format:r.date_format,time_format:r.time_format,default_event_duration_minutes:r.default_event_duration_minutes,default_reminder_minutes:r.default_reminder_minutes,show_weekends:r.show_weekends,working_hours_start:r.working_hours_start,working_hours_end:r.working_hours_end,notifications_email:r.notifications_email})},[r]),v.useEffect(()=>{q==="api-keys"&&(I(!0),de.listApiKeys().then(M=>_(M.items)).catch(()=>j("Failed to load API keys")).finally(()=>I(!1)))},[q]);const O=async()=>{R(!0),j("");try{const M=await de.updateMe(U);await w(),j("Settings saved"),setTimeout(()=>j(""),2e3)}catch(M){j(M.error||"Failed to save")}finally{R(!1)}},V=async()=>{if(!ge.trim()){j("Name is required");return}R(!0),j("");try{const M=await de.createApiKey({name:ge.trim(),scopes:be});Ne(M),_(A=>[M,...A]),J(!1),ce("")}catch(M){j(M.error||"Failed to create API key")}finally{R(!1)}},me=async M=>{pe(M);try{await de.revokeApiKey(M),_(A=>A.map(ve=>ve.id===M?{...ve,revoked_at:new Date().toISOString()}:ve))}catch(A){j(A.error||"Failed to revoke")}finally{pe(null)}},oe=async()=>{if(Qe==="delete"){p(!0),j("");try{await de.deleteMe(),await d(),H("/login")}catch(M){j(M.error||"Failed to delete account")}finally{p(!1)}}},Q=()=>{Z!=null&&Z.token&&(navigator.clipboard.writeText(Z.token),j("Token copied to clipboard"),setTimeout(()=>j(""),2e3))};if(x||!r)return null;const ne=[{id:"general",label:"General"},{id:"calendars",label:"Calendars"},{id:"notifications",label:"Notifications"},{id:"api-keys",label:"API Keys"},{id:"account",label:"Account"}];return i.jsxs("div",{className:"h-full flex flex-col overflow-hidden",children:[i.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-gray-200 dark:border-gray-700",children:[i.jsx("h1",{className:"text-xl font-bold text-gray-900 dark:text-white",children:"Settings"}),i.jsx("button",{onClick:C,className:"p-2 rounded-xl hover:bg-gray-100 dark:hover:bg-gray-700 text-gray-600 dark:text-gray-400 transition-colors",children:T==="dark"?i.jsx("svg",{className:"w-5 h-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 3v1m0 16v1m9-9h-1M4 12H3m15.364 6.364l-.707-.707M6.343 6.343l-.707-.707m12.728 0l-.707.707M6.343 17.657l-.707.707M16 12a4 4 0 11-8 0 4 4 0 018 0z"})}):i.jsx("svg",{className:"w-5 h-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M20.354 15.354A9 9 0 018.646 3.646 9.003 9.003 0 0012 21a9.003 9.003 0 008.354-5.646z"})})})]}),i.jsxs("div",{className:"flex flex-1 overflow-hidden",children:[i.jsx("nav",{className:"w-48 border-r border-gray-200 dark:border-gray-700 p-4 flex-shrink-0",children:ne.map(M=>i.jsx("button",{onClick:()=>Y(M.id),className:`block w-full text-left px-3 py-2 rounded-lg text-sm font-medium transition-colors ${q===M.id?"bg-blue-100 dark:bg-blue-900/30 text-blue-700 dark:text-blue-400":"text-gray-600 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-800"}`,children:M.label},M.id))}),i.jsxs("main",{className:"flex-1 overflow-y-auto p-6",children:[D&&i.jsx("div",{className:`mb-4 px-4 py-2 rounded-lg text-sm ${D==="Settings saved"||D==="Token copied to clipboard"?"bg-green-50 dark:bg-green-900/20 text-green-700 dark:text-green-400":"bg-red-50 dark:bg-red-900/20 text-red-600 dark:text-red-400"}`,children:D}),q==="general"&&i.jsxs("div",{className:"space-y-6 max-w-xl",children:[i.jsx("h2",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:"General"}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Timezone"}),i.jsx("input",{type:"text",value:U.timezone||"",onChange:M=>E(A=>({...A,timezone:M.target.value})),placeholder:"America/New_York",className:"w-full px-3 py-2 rounded-lg border border-gray-200 dark:border-gray-600 bg-gray-50 dark:bg-gray-700 text-sm text-gray-900 dark:text-white focus:ring-2 focus:ring-blue-500 outline-none"})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Week starts on"}),i.jsxs("select",{value:U.week_start_day??0,onChange:M=>E(A=>({...A,week_start_day:parseInt(M.target.value,10)})),className:"w-full px-3 py-2 rounded-lg border border-gray-200 dark:border-gray-600 bg-gray-50 dark:bg-gray-700 text-sm text-gray-900 dark:text-white focus:ring-2 focus:ring-blue-500 outline-none",children:[i.jsx("option",{value:0,children:"Sunday"}),i.jsx("option",{value:1,children:"Monday"})]})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Date format"}),i.jsxs("select",{value:U.date_format||"MM/dd/yyyy",onChange:M=>E(A=>({...A,date_format:M.target.value})),className:"w-full px-3 py-2 rounded-lg border border-gray-200 dark:border-gray-600 bg-gray-50 dark:bg-gray-700 text-sm text-gray-900 dark:text-white focus:ring-2 focus:ring-blue-500 outline-none",children:[i.jsx("option",{value:"MM/dd/yyyy",children:"MM/DD/YYYY"}),i.jsx("option",{value:"dd/MM/yyyy",children:"DD/MM/YYYY"}),i.jsx("option",{value:"yyyy-MM-dd",children:"YYYY-MM-DD"})]})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Time format"}),i.jsxs("select",{value:U.time_format||"12h",onChange:M=>E(A=>({...A,time_format:M.target.value})),className:"w-full px-3 py-2 rounded-lg border border-gray-200 dark:border-gray-600 bg-gray-50 dark:bg-gray-700 text-sm text-gray-900 dark:text-white focus:ring-2 focus:ring-blue-500 outline-none",children:[i.jsx("option",{value:"12h",children:"12-hour"}),i.jsx("option",{value:"24h",children:"24-hour"})]})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Default event duration (minutes)"}),i.jsx("input",{type:"number",min:15,max:480,value:U.default_event_duration_minutes??60,onChange:M=>E(A=>({...A,default_event_duration_minutes:parseInt(M.target.value,10)||60})),className:"w-full px-3 py-2 rounded-lg border border-gray-200 dark:border-gray-600 bg-gray-50 dark:bg-gray-700 text-sm text-gray-900 dark:text-white focus:ring-2 focus:ring-blue-500 outline-none"})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Default reminder (minutes before)"}),i.jsx("input",{type:"number",min:0,max:10080,value:U.default_reminder_minutes??10,onChange:M=>E(A=>({...A,default_reminder_minutes:parseInt(M.target.value,10)||10})),className:"w-full px-3 py-2 rounded-lg border border-gray-200 dark:border-gray-600 bg-gray-50 dark:bg-gray-700 text-sm text-gray-900 dark:text-white focus:ring-2 focus:ring-blue-500 outline-none"})]}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("input",{type:"checkbox",id:"show_weekends",checked:U.show_weekends??!0,onChange:M=>E(A=>({...A,show_weekends:M.target.checked})),className:"rounded border-gray-300 dark:border-gray-600 text-blue-600 focus:ring-blue-500"}),i.jsx("label",{htmlFor:"show_weekends",className:"text-sm text-gray-700 dark:text-gray-300",children:"Show weekends"})]}),i.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Working hours start"}),i.jsx("input",{type:"time",value:U.working_hours_start||"09:00",onChange:M=>E(A=>({...A,working_hours_start:M.target.value})),className:"w-full px-3 py-2 rounded-lg border border-gray-200 dark:border-gray-600 bg-gray-50 dark:bg-gray-700 text-sm text-gray-900 dark:text-white focus:ring-2 focus:ring-blue-500 outline-none"})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Working hours end"}),i.jsx("input",{type:"time",value:U.working_hours_end||"17:00",onChange:M=>E(A=>({...A,working_hours_end:M.target.value})),className:"w-full px-3 py-2 rounded-lg border border-gray-200 dark:border-gray-600 bg-gray-50 dark:bg-gray-700 text-sm text-gray-900 dark:text-white focus:ring-2 focus:ring-blue-500 outline-none"})]})]})]}),q==="calendars"&&i.jsxs("div",{className:"space-y-4",children:[i.jsx("h2",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:"Calendars"}),i.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:"Manage your calendars from the main calendar view. Use the sidebar to add new calendars or add from URL."})]}),q==="notifications"&&i.jsxs("div",{className:"space-y-6 max-w-xl",children:[i.jsx("h2",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:"Notifications"}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("input",{type:"checkbox",id:"notifications_email",checked:U.notifications_email??!0,onChange:M=>E(A=>({...A,notifications_email:M.target.checked})),className:"rounded border-gray-300 dark:border-gray-600 text-blue-600 focus:ring-blue-500"}),i.jsx("label",{htmlFor:"notifications_email",className:"text-sm text-gray-700 dark:text-gray-300",children:"Email reminders for events"})]})]}),q==="api-keys"&&i.jsxs("div",{className:"space-y-6 max-w-2xl",children:[i.jsx("h2",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:"API Keys"}),i.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:"API keys allow programmatic access to your calendar. Use them for integrations, scripts, or AI agents. Keep keys secure and never share them."}),i.jsxs("div",{className:"flex justify-between items-center",children:[i.jsxs("span",{className:"text-sm text-gray-600 dark:text-gray-400",children:[z.length," key",z.length!==1?"s":""]}),i.jsx("button",{onClick:()=>{J(!0),Ne(null),j("")},className:"px-4 py-2 bg-blue-600 hover:bg-blue-700 text-white text-sm font-medium rounded-lg transition-colors",children:"Create API key"})]}),X?i.jsxs("div",{className:"flex items-center gap-2 text-gray-500 dark:text-gray-400",children:[i.jsx("span",{className:"w-4 h-4 border-2 border-gray-400 border-t-transparent rounded-full animate-spin"}),"Loading..."]}):i.jsx("div",{className:"space-y-6 max-w-2xl",children:z.length===0?i.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400 py-4",children:"No API keys yet. Create one to get started."}):i.jsx("ul",{className:"divide-y divide-gray-200 dark:divide-gray-700",children:z.map(M=>i.jsxs("li",{className:"py-4 flex items-center justify-between gap-4",children:[i.jsxs("div",{className:"flex-1 min-w-0",children:[i.jsx("p",{className:"font-medium text-gray-900 dark:text-white truncate",children:M.name}),i.jsxs("p",{className:"text-xs text-gray-500 dark:text-gray-400 mt-0.5",children:["Created ",new Date(M.created_at).toLocaleDateString(),M.revoked_at&&i.jsx("span",{className:"ml-2 text-amber-600 dark:text-amber-400",children:"• Revoked"})]})]}),!M.revoked_at&&i.jsx("button",{onClick:()=>me(M.id),disabled:ee===M.id,className:"px-3 py-1.5 text-sm text-red-600 dark:text-red-400 hover:bg-red-50 dark:hover:bg-red-900/20 rounded-lg transition-colors disabled:opacity-50",children:ee===M.id?"Revoking...":"Revoke"})]},M.id))})})]}),q==="account"&&i.jsxs("div",{className:"space-y-6 max-w-xl",children:[i.jsx("h2",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:"Account"}),i.jsxs("div",{className:"rounded-lg border border-gray-200 dark:border-gray-600 p-4 dark:bg-gray-800/50",children:[i.jsxs("p",{className:"text-sm text-gray-600 dark:text-gray-400 mb-2",children:["Signed in as ",i.jsx("span",{className:"font-medium text-gray-900 dark:text-white",children:r.email})]}),i.jsxs("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:["Account created ",new Date(r.created_at).toLocaleDateString()]})]}),i.jsxs("div",{className:"pt-6 border-t border-gray-200 dark:border-gray-700",children:[i.jsx("h3",{className:"text-sm font-medium text-red-600 dark:text-red-400 mb-2",children:"Danger zone"}),i.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400 mb-4",children:"Deleting your account will permanently remove all your calendars, events, contacts, and revoke all API keys. This action cannot be undone."}),i.jsxs("div",{className:"flex flex-wrap items-end gap-4",children:[i.jsxs("div",{className:"flex-1 min-w-[200px]",children:[i.jsxs("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:["Type ",i.jsx("span",{className:"font-mono text-red-600 dark:text-red-400",children:"delete"})," to confirm"]}),i.jsx("input",{type:"text",value:Qe,onChange:M=>Ve(M.target.value),placeholder:"delete",className:"w-full px-3 py-2 rounded-lg border border-gray-200 dark:border-gray-600 bg-gray-50 dark:bg-gray-700 text-sm text-gray-900 dark:text-white focus:ring-2 focus:ring-red-500 outline-none placeholder:text-gray-400"})]}),i.jsx("button",{onClick:oe,disabled:Qe!=="delete"||Re,className:"px-4 py-2 bg-red-600 hover:bg-red-700 disabled:opacity-50 disabled:cursor-not-allowed text-white text-sm font-medium rounded-lg transition-colors",children:Re?"Deleting...":"Delete account"})]})]})]}),(q==="general"||q==="notifications")&&i.jsx("div",{className:"mt-8",children:i.jsx("button",{onClick:O,disabled:B,className:"px-4 py-2 bg-blue-600 hover:bg-blue-700 disabled:opacity-50 text-white text-sm font-medium rounded-lg transition-colors",children:B?"Saving...":"Save changes"})})]})]}),i.jsx(Il,{open:te,onClose:()=>{J(!1),ce("")},title:"Create API key",wide:!0,children:i.jsxs("div",{className:"space-y-4",children:[i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:"Name"}),i.jsx("input",{type:"text",value:ge,onChange:M=>ce(M.target.value),placeholder:"e.g. My integration",className:"w-full px-3 py-2 rounded-lg border border-gray-200 dark:border-gray-600 bg-gray-50 dark:bg-gray-700 text-sm text-gray-900 dark:text-white focus:ring-2 focus:ring-blue-500 outline-none"})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:"Scopes"}),i.jsx("div",{className:"space-y-3",children:hh.map(({key:M,label:A,permissions:ve})=>i.jsxs("div",{className:"flex items-center gap-4",children:[i.jsx("span",{className:"w-28 text-sm text-gray-600 dark:text-gray-400",children:A}),i.jsx("div",{className:"flex gap-4",children:ve.map(Ke=>{const Yt=(be[M]||[]).includes(Ke);return i.jsxs("label",{className:"flex items-center gap-1.5 cursor-pointer",children:[i.jsx("input",{type:"checkbox",checked:Yt,onChange:At=>{const W=At.target.checked?[...be[M]||[],Ke]:(be[M]||[]).filter(Ee=>Ee!==Ke);P(Ee=>({...Ee,[M]:W}))},className:"rounded border-gray-300 dark:border-gray-600 text-blue-600 focus:ring-blue-500"}),i.jsx("span",{className:"text-sm text-gray-700 dark:text-gray-300 capitalize",children:Ke})]},Ke)})})]},M))})]}),i.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[i.jsx("button",{onClick:()=>J(!1),className:"px-4 py-2 text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-lg transition-colors",children:"Cancel"}),i.jsx("button",{onClick:V,disabled:B||!ge.trim(),className:"px-4 py-2 bg-blue-600 hover:bg-blue-700 disabled:opacity-50 text-white text-sm font-medium rounded-lg transition-colors",children:B?"Creating...":"Create"})]})]})}),i.jsx(Il,{open:!!(Z!=null&&Z.token),onClose:()=>Ne(null),title:"API key created",children:i.jsxs("div",{className:"space-y-4",children:[i.jsx("p",{className:"text-sm text-amber-600 dark:text-amber-400",children:"Copy this token now. It will not be shown again."}),i.jsxs("div",{className:"flex gap-2",children:[i.jsx("input",{type:"text",readOnly:!0,value:(Z==null?void 0:Z.token)||"",className:"flex-1 px-3 py-2 rounded-lg border border-gray-200 dark:border-gray-600 bg-gray-100 dark:bg-gray-700 text-sm font-mono text-gray-900 dark:text-white"}),i.jsx("button",{onClick:Q,className:"px-4 py-2 bg-blue-600 hover:bg-blue-700 text-white text-sm font-medium rounded-lg transition-colors",children:"Copy"})]}),i.jsxs("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:["Use in requests: ",i.jsx("code",{className:"bg-gray-100 dark:bg-gray-700 px-1 rounded",children:"X-API-Key: "})]}),i.jsx("div",{className:"flex justify-end",children:i.jsx("button",{onClick:()=>Ne(null),className:"px-4 py-2 bg-gray-200 dark:bg-gray-600 hover:bg-gray-300 dark:hover:bg-gray-500 text-gray-900 dark:text-white text-sm font-medium rounded-lg transition-colors",children:"Done"})})]})})]})}function xh(){const{user:r,loading:x}=Ya();return x?i.jsx("div",{className:"h-screen flex items-center justify-center bg-white dark:bg-gray-900",children:i.jsx("div",{className:"w-8 h-8 border-2 border-blue-600 border-t-transparent rounded-full animate-spin"})}):r?i.jsx(Os,{}):i.jsx(ws,{to:"/login",replace:!0})}function bh(){const{user:r,loading:x}=Ya();return x?i.jsx("div",{className:"h-screen flex items-center justify-center bg-white dark:bg-gray-900",children:i.jsx("div",{className:"w-8 h-8 border-2 border-blue-600 border-t-transparent rounded-full animate-spin"})}):r?i.jsx(ws,{to:"/",replace:!0}):i.jsx(Os,{})}function vh(){return i.jsxs("div",{className:"h-screen flex bg-white dark:bg-gray-900 transition-colors",children:[i.jsxs("nav",{className:"w-14 flex-shrink-0 flex flex-col items-center py-4 gap-1 border-r border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-900",children:[i.jsx(ei,{to:"/",end:!0,className:({isActive:r})=>`p-2.5 rounded-xl transition-colors ${r?"bg-blue-100 dark:bg-blue-900/30 text-blue-600 dark:text-blue-400":"text-gray-500 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-800 hover:text-gray-700 dark:hover:text-gray-300"}`,title:"Calendar",children:i.jsx("svg",{className:"w-5 h-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 7V3m8 4V3m-9 8h10M5 21h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z"})})}),i.jsx(ei,{to:"/todo",className:({isActive:r})=>`p-2.5 rounded-xl transition-colors ${r?"bg-blue-100 dark:bg-blue-900/30 text-blue-600 dark:text-blue-400":"text-gray-500 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-800 hover:text-gray-700 dark:hover:text-gray-300"}`,title:"To-do",children:i.jsx("svg",{className:"w-5 h-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"})})}),i.jsx(ei,{to:"/contacts",className:({isActive:r})=>`p-2.5 rounded-xl transition-colors ${r?"bg-blue-100 dark:bg-blue-900/30 text-blue-600 dark:text-blue-400":"text-gray-500 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-800 hover:text-gray-700 dark:hover:text-gray-300"}`,title:"Contacts",children:i.jsx("svg",{className:"w-5 h-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M17 20h5v-2a3 3 0 00-5.356-1.857M17 20H7m10 0v-2c0-.656-.126-1.283-.356-1.857M7 20H2v-2a3 3 0 015.356-1.857M7 20v-2c0-.656.126-1.283.356-1.857m0 0a5.002 5.002 0 019.288 0M15 7a3 3 0 11-6 0 3 3 0 016 0z"})})}),i.jsx(ei,{to:"/settings",className:({isActive:r})=>`p-2.5 rounded-xl transition-colors ${r?"bg-blue-100 dark:bg-blue-900/30 text-blue-600 dark:text-blue-400":"text-gray-500 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-800 hover:text-gray-700 dark:hover:text-gray-300"}`,title:"Settings",children:i.jsxs("svg",{className:"w-5 h-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:[i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.065-2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z"}),i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"})]})})]}),i.jsx("div",{className:"flex-1 overflow-hidden",children:i.jsx(Os,{})})]})}function ph(){return i.jsxs(Cm,{children:[i.jsxs(qt,{element:i.jsx(bh,{}),children:[i.jsx(qt,{path:"/login",element:i.jsx(Km,{})}),i.jsx(qt,{path:"/register",element:i.jsx(Jm,{})})]}),i.jsx(qt,{element:i.jsx(xh,{}),children:i.jsxs(qt,{element:i.jsx(vh,{}),children:[i.jsx(qt,{path:"/",element:i.jsx(ah,{})}),i.jsx(qt,{path:"/todo",element:i.jsx(mh,{})}),i.jsx(qt,{path:"/contacts",element:i.jsx(nh,{})}),i.jsx(qt,{path:"/settings",element:i.jsx(yh,{})})]})}),i.jsx(qt,{path:"*",element:i.jsx(ws,{to:"/",replace:!0})})]})}Lm.createRoot(document.getElementById("root")).render(i.jsx(v.StrictMode,{children:i.jsx(Vm,{children:i.jsx(Am,{children:i.jsx(Zm,{children:i.jsx(Qm,{children:i.jsx(ph,{})})})})})}));