/")+"/"),Eh(s,e,r,"",function(d){return d})):s!=null&&(bg(s)&&(s=xD(s,r+(!s.key||i&&i.key===s.key?"":(""+s.key).replace(b1,"/")+"/")+t)),e.push(s)),1;if(i=0,n=n===""?".":n+":",v1(t))for(var a=0;a>>1,$=M[ne];if(0>>1;nes(O,H))z<&0>s(F,O)?(M[ne]=F,M[z]=H,ne=z):(M[ne]=O,M[J]=H,ne=J);else if(z<&0>s(F,H))M[ne]=F,M[z]=H,ne=z;else break e}}return D}function s(M,D){var H=M.sortIndex-D.sortIndex;return H!==0?H:M.id-D.id}if(typeof performance=="object"&&typeof performance.now=="function"){var o=performance;t.unstable_now=function(){return o.now()}}else{var i=Date,a=i.now();t.unstable_now=function(){return i.now()-a}}var c=[],d=[],u=1,h=null,f=3,p=!1,g=!1,v=!1,y=typeof setTimeout=="function"?setTimeout:null,x=typeof clearTimeout=="function"?clearTimeout:null,w=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function b(M){for(var D=r(d);D!==null;){if(D.callback===null)n(d);else if(D.startTime<=M)n(d),D.sortIndex=D.expirationTime,e(c,D);else break;D=r(d)}}function k(M){if(v=!1,b(M),!g)if(r(c)!==null)g=!0,L(S);else{var D=r(d);D!==null&&U(k,D.startTime-M)}}function S(M,D){g=!1,v&&(v=!1,x(E),E=-1),p=!0;var H=f;try{for(b(D),h=r(c);h!==null&&(!(h.expirationTime>D)||M&&!P());){var ne=h.callback;if(typeof ne=="function"){h.callback=null,f=h.priorityLevel;var $=ne(h.expirationTime<=D);D=t.unstable_now(),typeof $=="function"?h.callback=$:h===r(c)&&n(c),b(D)}else n(c);h=r(c)}if(h!==null)var G=!0;else{var J=r(d);J!==null&&U(k,J.startTime-D),G=!1}return G}finally{h=null,f=H,p=!1}}var C=!1,N=null,E=-1,j=5,_=-1;function P(){return!(t.unstable_now()-_M||125ne?(M.sortIndex=H,e(d,M),r(c)===null&&M===r(d)&&(v?(x(E),E=-1):v=!0,U(k,H-ne))):(M.sortIndex=$,e(c,M),g||p||(g=!0,L(S))),M},t.unstable_shouldYield=P,t.unstable_wrapCallback=function(M){var D=f;return function(){var H=f;f=D;try{return M.apply(this,arguments)}finally{f=H}}}})(j1),C1.exports=j1;var TD=C1.exports;/** * @license React * react-dom.production.min.js * * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */var RD=m,Yr=TD;function X(t){for(var e="https://reactjs.org/docs/error-decoder.html?invariant="+t,r=1;r"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Ng=Object.prototype.hasOwnProperty,MD=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,_1={},T1={};function OD(t){return Ng.call(T1,t)?!0:Ng.call(_1,t)?!1:MD.test(t)?T1[t]=!0:(_1[t]=!0,!1)}function PD(t,e,r,n){if(r!==null&&r.type===0)return!1;switch(typeof e){case"function":case"symbol":return!0;case"boolean":return n?!1:r!==null?!r.acceptsBooleans:(t=t.toLowerCase().slice(0,5),t!=="data-"&&t!=="aria-");default:return!1}}function AD(t,e,r,n){if(e===null||typeof e>"u"||PD(t,e,r,n))return!0;if(n)return!1;if(r!==null)switch(r.type){case 3:return!e;case 4:return e===!1;case 5:return isNaN(e);case 6:return isNaN(e)||1>e}return!1}function wr(t,e,r,n,s,o,i){this.acceptsBooleans=e===2||e===3||e===4,this.attributeName=n,this.attributeNamespace=s,this.mustUseProperty=r,this.propertyName=t,this.type=e,this.sanitizeURL=o,this.removeEmptyString=i}var Qt={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(t){Qt[t]=new wr(t,0,!1,t,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(t){var e=t[0];Qt[e]=new wr(e,1,!1,t[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(t){Qt[t]=new wr(t,2,!1,t.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(t){Qt[t]=new wr(t,2,!1,t,null,!1,!1)}),"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(t){Qt[t]=new wr(t,3,!1,t.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(t){Qt[t]=new wr(t,3,!0,t,null,!1,!1)}),["capture","download"].forEach(function(t){Qt[t]=new wr(t,4,!1,t,null,!1,!1)}),["cols","rows","size","span"].forEach(function(t){Qt[t]=new wr(t,6,!1,t,null,!1,!1)}),["rowSpan","start"].forEach(function(t){Qt[t]=new wr(t,5,!1,t.toLowerCase(),null,!1,!1)});var Cg=/[\-:]([a-z])/g;function jg(t){return t[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(t){var e=t.replace(Cg,jg);Qt[e]=new wr(e,1,!1,t,null,!1,!1)}),"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(t){var e=t.replace(Cg,jg);Qt[e]=new wr(e,1,!1,t,"http://www.w3.org/1999/xlink",!1,!1)}),["xml:base","xml:lang","xml:space"].forEach(function(t){var e=t.replace(Cg,jg);Qt[e]=new wr(e,1,!1,t,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(t){Qt[t]=new wr(t,1,!1,t.toLowerCase(),null,!1,!1)}),Qt.xlinkHref=new wr("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(t){Qt[t]=new wr(t,1,!1,t.toLowerCase(),null,!0,!0)});function Eg(t,e,r,n){var s=Qt.hasOwnProperty(e)?Qt[e]:null;(s!==null?s.type!==0:n||!(2a||s[i]!==o[a]){var c=` `+s[i].replace(" at new "," at ");return t.displayName&&c.includes("")&&(c=c.replace("",t.displayName)),c}while(1<=i&&0<=a);break}}}finally{Ig=!1,Error.prepareStackTrace=r}return(t=t?t.displayName||t.name:"")?Jc(t):""}function ID(t){switch(t.tag){case 5:return Jc(t.type);case 16:return Jc("Lazy");case 13:return Jc("Suspense");case 19:return Jc("SuspenseList");case 0:case 2:case 15:return t=Dg(t.type,!1),t;case 11:return t=Dg(t.type.render,!1),t;case 1:return t=Dg(t.type,!0),t;default:return""}}function Lg(t){if(t==null)return null;if(typeof t=="function")return t.displayName||t.name||null;if(typeof t=="string")return t;switch(t){case Ja:return"Fragment";case Ya:return"Portal";case Tg:return"Profiler";case _g:return"StrictMode";case Mg:return"Suspense";case Og:return"SuspenseList"}if(typeof t=="object")switch(t.$typeof){case M1:return(t.displayName||"Context")+".Consumer";case R1:return(t._context.displayName||"Context")+".Provider";case Rg:var e=t.render;return t=t.displayName,t||(t=e.displayName||e.name||"",t=t!==""?"ForwardRef("+t+")":"ForwardRef"),t;case Pg:return e=t.displayName||null,e!==null?e:Lg(t.type)||"Memo";case vo:e=t._payload,t=t._init;try{return Lg(t(e))}catch{}}return null}function DD(t){var e=t.type;switch(t.tag){case 24:return"Cache";case 9:return(e.displayName||"Context")+".Consumer";case 10:return(e._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return t=e.render,t=t.displayName||t.name||"",e.displayName||(t!==""?"ForwardRef("+t+")":"ForwardRef");case 7:return"Fragment";case 5:return e;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return Lg(e);case 8:return e===_g?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e}return null}function yo(t){switch(typeof t){case"boolean":case"number":case"string":case"undefined":return t;case"object":return t;default:return""}}function A1(t){var e=t.type;return(t=t.nodeName)&&t.toLowerCase()==="input"&&(e==="checkbox"||e==="radio")}function LD(t){var e=A1(t)?"checked":"value",r=Object.getOwnPropertyDescriptor(t.constructor.prototype,e),n=""+t[e];if(!t.hasOwnProperty(e)&&typeof r<"u"&&typeof r.get=="function"&&typeof r.set=="function"){var s=r.get,o=r.set;return Object.defineProperty(t,e,{configurable:!0,get:function(){return s.call(this)},set:function(i){n=""+i,o.call(this,i)}}),Object.defineProperty(t,e,{enumerable:r.enumerable}),{getValue:function(){return n},setValue:function(i){n=""+i},stopTracking:function(){t._valueTracker=null,delete t[e]}}}}function Mh(t){t._valueTracker||(t._valueTracker=LD(t))}function I1(t){if(!t)return!1;var e=t._valueTracker;if(!e)return!0;var r=e.getValue(),n="";return t&&(n=A1(t)?t.checked?"true":"false":t.value),t=n,t!==r?(e.setValue(t),!0):!1}function Oh(t){if(t=t||(typeof document<"u"?document:void 0),typeof t>"u")return null;try{return t.activeElement||t.body}catch{return t.body}}function $g(t,e){var r=e.checked;return rt({},e,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:r??t._wrapperState.initialChecked})}function D1(t,e){var r=e.defaultValue==null?"":e.defaultValue,n=e.checked!=null?e.checked:e.defaultChecked;r=yo(e.value!=null?e.value:r),t._wrapperState={initialChecked:n,initialValue:r,controlled:e.type==="checkbox"||e.type==="radio"?e.checked!=null:e.value!=null}}function L1(t,e){e=e.checked,e!=null&&Eg(t,"checked",e,!1)}function Fg(t,e){L1(t,e);var r=yo(e.value),n=e.type;if(r!=null)n==="number"?(r===0&&t.value===""||t.value!=r)&&(t.value=""+r):t.value!==""+r&&(t.value=""+r);else if(n==="submit"||n==="reset"){t.removeAttribute("value");return}e.hasOwnProperty("value")?zg(t,e.type,r):e.hasOwnProperty("defaultValue")&&zg(t,e.type,yo(e.defaultValue)),e.checked==null&&e.defaultChecked!=null&&(t.defaultChecked=!!e.defaultChecked)}function $1(t,e,r){if(e.hasOwnProperty("value")||e.hasOwnProperty("defaultValue")){var n=e.type;if(!(n!=="submit"&&n!=="reset"||e.value!==void 0&&e.value!==null))return;e=""+t._wrapperState.initialValue,r||e===t.value||(t.value=e),t.defaultValue=e}r=t.name,r!==""&&(t.name=""),t.defaultChecked=!!t._wrapperState.initialChecked,r!==""&&(t.name=r)}function zg(t,e,r){(e!=="number"||Oh(t.ownerDocument)!==t)&&(r==null?t.defaultValue=""+t._wrapperState.initialValue:t.defaultValue!==""+r&&(t.defaultValue=""+r))}var Qc=Array.isArray;function Qa(t,e,r,n){if(t=t.options,e){e={};for(var s=0;s"+e.valueOf().toString()+"",e=Ph.firstChild;t.firstChild;)t.removeChild(t.firstChild);for(;e.firstChild;)t.appendChild(e.firstChild)}});function Xc(t,e){if(e){var r=t.firstChild;if(r&&r===t.lastChild&&r.nodeType===3){r.nodeValue=e;return}}t.textContent=e}var Zc={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},$D=["Webkit","ms","Moz","O"];Object.keys(Zc).forEach(function(t){$D.forEach(function(e){e=e+t.charAt(0).toUpperCase()+t.substring(1),Zc[e]=Zc[t]})});function W1(t,e,r){return e==null||typeof e=="boolean"||e===""?"":r||typeof e!="number"||e===0||Zc.hasOwnProperty(t)&&Zc[t]?(""+e).trim():e+"px"}function H1(t,e){t=t.style;for(var r in e)if(e.hasOwnProperty(r)){var n=r.indexOf("--")===0,s=W1(r,e[r],n);r==="float"&&(r="cssFloat"),n?t.setProperty(r,s):t[r]=s}}var FD=rt({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function Vg(t,e){if(e){if(FD[t]&&(e.children!=null||e.dangerouslySetInnerHTML!=null))throw Error(X(137,t));if(e.dangerouslySetInnerHTML!=null){if(e.children!=null)throw Error(X(60));if(typeof e.dangerouslySetInnerHTML!="object"||!("__html"in e.dangerouslySetInnerHTML))throw Error(X(61))}if(e.style!=null&&typeof e.style!="object")throw Error(X(62))}}function Wg(t,e){if(t.indexOf("-")===-1)return typeof e.is=="string";switch(t){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var Hg=null;function qg(t){return t=t.target||t.srcElement||window,t.correspondingUseElement&&(t=t.correspondingUseElement),t.nodeType===3?t.parentNode:t}var Kg=null,Xa=null,Za=null;function q1(t){if(t=bd(t)){if(typeof Kg!="function")throw Error(X(280));var e=t.stateNode;e&&(e=rf(e),Kg(t.stateNode,t.type,e))}}function K1(t){Xa?Za?Za.push(t):Za=[t]:Xa=t}function G1(){if(Xa){var t=Xa,e=Za;if(Za=Xa=null,q1(t),e)for(t=0;t>>=0,t===0?32:31-(JD(t)/QD|0)|0}var $h=64,Fh=4194304;function nd(t){switch(t&-t){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: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&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return t&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return t}}function zh(t,e){var r=t.pendingLanes;if(r===0)return 0;var n=0,s=t.suspendedLanes,o=t.pingedLanes,i=r&268435455;if(i!==0){var a=i&~s;a!==0?n=nd(a):(o&=i,o!==0&&(n=nd(o)))}else i=r&~s,i!==0?n=nd(i):o!==0&&(n=nd(o));if(n===0)return 0;if(e!==0&&e!==n&&!(e&s)&&(s=n&-n,o=e&-e,s>=o||s===16&&(o&4194240)!==0))return e;if(n&4&&(n|=r&16),e=t.entangledLanes,e!==0)for(t=t.entanglements,e&=n;0r;r++)e.push(t);return e}function sd(t,e,r){t.pendingLanes|=e,e!==536870912&&(t.suspendedLanes=0,t.pingedLanes=0),t=t.eventTimes,e=31-Ln(e),t[e]=r}function t5(t,e){var r=t.pendingLanes&~e;t.pendingLanes=e,t.suspendedLanes=0,t.pingedLanes=0,t.expiredLanes&=e,t.mutableReadLanes&=e,t.entangledLanes&=e,e=t.entanglements;var n=t.eventTimes;for(t=t.expirationTimes;0=hd),kk=" ",Sk=!1;function Nk(t,e){switch(t){case"keyup":return T5.indexOf(e.keyCode)!==-1;case"keydown":return e.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Ck(t){return t=t.detail,typeof t=="object"&&"data"in t?t.data:null}var rl=!1;function M5(t,e){switch(t){case"compositionend":return Ck(e);case"keypress":return e.which!==32?null:(Sk=!0,kk);case"textInput":return t=e.data,t===kk&&Sk?null:t;default:return null}}function O5(t,e){if(rl)return t==="compositionend"||!uv&&Nk(t,e)?(t=gk(),Hh=ov=So=null,rl=!1,t):null;switch(t){case"paste":return null;case"keypress":if(!(e.ctrlKey||e.altKey||e.metaKey)||e.ctrlKey&&e.altKey){if(e.char&&1=e)return{node:r,offset:e-t};t=n}e:{for(;r;){if(r.nextSibling){r=r.nextSibling;break e}r=r.parentNode}r=void 0}r=Ok(r)}}function Ak(t,e){return t&&e?t===e?!0:t&&t.nodeType===3?!1:e&&e.nodeType===3?Ak(t,e.parentNode):"contains"in t?t.contains(e):t.compareDocumentPosition?!!(t.compareDocumentPosition(e)&16):!1:!1}function Ik(){for(var t=window,e=Oh();e instanceof t.HTMLIFrameElement;){try{var r=typeof e.contentWindow.location.href=="string"}catch{r=!1}if(r)t=e.contentWindow;else break;e=Oh(t.document)}return e}function pv(t){var e=t&&t.nodeName&&t.nodeName.toLowerCase();return e&&(e==="input"&&(t.type==="text"||t.type==="search"||t.type==="tel"||t.type==="url"||t.type==="password")||e==="textarea"||t.contentEditable==="true")}function B5(t){var e=Ik(),r=t.focusedElem,n=t.selectionRange;if(e!==r&&r&&r.ownerDocument&&Ak(r.ownerDocument.documentElement,r)){if(n!==null&&pv(r)){if(e=n.start,t=n.end,t===void 0&&(t=e),"selectionStart"in r)r.selectionStart=e,r.selectionEnd=Math.min(t,r.value.length);else if(t=(e=r.ownerDocument||document)&&e.defaultView||window,t.getSelection){t=t.getSelection();var s=r.textContent.length,o=Math.min(n.start,s);n=n.end===void 0?o:Math.min(n.end,s),!t.extend&&o>n&&(s=n,n=o,o=s),s=Pk(r,o);var i=Pk(r,n);s&&i&&(t.rangeCount!==1||t.anchorNode!==s.node||t.anchorOffset!==s.offset||t.focusNode!==i.node||t.focusOffset!==i.offset)&&(e=e.createRange(),e.setStart(s.node,s.offset),t.removeAllRanges(),o>n?(t.addRange(e),t.extend(i.node,i.offset)):(e.setEnd(i.node,i.offset),t.addRange(e)))}}for(e=[],t=r;t=t.parentNode;)t.nodeType===1&&e.push({element:t,left:t.scrollLeft,top:t.scrollTop});for(typeof r.focus=="function"&&r.focus(),r=0;r=document.documentMode,nl=null,mv=null,gd=null,gv=!1;function Dk(t,e,r){var n=r.window===r?r.document:r.nodeType===9?r:r.ownerDocument;gv||nl==null||nl!==Oh(n)||(n=nl,"selectionStart"in n&&pv(n)?n={start:n.selectionStart,end:n.selectionEnd}:(n=(n.ownerDocument&&n.ownerDocument.defaultView||window).getSelection(),n={anchorNode:n.anchorNode,anchorOffset:n.anchorOffset,focusNode:n.focusNode,focusOffset:n.focusOffset}),gd&&md(gd,n)||(gd=n,n=Zh(mv,"onSelect"),0ll||(t.current=_v[ll],_v[ll]=null,ll--)}function He(t,e){ll++,_v[ll]=t.current,t.current=e}var Eo={},lr=jo(Eo),Pr=jo(!1),Fi=Eo;function cl(t,e){var r=t.type.contextTypes;if(!r)return Eo;var n=t.stateNode;if(n&&n.__reactInternalMemoizedUnmaskedChildContext===e)return n.__reactInternalMemoizedMaskedChildContext;var s={},o;for(o in r)s[o]=e[o];return n&&(t=t.stateNode,t.__reactInternalMemoizedUnmaskedChildContext=e,t.__reactInternalMemoizedMaskedChildContext=s),s}function Ar(t){return t=t.childContextTypes,t!=null}function nf(){Je(Pr),Je(lr)}function Qk(t,e,r){if(lr.current!==Eo)throw Error(X(168));He(lr,e),He(Pr,r)}function Xk(t,e,r){var n=t.stateNode;if(e=e.childContextTypes,typeof n.getChildContext!="function")return r;n=n.getChildContext();for(var s in n)if(!(s in e))throw Error(X(108,DD(t)||"Unknown",s));return rt({},r,n)}function sf(t){return t=(t=t.stateNode)&&t.__reactInternalMemoizedMergedChildContext||Eo,Fi=lr.current,He(lr,t),He(Pr,Pr.current),!0}function Zk(t,e,r){var n=t.stateNode;if(!n)throw Error(X(169));r?(t=Xk(t,e,Fi),n.__reactInternalMemoizedMergedChildContext=t,Je(Pr),Je(lr),He(lr,t)):Je(Pr),He(Pr,r)}var zs=null,of=!1,Tv=!1;function eS(t){zs===null?zs=[t]:zs.push(t)}function Z5(t){of=!0,eS(t)}function _o(){if(!Tv&&zs!==null){Tv=!0;var t=0,e=Be;try{var r=zs;for(Be=1;t>=i,s-=i,Bs=1<<32-Ln(e)+s|r<E?(j=N,N=null):j=N.sibling;var _=f(x,N,b[E],k);if(_===null){N===null&&(N=j);break}t&&N&&_.alternate===null&&e(x,N),w=o(_,w,E),C===null?S=_:C.sibling=_,C=_,N=j}if(E===b.length)return r(x,N),Xe&&Bi(x,E),S;if(N===null){for(;EE?(j=N,N=null):j=N.sibling;var P=f(x,N,_.value,k);if(P===null){N===null&&(N=j);break}t&&N&&P.alternate===null&&e(x,N),w=o(P,w,E),C===null?S=P:C.sibling=P,C=P,N=j}if(_.done)return r(x,N),Xe&&Bi(x,E),S;if(N===null){for(;!_.done;E++,_=b.next())_=h(x,_.value,k),_!==null&&(w=o(_,w,E),C===null?S=_:C.sibling=_,C=_);return Xe&&Bi(x,E),S}for(N=n(x,N);!_.done;E++,_=b.next())_=p(N,x,E,_.value,k),_!==null&&(t&&_.alternate!==null&&N.delete(_.key===null?E:_.key),w=o(_,w,E),C===null?S=_:C.sibling=_,C=_);return t&&N.forEach(function(T){return e(x,T)}),Xe&&Bi(x,E),S}function y(x,w,b,k){if(typeof b=="object"&&b!==null&&b.type===Ja&&b.key===null&&(b=b.props.children),typeof b=="object"&&b!==null){switch(b.$typeof){case Rh:e:{for(var S=b.key,C=w;C!==null;){if(C.key===S){if(S=b.type,S===Ja){if(C.tag===7){r(x,C.sibling),w=s(C,b.props.children),w.return=x,x=w;break e}}else if(C.elementType===S||typeof S=="object"&&S!==null&&S.$typeof===vo&&iS(S)===C.type){r(x,C.sibling),w=s(C,b.props),w.ref=kd(x,C,b),w.return=x,x=w;break e}r(x,C);break}else e(x,C);C=C.sibling}b.type===Ja?(w=Yi(b.props.children,x.mode,k,b.key),w.return=x,x=w):(k=Af(b.type,b.key,b.props,null,x.mode,k),k.ref=kd(x,w,b),k.return=x,x=k)}return i(x);case Ya:e:{for(C=b.key;w!==null;){if(w.key===C)if(w.tag===4&&w.stateNode.containerInfo===b.containerInfo&&w.stateNode.implementation===b.implementation){r(x,w.sibling),w=s(w,b.children||[]),w.return=x,x=w;break e}else{r(x,w);break}else e(x,w);w=w.sibling}w=jy(b,x.mode,k),w.return=x,x=w}return i(x);case vo:return C=b._init,y(x,w,C(b._payload),k)}if(Qc(b))return g(x,w,b,k);if(Yc(b))return v(x,w,b,k);df(x,b)}return typeof b=="string"&&b!==""||typeof b=="number"?(b=""+b,w!==null&&w.tag===6?(r(x,w.sibling),w=s(w,b),w.return=x,x=w):(r(x,w),w=Cy(b,x.mode,k),w.return=x,x=w),i(x)):r(x,w)}return y}var fl=aS(!0),lS=aS(!1),uf=jo(null),hf=null,pl=null,Iv=null;function Dv(){Iv=pl=hf=null}function Lv(t){var e=uf.current;Je(uf),t._currentValue=e}function $v(t,e,r){for(;t!==null;){var n=t.alternate;if((t.childLanes&e)!==e?(t.childLanes|=e,n!==null&&(n.childLanes|=e)):n!==null&&(n.childLanes&e)!==e&&(n.childLanes|=e),t===r)break;t=t.return}}function ml(t,e){hf=t,Iv=pl=null,t=t.dependencies,t!==null&&t.firstContext!==null&&(t.lanes&e&&(Ir=!0),t.firstContext=null)}function fn(t){var e=t._currentValue;if(Iv!==t)if(t={context:t,memoizedValue:e,next:null},pl===null){if(hf===null)throw Error(X(308));pl=t,hf.dependencies={lanes:0,firstContext:t}}else pl=pl.next=t;return e}var Ui=null;function Fv(t){Ui===null?Ui=[t]:Ui.push(t)}function cS(t,e,r,n){var s=e.interleaved;return s===null?(r.next=r,Fv(e)):(r.next=s.next,s.next=r),e.interleaved=r,Vs(t,n)}function Vs(t,e){t.lanes|=e;var r=t.alternate;for(r!==null&&(r.lanes|=e),r=t,t=t.return;t!==null;)t.childLanes|=e,r=t.alternate,r!==null&&(r.childLanes|=e),r=t,t=t.return;return r.tag===3?r.stateNode:null}var To=!1;function zv(t){t.updateQueue={baseState:t.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function dS(t,e){t=t.updateQueue,e.updateQueue===t&&(e.updateQueue={baseState:t.baseState,firstBaseUpdate:t.firstBaseUpdate,lastBaseUpdate:t.lastBaseUpdate,shared:t.shared,effects:t.effects})}function Ws(t,e){return{eventTime:t,lane:e,tag:0,payload:null,callback:null,next:null}}function Ro(t,e,r){var n=t.updateQueue;if(n===null)return null;if(n=n.shared,$e&2){var s=n.pending;return s===null?e.next=e:(e.next=s.next,s.next=e),n.pending=e,Vs(t,r)}return s=n.interleaved,s===null?(e.next=e,Fv(n)):(e.next=s.next,s.next=e),n.interleaved=e,Vs(t,r)}function ff(t,e,r){if(e=e.updateQueue,e!==null&&(e=e.shared,(r&4194240)!==0)){var n=e.lanes;n&=t.pendingLanes,r|=n,e.lanes=r,ev(t,r)}}function uS(t,e){var r=t.updateQueue,n=t.alternate;if(n!==null&&(n=n.updateQueue,r===n)){var s=null,o=null;if(r=r.firstBaseUpdate,r!==null){do{var i={eventTime:r.eventTime,lane:r.lane,tag:r.tag,payload:r.payload,callback:r.callback,next:null};o===null?s=o=i:o=o.next=i,r=r.next}while(r!==null);o===null?s=o=e:o=o.next=e}else s=o=e;r={baseState:n.baseState,firstBaseUpdate:s,lastBaseUpdate:o,shared:n.shared,effects:n.effects},t.updateQueue=r;return}t=r.lastBaseUpdate,t===null?r.firstBaseUpdate=e:t.next=e,r.lastBaseUpdate=e}function pf(t,e,r,n){var s=t.updateQueue;To=!1;var o=s.firstBaseUpdate,i=s.lastBaseUpdate,a=s.shared.pending;if(a!==null){s.shared.pending=null;var c=a,d=c.next;c.next=null,i===null?o=d:i.next=d,i=c;var u=t.alternate;u!==null&&(u=u.updateQueue,a=u.lastBaseUpdate,a!==i&&(a===null?u.firstBaseUpdate=d:a.next=d,u.lastBaseUpdate=c))}if(o!==null){var h=s.baseState;i=0,u=d=c=null,a=o;do{var f=a.lane,p=a.eventTime;if((n&f)===f){u!==null&&(u=u.next={eventTime:p,lane:0,tag:a.tag,payload:a.payload,callback:a.callback,next:null});e:{var g=t,v=a;switch(f=e,p=r,v.tag){case 1:if(g=v.payload,typeof g=="function"){h=g.call(p,h,f);break e}h=g;break e;case 3:g.flags=g.flags&-65537|128;case 0:if(g=v.payload,f=typeof g=="function"?g.call(p,h,f):g,f==null)break e;h=rt({},h,f);break e;case 2:To=!0}}a.callback!==null&&a.lane!==0&&(t.flags|=64,f=s.effects,f===null?s.effects=[a]:f.push(a))}else p={eventTime:p,lane:f,tag:a.tag,payload:a.payload,callback:a.callback,next:null},u===null?(d=u=p,c=h):u=u.next=p,i|=f;if(a=a.next,a===null){if(a=s.shared.pending,a===null)break;f=a,a=f.next,f.next=null,s.lastBaseUpdate=f,s.shared.pending=null}}while(!0);if(u===null&&(c=h),s.baseState=c,s.firstBaseUpdate=d,s.lastBaseUpdate=u,e=s.shared.interleaved,e!==null){s=e;do i|=s.lane,s=s.next;while(s!==e)}else o===null&&(s.shared.lanes=0);Hi|=i,t.lanes=i,t.memoizedState=h}}function hS(t,e,r){if(t=e.effects,e.effects=null,t!==null)for(e=0;er?r:4,t(!0);var n=Hv.transition;Hv.transition={};try{t(!1),e()}finally{Be=r,Hv.transition=n}}function MS(){return pn().memoizedState}function n4(t,e,r){var n=Ao(t);if(r={lane:n,action:r,hasEagerState:!1,eagerState:null,next:null},OS(t))PS(e,r);else if(r=cS(t,e,r,n),r!==null){var s=kr();Vn(r,t,n,s),AS(r,e,n)}}function s4(t,e,r){var n=Ao(t),s={lane:n,action:r,hasEagerState:!1,eagerState:null,next:null};if(OS(t))PS(e,s);else{var o=t.alternate;if(t.lanes===0&&(o===null||o.lanes===0)&&(o=e.lastRenderedReducer,o!==null))try{var i=e.lastRenderedState,a=o(i,r);if(s.hasEagerState=!0,s.eagerState=a,$n(a,i)){var c=e.interleaved;c===null?(s.next=s,Fv(e)):(s.next=c.next,c.next=s),e.interleaved=s;return}}catch{}finally{}r=cS(t,e,s,n),r!==null&&(s=kr(),Vn(r,t,n,s),AS(r,e,n))}}function OS(t){var e=t.alternate;return t===st||e!==null&&e===st}function PS(t,e){jd=vf=!0;var r=t.pending;r===null?e.next=e:(e.next=r.next,r.next=e),t.pending=e}function AS(t,e,r){if(r&4194240){var n=e.lanes;n&=t.pendingLanes,r|=n,e.lanes=r,ev(t,r)}}var wf={readContext:fn,useCallback:cr,useContext:cr,useEffect:cr,useImperativeHandle:cr,useInsertionEffect:cr,useLayoutEffect:cr,useMemo:cr,useReducer:cr,useRef:cr,useState:cr,useDebugValue:cr,useDeferredValue:cr,useTransition:cr,useMutableSource:cr,useSyncExternalStore:cr,useId:cr,unstable_isNewReconciler:!1},o4={readContext:fn,useCallback:function(t,e){return ps().memoizedState=[t,e===void 0?null:e],t},useContext:fn,useEffect:SS,useImperativeHandle:function(t,e,r){return r=r!=null?r.concat([t]):null,yf(4194308,4,jS.bind(null,e,t),r)},useLayoutEffect:function(t,e){return yf(4194308,4,t,e)},useInsertionEffect:function(t,e){return yf(4,2,t,e)},useMemo:function(t,e){var r=ps();return e=e===void 0?null:e,t=t(),r.memoizedState=[t,e],t},useReducer:function(t,e,r){var n=ps();return e=r!==void 0?r(e):e,n.memoizedState=n.baseState=e,t={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:t,lastRenderedState:e},n.queue=t,t=t.dispatch=n4.bind(null,st,t),[n.memoizedState,t]},useRef:function(t){var e=ps();return t={current:t},e.memoizedState=t},useState:bS,useDebugValue:Xv,useDeferredValue:function(t){return ps().memoizedState=t},useTransition:function(){var t=bS(!1),e=t[0];return t=r4.bind(null,t[1]),ps().memoizedState=t,[e,t]},useMutableSource:function(){},useSyncExternalStore:function(t,e,r){var n=st,s=ps();if(Xe){if(r===void 0)throw Error(X(407));r=r()}else{if(r=e(),$t===null)throw Error(X(349));Wi&30||gS(n,e,r)}s.memoizedState=r;var o={value:r,getSnapshot:e};return s.queue=o,SS(yS.bind(null,n,o,t),[t]),n.flags|=2048,Td(9,vS.bind(null,n,o,r,e),void 0,null),r},useId:function(){var t=ps(),e=$t.identifierPrefix;if(Xe){var r=Us,n=Bs;r=(n&~(1<<32-Ln(n)-1)).toString(32)+r,e=":"+e+"R"+r,r=Ed++,0<\/script>",t=t.removeChild(t.firstChild)):typeof n.is=="string"?t=i.createElement(r,{is:n.is}):(t=i.createElement(r),r==="select"&&(i=t,n.multiple?i.multiple=!0:n.size&&(i.size=n.size))):t=i.createElementNS(t,r),t[hs]=e,t[wd]=n,eN(t,e,!1,!1),e.stateNode=t;e:{switch(i=Wg(r,n),r){case"dialog":Ye("cancel",t),Ye("close",t),s=n;break;case"iframe":case"object":case"embed":Ye("load",t),s=n;break;case"video":case"audio":for(s=0;swl&&(e.flags|=128,n=!0,Rd(o,!1),e.lanes=4194304)}else{if(!n)if(t=mf(i),t!==null){if(e.flags|=128,n=!0,r=t.updateQueue,r!==null&&(e.updateQueue=r,e.flags|=4),Rd(o,!0),o.tail===null&&o.tailMode==="hidden"&&!i.alternate&&!Xe)return dr(e),null}else 2*mt()-o.renderingStartTime>wl&&r!==1073741824&&(e.flags|=128,n=!0,Rd(o,!1),e.lanes=4194304);o.isBackwards?(i.sibling=e.child,e.child=i):(r=o.last,r!==null?r.sibling=i:e.child=i,o.last=i)}return o.tail!==null?(e=o.tail,o.rendering=e,o.tail=e.sibling,o.renderingStartTime=mt(),e.sibling=null,r=nt.current,He(nt,n?r&1|2:r&1),e):(dr(e),null);case 22:case 23:return ky(),n=e.memoizedState!==null,t!==null&&t.memoizedState!==null!==n&&(e.flags|=8192),n&&e.mode&1?Zr&1073741824&&(dr(e),e.subtreeFlags&6&&(e.flags|=8192)):dr(e),null;case 24:return null;case 25:return null}throw Error(X(156,e.tag))}function f4(t,e){switch(Mv(e),e.tag){case 1:return Ar(e.type)&&nf(),t=e.flags,t&65536?(e.flags=t&-65537|128,e):null;case 3:return gl(),Je(Pr),Je(lr),Wv(),t=e.flags,t&65536&&!(t&128)?(e.flags=t&-65537|128,e):null;case 5:return Uv(e),null;case 13:if(Je(nt),t=e.memoizedState,t!==null&&t.dehydrated!==null){if(e.alternate===null)throw Error(X(340));hl()}return t=e.flags,t&65536?(e.flags=t&-65537|128,e):null;case 19:return Je(nt),null;case 4:return gl(),null;case 10:return Lv(e.type._context),null;case 22:case 23:return ky(),null;case 24:return null;default:return null}}var Nf=!1,ur=!1,p4=typeof WeakSet=="function"?WeakSet:Set,ae=null;function yl(t,e){var r=t.ref;if(r!==null)if(typeof r=="function")try{r(null)}catch(n){it(t,e,n)}else r.current=null}function dy(t,e,r){try{r()}catch(n){it(t,e,n)}}var nN=!1;function m4(t,e){if(kv=Vh,t=Ik(),pv(t)){if("selectionStart"in t)var r={start:t.selectionStart,end:t.selectionEnd};else e:{r=(r=t.ownerDocument)&&r.defaultView||window;var n=r.getSelection&&r.getSelection();if(n&&n.rangeCount!==0){r=n.anchorNode;var s=n.anchorOffset,o=n.focusNode;n=n.focusOffset;try{r.nodeType,o.nodeType}catch{r=null;break e}var i=0,a=-1,c=-1,d=0,u=0,h=t,f=null;t:for(;;){for(var p;h!==r||s!==0&&h.nodeType!==3||(a=i+s),h!==o||n!==0&&h.nodeType!==3||(c=i+n),h.nodeType===3&&(i+=h.nodeValue.length),(p=h.firstChild)!==null;)f=h,h=p;for(;;){if(h===t)break t;if(f===r&&++d===s&&(a=i),f===o&&++u===n&&(c=i),(p=h.nextSibling)!==null)break;h=f,f=h.parentNode}h=p}r=a===-1||c===-1?null:{start:a,end:c}}else r=null}r=r||{start:0,end:0}}else r=null;for(Sv={focusedElem:t,selectionRange:r},Vh=!1,ae=e;ae!==null;)if(e=ae,t=e.child,(e.subtreeFlags&1028)!==0&&t!==null)t.return=e,ae=t;else for(;ae!==null;){e=ae;try{var g=e.alternate;if(e.flags&1024)switch(e.tag){case 0:case 11:case 15:break;case 1:if(g!==null){var v=g.memoizedProps,y=g.memoizedState,x=e.stateNode,w=x.getSnapshotBeforeUpdate(e.elementType===e.type?v:zn(e.type,v),y);x.__reactInternalSnapshotBeforeUpdate=w}break;case 3:var b=e.stateNode.containerInfo;b.nodeType===1?b.textContent="":b.nodeType===9&&b.documentElement&&b.removeChild(b.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(X(163))}}catch(k){it(e,e.return,k)}if(t=e.sibling,t!==null){t.return=e.return,ae=t;break}ae=e.return}return g=nN,nN=!1,g}function Md(t,e,r){var n=e.updateQueue;if(n=n!==null?n.lastEffect:null,n!==null){var s=n=n.next;do{if((s.tag&t)===t){var o=s.destroy;s.destroy=void 0,o!==void 0&&dy(e,r,o)}s=s.next}while(s!==n)}}function Cf(t,e){if(e=e.updateQueue,e=e!==null?e.lastEffect:null,e!==null){var r=e=e.next;do{if((r.tag&t)===t){var n=r.create;r.destroy=n()}r=r.next}while(r!==e)}}function uy(t){var e=t.ref;if(e!==null){var r=t.stateNode;switch(t.tag){case 5:t=r;break;default:t=r}typeof e=="function"?e(t):e.current=t}}function sN(t){var e=t.alternate;e!==null&&(t.alternate=null,sN(e)),t.child=null,t.deletions=null,t.sibling=null,t.tag===5&&(e=t.stateNode,e!==null&&(delete e[hs],delete e[wd],delete e[Ev],delete e[Q5],delete e[X5])),t.stateNode=null,t.return=null,t.dependencies=null,t.memoizedProps=null,t.memoizedState=null,t.pendingProps=null,t.stateNode=null,t.updateQueue=null}function oN(t){return t.tag===5||t.tag===3||t.tag===4}function iN(t){e:for(;;){for(;t.sibling===null;){if(t.return===null||oN(t.return))return null;t=t.return}for(t.sibling.return=t.return,t=t.sibling;t.tag!==5&&t.tag!==6&&t.tag!==18;){if(t.flags&2||t.child===null||t.tag===4)continue e;t.child.return=t,t=t.child}if(!(t.flags&2))return t.stateNode}}function hy(t,e,r){var n=t.tag;if(n===5||n===6)t=t.stateNode,e?r.nodeType===8?r.parentNode.insertBefore(t,e):r.insertBefore(t,e):(r.nodeType===8?(e=r.parentNode,e.insertBefore(t,r)):(e=r,e.appendChild(t)),r=r._reactRootContainer,r!=null||e.onclick!==null||(e.onclick=tf));else if(n!==4&&(t=t.child,t!==null))for(hy(t,e,r),t=t.sibling;t!==null;)hy(t,e,r),t=t.sibling}function fy(t,e,r){var n=t.tag;if(n===5||n===6)t=t.stateNode,e?r.insertBefore(t,e):r.appendChild(t);else if(n!==4&&(t=t.child,t!==null))for(fy(t,e,r),t=t.sibling;t!==null;)fy(t,e,r),t=t.sibling}var Xt=null,Bn=!1;function Mo(t,e,r){for(r=r.child;r!==null;)aN(t,e,r),r=r.sibling}function aN(t,e,r){if(us&&typeof us.onCommitFiberUnmount=="function")try{us.onCommitFiberUnmount(Lh,r)}catch{}switch(r.tag){case 5:ur||yl(r,e);case 6:var n=Xt,s=Bn;Xt=null,Mo(t,e,r),Xt=n,Bn=s,Xt!==null&&(Bn?(t=Xt,r=r.stateNode,t.nodeType===8?t.parentNode.removeChild(r):t.removeChild(r)):Xt.removeChild(r.stateNode));break;case 18:Xt!==null&&(Bn?(t=Xt,r=r.stateNode,t.nodeType===8?jv(t.parentNode,r):t.nodeType===1&&jv(t,r),cd(t)):jv(Xt,r.stateNode));break;case 4:n=Xt,s=Bn,Xt=r.stateNode.containerInfo,Bn=!0,Mo(t,e,r),Xt=n,Bn=s;break;case 0:case 11:case 14:case 15:if(!ur&&(n=r.updateQueue,n!==null&&(n=n.lastEffect,n!==null))){s=n=n.next;do{var o=s,i=o.destroy;o=o.tag,i!==void 0&&(o&2||o&4)&&dy(r,e,i),s=s.next}while(s!==n)}Mo(t,e,r);break;case 1:if(!ur&&(yl(r,e),n=r.stateNode,typeof n.componentWillUnmount=="function"))try{n.props=r.memoizedProps,n.state=r.memoizedState,n.componentWillUnmount()}catch(a){it(r,e,a)}Mo(t,e,r);break;case 21:Mo(t,e,r);break;case 22:r.mode&1?(ur=(n=ur)||r.memoizedState!==null,Mo(t,e,r),ur=n):Mo(t,e,r);break;default:Mo(t,e,r)}}function lN(t){var e=t.updateQueue;if(e!==null){t.updateQueue=null;var r=t.stateNode;r===null&&(r=t.stateNode=new p4),e.forEach(function(n){var s=N4.bind(null,t,n);r.has(n)||(r.add(n),n.then(s,s))})}}function Un(t,e){var r=e.deletions;if(r!==null)for(var n=0;ns&&(s=i),n&=~o}if(n=s,n=mt()-n,n=(120>n?120:480>n?480:1080>n?1080:1920>n?1920:3e3>n?3e3:4320>n?4320:1960*v4(n/1960))-n,10t?16:t,Po===null)var n=!1;else{if(t=Po,Po=null,Rf=0,$e&6)throw Error(X(331));var s=$e;for($e|=4,ae=t.current;ae!==null;){var o=ae,i=o.child;if(ae.flags&16){var a=o.deletions;if(a!==null){for(var c=0;cmt()-gy?Ki(t,0):my|=r),Lr(t,e)}function bN(t,e){e===0&&(t.mode&1?(e=Fh,Fh<<=1,!(Fh&130023424)&&(Fh=4194304)):e=1);var r=kr();t=Vs(t,e),t!==null&&(sd(t,e,r),Lr(t,r))}function S4(t){var e=t.memoizedState,r=0;e!==null&&(r=e.retryLane),bN(t,r)}function N4(t,e){var r=0;switch(t.tag){case 13:var n=t.stateNode,s=t.memoizedState;s!==null&&(r=s.retryLane);break;case 19:n=t.stateNode;break;default:throw Error(X(314))}n!==null&&n.delete(e),bN(t,r)}var kN;kN=function(t,e,r){if(t!==null)if(t.memoizedProps!==e.pendingProps||Pr.current)Ir=!0;else{if(!(t.lanes&r)&&!(e.flags&128))return Ir=!1,u4(t,e,r);Ir=!!(t.flags&131072)}else Ir=!1,Xe&&e.flags&1048576&&tS(e,lf,e.index);switch(e.lanes=0,e.tag){case 2:var n=e.type;Sf(t,e),t=e.pendingProps;var s=cl(e,lr.current);ml(e,r),s=Kv(null,e,n,t,s,r);var o=Gv();return e.flags|=1,typeof s=="object"&&s!==null&&typeof s.render=="function"&&s.$typeof===void 0?(e.tag=1,e.memoizedState=null,e.updateQueue=null,Ar(n)?(o=!0,sf(e)):o=!1,e.memoizedState=s.state!==null&&s.state!==void 0?s.state:null,zv(e),s.updater=bf,e.stateNode=s,s._reactInternals=e,ey(e,n,t,r),e=sy(null,e,n,!0,o,r)):(e.tag=0,Xe&&o&&Rv(e),br(null,e,s,r),e=e.child),e;case 16:n=e.elementType;e:{switch(Sf(t,e),t=e.pendingProps,s=n._init,n=s(n._payload),e.type=n,s=e.tag=j4(n),t=zn(n,t),s){case 0:e=ny(null,e,n,t,r);break e;case 1:e=GS(null,e,n,t,r);break e;case 11:e=VS(null,e,n,t,r);break e;case 14:e=WS(null,e,n,zn(n.type,t),r);break e}throw Error(X(306,n,""))}return e;case 0:return n=e.type,s=e.pendingProps,s=e.elementType===n?s:zn(n,s),ny(t,e,n,s,r);case 1:return n=e.type,s=e.pendingProps,s=e.elementType===n?s:zn(n,s),GS(t,e,n,s,r);case 3:e:{if(YS(e),t===null)throw Error(X(387));n=e.pendingProps,o=e.memoizedState,s=o.element,dS(t,e),pf(e,n,null,r);var i=e.memoizedState;if(n=i.element,o.isDehydrated)if(o={element:n,isDehydrated:!1,cache:i.cache,pendingSuspenseBoundaries:i.pendingSuspenseBoundaries,transitions:i.transitions},e.updateQueue.baseState=o,e.memoizedState=o,e.flags&256){s=vl(Error(X(423)),e),e=JS(t,e,n,r,s);break e}else if(n!==s){s=vl(Error(X(424)),e),e=JS(t,e,n,r,s);break e}else for(Xr=Co(e.stateNode.containerInfo.firstChild),Qr=e,Xe=!0,Fn=null,r=lS(e,null,n,r),e.child=r;r;)r.flags=r.flags&-3|4096,r=r.sibling;else{if(hl(),n===s){e=Hs(t,e,r);break e}br(t,e,n,r)}e=e.child}return e;case 5:return fS(e),t===null&&Pv(e),n=e.type,s=e.pendingProps,o=t!==null?t.memoizedProps:null,i=s.children,Nv(n,s)?i=null:o!==null&&Nv(n,o)&&(e.flags|=32),KS(t,e),br(t,e,i,r),e.child;case 6:return t===null&&Pv(e),null;case 13:return QS(t,e,r);case 4:return Bv(e,e.stateNode.containerInfo),n=e.pendingProps,t===null?e.child=fl(e,null,n,r):br(t,e,n,r),e.child;case 11:return n=e.type,s=e.pendingProps,s=e.elementType===n?s:zn(n,s),VS(t,e,n,s,r);case 7:return br(t,e,e.pendingProps,r),e.child;case 8:return br(t,e,e.pendingProps.children,r),e.child;case 12:return br(t,e,e.pendingProps.children,r),e.child;case 10:e:{if(n=e.type._context,s=e.pendingProps,o=e.memoizedProps,i=s.value,He(uf,n._currentValue),n._currentValue=i,o!==null)if($n(o.value,i)){if(o.children===s.children&&!Pr.current){e=Hs(t,e,r);break e}}else for(o=e.child,o!==null&&(o.return=e);o!==null;){var a=o.dependencies;if(a!==null){i=o.child;for(var c=a.firstContext;c!==null;){if(c.context===n){if(o.tag===1){c=Ws(-1,r&-r),c.tag=2;var d=o.updateQueue;if(d!==null){d=d.shared;var u=d.pending;u===null?c.next=c:(c.next=u.next,u.next=c),d.pending=c}}o.lanes|=r,c=o.alternate,c!==null&&(c.lanes|=r),$v(o.return,r,e),a.lanes|=r;break}c=c.next}}else if(o.tag===10)i=o.type===e.type?null:o.child;else if(o.tag===18){if(i=o.return,i===null)throw Error(X(341));i.lanes|=r,a=i.alternate,a!==null&&(a.lanes|=r),$v(i,r,e),i=o.sibling}else i=o.child;if(i!==null)i.return=o;else for(i=o;i!==null;){if(i===e){i=null;break}if(o=i.sibling,o!==null){o.return=i.return,i=o;break}i=i.return}o=i}br(t,e,s.children,r),e=e.child}return e;case 9:return s=e.type,n=e.pendingProps.children,ml(e,r),s=fn(s),n=n(s),e.flags|=1,br(t,e,n,r),e.child;case 14:return n=e.type,s=zn(n,e.pendingProps),s=zn(n.type,s),WS(t,e,n,s,r);case 15:return HS(t,e,e.type,e.pendingProps,r);case 17:return n=e.type,s=e.pendingProps,s=e.elementType===n?s:zn(n,s),Sf(t,e),e.tag=1,Ar(n)?(t=!0,sf(e)):t=!1,ml(e,r),DS(e,n,s),ey(e,n,s,r),sy(null,e,n,!0,t,r);case 19:return ZS(t,e,r);case 22:return qS(t,e,r)}throw Error(X(156,e.tag))};function SN(t,e){return rk(t,e)}function C4(t,e,r,n){this.tag=t,this.key=r,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=e,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=n,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function gn(t,e,r,n){return new C4(t,e,r,n)}function Ny(t){return t=t.prototype,!(!t||!t.isReactComponent)}function j4(t){if(typeof t=="function")return Ny(t)?1:0;if(t!=null){if(t=t.$typeof,t===Rg)return 11;if(t===Pg)return 14}return 2}function Do(t,e){var r=t.alternate;return r===null?(r=gn(t.tag,e,t.key,t.mode),r.elementType=t.elementType,r.type=t.type,r.stateNode=t.stateNode,r.alternate=t,t.alternate=r):(r.pendingProps=e,r.type=t.type,r.flags=0,r.subtreeFlags=0,r.deletions=null),r.flags=t.flags&14680064,r.childLanes=t.childLanes,r.lanes=t.lanes,r.child=t.child,r.memoizedProps=t.memoizedProps,r.memoizedState=t.memoizedState,r.updateQueue=t.updateQueue,e=t.dependencies,r.dependencies=e===null?null:{lanes:e.lanes,firstContext:e.firstContext},r.sibling=t.sibling,r.index=t.index,r.ref=t.ref,r}function Af(t,e,r,n,s,o){var i=2;if(n=t,typeof t=="function")Ny(t)&&(i=1);else if(typeof t=="string")i=5;else e:switch(t){case Ja:return Yi(r.children,s,o,e);case _g:i=8,s|=8;break;case Tg:return t=gn(12,r,e,s|2),t.elementType=Tg,t.lanes=o,t;case Mg:return t=gn(13,r,e,s),t.elementType=Mg,t.lanes=o,t;case Og:return t=gn(19,r,e,s),t.elementType=Og,t.lanes=o,t;case O1:return If(r,s,o,e);default:if(typeof t=="object"&&t!==null)switch(t.$typeof){case R1:i=10;break e;case M1:i=9;break e;case Rg:i=11;break e;case Pg:i=14;break e;case vo:i=16,n=null;break e}throw Error(X(130,t==null?t:typeof t,""))}return e=gn(i,r,e,s),e.elementType=t,e.type=n,e.lanes=o,e}function Yi(t,e,r,n){return t=gn(7,t,n,e),t.lanes=r,t}function If(t,e,r,n){return t=gn(22,t,n,e),t.elementType=O1,t.lanes=r,t.stateNode={isHidden:!1},t}function Cy(t,e,r){return t=gn(6,t,null,e),t.lanes=r,t}function jy(t,e,r){return e=gn(4,t.children!==null?t.children:[],t.key,e),e.lanes=r,e.stateNode={containerInfo:t.containerInfo,pendingChildren:null,implementation:t.implementation},e}function E4(t,e,r,n,s){this.tag=e,this.containerInfo=t,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=Zg(0),this.expirationTimes=Zg(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Zg(0),this.identifierPrefix=n,this.onRecoverableError=s,this.mutableSourceEagerHydrationData=null}function Ey(t,e,r,n,s,o,i,a,c){return t=new E4(t,e,r,a,c),e===1?(e=1,o===!0&&(e|=8)):e=0,o=gn(3,null,null,e),t.current=o,o.stateNode=t,o.memoizedState={element:n,isDehydrated:r,cache:null,transitions:null,pendingSuspenseBoundaries:null},zv(o),t}function _4(t,e,r){var n=3"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(TN)}catch(t){console.error(t)}}TN(),N1.exports=Gr;var vn=N1.exports;const My=Jt(vn);var RN,MN=vn;RN=MN.createRoot,MN.hydrateRoot;const P4=1,A4=1e6;let Oy=0;function I4(){return Oy=(Oy+1)%Number.MAX_SAFE_INTEGER,Oy.toString()}const Py=new Map,ON=t=>{if(Py.has(t))return;const e=setTimeout(()=>{Py.delete(t),Dd({type:"REMOVE_TOAST",toastId:t})},A4);Py.set(t,e)},D4=(t,e)=>{switch(e.type){case"ADD_TOAST":return{...t,toasts:[e.toast,...t.toasts].slice(0,P4)};case"UPDATE_TOAST":return{...t,toasts:t.toasts.map(r=>r.id===e.toast.id?{...r,...e.toast}:r)};case"DISMISS_TOAST":{const{toastId:r}=e;return r?ON(r):t.toasts.forEach(n=>{ON(n.id)}),{...t,toasts:t.toasts.map(n=>n.id===r||r===void 0?{...n,open:!1}:n)}}case"REMOVE_TOAST":return e.toastId===void 0?{...t,toasts:[]}:{...t,toasts:t.toasts.filter(r=>r.id!==e.toastId)}}},Uf=[];let Vf={toasts:[]};function Dd(t){Vf=D4(Vf,t),Uf.forEach(e=>{e(Vf)})}function L4({...t}){const e=I4(),r=s=>Dd({type:"UPDATE_TOAST",toast:{...s,id:e}}),n=()=>Dd({type:"DISMISS_TOAST",toastId:e});return Dd({type:"ADD_TOAST",toast:{...t,id:e,open:!0,onOpenChange:s=>{s||n()}}}),{id:e,dismiss:n,update:r}}function gs(){const[t,e]=m.useState(Vf);return m.useEffect(()=>(Uf.push(e),()=>{const r=Uf.indexOf(e);r>-1&&Uf.splice(r,1)}),[t]),{...t,toast:L4,dismiss:r=>Dd({type:"DISMISS_TOAST",toastId:r})}}function Q(t,e,{checkForDefaultPrevented:r=!0}={}){return function(s){if(t==null||t(s),r===!1||!s.defaultPrevented)return e==null?void 0:e(s)}}function PN(t,e){if(typeof t=="function")return t(e);t!=null&&(t.current=e)}function Ks(...t){return e=>{let r=!1;const n=t.map(s=>{const o=PN(s,e);return!r&&typeof o=="function"&&(r=!0),o});if(r)return()=>{for(let s=0;s{const{children:i,...a}=o,c=m.useMemo(()=>a,Object.values(a));return l.jsx(r.Provider,{value:c,children:i})};n.displayName=t+"Provider";function s(o){const i=m.useContext(r);if(i)return i;if(e!==void 0)return e;throw new Error(`\`${o}\` must be used within \`${t}\``)}return[n,s]}function Ft(t,e=[]){let r=[];function n(o,i){const a=m.createContext(i),c=r.length;r=[...r,i];const d=h=>{var x;const{scope:f,children:p,...g}=h,v=((x=f==null?void 0:f[t])==null?void 0:x[c])||a,y=m.useMemo(()=>g,Object.values(g));return l.jsx(v.Provider,{value:y,children:p})};d.displayName=o+"Provider";function u(h,f){var v;const p=((v=f==null?void 0:f[t])==null?void 0:v[c])||a,g=m.useContext(p);if(g)return g;if(i!==void 0)return i;throw new Error(`\`${h}\` must be used within \`${o}\``)}return[d,u]}const s=()=>{const o=r.map(i=>m.createContext(i));return function(a){const c=(a==null?void 0:a[t])||o;return m.useMemo(()=>({[`__scope${t}`]:{...a,[t]:c}}),[a,c])}};return s.scopeName=t,[n,F4(s,...e)]}function F4(...t){const e=t[0];if(t.length===1)return e;const r=()=>{const n=t.map(s=>({useScope:s(),scopeName:s.scopeName}));return function(o){const i=n.reduce((a,{useScope:c,scopeName:d})=>{const h=c(o)[`__scope${d}`];return{...a,...h}},{});return m.useMemo(()=>({[`__scope${e.scopeName}`]:i}),[i])}};return r.scopeName=e.scopeName,r}function Ji(t){const e=B4(t),r=m.forwardRef((n,s)=>{const{children:o,...i}=n,a=m.Children.toArray(o),c=a.find(V4);if(c){const d=c.props.children,u=a.map(h=>h===c?m.Children.count(d)>1?m.Children.only(null):m.isValidElement(d)?d.props.children:null:h);return l.jsx(e,{...i,ref:s,children:m.isValidElement(d)?m.cloneElement(d,void 0,u):null})}return l.jsx(e,{...i,ref:s,children:o})});return r.displayName=`${t}.Slot`,r}var z4=Ji("Slot");function B4(t){const e=m.forwardRef((r,n)=>{const{children:s,...o}=r;if(m.isValidElement(s)){const i=H4(s),a=W4(o,s.props);return s.type!==m.Fragment&&(a.ref=n?Ks(n,i):i),m.cloneElement(s,a)}return m.Children.count(s)>1?m.Children.only(null):null});return e.displayName=`${t}.SlotClone`,e}var AN=Symbol("radix.slottable");function U4(t){const e=({children:r})=>l.jsx(l.Fragment,{children:r});return e.displayName=`${t}.Slottable`,e.__radixId=AN,e}function V4(t){return m.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===AN}function W4(t,e){const r={...e};for(const n in e){const s=t[n],o=e[n];/^on[A-Z]/.test(n)?s&&o?r[n]=(...a)=>{const c=o(...a);return s(...a),c}:s&&(r[n]=s):n==="style"?r[n]={...s,...o}:n==="className"&&(r[n]=[s,o].filter(Boolean).join(" "))}return{...t,...r}}function H4(t){var n,s;let e=(n=Object.getOwnPropertyDescriptor(t.props,"ref"))==null?void 0:n.get,r=e&&"isReactWarning"in e&&e.isReactWarning;return r?t.ref:(e=(s=Object.getOwnPropertyDescriptor(t,"ref"))==null?void 0:s.get,r=e&&"isReactWarning"in e&&e.isReactWarning,r?t.props.ref:t.props.ref||t.ref)}function Ld(t){const e=t+"CollectionProvider",[r,n]=Ft(e),[s,o]=r(e,{collectionRef:{current:null},itemMap:new Map}),i=v=>{const{scope:y,children:x}=v,w=W.useRef(null),b=W.useRef(new Map).current;return l.jsx(s,{scope:y,itemMap:b,collectionRef:w,children:x})};i.displayName=e;const a=t+"CollectionSlot",c=Ji(a),d=W.forwardRef((v,y)=>{const{scope:x,children:w}=v,b=o(a,x),k=we(y,b.collectionRef);return l.jsx(c,{ref:k,children:w})});d.displayName=a;const u=t+"CollectionItemSlot",h="data-radix-collection-item",f=Ji(u),p=W.forwardRef((v,y)=>{const{scope:x,children:w,...b}=v,k=W.useRef(null),S=we(y,k),C=o(u,x);return W.useEffect(()=>(C.itemMap.set(k,{ref:k,...b}),()=>void C.itemMap.delete(k))),l.jsx(f,{[h]:"",ref:S,children:w})});p.displayName=u;function g(v){const y=o(t+"CollectionConsumer",v);return W.useCallback(()=>{const w=y.collectionRef.current;if(!w)return[];const b=Array.from(w.querySelectorAll(`[${h}]`));return Array.from(y.itemMap.values()).sort((C,N)=>b.indexOf(C.ref.current)-b.indexOf(N.ref.current))},[y.collectionRef,y.itemMap])}return[{Provider:i,Slot:d,ItemSlot:p},g,n]}var q4=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],se=q4.reduce((t,e)=>{const r=Ji(`Primitive.${e}`),n=m.forwardRef((s,o)=>{const{asChild:i,...a}=s,c=i?r:e;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),l.jsx(c,{...a,ref:o})});return n.displayName=`Primitive.${e}`,{...t,[e]:n}},{});function Ay(t,e){t&&vn.flushSync(()=>t.dispatchEvent(e))}function at(t){const e=m.useRef(t);return m.useEffect(()=>{e.current=t}),m.useMemo(()=>(...r)=>{var n;return(n=e.current)==null?void 0:n.call(e,...r)},[])}function K4(t,e=globalThis==null?void 0:globalThis.document){const r=at(t);m.useEffect(()=>{const n=s=>{s.key==="Escape"&&r(s)};return e.addEventListener("keydown",n,{capture:!0}),()=>e.removeEventListener("keydown",n,{capture:!0})},[r,e])}var G4="DismissableLayer",Iy="dismissableLayer.update",Y4="dismissableLayer.pointerDownOutside",J4="dismissableLayer.focusOutside",IN,DN=m.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),kl=m.forwardRef((t,e)=>{const{disableOutsidePointerEvents:r=!1,onEscapeKeyDown:n,onPointerDownOutside:s,onFocusOutside:o,onInteractOutside:i,onDismiss:a,...c}=t,d=m.useContext(DN),[u,h]=m.useState(null),f=(u==null?void 0:u.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,p]=m.useState({}),g=we(e,N=>h(N)),v=Array.from(d.layers),[y]=[...d.layersWithOutsidePointerEventsDisabled].slice(-1),x=v.indexOf(y),w=u?v.indexOf(u):-1,b=d.layersWithOutsidePointerEventsDisabled.size>0,k=w>=x,S=X4(N=>{const E=N.target,j=[...d.branches].some(_=>_.contains(E));!k||j||(s==null||s(N),i==null||i(N),N.defaultPrevented||a==null||a())},f),C=Z4(N=>{const E=N.target;[...d.branches].some(_=>_.contains(E))||(o==null||o(N),i==null||i(N),N.defaultPrevented||a==null||a())},f);return K4(N=>{w===d.layers.size-1&&(n==null||n(N),!N.defaultPrevented&&a&&(N.preventDefault(),a()))},f),m.useEffect(()=>{if(u)return r&&(d.layersWithOutsidePointerEventsDisabled.size===0&&(IN=f.body.style.pointerEvents,f.body.style.pointerEvents="none"),d.layersWithOutsidePointerEventsDisabled.add(u)),d.layers.add(u),$N(),()=>{r&&d.layersWithOutsidePointerEventsDisabled.size===1&&(f.body.style.pointerEvents=IN)}},[u,f,r,d]),m.useEffect(()=>()=>{u&&(d.layers.delete(u),d.layersWithOutsidePointerEventsDisabled.delete(u),$N())},[u,d]),m.useEffect(()=>{const N=()=>p({});return document.addEventListener(Iy,N),()=>document.removeEventListener(Iy,N)},[]),l.jsx(se.div,{...c,ref:g,style:{pointerEvents:b?k?"auto":"none":void 0,...t.style},onFocusCapture:Q(t.onFocusCapture,C.onFocusCapture),onBlurCapture:Q(t.onBlurCapture,C.onBlurCapture),onPointerDownCapture:Q(t.onPointerDownCapture,S.onPointerDownCapture)})});kl.displayName=G4;var Q4="DismissableLayerBranch",LN=m.forwardRef((t,e)=>{const r=m.useContext(DN),n=m.useRef(null),s=we(e,n);return m.useEffect(()=>{const o=n.current;if(o)return r.branches.add(o),()=>{r.branches.delete(o)}},[r.branches]),l.jsx(se.div,{...t,ref:s})});LN.displayName=Q4;function X4(t,e=globalThis==null?void 0:globalThis.document){const r=at(t),n=m.useRef(!1),s=m.useRef(()=>{});return m.useEffect(()=>{const o=a=>{if(a.target&&!n.current){let c=function(){FN(Y4,r,d,{discrete:!0})};const d={originalEvent:a};a.pointerType==="touch"?(e.removeEventListener("click",s.current),s.current=c,e.addEventListener("click",s.current,{once:!0})):c()}else e.removeEventListener("click",s.current);n.current=!1},i=window.setTimeout(()=>{e.addEventListener("pointerdown",o)},0);return()=>{window.clearTimeout(i),e.removeEventListener("pointerdown",o),e.removeEventListener("click",s.current)}},[e,r]),{onPointerDownCapture:()=>n.current=!0}}function Z4(t,e=globalThis==null?void 0:globalThis.document){const r=at(t),n=m.useRef(!1);return m.useEffect(()=>{const s=o=>{o.target&&!n.current&&FN(J4,r,{originalEvent:o},{discrete:!1})};return e.addEventListener("focusin",s),()=>e.removeEventListener("focusin",s)},[e,r]),{onFocusCapture:()=>n.current=!0,onBlurCapture:()=>n.current=!1}}function $N(){const t=new CustomEvent(Iy);document.dispatchEvent(t)}function FN(t,e,r,{discrete:n}){const s=r.originalEvent.target,o=new CustomEvent(t,{bubbles:!1,cancelable:!0,detail:r});e&&s.addEventListener(t,e,{once:!0}),n?Ay(s,o):s.dispatchEvent(o)}var e3=kl,t3=LN,gt=globalThis!=null&&globalThis.document?m.useLayoutEffect:()=>{},r3="Portal",$d=m.forwardRef((t,e)=>{var a;const{container:r,...n}=t,[s,o]=m.useState(!1);gt(()=>o(!0),[]);const i=r||s&&((a=globalThis==null?void 0:globalThis.document)==null?void 0:a.body);return i?My.createPortal(l.jsx(se.div,{...n,ref:e}),i):null});$d.displayName=r3;function n3(t,e){return m.useReducer((r,n)=>e[r][n]??r,t)}var er=t=>{const{present:e,children:r}=t,n=s3(e),s=typeof r=="function"?r({present:n.isPresent}):m.Children.only(r),o=we(n.ref,o3(s));return typeof r=="function"||n.isPresent?m.cloneElement(s,{ref:o}):null};er.displayName="Presence";function s3(t){const[e,r]=m.useState(),n=m.useRef(null),s=m.useRef(t),o=m.useRef("none"),i=t?"mounted":"unmounted",[a,c]=n3(i,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return m.useEffect(()=>{const d=Wf(n.current);o.current=a==="mounted"?d:"none"},[a]),gt(()=>{const d=n.current,u=s.current;if(u!==t){const f=o.current,p=Wf(d);t?c("MOUNT"):p==="none"||(d==null?void 0:d.display)==="none"?c("UNMOUNT"):c(u&&f!==p?"ANIMATION_OUT":"UNMOUNT"),s.current=t}},[t,c]),gt(()=>{if(e){let d;const u=e.ownerDocument.defaultView??window,h=p=>{const v=Wf(n.current).includes(p.animationName);if(p.target===e&&v&&(c("ANIMATION_END"),!s.current)){const y=e.style.animationFillMode;e.style.animationFillMode="forwards",d=u.setTimeout(()=>{e.style.animationFillMode==="forwards"&&(e.style.animationFillMode=y)})}},f=p=>{p.target===e&&(o.current=Wf(n.current))};return e.addEventListener("animationstart",f),e.addEventListener("animationcancel",h),e.addEventListener("animationend",h),()=>{u.clearTimeout(d),e.removeEventListener("animationstart",f),e.removeEventListener("animationcancel",h),e.removeEventListener("animationend",h)}}else c("ANIMATION_END")},[e,c]),{isPresent:["mounted","unmountSuspended"].includes(a),ref:m.useCallback(d=>{n.current=d?getComputedStyle(d):null,r(d)},[])}}function Wf(t){return(t==null?void 0:t.animationName)||"none"}function o3(t){var n,s;let e=(n=Object.getOwnPropertyDescriptor(t.props,"ref"))==null?void 0:n.get,r=e&&"isReactWarning"in e&&e.isReactWarning;return r?t.ref:(e=(s=Object.getOwnPropertyDescriptor(t,"ref"))==null?void 0:s.get,r=e&&"isReactWarning"in e&&e.isReactWarning,r?t.props.ref:t.props.ref||t.ref)}var i3=Sg[" useInsertionEffect ".trim().toString()]||gt;function Wn({prop:t,defaultProp:e,onChange:r=()=>{},caller:n}){const[s,o,i]=a3({defaultProp:e,onChange:r}),a=t!==void 0,c=a?t:s;{const u=m.useRef(t!==void 0);m.useEffect(()=>{const h=u.current;h!==a&&console.warn(`${n} is changing from ${h?"controlled":"uncontrolled"} to ${a?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),u.current=a},[a,n])}const d=m.useCallback(u=>{var h;if(a){const f=l3(u)?u(t):u;f!==t&&((h=i.current)==null||h.call(i,f))}else o(u)},[a,t,o,i]);return[c,d]}function a3({defaultProp:t,onChange:e}){const[r,n]=m.useState(t),s=m.useRef(r),o=m.useRef(e);return i3(()=>{o.current=e},[e]),m.useEffect(()=>{var i;s.current!==r&&((i=o.current)==null||i.call(o,r),s.current=r)},[r,s]),[r,n,o]}function l3(t){return typeof t=="function"}var zN=Object.freeze({position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal"}),c3="VisuallyHidden",Hf=m.forwardRef((t,e)=>l.jsx(se.span,{...t,ref:e,style:{...zN,...t.style}}));Hf.displayName=c3;var d3=Hf,Dy="ToastProvider",[Ly,u3,h3]=Ld("Toast"),[BN,mre]=Ft("Toast",[h3]),[f3,qf]=BN(Dy),UN=t=>{const{__scopeToast:e,label:r="Notification",duration:n=5e3,swipeDirection:s="right",swipeThreshold:o=50,children:i}=t,[a,c]=m.useState(null),[d,u]=m.useState(0),h=m.useRef(!1),f=m.useRef(!1);return r.trim()||console.error(`Invalid prop \`label\` supplied to \`${Dy}\`. Expected non-empty \`string\`.`),l.jsx(Ly.Provider,{scope:e,children:l.jsx(f3,{scope:e,label:r,duration:n,swipeDirection:s,swipeThreshold:o,toastCount:d,viewport:a,onViewportChange:c,onToastAdd:m.useCallback(()=>u(p=>p+1),[]),onToastRemove:m.useCallback(()=>u(p=>p-1),[]),isFocusedToastEscapeKeyDownRef:h,isClosePausedRef:f,children:i})})};UN.displayName=Dy;var VN="ToastViewport",p3=["F8"],$y="toast.viewportPause",Fy="toast.viewportResume",WN=m.forwardRef((t,e)=>{const{__scopeToast:r,hotkey:n=p3,label:s="Notifications ({hotkey})",...o}=t,i=qf(VN,r),a=u3(r),c=m.useRef(null),d=m.useRef(null),u=m.useRef(null),h=m.useRef(null),f=we(e,h,i.onViewportChange),p=n.join("+").replace(/Key/g,"").replace(/Digit/g,""),g=i.toastCount>0;m.useEffect(()=>{const y=x=>{var b;n.length!==0&&n.every(k=>x[k]||x.code===k)&&((b=h.current)==null||b.focus())};return document.addEventListener("keydown",y),()=>document.removeEventListener("keydown",y)},[n]),m.useEffect(()=>{const y=c.current,x=h.current;if(g&&y&&x){const w=()=>{if(!i.isClosePausedRef.current){const C=new CustomEvent($y);x.dispatchEvent(C),i.isClosePausedRef.current=!0}},b=()=>{if(i.isClosePausedRef.current){const C=new CustomEvent(Fy);x.dispatchEvent(C),i.isClosePausedRef.current=!1}},k=C=>{!y.contains(C.relatedTarget)&&b()},S=()=>{y.contains(document.activeElement)||b()};return y.addEventListener("focusin",w),y.addEventListener("focusout",k),y.addEventListener("pointermove",w),y.addEventListener("pointerleave",S),window.addEventListener("blur",w),window.addEventListener("focus",b),()=>{y.removeEventListener("focusin",w),y.removeEventListener("focusout",k),y.removeEventListener("pointermove",w),y.removeEventListener("pointerleave",S),window.removeEventListener("blur",w),window.removeEventListener("focus",b)}}},[g,i.isClosePausedRef]);const v=m.useCallback(({tabbingDirection:y})=>{const w=a().map(b=>{const k=b.ref.current,S=[k,...E3(k)];return y==="forwards"?S:S.reverse()});return(y==="forwards"?w.reverse():w).flat()},[a]);return m.useEffect(()=>{const y=h.current;if(y){const x=w=>{var S,C,N;const b=w.altKey||w.ctrlKey||w.metaKey;if(w.key==="Tab"&&!b){const E=document.activeElement,j=w.shiftKey;if(w.target===y&&j){(S=d.current)==null||S.focus();return}const T=v({tabbingDirection:j?"backwards":"forwards"}),A=T.findIndex(I=>I===E);Uy(T.slice(A+1))?w.preventDefault():j?(C=d.current)==null||C.focus():(N=u.current)==null||N.focus()}};return y.addEventListener("keydown",x),()=>y.removeEventListener("keydown",x)}},[a,v]),l.jsxs(t3,{ref:c,role:"region","aria-label":s.replace("{hotkey}",p),tabIndex:-1,style:{pointerEvents:g?void 0:"none"},children:[g&&l.jsx(zy,{ref:d,onFocusFromOutsideViewport:()=>{const y=v({tabbingDirection:"forwards"});Uy(y)}}),l.jsx(Ly.Slot,{scope:r,children:l.jsx(se.ol,{tabIndex:-1,...o,ref:f})}),g&&l.jsx(zy,{ref:u,onFocusFromOutsideViewport:()=>{const y=v({tabbingDirection:"backwards"});Uy(y)}})]})});WN.displayName=VN;var HN="ToastFocusProxy",zy=m.forwardRef((t,e)=>{const{__scopeToast:r,onFocusFromOutsideViewport:n,...s}=t,o=qf(HN,r);return l.jsx(Hf,{"aria-hidden":!0,tabIndex:0,...s,ref:e,style:{position:"fixed"},onFocus:i=>{var d;const a=i.relatedTarget;!((d=o.viewport)!=null&&d.contains(a))&&n()}})});zy.displayName=HN;var Fd="Toast",m3="toast.swipeStart",g3="toast.swipeMove",v3="toast.swipeCancel",y3="toast.swipeEnd",qN=m.forwardRef((t,e)=>{const{forceMount:r,open:n,defaultOpen:s,onOpenChange:o,...i}=t,[a,c]=Wn({prop:n,defaultProp:s??!0,onChange:o,caller:Fd});return l.jsx(er,{present:r||a,children:l.jsx(b3,{open:a,...i,ref:e,onClose:()=>c(!1),onPause:at(t.onPause),onResume:at(t.onResume),onSwipeStart:Q(t.onSwipeStart,d=>{d.currentTarget.setAttribute("data-swipe","start")}),onSwipeMove:Q(t.onSwipeMove,d=>{const{x:u,y:h}=d.detail.delta;d.currentTarget.setAttribute("data-swipe","move"),d.currentTarget.style.setProperty("--radix-toast-swipe-move-x",`${u}px`),d.currentTarget.style.setProperty("--radix-toast-swipe-move-y",`${h}px`)}),onSwipeCancel:Q(t.onSwipeCancel,d=>{d.currentTarget.setAttribute("data-swipe","cancel"),d.currentTarget.style.removeProperty("--radix-toast-swipe-move-x"),d.currentTarget.style.removeProperty("--radix-toast-swipe-move-y"),d.currentTarget.style.removeProperty("--radix-toast-swipe-end-x"),d.currentTarget.style.removeProperty("--radix-toast-swipe-end-y")}),onSwipeEnd:Q(t.onSwipeEnd,d=>{const{x:u,y:h}=d.detail.delta;d.currentTarget.setAttribute("data-swipe","end"),d.currentTarget.style.removeProperty("--radix-toast-swipe-move-x"),d.currentTarget.style.removeProperty("--radix-toast-swipe-move-y"),d.currentTarget.style.setProperty("--radix-toast-swipe-end-x",`${u}px`),d.currentTarget.style.setProperty("--radix-toast-swipe-end-y",`${h}px`),c(!1)})})})});qN.displayName=Fd;var[x3,w3]=BN(Fd,{onClose(){}}),b3=m.forwardRef((t,e)=>{const{__scopeToast:r,type:n="foreground",duration:s,open:o,onClose:i,onEscapeKeyDown:a,onPause:c,onResume:d,onSwipeStart:u,onSwipeMove:h,onSwipeCancel:f,onSwipeEnd:p,...g}=t,v=qf(Fd,r),[y,x]=m.useState(null),w=we(e,I=>x(I)),b=m.useRef(null),k=m.useRef(null),S=s||v.duration,C=m.useRef(0),N=m.useRef(S),E=m.useRef(0),{onToastAdd:j,onToastRemove:_}=v,P=at(()=>{var V;(y==null?void 0:y.contains(document.activeElement))&&((V=v.viewport)==null||V.focus()),i()}),T=m.useCallback(I=>{!I||I===1/0||(window.clearTimeout(E.current),C.current=new Date().getTime(),E.current=window.setTimeout(P,I))},[P]);m.useEffect(()=>{const I=v.viewport;if(I){const V=()=>{T(N.current),d==null||d()},L=()=>{const U=new Date().getTime()-C.current;N.current=N.current-U,window.clearTimeout(E.current),c==null||c()};return I.addEventListener($y,L),I.addEventListener(Fy,V),()=>{I.removeEventListener($y,L),I.removeEventListener(Fy,V)}}},[v.viewport,S,c,d,T]),m.useEffect(()=>{o&&!v.isClosePausedRef.current&&T(S)},[o,S,v.isClosePausedRef,T]),m.useEffect(()=>(j(),()=>_()),[j,_]);const A=m.useMemo(()=>y?ZN(y):null,[y]);return v.viewport?l.jsxs(l.Fragment,{children:[A&&l.jsx(k3,{__scopeToast:r,role:"status","aria-live":n==="foreground"?"assertive":"polite","aria-atomic":!0,children:A}),l.jsx(x3,{scope:r,onClose:P,children:vn.createPortal(l.jsx(Ly.ItemSlot,{scope:r,children:l.jsx(e3,{asChild:!0,onEscapeKeyDown:Q(a,()=>{v.isFocusedToastEscapeKeyDownRef.current||P(),v.isFocusedToastEscapeKeyDownRef.current=!1}),children:l.jsx(se.li,{role:"status","aria-live":"off","aria-atomic":!0,tabIndex:0,"data-state":o?"open":"closed","data-swipe-direction":v.swipeDirection,...g,ref:w,style:{userSelect:"none",touchAction:"none",...t.style},onKeyDown:Q(t.onKeyDown,I=>{I.key==="Escape"&&(a==null||a(I.nativeEvent),I.nativeEvent.defaultPrevented||(v.isFocusedToastEscapeKeyDownRef.current=!0,P()))}),onPointerDown:Q(t.onPointerDown,I=>{I.button===0&&(b.current={x:I.clientX,y:I.clientY})}),onPointerMove:Q(t.onPointerMove,I=>{if(!b.current)return;const V=I.clientX-b.current.x,L=I.clientY-b.current.y,U=!!k.current,M=["left","right"].includes(v.swipeDirection),D=["left","up"].includes(v.swipeDirection)?Math.min:Math.max,H=M?D(0,V):0,ne=M?0:D(0,L),$=I.pointerType==="touch"?10:2,G={x:H,y:ne},J={originalEvent:I,delta:G};U?(k.current=G,Kf(g3,h,J,{discrete:!1})):eC(G,v.swipeDirection,$)?(k.current=G,Kf(m3,u,J,{discrete:!1}),I.target.setPointerCapture(I.pointerId)):(Math.abs(V)>$||Math.abs(L)>$)&&(b.current=null)}),onPointerUp:Q(t.onPointerUp,I=>{const V=k.current,L=I.target;if(L.hasPointerCapture(I.pointerId)&&L.releasePointerCapture(I.pointerId),k.current=null,b.current=null,V){const U=I.currentTarget,M={originalEvent:I,delta:V};eC(V,v.swipeDirection,v.swipeThreshold)?Kf(y3,p,M,{discrete:!0}):Kf(v3,f,M,{discrete:!0}),U.addEventListener("click",D=>D.preventDefault(),{once:!0})}})})})}),v.viewport)})]}):null}),k3=t=>{const{__scopeToast:e,children:r,...n}=t,s=qf(Fd,e),[o,i]=m.useState(!1),[a,c]=m.useState(!1);return C3(()=>i(!0)),m.useEffect(()=>{const d=window.setTimeout(()=>c(!0),1e3);return()=>window.clearTimeout(d)},[]),a?null:l.jsx($d,{asChild:!0,children:l.jsx(Hf,{...n,children:o&&l.jsxs(l.Fragment,{children:[s.label," ",r]})})})},S3="ToastTitle",KN=m.forwardRef((t,e)=>{const{__scopeToast:r,...n}=t;return l.jsx(se.div,{...n,ref:e})});KN.displayName=S3;var N3="ToastDescription",GN=m.forwardRef((t,e)=>{const{__scopeToast:r,...n}=t;return l.jsx(se.div,{...n,ref:e})});GN.displayName=N3;var YN="ToastAction",JN=m.forwardRef((t,e)=>{const{altText:r,...n}=t;return r.trim()?l.jsx(XN,{altText:r,asChild:!0,children:l.jsx(By,{...n,ref:e})}):(console.error(`Invalid prop \`altText\` supplied to \`${YN}\`. Expected non-empty \`string\`.`),null)});JN.displayName=YN;var QN="ToastClose",By=m.forwardRef((t,e)=>{const{__scopeToast:r,...n}=t,s=w3(QN,r);return l.jsx(XN,{asChild:!0,children:l.jsx(se.button,{type:"button",...n,ref:e,onClick:Q(t.onClick,s.onClose)})})});By.displayName=QN;var XN=m.forwardRef((t,e)=>{const{__scopeToast:r,altText:n,...s}=t;return l.jsx(se.div,{"data-radix-toast-announce-exclude":"","data-radix-toast-announce-alt":n||void 0,...s,ref:e})});function ZN(t){const e=[];return Array.from(t.childNodes).forEach(n=>{if(n.nodeType===n.TEXT_NODE&&n.textContent&&e.push(n.textContent),j3(n)){const s=n.ariaHidden||n.hidden||n.style.display==="none",o=n.dataset.radixToastAnnounceExclude==="";if(!s)if(o){const i=n.dataset.radixToastAnnounceAlt;i&&e.push(i)}else e.push(...ZN(n))}}),e}function Kf(t,e,r,{discrete:n}){const s=r.originalEvent.currentTarget,o=new CustomEvent(t,{bubbles:!0,cancelable:!0,detail:r});e&&s.addEventListener(t,e,{once:!0}),n?Ay(s,o):s.dispatchEvent(o)}var eC=(t,e,r=0)=>{const n=Math.abs(t.x),s=Math.abs(t.y),o=n>s;return e==="left"||e==="right"?o&&n>r:!o&&s>r};function C3(t=()=>{}){const e=at(t);gt(()=>{let r=0,n=0;return r=window.requestAnimationFrame(()=>n=window.requestAnimationFrame(e)),()=>{window.cancelAnimationFrame(r),window.cancelAnimationFrame(n)}},[e])}function j3(t){return t.nodeType===t.ELEMENT_NODE}function E3(t){const e=[],r=document.createTreeWalker(t,NodeFilter.SHOW_ELEMENT,{acceptNode:n=>{const s=n.tagName==="INPUT"&&n.type==="hidden";return n.disabled||n.hidden||s?NodeFilter.FILTER_SKIP:n.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;r.nextNode();)e.push(r.currentNode);return e}function Uy(t){const e=document.activeElement;return t.some(r=>r===e?!0:(r.focus(),document.activeElement!==e))}var _3=UN,tC=WN,rC=qN,nC=KN,sC=GN,oC=JN,iC=By;function aC(t){var e,r,n="";if(typeof t=="string"||typeof t=="number")n+=t;else if(typeof t=="object")if(Array.isArray(t)){var s=t.length;for(e=0;etypeof t=="boolean"?`${t}`:t===0?"0":t,dC=lC,Sl=(t,e)=>r=>{var n;if((e==null?void 0:e.variants)==null)return dC(t,r==null?void 0:r.class,r==null?void 0:r.className);const{variants:s,defaultVariants:o}=e,i=Object.keys(s).map(d=>{const u=r==null?void 0:r[d],h=o==null?void 0:o[d];if(u===null)return null;const f=cC(u)||cC(h);return s[d][f]}),a=r&&Object.entries(r).reduce((d,u)=>{let[h,f]=u;return f===void 0||(d[h]=f),d},{}),c=e==null||(n=e.compoundVariants)===null||n===void 0?void 0:n.reduce((d,u)=>{let{class:h,className:f,...p}=u;return Object.entries(p).every(g=>{let[v,y]=g;return Array.isArray(y)?y.includes({...o,...a}[v]):{...o,...a}[v]===y})?[...d,h,f]:d},[]);return dC(t,i,c,r==null?void 0:r.class,r==null?void 0:r.className)};/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const T3=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),uC=(...t)=>t.filter((e,r,n)=>!!e&&e.trim()!==""&&n.indexOf(e)===r).join(" ").trim();/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */var R3={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const M3=m.forwardRef(({color:t="currentColor",size:e=24,strokeWidth:r=2,absoluteStrokeWidth:n,className:s="",children:o,iconNode:i,...a},c)=>m.createElement("svg",{ref:c,...R3,width:e,height:e,stroke:t,strokeWidth:n?Number(r)*24/Number(e):r,className:uC("lucide",s),...a},[...i.map(([d,u])=>m.createElement(d,u)),...Array.isArray(o)?o:[o]]));/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const re=(t,e)=>{const r=m.forwardRef(({className:n,...s},o)=>m.createElement(M3,{ref:o,iconNode:e,className:uC(`lucide-${T3(t)}`,n),...s}));return r.displayName=`${t}`,r};/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const O3=re("ArrowLeft",[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const hC=re("ArrowRight",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const P3=re("Bold",[["path",{d:"M6 12h9a4 4 0 0 1 0 8H7a1 1 0 0 1-1-1V5a1 1 0 0 1 1-1h7a4 4 0 0 1 0 8",key:"mg9rjx"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const vt=re("BookOpen",[["path",{d:"M12 7v14",key:"1akyts"}],["path",{d:"M3 18a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h5a4 4 0 0 1 4 4 4 4 0 0 1 4-4h5a1 1 0 0 1 1 1v13a1 1 0 0 1-1 1h-6a3 3 0 0 0-3 3 3 3 0 0 0-3-3z",key:"ruj8y"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const fC=re("Brain",[["path",{d:"M12 5a3 3 0 1 0-5.997.125 4 4 0 0 0-2.526 5.77 4 4 0 0 0 .556 6.588A4 4 0 1 0 12 18Z",key:"l5xja"}],["path",{d:"M12 5a3 3 0 1 1 5.997.125 4 4 0 0 1 2.526 5.77 4 4 0 0 1-.556 6.588A4 4 0 1 1 12 18Z",key:"ep3f8r"}],["path",{d:"M15 13a4.5 4.5 0 0 1-3-4 4.5 4.5 0 0 1-3 4",key:"1p4c4q"}],["path",{d:"M17.599 6.5a3 3 0 0 0 .399-1.375",key:"tmeiqw"}],["path",{d:"M6.003 5.125A3 3 0 0 0 6.401 6.5",key:"105sqy"}],["path",{d:"M3.477 10.896a4 4 0 0 1 .585-.396",key:"ql3yin"}],["path",{d:"M19.938 10.5a4 4 0 0 1 .585.396",key:"1qfode"}],["path",{d:"M6 18a4 4 0 0 1-1.967-.516",key:"2e4loj"}],["path",{d:"M19.967 17.484A4 4 0 0 1 18 18",key:"159ez6"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Sr=re("Calendar",[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2",key:"1hopcy"}],["path",{d:"M3 10h18",key:"8toen8"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Qi=re("Check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const pC=re("ChevronDown",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Nl=re("ChevronLeft",[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const wt=re("ChevronRight",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const A3=re("ChevronUp",[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const zd=re("CircleAlert",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Lo=re("CircleCheck",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const I3=re("CircleHelp",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",key:"1u773s"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Gs=re("Circle",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const tr=re("Clock",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 16 14",key:"68esgv"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Vy=re("Copy",[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Cl=re("Crown",[["path",{d:"M11.562 3.266a.5.5 0 0 1 .876 0L15.39 8.87a1 1 0 0 0 1.516.294L21.183 5.5a.5.5 0 0 1 .798.519l-2.834 10.246a1 1 0 0 1-.956.734H5.81a1 1 0 0 1-.957-.734L2.02 6.02a.5.5 0 0 1 .798-.519l4.276 3.664a1 1 0 0 0 1.516-.294z",key:"1vdc57"}],["path",{d:"M5 21h14",key:"11awu3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const D3=re("Download",[["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["polyline",{points:"7 10 12 15 17 10",key:"2ggqvy"}],["line",{x1:"12",x2:"12",y1:"15",y2:"3",key:"1vk2je"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const L3=re("Ellipsis",[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"19",cy:"12",r:"1",key:"1wjl8i"}],["circle",{cx:"5",cy:"12",r:"1",key:"1pcz8c"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const $3=re("Eraser",[["path",{d:"m7 21-4.3-4.3c-1-1-1-2.5 0-3.4l9.6-9.6c1-1 2.5-1 3.4 0l5.6 5.6c1 1 1 2.5 0 3.4L13 21",key:"182aya"}],["path",{d:"M22 21H7",key:"t4ddhn"}],["path",{d:"m5 11 9 9",key:"1mo9qw"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const F3=re("ExternalLink",[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const z3=re("EyeOff",[["path",{d:"M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49",key:"ct8e1f"}],["path",{d:"M14.084 14.158a3 3 0 0 1-4.242-4.242",key:"151rxh"}],["path",{d:"M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143",key:"13bj9a"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const B3=re("Eye",[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const zt=re("FileText",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const mC=re("Filter",[["polygon",{points:"22 3 2 3 10 12.46 10 19 14 21 14 12.46 22 3",key:"1yg77f"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Wy=re("GraduationCap",[["path",{d:"M21.42 10.922a1 1 0 0 0-.019-1.838L12.83 5.18a2 2 0 0 0-1.66 0L2.6 9.08a1 1 0 0 0 0 1.832l8.57 3.908a2 2 0 0 0 1.66 0z",key:"j76jl0"}],["path",{d:"M22 10v6",key:"1lu8f3"}],["path",{d:"M6 12.5V16a6 3 0 0 0 12 0v-3.5",key:"1r8lef"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const U3=re("Grid3x3",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 9h18",key:"1pudct"}],["path",{d:"M3 15h18",key:"5xshup"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"M15 3v18",key:"14nvp0"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const V3=re("GripVertical",[["circle",{cx:"9",cy:"12",r:"1",key:"1vctgf"}],["circle",{cx:"9",cy:"5",r:"1",key:"hp0tcf"}],["circle",{cx:"9",cy:"19",r:"1",key:"fkjjf6"}],["circle",{cx:"15",cy:"12",r:"1",key:"1tmaij"}],["circle",{cx:"15",cy:"5",r:"1",key:"19l28e"}],["circle",{cx:"15",cy:"19",r:"1",key:"f4zoj3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const gC=re("HardDrive",[["line",{x1:"22",x2:"2",y1:"12",y2:"12",key:"1y58io"}],["path",{d:"M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z",key:"oot6mr"}],["line",{x1:"6",x2:"6.01",y1:"16",y2:"16",key:"sgf278"}],["line",{x1:"10",x2:"10.01",y1:"16",y2:"16",key:"1l4acy"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const W3=re("Heading1",[["path",{d:"M4 12h8",key:"17cfdx"}],["path",{d:"M4 18V6",key:"1rz3zl"}],["path",{d:"M12 18V6",key:"zqpxq5"}],["path",{d:"m17 12 3-2v8",key:"1hhhft"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const H3=re("Heading2",[["path",{d:"M4 12h8",key:"17cfdx"}],["path",{d:"M4 18V6",key:"1rz3zl"}],["path",{d:"M12 18V6",key:"zqpxq5"}],["path",{d:"M21 18h-4c0-4 4-3 4-6 0-1.5-2-2.5-4-1",key:"9jr5yi"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const q3=re("Heading3",[["path",{d:"M4 12h8",key:"17cfdx"}],["path",{d:"M4 18V6",key:"1rz3zl"}],["path",{d:"M12 18V6",key:"zqpxq5"}],["path",{d:"M17.5 10.5c1.7-1 3.5 0 3.5 1.5a2 2 0 0 1-2 2",key:"68ncm8"}],["path",{d:"M17 17.5c2 1.5 4 .3 4-1.5a2 2 0 0 0-2-2",key:"1ejuhz"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const vC=re("History",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const K3=re("House",[["path",{d:"M15 21v-8a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v8",key:"5wwlr5"}],["path",{d:"M3 10a2 2 0 0 1 .709-1.528l7-5.999a2 2 0 0 1 2.582 0l7 5.999A2 2 0 0 1 21 10v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z",key:"1d0kgt"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const G3=re("Italic",[["line",{x1:"19",x2:"10",y1:"4",y2:"4",key:"15jd3p"}],["line",{x1:"14",x2:"5",y1:"20",y2:"20",key:"bu0au3"}],["line",{x1:"15",x2:"9",y1:"4",y2:"20",key:"uljnxc"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Y3=re("Layers",[["path",{d:"m12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83Z",key:"8b97xw"}],["path",{d:"m22 17.65-9.17 4.16a2 2 0 0 1-1.66 0L2 17.65",key:"dd6zsq"}],["path",{d:"m22 12.65-9.17 4.16a2 2 0 0 1-1.66 0L2 12.65",key:"ep9fru"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Hy=re("LayoutDashboard",[["rect",{width:"7",height:"9",x:"3",y:"3",rx:"1",key:"10lvy0"}],["rect",{width:"7",height:"5",x:"14",y:"3",rx:"1",key:"16une8"}],["rect",{width:"7",height:"9",x:"14",y:"12",rx:"1",key:"1hutg5"}],["rect",{width:"7",height:"5",x:"3",y:"16",rx:"1",key:"ldoo1y"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Bd=re("Link2",[["path",{d:"M9 17H7A5 5 0 0 1 7 7h2",key:"8i5ue5"}],["path",{d:"M15 7h2a5 5 0 1 1 0 10h-2",key:"1b9ql8"}],["line",{x1:"8",x2:"16",y1:"12",y2:"12",key:"1jonct"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const J3=re("ListOrdered",[["path",{d:"M10 12h11",key:"6m4ad9"}],["path",{d:"M10 18h11",key:"11hvi2"}],["path",{d:"M10 6h11",key:"c7qv1k"}],["path",{d:"M4 10h2",key:"16xx2s"}],["path",{d:"M4 6h1v4",key:"cnovpq"}],["path",{d:"M6 18H4c0-1 2-2 2-3s-1-1.5-2-1",key:"m9a95d"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const yC=re("List",[["path",{d:"M3 12h.01",key:"nlz23k"}],["path",{d:"M3 18h.01",key:"1tta3j"}],["path",{d:"M3 6h.01",key:"1rqtza"}],["path",{d:"M8 12h13",key:"1za7za"}],["path",{d:"M8 18h13",key:"1lx6n3"}],["path",{d:"M8 6h13",key:"ik3vkj"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Bt=re("LoaderCircle",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Q3=re("LogOut",[["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}],["polyline",{points:"16 17 21 12 16 7",key:"1gabdz"}],["line",{x1:"21",x2:"9",y1:"12",y2:"12",key:"1uyos4"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const $o=re("MapPin",[["path",{d:"M20 10c0 4.993-5.539 10.193-7.399 11.799a1 1 0 0 1-1.202 0C9.539 20.193 4 14.993 4 10a8 8 0 0 1 16 0",key:"1r0f0z"}],["circle",{cx:"12",cy:"10",r:"3",key:"ilqhr7"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const X3=re("Medal",[["path",{d:"M7.21 15 2.66 7.14a2 2 0 0 1 .13-2.2L4.4 2.8A2 2 0 0 1 6 2h12a2 2 0 0 1 1.6.8l1.6 2.14a2 2 0 0 1 .14 2.2L16.79 15",key:"143lza"}],["path",{d:"M11 12 5.12 2.2",key:"qhuxz6"}],["path",{d:"m13 12 5.88-9.8",key:"hbye0f"}],["path",{d:"M8 7h8",key:"i86dvs"}],["circle",{cx:"12",cy:"17",r:"5",key:"qbz8iq"}],["path",{d:"M12 18v-2h-.5",key:"fawc4q"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Z3=re("Menu",[["line",{x1:"4",x2:"20",y1:"12",y2:"12",key:"1e0a9i"}],["line",{x1:"4",x2:"20",y1:"6",y2:"6",key:"1owob3"}],["line",{x1:"4",x2:"20",y1:"18",y2:"18",key:"yk5zj1"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Gf=re("Mic",[["path",{d:"M12 2a3 3 0 0 0-3 3v7a3 3 0 0 0 6 0V5a3 3 0 0 0-3-3Z",key:"131961"}],["path",{d:"M19 10v2a7 7 0 0 1-14 0v-2",key:"1vc78b"}],["line",{x1:"12",x2:"12",y1:"19",y2:"22",key:"x3vr5v"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const eL=re("Minus",[["path",{d:"M5 12h14",key:"1ays0h"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const xC=re("Moon",[["path",{d:"M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z",key:"a7tn18"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const tL=re("Pen",[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const rL=re("Pencil",[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const qy=re("Play",[["polygon",{points:"6 3 20 12 6 21 6 3",key:"1oa8hb"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Rt=re("Plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const nL=re("Quote",[["path",{d:"M16 3a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2 1 1 0 0 1 1 1v1a2 2 0 0 1-2 2 1 1 0 0 0-1 1v2a1 1 0 0 0 1 1 6 6 0 0 0 6-6V5a2 2 0 0 0-2-2z",key:"rib7q0"}],["path",{d:"M5 3a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2 1 1 0 0 1 1 1v1a2 2 0 0 1-2 2 1 1 0 0 0-1 1v2a1 1 0 0 0 1 1 6 6 0 0 0 6-6V5a2 2 0 0 0-2-2z",key:"1ymkrd"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const wC=re("Redo2",[["path",{d:"m15 14 5-5-5-5",key:"12vg1m"}],["path",{d:"M20 9H9.5A5.5 5.5 0 0 0 4 14.5A5.5 5.5 0 0 0 9.5 20H13",key:"6uklza"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const bC=re("RefreshCw",[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const kC=re("RotateCcw",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const sL=re("Save",[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ud=re("Search",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const oL=re("Send",[["path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",key:"1ffxy3"}],["path",{d:"m21.854 2.147-10.94 10.939",key:"12cjpa"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const iL=re("Settings2",[["path",{d:"M20 7h-9",key:"3s1dr2"}],["path",{d:"M14 17H5",key:"gfn3mx"}],["circle",{cx:"17",cy:"17",r:"3",key:"18b49y"}],["circle",{cx:"7",cy:"7",r:"3",key:"dfmy0x"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const aL=re("Settings",[["path",{d:"M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z",key:"1qme2f"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const SC=re("Share2",[["circle",{cx:"18",cy:"5",r:"3",key:"gq8acd"}],["circle",{cx:"6",cy:"12",r:"3",key:"w7nqdw"}],["circle",{cx:"18",cy:"19",r:"3",key:"1xt0gg"}],["line",{x1:"8.59",x2:"15.42",y1:"13.51",y2:"17.49",key:"47mynk"}],["line",{x1:"15.41",x2:"8.59",y1:"6.51",y2:"10.49",key:"1n3mei"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Nr=re("Sparkles",[["path",{d:"M9.937 15.5A2 2 0 0 0 8.5 14.063l-6.135-1.582a.5.5 0 0 1 0-.962L8.5 9.936A2 2 0 0 0 9.937 8.5l1.582-6.135a.5.5 0 0 1 .963 0L14.063 8.5A2 2 0 0 0 15.5 9.937l6.135 1.581a.5.5 0 0 1 0 .964L15.5 14.063a2 2 0 0 0-1.437 1.437l-1.582 6.135a.5.5 0 0 1-.963 0z",key:"4pj2yx"}],["path",{d:"M20 3v4",key:"1olli1"}],["path",{d:"M22 5h-4",key:"1gvqau"}],["path",{d:"M4 17v2",key:"vumght"}],["path",{d:"M5 18H3",key:"zchphs"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const jl=re("SquareCheckBig",[["path",{d:"M21 10.5V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h12.5",key:"1uzm8b"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const lL=re("Square",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const cL=re("Strikethrough",[["path",{d:"M16 4H9a3 3 0 0 0-2.83 4",key:"43sutm"}],["path",{d:"M14 12a4 4 0 0 1 0 8H6",key:"nlfj13"}],["line",{x1:"4",x2:"20",y1:"12",y2:"12",key:"1e0a9i"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const dL=re("Sun",[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m4.93 4.93 1.41 1.41",key:"149t6j"}],["path",{d:"m17.66 17.66 1.41 1.41",key:"ptbguv"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m6.34 17.66-1.41 1.41",key:"1m8zz5"}],["path",{d:"m19.07 4.93-1.41 1.41",key:"1shlcs"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const uL=re("Target",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"6",key:"1vlfrh"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const hL=re("Timer",[["line",{x1:"10",x2:"14",y1:"2",y2:"2",key:"14vaq8"}],["line",{x1:"12",x2:"15",y1:"14",y2:"11",key:"17fdiu"}],["circle",{cx:"12",cy:"14",r:"8",key:"1e1u0o"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Ky=re("Trash2",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Gy=re("TrendingUp",[["polyline",{points:"22 7 13.5 15.5 8.5 10.5 2 17",key:"126l90"}],["polyline",{points:"16 7 22 7 22 13",key:"kwv8wd"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Vd=re("TriangleAlert",[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Yy=re("Trophy",[["path",{d:"M6 9H4.5a2.5 2.5 0 0 1 0-5H6",key:"17hqa7"}],["path",{d:"M18 9h1.5a2.5 2.5 0 0 0 0-5H18",key:"lmptdp"}],["path",{d:"M4 22h16",key:"57wxv0"}],["path",{d:"M10 14.66V17c0 .55-.47.98-.97 1.21C7.85 18.75 7 20.24 7 22",key:"1nw9bq"}],["path",{d:"M14 14.66V17c0 .55.47.98.97 1.21C16.15 18.75 17 20.24 17 22",key:"1np0yb"}],["path",{d:"M18 2H6v7a6 6 0 0 0 12 0V2Z",key:"u46fv3"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const fL=re("Underline",[["path",{d:"M6 4v6a6 6 0 0 0 12 0V4",key:"9kb039"}],["line",{x1:"4",x2:"20",y1:"20",y2:"20",key:"nun2al"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const NC=re("Undo2",[["path",{d:"M9 14 4 9l5-5",key:"102s5s"}],["path",{d:"M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11",key:"f3b9sd"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const CC=re("Upload",[["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["polyline",{points:"17 8 12 3 7 8",key:"t8dd8p"}],["line",{x1:"12",x2:"12",y1:"3",y2:"15",key:"widbto"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const pL=re("User",[["path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2",key:"975kel"}],["circle",{cx:"12",cy:"7",r:"4",key:"17ys0d"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const $r=re("Users",[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["path",{d:"M22 21v-2a4 4 0 0 0-3-3.87",key:"kshegd"}],["path",{d:"M16 3.13a4 4 0 0 1 0 7.75",key:"1da9ce"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Wd=re("X",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]);/** * @license lucide-react v0.462.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const mL=re("Zap",[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]]),Jy="-",gL=t=>{const e=yL(t),{conflictingClassGroups:r,conflictingClassGroupModifiers:n}=t;return{getClassGroupId:i=>{const a=i.split(Jy);return a[0]===""&&a.length!==1&&a.shift(),jC(a,e)||vL(i)},getConflictingClassGroupIds:(i,a)=>{const c=r[i]||[];return a&&n[i]?[...c,...n[i]]:c}}},jC=(t,e)=>{var i;if(t.length===0)return e.classGroupId;const r=t[0],n=e.nextPart.get(r),s=n?jC(t.slice(1),n):void 0;if(s)return s;if(e.validators.length===0)return;const o=t.join(Jy);return(i=e.validators.find(({validator:a})=>a(o)))==null?void 0:i.classGroupId},EC=/^\[(.+)\]$/,vL=t=>{if(EC.test(t)){const e=EC.exec(t)[1],r=e==null?void 0:e.substring(0,e.indexOf(":"));if(r)return"arbitrary.."+r}},yL=t=>{const{theme:e,prefix:r}=t,n={nextPart:new Map,validators:[]};return wL(Object.entries(t.classGroups),r).forEach(([o,i])=>{Qy(i,n,o,e)}),n},Qy=(t,e,r,n)=>{t.forEach(s=>{if(typeof s=="string"){const o=s===""?e:_C(e,s);o.classGroupId=r;return}if(typeof s=="function"){if(xL(s)){Qy(s(n),e,r,n);return}e.validators.push({validator:s,classGroupId:r});return}Object.entries(s).forEach(([o,i])=>{Qy(i,_C(e,o),r,n)})})},_C=(t,e)=>{let r=t;return e.split(Jy).forEach(n=>{r.nextPart.has(n)||r.nextPart.set(n,{nextPart:new Map,validators:[]}),r=r.nextPart.get(n)}),r},xL=t=>t.isThemeGetter,wL=(t,e)=>e?t.map(([r,n])=>{const s=n.map(o=>typeof o=="string"?e+o:typeof o=="object"?Object.fromEntries(Object.entries(o).map(([i,a])=>[e+i,a])):o);return[r,s]}):t,bL=t=>{if(t<1)return{get:()=>{},set:()=>{}};let e=0,r=new Map,n=new Map;const s=(o,i)=>{r.set(o,i),e++,e>t&&(e=0,n=r,r=new Map)};return{get(o){let i=r.get(o);if(i!==void 0)return i;if((i=n.get(o))!==void 0)return s(o,i),i},set(o,i){r.has(o)?r.set(o,i):s(o,i)}}},TC="!",kL=t=>{const{separator:e,experimentalParseClassName:r}=t,n=e.length===1,s=e[0],o=e.length,i=a=>{const c=[];let d=0,u=0,h;for(let y=0;yu?h-u:void 0;return{modifiers:c,hasImportantModifier:p,baseClassName:g,maybePostfixModifierPosition:v}};return r?a=>r({className:a,parseClassName:i}):i},SL=t=>{if(t.length<=1)return t;const e=[];let r=[];return t.forEach(n=>{n[0]==="["?(e.push(...r.sort(),n),r=[]):r.push(n)}),e.push(...r.sort()),e},NL=t=>({cache:bL(t.cacheSize),parseClassName:kL(t),...gL(t)}),CL=/\s+/,jL=(t,e)=>{const{parseClassName:r,getClassGroupId:n,getConflictingClassGroupIds:s}=e,o=[],i=t.trim().split(CL);let a="";for(let c=i.length-1;c>=0;c-=1){const d=i[c],{modifiers:u,hasImportantModifier:h,baseClassName:f,maybePostfixModifierPosition:p}=r(d);let g=!!p,v=n(g?f.substring(0,p):f);if(!v){if(!g){a=d+(a.length>0?" "+a:a);continue}if(v=n(f),!v){a=d+(a.length>0?" "+a:a);continue}g=!1}const y=SL(u).join(":"),x=h?y+TC:y,w=x+v;if(o.includes(w))continue;o.push(w);const b=s(v,g);for(let k=0;k0?" "+a:a)}return a};function EL(){let t=0,e,r,n="";for(;t{if(typeof t=="string")return t;let e,r="";for(let n=0;nh(u),t());return r=NL(d),n=r.cache.get,s=r.cache.set,o=a,a(c)}function a(c){const d=n(c);if(d)return d;const u=jL(c,r);return s(c,u),u}return function(){return o(EL.apply(null,arguments))}}const Qe=t=>{const e=r=>r[t]||[];return e.isThemeGetter=!0,e},MC=/^\[(?:([a-z-]+):)?(.+)\]$/i,TL=/^\d+\/\d+$/,RL=new Set(["px","full","screen"]),ML=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,OL=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,PL=/^(rgba?|hsla?|hwb|(ok)?(lab|lch))\(.+\)$/,AL=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,IL=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,Ys=t=>El(t)||RL.has(t)||TL.test(t),Fo=t=>_l(t,"length",VL),El=t=>!!t&&!Number.isNaN(Number(t)),Xy=t=>_l(t,"number",El),Hd=t=>!!t&&Number.isInteger(Number(t)),DL=t=>t.endsWith("%")&&El(t.slice(0,-1)),je=t=>MC.test(t),zo=t=>ML.test(t),LL=new Set(["length","size","percentage"]),$L=t=>_l(t,LL,OC),FL=t=>_l(t,"position",OC),zL=new Set(["image","url"]),BL=t=>_l(t,zL,HL),UL=t=>_l(t,"",WL),qd=()=>!0,_l=(t,e,r)=>{const n=MC.exec(t);return n?n[1]?typeof e=="string"?n[1]===e:e.has(n[1]):r(n[2]):!1},VL=t=>OL.test(t)&&!PL.test(t),OC=()=>!1,WL=t=>AL.test(t),HL=t=>IL.test(t),qL=_L(()=>{const t=Qe("colors"),e=Qe("spacing"),r=Qe("blur"),n=Qe("brightness"),s=Qe("borderColor"),o=Qe("borderRadius"),i=Qe("borderSpacing"),a=Qe("borderWidth"),c=Qe("contrast"),d=Qe("grayscale"),u=Qe("hueRotate"),h=Qe("invert"),f=Qe("gap"),p=Qe("gradientColorStops"),g=Qe("gradientColorStopPositions"),v=Qe("inset"),y=Qe("margin"),x=Qe("opacity"),w=Qe("padding"),b=Qe("saturate"),k=Qe("scale"),S=Qe("sepia"),C=Qe("skew"),N=Qe("space"),E=Qe("translate"),j=()=>["auto","contain","none"],_=()=>["auto","hidden","clip","visible","scroll"],P=()=>["auto",je,e],T=()=>[je,e],A=()=>["",Ys,Fo],I=()=>["auto",El,je],V=()=>["bottom","center","left","left-bottom","left-top","right","right-bottom","right-top","top"],L=()=>["solid","dashed","dotted","double","none"],U=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],M=()=>["start","end","center","between","around","evenly","stretch"],D=()=>["","0",je],H=()=>["auto","avoid","all","avoid-page","page","left","right","column"],ne=()=>[El,je];return{cacheSize:500,separator:":",theme:{colors:[qd],spacing:[Ys,Fo],blur:["none","",zo,je],brightness:ne(),borderColor:[t],borderRadius:["none","","full",zo,je],borderSpacing:T(),borderWidth:A(),contrast:ne(),grayscale:D(),hueRotate:ne(),invert:D(),gap:T(),gradientColorStops:[t],gradientColorStopPositions:[DL,Fo],inset:P(),margin:P(),opacity:ne(),padding:T(),saturate:ne(),scale:ne(),sepia:D(),skew:ne(),space:T(),translate:T()},classGroups:{aspect:[{aspect:["auto","square","video",je]}],container:["container"],columns:[{columns:[zo]}],"break-after":[{"break-after":H()}],"break-before":[{"break-before":H()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:[...V(),je]}],overflow:[{overflow:_()}],"overflow-x":[{"overflow-x":_()}],"overflow-y":[{"overflow-y":_()}],overscroll:[{overscroll:j()}],"overscroll-x":[{"overscroll-x":j()}],"overscroll-y":[{"overscroll-y":j()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:[v]}],"inset-x":[{"inset-x":[v]}],"inset-y":[{"inset-y":[v]}],start:[{start:[v]}],end:[{end:[v]}],top:[{top:[v]}],right:[{right:[v]}],bottom:[{bottom:[v]}],left:[{left:[v]}],visibility:["visible","invisible","collapse"],z:[{z:["auto",Hd,je]}],basis:[{basis:P()}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["wrap","wrap-reverse","nowrap"]}],flex:[{flex:["1","auto","initial","none",je]}],grow:[{grow:D()}],shrink:[{shrink:D()}],order:[{order:["first","last","none",Hd,je]}],"grid-cols":[{"grid-cols":[qd]}],"col-start-end":[{col:["auto",{span:["full",Hd,je]},je]}],"col-start":[{"col-start":I()}],"col-end":[{"col-end":I()}],"grid-rows":[{"grid-rows":[qd]}],"row-start-end":[{row:["auto",{span:[Hd,je]},je]}],"row-start":[{"row-start":I()}],"row-end":[{"row-end":I()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":["auto","min","max","fr",je]}],"auto-rows":[{"auto-rows":["auto","min","max","fr",je]}],gap:[{gap:[f]}],"gap-x":[{"gap-x":[f]}],"gap-y":[{"gap-y":[f]}],"justify-content":[{justify:["normal",...M()]}],"justify-items":[{"justify-items":["start","end","center","stretch"]}],"justify-self":[{"justify-self":["auto","start","end","center","stretch"]}],"align-content":[{content:["normal",...M(),"baseline"]}],"align-items":[{items:["start","end","center","baseline","stretch"]}],"align-self":[{self:["auto","start","end","center","stretch","baseline"]}],"place-content":[{"place-content":[...M(),"baseline"]}],"place-items":[{"place-items":["start","end","center","baseline","stretch"]}],"place-self":[{"place-self":["auto","start","end","center","stretch"]}],p:[{p:[w]}],px:[{px:[w]}],py:[{py:[w]}],ps:[{ps:[w]}],pe:[{pe:[w]}],pt:[{pt:[w]}],pr:[{pr:[w]}],pb:[{pb:[w]}],pl:[{pl:[w]}],m:[{m:[y]}],mx:[{mx:[y]}],my:[{my:[y]}],ms:[{ms:[y]}],me:[{me:[y]}],mt:[{mt:[y]}],mr:[{mr:[y]}],mb:[{mb:[y]}],ml:[{ml:[y]}],"space-x":[{"space-x":[N]}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":[N]}],"space-y-reverse":["space-y-reverse"],w:[{w:["auto","min","max","fit","svw","lvw","dvw",je,e]}],"min-w":[{"min-w":[je,e,"min","max","fit"]}],"max-w":[{"max-w":[je,e,"none","full","min","max","fit","prose",{screen:[zo]},zo]}],h:[{h:[je,e,"auto","min","max","fit","svh","lvh","dvh"]}],"min-h":[{"min-h":[je,e,"min","max","fit","svh","lvh","dvh"]}],"max-h":[{"max-h":[je,e,"min","max","fit","svh","lvh","dvh"]}],size:[{size:[je,e,"auto","min","max","fit"]}],"font-size":[{text:["base",zo,Fo]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:["thin","extralight","light","normal","medium","semibold","bold","extrabold","black",Xy]}],"font-family":[{font:[qd]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:["tighter","tight","normal","wide","wider","widest",je]}],"line-clamp":[{"line-clamp":["none",El,Xy]}],leading:[{leading:["none","tight","snug","normal","relaxed","loose",Ys,je]}],"list-image":[{"list-image":["none",je]}],"list-style-type":[{list:["none","disc","decimal",je]}],"list-style-position":[{list:["inside","outside"]}],"placeholder-color":[{placeholder:[t]}],"placeholder-opacity":[{"placeholder-opacity":[x]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"text-color":[{text:[t]}],"text-opacity":[{"text-opacity":[x]}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...L(),"wavy"]}],"text-decoration-thickness":[{decoration:["auto","from-font",Ys,Fo]}],"underline-offset":[{"underline-offset":["auto",Ys,je]}],"text-decoration-color":[{decoration:[t]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:T()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",je]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",je]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-opacity":[{"bg-opacity":[x]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:[...V(),FL]}],"bg-repeat":[{bg:["no-repeat",{repeat:["","x","y","round","space"]}]}],"bg-size":[{bg:["auto","cover","contain",$L]}],"bg-image":[{bg:["none",{"gradient-to":["t","tr","r","br","b","bl","l","tl"]},BL]}],"bg-color":[{bg:[t]}],"gradient-from-pos":[{from:[g]}],"gradient-via-pos":[{via:[g]}],"gradient-to-pos":[{to:[g]}],"gradient-from":[{from:[p]}],"gradient-via":[{via:[p]}],"gradient-to":[{to:[p]}],rounded:[{rounded:[o]}],"rounded-s":[{"rounded-s":[o]}],"rounded-e":[{"rounded-e":[o]}],"rounded-t":[{"rounded-t":[o]}],"rounded-r":[{"rounded-r":[o]}],"rounded-b":[{"rounded-b":[o]}],"rounded-l":[{"rounded-l":[o]}],"rounded-ss":[{"rounded-ss":[o]}],"rounded-se":[{"rounded-se":[o]}],"rounded-ee":[{"rounded-ee":[o]}],"rounded-es":[{"rounded-es":[o]}],"rounded-tl":[{"rounded-tl":[o]}],"rounded-tr":[{"rounded-tr":[o]}],"rounded-br":[{"rounded-br":[o]}],"rounded-bl":[{"rounded-bl":[o]}],"border-w":[{border:[a]}],"border-w-x":[{"border-x":[a]}],"border-w-y":[{"border-y":[a]}],"border-w-s":[{"border-s":[a]}],"border-w-e":[{"border-e":[a]}],"border-w-t":[{"border-t":[a]}],"border-w-r":[{"border-r":[a]}],"border-w-b":[{"border-b":[a]}],"border-w-l":[{"border-l":[a]}],"border-opacity":[{"border-opacity":[x]}],"border-style":[{border:[...L(),"hidden"]}],"divide-x":[{"divide-x":[a]}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":[a]}],"divide-y-reverse":["divide-y-reverse"],"divide-opacity":[{"divide-opacity":[x]}],"divide-style":[{divide:L()}],"border-color":[{border:[s]}],"border-color-x":[{"border-x":[s]}],"border-color-y":[{"border-y":[s]}],"border-color-s":[{"border-s":[s]}],"border-color-e":[{"border-e":[s]}],"border-color-t":[{"border-t":[s]}],"border-color-r":[{"border-r":[s]}],"border-color-b":[{"border-b":[s]}],"border-color-l":[{"border-l":[s]}],"divide-color":[{divide:[s]}],"outline-style":[{outline:["",...L()]}],"outline-offset":[{"outline-offset":[Ys,je]}],"outline-w":[{outline:[Ys,Fo]}],"outline-color":[{outline:[t]}],"ring-w":[{ring:A()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:[t]}],"ring-opacity":[{"ring-opacity":[x]}],"ring-offset-w":[{"ring-offset":[Ys,Fo]}],"ring-offset-color":[{"ring-offset":[t]}],shadow:[{shadow:["","inner","none",zo,UL]}],"shadow-color":[{shadow:[qd]}],opacity:[{opacity:[x]}],"mix-blend":[{"mix-blend":[...U(),"plus-lighter","plus-darker"]}],"bg-blend":[{"bg-blend":U()}],filter:[{filter:["","none"]}],blur:[{blur:[r]}],brightness:[{brightness:[n]}],contrast:[{contrast:[c]}],"drop-shadow":[{"drop-shadow":["","none",zo,je]}],grayscale:[{grayscale:[d]}],"hue-rotate":[{"hue-rotate":[u]}],invert:[{invert:[h]}],saturate:[{saturate:[b]}],sepia:[{sepia:[S]}],"backdrop-filter":[{"backdrop-filter":["","none"]}],"backdrop-blur":[{"backdrop-blur":[r]}],"backdrop-brightness":[{"backdrop-brightness":[n]}],"backdrop-contrast":[{"backdrop-contrast":[c]}],"backdrop-grayscale":[{"backdrop-grayscale":[d]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[u]}],"backdrop-invert":[{"backdrop-invert":[h]}],"backdrop-opacity":[{"backdrop-opacity":[x]}],"backdrop-saturate":[{"backdrop-saturate":[b]}],"backdrop-sepia":[{"backdrop-sepia":[S]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":[i]}],"border-spacing-x":[{"border-spacing-x":[i]}],"border-spacing-y":[{"border-spacing-y":[i]}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["none","all","","colors","opacity","shadow","transform",je]}],duration:[{duration:ne()}],ease:[{ease:["linear","in","out","in-out",je]}],delay:[{delay:ne()}],animate:[{animate:["none","spin","ping","pulse","bounce",je]}],transform:[{transform:["","gpu","none"]}],scale:[{scale:[k]}],"scale-x":[{"scale-x":[k]}],"scale-y":[{"scale-y":[k]}],rotate:[{rotate:[Hd,je]}],"translate-x":[{"translate-x":[E]}],"translate-y":[{"translate-y":[E]}],"skew-x":[{"skew-x":[C]}],"skew-y":[{"skew-y":[C]}],"transform-origin":[{origin:["center","top","top-right","right","bottom-right","bottom","bottom-left","left","top-left",je]}],accent:[{accent:["auto",t]}],appearance:[{appearance:["none","auto"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",je]}],"caret-color":[{caret:[t]}],"pointer-events":[{"pointer-events":["none","auto"]}],resize:[{resize:["none","y","x",""]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":T()}],"scroll-mx":[{"scroll-mx":T()}],"scroll-my":[{"scroll-my":T()}],"scroll-ms":[{"scroll-ms":T()}],"scroll-me":[{"scroll-me":T()}],"scroll-mt":[{"scroll-mt":T()}],"scroll-mr":[{"scroll-mr":T()}],"scroll-mb":[{"scroll-mb":T()}],"scroll-ml":[{"scroll-ml":T()}],"scroll-p":[{"scroll-p":T()}],"scroll-px":[{"scroll-px":T()}],"scroll-py":[{"scroll-py":T()}],"scroll-ps":[{"scroll-ps":T()}],"scroll-pe":[{"scroll-pe":T()}],"scroll-pt":[{"scroll-pt":T()}],"scroll-pr":[{"scroll-pr":T()}],"scroll-pb":[{"scroll-pb":T()}],"scroll-pl":[{"scroll-pl":T()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",je]}],fill:[{fill:[t,"none"]}],"stroke-w":[{stroke:[Ys,Fo,Xy]}],stroke:[{stroke:[t,"none"]}],sr:["sr-only","not-sr-only"],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-s","border-w-e","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-s","border-color-e","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]}}});function B(...t){return qL(lC(t))}const KL=_3,PC=m.forwardRef(({className:t,...e},r)=>l.jsx(tC,{ref:r,className:B("fixed top-0 z-[100] flex max-h-screen w-full flex-col-reverse p-4 sm:bottom-0 sm:right-0 sm:top-auto sm:flex-col md:max-w-[420px]",t),...e}));PC.displayName=tC.displayName;const GL=Sl("group pointer-events-auto relative flex w-full items-center justify-between space-x-4 overflow-hidden rounded-md border p-6 pr-8 shadow-lg transition-all data-[swipe=cancel]:translate-x-0 data-[swipe=end]:translate-x-[var(--radix-toast-swipe-end-x)] data-[swipe=move]:translate-x-[var(--radix-toast-swipe-move-x)] data-[swipe=move]:transition-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[swipe=end]:animate-out data-[state=closed]:fade-out-80 data-[state=closed]:slide-out-to-right-full data-[state=open]:slide-in-from-top-full data-[state=open]:sm:slide-in-from-bottom-full",{variants:{variant:{default:"border bg-background text-foreground",destructive:"destructive group border-destructive bg-destructive text-destructive-foreground"}},defaultVariants:{variant:"default"}}),AC=m.forwardRef(({className:t,variant:e,...r},n)=>l.jsx(rC,{ref:n,className:B(GL({variant:e}),t),...r}));AC.displayName=rC.displayName;const YL=m.forwardRef(({className:t,...e},r)=>l.jsx(oC,{ref:r,className:B("inline-flex h-8 shrink-0 items-center justify-center rounded-md border bg-transparent px-3 text-sm font-medium ring-offset-background transition-colors group-[.destructive]:border-muted/40 hover:bg-secondary group-[.destructive]:hover:border-destructive/30 group-[.destructive]:hover:bg-destructive group-[.destructive]:hover:text-destructive-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 group-[.destructive]:focus:ring-destructive disabled:pointer-events-none disabled:opacity-50",t),...e}));YL.displayName=oC.displayName;const IC=m.forwardRef(({className:t,...e},r)=>l.jsx(iC,{ref:r,className:B("absolute right-2 top-2 rounded-md p-1 text-foreground/50 opacity-0 transition-opacity group-hover:opacity-100 group-[.destructive]:text-red-300 hover:text-foreground group-[.destructive]:hover:text-red-50 focus:opacity-100 focus:outline-none focus:ring-2 group-[.destructive]:focus:ring-red-400 group-[.destructive]:focus:ring-offset-red-600",t),"toast-close":"",...e,children:l.jsx(Wd,{className:"h-4 w-4"})}));IC.displayName=iC.displayName;const DC=m.forwardRef(({className:t,...e},r)=>l.jsx(nC,{ref:r,className:B("text-sm font-semibold",t),...e}));DC.displayName=nC.displayName;const LC=m.forwardRef(({className:t,...e},r)=>l.jsx(sC,{ref:r,className:B("text-sm opacity-90",t),...e}));LC.displayName=sC.displayName;function JL(){const{toasts:t}=gs();return l.jsxs(KL,{children:[t.map(function({id:e,title:r,description:n,action:s,...o}){return l.jsxs(AC,{...o,children:[l.jsxs("div",{className:"grid gap-1",children:[r&&l.jsx(DC,{children:r}),n&&l.jsx(LC,{children:n})]}),s,l.jsx(IC,{})]},e)}),l.jsx(PC,{})]})}var $C=["light","dark"],QL="(prefers-color-scheme: dark)",XL=m.createContext(void 0),ZL={setTheme:t=>{},themes:[]},e$=()=>{var t;return(t=m.useContext(XL))!=null?t:ZL};m.memo(({forcedTheme:t,storageKey:e,attribute:r,enableSystem:n,enableColorScheme:s,defaultTheme:o,value:i,attrs:a,nonce:c})=>{let d=o==="system",u=r==="class"?`var d=document.documentElement,c=d.classList;${`c.remove(${a.map(g=>`'${g}'`).join(",")})`};`:`var d=document.documentElement,n='${r}',s='setAttribute';`,h=s?$C.includes(o)&&o?`if(e==='light'||e==='dark'||!e)d.style.colorScheme=e||'${o}'`:"if(e==='light'||e==='dark')d.style.colorScheme=e":"",f=(g,v=!1,y=!0)=>{let x=i?i[g]:g,w=v?g+"|| ''":`'${x}'`,b="";return s&&y&&!v&&$C.includes(g)&&(b+=`d.style.colorScheme = '${g}';`),r==="class"?v||x?b+=`c.add(${w})`:b+="null":x&&(b+=`d[s](n,${w})`),b},p=t?`!function(){${u}${f(t)}}()`:n?`!function(){try{${u}var e=localStorage.getItem('${e}');if('system'===e||(!e&&${d})){var t='${QL}',m=window.matchMedia(t);if(m.media!==t||m.matches){${f("dark")}}else{${f("light")}}}else if(e){${i?`var x=${JSON.stringify(i)};`:""}${f(i?"x[e]":"e",!0)}}${d?"":"else{"+f(o,!1,!1)+"}"}${h}}catch(e){}}()`:`!function(){try{${u}var e=localStorage.getItem('${e}');if(e){${i?`var x=${JSON.stringify(i)};`:""}${f(i?"x[e]":"e",!0)}}else{${f(o,!1,!1)};}${h}}catch(t){}}();`;return m.createElement("script",{nonce:c,dangerouslySetInnerHTML:{__html:p}})});var t$=t=>{switch(t){case"success":return s$;case"info":return i$;case"warning":return o$;case"error":return a$;default:return null}},r$=Array(12).fill(0),n$=({visible:t,className:e})=>W.createElement("div",{className:["sonner-loading-wrapper",e].filter(Boolean).join(" "),"data-visible":t},W.createElement("div",{className:"sonner-spinner"},r$.map((r,n)=>W.createElement("div",{className:"sonner-loading-bar",key:`spinner-bar-${n}`})))),s$=W.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},W.createElement("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zm3.857-9.809a.75.75 0 00-1.214-.882l-3.483 4.79-1.88-1.88a.75.75 0 10-1.06 1.061l2.5 2.5a.75.75 0 001.137-.089l4-5.5z",clipRule:"evenodd"})),o$=W.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",height:"20",width:"20"},W.createElement("path",{fillRule:"evenodd",d:"M9.401 3.003c1.155-2 4.043-2 5.197 0l7.355 12.748c1.154 2-.29 4.5-2.599 4.5H4.645c-2.309 0-3.752-2.5-2.598-4.5L9.4 3.003zM12 8.25a.75.75 0 01.75.75v3.75a.75.75 0 01-1.5 0V9a.75.75 0 01.75-.75zm0 8.25a.75.75 0 100-1.5.75.75 0 000 1.5z",clipRule:"evenodd"})),i$=W.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},W.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a.75.75 0 000 1.5h.253a.25.25 0 01.244.304l-.459 2.066A1.75 1.75 0 0010.747 15H11a.75.75 0 000-1.5h-.253a.25.25 0 01-.244-.304l.459-2.066A1.75 1.75 0 009.253 9H9z",clipRule:"evenodd"})),a$=W.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},W.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-8-5a.75.75 0 01.75.75v4.5a.75.75 0 01-1.5 0v-4.5A.75.75 0 0110 5zm0 10a1 1 0 100-2 1 1 0 000 2z",clipRule:"evenodd"})),l$=W.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"},W.createElement("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),W.createElement("line",{x1:"6",y1:"6",x2:"18",y2:"18"})),c$=()=>{let[t,e]=W.useState(document.hidden);return W.useEffect(()=>{let r=()=>{e(document.hidden)};return document.addEventListener("visibilitychange",r),()=>window.removeEventListener("visibilitychange",r)},[]),t},Zy=1,d$=class{constructor(){this.subscribe=t=>(this.subscribers.push(t),()=>{let e=this.subscribers.indexOf(t);this.subscribers.splice(e,1)}),this.publish=t=>{this.subscribers.forEach(e=>e(t))},this.addToast=t=>{this.publish(t),this.toasts=[...this.toasts,t]},this.create=t=>{var e;let{message:r,...n}=t,s=typeof(t==null?void 0:t.id)=="number"||((e=t.id)==null?void 0:e.length)>0?t.id:Zy++,o=this.toasts.find(a=>a.id===s),i=t.dismissible===void 0?!0:t.dismissible;return this.dismissedToasts.has(s)&&this.dismissedToasts.delete(s),o?this.toasts=this.toasts.map(a=>a.id===s?(this.publish({...a,...t,id:s,title:r}),{...a,...t,id:s,dismissible:i,title:r}):a):this.addToast({title:r,...n,dismissible:i,id:s}),s},this.dismiss=t=>(this.dismissedToasts.add(t),t||this.toasts.forEach(e=>{this.subscribers.forEach(r=>r({id:e.id,dismiss:!0}))}),this.subscribers.forEach(e=>e({id:t,dismiss:!0})),t),this.message=(t,e)=>this.create({...e,message:t}),this.error=(t,e)=>this.create({...e,message:t,type:"error"}),this.success=(t,e)=>this.create({...e,type:"success",message:t}),this.info=(t,e)=>this.create({...e,type:"info",message:t}),this.warning=(t,e)=>this.create({...e,type:"warning",message:t}),this.loading=(t,e)=>this.create({...e,type:"loading",message:t}),this.promise=(t,e)=>{if(!e)return;let r;e.loading!==void 0&&(r=this.create({...e,promise:t,type:"loading",message:e.loading,description:typeof e.description!="function"?e.description:void 0}));let n=t instanceof Promise?t:t(),s=r!==void 0,o,i=n.then(async c=>{if(o=["resolve",c],W.isValidElement(c))s=!1,this.create({id:r,type:"default",message:c});else if(h$(c)&&!c.ok){s=!1;let d=typeof e.error=="function"?await e.error(`HTTP error! status: ${c.status}`):e.error,u=typeof e.description=="function"?await e.description(`HTTP error! status: ${c.status}`):e.description;this.create({id:r,type:"error",message:d,description:u})}else if(e.success!==void 0){s=!1;let d=typeof e.success=="function"?await e.success(c):e.success,u=typeof e.description=="function"?await e.description(c):e.description;this.create({id:r,type:"success",message:d,description:u})}}).catch(async c=>{if(o=["reject",c],e.error!==void 0){s=!1;let d=typeof e.error=="function"?await e.error(c):e.error,u=typeof e.description=="function"?await e.description(c):e.description;this.create({id:r,type:"error",message:d,description:u})}}).finally(()=>{var c;s&&(this.dismiss(r),r=void 0),(c=e.finally)==null||c.call(e)}),a=()=>new Promise((c,d)=>i.then(()=>o[0]==="reject"?d(o[1]):c(o[1])).catch(d));return typeof r!="string"&&typeof r!="number"?{unwrap:a}:Object.assign(r,{unwrap:a})},this.custom=(t,e)=>{let r=(e==null?void 0:e.id)||Zy++;return this.create({jsx:t(r),id:r,...e}),r},this.getActiveToasts=()=>this.toasts.filter(t=>!this.dismissedToasts.has(t.id)),this.subscribers=[],this.toasts=[],this.dismissedToasts=new Set}},Fr=new d$,u$=(t,e)=>{let r=(e==null?void 0:e.id)||Zy++;return Fr.addToast({title:t,...e,id:r}),r},h$=t=>t&&typeof t=="object"&&"ok"in t&&typeof t.ok=="boolean"&&"status"in t&&typeof t.status=="number",f$=u$,p$=()=>Fr.toasts,m$=()=>Fr.getActiveToasts(),Se=Object.assign(f$,{success:Fr.success,info:Fr.info,warning:Fr.warning,error:Fr.error,custom:Fr.custom,message:Fr.message,promise:Fr.promise,dismiss:Fr.dismiss,loading:Fr.loading},{getHistory:p$,getToasts:m$});function g$(t,{insertAt:e}={}){if(typeof document>"u")return;let r=document.head||document.getElementsByTagName("head")[0],n=document.createElement("style");n.type="text/css",e==="top"&&r.firstChild?r.insertBefore(n,r.firstChild):r.appendChild(n),n.styleSheet?n.styleSheet.cssText=t:n.appendChild(document.createTextNode(t))}g$(`:where(html[dir="ltr"]),:where([data-sonner-toaster][dir="ltr"]){--toast-icon-margin-start: -3px;--toast-icon-margin-end: 4px;--toast-svg-margin-start: -1px;--toast-svg-margin-end: 0px;--toast-button-margin-start: auto;--toast-button-margin-end: 0;--toast-close-button-start: 0;--toast-close-button-end: unset;--toast-close-button-transform: translate(-35%, -35%)}:where(html[dir="rtl"]),:where([data-sonner-toaster][dir="rtl"]){--toast-icon-margin-start: 4px;--toast-icon-margin-end: -3px;--toast-svg-margin-start: 0px;--toast-svg-margin-end: -1px;--toast-button-margin-start: 0;--toast-button-margin-end: auto;--toast-close-button-start: unset;--toast-close-button-end: 0;--toast-close-button-transform: translate(35%, -35%)}:where([data-sonner-toaster]){position:fixed;width:var(--width);font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;--gray1: hsl(0, 0%, 99%);--gray2: hsl(0, 0%, 97.3%);--gray3: hsl(0, 0%, 95.1%);--gray4: hsl(0, 0%, 93%);--gray5: hsl(0, 0%, 90.9%);--gray6: hsl(0, 0%, 88.7%);--gray7: hsl(0, 0%, 85.8%);--gray8: hsl(0, 0%, 78%);--gray9: hsl(0, 0%, 56.1%);--gray10: hsl(0, 0%, 52.3%);--gray11: hsl(0, 0%, 43.5%);--gray12: hsl(0, 0%, 9%);--border-radius: 8px;box-sizing:border-box;padding:0;margin:0;list-style:none;outline:none;z-index:999999999;transition:transform .4s ease}:where([data-sonner-toaster][data-lifted="true"]){transform:translateY(-10px)}@media (hover: none) and (pointer: coarse){:where([data-sonner-toaster][data-lifted="true"]){transform:none}}:where([data-sonner-toaster][data-x-position="right"]){right:var(--offset-right)}:where([data-sonner-toaster][data-x-position="left"]){left:var(--offset-left)}:where([data-sonner-toaster][data-x-position="center"]){left:50%;transform:translate(-50%)}:where([data-sonner-toaster][data-y-position="top"]){top:var(--offset-top)}:where([data-sonner-toaster][data-y-position="bottom"]){bottom:var(--offset-bottom)}:where([data-sonner-toast]){--y: translateY(100%);--lift-amount: calc(var(--lift) * var(--gap));z-index:var(--z-index);position:absolute;opacity:0;transform:var(--y);filter:blur(0);touch-action:none;transition:transform .4s,opacity .4s,height .4s,box-shadow .2s;box-sizing:border-box;outline:none;overflow-wrap:anywhere}:where([data-sonner-toast][data-styled="true"]){padding:16px;background:var(--normal-bg);border:1px solid var(--normal-border);color:var(--normal-text);border-radius:var(--border-radius);box-shadow:0 4px 12px #0000001a;width:var(--width);font-size:13px;display:flex;align-items:center;gap:6px}:where([data-sonner-toast]:focus-visible){box-shadow:0 4px 12px #0000001a,0 0 0 2px #0003}:where([data-sonner-toast][data-y-position="top"]){top:0;--y: translateY(-100%);--lift: 1;--lift-amount: calc(1 * var(--gap))}:where([data-sonner-toast][data-y-position="bottom"]){bottom:0;--y: translateY(100%);--lift: -1;--lift-amount: calc(var(--lift) * var(--gap))}:where([data-sonner-toast]) :where([data-description]){font-weight:400;line-height:1.4;color:inherit}:where([data-sonner-toast]) :where([data-title]){font-weight:500;line-height:1.5;color:inherit}:where([data-sonner-toast]) :where([data-icon]){display:flex;height:16px;width:16px;position:relative;justify-content:flex-start;align-items:center;flex-shrink:0;margin-left:var(--toast-icon-margin-start);margin-right:var(--toast-icon-margin-end)}:where([data-sonner-toast][data-promise="true"]) :where([data-icon])>svg{opacity:0;transform:scale(.8);transform-origin:center;animation:sonner-fade-in .3s ease forwards}:where([data-sonner-toast]) :where([data-icon])>*{flex-shrink:0}:where([data-sonner-toast]) :where([data-icon]) svg{margin-left:var(--toast-svg-margin-start);margin-right:var(--toast-svg-margin-end)}:where([data-sonner-toast]) :where([data-content]){display:flex;flex-direction:column;gap:2px}[data-sonner-toast][data-styled=true] [data-button]{border-radius:4px;padding-left:8px;padding-right:8px;height:24px;font-size:12px;color:var(--normal-bg);background:var(--normal-text);margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end);border:none;cursor:pointer;outline:none;display:flex;align-items:center;flex-shrink:0;transition:opacity .4s,box-shadow .2s}:where([data-sonner-toast]) :where([data-button]):focus-visible{box-shadow:0 0 0 2px #0006}:where([data-sonner-toast]) :where([data-button]):first-of-type{margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end)}:where([data-sonner-toast]) :where([data-cancel]){color:var(--normal-text);background:rgba(0,0,0,.08)}:where([data-sonner-toast][data-theme="dark"]) :where([data-cancel]){background:rgba(255,255,255,.3)}:where([data-sonner-toast]) :where([data-close-button]){position:absolute;left:var(--toast-close-button-start);right:var(--toast-close-button-end);top:0;height:20px;width:20px;display:flex;justify-content:center;align-items:center;padding:0;color:var(--gray12);border:1px solid var(--gray4);transform:var(--toast-close-button-transform);border-radius:50%;cursor:pointer;z-index:1;transition:opacity .1s,background .2s,border-color .2s}[data-sonner-toast] [data-close-button]{background:var(--gray1)}:where([data-sonner-toast]) :where([data-close-button]):focus-visible{box-shadow:0 4px 12px #0000001a,0 0 0 2px #0003}:where([data-sonner-toast]) :where([data-disabled="true"]){cursor:not-allowed}:where([data-sonner-toast]):hover :where([data-close-button]):hover{background:var(--gray2);border-color:var(--gray5)}:where([data-sonner-toast][data-swiping="true"]):before{content:"";position:absolute;left:-50%;right:-50%;height:100%;z-index:-1}:where([data-sonner-toast][data-y-position="top"][data-swiping="true"]):before{bottom:50%;transform:scaleY(3) translateY(50%)}:where([data-sonner-toast][data-y-position="bottom"][data-swiping="true"]):before{top:50%;transform:scaleY(3) translateY(-50%)}:where([data-sonner-toast][data-swiping="false"][data-removed="true"]):before{content:"";position:absolute;inset:0;transform:scaleY(2)}:where([data-sonner-toast]):after{content:"";position:absolute;left:0;height:calc(var(--gap) + 1px);bottom:100%;width:100%}:where([data-sonner-toast][data-mounted="true"]){--y: translateY(0);opacity:1}:where([data-sonner-toast][data-expanded="false"][data-front="false"]){--scale: var(--toasts-before) * .05 + 1;--y: translateY(calc(var(--lift-amount) * var(--toasts-before))) scale(calc(-1 * var(--scale)));height:var(--front-toast-height)}:where([data-sonner-toast])>*{transition:opacity .4s}:where([data-sonner-toast][data-expanded="false"][data-front="false"][data-styled="true"])>*{opacity:0}:where([data-sonner-toast][data-visible="false"]){opacity:0;pointer-events:none}:where([data-sonner-toast][data-mounted="true"][data-expanded="true"]){--y: translateY(calc(var(--lift) * var(--offset)));height:var(--initial-height)}:where([data-sonner-toast][data-removed="true"][data-front="true"][data-swipe-out="false"]){--y: translateY(calc(var(--lift) * -100%));opacity:0}:where([data-sonner-toast][data-removed="true"][data-front="false"][data-swipe-out="false"][data-expanded="true"]){--y: translateY(calc(var(--lift) * var(--offset) + var(--lift) * -100%));opacity:0}:where([data-sonner-toast][data-removed="true"][data-front="false"][data-swipe-out="false"][data-expanded="false"]){--y: translateY(40%);opacity:0;transition:transform .5s,opacity .2s}:where([data-sonner-toast][data-removed="true"][data-front="false"]):before{height:calc(var(--initial-height) + 20%)}[data-sonner-toast][data-swiping=true]{transform:var(--y) translateY(var(--swipe-amount-y, 0px)) translate(var(--swipe-amount-x, 0px));transition:none}[data-sonner-toast][data-swiped=true]{user-select:none}[data-sonner-toast][data-swipe-out=true][data-y-position=bottom],[data-sonner-toast][data-swipe-out=true][data-y-position=top]{animation-duration:.2s;animation-timing-function:ease-out;animation-fill-mode:forwards}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=left]{animation-name:swipe-out-left}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=right]{animation-name:swipe-out-right}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=up]{animation-name:swipe-out-up}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=down]{animation-name:swipe-out-down}@keyframes swipe-out-left{0%{transform:var(--y) translate(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translate(calc(var(--swipe-amount-x) - 100%));opacity:0}}@keyframes swipe-out-right{0%{transform:var(--y) translate(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translate(calc(var(--swipe-amount-x) + 100%));opacity:0}}@keyframes swipe-out-up{0%{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) - 100%));opacity:0}}@keyframes swipe-out-down{0%{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) + 100%));opacity:0}}@media (max-width: 600px){[data-sonner-toaster]{position:fixed;right:var(--mobile-offset-right);left:var(--mobile-offset-left);width:100%}[data-sonner-toaster][dir=rtl]{left:calc(var(--mobile-offset-left) * -1)}[data-sonner-toaster] [data-sonner-toast]{left:0;right:0;width:calc(100% - var(--mobile-offset-left) * 2)}[data-sonner-toaster][data-x-position=left]{left:var(--mobile-offset-left)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--mobile-offset-bottom)}[data-sonner-toaster][data-y-position=top]{top:var(--mobile-offset-top)}[data-sonner-toaster][data-x-position=center]{left:var(--mobile-offset-left);right:var(--mobile-offset-right);transform:none}}[data-sonner-toaster][data-theme=light]{--normal-bg: #fff;--normal-border: var(--gray4);--normal-text: var(--gray12);--success-bg: hsl(143, 85%, 96%);--success-border: hsl(145, 92%, 91%);--success-text: hsl(140, 100%, 27%);--info-bg: hsl(208, 100%, 97%);--info-border: hsl(221, 91%, 91%);--info-text: hsl(210, 92%, 45%);--warning-bg: hsl(49, 100%, 97%);--warning-border: hsl(49, 91%, 91%);--warning-text: hsl(31, 92%, 45%);--error-bg: hsl(359, 100%, 97%);--error-border: hsl(359, 100%, 94%);--error-text: hsl(360, 100%, 45%)}[data-sonner-toaster][data-theme=light] [data-sonner-toast][data-invert=true]{--normal-bg: #000;--normal-border: hsl(0, 0%, 20%);--normal-text: var(--gray1)}[data-sonner-toaster][data-theme=dark] [data-sonner-toast][data-invert=true]{--normal-bg: #fff;--normal-border: var(--gray3);--normal-text: var(--gray12)}[data-sonner-toaster][data-theme=dark]{--normal-bg: #000;--normal-bg-hover: hsl(0, 0%, 12%);--normal-border: hsl(0, 0%, 20%);--normal-border-hover: hsl(0, 0%, 25%);--normal-text: var(--gray1);--success-bg: hsl(150, 100%, 6%);--success-border: hsl(147, 100%, 12%);--success-text: hsl(150, 86%, 65%);--info-bg: hsl(215, 100%, 6%);--info-border: hsl(223, 100%, 12%);--info-text: hsl(216, 87%, 65%);--warning-bg: hsl(64, 100%, 6%);--warning-border: hsl(60, 100%, 12%);--warning-text: hsl(46, 87%, 65%);--error-bg: hsl(358, 76%, 10%);--error-border: hsl(357, 89%, 16%);--error-text: hsl(358, 100%, 81%)}[data-sonner-toaster][data-theme=dark] [data-sonner-toast] [data-close-button]{background:var(--normal-bg);border-color:var(--normal-border);color:var(--normal-text)}[data-sonner-toaster][data-theme=dark] [data-sonner-toast] [data-close-button]:hover{background:var(--normal-bg-hover);border-color:var(--normal-border-hover)}[data-rich-colors=true][data-sonner-toast][data-type=success],[data-rich-colors=true][data-sonner-toast][data-type=success] [data-close-button]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=info],[data-rich-colors=true][data-sonner-toast][data-type=info] [data-close-button]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning],[data-rich-colors=true][data-sonner-toast][data-type=warning] [data-close-button]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=error],[data-rich-colors=true][data-sonner-toast][data-type=error] [data-close-button]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}.sonner-loading-wrapper{--size: 16px;height:var(--size);width:var(--size);position:absolute;inset:0;z-index:10}.sonner-loading-wrapper[data-visible=false]{transform-origin:center;animation:sonner-fade-out .2s ease forwards}.sonner-spinner{position:relative;top:50%;left:50%;height:var(--size);width:var(--size)}.sonner-loading-bar{animation:sonner-spin 1.2s linear infinite;background:var(--gray11);border-radius:6px;height:8%;left:-10%;position:absolute;top:-3.9%;width:24%}.sonner-loading-bar:nth-child(1){animation-delay:-1.2s;transform:rotate(.0001deg) translate(146%)}.sonner-loading-bar:nth-child(2){animation-delay:-1.1s;transform:rotate(30deg) translate(146%)}.sonner-loading-bar:nth-child(3){animation-delay:-1s;transform:rotate(60deg) translate(146%)}.sonner-loading-bar:nth-child(4){animation-delay:-.9s;transform:rotate(90deg) translate(146%)}.sonner-loading-bar:nth-child(5){animation-delay:-.8s;transform:rotate(120deg) translate(146%)}.sonner-loading-bar:nth-child(6){animation-delay:-.7s;transform:rotate(150deg) translate(146%)}.sonner-loading-bar:nth-child(7){animation-delay:-.6s;transform:rotate(180deg) translate(146%)}.sonner-loading-bar:nth-child(8){animation-delay:-.5s;transform:rotate(210deg) translate(146%)}.sonner-loading-bar:nth-child(9){animation-delay:-.4s;transform:rotate(240deg) translate(146%)}.sonner-loading-bar:nth-child(10){animation-delay:-.3s;transform:rotate(270deg) translate(146%)}.sonner-loading-bar:nth-child(11){animation-delay:-.2s;transform:rotate(300deg) translate(146%)}.sonner-loading-bar:nth-child(12){animation-delay:-.1s;transform:rotate(330deg) translate(146%)}@keyframes sonner-fade-in{0%{opacity:0;transform:scale(.8)}to{opacity:1;transform:scale(1)}}@keyframes sonner-fade-out{0%{opacity:1;transform:scale(1)}to{opacity:0;transform:scale(.8)}}@keyframes sonner-spin{0%{opacity:1}to{opacity:.15}}@media (prefers-reduced-motion){[data-sonner-toast],[data-sonner-toast]>*,.sonner-loading-bar{transition:none!important;animation:none!important}}.sonner-loader{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);transform-origin:center;transition:opacity .2s,transform .2s}.sonner-loader[data-visible=false]{opacity:0;transform:scale(.8) translate(-50%,-50%)} `);function Yf(t){return t.label!==void 0}var v$=3,y$="32px",x$="16px",FC=4e3,w$=356,b$=14,k$=20,S$=200;function Hn(...t){return t.filter(Boolean).join(" ")}function N$(t){let[e,r]=t.split("-"),n=[];return e&&n.push(e),r&&n.push(r),n}var C$=t=>{var e,r,n,s,o,i,a,c,d,u,h;let{invert:f,toast:p,unstyled:g,interacting:v,setHeights:y,visibleToasts:x,heights:w,index:b,toasts:k,expanded:S,removeToast:C,defaultRichColors:N,closeButton:E,style:j,cancelButtonStyle:_,actionButtonStyle:P,className:T="",descriptionClassName:A="",duration:I,position:V,gap:L,loadingIcon:U,expandByDefault:M,classNames:D,icons:H,closeButtonAriaLabel:ne="Close toast",pauseWhenPageIsHidden:$}=t,[G,J]=W.useState(null),[O,z]=W.useState(null),[F,te]=W.useState(!1),[ee,Z]=W.useState(!1),[ve,ce]=W.useState(!1),[Le,We]=W.useState(!1),[It,Dt]=W.useState(!1),[Dn,cs]=W.useState(0),[Ps,ds]=W.useState(0),As=W.useRef(p.duration||I||FC),Va=W.useRef(null),Is=W.useRef(null),hg=b===0,Yb=b+1<=x,Kr=p.type,dn=p.dismissible!==!1,Mi=p.className||"",Wa=p.descriptionClassName||"",Ha=W.useMemo(()=>w.findIndex(ye=>ye.toastId===p.id)||0,[w,p.id]),Ds=W.useMemo(()=>{var ye;return(ye=p.closeButton)!=null?ye:E},[p.closeButton,E]),bh=W.useMemo(()=>p.duration||I||FC,[p.duration,I]),kh=W.useRef(0),Oi=W.useRef(0),qc=W.useRef(0),mo=W.useRef(null),[Jb,fg]=V.split("-"),pg=W.useMemo(()=>w.reduce((ye,Ee,Me)=>Me>=Ha?ye:ye+Ee.height,0),[w,Ha]),mg=c$(),Qb=p.invert||f,jt=Kr==="loading";Oi.current=W.useMemo(()=>Ha*L+pg,[Ha,pg]),W.useEffect(()=>{As.current=bh},[bh]),W.useEffect(()=>{te(!0)},[]),W.useEffect(()=>{let ye=Is.current;if(ye){let Ee=ye.getBoundingClientRect().height;return ds(Ee),y(Me=>[{toastId:p.id,height:Ee,position:p.position},...Me]),()=>y(Me=>Me.filter(ft=>ft.toastId!==p.id))}},[y,p.id]),W.useLayoutEffect(()=>{if(!F)return;let ye=Is.current,Ee=ye.style.height;ye.style.height="auto";let Me=ye.getBoundingClientRect().height;ye.style.height=Ee,ds(Me),y(ft=>ft.find(Gt=>Gt.toastId===p.id)?ft.map(Gt=>Gt.toastId===p.id?{...Gt,height:Me}:Gt):[{toastId:p.id,height:Me,position:p.position},...ft])},[F,p.title,p.description,y,p.id]);let ht=W.useCallback(()=>{Z(!0),cs(Oi.current),y(ye=>ye.filter(Ee=>Ee.toastId!==p.id)),setTimeout(()=>{C(p)},S$)},[p,C,y,Oi]);W.useEffect(()=>{if(p.promise&&Kr==="loading"||p.duration===1/0||p.type==="loading")return;let ye;return S||v||&mg?(()=>{if(qc.current{var Ee;(Ee=p.onAutoClose)==null||Ee.call(p,p),ht()},As.current)),()=>clearTimeout(ye)},[S,v,p,Kr,$,mg,ht]),W.useEffect(()=>{p.delete&&ht()},[ht,p.delete]);function Or(){var ye,Ee,Me;return H!=null&&H.loading?W.createElement("div",{className:Hn(D==null?void 0:D.loader,(ye=p==null?void 0:p.classNames)==null?void 0:ye.loader,"sonner-loader"),"data-visible":Kr==="loading"},H.loading):U?W.createElement("div",{className:Hn(D==null?void 0:D.loader,(Ee=p==null?void 0:p.classNames)==null?void 0:Ee.loader,"sonner-loader"),"data-visible":Kr==="loading"},U):W.createElement(n$,{className:Hn(D==null?void 0:D.loader,(Me=p==null?void 0:p.classNames)==null?void 0:Me.loader),visible:Kr==="loading"})}return W.createElement("li",{tabIndex:0,ref:Is,className:Hn(T,Mi,D==null?void 0:D.toast,(e=p==null?void 0:p.classNames)==null?void 0:e.toast,D==null?void 0:D.default,D==null?void 0:D[Kr],(r=p==null?void 0:p.classNames)==null?void 0:r[Kr]),"data-sonner-toast":"","data-rich-colors":(n=p.richColors)!=null?n:N,"data-styled":!(p.jsx||p.unstyled||g),"data-mounted":F,"data-promise":!!p.promise,"data-swiped":It,"data-removed":ee,"data-visible":Yb,"data-y-position":Jb,"data-x-position":fg,"data-index":b,"data-front":hg,"data-swiping":ve,"data-dismissible":dn,"data-type":Kr,"data-invert":Qb,"data-swipe-out":Le,"data-swipe-direction":O,"data-expanded":!!(S||M&&F),style:{"--index":b,"--toasts-before":b,"--z-index":k.length-b,"--offset":`${ee?Dn:Oi.current}px`,"--initial-height":M?"auto":`${Ps}px`,...j,...p.style},onDragEnd:()=>{ce(!1),J(null),mo.current=null},onPointerDown:ye=>{jt||!dn||(Va.current=new Date,cs(Oi.current),ye.target.setPointerCapture(ye.pointerId),ye.target.tagName!=="BUTTON"&&(ce(!0),mo.current={x:ye.clientX,y:ye.clientY}))},onPointerUp:()=>{var ye,Ee,Me,ft;if(Le||!dn)return;mo.current=null;let Gt=Number(((ye=Is.current)==null?void 0:ye.style.getPropertyValue("--swipe-amount-x").replace("px",""))||0),Ge=Number(((Ee=Is.current)==null?void 0:Ee.style.getPropertyValue("--swipe-amount-y").replace("px",""))||0),yr=new Date().getTime()-((Me=Va.current)==null?void 0:Me.getTime()),pt=G==="x"?Gt:Ge,Yt=Math.abs(pt)/yr;if(Math.abs(pt)>=k$||Yt>.11){cs(Oi.current),(ft=p.onDismiss)==null||ft.call(p,p),z(G==="x"?Gt>0?"right":"left":Ge>0?"down":"up"),ht(),We(!0),Dt(!1);return}ce(!1),J(null)},onPointerMove:ye=>{var Ee,Me,ft,Gt;if(!mo.current||!dn||((Ee=window.getSelection())==null?void 0:Ee.toString().length)>0)return;let Ge=ye.clientY-mo.current.y,yr=ye.clientX-mo.current.x,pt=(Me=t.swipeDirections)!=null?Me:N$(V);!G&&(Math.abs(yr)>1||Math.abs(Ge)>1)&&J(Math.abs(yr)>Math.abs(Ge)?"x":"y");let Yt={x:0,y:0};G==="y"?(pt.includes("top")||pt.includes("bottom"))&&(pt.includes("top")&&Ge<0||pt.includes("bottom")&&Ge>0)&&(Yt.y=Ge):G==="x"&&(pt.includes("left")||pt.includes("right"))&&(pt.includes("left")&&yr<0||pt.includes("right")&&yr>0)&&(Yt.x=yr),(Math.abs(Yt.x)>0||Math.abs(Yt.y)>0)&&Dt(!0),(ft=Is.current)==null||ft.style.setProperty("--swipe-amount-x",`${Yt.x}px`),(Gt=Is.current)==null||Gt.style.setProperty("--swipe-amount-y",`${Yt.y}px`)}},Ds&&!p.jsx?W.createElement("button",{"aria-label":ne,"data-disabled":jt,"data-close-button":!0,onClick:jt||!dn?()=>{}:()=>{var ye;ht(),(ye=p.onDismiss)==null||ye.call(p,p)},className:Hn(D==null?void 0:D.closeButton,(s=p==null?void 0:p.classNames)==null?void 0:s.closeButton)},(o=H==null?void 0:H.close)!=null?o:l$):null,p.jsx||m.isValidElement(p.title)?p.jsx?p.jsx:typeof p.title=="function"?p.title():p.title:W.createElement(W.Fragment,null,Kr||p.icon||p.promise?W.createElement("div",{"data-icon":"",className:Hn(D==null?void 0:D.icon,(i=p==null?void 0:p.classNames)==null?void 0:i.icon)},p.promise||p.type==="loading"&&!p.icon?p.icon||Or():null,p.type!=="loading"?p.icon||(H==null?void 0:H[Kr])||t$(Kr):null):null,W.createElement("div",{"data-content":"",className:Hn(D==null?void 0:D.content,(a=p==null?void 0:p.classNames)==null?void 0:a.content)},W.createElement("div",{"data-title":"",className:Hn(D==null?void 0:D.title,(c=p==null?void 0:p.classNames)==null?void 0:c.title)},typeof p.title=="function"?p.title():p.title),p.description?W.createElement("div",{"data-description":"",className:Hn(A,Wa,D==null?void 0:D.description,(d=p==null?void 0:p.classNames)==null?void 0:d.description)},typeof p.description=="function"?p.description():p.description):null),m.isValidElement(p.cancel)?p.cancel:p.cancel&&Yf(p.cancel)?W.createElement("button",{"data-button":!0,"data-cancel":!0,style:p.cancelButtonStyle||_,onClick:ye=>{var Ee,Me;Yf(p.cancel)&&dn&&((Me=(Ee=p.cancel).onClick)==null||Me.call(Ee,ye),ht())},className:Hn(D==null?void 0:D.cancelButton,(u=p==null?void 0:p.classNames)==null?void 0:u.cancelButton)},p.cancel.label):null,m.isValidElement(p.action)?p.action:p.action&&Yf(p.action)?W.createElement("button",{"data-button":!0,"data-action":!0,style:p.actionButtonStyle||P,onClick:ye=>{var Ee,Me;Yf(p.action)&&((Me=(Ee=p.action).onClick)==null||Me.call(Ee,ye),!ye.defaultPrevented&&ht())},className:Hn(D==null?void 0:D.actionButton,(h=p==null?void 0:p.classNames)==null?void 0:h.actionButton)},p.action.label):null))};function zC(){if(typeof window>"u"||typeof document>"u")return"ltr";let t=document.documentElement.getAttribute("dir");return t==="auto"||!t?window.getComputedStyle(document.documentElement).direction:t}function j$(t,e){let r={};return[t,e].forEach((n,s)=>{let o=s===1,i=o?"--mobile-offset":"--offset",a=o?x$:y$;function c(d){["top","right","bottom","left"].forEach(u=>{r[`${i}-${u}`]=typeof d=="number"?`${d}px`:d})}typeof n=="number"||typeof n=="string"?c(n):typeof n=="object"?["top","right","bottom","left"].forEach(d=>{n[d]===void 0?r[`${i}-${d}`]=a:r[`${i}-${d}`]=typeof n[d]=="number"?`${n[d]}px`:n[d]}):c(a)}),r}var E$=m.forwardRef(function(t,e){let{invert:r,position:n="bottom-right",hotkey:s=["altKey","KeyT"],expand:o,closeButton:i,className:a,offset:c,mobileOffset:d,theme:u="light",richColors:h,duration:f,style:p,visibleToasts:g=v$,toastOptions:v,dir:y=zC(),gap:x=b$,loadingIcon:w,icons:b,containerAriaLabel:k="Notifications",pauseWhenPageIsHidden:S}=t,[C,N]=W.useState([]),E=W.useMemo(()=>Array.from(new Set([n].concat(C.filter($=>$.position).map($=>$.position)))),[C,n]),[j,_]=W.useState([]),[P,T]=W.useState(!1),[A,I]=W.useState(!1),[V,L]=W.useState(u!=="system"?u:typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),U=W.useRef(null),M=s.join("+").replace(/Key/g,"").replace(/Digit/g,""),D=W.useRef(null),H=W.useRef(!1),ne=W.useCallback($=>{N(G=>{var J;return(J=G.find(O=>O.id===$.id))!=null&&J.delete||Fr.dismiss($.id),G.filter(({id:O})=>O!==$.id)})},[]);return W.useEffect(()=>Fr.subscribe($=>{if($.dismiss){N(G=>G.map(J=>J.id===$.id?{...J,delete:!0}:J));return}setTimeout(()=>{My.flushSync(()=>{N(G=>{let J=G.findIndex(O=>O.id===$.id);return J!==-1?[...G.slice(0,J),{...G[J],...$},...G.slice(J+1)]:[$,...G]})})})}),[]),W.useEffect(()=>{if(u!=="system"){L(u);return}if(u==="system"&&(window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?L("dark"):L("light")),typeof window>"u")return;let $=window.matchMedia("(prefers-color-scheme: dark)");try{$.addEventListener("change",({matches:G})=>{L(G?"dark":"light")})}catch{$.addListener(({matches:J})=>{try{L(J?"dark":"light")}catch(O){console.error(O)}})}},[u]),W.useEffect(()=>{C.length<=1&&T(!1)},[C]),W.useEffect(()=>{let $=G=>{var J,O;s.every(z=>G[z]||G.code===z)&&(T(!0),(J=U.current)==null||J.focus()),G.code==="Escape"&&(document.activeElement===U.current||(O=U.current)!=null&&O.contains(document.activeElement))&&T(!1)};return document.addEventListener("keydown",$),()=>document.removeEventListener("keydown",$)},[s]),W.useEffect(()=>{if(U.current)return()=>{D.current&&(D.current.focus({preventScroll:!0}),D.current=null,H.current=!1)}},[U.current]),W.createElement("section",{ref:e,"aria-label":`${k} ${M}`,tabIndex:-1,"aria-live":"polite","aria-relevant":"additions text","aria-atomic":"false",suppressHydrationWarning:!0},E.map(($,G)=>{var J;let[O,z]=$.split("-");return C.length?W.createElement("ol",{key:$,dir:y==="auto"?zC():y,tabIndex:-1,ref:U,className:a,"data-sonner-toaster":!0,"data-theme":V,"data-y-position":O,"data-lifted":P&&C.length>1&&!o,"data-x-position":z,style:{"--front-toast-height":`${((J=j[0])==null?void 0:J.height)||0}px`,"--width":`${w$}px`,"--gap":`${x}px`,...p,...j$(c,d)},onBlur:F=>{H.current&&!F.currentTarget.contains(F.relatedTarget)&&(H.current=!1,D.current&&(D.current.focus({preventScroll:!0}),D.current=null))},onFocus:F=>{F.target instanceof HTMLElement&&F.target.dataset.dismissible==="false"||H.current||(H.current=!0,D.current=F.relatedTarget)},onMouseEnter:()=>T(!0),onMouseMove:()=>T(!0),onMouseLeave:()=>{A||T(!1)},onDragEnd:()=>T(!1),onPointerDown:F=>{F.target instanceof HTMLElement&&F.target.dataset.dismissible==="false"||I(!0)},onPointerUp:()=>I(!1)},C.filter(F=>!F.position&&G===0||F.position===$).map((F,te)=>{var ee,Z;return W.createElement(C$,{key:F.id,icons:b,index:te,toast:F,defaultRichColors:h,duration:(ee=v==null?void 0:v.duration)!=null?ee:f,className:v==null?void 0:v.className,descriptionClassName:v==null?void 0:v.descriptionClassName,invert:r,visibleToasts:g,closeButton:(Z=v==null?void 0:v.closeButton)!=null?Z:i,interacting:A,position:$,style:v==null?void 0:v.style,unstyled:v==null?void 0:v.unstyled,classNames:v==null?void 0:v.classNames,cancelButtonStyle:v==null?void 0:v.cancelButtonStyle,actionButtonStyle:v==null?void 0:v.actionButtonStyle,removeToast:ne,toasts:C.filter(ve=>ve.position==F.position),heights:j.filter(ve=>ve.position==F.position),setHeights:_,expandByDefault:o,gap:x,loadingIcon:w,expanded:P,pauseWhenPageIsHidden:S,swipeDirections:t.swipeDirections})})):null}))});const _$=({...t})=>{const{theme:e="system"}=e$();return l.jsx(E$,{theme:e,className:"toaster group",toastOptions:{classNames:{toast:"group toast group-[.toaster]:bg-background group-[.toaster]:text-foreground group-[.toaster]:border-border group-[.toaster]:shadow-lg",description:"group-[.toast]:text-muted-foreground",actionButton:"group-[.toast]:bg-primary group-[.toast]:text-primary-foreground",cancelButton:"group-[.toast]:bg-muted group-[.toast]:text-muted-foreground"}},...t})};var T$=Sg[" useId ".trim().toString()]||(()=>{}),R$=0;function hr(t){const[e,r]=m.useState(T$());return gt(()=>{t||r(n=>n??String(R$++))},[t]),t||(e?`radix-${e}`:"")}const M$=["top","right","bottom","left"],Bo=Math.min,en=Math.max,Jf=Math.round,Qf=Math.floor,vs=t=>({x:t,y:t}),O$={left:"right",right:"left",bottom:"top",top:"bottom"},P$={start:"end",end:"start"};function ex(t,e,r){return en(t,Bo(e,r))}function Js(t,e){return typeof t=="function"?t(e):t}function Qs(t){return t.split("-")[0]}function Tl(t){return t.split("-")[1]}function tx(t){return t==="x"?"y":"x"}function rx(t){return t==="y"?"height":"width"}const A$=new Set(["top","bottom"]);function ys(t){return A$.has(Qs(t))?"y":"x"}function nx(t){return tx(ys(t))}function I$(t,e,r){r===void 0&&(r=!1);const n=Tl(t),s=nx(t),o=rx(s);let i=s==="x"?n===(r?"end":"start")?"right":"left":n==="start"?"bottom":"top";return e.reference[o]>e.floating[o]&&(i=Xf(i)),[i,Xf(i)]}function D$(t){const e=Xf(t);return[sx(t),e,sx(e)]}function sx(t){return t.replace(/start|end/g,e=>P$[e])}const BC=["left","right"],UC=["right","left"],L$=["top","bottom"],$=["bottom","top"];function F$(t,e,r){switch(t){case"top":case"bottom":return r?e?UC:BC:e?BC:UC;case"left":case"right":return e?L$:$;default:return[]}}function z$(t,e,r,n){const s=Tl(t);let o=F$(Qs(t),r==="start",n);return s&&(o=o.map(i=>i+"-"+s),e&&(o=o.concat(o.map(sx)))),o}function Xf(t){return t.replace(/left|right|bottom|top/g,e=>O$[e])}function B$(t){return{top:0,right:0,bottom:0,left:0,...t}}function VC(t){return typeof t!="number"?B$(t):{top:t,right:t,bottom:t,left:t}}function Zf(t){const{x:e,y:r,width:n,height:s}=t;return{width:n,height:s,top:r,left:e,right:e+n,bottom:r+s,x:e,y:r}}function WC(t,e,r){let{reference:n,floating:s}=t;const o=ys(e),i=nx(e),a=rx(i),c=Qs(e),d=o==="y",u=n.x+n.width/2-s.width/2,h=n.y+n.height/2-s.height/2,f=n[a]/2-s[a]/2;let p;switch(c){case"top":p={x:u,y:n.y-s.height};break;case"bottom":p={x:u,y:n.y+n.height};break;case"right":p={x:n.x+n.width,y:h};break;case"left":p={x:n.x-s.width,y:h};break;default:p={x:n.x,y:n.y}}switch(Tl(e)){case"start":p[i]-=f*(r&&d?-1:1);break;case"end":p[i]+=f*(r&&d?-1:1);break}return p}const U$=async(t,e,r)=>{const{placement:n="bottom",strategy:s="absolute",middleware:o=[],platform:i}=r,a=o.filter(Boolean),c=await(i.isRTL==null?void 0:i.isRTL(e));let d=await i.getElementRects({reference:t,floating:e,strategy:s}),{x:u,y:h}=WC(d,n,c),f=n,p={},g=0;for(let v=0;v({name:"arrow",options:t,async fn(e){const{x:r,y:n,placement:s,rects:o,platform:i,elements:a,middlewareData:c}=e,{element:d,padding:u=0}=Js(t,e)||{};if(d==null)return{};const h=VC(u),f={x:r,y:n},p=nx(s),g=rx(p),v=await i.getDimensions(d),y=p==="y",x=y?"top":"left",w=y?"bottom":"right",b=y?"clientHeight":"clientWidth",k=o.reference[g]+o.reference[p]-f[p]-o.floating[g],S=f[p]-o.reference[p],C=await(i.getOffsetParent==null?void 0:i.getOffsetParent(d));let N=C?C[b]:0;(!N||!await(i.isElement==null?void 0:i.isElement(C)))&&(N=a.floating[b]||o.floating[g]);const E=k/2-S/2,j=N/2-v[g]/2-1,_=Bo(h[x],j),P=Bo(h[w],j),T=_,A=N-v[g]-P,I=N/2-v[g]/2+E,V=ex(T,I,A),L=!c.arrow&&Tl(s)!=null&&I!==V&&o.reference[g]/2-(II<=0)){var P,T;const I=(((P=o.flip)==null?void 0:P.index)||0)+1,V=N[I];if(V&&(!(h==="alignment"?w!==ys(V):!1)||_.every(M=>M.overflows[0]>0&&ys(M.placement)===w)))return{data:{index:I,overflows:_},reset:{placement:V}};let L=(T=_.filter(U=>U.overflows[0]<=0).sort((U,M)=>U.overflows[1]-M.overflows[1])[0])==null?void 0:T.placement;if(!L)switch(p){case"bestFit":{var A;const U=(A=_.filter(M=>{if(C){const D=ys(M.placement);return D===w||D==="y"}return!0}).map(M=>[M.placement,M.overflows.filter(D=>D>0).reduce((D,H)=>D+H,0)]).sort((M,D)=>M[1]-D[1])[0])==null?void 0:A[0];U&&(L=U);break}case"initialPlacement":L=a;break}if(s!==L)return{reset:{placement:L}}}return{}}}};function HC(t,e){return{top:t.top-e.height,right:t.right-e.width,bottom:t.bottom-e.height,left:t.left-e.width}}function qC(t){return M$.some(e=>t[e]>=0)}const H$=function(t){return t===void 0&&(t={}),{name:"hide",options:t,async fn(e){const{rects:r}=e,{strategy:n="referenceHidden",...s}=Js(t,e);switch(n){case"referenceHidden":{const o=await Kd(e,{...s,elementContext:"reference"}),i=HC(o,r.reference);return{data:{referenceHiddenOffsets:i,referenceHidden:qC(i)}}}case"escaped":{const o=await Kd(e,{...s,altBoundary:!0}),i=HC(o,r.floating);return{data:{escapedOffsets:i,escaped:qC(i)}}}default:return{}}}}},KC=new Set(["left","top"]);async function q$(t,e){const{placement:r,platform:n,elements:s}=t,o=await(n.isRTL==null?void 0:n.isRTL(s.floating)),i=Qs(r),a=Tl(r),c=ys(r)==="y",d=KC.has(i)?-1:1,u=o&&c?-1:1,h=Js(e,t);let{mainAxis:f,crossAxis:p,alignmentAxis:g}=typeof h=="number"?{mainAxis:h,crossAxis:0,alignmentAxis:null}:{mainAxis:h.mainAxis||0,crossAxis:h.crossAxis||0,alignmentAxis:h.alignmentAxis};return a&&typeof g=="number"&&(p=a==="end"?g*-1:g),c?{x:p*u,y:f*d}:{x:f*d,y:p*u}}const K$=function(t){return t===void 0&&(t=0),{name:"offset",options:t,async fn(e){var r,n;const{x:s,y:o,placement:i,middlewareData:a}=e,c=await q$(e,t);return i===((r=a.offset)==null?void 0:r.placement)&&(n=a.arrow)!=null&&n.alignmentOffset?{}:{x:s+c.x,y:o+c.y,data:{...c,placement:i}}}}},G$=function(t){return t===void 0&&(t={}),{name:"shift",options:t,async fn(e){const{x:r,y:n,placement:s}=e,{mainAxis:o=!0,crossAxis:i=!1,limiter:a={fn:y=>{let{x,y:w}=y;return{x,y:w}}},...c}=Js(t,e),d={x:r,y:n},u=await Kd(e,c),h=ys(Qs(s)),f=tx(h);let p=d[f],g=d[h];if(o){const y=f==="y"?"top":"left",x=f==="y"?"bottom":"right",w=p+u[y],b=p-u[x];p=ex(w,p,b)}if(i){const y=h==="y"?"top":"left",x=h==="y"?"bottom":"right",w=g+u[y],b=g-u[x];g=ex(w,g,b)}const v=a.fn({...e,[f]:p,[h]:g});return{...v,data:{x:v.x-r,y:v.y-n,enabled:{[f]:o,[h]:i}}}}}},Y$=function(t){return t===void 0&&(t={}),{options:t,fn(e){const{x:r,y:n,placement:s,rects:o,middlewareData:i}=e,{offset:a=0,mainAxis:c=!0,crossAxis:d=!0}=Js(t,e),u={x:r,y:n},h=ys(s),f=tx(h);let p=u[f],g=u[h];const v=Js(a,e),y=typeof v=="number"?{mainAxis:v,crossAxis:0}:{mainAxis:0,crossAxis:0,...v};if(c){const b=f==="y"?"height":"width",k=o.reference[f]-o.floating[b]+y.mainAxis,S=o.reference[f]+o.reference[b]-y.mainAxis;pS&&(p=S)}if(d){var x,w;const b=f==="y"?"width":"height",k=KC.has(Qs(s)),S=o.reference[h]-o.floating[b]+(k&&((x=i.offset)==null?void 0:x[h])||0)+(k?0:y.crossAxis),C=o.reference[h]+o.reference[b]+(k?0:((w=i.offset)==null?void 0:w[h])||0)-(k?y.crossAxis:0);gC&&(g=C)}return{[f]:p,[h]:g}}}},J$=function(t){return t===void 0&&(t={}),{name:"size",options:t,async fn(e){var r,n;const{placement:s,rects:o,platform:i,elements:a}=e,{apply:c=()=>{},...d}=Js(t,e),u=await Kd(e,d),h=Qs(s),f=Tl(s),p=ys(s)==="y",{width:g,height:v}=o.floating;let y,x;h==="top"||h==="bottom"?(y=h,x=f===(await(i.isRTL==null?void 0:i.isRTL(a.floating))?"start":"end")?"left":"right"):(x=h,y=f==="end"?"top":"bottom");const w=v-u.top-u.bottom,b=g-u.left-u.right,k=Bo(v-u[y],w),S=Bo(g-u[x],b),C=!e.middlewareData.shift;let N=k,E=S;if((r=e.middlewareData.shift)!=null&&r.enabled.x&&(E=b),(n=e.middlewareData.shift)!=null&&n.enabled.y&&(N=w),C&&!f){const _=en(u.left,0),P=en(u.right,0),T=en(u.top,0),A=en(u.bottom,0);p?E=g-2*(_!==0||P!==0?_+P:en(u.left,u.right)):N=v-2*(T!==0||A!==0?T+A:en(u.top,u.bottom))}await c({...e,availableWidth:E,availableHeight:N});const j=await i.getDimensions(a.floating);return g!==j.width||v!==j.height?{reset:{rects:!0}}:{}}}};function ep(){return typeof window<"u"}function Rl(t){return GC(t)?(t.nodeName||"").toLowerCase():"#document"}function tn(t){var e;return(t==null||(e=t.ownerDocument)==null?void 0:e.defaultView)||window}function xs(t){var e;return(e=(GC(t)?t.ownerDocument:t.document)||window.document)==null?void 0:e.documentElement}function GC(t){return ep()?t instanceof Node||t instanceof tn(t).Node:!1}function qn(t){return ep()?t instanceof Element||t instanceof tn(t).Element:!1}function ws(t){return ep()?t instanceof HTMLElement||t instanceof tn(t).HTMLElement:!1}function YC(t){return!ep()||typeof ShadowRoot>"u"?!1:t instanceof ShadowRoot||t instanceof tn(t).ShadowRoot}const Q$=new Set(["inline","contents"]);function Gd(t){const{overflow:e,overflowX:r,overflowY:n,display:s}=Kn(t);return/auto|scroll|overlay|hidden|clip/.test(e+n+r)&&!Q$.has(s)}const X$=new Set(["table","td","th"]);function Z$(t){return X$.has(Rl(t))}const eF=[":popover-open",":modal"];function tp(t){return eF.some(e=>{try{return t.matches(e)}catch{return!1}})}const tF=["transform","translate","scale","rotate","perspective"],rF=["transform","translate","scale","rotate","perspective","filter"],nF=["paint","layout","strict","content"];function ox(t){const e=ix(),r=qn(t)?Kn(t):t;return tF.some(n=>r[n]?r[n]!=="none":!1)||(r.containerType?r.containerType!=="normal":!1)||!e&&(r.backdropFilter?r.backdropFilter!=="none":!1)||!e&&(r.filter?r.filter!=="none":!1)||rF.some(n=>(r.willChange||"").includes(n))||nF.some(n=>(r.contain||"").includes(n))}function sF(t){let e=Uo(t);for(;ws(e)&&!Ml(e);){if(ox(e))return e;if(tp(e))return null;e=Uo(e)}return null}function ix(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const oF=new Set(["html","body","#document"]);function Ml(t){return oF.has(Rl(t))}function Kn(t){return tn(t).getComputedStyle(t)}function rp(t){return qn(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.scrollX,scrollTop:t.scrollY}}function Uo(t){if(Rl(t)==="html")return t;const e=t.assignedSlot||t.parentNode||YC(t)&&t.host||xs(t);return YC(e)?e.host:e}function JC(t){const e=Uo(t);return Ml(e)?t.ownerDocument?t.ownerDocument.body:t.body:ws(e)&&Gd(e)?e:JC(e)}function Yd(t,e,r){var n;e===void 0&&(e=[]),r===void 0&&(r=!0);const s=JC(t),o=s===((n=t.ownerDocument)==null?void 0:n.body),i=tn(s);if(o){const a=ax(i);return e.concat(i,i.visualViewport||[],Gd(s)?s:[],a&&r?Yd(a):[])}return e.concat(s,Yd(s,[],r))}function ax(t){return t.parent&&Object.getPrototypeOf(t.parent)?t.frameElement:null}function QC(t){const e=Kn(t);let r=parseFloat(e.width)||0,n=parseFloat(e.height)||0;const s=ws(t),o=s?t.offsetWidth:r,i=s?t.offsetHeight:n,a=Jf(r)!==o||Jf(n)!==i;return a&&(r=o,n=i),{width:r,height:n,$:a}}function lx(t){return qn(t)?t:t.contextElement}function Ol(t){const e=lx(t);if(!ws(e))return vs(1);const r=e.getBoundingClientRect(),{width:n,height:s,$:o}=QC(e);let i=(o?Jf(r.width):r.width)/n,a=(o?Jf(r.height):r.height)/s;return(!i||!Number.isFinite(i))&&(i=1),(!a||!Number.isFinite(a))&&(a=1),{x:i,y:a}}const iF=vs(0);function XC(t){const e=tn(t);return!ix()||!e.visualViewport?iF:{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}}function aF(t,e,r){return e===void 0&&(e=!1),!r||e&&r!==tn(t)?!1:e}function Xi(t,e,r,n){e===void 0&&(e=!1),r===void 0&&(r=!1);const s=t.getBoundingClientRect(),o=lx(t);let i=vs(1);e&&(n?qn(n)&&(i=Ol(n)):i=Ol(t));const a=aF(o,r,n)?XC(o):vs(0);let c=(s.left+a.x)/i.x,d=(s.top+a.y)/i.y,u=s.width/i.x,h=s.height/i.y;if(o){const f=tn(o),p=n&&qn(n)?tn(n):n;let g=f,v=ax(g);for(;v&&n&&p!==g;){const y=Ol(v),x=v.getBoundingClientRect(),w=Kn(v),b=x.left+(v.clientLeft+parseFloat(w.paddingLeft))*y.x,k=x.top+(v.clientTop+parseFloat(w.paddingTop))*y.y;c*=y.x,d*=y.y,u*=y.x,h*=y.y,c+=b,d+=k,g=tn(v),v=ax(g)}}return Zf({width:u,height:h,x:c,y:d})}function cx(t,e){const r=rp(t).scrollLeft;return e?e.left+r:Xi(xs(t)).left+r}function ZC(t,e,r){r===void 0&&(r=!1);const n=t.getBoundingClientRect(),s=n.left+e.scrollLeft-(r?0:cx(t,n)),o=n.top+e.scrollTop;return{x:s,y:o}}function lF(t){let{elements:e,rect:r,offsetParent:n,strategy:s}=t;const o=s==="fixed",i=xs(n),a=e?tp(e.floating):!1;if(n===i||a&&o)return r;let c={scrollLeft:0,scrollTop:0},d=vs(1);const u=vs(0),h=ws(n);if((h||!h&&!o)&&((Rl(n)!=="body"||Gd(i))&&(c=rp(n)),ws(n))){const p=Xi(n);d=Ol(n),u.x=p.x+n.clientLeft,u.y=p.y+n.clientTop}const f=i&&!h&&!o?ZC(i,c,!0):vs(0);return{width:r.width*d.x,height:r.height*d.y,x:r.x*d.x-c.scrollLeft*d.x+u.x+f.x,y:r.y*d.y-c.scrollTop*d.y+u.y+f.y}}function cF(t){return Array.from(t.getClientRects())}function dF(t){const e=xs(t),r=rp(t),n=t.ownerDocument.body,s=en(e.scrollWidth,e.clientWidth,n.scrollWidth,n.clientWidth),o=en(e.scrollHeight,e.clientHeight,n.scrollHeight,n.clientHeight);let i=-r.scrollLeft+cx(t);const a=-r.scrollTop;return Kn(n).direction==="rtl"&&(i+=en(e.clientWidth,n.clientWidth)-s),{width:s,height:o,x:i,y:a}}function uF(t,e){const r=tn(t),n=xs(t),s=r.visualViewport;let o=n.clientWidth,i=n.clientHeight,a=0,c=0;if(s){o=s.width,i=s.height;const d=ix();(!d||d&&e==="fixed")&&(a=s.offsetLeft,c=s.offsetTop)}return{width:o,height:i,x:a,y:c}}const hF=new Set(["absolute","fixed"]);function fF(t,e){const r=Xi(t,!0,e==="fixed"),n=r.top+t.clientTop,s=r.left+t.clientLeft,o=ws(t)?Ol(t):vs(1),i=t.clientWidth*o.x,a=t.clientHeight*o.y,c=s*o.x,d=n*o.y;return{width:i,height:a,x:c,y:d}}function ej(t,e,r){let n;if(e==="viewport")n=uF(t,r);else if(e==="document")n=dF(xs(t));else if(qn(e))n=fF(e,r);else{const s=XC(t);n={x:e.x-s.x,y:e.y-s.y,width:e.width,height:e.height}}return Zf(n)}function tj(t,e){const r=Uo(t);return r===e||!qn(r)||Ml(r)?!1:Kn(r).position==="fixed"||tj(r,e)}function pF(t,e){const r=e.get(t);if(r)return r;let n=Yd(t,[],!1).filter(a=>qn(a)&&Rl(a)!=="body"),s=null;const o=Kn(t).position==="fixed";let i=o?Uo(t):t;for(;qn(i)&&!Ml(i);){const a=Kn(i),c=ox(i);!c&&a.position==="fixed"&&(s=null),(o?!c&&!s:!c&&a.position==="static"&&!!s&&hF.has(s.position)||Gd(i)&&!c&&tj(t,i))?n=n.filter(u=>u!==i):s=a,i=Uo(i)}return e.set(t,n),n}function mF(t){let{element:e,boundary:r,rootBoundary:n,strategy:s}=t;const i=[...r==="clippingAncestors"?tp(e)?[]:pF(e,this._c):[].concat(r),n],a=i[0],c=i.reduce((d,u)=>{const h=ej(e,u,s);return d.top=en(h.top,d.top),d.right=Bo(h.right,d.right),d.bottom=Bo(h.bottom,d.bottom),d.left=en(h.left,d.left),d},ej(e,a,s));return{width:c.right-c.left,height:c.bottom-c.top,x:c.left,y:c.top}}function gF(t){const{width:e,height:r}=QC(t);return{width:e,height:r}}function vF(t,e,r){const n=ws(e),s=xs(e),o=r==="fixed",i=Xi(t,!0,o,e);let a={scrollLeft:0,scrollTop:0};const c=vs(0);function d(){c.x=cx(s)}if(n||!n&&!o)if((Rl(e)!=="body"||Gd(s))&&(a=rp(e)),n){const p=Xi(e,!0,o,e);c.x=p.x+e.clientLeft,c.y=p.y+e.clientTop}else s&&d();o&&!n&&s&&d();const u=s&&!n&&!o?ZC(s,a):vs(0),h=i.left+a.scrollLeft-c.x-u.x,f=i.top+a.scrollTop-c.y-u.y;return{x:h,y:f,width:i.width,height:i.height}}function dx(t){return Kn(t).position==="static"}function rj(t,e){if(!ws(t)||Kn(t).position==="fixed")return null;if(e)return e(t);let r=t.offsetParent;return xs(t)===r&&(r=r.ownerDocument.body),r}function nj(t,e){const r=tn(t);if(tp(t))return r;if(!ws(t)){let s=Uo(t);for(;s&&!Ml(s);){if(qn(s)&&!dx(s))return s;s=Uo(s)}return r}let n=rj(t,e);for(;n&&Z$(n)&&dx(n);)n=rj(n,e);return n&&Ml(n)&&dx(n)&&!ox(n)?r:n||sF(t)||r}const yF=async function(t){const e=this.getOffsetParent||nj,r=this.getDimensions,n=await r(t.floating);return{reference:vF(t.reference,await e(t.floating),t.strategy),floating:{x:0,y:0,width:n.width,height:n.height}}};function xF(t){return Kn(t).direction==="rtl"}const wF={convertOffsetParentRelativeRectToViewportRelativeRect:lF,getDocumentElement:xs,getClippingRect:mF,getOffsetParent:nj,getElementRects:yF,getClientRects:cF,getDimensions:gF,getScale:Ol,isElement:qn,isRTL:xF};function sj(t,e){return t.x===e.x&&t.y===e.y&&t.width===e.width&&t.height===e.height}function bF(t,e){let r=null,n;const s=xs(t);function o(){var a;clearTimeout(n),(a=r)==null||a.disconnect(),r=null}function i(a,c){a===void 0&&(a=!1),c===void 0&&(c=1),o();const d=t.getBoundingClientRect(),{left:u,top:h,width:f,height:p}=d;if(a||e(),!f||!p)return;const g=Qf(h),v=Qf(s.clientWidth-(u+f)),y=Qf(s.clientHeight-(h+p)),x=Qf(u),b={rootMargin:-g+"px "+-v+"px "+-y+"px "+-x+"px",threshold:en(0,Bo(1,c))||1};let k=!0;function S(C){const N=C[0].intersectionRatio;if(N!==c){if(!k)return i();N?i(!1,N):n=setTimeout(()=>{i(!1,1e-7)},1e3)}N===1&&!sj(d,t.getBoundingClientRect())&&i(),k=!1}try{r=new IntersectionObserver(S,{...b,root:s.ownerDocument})}catch{r=new IntersectionObserver(S,b)}r.observe(t)}return i(!0),o}function kF(t,e,r,n){n===void 0&&(n={});const{ancestorScroll:s=!0,ancestorResize:o=!0,elementResize:i=typeof ResizeObserver=="function",layoutShift:a=typeof IntersectionObserver=="function",animationFrame:c=!1}=n,d=lx(t),u=s||o?[...d?Yd(d):[],...Yd(e)]:[];u.forEach(x=>{s&&x.addEventListener("scroll",r,{passive:!0}),o&&x.addEventListener("resize",r)});const h=d&&a?bF(d,r):null;let f=-1,p=null;i&&(p=new ResizeObserver(x=>{let[w]=x;w&&w.target===d&&p&&(p.unobserve(e),cancelAnimationFrame(f),f=requestAnimationFrame(()=>{var b;(b=p)==null||b.observe(e)})),r()}),d&&!c&&p.observe(d),p.observe(e));let g,v=c?Xi(t):null;c&&y();function y(){const x=Xi(t);v&&!sj(v,x)&&r(),v=x,g=requestAnimationFrame(y)}return r(),()=>{var x;u.forEach(w=>{s&&w.removeEventListener("scroll",r),o&&w.removeEventListener("resize",r)}),h==null||h(),(x=p)==null||x.disconnect(),p=null,c&&cancelAnimationFrame(g)}}const SF=K$,NF=G$,CF=W$,jF=J$,EF=H$,oj=V$,_F=Y$,TF=(t,e,r)=>{const n=new Map,s={platform:wF,...r},o={...s.platform,_c:n};return U$(t,e,{...s,platform:o})};var RF=typeof document<"u",MF=function(){},np=RF?m.useLayoutEffect:MF;function sp(t,e){if(t===e)return!0;if(typeof t!=typeof e)return!1;if(typeof t=="function"&&t.toString()===e.toString())return!0;let r,n,s;if(t&&e&&typeof t=="object"){if(Array.isArray(t)){if(r=t.length,r!==e.length)return!1;for(n=r;n--!==0;)if(!sp(t[n],e[n]))return!1;return!0}if(s=Object.keys(t),r=s.length,r!==Object.keys(e).length)return!1;for(n=r;n--!==0;)if(!{}.hasOwnProperty.call(e,s[n]))return!1;for(n=r;n--!==0;){const o=s[n];if(!(o==="_owner"&&t.$typeof)&&!sp(t[o],e[o]))return!1}return!0}return t!==t&&e!==e}function ij(t){return typeof window>"u"?1:(t.ownerDocument.defaultView||window).devicePixelRatio||1}function aj(t,e){const r=ij(t);return Math.round(e*r)/r}function ux(t){const e=m.useRef(t);return np(()=>{e.current=t}),e}function OF(t){t===void 0&&(t={});const{placement:e="bottom",strategy:r="absolute",middleware:n=[],platform:s,elements:{reference:o,floating:i}={},transform:a=!0,whileElementsMounted:c,open:d}=t,[u,h]=m.useState({x:0,y:0,strategy:r,placement:e,middlewareData:{},isPositioned:!1}),[f,p]=m.useState(n);sp(f,n)||p(n);const[g,v]=m.useState(null),[y,x]=m.useState(null),w=m.useCallback(M=>{M!==C.current&&(C.current=M,v(M))},[]),b=m.useCallback(M=>{M!==N.current&&(N.current=M,x(M))},[]),k=o||g,S=i||y,C=m.useRef(null),N=m.useRef(null),E=m.useRef(u),j=c!=null,_=ux(c),P=ux(s),T=ux(d),A=m.useCallback(()=>{if(!C.current||!N.current)return;const M={placement:e,strategy:r,middleware:f};P.current&&(M.platform=P.current),TF(C.current,N.current,M).then(D=>{const H={...D,isPositioned:T.current!==!1};I.current&&!sp(E.current,H)&&(E.current=H,vn.flushSync(()=>{h(H)}))})},[f,e,r,P,T]);np(()=>{d===!1&&E.current.isPositioned&&(E.current.isPositioned=!1,h(M=>({...M,isPositioned:!1})))},[d]);const I=m.useRef(!1);np(()=>(I.current=!0,()=>{I.current=!1}),[]),np(()=>{if(k&&(C.current=k),S&&(N.current=S),k&&S){if(_.current)return _.current(k,S,A);A()}},[k,S,A,_,j]);const V=m.useMemo(()=>({reference:C,floating:N,setReference:w,setFloating:b}),[w,b]),L=m.useMemo(()=>({reference:k,floating:S}),[k,S]),U=m.useMemo(()=>{const M={position:r,left:0,top:0};if(!L.floating)return M;const D=aj(L.floating,u.x),H=aj(L.floating,u.y);return a?{...M,transform:"translate("+D+"px, "+H+"px)",...ij(L.floating)>=1.5&&{willChange:"transform"}}:{position:r,left:D,top:H}},[r,a,L.floating,u.x,u.y]);return m.useMemo(()=>({...u,update:A,refs:V,elements:L,floatingStyles:U}),[u,A,V,L,U])}const PF=t=>{function e(r){return{}.hasOwnProperty.call(r,"current")}return{name:"arrow",options:t,fn(r){const{element:n,padding:s}=typeof t=="function"?t(r):t;return n&&e(n)?n.current!=null?oj({element:n.current,padding:s}).fn(r):{}:n?oj({element:n,padding:s}).fn(r):{}}}},AF=(t,e)=>({...SF(t),options:[t,e]}),IF=(t,e)=>({...NF(t),options:[t,e]}),DF=(t,e)=>({..._F(t),options:[t,e]}),LF=(t,e)=>({...CF(t),options:[t,e]}),$F=(t,e)=>({...jF(t),options:[t,e]}),FF=(t,e)=>({...EF(t),options:[t,e]}),zF=(t,e)=>({...PF(t),options:[t,e]});var BF="Arrow",lj=m.forwardRef((t,e)=>{const{children:r,width:n=10,height:s=5,...o}=t;return l.jsx(se.svg,{...o,ref:e,width:n,height:s,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:t.asChild?r:l.jsx("polygon",{points:"0,0 30,0 15,10"})})});lj.displayName=BF;var UF=lj;function Jd(t){const[e,r]=m.useState(void 0);return gt(()=>{if(t){r({width:t.offsetWidth,height:t.offsetHeight});const n=new ResizeObserver(s=>{if(!Array.isArray(s)||!s.length)return;const o=s[0];let i,a;if("borderBoxSize"in o){const c=o.borderBoxSize,d=Array.isArray(c)?c[0]:c;i=d.inlineSize,a=d.blockSize}else i=t.offsetWidth,a=t.offsetHeight;r({width:i,height:a})});return n.observe(t,{box:"border-box"}),()=>n.unobserve(t)}else r(void 0)},[t]),e}var hx="Popper",[cj,Pl]=Ft(hx),[VF,dj]=cj(hx),uj=t=>{const{__scopePopper:e,children:r}=t,[n,s]=m.useState(null);return l.jsx(VF,{scope:e,anchor:n,onAnchorChange:s,children:r})};uj.displayName=hx;var hj="PopperAnchor",fj=m.forwardRef((t,e)=>{const{__scopePopper:r,virtualRef:n,...s}=t,o=dj(hj,r),i=m.useRef(null),a=we(e,i);return m.useEffect(()=>{o.onAnchorChange((n==null?void 0:n.current)||i.current)}),n?null:l.jsx(se.div,{...s,ref:a})});fj.displayName=hj;var fx="PopperContent",[WF,HF]=cj(fx),pj=m.forwardRef((t,e)=>{var F,te,ee,Z,ve,ce;const{__scopePopper:r,side:n="bottom",sideOffset:s=0,align:o="center",alignOffset:i=0,arrowPadding:a=0,avoidCollisions:c=!0,collisionBoundary:d=[],collisionPadding:u=0,sticky:h="partial",hideWhenDetached:f=!1,updatePositionStrategy:p="optimized",onPlaced:g,...v}=t,y=dj(fx,r),[x,w]=m.useState(null),b=we(e,Le=>w(Le)),[k,S]=m.useState(null),C=Jd(k),N=(C==null?void 0:C.width)??0,E=(C==null?void 0:C.height)??0,j=n+(o!=="center"?"-"+o:""),_=typeof u=="number"?u:{top:0,right:0,bottom:0,left:0,...u},P=Array.isArray(d)?d:[d],T=P.length>0,A={padding:_,boundary:P.filter(KF),altBoundary:T},{refs:I,floatingStyles:V,placement:L,isPositioned:U,middlewareData:M}=OF({strategy:"fixed",placement:j,whileElementsMounted:(...Le)=>kF(...Le,{animationFrame:p==="always"}),elements:{reference:y.anchor},middleware:[AF({mainAxis:s+E,alignmentAxis:i}),c&&IF({mainAxis:!0,crossAxis:!1,limiter:h==="partial"?DF():void 0,...A}),c&&LF({...A}),$F({...A,apply:({elements:Le,rects:We,availableWidth:It,availableHeight:Dt})=>{const{width:Dn,height:cs}=We.reference,Ps=Le.floating.style;Ps.setProperty("--radix-popper-available-width",`${It}px`),Ps.setProperty("--radix-popper-available-height",`${Dt}px`),Ps.setProperty("--radix-popper-anchor-width",`${Dn}px`),Ps.setProperty("--radix-popper-anchor-height",`${cs}px`)}}),k&&zF({element:k,padding:a}),GF({arrowWidth:N,arrowHeight:E}),f&&FF({strategy:"referenceHidden",...A})]}),[D,H]=vj(L),ne=at(g);gt(()=>{U&&(ne==null||ne())},[U,ne]);const $=(F=M.arrow)==null?void 0:F.x,G=(te=M.arrow)==null?void 0:te.y,J=((ee=M.arrow)==null?void 0:ee.centerOffset)!==0,[O,z]=m.useState();return gt(()=>{x&&z(window.getComputedStyle(x).zIndex)},[x]),l.jsx("div",{ref:I.setFloating,"data-radix-popper-content-wrapper":"",style:{...V,transform:U?V.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:O,"--radix-popper-transform-origin":[(Z=M.transformOrigin)==null?void 0:Z.x,(ve=M.transformOrigin)==null?void 0:ve.y].join(" "),...((ce=M.hide)==null?void 0:ce.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:t.dir,children:l.jsx(WF,{scope:r,placedSide:D,onArrowChange:S,arrowX:$,arrowY:G,shouldHideArrow:J,children:l.jsx(se.div,{"data-side":D,"data-align":H,...v,ref:b,style:{...v.style,animation:U?void 0:"none"}})})})});pj.displayName=fx;var mj="PopperArrow",qF={top:"bottom",right:"left",bottom:"top",left:"right"},gj=m.forwardRef(function(e,r){const{__scopePopper:n,...s}=e,o=HF(mj,n),i=qF[o.placedSide];return l.jsx("span",{ref:o.onArrowChange,style:{position:"absolute",left:o.arrowX,top:o.arrowY,[i]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[o.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[o.placedSide],visibility:o.shouldHideArrow?"hidden":void 0},children:l.jsx(UF,{...s,ref:r,style:{...s.style,display:"block"}})})});gj.displayName=mj;function KF(t){return t!==null}var GF=t=>({name:"transformOrigin",options:t,fn(e){var y,x,w;const{placement:r,rects:n,middlewareData:s}=e,i=((y=s.arrow)==null?void 0:y.centerOffset)!==0,a=i?0:t.arrowWidth,c=i?0:t.arrowHeight,[d,u]=vj(r),h={start:"0%",center:"50%",end:"100%"}[u],f=(((x=s.arrow)==null?void 0:x.x)??0)+a/2,p=(((w=s.arrow)==null?void 0:w.y)??0)+c/2;let g="",v="";return d==="bottom"?(g=i?h:`${f}px`,v=`${-c}px`):d==="top"?(g=i?h:`${f}px`,v=`${n.floating.height+c}px`):d==="right"?(g=`${-c}px`,v=i?h:`${p}px`):d==="left"&&(g=`${n.floating.width+c}px`,v=i?h:`${p}px`),{data:{x:g,y:v}}}});function vj(t){const[e,r="center"]=t.split("-");return[e,r]}var yj=uj,px=fj,mx=pj,gx=gj,[op,vre]=Ft("Tooltip",[Pl]),vx=Pl(),xj="TooltipProvider",YF=700,wj="tooltip.open",[JF,bj]=op(xj),kj=t=>{const{__scopeTooltip:e,delayDuration:r=YF,skipDelayDuration:n=300,disableHoverableContent:s=!1,children:o}=t,i=m.useRef(!0),a=m.useRef(!1),c=m.useRef(0);return m.useEffect(()=>{const d=c.current;return()=>window.clearTimeout(d)},[]),l.jsx(JF,{scope:e,isOpenDelayedRef:i,delayDuration:r,onOpen:m.useCallback(()=>{window.clearTimeout(c.current),i.current=!1},[]),onClose:m.useCallback(()=>{window.clearTimeout(c.current),c.current=window.setTimeout(()=>i.current=!0,n)},[n]),isPointerInTransitRef:a,onPointerInTransitChange:m.useCallback(d=>{a.current=d},[]),disableHoverableContent:s,children:o})};kj.displayName=xj;var Sj="Tooltip",[yre,ip]=op(Sj),yx="TooltipTrigger",QF=m.forwardRef((t,e)=>{const{__scopeTooltip:r,...n}=t,s=ip(yx,r),o=bj(yx,r),i=vx(r),a=m.useRef(null),c=we(e,a,s.onTriggerChange),d=m.useRef(!1),u=m.useRef(!1),h=m.useCallback(()=>d.current=!1,[]);return m.useEffect(()=>()=>document.removeEventListener("pointerup",h),[h]),l.jsx(px,{asChild:!0,...i,children:l.jsx(se.button,{"aria-describedby":s.open?s.contentId:void 0,"data-state":s.stateAttribute,...n,ref:c,onPointerMove:Q(t.onPointerMove,f=>{f.pointerType!=="touch"&&!u.current&&!o.isPointerInTransitRef.current&&(s.onTriggerEnter(),u.current=!0)}),onPointerLeave:Q(t.onPointerLeave,()=>{s.onTriggerLeave(),u.current=!1}),onPointerDown:Q(t.onPointerDown,()=>{s.open&&s.onClose(),d.current=!0,document.addEventListener("pointerup",h,{once:!0})}),onFocus:Q(t.onFocus,()=>{d.current||s.onOpen()}),onBlur:Q(t.onBlur,s.onClose),onClick:Q(t.onClick,s.onClose)})})});QF.displayName=yx;var XF="TooltipPortal",[xre,ZF]=op(XF,{forceMount:void 0}),Al="TooltipContent",Nj=m.forwardRef((t,e)=>{const r=ZF(Al,t.__scopeTooltip),{forceMount:n=r.forceMount,side:s="top",...o}=t,i=ip(Al,t.__scopeTooltip);return l.jsx(er,{present:n||i.open,children:i.disableHoverableContent?l.jsx(Cj,{side:s,...o,ref:e}):l.jsx(ez,{side:s,...o,ref:e})})}),ez=m.forwardRef((t,e)=>{const r=ip(Al,t.__scopeTooltip),n=bj(Al,t.__scopeTooltip),s=m.useRef(null),o=we(e,s),[i,a]=m.useState(null),{trigger:c,onClose:d}=r,u=s.current,{onPointerInTransitChange:h}=n,f=m.useCallback(()=>{a(null),h(!1)},[h]),p=m.useCallback((g,v)=>{const y=g.currentTarget,x={x:g.clientX,y:g.clientY},w=oz(x,y.getBoundingClientRect()),b=iz(x,w),k=az(v.getBoundingClientRect()),S=cz([...b,...k]);a(S),h(!0)},[h]);return m.useEffect(()=>()=>f(),[f]),m.useEffect(()=>{if(c&&u){const g=y=>p(y,u),v=y=>p(y,c);return c.addEventListener("pointerleave",g),u.addEventListener("pointerleave",v),()=>{c.removeEventListener("pointerleave",g),u.removeEventListener("pointerleave",v)}}},[c,u,p,f]),m.useEffect(()=>{if(i){const g=v=>{const y=v.target,x={x:v.clientX,y:v.clientY},w=(c==null?void 0:c.contains(y))||(u==null?void 0:u.contains(y)),b=!lz(x,i);w?f():b&&(f(),d())};return document.addEventListener("pointermove",g),()=>document.removeEventListener("pointermove",g)}},[c,u,i,d,f]),l.jsx(Cj,{...t,ref:o})}),[tz,rz]=op(Sj,{isInside:!1}),nz=U4("TooltipContent"),Cj=m.forwardRef((t,e)=>{const{__scopeTooltip:r,children:n,"aria-label":s,onEscapeKeyDown:o,onPointerDownOutside:i,...a}=t,c=ip(Al,r),d=vx(r),{onClose:u}=c;return m.useEffect(()=>(document.addEventListener(wj,u),()=>document.removeEventListener(wj,u)),[u]),m.useEffect(()=>{if(c.trigger){const h=f=>{const p=f.target;p!=null&&p.contains(c.trigger)&&u()};return window.addEventListener("scroll",h,{capture:!0}),()=>window.removeEventListener("scroll",h,{capture:!0})}},[c.trigger,u]),l.jsx(kl,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:o,onPointerDownOutside:i,onFocusOutside:h=>h.preventDefault(),onDismiss:u,children:l.jsxs(mx,{"data-state":c.stateAttribute,...d,...a,ref:e,style:{...a.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-tooltip-content-available-width":"var(--radix-popper-available-width)","--radix-tooltip-content-available-height":"var(--radix-popper-available-height)","--radix-tooltip-trigger-width":"var(--radix-popper-anchor-width)","--radix-tooltip-trigger-height":"var(--radix-popper-anchor-height)"},children:[l.jsx(nz,{children:n}),l.jsx(tz,{scope:r,isInside:!0,children:l.jsx(d3,{id:c.contentId,role:"tooltip",children:s||n})})]})})});Nj.displayName=Al;var jj="TooltipArrow",sz=m.forwardRef((t,e)=>{const{__scopeTooltip:r,...n}=t,s=vx(r);return rz(jj,r).isInside?null:l.jsx(gx,{...s,...n,ref:e})});sz.displayName=jj;function oz(t,e){const r=Math.abs(e.top-t.y),n=Math.abs(e.bottom-t.y),s=Math.abs(e.right-t.x),o=Math.abs(e.left-t.x);switch(Math.min(r,n,s,o)){case o:return"left";case s:return"right";case r:return"top";case n:return"bottom";default:throw new Error("unreachable")}}function iz(t,e,r=5){const n=[];switch(e){case"top":n.push({x:t.x-r,y:t.y+r},{x:t.x+r,y:t.y+r});break;case"bottom":n.push({x:t.x-r,y:t.y-r},{x:t.x+r,y:t.y-r});break;case"left":n.push({x:t.x+r,y:t.y-r},{x:t.x+r,y:t.y+r});break;case"right":n.push({x:t.x-r,y:t.y-r},{x:t.x-r,y:t.y+r});break}return n}function az(t){const{top:e,right:r,bottom:n,left:s}=t;return[{x:s,y:e},{x:r,y:e},{x:r,y:n},{x:s,y:n}]}function lz(t,e){const{x:r,y:n}=t;let s=!1;for(let o=0,i=e.length-1;on!=f>n&&r<(h-d)*(n-u)/(f-u)+d&&(s=!s)}return s}function cz(t){const e=t.slice();return e.sort((r,n)=>r.xn.x?1:r.yn.y?1:0),dz(e)}function dz(t){if(t.length<=1)return t.slice();const e=[];for(let n=0;n=2;){const o=e[e.length-1],i=e[e.length-2];if((o.x-i.x)*(s.y-i.y)>=(o.y-i.y)*(s.x-i.x))e.pop();else break}e.push(s)}e.pop();const r=[];for(let n=t.length-1;n>=0;n--){const s=t[n];for(;r.length>=2;){const o=r[r.length-1],i=r[r.length-2];if((o.x-i.x)*(s.y-i.y)>=(o.y-i.y)*(s.x-i.x))r.pop();else break}r.push(s)}return r.pop(),e.length===1&&r.length===1&&e[0].x===r[0].x&&e[0].y===r[0].y?e:e.concat(r)}var uz=kj,Ej=Nj;const hz=uz,fz=m.forwardRef(({className:t,sideOffset:e=4,...r},n)=>l.jsx(Ej,{ref:n,sideOffset:e,className:B("z-50 overflow-hidden rounded-md border bg-popover px-3 py-1.5 text-sm text-popover-foreground shadow-md animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",t),...r}));fz.displayName=Ej.displayName;var Il=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(t){return this.listeners.add(t),this.onSubscribe(),()=>{this.listeners.delete(t),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},Zi=typeof window>"u"||"Deno"in globalThis;function Cr(){}function pz(t,e){return typeof t=="function"?t(e):t}function xx(t){return typeof t=="number"&&t>=0&&t!==1/0}function _j(t,e){return Math.max(t+(e||0)-Date.now(),0)}function Vo(t,e){return typeof t=="function"?t(e):t}function yn(t,e){return typeof t=="function"?t(e):t}function Tj(t,e){const{type:r="all",exact:n,fetchStatus:s,predicate:o,queryKey:i,stale:a}=t;if(i){if(n){if(e.queryHash!==wx(i,e.options))return!1}else if(!Qd(e.queryKey,i))return!1}if(r!=="all"){const c=e.isActive();if(r==="active"&&!c||r==="inactive"&&c)return!1}return!(typeof a=="boolean"&&e.isStale()!==a||s&&s!==e.state.fetchStatus||o&&!o(e))}function Rj(t,e){const{exact:r,status:n,predicate:s,mutationKey:o}=t;if(o){if(!e.options.mutationKey)return!1;if(r){if(ea(e.options.mutationKey)!==ea(o))return!1}else if(!Qd(e.options.mutationKey,o))return!1}return!(n&&e.state.status!==n||s&&!s(e))}function wx(t,e){return((e==null?void 0:e.queryKeyHashFn)||ea)(t)}function ea(t){return JSON.stringify(t,(e,r)=>bx(r)?Object.keys(r).sort().reduce((n,s)=>(n[s]=r[s],n),{}):r)}function Qd(t,e){return t===e?!0:typeof t!=typeof e?!1:t&&e&&typeof t=="object"&&typeof e=="object"?Object.keys(e).every(r=>Qd(t[r],e[r])):!1}function Mj(t,e){if(t===e)return t;const r=Oj(t)&&Oj(e);if(r||bx(t)&&bx(e)){const n=r?t:Object.keys(t),s=n.length,o=r?e:Object.keys(e),i=o.length,a=r?[]:{},c=new Set(n);let d=0;for(let u=0;u{setTimeout(e,t)})}function kx(t,e,r){return typeof r.structuralSharing=="function"?r.structuralSharing(t,e):r.structuralSharing!==!1?Mj(t,e):e}function gz(t,e,r=0){const n=[...t,e];return r&&n.length>r?n.slice(1):n}function vz(t,e,r=0){const n=[e,...t];return r&&n.length>r?n.slice(0,-1):n}var Sx=Symbol();function Aj(t,e){return!t.queryFn&&(e!=null&&e.initialPromise)?()=>e.initialPromise:!t.queryFn||t.queryFn===Sx?()=>Promise.reject(new Error(`Missing queryFn: '${t.queryHash}'`)):t.queryFn}function Ij(t,e){return typeof t=="function"?t(...e):!!t}var yz=(KI=class extends Il{constructor(){super();ge(this,Aa);ge(this,bi);ge(this,Ac);ie(this,Ac,e=>{if(!Zi&&window.addEventListener){const r=()=>e();return window.addEventListener("visibilitychange",r,!1),()=>{window.removeEventListener("visibilitychange",r)}}})}onSubscribe(){R(this,bi)||this.setEventListener(R(this,Ac))}onUnsubscribe(){var e;this.hasListeners()||((e=R(this,bi))==null||e.call(this),ie(this,bi,void 0))}setEventListener(e){var r;ie(this,Ac,e),(r=R(this,bi))==null||r.call(this),ie(this,bi,e(n=>{typeof n=="boolean"?this.setFocused(n):this.onFocus()}))}setFocused(e){R(this,Aa)!==e&&(ie(this,Aa,e),this.onFocus())}onFocus(){const e=this.isFocused();this.listeners.forEach(r=>{r(e)})}isFocused(){var e;return typeof R(this,Aa)=="boolean"?R(this,Aa):((e=globalThis.document)==null?void 0:e.visibilityState)!=="hidden"}},Aa=new WeakMap,bi=new WeakMap,Ac=new WeakMap,KI),Nx=new yz,xz=(GI=class extends Il{constructor(){super();ge(this,Ic,!0);ge(this,ki);ge(this,Dc);ie(this,Dc,e=>{if(!Zi&&window.addEventListener){const r=()=>e(!0),n=()=>e(!1);return window.addEventListener("online",r,!1),window.addEventListener("offline",n,!1),()=>{window.removeEventListener("online",r),window.removeEventListener("offline",n)}}})}onSubscribe(){R(this,ki)||this.setEventListener(R(this,Dc))}onUnsubscribe(){var e;this.hasListeners()||((e=R(this,ki))==null||e.call(this),ie(this,ki,void 0))}setEventListener(e){var r;ie(this,Dc,e),(r=R(this,ki))==null||r.call(this),ie(this,ki,e(this.setOnline.bind(this)))}setOnline(e){R(this,Ic)!==e&&(ie(this,Ic,e),this.listeners.forEach(n=>{n(e)}))}isOnline(){return R(this,Ic)}},Ic=new WeakMap,ki=new WeakMap,Dc=new WeakMap,GI),lp=new xz;function Cx(){let t,e;const r=new Promise((s,o)=>{t=s,e=o});r.status="pending",r.catch(()=>{});function n(s){Object.assign(r,s),delete r.resolve,delete r.reject}return r.resolve=s=>{n({status:"fulfilled",value:s}),t(s)},r.reject=s=>{n({status:"rejected",reason:s}),e(s)},r}function wz(t){return Math.min(1e3*2**t,3e4)}function Dj(t){return(t??"online")==="online"?lp.isOnline():!0}var Lj=class extends Error{constructor(t){super("CancelledError"),this.revert=t==null?void 0:t.revert,this.silent=t==null?void 0:t.silent}};function jx(t){return t instanceof Lj}function $j(t){let e=!1,r=0,n=!1,s;const o=Cx(),i=v=>{var y;n||(f(new Lj(v)),(y=t.abort)==null||y.call(t))},a=()=>{e=!0},c=()=>{e=!1},d=()=>Nx.isFocused()&&(t.networkMode==="always"||lp.isOnline())&&t.canRun(),u=()=>Dj(t.networkMode)&&t.canRun(),h=v=>{var y;n||(n=!0,(y=t.onSuccess)==null||y.call(t,v),s==null||s(),o.resolve(v))},f=v=>{var y;n||(n=!0,(y=t.onError)==null||y.call(t,v),s==null||s(),o.reject(v))},p=()=>new Promise(v=>{var y;s=x=>{(n||d())&&v(x)},(y=t.onPause)==null||y.call(t)}).then(()=>{var v;s=void 0,n||(v=t.onContinue)==null||v.call(t)}),g=()=>{if(n)return;let v;const y=r===0?t.initialPromise:void 0;try{v=y??t.fn()}catch(x){v=Promise.reject(x)}Promise.resolve(v).then(h).catch(x=>{var C;if(n)return;const w=t.retry??(Zi?0:3),b=t.retryDelay??wz,k=typeof b=="function"?b(r,x):b,S=w===!0||typeof w=="number"&&rd()?void 0:p()).then(()=>{e?f(x):g()})})};return{promise:o,cancel:i,continue:()=>(s==null||s(),o),cancelRetry:a,continueRetry:c,canStart:u,start:()=>(u()?g():p().then(g),o)}}var bz=t=>setTimeout(t,0);function kz(){let t=[],e=0,r=a=>{a()},n=a=>{a()},s=bz;const o=a=>{e?t.push(a):s(()=>{r(a)})},i=()=>{const a=t;t=[],a.length&&s(()=>{n(()=>{a.forEach(c=>{r(c)})})})};return{batch:a=>{let c;e++;try{c=a()}finally{e--,e||i()}return c},batchCalls:a=>(...c)=>{o(()=>{a(...c)})},schedule:o,setNotifyFunction:a=>{r=a},setBatchNotifyFunction:a=>{n=a},setScheduler:a=>{s=a}}}var Mt=kz(),Fj=(YI=class{constructor(){ge(this,Ia)}destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),xx(this.gcTime)&&ie(this,Ia,setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(t){this.gcTime=Math.max(this.gcTime||0,t??(Zi?1/0:5*60*1e3))}clearGcTimeout(){R(this,Ia)&&(clearTimeout(R(this,Ia)),ie(this,Ia,void 0))}},Ia=new WeakMap,YI),Sz=(JI=class extends Fj{constructor(e){super();ge(this,as);ge(this,Lc);ge(this,Da);ge(this,In);ge(this,La);ge(this,vr);ge(this,vh);ge(this,$a);ie(this,$a,!1),ie(this,vh,e.defaultOptions),this.setOptions(e.options),this.observers=[],ie(this,La,e.client),ie(this,In,R(this,La).getQueryCache()),this.queryKey=e.queryKey,this.queryHash=e.queryHash,ie(this,Lc,Nz(this.options)),this.state=e.state??R(this,Lc),this.scheduleGc()}get meta(){return this.options.meta}get promise(){var e;return(e=R(this,vr))==null?void 0:e.promise}setOptions(e){this.options={...R(this,vh),...e},this.updateGcTime(this.options.gcTime)}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&R(this,In).remove(this)}setData(e,r){const n=kx(this.state.data,e,this.options);return Te(this,as,go).call(this,{data:n,type:"success",dataUpdatedAt:r==null?void 0:r.updatedAt,manual:r==null?void 0:r.manual}),n}setState(e,r){Te(this,as,go).call(this,{type:"setState",state:e,setStateOptions:r})}cancel(e){var n,s;const r=(n=R(this,vr))==null?void 0:n.promise;return(s=R(this,vr))==null||s.cancel(e),r?r.then(Cr).catch(Cr):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(R(this,Lc))}isActive(){return this.observers.some(e=>yn(e.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===Sx||this.state.dataUpdateCount+this.state.errorUpdateCount===0}isStatic(){return this.getObserversCount()>0?this.observers.some(e=>Vo(e.options.staleTime,this)==="static"):!1}isStale(){return this.getObserversCount()>0?this.observers.some(e=>e.getCurrentResult().isStale):this.state.data===void 0||this.state.isInvalidated}isStaleByTime(e=0){return this.state.data===void 0?!0:e==="static"?!1:this.state.isInvalidated?!0:!_j(this.state.dataUpdatedAt,e)}onFocus(){var r;const e=this.observers.find(n=>n.shouldFetchOnWindowFocus());e==null||e.refetch({cancelRefetch:!1}),(r=R(this,vr))==null||r.continue()}onOnline(){var r;const e=this.observers.find(n=>n.shouldFetchOnReconnect());e==null||e.refetch({cancelRefetch:!1}),(r=R(this,vr))==null||r.continue()}addObserver(e){this.observers.includes(e)||(this.observers.push(e),this.clearGcTimeout(),R(this,In).notify({type:"observerAdded",query:this,observer:e}))}removeObserver(e){this.observers.includes(e)&&(this.observers=this.observers.filter(r=>r!==e),this.observers.length||(R(this,vr)&&(R(this,$a)?R(this,vr).cancel({revert:!0}):R(this,vr).cancelRetry()),this.scheduleGc()),R(this,In).notify({type:"observerRemoved",query:this,observer:e}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||Te(this,as,go).call(this,{type:"invalidate"})}fetch(e,r){var d,u,h;if(this.state.fetchStatus!=="idle"){if(this.state.data!==void 0&&(r!=null&&r.cancelRefetch))this.cancel({silent:!0});else if(R(this,vr))return R(this,vr).continueRetry(),R(this,vr).promise}if(e&&this.setOptions(e),!this.options.queryFn){const f=this.observers.find(p=>p.options.queryFn);f&&this.setOptions(f.options)}const n=new AbortController,s=f=>{Object.defineProperty(f,"signal",{enumerable:!0,get:()=>(ie(this,$a,!0),n.signal)})},o=()=>{const f=Aj(this.options,r),g=(()=>{const v={client:R(this,La),queryKey:this.queryKey,meta:this.meta};return s(v),v})();return ie(this,$a,!1),this.options.persister?this.options.persister(f,g,this):f(g)},a=(()=>{const f={fetchOptions:r,options:this.options,queryKey:this.queryKey,client:R(this,La),state:this.state,fetchFn:o};return s(f),f})();(d=this.options.behavior)==null||d.onFetch(a,this),ie(this,Da,this.state),(this.state.fetchStatus==="idle"||this.state.fetchMeta!==((u=a.fetchOptions)==null?void 0:u.meta))&&Te(this,as,go).call(this,{type:"fetch",meta:(h=a.fetchOptions)==null?void 0:h.meta});const c=f=>{var p,g,v,y;jx(f)&&f.silent||Te(this,as,go).call(this,{type:"error",error:f}),jx(f)||((g=(p=R(this,In).config).onError)==null||g.call(p,f,this),(y=(v=R(this,In).config).onSettled)==null||y.call(v,this.state.data,f,this)),this.scheduleGc()};return ie(this,vr,$j({initialPromise:r==null?void 0:r.initialPromise,fn:a.fetchFn,abort:n.abort.bind(n),onSuccess:f=>{var p,g,v,y;if(f===void 0){c(new Error(`${this.queryHash} data is undefined`));return}try{this.setData(f)}catch(x){c(x);return}(g=(p=R(this,In).config).onSuccess)==null||g.call(p,f,this),(y=(v=R(this,In).config).onSettled)==null||y.call(v,f,this.state.error,this),this.scheduleGc()},onError:c,onFail:(f,p)=>{Te(this,as,go).call(this,{type:"failed",failureCount:f,error:p})},onPause:()=>{Te(this,as,go).call(this,{type:"pause"})},onContinue:()=>{Te(this,as,go).call(this,{type:"continue"})},retry:a.options.retry,retryDelay:a.options.retryDelay,networkMode:a.options.networkMode,canRun:()=>!0})),R(this,vr).start()}},Lc=new WeakMap,Da=new WeakMap,In=new WeakMap,La=new WeakMap,vr=new WeakMap,vh=new WeakMap,$a=new WeakMap,as=new WeakSet,go=function(e){const r=n=>{switch(e.type){case"failed":return{...n,fetchFailureCount:e.failureCount,fetchFailureReason:e.error};case"pause":return{...n,fetchStatus:"paused"};case"continue":return{...n,fetchStatus:"fetching"};case"fetch":return{...n,...zj(n.data,this.options),fetchMeta:e.meta??null};case"success":return ie(this,Da,void 0),{...n,data:e.data,dataUpdateCount:n.dataUpdateCount+1,dataUpdatedAt:e.dataUpdatedAt??Date.now(),error:null,isInvalidated:!1,status:"success",...!e.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};case"error":const s=e.error;return jx(s)&&s.revert&&R(this,Da)?{...R(this,Da),fetchStatus:"idle"}:{...n,error:s,errorUpdateCount:n.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:n.fetchFailureCount+1,fetchFailureReason:s,fetchStatus:"idle",status:"error"};case"invalidate":return{...n,isInvalidated:!0};case"setState":return{...n,...e.state}}};this.state=r(this.state),Mt.batch(()=>{this.observers.forEach(n=>{n.onQueryUpdate()}),R(this,In).notify({query:this,type:"updated",action:e})})},JI);function zj(t,e){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:Dj(e.networkMode)?"fetching":"paused",...t===void 0&&{error:null,status:"pending"}}}function Nz(t){const e=typeof t.initialData=="function"?t.initialData():t.initialData,r=e!==void 0,n=r?typeof t.initialDataUpdatedAt=="function"?t.initialDataUpdatedAt():t.initialDataUpdatedAt:0;return{data:e,dataUpdateCount:0,dataUpdatedAt:r?n??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:r?"success":"pending",fetchStatus:"idle"}}var Cz=(QI=class extends Il{constructor(e={}){super();ge(this,Rs);this.config=e,ie(this,Rs,new Map)}build(e,r,n){const s=r.queryKey,o=r.queryHash??wx(s,r);let i=this.get(o);return i||(i=new Sz({client:e,queryKey:s,queryHash:o,options:e.defaultQueryOptions(r),state:n,defaultOptions:e.getQueryDefaults(s)}),this.add(i)),i}add(e){R(this,Rs).has(e.queryHash)||(R(this,Rs).set(e.queryHash,e),this.notify({type:"added",query:e}))}remove(e){const r=R(this,Rs).get(e.queryHash);r&&(e.destroy(),r===e&&R(this,Rs).delete(e.queryHash),this.notify({type:"removed",query:e}))}clear(){Mt.batch(()=>{this.getAll().forEach(e=>{this.remove(e)})})}get(e){return R(this,Rs).get(e)}getAll(){return[...R(this,Rs).values()]}find(e){const r={exact:!0,...e};return this.getAll().find(n=>Tj(r,n))}findAll(e={}){const r=this.getAll();return Object.keys(e).length>0?r.filter(n=>Tj(e,n)):r}notify(e){Mt.batch(()=>{this.listeners.forEach(r=>{r(e)})})}onFocus(){Mt.batch(()=>{this.getAll().forEach(e=>{e.onFocus()})})}onOnline(){Mt.batch(()=>{this.getAll().forEach(e=>{e.onOnline()})})}},Rs=new WeakMap,QI),jz=(XI=class extends Fj{constructor(e){super();ge(this,Os);ge(this,Ms);ge(this,Rr);ge(this,Fa);this.mutationId=e.mutationId,ie(this,Rr,e.mutationCache),ie(this,Ms,[]),this.state=e.state||Bj(),this.setOptions(e.options),this.scheduleGc()}setOptions(e){this.options=e,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(e){R(this,Ms).includes(e)||(R(this,Ms).push(e),this.clearGcTimeout(),R(this,Rr).notify({type:"observerAdded",mutation:this,observer:e}))}removeObserver(e){ie(this,Ms,R(this,Ms).filter(r=>r!==e)),this.scheduleGc(),R(this,Rr).notify({type:"observerRemoved",mutation:this,observer:e})}optionalRemove(){R(this,Ms).length||(this.state.status==="pending"?this.scheduleGc():R(this,Rr).remove(this))}continue(){var e;return((e=R(this,Fa))==null?void 0:e.continue())??this.execute(this.state.variables)}async execute(e){var o,i,a,c,d,u,h,f,p,g,v,y,x,w,b,k,S,C,N,E;const r=()=>{Te(this,Os,Ai).call(this,{type:"continue"})};ie(this,Fa,$j({fn:()=>this.options.mutationFn?this.options.mutationFn(e):Promise.reject(new Error("No mutationFn found")),onFail:(j,_)=>{Te(this,Os,Ai).call(this,{type:"failed",failureCount:j,error:_})},onPause:()=>{Te(this,Os,Ai).call(this,{type:"pause"})},onContinue:r,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>R(this,Rr).canRun(this)}));const n=this.state.status==="pending",s=!R(this,Fa).canStart();try{if(n)r();else{Te(this,Os,Ai).call(this,{type:"pending",variables:e,isPaused:s}),await((i=(o=R(this,Rr).config).onMutate)==null?void 0:i.call(o,e,this));const _=await((c=(a=this.options).onMutate)==null?void 0:c.call(a,e));_!==this.state.context&&Te(this,Os,Ai).call(this,{type:"pending",context:_,variables:e,isPaused:s})}const j=await R(this,Fa).start();return await((u=(d=R(this,Rr).config).onSuccess)==null?void 0:u.call(d,j,e,this.state.context,this)),await((f=(h=this.options).onSuccess)==null?void 0:f.call(h,j,e,this.state.context)),await((g=(p=R(this,Rr).config).onSettled)==null?void 0:g.call(p,j,null,this.state.variables,this.state.context,this)),await((y=(v=this.options).onSettled)==null?void 0:y.call(v,j,null,e,this.state.context)),Te(this,Os,Ai).call(this,{type:"success",data:j}),j}catch(j){try{throw await((w=(x=R(this,Rr).config).onError)==null?void 0:w.call(x,j,e,this.state.context,this)),await((k=(b=this.options).onError)==null?void 0:k.call(b,j,e,this.state.context)),await((C=(S=R(this,Rr).config).onSettled)==null?void 0:C.call(S,void 0,j,this.state.variables,this.state.context,this)),await((E=(N=this.options).onSettled)==null?void 0:E.call(N,void 0,j,e,this.state.context)),j}finally{Te(this,Os,Ai).call(this,{type:"error",error:j})}}finally{R(this,Rr).runNext(this)}}},Ms=new WeakMap,Rr=new WeakMap,Fa=new WeakMap,Os=new WeakSet,Ai=function(e){const r=n=>{switch(e.type){case"failed":return{...n,failureCount:e.failureCount,failureReason:e.error};case"pause":return{...n,isPaused:!0};case"continue":return{...n,isPaused:!1};case"pending":return{...n,context:e.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:e.isPaused,status:"pending",variables:e.variables,submittedAt:Date.now()};case"success":return{...n,data:e.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...n,data:void 0,error:e.error,failureCount:n.failureCount+1,failureReason:e.error,isPaused:!1,status:"error"}}};this.state=r(this.state),Mt.batch(()=>{R(this,Ms).forEach(n=>{n.onMutationUpdate(e)}),R(this,Rr).notify({mutation:this,type:"updated",action:e})})},XI);function Bj(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var Ez=(ZI=class extends Il{constructor(e={}){super();ge(this,ho);ge(this,ls);ge(this,yh);this.config=e,ie(this,ho,new Set),ie(this,ls,new Map),ie(this,yh,0)}build(e,r,n){const s=new jz({mutationCache:this,mutationId:++gg(this,yh)._,options:e.defaultMutationOptions(r),state:n});return this.add(s),s}add(e){R(this,ho).add(e);const r=cp(e);if(typeof r=="string"){const n=R(this,ls).get(r);n?n.push(e):R(this,ls).set(r,[e])}this.notify({type:"added",mutation:e})}remove(e){if(R(this,ho).delete(e)){const r=cp(e);if(typeof r=="string"){const n=R(this,ls).get(r);if(n)if(n.length>1){const s=n.indexOf(e);s!==-1&&n.splice(s,1)}else n[0]===e&&R(this,ls).delete(r)}}this.notify({type:"removed",mutation:e})}canRun(e){const r=cp(e);if(typeof r=="string"){const n=R(this,ls).get(r),s=n==null?void 0:n.find(o=>o.state.status==="pending");return!s||s===e}else return!0}runNext(e){var n;const r=cp(e);if(typeof r=="string"){const s=(n=R(this,ls).get(r))==null?void 0:n.find(o=>o!==e&&o.state.isPaused);return(s==null?void 0:s.continue())??Promise.resolve()}else return Promise.resolve()}clear(){Mt.batch(()=>{R(this,ho).forEach(e=>{this.notify({type:"removed",mutation:e})}),R(this,ho).clear(),R(this,ls).clear()})}getAll(){return Array.from(R(this,ho))}find(e){const r={exact:!0,...e};return this.getAll().find(n=>Rj(r,n))}findAll(e={}){return this.getAll().filter(r=>Rj(e,r))}notify(e){Mt.batch(()=>{this.listeners.forEach(r=>{r(e)})})}resumePausedMutations(){const e=this.getAll().filter(r=>r.state.isPaused);return Mt.batch(()=>Promise.all(e.map(r=>r.continue().catch(Cr))))}},ho=new WeakMap,ls=new WeakMap,yh=new WeakMap,ZI);function cp(t){var e;return(e=t.options.scope)==null?void 0:e.id}function Uj(t){return{onFetch:(e,r)=>{var u,h,f,p,g;const n=e.options,s=(f=(h=(u=e.fetchOptions)==null?void 0:u.meta)==null?void 0:h.fetchMore)==null?void 0:f.direction,o=((p=e.state.data)==null?void 0:p.pages)||[],i=((g=e.state.data)==null?void 0:g.pageParams)||[];let a={pages:[],pageParams:[]},c=0;const d=async()=>{let v=!1;const y=b=>{Object.defineProperty(b,"signal",{enumerable:!0,get:()=>(e.signal.aborted?v=!0:e.signal.addEventListener("abort",()=>{v=!0}),e.signal)})},x=Aj(e.options,e.fetchOptions),w=async(b,k,S)=>{if(v)return Promise.reject();if(k==null&&b.pages.length)return Promise.resolve(b);const N=(()=>{const P={client:e.client,queryKey:e.queryKey,pageParam:k,direction:S?"backward":"forward",meta:e.options.meta};return y(P),P})(),E=await x(N),{maxPages:j}=e.options,_=S?vz:gz;return{pages:_(b.pages,E,j),pageParams:_(b.pageParams,k,j)}};if(s&&o.length){const b=s==="backward",k=b?_z:Vj,S={pages:o,pageParams:i},C=k(n,S);a=await w(S,C,b)}else{const b=t??o.length;do{const k=c===0?i[0]??n.initialPageParam:Vj(n,a);if(c>0&&k==null)break;a=await w(a,k),c++}while(c{var v,y;return(y=(v=e.options).persister)==null?void 0:y.call(v,d,{client:e.client,queryKey:e.queryKey,meta:e.options.meta,signal:e.signal},r)}:e.fetchFn=d}}}function Vj(t,{pages:e,pageParams:r}){const n=e.length-1;return e.length>0?t.getNextPageParam(e[n],e,r[n],r):void 0}function _z(t,{pages:e,pageParams:r}){var n;return e.length>0?(n=t.getPreviousPageParam)==null?void 0:n.call(t,e[0],e,r[0],r):void 0}var Tz=(eD=class{constructor(t={}){ge(this,ut);ge(this,Si);ge(this,Ni);ge(this,$c);ge(this,Fc);ge(this,Ci);ge(this,zc);ge(this,Bc);ie(this,ut,t.queryCache||new Cz),ie(this,Si,t.mutationCache||new Ez),ie(this,Ni,t.defaultOptions||{}),ie(this,$c,new Map),ie(this,Fc,new Map),ie(this,Ci,0)}mount(){gg(this,Ci)._++,R(this,Ci)===1&&(ie(this,zc,Nx.subscribe(async t=>{t&&(await this.resumePausedMutations(),R(this,ut).onFocus())})),ie(this,Bc,lp.subscribe(async t=>{t&&(await this.resumePausedMutations(),R(this,ut).onOnline())})))}unmount(){var t,e;gg(this,Ci)._--,R(this,Ci)===0&&((t=R(this,zc))==null||t.call(this),ie(this,zc,void 0),(e=R(this,Bc))==null||e.call(this),ie(this,Bc,void 0))}isFetching(t){return R(this,ut).findAll({...t,fetchStatus:"fetching"}).length}isMutating(t){return R(this,Si).findAll({...t,status:"pending"}).length}getQueryData(t){var r;const e=this.defaultQueryOptions({queryKey:t});return(r=R(this,ut).get(e.queryHash))==null?void 0:r.state.data}ensureQueryData(t){const e=this.defaultQueryOptions(t),r=R(this,ut).build(this,e),n=r.state.data;return n===void 0?this.fetchQuery(t):(t.revalidateIfStale&&r.isStaleByTime(Vo(e.staleTime,r))&&this.prefetchQuery(e),Promise.resolve(n))}getQueriesData(t){return R(this,ut).findAll(t).map(({queryKey:e,state:r})=>{const n=r.data;return[e,n]})}setQueryData(t,e,r){const n=this.defaultQueryOptions({queryKey:t}),s=R(this,ut).get(n.queryHash),o=s==null?void 0:s.state.data,i=pz(e,o);if(i!==void 0)return R(this,ut).build(this,n).setData(i,{...r,manual:!0})}setQueriesData(t,e,r){return Mt.batch(()=>R(this,ut).findAll(t).map(({queryKey:n})=>[n,this.setQueryData(n,e,r)]))}getQueryState(t){var r;const e=this.defaultQueryOptions({queryKey:t});return(r=R(this,ut).get(e.queryHash))==null?void 0:r.state}removeQueries(t){const e=R(this,ut);Mt.batch(()=>{e.findAll(t).forEach(r=>{e.remove(r)})})}resetQueries(t,e){const r=R(this,ut);return Mt.batch(()=>(r.findAll(t).forEach(n=>{n.reset()}),this.refetchQueries({type:"active",...t},e)))}cancelQueries(t,e={}){const r={revert:!0,...e},n=Mt.batch(()=>R(this,ut).findAll(t).map(s=>s.cancel(r)));return Promise.all(n).then(Cr).catch(Cr)}invalidateQueries(t,e={}){return Mt.batch(()=>(R(this,ut).findAll(t).forEach(r=>{r.invalidate()}),(t==null?void 0:t.refetchType)==="none"?Promise.resolve():this.refetchQueries({...t,type:(t==null?void 0:t.refetchType)??(t==null?void 0:t.type)??"active"},e)))}refetchQueries(t,e={}){const r={...e,cancelRefetch:e.cancelRefetch??!0},n=Mt.batch(()=>R(this,ut).findAll(t).filter(s=>!s.isDisabled()&&!s.isStatic()).map(s=>{let o=s.fetch(void 0,r);return r.throwOnError||(o=o.catch(Cr)),s.state.fetchStatus==="paused"?Promise.resolve():o}));return Promise.all(n).then(Cr)}fetchQuery(t){const e=this.defaultQueryOptions(t);e.retry===void 0&&(e.retry=!1);const r=R(this,ut).build(this,e);return r.isStaleByTime(Vo(e.staleTime,r))?r.fetch(e):Promise.resolve(r.state.data)}prefetchQuery(t){return this.fetchQuery(t).then(Cr).catch(Cr)}fetchInfiniteQuery(t){return t.behavior=Uj(t.pages),this.fetchQuery(t)}prefetchInfiniteQuery(t){return this.fetchInfiniteQuery(t).then(Cr).catch(Cr)}ensureInfiniteQueryData(t){return t.behavior=Uj(t.pages),this.ensureQueryData(t)}resumePausedMutations(){return lp.isOnline()?R(this,Si).resumePausedMutations():Promise.resolve()}getQueryCache(){return R(this,ut)}getMutationCache(){return R(this,Si)}getDefaultOptions(){return R(this,Ni)}setDefaultOptions(t){ie(this,Ni,t)}setQueryDefaults(t,e){R(this,$c).set(ea(t),{queryKey:t,defaultOptions:e})}getQueryDefaults(t){const e=[...R(this,$c).values()],r={};return e.forEach(n=>{Qd(t,n.queryKey)&&Object.assign(r,n.defaultOptions)}),r}setMutationDefaults(t,e){R(this,Fc).set(ea(t),{mutationKey:t,defaultOptions:e})}getMutationDefaults(t){const e=[...R(this,Fc).values()],r={};return e.forEach(n=>{Qd(t,n.mutationKey)&&Object.assign(r,n.defaultOptions)}),r}defaultQueryOptions(t){if(t._defaulted)return t;const e={...R(this,Ni).queries,...this.getQueryDefaults(t.queryKey),...t,_defaulted:!0};return e.queryHash||(e.queryHash=wx(e.queryKey,e)),e.refetchOnReconnect===void 0&&(e.refetchOnReconnect=e.networkMode!=="always"),e.throwOnError===void 0&&(e.throwOnError=!!e.suspense),!e.networkMode&&e.persister&&(e.networkMode="offlineFirst"),e.queryFn===Sx&&(e.enabled=!1),e}defaultMutationOptions(t){return t!=null&&t._defaulted?t:{...R(this,Ni).mutations,...(t==null?void 0:t.mutationKey)&&this.getMutationDefaults(t.mutationKey),...t,_defaulted:!0}}clear(){R(this,ut).clear(),R(this,Si).clear()}},ut=new WeakMap,Si=new WeakMap,Ni=new WeakMap,$c=new WeakMap,Fc=new WeakMap,Ci=new WeakMap,zc=new WeakMap,Bc=new WeakMap,eD),Rz=(tD=class extends Il{constructor(e,r){super();ge(this,ze);ge(this,Hr);ge(this,De);ge(this,xh);ge(this,Mr);ge(this,za);ge(this,Uc);ge(this,ji);ge(this,Ei);ge(this,wh);ge(this,Vc);ge(this,Wc);ge(this,Ba);ge(this,Ua);ge(this,_i);ge(this,Hc,new Set);this.options=r,ie(this,Hr,e),ie(this,Ei,null),ie(this,ji,Cx()),this.options.experimental_prefetchInRender||R(this,ji).reject(new Error("experimental_prefetchInRender feature flag is not enabled")),this.bindMethods(),this.setOptions(r)}bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(R(this,De).addObserver(this),Wj(R(this,De),this.options)?Te(this,ze,jh).call(this):this.updateResult(),Te(this,ze,n1).call(this))}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return Ex(R(this,De),this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return Ex(R(this,De),this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,Te(this,ze,s1).call(this),Te(this,ze,o1).call(this),R(this,De).removeObserver(this)}setOptions(e){const r=this.options,n=R(this,De);if(this.options=R(this,Hr).defaultQueryOptions(e),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof yn(this.options.enabled,R(this,De))!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");Te(this,ze,i1).call(this),R(this,De).setOptions(this.options),r._defaulted&&!ap(this.options,r)&&R(this,Hr).getQueryCache().notify({type:"observerOptionsUpdated",query:R(this,De),observer:this});const s=this.hasListeners();s&&Hj(R(this,De),n,this.options,r)&&Te(this,ze,jh).call(this),this.updateResult(),s&&(R(this,De)!==n||yn(this.options.enabled,R(this,De))!==yn(r.enabled,R(this,De))||Vo(this.options.staleTime,R(this,De))!==Vo(r.staleTime,R(this,De)))&&Te(this,ze,e1).call(this);const o=Te(this,ze,t1).call(this);s&&(R(this,De)!==n||yn(this.options.enabled,R(this,De))!==yn(r.enabled,R(this,De))||o!==R(this,_i))&&Te(this,ze,r1).call(this,o)}getOptimisticResult(e){const r=R(this,Hr).getQueryCache().build(R(this,Hr),e),n=this.createResult(r,e);return Oz(this,n)&&(ie(this,Mr,n),ie(this,Uc,this.options),ie(this,za,R(this,De).state)),n}getCurrentResult(){return R(this,Mr)}trackResult(e,r){return new Proxy(e,{get:(n,s)=>(this.trackProp(s),r==null||r(s),Reflect.get(n,s))})}trackProp(e){R(this,Hc).add(e)}getCurrentQuery(){return R(this,De)}refetch({...e}={}){return this.fetch({...e})}fetchOptimistic(e){const r=R(this,Hr).defaultQueryOptions(e),n=R(this,Hr).getQueryCache().build(R(this,Hr),r);return n.fetch().then(()=>this.createResult(n,r))}fetch(e){return Te(this,ze,jh).call(this,{...e,cancelRefetch:e.cancelRefetch??!0}).then(()=>(this.updateResult(),R(this,Mr)))}createResult(e,r){var j;const n=R(this,De),s=this.options,o=R(this,Mr),i=R(this,za),a=R(this,Uc),d=e!==n?e.state:R(this,xh),{state:u}=e;let h={...u},f=!1,p;if(r._optimisticResults){const _=this.hasListeners(),P=!_&&Wj(e,r),T=_&&Hj(e,n,r,s);(P||T)&&(h={...h,...zj(u.data,e.options)}),r._optimisticResults==="isRestoring"&&(h.fetchStatus="idle")}let{error:g,errorUpdatedAt:v,status:y}=h;p=h.data;let x=!1;if(r.placeholderData!==void 0&&p===void 0&&y==="pending"){let _;o!=null&&o.isPlaceholderData&&r.placeholderData===(a==null?void 0:a.placeholderData)?(_=o.data,x=!0):_=typeof r.placeholderData=="function"?r.placeholderData((j=R(this,Wc))==null?void 0:j.state.data,R(this,Wc)):r.placeholderData,_!==void 0&&(y="success",p=kx(o==null?void 0:o.data,_,r),f=!0)}if(r.select&&p!==void 0&&!x)if(o&&p===(i==null?void 0:i.data)&&r.select===R(this,wh))p=R(this,Vc);else try{ie(this,wh,r.select),p=r.select(p),p=kx(o==null?void 0:o.data,p,r),ie(this,Vc,p),ie(this,Ei,null)}catch(_){ie(this,Ei,_)}R(this,Ei)&&(g=R(this,Ei),p=R(this,Vc),v=Date.now(),y="error");const w=h.fetchStatus==="fetching",b=y==="pending",k=y==="error",S=b&&w,C=p!==void 0,E={status:y,fetchStatus:h.fetchStatus,isPending:b,isSuccess:y==="success",isError:k,isInitialLoading:S,isLoading:S,data:p,dataUpdatedAt:h.dataUpdatedAt,error:g,errorUpdatedAt:v,failureCount:h.fetchFailureCount,failureReason:h.fetchFailureReason,errorUpdateCount:h.errorUpdateCount,isFetched:h.dataUpdateCount>0||h.errorUpdateCount>0,isFetchedAfterMount:h.dataUpdateCount>d.dataUpdateCount||h.errorUpdateCount>d.errorUpdateCount,isFetching:w,isRefetching:w&&!b,isLoadingError:k&&!C,isPaused:h.fetchStatus==="paused",isPlaceholderData:f,isRefetchError:k&&C,isStale:_x(e,r),refetch:this.refetch,promise:R(this,ji),isEnabled:yn(r.enabled,e)!==!1};if(this.options.experimental_prefetchInRender){const _=A=>{E.status==="error"?A.reject(E.error):E.data!==void 0&&A.resolve(E.data)},P=()=>{const A=ie(this,ji,E.promise=Cx());_(A)},T=R(this,ji);switch(T.status){case"pending":e.queryHash===n.queryHash&&_(T);break;case"fulfilled":(E.status==="error"||E.data!==T.value)&&P();break;case"rejected":(E.status!=="error"||E.error!==T.reason)&&P();break}}return E}updateResult(){const e=R(this,Mr),r=this.createResult(R(this,De),this.options);if(ie(this,za,R(this,De).state),ie(this,Uc,this.options),R(this,za).data!==void 0&&ie(this,Wc,R(this,De)),ap(r,e))return;ie(this,Mr,r);const n=()=>{if(!e)return!0;const{notifyOnChangeProps:s}=this.options,o=typeof s=="function"?s():s;if(o==="all"||!o&&!R(this,Hc).size)return!0;const i=new Set(o??R(this,Hc));return this.options.throwOnError&&i.add("error"),Object.keys(R(this,Mr)).some(a=>{const c=a;return R(this,Mr)[c]!==e[c]&&i.has(c)})};Te(this,ze,sD).call(this,{listeners:n()})}onQueryUpdate(){this.updateResult(),this.hasListeners()&&Te(this,ze,n1).call(this)}},Hr=new WeakMap,De=new WeakMap,xh=new WeakMap,Mr=new WeakMap,za=new WeakMap,Uc=new WeakMap,ji=new WeakMap,Ei=new WeakMap,wh=new WeakMap,Vc=new WeakMap,Wc=new WeakMap,Ba=new WeakMap,Ua=new WeakMap,_i=new WeakMap,Hc=new WeakMap,ze=new WeakSet,jh=function(e){Te(this,ze,i1).call(this);let r=R(this,De).fetch(this.options,e);return e!=null&&e.throwOnError||(r=r.catch(Cr)),r},e1=function(){Te(this,ze,s1).call(this);const e=Vo(this.options.staleTime,R(this,De));if(Zi||R(this,Mr).isStale||!xx(e))return;const n=_j(R(this,Mr).dataUpdatedAt,e)+1;ie(this,Ba,setTimeout(()=>{R(this,Mr).isStale||this.updateResult()},n))},t1=function(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(R(this,De)):this.options.refetchInterval)??!1},r1=function(e){Te(this,ze,o1).call(this),ie(this,_i,e),!(Zi||yn(this.options.enabled,R(this,De))===!1||!xx(R(this,_i))||R(this,_i)===0)&&ie(this,Ua,setInterval(()=>{(this.options.refetchIntervalInBackground||Nx.isFocused())&&Te(this,ze,jh).call(this)},R(this,_i)))},n1=function(){Te(this,ze,e1).call(this),Te(this,ze,r1).call(this,Te(this,ze,t1).call(this))},s1=function(){R(this,Ba)&&(clearTimeout(R(this,Ba)),ie(this,Ba,void 0))},o1=function(){R(this,Ua)&&(clearInterval(R(this,Ua)),ie(this,Ua,void 0))},i1=function(){const e=R(this,Hr).getQueryCache().build(R(this,Hr),this.options);if(e===R(this,De))return;const r=R(this,De);ie(this,De,e),ie(this,xh,e.state),this.hasListeners()&&(r==null||r.removeObserver(this),e.addObserver(this))},sD=function(e){Mt.batch(()=>{e.listeners&&this.listeners.forEach(r=>{r(R(this,Mr))}),R(this,Hr).getQueryCache().notify({query:R(this,De),type:"observerResultsUpdated"})})},tD);function Mz(t,e){return yn(e.enabled,t)!==!1&&t.state.data===void 0&&!(t.state.status==="error"&&e.retryOnMount===!1)}function Wj(t,e){return Mz(t,e)||t.state.data!==void 0&&Ex(t,e,e.refetchOnMount)}function Ex(t,e,r){if(yn(e.enabled,t)!==!1&&Vo(e.staleTime,t)!=="static"){const n=typeof r=="function"?r(t):r;return n==="always"||n!==!1&&_x(t,e)}return!1}function Hj(t,e,r,n){return(t!==e||yn(n.enabled,t)===!1)&&(!r.suspense||t.state.status!=="error")&&_x(t,r)}function _x(t,e){return yn(e.enabled,t)!==!1&&t.isStaleByTime(Vo(e.staleTime,t))}function Oz(t,e){return!ap(t.getCurrentResult(),e)}var Pz=(rD=class extends Il{constructor(r,n){super();ge(this,po);ge(this,Ti);ge(this,Ri);ge(this,qr);ge(this,fo);ie(this,Ti,r),this.setOptions(n),this.bindMethods(),Te(this,po,vg).call(this)}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(r){var s;const n=this.options;this.options=R(this,Ti).defaultMutationOptions(r),ap(this.options,n)||R(this,Ti).getMutationCache().notify({type:"observerOptionsUpdated",mutation:R(this,qr),observer:this}),n!=null&&n.mutationKey&&this.options.mutationKey&&ea(n.mutationKey)!==ea(this.options.mutationKey)?this.reset():((s=R(this,qr))==null?void 0:s.state.status)==="pending"&&R(this,qr).setOptions(this.options)}onUnsubscribe(){var r;this.hasListeners()||(r=R(this,qr))==null||r.removeObserver(this)}onMutationUpdate(r){Te(this,po,vg).call(this),Te(this,po,a1).call(this,r)}getCurrentResult(){return R(this,Ri)}reset(){var r;(r=R(this,qr))==null||r.removeObserver(this),ie(this,qr,void 0),Te(this,po,vg).call(this),Te(this,po,a1).call(this)}mutate(r,n){var s;return ie(this,fo,n),(s=R(this,qr))==null||s.removeObserver(this),ie(this,qr,R(this,Ti).getMutationCache().build(R(this,Ti),this.options)),R(this,qr).addObserver(this),R(this,qr).execute(r)}},Ti=new WeakMap,Ri=new WeakMap,qr=new WeakMap,fo=new WeakMap,po=new WeakSet,vg=function(){var n;const r=((n=R(this,qr))==null?void 0:n.state)??Bj();ie(this,Ri,{...r,isPending:r.status==="pending",isSuccess:r.status==="success",isError:r.status==="error",isIdle:r.status==="idle",mutate:this.mutate,reset:this.reset})},a1=function(r){Mt.batch(()=>{var n,s,o,i,a,c,d,u;if(R(this,fo)&&this.hasListeners()){const h=R(this,Ri).variables,f=R(this,Ri).context;(r==null?void 0:r.type)==="success"?((s=(n=R(this,fo)).onSuccess)==null||s.call(n,r.data,h,f),(i=(o=R(this,fo)).onSettled)==null||i.call(o,r.data,null,h,f)):(r==null?void 0:r.type)==="error"&&((c=(a=R(this,fo)).onError)==null||c.call(a,r.error,h,f),(u=(d=R(this,fo)).onSettled)==null||u.call(d,void 0,r.error,h,f))}this.listeners.forEach(h=>{h(R(this,Ri))})})},rD),qj=m.createContext(void 0),Dl=t=>{const e=m.useContext(qj);if(!e)throw new Error("No QueryClient set, use QueryClientProvider to set one");return e},Az=({client:t,children:e})=>(m.useEffect(()=>(t.mount(),()=>{t.unmount()}),[t]),l.jsx(qj.Provider,{value:t,children:e})),Kj=m.createContext(!1),Iz=()=>m.useContext(Kj);Kj.Provider;function Dz(){let t=!1;return{clearReset:()=>{t=!1},reset:()=>{t=!0},isReset:()=>t}}var Lz=m.createContext(Dz()),$z=()=>m.useContext(Lz),Fz=(t,e)=>{(t.suspense||t.throwOnError||t.experimental_prefetchInRender)&&(e.isReset()||(t.retryOnMount=!1))},zz=t=>{m.useEffect(()=>{t.clearReset()},[t])},Bz=({result:t,errorResetBoundary:e,throwOnError:r,query:n,suspense:s})=>t.isError&&!e.isReset()&&!t.isFetching&&n&&(s&&t.data===void 0||Ij(r,[t.error,n])),Uz=t=>{if(t.suspense){const e=n=>n==="static"?n:Math.max(n??1e3,1e3),r=t.staleTime;t.staleTime=typeof r=="function"?(...n)=>e(r(...n)):e(r),typeof t.gcTime=="number"&&(t.gcTime=Math.max(t.gcTime,1e3))}},Vz=(t,e)=>t.isLoading&&t.isFetching&&!e,Wz=(t,e)=>(t==null?void 0:t.suspense)&&e.isPending,Gj=(t,e,r)=>e.fetchOptimistic(t).catch(()=>{r.clearReset()});function Hz(t,e,r){var h,f,p,g,v;const n=Iz(),s=$z(),o=Dl(),i=o.defaultQueryOptions(t);(f=(h=o.getDefaultOptions().queries)==null?void 0:h._experimental_beforeQuery)==null||f.call(h,i),i._optimisticResults=n?"isRestoring":"optimistic",Uz(i),Fz(i,s),zz(s);const a=!o.getQueryCache().get(i.queryHash),[c]=m.useState(()=>new e(o,i)),d=c.getOptimisticResult(i),u=!n&&t.subscribed!==!1;if(m.useSyncExternalStore(m.useCallback(y=>{const x=u?c.subscribe(Mt.batchCalls(y)):Cr;return c.updateResult(),x},[c,u]),()=>c.getCurrentResult(),()=>c.getCurrentResult()),m.useEffect(()=>{c.setOptions(i)},[i,c]),Wz(i,d))throw Gj(i,c,s);if(Bz({result:d,errorResetBoundary:s,throwOnError:i.throwOnError,query:o.getQueryCache().get(i.queryHash),suspense:i.suspense}))throw d.error;if((g=(p=o.getDefaultOptions().queries)==null?void 0:p._experimental_afterQuery)==null||g.call(p,i,d),i.experimental_prefetchInRender&&!Zi&&Vz(d,n)){const y=a?Gj(i,c,s):(v=o.getQueryCache().get(i.queryHash))==null?void 0:v.promise;y==null||y.catch(Cr).finally(()=>{c.updateResult()})}return i.notifyOnChangeProps?d:c.trackResult(d)}function xn(t,e){return Hz(t,Rz)}function ta(t,e){const r=Dl(),[n]=m.useState(()=>new Pz(r,t));m.useEffect(()=>{n.setOptions(t)},[n,t]);const s=m.useSyncExternalStore(m.useCallback(i=>n.subscribe(Mt.batchCalls(i)),[n]),()=>n.getCurrentResult(),()=>n.getCurrentResult()),o=m.useCallback((i,a)=>{n.mutate(i,a).catch(Cr)},[n]);if(s.error&&Ij(n.options.throwOnError,[s.error]))throw s.error;return{...s,mutate:o,mutateAsync:s.mutate}}/** * @remix-run/router v1.23.0 * * Copyright (c) Remix Software Inc. * * This source code is licensed under the MIT license found in the * LICENSE.md file in the root directory of this source tree. * * @license MIT */function Xd(){return Xd=Object.assign?Object.assign.bind():function(t){for(var e=1;e"u")throw new Error(e)}function Jj(t,e){if(!t){typeof console<"u"&&console.warn(e);try{throw new Error(e)}catch{}}}function Kz(){return Math.random().toString(36).substr(2,8)}function Qj(t,e){return{usr:t.state,key:t.key,idx:e}}function Tx(t,e,r,n){return r===void 0&&(r=null),Xd({pathname:typeof t=="string"?t:t.pathname,search:"",hash:""},typeof e=="string"?Ll(e):e,{state:r,key:e&&e.key||n||Kz()})}function dp(t){let{pathname:e="/",search:r="",hash:n=""}=t;return r&&r!=="?"&&(e+=r.charAt(0)==="?"?r:"?"+r),n&&n!=="#"&&(e+=n.charAt(0)==="#"?n:"#"+n),e}function Ll(t){let e={};if(t){let r=t.indexOf("#");r>=0&&(e.hash=t.substr(r),t=t.substr(0,r));let n=t.indexOf("?");n>=0&&(e.search=t.substr(n),t=t.substr(0,n)),t&&(e.pathname=t)}return e}function Gz(t,e,r,n){n===void 0&&(n={});let{window:s=document.defaultView,v5Compat:o=!1}=n,i=s.history,a=Wo.Pop,c=null,d=u();d==null&&(d=0,i.replaceState(Xd({},i.state,{idx:d}),""));function u(){return(i.state||{idx:null}).idx}function h(){a=Wo.Pop;let y=u(),x=y==null?null:y-d;d=y,c&&c({action:a,location:v.location,delta:x})}function f(y,x){a=Wo.Push;let w=Tx(v.location,y,x);d=u()+1;let b=Qj(w,d),k=v.createHref(w);try{i.pushState(b,"",k)}catch(S){if(S instanceof DOMException&&S.name==="DataCloneError")throw S;s.location.assign(k)}o&&c&&c({action:a,location:v.location,delta:1})}function p(y,x){a=Wo.Replace;let w=Tx(v.location,y,x);d=u();let b=Qj(w,d),k=v.createHref(w);i.replaceState(b,"",k),o&&c&&c({action:a,location:v.location,delta:0})}function g(y){let x=s.location.origin!=="null"?s.location.origin:s.location.href,w=typeof y=="string"?y:dp(y);return w=w.replace(/ $/,"%20"),lt(x,"No window.location.(origin|href) available to create URL for href: "+w),new URL(w,x)}let v={get action(){return a},get location(){return t(s,i)},listen(y){if(c)throw new Error("A history only accepts one active listener");return s.addEventListener(Yj,h),c=y,()=>{s.removeEventListener(Yj,h),c=null}},createHref(y){return e(s,y)},createURL:g,encodeLocation(y){let x=g(y);return{pathname:x.pathname,search:x.search,hash:x.hash}},push:f,replace:p,go(y){return i.go(y)}};return v}var Xj;(function(t){t.data="data",t.deferred="deferred",t.redirect="redirect",t.error="error"})(Xj||(Xj={}));function Yz(t,e,r){return r===void 0&&(r="/"),Jz(t,e,r,!1)}function Jz(t,e,r,n){let s=typeof e=="string"?Ll(e):e,o=$l(s.pathname||"/",r);if(o==null)return null;let i=Zj(t);Qz(i);let a=null;for(let c=0;a==null&&c{let c={relativePath:a===void 0?o.path||"":a,caseSensitive:o.caseSensitive===!0,childrenIndex:i,route:o};c.relativePath.startsWith("/")&&(lt(c.relativePath.startsWith(n),'Absolute route path "'+c.relativePath+'" nested under path '+('"'+n+'" is not valid. An absolute child route path ')+"must start with the combined path of all its parent routes."),c.relativePath=c.relativePath.slice(n.length));let d=Ho([n,c.relativePath]),u=r.concat(c);o.children&&o.children.length>0&&(lt(o.index!==!0,"Index routes must not have child routes. Please remove "+('all child routes from route path "'+d+'".')),Zj(o.children,e,u,d)),!(o.path==null&&!o.index)&&e.push({path:d,score:sB(d,o.index),routesMeta:u})};return t.forEach((o,i)=>{var a;if(o.path===""||!((a=o.path)!=null&&a.includes("?")))s(o,i);else for(let c of eE(o.path))s(o,i,c)}),e}function eE(t){let e=t.split("/");if(e.length===0)return[];let[r,...n]=e,s=r.endsWith("?"),o=r.replace(/\?$/,"");if(n.length===0)return s?[o,""]:[o];let i=eE(n.join("/")),a=[];return a.push(...i.map(c=>c===""?o:[o,c].join("/"))),s&&a.push(...i),a.map(c=>t.startsWith("/")&&c===""?"/":c)}function Qz(t){t.sort((e,r)=>e.score!==r.score?r.score-e.score:oB(e.routesMeta.map(n=>n.childrenIndex),r.routesMeta.map(n=>n.childrenIndex)))}const Xz=/^:[\w-]+$/,Zz=3,eB=2,tB=1,rB=10,nB=-2,tE=t=>t==="*";function sB(t,e){let r=t.split("/"),n=r.length;return r.some(tE)&&(n+=nB),e&&(n+=eB),r.filter(s=>!tE(s)).reduce((s,o)=>s+(Xz.test(o)?Zz:o===""?tB:rB),n)}function oB(t,e){return t.length===e.length&&t.slice(0,-1).every((n,s)=>n===e[s])?t[t.length-1]-e[e.length-1]:0}function iB(t,e,r){let{routesMeta:n}=t,s={},o="/",i=[];for(let a=0;a{let{paramName:f,isOptional:p}=u;if(f==="*"){let v=a[h]||"";i=o.slice(0,o.length-v.length).replace(/(.)\/+$/,"$1")}const g=a[h];return p&&!g?d[f]=void 0:d[f]=(g||"").replace(/%2F/g,"/"),d},{}),pathname:o,pathnameBase:i,pattern:t}}function aB(t,e,r){e===void 0&&(e=!1),r===void 0&&(r=!0),Jj(t==="*"||!t.endsWith("*")||t.endsWith("/*"),'Route path "'+t+'" will be treated as if it were '+('"'+t.replace(/\*$/,"/*")+'" because the `*` character must ')+"always follow a `/` in the pattern. To get rid of this warning, "+('please change the route path to "'+t.replace(/\*$/,"/*")+'".'));let n=[],s="^"+t.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\").replace(/\/:([\w-]+)(\?)?/g,(i,a,c)=>(n.push({paramName:a,isOptional:c!=null}),c?"/?([^\\/]+)?":"/([^\\/]+)"));return t.endsWith("*")?(n.push({paramName:"*"}),s+=t==="*"||t==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):r?s+="\\/*$":t!==""&&t!=="/"&&(s+="(?:(?=\\/|$))"),[new RegExp(s,e?void 0:"i"),n]}function lB(t){try{return t.split("/").map(e=>decodeURIComponent(e).replace(/\//g,"%2F")).join("/")}catch(e){return Jj(!1,'The URL path "'+t+'" could not be decoded because it is is a malformed URL segment. This is probably due to a bad percent '+("encoding ("+e+").")),t}}function $l(t,e){if(e==="/")return t;if(!t.toLowerCase().startsWith(e.toLowerCase()))return null;let r=e.endsWith("/")?e.length-1:e.length,n=t.charAt(r);return n&&n!=="/"?null:t.slice(r)||"/"}function cB(t,e){e===void 0&&(e="/");let{pathname:r,search:n="",hash:s=""}=typeof t=="string"?Ll(t):t;return{pathname:r?r.startsWith("/")?r:dB(r,e):e,search:fB(n),hash:pB(s)}}function dB(t,e){let r=e.replace(/\/+$/,"").split("/");return t.split("/").forEach(s=>{s===".."?r.length>1&&r.pop():s!=="."&&r.push(s)}),r.length>1?r.join("/"):"/"}function Rx(t,e,r,n){return"Cannot include a '"+t+"' character in a manually specified "+("`to."+e+"` field ["+JSON.stringify(n)+"]. Please separate it out to the ")+("`to."+r+"` field. Alternatively you may provide the full path as ")+'a string in and the router will parse it for you.'}function uB(t){return t.filter((e,r)=>r===0||e.route.path&&e.route.path.length>0)}function rE(t,e){let r=uB(t);return e?r.map((n,s)=>s===r.length-1?n.pathname:n.pathnameBase):r.map(n=>n.pathnameBase)}function nE(t,e,r,n){n===void 0&&(n=!1);let s;typeof t=="string"?s=Ll(t):(s=Xd({},t),lt(!s.pathname||!s.pathname.includes("?"),Rx("?","pathname","search",s)),lt(!s.pathname||!s.pathname.includes("#"),Rx("#","pathname","hash",s)),lt(!s.search||!s.search.includes("#"),Rx("#","search","hash",s)));let o=t===""||s.pathname==="",i=o?"/":s.pathname,a;if(i==null)a=r;else{let h=e.length-1;if(!n&&i.startsWith("..")){let f=i.split("/");for(;f[0]==="..";)f.shift(),h-=1;s.pathname=f.join("/")}a=h>=0?e[h]:"/"}let c=cB(s,a),d=i&&i!=="/"&&i.endsWith("/"),u=(o||i===".")&&r.endsWith("/");return!c.pathname.endsWith("/")&&(d||u)&&(c.pathname+="/"),c}const Ho=t=>t.join("/").replace(/\/\/+/g,"/"),hB=t=>t.replace(/\/+$/,"").replace(/^\/*/,"/"),fB=t=>!t||t==="?"?"":t.startsWith("?")?t:"?"+t,pB=t=>!t||t==="#"?"":t.startsWith("#")?t:"#"+t;function mB(t){return t!=null&&typeof t.status=="number"&&typeof t.statusText=="string"&&typeof t.internal=="boolean"&&"data"in t}const sE=["post","put","patch","delete"];new Set(sE);const gB=["get",...sE];new Set(gB);/** * React Router v6.30.1 * * Copyright (c) Remix Software Inc. * * This source code is licensed under the MIT license found in the * LICENSE.md file in the root directory of this source tree. * * @license MIT */function Zd(){return Zd=Object.assign?Object.assign.bind():function(t){for(var e=1;e{a.current=!0}),m.useCallback(function(d,u){if(u===void 0&&(u={}),!a.current)return;if(typeof d=="number"){n.go(d);return}let h=nE(d,JSON.parse(i),o,u.relative==="path");t==null&&e!=="/"&&(h.pathname=h.pathname==="/"?e:Ho([e,h.pathname])),(u.replace?n.replace:n.push)(h,u.state,u)},[e,n,i,o,t])}const xB=m.createContext(null);function wB(t){let e=m.useContext(Xs).outlet;return e&&m.createElement(xB.Provider,{value:t},e)}function lE(){let{matches:t}=m.useContext(Xs),e=t[t.length-1];return e?e.params:{}}function pp(t,e){let{relative:r}=e===void 0?{}:e,{future:n}=m.useContext(qo),{matches:s}=m.useContext(Xs),{pathname:o}=ra(),i=JSON.stringify(rE(s,n.v7_relativeSplatPath));return m.useMemo(()=>nE(t,JSON.parse(i),o,r==="path"),[t,i,o,r])}function bB(t,e){return kB(t,e)}function kB(t,e,r,n){eu()||lt(!1);let{navigator:s}=m.useContext(qo),{matches:o}=m.useContext(Xs),i=o[o.length-1],a=i?i.params:{};i&&i.pathname;let c=i?i.pathnameBase:"/";i&&i.route;let d=ra(),u;if(e){var h;let y=typeof e=="string"?Ll(e):e;c==="/"||(h=y.pathname)!=null&&h.startsWith(c)||lt(!1),u=y}else u=d;let f=u.pathname||"/",p=f;if(c!=="/"){let y=c.replace(/^\//,"").split("/");p="/"+f.replace(/^\//,"").split("/").slice(y.length).join("/")}let g=Yz(t,{pathname:p}),v=EB(g&&g.map(y=>Object.assign({},y,{params:Object.assign({},a,y.params),pathname:Ho([c,s.encodeLocation?s.encodeLocation(y.pathname).pathname:y.pathname]),pathnameBase:y.pathnameBase==="/"?c:Ho([c,s.encodeLocation?s.encodeLocation(y.pathnameBase).pathname:y.pathnameBase])})),o,r,n);return e&&v?m.createElement(fp.Provider,{value:{location:Zd({pathname:"/",search:"",hash:"",state:null,key:"default"},u),navigationType:Wo.Pop}},v):v}function SB(){let t=MB(),e=mB(t)?t.status+" "+t.statusText:t instanceof Error?t.message:JSON.stringify(t),r=t instanceof Error?t.stack:null,s={padding:"0.5rem",backgroundColor:"rgba(200,200,200, 0.5)"};return m.createElement(m.Fragment,null,m.createElement("h2",null,"Unexpected Application Error!"),m.createElement("h3",{style:{fontStyle:"italic"}},e),r?m.createElement("pre",{style:s},r):null,null)}const NB=m.createElement(SB,null);class CB extends m.Component{constructor(e){super(e),this.state={location:e.location,revalidation:e.revalidation,error:e.error}}static getDerivedStateFromError(e){return{error:e}}static getDerivedStateFromProps(e,r){return r.location!==e.location||r.revalidation!=="idle"&&e.revalidation==="idle"?{error:e.error,location:e.location,revalidation:e.revalidation}:{error:e.error!==void 0?e.error:r.error,location:r.location,revalidation:e.revalidation||r.revalidation}}componentDidCatch(e,r){console.error("React Router caught the following error during render",e,r)}render(){return this.state.error!==void 0?m.createElement(Xs.Provider,{value:this.props.routeContext},m.createElement(iE.Provider,{value:this.state.error,children:this.props.component})):this.props.children}}function jB(t){let{routeContext:e,match:r,children:n}=t,s=m.useContext(hp);return s&&s.static&&s.staticContext&&(r.route.errorElement||r.route.ErrorBoundary)&&(s.staticContext._deepestRenderedBoundaryId=r.route.id),m.createElement(Xs.Provider,{value:e},n)}function EB(t,e,r,n){var s;if(e===void 0&&(e=[]),r===void 0&&(r=null),n===void 0&&(n=null),t==null){var o;if(!r)return null;if(r.errors)t=r.matches;else if((o=n)!=null&&o.v7_partialHydration&&e.length===0&&!r.initialized&&r.matches.length>0)t=r.matches;else return null}let i=t,a=(s=r)==null?void 0:s.errors;if(a!=null){let u=i.findIndex(h=>h.route.id&&(a==null?void 0:a[h.route.id])!==void 0);u>=0||lt(!1),i=i.slice(0,Math.min(i.length,u+1))}let c=!1,d=-1;if(r&&n&&n.v7_partialHydration)for(let u=0;u=0?i=i.slice(0,d+1):i=[i[0]];break}}}return i.reduceRight((u,h,f)=>{let p,g=!1,v=null,y=null;r&&(p=a&&h.route.id?a[h.route.id]:void 0,v=h.route.errorElement||NB,c&&(d<0&&f===0?(g=!0,y=null):d===f&&(g=!0,y=h.route.hydrateFallbackElement||null)));let x=e.concat(i.slice(0,f+1)),w=()=>{let b;return p?b=v:g?b=y:h.route.Component?b=m.createElement(h.route.Component,null):h.route.element?b=h.route.element:b=u,m.createElement(jB,{match:h,routeContext:{outlet:u,matches:x,isDataRoute:r!=null},children:b})};return r&&(h.route.ErrorBoundary||h.route.errorElement||f===0)?m.createElement(CB,{location:r.location,revalidation:r.revalidation,component:v,error:p,children:w(),routeContext:{outlet:null,matches:x,isDataRoute:!0}}):w()},null)}var cE=function(t){return t.UseBlocker="useBlocker",t.UseRevalidator="useRevalidator",t.UseNavigateStable="useNavigate",t}(cE||{}),mp=function(t){return t.UseBlocker="useBlocker",t.UseLoaderData="useLoaderData",t.UseActionData="useActionData",t.UseRouteError="useRouteError",t.UseNavigation="useNavigation",t.UseRouteLoaderData="useRouteLoaderData",t.UseMatches="useMatches",t.UseRevalidator="useRevalidator",t.UseNavigateStable="useNavigate",t.UseRouteId="useRouteId",t}(mp||{});function _B(t){let e=m.useContext(hp);return e||lt(!1),e}function TB(t){let e=m.useContext(oE);return e||lt(!1),e}function RB(t){let e=m.useContext(Xs);return e||lt(!1),e}function dE(t){let e=RB(),r=e.matches[e.matches.length-1];return r.route.id||lt(!1),r.route.id}function MB(){var t;let e=m.useContext(iE),r=TB(mp.UseRouteError),n=dE(mp.UseRouteError);return e!==void 0?e:(t=r.errors)==null?void 0:t[n]}function OB(){let{router:t}=_B(cE.UseNavigateStable),e=dE(mp.UseNavigateStable),r=m.useRef(!1);return aE(()=>{r.current=!0}),m.useCallback(function(s,o){o===void 0&&(o={}),r.current&&(typeof s=="number"?t.navigate(s):t.navigate(s,Zd({fromRouteId:e},o)))},[t,e])}function PB(t,e){t==null||t.v7_startTransition,t==null||t.v7_relativeSplatPath}function AB(t){return wB(t.context)}function zr(t){lt(!1)}function IB(t){let{basename:e="/",children:r=null,location:n,navigationType:s=Wo.Pop,navigator:o,static:i=!1,future:a}=t;eu()&<(!1);let c=e.replace(/^\/*/,"/"),d=m.useMemo(()=>({basename:c,navigator:o,static:i,future:Zd({v7_relativeSplatPath:!1},a)}),[c,a,o,i]);typeof n=="string"&&(n=Ll(n));let{pathname:u="/",search:h="",hash:f="",state:p=null,key:g="default"}=n,v=m.useMemo(()=>{let y=$l(u,c);return y==null?null:{location:{pathname:y,search:h,hash:f,state:p,key:g},navigationType:s}},[c,u,h,f,p,g,s]);return v==null?null:m.createElement(qo.Provider,{value:d},m.createElement(fp.Provider,{children:r,value:v}))}function DB(t){let{children:e,location:r}=t;return bB(Mx(e),r)}new Promise(()=>{});function Mx(t,e){e===void 0&&(e=[]);let r=[];return m.Children.forEach(t,(n,s)=>{if(!m.isValidElement(n))return;let o=[...e,s];if(n.type===m.Fragment){r.push.apply(r,Mx(n.props.children,o));return}n.type!==zr&<(!1),!n.props.index||!n.props.children||lt(!1);let i={id:n.props.id||o.join("-"),caseSensitive:n.props.caseSensitive,element:n.props.element,Component:n.props.Component,index:n.props.index,path:n.props.path,loader:n.props.loader,action:n.props.action,errorElement:n.props.errorElement,ErrorBoundary:n.props.ErrorBoundary,hasErrorBoundary:n.props.ErrorBoundary!=null||n.props.errorElement!=null,shouldRevalidate:n.props.shouldRevalidate,handle:n.props.handle,lazy:n.props.lazy};n.props.children&&(i.children=Mx(n.props.children,o)),r.push(i)}),r}/** * React Router DOM v6.30.1 * * Copyright (c) Remix Software Inc. * * This source code is licensed under the MIT license found in the * LICENSE.md file in the root directory of this source tree. * * @license MIT */function gp(){return gp=Object.assign?Object.assign.bind():function(t){for(var e=1;e=0)&&(r[s]=t[s]);return r}function LB(t){return!!(t.metaKey||t.altKey||t.ctrlKey||t.shiftKey)}function $B(t,e){return t.button===0&&(!e||e==="_self")&&!LB(t)}const FB=["onClick","relative","reloadDocument","replace","state","target","to","preventScrollReset","viewTransition"],zB=["aria-current","caseSensitive","className","end","style","to","viewTransition","children"],BB="6";try{window.__reactRouterVersion=BB}catch{}const UB=m.createContext({isTransitioning:!1}),hE=Sg["startTransition"];function VB(t){let{basename:e,children:r,future:n,window:s}=t,o=m.useRef();o.current==null&&(o.current=qz({window:s,v5Compat:!0}));let i=o.current,[a,c]=m.useState({action:i.action,location:i.location}),{v7_startTransition:d}=n||{},u=m.useCallback(h=>{d&&hE?hE(()=>c(h)):c(h)},[c,d]);return m.useLayoutEffect(()=>i.listen(u),[i,u]),m.useEffect(()=>PB(n),[n]),m.createElement(IB,{basename:e,children:r,location:a.location,navigationType:a.action,navigator:i,future:n})}const WB=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",HB=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,rn=m.forwardRef(function(e,r){let{onClick:n,relative:s,reloadDocument:o,replace:i,state:a,target:c,to:d,preventScrollReset:u,viewTransition:h}=e,f=uE(e,FB),{basename:p}=m.useContext(qo),g,v=!1;if(typeof d=="string"&&HB.test(d)&&(g=d,WB))try{let b=new URL(window.location.href),k=d.startsWith("//")?new URL(b.protocol+d):new URL(d),S=$l(k.pathname,p);k.origin===b.origin&&S!=null?d=S+k.search+k.hash:v=!0}catch{}let y=vB(d,{relative:s}),x=KB(d,{replace:i,state:a,target:c,preventScrollReset:u,relative:s,viewTransition:h});function w(b){n&&n(b),b.defaultPrevented||x(b)}return m.createElement("a",gp({},f,{href:g||y,onClick:v||o?n:w,ref:r,target:c}))}),Ox=m.forwardRef(function(e,r){let{"aria-current":n="page",caseSensitive:s=!1,className:o="",end:i=!1,style:a,to:c,viewTransition:d,children:u}=e,h=uE(e,zB),f=pp(c,{relative:h.relative}),p=ra(),g=m.useContext(oE),{navigator:v,basename:y}=m.useContext(qo),x=g!=null&&GB(f)&&d===!0,w=v.encodeLocation?v.encodeLocation(f).pathname:f.pathname,b=p.pathname,k=g&&g.navigation&&g.navigation.location?g.navigation.location.pathname:null;s||(b=b.toLowerCase(),k=k?k.toLowerCase():null,w=w.toLowerCase()),k&&y&&(k=$l(k,y)||k);const S=w!=="/"&&w.endsWith("/")?w.length-1:w.length;let C=b===w||!i&&b.startsWith(w)&&b.charAt(S)==="/",N=k!=null&&(k===w||!i&&k.startsWith(w)&&k.charAt(w.length)==="/"),E={isActive:C,isPending:N,isTransitioning:x},j=C?n:void 0,_;typeof o=="function"?_=o(E):_=[o,C?"active":null,N?"pending":null,x?"transitioning":null].filter(Boolean).join(" ");let P=typeof a=="function"?a(E):a;return m.createElement(rn,gp({},h,{"aria-current":j,className:_,ref:r,style:P,to:c,viewTransition:d}),typeof u=="function"?u(E):u)});var Px;(function(t){t.UseScrollRestoration="useScrollRestoration",t.UseSubmit="useSubmit",t.UseSubmitFetcher="useSubmitFetcher",t.UseFetcher="useFetcher",t.useViewTransitionState="useViewTransitionState"})(Px||(Px={}));var fE;(function(t){t.UseFetcher="useFetcher",t.UseFetchers="useFetchers",t.UseScrollRestoration="useScrollRestoration"})(fE||(fE={}));function qB(t){let e=m.useContext(hp);return e||lt(!1),e}function KB(t,e){let{target:r,replace:n,state:s,preventScrollReset:o,relative:i,viewTransition:a}=e===void 0?{}:e,c=Zs(),d=ra(),u=pp(t,{relative:i});return m.useCallback(h=>{if($B(h,r)){h.preventDefault();let f=n!==void 0?n:dp(d)===dp(u);c(t,{replace:f,state:s,preventScrollReset:o,relative:i,viewTransition:a})}},[d,c,u,n,s,r,t,o,i,a])}function GB(t,e){e===void 0&&(e={});let r=m.useContext(UB);r==null&<(!1);let{basename:n}=qB(Px.useViewTransitionState),s=pp(t,{relative:e.relative});if(!r.isTransitioning)return!1;let o=$l(r.currentLocation.pathname,n)||r.currentLocation.pathname,i=$l(r.nextLocation.pathname,n)||r.nextLocation.pathname;return up(s.pathname,i)!=null||up(s.pathname,o)!=null}const YB=Sl("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-lg text-sm font-medium ring-offset-background transition-all duration-200 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0 touch-manipulation",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/90 shadow-sm hover:shadow-md",destructive:"bg-destructive text-destructive-foreground hover:bg-destructive/90 shadow-sm",outline:"border border-border bg-transparent hover:bg-secondary hover:border-primary/30 text-foreground",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",ghost:"hover:bg-secondary hover:text-foreground text-muted-foreground",link:"text-primary underline-offset-4 hover:underline",glow:"bg-primary text-primary-foreground hover:bg-primary/90 shadow-[0_4px_14px_-2px_hsl(var(--primary)/0.4)] hover:shadow-[0_6px_20px_-4px_hsl(var(--primary)/0.5)] transition-shadow",recording:"bg-destructive text-destructive-foreground hover:bg-destructive/90 animate-pulse",success:"bg-success text-primary-foreground hover:opacity-90 shadow-sm",calendar:"bg-accent text-accent-foreground hover:bg-accent/80",nav:"text-muted-foreground hover:text-foreground hover:bg-secondary/50 justify-start","nav-active":"text-primary bg-primary/10 hover:bg-primary/15 justify-start font-medium"},size:{default:"h-10 px-4 py-2",sm:"h-9 rounded-md px-3",lg:"h-11 rounded-lg px-8",xl:"h-12 rounded-lg px-10 text-base",icon:"h-10 w-10","icon-sm":"h-8 w-8","icon-lg":"h-12 w-12"}},defaultVariants:{variant:"default",size:"default"}}),K=m.forwardRef(({className:t,variant:e,size:r,asChild:n=!1,...s},o)=>{const i=n?z4:"button";return l.jsx(i,{className:B(YB({variant:e,size:r,className:t})),ref:o,...s})});K.displayName="Button";const JB=Sl("inline-flex items-center rounded-full border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground hover:bg-primary/80",secondary:"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",destructive:"border-transparent bg-destructive text-destructive-foreground hover:bg-destructive/80",outline:"text-foreground border-border",success:"border-success/30 bg-success/20 text-success",warning:"border-warning/30 bg-warning/20 text-warning",info:"border-info/30 bg-info/20 text-info",class:"border text-foreground"}},defaultVariants:{variant:"default"}});function ue({className:t,variant:e,...r}){return l.jsx("div",{className:B(JB({variant:e}),t),...r})}function tu(t){const e=m.useRef({value:t,previous:t});return m.useMemo(()=>(e.current.value!==t&&(e.current.previous=e.current.value,e.current.value=t),e.current.previous),[t])}var vp="Switch",[QB,bre]=Ft(vp),[XB,ZB]=QB(vp),pE=m.forwardRef((t,e)=>{const{__scopeSwitch:r,name:n,checked:s,defaultChecked:o,required:i,disabled:a,value:c="on",onCheckedChange:d,form:u,...h}=t,[f,p]=m.useState(null),g=we(e,b=>p(b)),v=m.useRef(!1),y=f?u||!!f.closest("form"):!0,[x,w]=Wn({prop:s,defaultProp:o??!1,onChange:d,caller:vp});return l.jsxs(XB,{scope:r,checked:x,disabled:a,children:[l.jsx(se.button,{type:"button",role:"switch","aria-checked":x,"aria-required":i,"data-state":yE(x),"data-disabled":a?"":void 0,disabled:a,value:c,...h,ref:g,onClick:Q(t.onClick,b=>{w(k=>!k),y&&(v.current=b.isPropagationStopped(),v.current||b.stopPropagation())})}),y&&l.jsx(vE,{control:f,bubbles:!v.current,name:n,value:c,checked:x,required:i,disabled:a,form:u,style:{transform:"translateX(-100%)"}})]})});pE.displayName=vp;var mE="SwitchThumb",gE=m.forwardRef((t,e)=>{const{__scopeSwitch:r,...n}=t,s=ZB(mE,r);return l.jsx(se.span,{"data-state":yE(s.checked),"data-disabled":s.disabled?"":void 0,...n,ref:e})});gE.displayName=mE;var e6="SwitchBubbleInput",vE=m.forwardRef(({__scopeSwitch:t,control:e,checked:r,bubbles:n=!0,...s},o)=>{const i=m.useRef(null),a=we(i,o),c=tu(r),d=Jd(e);return m.useEffect(()=>{const u=i.current;if(!u)return;const h=window.HTMLInputElement.prototype,p=Object.getOwnPropertyDescriptor(h,"checked").set;if(c!==r&&p){const g=new Event("click",{bubbles:n});p.call(u,r),u.dispatchEvent(g)}},[c,r,n]),l.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:r,...s,tabIndex:-1,ref:a,style:{...s.style,...d,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});vE.displayName=e6;function yE(t){return t?"checked":"unchecked"}var xE=pE,t6=gE;const Ko=m.forwardRef(({className:t,...e},r)=>l.jsx(xE,{className:B("peer inline-flex h-6 w-11 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors data-[state=checked]:bg-primary data-[state=unchecked]:bg-input focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50",t),...e,ref:r,children:l.jsx(t6,{className:B("pointer-events-none block h-5 w-5 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-5 data-[state=unchecked]:translate-x-0")})}));Ko.displayName=xE.displayName;var Ax="focusScope.autoFocusOnMount",Ix="focusScope.autoFocusOnUnmount",wE={bubbles:!1,cancelable:!0},r6="FocusScope",yp=m.forwardRef((t,e)=>{const{loop:r=!1,trapped:n=!1,onMountAutoFocus:s,onUnmountAutoFocus:o,...i}=t,[a,c]=m.useState(null),d=at(s),u=at(o),h=m.useRef(null),f=we(e,v=>c(v)),p=m.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;m.useEffect(()=>{if(n){let v=function(b){if(p.paused||!a)return;const k=b.target;a.contains(k)?h.current=k:Go(h.current,{select:!0})},y=function(b){if(p.paused||!a)return;const k=b.relatedTarget;k!==null&&(a.contains(k)||Go(h.current,{select:!0}))},x=function(b){if(document.activeElement===document.body)for(const S of b)S.removedNodes.length>0&&Go(a)};document.addEventListener("focusin",v),document.addEventListener("focusout",y);const w=new MutationObserver(x);return a&&w.observe(a,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",v),document.removeEventListener("focusout",y),w.disconnect()}}},[n,a,p.paused]),m.useEffect(()=>{if(a){SE.add(p);const v=document.activeElement;if(!a.contains(v)){const x=new CustomEvent(Ax,wE);a.addEventListener(Ax,d),a.dispatchEvent(x),x.defaultPrevented||(n6(l6(bE(a)),{select:!0}),document.activeElement===v&&Go(a))}return()=>{a.removeEventListener(Ax,d),setTimeout(()=>{const x=new CustomEvent(Ix,wE);a.addEventListener(Ix,u),a.dispatchEvent(x),x.defaultPrevented||Go(v??document.body,{select:!0}),a.removeEventListener(Ix,u),SE.remove(p)},0)}}},[a,d,u,p]);const g=m.useCallback(v=>{if(!r&&!n||p.paused)return;const y=v.key==="Tab"&&!v.altKey&&!v.ctrlKey&&!v.metaKey,x=document.activeElement;if(y&&x){const w=v.currentTarget,[b,k]=s6(w);b&&k?!v.shiftKey&&x===k?(v.preventDefault(),r&&Go(b,{select:!0})):v.shiftKey&&x===b&&(v.preventDefault(),r&&Go(k,{select:!0})):x===w&&v.preventDefault()}},[r,n,p.paused]);return l.jsx(se.div,{tabIndex:-1,...i,ref:f,onKeyDown:g})});yp.displayName=r6;function n6(t,{select:e=!1}={}){const r=document.activeElement;for(const n of t)if(Go(n,{select:e}),document.activeElement!==r)return}function s6(t){const e=bE(t),r=kE(e,t),n=kE(e.reverse(),t);return[r,n]}function bE(t){const e=[],r=document.createTreeWalker(t,NodeFilter.SHOW_ELEMENT,{acceptNode:n=>{const s=n.tagName==="INPUT"&&n.type==="hidden";return n.disabled||n.hidden||s?NodeFilter.FILTER_SKIP:n.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;r.nextNode();)e.push(r.currentNode);return e}function kE(t,e){for(const r of t)if(!o6(r,{upTo:e}))return r}function o6(t,{upTo:e}){if(getComputedStyle(t).visibility==="hidden")return!0;for(;t;){if(e!==void 0&&t===e)return!1;if(getComputedStyle(t).display==="none")return!0;t=t.parentElement}return!1}function i6(t){return t instanceof HTMLInputElement&&"select"in t}function Go(t,{select:e=!1}={}){if(t&&t.focus){const r=document.activeElement;t.focus({preventScroll:!0}),t!==r&&i6(t)&&e&&t.select()}}var SE=a6();function a6(){let t=[];return{add(e){const r=t[0];e!==r&&(r==null||r.pause()),t=NE(t,e),t.unshift(e)},remove(e){var r;t=NE(t,e),(r=t[0])==null||r.resume()}}}function NE(t,e){const r=[...t],n=r.indexOf(e);return n!==-1&&r.splice(n,1),r}function l6(t){return t.filter(e=>e.tagName!=="A")}var Dx=0;function Lx(){m.useEffect(()=>{const t=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",t[0]??CE()),document.body.insertAdjacentElement("beforeend",t[1]??CE()),Dx++,()=>{Dx===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(e=>e.remove()),Dx--}},[])}function CE(){const t=document.createElement("span");return t.setAttribute("data-radix-focus-guard",""),t.tabIndex=0,t.style.outline="none",t.style.opacity="0",t.style.position="fixed",t.style.pointerEvents="none",t}var bs=function(){return bs=Object.assign||function(e){for(var r,n=1,s=arguments.length;n"u")return j6;var e=E6(t),r=document.documentElement.clientWidth,n=window.innerWidth;return{left:e[0],top:e[1],right:e[2],gap:Math.max(0,n-r+e[2]-e[0])}},T6=TE(),zl="data-scroll-locked",R6=function(t,e,r,n){var s=t.left,o=t.top,i=t.right,a=t.gap;return r===void 0&&(r="margin"),` .`.concat(u6,` { overflow: hidden `).concat(n,`; padding-right: `).concat(a,"px ").concat(n,`; } body[`).concat(zl,`] { overflow: hidden `).concat(n,`; overscroll-behavior: contain; `).concat([e&&"position: relative ".concat(n,";"),r==="margin"&&` padding-left: `.concat(s,`px; padding-top: `).concat(o,`px; padding-right: `).concat(i,`px; margin-left:0; margin-top:0; margin-right: `).concat(a,"px ").concat(n,`; `),r==="padding"&&"padding-right: ".concat(a,"px ").concat(n,";")].filter(Boolean).join(""),` } .`).concat(xp,` { right: `).concat(a,"px ").concat(n,`; } .`).concat(wp,` { margin-right: `).concat(a,"px ").concat(n,`; } .`).concat(xp," .").concat(xp,` { right: 0 `).concat(n,`; } .`).concat(wp," .").concat(wp,` { margin-right: 0 `).concat(n,`; } body[`).concat(zl,`] { `).concat(h6,": ").concat(a,`px; } `)},RE=function(){var t=parseInt(document.body.getAttribute(zl)||"0",10);return isFinite(t)?t:0},M6=function(){m.useEffect(function(){return document.body.setAttribute(zl,(RE()+1).toString()),function(){var t=RE()-1;t<=0?document.body.removeAttribute(zl):document.body.setAttribute(zl,t.toString())}},[])},O6=function(t){var e=t.noRelative,r=t.noImportant,n=t.gapMode,s=n===void 0?"margin":n;M6();var o=m.useMemo(function(){return _6(s)},[s]);return m.createElement(T6,{styles:R6(o,!e,s,r?"":"!important")})},Bx=!1;if(typeof window<"u")try{var kp=Object.defineProperty({},"passive",{get:function(){return Bx=!0,!0}});window.addEventListener("test",kp,kp),window.removeEventListener("test",kp,kp)}catch{Bx=!1}var Bl=Bx?{passive:!1}:!1,P6=function(t){return t.tagName==="TEXTAREA"},ME=function(t,e){if(!(t instanceof Element))return!1;var r=window.getComputedStyle(t);return r[e]!=="hidden"&&!(r.overflowY===r.overflowX&&!P6(t)&&r[e]==="visible")},A6=function(t){return ME(t,"overflowY")},I6=function(t){return ME(t,"overflowX")},OE=function(t,e){var r=e.ownerDocument,n=e;do{typeof ShadowRoot<"u"&&n instanceof ShadowRoot&&(n=n.host);var s=PE(t,n);if(s){var o=AE(t,n),i=o[1],a=o[2];if(i>a)return!0}n=n.parentNode}while(n&&n!==r.body);return!1},D6=function(t){var e=t.scrollTop,r=t.scrollHeight,n=t.clientHeight;return[e,r,n]},L6=function(t){var e=t.scrollLeft,r=t.scrollWidth,n=t.clientWidth;return[e,r,n]},PE=function(t,e){return t==="v"?A6(e):I6(e)},AE=function(t,e){return t==="v"?D6(e):L6(e)},$6=function(t,e){return t==="h"&&e==="rtl"?-1:1},F6=function(t,e,r,n,s){var o=$6(t,window.getComputedStyle(e).direction),i=o*n,a=r.target,c=e.contains(a),d=!1,u=i>0,h=0,f=0;do{if(!a)break;var p=AE(t,a),g=p[0],v=p[1],y=p[2],x=v-y-o*g;(g||x)&&PE(t,a)&&(h+=x,f+=g);var w=a.parentNode;a=w&&w.nodeType===Node.DOCUMENT_FRAGMENT_NODE?w.host:w}while(!c&&a!==document.body||c&&(e.contains(a)||e===a));return(u&&(Math.abs(h)<1||!s)||!u&&(Math.abs(f)<1||!s))&&(d=!0),d},Sp=function(t){return"changedTouches"in t?[t.changedTouches[0].clientX,t.changedTouches[0].clientY]:[0,0]},IE=function(t){return[t.deltaX,t.deltaY]},DE=function(t){return t&&"current"in t?t.current:t},z6=function(t,e){return t[0]===e[0]&&t[1]===e[1]},B6=function(t){return` .block-interactivity-`.concat(t,` {pointer-events: none;} .allow-interactivity-`).concat(t,` {pointer-events: all;} `)},U6=0,Ul=[];function V6(t){var e=m.useRef([]),r=m.useRef([0,0]),n=m.useRef(),s=m.useState(U6++)[0],o=m.useState(TE)[0],i=m.useRef(t);m.useEffect(function(){i.current=t},[t]),m.useEffect(function(){if(t.inert){document.body.classList.add("block-interactivity-".concat(s));var v=d6([t.lockRef.current],(t.shards||[]).map(DE),!0).filter(Boolean);return v.forEach(function(y){return y.classList.add("allow-interactivity-".concat(s))}),function(){document.body.classList.remove("block-interactivity-".concat(s)),v.forEach(function(y){return y.classList.remove("allow-interactivity-".concat(s))})}}},[t.inert,t.lockRef.current,t.shards]);var a=m.useCallback(function(v,y){if("touches"in v&&v.touches.length===2||v.type==="wheel"&&v.ctrlKey)return!i.current.allowPinchZoom;var x=Sp(v),w=r.current,b="deltaX"in v?v.deltaX:w[0]-x[0],k="deltaY"in v?v.deltaY:w[1]-x[1],S,C=v.target,N=Math.abs(b)>Math.abs(k)?"h":"v";if("touches"in v&&N==="h"&&C.type==="range")return!1;var E=OE(N,C);if(!E)return!0;if(E?S=N:(S=N==="v"?"h":"v",E=OE(N,C)),!E)return!1;if(!n.current&&"changedTouches"in v&&(b||k)&&(n.current=S),!S)return!0;var j=n.current||S;return F6(j,y,v,j==="h"?b:k,!0)},[]),c=m.useCallback(function(v){var y=v;if(!(!Ul.length||Ul[Ul.length-1]!==o)){var x="deltaY"in y?IE(y):Sp(y),w=e.current.filter(function(S){return S.name===y.type&&(S.target===y.target||y.target===S.shadowParent)&&z6(S.delta,x)})[0];if(w&&w.should){y.cancelable&&y.preventDefault();return}if(!w){var b=(i.current.shards||[]).map(DE).filter(Boolean).filter(function(S){return S.contains(y.target)}),k=b.length>0?a(y,b[0]):!i.current.noIsolation;k&&y.cancelable&&y.preventDefault()}}},[]),d=m.useCallback(function(v,y,x,w){var b={name:v,delta:y,target:x,should:w,shadowParent:W6(x)};e.current.push(b),setTimeout(function(){e.current=e.current.filter(function(k){return k!==b})},1)},[]),u=m.useCallback(function(v){r.current=Sp(v),n.current=void 0},[]),h=m.useCallback(function(v){d(v.type,IE(v),v.target,a(v,t.lockRef.current))},[]),f=m.useCallback(function(v){d(v.type,Sp(v),v.target,a(v,t.lockRef.current))},[]);m.useEffect(function(){return Ul.push(o),t.setCallbacks({onScrollCapture:h,onWheelCapture:h,onTouchMoveCapture:f}),document.addEventListener("wheel",c,Bl),document.addEventListener("touchmove",c,Bl),document.addEventListener("touchstart",u,Bl),function(){Ul=Ul.filter(function(v){return v!==o}),document.removeEventListener("wheel",c,Bl),document.removeEventListener("touchmove",c,Bl),document.removeEventListener("touchstart",u,Bl)}},[]);var p=t.removeScrollBar,g=t.inert;return m.createElement(m.Fragment,null,g?m.createElement(o,{styles:B6(s)}):null,p?m.createElement(O6,{noRelative:t.noRelative,gapMode:t.gapMode}):null)}function W6(t){for(var e=null;t!==null;)t instanceof ShadowRoot&&(e=t.host,t=t.host),t=t.parentNode;return e}const H6=x6(_E,V6);var Np=m.forwardRef(function(t,e){return m.createElement(bp,bs({},t,{ref:e,sideCar:H6}))});Np.classNames=bp.classNames;var q6=function(t){if(typeof document>"u")return null;var e=Array.isArray(t)?t[0]:t;return e.ownerDocument.body},Vl=new WeakMap,Cp=new WeakMap,jp={},Ux=0,LE=function(t){return t&&(t.host||LE(t.parentNode))},K6=function(t,e){return e.map(function(r){if(t.contains(r))return r;var n=LE(r);return n&&t.contains(n)?n:(console.error("aria-hidden",r,"in not contained inside",t,". Doing nothing"),null)}).filter(function(r){return!!r})},G6=function(t,e,r,n){var s=K6(e,Array.isArray(t)?t:[t]);jp[r]||(jp[r]=new WeakMap);var o=jp[r],i=[],a=new Set,c=new Set(s),d=function(h){!h||a.has(h)||(a.add(h),d(h.parentNode))};s.forEach(d);var u=function(h){!h||c.has(h)||Array.prototype.forEach.call(h.children,function(f){if(a.has(f))u(f);else try{var p=f.getAttribute(n),g=p!==null&&p!=="false",v=(Vl.get(f)||0)+1,y=(o.get(f)||0)+1;Vl.set(f,v),o.set(f,y),i.push(f),v===1&&g&&Cp.set(f,!0),y===1&&f.setAttribute(r,"true"),g||f.setAttribute(n,"true")}catch(x){console.error("aria-hidden: cannot operate on ",f,x)}})};return u(e),a.clear(),Ux++,function(){i.forEach(function(h){var f=Vl.get(h)-1,p=o.get(h)-1;Vl.set(h,f),o.set(h,p),f||(Cp.has(h)||h.removeAttribute(n),Cp.delete(h)),p||h.removeAttribute(r)}),Ux--,Ux||(Vl=new WeakMap,Vl=new WeakMap,Cp=new WeakMap,jp={})}},Vx=function(t,e,r){r===void 0&&(r="data-aria-hidden");var n=Array.from(Array.isArray(t)?t:[t]),s=q6(t);return s?(n.push.apply(n,Array.from(s.querySelectorAll("[aria-live]"))),G6(n,s,r,"aria-hidden")):function(){return null}},Ep="Dialog",[$E,kre]=Ft(Ep),[Y6,Gn]=$E(Ep),FE=t=>{const{__scopeDialog:e,children:r,open:n,defaultOpen:s,onOpenChange:o,modal:i=!0}=t,a=m.useRef(null),c=m.useRef(null),[d,u]=Wn({prop:n,defaultProp:s??!1,onChange:o,caller:Ep});return l.jsx(Y6,{scope:e,triggerRef:a,contentRef:c,contentId:hr(),titleId:hr(),descriptionId:hr(),open:d,onOpenChange:u,onOpenToggle:m.useCallback(()=>u(h=>!h),[u]),modal:i,children:r})};FE.displayName=Ep;var zE="DialogTrigger",BE=m.forwardRef((t,e)=>{const{__scopeDialog:r,...n}=t,s=Gn(zE,r),o=we(e,s.triggerRef);return l.jsx(se.button,{type:"button","aria-haspopup":"dialog","aria-expanded":s.open,"aria-controls":s.contentId,"data-state":qx(s.open),...n,ref:o,onClick:Q(t.onClick,s.onOpenToggle)})});BE.displayName=zE;var Wx="DialogPortal",[J6,UE]=$E(Wx,{forceMount:void 0}),VE=t=>{const{__scopeDialog:e,forceMount:r,children:n,container:s}=t,o=Gn(Wx,e);return l.jsx(J6,{scope:e,forceMount:r,children:m.Children.map(n,i=>l.jsx(er,{present:r||o.open,children:l.jsx($d,{asChild:!0,container:s,children:i})}))})};VE.displayName=Wx;var _p="DialogOverlay",WE=m.forwardRef((t,e)=>{const r=UE(_p,t.__scopeDialog),{forceMount:n=r.forceMount,...s}=t,o=Gn(_p,t.__scopeDialog);return o.modal?l.jsx(er,{present:n||o.open,children:l.jsx(X6,{...s,ref:e})}):null});WE.displayName=_p;var Q6=Ji("DialogOverlay.RemoveScroll"),X6=m.forwardRef((t,e)=>{const{__scopeDialog:r,...n}=t,s=Gn(_p,r);return l.jsx(Np,{as:Q6,allowPinchZoom:!0,shards:[s.contentRef],children:l.jsx(se.div,{"data-state":qx(s.open),...n,ref:e,style:{pointerEvents:"auto",...n.style}})})}),na="DialogContent",HE=m.forwardRef((t,e)=>{const r=UE(na,t.__scopeDialog),{forceMount:n=r.forceMount,...s}=t,o=Gn(na,t.__scopeDialog);return l.jsx(er,{present:n||o.open,children:o.modal?l.jsx(Z6,{...s,ref:e}):l.jsx(eU,{...s,ref:e})})});HE.displayName=na;var Z6=m.forwardRef((t,e)=>{const r=Gn(na,t.__scopeDialog),n=m.useRef(null),s=we(e,r.contentRef,n);return m.useEffect(()=>{const o=n.current;if(o)return Vx(o)},[]),l.jsx(qE,{...t,ref:s,trapFocus:r.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Q(t.onCloseAutoFocus,o=>{var i;o.preventDefault(),(i=r.triggerRef.current)==null||i.focus()}),onPointerDownOutside:Q(t.onPointerDownOutside,o=>{const i=o.detail.originalEvent,a=i.button===0&&i.ctrlKey===!0;(i.button===2||a)&&o.preventDefault()}),onFocusOutside:Q(t.onFocusOutside,o=>o.preventDefault())})}),eU=m.forwardRef((t,e)=>{const r=Gn(na,t.__scopeDialog),n=m.useRef(!1),s=m.useRef(!1);return l.jsx(qE,{...t,ref:e,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:o=>{var i,a;(i=t.onCloseAutoFocus)==null||i.call(t,o),o.defaultPrevented||(n.current||(a=r.triggerRef.current)==null||a.focus(),o.preventDefault()),n.current=!1,s.current=!1},onInteractOutside:o=>{var c,d;(c=t.onInteractOutside)==null||c.call(t,o),o.defaultPrevented||(n.current=!0,o.detail.originalEvent.type==="pointerdown"&&(s.current=!0));const i=o.target;((d=r.triggerRef.current)==null?void 0:d.contains(i))&&o.preventDefault(),o.detail.originalEvent.type==="focusin"&&s.current&&o.preventDefault()}})}),qE=m.forwardRef((t,e)=>{const{__scopeDialog:r,trapFocus:n,onOpenAutoFocus:s,onCloseAutoFocus:o,...i}=t,a=Gn(na,r),c=m.useRef(null),d=we(e,c);return Lx(),l.jsxs(l.Fragment,{children:[l.jsx(yp,{asChild:!0,loop:!0,trapped:n,onMountAutoFocus:s,onUnmountAutoFocus:o,children:l.jsx(kl,{role:"dialog",id:a.contentId,"aria-describedby":a.descriptionId,"aria-labelledby":a.titleId,"data-state":qx(a.open),...i,ref:d,onDismiss:()=>a.onOpenChange(!1)})}),l.jsxs(l.Fragment,{children:[l.jsx(tU,{titleId:a.titleId}),l.jsx(nU,{contentRef:c,descriptionId:a.descriptionId})]})]})}),Hx="DialogTitle",KE=m.forwardRef((t,e)=>{const{__scopeDialog:r,...n}=t,s=Gn(Hx,r);return l.jsx(se.h2,{id:s.titleId,...n,ref:e})});KE.displayName=Hx;var GE="DialogDescription",YE=m.forwardRef((t,e)=>{const{__scopeDialog:r,...n}=t,s=Gn(GE,r);return l.jsx(se.p,{id:s.descriptionId,...n,ref:e})});YE.displayName=GE;var JE="DialogClose",QE=m.forwardRef((t,e)=>{const{__scopeDialog:r,...n}=t,s=Gn(JE,r);return l.jsx(se.button,{type:"button",...n,ref:e,onClick:Q(t.onClick,()=>s.onOpenChange(!1))})});QE.displayName=JE;function qx(t){return t?"open":"closed"}var XE="DialogTitleWarning",[Sre,ZE]=$4(XE,{contentName:na,titleName:Hx,docsSlug:"dialog"}),tU=({titleId:t})=>{const e=ZE(XE),r=`\`${e.contentName}\` requires a \`${e.titleName}\` for the component to be accessible for screen reader users. If you want to hide the \`${e.titleName}\`, you can wrap it with our VisuallyHidden component. For more information, see https://radix-ui.com/primitives/docs/components/${e.docsSlug}`;return m.useEffect(()=>{t&&(document.getElementById(t)||console.error(r))},[r,t]),null},rU="DialogDescriptionWarning",nU=({contentRef:t,descriptionId:e})=>{const n=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${ZE(rU).contentName}}.`;return m.useEffect(()=>{var o;const s=(o=t.current)==null?void 0:o.getAttribute("aria-describedby");e&&s&&(document.getElementById(e)||console.warn(n))},[n,t,e]),null},Kx=FE,sU=BE,Gx=VE,ru=WE,nu=HE,Tp=KE,Rp=YE,e_=QE;const wn=Kx,t_=sU,oU=Gx,r_=m.forwardRef(({className:t,...e},r)=>l.jsx(ru,{ref:r,className:B("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",t),...e}));r_.displayName=ru.displayName;const nn=m.forwardRef(({className:t,children:e,...r},n)=>l.jsxs(oU,{children:[l.jsx(r_,{}),l.jsxs(nu,{ref:n,className:B("fixed left-[50%] top-[50%] z-50 grid w-[calc(100%-2rem)] max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-4 sm:p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] max-h-[90vh] overflow-y-auto rounded-lg sm:rounded-lg",t),...r,children:[e,l.jsxs(e_,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity data-[state=open]:bg-accent data-[state=open]:text-muted-foreground hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none",children:[l.jsx(Wd,{className:"h-4 w-4"}),l.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));nn.displayName=nu.displayName;const bn=({className:t,...e})=>l.jsx("div",{className:B("flex flex-col space-y-1.5 text-center sm:text-left",t),...e});bn.displayName="DialogHeader";const n_=({className:t,...e})=>l.jsx("div",{className:B("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",t),...e});n_.displayName="DialogFooter";const kn=m.forwardRef(({className:t,...e},r)=>l.jsx(Tp,{ref:r,className:B("text-lg font-semibold leading-none tracking-tight",t),...e}));kn.displayName=Tp.displayName;const Wl=m.forwardRef(({className:t,...e},r)=>l.jsx(Rp,{ref:r,className:B("text-sm text-muted-foreground",t),...e}));Wl.displayName=Rp.displayName;const s_=t=>{let e;const r=new Set,n=(d,u)=>{const h=typeof d=="function"?d(e):d;if(!Object.is(h,e)){const f=e;e=u??(typeof h!="object"||h===null)?h:Object.assign({},e,h),r.forEach(p=>p(e,f))}},s=()=>e,a={setState:n,getState:s,getInitialState:()=>c,subscribe:d=>(r.add(d),()=>r.delete(d))},c=e=t(n,s,a);return a},iU=t=>t?s_(t):s_,aU=t=>t;function lU(t,e=aU){const r=W.useSyncExternalStore(t.subscribe,W.useCallback(()=>e(t.getState()),[t,e]),W.useCallback(()=>e(t.getInitialState()),[t,e]));return W.useDebugValue(r),r}const o_=t=>{const e=iU(t),r=n=>lU(e,n);return Object.assign(r,e),r},cU=t=>t?o_(t):o_;function qe(t){const e=Object.prototype.toString.call(t);return t instanceof Date||typeof t=="object"&&e==="[object Date]"?new t.constructor(+t):typeof t=="number"||e==="[object Number]"||typeof t=="string"||e==="[object String]"?new Date(t):new Date(NaN)}function Yn(t,e){return t instanceof Date?new t.constructor(e):new Date(e)}function yt(t,e){const r=qe(t);return isNaN(e)?Yn(t,NaN):(e&&r.setDate(r.getDate()+e),r)}function Yx(t,e){const r=qe(t);if(isNaN(e))return Yn(t,NaN);if(!e)return r;const n=r.getDate(),s=Yn(t,r.getTime());s.setMonth(r.getMonth()+e+1,0);const o=s.getDate();return n>=o?s:(r.setFullYear(s.getFullYear(),s.getMonth(),n),r)}const i_=6048e5,dU=864e5,a_=6e4,l_=36e5;let uU={};function su(){return uU}function Sn(t,e){var a,c,d,u;const r=su(),n=(e==null?void 0:e.weekStartsOn)??((c=(a=e==null?void 0:e.locale)==null?void 0:a.options)==null?void 0:c.weekStartsOn)??r.weekStartsOn??((u=(d=r.locale)==null?void 0:d.options)==null?void 0:u.weekStartsOn)??0,s=qe(t),o=s.getDay(),i=(o=s.getTime()?r+1:e.getTime()>=i.getTime()?r:r-1}function ou(t){const e=qe(t);return e.setHours(0,0,0,0),e}function d_(t){const e=qe(t),r=new Date(Date.UTC(e.getFullYear(),e.getMonth(),e.getDate(),e.getHours(),e.getMinutes(),e.getSeconds(),e.getMilliseconds()));return r.setUTCFullYear(e.getFullYear()),+t-+r}function hU(t,e){const r=ou(t),n=ou(e),s=+r-d_(r),o=+n-d_(n);return Math.round((s-o)/dU)}function fU(t){const e=c_(t),r=Yn(t,0);return r.setFullYear(e,0,4),r.setHours(0,0,0,0),Mp(r)}function u_(t,e){const r=e*7;return yt(t,r)}function h_(t){return Yn(t,Date.now())}function eo(t,e){const r=ou(t),n=ou(e);return+r==+n}function pU(t){return t instanceof Date||typeof t=="object"&&Object.prototype.toString.call(t)==="[object Date]"}function mU(t){if(!pU(t)&&typeof t!="number")return!1;const e=qe(t);return!isNaN(Number(e))}function f_(t){const e=qe(t),r=e.getMonth();return e.setFullYear(e.getFullYear(),r+1,0),e.setHours(23,59,59,999),e}function Jx(t,e){const r=qe(t.start),n=qe(t.end);let s=+r>+n;const o=s?+r:+n,i=s?n:r;i.setHours(0,0,0,0);let a=1;const c=[];for(;+i<=o;)c.push(qe(i)),i.setDate(i.getDate()+a),i.setHours(0,0,0,0);return s?c.reverse():c}function p_(t){const e=qe(t);return e.setDate(1),e.setHours(0,0,0,0),e}function gU(t){const e=qe(t),r=Yn(t,0);return r.setFullYear(e.getFullYear(),0,1),r.setHours(0,0,0,0),r}function Op(t,e){var a,c,d,u;const r=su(),n=(e==null?void 0:e.weekStartsOn)??((c=(a=e==null?void 0:e.locale)==null?void 0:a.options)==null?void 0:c.weekStartsOn)??r.weekStartsOn??((u=(d=r.locale)==null?void 0:d.options)==null?void 0:u.weekStartsOn)??0,s=qe(t),o=s.getDay(),i=(o{let n;const s=vU[t];return typeof s=="string"?n=s:e===1?n=s.one:n=s.other.replace("{{count}}",e.toString()),r!=null&&r.addSuffix?r.comparison&&r.comparison>0?"in "+n:n+" ago":n};function Qx(t){return(e={})=>{const r=e.width?String(e.width):t.defaultWidth;return t.formats[r]||t.formats[t.defaultWidth]}}const xU={full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},wU={full:"h:mm:ss a zzzz",long:"h:mm:ss a z",medium:"h:mm:ss a",short:"h:mm a"},bU={full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},kU={date:Qx({formats:xU,defaultWidth:"full"}),time:Qx({formats:wU,defaultWidth:"full"}),dateTime:Qx({formats:bU,defaultWidth:"full"})},SU={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"},NU=(t,e,r,n)=>SU[t];function iu(t){return(e,r)=>{const n=r!=null&&r.context?String(r.context):"standalone";let s;if(n==="formatting"&&t.formattingValues){const i=t.defaultFormattingWidth||t.defaultWidth,a=r!=null&&r.width?String(r.width):i;s=t.formattingValues[a]||t.formattingValues[i]}else{const i=t.defaultWidth,a=r!=null&&r.width?String(r.width):t.defaultWidth;s=t.values[a]||t.values[i]}const o=t.argumentCallback?t.argumentCallback(e):e;return s[o]}}const CU={narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},jU={narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1st quarter","2nd quarter","3rd quarter","4th quarter"]},EU={narrow:["J","F","M","A","M","J","J","A","S","O","N","D"],abbreviated:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],wide:["January","February","March","April","May","June","July","August","September","October","November","December"]},_U={narrow:["S","M","T","W","T","F","S"],short:["Su","Mo","Tu","We","Th","Fr","Sa"],abbreviated:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],wide:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]},TU={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"}},RU={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"}},MU={ordinalNumber:(t,e)=>{const r=Number(t),n=r%100;if(n>20||n<10)switch(n%10){case 1:return r+"st";case 2:return r+"nd";case 3:return r+"rd"}return r+"th"},era:iu({values:CU,defaultWidth:"wide"}),quarter:iu({values:jU,defaultWidth:"wide",argumentCallback:t=>t-1}),month:iu({values:EU,defaultWidth:"wide"}),day:iu({values:_U,defaultWidth:"wide"}),dayPeriod:iu({values:TU,defaultWidth:"wide",formattingValues:RU,defaultFormattingWidth:"wide"})};function au(t){return(e,r={})=>{const n=r.width,s=n&&t.matchPatterns[n]||t.matchPatterns[t.defaultMatchWidth],o=e.match(s);if(!o)return null;const i=o[0],a=n&&t.parsePatterns[n]||t.parsePatterns[t.defaultParseWidth],c=Array.isArray(a)?PU(a,h=>h.test(i)):OU(a,h=>h.test(i));let d;d=t.valueCallback?t.valueCallback(c):c,d=r.valueCallback?r.valueCallback(d):d;const u=e.slice(i.length);return{value:d,rest:u}}}function OU(t,e){for(const r in t)if(Object.prototype.hasOwnProperty.call(t,r)&&e(t[r]))return r}function PU(t,e){for(let r=0;r{const n=e.match(t.matchPattern);if(!n)return null;const s=n[0],o=e.match(t.parsePattern);if(!o)return null;let i=t.valueCallback?t.valueCallback(o[0]):o[0];i=r.valueCallback?r.valueCallback(i):i;const a=e.slice(s.length);return{value:i,rest:a}}}const IU=/^(\d+)(th|st|nd|rd)?/i,DU=/\d+/i,LU={narrow:/^(b|a)/i,abbreviated:/^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,wide:/^(before christ|before common era|anno domini|common era)/i},$U={any:[/^b/i,/^(a|c)/i]},FU={narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},zU={any:[/1/i,/2/i,/3/i,/4/i]},BU={narrow:/^[jfmasond]/i,abbreviated:/^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,wide:/^(january|february|march|april|may|june|july|august|september|october|november|december)/i},UU={narrow:[/^j/i,/^f/i,/^m/i,/^a/i,/^m/i,/^j/i,/^j/i,/^a/i,/^s/i,/^o/i,/^n/i,/^d/i],any:[/^ja/i,/^f/i,/^mar/i,/^ap/i,/^may/i,/^jun/i,/^jul/i,/^au/i,/^s/i,/^o/i,/^n/i,/^d/i]},VU={narrow:/^[smtwf]/i,short:/^(su|mo|tu|we|th|fr|sa)/i,abbreviated:/^(sun|mon|tue|wed|thu|fri|sat)/i,wide:/^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i},WU={narrow:[/^s/i,/^m/i,/^t/i,/^w/i,/^t/i,/^f/i,/^s/i],any:[/^su/i,/^m/i,/^tu/i,/^w/i,/^th/i,/^f/i,/^sa/i]},HU={narrow:/^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,any:/^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i},qU={any:{am:/^a/i,pm:/^p/i,midnight:/^mi/i,noon:/^no/i,morning:/morning/i,afternoon:/afternoon/i,evening:/evening/i,night:/night/i}},KU={ordinalNumber:AU({matchPattern:IU,parsePattern:DU,valueCallback:t=>parseInt(t,10)}),era:au({matchPatterns:LU,defaultMatchWidth:"wide",parsePatterns:$U,defaultParseWidth:"any"}),quarter:au({matchPatterns:FU,defaultMatchWidth:"wide",parsePatterns:zU,defaultParseWidth:"any",valueCallback:t=>t+1}),month:au({matchPatterns:BU,defaultMatchWidth:"wide",parsePatterns:UU,defaultParseWidth:"any"}),day:au({matchPatterns:VU,defaultMatchWidth:"wide",parsePatterns:WU,defaultParseWidth:"any"}),dayPeriod:au({matchPatterns:HU,defaultMatchWidth:"any",parsePatterns:qU,defaultParseWidth:"any"})},GU={code:"en-US",formatDistance:yU,formatLong:kU,formatRelative:NU,localize:MU,match:KU,options:{weekStartsOn:0,firstWeekContainsDate:1}};function YU(t){const e=qe(t);return hU(e,gU(e))+1}function JU(t){const e=qe(t),r=+Mp(e)-+fU(e);return Math.round(r/i_)+1}function m_(t,e){var u,h,f,p;const r=qe(t),n=r.getFullYear(),s=su(),o=(e==null?void 0:e.firstWeekContainsDate)??((h=(u=e==null?void 0:e.locale)==null?void 0:u.options)==null?void 0:h.firstWeekContainsDate)??s.firstWeekContainsDate??((p=(f=s.locale)==null?void 0:f.options)==null?void 0:p.firstWeekContainsDate)??1,i=Yn(t,0);i.setFullYear(n+1,0,o),i.setHours(0,0,0,0);const a=Sn(i,e),c=Yn(t,0);c.setFullYear(n,0,o),c.setHours(0,0,0,0);const d=Sn(c,e);return r.getTime()>=a.getTime()?n+1:r.getTime()>=d.getTime()?n:n-1}function QU(t,e){var a,c,d,u;const r=su(),n=(e==null?void 0:e.firstWeekContainsDate)??((c=(a=e==null?void 0:e.locale)==null?void 0:a.options)==null?void 0:c.firstWeekContainsDate)??r.firstWeekContainsDate??((u=(d=r.locale)==null?void 0:d.options)==null?void 0:u.firstWeekContainsDate)??1,s=m_(t,e),o=Yn(t,0);return o.setFullYear(s,0,n),o.setHours(0,0,0,0),Sn(o,e)}function XU(t,e){const r=qe(t),n=+Sn(r,e)-+QU(r,e);return Math.round(n/i_)+1}function Ue(t,e){const r=t<0?"-":"",n=Math.abs(t).toString().padStart(e,"0");return r+n}const Yo={y(t,e){const r=t.getFullYear(),n=r>0?r:1-r;return Ue(e==="yy"?n%100:n,e.length)},M(t,e){const r=t.getMonth();return e==="M"?String(r+1):Ue(r+1,2)},d(t,e){return Ue(t.getDate(),e.length)},a(t,e){const r=t.getHours()/12>=1?"pm":"am";switch(e){case"a":case"aa":return r.toUpperCase();case"aaa":return r;case"aaaaa":return r[0];case"aaaa":default:return r==="am"?"a.m.":"p.m."}},h(t,e){return Ue(t.getHours()%12||12,e.length)},H(t,e){return Ue(t.getHours(),e.length)},m(t,e){return Ue(t.getMinutes(),e.length)},s(t,e){return Ue(t.getSeconds(),e.length)},S(t,e){const r=e.length,n=t.getMilliseconds(),s=Math.trunc(n*Math.pow(10,r-3));return Ue(s,e.length)}},Hl={am:"am",pm:"pm",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},g_={G:function(t,e,r){const n=t.getFullYear()>0?1:0;switch(e){case"G":case"GG":case"GGG":return r.era(n,{width:"abbreviated"});case"GGGGG":return r.era(n,{width:"narrow"});case"GGGG":default:return r.era(n,{width:"wide"})}},y:function(t,e,r){if(e==="yo"){const n=t.getFullYear(),s=n>0?n:1-n;return r.ordinalNumber(s,{unit:"year"})}return Yo.y(t,e)},Y:function(t,e,r,n){const s=m_(t,n),o=s>0?s:1-s;if(e==="YY"){const i=o%100;return Ue(i,2)}return e==="Yo"?r.ordinalNumber(o,{unit:"year"}):Ue(o,e.length)},R:function(t,e){const r=c_(t);return Ue(r,e.length)},u:function(t,e){const r=t.getFullYear();return Ue(r,e.length)},Q:function(t,e,r){const n=Math.ceil((t.getMonth()+1)/3);switch(e){case"Q":return String(n);case"QQ":return Ue(n,2);case"Qo":return r.ordinalNumber(n,{unit:"quarter"});case"QQQ":return r.quarter(n,{width:"abbreviated",context:"formatting"});case"QQQQQ":return r.quarter(n,{width:"narrow",context:"formatting"});case"QQQQ":default:return r.quarter(n,{width:"wide",context:"formatting"})}},q:function(t,e,r){const n=Math.ceil((t.getMonth()+1)/3);switch(e){case"q":return String(n);case"qq":return Ue(n,2);case"qo":return r.ordinalNumber(n,{unit:"quarter"});case"qqq":return r.quarter(n,{width:"abbreviated",context:"standalone"});case"qqqqq":return r.quarter(n,{width:"narrow",context:"standalone"});case"qqqq":default:return r.quarter(n,{width:"wide",context:"standalone"})}},M:function(t,e,r){const n=t.getMonth();switch(e){case"M":case"MM":return Yo.M(t,e);case"Mo":return r.ordinalNumber(n+1,{unit:"month"});case"MMM":return r.month(n,{width:"abbreviated",context:"formatting"});case"MMMMM":return r.month(n,{width:"narrow",context:"formatting"});case"MMMM":default:return r.month(n,{width:"wide",context:"formatting"})}},L:function(t,e,r){const n=t.getMonth();switch(e){case"L":return String(n+1);case"LL":return Ue(n+1,2);case"Lo":return r.ordinalNumber(n+1,{unit:"month"});case"LLL":return r.month(n,{width:"abbreviated",context:"standalone"});case"LLLLL":return r.month(n,{width:"narrow",context:"standalone"});case"LLLL":default:return r.month(n,{width:"wide",context:"standalone"})}},w:function(t,e,r,n){const s=XU(t,n);return e==="wo"?r.ordinalNumber(s,{unit:"week"}):Ue(s,e.length)},I:function(t,e,r){const n=JU(t);return e==="Io"?r.ordinalNumber(n,{unit:"week"}):Ue(n,e.length)},d:function(t,e,r){return e==="do"?r.ordinalNumber(t.getDate(),{unit:"date"}):Yo.d(t,e)},D:function(t,e,r){const n=YU(t);return e==="Do"?r.ordinalNumber(n,{unit:"dayOfYear"}):Ue(n,e.length)},E:function(t,e,r){const n=t.getDay();switch(e){case"E":case"EE":case"EEE":return r.day(n,{width:"abbreviated",context:"formatting"});case"EEEEE":return r.day(n,{width:"narrow",context:"formatting"});case"EEEEEE":return r.day(n,{width:"short",context:"formatting"});case"EEEE":default:return r.day(n,{width:"wide",context:"formatting"})}},e:function(t,e,r,n){const s=t.getDay(),o=(s-n.weekStartsOn+8)%7||7;switch(e){case"e":return String(o);case"ee":return Ue(o,2);case"eo":return r.ordinalNumber(o,{unit:"day"});case"eee":return r.day(s,{width:"abbreviated",context:"formatting"});case"eeeee":return r.day(s,{width:"narrow",context:"formatting"});case"eeeeee":return r.day(s,{width:"short",context:"formatting"});case"eeee":default:return r.day(s,{width:"wide",context:"formatting"})}},c:function(t,e,r,n){const s=t.getDay(),o=(s-n.weekStartsOn+8)%7||7;switch(e){case"c":return String(o);case"cc":return Ue(o,e.length);case"co":return r.ordinalNumber(o,{unit:"day"});case"ccc":return r.day(s,{width:"abbreviated",context:"standalone"});case"ccccc":return r.day(s,{width:"narrow",context:"standalone"});case"cccccc":return r.day(s,{width:"short",context:"standalone"});case"cccc":default:return r.day(s,{width:"wide",context:"standalone"})}},i:function(t,e,r){const n=t.getDay(),s=n===0?7:n;switch(e){case"i":return String(s);case"ii":return Ue(s,e.length);case"io":return r.ordinalNumber(s,{unit:"day"});case"iii":return r.day(n,{width:"abbreviated",context:"formatting"});case"iiiii":return r.day(n,{width:"narrow",context:"formatting"});case"iiiiii":return r.day(n,{width:"short",context:"formatting"});case"iiii":default:return r.day(n,{width:"wide",context:"formatting"})}},a:function(t,e,r){const s=t.getHours()/12>=1?"pm":"am";switch(e){case"a":case"aa":return r.dayPeriod(s,{width:"abbreviated",context:"formatting"});case"aaa":return r.dayPeriod(s,{width:"abbreviated",context:"formatting"}).toLowerCase();case"aaaaa":return r.dayPeriod(s,{width:"narrow",context:"formatting"});case"aaaa":default:return r.dayPeriod(s,{width:"wide",context:"formatting"})}},b:function(t,e,r){const n=t.getHours();let s;switch(n===12?s=Hl.noon:n===0?s=Hl.midnight:s=n/12>=1?"pm":"am",e){case"b":case"bb":return r.dayPeriod(s,{width:"abbreviated",context:"formatting"});case"bbb":return r.dayPeriod(s,{width:"abbreviated",context:"formatting"}).toLowerCase();case"bbbbb":return r.dayPeriod(s,{width:"narrow",context:"formatting"});case"bbbb":default:return r.dayPeriod(s,{width:"wide",context:"formatting"})}},B:function(t,e,r){const n=t.getHours();let s;switch(n>=17?s=Hl.evening:n>=12?s=Hl.afternoon:n>=4?s=Hl.morning:s=Hl.night,e){case"B":case"BB":case"BBB":return r.dayPeriod(s,{width:"abbreviated",context:"formatting"});case"BBBBB":return r.dayPeriod(s,{width:"narrow",context:"formatting"});case"BBBB":default:return r.dayPeriod(s,{width:"wide",context:"formatting"})}},h:function(t,e,r){if(e==="ho"){let n=t.getHours()%12;return n===0&&(n=12),r.ordinalNumber(n,{unit:"hour"})}return Yo.h(t,e)},H:function(t,e,r){return e==="Ho"?r.ordinalNumber(t.getHours(),{unit:"hour"}):Yo.H(t,e)},K:function(t,e,r){const n=t.getHours()%12;return e==="Ko"?r.ordinalNumber(n,{unit:"hour"}):Ue(n,e.length)},k:function(t,e,r){let n=t.getHours();return n===0&&(n=24),e==="ko"?r.ordinalNumber(n,{unit:"hour"}):Ue(n,e.length)},m:function(t,e,r){return e==="mo"?r.ordinalNumber(t.getMinutes(),{unit:"minute"}):Yo.m(t,e)},s:function(t,e,r){return e==="so"?r.ordinalNumber(t.getSeconds(),{unit:"second"}):Yo.s(t,e)},S:function(t,e){return Yo.S(t,e)},X:function(t,e,r){const n=t.getTimezoneOffset();if(n===0)return"Z";switch(e){case"X":return y_(n);case"XXXX":case"XX":return sa(n);case"XXXXX":case"XXX":default:return sa(n,":")}},x:function(t,e,r){const n=t.getTimezoneOffset();switch(e){case"x":return y_(n);case"xxxx":case"xx":return sa(n);case"xxxxx":case"xxx":default:return sa(n,":")}},O:function(t,e,r){const n=t.getTimezoneOffset();switch(e){case"O":case"OO":case"OOO":return"GMT"+v_(n,":");case"OOOO":default:return"GMT"+sa(n,":")}},z:function(t,e,r){const n=t.getTimezoneOffset();switch(e){case"z":case"zz":case"zzz":return"GMT"+v_(n,":");case"zzzz":default:return"GMT"+sa(n,":")}},t:function(t,e,r){const n=Math.trunc(t.getTime()/1e3);return Ue(n,e.length)},T:function(t,e,r){const n=t.getTime();return Ue(n,e.length)}};function v_(t,e=""){const r=t>0?"-":"+",n=Math.abs(t),s=Math.trunc(n/60),o=n%60;return o===0?r+String(s):r+String(s)+e+Ue(o,2)}function y_(t,e){return t%60===0?(t>0?"-":"+")+Ue(Math.abs(t)/60,2):sa(t,e)}function sa(t,e=""){const r=t>0?"-":"+",n=Math.abs(t),s=Ue(Math.trunc(n/60),2),o=Ue(n%60,2);return r+s+e+o}const x_=(t,e)=>{switch(t){case"P":return e.date({width:"short"});case"PP":return e.date({width:"medium"});case"PPP":return e.date({width:"long"});case"PPPP":default:return e.date({width:"full"})}},w_=(t,e)=>{switch(t){case"p":return e.time({width:"short"});case"pp":return e.time({width:"medium"});case"ppp":return e.time({width:"long"});case"pppp":default:return e.time({width:"full"})}},ZU={p:w_,P:(t,e)=>{const r=t.match(/(P+)(p+)?/)||[],n=r[1],s=r[2];if(!s)return x_(t,e);let o;switch(n){case"P":o=e.dateTime({width:"short"});break;case"PP":o=e.dateTime({width:"medium"});break;case"PPP":o=e.dateTime({width:"long"});break;case"PPPP":default:o=e.dateTime({width:"full"});break}return o.replace("{{date}}",x_(n,e)).replace("{{time}}",w_(s,e))}},e8=/^D+$/,t8=/^Y+$/,r8=["D","DD","YY","YYYY"];function n8(t){return e8.test(t)}function s8(t){return t8.test(t)}function o8(t,e,r){const n=i8(t,e,r);if(console.warn(n),r8.includes(t))throw new RangeError(n)}function i8(t,e,r){const n=t[0]==="Y"?"years":"days of the month";return`Use \`${t.toLowerCase()}\` instead of \`${t}\` (in \`${e}\`) for formatting ${n} to the input \`${r}\`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md`}const a8=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,l8=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,c8=/^'([^]*?)'?$/,d8=/''/g,u8=/[a-zA-Z]/;function pe(t,e,r){var u,h,f,p;const n=su(),s=n.locale??GU,o=n.firstWeekContainsDate??((h=(u=n.locale)==null?void 0:u.options)==null?void 0:h.firstWeekContainsDate)??1,i=n.weekStartsOn??((p=(f=n.locale)==null?void 0:f.options)==null?void 0:p.weekStartsOn)??0,a=qe(t);if(!mU(a))throw new RangeError("Invalid time value");let c=e.match(l8).map(g=>{const v=g[0];if(v==="p"||v==="P"){const y=ZU[v];return y(g,s.formatLong)}return g}).join("").match(a8).map(g=>{if(g==="''")return{isToken:!1,value:"'"};const v=g[0];if(v==="'")return{isToken:!1,value:h8(g)};if(g_[v])return{isToken:!0,value:g};if(v.match(u8))throw new RangeError("Format string contains an unescaped latin alphabet character `"+v+"`");return{isToken:!1,value:g}});s.localize.preprocessor&&(c=s.localize.preprocessor(a,c));const d={firstWeekContainsDate:o,weekStartsOn:i,locale:s};return c.map(g=>{if(!g.isToken)return g.value;const v=g.value;(s8(v)||n8(v))&&o8(v,e,String(t));const y=g_[v[0]];return y(a,v,s.localize,d)}).join("")}function h8(t){const e=t.match(c8);return e?e[1].replace(d8,"'"):t}function f8(t){return qe(t).getDay()}function p8(t,e){const r=qe(t),n=qe(e);return+r<+n}function m8(t){return+qe(t)>Date.now()}function Xx(t){return+qe(t)2)return e;if(/:/.test(r[0])?n=r[0]:(e.date=r[0],n=r[1],Pp.timeZoneDelimiter.test(e.date)&&(e.date=t.split(Pp.timeZoneDelimiter)[0],n=t.substr(e.date.length,t.length))),n){const s=Pp.timezone.exec(n);s?(e.time=n.replace(s[1],""),e.timezone=s[1]):e.time=n}return e}function b8(t,e){const r=new RegExp("^(?:(\\d{4}|[+-]\\d{"+(4+e)+"})|(\\d{2}|[+-]\\d{"+(2+e)+"})$)"),n=t.match(r);if(!n)return{year:NaN,restDateString:""};const s=n[1]?parseInt(n[1]):null,o=n[2]?parseInt(n[2]):null;return{year:o===null?s:o*100,restDateString:t.slice((n[1]||n[2]).length)}}function k8(t,e){if(e===null)return new Date(NaN);const r=t.match(v8);if(!r)return new Date(NaN);const n=!!r[4],s=cu(r[1]),o=cu(r[2])-1,i=cu(r[3]),a=cu(r[4]),c=cu(r[5])-1;if(n)return T8(e,a,c)?C8(e,a,c):new Date(NaN);{const d=new Date(0);return!E8(e,o,i)||!_8(e,s)?new Date(NaN):(d.setUTCFullYear(e,o,Math.max(s,i)),d)}}function cu(t){return t?parseInt(t):1}function S8(t){const e=t.match(y8);if(!e)return NaN;const r=Zx(e[1]),n=Zx(e[2]),s=Zx(e[3]);return R8(r,n,s)?r*l_+n*a_+s*1e3:NaN}function Zx(t){return t&&parseFloat(t.replace(",","."))||0}function N8(t){if(t==="Z")return 0;const e=t.match(x8);if(!e)return 0;const r=e[1]==="+"?-1:1,n=parseInt(e[2]),s=e[3]&&parseInt(e[3])||0;return M8(n,s)?r*(n*l_+s*a_):NaN}function C8(t,e,r){const n=new Date(0);n.setUTCFullYear(t,0,4);const s=n.getUTCDay()||7,o=(e-1)*7+r+1-s;return n.setUTCDate(n.getUTCDate()+o),n}const j8=[31,null,31,30,31,30,31,31,30,31,30,31];function k_(t){return t%400===0||t%4===0&&t%100!==0}function E8(t,e,r){return e>=0&&e<=11&&r>=1&&r<=(j8[e]||(k_(t)?29:28))}function _8(t,e){return e>=1&&e<=(k_(t)?366:365)}function T8(t,e,r){return e>=1&&e<=53&&r>=0&&r<=6}function R8(t,e,r){return t===24?e===0&&r===0:r>=0&&r<60&&e>=0&&e<60&&t>=0&&t<25}function M8(t,e){return e>=0&&e<=59}function S_(t,e){return Yx(t,-e)}function O8(t,e){return u_(t,-e)}const Ae=new Date,Br=Sn(Ae,{weekStartsOn:0}),P8=[{id:"class-1",userId:"user-1",name:"Introduction to Computer Science",code:"CS101",color:"#14b8a6",instructor:"Dr. Sarah Chen",location:"Engineering Hall 201",schedule:[{dayOfWeek:1,startTime:"09:00",endTime:"10:30"},{dayOfWeek:3,startTime:"09:00",endTime:"10:30"}],createdAt:Pe(Ae,30)},{id:"class-2",userId:"user-1",name:"Calculus II",code:"MATH201",color:"#f59e0b",instructor:"Prof. James Miller",location:"Science Building 105",schedule:[{dayOfWeek:2,startTime:"11:00",endTime:"12:30"},{dayOfWeek:4,startTime:"11:00",endTime:"12:30"}],createdAt:Pe(Ae,30)},{id:"class-3",userId:"user-1",name:"Modern Philosophy",code:"PHIL302",color:"#8b5cf6",instructor:"Dr. Emma Thompson",location:"Humanities 301",schedule:[{dayOfWeek:1,startTime:"14:00",endTime:"15:30"},{dayOfWeek:3,startTime:"14:00",endTime:"15:30"},{dayOfWeek:5,startTime:"14:00",endTime:"15:30"}],createdAt:Pe(Ae,30)},{id:"class-4",userId:"user-1",name:"Organic Chemistry",code:"CHEM301",color:"#ec4899",instructor:"Dr. Michael Park",location:"Chemistry Lab 102",schedule:[{dayOfWeek:2,startTime:"09:00",endTime:"10:30"},{dayOfWeek:4,startTime:"09:00",endTime:"10:30"}],createdAt:Pe(Ae,30)}],A8=[{id:"event-1",classId:"class-1",userId:"user-1",title:"Algorithms & Data Structures",date:yt(Br,0),startTime:"09:00",endTime:"10:30",type:"lecture",location:"Engineering Hall 201",notes:[],createdAt:Pe(Ae,7)},{id:"event-2",classId:"class-2",userId:"user-1",title:"Integration Techniques",date:yt(Br,1),startTime:"11:00",endTime:"12:30",type:"lecture",location:"Science Building 105",notes:[],createdAt:Pe(Ae,7)},{id:"event-3",classId:"class-3",userId:"user-1",title:"Kant's Critique of Pure Reason",date:yt(Br,0),startTime:"14:00",endTime:"15:30",type:"lecture",location:"Humanities 301",notes:[],createdAt:Pe(Ae,7)},{id:"event-4",classId:"class-4",userId:"user-1",title:"Stereochemistry",date:yt(Br,1),startTime:"09:00",endTime:"10:30",type:"lecture",location:"Chemistry Lab 102",notes:[],createdAt:Pe(Ae,7)},{id:"event-5",classId:"class-1",userId:"user-1",title:"Recursion & Dynamic Programming",date:yt(Br,2),startTime:"09:00",endTime:"10:30",type:"lecture",location:"Engineering Hall 201",notes:[],createdAt:Pe(Ae,5)},{id:"event-6",classId:"class-3",userId:"user-1",title:"Hegel's Dialectic",date:yt(Br,2),startTime:"14:00",endTime:"15:30",type:"lecture",location:"Humanities 301",notes:[],createdAt:Pe(Ae,5)},{id:"event-7",classId:"class-2",userId:"user-1",title:"Series Convergence",date:yt(Br,3),startTime:"11:00",endTime:"12:30",type:"lecture",location:"Science Building 105",notes:[],createdAt:Pe(Ae,4)},{id:"event-8",classId:"class-4",userId:"user-1",title:"Organic Reactions Lab",date:yt(Br,3),startTime:"09:00",endTime:"10:30",type:"lab",location:"Chemistry Lab 102",notes:[],createdAt:Pe(Ae,4)},{id:"event-9",classId:"class-3",userId:"user-1",title:"Nietzsche & Existentialism",date:yt(Br,4),startTime:"14:00",endTime:"15:30",type:"lecture",location:"Humanities 301",notes:[],createdAt:Pe(Ae,3)},{id:"event-10",classId:"class-1",userId:"user-1",title:"CS101 Midterm Exam",date:yt(Br,7),startTime:"09:00",endTime:"11:00",type:"exam",location:"Engineering Hall 201",notes:[],createdAt:Pe(Ae,14)}],I8=[{id:"note-1",eventId:"event-1",classId:"class-1",userId:"user-1",type:"audio",content:"",audioUrl:"/audio/lecture1.mp3",transcription:`Today we covered algorithms and data structures. Key points: 1. **Big O Notation** - We learned about time complexity analysis. O(1) constant, O(n) linear, O(n²) quadratic, O(log n) logarithmic. 2. **Arrays vs Linked Lists** - Arrays have O(1) access but O(n) insertion. Linked lists have O(n) access but O(1) insertion at head. 3. **Binary Search** - Only works on sorted arrays. Divides search space in half each iteration. Time complexity: O(log n). 4. **Hash Tables** - Average O(1) for insert, delete, search. Collision handling: chaining vs open addressing. Professor mentioned this will be heavily tested on the midterm.`,topics:["Big O Notation","Arrays","Linked Lists","Binary Search","Hash Tables"],keywords:["time complexity","data structures","algorithms","midterm"],createdAt:Pe(Ae,7),updatedAt:Pe(Ae,7)},{id:"note-2",eventId:"event-2",classId:"class-2",userId:"user-1",type:"text",content:`## Integration Techniques ### Integration by Parts Formula: ∫u dv = uv - ∫v du Remember LIATE for choosing u: - Logarithmic - Inverse trig - Algebraic - Trigonometric - Exponential ### Partial Fractions Used when integrating rational functions P(x)/Q(x) Steps: 1. Factor denominator completely 2. Set up partial fraction decomposition 3. Solve for coefficients 4. Integrate each term ### Practice Problems - Problem Set 4.3: #1-15, 22-30 - Due next Thursday`,topics:["Integration by Parts","Partial Fractions","LIATE"],keywords:["calculus","integration","formulas"],createdAt:Pe(Ae,6),updatedAt:Pe(Ae,6)},{id:"note-3",eventId:"event-3",content:"",classId:"class-3",userId:"user-1",type:"audio",transcription:`Kant's Critique of Pure Reason - Key Concepts: **The Copernican Revolution in Philosophy** - Kant reversed traditional epistemology - Instead of mind conforming to objects, objects conform to our mind's structures - This explains how synthetic a priori knowledge is possible **Categories of Understanding** - Quantity: Unity, Plurality, Totality - Quality: Reality, Negation, Limitation - Relation: Substance, Causality, Community - Modality: Possibility, Existence, Necessity **Phenomena vs Noumena** - Phenomena: Things as they appear to us - Noumena: Things in themselves (unknowable) - We can never know the "thing-in-itself" Essay due in 2 weeks on the synthetic a priori.`,topics:["Kant","Epistemology","Categories","Phenomena","Noumena"],keywords:["philosophy","critique","knowledge","essay"],createdAt:Pe(Ae,7),updatedAt:Pe(Ae,7)}],D8=[{id:"assign-1",classId:"class-1",userId:"user-1",title:"Algorithm Analysis Problem Set",description:"Complete problems 1-15 from Chapter 4. Show all work for Big O derivations.",dueDate:yt(Ae,3),priority:"high",status:"in-progress",createdAt:Pe(Ae,10)},{id:"assign-2",classId:"class-2",userId:"user-1",title:"Integration Practice Set 4.3",description:"Problems #1-15, 22-30. Focus on integration by parts and partial fractions.",dueDate:yt(Ae,5),priority:"medium",status:"todo",createdAt:Pe(Ae,6)},{id:"assign-3",classId:"class-3",userId:"user-1",title:"Essay: Synthetic A Priori Knowledge",description:"2000-word essay analyzing Kant's argument for synthetic a priori propositions.",dueDate:yt(Ae,14),priority:"high",status:"todo",createdAt:Pe(Ae,7)},{id:"assign-4",classId:"class-4",userId:"user-1",title:"Lab Report: Stereochemistry",description:"Write up results from Thursday's lab. Include all observations and conclusions.",dueDate:yt(Ae,7),priority:"medium",status:"todo",createdAt:Pe(Ae,4)},{id:"assign-5",classId:"class-1",userId:"user-1",title:"Study for CS101 Midterm",description:"Review chapters 1-5. Focus on algorithms, data structures, and time complexity.",dueDate:yt(Ae,7),priority:"high",status:"in-progress",createdAt:Pe(Ae,14)},{id:"assign-6",classId:"class-2",userId:"user-1",title:"Quiz Prep: Series",description:"Review convergence tests for infinite series.",dueDate:yt(Ae,1),priority:"high",status:"in-progress",createdAt:Pe(Ae,3)}],N_=[{id:"summary-1",userId:"user-1",classId:"class-1",weekStartDate:Pe(Br,7),weekEndDate:Pe(Br,1),summary:`This week in CS101, we covered fundamental algorithm analysis and core data structures. **Key Concepts Learned:** - Big O notation for analyzing time and space complexity - Comparison of array vs linked list performance characteristics - Binary search algorithm and its logarithmic time complexity - Hash table implementation with collision resolution strategies **Important for Midterm:** The professor emphasized that Big O analysis and data structure trade-offs will be heavily tested. Practice identifying time complexity of nested loops and recursive functions. **Action Items:** - Complete Problem Set on algorithm analysis - Review lecture recording on hash tables - Practice whiteboard problems for common data structures`,keyTopics:["Big O Notation","Data Structures","Binary Search","Hash Tables"],sourceNoteIds:["note-1"],generatedAt:Pe(Ae,1)},{id:"summary-2",userId:"user-1",classId:"class-3",weekStartDate:Pe(Br,7),weekEndDate:Pe(Br,1),summary:`Philosophy 302 this week focused on Kant's revolutionary approach to epistemology. **Core Ideas:** - The "Copernican Revolution" in philosophy: objects conform to our minds, not vice versa - The 12 Categories of Understanding that structure our experience - The distinction between phenomena (appearances) and noumena (things-in-themselves) **Essay Preparation:** The upcoming essay on synthetic a priori knowledge requires understanding how Kant bridges rationalism and empiricism. Key examples: mathematical truths and the principle of causality. **Reading Notes:** Focus on Critique of Pure Reason, Introduction and Transcendental Aesthetic sections.`,keyTopics:["Kant","Epistemology","Categories of Understanding","Phenomena vs Noumena"],sourceNoteIds:["note-3"],generatedAt:Pe(Ae,1)}],Ot=cU(t=>({classes:P8,events:A8,notes:I8,assignments:D8,currentDate:new Date,calendarView:"week",selectedDate:null,selectedEvent:null,sidebarOpen:!0,mobileSidebarOpen:!1,searchOpen:!1,searchFilters:{query:"",classIds:[],dateRange:null,types:[],topics:[]},isRecording:!1,focusModeEnabled:!1,setCurrentDate:e=>t({currentDate:e}),setCalendarView:e=>t({calendarView:e}),setSelectedDate:e=>t({selectedDate:e}),setSelectedEvent:e=>t({selectedEvent:e}),toggleSidebar:()=>t(e=>({sidebarOpen:!e.sidebarOpen})),setMobileSidebarOpen:e=>t({mobileSidebarOpen:e}),toggleSearch:()=>t(e=>({searchOpen:!e.searchOpen})),setSearchFilters:e=>t(r=>({searchFilters:{...r.searchFilters,...e}})),setIsRecording:e=>t({isRecording:e}),setFocusMode:e=>t({focusModeEnabled:e}),addNote:e=>t(r=>({notes:[...r.notes,e]})),updateNote:(e,r)=>t(n=>({notes:n.notes.map(s=>s.id===e?{...s,...r}:s)})),addAssignment:e=>t(r=>({assignments:[...r.assignments,e]})),updateAssignment:(e,r)=>t(n=>({assignments:n.assignments.map(s=>s.id===e?{...s,...r}:s)})),addClass:e=>t(r=>({classes:[...r.classes,e]})),addEvent:e=>t(r=>({events:[...r.events,e]})),updateEvent:(e,r)=>t(n=>({events:n.events.map(s=>s.id===e?{...s,...r}:s)}))})),ew=768;function du(){const[t,e]=m.useState(void 0);return m.useEffect(()=>{const r=window.matchMedia(`(max-width: ${ew-1}px)`),n=()=>{e(window.innerWidthr.removeEventListener("change",n)},[]),!!t}function C_(){const{focusModeEnabled:t,setFocusMode:e}=Ot(),r=m.useCallback(()=>{const n=!t;e(n),n?Se.success("Focus Mode enabled",{description:"In-app notifications are now muted. For full iOS Do Not Disturb, enable it in iOS Settings → Focus.",duration:4e3}):Se("Focus Mode disabled",{description:"Notifications are back on.",duration:2e3})},[t,e]);return m.useEffect(()=>{t?document.body.classList.add("focus-mode-active"):document.body.classList.remove("focus-mode-active")},[t]),{focusModeEnabled:t,toggleFocusMode:r,setFocusMode:e}}const L8=t=>t?(...e)=>t(...e):(...e)=>fetch(...e);class tw extends Error{constructor(e,r="FunctionsError",n){super(e),this.name=r,this.context=n}}class $8 extends tw{constructor(e){super("Failed to send a request to the Edge Function","FunctionsFetchError",e)}}class j_ extends tw{constructor(e){super("Relay Error invoking the Edge Function","FunctionsRelayError",e)}}class E_ extends tw{constructor(e){super("Edge Function returned a non-2xx status code","FunctionsHttpError",e)}}var rw;(function(t){t.Any="any",t.ApNortheast1="ap-northeast-1",t.ApNortheast2="ap-northeast-2",t.ApSouth1="ap-south-1",t.ApSoutheast1="ap-southeast-1",t.ApSoutheast2="ap-southeast-2",t.CaCentral1="ca-central-1",t.EuCentral1="eu-central-1",t.EuWest1="eu-west-1",t.EuWest2="eu-west-2",t.EuWest3="eu-west-3",t.SaEast1="sa-east-1",t.UsEast1="us-east-1",t.UsWest1="us-west-1",t.UsWest2="us-west-2"})(rw||(rw={}));class F8{constructor(e,{headers:r={},customFetch:n,region:s=rw.Any}={}){this.url=e,this.headers=r,this.region=s,this.fetch=L8(n)}setAuth(e){this.headers.Authorization=`Bearer ${e}`}invoke(e){return c6(this,arguments,void 0,function*(r,n={}){var s;let o,i;try{const{headers:a,method:c,body:d,signal:u,timeout:h}=n;let f={},{region:p}=n;p||(p=this.region);const g=new URL(`${this.url}/${r}`);p&&p!=="any"&&(f["x-region"]=p,g.searchParams.set("forceFunctionRegion",p));let v;d&&(a&&!Object.prototype.hasOwnProperty.call(a,"Content-Type")||!a)?typeof Blob<"u"&&d instanceof Blob||d instanceof ArrayBuffer?(f["Content-Type"]="application/octet-stream",v=d):typeof d=="string"?(f["Content-Type"]="text/plain",v=d):typeof FormData<"u"&&d instanceof FormData?v=d:(f["Content-Type"]="application/json",v=JSON.stringify(d)):v=d;let y=u;h&&(i=new AbortController,o=setTimeout(()=>i.abort(),h),u?(y=i.signal,u.addEventListener("abort",()=>i.abort())):y=i.signal);const x=yield this.fetch(g.toString(),{method:c||"POST",headers:Object.assign(Object.assign(Object.assign({},f),this.headers),a),body:v,signal:y}).catch(S=>{throw new $8(S)}),w=x.headers.get("x-relay-error");if(w&&w==="true")throw new j_(x);if(!x.ok)throw new E_(x);let b=((s=x.headers.get("Content-Type"))!==null&&s!==void 0?s:"text/plain").split(";")[0].trim(),k;return b==="application/json"?k=yield x.json():b==="application/octet-stream"||b==="application/pdf"?k=yield x.blob():b==="text/event-stream"?k=x:b==="multipart/form-data"?k=yield x.formData():k=yield x.text(),{data:k,error:null,response:x}}catch(a){return{data:null,error:a,response:a instanceof E_||a instanceof j_?a.context:void 0}}finally{o&&clearTimeout(o)}})}}var z8=class extends Error{constructor(t){super(t.message),this.name="PostgrestError",this.details=t.details,this.hint=t.hint,this.code=t.code}},B8=class{constructor(t){var e,r;this.shouldThrowOnError=!1,this.method=t.method,this.url=t.url,this.headers=new Headers(t.headers),this.schema=t.schema,this.body=t.body,this.shouldThrowOnError=(e=t.shouldThrowOnError)!==null&&e!==void 0?e:!1,this.signal=t.signal,this.isMaybeSingle=(r=t.isMaybeSingle)!==null&&r!==void 0?r:!1,t.fetch?this.fetch=t.fetch:this.fetch=fetch}throwOnError(){return this.shouldThrowOnError=!0,this}setHeader(t,e){return this.headers=new Headers(this.headers),this.headers.set(t,e),this}then(t,e){var r=this;this.schema===void 0||(["GET","HEAD"].includes(this.method)?this.headers.set("Accept-Profile",this.schema):this.headers.set("Content-Profile",this.schema)),this.method!=="GET"&&this.method!=="HEAD"&&this.headers.set("Content-Type","application/json");const n=this.fetch;let s=n(this.url.toString(),{method:this.method,headers:this.headers,body:JSON.stringify(this.body),signal:this.signal}).then(async o=>{let i=null,a=null,c=null,d=o.status,u=o.statusText;if(o.ok){var h,f;if(r.method!=="HEAD"){var p;const x=await o.text();x===""||(r.headers.get("Accept")==="text/csv"||r.headers.get("Accept")&&(!((p=r.headers.get("Accept"))===null||p===void 0)&&p.includes("application/vnd.pgrst.plan+text"))?a=x:a=JSON.parse(x))}const v=(h=r.headers.get("Prefer"))===null||h===void 0?void 0:h.match(/count=(exact|planned|estimated)/),y=(f=o.headers.get("content-range"))===null||f===void 0?void 0:f.split("/");v&&y&&y.length>1&&(c=parseInt(y[1])),r.isMaybeSingle&&r.method==="GET"&&Array.isArray(a)&&(a.length>1?(i={code:"PGRST116",details:`Results contain ${a.length} rows, application/vnd.pgrst.object+json requires 1 row`,hint:null,message:"JSON object requested, multiple (or no) rows returned"},a=null,c=null,d=406,u="Not Acceptable"):a.length===1?a=a[0]:a=null)}else{var g;const v=await o.text();try{i=JSON.parse(v),Array.isArray(i)&&o.status===404&&(a=[],i=null,d=200,u="OK")}catch{o.status===404&&v===""?(d=204,u="No Content"):i={message:v}}if(i&&r.isMaybeSingle&&(!(i==null||(g=i.details)===null||g===void 0)&&g.includes("0 rows"))&&(i=null,d=200,u="OK"),i&&r.shouldThrowOnError)throw new z8(i)}return{error:i,data:a,count:c,status:d,statusText:u}});return this.shouldThrowOnError||(s=s.catch(o=>{var i;let a="";const c=o==null?void 0:o.cause;if(c){var d,u,h,f;const g=(d=c==null?void 0:c.message)!==null&&d!==void 0?d:"",v=(u=c==null?void 0:c.code)!==null&&u!==void 0?u:"";a=`${(h=o==null?void 0:o.name)!==null&&h!==void 0?h:"FetchError"}: ${o==null?void 0:o.message}`,a+=` Caused by: ${(f=c==null?void 0:c.name)!==null&&f!==void 0?f:"Error"}: ${g}`,v&&(a+=` (${v})`),c!=null&&c.stack&&(a+=` ${c.stack}`)}else{var p;a=(p=o==null?void 0:o.stack)!==null&&p!==void 0?p:""}return{error:{message:`${(i=o==null?void 0:o.name)!==null&&i!==void 0?i:"FetchError"}: ${o==null?void 0:o.message}`,details:a,hint:"",code:""},data:null,count:null,status:0,statusText:""}})),s.then(t,e)}returns(){return this}overrideTypes(){return this}},U8=class extends B8{select(t){let e=!1;const r=(t??"*").split("").map(n=>/\s/.test(n)&&!e?"":(n==='"'&&(e=!e),n)).join("");return this.url.searchParams.set("select",r),this.headers.append("Prefer","return=representation"),this}order(t,{ascending:e=!0,nullsFirst:r,foreignTable:n,referencedTable:s=n}={}){const o=s?`${s}.order`:"order",i=this.url.searchParams.get(o);return this.url.searchParams.set(o,`${i?`${i},`:""}${t}.${e?"asc":"desc"}${r===void 0?"":r?".nullsfirst":".nullslast"}`),this}limit(t,{foreignTable:e,referencedTable:r=e}={}){const n=typeof r>"u"?"limit":`${r}.limit`;return this.url.searchParams.set(n,`${t}`),this}range(t,e,{foreignTable:r,referencedTable:n=r}={}){const s=typeof n>"u"?"offset":`${n}.offset`,o=typeof n>"u"?"limit":`${n}.limit`;return this.url.searchParams.set(s,`${t}`),this.url.searchParams.set(o,`${e-t+1}`),this}abortSignal(t){return this.signal=t,this}single(){return this.headers.set("Accept","application/vnd.pgrst.object+json"),this}maybeSingle(){return this.method==="GET"?this.headers.set("Accept","application/json"):this.headers.set("Accept","application/vnd.pgrst.object+json"),this.isMaybeSingle=!0,this}csv(){return this.headers.set("Accept","text/csv"),this}geojson(){return this.headers.set("Accept","application/geo+json"),this}explain({analyze:t=!1,verbose:e=!1,settings:r=!1,buffers:n=!1,wal:s=!1,format:o="text"}={}){var i;const a=[t?"analyze":null,e?"verbose":null,r?"settings":null,n?"buffers":null,s?"wal":null].filter(Boolean).join("|"),c=(i=this.headers.get("Accept"))!==null&&i!==void 0?i:"application/json";return this.headers.set("Accept",`application/vnd.pgrst.plan+${o}; for="${c}"; options=${a};`),o==="json"?this:this}rollback(){return this.headers.append("Prefer","tx=rollback"),this}returns(){return this}maxAffected(t){return this.headers.append("Prefer","handling=strict"),this.headers.append("Prefer",`max-affected=${t}`),this}};const __=new RegExp("[,()]");var ql=class extends U8{eq(t,e){return this.url.searchParams.append(t,`eq.${e}`),this}neq(t,e){return this.url.searchParams.append(t,`neq.${e}`),this}gt(t,e){return this.url.searchParams.append(t,`gt.${e}`),this}gte(t,e){return this.url.searchParams.append(t,`gte.${e}`),this}lt(t,e){return this.url.searchParams.append(t,`lt.${e}`),this}lte(t,e){return this.url.searchParams.append(t,`lte.${e}`),this}like(t,e){return this.url.searchParams.append(t,`like.${e}`),this}likeAllOf(t,e){return this.url.searchParams.append(t,`like(all).{${e.join(",")}}`),this}likeAnyOf(t,e){return this.url.searchParams.append(t,`like(any).{${e.join(",")}}`),this}ilike(t,e){return this.url.searchParams.append(t,`ilike.${e}`),this}ilikeAllOf(t,e){return this.url.searchParams.append(t,`ilike(all).{${e.join(",")}}`),this}ilikeAnyOf(t,e){return this.url.searchParams.append(t,`ilike(any).{${e.join(",")}}`),this}regexMatch(t,e){return this.url.searchParams.append(t,`match.${e}`),this}regexIMatch(t,e){return this.url.searchParams.append(t,`imatch.${e}`),this}is(t,e){return this.url.searchParams.append(t,`is.${e}`),this}isDistinct(t,e){return this.url.searchParams.append(t,`isdistinct.${e}`),this}in(t,e){const r=Array.from(new Set(e)).map(n=>typeof n=="string"&&__.test(n)?`"${n}"`:`${n}`).join(",");return this.url.searchParams.append(t,`in.(${r})`),this}notIn(t,e){const r=Array.from(new Set(e)).map(n=>typeof n=="string"&&__.test(n)?`"${n}"`:`${n}`).join(",");return this.url.searchParams.append(t,`not.in.(${r})`),this}contains(t,e){return typeof e=="string"?this.url.searchParams.append(t,`cs.${e}`):Array.isArray(e)?this.url.searchParams.append(t,`cs.{${e.join(",")}}`):this.url.searchParams.append(t,`cs.${JSON.stringify(e)}`),this}containedBy(t,e){return typeof e=="string"?this.url.searchParams.append(t,`cd.${e}`):Array.isArray(e)?this.url.searchParams.append(t,`cd.{${e.join(",")}}`):this.url.searchParams.append(t,`cd.${JSON.stringify(e)}`),this}rangeGt(t,e){return this.url.searchParams.append(t,`sr.${e}`),this}rangeGte(t,e){return this.url.searchParams.append(t,`nxl.${e}`),this}rangeLt(t,e){return this.url.searchParams.append(t,`sl.${e}`),this}rangeLte(t,e){return this.url.searchParams.append(t,`nxr.${e}`),this}rangeAdjacent(t,e){return this.url.searchParams.append(t,`adj.${e}`),this}overlaps(t,e){return typeof e=="string"?this.url.searchParams.append(t,`ov.${e}`):this.url.searchParams.append(t,`ov.{${e.join(",")}}`),this}textSearch(t,e,{config:r,type:n}={}){let s="";n==="plain"?s="pl":n==="phrase"?s="ph":n==="websearch"&&(s="w");const o=r===void 0?"":`(${r})`;return this.url.searchParams.append(t,`${s}fts${o}.${e}`),this}match(t){return Object.entries(t).forEach(([e,r])=>{this.url.searchParams.append(e,`eq.${r}`)}),this}not(t,e,r){return this.url.searchParams.append(t,`not.${e}.${r}`),this}or(t,{foreignTable:e,referencedTable:r=e}={}){const n=r?`${r}.or`:"or";return this.url.searchParams.append(n,`(${t})`),this}filter(t,e,r){return this.url.searchParams.append(t,`${e}.${r}`),this}},V8=class{constructor(t,{headers:e={},schema:r,fetch:n}){this.url=t,this.headers=new Headers(e),this.schema=r,this.fetch=n}select(t,e){const{head:r=!1,count:n}=e??{},s=r?"HEAD":"GET";let o=!1;const i=(t??"*").split("").map(a=>/\s/.test(a)&&!o?"":(a==='"'&&(o=!o),a)).join("");return this.url.searchParams.set("select",i),n&&this.headers.append("Prefer",`count=${n}`),new ql({method:s,url:this.url,headers:this.headers,schema:this.schema,fetch:this.fetch})}insert(t,{count:e,defaultToNull:r=!0}={}){var n;const s="POST";if(e&&this.headers.append("Prefer",`count=${e}`),r||this.headers.append("Prefer","missing=default"),Array.isArray(t)){const o=t.reduce((i,a)=>i.concat(Object.keys(a)),[]);if(o.length>0){const i=[...new Set(o)].map(a=>`"${a}"`);this.url.searchParams.set("columns",i.join(","))}}return new ql({method:s,url:this.url,headers:this.headers,schema:this.schema,body:t,fetch:(n=this.fetch)!==null&&n!==void 0?n:fetch})}upsert(t,{onConflict:e,ignoreDuplicates:r=!1,count:n,defaultToNull:s=!0}={}){var o;const i="POST";if(this.headers.append("Prefer",`resolution=${r?"ignore":"merge"}-duplicates`),e!==void 0&&this.url.searchParams.set("on_conflict",e),n&&this.headers.append("Prefer",`count=${n}`),s||this.headers.append("Prefer","missing=default"),Array.isArray(t)){const a=t.reduce((c,d)=>c.concat(Object.keys(d)),[]);if(a.length>0){const c=[...new Set(a)].map(d=>`"${d}"`);this.url.searchParams.set("columns",c.join(","))}}return new ql({method:i,url:this.url,headers:this.headers,schema:this.schema,body:t,fetch:(o=this.fetch)!==null&&o!==void 0?o:fetch})}update(t,{count:e}={}){var r;const n="PATCH";return e&&this.headers.append("Prefer",`count=${e}`),new ql({method:n,url:this.url,headers:this.headers,schema:this.schema,body:t,fetch:(r=this.fetch)!==null&&r!==void 0?r:fetch})}delete({count:t}={}){var e;const r="DELETE";return t&&this.headers.append("Prefer",`count=${t}`),new ql({method:r,url:this.url,headers:this.headers,schema:this.schema,fetch:(e=this.fetch)!==null&&e!==void 0?e:fetch})}},W8=class oD{constructor(e,{headers:r={},schema:n,fetch:s}={}){this.url=e,this.headers=new Headers(r),this.schemaName=n,this.fetch=s}from(e){if(!e||typeof e!="string"||e.trim()==="")throw new Error("Invalid relation name: relation must be a non-empty string.");return new V8(new URL(`${this.url}/${e}`),{headers:new Headers(this.headers),schema:this.schemaName,fetch:this.fetch})}schema(e){return new oD(this.url,{headers:this.headers,schema:e,fetch:this.fetch})}rpc(e,r={},{head:n=!1,get:s=!1,count:o}={}){var i;let a;const c=new URL(`${this.url}/rpc/${e}`);let d;n||s?(a=n?"HEAD":"GET",Object.entries(r).filter(([h,f])=>f!==void 0).map(([h,f])=>[h,Array.isArray(f)?`{${f.join(",")}}`:`${f}`]).forEach(([h,f])=>{c.searchParams.append(h,f)})):(a="POST",d=r);const u=new Headers(this.headers);return o&&u.set("Prefer",`count=${o}`),new ql({method:a,url:c,headers:u,schema:this.schemaName,body:d,fetch:(i=this.fetch)!==null&&i!==void 0?i:fetch})}};class H8{constructor(){}static detectEnvironment(){var e;if(typeof WebSocket<"u")return{type:"native",constructor:WebSocket};if(typeof globalThis<"u"&&typeof globalThis.WebSocket<"u")return{type:"native",constructor:globalThis.WebSocket};if(typeof global<"u"&&typeof global.WebSocket<"u")return{type:"native",constructor:global.WebSocket};if(typeof globalThis<"u"&&typeof globalThis.WebSocketPair<"u"&&typeof globalThis.WebSocket>"u")return{type:"cloudflare",error:"Cloudflare Workers detected. WebSocket clients are not supported in Cloudflare Workers.",workaround:"Use Cloudflare Workers WebSocket API for server-side WebSocket handling, or deploy to a different runtime."};if(typeof globalThis<"u"&&globalThis.EdgeRuntime||typeof navigator<"u"&&(!((e=navigator.userAgent)===null||e===void 0)&&e.includes("Vercel-Edge")))return{type:"unsupported",error:"Edge runtime detected (Vercel Edge/Netlify Edge). WebSockets are not supported in edge functions.",workaround:"Use serverless functions or a different deployment target for WebSocket functionality."};if(typeof process<"u"){const r=process.versions;if(r&&r.node){const n=r.node,s=parseInt(n.replace(/^v/,"").split(".")[0]);return s>=22?typeof globalThis.WebSocket<"u"?{type:"native",constructor:globalThis.WebSocket}:{type:"unsupported",error:`Node.js ${s} detected but native WebSocket not found.`,workaround:"Provide a WebSocket implementation via the transport option."}:{type:"unsupported",error:`Node.js ${s} detected without native WebSocket support.`,workaround:`For Node.js < 22, install "ws" package and provide it via the transport option: import ws from "ws" new RealtimeClient(url, { transport: ws })`}}}return{type:"unsupported",error:"Unknown JavaScript runtime without WebSocket support.",workaround:"Ensure you're running in a supported environment (browser, Node.js, Deno) or provide a custom WebSocket implementation."}}static getWebSocketConstructor(){const e=this.detectEnvironment();if(e.constructor)return e.constructor;let r=e.error||"WebSocket not supported in this environment.";throw e.workaround&&(r+=` Suggested solution: ${e.workaround}`),new Error(r)}static createWebSocket(e,r){const n=this.getWebSocketConstructor();return new n(e,r)}static isWebSocketSupported(){try{const e=this.detectEnvironment();return e.type==="native"||e.type==="ws"}catch{return!1}}}const q8="realtime-js/2.88.0",T_="1.0.0",K8="2.0.0",R_=T_,nw=1e4,G8=1e3,Y8=100;var Jo;(function(t){t[t.connecting=0]="connecting",t[t.open=1]="open",t[t.closing=2]="closing",t[t.closed=3]="closed"})(Jo||(Jo={}));var Pt;(function(t){t.closed="closed",t.errored="errored",t.joined="joined",t.joining="joining",t.leaving="leaving"})(Pt||(Pt={}));var Jn;(function(t){t.close="phx_close",t.error="phx_error",t.join="phx_join",t.reply="phx_reply",t.leave="phx_leave",t.access_token="access_token"})(Jn||(Jn={}));var sw;(function(t){t.websocket="websocket"})(sw||(sw={}));var oa;(function(t){t.Connecting="connecting",t.Open="open",t.Closing="closing",t.Closed="closed"})(oa||(oa={}));class J8{constructor(e){this.HEADER_LENGTH=1,this.USER_BROADCAST_PUSH_META_LENGTH=6,this.KINDS={userBroadcastPush:3,userBroadcast:4},this.BINARY_ENCODING=0,this.JSON_ENCODING=1,this.BROADCAST_EVENT="broadcast",this.allowedMetadataKeys=[],this.allowedMetadataKeys=e??[]}encode(e,r){if(e.event===this.BROADCAST_EVENT&&!(e.payload instanceof ArrayBuffer)&&typeof e.payload.event=="string")return r(this._binaryEncodeUserBroadcastPush(e));let n=[e.join_ref,e.ref,e.topic,e.event,e.payload];return r(JSON.stringify(n))}_binaryEncodeUserBroadcastPush(e){var r;return this._isArrayBuffer((r=e.payload)===null||r===void 0?void 0:r.payload)?this._encodeBinaryUserBroadcastPush(e):this._encodeJsonUserBroadcastPush(e)}_encodeBinaryUserBroadcastPush(e){var r,n;const s=(n=(r=e.payload)===null||r===void 0?void 0:r.payload)!==null&&n!==void 0?n:new ArrayBuffer(0);return this._encodeUserBroadcastPush(e,this.BINARY_ENCODING,s)}_encodeJsonUserBroadcastPush(e){var r,n;const s=(n=(r=e.payload)===null||r===void 0?void 0:r.payload)!==null&&n!==void 0?n:{},i=new TextEncoder().encode(JSON.stringify(s)).buffer;return this._encodeUserBroadcastPush(e,this.JSON_ENCODING,i)}_encodeUserBroadcastPush(e,r,n){var s,o;const i=e.topic,a=(s=e.ref)!==null&&s!==void 0?s:"",c=(o=e.join_ref)!==null&&o!==void 0?o:"",d=e.payload.event,u=this.allowedMetadataKeys?this._pick(e.payload,this.allowedMetadataKeys):{},h=Object.keys(u).length===0?"":JSON.stringify(u);if(c.length>255)throw new Error(`joinRef length ${c.length} exceeds maximum of 255`);if(a.length>255)throw new Error(`ref length ${a.length} exceeds maximum of 255`);if(i.length>255)throw new Error(`topic length ${i.length} exceeds maximum of 255`);if(d.length>255)throw new Error(`userEvent length ${d.length} exceeds maximum of 255`);if(h.length>255)throw new Error(`metadata length ${h.length} exceeds maximum of 255`);const f=this.USER_BROADCAST_PUSH_META_LENGTH+c.length+a.length+i.length+d.length+h.length,p=new ArrayBuffer(this.HEADER_LENGTH+f);let g=new DataView(p),v=0;g.setUint8(v++,this.KINDS.userBroadcastPush),g.setUint8(v++,c.length),g.setUint8(v++,a.length),g.setUint8(v++,i.length),g.setUint8(v++,d.length),g.setUint8(v++,h.length),g.setUint8(v++,r),Array.from(c,x=>g.setUint8(v++,x.charCodeAt(0))),Array.from(a,x=>g.setUint8(v++,x.charCodeAt(0))),Array.from(i,x=>g.setUint8(v++,x.charCodeAt(0))),Array.from(d,x=>g.setUint8(v++,x.charCodeAt(0))),Array.from(h,x=>g.setUint8(v++,x.charCodeAt(0)));var y=new Uint8Array(p.byteLength+n.byteLength);return y.set(new Uint8Array(p),0),y.set(new Uint8Array(n),p.byteLength),y.buffer}decode(e,r){if(this._isArrayBuffer(e)){let n=this._binaryDecode(e);return r(n)}if(typeof e=="string"){const n=JSON.parse(e),[s,o,i,a,c]=n;return r({join_ref:s,ref:o,topic:i,event:a,payload:c})}return r({})}_binaryDecode(e){const r=new DataView(e),n=r.getUint8(0),s=new TextDecoder;switch(n){case this.KINDS.userBroadcast:return this._decodeUserBroadcast(e,r,s)}}_decodeUserBroadcast(e,r,n){const s=r.getUint8(1),o=r.getUint8(2),i=r.getUint8(3),a=r.getUint8(4);let c=this.HEADER_LENGTH+4;const d=n.decode(e.slice(c,c+s));c=c+s;const u=n.decode(e.slice(c,c+o));c=c+o;const h=n.decode(e.slice(c,c+i));c=c+i;const f=e.slice(c,e.byteLength),p=a===this.JSON_ENCODING?JSON.parse(n.decode(f)):f,g={type:this.BROADCAST_EVENT,event:u,payload:p};return i>0&&(g.meta=JSON.parse(h)),{join_ref:null,ref:null,topic:d,event:this.BROADCAST_EVENT,payload:g}}_isArrayBuffer(e){var r;return e instanceof ArrayBuffer||((r=e==null?void 0:e.constructor)===null||r===void 0?void 0:r.name)==="ArrayBuffer"}_pick(e,r){return!e||typeof e!="object"?{}:Object.fromEntries(Object.entries(e).filter(([n])=>r.includes(n)))}}class M_{constructor(e,r){this.callback=e,this.timerCalc=r,this.timer=void 0,this.tries=0,this.callback=e,this.timerCalc=r}reset(){this.tries=0,clearTimeout(this.timer),this.timer=void 0}scheduleTimeout(){clearTimeout(this.timer),this.timer=setTimeout(()=>{this.tries=this.tries+1,this.callback()},this.timerCalc(this.tries+1))}}var Ke;(function(t){t.abstime="abstime",t.bool="bool",t.date="date",t.daterange="daterange",t.float4="float4",t.float8="float8",t.int2="int2",t.int4="int4",t.int4range="int4range",t.int8="int8",t.int8range="int8range",t.json="json",t.jsonb="jsonb",t.money="money",t.numeric="numeric",t.oid="oid",t.reltime="reltime",t.text="text",t.time="time",t.timestamp="timestamp",t.timestamptz="timestamptz",t.timetz="timetz",t.tsrange="tsrange",t.tstzrange="tstzrange"})(Ke||(Ke={}));const O_=(t,e,r={})=>{var n;const s=(n=r.skipTypes)!==null&&n!==void 0?n:[];return e?Object.keys(e).reduce((o,i)=>(o[i]=Q8(i,t,e,s),o),{}):{}},Q8=(t,e,r,n)=>{const s=e.find(a=>a.name===t),o=s==null?void 0:s.type,i=r[t];return o&&!n.includes(o)?P_(o,i):ow(i)},P_=(t,e)=>{if(t.charAt(0)==="_"){const r=t.slice(1,t.length);return tV(e,r)}switch(t){case Ke.bool:return X8(e);case Ke.float4:case Ke.float8:case Ke.int2:case Ke.int4:case Ke.int8:case Ke.numeric:case Ke.oid:return Z8(e);case Ke.json:case Ke.jsonb:return eV(e);case Ke.timestamp:return rV(e);case Ke.abstime:case Ke.date:case Ke.daterange:case Ke.int4range:case Ke.int8range:case Ke.money:case Ke.reltime:case Ke.text:case Ke.time:case Ke.timestamptz:case Ke.timetz:case Ke.tsrange:case Ke.tstzrange:return ow(e);default:return ow(e)}},ow=t=>t,X8=t=>{switch(t){case"t":return!0;case"f":return!1;default:return t}},Z8=t=>{if(typeof t=="string"){const e=parseFloat(t);if(!Number.isNaN(e))return e}return t},eV=t=>{if(typeof t=="string")try{return JSON.parse(t)}catch{return t}return t},tV=(t,e)=>{if(typeof t!="string")return t;const r=t.length-1,n=t[r];if(t[0]==="{"&&n==="}"){let o;const i=t.slice(1,r);try{o=JSON.parse("["+i+"]")}catch{o=i?i.split(","):[]}return o.map(a=>P_(e,a))}return t},rV=t=>typeof t=="string"?t.replace(" ","T"):t,A_=t=>{const e=new URL(t);return e.protocol=e.protocol.replace(/^ws/i,"http"),e.pathname=e.pathname.replace(/\/+$/,"").replace(/\/socket\/websocket$/i,"").replace(/\/socket$/i,"").replace(/\/websocket$/i,""),e.pathname===""||e.pathname==="/"?e.pathname="/api/broadcast":e.pathname=e.pathname+"/api/broadcast",e.href};class iw{constructor(e,r,n={},s=nw){this.channel=e,this.event=r,this.payload=n,this.timeout=s,this.sent=!1,this.timeoutTimer=void 0,this.ref="",this.receivedResp=null,this.recHooks=[],this.refEvent=null}resend(e){this.timeout=e,this._cancelRefEvent(),this.ref="",this.refEvent=null,this.receivedResp=null,this.sent=!1,this.send()}send(){this._hasReceived("timeout")||(this.startTimeout(),this.sent=!0,this.channel.socket.push({topic:this.channel.topic,event:this.event,payload:this.payload,ref:this.ref,join_ref:this.channel._joinRef()}))}updatePayload(e){this.payload=Object.assign(Object.assign({},this.payload),e)}receive(e,r){var n;return this._hasReceived(e)&&r((n=this.receivedResp)===null||n===void 0?void 0:n.response),this.recHooks.push({status:e,callback:r}),this}startTimeout(){if(this.timeoutTimer)return;this.ref=this.channel.socket._makeRef(),this.refEvent=this.channel._replyEventName(this.ref);const e=r=>{this._cancelRefEvent(),this._cancelTimeout(),this.receivedResp=r,this._matchReceive(r)};this.channel._on(this.refEvent,{},e),this.timeoutTimer=setTimeout(()=>{this.trigger("timeout",{})},this.timeout)}trigger(e,r){this.refEvent&&this.channel._trigger(this.refEvent,{status:e,response:r})}destroy(){this._cancelRefEvent(),this._cancelTimeout()}_cancelRefEvent(){this.refEvent&&this.channel._off(this.refEvent,{})}_cancelTimeout(){clearTimeout(this.timeoutTimer),this.timeoutTimer=void 0}_matchReceive({status:e,response:r}){this.recHooks.filter(n=>n.status===e).forEach(n=>n.callback(r))}_hasReceived(e){return this.receivedResp&&this.receivedResp.status===e}}var I_;(function(t){t.SYNC="sync",t.JOIN="join",t.LEAVE="leave"})(I_||(I_={}));class uu{constructor(e,r){this.channel=e,this.state={},this.pendingDiffs=[],this.joinRef=null,this.enabled=!1,this.caller={onJoin:()=>{},onLeave:()=>{},onSync:()=>{}};const n=(r==null?void 0:r.events)||{state:"presence_state",diff:"presence_diff"};this.channel._on(n.state,{},s=>{const{onJoin:o,onLeave:i,onSync:a}=this.caller;this.joinRef=this.channel._joinRef(),this.state=uu.syncState(this.state,s,o,i),this.pendingDiffs.forEach(c=>{this.state=uu.syncDiff(this.state,c,o,i)}),this.pendingDiffs=[],a()}),this.channel._on(n.diff,{},s=>{const{onJoin:o,onLeave:i,onSync:a}=this.caller;this.inPendingSyncState()?this.pendingDiffs.push(s):(this.state=uu.syncDiff(this.state,s,o,i),a())}),this.onJoin((s,o,i)=>{this.channel._trigger("presence",{event:"join",key:s,currentPresences:o,newPresences:i})}),this.onLeave((s,o,i)=>{this.channel._trigger("presence",{event:"leave",key:s,currentPresences:o,leftPresences:i})}),this.onSync(()=>{this.channel._trigger("presence",{event:"sync"})})}static syncState(e,r,n,s){const o=this.cloneDeep(e),i=this.transformState(r),a={},c={};return this.map(o,(d,u)=>{i[d]||(c[d]=u)}),this.map(i,(d,u)=>{const h=o[d];if(h){const f=u.map(y=>y.presence_ref),p=h.map(y=>y.presence_ref),g=u.filter(y=>p.indexOf(y.presence_ref)<0),v=h.filter(y=>f.indexOf(y.presence_ref)<0);g.length>0&&(a[d]=g),v.length>0&&(c[d]=v)}else a[d]=u}),this.syncDiff(o,{joins:a,leaves:c},n,s)}static syncDiff(e,r,n,s){const{joins:o,leaves:i}={joins:this.transformState(r.joins),leaves:this.transformState(r.leaves)};return n||(n=()=>{}),s||(s=()=>{}),this.map(o,(a,c)=>{var d;const u=(d=e[a])!==null&&d!==void 0?d:[];if(e[a]=this.cloneDeep(c),u.length>0){const h=e[a].map(p=>p.presence_ref),f=u.filter(p=>h.indexOf(p.presence_ref)<0);e[a].unshift(...f)}n(a,u,c)}),this.map(i,(a,c)=>{let d=e[a];if(!d)return;const u=c.map(h=>h.presence_ref);d=d.filter(h=>u.indexOf(h.presence_ref)<0),e[a]=d,s(a,d,c),d.length===0&&delete e[a]}),e}static map(e,r){return Object.getOwnPropertyNames(e).map(n=>r(n,e[n]))}static transformState(e){return e=this.cloneDeep(e),Object.getOwnPropertyNames(e).reduce((r,n)=>{const s=e[n];return"metas"in s?r[n]=s.metas.map(o=>(o.presence_ref=o.phx_ref,delete o.phx_ref,delete o.phx_ref_prev,o)):r[n]=s,r},{})}static cloneDeep(e){return JSON.parse(JSON.stringify(e))}onJoin(e){this.caller.onJoin=e}onLeave(e){this.caller.onLeave=e}onSync(e){this.caller.onSync=e}inPendingSyncState(){return!this.joinRef||this.joinRef!==this.channel._joinRef()}}var D_;(function(t){t.ALL="*",t.INSERT="INSERT",t.UPDATE="UPDATE",t.DELETE="DELETE"})(D_||(D_={}));var hu;(function(t){t.BROADCAST="broadcast",t.PRESENCE="presence",t.POSTGRES_CHANGES="postgres_changes",t.SYSTEM="system"})(hu||(hu={}));var to;(function(t){t.SUBSCRIBED="SUBSCRIBED",t.TIMED_OUT="TIMED_OUT",t.CLOSED="CLOSED",t.CHANNEL_ERROR="CHANNEL_ERROR"})(to||(to={}));class Kl{constructor(e,r={config:{}},n){var s,o;if(this.topic=e,this.params=r,this.socket=n,this.bindings={},this.state=Pt.closed,this.joinedOnce=!1,this.pushBuffer=[],this.subTopic=e.replace(/^realtime:/i,""),this.params.config=Object.assign({broadcast:{ack:!1,self:!1},presence:{key:"",enabled:!1},private:!1},r.config),this.timeout=this.socket.timeout,this.joinPush=new iw(this,Jn.join,this.params,this.timeout),this.rejoinTimer=new M_(()=>this._rejoinUntilConnected(),this.socket.reconnectAfterMs),this.joinPush.receive("ok",()=>{this.state=Pt.joined,this.rejoinTimer.reset(),this.pushBuffer.forEach(i=>i.send()),this.pushBuffer=[]}),this._onClose(()=>{this.rejoinTimer.reset(),this.socket.log("channel",`close ${this.topic} ${this._joinRef()}`),this.state=Pt.closed,this.socket._remove(this)}),this._onError(i=>{this._isLeaving()||this._isClosed()||(this.socket.log("channel",`error ${this.topic}`,i),this.state=Pt.errored,this.rejoinTimer.scheduleTimeout())}),this.joinPush.receive("timeout",()=>{this._isJoining()&&(this.socket.log("channel",`timeout ${this.topic}`,this.joinPush.timeout),this.state=Pt.errored,this.rejoinTimer.scheduleTimeout())}),this.joinPush.receive("error",i=>{this._isLeaving()||this._isClosed()||(this.socket.log("channel",`error ${this.topic}`,i),this.state=Pt.errored,this.rejoinTimer.scheduleTimeout())}),this._on(Jn.reply,{},(i,a)=>{this._trigger(this._replyEventName(a),i)}),this.presence=new uu(this),this.broadcastEndpointURL=A_(this.socket.endPoint),this.private=this.params.config.private||!1,!this.private&&(!((o=(s=this.params.config)===null||s===void 0?void 0:s.broadcast)===null||o===void 0)&&o.replay))throw`tried to use replay on public channel '${this.topic}'. It must be a private channel.`}subscribe(e,r=this.timeout){var n,s,o;if(this.socket.isConnected()||this.socket.connect(),this.state==Pt.closed){const{config:{broadcast:i,presence:a,private:c}}=this.params,d=(s=(n=this.bindings.postgres_changes)===null||n===void 0?void 0:n.map(p=>p.filter))!==null&&s!==void 0?s:[],u=!!this.bindings[hu.PRESENCE]&&this.bindings[hu.PRESENCE].length>0||((o=this.params.config.presence)===null||o===void 0?void 0:o.enabled)===!0,h={},f={broadcast:i,presence:Object.assign(Object.assign({},a),{enabled:u}),postgres_changes:d,private:c};this.socket.accessTokenValue&&(h.access_token=this.socket.accessTokenValue),this._onError(p=>e==null?void 0:e(to.CHANNEL_ERROR,p)),this._onClose(()=>e==null?void 0:e(to.CLOSED)),this.updateJoinPayload(Object.assign({config:f},h)),this.joinedOnce=!0,this._rejoin(r),this.joinPush.receive("ok",async({postgres_changes:p})=>{var g;if(this.socket._isManualToken()||this.socket.setAuth(),p===void 0){e==null||e(to.SUBSCRIBED);return}else{const v=this.bindings.postgres_changes,y=(g=v==null?void 0:v.length)!==null&&g!==void 0?g:0,x=[];for(let w=0;w{this.state=Pt.errored,e==null||e(to.CHANNEL_ERROR,new Error(JSON.stringify(Object.values(p).join(", ")||"error")))}).receive("timeout",()=>{e==null||e(to.TIMED_OUT)})}return this}presenceState(){return this.presence.state}async track(e,r={}){return await this.send({type:"presence",event:"track",payload:e},r.timeout||this.timeout)}async untrack(e={}){return await this.send({type:"presence",event:"untrack"},e)}on(e,r,n){return this.state===Pt.joined&&e===hu.PRESENCE&&(this.socket.log("channel",`resubscribe to ${this.topic} due to change in presence callbacks on joined channel`),this.unsubscribe().then(async()=>await this.subscribe())),this._on(e,r,n)}async httpSend(e,r,n={}){var s;if(r==null)return Promise.reject("Payload is required for httpSend()");const o={apikey:this.socket.apiKey?this.socket.apiKey:"","Content-Type":"application/json"};this.socket.accessTokenValue&&(o.Authorization=`Bearer ${this.socket.accessTokenValue}`);const i={method:"POST",headers:o,body:JSON.stringify({messages:[{topic:this.subTopic,event:e,payload:r,private:this.private}]})},a=await this._fetchWithTimeout(this.broadcastEndpointURL,i,(s=n.timeout)!==null&&s!==void 0?s:this.timeout);if(a.status===202)return{success:!0};let c=a.statusText;try{const d=await a.json();c=d.error||d.message||c}catch{}return Promise.reject(new Error(c))}async send(e,r={}){var n,s;if(!this._canPush()&&e.type==="broadcast"){console.warn("Realtime send() is automatically falling back to REST API. This behavior will be deprecated in the future. Please use httpSend() explicitly for REST delivery.");const{event:o,payload:i}=e,a={apikey:this.socket.apiKey?this.socket.apiKey:"","Content-Type":"application/json"};this.socket.accessTokenValue&&(a.Authorization=`Bearer ${this.socket.accessTokenValue}`);const c={method:"POST",headers:a,body:JSON.stringify({messages:[{topic:this.subTopic,event:o,payload:i,private:this.private}]})};try{const d=await this._fetchWithTimeout(this.broadcastEndpointURL,c,(n=r.timeout)!==null&&n!==void 0?n:this.timeout);return await((s=d.body)===null||s===void 0?void 0:s.cancel()),d.ok?"ok":"error"}catch(d){return d.name==="AbortError"?"timed out":"error"}}else return new Promise(o=>{var i,a,c;const d=this._push(e.type,e,r.timeout||this.timeout);e.type==="broadcast"&&!(!((c=(a=(i=this.params)===null||i===void 0?void 0:i.config)===null||a===void 0?void 0:a.broadcast)===null||c===void 0)&&c.ack)&&o("ok"),d.receive("ok",()=>o("ok")),d.receive("error",()=>o("error")),d.receive("timeout",()=>o("timed out"))})}updateJoinPayload(e){this.joinPush.updatePayload(e)}unsubscribe(e=this.timeout){this.state=Pt.leaving;const r=()=>{this.socket.log("channel",`leave ${this.topic}`),this._trigger(Jn.close,"leave",this._joinRef())};this.joinPush.destroy();let n=null;return new Promise(s=>{n=new iw(this,Jn.leave,{},e),n.receive("ok",()=>{r(),s("ok")}).receive("timeout",()=>{r(),s("timed out")}).receive("error",()=>{s("error")}),n.send(),this._canPush()||n.trigger("ok",{})}).finally(()=>{n==null||n.destroy()})}teardown(){this.pushBuffer.forEach(e=>e.destroy()),this.pushBuffer=[],this.rejoinTimer.reset(),this.joinPush.destroy(),this.state=Pt.closed,this.bindings={}}async _fetchWithTimeout(e,r,n){const s=new AbortController,o=setTimeout(()=>s.abort(),n),i=await this.socket.fetch(e,Object.assign(Object.assign({},r),{signal:s.signal}));return clearTimeout(o),i}_push(e,r,n=this.timeout){if(!this.joinedOnce)throw`tried to push '${e}' to '${this.topic}' before joining. Use channel.subscribe() before pushing events`;let s=new iw(this,e,r,n);return this._canPush()?s.send():this._addToPushBuffer(s),s}_addToPushBuffer(e){if(e.startTimeout(),this.pushBuffer.push(e),this.pushBuffer.length>Y8){const r=this.pushBuffer.shift();r&&(r.destroy(),this.socket.log("channel",`discarded push due to buffer overflow: ${r.event}`,r.payload))}}_onMessage(e,r,n){return r}_isMember(e){return this.topic===e}_joinRef(){return this.joinPush.ref}_trigger(e,r,n){var s,o;const i=e.toLocaleLowerCase(),{close:a,error:c,leave:d,join:u}=Jn;if(n&&[a,c,d,u].indexOf(i)>=0&&n!==this._joinRef())return;let f=this._onMessage(i,r,n);if(r&&!f)throw"channel onMessage callbacks must return the payload, modified or unmodified";["insert","update","delete"].includes(i)?(s=this.bindings.postgres_changes)===null||s===void 0||s.filter(p=>{var g,v,y;return((g=p.filter)===null||g===void 0?void 0:g.event)==="*"||((y=(v=p.filter)===null||v===void 0?void 0:v.event)===null||y===void 0?void 0:y.toLocaleLowerCase())===i}).map(p=>p.callback(f,n)):(o=this.bindings[i])===null||o===void 0||o.filter(p=>{var g,v,y,x,w,b;if(["broadcast","presence","postgres_changes"].includes(i))if("id"in p){const k=p.id,S=(g=p.filter)===null||g===void 0?void 0:g.event;return k&&((v=r.ids)===null||v===void 0?void 0:v.includes(k))&&(S==="*"||(S==null?void 0:S.toLocaleLowerCase())===((y=r.data)===null||y===void 0?void 0:y.type.toLocaleLowerCase()))}else{const k=(w=(x=p==null?void 0:p.filter)===null||x===void 0?void 0:x.event)===null||w===void 0?void 0:w.toLocaleLowerCase();return k==="*"||k===((b=r==null?void 0:r.event)===null||b===void 0?void 0:b.toLocaleLowerCase())}else return p.type.toLocaleLowerCase()===i}).map(p=>{if(typeof f=="object"&&"ids"in f){const g=f.data,{schema:v,table:y,commit_timestamp:x,type:w,errors:b}=g;f=Object.assign(Object.assign({},{schema:v,table:y,commit_timestamp:x,eventType:w,new:{},old:{},errors:b}),this._getPayloadRecords(g))}p.callback(f,n)})}_isClosed(){return this.state===Pt.closed}_isJoined(){return this.state===Pt.joined}_isJoining(){return this.state===Pt.joining}_isLeaving(){return this.state===Pt.leaving}_replyEventName(e){return`chan_reply_${e}`}_on(e,r,n){const s=e.toLocaleLowerCase(),o={type:s,filter:r,callback:n};return this.bindings[s]?this.bindings[s].push(o):this.bindings[s]=[o],this}_off(e,r){const n=e.toLocaleLowerCase();return this.bindings[n]&&(this.bindings[n]=this.bindings[n].filter(s=>{var o;return!(((o=s.type)===null||o===void 0?void 0:o.toLocaleLowerCase())===n&&Kl.isEqual(s.filter,r))})),this}static isEqual(e,r){if(Object.keys(e).length!==Object.keys(r).length)return!1;for(const n in e)if(e[n]!==r[n])return!1;return!0}static isFilterValueEqual(e,r){return(e??void 0)===(r??void 0)}_rejoinUntilConnected(){this.rejoinTimer.scheduleTimeout(),this.socket.isConnected()&&this._rejoin()}_onClose(e){this._on(Jn.close,{},e)}_onError(e){this._on(Jn.error,{},r=>e(r))}_canPush(){return this.socket.isConnected()&&this._isJoined()}_rejoin(e=this.timeout){this._isLeaving()||(this.socket._leaveOpenTopic(this.topic),this.state=Pt.joining,this.joinPush.resend(e))}_getPayloadRecords(e){const r={new:{},old:{}};return(e.type==="INSERT"||e.type==="UPDATE")&&(r.new=O_(e.columns,e.record)),(e.type==="UPDATE"||e.type==="DELETE")&&(r.old=O_(e.columns,e.old_record)),r}}const aw=()=>{},Ap={HEARTBEAT_INTERVAL:25e3,RECONNECT_DELAY:10,HEARTBEAT_TIMEOUT_FALLBACK:100},nV=[1e3,2e3,5e3,1e4],sV=1e4,oV=` addEventListener("message", (e) => { if (e.data.event === "start") { setInterval(() => postMessage({ event: "keepAlive" }), e.data.interval); } });`;class iV{constructor(e,r){var n;if(this.accessTokenValue=null,this.apiKey=null,this._manuallySetToken=!1,this.channels=new Array,this.endPoint="",this.httpEndpoint="",this.headers={},this.params={},this.timeout=nw,this.transport=null,this.heartbeatIntervalMs=Ap.HEARTBEAT_INTERVAL,this.heartbeatTimer=void 0,this.pendingHeartbeatRef=null,this.heartbeatCallback=aw,this.ref=0,this.reconnectTimer=null,this.vsn=R_,this.logger=aw,this.conn=null,this.sendBuffer=[],this.serializer=new J8,this.stateChangeCallbacks={open:[],close:[],error:[],message:[]},this.accessToken=null,this._connectionState="disconnected",this._wasManualDisconnect=!1,this._authPromise=null,this._resolveFetch=s=>s?(...o)=>s(...o):(...o)=>fetch(...o),!(!((n=r==null?void 0:r.params)===null||n===void 0)&&n.apikey))throw new Error("API key is required to connect to Realtime");this.apiKey=r.params.apikey,this.endPoint=`${e}/${sw.websocket}`,this.httpEndpoint=A_(e),this._initializeOptions(r),this._setupReconnectionTimer(),this.fetch=this._resolveFetch(r==null?void 0:r.fetch)}connect(){if(!(this.isConnecting()||this.isDisconnecting()||this.conn!==null&&this.isConnected())){if(this._setConnectionState("connecting"),this.accessToken&&!this._authPromise&&this._setAuthSafely("connect"),this.transport)this.conn=new this.transport(this.endpointURL());else try{this.conn=H8.createWebSocket(this.endpointURL())}catch(e){this._setConnectionState("disconnected");const r=e.message;throw r.includes("Node.js")?new Error(`${r} To use Realtime in Node.js, you need to provide a WebSocket implementation: Option 1: Use Node.js 22+ which has native WebSocket support Option 2: Install and provide the "ws" package: npm install ws import ws from "ws" const client = new RealtimeClient(url, { ...options, transport: ws })`):new Error(`WebSocket not available: ${r}`)}this._setupConnectionHandlers()}}endpointURL(){return this._appendParams(this.endPoint,Object.assign({},this.params,{vsn:this.vsn}))}disconnect(e,r){if(!this.isDisconnecting())if(this._setConnectionState("disconnecting",!0),this.conn){const n=setTimeout(()=>{this._setConnectionState("disconnected")},100);this.conn.onclose=()=>{clearTimeout(n),this._setConnectionState("disconnected")},typeof this.conn.close=="function"&&(e?this.conn.close(e,r??""):this.conn.close()),this._teardownConnection()}else this._setConnectionState("disconnected")}getChannels(){return this.channels}async removeChannel(e){const r=await e.unsubscribe();return this.channels.length===0&&this.disconnect(),r}async removeAllChannels(){const e=await Promise.all(this.channels.map(r=>r.unsubscribe()));return this.channels=[],this.disconnect(),e}log(e,r,n){this.logger(e,r,n)}connectionState(){switch(this.conn&&this.conn.readyState){case Jo.connecting:return oa.Connecting;case Jo.open:return oa.Open;case Jo.closing:return oa.Closing;default:return oa.Closed}}isConnected(){return this.connectionState()===oa.Open}isConnecting(){return this._connectionState==="connecting"}isDisconnecting(){return this._connectionState==="disconnecting"}channel(e,r={config:{}}){const n=`realtime:${e}`,s=this.getChannels().find(o=>o.topic===n);if(s)return s;{const o=new Kl(`realtime:${e}`,r,this);return this.channels.push(o),o}}push(e){const{topic:r,event:n,payload:s,ref:o}=e,i=()=>{this.encode(e,a=>{var c;(c=this.conn)===null||c===void 0||c.send(a)})};this.log("push",`${r} ${n} (${o})`,s),this.isConnected()?i():this.sendBuffer.push(i)}async setAuth(e=null){this._authPromise=this._performAuth(e);try{await this._authPromise}finally{this._authPromise=null}}_isManualToken(){return this._manuallySetToken}async sendHeartbeat(){var e;if(!this.isConnected()){try{this.heartbeatCallback("disconnected")}catch(r){this.log("error","error in heartbeat callback",r)}return}if(this.pendingHeartbeatRef){this.pendingHeartbeatRef=null,this.log("transport","heartbeat timeout. Attempting to re-establish connection");try{this.heartbeatCallback("timeout")}catch(r){this.log("error","error in heartbeat callback",r)}this._wasManualDisconnect=!1,(e=this.conn)===null||e===void 0||e.close(G8,"heartbeat timeout"),setTimeout(()=>{var r;this.isConnected()||(r=this.reconnectTimer)===null||r===void 0||r.scheduleTimeout()},Ap.HEARTBEAT_TIMEOUT_FALLBACK);return}this.pendingHeartbeatRef=this._makeRef(),this.push({topic:"phoenix",event:"heartbeat",payload:{},ref:this.pendingHeartbeatRef});try{this.heartbeatCallback("sent")}catch(r){this.log("error","error in heartbeat callback",r)}this._setAuthSafely("heartbeat")}onHeartbeat(e){this.heartbeatCallback=e}flushSendBuffer(){this.isConnected()&&this.sendBuffer.length>0&&(this.sendBuffer.forEach(e=>e()),this.sendBuffer=[])}_makeRef(){let e=this.ref+1;return e===this.ref?this.ref=0:this.ref=e,this.ref.toString()}_leaveOpenTopic(e){let r=this.channels.find(n=>n.topic===e&&(n._isJoined()||n._isJoining()));r&&(this.log("transport",`leaving duplicate topic "${e}"`),r.unsubscribe())}_remove(e){this.channels=this.channels.filter(r=>r.topic!==e.topic)}_onConnMessage(e){this.decode(e.data,r=>{if(r.topic==="phoenix"&&r.event==="phx_reply")try{this.heartbeatCallback(r.payload.status==="ok"?"ok":"error")}catch(d){this.log("error","error in heartbeat callback",d)}r.ref&&r.ref===this.pendingHeartbeatRef&&(this.pendingHeartbeatRef=null);const{topic:n,event:s,payload:o,ref:i}=r,a=i?`(${i})`:"",c=o.status||"";this.log("receive",`${c} ${n} ${s} ${a}`.trim(),o),this.channels.filter(d=>d._isMember(n)).forEach(d=>d._trigger(s,o,i)),this._triggerStateCallbacks("message",r)})}_clearTimer(e){var r;e==="heartbeat"&&this.heartbeatTimer?(clearInterval(this.heartbeatTimer),this.heartbeatTimer=void 0):e==="reconnect"&&((r=this.reconnectTimer)===null||r===void 0||r.reset())}_clearAllTimers(){this._clearTimer("heartbeat"),this._clearTimer("reconnect")}_setupConnectionHandlers(){this.conn&&("binaryType"in this.conn&&(this.conn.binaryType="arraybuffer"),this.conn.onopen=()=>this._onConnOpen(),this.conn.onerror=e=>this._onConnError(e),this.conn.onmessage=e=>this._onConnMessage(e),this.conn.onclose=e=>this._onConnClose(e),this.conn.readyState===Jo.open&&this._onConnOpen())}_teardownConnection(){if(this.conn){if(this.conn.readyState===Jo.open||this.conn.readyState===Jo.connecting)try{this.conn.close()}catch(e){this.log("error","Error closing connection",e)}this.conn.onopen=null,this.conn.onerror=null,this.conn.onmessage=null,this.conn.onclose=null,this.conn=null}this._clearAllTimers(),this._terminateWorker(),this.channels.forEach(e=>e.teardown())}_onConnOpen(){this._setConnectionState("connected"),this.log("transport",`connected to ${this.endpointURL()}`),(this._authPromise||(this.accessToken&&!this.accessTokenValue?this.setAuth():Promise.resolve())).then(()=>{this.flushSendBuffer()}).catch(r=>{this.log("error","error waiting for auth on connect",r),this.flushSendBuffer()}),this._clearTimer("reconnect"),this.worker?this.workerRef||this._startWorkerHeartbeat():this._startHeartbeat(),this._triggerStateCallbacks("open")}_startHeartbeat(){this.heartbeatTimer&&clearInterval(this.heartbeatTimer),this.heartbeatTimer=setInterval(()=>this.sendHeartbeat(),this.heartbeatIntervalMs)}_startWorkerHeartbeat(){this.workerUrl?this.log("worker",`starting worker for from ${this.workerUrl}`):this.log("worker","starting default worker");const e=this._workerObjectUrl(this.workerUrl);this.workerRef=new Worker(e),this.workerRef.onerror=r=>{this.log("worker","worker error",r.message),this._terminateWorker()},this.workerRef.onmessage=r=>{r.data.event==="keepAlive"&&this.sendHeartbeat()},this.workerRef.postMessage({event:"start",interval:this.heartbeatIntervalMs})}_terminateWorker(){this.workerRef&&(this.log("worker","terminating worker"),this.workerRef.terminate(),this.workerRef=void 0)}_onConnClose(e){var r;this._setConnectionState("disconnected"),this.log("transport","close",e),this._triggerChanError(),this._clearTimer("heartbeat"),this._wasManualDisconnect||(r=this.reconnectTimer)===null||r===void 0||r.scheduleTimeout(),this._triggerStateCallbacks("close",e)}_onConnError(e){this._setConnectionState("disconnected"),this.log("transport",`${e}`),this._triggerChanError(),this._triggerStateCallbacks("error",e)}_triggerChanError(){this.channels.forEach(e=>e._trigger(Jn.error))}_appendParams(e,r){if(Object.keys(r).length===0)return e;const n=e.match(/\?/)?"&":"?",s=new URLSearchParams(r);return`${e}${n}${s}`}_workerObjectUrl(e){let r;if(e)r=e;else{const n=new Blob([oV],{type:"application/javascript"});r=URL.createObjectURL(n)}return r}_setConnectionState(e,r=!1){this._connectionState=e,e==="connecting"?this._wasManualDisconnect=!1:e==="disconnecting"&&(this._wasManualDisconnect=r)}async _performAuth(e=null){let r,n=!1;if(e)r=e,n=!0;else if(this.accessToken)try{r=await this.accessToken()}catch(s){this.log("error","Error fetching access token from callback",s),r=this.accessTokenValue}else r=this.accessTokenValue;n?this._manuallySetToken=!0:this.accessToken&&(this._manuallySetToken=!1),this.accessTokenValue!=r&&(this.accessTokenValue=r,this.channels.forEach(s=>{const o={access_token:r,version:q8};r&&s.updateJoinPayload(o),s.joinedOnce&&s._isJoined()&&s._push(Jn.access_token,{access_token:r})}))}async _waitForAuthIfNeeded(){this._authPromise&&await this._authPromise}_setAuthSafely(e="general"){this._isManualToken()||this.setAuth().catch(r=>{this.log("error",`Error setting auth in ${e}`,r)})}_triggerStateCallbacks(e,r){try{this.stateChangeCallbacks[e].forEach(n=>{try{n(r)}catch(s){this.log("error",`error in ${e} callback`,s)}})}catch(n){this.log("error",`error triggering ${e} callbacks`,n)}}_setupReconnectionTimer(){this.reconnectTimer=new M_(async()=>{setTimeout(async()=>{await this._waitForAuthIfNeeded(),this.isConnected()||this.connect()},Ap.RECONNECT_DELAY)},this.reconnectAfterMs)}_initializeOptions(e){var r,n,s,o,i,a,c,d,u,h,f,p;switch(this.transport=(r=e==null?void 0:e.transport)!==null&&r!==void 0?r:null,this.timeout=(n=e==null?void 0:e.timeout)!==null&&n!==void 0?n:nw,this.heartbeatIntervalMs=(s=e==null?void 0:e.heartbeatIntervalMs)!==null&&s!==void 0?s:Ap.HEARTBEAT_INTERVAL,this.worker=(o=e==null?void 0:e.worker)!==null&&o!==void 0?o:!1,this.accessToken=(i=e==null?void 0:e.accessToken)!==null&&i!==void 0?i:null,this.heartbeatCallback=(a=e==null?void 0:e.heartbeatCallback)!==null&&a!==void 0?a:aw,this.vsn=(c=e==null?void 0:e.vsn)!==null&&c!==void 0?c:R_,e!=null&&e.params&&(this.params=e.params),e!=null&&e.logger&&(this.logger=e.logger),(e!=null&&e.logLevel||e!=null&&e.log_level)&&(this.logLevel=e.logLevel||e.log_level,this.params=Object.assign(Object.assign({},this.params),{log_level:this.logLevel})),this.reconnectAfterMs=(d=e==null?void 0:e.reconnectAfterMs)!==null&&d!==void 0?d:g=>nV[g-1]||sV,this.vsn){case T_:this.encode=(u=e==null?void 0:e.encode)!==null&&u!==void 0?u:(g,v)=>v(JSON.stringify(g)),this.decode=(h=e==null?void 0:e.decode)!==null&&h!==void 0?h:(g,v)=>v(JSON.parse(g));break;case K8:this.encode=(f=e==null?void 0:e.encode)!==null&&f!==void 0?f:this.serializer.encode.bind(this.serializer),this.decode=(p=e==null?void 0:e.decode)!==null&&p!==void 0?p:this.serializer.decode.bind(this.serializer);break;default:throw new Error(`Unsupported serializer version: ${this.vsn}`)}if(this.worker){if(typeof window<"u"&&!window.Worker)throw new Error("Web Worker is not supported");this.workerUrl=e==null?void 0:e.workerUrl}}}var fu=class extends Error{constructor(t,e){var r;super(t),this.name="IcebergError",this.status=e.status,this.icebergType=e.icebergType,this.icebergCode=e.icebergCode,this.details=e.details,this.isCommitStateUnknown=e.icebergType==="CommitStateUnknownException"||[500,502,504].includes(e.status)&&((r=e.icebergType)==null?void 0:r.includes("CommitState"))===!0}isNotFound(){return this.status===404}isConflict(){return this.status===409}isAuthenticationTimeout(){return this.status===419}};function aV(t,e,r){const n=new URL(e,t);if(r)for(const[s,o]of Object.entries(r))o!==void 0&&n.searchParams.set(s,o);return n.toString()}async function lV(t){return!t||t.type==="none"?{}:t.type==="bearer"?{Authorization:`Bearer ${t.token}`}:t.type==="header"?{[t.name]:t.value}:t.type==="custom"?await t.getHeaders():{}}function cV(t){const e=t.fetchImpl??globalThis.fetch;return{async request({method:r,path:n,query:s,body:o,headers:i}){const a=aV(t.baseUrl,n,s),c=await lV(t.auth),d=await e(a,{method:r,headers:{...o?{"Content-Type":"application/json"}:{},...c,...i},body:o?JSON.stringify(o):void 0}),u=await d.text(),h=(d.headers.get("content-type")||"").includes("application/json"),f=h&&u?JSON.parse(u):u;if(!d.ok){const p=h?f:void 0,g=p==null?void 0:p.error;throw new fu((g==null?void 0:g.message)??`Request failed with status ${d.status}`,{status:d.status,icebergType:g==null?void 0:g.type,icebergCode:g==null?void 0:g.code,details:p})}return{status:d.status,headers:d.headers,data:f}}}}function Ip(t){return t.join("")}var dV=class{constructor(t,e=""){this.client=t,this.prefix=e}async listNamespaces(t){const e=t?{parent:Ip(t.namespace)}:void 0;return(await this.client.request({method:"GET",path:`${this.prefix}/namespaces`,query:e})).data.namespaces.map(n=>({namespace:n}))}async createNamespace(t,e){const r={namespace:t.namespace,properties:e==null?void 0:e.properties};return(await this.client.request({method:"POST",path:`${this.prefix}/namespaces`,body:r})).data}async dropNamespace(t){await this.client.request({method:"DELETE",path:`${this.prefix}/namespaces/${Ip(t.namespace)}`})}async loadNamespaceMetadata(t){return{properties:(await this.client.request({method:"GET",path:`${this.prefix}/namespaces/${Ip(t.namespace)}`})).data.properties}}async namespaceExists(t){try{return await this.client.request({method:"HEAD",path:`${this.prefix}/namespaces/${Ip(t.namespace)}`}),!0}catch(e){if(e instanceof fu&&e.status===404)return!1;throw e}}async createNamespaceIfNotExists(t,e){try{return await this.createNamespace(t,e)}catch(r){if(r instanceof fu&&r.status===409)return;throw r}}};function Gl(t){return t.join("")}var uV=class{constructor(t,e="",r){this.client=t,this.prefix=e,this.accessDelegation=r}async listTables(t){return(await this.client.request({method:"GET",path:`${this.prefix}/namespaces/${Gl(t.namespace)}/tables`})).data.identifiers}async createTable(t,e){const r={};return this.accessDelegation&&(r["X-Iceberg-Access-Delegation"]=this.accessDelegation),(await this.client.request({method:"POST",path:`${this.prefix}/namespaces/${Gl(t.namespace)}/tables`,body:e,headers:r})).data.metadata}async updateTable(t,e){const r=await this.client.request({method:"POST",path:`${this.prefix}/namespaces/${Gl(t.namespace)}/tables/${t.name}`,body:e});return{"metadata-location":r.data["metadata-location"],metadata:r.data.metadata}}async dropTable(t,e){await this.client.request({method:"DELETE",path:`${this.prefix}/namespaces/${Gl(t.namespace)}/tables/${t.name}`,query:{purgeRequested:String((e==null?void 0:e.purge)??!1)}})}async loadTable(t){const e={};return this.accessDelegation&&(e["X-Iceberg-Access-Delegation"]=this.accessDelegation),(await this.client.request({method:"GET",path:`${this.prefix}/namespaces/${Gl(t.namespace)}/tables/${t.name}`,headers:e})).data.metadata}async tableExists(t){const e={};this.accessDelegation&&(e["X-Iceberg-Access-Delegation"]=this.accessDelegation);try{return await this.client.request({method:"HEAD",path:`${this.prefix}/namespaces/${Gl(t.namespace)}/tables/${t.name}`,headers:e}),!0}catch(r){if(r instanceof fu&&r.status===404)return!1;throw r}}async createTableIfNotExists(t,e){try{return await this.createTable(t,e)}catch(r){if(r instanceof fu&&r.status===409)return await this.loadTable({namespace:t.namespace,name:e.name});throw r}}},hV=class{constructor(t){var n;let e="v1";t.catalogName&&(e+=`/${t.catalogName}`);const r=t.baseUrl.endsWith("/")?t.baseUrl:`${t.baseUrl}/`;this.client=cV({baseUrl:r,auth:t.auth,fetchImpl:t.fetch}),this.accessDelegation=(n=t.accessDelegation)==null?void 0:n.join(","),this.namespaceOps=new dV(this.client,e),this.tableOps=new uV(this.client,e,this.accessDelegation)}async listNamespaces(t){return this.namespaceOps.listNamespaces(t)}async createNamespace(t,e){return this.namespaceOps.createNamespace(t,e)}async dropNamespace(t){await this.namespaceOps.dropNamespace(t)}async loadNamespaceMetadata(t){return this.namespaceOps.loadNamespaceMetadata(t)}async listTables(t){return this.tableOps.listTables(t)}async createTable(t,e){return this.tableOps.createTable(t,e)}async updateTable(t,e){return this.tableOps.updateTable(t,e)}async dropTable(t,e){await this.tableOps.dropTable(t,e)}async loadTable(t){return this.tableOps.loadTable(t)}async namespaceExists(t){return this.namespaceOps.namespaceExists(t)}async tableExists(t){return this.tableOps.tableExists(t)}async createNamespaceIfNotExists(t,e){return this.namespaceOps.createNamespaceIfNotExists(t,e)}async createTableIfNotExists(t,e){return this.tableOps.createTableIfNotExists(t,e)}},Dp=class extends Error{constructor(t){super(t),this.__isStorageError=!0,this.name="StorageError"}};function ot(t){return typeof t=="object"&&t!==null&&"__isStorageError"in t}var fV=class extends Dp{constructor(t,e,r){super(t),this.name="StorageApiError",this.status=e,this.statusCode=r}toJSON(){return{name:this.name,message:this.message,status:this.status,statusCode:this.statusCode}}},lw=class extends Dp{constructor(t,e){super(t),this.name="StorageUnknownError",this.originalError=e}};const cw=t=>t?(...e)=>t(...e):(...e)=>fetch(...e),pV=()=>Response,dw=t=>{if(Array.isArray(t))return t.map(r=>dw(r));if(typeof t=="function"||t!==Object(t))return t;const e={};return Object.entries(t).forEach(([r,n])=>{const s=r.replace(/([-_][a-z])/gi,o=>o.toUpperCase().replace(/[-_]/g,""));e[s]=dw(n)}),e},mV=t=>{if(typeof t!="object"||t===null)return!1;const e=Object.getPrototypeOf(t);return(e===null||e===Object.prototype||Object.getPrototypeOf(e)===null)&&!(Symbol.toStringTag in t)&&!(Symbol.iterator in t)},gV=t=>!t||typeof t!="string"||t.length===0||t.length>100||t.trim()!==t||t.includes("/")||t.includes("\\")?!1:/^[\w!.\*'() &$@=;:+,?-]+$/.test(t);function pu(t){"@babel/helpers - typeof";return pu=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},pu(t)}function vV(t,e){if(pu(t)!="object"||!t)return t;var r=t[Symbol.toPrimitive];if(r!==void 0){var n=r.call(t,e||"default");if(pu(n)!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function yV(t){var e=vV(t,"string");return pu(e)=="symbol"?e:e+""}function xV(t,e,r){return(e=yV(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function L_(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(s){return Object.getOwnPropertyDescriptor(t,s).enumerable})),r.push.apply(r,n)}return r}function be(t){for(var e=1;e{var e;return t.msg||t.message||t.error_description||(typeof t.error=="string"?t.error:(e=t.error)===null||e===void 0?void 0:e.message)||JSON.stringify(t)},wV=async(t,e,r)=>{t instanceof await pV()&&!(r!=null&&r.noResolveJson)?t.json().then(n=>{const s=t.status||500,o=(n==null?void 0:n.statusCode)||s+"";e(new fV(uw(n),s,o))}).catch(n=>{e(new lw(uw(n),n))}):e(new lw(uw(t),t))},bV=(t,e,r,n)=>{const s={method:t,headers:(e==null?void 0:e.headers)||{}};return t==="GET"||!n?s:(mV(n)?(s.headers=be({"Content-Type":"application/json"},e==null?void 0:e.headers),s.body=JSON.stringify(n)):s.body=n,e!=null&&e.duplex&&(s.duplex=e.duplex),be(be({},s),r))};async function mu(t,e,r,n,s,o){return new Promise((i,a)=>{t(r,bV(e,n,s,o)).then(c=>{if(!c.ok)throw c;return n!=null&&n.noResolveJson?c:c.json()}).then(c=>i(c)).catch(c=>wV(c,a,n))})}async function gu(t,e,r,n){return mu(t,"GET",e,r,n)}async function Qn(t,e,r,n,s){return mu(t,"POST",e,n,s,r)}async function hw(t,e,r,n,s){return mu(t,"PUT",e,n,s,r)}async function kV(t,e,r,n){return mu(t,"HEAD",e,be(be({},r),{},{noResolveJson:!0}),n)}async function fw(t,e,r,n,s){return mu(t,"DELETE",e,n,s,r)}var SV=class{constructor(t,e){this.downloadFn=t,this.shouldThrowOnError=e}then(t,e){return this.execute().then(t,e)}async execute(){var t=this;try{return{data:(await t.downloadFn()).body,error:null}}catch(e){if(t.shouldThrowOnError)throw e;if(ot(e))return{data:null,error:e};throw e}}};let $_;$_=Symbol.toStringTag;var NV=class{constructor(t,e){this.downloadFn=t,this.shouldThrowOnError=e,this[$_]="BlobDownloadBuilder",this.promise=null}asStream(){return new SV(this.downloadFn,this.shouldThrowOnError)}then(t,e){return this.getPromise().then(t,e)}catch(t){return this.getPromise().catch(t)}finally(t){return this.getPromise().finally(t)}getPromise(){return this.promise||(this.promise=this.execute()),this.promise}async execute(){var t=this;try{return{data:await(await t.downloadFn()).blob(),error:null}}catch(e){if(t.shouldThrowOnError)throw e;if(ot(e))return{data:null,error:e};throw e}}};const CV={limit:100,offset:0,sortBy:{column:"name",order:"asc"}},F_={cacheControl:"3600",contentType:"text/plain;charset=UTF-8",upsert:!1};var jV=class{constructor(t,e={},r,n){this.shouldThrowOnError=!1,this.url=t,this.headers=e,this.bucketId=r,this.fetch=cw(n)}throwOnError(){return this.shouldThrowOnError=!0,this}async uploadOrUpdate(t,e,r,n){var s=this;try{let o;const i=be(be({},F_),n);let a=be(be({},s.headers),t==="POST"&&{"x-upsert":String(i.upsert)});const c=i.metadata;typeof Blob<"u"&&r instanceof Blob?(o=new FormData,o.append("cacheControl",i.cacheControl),c&&o.append("metadata",s.encodeMetadata(c)),o.append("",r)):typeof FormData<"u"&&r instanceof FormData?(o=r,o.has("cacheControl")||o.append("cacheControl",i.cacheControl),c&&!o.has("metadata")&&o.append("metadata",s.encodeMetadata(c))):(o=r,a["cache-control"]=`max-age=${i.cacheControl}`,a["content-type"]=i.contentType,c&&(a["x-metadata"]=s.toBase64(s.encodeMetadata(c))),(typeof ReadableStream<"u"&&o instanceof ReadableStream||o&&typeof o=="object"&&"pipe"in o&&typeof o.pipe=="function")&&!i.duplex&&(i.duplex="half")),n!=null&&n.headers&&(a=be(be({},a),n.headers));const d=s._removeEmptyFolders(e),u=s._getFinalPath(d),h=await(t=="PUT"?hw:Qn)(s.fetch,`${s.url}/object/${u}`,o,be({headers:a},i!=null&&i.duplex?{duplex:i.duplex}:{}));return{data:{path:d,id:h.Id,fullPath:h.Key},error:null}}catch(o){if(s.shouldThrowOnError)throw o;if(ot(o))return{data:null,error:o};throw o}}async upload(t,e,r){return this.uploadOrUpdate("POST",t,e,r)}async uploadToSignedUrl(t,e,r,n){var s=this;const o=s._removeEmptyFolders(t),i=s._getFinalPath(o),a=new URL(s.url+`/object/upload/sign/${i}`);a.searchParams.set("token",e);try{let c;const d=be({upsert:F_.upsert},n),u=be(be({},s.headers),{"x-upsert":String(d.upsert)});return typeof Blob<"u"&&r instanceof Blob?(c=new FormData,c.append("cacheControl",d.cacheControl),c.append("",r)):typeof FormData<"u"&&r instanceof FormData?(c=r,c.append("cacheControl",d.cacheControl)):(c=r,u["cache-control"]=`max-age=${d.cacheControl}`,u["content-type"]=d.contentType),{data:{path:o,fullPath:(await hw(s.fetch,a.toString(),c,{headers:u})).Key},error:null}}catch(c){if(s.shouldThrowOnError)throw c;if(ot(c))return{data:null,error:c};throw c}}async createSignedUploadUrl(t,e){var r=this;try{let n=r._getFinalPath(t);const s=be({},r.headers);e!=null&&e.upsert&&(s["x-upsert"]="true");const o=await Qn(r.fetch,`${r.url}/object/upload/sign/${n}`,{},{headers:s}),i=new URL(r.url+o.url),a=i.searchParams.get("token");if(!a)throw new Dp("No token returned by API");return{data:{signedUrl:i.toString(),path:t,token:a},error:null}}catch(n){if(r.shouldThrowOnError)throw n;if(ot(n))return{data:null,error:n};throw n}}async update(t,e,r){return this.uploadOrUpdate("PUT",t,e,r)}async move(t,e,r){var n=this;try{return{data:await Qn(n.fetch,`${n.url}/object/move`,{bucketId:n.bucketId,sourceKey:t,destinationKey:e,destinationBucket:r==null?void 0:r.destinationBucket},{headers:n.headers}),error:null}}catch(s){if(n.shouldThrowOnError)throw s;if(ot(s))return{data:null,error:s};throw s}}async copy(t,e,r){var n=this;try{return{data:{path:(await Qn(n.fetch,`${n.url}/object/copy`,{bucketId:n.bucketId,sourceKey:t,destinationKey:e,destinationBucket:r==null?void 0:r.destinationBucket},{headers:n.headers})).Key},error:null}}catch(s){if(n.shouldThrowOnError)throw s;if(ot(s))return{data:null,error:s};throw s}}async createSignedUrl(t,e,r){var n=this;try{let s=n._getFinalPath(t),o=await Qn(n.fetch,`${n.url}/object/sign/${s}`,be({expiresIn:e},r!=null&&r.transform?{transform:r.transform}:{}),{headers:n.headers});const i=r!=null&&r.download?`&download=${r.download===!0?"":r.download}`:"";return o={signedUrl:encodeURI(`${n.url}${o.signedURL}${i}`)},{data:o,error:null}}catch(s){if(n.shouldThrowOnError)throw s;if(ot(s))return{data:null,error:s};throw s}}async createSignedUrls(t,e,r){var n=this;try{const s=await Qn(n.fetch,`${n.url}/object/sign/${n.bucketId}`,{expiresIn:e,paths:t},{headers:n.headers}),o=r!=null&&r.download?`&download=${r.download===!0?"":r.download}`:"";return{data:s.map(i=>be(be({},i),{},{signedUrl:i.signedURL?encodeURI(`${n.url}${i.signedURL}${o}`):null})),error:null}}catch(s){if(n.shouldThrowOnError)throw s;if(ot(s))return{data:null,error:s};throw s}}download(t,e){const r=typeof(e==null?void 0:e.transform)<"u"?"render/image/authenticated":"object",n=this.transformOptsToQueryString((e==null?void 0:e.transform)||{}),s=n?`?${n}`:"",o=this._getFinalPath(t),i=()=>gu(this.fetch,`${this.url}/${r}/${o}${s}`,{headers:this.headers,noResolveJson:!0});return new NV(i,this.shouldThrowOnError)}async info(t){var e=this;const r=e._getFinalPath(t);try{return{data:dw(await gu(e.fetch,`${e.url}/object/info/${r}`,{headers:e.headers})),error:null}}catch(n){if(e.shouldThrowOnError)throw n;if(ot(n))return{data:null,error:n};throw n}}async exists(t){var e=this;const r=e._getFinalPath(t);try{return await kV(e.fetch,`${e.url}/object/${r}`,{headers:e.headers}),{data:!0,error:null}}catch(n){if(e.shouldThrowOnError)throw n;if(ot(n)&&n instanceof lw){const s=n.originalError;if([400,404].includes(s==null?void 0:s.status))return{data:!1,error:n}}throw n}}getPublicUrl(t,e){const r=this._getFinalPath(t),n=[],s=e!=null&&e.download?`download=${e.download===!0?"":e.download}`:"";s!==""&&n.push(s);const o=typeof(e==null?void 0:e.transform)<"u"?"render/image":"object",i=this.transformOptsToQueryString((e==null?void 0:e.transform)||{});i!==""&&n.push(i);let a=n.join("&");return a!==""&&(a=`?${a}`),{data:{publicUrl:encodeURI(`${this.url}/${o}/public/${r}${a}`)}}}async remove(t){var e=this;try{return{data:await fw(e.fetch,`${e.url}/object/${e.bucketId}`,{prefixes:t},{headers:e.headers}),error:null}}catch(r){if(e.shouldThrowOnError)throw r;if(ot(r))return{data:null,error:r};throw r}}async list(t,e,r){var n=this;try{const s=be(be(be({},CV),e),{},{prefix:t||""});return{data:await Qn(n.fetch,`${n.url}/object/list/${n.bucketId}`,s,{headers:n.headers},r),error:null}}catch(s){if(n.shouldThrowOnError)throw s;if(ot(s))return{data:null,error:s};throw s}}async listV2(t,e){var r=this;try{const n=be({},t);return{data:await Qn(r.fetch,`${r.url}/object/list-v2/${r.bucketId}`,n,{headers:r.headers},e),error:null}}catch(n){if(r.shouldThrowOnError)throw n;if(ot(n))return{data:null,error:n};throw n}}encodeMetadata(t){return JSON.stringify(t)}toBase64(t){return typeof Buffer<"u"?Buffer.from(t).toString("base64"):btoa(t)}_getFinalPath(t){return`${this.bucketId}/${t.replace(/^\/+/,"")}`}_removeEmptyFolders(t){return t.replace(/^\/|\/$/g,"").replace(/\/+/g,"/")}transformOptsToQueryString(t){const e=[];return t.width&&e.push(`width=${t.width}`),t.height&&e.push(`height=${t.height}`),t.resize&&e.push(`resize=${t.resize}`),t.format&&e.push(`format=${t.format}`),t.quality&&e.push(`quality=${t.quality}`),e.join("&")}};const z_="2.88.0",B_={"X-Client-Info":`storage-js/${z_}`};var EV=class{constructor(t,e={},r,n){this.shouldThrowOnError=!1;const s=new URL(t);n!=null&&n.useNewHostname&&/supabase\.(co|in|red)$/.test(s.hostname)&&!s.hostname.includes("storage.supabase.")&&(s.hostname=s.hostname.replace("supabase.","storage.supabase.")),this.url=s.href.replace(/\/$/,""),this.headers=be(be({},B_),e),this.fetch=cw(r)}throwOnError(){return this.shouldThrowOnError=!0,this}async listBuckets(t){var e=this;try{const r=e.listBucketOptionsToQueryString(t);return{data:await gu(e.fetch,`${e.url}/bucket${r}`,{headers:e.headers}),error:null}}catch(r){if(e.shouldThrowOnError)throw r;if(ot(r))return{data:null,error:r};throw r}}async getBucket(t){var e=this;try{return{data:await gu(e.fetch,`${e.url}/bucket/${t}`,{headers:e.headers}),error:null}}catch(r){if(e.shouldThrowOnError)throw r;if(ot(r))return{data:null,error:r};throw r}}async createBucket(t,e={public:!1}){var r=this;try{return{data:await Qn(r.fetch,`${r.url}/bucket`,{id:t,name:t,type:e.type,public:e.public,file_size_limit:e.fileSizeLimit,allowed_mime_types:e.allowedMimeTypes},{headers:r.headers}),error:null}}catch(n){if(r.shouldThrowOnError)throw n;if(ot(n))return{data:null,error:n};throw n}}async updateBucket(t,e){var r=this;try{return{data:await hw(r.fetch,`${r.url}/bucket/${t}`,{id:t,name:t,public:e.public,file_size_limit:e.fileSizeLimit,allowed_mime_types:e.allowedMimeTypes},{headers:r.headers}),error:null}}catch(n){if(r.shouldThrowOnError)throw n;if(ot(n))return{data:null,error:n};throw n}}async emptyBucket(t){var e=this;try{return{data:await Qn(e.fetch,`${e.url}/bucket/${t}/empty`,{},{headers:e.headers}),error:null}}catch(r){if(e.shouldThrowOnError)throw r;if(ot(r))return{data:null,error:r};throw r}}async deleteBucket(t){var e=this;try{return{data:await fw(e.fetch,`${e.url}/bucket/${t}`,{},{headers:e.headers}),error:null}}catch(r){if(e.shouldThrowOnError)throw r;if(ot(r))return{data:null,error:r};throw r}}listBucketOptionsToQueryString(t){const e={};return t&&("limit"in t&&(e.limit=String(t.limit)),"offset"in t&&(e.offset=String(t.offset)),t.search&&(e.search=t.search),t.sortColumn&&(e.sortColumn=t.sortColumn),t.sortOrder&&(e.sortOrder=t.sortOrder)),Object.keys(e).length>0?"?"+new URLSearchParams(e).toString():""}},_V=class{constructor(t,e={},r){this.shouldThrowOnError=!1,this.url=t.replace(/\/$/,""),this.headers=be(be({},B_),e),this.fetch=cw(r)}throwOnError(){return this.shouldThrowOnError=!0,this}async createBucket(t){var e=this;try{return{data:await Qn(e.fetch,`${e.url}/bucket`,{name:t},{headers:e.headers}),error:null}}catch(r){if(e.shouldThrowOnError)throw r;if(ot(r))return{data:null,error:r};throw r}}async listBuckets(t){var e=this;try{const r=new URLSearchParams;(t==null?void 0:t.limit)!==void 0&&r.set("limit",t.limit.toString()),(t==null?void 0:t.offset)!==void 0&&r.set("offset",t.offset.toString()),t!=null&&t.sortColumn&&r.set("sortColumn",t.sortColumn),t!=null&&t.sortOrder&&r.set("sortOrder",t.sortOrder),t!=null&&t.search&&r.set("search",t.search);const n=r.toString(),s=n?`${e.url}/bucket?${n}`:`${e.url}/bucket`;return{data:await gu(e.fetch,s,{headers:e.headers}),error:null}}catch(r){if(e.shouldThrowOnError)throw r;if(ot(r))return{data:null,error:r};throw r}}async deleteBucket(t){var e=this;try{return{data:await fw(e.fetch,`${e.url}/bucket/${t}`,{},{headers:e.headers}),error:null}}catch(r){if(e.shouldThrowOnError)throw r;if(ot(r))return{data:null,error:r};throw r}}from(t){var e=this;if(!gV(t))throw new Dp("Invalid bucket name: File, folder, and bucket names must follow AWS object key naming guidelines and should avoid the use of any other characters.");const r=new hV({baseUrl:this.url,catalogName:t,auth:{type:"custom",getHeaders:async()=>e.headers},fetch:this.fetch}),n=this.shouldThrowOnError;return new Proxy(r,{get(s,o){const i=s[o];return typeof i!="function"?i:async(...a)=>{try{return{data:await i.apply(s,a),error:null}}catch(c){if(n)throw c;return{data:null,error:c}}}}})}};const pw={"X-Client-Info":`storage-js/${z_}`,"Content-Type":"application/json"};var U_=class extends Error{constructor(t){super(t),this.__isStorageVectorsError=!0,this.name="StorageVectorsError"}};function sn(t){return typeof t=="object"&&t!==null&&"__isStorageVectorsError"in t}var mw=class extends U_{constructor(t,e,r){super(t),this.name="StorageVectorsApiError",this.status=e,this.statusCode=r}toJSON(){return{name:this.name,message:this.message,status:this.status,statusCode:this.statusCode}}},TV=class extends U_{constructor(t,e){super(t),this.name="StorageVectorsUnknownError",this.originalError=e}};const gw=t=>t?(...e)=>t(...e):(...e)=>fetch(...e),RV=t=>{if(typeof t!="object"||t===null)return!1;const e=Object.getPrototypeOf(t);return(e===null||e===Object.prototype||Object.getPrototypeOf(e)===null)&&!(Symbol.toStringTag in t)&&!(Symbol.iterator in t)},V_=t=>t.msg||t.message||t.error_description||t.error||JSON.stringify(t),MV=async(t,e,r)=>{if(t&&typeof t=="object"&&"status"in t&&"ok"in t&&typeof t.status=="number"&&!(r!=null&&r.noResolveJson)){const n=t.status||500,s=t;if(typeof s.json=="function")s.json().then(o=>{const i=(o==null?void 0:o.statusCode)||(o==null?void 0:o.code)||n+"";e(new mw(V_(o),n,i))}).catch(()=>{const o=n+"";e(new mw(s.statusText||`HTTP ${n} error`,n,o))});else{const o=n+"";e(new mw(s.statusText||`HTTP ${n} error`,n,o))}}else e(new TV(V_(t),t))},OV=(t,e,r,n)=>{const s={method:t,headers:(e==null?void 0:e.headers)||{}};return n?(RV(n)?(s.headers=be({"Content-Type":"application/json"},e==null?void 0:e.headers),s.body=JSON.stringify(n)):s.body=n,be(be({},s),r)):s};async function PV(t,e,r,n,s,o){return new Promise((i,a)=>{t(r,OV(e,n,s,o)).then(c=>{if(!c.ok)throw c;if(n!=null&&n.noResolveJson)return c;const d=c.headers.get("content-type");return!d||!d.includes("application/json")?{}:c.json()}).then(c=>i(c)).catch(c=>MV(c,a,n))})}async function on(t,e,r,n,s){return PV(t,"POST",e,n,s,r)}var AV=class{constructor(t,e={},r){this.shouldThrowOnError=!1,this.url=t.replace(/\/$/,""),this.headers=be(be({},pw),e),this.fetch=gw(r)}throwOnError(){return this.shouldThrowOnError=!0,this}async createIndex(t){var e=this;try{return{data:await on(e.fetch,`${e.url}/CreateIndex`,t,{headers:e.headers})||{},error:null}}catch(r){if(e.shouldThrowOnError)throw r;if(sn(r))return{data:null,error:r};throw r}}async getIndex(t,e){var r=this;try{return{data:await on(r.fetch,`${r.url}/GetIndex`,{vectorBucketName:t,indexName:e},{headers:r.headers}),error:null}}catch(n){if(r.shouldThrowOnError)throw n;if(sn(n))return{data:null,error:n};throw n}}async listIndexes(t){var e=this;try{return{data:await on(e.fetch,`${e.url}/ListIndexes`,t,{headers:e.headers}),error:null}}catch(r){if(e.shouldThrowOnError)throw r;if(sn(r))return{data:null,error:r};throw r}}async deleteIndex(t,e){var r=this;try{return{data:await on(r.fetch,`${r.url}/DeleteIndex`,{vectorBucketName:t,indexName:e},{headers:r.headers})||{},error:null}}catch(n){if(r.shouldThrowOnError)throw n;if(sn(n))return{data:null,error:n};throw n}}},IV=class{constructor(t,e={},r){this.shouldThrowOnError=!1,this.url=t.replace(/\/$/,""),this.headers=be(be({},pw),e),this.fetch=gw(r)}throwOnError(){return this.shouldThrowOnError=!0,this}async putVectors(t){var e=this;try{if(t.vectors.length<1||t.vectors.length>500)throw new Error("Vector batch size must be between 1 and 500 items");return{data:await on(e.fetch,`${e.url}/PutVectors`,t,{headers:e.headers})||{},error:null}}catch(r){if(e.shouldThrowOnError)throw r;if(sn(r))return{data:null,error:r};throw r}}async getVectors(t){var e=this;try{return{data:await on(e.fetch,`${e.url}/GetVectors`,t,{headers:e.headers}),error:null}}catch(r){if(e.shouldThrowOnError)throw r;if(sn(r))return{data:null,error:r};throw r}}async listVectors(t){var e=this;try{if(t.segmentCount!==void 0){if(t.segmentCount<1||t.segmentCount>16)throw new Error("segmentCount must be between 1 and 16");if(t.segmentIndex!==void 0&&(t.segmentIndex<0||t.segmentIndex>=t.segmentCount))throw new Error(`segmentIndex must be between 0 and ${t.segmentCount-1}`)}return{data:await on(e.fetch,`${e.url}/ListVectors`,t,{headers:e.headers}),error:null}}catch(r){if(e.shouldThrowOnError)throw r;if(sn(r))return{data:null,error:r};throw r}}async queryVectors(t){var e=this;try{return{data:await on(e.fetch,`${e.url}/QueryVectors`,t,{headers:e.headers}),error:null}}catch(r){if(e.shouldThrowOnError)throw r;if(sn(r))return{data:null,error:r};throw r}}async deleteVectors(t){var e=this;try{if(t.keys.length<1||t.keys.length>500)throw new Error("Keys batch size must be between 1 and 500 items");return{data:await on(e.fetch,`${e.url}/DeleteVectors`,t,{headers:e.headers})||{},error:null}}catch(r){if(e.shouldThrowOnError)throw r;if(sn(r))return{data:null,error:r};throw r}}},DV=class{constructor(t,e={},r){this.shouldThrowOnError=!1,this.url=t.replace(/\/$/,""),this.headers=be(be({},pw),e),this.fetch=gw(r)}throwOnError(){return this.shouldThrowOnError=!0,this}async createBucket(t){var e=this;try{return{data:await on(e.fetch,`${e.url}/CreateVectorBucket`,{vectorBucketName:t},{headers:e.headers})||{},error:null}}catch(r){if(e.shouldThrowOnError)throw r;if(sn(r))return{data:null,error:r};throw r}}async getBucket(t){var e=this;try{return{data:await on(e.fetch,`${e.url}/GetVectorBucket`,{vectorBucketName:t},{headers:e.headers}),error:null}}catch(r){if(e.shouldThrowOnError)throw r;if(sn(r))return{data:null,error:r};throw r}}async listBuckets(t={}){var e=this;try{return{data:await on(e.fetch,`${e.url}/ListVectorBuckets`,t,{headers:e.headers}),error:null}}catch(r){if(e.shouldThrowOnError)throw r;if(sn(r))return{data:null,error:r};throw r}}async deleteBucket(t){var e=this;try{return{data:await on(e.fetch,`${e.url}/DeleteVectorBucket`,{vectorBucketName:t},{headers:e.headers})||{},error:null}}catch(r){if(e.shouldThrowOnError)throw r;if(sn(r))return{data:null,error:r};throw r}}},LV=class extends DV{constructor(t,e={}){super(t,e.headers||{},e.fetch)}from(t){return new $V(this.url,this.headers,t,this.fetch)}async createBucket(t){var e=()=>super.createBucket,r=this;return e().call(r,t)}async getBucket(t){var e=()=>super.getBucket,r=this;return e().call(r,t)}async listBuckets(t={}){var e=()=>super.listBuckets,r=this;return e().call(r,t)}async deleteBucket(t){var e=()=>super.deleteBucket,r=this;return e().call(r,t)}},$V=class extends AV{constructor(t,e,r,n){super(t,e,n),this.vectorBucketName=r}async createIndex(t){var e=()=>super.createIndex,r=this;return e().call(r,be(be({},t),{},{vectorBucketName:r.vectorBucketName}))}async listIndexes(t={}){var e=()=>super.listIndexes,r=this;return e().call(r,be(be({},t),{},{vectorBucketName:r.vectorBucketName}))}async getIndex(t){var e=()=>super.getIndex,r=this;return e().call(r,r.vectorBucketName,t)}async deleteIndex(t){var e=()=>super.deleteIndex,r=this;return e().call(r,r.vectorBucketName,t)}index(t){return new FV(this.url,this.headers,this.vectorBucketName,t,this.fetch)}},FV=class extends IV{constructor(t,e,r,n,s){super(t,e,s),this.vectorBucketName=r,this.indexName=n}async putVectors(t){var e=()=>super.putVectors,r=this;return e().call(r,be(be({},t),{},{vectorBucketName:r.vectorBucketName,indexName:r.indexName}))}async getVectors(t){var e=()=>super.getVectors,r=this;return e().call(r,be(be({},t),{},{vectorBucketName:r.vectorBucketName,indexName:r.indexName}))}async listVectors(t={}){var e=()=>super.listVectors,r=this;return e().call(r,be(be({},t),{},{vectorBucketName:r.vectorBucketName,indexName:r.indexName}))}async queryVectors(t){var e=()=>super.queryVectors,r=this;return e().call(r,be(be({},t),{},{vectorBucketName:r.vectorBucketName,indexName:r.indexName}))}async deleteVectors(t){var e=()=>super.deleteVectors,r=this;return e().call(r,be(be({},t),{},{vectorBucketName:r.vectorBucketName,indexName:r.indexName}))}},zV=class extends EV{constructor(t,e={},r,n){super(t,e,r,n)}from(t){return new jV(this.url,this.headers,t,this.fetch)}get vectors(){return new LV(this.url+"/vector",{headers:this.headers,fetch:this.fetch})}get analytics(){return new _V(this.url+"/iceberg",this.headers,this.fetch)}};const W_="2.88.0",Yl=30*1e3,vw=3,yw=vw*Yl,BV="http://localhost:9999",UV="supabase.auth.token",VV={"X-Client-Info":`gotrue-js/${W_}`},xw="X-Supabase-Api-Version",H_={"2024-01-01":{timestamp:Date.parse("2024-01-01T00:00:00.0Z"),name:"2024-01-01"}},WV=/^([a-z0-9_-]{4})*($|[a-z0-9_-]{3}$|[a-z0-9_-]{2}$)$/i,HV=10*60*1e3;class vu extends Error{constructor(e,r,n){super(e),this.__isAuthError=!0,this.name="AuthError",this.status=r,this.code=n}}function he(t){return typeof t=="object"&&t!==null&&"__isAuthError"in t}class qV extends vu{constructor(e,r,n){super(e,r,n),this.name="AuthApiError",this.status=r,this.code=n}}function KV(t){return he(t)&&t.name==="AuthApiError"}class ia extends vu{constructor(e,r){super(e),this.name="AuthUnknownError",this.originalError=r}}class ro extends vu{constructor(e,r,n,s){super(e,n,s),this.name=r,this.status=n}}class an extends ro{constructor(){super("Auth session missing!","AuthSessionMissingError",400,void 0)}}function GV(t){return he(t)&&t.name==="AuthSessionMissingError"}class Jl extends ro{constructor(){super("Auth session or user missing","AuthInvalidTokenResponseError",500,void 0)}}class Lp extends ro{constructor(e){super(e,"AuthInvalidCredentialsError",400,void 0)}}class $p extends ro{constructor(e,r=null){super(e,"AuthImplicitGrantRedirectError",500,void 0),this.details=null,this.details=r}toJSON(){return{name:this.name,message:this.message,status:this.status,details:this.details}}}function YV(t){return he(t)&&t.name==="AuthImplicitGrantRedirectError"}class q_ extends ro{constructor(e,r=null){super(e,"AuthPKCEGrantCodeExchangeError",500,void 0),this.details=null,this.details=r}toJSON(){return{name:this.name,message:this.message,status:this.status,details:this.details}}}class JV extends ro{constructor(){super("PKCE code verifier not found in storage. This can happen if the auth flow was initiated in a different browser or device, or if the storage was cleared. For SSR frameworks (Next.js, SvelteKit, etc.), use @supabase/ssr on both the server and client to store the code verifier in cookies.","AuthPKCECodeVerifierMissingError",400,"pkce_code_verifier_not_found")}}class ww extends ro{constructor(e,r){super(e,"AuthRetryableFetchError",r,void 0)}}function bw(t){return he(t)&&t.name==="AuthRetryableFetchError"}class K_ extends ro{constructor(e,r,n){super(e,"AuthWeakPasswordError",r,"weak_password"),this.reasons=n}}class kw extends ro{constructor(e){super(e,"AuthInvalidJwtError",400,"invalid_jwt")}}const Fp="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_".split(""),G_=` \r=`.split(""),QV=(()=>{const t=new Array(128);for(let e=0;e=6;){const n=e.queue>>e.queuedBits-6&63;r(Fp[n]),e.queuedBits-=6}else if(e.queuedBits>0)for(e.queue=e.queue<<6-e.queuedBits,e.queuedBits=6;e.queuedBits>=6;){const n=e.queue>>e.queuedBits-6&63;r(Fp[n]),e.queuedBits-=6}}function J_(t,e,r){const n=QV[t];if(n>-1)for(e.queue=e.queue<<6|n,e.queuedBits+=6;e.queuedBits>=8;)r(e.queue>>e.queuedBits-8&255),e.queuedBits-=8;else{if(n===-2)return;throw new Error(`Invalid Base64-URL character "${String.fromCharCode(t)}"`)}}function Q_(t){const e=[],r=i=>{e.push(String.fromCodePoint(i))},n={utf8seq:0,codepoint:0},s={queue:0,queuedBits:0},o=i=>{eW(i,n,r)};for(let i=0;i>6),e(128|t&63);return}else if(t<=65535){e(224|t>>12),e(128|t>>6&63),e(128|t&63);return}else if(t<=1114111){e(240|t>>18),e(128|t>>12&63),e(128|t>>6&63),e(128|t&63);return}throw new Error(`Unrecognized Unicode codepoint: ${t.toString(16)}`)}function ZV(t,e){for(let r=0;r55295&&n<=56319){const s=(n-55296)*1024&65535;n=(t.charCodeAt(r+1)-56320&65535|s)+65536,r+=1}XV(n,e)}}function eW(t,e,r){if(e.utf8seq===0){if(t<=127){r(t);return}for(let n=1;n<6;n+=1)if(!(t>>7-n&1)){e.utf8seq=n;break}if(e.utf8seq===2)e.codepoint=t&31;else if(e.utf8seq===3)e.codepoint=t&15;else if(e.utf8seq===4)e.codepoint=t&7;else throw new Error("Invalid UTF-8 sequence");e.utf8seq-=1}else if(e.utf8seq>0){if(t<=127)throw new Error("Invalid UTF-8 sequence");e.codepoint=e.codepoint<<6|t&63,e.utf8seq-=1,e.utf8seq===0&&r(e.codepoint)}}function Ql(t){const e=[],r={queue:0,queuedBits:0},n=s=>{e.push(s)};for(let s=0;se.push(r)),new Uint8Array(e)}function aa(t){const e=[],r={queue:0,queuedBits:0},n=s=>{e.push(s)};return t.forEach(s=>Y_(s,r,n)),Y_(null,r,n),e.join("")}function rW(t){return Math.round(Date.now()/1e3)+t}function nW(){return Symbol("auth-callback")}const rr=()=>typeof window<"u"&&typeof document<"u",la={tested:!1,writable:!1},X_=()=>{if(!rr())return!1;try{if(typeof globalThis.localStorage!="object")return!1}catch{return!1}if(la.tested)return la.writable;const t=`lswt-${Math.random()}${Math.random()}`;try{globalThis.localStorage.setItem(t,t),globalThis.localStorage.removeItem(t),la.tested=!0,la.writable=!0}catch{la.tested=!0,la.writable=!1}return la.writable};function sW(t){const e={},r=new URL(t);if(r.hash&&r.hash[0]==="#")try{new URLSearchParams(r.hash.substring(1)).forEach((s,o)=>{e[o]=s})}catch{}return r.searchParams.forEach((n,s)=>{e[s]=n}),e}const Z_=t=>t?(...e)=>t(...e):(...e)=>fetch(...e),oW=t=>typeof t=="object"&&t!==null&&"status"in t&&"ok"in t&&"json"in t&&typeof t.json=="function",Xl=async(t,e,r)=>{await t.setItem(e,JSON.stringify(r))},ca=async(t,e)=>{const r=await t.getItem(e);if(!r)return null;try{return JSON.parse(r)}catch{return r}},nr=async(t,e)=>{await t.removeItem(e)};class zp{constructor(){this.promise=new zp.promiseConstructor((e,r)=>{this.resolve=e,this.reject=r})}}zp.promiseConstructor=Promise;function Sw(t){const e=t.split(".");if(e.length!==3)throw new kw("Invalid JWT structure");for(let n=0;n{setTimeout(()=>e(null),t)})}function aW(t,e){return new Promise((n,s)=>{(async()=>{for(let o=0;o<1/0;o++)try{const i=await t(o);if(!e(o,null,i)){n(i);return}}catch(i){if(!e(o,i)){s(i);return}}})()})}function lW(t){return("0"+t.toString(16)).substr(-2)}function cW(){const e=new Uint32Array(56);if(typeof crypto>"u"){const r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~",n=r.length;let s="";for(let o=0;o<56;o++)s+=r.charAt(Math.floor(Math.random()*n));return s}return crypto.getRandomValues(e),Array.from(e,lW).join("")}async function dW(t){const r=new TextEncoder().encode(t),n=await crypto.subtle.digest("SHA-256",r),s=new Uint8Array(n);return Array.from(s).map(o=>String.fromCharCode(o)).join("")}async function uW(t){if(!(typeof crypto<"u"&&typeof crypto.subtle<"u"&&typeof TextEncoder<"u"))return console.warn("WebCrypto API is not supported. Code challenge method will default to use plain instead of sha256."),t;const r=await dW(t);return btoa(r).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}async function Zl(t,e,r=!1){const n=cW();let s=n;r&&(s+="/PASSWORD_RECOVERY"),await Xl(t,`${e}-code-verifier`,s);const o=await uW(n);return[o,n===o?"plain":"s256"]}const hW=/^2[0-9]{3}-(0[1-9]|1[0-2])-(0[1-9]|1[0-9]|2[0-9]|3[0-1])$/i;function fW(t){const e=t.headers.get(xw);if(!e||!e.match(hW))return null;try{return new Date(`${e}T00:00:00.0Z`)}catch{return null}}function pW(t){if(!t)throw new Error("Missing exp claim");const e=Math.floor(Date.now()/1e3);if(t<=e)throw new Error("JWT has expired")}function mW(t){switch(t){case"RS256":return{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}};case"ES256":return{name:"ECDSA",namedCurve:"P-256",hash:{name:"SHA-256"}};default:throw new Error("Invalid alg claim")}}const gW=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;function ec(t){if(!gW.test(t))throw new Error("@supabase/auth-js: Expected parameter to be UUID but is not")}function Nw(){const t={};return new Proxy(t,{get:(e,r)=>{if(r==="__isUserNotAvailableProxy")return!0;if(typeof r=="symbol"){const n=r.toString();if(n==="Symbol(Symbol.toPrimitive)"||n==="Symbol(Symbol.toStringTag)"||n==="Symbol(util.inspect.custom)")return}throw new Error(`@supabase/auth-js: client was created with userStorage option and there was no user stored in the user storage. Accessing the "${r}" property of the session object is not supported. Please use getUser() instead.`)},set:(e,r)=>{throw new Error(`@supabase/auth-js: client was created with userStorage option and there was no user stored in the user storage. Setting the "${r}" property of the session object is not supported. Please use getUser() to fetch a user object you can manipulate.`)},deleteProperty:(e,r)=>{throw new Error(`@supabase/auth-js: client was created with userStorage option and there was no user stored in the user storage. Deleting the "${r}" property of the session object is not supported. Please use getUser() to fetch a user object you can manipulate.`)}})}function vW(t,e){return new Proxy(t,{get:(r,n,s)=>{if(n==="__isInsecureUserWarningProxy")return!0;if(typeof n=="symbol"){const o=n.toString();if(o==="Symbol(Symbol.toPrimitive)"||o==="Symbol(Symbol.toStringTag)"||o==="Symbol(util.inspect.custom)"||o==="Symbol(nodejs.util.inspect.custom)")return Reflect.get(r,n,s)}return!e.value&&typeof n=="string"&&(console.warn("Using the user object as returned from supabase.auth.getSession() or from some supabase.auth.onAuthStateChange() events could be insecure! This value comes directly from the storage medium (usually cookies on the server) and may not be authentic. Use supabase.auth.getUser() instead which authenticates the data by contacting the Supabase Auth server."),e.value=!0),Reflect.get(r,n,s)}})}function e2(t){return JSON.parse(JSON.stringify(t))}const da=t=>t.msg||t.message||t.error_description||t.error||JSON.stringify(t),yW=[502,503,504];async function t2(t){var e;if(!oW(t))throw new ww(da(t),0);if(yW.includes(t.status))throw new ww(da(t),t.status);let r;try{r=await t.json()}catch(o){throw new ia(da(o),o)}let n;const s=fW(t);if(s&&s.getTime()>=H_["2024-01-01"].timestamp&&typeof r=="object"&&r&&typeof r.code=="string"?n=r.code:typeof r=="object"&&r&&typeof r.error_code=="string"&&(n=r.error_code),n){if(n==="weak_password")throw new K_(da(r),t.status,((e=r.weak_password)===null||e===void 0?void 0:e.reasons)||[]);if(n==="session_not_found")throw new an}else if(typeof r=="object"&&r&&typeof r.weak_password=="object"&&r.weak_password&&Array.isArray(r.weak_password.reasons)&&r.weak_password.reasons.length&&r.weak_password.reasons.reduce((o,i)=>o&&typeof i=="string",!0))throw new K_(da(r),t.status,r.weak_password.reasons);throw new qV(da(r),t.status||500,n)}const xW=(t,e,r,n)=>{const s={method:t,headers:(e==null?void 0:e.headers)||{}};return t==="GET"?s:(s.headers=Object.assign({"Content-Type":"application/json;charset=UTF-8"},e==null?void 0:e.headers),s.body=JSON.stringify(n),Object.assign(Object.assign({},s),r))};async function ke(t,e,r,n){var s;const o=Object.assign({},n==null?void 0:n.headers);o[xw]||(o[xw]=H_["2024-01-01"].name),n!=null&&n.jwt&&(o.Authorization=`Bearer ${n.jwt}`);const i=(s=n==null?void 0:n.query)!==null&&s!==void 0?s:{};n!=null&&n.redirectTo&&(i.redirect_to=n.redirectTo);const a=Object.keys(i).length?"?"+new URLSearchParams(i).toString():"",c=await wW(t,e,r+a,{headers:o,noResolveJson:n==null?void 0:n.noResolveJson},{},n==null?void 0:n.body);return n!=null&&n.xform?n==null?void 0:n.xform(c):{data:Object.assign({},c),error:null}}async function wW(t,e,r,n,s,o){const i=xW(e,n,s,o);let a;try{a=await t(r,Object.assign({},i))}catch(c){throw console.error(c),new ww(da(c),0)}if(a.ok||await t2(a),n!=null&&n.noResolveJson)return a;try{return await a.json()}catch(c){await t2(c)}}function Xn(t){var e;let r=null;SW(t)&&(r=Object.assign({},t),t.expires_at||(r.expires_at=rW(t.expires_in)));const n=(e=t.user)!==null&&e!==void 0?e:t;return{data:{session:r,user:n},error:null}}function r2(t){const e=Xn(t);return!e.error&&t.weak_password&&typeof t.weak_password=="object"&&Array.isArray(t.weak_password.reasons)&&t.weak_password.reasons.length&&t.weak_password.message&&typeof t.weak_password.message=="string"&&t.weak_password.reasons.reduce((r,n)=>r&&typeof n=="string",!0)&&(e.data.weak_password=t.weak_password),e}function Qo(t){var e;return{data:{user:(e=t.user)!==null&&e!==void 0?e:t},error:null}}function bW(t){return{data:t,error:null}}function kW(t){const{action_link:e,email_otp:r,hashed_token:n,redirect_to:s,verification_type:o}=t,i=Fl(t,["action_link","email_otp","hashed_token","redirect_to","verification_type"]),a={action_link:e,email_otp:r,hashed_token:n,redirect_to:s,verification_type:o},c=Object.assign({},i);return{data:{properties:a,user:c},error:null}}function n2(t){return t}function SW(t){return t.access_token&&t.refresh_token&&t.expires_in}const Cw=["global","local","others"];class NW{constructor({url:e="",headers:r={},fetch:n}){this.url=e,this.headers=r,this.fetch=Z_(n),this.mfa={listFactors:this._listFactors.bind(this),deleteFactor:this._deleteFactor.bind(this)},this.oauth={listClients:this._listOAuthClients.bind(this),createClient:this._createOAuthClient.bind(this),getClient:this._getOAuthClient.bind(this),updateClient:this._updateOAuthClient.bind(this),deleteClient:this._deleteOAuthClient.bind(this),regenerateClientSecret:this._regenerateOAuthClientSecret.bind(this)}}async signOut(e,r=Cw[0]){if(Cw.indexOf(r)<0)throw new Error(`@supabase/auth-js: Parameter scope must be one of ${Cw.join(", ")}`);try{return await ke(this.fetch,"POST",`${this.url}/logout?scope=${r}`,{headers:this.headers,jwt:e,noResolveJson:!0}),{data:null,error:null}}catch(n){if(he(n))return{data:null,error:n};throw n}}async inviteUserByEmail(e,r={}){try{return await ke(this.fetch,"POST",`${this.url}/invite`,{body:{email:e,data:r.data},headers:this.headers,redirectTo:r.redirectTo,xform:Qo})}catch(n){if(he(n))return{data:{user:null},error:n};throw n}}async generateLink(e){try{const{options:r}=e,n=Fl(e,["options"]),s=Object.assign(Object.assign({},n),r);return"newEmail"in n&&(s.new_email=n==null?void 0:n.newEmail,delete s.newEmail),await ke(this.fetch,"POST",`${this.url}/admin/generate_link`,{body:s,headers:this.headers,xform:kW,redirectTo:r==null?void 0:r.redirectTo})}catch(r){if(he(r))return{data:{properties:null,user:null},error:r};throw r}}async createUser(e){try{return await ke(this.fetch,"POST",`${this.url}/admin/users`,{body:e,headers:this.headers,xform:Qo})}catch(r){if(he(r))return{data:{user:null},error:r};throw r}}async listUsers(e){var r,n,s,o,i,a,c;try{const d={nextPage:null,lastPage:0,total:0},u=await ke(this.fetch,"GET",`${this.url}/admin/users`,{headers:this.headers,noResolveJson:!0,query:{page:(n=(r=e==null?void 0:e.page)===null||r===void 0?void 0:r.toString())!==null&&n!==void 0?n:"",per_page:(o=(s=e==null?void 0:e.perPage)===null||s===void 0?void 0:s.toString())!==null&&o!==void 0?o:""},xform:n2});if(u.error)throw u.error;const h=await u.json(),f=(i=u.headers.get("x-total-count"))!==null&&i!==void 0?i:0,p=(c=(a=u.headers.get("link"))===null||a===void 0?void 0:a.split(","))!==null&&c!==void 0?c:[];return p.length>0&&(p.forEach(g=>{const v=parseInt(g.split(";")[0].split("=")[1].substring(0,1)),y=JSON.parse(g.split(";")[1].split("=")[1]);d[`${y}Page`]=v}),d.total=parseInt(f)),{data:Object.assign(Object.assign({},h),d),error:null}}catch(d){if(he(d))return{data:{users:[]},error:d};throw d}}async getUserById(e){ec(e);try{return await ke(this.fetch,"GET",`${this.url}/admin/users/${e}`,{headers:this.headers,xform:Qo})}catch(r){if(he(r))return{data:{user:null},error:r};throw r}}async updateUserById(e,r){ec(e);try{return await ke(this.fetch,"PUT",`${this.url}/admin/users/${e}`,{body:r,headers:this.headers,xform:Qo})}catch(n){if(he(n))return{data:{user:null},error:n};throw n}}async deleteUser(e,r=!1){ec(e);try{return await ke(this.fetch,"DELETE",`${this.url}/admin/users/${e}`,{headers:this.headers,body:{should_soft_delete:r},xform:Qo})}catch(n){if(he(n))return{data:{user:null},error:n};throw n}}async _listFactors(e){ec(e.userId);try{const{data:r,error:n}=await ke(this.fetch,"GET",`${this.url}/admin/users/${e.userId}/factors`,{headers:this.headers,xform:s=>({data:{factors:s},error:null})});return{data:r,error:n}}catch(r){if(he(r))return{data:null,error:r};throw r}}async _deleteFactor(e){ec(e.userId),ec(e.id);try{return{data:await ke(this.fetch,"DELETE",`${this.url}/admin/users/${e.userId}/factors/${e.id}`,{headers:this.headers}),error:null}}catch(r){if(he(r))return{data:null,error:r};throw r}}async _listOAuthClients(e){var r,n,s,o,i,a,c;try{const d={nextPage:null,lastPage:0,total:0},u=await ke(this.fetch,"GET",`${this.url}/admin/oauth/clients`,{headers:this.headers,noResolveJson:!0,query:{page:(n=(r=e==null?void 0:e.page)===null||r===void 0?void 0:r.toString())!==null&&n!==void 0?n:"",per_page:(o=(s=e==null?void 0:e.perPage)===null||s===void 0?void 0:s.toString())!==null&&o!==void 0?o:""},xform:n2});if(u.error)throw u.error;const h=await u.json(),f=(i=u.headers.get("x-total-count"))!==null&&i!==void 0?i:0,p=(c=(a=u.headers.get("link"))===null||a===void 0?void 0:a.split(","))!==null&&c!==void 0?c:[];return p.length>0&&(p.forEach(g=>{const v=parseInt(g.split(";")[0].split("=")[1].substring(0,1)),y=JSON.parse(g.split(";")[1].split("=")[1]);d[`${y}Page`]=v}),d.total=parseInt(f)),{data:Object.assign(Object.assign({},h),d),error:null}}catch(d){if(he(d))return{data:{clients:[]},error:d};throw d}}async _createOAuthClient(e){try{return await ke(this.fetch,"POST",`${this.url}/admin/oauth/clients`,{body:e,headers:this.headers,xform:r=>({data:r,error:null})})}catch(r){if(he(r))return{data:null,error:r};throw r}}async _getOAuthClient(e){try{return await ke(this.fetch,"GET",`${this.url}/admin/oauth/clients/${e}`,{headers:this.headers,xform:r=>({data:r,error:null})})}catch(r){if(he(r))return{data:null,error:r};throw r}}async _updateOAuthClient(e,r){try{return await ke(this.fetch,"PUT",`${this.url}/admin/oauth/clients/${e}`,{body:r,headers:this.headers,xform:n=>({data:n,error:null})})}catch(n){if(he(n))return{data:null,error:n};throw n}}async _deleteOAuthClient(e){try{return await ke(this.fetch,"DELETE",`${this.url}/admin/oauth/clients/${e}`,{headers:this.headers,noResolveJson:!0}),{data:null,error:null}}catch(r){if(he(r))return{data:null,error:r};throw r}}async _regenerateOAuthClientSecret(e){try{return await ke(this.fetch,"POST",`${this.url}/admin/oauth/clients/${e}/regenerate_secret`,{headers:this.headers,xform:r=>({data:r,error:null})})}catch(r){if(he(r))return{data:null,error:r};throw r}}}function s2(t={}){return{getItem:e=>t[e]||null,setItem:(e,r)=>{t[e]=r},removeItem:e=>{delete t[e]}}}const tc={debug:!!(globalThis&&X_()&&globalThis.localStorage&&globalThis.localStorage.getItem("supabase.gotrue-js.locks.debug")==="true")};class o2 extends Error{constructor(e){super(e),this.isAcquireTimeout=!0}}class CW extends o2{}async function jW(t,e,r){tc.debug&&console.log("@supabase/gotrue-js: navigatorLock: acquire lock",t,e);const n=new globalThis.AbortController;return e>0&&setTimeout(()=>{n.abort(),tc.debug&&console.log("@supabase/gotrue-js: navigatorLock acquire timed out",t)},e),await Promise.resolve().then(()=>globalThis.navigator.locks.request(t,e===0?{mode:"exclusive",ifAvailable:!0}:{mode:"exclusive",signal:n.signal},async s=>{if(s){tc.debug&&console.log("@supabase/gotrue-js: navigatorLock: acquired",t,s.name);try{return await r()}finally{tc.debug&&console.log("@supabase/gotrue-js: navigatorLock: released",t,s.name)}}else{if(e===0)throw tc.debug&&console.log("@supabase/gotrue-js: navigatorLock: not immediately available",t),new CW(`Acquiring an exclusive Navigator LockManager lock "${t}" immediately failed`);if(tc.debug)try{const o=await globalThis.navigator.locks.query();console.log("@supabase/gotrue-js: Navigator LockManager state",JSON.stringify(o,null," "))}catch(o){console.warn("@supabase/gotrue-js: Error when querying Navigator LockManager state",o)}return console.warn("@supabase/gotrue-js: Navigator LockManager returned a null lock when using #request without ifAvailable set to true, it appears this browser is not following the LockManager spec https://developer.mozilla.org/en-US/docs/Web/API/LockManager/request"),await r()}}))}function EW(){if(typeof globalThis!="object")try{Object.defineProperty(Object.prototype,"__magic__",{get:function(){return this},configurable:!0}),__magic__.globalThis=__magic__,delete Object.prototype.__magic__}catch{typeof self<"u"&&(self.globalThis=self)}}function i2(t){if(!/^0x[a-fA-F0-9]{40}$/.test(t))throw new Error(`@supabase/auth-js: Address "${t}" is invalid.`);return t.toLowerCase()}function _W(t){return parseInt(t,16)}function TW(t){const e=new TextEncoder().encode(t);return"0x"+Array.from(e,n=>n.toString(16).padStart(2,"0")).join("")}function RW(t){var e;const{chainId:r,domain:n,expirationTime:s,issuedAt:o=new Date,nonce:i,notBefore:a,requestId:c,resources:d,scheme:u,uri:h,version:f}=t;{if(!Number.isInteger(r))throw new Error(`@supabase/auth-js: Invalid SIWE message field "chainId". Chain ID must be a EIP-155 chain ID. Provided value: ${r}`);if(!n)throw new Error('@supabase/auth-js: Invalid SIWE message field "domain". Domain must be provided.');if(i&&i.length<8)throw new Error(`@supabase/auth-js: Invalid SIWE message field "nonce". Nonce must be at least 8 characters. Provided value: ${i}`);if(!h)throw new Error('@supabase/auth-js: Invalid SIWE message field "uri". URI must be provided.');if(f!=="1")throw new Error(`@supabase/auth-js: Invalid SIWE message field "version". Version must be '1'. Provided value: ${f}`);if(!((e=t.statement)===null||e===void 0)&&e.includes(` `))throw new Error(`@supabase/auth-js: Invalid SIWE message field "statement". Statement must not include '\\n'. Provided value: ${t.statement}`)}const p=i2(t.address),g=u?`${u}://${n}`:n,v=t.statement?`${t.statement} `:"",y=`${g} wants you to sign in with your Ethereum account: ${p} ${v}`;let x=`URI: ${h} Version: ${f} Chain ID: ${r}${i?` Nonce: ${i}`:""} Issued At: ${o.toISOString()}`;if(s&&(x+=` Expiration Time: ${s.toISOString()}`),a&&(x+=` Not Before: ${a.toISOString()}`),c&&(x+=` Request ID: ${c}`),d){let w=` Resources:`;for(const b of d){if(!b||typeof b!="string")throw new Error(`@supabase/auth-js: Invalid SIWE message field "resources". Every resource must be a valid string. Provided value: ${b}`);w+=` - ${b}`}x+=w}return`${y} ${x}`}class bt extends Error{constructor({message:e,code:r,cause:n,name:s}){var o;super(e,{cause:n}),this.__isWebAuthnError=!0,this.name=(o=s??(n instanceof Error?n.name:void 0))!==null&&o!==void 0?o:"Unknown Error",this.code=r}}class Bp extends bt{constructor(e,r){super({code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:r,message:e}),this.name="WebAuthnUnknownError",this.originalError=r}}function MW({error:t,options:e}){var r,n,s;const{publicKey:o}=e;if(!o)throw Error("options was missing required publicKey property");if(t.name==="AbortError"){if(e.signal instanceof AbortSignal)return new bt({message:"Registration ceremony was sent an abort signal",code:"ERROR_CEREMONY_ABORTED",cause:t})}else if(t.name==="ConstraintError"){if(((r=o.authenticatorSelection)===null||r===void 0?void 0:r.requireResidentKey)===!0)return new bt({message:"Discoverable credentials were required but no available authenticator supported it",code:"ERROR_AUTHENTICATOR_MISSING_DISCOVERABLE_CREDENTIAL_SUPPORT",cause:t});if(e.mediation==="conditional"&&((n=o.authenticatorSelection)===null||n===void 0?void 0:n.userVerification)==="required")return new bt({message:"User verification was required during automatic registration but it could not be performed",code:"ERROR_AUTO_REGISTER_USER_VERIFICATION_FAILURE",cause:t});if(((s=o.authenticatorSelection)===null||s===void 0?void 0:s.userVerification)==="required")return new bt({message:"User verification was required but no available authenticator supported it",code:"ERROR_AUTHENTICATOR_MISSING_USER_VERIFICATION_SUPPORT",cause:t})}else{if(t.name==="InvalidStateError")return new bt({message:"The authenticator was previously registered",code:"ERROR_AUTHENTICATOR_PREVIOUSLY_REGISTERED",cause:t});if(t.name==="NotAllowedError")return new bt({message:t.message,code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:t});if(t.name==="NotSupportedError")return o.pubKeyCredParams.filter(a=>a.type==="public-key").length===0?new bt({message:'No entry in pubKeyCredParams was of type "public-key"',code:"ERROR_MALFORMED_PUBKEYCREDPARAMS",cause:t}):new bt({message:"No available authenticator supported any of the specified pubKeyCredParams algorithms",code:"ERROR_AUTHENTICATOR_NO_SUPPORTED_PUBKEYCREDPARAMS_ALG",cause:t});if(t.name==="SecurityError"){const i=window.location.hostname;if(a2(i)){if(o.rp.id!==i)return new bt({message:`The RP ID "${o.rp.id}" is invalid for this domain`,code:"ERROR_INVALID_RP_ID",cause:t})}else return new bt({message:`${window.location.hostname} is an invalid domain`,code:"ERROR_INVALID_DOMAIN",cause:t})}else if(t.name==="TypeError"){if(o.user.id.byteLength<1||o.user.id.byteLength>64)return new bt({message:"User ID was not between 1 and 64 characters",code:"ERROR_INVALID_USER_ID_LENGTH",cause:t})}else if(t.name==="UnknownError")return new bt({message:"The authenticator was unable to process the specified options, or could not create a new credential",code:"ERROR_AUTHENTICATOR_GENERAL_ERROR",cause:t})}return new bt({message:"a Non-Webauthn related error has occurred",code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:t})}function OW({error:t,options:e}){const{publicKey:r}=e;if(!r)throw Error("options was missing required publicKey property");if(t.name==="AbortError"){if(e.signal instanceof AbortSignal)return new bt({message:"Authentication ceremony was sent an abort signal",code:"ERROR_CEREMONY_ABORTED",cause:t})}else{if(t.name==="NotAllowedError")return new bt({message:t.message,code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:t});if(t.name==="SecurityError"){const n=window.location.hostname;if(a2(n)){if(r.rpId!==n)return new bt({message:`The RP ID "${r.rpId}" is invalid for this domain`,code:"ERROR_INVALID_RP_ID",cause:t})}else return new bt({message:`${window.location.hostname} is an invalid domain`,code:"ERROR_INVALID_DOMAIN",cause:t})}else if(t.name==="UnknownError")return new bt({message:"The authenticator was unable to process the specified options, or could not create a new assertion signature",code:"ERROR_AUTHENTICATOR_GENERAL_ERROR",cause:t})}return new bt({message:"a Non-Webauthn related error has occurred",code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:t})}class PW{createNewAbortSignal(){if(this.controller){const r=new Error("Cancelling existing WebAuthn API call for new one");r.name="AbortError",this.controller.abort(r)}const e=new AbortController;return this.controller=e,e.signal}cancelCeremony(){if(this.controller){const e=new Error("Manually cancelling existing WebAuthn API call");e.name="AbortError",this.controller.abort(e),this.controller=void 0}}}const AW=new PW;function IW(t){if(!t)throw new Error("Credential creation options are required");if(typeof PublicKeyCredential<"u"&&"parseCreationOptionsFromJSON"in PublicKeyCredential&&typeof PublicKeyCredential.parseCreationOptionsFromJSON=="function")return PublicKeyCredential.parseCreationOptionsFromJSON(t);const{challenge:e,user:r,excludeCredentials:n}=t,s=Fl(t,["challenge","user","excludeCredentials"]),o=Ql(e).buffer,i=Object.assign(Object.assign({},r),{id:Ql(r.id).buffer}),a=Object.assign(Object.assign({},s),{challenge:o,user:i});if(n&&n.length>0){a.excludeCredentials=new Array(n.length);for(let c=0;c0){o.allowCredentials=new Array(r.length);for(let i=0;is!==null&&typeof s=="object"&&!Array.isArray(s),r=s=>s instanceof ArrayBuffer||ArrayBuffer.isView(s),n={};for(const s of t)if(s)for(const o in s){const i=s[o];if(i!==void 0)if(Array.isArray(i))n[o]=i;else if(r(i))n[o]=i;else if(e(i)){const a=n[o];e(a)?n[o]=Up(a,i):n[o]=Up(i)}else n[o]=i}return n}function VW(t,e){return Up(BW,t,e||{})}function WW(t,e){return Up(UW,t,e||{})}class HW{constructor(e){this.client=e,this.enroll=this._enroll.bind(this),this.challenge=this._challenge.bind(this),this.verify=this._verify.bind(this),this.authenticate=this._authenticate.bind(this),this.register=this._register.bind(this)}async _enroll(e){return this.client.mfa.enroll(Object.assign(Object.assign({},e),{factorType:"webauthn"}))}async _challenge({factorId:e,webauthn:r,friendlyName:n,signal:s},o){try{const{data:i,error:a}=await this.client.mfa.challenge({factorId:e,webauthn:r});if(!i)return{data:null,error:a};const c=s??AW.createNewAbortSignal();if(i.webauthn.type==="create"){const{user:d}=i.webauthn.credential_options.publicKey;d.name||(d.name=`${d.id}:${n}`),d.displayName||(d.displayName=d.name)}switch(i.webauthn.type){case"create":{const d=VW(i.webauthn.credential_options.publicKey,o==null?void 0:o.create),{data:u,error:h}=await FW({publicKey:d,signal:c});return u?{data:{factorId:e,challengeId:i.id,webauthn:{type:i.webauthn.type,credential_response:u}},error:null}:{data:null,error:h}}case"request":{const d=WW(i.webauthn.credential_options.publicKey,o==null?void 0:o.request),{data:u,error:h}=await zW(Object.assign(Object.assign({},i.webauthn.credential_options),{publicKey:d,signal:c}));return u?{data:{factorId:e,challengeId:i.id,webauthn:{type:i.webauthn.type,credential_response:u}},error:null}:{data:null,error:h}}}}catch(i){return he(i)?{data:null,error:i}:{data:null,error:new ia("Unexpected error in challenge",i)}}}async _verify({challengeId:e,factorId:r,webauthn:n}){return this.client.mfa.verify({factorId:r,challengeId:e,webauthn:n})}async _authenticate({factorId:e,webauthn:{rpId:r=typeof window<"u"?window.location.hostname:void 0,rpOrigins:n=typeof window<"u"?[window.location.origin]:void 0,signal:s}={}},o){if(!r)return{data:null,error:new vu("rpId is required for WebAuthn authentication")};try{if(!l2())return{data:null,error:new ia("Browser does not support WebAuthn",null)};const{data:i,error:a}=await this.challenge({factorId:e,webauthn:{rpId:r,rpOrigins:n},signal:s},{request:o});if(!i)return{data:null,error:a};const{webauthn:c}=i;return this._verify({factorId:e,challengeId:i.challengeId,webauthn:{type:c.type,rpId:r,rpOrigins:n,credential_response:c.credential_response}})}catch(i){return he(i)?{data:null,error:i}:{data:null,error:new ia("Unexpected error in authenticate",i)}}}async _register({friendlyName:e,webauthn:{rpId:r=typeof window<"u"?window.location.hostname:void 0,rpOrigins:n=typeof window<"u"?[window.location.origin]:void 0,signal:s}={}},o){if(!r)return{data:null,error:new vu("rpId is required for WebAuthn registration")};try{if(!l2())return{data:null,error:new ia("Browser does not support WebAuthn",null)};const{data:i,error:a}=await this._enroll({friendlyName:e});if(!i)return await this.client.mfa.listFactors().then(u=>{var h;return(h=u.data)===null||h===void 0?void 0:h.all.find(f=>f.factor_type==="webauthn"&&f.friendly_name===e&&f.status!=="unverified")}).then(u=>u?this.client.mfa.unenroll({factorId:u==null?void 0:u.id}):void 0),{data:null,error:a};const{data:c,error:d}=await this._challenge({factorId:i.id,friendlyName:i.friendly_name,webauthn:{rpId:r,rpOrigins:n},signal:s},{create:o});return c?this._verify({factorId:i.id,challengeId:c.challengeId,webauthn:{rpId:r,rpOrigins:n,type:c.webauthn.type,credential_response:c.webauthn.credential_response}}):{data:null,error:d}}catch(i){return he(i)?{data:null,error:i}:{data:null,error:new ia("Unexpected error in register",i)}}}}EW();const qW={url:BV,storageKey:UV,autoRefreshToken:!0,persistSession:!0,detectSessionInUrl:!0,headers:VV,flowType:"implicit",debug:!1,hasCustomAuthorizationHeader:!1,throwOnError:!1};async function c2(t,e,r){return await r()}const rc={};class yu{get jwks(){var e,r;return(r=(e=rc[this.storageKey])===null||e===void 0?void 0:e.jwks)!==null&&r!==void 0?r:{keys:[]}}set jwks(e){rc[this.storageKey]=Object.assign(Object.assign({},rc[this.storageKey]),{jwks:e})}get jwks_cached_at(){var e,r;return(r=(e=rc[this.storageKey])===null||e===void 0?void 0:e.cachedAt)!==null&&r!==void 0?r:Number.MIN_SAFE_INTEGER}set jwks_cached_at(e){rc[this.storageKey]=Object.assign(Object.assign({},rc[this.storageKey]),{cachedAt:e})}constructor(e){var r,n,s;this.userStorage=null,this.memoryStorage=null,this.stateChangeEmitters=new Map,this.autoRefreshTicker=null,this.visibilityChangedCallback=null,this.refreshingDeferred=null,this.initializePromise=null,this.detectSessionInUrl=!0,this.hasCustomAuthorizationHeader=!1,this.suppressGetSessionWarning=!1,this.lockAcquired=!1,this.pendingInLock=[],this.broadcastChannel=null,this.logger=console.log;const o=Object.assign(Object.assign({},qW),e);if(this.storageKey=o.storageKey,this.instanceID=(r=yu.nextInstanceID[this.storageKey])!==null&&r!==void 0?r:0,yu.nextInstanceID[this.storageKey]=this.instanceID+1,this.logDebugMessages=!!o.debug,typeof o.debug=="function"&&(this.logger=o.debug),this.instanceID>0&&rr()){const i=`${this._logPrefix()} Multiple GoTrueClient instances detected in the same browser context. It is not an error, but this should be avoided as it may produce undefined behavior when used concurrently under the same storage key.`;console.warn(i),this.logDebugMessages&&console.trace(i)}if(this.persistSession=o.persistSession,this.autoRefreshToken=o.autoRefreshToken,this.admin=new NW({url:o.url,headers:o.headers,fetch:o.fetch}),this.url=o.url,this.headers=o.headers,this.fetch=Z_(o.fetch),this.lock=o.lock||c2,this.detectSessionInUrl=o.detectSessionInUrl,this.flowType=o.flowType,this.hasCustomAuthorizationHeader=o.hasCustomAuthorizationHeader,this.throwOnError=o.throwOnError,o.lock?this.lock=o.lock:this.persistSession&&rr()&&(!((n=globalThis==null?void 0:globalThis.navigator)===null||n===void 0)&&n.locks)?this.lock=jW:this.lock=c2,this.jwks||(this.jwks={keys:[]},this.jwks_cached_at=Number.MIN_SAFE_INTEGER),this.mfa={verify:this._verify.bind(this),enroll:this._enroll.bind(this),unenroll:this._unenroll.bind(this),challenge:this._challenge.bind(this),listFactors:this._listFactors.bind(this),challengeAndVerify:this._challengeAndVerify.bind(this),getAuthenticatorAssuranceLevel:this._getAuthenticatorAssuranceLevel.bind(this),webauthn:new HW(this)},this.oauth={getAuthorizationDetails:this._getAuthorizationDetails.bind(this),approveAuthorization:this._approveAuthorization.bind(this),denyAuthorization:this._denyAuthorization.bind(this),listGrants:this._listOAuthGrants.bind(this),revokeGrant:this._revokeOAuthGrant.bind(this)},this.persistSession?(o.storage?this.storage=o.storage:X_()?this.storage=globalThis.localStorage:(this.memoryStorage={},this.storage=s2(this.memoryStorage)),o.userStorage&&(this.userStorage=o.userStorage)):(this.memoryStorage={},this.storage=s2(this.memoryStorage)),rr()&&globalThis.BroadcastChannel&&this.persistSession&&this.storageKey){try{this.broadcastChannel=new globalThis.BroadcastChannel(this.storageKey)}catch(i){console.error("Failed to create a new BroadcastChannel, multi-tab state changes will not be available",i)}(s=this.broadcastChannel)===null||s===void 0||s.addEventListener("message",async i=>{this._debug("received broadcast notification from other tab or client",i),await this._notifyAllSubscribers(i.data.event,i.data.session,!1)})}this.initialize()}isThrowOnErrorEnabled(){return this.throwOnError}_returnResult(e){if(this.throwOnError&&e&&e.error)throw e.error;return e}_logPrefix(){return`GoTrueClient@${this.storageKey}:${this.instanceID} (${W_}) ${new Date().toISOString()}`}_debug(...e){return this.logDebugMessages&&this.logger(this._logPrefix(),...e),this}async initialize(){return this.initializePromise?await this.initializePromise:(this.initializePromise=(async()=>await this._acquireLock(-1,async()=>await this._initialize()))(),await this.initializePromise)}async _initialize(){var e;try{let r={},n="none";if(rr()&&(r=sW(window.location.href),this._isImplicitGrantCallback(r)?n="implicit":await this._isPKCECallback(r)&&(n="pkce")),rr()&&this.detectSessionInUrl&&n!=="none"){const{data:s,error:o}=await this._getSessionFromURL(r,n);if(o){if(this._debug("#_initialize()","error detecting session from URL",o),YV(o)){const c=(e=o.details)===null||e===void 0?void 0:e.code;if(c==="identity_already_exists"||c==="identity_not_found"||c==="single_identity_not_deletable")return{error:o}}return await this._removeSession(),{error:o}}const{session:i,redirectType:a}=s;return this._debug("#_initialize()","detected session in URL",i,"redirect type",a),await this._saveSession(i),setTimeout(async()=>{a==="recovery"?await this._notifyAllSubscribers("PASSWORD_RECOVERY",i):await this._notifyAllSubscribers("SIGNED_IN",i)},0),{error:null}}return await this._recoverAndRefresh(),{error:null}}catch(r){return he(r)?this._returnResult({error:r}):this._returnResult({error:new ia("Unexpected error during initialization",r)})}finally{await this._handleVisibilityChange(),this._debug("#_initialize()","end")}}async signInAnonymously(e){var r,n,s;try{const o=await ke(this.fetch,"POST",`${this.url}/signup`,{headers:this.headers,body:{data:(n=(r=e==null?void 0:e.options)===null||r===void 0?void 0:r.data)!==null&&n!==void 0?n:{},gotrue_meta_security:{captcha_token:(s=e==null?void 0:e.options)===null||s===void 0?void 0:s.captchaToken}},xform:Xn}),{data:i,error:a}=o;if(a||!i)return this._returnResult({data:{user:null,session:null},error:a});const c=i.session,d=i.user;return i.session&&(await this._saveSession(i.session),await this._notifyAllSubscribers("SIGNED_IN",c)),this._returnResult({data:{user:d,session:c},error:null})}catch(o){if(he(o))return this._returnResult({data:{user:null,session:null},error:o});throw o}}async signUp(e){var r,n,s;try{let o;if("email"in e){const{email:u,password:h,options:f}=e;let p=null,g=null;this.flowType==="pkce"&&([p,g]=await Zl(this.storage,this.storageKey)),o=await ke(this.fetch,"POST",`${this.url}/signup`,{headers:this.headers,redirectTo:f==null?void 0:f.emailRedirectTo,body:{email:u,password:h,data:(r=f==null?void 0:f.data)!==null&&r!==void 0?r:{},gotrue_meta_security:{captcha_token:f==null?void 0:f.captchaToken},code_challenge:p,code_challenge_method:g},xform:Xn})}else if("phone"in e){const{phone:u,password:h,options:f}=e;o=await ke(this.fetch,"POST",`${this.url}/signup`,{headers:this.headers,body:{phone:u,password:h,data:(n=f==null?void 0:f.data)!==null&&n!==void 0?n:{},channel:(s=f==null?void 0:f.channel)!==null&&s!==void 0?s:"sms",gotrue_meta_security:{captcha_token:f==null?void 0:f.captchaToken}},xform:Xn})}else throw new Lp("You must provide either an email or phone number and a password");const{data:i,error:a}=o;if(a||!i)return await nr(this.storage,`${this.storageKey}-code-verifier`),this._returnResult({data:{user:null,session:null},error:a});const c=i.session,d=i.user;return i.session&&(await this._saveSession(i.session),await this._notifyAllSubscribers("SIGNED_IN",c)),this._returnResult({data:{user:d,session:c},error:null})}catch(o){if(await nr(this.storage,`${this.storageKey}-code-verifier`),he(o))return this._returnResult({data:{user:null,session:null},error:o});throw o}}async signInWithPassword(e){try{let r;if("email"in e){const{email:o,password:i,options:a}=e;r=await ke(this.fetch,"POST",`${this.url}/token?grant_type=password`,{headers:this.headers,body:{email:o,password:i,gotrue_meta_security:{captcha_token:a==null?void 0:a.captchaToken}},xform:r2})}else if("phone"in e){const{phone:o,password:i,options:a}=e;r=await ke(this.fetch,"POST",`${this.url}/token?grant_type=password`,{headers:this.headers,body:{phone:o,password:i,gotrue_meta_security:{captcha_token:a==null?void 0:a.captchaToken}},xform:r2})}else throw new Lp("You must provide either an email or phone number and a password");const{data:n,error:s}=r;if(s)return this._returnResult({data:{user:null,session:null},error:s});if(!n||!n.session||!n.user){const o=new Jl;return this._returnResult({data:{user:null,session:null},error:o})}return n.session&&(await this._saveSession(n.session),await this._notifyAllSubscribers("SIGNED_IN",n.session)),this._returnResult({data:Object.assign({user:n.user,session:n.session},n.weak_password?{weakPassword:n.weak_password}:null),error:s})}catch(r){if(he(r))return this._returnResult({data:{user:null,session:null},error:r});throw r}}async signInWithOAuth(e){var r,n,s,o;return await this._handleProviderSignIn(e.provider,{redirectTo:(r=e.options)===null||r===void 0?void 0:r.redirectTo,scopes:(n=e.options)===null||n===void 0?void 0:n.scopes,queryParams:(s=e.options)===null||s===void 0?void 0:s.queryParams,skipBrowserRedirect:(o=e.options)===null||o===void 0?void 0:o.skipBrowserRedirect})}async exchangeCodeForSession(e){return await this.initializePromise,this._acquireLock(-1,async()=>this._exchangeCodeForSession(e))}async signInWithWeb3(e){const{chain:r}=e;switch(r){case"ethereum":return await this.signInWithEthereum(e);case"solana":return await this.signInWithSolana(e);default:throw new Error(`@supabase/auth-js: Unsupported chain "${r}"`)}}async signInWithEthereum(e){var r,n,s,o,i,a,c,d,u,h,f;let p,g;if("message"in e)p=e.message,g=e.signature;else{const{chain:v,wallet:y,statement:x,options:w}=e;let b;if(rr())if(typeof y=="object")b=y;else{const j=window;if("ethereum"in j&&typeof j.ethereum=="object"&&"request"in j.ethereum&&typeof j.ethereum.request=="function")b=j.ethereum;else throw new Error("@supabase/auth-js: No compatible Ethereum wallet interface on the window object (window.ethereum) detected. Make sure the user already has a wallet installed and connected for this app. Prefer passing the wallet interface object directly to signInWithWeb3({ chain: 'ethereum', wallet: resolvedUserWallet }) instead.")}else{if(typeof y!="object"||!(w!=null&&w.url))throw new Error("@supabase/auth-js: Both wallet and url must be specified in non-browser environments.");b=y}const k=new URL((r=w==null?void 0:w.url)!==null&&r!==void 0?r:window.location.href),S=await b.request({method:"eth_requestAccounts"}).then(j=>j).catch(()=>{throw new Error("@supabase/auth-js: Wallet method eth_requestAccounts is missing or invalid")});if(!S||S.length===0)throw new Error("@supabase/auth-js: No accounts available. Please ensure the wallet is connected.");const C=i2(S[0]);let N=(n=w==null?void 0:w.signInWithEthereum)===null||n===void 0?void 0:n.chainId;if(!N){const j=await b.request({method:"eth_chainId"});N=_W(j)}const E={domain:k.host,address:C,statement:x,uri:k.href,version:"1",chainId:N,nonce:(s=w==null?void 0:w.signInWithEthereum)===null||s===void 0?void 0:s.nonce,issuedAt:(i=(o=w==null?void 0:w.signInWithEthereum)===null||o===void 0?void 0:o.issuedAt)!==null&&i!==void 0?i:new Date,expirationTime:(a=w==null?void 0:w.signInWithEthereum)===null||a===void 0?void 0:a.expirationTime,notBefore:(c=w==null?void 0:w.signInWithEthereum)===null||c===void 0?void 0:c.notBefore,requestId:(d=w==null?void 0:w.signInWithEthereum)===null||d===void 0?void 0:d.requestId,resources:(u=w==null?void 0:w.signInWithEthereum)===null||u===void 0?void 0:u.resources};p=RW(E),g=await b.request({method:"personal_sign",params:[TW(p),C]})}try{const{data:v,error:y}=await ke(this.fetch,"POST",`${this.url}/token?grant_type=web3`,{headers:this.headers,body:Object.assign({chain:"ethereum",message:p,signature:g},!((h=e.options)===null||h===void 0)&&h.captchaToken?{gotrue_meta_security:{captcha_token:(f=e.options)===null||f===void 0?void 0:f.captchaToken}}:null),xform:Xn});if(y)throw y;if(!v||!v.session||!v.user){const x=new Jl;return this._returnResult({data:{user:null,session:null},error:x})}return v.session&&(await this._saveSession(v.session),await this._notifyAllSubscribers("SIGNED_IN",v.session)),this._returnResult({data:Object.assign({},v),error:y})}catch(v){if(he(v))return this._returnResult({data:{user:null,session:null},error:v});throw v}}async signInWithSolana(e){var r,n,s,o,i,a,c,d,u,h,f,p;let g,v;if("message"in e)g=e.message,v=e.signature;else{const{chain:y,wallet:x,statement:w,options:b}=e;let k;if(rr())if(typeof x=="object")k=x;else{const C=window;if("solana"in C&&typeof C.solana=="object"&&("signIn"in C.solana&&typeof C.solana.signIn=="function"||"signMessage"in C.solana&&typeof C.solana.signMessage=="function"))k=C.solana;else throw new Error("@supabase/auth-js: No compatible Solana wallet interface on the window object (window.solana) detected. Make sure the user already has a wallet installed and connected for this app. Prefer passing the wallet interface object directly to signInWithWeb3({ chain: 'solana', wallet: resolvedUserWallet }) instead.")}else{if(typeof x!="object"||!(b!=null&&b.url))throw new Error("@supabase/auth-js: Both wallet and url must be specified in non-browser environments.");k=x}const S=new URL((r=b==null?void 0:b.url)!==null&&r!==void 0?r:window.location.href);if("signIn"in k&&k.signIn){const C=await k.signIn(Object.assign(Object.assign(Object.assign({issuedAt:new Date().toISOString()},b==null?void 0:b.signInWithSolana),{version:"1",domain:S.host,uri:S.href}),w?{statement:w}:null));let N;if(Array.isArray(C)&&C[0]&&typeof C[0]=="object")N=C[0];else if(C&&typeof C=="object"&&"signedMessage"in C&&"signature"in C)N=C;else throw new Error("@supabase/auth-js: Wallet method signIn() returned unrecognized value");if("signedMessage"in N&&"signature"in N&&(typeof N.signedMessage=="string"||N.signedMessage instanceof Uint8Array)&&N.signature instanceof Uint8Array)g=typeof N.signedMessage=="string"?N.signedMessage:new TextDecoder().decode(N.signedMessage),v=N.signature;else throw new Error("@supabase/auth-js: Wallet method signIn() API returned object without signedMessage and signature fields")}else{if(!("signMessage"in k)||typeof k.signMessage!="function"||!("publicKey"in k)||typeof k!="object"||!k.publicKey||!("toBase58"in k.publicKey)||typeof k.publicKey.toBase58!="function")throw new Error("@supabase/auth-js: Wallet does not have a compatible signMessage() and publicKey.toBase58() API");g=[`${S.host} wants you to sign in with your Solana account:`,k.publicKey.toBase58(),...w?["",w,""]:[""],"Version: 1",`URI: ${S.href}`,`Issued At: ${(s=(n=b==null?void 0:b.signInWithSolana)===null||n===void 0?void 0:n.issuedAt)!==null&&s!==void 0?s:new Date().toISOString()}`,...!((o=b==null?void 0:b.signInWithSolana)===null||o===void 0)&&o.notBefore?[`Not Before: ${b.signInWithSolana.notBefore}`]:[],...!((i=b==null?void 0:b.signInWithSolana)===null||i===void 0)&&i.expirationTime?[`Expiration Time: ${b.signInWithSolana.expirationTime}`]:[],...!((a=b==null?void 0:b.signInWithSolana)===null||a===void 0)&&a.chainId?[`Chain ID: ${b.signInWithSolana.chainId}`]:[],...!((c=b==null?void 0:b.signInWithSolana)===null||c===void 0)&&c.nonce?[`Nonce: ${b.signInWithSolana.nonce}`]:[],...!((d=b==null?void 0:b.signInWithSolana)===null||d===void 0)&&d.requestId?[`Request ID: ${b.signInWithSolana.requestId}`]:[],...!((h=(u=b==null?void 0:b.signInWithSolana)===null||u===void 0?void 0:u.resources)===null||h===void 0)&&h.length?["Resources",...b.signInWithSolana.resources.map(N=>`- ${N}`)]:[]].join(` `);const C=await k.signMessage(new TextEncoder().encode(g),"utf8");if(!C||!(C instanceof Uint8Array))throw new Error("@supabase/auth-js: Wallet signMessage() API returned an recognized value");v=C}}try{const{data:y,error:x}=await ke(this.fetch,"POST",`${this.url}/token?grant_type=web3`,{headers:this.headers,body:Object.assign({chain:"solana",message:g,signature:aa(v)},!((f=e.options)===null||f===void 0)&&f.captchaToken?{gotrue_meta_security:{captcha_token:(p=e.options)===null||p===void 0?void 0:p.captchaToken}}:null),xform:Xn});if(x)throw x;if(!y||!y.session||!y.user){const w=new Jl;return this._returnResult({data:{user:null,session:null},error:w})}return y.session&&(await this._saveSession(y.session),await this._notifyAllSubscribers("SIGNED_IN",y.session)),this._returnResult({data:Object.assign({},y),error:x})}catch(y){if(he(y))return this._returnResult({data:{user:null,session:null},error:y});throw y}}async _exchangeCodeForSession(e){const r=await ca(this.storage,`${this.storageKey}-code-verifier`),[n,s]=(r??"").split("/");try{if(!n&&this.flowType==="pkce")throw new JV;const{data:o,error:i}=await ke(this.fetch,"POST",`${this.url}/token?grant_type=pkce`,{headers:this.headers,body:{auth_code:e,code_verifier:n},xform:Xn});if(await nr(this.storage,`${this.storageKey}-code-verifier`),i)throw i;if(!o||!o.session||!o.user){const a=new Jl;return this._returnResult({data:{user:null,session:null,redirectType:null},error:a})}return o.session&&(await this._saveSession(o.session),await this._notifyAllSubscribers("SIGNED_IN",o.session)),this._returnResult({data:Object.assign(Object.assign({},o),{redirectType:s??null}),error:i})}catch(o){if(await nr(this.storage,`${this.storageKey}-code-verifier`),he(o))return this._returnResult({data:{user:null,session:null,redirectType:null},error:o});throw o}}async signInWithIdToken(e){try{const{options:r,provider:n,token:s,access_token:o,nonce:i}=e,a=await ke(this.fetch,"POST",`${this.url}/token?grant_type=id_token`,{headers:this.headers,body:{provider:n,id_token:s,access_token:o,nonce:i,gotrue_meta_security:{captcha_token:r==null?void 0:r.captchaToken}},xform:Xn}),{data:c,error:d}=a;if(d)return this._returnResult({data:{user:null,session:null},error:d});if(!c||!c.session||!c.user){const u=new Jl;return this._returnResult({data:{user:null,session:null},error:u})}return c.session&&(await this._saveSession(c.session),await this._notifyAllSubscribers("SIGNED_IN",c.session)),this._returnResult({data:c,error:d})}catch(r){if(he(r))return this._returnResult({data:{user:null,session:null},error:r});throw r}}async signInWithOtp(e){var r,n,s,o,i;try{if("email"in e){const{email:a,options:c}=e;let d=null,u=null;this.flowType==="pkce"&&([d,u]=await Zl(this.storage,this.storageKey));const{error:h}=await ke(this.fetch,"POST",`${this.url}/otp`,{headers:this.headers,body:{email:a,data:(r=c==null?void 0:c.data)!==null&&r!==void 0?r:{},create_user:(n=c==null?void 0:c.shouldCreateUser)!==null&&n!==void 0?n:!0,gotrue_meta_security:{captcha_token:c==null?void 0:c.captchaToken},code_challenge:d,code_challenge_method:u},redirectTo:c==null?void 0:c.emailRedirectTo});return this._returnResult({data:{user:null,session:null},error:h})}if("phone"in e){const{phone:a,options:c}=e,{data:d,error:u}=await ke(this.fetch,"POST",`${this.url}/otp`,{headers:this.headers,body:{phone:a,data:(s=c==null?void 0:c.data)!==null&&s!==void 0?s:{},create_user:(o=c==null?void 0:c.shouldCreateUser)!==null&&o!==void 0?o:!0,gotrue_meta_security:{captcha_token:c==null?void 0:c.captchaToken},channel:(i=c==null?void 0:c.channel)!==null&&i!==void 0?i:"sms"}});return this._returnResult({data:{user:null,session:null,messageId:d==null?void 0:d.message_id},error:u})}throw new Lp("You must provide either an email or phone number.")}catch(a){if(await nr(this.storage,`${this.storageKey}-code-verifier`),he(a))return this._returnResult({data:{user:null,session:null},error:a});throw a}}async verifyOtp(e){var r,n;try{let s,o;"options"in e&&(s=(r=e.options)===null||r===void 0?void 0:r.redirectTo,o=(n=e.options)===null||n===void 0?void 0:n.captchaToken);const{data:i,error:a}=await ke(this.fetch,"POST",`${this.url}/verify`,{headers:this.headers,body:Object.assign(Object.assign({},e),{gotrue_meta_security:{captcha_token:o}}),redirectTo:s,xform:Xn});if(a)throw a;if(!i)throw new Error("An error occurred on token verification.");const c=i.session,d=i.user;return c!=null&&c.access_token&&(await this._saveSession(c),await this._notifyAllSubscribers(e.type=="recovery"?"PASSWORD_RECOVERY":"SIGNED_IN",c)),this._returnResult({data:{user:d,session:c},error:null})}catch(s){if(he(s))return this._returnResult({data:{user:null,session:null},error:s});throw s}}async signInWithSSO(e){var r,n,s,o,i;try{let a=null,c=null;this.flowType==="pkce"&&([a,c]=await Zl(this.storage,this.storageKey));const d=await ke(this.fetch,"POST",`${this.url}/sso`,{body:Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},"providerId"in e?{provider_id:e.providerId}:null),"domain"in e?{domain:e.domain}:null),{redirect_to:(n=(r=e.options)===null||r===void 0?void 0:r.redirectTo)!==null&&n!==void 0?n:void 0}),!((s=e==null?void 0:e.options)===null||s===void 0)&&s.captchaToken?{gotrue_meta_security:{captcha_token:e.options.captchaToken}}:null),{skip_http_redirect:!0,code_challenge:a,code_challenge_method:c}),headers:this.headers,xform:bW});return!((o=d.data)===null||o===void 0)&&o.url&&rr()&&!(!((i=e.options)===null||i===void 0)&&i.skipBrowserRedirect)&&window.location.assign(d.data.url),this._returnResult(d)}catch(a){if(await nr(this.storage,`${this.storageKey}-code-verifier`),he(a))return this._returnResult({data:null,error:a});throw a}}async reauthenticate(){return await this.initializePromise,await this._acquireLock(-1,async()=>await this._reauthenticate())}async _reauthenticate(){try{return await this._useSession(async e=>{const{data:{session:r},error:n}=e;if(n)throw n;if(!r)throw new an;const{error:s}=await ke(this.fetch,"GET",`${this.url}/reauthenticate`,{headers:this.headers,jwt:r.access_token});return this._returnResult({data:{user:null,session:null},error:s})})}catch(e){if(he(e))return this._returnResult({data:{user:null,session:null},error:e});throw e}}async resend(e){try{const r=`${this.url}/resend`;if("email"in e){const{email:n,type:s,options:o}=e,{error:i}=await ke(this.fetch,"POST",r,{headers:this.headers,body:{email:n,type:s,gotrue_meta_security:{captcha_token:o==null?void 0:o.captchaToken}},redirectTo:o==null?void 0:o.emailRedirectTo});return this._returnResult({data:{user:null,session:null},error:i})}else if("phone"in e){const{phone:n,type:s,options:o}=e,{data:i,error:a}=await ke(this.fetch,"POST",r,{headers:this.headers,body:{phone:n,type:s,gotrue_meta_security:{captcha_token:o==null?void 0:o.captchaToken}}});return this._returnResult({data:{user:null,session:null,messageId:i==null?void 0:i.message_id},error:a})}throw new Lp("You must provide either an email or phone number and a type")}catch(r){if(he(r))return this._returnResult({data:{user:null,session:null},error:r});throw r}}async getSession(){return await this.initializePromise,await this._acquireLock(-1,async()=>this._useSession(async r=>r))}async _acquireLock(e,r){this._debug("#_acquireLock","begin",e);try{if(this.lockAcquired){const n=this.pendingInLock.length?this.pendingInLock[this.pendingInLock.length-1]:Promise.resolve(),s=(async()=>(await n,await r()))();return this.pendingInLock.push((async()=>{try{await s}catch{}})()),s}return await this.lock(`lock:${this.storageKey}`,e,async()=>{this._debug("#_acquireLock","lock acquired for storage key",this.storageKey);try{this.lockAcquired=!0;const n=r();for(this.pendingInLock.push((async()=>{try{await n}catch{}})()),await n;this.pendingInLock.length;){const s=[...this.pendingInLock];await Promise.all(s),this.pendingInLock.splice(0,s.length)}return await n}finally{this._debug("#_acquireLock","lock released for storage key",this.storageKey),this.lockAcquired=!1}})}finally{this._debug("#_acquireLock","end")}}async _useSession(e){this._debug("#_useSession","begin");try{const r=await this.__loadSession();return await e(r)}finally{this._debug("#_useSession","end")}}async __loadSession(){this._debug("#__loadSession()","begin"),this.lockAcquired||this._debug("#__loadSession()","used outside of an acquired lock!",new Error().stack);try{let e=null;const r=await ca(this.storage,this.storageKey);if(this._debug("#getSession()","session from storage",r),r!==null&&(this._isValidSession(r)?e=r:(this._debug("#getSession()","session from storage is not valid"),await this._removeSession())),!e)return{data:{session:null},error:null};const n=e.expires_at?e.expires_at*1e3-Date.now()await this._getUser());return r.data.user&&(this.suppressGetSessionWarning=!0),r}async _getUser(e){try{return e?await ke(this.fetch,"GET",`${this.url}/user`,{headers:this.headers,jwt:e,xform:Qo}):await this._useSession(async r=>{var n,s,o;const{data:i,error:a}=r;if(a)throw a;return!(!((n=i.session)===null||n===void 0)&&n.access_token)&&!this.hasCustomAuthorizationHeader?{data:{user:null},error:new an}:await ke(this.fetch,"GET",`${this.url}/user`,{headers:this.headers,jwt:(o=(s=i.session)===null||s===void 0?void 0:s.access_token)!==null&&o!==void 0?o:void 0,xform:Qo})})}catch(r){if(he(r))return GV(r)&&(await this._removeSession(),await nr(this.storage,`${this.storageKey}-code-verifier`)),this._returnResult({data:{user:null},error:r});throw r}}async updateUser(e,r={}){return await this.initializePromise,await this._acquireLock(-1,async()=>await this._updateUser(e,r))}async _updateUser(e,r={}){try{return await this._useSession(async n=>{const{data:s,error:o}=n;if(o)throw o;if(!s.session)throw new an;const i=s.session;let a=null,c=null;this.flowType==="pkce"&&e.email!=null&&([a,c]=await Zl(this.storage,this.storageKey));const{data:d,error:u}=await ke(this.fetch,"PUT",`${this.url}/user`,{headers:this.headers,redirectTo:r==null?void 0:r.emailRedirectTo,body:Object.assign(Object.assign({},e),{code_challenge:a,code_challenge_method:c}),jwt:i.access_token,xform:Qo});if(u)throw u;return i.user=d.user,await this._saveSession(i),await this._notifyAllSubscribers("USER_UPDATED",i),this._returnResult({data:{user:i.user},error:null})})}catch(n){if(await nr(this.storage,`${this.storageKey}-code-verifier`),he(n))return this._returnResult({data:{user:null},error:n});throw n}}async setSession(e){return await this.initializePromise,await this._acquireLock(-1,async()=>await this._setSession(e))}async _setSession(e){try{if(!e.access_token||!e.refresh_token)throw new an;const r=Date.now()/1e3;let n=r,s=!0,o=null;const{payload:i}=Sw(e.access_token);if(i.exp&&(n=i.exp,s=n<=r),s){const{data:a,error:c}=await this._callRefreshToken(e.refresh_token);if(c)return this._returnResult({data:{user:null,session:null},error:c});if(!a)return{data:{user:null,session:null},error:null};o=a}else{const{data:a,error:c}=await this._getUser(e.access_token);if(c)throw c;o={access_token:e.access_token,refresh_token:e.refresh_token,user:a.user,token_type:"bearer",expires_in:n-r,expires_at:n},await this._saveSession(o),await this._notifyAllSubscribers("SIGNED_IN",o)}return this._returnResult({data:{user:o.user,session:o},error:null})}catch(r){if(he(r))return this._returnResult({data:{session:null,user:null},error:r});throw r}}async refreshSession(e){return await this.initializePromise,await this._acquireLock(-1,async()=>await this._refreshSession(e))}async _refreshSession(e){try{return await this._useSession(async r=>{var n;if(!e){const{data:i,error:a}=r;if(a)throw a;e=(n=i.session)!==null&&n!==void 0?n:void 0}if(!(e!=null&&e.refresh_token))throw new an;const{data:s,error:o}=await this._callRefreshToken(e.refresh_token);return o?this._returnResult({data:{user:null,session:null},error:o}):s?this._returnResult({data:{user:s.user,session:s},error:null}):this._returnResult({data:{user:null,session:null},error:null})})}catch(r){if(he(r))return this._returnResult({data:{user:null,session:null},error:r});throw r}}async _getSessionFromURL(e,r){try{if(!rr())throw new $p("No browser detected.");if(e.error||e.error_description||e.error_code)throw new $p(e.error_description||"Error in URL with unspecified error_description",{error:e.error||"unspecified_error",code:e.error_code||"unspecified_code"});switch(r){case"implicit":if(this.flowType==="pkce")throw new q_("Not a valid PKCE flow url.");break;case"pkce":if(this.flowType==="implicit")throw new $p("Not a valid implicit grant flow url.");break;default:}if(r==="pkce"){if(this._debug("#_initialize()","begin","is PKCE flow",!0),!e.code)throw new q_("No code detected.");const{data:w,error:b}=await this._exchangeCodeForSession(e.code);if(b)throw b;const k=new URL(window.location.href);return k.searchParams.delete("code"),window.history.replaceState(window.history.state,"",k.toString()),{data:{session:w.session,redirectType:null},error:null}}const{provider_token:n,provider_refresh_token:s,access_token:o,refresh_token:i,expires_in:a,expires_at:c,token_type:d}=e;if(!o||!a||!i||!d)throw new $p("No session defined in URL");const u=Math.round(Date.now()/1e3),h=parseInt(a);let f=u+h;c&&(f=parseInt(c));const p=f-u;p*1e3<=Yl&&console.warn(`@supabase/gotrue-js: Session as retrieved from URL expires in ${p}s, should have been closer to ${h}s`);const g=f-h;u-g>=120?console.warn("@supabase/gotrue-js: Session as retrieved from URL was issued over 120s ago, URL could be stale",g,f,u):u-g<0&&console.warn("@supabase/gotrue-js: Session as retrieved from URL was issued in the future? Check the device clock for skew",g,f,u);const{data:v,error:y}=await this._getUser(o);if(y)throw y;const x={provider_token:n,provider_refresh_token:s,access_token:o,expires_in:h,expires_at:f,refresh_token:i,token_type:d,user:v.user};return window.location.hash="",this._debug("#_getSessionFromURL()","clearing window.location.hash"),this._returnResult({data:{session:x,redirectType:e.type},error:null})}catch(n){if(he(n))return this._returnResult({data:{session:null,redirectType:null},error:n});throw n}}_isImplicitGrantCallback(e){return typeof this.detectSessionInUrl=="function"?this.detectSessionInUrl(new URL(window.location.href),e):!!(e.access_token||e.error_description)}async _isPKCECallback(e){const r=await ca(this.storage,`${this.storageKey}-code-verifier`);return!!(e.code&&r)}async signOut(e={scope:"global"}){return await this.initializePromise,await this._acquireLock(-1,async()=>await this._signOut(e))}async _signOut({scope:e}={scope:"global"}){return await this._useSession(async r=>{var n;const{data:s,error:o}=r;if(o)return this._returnResult({error:o});const i=(n=s.session)===null||n===void 0?void 0:n.access_token;if(i){const{error:a}=await this.admin.signOut(i,e);if(a&&!(KV(a)&&(a.status===404||a.status===401||a.status===403)))return this._returnResult({error:a})}return e!=="others"&&(await this._removeSession(),await nr(this.storage,`${this.storageKey}-code-verifier`)),this._returnResult({error:null})})}onAuthStateChange(e){const r=nW(),n={id:r,callback:e,unsubscribe:()=>{this._debug("#unsubscribe()","state change callback with id removed",r),this.stateChangeEmitters.delete(r)}};return this._debug("#onAuthStateChange()","registered callback with id",r),this.stateChangeEmitters.set(r,n),(async()=>(await this.initializePromise,await this._acquireLock(-1,async()=>{this._emitInitialSession(r)})))(),{data:{subscription:n}}}async _emitInitialSession(e){return await this._useSession(async r=>{var n,s;try{const{data:{session:o},error:i}=r;if(i)throw i;await((n=this.stateChangeEmitters.get(e))===null||n===void 0?void 0:n.callback("INITIAL_SESSION",o)),this._debug("INITIAL_SESSION","callback id",e,"session",o)}catch(o){await((s=this.stateChangeEmitters.get(e))===null||s===void 0?void 0:s.callback("INITIAL_SESSION",null)),this._debug("INITIAL_SESSION","callback id",e,"error",o),console.error(o)}})}async resetPasswordForEmail(e,r={}){let n=null,s=null;this.flowType==="pkce"&&([n,s]=await Zl(this.storage,this.storageKey,!0));try{return await ke(this.fetch,"POST",`${this.url}/recover`,{body:{email:e,code_challenge:n,code_challenge_method:s,gotrue_meta_security:{captcha_token:r.captchaToken}},headers:this.headers,redirectTo:r.redirectTo})}catch(o){if(await nr(this.storage,`${this.storageKey}-code-verifier`),he(o))return this._returnResult({data:null,error:o});throw o}}async getUserIdentities(){var e;try{const{data:r,error:n}=await this.getUser();if(n)throw n;return this._returnResult({data:{identities:(e=r.user.identities)!==null&&e!==void 0?e:[]},error:null})}catch(r){if(he(r))return this._returnResult({data:null,error:r});throw r}}async linkIdentity(e){return"token"in e?this.linkIdentityIdToken(e):this.linkIdentityOAuth(e)}async linkIdentityOAuth(e){var r;try{const{data:n,error:s}=await this._useSession(async o=>{var i,a,c,d,u;const{data:h,error:f}=o;if(f)throw f;const p=await this._getUrlForProvider(`${this.url}/user/identities/authorize`,e.provider,{redirectTo:(i=e.options)===null||i===void 0?void 0:i.redirectTo,scopes:(a=e.options)===null||a===void 0?void 0:a.scopes,queryParams:(c=e.options)===null||c===void 0?void 0:c.queryParams,skipBrowserRedirect:!0});return await ke(this.fetch,"GET",p,{headers:this.headers,jwt:(u=(d=h.session)===null||d===void 0?void 0:d.access_token)!==null&&u!==void 0?u:void 0})});if(s)throw s;return rr()&&!(!((r=e.options)===null||r===void 0)&&r.skipBrowserRedirect)&&window.location.assign(n==null?void 0:n.url),this._returnResult({data:{provider:e.provider,url:n==null?void 0:n.url},error:null})}catch(n){if(he(n))return this._returnResult({data:{provider:e.provider,url:null},error:n});throw n}}async linkIdentityIdToken(e){return await this._useSession(async r=>{var n;try{const{error:s,data:{session:o}}=r;if(s)throw s;const{options:i,provider:a,token:c,access_token:d,nonce:u}=e,h=await ke(this.fetch,"POST",`${this.url}/token?grant_type=id_token`,{headers:this.headers,jwt:(n=o==null?void 0:o.access_token)!==null&&n!==void 0?n:void 0,body:{provider:a,id_token:c,access_token:d,nonce:u,link_identity:!0,gotrue_meta_security:{captcha_token:i==null?void 0:i.captchaToken}},xform:Xn}),{data:f,error:p}=h;return p?this._returnResult({data:{user:null,session:null},error:p}):!f||!f.session||!f.user?this._returnResult({data:{user:null,session:null},error:new Jl}):(f.session&&(await this._saveSession(f.session),await this._notifyAllSubscribers("USER_UPDATED",f.session)),this._returnResult({data:f,error:p}))}catch(s){if(await nr(this.storage,`${this.storageKey}-code-verifier`),he(s))return this._returnResult({data:{user:null,session:null},error:s});throw s}})}async unlinkIdentity(e){try{return await this._useSession(async r=>{var n,s;const{data:o,error:i}=r;if(i)throw i;return await ke(this.fetch,"DELETE",`${this.url}/user/identities/${e.identity_id}`,{headers:this.headers,jwt:(s=(n=o.session)===null||n===void 0?void 0:n.access_token)!==null&&s!==void 0?s:void 0})})}catch(r){if(he(r))return this._returnResult({data:null,error:r});throw r}}async _refreshAccessToken(e){const r=`#_refreshAccessToken(${e.substring(0,5)}...)`;this._debug(r,"begin");try{const n=Date.now();return await aW(async s=>(s>0&&await iW(200*Math.pow(2,s-1)),this._debug(r,"refreshing attempt",s),await ke(this.fetch,"POST",`${this.url}/token?grant_type=refresh_token`,{body:{refresh_token:e},headers:this.headers,xform:Xn})),(s,o)=>{const i=200*Math.pow(2,s);return o&&bw(o)&&Date.now()+i-n{try{await a.callback(e,r)}catch(c){o.push(c)}});if(await Promise.all(i),o.length>0){for(let a=0;athis._autoRefreshTokenTick(),Yl);this.autoRefreshTicker=e,e&&typeof e=="object"&&typeof e.unref=="function"?e.unref():typeof Deno<"u"&&typeof Deno.unrefTimer=="function"&&Deno.unrefTimer(e),setTimeout(async()=>{await this.initializePromise,await this._autoRefreshTokenTick()},0)}async _stopAutoRefresh(){this._debug("#_stopAutoRefresh()");const e=this.autoRefreshTicker;this.autoRefreshTicker=null,e&&clearInterval(e)}async startAutoRefresh(){this._removeVisibilityChangedCallback(),await this._startAutoRefresh()}async stopAutoRefresh(){this._removeVisibilityChangedCallback(),await this._stopAutoRefresh()}async _autoRefreshTokenTick(){this._debug("#_autoRefreshTokenTick()","begin");try{await this._acquireLock(0,async()=>{try{const e=Date.now();try{return await this._useSession(async r=>{const{data:{session:n}}=r;if(!n||!n.refresh_token||!n.expires_at){this._debug("#_autoRefreshTokenTick()","no session");return}const s=Math.floor((n.expires_at*1e3-e)/Yl);this._debug("#_autoRefreshTokenTick()",`access token expires in ${s} ticks, a tick lasts ${Yl}ms, refresh threshold is ${vw} ticks`),s<=vw&&await this._callRefreshToken(n.refresh_token)})}catch(r){console.error("Auto refresh tick failed with error. This is likely a transient error.",r)}}finally{this._debug("#_autoRefreshTokenTick()","end")}})}catch(e){if(e.isAcquireTimeout||e instanceof o2)this._debug("auto refresh token tick lock not available");else throw e}}async _handleVisibilityChange(){if(this._debug("#_handleVisibilityChange()"),!rr()||!(window!=null&&window.addEventListener))return this.autoRefreshToken&&this.startAutoRefresh(),!1;try{this.visibilityChangedCallback=async()=>await this._onVisibilityChanged(!1),window==null||window.addEventListener("visibilitychange",this.visibilityChangedCallback),await this._onVisibilityChanged(!0)}catch(e){console.error("_handleVisibilityChange",e)}}async _onVisibilityChanged(e){const r=`#_onVisibilityChanged(${e})`;this._debug(r,"visibilityState",document.visibilityState),document.visibilityState==="visible"?(this.autoRefreshToken&&this._startAutoRefresh(),e||(await this.initializePromise,await this._acquireLock(-1,async()=>{if(document.visibilityState!=="visible"){this._debug(r,"acquired the lock to recover the session, but the browser visibilityState is no longer visible, aborting");return}await this._recoverAndRefresh()}))):document.visibilityState==="hidden"&&this.autoRefreshToken&&this._stopAutoRefresh()}async _getUrlForProvider(e,r,n){const s=[`provider=${encodeURIComponent(r)}`];if(n!=null&&n.redirectTo&&s.push(`redirect_to=${encodeURIComponent(n.redirectTo)}`),n!=null&&n.scopes&&s.push(`scopes=${encodeURIComponent(n.scopes)}`),this.flowType==="pkce"){const[o,i]=await Zl(this.storage,this.storageKey),a=new URLSearchParams({code_challenge:`${encodeURIComponent(o)}`,code_challenge_method:`${encodeURIComponent(i)}`});s.push(a.toString())}if(n!=null&&n.queryParams){const o=new URLSearchParams(n.queryParams);s.push(o.toString())}return n!=null&&n.skipBrowserRedirect&&s.push(`skip_http_redirect=${n.skipBrowserRedirect}`),`${e}?${s.join("&")}`}async _unenroll(e){try{return await this._useSession(async r=>{var n;const{data:s,error:o}=r;return o?this._returnResult({data:null,error:o}):await ke(this.fetch,"DELETE",`${this.url}/factors/${e.factorId}`,{headers:this.headers,jwt:(n=s==null?void 0:s.session)===null||n===void 0?void 0:n.access_token})})}catch(r){if(he(r))return this._returnResult({data:null,error:r});throw r}}async _enroll(e){try{return await this._useSession(async r=>{var n,s;const{data:o,error:i}=r;if(i)return this._returnResult({data:null,error:i});const a=Object.assign({friendly_name:e.friendlyName,factor_type:e.factorType},e.factorType==="phone"?{phone:e.phone}:e.factorType==="totp"?{issuer:e.issuer}:{}),{data:c,error:d}=await ke(this.fetch,"POST",`${this.url}/factors`,{body:a,headers:this.headers,jwt:(n=o==null?void 0:o.session)===null||n===void 0?void 0:n.access_token});return d?this._returnResult({data:null,error:d}):(e.factorType==="totp"&&c.type==="totp"&&(!((s=c==null?void 0:c.totp)===null||s===void 0)&&s.qr_code)&&(c.totp.qr_code=`data:image/svg+xml;utf-8,${c.totp.qr_code}`),this._returnResult({data:c,error:null}))})}catch(r){if(he(r))return this._returnResult({data:null,error:r});throw r}}async _verify(e){return this._acquireLock(-1,async()=>{try{return await this._useSession(async r=>{var n;const{data:s,error:o}=r;if(o)return this._returnResult({data:null,error:o});const i=Object.assign({challenge_id:e.challengeId},"webauthn"in e?{webauthn:Object.assign(Object.assign({},e.webauthn),{credential_response:e.webauthn.type==="create"?LW(e.webauthn.credential_response):$W(e.webauthn.credential_response)})}:{code:e.code}),{data:a,error:c}=await ke(this.fetch,"POST",`${this.url}/factors/${e.factorId}/verify`,{body:i,headers:this.headers,jwt:(n=s==null?void 0:s.session)===null||n===void 0?void 0:n.access_token});return c?this._returnResult({data:null,error:c}):(await this._saveSession(Object.assign({expires_at:Math.round(Date.now()/1e3)+a.expires_in},a)),await this._notifyAllSubscribers("MFA_CHALLENGE_VERIFIED",a),this._returnResult({data:a,error:c}))})}catch(r){if(he(r))return this._returnResult({data:null,error:r});throw r}})}async _challenge(e){return this._acquireLock(-1,async()=>{try{return await this._useSession(async r=>{var n;const{data:s,error:o}=r;if(o)return this._returnResult({data:null,error:o});const i=await ke(this.fetch,"POST",`${this.url}/factors/${e.factorId}/challenge`,{body:e,headers:this.headers,jwt:(n=s==null?void 0:s.session)===null||n===void 0?void 0:n.access_token});if(i.error)return i;const{data:a}=i;if(a.type!=="webauthn")return{data:a,error:null};switch(a.webauthn.type){case"create":return{data:Object.assign(Object.assign({},a),{webauthn:Object.assign(Object.assign({},a.webauthn),{credential_options:Object.assign(Object.assign({},a.webauthn.credential_options),{publicKey:IW(a.webauthn.credential_options.publicKey)})})}),error:null};case"request":return{data:Object.assign(Object.assign({},a),{webauthn:Object.assign(Object.assign({},a.webauthn),{credential_options:Object.assign(Object.assign({},a.webauthn.credential_options),{publicKey:DW(a.webauthn.credential_options.publicKey)})})}),error:null}}})}catch(r){if(he(r))return this._returnResult({data:null,error:r});throw r}})}async _challengeAndVerify(e){const{data:r,error:n}=await this._challenge({factorId:e.factorId});return n?this._returnResult({data:null,error:n}):await this._verify({factorId:e.factorId,challengeId:r.id,code:e.code})}async _listFactors(){var e;const{data:{user:r},error:n}=await this.getUser();if(n)return{data:null,error:n};const s={all:[],phone:[],totp:[],webauthn:[]};for(const o of(e=r==null?void 0:r.factors)!==null&&e!==void 0?e:[])s.all.push(o),o.status==="verified"&&s[o.factor_type].push(o);return{data:s,error:null}}async _getAuthenticatorAssuranceLevel(){var e,r;const{data:{session:n},error:s}=await this.getSession();if(s)return this._returnResult({data:null,error:s});if(!n)return{data:{currentLevel:null,nextLevel:null,currentAuthenticationMethods:[]},error:null};const{payload:o}=Sw(n.access_token);let i=null;o.aal&&(i=o.aal);let a=i;((r=(e=n.user.factors)===null||e===void 0?void 0:e.filter(u=>u.status==="verified"))!==null&&r!==void 0?r:[]).length>0&&(a="aal2");const d=o.amr||[];return{data:{currentLevel:i,nextLevel:a,currentAuthenticationMethods:d},error:null}}async _getAuthorizationDetails(e){try{return await this._useSession(async r=>{const{data:{session:n},error:s}=r;return s?this._returnResult({data:null,error:s}):n?await ke(this.fetch,"GET",`${this.url}/oauth/authorizations/${e}`,{headers:this.headers,jwt:n.access_token,xform:o=>({data:o,error:null})}):this._returnResult({data:null,error:new an})})}catch(r){if(he(r))return this._returnResult({data:null,error:r});throw r}}async _approveAuthorization(e,r){try{return await this._useSession(async n=>{const{data:{session:s},error:o}=n;if(o)return this._returnResult({data:null,error:o});if(!s)return this._returnResult({data:null,error:new an});const i=await ke(this.fetch,"POST",`${this.url}/oauth/authorizations/${e}/consent`,{headers:this.headers,jwt:s.access_token,body:{action:"approve"},xform:a=>({data:a,error:null})});return i.data&&i.data.redirect_url&&rr()&&!(r!=null&&r.skipBrowserRedirect)&&window.location.assign(i.data.redirect_url),i})}catch(n){if(he(n))return this._returnResult({data:null,error:n});throw n}}async _denyAuthorization(e,r){try{return await this._useSession(async n=>{const{data:{session:s},error:o}=n;if(o)return this._returnResult({data:null,error:o});if(!s)return this._returnResult({data:null,error:new an});const i=await ke(this.fetch,"POST",`${this.url}/oauth/authorizations/${e}/consent`,{headers:this.headers,jwt:s.access_token,body:{action:"deny"},xform:a=>({data:a,error:null})});return i.data&&i.data.redirect_url&&rr()&&!(r!=null&&r.skipBrowserRedirect)&&window.location.assign(i.data.redirect_url),i})}catch(n){if(he(n))return this._returnResult({data:null,error:n});throw n}}async _listOAuthGrants(){try{return await this._useSession(async e=>{const{data:{session:r},error:n}=e;return n?this._returnResult({data:null,error:n}):r?await ke(this.fetch,"GET",`${this.url}/user/oauth/grants`,{headers:this.headers,jwt:r.access_token,xform:s=>({data:s,error:null})}):this._returnResult({data:null,error:new an})})}catch(e){if(he(e))return this._returnResult({data:null,error:e});throw e}}async _revokeOAuthGrant(e){try{return await this._useSession(async r=>{const{data:{session:n},error:s}=r;return s?this._returnResult({data:null,error:s}):n?(await ke(this.fetch,"DELETE",`${this.url}/user/oauth/grants`,{headers:this.headers,jwt:n.access_token,query:{client_id:e.clientId},noResolveJson:!0}),{data:{},error:null}):this._returnResult({data:null,error:new an})})}catch(r){if(he(r))return this._returnResult({data:null,error:r});throw r}}async fetchJwk(e,r={keys:[]}){let n=r.keys.find(a=>a.kid===e);if(n)return n;const s=Date.now();if(n=this.jwks.keys.find(a=>a.kid===e),n&&this.jwks_cached_at+HV>s)return n;const{data:o,error:i}=await ke(this.fetch,"GET",`${this.url}/.well-known/jwks.json`,{headers:this.headers});if(i)throw i;return!o.keys||o.keys.length===0||(this.jwks=o,this.jwks_cached_at=s,n=o.keys.find(a=>a.kid===e),!n)?null:n}async getClaims(e,r={}){try{let n=e;if(!n){const{data:p,error:g}=await this.getSession();if(g||!p.session)return this._returnResult({data:null,error:g});n=p.session.access_token}const{header:s,payload:o,signature:i,raw:{header:a,payload:c}}=Sw(n);r!=null&&r.allowExpired||pW(o.exp);const d=!s.alg||s.alg.startsWith("HS")||!s.kid||!("crypto"in globalThis&&"subtle"in globalThis.crypto)?null:await this.fetchJwk(s.kid,r!=null&&r.keys?{keys:r.keys}:r==null?void 0:r.jwks);if(!d){const{error:p}=await this.getUser(n);if(p)throw p;return{data:{claims:o,header:s,signature:i},error:null}}const u=mW(s.alg),h=await crypto.subtle.importKey("jwk",d,u,!0,["verify"]);if(!await crypto.subtle.verify(u,h,i,tW(`${a}.${c}`)))throw new kw("Invalid JWT signature");return{data:{claims:o,header:s,signature:i},error:null}}catch(n){if(he(n))return this._returnResult({data:null,error:n});throw n}}}yu.nextInstanceID={};const KW=yu,GW="2.88.0";let xu="";typeof Deno<"u"?xu="deno":typeof document<"u"?xu="web":typeof navigator<"u"&&navigator.product==="ReactNative"?xu="react-native":xu="node";const YW={headers:{"X-Client-Info":`supabase-js-${xu}/${GW}`}},JW={schema:"public"},QW={autoRefreshToken:!0,persistSession:!0,detectSessionInUrl:!0,flowType:"implicit"},XW={};function wu(t){"@babel/helpers - typeof";return wu=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},wu(t)}function ZW(t,e){if(wu(t)!="object"||!t)return t;var r=t[Symbol.toPrimitive];if(r!==void 0){var n=r.call(t,e||"default");if(wu(n)!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function eH(t){var e=ZW(t,"string");return wu(e)=="symbol"?e:e+""}function tH(t,e,r){return(e=eH(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function d2(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(s){return Object.getOwnPropertyDescriptor(t,s).enumerable})),r.push.apply(r,n)}return r}function ct(t){for(var e=1;et?(...e)=>t(...e):(...e)=>fetch(...e),nH=()=>Headers,sH=(t,e,r)=>{const n=rH(r),s=nH();return async(o,i)=>{var a;const c=(a=await e())!==null&&a!==void 0?a:t;let d=new s(i==null?void 0:i.headers);return d.has("apikey")||d.set("apikey",t),d.has("Authorization")||d.set("Authorization",`Bearer ${c}`),n(o,ct(ct({},i),{},{headers:d}))}};function oH(t){return t.endsWith("/")?t:t+"/"}function iH(t,e){var r,n;const{db:s,auth:o,realtime:i,global:a}=t,{db:c,auth:d,realtime:u,global:h}=e,f={db:ct(ct({},c),s),auth:ct(ct({},d),o),realtime:ct(ct({},u),i),storage:{},global:ct(ct(ct({},h),a),{},{headers:ct(ct({},(r=h==null?void 0:h.headers)!==null&&r!==void 0?r:{}),(n=a==null?void 0:a.headers)!==null&&n!==void 0?n:{})}),accessToken:async()=>""};return t.accessToken?f.accessToken=t.accessToken:delete f.accessToken,f}function aH(t){const e=t==null?void 0:t.trim();if(!e)throw new Error("supabaseUrl is required.");if(!e.match(/^https?:\/\//i))throw new Error("Invalid supabaseUrl: Must be a valid HTTP or HTTPS URL.");try{return new URL(oH(e))}catch{throw Error("Invalid supabaseUrl: Provided URL is malformed.")}}var lH=class extends KW{constructor(t){super(t)}},cH=class{constructor(t,e,r){var n,s;this.supabaseUrl=t,this.supabaseKey=e;const o=aH(t);if(!e)throw new Error("supabaseKey is required.");this.realtimeUrl=new URL("realtime/v1",o),this.realtimeUrl.protocol=this.realtimeUrl.protocol.replace("http","ws"),this.authUrl=new URL("auth/v1",o),this.storageUrl=new URL("storage/v1",o),this.functionsUrl=new URL("functions/v1",o);const i=`sb-${o.hostname.split(".")[0]}-auth-token`,a={db:JW,realtime:XW,auth:ct(ct({},QW),{},{storageKey:i}),global:YW},c=iH(r??{},a);if(this.storageKey=(n=c.auth.storageKey)!==null&&n!==void 0?n:"",this.headers=(s=c.global.headers)!==null&&s!==void 0?s:{},c.accessToken)this.accessToken=c.accessToken,this.auth=new Proxy({},{get:(u,h)=>{throw new Error(`@supabase/supabase-js: Supabase Client is configured with the accessToken option, accessing supabase.auth.${String(h)} is not possible`)}});else{var d;this.auth=this._initSupabaseAuthClient((d=c.auth)!==null&&d!==void 0?d:{},this.headers,c.global.fetch)}this.fetch=sH(e,this._getAccessToken.bind(this),c.global.fetch),this.realtime=this._initRealtimeClient(ct({headers:this.headers,accessToken:this._getAccessToken.bind(this)},c.realtime)),this.accessToken&&this.accessToken().then(u=>this.realtime.setAuth(u)).catch(u=>console.warn("Failed to set initial Realtime auth token:",u)),this.rest=new W8(new URL("rest/v1",o).href,{headers:this.headers,schema:c.db.schema,fetch:this.fetch}),this.storage=new zV(this.storageUrl.href,this.headers,this.fetch,r==null?void 0:r.storage),c.accessToken||this._listenForAuthEvents()}get functions(){return new F8(this.functionsUrl.href,{headers:this.headers,customFetch:this.fetch})}from(t){return this.rest.from(t)}schema(t){return this.rest.schema(t)}rpc(t,e={},r={head:!1,get:!1,count:void 0}){return this.rest.rpc(t,e,r)}channel(t,e={config:{}}){return this.realtime.channel(t,e)}getChannels(){return this.realtime.getChannels()}removeChannel(t){return this.realtime.removeChannel(t)}removeAllChannels(){return this.realtime.removeAllChannels()}async _getAccessToken(){var t=this,e,r;if(t.accessToken)return await t.accessToken();const{data:n}=await t.auth.getSession();return(e=(r=n.session)===null||r===void 0?void 0:r.access_token)!==null&&e!==void 0?e:t.supabaseKey}_initSupabaseAuthClient({autoRefreshToken:t,persistSession:e,detectSessionInUrl:r,storage:n,userStorage:s,storageKey:o,flowType:i,lock:a,debug:c,throwOnError:d},u,h){const f={Authorization:`Bearer ${this.supabaseKey}`,apikey:`${this.supabaseKey}`};return new lH({url:this.authUrl.href,headers:ct(ct({},f),u),storageKey:o,autoRefreshToken:t,persistSession:e,detectSessionInUrl:r,storage:n,userStorage:s,flowType:i,lock:a,debug:c,throwOnError:d,fetch:h,hasCustomAuthorizationHeader:Object.keys(this.headers).some(p=>p.toLowerCase()==="authorization")})}_initRealtimeClient(t){return new iV(this.realtimeUrl.href,ct(ct({},t),{},{params:ct(ct({},{apikey:this.supabaseKey}),t==null?void 0:t.params)}))}_listenForAuthEvents(){return this.auth.onAuthStateChange((t,e)=>{this._handleTokenChanged(t,"CLIENT",e==null?void 0:e.access_token)})}_handleTokenChanged(t,e,r){(t==="TOKEN_REFRESHED"||t==="SIGNED_IN")&&this.changedAccessToken!==r?(this.changedAccessToken=r,this.realtime.setAuth(r)):t==="SIGNED_OUT"&&(this.realtime.setAuth(),e=="STORAGE"&&this.auth.signOut(),this.changedAccessToken=void 0)}};const dH=(t,e,r)=>new cH(t,e,r);function uH(){if(typeof window<"u"||typeof process>"u")return!1;const t=process.version;if(t==null)return!1;const e=t.match(/^v(\d+)\./);return e?parseInt(e[1],10)<=18:!1}uH()&&console.warn("⚠️ Node.js 18 and below are deprecated and will no longer be supported in future versions of @supabase/supabase-js. Please upgrade to Node.js 20 or later. For more information, visit: https://github.com/orgs/supabase/discussions/37217");const q=dH("https://jqoaxvwjqgjxmenvuwql.supabase.co","eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6Impxb2F4dndqcWdqeG1lbnZ1d3FsIiwicm9sZSI6ImFub24iLCJpYXQiOjE3NzEwOTUxMTYsImV4cCI6MjA4NjY3MTExNn0.0em4louFIEQkjQwCvudwxWQILppMpGcPtWTIwd1yvQw",{auth:{storage:localStorage,persistSession:!0,autoRefreshToken:!0}}),Cn=new Date().toISOString(),hH=[{id:"sample-1",user_id:"demo-user",name:"Introduction to Computer Science",code:"CS101",professor_name:"Dr. Sarah Chen",professor_email:"schen@university.edu",color:"#14b8a6",meeting_days:[1,3],start_time:"09:00",end_time:"10:30",location:"Engineering Hall 201",timezone:"America/New_York",semester_start:"2025-01-13",semester_end:"2025-05-02",section_number:"001",office_hours_day:"Wednesday",office_hours_time:"2:00 PM - 4:00 PM",office_hours_location:"Engineering 305",class_website:null,notes:null,syllabus_url:null,syllabus_parsed_at:null,created_at:Cn,updated_at:Cn},{id:"sample-2",user_id:"demo-user",name:"Calculus II",code:"MATH201",professor_name:"Prof. James Miller",professor_email:"jmiller@university.edu",color:"#f59e0b",meeting_days:[2,4],start_time:"11:00",end_time:"12:30",location:"Science Building 105",timezone:"America/New_York",semester_start:"2025-01-13",semester_end:"2025-05-02",section_number:"002",office_hours_day:"Thursday",office_hours_time:"1:00 PM - 3:00 PM",office_hours_location:"Science 210",class_website:null,notes:null,syllabus_url:null,syllabus_parsed_at:null,created_at:Cn,updated_at:Cn},{id:"sample-3",user_id:"demo-user",name:"Modern Philosophy",code:"PHIL302",professor_name:"Dr. Emma Thompson",professor_email:"ethompson@university.edu",color:"#8b5cf6",meeting_days:[1,3,5],start_time:"14:00",end_time:"15:30",location:"Humanities 301",timezone:"America/New_York",semester_start:"2025-01-13",semester_end:"2025-05-02",section_number:null,office_hours_day:"Tuesday",office_hours_time:"10:00 AM - 12:00 PM",office_hours_location:"Humanities 205",class_website:null,notes:null,syllabus_url:null,syllabus_parsed_at:null,created_at:Cn,updated_at:Cn},{id:"sample-4",user_id:"demo-user",name:"Organic Chemistry",code:"CHEM301",professor_name:"Dr. Michael Park",professor_email:"mpark@university.edu",color:"#ec4899",meeting_days:[2,4],start_time:"09:00",end_time:"10:30",location:"Chemistry Lab 102",timezone:"America/New_York",semester_start:"2025-01-13",semester_end:"2025-05-02",section_number:"A",office_hours_day:"Monday",office_hours_time:"3:00 PM - 5:00 PM",office_hours_location:"Chemistry 150",class_website:null,notes:null,syllabus_url:null,syllabus_parsed_at:null,created_at:Cn,updated_at:Cn},{id:"sample-5",user_id:"demo-user",name:"Introduction to Psychology",code:"PSYCH101",professor_name:"Dr. Lisa Rodriguez",professor_email:"lrodriguez@university.edu",color:"#6366f1",meeting_days:[1,4],start_time:"10:00",end_time:"11:30",location:"Social Sciences 201",timezone:"America/New_York",semester_start:"2025-01-13",semester_end:"2025-05-02",section_number:"001",office_hours_day:"Wednesday",office_hours_time:"9:00 AM - 11:00 AM",office_hours_location:"Social Sciences 315",class_website:null,notes:null,syllabus_url:null,syllabus_parsed_at:null,created_at:Cn,updated_at:Cn},{id:"sample-6",user_id:"demo-user",name:"Principles of Economics",code:"ECON201",professor_name:"Prof. David Kim",professor_email:"dkim@university.edu",color:"#22c55e",meeting_days:[2,5],start_time:"13:00",end_time:"14:30",location:"Business Hall 104",timezone:"America/New_York",semester_start:"2025-01-13",semester_end:"2025-05-02",section_number:"003",office_hours_day:"Friday",office_hours_time:"11:00 AM - 1:00 PM",office_hours_location:"Business 220",class_website:null,notes:null,syllabus_url:null,syllabus_parsed_at:null,created_at:Cn,updated_at:Cn}];function ua(){const{toast:t}=gs(),e=Dl(),r=xn({queryKey:["classes"],queryFn:async()=>{const{data:{user:a}}=await q.auth.getUser();if(!a)return hH;const{data:c,error:d}=await q.from("classes").select("*").eq("user_id",a.id).order("created_at",{ascending:!1});if(d)throw d;return c}}),n=(a,c,d,u,h,f,p,g)=>{const v=[],y=lu(p),x=lu(g);let w=y;for(;p8(w,x)||pe(w,"yyyy-MM-dd")===pe(x,"yyyy-MM-dd");){const b=f8(w);d.includes(b)&&v.push({class_id:a,user_id:c,session_date:pe(w,"yyyy-MM-dd"),start_time:u,end_time:h,location:f,topics:[],attendance:"pending",notes:null,calendar_event_id:null}),w=yt(w,1)}return v},s=ta({mutationFn:async a=>{const{data:{user:c}}=await q.auth.getUser();if(!c)throw new Error("Not authenticated");const{data:d,error:u}=await q.from("classes").insert({user_id:c.id,name:a.name,code:a.code||null,professor_name:a.professor_name,professor_email:a.professor_email||null,color:a.color,meeting_days:a.meeting_days,start_time:a.start_time,end_time:a.end_time,location:a.location,timezone:a.timezone,semester_start:a.semester_start,semester_end:a.semester_end,section_number:a.section_number||null,office_hours_day:a.office_hours_day||null,office_hours_time:a.office_hours_time||null,office_hours_location:a.office_hours_location||null,class_website:a.class_website||null,notes:a.notes||null}).select().single();if(u)throw u;const h=n(d.id,c.id,a.meeting_days,a.start_time,a.end_time,a.location,a.semester_start,a.semester_end);if(h.length>0){const{error:f}=await q.from("sessions").insert(h);f&&console.error("Error creating sessions:",f)}return d},onSuccess:()=>{e.invalidateQueries({queryKey:["classes"]}),e.invalidateQueries({queryKey:["sessions"]}),t({title:"Class created",description:"Your class and sessions have been added."})},onError:a=>{t({title:"Failed to create class",description:a.message,variant:"destructive"})}}),o=ta({mutationFn:async({id:a,...c})=>{const{data:d,error:u}=await q.from("classes").update(c).eq("id",a).select().single();if(u)throw u;return d},onSuccess:()=>{e.invalidateQueries({queryKey:["classes"]}),t({title:"Class updated"})},onError:a=>{t({title:"Failed to update class",description:a.message,variant:"destructive"})}}),i=ta({mutationFn:async a=>{if(a.startsWith("sample-"))return;const{error:c}=await q.from("classes").delete().eq("id",a);if(c)throw c},onSuccess:(a,c)=>{c.startsWith("sample-")?e.setQueryData(["classes"],d=>d?d.filter(u=>u.id!==c):[]):(e.invalidateQueries({queryKey:["classes"]}),e.invalidateQueries({queryKey:["sessions"]}),e.invalidateQueries({queryKey:["deadlines"]})),t({title:"Class deleted"})},onError:a=>{t({title:"Failed to delete class",description:a.message,variant:"destructive"})}});return{classes:r.data??[],isLoading:r.isLoading,error:r.error,createClass:s.mutate,updateClass:o.mutate,deleteClass:i.mutate,isCreating:s.isPending,isUpdating:o.isPending,isDeleting:i.isPending}}function fH(t){const e=Dl(),{toast:r}=gs(),n=xn({queryKey:["class",t],queryFn:async()=>{if(!t)return null;const{data:f,error:p}=await q.from("classes").select("*").eq("id",t).maybeSingle();if(p)throw p;return f},enabled:!!t}),s=xn({queryKey:["sessions",t],queryFn:async()=>{if(!t)return[];const{data:f,error:p}=await q.from("sessions").select("*").eq("class_id",t).order("session_date",{ascending:!0});if(p)throw p;return f},enabled:!!t}),o=xn({queryKey:["deadlines",t],queryFn:async()=>{if(!t)return[];const{data:f,error:p}=await q.from("deadlines").select("*").eq("class_id",t).order("due_date",{ascending:!0});if(p)throw p;return f},enabled:!!t}),i=xn({queryKey:["class-todos",t],queryFn:async()=>{if(!t)return[];const{data:f,error:p}=await q.from("class_todos").select("*").eq("class_id",t).order("created_at",{ascending:!1});if(p)throw p;return f},enabled:!!t}),a=xn({queryKey:["class-notes",t],queryFn:async()=>{if(!t)return[];const{data:f,error:p}=await q.from("notes").select("*").eq("class_id",t).order("created_at",{ascending:!1});if(p)throw p;return f},enabled:!!t}),c=ta({mutationFn:async f=>{const{data:p,error:g}=await q.from("deadlines").insert(f).select().single();if(g)throw g;return p},onSuccess:()=>{e.invalidateQueries({queryKey:["deadlines",t]}),r({title:"Deadline added"})}}),d=ta({mutationFn:async({id:f,...p})=>{const{data:g,error:v}=await q.from("deadlines").update(p).eq("id",f).select().single();if(v)throw v;return g},onSuccess:()=>{e.invalidateQueries({queryKey:["deadlines",t]})}}),u=ta({mutationFn:async f=>{const{data:p,error:g}=await q.from("class_todos").insert(f).select().single();if(g)throw g;return p},onSuccess:()=>{e.invalidateQueries({queryKey:["class-todos",t]}),r({title:"To-do added"})}}),h=ta({mutationFn:async({id:f,...p})=>{const{data:g,error:v}=await q.from("class_todos").update(p).eq("id",f).select().single();if(v)throw v;return g},onSuccess:()=>{e.invalidateQueries({queryKey:["class-todos",t]})}});return{classData:n.data,sessions:s.data??[],deadlines:o.data??[],todos:i.data??[],notes:a.data??[],isLoading:n.isLoading||s.isLoading||o.isLoading,addDeadline:c.mutate,updateDeadline:d.mutate,addTodo:u.mutate,updateTodo:h.mutate}}const Vp=Kx,pH=Gx,u2=m.forwardRef(({className:t,...e},r)=>l.jsx(ru,{className:B("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",t),...e,ref:r}));u2.displayName=ru.displayName;const mH=Sl("fixed z-50 gap-4 bg-background p-6 shadow-lg transition ease-in-out data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:duration-300 data-[state=open]:duration-500",{variants:{side:{top:"inset-x-0 top-0 border-b data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top",bottom:"inset-x-0 bottom-0 border-t data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom",left:"inset-y-0 left-0 h-full w-3/4 border-r data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left sm:max-w-sm",right:"inset-y-0 right-0 h-full w-3/4 border-l data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right sm:max-w-sm"}},defaultVariants:{side:"right"}}),bu=m.forwardRef(({side:t="right",className:e,children:r,...n},s)=>l.jsxs(pH,{children:[l.jsx(u2,{}),l.jsxs(nu,{ref:s,className:B(mH({side:t}),e),...n,children:[r,l.jsxs(e_,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity data-[state=open]:bg-secondary hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none",children:[l.jsx(Wd,{className:"h-4 w-4"}),l.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));bu.displayName=nu.displayName;const ku=({className:t,...e})=>l.jsx("div",{className:B("flex flex-col space-y-2 text-center sm:text-left",t),...e});ku.displayName="SheetHeader";const Wp=m.forwardRef(({className:t,...e},r)=>l.jsx(Tp,{ref:r,className:B("text-lg font-semibold text-foreground",t),...e}));Wp.displayName=Tp.displayName;const gH=m.forwardRef(({className:t,...e},r)=>l.jsx(Rp,{ref:r,className:B("text-sm text-muted-foreground",t),...e}));gH.displayName=Rp.displayName;const Ne=m.forwardRef(({className:t,type:e,...r},n)=>l.jsx("input",{type:e,className:B("flex h-10 w-full rounded-lg border border-input bg-background px-3 py-2 text-base ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 md:text-sm transition-colors",t),ref:n,...r}));Ne.displayName="Input";var vH=m.createContext(void 0);function ha(t){const e=m.useContext(vH);return t||e||"ltr"}var jw="rovingFocusGroup.onEntryFocus",yH={bubbles:!1,cancelable:!0},Su="RovingFocusGroup",[Ew,h2,xH]=Ld(Su),[wH,nc]=Ft(Su,[xH]),[bH,kH]=wH(Su),f2=m.forwardRef((t,e)=>l.jsx(Ew.Provider,{scope:t.__scopeRovingFocusGroup,children:l.jsx(Ew.Slot,{scope:t.__scopeRovingFocusGroup,children:l.jsx(SH,{...t,ref:e})})}));f2.displayName=Su;var SH=m.forwardRef((t,e)=>{const{__scopeRovingFocusGroup:r,orientation:n,loop:s=!1,dir:o,currentTabStopId:i,defaultCurrentTabStopId:a,onCurrentTabStopIdChange:c,onEntryFocus:d,preventScrollOnEntryFocus:u=!1,...h}=t,f=m.useRef(null),p=we(e,f),g=ha(o),[v,y]=Wn({prop:i,defaultProp:a??null,onChange:c,caller:Su}),[x,w]=m.useState(!1),b=at(d),k=h2(r),S=m.useRef(!1),[C,N]=m.useState(0);return m.useEffect(()=>{const E=f.current;if(E)return E.addEventListener(jw,b),()=>E.removeEventListener(jw,b)},[b]),l.jsx(bH,{scope:r,orientation:n,dir:g,loop:s,currentTabStopId:v,onItemFocus:m.useCallback(E=>y(E),[y]),onItemShiftTab:m.useCallback(()=>w(!0),[]),onFocusableItemAdd:m.useCallback(()=>N(E=>E+1),[]),onFocusableItemRemove:m.useCallback(()=>N(E=>E-1),[]),children:l.jsx(se.div,{tabIndex:x||C===0?-1:0,"data-orientation":n,...h,ref:p,style:{outline:"none",...t.style},onMouseDown:Q(t.onMouseDown,()=>{S.current=!0}),onFocus:Q(t.onFocus,E=>{const j=!S.current;if(E.target===E.currentTarget&&j&&!x){const _=new CustomEvent(jw,yH);if(E.currentTarget.dispatchEvent(_),!_.defaultPrevented){const P=k().filter(L=>L.focusable),T=P.find(L=>L.active),A=P.find(L=>L.id===v),V=[T,A,...P].filter(Boolean).map(L=>L.ref.current);g2(V,u)}}S.current=!1}),onBlur:Q(t.onBlur,()=>w(!1))})})}),p2="RovingFocusGroupItem",m2=m.forwardRef((t,e)=>{const{__scopeRovingFocusGroup:r,focusable:n=!0,active:s=!1,tabStopId:o,children:i,...a}=t,c=hr(),d=o||c,u=kH(p2,r),h=u.currentTabStopId===d,f=h2(r),{onFocusableItemAdd:p,onFocusableItemRemove:g,currentTabStopId:v}=u;return m.useEffect(()=>{if(n)return p(),()=>g()},[n,p,g]),l.jsx(Ew.ItemSlot,{scope:r,id:d,focusable:n,active:s,children:l.jsx(se.span,{tabIndex:h?0:-1,"data-orientation":u.orientation,...a,ref:e,onMouseDown:Q(t.onMouseDown,y=>{n?u.onItemFocus(d):y.preventDefault()}),onFocus:Q(t.onFocus,()=>u.onItemFocus(d)),onKeyDown:Q(t.onKeyDown,y=>{if(y.key==="Tab"&&y.shiftKey){u.onItemShiftTab();return}if(y.target!==y.currentTarget)return;const x=jH(y,u.orientation,u.dir);if(x!==void 0){if(y.metaKey||y.ctrlKey||y.altKey||y.shiftKey)return;y.preventDefault();let b=f().filter(k=>k.focusable).map(k=>k.ref.current);if(x==="last")b.reverse();else if(x==="prev"||x==="next"){x==="prev"&&b.reverse();const k=b.indexOf(y.currentTarget);b=u.loop?EH(b,k+1):b.slice(k+1)}setTimeout(()=>g2(b))}}),children:typeof i=="function"?i({isCurrentTabStop:h,hasTabStop:v!=null}):i})})});m2.displayName=p2;var NH={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function CH(t,e){return e!=="rtl"?t:t==="ArrowLeft"?"ArrowRight":t==="ArrowRight"?"ArrowLeft":t}function jH(t,e,r){const n=CH(t.key,r);if(!(e==="vertical"&&["ArrowLeft","ArrowRight"].includes(n))&&!(e==="horizontal"&&["ArrowUp","ArrowDown"].includes(n)))return NH[n]}function g2(t,e=!1){const r=document.activeElement;for(const n of t)if(n===r||(n.focus({preventScroll:e}),document.activeElement!==r))return}function EH(t,e){return t.map((r,n)=>t[(e+n)%t.length])}var _w=f2,Tw=m2,Hp="Tabs",[_H,Rre]=Ft(Hp,[nc]),v2=nc(),[TH,Rw]=_H(Hp),y2=m.forwardRef((t,e)=>{const{__scopeTabs:r,value:n,onValueChange:s,defaultValue:o,orientation:i="horizontal",dir:a,activationMode:c="automatic",...d}=t,u=ha(a),[h,f]=Wn({prop:n,onChange:s,defaultProp:o??"",caller:Hp});return l.jsx(TH,{scope:r,baseId:hr(),value:h,onValueChange:f,orientation:i,dir:u,activationMode:c,children:l.jsx(se.div,{dir:u,"data-orientation":i,...d,ref:e})})});y2.displayName=Hp;var x2="TabsList",w2=m.forwardRef((t,e)=>{const{__scopeTabs:r,loop:n=!0,...s}=t,o=Rw(x2,r),i=v2(r);return l.jsx(_w,{asChild:!0,...i,orientation:o.orientation,dir:o.dir,loop:n,children:l.jsx(se.div,{role:"tablist","aria-orientation":o.orientation,...s,ref:e})})});w2.displayName=x2;var b2="TabsTrigger",k2=m.forwardRef((t,e)=>{const{__scopeTabs:r,value:n,disabled:s=!1,...o}=t,i=Rw(b2,r),a=v2(r),c=C2(i.baseId,n),d=j2(i.baseId,n),u=n===i.value;return l.jsx(Tw,{asChild:!0,...a,focusable:!s,active:u,children:l.jsx(se.button,{type:"button",role:"tab","aria-selected":u,"aria-controls":d,"data-state":u?"active":"inactive","data-disabled":s?"":void 0,disabled:s,id:c,...o,ref:e,onMouseDown:Q(t.onMouseDown,h=>{!s&&h.button===0&&h.ctrlKey===!1?i.onValueChange(n):h.preventDefault()}),onKeyDown:Q(t.onKeyDown,h=>{[" ","Enter"].includes(h.key)&&i.onValueChange(n)}),onFocus:Q(t.onFocus,()=>{const h=i.activationMode!=="manual";!u&&!s&&h&&i.onValueChange(n)})})})});k2.displayName=b2;var S2="TabsContent",N2=m.forwardRef((t,e)=>{const{__scopeTabs:r,value:n,forceMount:s,children:o,...i}=t,a=Rw(S2,r),c=C2(a.baseId,n),d=j2(a.baseId,n),u=n===a.value,h=m.useRef(u);return m.useEffect(()=>{const f=requestAnimationFrame(()=>h.current=!1);return()=>cancelAnimationFrame(f)},[]),l.jsx(er,{present:s||u,children:({present:f})=>l.jsx(se.div,{"data-state":u?"active":"inactive","data-orientation":a.orientation,role:"tabpanel","aria-labelledby":c,hidden:!f,id:d,tabIndex:0,...i,ref:e,style:{...t.style,animationDuration:h.current?"0s":void 0},children:f&&o})})});N2.displayName=S2;function C2(t,e){return`${t}-trigger-${e}`}function j2(t,e){return`${t}-content-${e}`}var RH=y2,E2=w2,_2=k2,T2=N2;const no=RH,ks=m.forwardRef(({className:t,...e},r)=>l.jsx(E2,{ref:r,className:B("inline-flex h-10 items-center justify-center rounded-md bg-muted p-1 text-muted-foreground",t),...e}));ks.displayName=E2.displayName;const Ze=m.forwardRef(({className:t,...e},r)=>l.jsx(_2,{ref:r,className:B("inline-flex items-center justify-center whitespace-nowrap rounded-sm px-3 py-1.5 text-sm font-medium ring-offset-background transition-all data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow-sm focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50",t),...e}));Ze.displayName=_2.displayName;const et=m.forwardRef(({className:t,...e},r)=>l.jsx(T2,{ref:r,className:B("mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",t),...e}));et.displayName=T2.displayName;function sr(t){this.content=t}sr.prototype={constructor:sr,find:function(t){for(var e=0;e>1}},sr.from=function(t){if(t instanceof sr)return t;var e=[];if(t)for(var r in t)e.push(r,t[r]);return new sr(e)};function R2(t,e,r){for(let n=0;;n++){if(n==t.childCount||n==e.childCount)return t.childCount==e.childCount?null:r;let s=t.child(n),o=e.child(n);if(s==o){r+=s.nodeSize;continue}if(!s.sameMarkup(o))return r;if(s.isText&&s.text!=o.text){for(let i=0;s.text[i]==o.text[i];i++)r++;return r}if(s.content.size||o.content.size){let i=R2(s.content,o.content,r+1);if(i!=null)return i}r+=s.nodeSize}}function M2(t,e,r,n){for(let s=t.childCount,o=e.childCount;;){if(s==0||o==0)return s==o?null:{a:r,b:n};let i=t.child(--s),a=e.child(--o),c=i.nodeSize;if(i==a){r-=c,n-=c;continue}if(!i.sameMarkup(a))return{a:r,b:n};if(i.isText&&i.text!=a.text){let d=0,u=Math.min(i.text.length,a.text.length);for(;de&&n(c,s+a,o||null,i)!==!1&&c.content.size){let u=a+1;c.nodesBetween(Math.max(0,e-u),Math.min(c.content.size,r-u),n,s+u)}a=d}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,r,n,s){let o="",i=!0;return this.nodesBetween(e,r,(a,c)=>{let d=a.isText?a.text.slice(Math.max(e,c)-c,r-c):a.isLeaf?s?typeof s=="function"?s(a):s:a.type.spec.leafText?a.type.spec.leafText(a):"":"";a.isBlock&&(a.isLeaf&&d||a.isTextblock)&&n&&(i?i=!1:o+=n),o+=d},0),o}append(e){if(!e.size)return this;if(!this.size)return e;let r=this.lastChild,n=e.firstChild,s=this.content.slice(),o=0;for(r.isText&&r.sameMarkup(n)&&(s[s.length-1]=r.withText(r.text+n.text),o=1);oe)for(let o=0,i=0;ie&&((ir)&&(a.isText?a=a.cut(Math.max(0,e-i),Math.min(a.text.length,r-i)):a=a.cut(Math.max(0,e-i-1),Math.min(a.content.size,r-i-1))),n.push(a),s+=a.nodeSize),i=c}return new Y(n,s)}cutByIndex(e,r){return e==r?Y.empty:e==0&&r==this.content.length?this:new Y(this.content.slice(e,r))}replaceChild(e,r){let n=this.content[e];if(n==r)return this;let s=this.content.slice(),o=this.size+r.nodeSize-n.nodeSize;return s[e]=r,new Y(s,o)}addToStart(e){return new Y([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new Y(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let r=0;rthis.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let r=0,n=0;;r++){let s=this.child(r),o=n+s.nodeSize;if(o>=e)return o==e?qp(r+1,o):qp(r,n);n=o}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(e,r){if(!r)return Y.empty;if(!Array.isArray(r))throw new RangeError("Invalid input for Fragment.fromJSON");return new Y(r.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return Y.empty;let r,n=0;for(let s=0;sthis.type.rank&&(r||(r=e.slice(0,s)),r.push(this),n=!0),r&&r.push(o)}}return r||(r=e.slice()),n||r.push(this),r}removeFromSet(e){for(let r=0;rn.type.rank-s.type.rank),r}};Ve.none=[];class Gp extends Error{}class oe{constructor(e,r,n){this.content=e,this.openStart=r,this.openEnd=n}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,r){let n=P2(this.content,e+this.openStart,r);return n&&new oe(n,this.openStart,this.openEnd)}removeBetween(e,r){return new oe(O2(this.content,e+this.openStart,r+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(e,r){if(!r)return oe.empty;let n=r.openStart||0,s=r.openEnd||0;if(typeof n!="number"||typeof s!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new oe(Y.fromJSON(e,r.content),n,s)}static maxOpen(e,r=!0){let n=0,s=0;for(let o=e.firstChild;o&&!o.isLeaf&&(r||!o.type.spec.isolating);o=o.firstChild)n++;for(let o=e.lastChild;o&&!o.isLeaf&&(r||!o.type.spec.isolating);o=o.lastChild)s++;return new oe(e,n,s)}}oe.empty=new oe(Y.empty,0,0);function O2(t,e,r){let{index:n,offset:s}=t.findIndex(e),o=t.maybeChild(n),{index:i,offset:a}=t.findIndex(r);if(s==e||o.isText){if(a!=r&&!t.child(i).isText)throw new RangeError("Removing non-flat range");return t.cut(0,e).append(t.cut(r))}if(n!=i)throw new RangeError("Removing non-flat range");return t.replaceChild(n,o.copy(O2(o.content,e-s-1,r-s-1)))}function P2(t,e,r,n){let{index:s,offset:o}=t.findIndex(e),i=t.maybeChild(s);if(o==e||i.isText)return n&&!n.canReplace(s,s,r)?null:t.cut(0,e).append(r).append(t.cut(e));let a=P2(i.content,e-o-1,r,i);return a&&t.replaceChild(s,i.copy(a))}function MH(t,e,r){if(r.openStart>t.depth)throw new Gp("Inserted content deeper than insertion position");if(t.depth-r.openStart!=e.depth-r.openEnd)throw new Gp("Inconsistent open depths");return A2(t,e,r,0)}function A2(t,e,r,n){let s=t.index(n),o=t.node(n);if(s==e.index(n)&&n=0&&t.isText&&t.sameMarkup(e[r])?e[r]=t.withText(e[r].text+t.text):e.push(t)}function Nu(t,e,r,n){let s=(e||t).node(r),o=0,i=e?e.index(r):s.childCount;t&&(o=t.index(r),t.depth>r?o++:t.textOffset&&(fa(t.nodeAfter,n),o++));for(let a=o;as&&Ow(t,e,s+1),i=n.depth>s&&Ow(r,n,s+1),a=[];return Nu(null,t,s,a),o&&i&&e.index(s)==r.index(s)?(I2(o,i),fa(pa(o,D2(t,e,r,n,s+1)),a)):(o&&fa(pa(o,Yp(t,e,s+1)),a),Nu(e,r,s,a),i&&fa(pa(i,Yp(r,n,s+1)),a)),Nu(n,null,s,a),new Y(a)}function Yp(t,e,r){let n=[];if(Nu(null,t,r,n),t.depth>r){let s=Ow(t,e,r+1);fa(pa(s,Yp(t,e,r+1)),n)}return Nu(e,null,r,n),new Y(n)}function OH(t,e){let r=e.depth-t.openStart,s=e.node(r).copy(t.content);for(let o=r-1;o>=0;o--)s=e.node(o).copy(Y.from(s));return{start:s.resolveNoCache(t.openStart+r),end:s.resolveNoCache(s.content.size-t.openEnd-r)}}class Cu{constructor(e,r,n){this.pos=e,this.path=r,this.parentOffset=n,this.depth=r.length/3-1}resolveDepth(e){return e==null?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position before the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position after the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,r=this.index(this.depth);if(r==e.childCount)return null;let n=this.pos-this.path[this.path.length-1],s=e.child(r);return n?e.child(r).cut(n):s}get nodeBefore(){let e=this.index(this.depth),r=this.pos-this.path[this.path.length-1];return r?this.parent.child(e).cut(0,r):e==0?null:this.parent.child(e-1)}posAtIndex(e,r){r=this.resolveDepth(r);let n=this.path[r*3],s=r==0?0:this.path[r*3-1]+1;for(let o=0;o0;r--)if(this.start(r)<=e&&this.end(r)>=e)return r;return 0}blockRange(e=this,r){if(e.pos=0;n--)if(e.pos<=this.end(n)&&(!r||r(this.node(n))))return new Jp(this,e,n);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos=0&&r<=e.content.size))throw new RangeError("Position "+r+" out of range");let n=[],s=0,o=r;for(let i=e;;){let{index:a,offset:c}=i.content.findIndex(o),d=o-c;if(n.push(i,a,s+c),!d||(i=i.child(a),i.isText))break;o=d-1,s+=c+1}return new Cu(r,n,o)}static resolveCached(e,r){let n=L2.get(e);if(n)for(let o=0;oe&&this.nodesBetween(e,r,o=>(n.isInSet(o.marks)&&(s=!0),!s)),s}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let e=this.type.name;return this.content.size&&(e+="("+this.content.toStringInner()+")"),$2(this.marks,e)}contentMatchAt(e){let r=this.type.contentMatch.matchFragment(this.content,0,e);if(!r)throw new Error("Called contentMatchAt on a node with invalid content");return r}canReplace(e,r,n=Y.empty,s=0,o=n.childCount){let i=this.contentMatchAt(e).matchFragment(n,s,o),a=i&&i.matchFragment(this.content,r);if(!a||!a.validEnd)return!1;for(let c=s;cr.type.name)}`);this.content.forEach(r=>r.check())}toJSON(){let e={type:this.type.name};for(let r in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(r=>r.toJSON())),e}static fromJSON(e,r){if(!r)throw new RangeError("Invalid input for Node.fromJSON");let n;if(r.marks){if(!Array.isArray(r.marks))throw new RangeError("Invalid mark data for Node.fromJSON");n=r.marks.map(e.markFromJSON)}if(r.type=="text"){if(typeof r.text!="string")throw new RangeError("Invalid text node in JSON");return e.text(r.text,n)}let s=Y.fromJSON(e,r.content),o=e.nodeType(r.type).create(r.attrs,s,n);return o.type.checkAttrs(o.attrs),o}};Xo.prototype.text=void 0;class Qp extends Xo{constructor(e,r,n,s){if(super(e,r,null,s),!n)throw new RangeError("Empty text nodes are not allowed");this.text=n}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):$2(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,r){return this.text.slice(e,r)}get nodeSize(){return this.text.length}mark(e){return e==this.marks?this:new Qp(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new Qp(this.type,this.attrs,e,this.marks)}cut(e=0,r=this.text.length){return e==0&&r==this.text.length?this:this.withText(this.text.slice(e,r))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}}function $2(t,e){for(let r=t.length-1;r>=0;r--)e=t[r].type.name+"("+e+")";return e}class ma{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,r){let n=new DH(e,r);if(n.next==null)return ma.empty;let s=F2(n);n.next&&n.err("Unexpected trailing text");let o=VH(UH(s));return WH(o,n),o}matchType(e){for(let r=0;rd.createAndFill()));for(let d=0;d=this.next.length)throw new RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function r(n){e.push(n);for(let s=0;s{let o=s+(n.validEnd?"*":" ")+" ";for(let i=0;i"+e.indexOf(n.next[i].next);return o}).join(` `)}}ma.empty=new ma(!0);class DH{constructor(e,r){this.string=e,this.nodeTypes=r,this.inline=null,this.pos=0,this.tokens=e.split(/\s*(?=\b|\W|$)/),this.tokens[this.tokens.length-1]==""&&this.tokens.pop(),this.tokens[0]==""&&this.tokens.shift()}get next(){return this.tokens[this.pos]}eat(e){return this.next==e&&(this.pos++||!0)}err(e){throw new SyntaxError(e+" (in content expression '"+this.string+"')")}}function F2(t){let e=[];do e.push(LH(t));while(t.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function LH(t){let e=[];do e.push($H(t));while(t.next&&t.next!=")"&&t.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function $H(t){let e=BH(t);for(;;)if(t.eat("+"))e={type:"plus",expr:e};else if(t.eat("*"))e={type:"star",expr:e};else if(t.eat("?"))e={type:"opt",expr:e};else if(t.eat("{"))e=FH(t,e);else break;return e}function z2(t){/\D/.test(t.next)&&t.err("Expected number, got '"+t.next+"'");let e=Number(t.next);return t.pos++,e}function FH(t,e){let r=z2(t),n=r;return t.eat(",")&&(t.next!="}"?n=z2(t):n=-1),t.eat("}")||t.err("Unclosed braced range"),{type:"range",min:r,max:n,expr:e}}function zH(t,e){let r=t.nodeTypes,n=r[e];if(n)return[n];let s=[];for(let o in r){let i=r[o];i.isInGroup(e)&&s.push(i)}return s.length==0&&t.err("No node type or group '"+e+"' found"),s}function BH(t){if(t.eat("(")){let e=F2(t);return t.eat(")")||t.err("Missing closing paren"),e}else if(/\W/.test(t.next))t.err("Unexpected token '"+t.next+"'");else{let e=zH(t,t.next).map(r=>(t.inline==null?t.inline=r.isInline:t.inline!=r.isInline&&t.err("Mixing inline and block content"),{type:"name",value:r}));return t.pos++,e.length==1?e[0]:{type:"choice",exprs:e}}}function UH(t){let e=[[]];return s(o(t,0),r()),e;function r(){return e.push([])-1}function n(i,a,c){let d={term:c,to:a};return e[i].push(d),d}function s(i,a){i.forEach(c=>c.to=a)}function o(i,a){if(i.type=="choice")return i.exprs.reduce((c,d)=>c.concat(o(d,a)),[]);if(i.type=="seq")for(let c=0;;c++){let d=o(i.exprs[c],a);if(c==i.exprs.length-1)return d;s(d,a=r())}else if(i.type=="star"){let c=r();return n(a,c),s(o(i.expr,c),c),[n(c)]}else if(i.type=="plus"){let c=r();return s(o(i.expr,a),c),s(o(i.expr,c),c),[n(c)]}else{if(i.type=="opt")return[n(a)].concat(o(i.expr,a));if(i.type=="range"){let c=a;for(let d=0;d{t[i].forEach(({term:a,to:c})=>{if(!a)return;let d;for(let u=0;u{d||s.push([a,d=[]]),d.indexOf(u)==-1&&d.push(u)})})});let o=e[n.join(",")]=new ma(n.indexOf(t.length-1)>-1);for(let i=0;i-1}get whitespace(){return this.spec.whitespace||(this.spec.code?"pre":"normal")}hasRequiredAttrs(){for(let e in this.attrs)if(this.attrs[e].isRequired)return!0;return!1}compatibleContent(e){return this==e||this.contentMatch.compatible(e.contentMatch)}computeAttrs(e){return!e&&this.defaultAttrs?this.defaultAttrs:W2(this.attrs,e)}create(e=null,r,n){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new Xo(this,this.computeAttrs(e),Y.from(r),Ve.setFrom(n))}createChecked(e=null,r,n){return r=Y.from(r),this.checkContent(r),new Xo(this,this.computeAttrs(e),r,Ve.setFrom(n))}createAndFill(e=null,r,n){if(e=this.computeAttrs(e),r=Y.from(r),r.size){let i=this.contentMatch.fillBefore(r);if(!i)return null;r=i.append(r)}let s=this.contentMatch.matchFragment(r),o=s&&s.fillBefore(Y.empty,!0);return o?new Xo(this,e,r.append(o),Ve.setFrom(n)):null}validContent(e){let r=this.contentMatch.matchFragment(e);if(!r||!r.validEnd)return!1;for(let n=0;n-1}allowsMarks(e){if(this.markSet==null)return!0;for(let r=0;rn[o]=new iD(o,r,i));let s=r.spec.topNode||"doc";if(!n[s])throw new RangeError("Schema is missing its top node type ('"+s+"')");if(!n.text)throw new RangeError("Every schema needs a 'text' type");for(let o in n.text.attrs)throw new RangeError("The text node type should not have attributes");return n}};function HH(t,e,r){let n=r.split("|");return s=>{let o=s===null?"null":typeof s;if(n.indexOf(o)<0)throw new RangeError(`Expected value of type ${n} for attribute ${e} on type ${t}, got ${o}`)}}class qH{constructor(e,r,n){this.hasDefault=Object.prototype.hasOwnProperty.call(n,"default"),this.default=n.default,this.validate=typeof n.validate=="string"?HH(e,r,n.validate):n.validate}get isRequired(){return!this.hasDefault}}class Xp{constructor(e,r,n,s){this.name=e,this.rank=r,this.schema=n,this.spec=s,this.attrs=q2(e,s.attrs),this.excluded=null;let o=V2(this.attrs);this.instance=o?new Ve(this,o):null}create(e=null){return!e&&this.instance?this.instance:new Ve(this,W2(this.attrs,e))}static compile(e,r){let n=Object.create(null),s=0;return e.forEach((o,i)=>n[o]=new Xp(o,s++,r,i)),n}removeFromSet(e){for(var r=0;r-1}}class G2{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let r=this.spec={};for(let s in e)r[s]=e[s];r.nodes=sr.from(e.nodes),r.marks=sr.from(e.marks||{}),this.nodes=K2.compile(this.spec.nodes,this),this.marks=Xp.compile(this.spec.marks,this);let n=Object.create(null);for(let s in this.nodes){if(s in this.marks)throw new RangeError(s+" can not be both a node and a mark");let o=this.nodes[s],i=o.spec.content||"",a=o.spec.marks;if(o.contentMatch=n[i]||(n[i]=ma.parse(i,this.nodes)),o.inlineContent=o.contentMatch.inlineContent,o.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!o.isInline||!o.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=o}o.markSet=a=="_"?null:a?Y2(this,a.split(" ")):a==""||!o.inlineContent?[]:null}for(let s in this.marks){let o=this.marks[s],i=o.spec.excludes;o.excluded=i==null?[o]:i==""?[]:Y2(this,i.split(" "))}this.nodeFromJSON=s=>Xo.fromJSON(this,s),this.markFromJSON=s=>Ve.fromJSON(this,s),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(e,r=null,n,s){if(typeof e=="string")e=this.nodeType(e);else if(e instanceof K2){if(e.schema!=this)throw new RangeError("Node type from different schema used ("+e.name+")")}else throw new RangeError("Invalid node type: "+e);return e.createChecked(r,n,s)}text(e,r){let n=this.nodes.text;return new Qp(n,n.defaultAttrs,e,Ve.setFrom(r))}mark(e,r){return typeof e=="string"&&(e=this.marks[e]),e.create(r)}nodeType(e){let r=this.nodes[e];if(!r)throw new RangeError("Unknown node type: "+e);return r}}function Y2(t,e){let r=[];for(let n=0;n-1)&&r.push(i=c)}if(!i)throw new SyntaxError("Unknown mark type: '"+e[n]+"'")}return r}function KH(t){return t.tag!=null}function GH(t){return t.style!=null}class Zo{constructor(e,r){this.schema=e,this.rules=r,this.tags=[],this.styles=[];let n=this.matchedStyles=[];r.forEach(s=>{if(KH(s))this.tags.push(s);else if(GH(s)){let o=/[^=]*/.exec(s.style)[0];n.indexOf(o)<0&&n.push(o),this.styles.push(s)}}),this.normalizeLists=!this.tags.some(s=>{if(!/^(ul|ol)\b/.test(s.tag)||!s.node)return!1;let o=e.nodes[s.node];return o.contentMatch.matchType(o)})}parse(e,r={}){let n=new Z2(this,r,!1);return n.addAll(e,Ve.none,r.from,r.to),n.finish()}parseSlice(e,r={}){let n=new Z2(this,r,!0);return n.addAll(e,Ve.none,r.from,r.to),oe.maxOpen(n.finish())}matchTag(e,r,n){for(let s=n?this.tags.indexOf(n)+1:0;se.length&&(a.charCodeAt(e.length)!=61||a.slice(e.length+1)!=r))){if(i.getAttrs){let c=i.getAttrs(r);if(c===!1)continue;i.attrs=c||void 0}return i}}}static schemaRules(e){let r=[];function n(s){let o=s.priority==null?50:s.priority,i=0;for(;i{n(i=eT(i)),i.mark||i.ignore||i.clearMark||(i.mark=s)})}for(let s in e.nodes){let o=e.nodes[s].spec.parseDOM;o&&o.forEach(i=>{n(i=eT(i)),i.node||i.ignore||i.mark||(i.node=s)})}return r}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new Zo(e,Zo.schemaRules(e)))}}const J2={address:!0,article:!0,aside:!0,blockquote:!0,canvas:!0,dd:!0,div:!0,dl:!0,fieldset:!0,figcaption:!0,figure:!0,footer:!0,form:!0,h1:!0,h2:!0,h3:!0,h4:!0,h5:!0,h6:!0,header:!0,hgroup:!0,hr:!0,li:!0,noscript:!0,ol:!0,output:!0,p:!0,pre:!0,section:!0,table:!0,tfoot:!0,ul:!0},YH={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},Q2={ol:!0,ul:!0},ju=1,Pw=2,Eu=4;function X2(t,e,r){return e!=null?(e?ju:0)|(e==="full"?Pw:0):t&&t.whitespace=="pre"?ju|Pw:r&~Eu}class Zp{constructor(e,r,n,s,o,i){this.type=e,this.attrs=r,this.marks=n,this.solid=s,this.options=i,this.content=[],this.activeMarks=Ve.none,this.match=o||(i&Eu?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let r=this.type.contentMatch.fillBefore(Y.from(e));if(r)this.match=this.type.contentMatch.matchFragment(r);else{let n=this.type.contentMatch,s;return(s=n.findWrapping(e.type))?(this.match=n,s):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&ju)){let n=this.content[this.content.length-1],s;if(n&&n.isText&&(s=/[ \t\r\n\u000c]+$/.exec(n.text))){let o=n;n.text.length==s[0].length?this.content.pop():this.content[this.content.length-1]=o.withText(o.text.slice(0,o.text.length-s[0].length))}}let r=Y.from(this.content);return!e&&this.match&&(r=r.append(this.match.fillBefore(Y.empty,!0))),this.type?this.type.create(this.attrs,r,this.marks):r}inlineContext(e){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:e.parentNode&&!J2.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class Z2{constructor(e,r,n){this.parser=e,this.options=r,this.isOpen=n,this.open=0,this.localPreserveWS=!1;let s=r.topNode,o,i=X2(null,r.preserveWhitespace,0)|(n?Eu:0);s?o=new Zp(s.type,s.attrs,Ve.none,!0,r.topMatch||s.type.contentMatch,i):n?o=new Zp(null,null,Ve.none,!0,null,i):o=new Zp(e.schema.topNodeType,null,Ve.none,!0,null,i),this.nodes=[o],this.find=r.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e,r){e.nodeType==3?this.addTextNode(e,r):e.nodeType==1&&this.addElement(e,r)}addTextNode(e,r){let n=e.nodeValue,s=this.top,o=s.options&Pw?"full":this.localPreserveWS||(s.options&ju)>0,{schema:i}=this.parser;if(o==="full"||s.inlineContext(e)||/[^ \t\r\n\u000c]/.test(n)){if(o)if(o==="full")n=n.replace(/\r\n?/g,` `);else if(i.linebreakReplacement&&/[\r\n]/.test(n)&&this.top.findWrapping(i.linebreakReplacement.create())){let a=n.split(/\r?\n|\r/);for(let c=0;c!c.clearMark(d)):r=r.concat(this.parser.schema.marks[c.mark].create(c.attrs)),c.consuming===!1)a=c;else break}}return r}addElementByRule(e,r,n,s){let o,i;if(r.node)if(i=this.parser.schema.nodes[r.node],i.isLeaf)this.insertNode(i.create(r.attrs),n,e.nodeName=="BR")||this.leafFallback(e,n);else{let c=this.enter(i,r.attrs||null,n,r.preserveWhitespace);c&&(o=!0,n=c)}else{let c=this.parser.schema.marks[r.mark];n=n.concat(c.create(r.attrs))}let a=this.top;if(i&&i.isLeaf)this.findInside(e);else if(s)this.addElement(e,n,s);else if(r.getContent)this.findInside(e),r.getContent(e,this.parser.schema).forEach(c=>this.insertNode(c,n,!1));else{let c=e;typeof r.contentElement=="string"?c=e.querySelector(r.contentElement):typeof r.contentElement=="function"?c=r.contentElement(e):r.contentElement&&(c=r.contentElement),this.findAround(e,c,!0),this.addAll(c,n),this.findAround(e,c,!1)}o&&this.sync(a)&&this.open--}addAll(e,r,n,s){let o=n||0;for(let i=n?e.childNodes[n]:e.firstChild,a=s==null?null:e.childNodes[s];i!=a;i=i.nextSibling,++o)this.findAtPoint(e,o),this.addDOM(i,r);this.findAtPoint(e,o)}findPlace(e,r,n){let s,o;for(let i=this.open,a=0;i>=0;i--){let c=this.nodes[i],d=c.findWrapping(e);if(d&&(!s||s.length>d.length+a)&&(s=d,o=c,!d.length))break;if(c.solid){if(n)break;a+=2}}if(!s)return null;this.sync(o);for(let i=0;i(i.type?i.type.allowsMarkType(d.type):tT(d.type,e))?(c=d.addToSet(c),!1):!0),this.nodes.push(new Zp(e,r,c,s,null,a)),this.open++,n}closeExtra(e=!1){let r=this.nodes.length-1;if(r>this.open){for(;r>this.open;r--)this.nodes[r-1].content.push(this.nodes[r].finish(e));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(!!(this.isOpen||this.options.topOpen))}sync(e){for(let r=this.open;r>=0;r--){if(this.nodes[r]==e)return this.open=r,!0;this.localPreserveWS&&(this.nodes[r].options|=ju)}return!1}get currentPos(){this.closeExtra();let e=0;for(let r=this.open;r>=0;r--){let n=this.nodes[r].content;for(let s=n.length-1;s>=0;s--)e+=n[s].nodeSize;r&&e++}return e}findAtPoint(e,r){if(this.find)for(let n=0;n-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let r=e.split("/"),n=this.options.context,s=!this.isOpen&&(!n||n.parent.type==this.nodes[0].type),o=-(n?n.depth+1:0)+(s?0:1),i=(a,c)=>{for(;a>=0;a--){let d=r[a];if(d==""){if(a==r.length-1||a==0)continue;for(;c>=o;c--)if(i(a-1,c))return!0;return!1}else{let u=c>0||c==0&&s?this.nodes[c].type:n&&c>=o?n.node(c-o).type:null;if(!u||u.name!=d&&!u.isInGroup(d))return!1;c--}}return!0};return i(r.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let r=e.depth;r>=0;r--){let n=e.node(r).contentMatchAt(e.indexAfter(r)).defaultType;if(n&&n.isTextblock&&n.defaultAttrs)return n}for(let r in this.parser.schema.nodes){let n=this.parser.schema.nodes[r];if(n.isTextblock&&n.defaultAttrs)return n}}}function JH(t){for(let e=t.firstChild,r=null;e;e=e.nextSibling){let n=e.nodeType==1?e.nodeName.toLowerCase():null;n&&Q2.hasOwnProperty(n)&&r?(r.appendChild(e),e=r):n=="li"?r=e:n&&(r=null)}}function QH(t,e){return(t.matches||t.msMatchesSelector||t.webkitMatchesSelector||t.mozMatchesSelector).call(t,e)}function eT(t){let e={};for(let r in t)e[r]=t[r];return e}function tT(t,e){let r=e.schema.nodes;for(let n in r){let s=r[n];if(!s.allowsMarkType(t))continue;let o=[],i=a=>{o.push(a);for(let c=0;c{if(o.length||i.marks.length){let a=0,c=0;for(;a=0;s--){let o=this.serializeMark(e.marks[s],e.isInline,r);o&&((o.contentDOM||o.dom).appendChild(n),n=o.dom)}return n}serializeMark(e,r,n={}){let s=this.marks[e.type.name];return s&&em(Aw(n),s(e,r),null,e.attrs)}static renderSpec(e,r,n=null,s){return em(e,r,n,s)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new ga(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let r=rT(e.nodes);return r.text||(r.text=n=>n.text),r}static marksFromSchema(e){return rT(e.marks)}}function rT(t){let e={};for(let r in t){let n=t[r].spec.toDOM;n&&(e[r]=n)}return e}function Aw(t){return t.document||window.document}const nT=new WeakMap;function XH(t){let e=nT.get(t);return e===void 0&&nT.set(t,e=ZH(t)),e}function ZH(t){let e=null;function r(n){if(n&&typeof n=="object")if(Array.isArray(n))if(typeof n[0]=="string")e||(e=[]),e.push(n);else for(let s=0;s-1)throw new RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");let i=s.indexOf(" ");i>0&&(r=s.slice(0,i),s=s.slice(i+1));let a,c=r?t.createElementNS(r,s):t.createElement(s),d=e[1],u=1;if(d&&typeof d=="object"&&d.nodeType==null&&!Array.isArray(d)){u=2;for(let h in d)if(d[h]!=null){let f=h.indexOf(" ");f>0?c.setAttributeNS(h.slice(0,f),h.slice(f+1),d[h]):h=="style"&&c.style?c.style.cssText=d[h]:c.setAttribute(h,d[h])}}for(let h=u;hu)throw new RangeError("Content hole must be the only child of its parent node");return{dom:c,contentDOM:c}}else{let{dom:p,contentDOM:g}=em(t,f,r,n);if(c.appendChild(p),g){if(a)throw new RangeError("Multiple content holes");a=g}}}return{dom:c,contentDOM:a}}const sT=65535,oT=Math.pow(2,16);function e9(t,e){return t+e*oT}function iT(t){return t&sT}function t9(t){return(t-(t&sT))/oT}const aT=1,lT=2,tm=4,cT=8;class Iw{constructor(e,r,n){this.pos=e,this.delInfo=r,this.recover=n}get deleted(){return(this.delInfo&cT)>0}get deletedBefore(){return(this.delInfo&(aT|tm))>0}get deletedAfter(){return(this.delInfo&(lT|tm))>0}get deletedAcross(){return(this.delInfo&tm)>0}}class ln{constructor(e,r=!1){if(this.ranges=e,this.inverted=r,!e.length&&ln.empty)return ln.empty}recover(e){let r=0,n=iT(e);if(!this.inverted)for(let s=0;se)break;let d=this.ranges[a+o],u=this.ranges[a+i],h=c+d;if(e<=h){let f=d?e==c?-1:e==h?1:r:r,p=c+s+(f<0?0:u);if(n)return p;let g=e==(r<0?c:h)?null:e9(a/3,e-c),v=e==c?lT:e==h?aT:tm;return(r<0?e!=c:e!=h)&&(v|=cT),new Iw(p,v,g)}s+=u-d}return n?e+s:new Iw(e+s,0,null)}touches(e,r){let n=0,s=iT(r),o=this.inverted?2:1,i=this.inverted?1:2;for(let a=0;ae)break;let d=this.ranges[a+o],u=c+d;if(e<=u&&a==s*3)return!0;n+=this.ranges[a+i]-d}return!1}forEach(e){let r=this.inverted?2:1,n=this.inverted?1:2;for(let s=0,o=0;s=0;r--){let s=e.getMirror(r);this.appendMap(e._maps[r].invert(),s!=null&&s>r?n-s-1:void 0)}}invert(){let e=new _u;return e.appendMappingInverted(this),e}map(e,r=1){if(this.mirror)return this._map(e,r,!0);for(let n=this.from;no&&c!i.isAtom||!a.type.allowsMarkType(this.mark.type)?i:i.mark(this.mark.addToSet(i.marks)),s),r.openStart,r.openEnd);return kt.fromReplace(e,this.from,this.to,o)}invert(){return new Ss(this.from,this.to,this.mark)}map(e){let r=e.mapResult(this.from,1),n=e.mapResult(this.to,-1);return r.deleted&&n.deleted||r.pos>=n.pos?null:new ei(r.pos,n.pos,this.mark)}merge(e){return e instanceof ei&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new ei(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,r){if(typeof r.from!="number"||typeof r.to!="number")throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new ei(r.from,r.to,e.markFromJSON(r.mark))}}fr.jsonID("addMark",ei);class Ss extends fr{constructor(e,r,n){super(),this.from=e,this.to=r,this.mark=n}apply(e){let r=e.slice(this.from,this.to),n=new oe(Lw(r.content,s=>s.mark(this.mark.removeFromSet(s.marks)),e),r.openStart,r.openEnd);return kt.fromReplace(e,this.from,this.to,n)}invert(){return new ei(this.from,this.to,this.mark)}map(e){let r=e.mapResult(this.from,1),n=e.mapResult(this.to,-1);return r.deleted&&n.deleted||r.pos>=n.pos?null:new Ss(r.pos,n.pos,this.mark)}merge(e){return e instanceof Ss&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Ss(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,r){if(typeof r.from!="number"||typeof r.to!="number")throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new Ss(r.from,r.to,e.markFromJSON(r.mark))}}fr.jsonID("removeMark",Ss);class ti extends fr{constructor(e,r){super(),this.pos=e,this.mark=r}apply(e){let r=e.nodeAt(this.pos);if(!r)return kt.fail("No node at mark step's position");let n=r.type.create(r.attrs,null,this.mark.addToSet(r.marks));return kt.fromReplace(e,this.pos,this.pos+1,new oe(Y.from(n),0,r.isLeaf?0:1))}invert(e){let r=e.nodeAt(this.pos);if(r){let n=this.mark.addToSet(r.marks);if(n.length==r.marks.length){for(let s=0;sn.pos?null:new Vt(r.pos,n.pos,s,o,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,r){if(typeof r.from!="number"||typeof r.to!="number"||typeof r.gapFrom!="number"||typeof r.gapTo!="number"||typeof r.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new Vt(r.from,r.to,r.gapFrom,r.gapTo,oe.fromJSON(e,r.slice),r.insert,!!r.structure)}}fr.jsonID("replaceAround",Vt);function $w(t,e,r){let n=t.resolve(e),s=r-e,o=n.depth;for(;s>0&&o>0&&n.indexAfter(o)==n.node(o).childCount;)o--,s--;if(s>0){let i=n.node(o).maybeChild(n.indexAfter(o));for(;s>0;){if(!i||i.isLeaf)return!0;i=i.firstChild,s--}}return!1}function r9(t,e,r,n){let s=[],o=[],i,a;t.doc.nodesBetween(e,r,(c,d,u)=>{if(!c.isInline)return;let h=c.marks;if(!n.isInSet(h)&&u.type.allowsMarkType(n.type)){let f=Math.max(d,e),p=Math.min(d+c.nodeSize,r),g=n.addToSet(h);for(let v=0;vt.step(c)),o.forEach(c=>t.step(c))}function n9(t,e,r,n){let s=[],o=0;t.doc.nodesBetween(e,r,(i,a)=>{if(!i.isInline)return;o++;let c=null;if(n instanceof Xp){let d=i.marks,u;for(;u=n.isInSet(d);)(c||(c=[])).push(u),d=u.removeFromSet(d)}else n?n.isInSet(i.marks)&&(c=[n]):c=i.marks;if(c&&c.length){let d=Math.min(a+i.nodeSize,r);for(let u=0;ut.step(new Ss(i.from,i.to,i.style)))}function Fw(t,e,r,n=r.contentMatch,s=!0){let o=t.doc.nodeAt(e),i=[],a=e+1;for(let c=0;c=0;c--)t.step(i[c])}function s9(t,e,r){return(e==0||t.canReplace(e,t.childCount))&&(r==t.childCount||t.canReplace(0,r))}function sc(t){let r=t.parent.content.cutByIndex(t.startIndex,t.endIndex);for(let n=t.depth,s=0,o=0;;--n){let i=t.$from.node(n),a=t.$from.index(n)+s,c=t.$to.indexAfter(n)-o;if(nr;g--)v||n.index(g)>0?(v=!0,u=Y.from(n.node(g).copy(u)),h++):c--;let f=Y.empty,p=0;for(let g=o,v=!1;g>r;g--)v||s.after(g+1)=0;i--){if(n.size){let a=r[i].type.contentMatch.matchFragment(n);if(!a||!a.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}n=Y.from(r[i].type.create(r[i].attrs,n))}let s=e.start,o=e.end;t.step(new Vt(s,o,s,o,new oe(n,0,0),r.length,!0))}function c9(t,e,r,n,s){if(!n.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let o=t.steps.length;t.doc.nodesBetween(e,r,(i,a)=>{let c=typeof s=="function"?s(i):s;if(i.isTextblock&&!i.hasMarkup(n,c)&&d9(t.doc,t.mapping.slice(o).map(a),n)){let d=null;if(n.schema.linebreakReplacement){let p=n.whitespace=="pre",g=!!n.contentMatch.matchType(n.schema.linebreakReplacement);p&&!g?d=!1:!p&&g&&(d=!0)}d===!1&&hT(t,i,a,o),Fw(t,t.mapping.slice(o).map(a,1),n,void 0,d===null);let u=t.mapping.slice(o),h=u.map(a,1),f=u.map(a+i.nodeSize,1);return t.step(new Vt(h,f,h+1,f-1,new oe(Y.from(n.create(c,null,i.marks)),0,0),1,!0)),d===!0&&uT(t,i,a,o),!1}})}function uT(t,e,r,n){e.forEach((s,o)=>{if(s.isText){let i,a=/\r?\n|\r/g;for(;i=a.exec(s.text);){let c=t.mapping.slice(n).map(r+1+o+i.index);t.replaceWith(c,c+1,e.type.schema.linebreakReplacement.create())}}})}function hT(t,e,r,n){e.forEach((s,o)=>{if(s.type==s.type.schema.linebreakReplacement){let i=t.mapping.slice(n).map(r+1+o);t.replaceWith(i,i+1,e.type.schema.text(` `))}})}function d9(t,e,r){let n=t.resolve(e),s=n.index();return n.parent.canReplaceWith(s,s+1,r)}function u9(t,e,r,n,s){let o=t.doc.nodeAt(e);if(!o)throw new RangeError("No node at given position");r||(r=o.type);let i=r.create(n,null,s||o.marks);if(o.isLeaf)return t.replaceWith(e,e+o.nodeSize,i);if(!r.validContent(o.content))throw new RangeError("Invalid content for node type "+r.name);t.step(new Vt(e,e+o.nodeSize,e+1,e+o.nodeSize-1,new oe(Y.from(i),0,0),1,!0))}function oc(t,e,r=1,n){let s=t.resolve(e),o=s.depth-r,i=n&&n[n.length-1]||s.parent;if(o<0||s.parent.type.spec.isolating||!s.parent.canReplace(s.index(),s.parent.childCount)||!i.type.validContent(s.parent.content.cutByIndex(s.index(),s.parent.childCount)))return!1;for(let d=s.depth-1,u=r-2;d>o;d--,u--){let h=s.node(d),f=s.index(d);if(h.type.spec.isolating)return!1;let p=h.content.cutByIndex(f,h.childCount),g=n&&n[u+1];g&&(p=p.replaceChild(0,g.type.create(g.attrs)));let v=n&&n[u]||h;if(!h.canReplace(f+1,h.childCount)||!v.type.validContent(p))return!1}let a=s.indexAfter(o),c=n&&n[0];return s.node(o).canReplaceWith(a,a,c?c.type:s.node(o+1).type)}function h9(t,e,r=1,n){let s=t.doc.resolve(e),o=Y.empty,i=Y.empty;for(let a=s.depth,c=s.depth-r,d=r-1;a>c;a--,d--){o=Y.from(s.node(a).copy(o));let u=n&&n[d];i=Y.from(u?u.type.create(u.attrs,i):s.node(a).copy(i))}t.step(new Ut(e,e,new oe(o.append(i),r,r),!0))}function ri(t,e){let r=t.resolve(e),n=r.index();return fT(r.nodeBefore,r.nodeAfter)&&r.parent.canReplace(n,n+1)}function f9(t,e){e.content.size||t.type.compatibleContent(e.type);let r=t.contentMatchAt(t.childCount),{linebreakReplacement:n}=t.type.schema;for(let s=0;s0?(o=n.node(s+1),a++,i=n.node(s).maybeChild(a)):(o=n.node(s).maybeChild(a-1),i=n.node(s+1)),o&&!o.isTextblock&&fT(o,i)&&n.node(s).canReplace(a,a+1))return e;if(s==0)break;e=r<0?n.before(s):n.after(s)}}function p9(t,e,r){let n=null,{linebreakReplacement:s}=t.doc.type.schema,o=t.doc.resolve(e-r),i=o.node().type;if(s&&i.inlineContent){let u=i.whitespace=="pre",h=!!i.contentMatch.matchType(s);u&&!h?n=!1:!u&&h&&(n=!0)}let a=t.steps.length;if(n===!1){let u=t.doc.resolve(e+r);hT(t,u.node(),u.before(),a)}i.inlineContent&&Fw(t,e+r-1,i,o.node().contentMatchAt(o.index()),n==null);let c=t.mapping.slice(a),d=c.map(e-r);if(t.step(new Ut(d,c.map(e+r,-1),oe.empty,!0)),n===!0){let u=t.doc.resolve(d);uT(t,u.node(),u.before(),t.steps.length)}return t}function m9(t,e,r){let n=t.resolve(e);if(n.parent.canReplaceWith(n.index(),n.index(),r))return e;if(n.parentOffset==0)for(let s=n.depth-1;s>=0;s--){let o=n.index(s);if(n.node(s).canReplaceWith(o,o,r))return n.before(s+1);if(o>0)return null}if(n.parentOffset==n.parent.content.size)for(let s=n.depth-1;s>=0;s--){let o=n.indexAfter(s);if(n.node(s).canReplaceWith(o,o,r))return n.after(s+1);if(o=0;i--){let a=i==n.depth?0:n.pos<=(n.start(i+1)+n.end(i+1))/2?-1:1,c=n.index(i)+(a>0?1:0),d=n.node(i),u=!1;if(o==1)u=d.canReplace(c,c,s);else{let h=d.contentMatchAt(c).findWrapping(s.firstChild.type);u=h&&d.canReplaceWith(c,c,h[0])}if(u)return a==0?n.pos:a<0?n.before(i+1):n.after(i+1)}return null}function nm(t,e,r=e,n=oe.empty){if(e==r&&!n.size)return null;let s=t.resolve(e),o=t.resolve(r);return mT(s,o,n)?new Ut(e,r,n):new g9(s,o,n).fit()}function mT(t,e,r){return!r.openStart&&!r.openEnd&&t.start()==e.start()&&t.parent.canReplace(t.index(),e.index(),r.content)}class g9{constructor(e,r,n){this.$from=e,this.$to=r,this.unplaced=n,this.frontier=[],this.placed=Y.empty;for(let s=0;s<=e.depth;s++){let o=e.node(s);this.frontier.push({type:o.type,match:o.contentMatchAt(e.indexAfter(s))})}for(let s=e.depth;s>0;s--)this.placed=Y.from(e.node(s).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let d=this.findFittable();d?this.placeNodes(d):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),r=this.placed.size-this.depth-this.$from.depth,n=this.$from,s=this.close(e<0?this.$to:n.doc.resolve(e));if(!s)return null;let o=this.placed,i=n.depth,a=s.depth;for(;i&&a&&o.childCount==1;)o=o.firstChild.content,i--,a--;let c=new oe(o,i,a);return e>-1?new Vt(n.pos,e,this.$to.pos,this.$to.end(),c,r):c.size||n.pos!=this.$to.pos?new Ut(n.pos,s.pos,c):null}findFittable(){let e=this.unplaced.openStart;for(let r=this.unplaced.content,n=0,s=this.unplaced.openEnd;n1&&(s=0),o.type.spec.isolating&&s<=n){e=n;break}r=o.content}for(let r=1;r<=2;r++)for(let n=r==1?e:this.unplaced.openStart;n>=0;n--){let s,o=null;n?(o=Bw(this.unplaced.content,n-1).firstChild,s=o.content):s=this.unplaced.content;let i=s.firstChild;for(let a=this.depth;a>=0;a--){let{type:c,match:d}=this.frontier[a],u,h=null;if(r==1&&(i?d.matchType(i.type)||(h=d.fillBefore(Y.from(i),!1)):o&&c.compatibleContent(o.type)))return{sliceDepth:n,frontierDepth:a,parent:o,inject:h};if(r==2&&i&&(u=d.findWrapping(i.type)))return{sliceDepth:n,frontierDepth:a,parent:o,wrap:u};if(o&&d.matchType(o.type))break}}}openMore(){let{content:e,openStart:r,openEnd:n}=this.unplaced,s=Bw(e,r);return!s.childCount||s.firstChild.isLeaf?!1:(this.unplaced=new oe(e,r+1,Math.max(n,s.size+r>=e.size-n?r+1:0)),!0)}dropNode(){let{content:e,openStart:r,openEnd:n}=this.unplaced,s=Bw(e,r);if(s.childCount<=1&&r>0){let o=e.size-r<=r+s.size;this.unplaced=new oe(Tu(e,r-1,1),r-1,o?r-1:n)}else this.unplaced=new oe(Tu(e,r,1),r,n)}placeNodes({sliceDepth:e,frontierDepth:r,parent:n,inject:s,wrap:o}){for(;this.depth>r;)this.closeFrontierNode();if(o)for(let v=0;v1||c==0||v.content.size)&&(h=y,u.push(gT(v.mark(f.allowedMarks(v.marks)),d==1?c:0,d==a.childCount?p:-1)))}let g=d==a.childCount;g||(p=-1),this.placed=Ru(this.placed,r,Y.from(u)),this.frontier[r].match=h,g&&p<0&&n&&n.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let v=0,y=a;v1&&s==this.$to.end(--n);)++s;return s}findCloseLevel(e){e:for(let r=Math.min(this.depth,e.depth);r>=0;r--){let{match:n,type:s}=this.frontier[r],o=r=0;a--){let{match:c,type:d}=this.frontier[a],u=Uw(e,a,d,c,!0);if(!u||u.childCount)continue e}return{depth:r,fit:i,move:o?e.doc.resolve(e.after(r+1)):e}}}}close(e){let r=this.findCloseLevel(e);if(!r)return null;for(;this.depth>r.depth;)this.closeFrontierNode();r.fit.childCount&&(this.placed=Ru(this.placed,r.depth,r.fit)),e=r.move;for(let n=r.depth+1;n<=e.depth;n++){let s=e.node(n),o=s.type.contentMatch.fillBefore(s.content,!0,e.index(n));this.openFrontierNode(s.type,s.attrs,o)}return e}openFrontierNode(e,r=null,n){let s=this.frontier[this.depth];s.match=s.match.matchType(e),this.placed=Ru(this.placed,this.depth,Y.from(e.create(r,n))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let r=this.frontier.pop().match.fillBefore(Y.empty,!0);r.childCount&&(this.placed=Ru(this.placed,this.frontier.length,r))}}function Tu(t,e,r){return e==0?t.cutByIndex(r,t.childCount):t.replaceChild(0,t.firstChild.copy(Tu(t.firstChild.content,e-1,r)))}function Ru(t,e,r){return e==0?t.append(r):t.replaceChild(t.childCount-1,t.lastChild.copy(Ru(t.lastChild.content,e-1,r)))}function Bw(t,e){for(let r=0;r1&&(n=n.replaceChild(0,gT(n.firstChild,e-1,n.childCount==1?r-1:0))),e>0&&(n=t.type.contentMatch.fillBefore(n).append(n),r<=0&&(n=n.append(t.type.contentMatch.matchFragment(n).fillBefore(Y.empty,!0)))),t.copy(n)}function Uw(t,e,r,n,s){let o=t.node(e),i=s?t.indexAfter(e):t.index(e);if(i==o.childCount&&!r.compatibleContent(o.type))return null;let a=n.fillBefore(o.content,!0,i);return a&&!v9(r,o.content,i)?a:null}function v9(t,e,r){for(let n=r;n0;f--,p--){let g=s.node(f).type.spec;if(g.defining||g.definingAsContext||g.isolating)break;i.indexOf(f)>-1?a=f:s.before(f)==p&&i.splice(1,0,-f)}let c=i.indexOf(a),d=[],u=n.openStart;for(let f=n.content,p=0;;p++){let g=f.firstChild;if(d.push(g),p==n.openStart)break;f=g.content}for(let f=u-1;f>=0;f--){let p=d[f],g=y9(p.type);if(g&&!p.sameMarkup(s.node(Math.abs(a)-1)))u=f;else if(g||!p.type.isTextblock)break}for(let f=n.openStart;f>=0;f--){let p=(f+u+1)%(n.openStart+1),g=d[p];if(g)for(let v=0;v=0&&(t.replace(e,r,n),!(t.steps.length>h));f--){let p=i[f];p<0||(e=s.before(p),r=o.after(p))}}function vT(t,e,r,n,s){if(en){let o=s.contentMatchAt(0),i=o.fillBefore(t).append(t);t=i.append(o.matchFragment(i).fillBefore(Y.empty,!0))}return t}function w9(t,e,r,n){if(!n.isInline&&e==r&&t.doc.resolve(e).parent.content.size){let s=m9(t.doc,e,n.type);s!=null&&(e=r=s)}t.replaceRange(e,r,new oe(Y.from(n),0,0))}function b9(t,e,r){let n=t.doc.resolve(e),s=t.doc.resolve(r),o=yT(n,s);for(let i=0;i0&&(c||n.node(a-1).canReplace(n.index(a-1),s.indexAfter(a-1))))return t.delete(n.before(a),s.after(a))}for(let i=1;i<=n.depth&&i<=s.depth;i++)if(e-n.start(i)==n.depth-i&&r>n.end(i)&&s.end(i)-r!=s.depth-i&&n.start(i-1)==s.start(i-1)&&n.node(i-1).canReplace(n.index(i-1),s.index(i-1)))return t.delete(n.before(i),r);t.delete(e,r)}function yT(t,e){let r=[],n=Math.min(t.depth,e.depth);for(let s=n;s>=0;s--){let o=t.start(s);if(oe.pos+(e.depth-s)||t.node(s).type.spec.isolating||e.node(s).type.spec.isolating)break;(o==e.start(s)||s==t.depth&&s==e.depth&&t.parent.inlineContent&&e.parent.inlineContent&&s&&e.start(s-1)==o-1)&&r.push(s)}return r}class ic extends fr{constructor(e,r,n){super(),this.pos=e,this.attr=r,this.value=n}apply(e){let r=e.nodeAt(this.pos);if(!r)return kt.fail("No node at attribute step's position");let n=Object.create(null);for(let o in r.attrs)n[o]=r.attrs[o];n[this.attr]=this.value;let s=r.type.create(n,null,r.marks);return kt.fromReplace(e,this.pos,this.pos+1,new oe(Y.from(s),0,r.isLeaf?0:1))}getMap(){return ln.empty}invert(e){return new ic(this.pos,this.attr,e.nodeAt(this.pos).attrs[this.attr])}map(e){let r=e.mapResult(this.pos,1);return r.deletedAfter?null:new ic(r.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(e,r){if(typeof r.pos!="number"||typeof r.attr!="string")throw new RangeError("Invalid input for AttrStep.fromJSON");return new ic(r.pos,r.attr,r.value)}}fr.jsonID("attr",ic);class Mu extends fr{constructor(e,r){super(),this.attr=e,this.value=r}apply(e){let r=Object.create(null);for(let s in e.attrs)r[s]=e.attrs[s];r[this.attr]=this.value;let n=e.type.create(r,e.content,e.marks);return kt.ok(n)}getMap(){return ln.empty}invert(e){return new Mu(this.attr,e.attrs[this.attr])}map(e){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(e,r){if(typeof r.attr!="string")throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new Mu(r.attr,r.value)}}fr.jsonID("docAttr",Mu);let ac=class extends Error{};ac=function t(e){let r=Error.call(this,e);return r.__proto__=t.prototype,r},ac.prototype=Object.create(Error.prototype),ac.prototype.constructor=ac,ac.prototype.name="TransformError";class k9{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new _u}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let r=this.maybeStep(e);if(r.failed)throw new ac(r.failed);return this}maybeStep(e){let r=e.apply(this.doc);return r.failed||this.addStep(e,r.doc),r}get docChanged(){return this.steps.length>0}changedRange(){let e=1e9,r=-1e9;for(let n=0;n{e=Math.min(e,a),r=Math.max(r,c)})}return e==1e9?null:{from:e,to:r}}addStep(e,r){this.docs.push(this.doc),this.steps.push(e),this.mapping.appendMap(e.getMap()),this.doc=r}replace(e,r=e,n=oe.empty){let s=nm(this.doc,e,r,n);return s&&this.step(s),this}replaceWith(e,r,n){return this.replace(e,r,new oe(Y.from(n),0,0))}delete(e,r){return this.replace(e,r,oe.empty)}insert(e,r){return this.replaceWith(e,e,r)}replaceRange(e,r,n){return x9(this,e,r,n),this}replaceRangeWith(e,r,n){return w9(this,e,r,n),this}deleteRange(e,r){return b9(this,e,r),this}lift(e,r){return o9(this,e,r),this}join(e,r=1){return p9(this,e,r),this}wrap(e,r){return l9(this,e,r),this}setBlockType(e,r=e,n,s=null){return c9(this,e,r,n,s),this}setNodeMarkup(e,r,n=null,s){return u9(this,e,r,n,s),this}setNodeAttribute(e,r,n){return this.step(new ic(e,r,n)),this}setDocAttribute(e,r){return this.step(new Mu(e,r)),this}addNodeMark(e,r){return this.step(new ti(e,r)),this}removeNodeMark(e,r){let n=this.doc.nodeAt(e);if(!n)throw new RangeError("No node at position "+e);if(r instanceof Ve)r.isInSet(n.marks)&&this.step(new va(e,r));else{let s=n.marks,o,i=[];for(;o=r.isInSet(s);)i.push(new va(e,o)),s=o.removeFromSet(s);for(let a=i.length-1;a>=0;a--)this.step(i[a])}return this}split(e,r=1,n){return h9(this,e,r,n),this}addMark(e,r,n){return r9(this,e,r,n),this}removeMark(e,r,n){return n9(this,e,r,n),this}clearIncompatible(e,r,n){return Fw(this,e,r,n),this}}const Vw=Object.create(null);class _e{constructor(e,r,n){this.$anchor=e,this.$head=r,this.ranges=n||[new S9(e.min(r),e.max(r))]}get anchor(){return this.$anchor.pos}get head(){return this.$head.pos}get from(){return this.$from.pos}get to(){return this.$to.pos}get $from(){return this.ranges[0].$from}get $to(){return this.ranges[0].$to}get empty(){let e=this.ranges;for(let r=0;r=0;o--){let i=r<0?lc(e.node(0),e.node(o),e.before(o+1),e.index(o),r,n):lc(e.node(0),e.node(o),e.after(o+1),e.index(o)+1,r,n);if(i)return i}return null}static near(e,r=1){return this.findFrom(e,r)||this.findFrom(e,-r)||new jn(e.node(0))}static atStart(e){return lc(e,e,0,0,1)||new jn(e)}static atEnd(e){return lc(e,e,e.content.size,e.childCount,-1)||new jn(e)}static fromJSON(e,r){if(!r||!r.type)throw new RangeError("Invalid input for Selection.fromJSON");let n=Vw[r.type];if(!n)throw new RangeError(`No selection type ${r.type} defined`);return n.fromJSON(e,r)}static jsonID(e,r){if(e in Vw)throw new RangeError("Duplicate use of selection JSON ID "+e);return Vw[e]=r,r.prototype.jsonID=e,r}getBookmark(){return Ce.between(this.$anchor,this.$head).getBookmark()}}_e.prototype.visible=!0;class S9{constructor(e,r){this.$from=e,this.$to=r}}let xT=!1;function wT(t){!xT&&!t.parent.inlineContent&&(xT=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+t.parent.type.name+")"))}class Ce extends _e{constructor(e,r=e){wT(e),wT(r),super(e,r)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,r){let n=e.resolve(r.map(this.head));if(!n.parent.inlineContent)return _e.near(n);let s=e.resolve(r.map(this.anchor));return new Ce(s.parent.inlineContent?s:n,n)}replace(e,r=oe.empty){if(super.replace(e,r),r==oe.empty){let n=this.$from.marksAcross(this.$to);n&&e.ensureMarks(n)}}eq(e){return e instanceof Ce&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new sm(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(e,r){if(typeof r.anchor!="number"||typeof r.head!="number")throw new RangeError("Invalid input for TextSelection.fromJSON");return new Ce(e.resolve(r.anchor),e.resolve(r.head))}static create(e,r,n=r){let s=e.resolve(r);return new this(s,n==r?s:e.resolve(n))}static between(e,r,n){let s=e.pos-r.pos;if((!n||s)&&(n=s>=0?1:-1),!r.parent.inlineContent){let o=_e.findFrom(r,n,!0)||_e.findFrom(r,-n,!0);if(o)r=o.$head;else return _e.near(r,n)}return e.parent.inlineContent||(s==0?e=r:(e=(_e.findFrom(e,-n,!0)||_e.findFrom(e,n,!0)).$anchor,e.pos0?0:1);s>0?i=0;i+=s){let a=e.child(i);if(a.isAtom){if(!o&&me.isSelectable(a))return me.create(t,r-(s<0?a.nodeSize:0))}else{let c=lc(t,a,r+s,s<0?a.childCount:0,s,o);if(c)return c}r+=a.nodeSize*s}return null}function bT(t,e,r){let n=t.steps.length-1;if(n{i==null&&(i=u)}),t.setSelection(_e.near(t.doc.resolve(i),r))}const kT=1,om=2,ST=4;class C9 extends k9{constructor(e){super(e.doc),this.curSelectionFor=0,this.updated=0,this.meta=Object.create(null),this.time=Date.now(),this.curSelection=e.selection,this.storedMarks=e.storedMarks}get selection(){return this.curSelectionFor0}setStoredMarks(e){return this.storedMarks=e,this.updated|=om,this}ensureMarks(e){return Ve.sameSet(this.storedMarks||this.selection.$from.marks(),e)||this.setStoredMarks(e),this}addStoredMark(e){return this.ensureMarks(e.addToSet(this.storedMarks||this.selection.$head.marks()))}removeStoredMark(e){return this.ensureMarks(e.removeFromSet(this.storedMarks||this.selection.$head.marks()))}get storedMarksSet(){return(this.updated&om)>0}addStep(e,r){super.addStep(e,r),this.updated=this.updated&~om,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,r=!0){let n=this.selection;return r&&(e=e.mark(this.storedMarks||(n.empty?n.$from.marks():n.$from.marksAcross(n.$to)||Ve.none))),n.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,r,n){let s=this.doc.type.schema;if(r==null)return e?this.replaceSelectionWith(s.text(e),!0):this.deleteSelection();{if(n==null&&(n=r),!e)return this.deleteRange(r,n);let o=this.storedMarks;if(!o){let i=this.doc.resolve(r);o=n==r?i.marks():i.marksAcross(this.doc.resolve(n))}return this.replaceRangeWith(r,n,s.text(e,o)),!this.selection.empty&&this.selection.to==r+e.length&&this.setSelection(_e.near(this.selection.$to)),this}}setMeta(e,r){return this.meta[typeof e=="string"?e:e.key]=r,this}getMeta(e){return this.meta[typeof e=="string"?e:e.key]}get isGeneric(){for(let e in this.meta)return!1;return!0}scrollIntoView(){return this.updated|=ST,this}get scrolledIntoView(){return(this.updated&ST)>0}}function NT(t,e){return!e||!t?t:t.bind(e)}class Ou{constructor(e,r,n){this.name=e,this.init=NT(r.init,n),this.apply=NT(r.apply,n)}}const j9=[new Ou("doc",{init(t){return t.doc||t.schema.topNodeType.createAndFill()},apply(t){return t.doc}}),new Ou("selection",{init(t,e){return t.selection||_e.atStart(e.doc)},apply(t){return t.selection}}),new Ou("storedMarks",{init(t){return t.storedMarks||null},apply(t,e,r,n){return n.selection.$cursor?t.storedMarks:null}}),new Ou("scrollToSelection",{init(){return 0},apply(t,e){return t.scrolledIntoView?e+1:e}})];class Hw{constructor(e,r){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=j9.slice(),r&&r.forEach(n=>{if(this.pluginsByKey[n.key])throw new RangeError("Adding different instances of a keyed plugin ("+n.key+")");this.plugins.push(n),this.pluginsByKey[n.key]=n,n.spec.state&&this.fields.push(new Ou(n.key,n.spec.state,n))})}}class cc{constructor(e){this.config=e}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(e){return this.applyTransaction(e).state}filterTransaction(e,r=-1){for(let n=0;nn.toJSON())),e&&typeof e=="object")for(let n in e){if(n=="doc"||n=="selection")throw new RangeError("The JSON fields `doc` and `selection` are reserved");let s=e[n],o=s.spec.state;o&&o.toJSON&&(r[n]=o.toJSON.call(s,this[s.key]))}return r}static fromJSON(e,r,n){if(!r)throw new RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw new RangeError("Required config field 'schema' missing");let s=new Hw(e.schema,e.plugins),o=new cc(s);return s.fields.forEach(i=>{if(i.name=="doc")o.doc=Xo.fromJSON(e.schema,r.doc);else if(i.name=="selection")o.selection=_e.fromJSON(o.doc,r.selection);else if(i.name=="storedMarks")r.storedMarks&&(o.storedMarks=r.storedMarks.map(e.schema.markFromJSON));else{if(n)for(let a in n){let c=n[a],d=c.spec.state;if(c.key==i.name&&d&&d.fromJSON&&Object.prototype.hasOwnProperty.call(r,a)){o[i.name]=d.fromJSON.call(c,e,r[a],o);return}}o[i.name]=i.init(e,o)}}),o}}function CT(t,e,r){for(let n in t){let s=t[n];s instanceof Function?s=s.bind(e):n=="handleDOMEvents"&&(s=CT(s,e,{})),r[n]=s}return r}class jr{constructor(e){this.spec=e,this.props={},e.props&&CT(e.props,this,this.props),this.key=e.key?e.key.key:jT("plugin")}getState(e){return e[this.key]}}const qw=Object.create(null);function jT(t){return t in qw?t+"$"+ ++qw[t]:(qw[t]=0,t+"$")}class Zn{constructor(e="key"){this.key=jT(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const or=function(t){for(var e=0;;e++)if(t=t.previousSibling,!t)return e},dc=function(t){let e=t.assignedSlot||t.parentNode;return e&&e.nodeType==11?e.host:e};let Kw=null;const so=function(t,e,r){let n=Kw||(Kw=document.createRange());return n.setEnd(t,r??t.nodeValue.length),n.setStart(t,e||0),n},E9=function(){Kw=null},ya=function(t,e,r,n){return r&&(ET(t,e,r,n,-1)||ET(t,e,r,n,1))},_9=/^(img|br|input|textarea|hr)$/i;function ET(t,e,r,n,s){for(var o;;){if(t==r&&e==n)return!0;if(e==(s<0?0:En(t))){let i=t.parentNode;if(!i||i.nodeType!=1||Pu(t)||_9.test(t.nodeName)||t.contentEditable=="false")return!1;e=or(t)+(s<0?0:1),t=i}else if(t.nodeType==1){let i=t.childNodes[e+(s<0?-1:0)];if(i.nodeType==1&&i.contentEditable=="false")if(!((o=i.pmViewDesc)===null||o===void 0)&&o.ignoreForSelection)e+=s;else return!1;else t=i,e=s<0?En(t):0}else return!1}}function En(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function T9(t,e){for(;;){if(t.nodeType==3&&e)return t;if(t.nodeType==1&&e>0){if(t.contentEditable=="false")return null;t=t.childNodes[e-1],e=En(t)}else if(t.parentNode&&!Pu(t))e=or(t),t=t.parentNode;else return null}}function R9(t,e){for(;;){if(t.nodeType==3&&e2),Tn=uc||(Ns?/Mac/.test(Ns.platform):!1),MT=Ns?/Win/.test(Ns.platform):!1,oo=/Android \d/.test(ni),Au=!!_T&&"webkitFontSmoothing"in _T.documentElement.style,A9=Au?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function I9(t){let e=t.defaultView&&t.defaultView.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:t.documentElement.clientWidth,top:0,bottom:t.documentElement.clientHeight}}function io(t,e){return typeof t=="number"?t:t[e]}function D9(t){let e=t.getBoundingClientRect(),r=e.width/t.offsetWidth||1,n=e.height/t.offsetHeight||1;return{left:e.left,right:e.left+t.clientWidth*r,top:e.top,bottom:e.top+t.clientHeight*n}}function OT(t,e,r){let n=t.someProp("scrollThreshold")||0,s=t.someProp("scrollMargin")||5,o=t.dom.ownerDocument;for(let i=r||t.dom;i;){if(i.nodeType!=1){i=dc(i);continue}let a=i,c=a==o.body,d=c?I9(o):D9(a),u=0,h=0;if(e.topd.bottom-io(n,"bottom")&&(h=e.bottom-e.top>d.bottom-d.top?e.top+io(s,"top")-d.top:e.bottom-d.bottom+io(s,"bottom")),e.leftd.right-io(n,"right")&&(u=e.right-d.right+io(s,"right")),u||h)if(c)o.defaultView.scrollBy(u,h);else{let p=a.scrollLeft,g=a.scrollTop;h&&(a.scrollTop+=h),u&&(a.scrollLeft+=u);let v=a.scrollLeft-p,y=a.scrollTop-g;e={left:e.left-v,top:e.top-y,right:e.right-v,bottom:e.bottom-y}}let f=c?"fixed":getComputedStyle(i).position;if(/^(fixed|sticky)$/.test(f))break;i=f=="absolute"?i.offsetParent:dc(i)}}function L9(t){let e=t.dom.getBoundingClientRect(),r=Math.max(0,e.top),n,s;for(let o=(e.left+e.right)/2,i=r+1;i=r-20){n=a,s=c.top;break}}return{refDOM:n,refTop:s,stack:PT(t.dom)}}function PT(t){let e=[],r=t.ownerDocument;for(let n=t;n&&(e.push({dom:n,top:n.scrollTop,left:n.scrollLeft}),t!=r);n=dc(n));return e}function $9({refDOM:t,refTop:e,stack:r}){let n=t?t.getBoundingClientRect().top:0;AT(r,n==0?0:n-e)}function AT(t,e){for(let r=0;r=a){i=Math.max(g.bottom,i),a=Math.min(g.top,a);let v=g.left>e.left?g.left-e.left:g.right=(g.left+g.right)/2?1:0));continue}}else g.top>e.top&&!c&&g.left<=e.left&&g.right>=e.left&&(c=u,d={left:Math.max(g.left,Math.min(g.right,e.left)),top:g.top});!r&&(e.left>=g.right&&e.top>=g.top||e.left>=g.left&&e.top>=g.bottom)&&(o=h+1)}}return!r&&c&&(r=c,s=d,n=0),r&&r.nodeType==3?z9(r,s):!r||n&&r.nodeType==1?{node:t,offset:o}:IT(r,s)}function z9(t,e){let r=t.nodeValue.length,n=document.createRange(),s;for(let o=0;o=(i.left+i.right)/2?1:0)};break}}return n.detach(),s||{node:t,offset:0}}function Qw(t,e){return t.left>=e.left-1&&t.left<=e.right+1&&t.top>=e.top-1&&t.top<=e.bottom+1}function B9(t,e){let r=t.parentNode;return r&&/^li$/i.test(r.nodeName)&&e.left(i.left+i.right)/2?1:-1}return t.docView.posFromDOM(n,s,o)}function V9(t,e,r,n){let s=-1;for(let o=e,i=!1;o!=t.dom;){let a=t.docView.nearestDesc(o,!0),c;if(!a)return null;if(a.dom.nodeType==1&&(a.node.isBlock&&a.parent||!a.contentDOM)&&((c=a.dom.getBoundingClientRect()).width||c.height)&&(a.node.isBlock&&a.parent&&!/^T(R|BODY|HEAD|FOOT)$/.test(a.dom.nodeName)&&(!i&&c.left>n.left||c.top>n.top?s=a.posBefore:(!i&&c.right-1?s:t.docView.posFromDOM(e,r,-1)}function DT(t,e,r){let n=t.childNodes.length;if(n&&r.tope.top&&s++}let d;Au&&s&&n.nodeType==1&&(d=n.childNodes[s-1]).nodeType==1&&d.contentEditable=="false"&&d.getBoundingClientRect().top>=e.top&&s--,n==t.dom&&s==n.childNodes.length-1&&n.lastChild.nodeType==1&&e.top>n.lastChild.getBoundingClientRect().bottom?a=t.state.doc.content.size:(s==0||n.nodeType!=1||n.childNodes[s-1].nodeName!="BR")&&(a=V9(t,n,s,e))}a==null&&(a=U9(t,i,e));let c=t.docView.nearestDesc(i,!0);return{pos:a,inside:c?c.posAtStart-c.border:-1}}function LT(t){return t.top=0&&s==n.nodeValue.length?(c--,u=1):r<0?c--:d++,Iu(oi(so(n,c,d),u),u<0)}if(!t.state.doc.resolve(e-(o||0)).parent.inlineContent){if(o==null&&s&&(r<0||s==En(n))){let c=n.childNodes[s-1];if(c.nodeType==1)return Xw(c.getBoundingClientRect(),!1)}if(o==null&&s=0)}if(o==null&&s&&(r<0||s==En(n))){let c=n.childNodes[s-1],d=c.nodeType==3?so(c,En(c)-(i?0:1)):c.nodeType==1&&(c.nodeName!="BR"||!c.nextSibling)?c:null;if(d)return Iu(oi(d,1),!1)}if(o==null&&s=0)}function Iu(t,e){if(t.width==0)return t;let r=e?t.left:t.right;return{top:t.top,bottom:t.bottom,left:r,right:r}}function Xw(t,e){if(t.height==0)return t;let r=e?t.top:t.bottom;return{top:r,bottom:r,left:t.left,right:t.right}}function FT(t,e,r){let n=t.state,s=t.root.activeElement;n!=e&&t.updateState(e),s!=t.dom&&t.focus();try{return r()}finally{n!=e&&t.updateState(n),s!=t.dom&&s&&s.focus()}}function q9(t,e,r){let n=e.selection,s=r=="up"?n.$from:n.$to;return FT(t,e,()=>{let{node:o}=t.docView.domFromPos(s.pos,r=="up"?-1:1);for(;;){let a=t.docView.nearestDesc(o,!0);if(!a)break;if(a.node.isBlock){o=a.contentDOM||a.dom;break}o=a.dom.parentNode}let i=$T(t,s.pos,1);for(let a=o.firstChild;a;a=a.nextSibling){let c;if(a.nodeType==1)c=a.getClientRects();else if(a.nodeType==3)c=so(a,0,a.nodeValue.length).getClientRects();else continue;for(let d=0;du.top+1&&(r=="up"?i.top-u.top>(u.bottom-i.top)*2:u.bottom-i.bottom>(i.bottom-u.top)*2))return!1}}return!0})}const K9=/[\u0590-\u08ac]/;function G9(t,e,r){let{$head:n}=e.selection;if(!n.parent.isTextblock)return!1;let s=n.parentOffset,o=!s,i=s==n.parent.content.size,a=t.domSelection();return a?!K9.test(n.parent.textContent)||!a.modify?r=="left"||r=="backward"?o:i:FT(t,e,()=>{let{focusNode:c,focusOffset:d,anchorNode:u,anchorOffset:h}=t.domSelectionRange(),f=a.caretBidiLevel;a.modify("move",r,"character");let p=n.depth?t.docView.domAfterPos(n.before()):t.dom,{focusNode:g,focusOffset:v}=t.domSelectionRange(),y=g&&!p.contains(g.nodeType==1?g:g.parentNode)||c==g&&d==v;try{a.collapse(u,h),c&&(c!=u||d!=h)&&a.extend&&a.extend(c,d)}catch{}return f!=null&&(a.caretBidiLevel=f),y}):n.pos==n.start()||n.pos==n.end()}let zT=null,BT=null,UT=!1;function Y9(t,e,r){return zT==e&&BT==r?UT:(zT=e,BT=r,UT=r=="up"||r=="down"?q9(t,e,r):G9(t,e,r))}const Rn=0,VT=1,wa=2,Cs=3;class Du{constructor(e,r,n,s){this.parent=e,this.children=r,this.dom=n,this.contentDOM=s,this.dirty=Rn,n.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,r,n){return!1}matchesHack(e){return!1}parseRule(){return null}stopEvent(e){return!1}get size(){let e=0;for(let r=0;ror(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))s=e.compareDocumentPosition(this.contentDOM)&2;else if(this.dom.firstChild){if(r==0)for(let o=e;;o=o.parentNode){if(o==this.dom){s=!1;break}if(o.previousSibling)break}if(s==null&&r==e.childNodes.length)for(let o=e;;o=o.parentNode){if(o==this.dom){s=!0;break}if(o.nextSibling)break}}return s??n>0?this.posAtEnd:this.posAtStart}nearestDesc(e,r=!1){for(let n=!0,s=e;s;s=s.parentNode){let o=this.getDesc(s),i;if(o&&(!r||o.node))if(n&&(i=o.nodeDOM)&&!(i.nodeType==1?i.contains(e.nodeType==1?e:e.parentNode):i==e))n=!1;else return o}}getDesc(e){let r=e.pmViewDesc;for(let n=r;n;n=n.parent)if(n==this)return r}posFromDOM(e,r,n){for(let s=e;s;s=s.parentNode){let o=this.getDesc(s);if(o)return o.localPosFromDOM(e,r,n)}return-1}descAt(e){for(let r=0,n=0;re||i instanceof qT){s=e-o;break}o=a}if(s)return this.children[n].domFromPos(s-this.children[n].border,r);for(let o;n&&!(o=this.children[n-1]).size&&o instanceof WT&&o.side>=0;n--);if(r<=0){let o,i=!0;for(;o=n?this.children[n-1]:null,!(!o||o.dom.parentNode==this.contentDOM);n--,i=!1);return o&&r&&i&&!o.border&&!o.domAtom?o.domFromPos(o.size,r):{node:this.contentDOM,offset:o?or(o.dom)+1:0}}else{let o,i=!0;for(;o=n=u&&r<=d-c.border&&c.node&&c.contentDOM&&this.contentDOM.contains(c.contentDOM))return c.parseRange(e,r,u);e=i;for(let h=a;h>0;h--){let f=this.children[h-1];if(f.size&&f.dom.parentNode==this.contentDOM&&!f.emptyChildAt(1)){s=or(f.dom)+1;break}e-=f.size}s==-1&&(s=0)}if(s>-1&&(d>r||a==this.children.length-1)){r=d;for(let u=a+1;ug&&ir){let g=a;a=c,c=g}let p=document.createRange();p.setEnd(c.node,c.offset),p.setStart(a.node,a.offset),d.removeAllRanges(),d.addRange(p)}}ignoreMutation(e){return!this.contentDOM&&e.type!="selection"}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,r){for(let n=0,s=0;s=n:en){let a=n+o.border,c=i-o.border;if(e>=a&&r<=c){this.dirty=e==n||r==i?wa:VT,e==a&&r==c&&(o.contentLost||o.dom.parentNode!=this.contentDOM)?o.dirty=Cs:o.markDirty(e-a,r-a);return}else o.dirty=o.dom==o.contentDOM&&o.dom.parentNode==this.contentDOM&&!o.children.length?wa:Cs}n=i}this.dirty=wa}markParentsDirty(){let e=1;for(let r=this.parent;r;r=r.parent,e++){let n=e==1?wa:VT;r.dirty{if(!o)return s;if(o.parent)return o.parent.posBeforeChild(o)})),!r.type.spec.raw){if(i.nodeType!=1){let a=document.createElement("span");a.appendChild(i),i=a}i.contentEditable="false",i.classList.add("ProseMirror-widget")}super(e,[],i,null),this.widget=r,this.widget=r,o=this}matchesWidget(e){return this.dirty==Rn&&e.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(e){let r=this.widget.spec.stopEvent;return r?r(e):!1}ignoreMutation(e){return e.type!="selection"||this.widget.spec.ignoreSelection}destroy(){this.widget.type.destroy(this.dom),super.destroy()}get domAtom(){return!0}get ignoreForSelection(){return!!this.widget.type.spec.relaxedSide}get side(){return this.widget.type.side}}class J9 extends Du{constructor(e,r,n,s){super(e,[],r,null),this.textDOM=n,this.text=s}get size(){return this.text.length}localPosFromDOM(e,r){return e!=this.textDOM?this.posAtStart+(r?this.size:0):this.posAtStart+r}domFromPos(e){return{node:this.textDOM,offset:e}}ignoreMutation(e){return e.type==="characterData"&&e.target.nodeValue==e.oldValue}}class ba extends Du{constructor(e,r,n,s,o){super(e,[],n,s),this.mark=r,this.spec=o}static create(e,r,n,s){let o=s.nodeViews[r.type.name],i=o&&o(r,s,n);return(!i||!i.dom)&&(i=ga.renderSpec(document,r.type.spec.toDOM(r,n),null,r.attrs)),new ba(e,r,i.dom,i.contentDOM||i.dom,i)}parseRule(){return this.dirty&Cs||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=Cs&&this.mark.eq(e)}markDirty(e,r){if(super.markDirty(e,r),this.dirty!=Rn){let n=this.parent;for(;!n.node;)n=n.parent;n.dirty0&&(o=e0(o,0,e,n));for(let a=0;a{if(!c)return i;if(c.parent)return c.parent.posBeforeChild(c)},n,s),u=d&&d.dom,h=d&&d.contentDOM;if(r.isText){if(!u)u=document.createTextNode(r.text);else if(u.nodeType!=3)throw new RangeError("Text must be rendered as a DOM text node")}else u||({dom:u,contentDOM:h}=ga.renderSpec(document,r.type.spec.toDOM(r),null,r.attrs));!h&&!r.isText&&u.nodeName!="BR"&&(u.hasAttribute("contenteditable")||(u.contentEditable="false"),r.type.spec.draggable&&(u.draggable=!0));let f=u;return u=YT(u,n,r),d?c=new Q9(e,r,n,s,u,h||null,f,d,o,i+1):r.isText?new am(e,r,n,s,u,f,o):new ii(e,r,n,s,u,h||null,f,o,i+1)}parseRule(){if(this.node.type.spec.reparseInView)return null;let e={node:this.node.type.name,attrs:this.node.attrs};if(this.node.type.whitespace=="pre"&&(e.preserveWhitespace="full"),!this.contentDOM)e.getContent=()=>this.node.content;else if(!this.contentLost)e.contentElement=this.contentDOM;else{for(let r=this.children.length-1;r>=0;r--){let n=this.children[r];if(this.dom.contains(n.dom.parentNode)){e.contentElement=n.dom.parentNode;break}}e.contentElement||(e.getContent=()=>Y.empty)}return e}matchesNode(e,r,n){return this.dirty==Rn&&e.eq(this.node)&&lm(r,this.outerDeco)&&n.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(e,r){let n=this.node.inlineContent,s=r,o=e.composing?this.localCompositionInfo(e,r):null,i=o&&o.pos>-1?o:null,a=o&&o.pos<0,c=new Z9(this,i&&i.node,e);r7(this.node,this.innerDeco,(d,u,h)=>{d.spec.marks?c.syncToMarks(d.spec.marks,n,e,u):d.type.side>=0&&!h&&c.syncToMarks(u==this.node.childCount?Ve.none:this.node.child(u).marks,n,e,u),c.placeWidget(d,e,s)},(d,u,h,f)=>{c.syncToMarks(d.marks,n,e,f);let p;c.findNodeMatch(d,u,h,f)||a&&e.state.selection.from>s&&e.state.selection.to-1&&c.updateNodeAt(d,u,h,p,e)||c.updateNextNode(d,u,h,e,f,s)||c.addNode(d,u,h,e,s),s+=d.nodeSize}),c.syncToMarks([],n,e,0),this.node.isTextblock&&c.addTextblockHacks(),c.destroyRest(),(c.changed||this.dirty==wa)&&(i&&this.protectLocalComposition(e,i),KT(this.contentDOM,this.children,e),uc&&n7(this.dom))}localCompositionInfo(e,r){let{from:n,to:s}=e.state.selection;if(!(e.state.selection instanceof Ce)||nr+this.node.content.size)return null;let o=e.input.compositionNode;if(!o||!this.dom.contains(o.parentNode))return null;if(this.node.inlineContent){let i=o.nodeValue,a=s7(this.node.content,i,n-r,s-r);return a<0?null:{node:o,pos:a,text:i}}else return{node:o,pos:-1,text:""}}protectLocalComposition(e,{node:r,pos:n,text:s}){if(this.getDesc(r))return;let o=r;for(;o.parentNode!=this.contentDOM;o=o.parentNode){for(;o.previousSibling;)o.parentNode.removeChild(o.previousSibling);for(;o.nextSibling;)o.parentNode.removeChild(o.nextSibling);o.pmViewDesc&&(o.pmViewDesc=void 0)}let i=new J9(this,o,r,s);e.input.compositionNodes.push(i),this.children=e0(this.children,n,n+s.length,e,i)}update(e,r,n,s){return this.dirty==Cs||!e.sameMarkup(this.node)?!1:(this.updateInner(e,r,n,s),!0)}updateInner(e,r,n,s){this.updateOuterDeco(r),this.node=e,this.innerDeco=n,this.contentDOM&&this.updateChildren(s,this.posAtStart),this.dirty=Rn}updateOuterDeco(e){if(lm(e,this.outerDeco))return;let r=this.nodeDOM.nodeType!=1,n=this.dom;this.dom=GT(this.dom,this.nodeDOM,Zw(this.outerDeco,this.node,r),Zw(e,this.node,r)),this.dom!=n&&(n.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=e}selectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.add("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&(this.nodeDOM.draggable=!0))}deselectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.remove("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&this.nodeDOM.removeAttribute("draggable"))}get domAtom(){return this.node.isAtom}}function HT(t,e,r,n,s){YT(n,e,t);let o=new ii(void 0,t,e,r,n,n,n,s,0);return o.contentDOM&&o.updateChildren(s,0),o}class am extends ii{constructor(e,r,n,s,o,i,a){super(e,r,n,s,o,null,i,a,0)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,r,n,s){return this.dirty==Cs||this.dirty!=Rn&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(r),(this.dirty!=Rn||e.text!=this.node.text)&&e.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=e.text,s.trackWrites==this.nodeDOM&&(s.trackWrites=null)),this.node=e,this.dirty=Rn,!0)}inParent(){let e=this.parent.contentDOM;for(let r=this.nodeDOM;r;r=r.parentNode)if(r==e)return!0;return!1}domFromPos(e){return{node:this.nodeDOM,offset:e}}localPosFromDOM(e,r,n){return e==this.nodeDOM?this.posAtStart+Math.min(r,this.node.text.length):super.localPosFromDOM(e,r,n)}ignoreMutation(e){return e.type!="characterData"&&e.type!="selection"}slice(e,r,n){let s=this.node.cut(e,r),o=document.createTextNode(s.text);return new am(this.parent,s,this.outerDeco,this.innerDeco,o,o,n)}markDirty(e,r){super.markDirty(e,r),this.dom!=this.nodeDOM&&(e==0||r==this.nodeDOM.nodeValue.length)&&(this.dirty=Cs)}get domAtom(){return!1}isText(e){return this.node.text==e}}class qT extends Du{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==Rn&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class Q9 extends ii{constructor(e,r,n,s,o,i,a,c,d,u){super(e,r,n,s,o,i,a,d,u),this.spec=c}update(e,r,n,s){if(this.dirty==Cs)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let o=this.spec.update(e,r,n);return o&&this.updateInner(e,r,n,s),o}else return!this.contentDOM&&!e.isLeaf?!1:super.update(e,r,n,s)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,r,n,s){this.spec.setSelection?this.spec.setSelection(e,r,n.root):super.setSelection(e,r,n,s)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(e){return this.spec.stopEvent?this.spec.stopEvent(e):!1}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}}function KT(t,e,r){let n=t.firstChild,s=!1;for(let o=0;o>1,a=Math.min(i,e.length);for(;o-1)c>this.index&&(this.changed=!0,this.destroyBetween(this.index,c)),this.top=this.top.children[this.index];else{let u=ba.create(this.top,e[i],r,n);this.top.children.splice(this.index,0,u),this.top=u,this.changed=!0}this.index=0,i++}}findNodeMatch(e,r,n,s){let o=-1,i;if(s>=this.preMatch.index&&(i=this.preMatch.matches[s-this.preMatch.index]).parent==this.top&&i.matchesNode(e,r,n))o=this.top.children.indexOf(i,this.index);else for(let a=this.index,c=Math.min(this.top.children.length,a+5);a0;){let a;for(;;)if(n){let d=r.children[n-1];if(d instanceof ba)r=d,n=d.children.length;else{a=d,n--;break}}else{if(r==e)break e;n=r.parent.children.indexOf(r),r=r.parent}let c=a.node;if(c){if(c!=t.child(s-1))break;--s,o.set(a,s),i.push(a)}}return{index:s,matched:o,matches:i.reverse()}}function t7(t,e){return t.type.side-e.type.side}function r7(t,e,r,n){let s=e.locals(t),o=0;if(s.length==0){for(let d=0;do;)a.push(s[i++]);let g=o+f.nodeSize;if(f.isText){let y=g;i!y.inline):a.slice();n(f,v,e.forChild(o,f),p),o=g}}function n7(t){if(t.nodeName=="UL"||t.nodeName=="OL"){let e=t.style.cssText;t.style.cssText=e+"; list-style: square !important",window.getComputedStyle(t).listStyle,t.style.cssText=e}}function s7(t,e,r,n){for(let s=0,o=0;s=r){if(o>=n&&c.slice(n-e.length-a,n-a)==e)return n-e.length;let d=a=0&&d+e.length+a>=r)return a+d;if(r==n&&c.length>=n+e.length-a&&c.slice(n-a,n-a+e.length)==e)return n}}return-1}function e0(t,e,r,n,s){let o=[];for(let i=0,a=0;i=r||u<=e?o.push(c):(dr&&o.push(c.slice(r-d,c.size,n)))}return o}function t0(t,e=null){let r=t.domSelectionRange(),n=t.state.doc;if(!r.focusNode)return null;let s=t.docView.nearestDesc(r.focusNode),o=s&&s.size==0,i=t.docView.posFromDOM(r.focusNode,r.focusOffset,1);if(i<0)return null;let a=n.resolve(i),c,d;if(im(r)){for(c=i;s&&!s.node;)s=s.parent;let h=s.node;if(s&&h.isAtom&&me.isSelectable(h)&&s.parent&&!(h.isInline&&M9(r.focusNode,r.focusOffset,s.dom))){let f=s.posBefore;d=new me(i==f?a:n.resolve(f))}}else{if(r instanceof t.dom.ownerDocument.defaultView.Selection&&r.rangeCount>1){let h=i,f=i;for(let p=0;p{(r.anchorNode!=n||r.anchorOffset!=s)&&(e.removeEventListener("selectionchange",t.input.hideSelectionGuard),setTimeout(()=>{(!QT(t)||t.state.selection.visible)&&t.dom.classList.remove("ProseMirror-hideselection")},20))})}function i7(t){let e=t.domSelection();if(!e)return;let r=t.cursorWrapper.dom,n=r.nodeName=="IMG";n?e.collapse(r.parentNode,or(r)+1):e.collapse(r,0),!n&&!t.state.selection.visible&&Ur&&si<=11&&(r.disabled=!0,r.disabled=!1)}function tR(t,e){if(e instanceof me){let r=t.docView.descAt(e.from);r!=t.lastSelectedViewDesc&&(rR(t),r&&r.selectNode(),t.lastSelectedViewDesc=r)}else rR(t)}function rR(t){t.lastSelectedViewDesc&&(t.lastSelectedViewDesc.parent&&t.lastSelectedViewDesc.deselectNode(),t.lastSelectedViewDesc=void 0)}function n0(t,e,r,n){return t.someProp("createSelectionBetween",s=>s(t,e,r))||Ce.between(e,r,n)}function nR(t){return t.editable&&!t.hasFocus()?!1:sR(t)}function sR(t){let e=t.domSelectionRange();if(!e.anchorNode)return!1;try{return t.dom.contains(e.anchorNode.nodeType==3?e.anchorNode.parentNode:e.anchorNode)&&(t.editable||t.dom.contains(e.focusNode.nodeType==3?e.focusNode.parentNode:e.focusNode))}catch{return!1}}function a7(t){let e=t.docView.domFromPos(t.state.selection.anchor,0),r=t.domSelectionRange();return ya(e.node,e.offset,r.anchorNode,r.anchorOffset)}function s0(t,e){let{$anchor:r,$head:n}=t.selection,s=e>0?r.max(n):r.min(n),o=s.parent.inlineContent?s.depth?t.doc.resolve(e>0?s.after():s.before()):null:s;return o&&_e.findFrom(o,e)}function ai(t,e){return t.dispatch(t.state.tr.setSelection(e).scrollIntoView()),!0}function oR(t,e,r){let n=t.state.selection;if(n instanceof Ce)if(r.indexOf("s")>-1){let{$head:s}=n,o=s.textOffset?null:e<0?s.nodeBefore:s.nodeAfter;if(!o||o.isText||!o.isLeaf)return!1;let i=t.state.doc.resolve(s.pos+o.nodeSize*(e<0?-1:1));return ai(t,new Ce(n.$anchor,i))}else if(n.empty){if(t.endOfTextblock(e>0?"forward":"backward")){let s=s0(t.state,e);return s&&s instanceof me?ai(t,s):!1}else if(!(Tn&&r.indexOf("m")>-1)){let s=n.$head,o=s.textOffset?null:e<0?s.nodeBefore:s.nodeAfter,i;if(!o||o.isText)return!1;let a=e<0?s.pos-o.nodeSize:s.pos;return o.isAtom||(i=t.docView.descAt(a))&&!i.contentDOM?me.isSelectable(o)?ai(t,new me(e<0?t.state.doc.resolve(s.pos-o.nodeSize):s)):Au?ai(t,new Ce(t.state.doc.resolve(e<0?a:a+o.nodeSize))):!1:!1}}else return!1;else{if(n instanceof me&&n.node.isInline)return ai(t,new Ce(e>0?n.$to:n.$from));{let s=s0(t.state,e);return s?ai(t,s):!1}}}function cm(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function $u(t,e){let r=t.pmViewDesc;return r&&r.size==0&&(e<0||t.nextSibling||t.nodeName!="BR")}function fc(t,e){return e<0?l7(t):c7(t)}function l7(t){let e=t.domSelectionRange(),r=e.focusNode,n=e.focusOffset;if(!r)return;let s,o,i=!1;for(_n&&r.nodeType==1&&n0){if(r.nodeType!=1)break;{let a=r.childNodes[n-1];if($u(a,-1))s=r,o=--n;else if(a.nodeType==3)r=a,n=r.nodeValue.length;else break}}else{if(iR(r))break;{let a=r.previousSibling;for(;a&&$u(a,-1);)s=r.parentNode,o=or(a),a=a.previousSibling;if(a)r=a,n=cm(r);else{if(r=r.parentNode,r==t.dom)break;n=0}}}i?o0(t,r,n):s&&o0(t,s,o)}function c7(t){let e=t.domSelectionRange(),r=e.focusNode,n=e.focusOffset;if(!r)return;let s=cm(r),o,i;for(;;)if(n{t.state==s&&ao(t)},50)}function aR(t,e){let r=t.state.doc.resolve(e);if(!(Wt||MT)&&r.parent.inlineContent){let s=t.coordsAtPos(e);if(e>r.start()){let o=t.coordsAtPos(e-1),i=(o.top+o.bottom)/2;if(i>s.top&&i1)return o.lefts.top&&i1)return o.left>s.left?"ltr":"rtl"}}return getComputedStyle(t.dom).direction=="rtl"?"rtl":"ltr"}function lR(t,e,r){let n=t.state.selection;if(n instanceof Ce&&!n.empty||r.indexOf("s")>-1||Tn&&r.indexOf("m")>-1)return!1;let{$from:s,$to:o}=n;if(!s.parent.inlineContent||t.endOfTextblock(e<0?"up":"down")){let i=s0(t.state,e);if(i&&i instanceof me)return ai(t,i)}if(!s.parent.inlineContent){let i=e<0?s:o,a=n instanceof jn?_e.near(i,e):_e.findFrom(i,e);return a?ai(t,a):!1}return!1}function cR(t,e){if(!(t.state.selection instanceof Ce))return!0;let{$head:r,$anchor:n,empty:s}=t.state.selection;if(!r.sameParent(n))return!0;if(!s)return!1;if(t.endOfTextblock(e>0?"forward":"backward"))return!0;let o=!r.textOffset&&(e<0?r.nodeBefore:r.nodeAfter);if(o&&!o.isText){let i=t.state.tr;return e<0?i.delete(r.pos-o.nodeSize,r.pos):i.delete(r.pos,r.pos+o.nodeSize),t.dispatch(i),!0}return!1}function dR(t,e,r){t.domObserver.stop(),e.contentEditable=r,t.domObserver.start()}function h7(t){if(!ir||t.state.selection.$head.parentOffset>0)return!1;let{focusNode:e,focusOffset:r}=t.domSelectionRange();if(e&&e.nodeType==1&&r==0&&e.firstChild&&e.firstChild.contentEditable=="false"){let n=e.firstChild;dR(t,n,"true"),setTimeout(()=>dR(t,n,"false"),20)}return!1}function f7(t){let e="";return t.ctrlKey&&(e+="c"),t.metaKey&&(e+="m"),t.altKey&&(e+="a"),t.shiftKey&&(e+="s"),e}function p7(t,e){let r=e.keyCode,n=f7(e);if(r==8||Tn&&r==72&&n=="c")return cR(t,-1)||fc(t,-1);if(r==46&&!e.shiftKey||Tn&&r==68&&n=="c")return cR(t,1)||fc(t,1);if(r==13||r==27)return!0;if(r==37||Tn&&r==66&&n=="c"){let s=r==37?aR(t,t.state.selection.from)=="ltr"?-1:1:-1;return oR(t,s,n)||fc(t,s)}else if(r==39||Tn&&r==70&&n=="c"){let s=r==39?aR(t,t.state.selection.from)=="ltr"?1:-1:1;return oR(t,s,n)||fc(t,s)}else{if(r==38||Tn&&r==80&&n=="c")return lR(t,-1,n)||fc(t,-1);if(r==40||Tn&&r==78&&n=="c")return h7(t)||lR(t,1,n)||fc(t,1);if(n==(Tn?"m":"c")&&(r==66||r==73||r==89||r==90))return!0}return!1}function i0(t,e){t.someProp("transformCopied",p=>{e=p(e,t)});let r=[],{content:n,openStart:s,openEnd:o}=e;for(;s>1&&o>1&&n.childCount==1&&n.firstChild.childCount==1;){s--,o--;let p=n.firstChild;r.push(p.type.name,p.attrs!=p.type.defaultAttrs?p.attrs:null),n=p.content}let i=t.someProp("clipboardSerializer")||ga.fromSchema(t.state.schema),a=yR(),c=a.createElement("div");c.appendChild(i.serializeFragment(n,{document:a}));let d=c.firstChild,u,h=0;for(;d&&d.nodeType==1&&(u=gR[d.nodeName.toLowerCase()]);){for(let p=u.length-1;p>=0;p--){let g=a.createElement(u[p]);for(;c.firstChild;)g.appendChild(c.firstChild);c.appendChild(g),h++}d=c.firstChild}d&&d.nodeType==1&&d.setAttribute("data-pm-slice",`${s} ${o}${h?` -${h}`:""} ${JSON.stringify(r)}`);let f=t.someProp("clipboardTextSerializer",p=>p(e,t))||e.content.textBetween(0,e.content.size,` `);return{dom:c,text:f,slice:e}}function uR(t,e,r,n,s){let o=s.parent.type.spec.code,i,a;if(!r&&!e)return null;let c=!!e&&(n||o||!r);if(c){if(t.someProp("transformPastedText",f=>{e=f(e,o||n,t)}),o)return a=new oe(Y.from(t.state.schema.text(e.replace(/\r\n?/g,` `))),0,0),t.someProp("transformPasted",f=>{a=f(a,t,!0)}),a;let h=t.someProp("clipboardTextParser",f=>f(e,s,n,t));if(h)a=h;else{let f=s.marks(),{schema:p}=t.state,g=ga.fromSchema(p);i=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(v=>{let y=i.appendChild(document.createElement("p"));v&&y.appendChild(g.serializeNode(p.text(v,f)))})}}else t.someProp("transformPastedHTML",h=>{r=h(r,t)}),i=y7(r),Au&&x7(i);let d=i&&i.querySelector("[data-pm-slice]"),u=d&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(d.getAttribute("data-pm-slice")||"");if(u&&u[3])for(let h=+u[3];h>0;h--){let f=i.firstChild;for(;f&&f.nodeType!=1;)f=f.nextSibling;if(!f)break;i=f}if(a||(a=(t.someProp("clipboardParser")||t.someProp("domParser")||Zo.fromSchema(t.state.schema)).parseSlice(i,{preserveWhitespace:!!(c||u),context:s,ruleFromNode(f){return f.nodeName=="BR"&&!f.nextSibling&&f.parentNode&&!m7.test(f.parentNode.nodeName)?{ignore:!0}:null}})),u)a=w7(mR(a,+u[1],+u[2]),u[4]);else if(a=oe.maxOpen(g7(a.content,s),!0),a.openStart||a.openEnd){let h=0,f=0;for(let p=a.content.firstChild;h{a=h(a,t,c)}),a}const m7=/^(a|abbr|acronym|b|cite|code|del|em|i|ins|kbd|label|output|q|ruby|s|samp|span|strong|sub|sup|time|u|tt|var)$/i;function g7(t,e){if(t.childCount<2)return t;for(let r=e.depth;r>=0;r--){let s=e.node(r).contentMatchAt(e.index(r)),o,i=[];if(t.forEach(a=>{if(!i)return;let c=s.findWrapping(a.type),d;if(!c)return i=null;if(d=i.length&&o.length&&fR(c,o,a,i[i.length-1],0))i[i.length-1]=d;else{i.length&&(i[i.length-1]=pR(i[i.length-1],o.length));let u=hR(a,c);i.push(u),s=s.matchType(u.type),o=c}}),i)return Y.from(i)}return t}function hR(t,e,r=0){for(let n=e.length-1;n>=r;n--)t=e[n].create(null,Y.from(t));return t}function fR(t,e,r,n,s){if(s1&&(o=0),s=r&&(a=e<0?i.contentMatchAt(0).fillBefore(a,o<=s).append(a):a.append(i.contentMatchAt(i.childCount).fillBefore(Y.empty,!0))),t.replaceChild(e<0?0:t.childCount-1,i.copy(a))}function mR(t,e,r){return er})),l0.createHTML(t)):t}function y7(t){let e=/^(\s*]*>)*/.exec(t);e&&(t=t.slice(e[0].length));let r=yR().createElement("div"),n=/<([a-z][^>\s]+)/i.exec(t),s;if((s=n&&gR[n[1].toLowerCase()])&&(t=s.map(o=>"<"+o+">").join("")+t+s.map(o=>"").reverse().join("")),r.innerHTML=v7(t),s)for(let o=0;o=0;a-=2){let c=r.nodes[n[a]];if(!c||c.hasRequiredAttrs())break;s=Y.from(c.create(n[a+1],s)),o++,i++}return new oe(s,o,i)}const Er={},_r={},b7={touchstart:!0,touchmove:!0};class k7{constructor(){this.shiftKey=!1,this.mouseDown=null,this.lastKeyCode=null,this.lastKeyCodeTime=0,this.lastClick={time:0,x:0,y:0,type:"",button:0},this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastIOSEnter=0,this.lastIOSEnterFallbackTimeout=-1,this.lastFocus=0,this.lastTouch=0,this.lastChromeDelete=0,this.composing=!1,this.compositionNode=null,this.composingTimeout=-1,this.compositionNodes=[],this.compositionEndedAt=-2e8,this.compositionID=1,this.badSafariComposition=!1,this.compositionPendingChanges=0,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null}}function S7(t){for(let e in Er){let r=Er[e];t.dom.addEventListener(e,t.input.eventHandlers[e]=n=>{C7(t,n)&&!d0(t,n)&&(t.editable||!(n.type in _r))&&r(t,n)},b7[e]?{passive:!0}:void 0)}ir&&t.dom.addEventListener("input",()=>null),c0(t)}function li(t,e){t.input.lastSelectionOrigin=e,t.input.lastSelectionTime=Date.now()}function N7(t){t.domObserver.stop();for(let e in t.input.eventHandlers)t.dom.removeEventListener(e,t.input.eventHandlers[e]);clearTimeout(t.input.composingTimeout),clearTimeout(t.input.lastIOSEnterFallbackTimeout)}function c0(t){t.someProp("handleDOMEvents",e=>{for(let r in e)t.input.eventHandlers[r]||t.dom.addEventListener(r,t.input.eventHandlers[r]=n=>d0(t,n))})}function d0(t,e){return t.someProp("handleDOMEvents",r=>{let n=r[e.type];return n?n(t,e)||e.defaultPrevented:!1})}function C7(t,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let r=e.target;r!=t.dom;r=r.parentNode)if(!r||r.nodeType==11||r.pmViewDesc&&r.pmViewDesc.stopEvent(e))return!1;return!0}function j7(t,e){!d0(t,e)&&Er[e.type]&&(t.editable||!(e.type in _r))&&Er[e.type](t,e)}_r.keydown=(t,e)=>{let r=e;if(t.input.shiftKey=r.keyCode==16||r.shiftKey,!wR(t,r)&&(t.input.lastKeyCode=r.keyCode,t.input.lastKeyCodeTime=Date.now(),!(oo&&Wt&&r.keyCode==13)))if(r.keyCode!=229&&t.domObserver.forceFlush(),uc&&r.keyCode==13&&!r.ctrlKey&&!r.altKey&&!r.metaKey){let n=Date.now();t.input.lastIOSEnter=n,t.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{t.input.lastIOSEnter==n&&(t.someProp("handleKeyDown",s=>s(t,xa(13,"Enter"))),t.input.lastIOSEnter=0)},200)}else t.someProp("handleKeyDown",n=>n(t,r))||p7(t,r)?r.preventDefault():li(t,"key")},_r.keyup=(t,e)=>{e.keyCode==16&&(t.input.shiftKey=!1)},_r.keypress=(t,e)=>{let r=e;if(wR(t,r)||!r.charCode||r.ctrlKey&&!r.altKey||Tn&&r.metaKey)return;if(t.someProp("handleKeyPress",s=>s(t,r))){r.preventDefault();return}let n=t.state.selection;if(!(n instanceof Ce)||!n.$from.sameParent(n.$to)){let s=String.fromCharCode(r.charCode),o=()=>t.state.tr.insertText(s).scrollIntoView();!/[\r\n]/.test(s)&&!t.someProp("handleTextInput",i=>i(t,n.$from.pos,n.$to.pos,s,o))&&t.dispatch(o()),r.preventDefault()}};function dm(t){return{left:t.clientX,top:t.clientY}}function E7(t,e){let r=e.x-t.clientX,n=e.y-t.clientY;return r*r+n*n<100}function u0(t,e,r,n,s){if(n==-1)return!1;let o=t.state.doc.resolve(n);for(let i=o.depth+1;i>0;i--)if(t.someProp(e,a=>i>o.depth?a(t,r,o.nodeAfter,o.before(i),s,!0):a(t,r,o.node(i),o.before(i),s,!1)))return!0;return!1}function pc(t,e,r){if(t.focused||t.focus(),t.state.selection.eq(e))return;let n=t.state.tr.setSelection(e);n.setMeta("pointer",!0),t.dispatch(n)}function _7(t,e){if(e==-1)return!1;let r=t.state.doc.resolve(e),n=r.nodeAfter;return n&&n.isAtom&&me.isSelectable(n)?(pc(t,new me(r)),!0):!1}function T7(t,e){if(e==-1)return!1;let r=t.state.selection,n,s;r instanceof me&&(n=r.node);let o=t.state.doc.resolve(e);for(let i=o.depth+1;i>0;i--){let a=i>o.depth?o.nodeAfter:o.node(i);if(me.isSelectable(a)){n&&r.$from.depth>0&&i>=r.$from.depth&&o.before(r.$from.depth+1)==r.$from.pos?s=o.before(r.$from.depth):s=o.before(i);break}}return s!=null?(pc(t,me.create(t.state.doc,s)),!0):!1}function R7(t,e,r,n,s){return u0(t,"handleClickOn",e,r,n)||t.someProp("handleClick",o=>o(t,e,n))||(s?T7(t,r):_7(t,r))}function M7(t,e,r,n){return u0(t,"handleDoubleClickOn",e,r,n)||t.someProp("handleDoubleClick",s=>s(t,e,n))}function O7(t,e,r,n){return u0(t,"handleTripleClickOn",e,r,n)||t.someProp("handleTripleClick",s=>s(t,e,n))||P7(t,r,n)}function P7(t,e,r){if(r.button!=0)return!1;let n=t.state.doc;if(e==-1)return n.inlineContent?(pc(t,Ce.create(n,0,n.content.size)),!0):!1;let s=n.resolve(e);for(let o=s.depth+1;o>0;o--){let i=o>s.depth?s.nodeAfter:s.node(o),a=s.before(o);if(i.inlineContent)pc(t,Ce.create(n,a+1,a+1+i.content.size));else if(me.isSelectable(i))pc(t,me.create(n,a));else continue;return!0}}function h0(t){return um(t)}const xR=Tn?"metaKey":"ctrlKey";Er.mousedown=(t,e)=>{let r=e;t.input.shiftKey=r.shiftKey;let n=h0(t),s=Date.now(),o="singleClick";s-t.input.lastClick.time<500&&E7(r,t.input.lastClick)&&!r[xR]&&t.input.lastClick.button==r.button&&(t.input.lastClick.type=="singleClick"?o="doubleClick":t.input.lastClick.type=="doubleClick"&&(o="tripleClick")),t.input.lastClick={time:s,x:r.clientX,y:r.clientY,type:o,button:r.button};let i=t.posAtCoords(dm(r));i&&(o=="singleClick"?(t.input.mouseDown&&t.input.mouseDown.done(),t.input.mouseDown=new A7(t,i,r,!!n)):(o=="doubleClick"?M7:O7)(t,i.pos,i.inside,r)?r.preventDefault():li(t,"pointer"))};class A7{constructor(e,r,n,s){this.view=e,this.pos=r,this.event=n,this.flushed=s,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=e.state.doc,this.selectNode=!!n[xR],this.allowDefault=n.shiftKey;let o,i;if(r.inside>-1)o=e.state.doc.nodeAt(r.inside),i=r.inside;else{let u=e.state.doc.resolve(r.pos);o=u.parent,i=u.depth?u.before():0}const a=s?null:n.target,c=a?e.docView.nearestDesc(a,!0):null;this.target=c&&c.nodeDOM.nodeType==1?c.nodeDOM:null;let{selection:d}=e.state;(n.button==0&&o.type.spec.draggable&&o.type.spec.selectable!==!1||d instanceof me&&d.from<=i&&d.to>i)&&(this.mightDrag={node:o,pos:i,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&_n&&!this.target.hasAttribute("contentEditable"))}),this.target&&this.mightDrag&&(this.mightDrag.addAttr||this.mightDrag.setUneditable)&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&(this.target.draggable=!0),this.mightDrag.setUneditable&&setTimeout(()=>{this.view.input.mouseDown==this&&this.target.setAttribute("contentEditable","false")},20),this.view.domObserver.start()),e.root.addEventListener("mouseup",this.up=this.up.bind(this)),e.root.addEventListener("mousemove",this.move=this.move.bind(this)),li(e,"pointer")}done(){this.view.root.removeEventListener("mouseup",this.up),this.view.root.removeEventListener("mousemove",this.move),this.mightDrag&&this.target&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&this.target.removeAttribute("draggable"),this.mightDrag.setUneditable&&this.target.removeAttribute("contentEditable"),this.view.domObserver.start()),this.delayedSelectionSync&&setTimeout(()=>ao(this.view)),this.view.input.mouseDown=null}up(e){if(this.done(),!this.view.dom.contains(e.target))return;let r=this.pos;this.view.state.doc!=this.startDoc&&(r=this.view.posAtCoords(dm(e))),this.updateAllowDefault(e),this.allowDefault||!r?li(this.view,"pointer"):R7(this.view,r.pos,r.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||ir&&this.mightDrag&&!this.mightDrag.node.isAtom||Wt&&!this.view.state.selection.visible&&Math.min(Math.abs(r.pos-this.view.state.selection.from),Math.abs(r.pos-this.view.state.selection.to))<=2)?(pc(this.view,_e.near(this.view.state.doc.resolve(r.pos))),e.preventDefault()):li(this.view,"pointer")}move(e){this.updateAllowDefault(e),li(this.view,"pointer"),e.buttons==0&&this.done()}updateAllowDefault(e){!this.allowDefault&&(Math.abs(this.event.x-e.clientX)>4||Math.abs(this.event.y-e.clientY)>4)&&(this.allowDefault=!0)}}Er.touchstart=t=>{t.input.lastTouch=Date.now(),h0(t),li(t,"pointer")},Er.touchmove=t=>{t.input.lastTouch=Date.now(),li(t,"pointer")},Er.contextmenu=t=>h0(t);function wR(t,e){return t.composing?!0:ir&&Math.abs(e.timeStamp-t.input.compositionEndedAt)<500?(t.input.compositionEndedAt=-2e8,!0):!1}const I7=oo?5e3:-1;_r.compositionstart=_r.compositionupdate=t=>{if(!t.composing){t.domObserver.flush();let{state:e}=t,r=e.selection.$to;if(e.selection instanceof Ce&&(e.storedMarks||!r.textOffset&&r.parentOffset&&r.nodeBefore.marks.some(n=>n.type.spec.inclusive===!1)||Wt&&MT&&D7(t)))t.markCursor=t.state.storedMarks||r.marks(),um(t,!0),t.markCursor=null;else if(um(t,!e.selection.empty),_n&&e.selection.empty&&r.parentOffset&&!r.textOffset&&r.nodeBefore.marks.length){let n=t.domSelectionRange();for(let s=n.focusNode,o=n.focusOffset;s&&s.nodeType==1&&o!=0;){let i=o<0?s.lastChild:s.childNodes[o-1];if(!i)break;if(i.nodeType==3){let a=t.domSelection();a&&a.collapse(i,i.nodeValue.length);break}else s=i,o=-1}}t.input.composing=!0}bR(t,I7)};function D7(t){let{focusNode:e,focusOffset:r}=t.domSelectionRange();if(!e||e.nodeType!=1||r>=e.childNodes.length)return!1;let n=e.childNodes[r];return n.nodeType==1&&n.contentEditable=="false"}_r.compositionend=(t,e)=>{t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=e.timeStamp,t.input.compositionPendingChanges=t.domObserver.pendingRecords().length?t.input.compositionID:0,t.input.compositionNode=null,t.input.badSafariComposition?t.domObserver.forceFlush():t.input.compositionPendingChanges&&Promise.resolve().then(()=>t.domObserver.flush()),t.input.compositionID++,bR(t,20))};function bR(t,e){clearTimeout(t.input.composingTimeout),e>-1&&(t.input.composingTimeout=setTimeout(()=>um(t),e))}function kR(t){for(t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=$7());t.input.compositionNodes.length>0;)t.input.compositionNodes.pop().markParentsDirty()}function L7(t){let e=t.domSelectionRange();if(!e.focusNode)return null;let r=T9(e.focusNode,e.focusOffset),n=R9(e.focusNode,e.focusOffset);if(r&&n&&r!=n){let s=n.pmViewDesc,o=t.domObserver.lastChangedTextNode;if(r==o||n==o)return o;if(!s||!s.isText(n.nodeValue))return n;if(t.input.compositionNode==n){let i=r.pmViewDesc;if(!(!i||!i.isText(r.nodeValue)))return n}}return r||n}function $7(){let t=document.createEvent("Event");return t.initEvent("event",!0,!0),t.timeStamp}function um(t,e=!1){if(!(oo&&t.domObserver.flushingSoon>=0)){if(t.domObserver.forceFlush(),kR(t),e||t.docView&&t.docView.dirty){let r=t0(t),n=t.state.selection;return r&&!r.eq(n)?t.dispatch(t.state.tr.setSelection(r)):(t.markCursor||e)&&!n.$from.node(n.$from.sharedDepth(n.to)).inlineContent?t.dispatch(t.state.tr.deleteSelection()):t.updateState(t.state),!0}return!1}}function F7(t,e){if(!t.dom.parentNode)return;let r=t.dom.parentNode.appendChild(document.createElement("div"));r.appendChild(e),r.style.cssText="position: fixed; left: -10000px; top: 10px";let n=getSelection(),s=document.createRange();s.selectNodeContents(e),t.dom.blur(),n.removeAllRanges(),n.addRange(s),setTimeout(()=>{r.parentNode&&r.parentNode.removeChild(r),t.focus()},50)}const Fu=Ur&&si<15||uc&&A9<604;Er.copy=_r.cut=(t,e)=>{let r=e,n=t.state.selection,s=r.type=="cut";if(n.empty)return;let o=Fu?null:r.clipboardData,i=n.content(),{dom:a,text:c}=i0(t,i);o?(r.preventDefault(),o.clearData(),o.setData("text/html",a.innerHTML),o.setData("text/plain",c)):F7(t,a),s&&t.dispatch(t.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function z7(t){return t.openStart==0&&t.openEnd==0&&t.content.childCount==1?t.content.firstChild:null}function B7(t,e){if(!t.dom.parentNode)return;let r=t.input.shiftKey||t.state.selection.$from.parent.type.spec.code,n=t.dom.parentNode.appendChild(document.createElement(r?"textarea":"div"));r||(n.contentEditable="true"),n.style.cssText="position: fixed; left: -10000px; top: 10px",n.focus();let s=t.input.shiftKey&&t.input.lastKeyCode!=45;setTimeout(()=>{t.focus(),n.parentNode&&n.parentNode.removeChild(n),r?zu(t,n.value,null,s,e):zu(t,n.textContent,n.innerHTML,s,e)},50)}function zu(t,e,r,n,s){let o=uR(t,e,r,n,t.state.selection.$from);if(t.someProp("handlePaste",c=>c(t,s,o||oe.empty)))return!0;if(!o)return!1;let i=z7(o),a=i?t.state.tr.replaceSelectionWith(i,n):t.state.tr.replaceSelection(o);return t.dispatch(a.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function SR(t){let e=t.getData("text/plain")||t.getData("Text");if(e)return e;let r=t.getData("text/uri-list");return r?r.replace(/\r?\n/g," "):""}_r.paste=(t,e)=>{let r=e;if(t.composing&&!oo)return;let n=Fu?null:r.clipboardData,s=t.input.shiftKey&&t.input.lastKeyCode!=45;n&&zu(t,SR(n),n.getData("text/html"),s,r)?r.preventDefault():B7(t,r)};class NR{constructor(e,r,n){this.slice=e,this.move=r,this.node=n}}const U7=Tn?"altKey":"ctrlKey";function CR(t,e){let r=t.someProp("dragCopies",n=>!n(e));return r??!e[U7]}Er.dragstart=(t,e)=>{let r=e,n=t.input.mouseDown;if(n&&n.done(),!r.dataTransfer)return;let s=t.state.selection,o=s.empty?null:t.posAtCoords(dm(r)),i;if(!(o&&o.pos>=s.from&&o.pos<=(s instanceof me?s.to-1:s.to))){if(n&&n.mightDrag)i=me.create(t.state.doc,n.mightDrag.pos);else if(r.target&&r.target.nodeType==1){let h=t.docView.nearestDesc(r.target,!0);h&&h.node.type.spec.draggable&&h!=t.docView&&(i=me.create(t.state.doc,h.posBefore))}}let a=(i||t.state.selection).content(),{dom:c,text:d,slice:u}=i0(t,a);(!r.dataTransfer.files.length||!Wt||RT>120)&&r.dataTransfer.clearData(),r.dataTransfer.setData(Fu?"Text":"text/html",c.innerHTML),r.dataTransfer.effectAllowed="copyMove",Fu||r.dataTransfer.setData("text/plain",d),t.dragging=new NR(u,CR(t,r),i)},Er.dragend=t=>{let e=t.dragging;window.setTimeout(()=>{t.dragging==e&&(t.dragging=null)},50)},_r.dragover=_r.dragenter=(t,e)=>e.preventDefault(),_r.drop=(t,e)=>{try{V7(t,e,t.dragging)}finally{t.dragging=null}};function V7(t,e,r){if(!e.dataTransfer)return;let n=t.posAtCoords(dm(e));if(!n)return;let s=t.state.doc.resolve(n.pos),o=r&&r.slice;o?t.someProp("transformPasted",p=>{o=p(o,t,!1)}):o=uR(t,SR(e.dataTransfer),Fu?null:e.dataTransfer.getData("text/html"),!1,s);let i=!!(r&&CR(t,e));if(t.someProp("handleDrop",p=>p(t,e,o||oe.empty,i))){e.preventDefault();return}if(!o)return;e.preventDefault();let a=o?pT(t.state.doc,s.pos,o):s.pos;a==null&&(a=s.pos);let c=t.state.tr;if(i){let{node:p}=r;p?p.replace(c):c.deleteSelection()}let d=c.mapping.map(a),u=o.openStart==0&&o.openEnd==0&&o.content.childCount==1,h=c.doc;if(u?c.replaceRangeWith(d,d,o.content.firstChild):c.replaceRange(d,d,o),c.doc.eq(h))return;let f=c.doc.resolve(d);if(u&&me.isSelectable(o.content.firstChild)&&f.nodeAfter&&f.nodeAfter.sameMarkup(o.content.firstChild))c.setSelection(new me(f));else{let p=c.mapping.map(a);c.mapping.maps[c.mapping.maps.length-1].forEach((g,v,y,x)=>p=x),c.setSelection(n0(t,f,c.doc.resolve(p)))}t.focus(),t.dispatch(c.setMeta("uiEvent","drop"))}Er.focus=t=>{t.input.lastFocus=Date.now(),t.focused||(t.domObserver.stop(),t.dom.classList.add("ProseMirror-focused"),t.domObserver.start(),t.focused=!0,setTimeout(()=>{t.docView&&t.hasFocus()&&!t.domObserver.currentSelection.eq(t.domSelectionRange())&&ao(t)},20))},Er.blur=(t,e)=>{let r=e;t.focused&&(t.domObserver.stop(),t.dom.classList.remove("ProseMirror-focused"),t.domObserver.start(),r.relatedTarget&&t.dom.contains(r.relatedTarget)&&t.domObserver.currentSelection.clear(),t.focused=!1)},Er.beforeinput=(t,e)=>{if(Wt&&oo&&e.inputType=="deleteContentBackward"){t.domObserver.flushSoon();let{domChangeCount:n}=t.input;setTimeout(()=>{if(t.input.domChangeCount!=n||(t.dom.blur(),t.focus(),t.someProp("handleKeyDown",o=>o(t,xa(8,"Backspace")))))return;let{$cursor:s}=t.state.selection;s&&s.pos>0&&t.dispatch(t.state.tr.delete(s.pos-1,s.pos).scrollIntoView())},50)}};for(let t in _r)Er[t]=_r[t];function Bu(t,e){if(t==e)return!0;for(let r in t)if(t[r]!==e[r])return!1;for(let r in e)if(!(r in t))return!1;return!0}class hm{constructor(e,r){this.toDOM=e,this.spec=r||Sa,this.side=this.spec.side||0}map(e,r,n,s){let{pos:o,deleted:i}=e.mapResult(r.from+s,this.side<0?-1:1);return i?null:new cn(o-n,o-n,this)}valid(){return!0}eq(e){return this==e||e instanceof hm&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&Bu(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class ci{constructor(e,r){this.attrs=e,this.spec=r||Sa}map(e,r,n,s){let o=e.map(r.from+s,this.spec.inclusiveStart?-1:1)-n,i=e.map(r.to+s,this.spec.inclusiveEnd?1:-1)-n;return o>=i?null:new cn(o,i,this)}valid(e,r){return r.from=e&&(!o||o(a.spec))&&n.push(a.copy(a.from+s,a.to+s))}for(let i=0;ie){let a=this.children[i]+1;this.children[i+2].findInner(e-a,r-a,n,s+a,o)}}map(e,r,n){return this==pr||e.maps.length==0?this:this.mapInner(e,r,0,0,n||Sa)}mapInner(e,r,n,s,o){let i;for(let a=0;a{let d=c+n,u;if(u=ER(r,a,d)){for(s||(s=this.children.slice());oa&&h.to=e){this.children[a]==e&&(n=this.children[a+2]);break}let o=e+1,i=o+r.content.size;for(let a=0;ao&&c.type instanceof ci){let d=Math.max(o,c.from)-o,u=Math.min(i,c.to)-o;ds.map(e,r,Sa));return di.from(n)}forChild(e,r){if(r.isLeaf)return St.empty;let n=[];for(let s=0;sr instanceof St)?e:e.reduce((r,n)=>r.concat(n instanceof St?n:n.members),[]))}}forEachSet(e){for(let r=0;r{let y=v-g-(p-f);for(let x=0;xw+u-h)continue;let b=a[x]+u-h;p>=b?a[x+1]=f<=b?-2:-1:f>=u&&y&&(a[x]+=y,a[x+1]+=y)}h+=y}),u=r.maps[d].map(u,-1)}let c=!1;for(let d=0;d=n.content.size){c=!0;continue}let f=r.map(t[d+1]+o,-1),p=f-s,{index:g,offset:v}=n.content.findIndex(h),y=n.maybeChild(g);if(y&&v==h&&v+y.nodeSize==p){let x=a[d+2].mapInner(r,y,u+1,t[d]+o+1,i);x!=pr?(a[d]=h,a[d+1]=p,a[d+2]=x):(a[d+1]=-2,c=!0)}else c=!0}if(c){let d=H7(a,t,e,r,s,o,i),u=fm(d,n,0,i);e=u.local;for(let h=0;hr&&i.to{let d=ER(t,a,c+r);if(d){o=!0;let u=fm(d,a,r+c+1,n);u!=pr&&s.push(c,c+a.nodeSize,u)}});let i=jR(o?_R(t):t,-r).sort(Na);for(let a=0;a0;)e++;t.splice(e,0,r)}function m0(t){let e=[];return t.someProp("decorations",r=>{let n=r(t.state);n&&n!=pr&&e.push(n)}),t.cursorWrapper&&e.push(St.create(t.state.doc,[t.cursorWrapper.deco])),di.from(e)}const q7={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},K7=Ur&&si<=11;class G7{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}set(e){this.anchorNode=e.anchorNode,this.anchorOffset=e.anchorOffset,this.focusNode=e.focusNode,this.focusOffset=e.focusOffset}clear(){this.anchorNode=this.focusNode=null}eq(e){return e.anchorNode==this.anchorNode&&e.anchorOffset==this.anchorOffset&&e.focusNode==this.focusNode&&e.focusOffset==this.focusOffset}}class Y7{constructor(e,r){this.view=e,this.handleDOMChange=r,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new G7,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(n=>{for(let s=0;ss.type=="childList"&&s.removedNodes.length||s.type=="characterData"&&s.oldValue.length>s.target.nodeValue.length)?this.flushSoon():ir&&e.composing&&n.some(s=>s.type=="childList"&&s.target.nodeName=="TR")?(e.input.badSafariComposition=!0,this.flushSoon()):this.flush()}),K7&&(this.onCharData=n=>{this.queue.push({target:n.target,type:"characterData",oldValue:n.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this)}flushSoon(){this.flushingSoon<0&&(this.flushingSoon=window.setTimeout(()=>{this.flushingSoon=-1,this.flush()},20))}forceFlush(){this.flushingSoon>-1&&(window.clearTimeout(this.flushingSoon),this.flushingSoon=-1,this.flush())}start(){this.observer&&(this.observer.takeRecords(),this.observer.observe(this.view.dom,q7)),this.onCharData&&this.view.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.connectSelection()}stop(){if(this.observer){let e=this.observer.takeRecords();if(e.length){for(let r=0;rthis.flush(),20)}this.observer.disconnect()}this.onCharData&&this.view.dom.removeEventListener("DOMCharacterDataModified",this.onCharData),this.disconnectSelection()}connectSelection(){this.view.dom.ownerDocument.addEventListener("selectionchange",this.onSelectionChange)}disconnectSelection(){this.view.dom.ownerDocument.removeEventListener("selectionchange",this.onSelectionChange)}suppressSelectionUpdates(){this.suppressingSelectionUpdates=!0,setTimeout(()=>this.suppressingSelectionUpdates=!1,50)}onSelectionChange(){if(nR(this.view)){if(this.suppressingSelectionUpdates)return ao(this.view);if(Ur&&si<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&ya(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset))return this.flushSoon()}this.flush()}}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(e){if(!e.focusNode)return!0;let r=new Set,n;for(let o=e.focusNode;o;o=dc(o))r.add(o);for(let o=e.anchorNode;o;o=dc(o))if(r.has(o)){n=o;break}let s=n&&this.view.docView.nearestDesc(n);if(s&&s.ignoreMutation({type:"selection",target:n.nodeType==3?n.parentNode:n}))return this.setCurSelection(),!0}pendingRecords(){if(this.observer)for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}flush(){let{view:e}=this;if(!e.docView||this.flushingSoon>-1)return;let r=this.pendingRecords();r.length&&(this.queue=[]);let n=e.domSelectionRange(),s=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(n)&&nR(e)&&!this.ignoreSelectionChange(n),o=-1,i=-1,a=!1,c=[];if(e.editable)for(let u=0;uh.nodeName=="BR");if(u.length==2){let[h,f]=u;h.parentNode&&h.parentNode.parentNode==f.parentNode?f.remove():h.remove()}else{let{focusNode:h}=this.currentSelection;for(let f of u){let p=f.parentNode;p&&p.nodeName=="LI"&&(!h||X7(e,h)!=p)&&f.remove()}}}else if((Wt||ir)&&c.some(u=>u.nodeName=="BR")&&(e.input.lastKeyCode==8||e.input.lastKeyCode==46)){for(let u of c)if(u.nodeName=="BR"&&u.parentNode){let h=u.nextSibling;h&&h.nodeType==1&&h.contentEditable=="false"&&u.parentNode.removeChild(u)}}let d=null;o<0&&s&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)-1||s)&&(o>-1&&(e.docView.markDirty(o,i),J7(e)),e.input.badSafariComposition&&(e.input.badSafariComposition=!1,Z7(e,c)),this.handleDOMChange(o,i,a,c),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(n)||ao(e),this.currentSelection.set(n))}registerMutation(e,r){if(r.indexOf(e.target)>-1)return null;let n=this.view.docView.nearestDesc(e.target);if(e.type=="attributes"&&(n==this.view.docView||e.attributeName=="contenteditable"||e.attributeName=="style"&&!e.oldValue&&!e.target.getAttribute("style"))||!n||n.ignoreMutation(e))return null;if(e.type=="childList"){for(let u=0;us;y--){let x=n.childNodes[y-1],w=x.pmViewDesc;if(x.nodeName=="BR"&&!w){o=y;break}if(!w||w.size)break}let h=t.state.doc,f=t.someProp("domParser")||Zo.fromSchema(t.state.schema),p=h.resolve(i),g=null,v=f.parse(n,{topNode:p.parent,topMatch:p.parent.contentMatchAt(p.index()),topOpen:!0,from:s,to:o,preserveWhitespace:p.parent.type.whitespace=="pre"?"full":!0,findPositions:d,ruleFromNode:tq,context:p});if(d&&d[0].pos!=null){let y=d[0].pos,x=d[1]&&d[1].pos;x==null&&(x=y),g={anchor:y+i,head:x+i}}return{doc:v,sel:g,from:i,to:a}}function tq(t){let e=t.pmViewDesc;if(e)return e.parseRule();if(t.nodeName=="BR"&&t.parentNode){if(ir&&/^(ul|ol)$/i.test(t.parentNode.nodeName)){let r=document.createElement("div");return r.appendChild(document.createElement("li")),{skip:r}}else if(t.parentNode.lastChild==t||ir&&/^(tr|table)$/i.test(t.parentNode.nodeName))return{ignore:!0}}else if(t.nodeName=="IMG"&&t.getAttribute("mark-placeholder"))return{ignore:!0};return null}const rq=/^(a|abbr|acronym|b|bd[io]|big|br|button|cite|code|data(list)?|del|dfn|em|i|img|ins|kbd|label|map|mark|meter|output|q|ruby|s|samp|small|span|strong|su[bp]|time|u|tt|var)$/i;function nq(t,e,r,n,s){let o=t.input.compositionPendingChanges||(t.composing?t.input.compositionID:0);if(t.input.compositionPendingChanges=0,e<0){let N=t.input.lastSelectionTime>Date.now()-50?t.input.lastSelectionOrigin:null,E=t0(t,N);if(E&&!t.state.selection.eq(E)){if(Wt&&oo&&t.input.lastKeyCode===13&&Date.now()-100_(t,xa(13,"Enter"))))return;let j=t.state.tr.setSelection(E);N=="pointer"?j.setMeta("pointer",!0):N=="key"&&j.scrollIntoView(),o&&j.setMeta("composition",o),t.dispatch(j)}return}let i=t.state.doc.resolve(e),a=i.sharedDepth(r);e=i.before(a+1),r=t.state.doc.resolve(r).after(a+1);let c=t.state.selection,d=eq(t,e,r),u=t.state.doc,h=u.slice(d.from,d.to),f,p;t.input.lastKeyCode===8&&Date.now()-100Date.now()-225||oo)&&s.some(N=>N.nodeType==1&&!rq.test(N.nodeName))&&(!g||g.endA>=g.endB)&&t.someProp("handleKeyDown",N=>N(t,xa(13,"Enter")))){t.input.lastIOSEnter=0;return}if(!g)if(n&&c instanceof Ce&&!c.empty&&c.$head.sameParent(c.$anchor)&&!t.composing&&!(d.sel&&d.sel.anchor!=d.sel.head))g={start:c.from,endA:c.to,endB:c.to};else{if(d.sel){let N=PR(t,t.state.doc,d.sel);if(N&&!N.eq(t.state.selection)){let E=t.state.tr.setSelection(N);o&&E.setMeta("composition",o),t.dispatch(E)}}return}t.state.selection.fromt.state.selection.from&&g.start<=t.state.selection.from+2&&t.state.selection.from>=d.from?g.start=t.state.selection.from:g.endA=t.state.selection.to-2&&t.state.selection.to<=d.to&&(g.endB+=t.state.selection.to-g.endA,g.endA=t.state.selection.to)),Ur&&si<=11&&g.endB==g.start+1&&g.endA==g.start&&g.start>d.from&&d.doc.textBetween(g.start-d.from-1,g.start-d.from+1)=="  "&&(g.start--,g.endA--,g.endB--);let v=d.doc.resolveNoCache(g.start-d.from),y=d.doc.resolveNoCache(g.endB-d.from),x=u.resolve(g.start),w=v.sameParent(y)&&v.parent.inlineContent&&x.end()>=g.endA;if((uc&&t.input.lastIOSEnter>Date.now()-225&&(!w||s.some(N=>N.nodeName=="DIV"||N.nodeName=="P"))||!w&&v.posN(t,xa(13,"Enter")))){t.input.lastIOSEnter=0;return}if(t.state.selection.anchor>g.start&&oq(u,g.start,g.endA,v,y)&&t.someProp("handleKeyDown",N=>N(t,xa(8,"Backspace")))){oo&&Wt&&t.domObserver.suppressSelectionUpdates();return}Wt&&g.endB==g.start&&(t.input.lastChromeDelete=Date.now()),oo&&!w&&v.start()!=y.start()&&y.parentOffset==0&&v.depth==y.depth&&d.sel&&d.sel.anchor==d.sel.head&&d.sel.head==g.endA&&(g.endB-=2,y=d.doc.resolveNoCache(g.endB-d.from),setTimeout(()=>{t.someProp("handleKeyDown",function(N){return N(t,xa(13,"Enter"))})},20));let b=g.start,k=g.endA,S=N=>{let E=N||t.state.tr.replace(b,k,d.doc.slice(g.start-d.from,g.endB-d.from));if(d.sel){let j=PR(t,E.doc,d.sel);j&&!(Wt&&t.composing&&j.empty&&(g.start!=g.endB||t.input.lastChromeDeleteao(t),20));let N=S(t.state.tr.delete(b,k)),E=u.resolve(g.start).marksAcross(u.resolve(g.endA));E&&N.ensureMarks(E),t.dispatch(N)}else if(g.endA==g.endB&&(C=sq(v.parent.content.cut(v.parentOffset,y.parentOffset),x.parent.content.cut(x.parentOffset,g.endA-x.start())))){let N=S(t.state.tr);C.type=="add"?N.addMark(b,k,C.mark):N.removeMark(b,k,C.mark),t.dispatch(N)}else if(v.parent.child(v.index()).isText&&v.index()==y.index()-(y.textOffset?0:1)){let N=v.parent.textBetween(v.parentOffset,y.parentOffset),E=()=>S(t.state.tr.insertText(N,b,k));t.someProp("handleTextInput",j=>j(t,b,k,N,E))||t.dispatch(E())}else t.dispatch(S());else t.dispatch(S())}function PR(t,e,r){return Math.max(r.anchor,r.head)>e.content.size?null:n0(t,e.resolve(r.anchor),e.resolve(r.head))}function sq(t,e){let r=t.firstChild.marks,n=e.firstChild.marks,s=r,o=n,i,a,c;for(let u=0;uu.mark(a.addToSet(u.marks));else if(s.length==0&&o.length==1)a=o[0],i="remove",c=u=>u.mark(a.removeFromSet(u.marks));else return null;let d=[];for(let u=0;ur||g0(i,!0,!1)0&&(e||t.indexAfter(n)==t.node(n).childCount);)n--,s++,e=!1;if(r){let o=t.node(n).maybeChild(t.indexAfter(n));for(;o&&!o.isLeaf;)o=o.firstChild,s++}return s}function iq(t,e,r,n,s){let o=t.findDiffStart(e,r);if(o==null)return null;let{a:i,b:a}=t.findDiffEnd(e,r+t.size,r+e.size);if(s=="end"){let c=Math.max(0,o-Math.min(i,a));n-=i+c-o}if(i=i?o-n:0;o-=c,o&&o=a?o-n:0;o-=c,o&&o=56320&&e<=57343&&r>=55296&&r<=56319}class IR{constructor(e,r){this._root=null,this.focused=!1,this.trackWrites=null,this.mounted=!1,this.markCursor=null,this.cursorWrapper=null,this.lastSelectedViewDesc=void 0,this.input=new k7,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=r,this.state=r.state,this.directPlugins=r.plugins||[],this.directPlugins.forEach(zR),this.dispatch=this.dispatch.bind(this),this.dom=e&&e.mount||document.createElement("div"),e&&(e.appendChild?e.appendChild(this.dom):typeof e=="function"?e(this.dom):e.mount&&(this.mounted=!0)),this.editable=$R(this),LR(this),this.nodeViews=FR(this),this.docView=HT(this.state.doc,DR(this),m0(this),this.dom,this),this.domObserver=new Y7(this,(n,s,o,i)=>nq(this,n,s,o,i)),this.domObserver.start(),S7(this),this.updatePluginViews()}get composing(){return this.input.composing}get props(){if(this._props.state!=this.state){let e=this._props;this._props={};for(let r in e)this._props[r]=e[r];this._props.state=this.state}return this._props}update(e){e.handleDOMEvents!=this._props.handleDOMEvents&&c0(this);let r=this._props;this._props=e,e.plugins&&(e.plugins.forEach(zR),this.directPlugins=e.plugins),this.updateStateInner(e.state,r)}setProps(e){let r={};for(let n in this._props)r[n]=this._props[n];r.state=this.state;for(let n in e)r[n]=e[n];this.update(r)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,r){var n;let s=this.state,o=!1,i=!1;e.storedMarks&&this.composing&&(kR(this),i=!0),this.state=e;let a=s.plugins!=e.plugins||this._props.plugins!=r.plugins;if(a||this._props.plugins!=r.plugins||this._props.nodeViews!=r.nodeViews){let p=FR(this);lq(p,this.nodeViews)&&(this.nodeViews=p,o=!0)}(a||r.handleDOMEvents!=this._props.handleDOMEvents)&&c0(this),this.editable=$R(this),LR(this);let c=m0(this),d=DR(this),u=s.plugins!=e.plugins&&!s.doc.eq(e.doc)?"reset":e.scrollToSelection>s.scrollToSelection?"to selection":"preserve",h=o||!this.docView.matchesNode(e.doc,d,c);(h||!e.selection.eq(s.selection))&&(i=!0);let f=u=="preserve"&&i&&this.dom.style.overflowAnchor==null&&L9(this);if(i){this.domObserver.stop();let p=h&&(Ur||Wt)&&!this.composing&&!s.selection.empty&&!e.selection.empty&&aq(s.selection,e.selection);if(h){let g=Wt?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=L7(this)),(o||!this.docView.update(e.doc,d,c,this))&&(this.docView.updateOuterDeco(d),this.docView.destroy(),this.docView=HT(e.doc,d,c,this.dom,this)),g&&(!this.trackWrites||!this.dom.contains(this.trackWrites))&&(p=!0)}p||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&a7(this))?ao(this,p):(tR(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(s),!((n=this.dragging)===null||n===void 0)&&n.node&&!s.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,s),u=="reset"?this.dom.scrollTop=0:u=="to selection"?this.scrollToSelection():f&&$9(f)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(!(!e||!this.dom.contains(e.nodeType==1?e:e.parentNode))){if(!this.someProp("handleScrollToSelection",r=>r(this)))if(this.state.selection instanceof me){let r=this.docView.domAfterPos(this.state.selection.from);r.nodeType==1&&OT(this,r.getBoundingClientRect(),e)}else OT(this,this.coordsAtPos(this.state.selection.head,1),e)}}destroyPluginViews(){let e;for(;e=this.pluginViews.pop();)e.destroy&&e.destroy()}updatePluginViews(e){if(!e||e.plugins!=this.state.plugins||this.directPlugins!=this.prevDirectPlugins){this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let r=0;r0&&this.state.doc.nodeAt(o))==n.node&&(s=o)}this.dragging=new NR(e.slice,e.move,s<0?void 0:me.create(this.state.doc,s))}someProp(e,r){let n=this._props&&this._props[e],s;if(n!=null&&(s=r?r(n):n))return s;for(let i=0;ir.ownerDocument.getSelection()),this._root=r}return e||document}updateRoot(){this._root=null}posAtCoords(e){return W9(this,e)}coordsAtPos(e,r=1){return $T(this,e,r)}domAtPos(e,r=0){return this.docView.domFromPos(e,r)}nodeDOM(e){let r=this.docView.descAt(e);return r?r.nodeDOM:null}posAtDOM(e,r,n=-1){let s=this.docView.posFromDOM(e,r,n);if(s==null)throw new RangeError("DOM position not inside the editor");return s}endOfTextblock(e,r){return Y9(this,r||this.state,e)}pasteHTML(e,r){return zu(this,"",e,!1,r||new ClipboardEvent("paste"))}pasteText(e,r){return zu(this,e,null,!0,r||new ClipboardEvent("paste"))}serializeForClipboard(e){return i0(this,e)}destroy(){this.docView&&(N7(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],m0(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,E9())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return j7(this,e)}domSelectionRange(){let e=this.domSelection();return e?ir&&this.root.nodeType===11&&O9(this.dom.ownerDocument)==this.dom&&Q7(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}IR.prototype.dispatch=function(t){let e=this._props.dispatchTransaction;e?e.call(this,t):this.updateState(this.state.apply(t))};function DR(t){let e=Object.create(null);return e.class="ProseMirror",e.contenteditable=String(t.editable),t.someProp("attributes",r=>{if(typeof r=="function"&&(r=r(t.state)),r)for(let n in r)n=="class"?e.class+=" "+r[n]:n=="style"?e.style=(e.style?e.style+";":"")+r[n]:!e[n]&&n!="contenteditable"&&n!="nodeName"&&(e[n]=String(r[n]))}),e.translate||(e.translate="no"),[cn.node(0,t.state.doc.content.size,e)]}function LR(t){if(t.markCursor){let e=document.createElement("img");e.className="ProseMirror-separator",e.setAttribute("mark-placeholder","true"),e.setAttribute("alt",""),t.cursorWrapper={dom:e,deco:cn.widget(t.state.selection.from,e,{raw:!0,marks:t.markCursor})}}else t.cursorWrapper=null}function $R(t){return!t.someProp("editable",e=>e(t.state)===!1)}function aq(t,e){let r=Math.min(t.$anchor.sharedDepth(t.head),e.$anchor.sharedDepth(e.head));return t.$anchor.start(r)!=e.$anchor.start(r)}function FR(t){let e=Object.create(null);function r(n){for(let s in n)Object.prototype.hasOwnProperty.call(e,s)||(e[s]=n[s])}return t.someProp("nodeViews",r),t.someProp("markViews",r),e}function lq(t,e){let r=0,n=0;for(let s in t){if(t[s]!=e[s])return!0;r++}for(let s in e)n++;return r!=n}function zR(t){if(t.spec.state||t.spec.filterTransaction||t.spec.appendTransaction)throw new RangeError("Plugins passed directly to the view must not have a state component")}for(var ui={8:"Backspace",9:"Tab",10:"Enter",12:"NumLock",13:"Enter",16:"Shift",17:"Control",18:"Alt",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",44:"PrintScreen",45:"Insert",46:"Delete",59:";",61:"=",91:"Meta",92:"Meta",106:"*",107:"+",108:",",109:"-",110:".",111:"/",144:"NumLock",145:"ScrollLock",160:"Shift",161:"Shift",162:"Control",163:"Control",164:"Alt",165:"Alt",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'"},pm={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},cq=typeof navigator<"u"&&/Mac/.test(navigator.platform),dq=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),ar=0;ar<10;ar++)ui[48+ar]=ui[96+ar]=String(ar);for(var ar=1;ar<=24;ar++)ui[ar+111]="F"+ar;for(var ar=65;ar<=90;ar++)ui[ar]=String.fromCharCode(ar+32),pm[ar]=String.fromCharCode(ar);for(var v0 in ui)pm.hasOwnProperty(v0)||(pm[v0]=ui[v0]);function uq(t){var e=cq&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||dq&&t.shiftKey&&t.key&&t.key.length==1||t.key=="Unidentified",r=!e&&t.key||(t.shiftKey?pm:ui)[t.keyCode]||t.key||"Unidentified";return r=="Esc"&&(r="Escape"),r=="Del"&&(r="Delete"),r=="Left"&&(r="ArrowLeft"),r=="Up"&&(r="ArrowUp"),r=="Right"&&(r="ArrowRight"),r=="Down"&&(r="ArrowDown"),r}const hq=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),fq=typeof navigator<"u"&&/Win/.test(navigator.platform);function pq(t){let e=t.split(/-(?!$)/),r=e[e.length-1];r=="Space"&&(r=" ");let n,s,o,i;for(let a=0;at.selection.empty?!1:(e&&e(t.tr.deleteSelection().scrollIntoView()),!0);function UR(t,e){let{$cursor:r}=t.selection;return!r||(e?!e.endOfTextblock("backward",t):r.parentOffset>0)?null:r}const yq=(t,e,r)=>{let n=UR(t,r);if(!n)return!1;let s=x0(n);if(!s){let i=n.blockRange(),a=i&&sc(i);return a==null?!1:(e&&e(t.tr.lift(i,a).scrollIntoView()),!0)}let o=s.nodeBefore;if(qR(t,s,e,-1))return!0;if(n.parent.content.size==0&&(gc(o,"end")||me.isSelectable(o)))for(let i=n.depth;;i--){let a=nm(t.doc,n.before(i),n.after(i),oe.empty);if(a&&a.slice.size1)break}return o.isAtom&&s.depth==n.depth-1?(e&&e(t.tr.delete(s.pos-o.nodeSize,s.pos).scrollIntoView()),!0):!1},xq=(t,e,r)=>{let n=UR(t,r);if(!n)return!1;let s=x0(n);return s?VR(t,s,e):!1},wq=(t,e,r)=>{let n=WR(t,r);if(!n)return!1;let s=w0(n);return s?VR(t,s,e):!1};function VR(t,e,r){let n=e.nodeBefore,s=n,o=e.pos-1;for(;!s.isTextblock;o--){if(s.type.spec.isolating)return!1;let u=s.lastChild;if(!u)return!1;s=u}let i=e.nodeAfter,a=i,c=e.pos+1;for(;!a.isTextblock;c++){if(a.type.spec.isolating)return!1;let u=a.firstChild;if(!u)return!1;a=u}let d=nm(t.doc,o,c,oe.empty);if(!d||d.from!=o||d instanceof Ut&&d.slice.size>=c-o)return!1;if(r){let u=t.tr.step(d);u.setSelection(Ce.create(u.doc,o)),r(u.scrollIntoView())}return!0}function gc(t,e,r=!1){for(let n=t;n;n=e=="start"?n.firstChild:n.lastChild){if(n.isTextblock)return!0;if(r&&n.childCount!=1)return!1}return!1}const bq=(t,e,r)=>{let{$head:n,empty:s}=t.selection,o=n;if(!s)return!1;if(n.parent.isTextblock){if(r?!r.endOfTextblock("backward",t):n.parentOffset>0)return!1;o=x0(n)}let i=o&&o.nodeBefore;return!i||!me.isSelectable(i)?!1:(e&&e(t.tr.setSelection(me.create(t.doc,o.pos-i.nodeSize)).scrollIntoView()),!0)};function x0(t){if(!t.parent.type.spec.isolating)for(let e=t.depth-1;e>=0;e--){if(t.index(e)>0)return t.doc.resolve(t.before(e+1));if(t.node(e).type.spec.isolating)break}return null}function WR(t,e){let{$cursor:r}=t.selection;return!r||(e?!e.endOfTextblock("forward",t):r.parentOffset{let n=WR(t,r);if(!n)return!1;let s=w0(n);if(!s)return!1;let o=s.nodeAfter;if(qR(t,s,e,1))return!0;if(n.parent.content.size==0&&(gc(o,"start")||me.isSelectable(o))){let i=nm(t.doc,n.before(),n.after(),oe.empty);if(i&&i.slice.size{let{$head:n,empty:s}=t.selection,o=n;if(!s)return!1;if(n.parent.isTextblock){if(r?!r.endOfTextblock("forward",t):n.parentOffset=0;e--){let r=t.node(e);if(t.index(e)+1{let r=t.selection,n=r instanceof me,s;if(n){if(r.node.isTextblock||!ri(t.doc,r.from))return!1;s=r.from}else if(s=rm(t.doc,r.from,-1),s==null)return!1;if(e){let o=t.tr.join(s);n&&o.setSelection(me.create(o.doc,s-t.doc.resolve(s).nodeBefore.nodeSize)),e(o.scrollIntoView())}return!0},Cq=(t,e)=>{let r=t.selection,n;if(r instanceof me){if(r.node.isTextblock||!ri(t.doc,r.to))return!1;n=r.to}else if(n=rm(t.doc,r.to,1),n==null)return!1;return e&&e(t.tr.join(n).scrollIntoView()),!0},jq=(t,e)=>{let{$from:r,$to:n}=t.selection,s=r.blockRange(n),o=s&&sc(s);return o==null?!1:(e&&e(t.tr.lift(s,o).scrollIntoView()),!0)},Eq=(t,e)=>{let{$head:r,$anchor:n}=t.selection;return!r.parent.type.spec.code||!r.sameParent(n)?!1:(e&&e(t.tr.insertText(` `).scrollIntoView()),!0)};function HR(t){for(let e=0;e{let{$head:r,$anchor:n}=t.selection;if(!r.parent.type.spec.code||!r.sameParent(n))return!1;let s=r.node(-1),o=r.indexAfter(-1),i=HR(s.contentMatchAt(o));if(!i||!s.canReplaceWith(o,o,i))return!1;if(e){let a=r.after(),c=t.tr.replaceWith(a,a,i.createAndFill());c.setSelection(_e.near(c.doc.resolve(a),1)),e(c.scrollIntoView())}return!0},Tq=(t,e)=>{let r=t.selection,{$from:n,$to:s}=r;if(r instanceof jn||n.parent.inlineContent||s.parent.inlineContent)return!1;let o=HR(s.parent.contentMatchAt(s.indexAfter()));if(!o||!o.isTextblock)return!1;if(e){let i=(!n.parentOffset&&s.index(){let{$cursor:r}=t.selection;if(!r||r.parent.content.size)return!1;if(r.depth>1&&r.after()!=r.end(-1)){let o=r.before();if(oc(t.doc,o))return e&&e(t.tr.split(o).scrollIntoView()),!0}let n=r.blockRange(),s=n&&sc(n);return s==null?!1:(e&&e(t.tr.lift(n,s).scrollIntoView()),!0)},Mq=(t,e)=>{let{$from:r,to:n}=t.selection,s,o=r.sharedDepth(n);return o==0?!1:(s=r.before(o),e&&e(t.tr.setSelection(me.create(t.doc,s))),!0)};function Oq(t,e,r){let n=e.nodeBefore,s=e.nodeAfter,o=e.index();return!n||!s||!n.type.compatibleContent(s.type)?!1:!n.content.size&&e.parent.canReplace(o-1,o)?(r&&r(t.tr.delete(e.pos-n.nodeSize,e.pos).scrollIntoView()),!0):!e.parent.canReplace(o,o+1)||!(s.isTextblock||ri(t.doc,e.pos))?!1:(r&&r(t.tr.join(e.pos).scrollIntoView()),!0)}function qR(t,e,r,n){let s=e.nodeBefore,o=e.nodeAfter,i,a,c=s.type.spec.isolating||o.type.spec.isolating;if(!c&&Oq(t,e,r))return!0;let d=!c&&e.parent.canReplace(e.index(),e.index()+1);if(d&&(i=(a=s.contentMatchAt(s.childCount)).findWrapping(o.type))&&a.matchType(i[0]||o.type).validEnd){if(r){let p=e.pos+o.nodeSize,g=Y.empty;for(let x=i.length-1;x>=0;x--)g=Y.from(i[x].create(null,g));g=Y.from(s.copy(g));let v=t.tr.step(new Vt(e.pos-1,p,e.pos,p,new oe(g,1,0),i.length,!0)),y=v.doc.resolve(p+2*i.length);y.nodeAfter&&y.nodeAfter.type==s.type&&ri(v.doc,y.pos)&&v.join(y.pos),r(v.scrollIntoView())}return!0}let u=o.type.spec.isolating||n>0&&c?null:_e.findFrom(e,1),h=u&&u.$from.blockRange(u.$to),f=h&&sc(h);if(f!=null&&f>=e.depth)return r&&r(t.tr.lift(h,f).scrollIntoView()),!0;if(d&&gc(o,"start",!0)&&gc(s,"end")){let p=s,g=[];for(;g.push(p),!p.isTextblock;)p=p.lastChild;let v=o,y=1;for(;!v.isTextblock;v=v.firstChild)y++;if(p.canReplace(p.childCount,p.childCount,v.content)){if(r){let x=Y.empty;for(let b=g.length-1;b>=0;b--)x=Y.from(g[b].copy(x));let w=t.tr.step(new Vt(e.pos-g.length,e.pos+o.nodeSize,e.pos+y,e.pos+o.nodeSize-y,new oe(x,g.length,0),0,!0));r(w.scrollIntoView())}return!0}}return!1}function KR(t){return function(e,r){let n=e.selection,s=t<0?n.$from:n.$to,o=s.depth;for(;s.node(o).isInline;){if(!o)return!1;o--}return s.node(o).isTextblock?(r&&r(e.tr.setSelection(Ce.create(e.doc,t<0?s.start(o):s.end(o)))),!0):!1}}const Pq=KR(-1),Aq=KR(1);function Iq(t,e=null){return function(r,n){let{$from:s,$to:o}=r.selection,i=s.blockRange(o),a=i&&zw(i,t,e);return a?(n&&n(r.tr.wrap(i,a).scrollIntoView()),!0):!1}}function GR(t,e=null){return function(r,n){let s=!1;for(let o=0;o{if(s)return!1;if(!(!c.isTextblock||c.hasMarkup(t,e)))if(c.type==t)s=!0;else{let u=r.doc.resolve(d),h=u.index();s=u.parent.canReplaceWith(h,h+1,t)}})}if(!s)return!1;if(n){let o=r.tr;for(let i=0;i=2&&e.$from.node(e.depth-1).type.compatibleContent(r)&&e.startIndex==0){if(e.$from.index(e.depth-1)==0)return!1;let c=i.resolve(e.start-2);o=new Jp(c,c,e.depth),e.endIndex=0;u--)o=Y.from(r[u].type.create(r[u].attrs,o));t.step(new Vt(e.start-(n?2:0),e.end,e.start,e.end,new oe(o,0,0),r.length,!0));let i=0;for(let u=0;ui.childCount>0&&i.firstChild.type==t);return o?r?n.node(o.depth-1).type==t?zq(e,r,t,o):Bq(e,r,o):!0:!1}}function zq(t,e,r,n){let s=t.tr,o=n.end,i=n.$to.end(n.depth);ov;g--)p-=s.child(g).nodeSize,n.delete(p-1,p+1);let o=n.doc.resolve(r.start),i=o.nodeAfter;if(n.mapping.map(r.end)!=r.start+o.nodeAfter.nodeSize)return!1;let a=r.startIndex==0,c=r.endIndex==s.childCount,d=o.node(-1),u=o.index(-1);if(!d.canReplace(u+(a?0:1),u+1,i.content.append(c?Y.empty:Y.from(s))))return!1;let h=o.pos,f=h+i.nodeSize;return n.step(new Vt(h-(a?1:0),f+(c?1:0),h+1,f-1,new oe((a?Y.empty:Y.from(s.copy(Y.empty))).append(c?Y.empty:Y.from(s.copy(Y.empty))),a?0:1,c?0:1),a?0:1)),e(n.scrollIntoView()),!0}function Uq(t){return function(e,r){let{$from:n,$to:s}=e.selection,o=n.blockRange(s,d=>d.childCount>0&&d.firstChild.type==t);if(!o)return!1;let i=o.startIndex;if(i==0)return!1;let a=o.parent,c=a.child(i-1);if(c.type!=t)return!1;if(r){let d=c.lastChild&&c.lastChild.type==a.type,u=Y.from(d?t.create():null),h=new oe(Y.from(t.create(null,Y.from(a.type.create(null,u)))),d?3:1,0),f=o.start,p=o.end;r(e.tr.step(new Vt(f-(d?3:1),p,f,p,h,1,!0)).scrollIntoView())}return!0}}function mm(t){const{state:e,transaction:r}=t;let{selection:n}=r,{doc:s}=r,{storedMarks:o}=r;return{...e,apply:e.apply.bind(e),applyTransaction:e.applyTransaction.bind(e),plugins:e.plugins,schema:e.schema,reconfigure:e.reconfigure.bind(e),toJSON:e.toJSON.bind(e),get storedMarks(){return o},get selection(){return n},get doc(){return s},get tr(){return n=r.selection,s=r.doc,o=r.storedMarks,r}}}class gm{constructor(e){this.editor=e.editor,this.rawCommands=this.editor.extensionManager.commands,this.customState=e.state}get hasCustomState(){return!!this.customState}get state(){return this.customState||this.editor.state}get commands(){const{rawCommands:e,editor:r,state:n}=this,{view:s}=r,{tr:o}=n,i=this.buildProps(o);return Object.fromEntries(Object.entries(e).map(([a,c])=>[a,(...u)=>{const h=c(...u)(i);return!o.getMeta("preventDispatch")&&!this.hasCustomState&&s.dispatch(o),h}]))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(e,r=!0){const{rawCommands:n,editor:s,state:o}=this,{view:i}=s,a=[],c=!!e,d=e||o.tr,u=()=>(!c&&r&&!d.getMeta("preventDispatch")&&!this.hasCustomState&&i.dispatch(d),a.every(f=>f===!0)),h={...Object.fromEntries(Object.entries(n).map(([f,p])=>[f,(...v)=>{const y=this.buildProps(d,r),x=p(...v)(y);return a.push(x),h}])),run:u};return h}createCan(e){const{rawCommands:r,state:n}=this,s=!1,o=e||n.tr,i=this.buildProps(o,s);return{...Object.fromEntries(Object.entries(r).map(([c,d])=>[c,(...u)=>d(...u)({...i,dispatch:void 0})])),chain:()=>this.createChain(o,s)}}buildProps(e,r=!0){const{rawCommands:n,editor:s,state:o}=this,{view:i}=s,a={tr:e,editor:s,view:i,state:mm({state:o,transaction:e}),dispatch:r?()=>{}:void 0,chain:()=>this.createChain(e,r),can:()=>this.createCan(e),get commands(){return Object.fromEntries(Object.entries(n).map(([c,d])=>[c,(...u)=>d(...u)(a)]))}};return a}}class Vq{constructor(){this.callbacks={}}on(e,r){return this.callbacks[e]||(this.callbacks[e]=[]),this.callbacks[e].push(r),this}emit(e,...r){const n=this.callbacks[e];return n&&n.forEach(s=>s.apply(this,r)),this}off(e,r){const n=this.callbacks[e];return n&&(r?this.callbacks[e]=n.filter(s=>s!==r):delete this.callbacks[e]),this}once(e,r){const n=(...s)=>{this.off(e,n),r.apply(this,s)};return this.on(e,n)}removeAllListeners(){this.callbacks={}}}function le(t,e,r){return t.config[e]===void 0&&t.parent?le(t.parent,e,r):typeof t.config[e]=="function"?t.config[e].bind({...r,parent:t.parent?le(t.parent,e,r):null}):t.config[e]}function vm(t){const e=t.filter(s=>s.type==="extension"),r=t.filter(s=>s.type==="node"),n=t.filter(s=>s.type==="mark");return{baseExtensions:e,nodeExtensions:r,markExtensions:n}}function YR(t){const e=[],{nodeExtensions:r,markExtensions:n}=vm(t),s=[...r,...n],o={default:null,rendered:!0,renderHTML:null,parseHTML:null,keepOnSplit:!0,isRequired:!1};return t.forEach(i=>{const a={name:i.name,options:i.options,storage:i.storage,extensions:s},c=le(i,"addGlobalAttributes",a);if(!c)return;c().forEach(u=>{u.types.forEach(h=>{Object.entries(u.attributes).forEach(([f,p])=>{e.push({type:h,name:f,attribute:{...o,...p}})})})})}),s.forEach(i=>{const a={name:i.name,options:i.options,storage:i.storage},c=le(i,"addAttributes",a);if(!c)return;const d=c();Object.entries(d).forEach(([u,h])=>{const f={...o,...h};typeof(f==null?void 0:f.default)=="function"&&(f.default=f.default()),f!=null&&f.isRequired&&(f==null?void 0:f.default)===void 0&&delete f.default,e.push({type:i.name,name:u,attribute:f})})}),e}function Ht(t,e){if(typeof t=="string"){if(!e.nodes[t])throw Error(`There is no node type named '${t}'. Maybe you forgot to add the extension?`);return e.nodes[t]}return t}function mr(...t){return t.filter(e=>!!e).reduce((e,r)=>{const n={...e};return Object.entries(r).forEach(([s,o])=>{if(!n[s]){n[s]=o;return}if(s==="class"){const a=o?String(o).split(" "):[],c=n[s]?n[s].split(" "):[],d=a.filter(u=>!c.includes(u));n[s]=[...c,...d].join(" ")}else if(s==="style"){const a=o?o.split(";").map(u=>u.trim()).filter(Boolean):[],c=n[s]?n[s].split(";").map(u=>u.trim()).filter(Boolean):[],d=new Map;c.forEach(u=>{const[h,f]=u.split(":").map(p=>p.trim());d.set(h,f)}),a.forEach(u=>{const[h,f]=u.split(":").map(p=>p.trim());d.set(h,f)}),n[s]=Array.from(d.entries()).map(([u,h])=>`${u}: ${h}`).join("; ")}else n[s]=o}),n},{})}function b0(t,e){return e.filter(r=>r.type===t.type.name).filter(r=>r.attribute.rendered).map(r=>r.attribute.renderHTML?r.attribute.renderHTML(t.attrs)||{}:{[r.name]:t.attrs[r.name]}).reduce((r,n)=>mr(r,n),{})}function JR(t){return typeof t=="function"}function Re(t,e=void 0,...r){return JR(t)?e?t.bind(e)(...r):t(...r):t}function Wq(t={}){return Object.keys(t).length===0&&t.constructor===Object}function Hq(t){return typeof t!="string"?t:t.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(t):t==="true"?!0:t==="false"?!1:t}function QR(t,e){return"style"in t?t:{...t,getAttrs:r=>{const n=t.getAttrs?t.getAttrs(r):t.attrs;if(n===!1)return!1;const s=e.reduce((o,i)=>{const a=i.attribute.parseHTML?i.attribute.parseHTML(r):Hq(r.getAttribute(i.name));return a==null?o:{...o,[i.name]:a}},{});return{...n,...s}}}}function XR(t){return Object.fromEntries(Object.entries(t).filter(([e,r])=>e==="attrs"&&Wq(r)?!1:r!=null))}function qq(t,e){var r;const n=YR(t),{nodeExtensions:s,markExtensions:o}=vm(t),i=(r=s.find(d=>le(d,"topNode")))===null||r===void 0?void 0:r.name,a=Object.fromEntries(s.map(d=>{const u=n.filter(x=>x.type===d.name),h={name:d.name,options:d.options,storage:d.storage,editor:e},f=t.reduce((x,w)=>{const b=le(w,"extendNodeSchema",h);return{...x,...b?b(d):{}}},{}),p=XR({...f,content:Re(le(d,"content",h)),marks:Re(le(d,"marks",h)),group:Re(le(d,"group",h)),inline:Re(le(d,"inline",h)),atom:Re(le(d,"atom",h)),selectable:Re(le(d,"selectable",h)),draggable:Re(le(d,"draggable",h)),code:Re(le(d,"code",h)),whitespace:Re(le(d,"whitespace",h)),linebreakReplacement:Re(le(d,"linebreakReplacement",h)),defining:Re(le(d,"defining",h)),isolating:Re(le(d,"isolating",h)),attrs:Object.fromEntries(u.map(x=>{var w;return[x.name,{default:(w=x==null?void 0:x.attribute)===null||w===void 0?void 0:w.default}]}))}),g=Re(le(d,"parseHTML",h));g&&(p.parseDOM=g.map(x=>QR(x,u)));const v=le(d,"renderHTML",h);v&&(p.toDOM=x=>v({node:x,HTMLAttributes:b0(x,u)}));const y=le(d,"renderText",h);return y&&(p.toText=y),[d.name,p]})),c=Object.fromEntries(o.map(d=>{const u=n.filter(y=>y.type===d.name),h={name:d.name,options:d.options,storage:d.storage,editor:e},f=t.reduce((y,x)=>{const w=le(x,"extendMarkSchema",h);return{...y,...w?w(d):{}}},{}),p=XR({...f,inclusive:Re(le(d,"inclusive",h)),excludes:Re(le(d,"excludes",h)),group:Re(le(d,"group",h)),spanning:Re(le(d,"spanning",h)),code:Re(le(d,"code",h)),attrs:Object.fromEntries(u.map(y=>{var x;return[y.name,{default:(x=y==null?void 0:y.attribute)===null||x===void 0?void 0:x.default}]}))}),g=Re(le(d,"parseHTML",h));g&&(p.parseDOM=g.map(y=>QR(y,u)));const v=le(d,"renderHTML",h);return v&&(p.toDOM=y=>v({mark:y,HTMLAttributes:b0(y,u)})),[d.name,p]}));return new G2({topNode:i,nodes:a,marks:c})}function k0(t,e){return e.nodes[t]||e.marks[t]||null}function ZR(t,e){return Array.isArray(e)?e.some(r=>(typeof r=="string"?r:r.name)===t.name):e}function S0(t,e){const r=ga.fromSchema(e).serializeFragment(t),s=document.implementation.createHTMLDocument().createElement("div");return s.appendChild(r),s.innerHTML}const Kq=(t,e=500)=>{let r="";const n=t.parentOffset;return t.parent.nodesBetween(Math.max(0,n-e),n,(s,o,i,a)=>{var c,d;const u=((d=(c=s.type.spec).toText)===null||d===void 0?void 0:d.call(c,{node:s,pos:o,parent:i,index:a}))||s.textContent||"%leaf%";r+=s.isAtom&&!s.isText?u:u.slice(0,Math.max(0,n-o))}),r};function N0(t){return Object.prototype.toString.call(t)==="[object RegExp]"}class ym{constructor(e){this.find=e.find,this.handler=e.handler}}const Gq=(t,e)=>{if(N0(e))return e.exec(t);const r=e(t);if(!r)return null;const n=[r.text];return n.index=r.index,n.input=t,n.data=r.data,r.replaceWith&&(r.text.includes(r.replaceWith)||console.warn('[tiptap warn]: "inputRuleMatch.replaceWith" must be part of "inputRuleMatch.text".'),n.push(r.replaceWith)),n};function xm(t){var e;const{editor:r,from:n,to:s,text:o,rules:i,plugin:a}=t,{view:c}=r;if(c.composing)return!1;const d=c.state.doc.resolve(n);if(d.parent.type.spec.code||!((e=d.nodeBefore||d.nodeAfter)===null||e===void 0)&&e.marks.find(f=>f.type.spec.code))return!1;let u=!1;const h=Kq(d)+o;return i.forEach(f=>{if(u)return;const p=Gq(h,f.find);if(!p)return;const g=c.state.tr,v=mm({state:c.state,transaction:g}),y={from:n-(p[0].length-o.length),to:s},{commands:x,chain:w,can:b}=new gm({editor:r,state:v});f.handler({state:v,range:y,match:p,commands:x,chain:w,can:b})===null||!g.steps.length||(g.setMeta(a,{transform:g,from:n,to:s,text:o}),c.dispatch(g),u=!0)}),u}function Yq(t){const{editor:e,rules:r}=t,n=new jr({state:{init(){return null},apply(s,o,i){const a=s.getMeta(n);if(a)return a;const c=s.getMeta("applyInputRules");return!!c&&setTimeout(()=>{let{text:u}=c;typeof u=="string"?u=u:u=S0(Y.from(u),i.schema);const{from:h}=c,f=h+u.length;xm({editor:e,from:h,to:f,text:u,rules:r,plugin:n})}),s.selectionSet||s.docChanged?null:o}},props:{handleTextInput(s,o,i,a){return xm({editor:e,from:o,to:i,text:a,rules:r,plugin:n})},handleDOMEvents:{compositionend:s=>(setTimeout(()=>{const{$cursor:o}=s.state.selection;o&&xm({editor:e,from:o.pos,to:o.pos,text:"",rules:r,plugin:n})}),!1)},handleKeyDown(s,o){if(o.key!=="Enter")return!1;const{$cursor:i}=s.state.selection;return i?xm({editor:e,from:i.pos,to:i.pos,text:` `,rules:r,plugin:n}):!1}},isInputRules:!0});return n}function Jq(t){return Object.prototype.toString.call(t).slice(8,-1)}function wm(t){return Jq(t)!=="Object"?!1:t.constructor===Object&&Object.getPrototypeOf(t)===Object.prototype}function bm(t,e){const r={...t};return wm(t)&&wm(e)&&Object.keys(e).forEach(n=>{wm(e[n])&&wm(t[n])?r[n]=bm(t[n],e[n]):r[n]=e[n]}),r}class lo{constructor(e={}){this.type="mark",this.name="mark",this.parent=null,this.child=null,this.config={name:this.name,defaultOptions:{}},this.config={...this.config,...e},this.name=this.config.name,e.defaultOptions&&Object.keys(e.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${this.name}".`),this.options=this.config.defaultOptions,this.config.addOptions&&(this.options=Re(le(this,"addOptions",{name:this.name}))),this.storage=Re(le(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(e={}){return new lo(e)}configure(e={}){const r=this.extend({...this.config,addOptions:()=>bm(this.options,e)});return r.name=this.name,r.parent=this.parent,r}extend(e={}){const r=new lo(e);return r.parent=this,this.child=r,r.name=e.name?e.name:r.parent.name,e.defaultOptions&&Object.keys(e.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${r.name}".`),r.options=Re(le(r,"addOptions",{name:r.name})),r.storage=Re(le(r,"addStorage",{name:r.name,options:r.options})),r}static handleExit({editor:e,mark:r}){const{tr:n}=e.state,s=e.state.selection.$from;if(s.pos===s.end()){const i=s.marks();if(!!!i.find(d=>(d==null?void 0:d.type.name)===r.name))return!1;const c=i.find(d=>(d==null?void 0:d.type.name)===r.name);return c&&n.removeStoredMark(c),n.insertText(" ",s.pos),e.view.dispatch(n),!0}return!1}}function Qq(t){return typeof t=="number"}class Xq{constructor(e){this.find=e.find,this.handler=e.handler}}const Zq=(t,e,r)=>{if(N0(e))return[...t.matchAll(e)];const n=e(t,r);return n?n.map(s=>{const o=[s.text];return o.index=s.index,o.input=t,o.data=s.data,s.replaceWith&&(s.text.includes(s.replaceWith)||console.warn('[tiptap warn]: "pasteRuleMatch.replaceWith" must be part of "pasteRuleMatch.text".'),o.push(s.replaceWith)),o}):[]};function eK(t){const{editor:e,state:r,from:n,to:s,rule:o,pasteEvent:i,dropEvent:a}=t,{commands:c,chain:d,can:u}=new gm({editor:e,state:r}),h=[];return r.doc.nodesBetween(n,s,(p,g)=>{if(!p.isTextblock||p.type.spec.code)return;const v=Math.max(n,g),y=Math.min(s,g+p.content.size),x=p.textBetween(v-g,y-g,void 0,"");Zq(x,o.find,i).forEach(b=>{if(b.index===void 0)return;const k=v+b.index+1,S=k+b[0].length,C={from:r.tr.mapping.map(k),to:r.tr.mapping.map(S)},N=o.handler({state:r,range:C,match:b,commands:c,chain:d,can:u,pasteEvent:i,dropEvent:a});h.push(N)})}),h.every(p=>p!==null)}let km=null;const tK=t=>{var e;const r=new ClipboardEvent("paste",{clipboardData:new DataTransfer});return(e=r.clipboardData)===null||e===void 0||e.setData("text/html",t),r};function rK(t){const{editor:e,rules:r}=t;let n=null,s=!1,o=!1,i=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,a;try{a=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{a=null}const c=({state:u,from:h,to:f,rule:p,pasteEvt:g})=>{const v=u.tr,y=mm({state:u,transaction:v});if(!(!eK({editor:e,state:y,from:Math.max(h-1,0),to:f.b-1,rule:p,pasteEvent:g,dropEvent:a})||!v.steps.length)){try{a=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{a=null}return i=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,v}};return r.map(u=>new jr({view(h){const f=g=>{var v;n=!((v=h.dom.parentElement)===null||v===void 0)&&v.contains(g.target)?h.dom.parentElement:null,n&&(km=e)},p=()=>{km&&(km=null)};return window.addEventListener("dragstart",f),window.addEventListener("dragend",p),{destroy(){window.removeEventListener("dragstart",f),window.removeEventListener("dragend",p)}}},props:{handleDOMEvents:{drop:(h,f)=>{if(o=n===h.dom.parentElement,a=f,!o){const p=km;p!=null&&p.isEditable&&setTimeout(()=>{const g=p.state.selection;g&&p.commands.deleteRange({from:g.from,to:g.to})},10)}return!1},paste:(h,f)=>{var p;const g=(p=f.clipboardData)===null||p===void 0?void 0:p.getData("text/html");return i=f,s=!!(g!=null&&g.includes("data-pm-slice")),!1}}},appendTransaction:(h,f,p)=>{const g=h[0],v=g.getMeta("uiEvent")==="paste"&&!s,y=g.getMeta("uiEvent")==="drop"&&!o,x=g.getMeta("applyPasteRules"),w=!!x;if(!v&&!y&&!w)return;if(w){let{text:S}=x;typeof S=="string"?S=S:S=S0(Y.from(S),p.schema);const{from:C}=x,N=C+S.length,E=tK(S);return c({rule:u,state:p,from:C,to:{b:N},pasteEvt:E})}const b=f.doc.content.findDiffStart(p.doc.content),k=f.doc.content.findDiffEnd(p.doc.content);if(!(!Qq(b)||!k||b===k.b))return c({rule:u,state:p,from:b,to:k,pasteEvt:i})}}))}function nK(t){const e=t.filter((r,n)=>t.indexOf(r)!==n);return Array.from(new Set(e))}class vc{constructor(e,r){this.splittableMarks=[],this.editor=r,this.extensions=vc.resolve(e),this.schema=qq(this.extensions,r),this.setupExtensions()}static resolve(e){const r=vc.sort(vc.flatten(e)),n=nK(r.map(s=>s.name));return n.length&&console.warn(`[tiptap warn]: Duplicate extension names found: [${n.map(s=>`'${s}'`).join(", ")}]. This can lead to issues.`),r}static flatten(e){return e.map(r=>{const n={name:r.name,options:r.options,storage:r.storage},s=le(r,"addExtensions",n);return s?[r,...this.flatten(s())]:r}).flat(10)}static sort(e){return e.sort((n,s)=>{const o=le(n,"priority")||100,i=le(s,"priority")||100;return o>i?-1:o{const n={name:r.name,options:r.options,storage:r.storage,editor:this.editor,type:k0(r.name,this.schema)},s=le(r,"addCommands",n);return s?{...e,...s()}:e},{})}get plugins(){const{editor:e}=this,r=vc.sort([...this.extensions].reverse()),n=[],s=[],o=r.map(i=>{const a={name:i.name,options:i.options,storage:i.storage,editor:e,type:k0(i.name,this.schema)},c=[],d=le(i,"addKeyboardShortcuts",a);let u={};if(i.type==="mark"&&le(i,"exitable",a)&&(u.ArrowRight=()=>lo.handleExit({editor:e,mark:i})),d){const v=Object.fromEntries(Object.entries(d()).map(([y,x])=>[y,()=>x({editor:e})]));u={...u,...v}}const h=gq(u);c.push(h);const f=le(i,"addInputRules",a);ZR(i,e.options.enableInputRules)&&f&&n.push(...f());const p=le(i,"addPasteRules",a);ZR(i,e.options.enablePasteRules)&&p&&s.push(...p());const g=le(i,"addProseMirrorPlugins",a);if(g){const v=g();c.push(...v)}return c}).flat();return[Yq({editor:e,rules:n}),...rK({editor:e,rules:s}),...o]}get attributes(){return YR(this.extensions)}get nodeViews(){const{editor:e}=this,{nodeExtensions:r}=vm(this.extensions);return Object.fromEntries(r.filter(n=>!!le(n,"addNodeView")).map(n=>{const s=this.attributes.filter(c=>c.type===n.name),o={name:n.name,options:n.options,storage:n.storage,editor:e,type:Ht(n.name,this.schema)},i=le(n,"addNodeView",o);if(!i)return[];const a=(c,d,u,h,f)=>{const p=b0(c,s);return i()({node:c,view:d,getPos:u,decorations:h,innerDecorations:f,editor:e,extension:n,HTMLAttributes:p})};return[n.name,a]}))}setupExtensions(){this.extensions.forEach(e=>{var r;this.editor.extensionStorage[e.name]=e.storage;const n={name:e.name,options:e.options,storage:e.storage,editor:this.editor,type:k0(e.name,this.schema)};e.type==="mark"&&(!((r=Re(le(e,"keepOnSplit",n)))!==null&&r!==void 0)||r)&&this.splittableMarks.push(e.name);const s=le(e,"onBeforeCreate",n),o=le(e,"onCreate",n),i=le(e,"onUpdate",n),a=le(e,"onSelectionUpdate",n),c=le(e,"onTransaction",n),d=le(e,"onFocus",n),u=le(e,"onBlur",n),h=le(e,"onDestroy",n);s&&this.editor.on("beforeCreate",s),o&&this.editor.on("create",o),i&&this.editor.on("update",i),a&&this.editor.on("selectionUpdate",a),c&&this.editor.on("transaction",c),d&&this.editor.on("focus",d),u&&this.editor.on("blur",u),h&&this.editor.on("destroy",h)})}}class gr{constructor(e={}){this.type="extension",this.name="extension",this.parent=null,this.child=null,this.config={name:this.name,defaultOptions:{}},this.config={...this.config,...e},this.name=this.config.name,e.defaultOptions&&Object.keys(e.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${this.name}".`),this.options=this.config.defaultOptions,this.config.addOptions&&(this.options=Re(le(this,"addOptions",{name:this.name}))),this.storage=Re(le(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(e={}){return new gr(e)}configure(e={}){const r=this.extend({...this.config,addOptions:()=>bm(this.options,e)});return r.name=this.name,r.parent=this.parent,r}extend(e={}){const r=new gr({...this.config,...e});return r.parent=this,this.child=r,r.name=e.name?e.name:r.parent.name,e.defaultOptions&&Object.keys(e.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${r.name}".`),r.options=Re(le(r,"addOptions",{name:r.name})),r.storage=Re(le(r,"addStorage",{name:r.name,options:r.options})),r}}function eM(t,e,r){const{from:n,to:s}=e,{blockSeparator:o=` `,textSerializers:i={}}=r||{};let a="";return t.nodesBetween(n,s,(c,d,u,h)=>{var f;c.isBlock&&d>n&&(a+=o);const p=i==null?void 0:i[c.type.name];if(p)return u&&(a+=p({node:c,pos:d,parent:u,index:h,range:e})),!1;c.isText&&(a+=(f=c==null?void 0:c.text)===null||f===void 0?void 0:f.slice(Math.max(n,d)-d,s-d))}),a}function tM(t){return Object.fromEntries(Object.entries(t.nodes).filter(([,e])=>e.spec.toText).map(([e,r])=>[e,r.spec.toText]))}const sK=gr.create({name:"clipboardTextSerializer",addOptions(){return{blockSeparator:void 0}},addProseMirrorPlugins(){return[new jr({key:new Zn("clipboardTextSerializer"),props:{clipboardTextSerializer:()=>{const{editor:t}=this,{state:e,schema:r}=t,{doc:n,selection:s}=e,{ranges:o}=s,i=Math.min(...o.map(u=>u.$from.pos)),a=Math.max(...o.map(u=>u.$to.pos)),c=tM(r);return eM(n,{from:i,to:a},{...this.options.blockSeparator!==void 0?{blockSeparator:this.options.blockSeparator}:{},textSerializers:c})}}})]}}),oK=()=>({editor:t,view:e})=>(requestAnimationFrame(()=>{var r;t.isDestroyed||(e.dom.blur(),(r=window==null?void 0:window.getSelection())===null||r===void 0||r.removeAllRanges())}),!0),iK=(t=!1)=>({commands:e})=>e.setContent("",t),aK=()=>({state:t,tr:e,dispatch:r})=>{const{selection:n}=e,{ranges:s}=n;return r&&s.forEach(({$from:o,$to:i})=>{t.doc.nodesBetween(o.pos,i.pos,(a,c)=>{if(a.type.isText)return;const{doc:d,mapping:u}=e,h=d.resolve(u.map(c)),f=d.resolve(u.map(c+a.nodeSize)),p=h.blockRange(f);if(!p)return;const g=sc(p);if(a.type.isTextblock){const{defaultType:v}=h.parent.contentMatchAt(h.index());e.setNodeMarkup(p.start,v)}(g||g===0)&&e.lift(p,g)})}),!0},lK=t=>e=>t(e),cK=()=>({state:t,dispatch:e})=>Tq(t,e),dK=(t,e)=>({editor:r,tr:n})=>{const{state:s}=r,o=s.doc.slice(t.from,t.to);n.deleteRange(t.from,t.to);const i=n.mapping.map(e);return n.insert(i,o.content),n.setSelection(new Ce(n.doc.resolve(Math.max(i-1,0)))),!0},uK=()=>({tr:t,dispatch:e})=>{const{selection:r}=t,n=r.$anchor.node();if(n.content.size>0)return!1;const s=t.selection.$anchor;for(let o=s.depth;o>0;o-=1)if(s.node(o).type===n.type){if(e){const a=s.before(o),c=s.after(o);t.delete(a,c).scrollIntoView()}return!0}return!1},hK=t=>({tr:e,state:r,dispatch:n})=>{const s=Ht(t,r.schema),o=e.selection.$anchor;for(let i=o.depth;i>0;i-=1)if(o.node(i).type===s){if(n){const c=o.before(i),d=o.after(i);e.delete(c,d).scrollIntoView()}return!0}return!1},fK=t=>({tr:e,dispatch:r})=>{const{from:n,to:s}=t;return r&&e.delete(n,s),!0},pK=()=>({state:t,dispatch:e})=>vq(t,e),mK=()=>({commands:t})=>t.keyboardShortcut("Enter"),gK=()=>({state:t,dispatch:e})=>_q(t,e);function Sm(t,e,r={strict:!0}){const n=Object.keys(e);return n.length?n.every(s=>r.strict?e[s]===t[s]:N0(e[s])?e[s].test(t[s]):e[s]===t[s]):!0}function rM(t,e,r={}){return t.find(n=>n.type===e&&Sm(Object.fromEntries(Object.keys(r).map(s=>[s,n.attrs[s]])),r))}function nM(t,e,r={}){return!!rM(t,e,r)}function C0(t,e,r){var n;if(!t||!e)return;let s=t.parent.childAfter(t.parentOffset);if((!s.node||!s.node.marks.some(u=>u.type===e))&&(s=t.parent.childBefore(t.parentOffset)),!s.node||!s.node.marks.some(u=>u.type===e)||(r=r||((n=s.node.marks[0])===null||n===void 0?void 0:n.attrs),!rM([...s.node.marks],e,r)))return;let i=s.index,a=t.start()+s.offset,c=i+1,d=a+s.node.nodeSize;for(;i>0&&nM([...t.parent.child(i-1).marks],e,r);)i-=1,a-=t.parent.child(i).nodeSize;for(;c({tr:r,state:n,dispatch:s})=>{const o=hi(t,n.schema),{doc:i,selection:a}=r,{$from:c,from:d,to:u}=a;if(s){const h=C0(c,o,e);if(h&&h.from<=d&&h.to>=u){const f=Ce.create(i,h.from,h.to);r.setSelection(f)}}return!0},yK=t=>e=>{const r=typeof t=="function"?t(e):t;for(let n=0;n({editor:r,view:n,tr:s,dispatch:o})=>{e={scrollIntoView:!0,...e};const i=()=>{(Nm()||iM())&&n.dom.focus(),requestAnimationFrame(()=>{r.isDestroyed||(n.focus(),xK()&&!Nm()&&!iM()&&n.dom.focus({preventScroll:!0}))})};if(n.hasFocus()&&t===null||t===!1)return!0;if(o&&t===null&&!sM(r.state.selection))return i(),!0;const a=oM(s.doc,t)||r.state.selection,c=r.state.selection.eq(a);return o&&(c||s.setSelection(a),c&&s.storedMarks&&s.setStoredMarks(s.storedMarks),i()),!0},bK=(t,e)=>r=>t.every((n,s)=>e(n,{...r,index:s})),kK=(t,e)=>({tr:r,commands:n})=>n.insertContentAt({from:r.selection.from,to:r.selection.to},t,e),aM=t=>{const e=t.childNodes;for(let r=e.length-1;r>=0;r-=1){const n=e[r];n.nodeType===3&&n.nodeValue&&/^(\n\s\s|\n)$/.test(n.nodeValue)?t.removeChild(n):n.nodeType===1&&aM(n)}return t};function Cm(t){const e=`${t}`,r=new window.DOMParser().parseFromString(e,"text/html").body;return aM(r)}function Uu(t,e,r){if(t instanceof Xo||t instanceof Y)return t;r={slice:!0,parseOptions:{},...r};const n=typeof t=="object"&&t!==null,s=typeof t=="string";if(n)try{if(Array.isArray(t)&&t.length>0)return Y.fromArray(t.map(a=>e.nodeFromJSON(a)));const i=e.nodeFromJSON(t);return r.errorOnInvalidContent&&i.check(),i}catch(o){if(r.errorOnInvalidContent)throw new Error("[tiptap error]: Invalid JSON content",{cause:o});return console.warn("[tiptap warn]: Invalid content.","Passed value:",t,"Error:",o),Uu("",e,r)}if(s){if(r.errorOnInvalidContent){let i=!1,a="";const c=new G2({topNode:e.spec.topNode,marks:e.spec.marks,nodes:e.spec.nodes.append({__tiptap__private__unknown__catch__all__node:{content:"inline*",group:"block",parseDOM:[{tag:"*",getAttrs:d=>(i=!0,a=typeof d=="string"?d:d.outerHTML,null)}]}})});if(r.slice?Zo.fromSchema(c).parseSlice(Cm(t),r.parseOptions):Zo.fromSchema(c).parse(Cm(t),r.parseOptions),r.errorOnInvalidContent&&i)throw new Error("[tiptap error]: Invalid HTML content",{cause:new Error(`Invalid element found: ${a}`)})}const o=Zo.fromSchema(e);return r.slice?o.parseSlice(Cm(t),r.parseOptions).content:o.parse(Cm(t),r.parseOptions)}return Uu("",e,r)}function SK(t,e,r){const n=t.steps.length-1;if(n{i===0&&(i=u)}),t.setSelection(_e.near(t.doc.resolve(i),r))}const NK=t=>!("type"in t),CK=(t,e,r)=>({tr:n,dispatch:s,editor:o})=>{var i;if(s){r={parseOptions:o.options.parseOptions,updateSelection:!0,applyInputRules:!1,applyPasteRules:!1,...r};let a;const c=y=>{o.emit("contentError",{editor:o,error:y,disableCollaboration:()=>{o.storage.collaboration&&(o.storage.collaboration.isDisabled=!0)}})},d={preserveWhitespace:"full",...r.parseOptions};if(!r.errorOnInvalidContent&&!o.options.enableContentCheck&&o.options.emitContentError)try{Uu(e,o.schema,{parseOptions:d,errorOnInvalidContent:!0})}catch(y){c(y)}try{a=Uu(e,o.schema,{parseOptions:d,errorOnInvalidContent:(i=r.errorOnInvalidContent)!==null&&i!==void 0?i:o.options.enableContentCheck})}catch(y){return c(y),!1}let{from:u,to:h}=typeof t=="number"?{from:t,to:t}:{from:t.from,to:t.to},f=!0,p=!0;if((NK(a)?a:[a]).forEach(y=>{y.check(),f=f?y.isText&&y.marks.length===0:!1,p=p?y.isBlock:!1}),u===h&&p){const{parent:y}=n.doc.resolve(u);y.isTextblock&&!y.type.spec.code&&!y.childCount&&(u-=1,h+=1)}let v;if(f){if(Array.isArray(e))v=e.map(y=>y.text||"").join("");else if(e instanceof Y){let y="";e.forEach(x=>{x.text&&(y+=x.text)}),v=y}else typeof e=="object"&&e&&e.text?v=e.text:v=e;n.insertText(v,u,h)}else v=a,n.replaceWith(u,h,v);r.updateSelection&&SK(n,n.steps.length-1,-1),r.applyInputRules&&n.setMeta("applyInputRules",{from:u,text:v}),r.applyPasteRules&&n.setMeta("applyPasteRules",{from:u,text:v})}return!0},jK=()=>({state:t,dispatch:e})=>Nq(t,e),EK=()=>({state:t,dispatch:e})=>Cq(t,e),_K=()=>({state:t,dispatch:e})=>yq(t,e),TK=()=>({state:t,dispatch:e})=>kq(t,e),RK=()=>({state:t,dispatch:e,tr:r})=>{try{const n=rm(t.doc,t.selection.$from.pos,-1);return n==null?!1:(r.join(n,2),e&&e(r),!0)}catch{return!1}},MK=()=>({state:t,dispatch:e,tr:r})=>{try{const n=rm(t.doc,t.selection.$from.pos,1);return n==null?!1:(r.join(n,2),e&&e(r),!0)}catch{return!1}},OK=()=>({state:t,dispatch:e})=>xq(t,e),PK=()=>({state:t,dispatch:e})=>wq(t,e);function lM(){return typeof navigator<"u"?/Mac/.test(navigator.platform):!1}function AK(t){const e=t.split(/-(?!$)/);let r=e[e.length-1];r==="Space"&&(r=" ");let n,s,o,i;for(let a=0;a({editor:e,view:r,tr:n,dispatch:s})=>{const o=AK(t).split(/-(?!$)/),i=o.find(d=>!["Alt","Ctrl","Meta","Shift"].includes(d)),a=new KeyboardEvent("keydown",{key:i==="Space"?" ":i,altKey:o.includes("Alt"),ctrlKey:o.includes("Ctrl"),metaKey:o.includes("Meta"),shiftKey:o.includes("Shift"),bubbles:!0,cancelable:!0}),c=e.captureTransaction(()=>{r.someProp("handleKeyDown",d=>d(r,a))});return c==null||c.steps.forEach(d=>{const u=d.map(n.mapping);u&&s&&n.maybeStep(u)}),!0};function Vu(t,e,r={}){const{from:n,to:s,empty:o}=t.selection,i=e?Ht(e,t.schema):null,a=[];t.doc.nodesBetween(n,s,(h,f)=>{if(h.isText)return;const p=Math.max(n,f),g=Math.min(s,f+h.nodeSize);a.push({node:h,from:p,to:g})});const c=s-n,d=a.filter(h=>i?i.name===h.node.type.name:!0).filter(h=>Sm(h.node.attrs,r,{strict:!1}));return o?!!d.length:d.reduce((h,f)=>h+f.to-f.from,0)>=c}const DK=(t,e={})=>({state:r,dispatch:n})=>{const s=Ht(t,r.schema);return Vu(r,s,e)?jq(r,n):!1},LK=()=>({state:t,dispatch:e})=>Rq(t,e),$K=t=>({state:e,dispatch:r})=>{const n=Ht(t,e.schema);return Fq(n)(e,r)},FK=()=>({state:t,dispatch:e})=>Eq(t,e);function jm(t,e){return e.nodes[t]?"node":e.marks[t]?"mark":null}function cM(t,e){const r=typeof e=="string"?[e]:e;return Object.keys(t).reduce((n,s)=>(r.includes(s)||(n[s]=t[s]),n),{})}const zK=(t,e)=>({tr:r,state:n,dispatch:s})=>{let o=null,i=null;const a=jm(typeof t=="string"?t:t.name,n.schema);return a?(a==="node"&&(o=Ht(t,n.schema)),a==="mark"&&(i=hi(t,n.schema)),s&&r.selection.ranges.forEach(c=>{n.doc.nodesBetween(c.$from.pos,c.$to.pos,(d,u)=>{o&&o===d.type&&r.setNodeMarkup(u,void 0,cM(d.attrs,e)),i&&d.marks.length&&d.marks.forEach(h=>{i===h.type&&r.addMark(u,u+d.nodeSize,i.create(cM(h.attrs,e)))})})}),!0):!1},BK=()=>({tr:t,dispatch:e})=>(e&&t.scrollIntoView(),!0),UK=()=>({tr:t,dispatch:e})=>{if(e){const r=new jn(t.doc);t.setSelection(r)}return!0},VK=()=>({state:t,dispatch:e})=>bq(t,e),WK=()=>({state:t,dispatch:e})=>Sq(t,e),HK=()=>({state:t,dispatch:e})=>Mq(t,e),qK=()=>({state:t,dispatch:e})=>Aq(t,e),KK=()=>({state:t,dispatch:e})=>Pq(t,e);function j0(t,e,r={},n={}){return Uu(t,e,{slice:!1,parseOptions:r,errorOnInvalidContent:n.errorOnInvalidContent})}const GK=(t,e=!1,r={},n={})=>({editor:s,tr:o,dispatch:i,commands:a})=>{var c,d;const{doc:u}=o;if(r.preserveWhitespace!=="full"){const h=j0(t,s.schema,r,{errorOnInvalidContent:(c=n.errorOnInvalidContent)!==null&&c!==void 0?c:s.options.enableContentCheck});return i&&o.replaceWith(0,u.content.size,h).setMeta("preventUpdate",!e),!0}return i&&o.setMeta("preventUpdate",!e),a.insertContentAt({from:0,to:u.content.size},t,{parseOptions:r,errorOnInvalidContent:(d=n.errorOnInvalidContent)!==null&&d!==void 0?d:s.options.enableContentCheck})};function dM(t,e){const r=hi(e,t.schema),{from:n,to:s,empty:o}=t.selection,i=[];o?(t.storedMarks&&i.push(...t.storedMarks),i.push(...t.selection.$head.marks())):t.doc.nodesBetween(n,s,c=>{i.push(...c.marks)});const a=i.find(c=>c.type.name===r.name);return a?{...a.attrs}:{}}function YK(t){for(let e=0;e0;r-=1){const n=t.node(r);if(e(n))return{pos:r>0?t.before(r):0,start:t.start(r),depth:r,node:n}}}function E0(t){return e=>JK(e.$from,t)}function QK(t,e){const r={from:0,to:t.content.size};return eM(t,r,e)}function XK(t,e){const r=Ht(e,t.schema),{from:n,to:s}=t.selection,o=[];t.doc.nodesBetween(n,s,a=>{o.push(a)});const i=o.reverse().find(a=>a.type.name===r.name);return i?{...i.attrs}:{}}function ZK(t,e){const r=jm(typeof e=="string"?e:e.name,t.schema);return r==="node"?XK(t,e):r==="mark"?dM(t,e):{}}function uM(t,e,r){const n=[];return t===e?r.resolve(t).marks().forEach(s=>{const o=r.resolve(t),i=C0(o,s.type);i&&n.push({mark:s,...i})}):r.nodesBetween(t,e,(s,o)=>{!s||(s==null?void 0:s.nodeSize)===void 0||n.push(...s.marks.map(i=>({from:o,to:o+s.nodeSize,mark:i})))}),n}function Em(t,e,r){return Object.fromEntries(Object.entries(r).filter(([n])=>{const s=t.find(o=>o.type===e&&o.name===n);return s?s.attribute.keepOnSplit:!1}))}function _0(t,e,r={}){const{empty:n,ranges:s}=t.selection,o=e?hi(e,t.schema):null;if(n)return!!(t.storedMarks||t.selection.$from.marks()).filter(h=>o?o.name===h.type.name:!0).find(h=>Sm(h.attrs,r,{strict:!1}));let i=0;const a=[];if(s.forEach(({$from:h,$to:f})=>{const p=h.pos,g=f.pos;t.doc.nodesBetween(p,g,(v,y)=>{if(!v.isText&&!v.marks.length)return;const x=Math.max(p,y),w=Math.min(g,y+v.nodeSize),b=w-x;i+=b,a.push(...v.marks.map(k=>({mark:k,from:x,to:w})))})}),i===0)return!1;const c=a.filter(h=>o?o.name===h.mark.type.name:!0).filter(h=>Sm(h.mark.attrs,r,{strict:!1})).reduce((h,f)=>h+f.to-f.from,0),d=a.filter(h=>o?h.mark.type!==o&&h.mark.type.excludes(o):!0).reduce((h,f)=>h+f.to-f.from,0);return(c>0?c+d:c)>=i}function eG(t,e,r={}){if(!e)return Vu(t,null,r)||_0(t,null,r);const n=jm(e,t.schema);return n==="node"?Vu(t,e,r):n==="mark"?_0(t,e,r):!1}function hM(t,e){const{nodeExtensions:r}=vm(e),n=r.find(i=>i.name===t);if(!n)return!1;const s={name:n.name,options:n.options,storage:n.storage},o=Re(le(n,"group",s));return typeof o!="string"?!1:o.split(" ").includes("list")}function _m(t,{checkChildren:e=!0,ignoreWhitespace:r=!1}={}){var n;if(r){if(t.type.name==="hardBreak")return!0;if(t.isText)return/^\s*$/m.test((n=t.text)!==null&&n!==void 0?n:"")}if(t.isText)return!t.text;if(t.isAtom||t.isLeaf)return!1;if(t.content.childCount===0)return!0;if(e){let s=!0;return t.content.forEach(o=>{s!==!1&&(_m(o,{ignoreWhitespace:r,checkChildren:e})||(s=!1))}),s}return!1}function tG(t){return t instanceof me}function rG(t,e,r){var n;const{selection:s}=e;let o=null;if(sM(s)&&(o=s.$cursor),o){const a=(n=t.storedMarks)!==null&&n!==void 0?n:o.marks();return!!r.isInSet(a)||!a.some(c=>c.type.excludes(r))}const{ranges:i}=s;return i.some(({$from:a,$to:c})=>{let d=a.depth===0?t.doc.inlineContent&&t.doc.type.allowsMarkType(r):!1;return t.doc.nodesBetween(a.pos,c.pos,(u,h,f)=>{if(d)return!1;if(u.isInline){const p=!f||f.type.allowsMarkType(r),g=!!r.isInSet(u.marks)||!u.marks.some(v=>v.type.excludes(r));d=p&&g}return!d}),d})}const nG=(t,e={})=>({tr:r,state:n,dispatch:s})=>{const{selection:o}=r,{empty:i,ranges:a}=o,c=hi(t,n.schema);if(s)if(i){const d=dM(n,c);r.addStoredMark(c.create({...d,...e}))}else a.forEach(d=>{const u=d.$from.pos,h=d.$to.pos;n.doc.nodesBetween(u,h,(f,p)=>{const g=Math.max(p,u),v=Math.min(p+f.nodeSize,h);f.marks.find(x=>x.type===c)?f.marks.forEach(x=>{c===x.type&&r.addMark(g,v,c.create({...x.attrs,...e}))}):r.addMark(g,v,c.create(e))})});return rG(n,r,c)},sG=(t,e)=>({tr:r})=>(r.setMeta(t,e),!0),oG=(t,e={})=>({state:r,dispatch:n,chain:s})=>{const o=Ht(t,r.schema);let i;return r.selection.$anchor.sameParent(r.selection.$head)&&(i=r.selection.$anchor.parent.attrs),o.isTextblock?s().command(({commands:a})=>GR(o,{...i,...e})(r)?!0:a.clearNodes()).command(({state:a})=>GR(o,{...i,...e})(a,n)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},iG=t=>({tr:e,dispatch:r})=>{if(r){const{doc:n}=e,s=Ca(t,0,n.content.size),o=me.create(n,s);e.setSelection(o)}return!0},aG=t=>({tr:e,dispatch:r})=>{if(r){const{doc:n}=e,{from:s,to:o}=typeof t=="number"?{from:t,to:t}:t,i=Ce.atStart(n).from,a=Ce.atEnd(n).to,c=Ca(s,i,a),d=Ca(o,i,a),u=Ce.create(n,c,d);e.setSelection(u)}return!0},lG=t=>({state:e,dispatch:r})=>{const n=Ht(t,e.schema);return Uq(n)(e,r)};function fM(t,e){const r=t.storedMarks||t.selection.$to.parentOffset&&t.selection.$from.marks();if(r){const n=r.filter(s=>e==null?void 0:e.includes(s.type.name));t.tr.ensureMarks(n)}}const cG=({keepMarks:t=!0}={})=>({tr:e,state:r,dispatch:n,editor:s})=>{const{selection:o,doc:i}=e,{$from:a,$to:c}=o,d=s.extensionManager.attributes,u=Em(d,a.node().type.name,a.node().attrs);if(o instanceof me&&o.node.isBlock)return!a.parentOffset||!oc(i,a.pos)?!1:(n&&(t&&fM(r,s.extensionManager.splittableMarks),e.split(a.pos).scrollIntoView()),!0);if(!a.parent.isBlock)return!1;const h=c.parentOffset===c.parent.content.size,f=a.depth===0?void 0:YK(a.node(-1).contentMatchAt(a.indexAfter(-1)));let p=h&&f?[{type:f,attrs:u}]:void 0,g=oc(e.doc,e.mapping.map(a.pos),1,p);if(!p&&!g&&oc(e.doc,e.mapping.map(a.pos),1,f?[{type:f}]:void 0)&&(g=!0,p=f?[{type:f,attrs:u}]:void 0),n){if(g&&(o instanceof Ce&&e.deleteSelection(),e.split(e.mapping.map(a.pos),1,p),f&&!h&&!a.parentOffset&&a.parent.type!==f)){const v=e.mapping.map(a.before()),y=e.doc.resolve(v);a.node(-1).canReplaceWith(y.index(),y.index()+1,f)&&e.setNodeMarkup(e.mapping.map(a.before()),f)}t&&fM(r,s.extensionManager.splittableMarks),e.scrollIntoView()}return g},dG=(t,e={})=>({tr:r,state:n,dispatch:s,editor:o})=>{var i;const a=Ht(t,n.schema),{$from:c,$to:d}=n.selection,u=n.selection.node;if(u&&u.isBlock||c.depth<2||!c.sameParent(d))return!1;const h=c.node(-1);if(h.type!==a)return!1;const f=o.extensionManager.attributes;if(c.parent.content.size===0&&c.node(-1).childCount===c.indexAfter(-1)){if(c.depth===2||c.node(-3).type!==a||c.index(-2)!==c.node(-2).childCount-1)return!1;if(s){let x=Y.empty;const w=c.index(-1)?1:c.index(-2)?2:3;for(let E=c.depth-w;E>=c.depth-3;E-=1)x=Y.from(c.node(E).copy(x));const b=c.indexAfter(-1){if(N>-1)return!1;E.isTextblock&&E.content.size===0&&(N=j+1)}),N>-1&&r.setSelection(Ce.near(r.doc.resolve(N))),r.scrollIntoView()}return!0}const p=d.pos===c.end()?h.contentMatchAt(0).defaultType:null,g={...Em(f,h.type.name,h.attrs),...e},v={...Em(f,c.node().type.name,c.node().attrs),...e};r.delete(c.pos,d.pos);const y=p?[{type:a,attrs:g},{type:p,attrs:v}]:[{type:a,attrs:g}];if(!oc(r.doc,c.pos,2))return!1;if(s){const{selection:x,storedMarks:w}=n,{splittableMarks:b}=o.extensionManager,k=w||x.$to.parentOffset&&x.$from.marks();if(r.split(c.pos,2,y).scrollIntoView(),!k||!s)return!0;const S=k.filter(C=>b.includes(C.type.name));r.ensureMarks(S)}return!0},T0=(t,e)=>{const r=E0(i=>i.type===e)(t.selection);if(!r)return!0;const n=t.doc.resolve(Math.max(0,r.pos-1)).before(r.depth);if(n===void 0)return!0;const s=t.doc.nodeAt(n);return r.node.type===(s==null?void 0:s.type)&&ri(t.doc,r.pos)&&t.join(r.pos),!0},R0=(t,e)=>{const r=E0(i=>i.type===e)(t.selection);if(!r)return!0;const n=t.doc.resolve(r.start).after(r.depth);if(n===void 0)return!0;const s=t.doc.nodeAt(n);return r.node.type===(s==null?void 0:s.type)&&ri(t.doc,n)&&t.join(n),!0};var uG=Object.freeze({__proto__:null,blur:oK,clearContent:iK,clearNodes:aK,command:lK,createParagraphNear:cK,cut:dK,deleteCurrentNode:uK,deleteNode:hK,deleteRange:fK,deleteSelection:pK,enter:mK,exitCode:gK,extendMarkRange:vK,first:yK,focus:wK,forEach:bK,insertContent:kK,insertContentAt:CK,joinBackward:_K,joinDown:EK,joinForward:TK,joinItemBackward:RK,joinItemForward:MK,joinTextblockBackward:OK,joinTextblockForward:PK,joinUp:jK,keyboardShortcut:IK,lift:DK,liftEmptyBlock:LK,liftListItem:$K,newlineInCode:FK,resetAttributes:zK,scrollIntoView:BK,selectAll:UK,selectNodeBackward:VK,selectNodeForward:WK,selectParentNode:HK,selectTextblockEnd:qK,selectTextblockStart:KK,setContent:GK,setMark:nG,setMeta:sG,setNode:oG,setNodeSelection:iG,setTextSelection:aG,sinkListItem:lG,splitBlock:cG,splitListItem:dG,toggleList:(t,e,r,n={})=>({editor:s,tr:o,state:i,dispatch:a,chain:c,commands:d,can:u})=>{const{extensions:h,splittableMarks:f}=s.extensionManager,p=Ht(t,i.schema),g=Ht(e,i.schema),{selection:v,storedMarks:y}=i,{$from:x,$to:w}=v,b=x.blockRange(w),k=y||v.$to.parentOffset&&v.$from.marks();if(!b)return!1;const S=E0(C=>hM(C.type.name,h))(v);if(b.depth>=1&&S&&b.depth-S.depth<=1){if(S.node.type===p)return d.liftListItem(g);if(hM(S.node.type.name,h)&&p.validContent(S.node.content)&&a)return c().command(()=>(o.setNodeMarkup(S.pos,p),!0)).command(()=>T0(o,p)).command(()=>R0(o,p)).run()}return!r||!k||!a?c().command(()=>u().wrapInList(p,n)?!0:d.clearNodes()).wrapInList(p,n).command(()=>T0(o,p)).command(()=>R0(o,p)).run():c().command(()=>{const C=u().wrapInList(p,n),N=k.filter(E=>f.includes(E.type.name));return o.ensureMarks(N),C?!0:d.clearNodes()}).wrapInList(p,n).command(()=>T0(o,p)).command(()=>R0(o,p)).run()},toggleMark:(t,e={},r={})=>({state:n,commands:s})=>{const{extendEmptyMarkRange:o=!1}=r,i=hi(t,n.schema);return _0(n,i,e)?s.unsetMark(i,{extendEmptyMarkRange:o}):s.setMark(i,e)},toggleNode:(t,e,r={})=>({state:n,commands:s})=>{const o=Ht(t,n.schema),i=Ht(e,n.schema),a=Vu(n,o,r);let c;return n.selection.$anchor.sameParent(n.selection.$head)&&(c=n.selection.$anchor.parent.attrs),a?s.setNode(i,c):s.setNode(o,{...c,...r})},toggleWrap:(t,e={})=>({state:r,commands:n})=>{const s=Ht(t,r.schema);return Vu(r,s,e)?n.lift(s):n.wrapIn(s,e)},undoInputRule:()=>({state:t,dispatch:e})=>{const r=t.plugins;for(let n=0;n=0;c-=1)i.step(a.steps[c].invert(a.docs[c]));if(o.text){const c=i.doc.resolve(o.from).marks();i.replaceWith(o.from,o.to,t.schema.text(o.text,c))}else i.delete(o.from,o.to)}return!0}}return!1},unsetAllMarks:()=>({tr:t,dispatch:e})=>{const{selection:r}=t,{empty:n,ranges:s}=r;return n||e&&s.forEach(o=>{t.removeMark(o.$from.pos,o.$to.pos)}),!0},unsetMark:(t,e={})=>({tr:r,state:n,dispatch:s})=>{var o;const{extendEmptyMarkRange:i=!1}=e,{selection:a}=r,c=hi(t,n.schema),{$from:d,empty:u,ranges:h}=a;if(!s)return!0;if(u&&i){let{from:f,to:p}=a;const g=(o=d.marks().find(y=>y.type===c))===null||o===void 0?void 0:o.attrs,v=C0(d,c,g);v&&(f=v.from,p=v.to),r.removeMark(f,p,c)}else h.forEach(f=>{r.removeMark(f.$from.pos,f.$to.pos,c)});return r.removeStoredMark(c),!0},updateAttributes:(t,e={})=>({tr:r,state:n,dispatch:s})=>{let o=null,i=null;const a=jm(typeof t=="string"?t:t.name,n.schema);return a?(a==="node"&&(o=Ht(t,n.schema)),a==="mark"&&(i=hi(t,n.schema)),s&&r.selection.ranges.forEach(c=>{const d=c.$from.pos,u=c.$to.pos;let h,f,p,g;r.selection.empty?n.doc.nodesBetween(d,u,(v,y)=>{o&&o===v.type&&(p=Math.max(y,d),g=Math.min(y+v.nodeSize,u),h=y,f=v)}):n.doc.nodesBetween(d,u,(v,y)=>{y=d&&y<=u&&(o&&o===v.type&&r.setNodeMarkup(y,void 0,{...v.attrs,...e}),i&&v.marks.length&&v.marks.forEach(x=>{if(i===x.type){const w=Math.max(y,d),b=Math.min(y+v.nodeSize,u);r.addMark(w,b,i.create({...x.attrs,...e}))}}))}),f&&(h!==void 0&&r.setNodeMarkup(h,void 0,{...f.attrs,...e}),i&&f.marks.length&&f.marks.forEach(v=>{i===v.type&&r.addMark(p,g,i.create({...v.attrs,...e}))}))}),!0):!1},wrapIn:(t,e={})=>({state:r,dispatch:n})=>{const s=Ht(t,r.schema);return Iq(s,e)(r,n)},wrapInList:(t,e={})=>({state:r,dispatch:n})=>{const s=Ht(t,r.schema);return Dq(s,e)(r,n)}});const hG=gr.create({name:"commands",addCommands(){return{...uG}}}),fG=gr.create({name:"drop",addProseMirrorPlugins(){return[new jr({key:new Zn("tiptapDrop"),props:{handleDrop:(t,e,r,n)=>{this.editor.emit("drop",{editor:this.editor,event:e,slice:r,moved:n})}}})]}}),pG=gr.create({name:"editable",addProseMirrorPlugins(){return[new jr({key:new Zn("editable"),props:{editable:()=>this.editor.options.editable}})]}}),mG=new Zn("focusEvents"),gG=gr.create({name:"focusEvents",addProseMirrorPlugins(){const{editor:t}=this;return[new jr({key:mG,props:{handleDOMEvents:{focus:(e,r)=>{t.isFocused=!0;const n=t.state.tr.setMeta("focus",{event:r}).setMeta("addToHistory",!1);return e.dispatch(n),!1},blur:(e,r)=>{t.isFocused=!1;const n=t.state.tr.setMeta("blur",{event:r}).setMeta("addToHistory",!1);return e.dispatch(n),!1}}}})]}}),vG=gr.create({name:"keymap",addKeyboardShortcuts(){const t=()=>this.editor.commands.first(({commands:i})=>[()=>i.undoInputRule(),()=>i.command(({tr:a})=>{const{selection:c,doc:d}=a,{empty:u,$anchor:h}=c,{pos:f,parent:p}=h,g=h.parent.isTextblock&&f>0?a.doc.resolve(f-1):h,v=g.parent.type.spec.isolating,y=h.pos-h.parentOffset,x=v&&g.parent.childCount===1?y===h.pos:_e.atStart(d).from===f;return!u||!p.type.isTextblock||p.textContent.length||!x||x&&h.parent.type.name==="paragraph"?!1:i.clearNodes()}),()=>i.deleteSelection(),()=>i.joinBackward(),()=>i.selectNodeBackward()]),e=()=>this.editor.commands.first(({commands:i})=>[()=>i.deleteSelection(),()=>i.deleteCurrentNode(),()=>i.joinForward(),()=>i.selectNodeForward()]),n={Enter:()=>this.editor.commands.first(({commands:i})=>[()=>i.newlineInCode(),()=>i.createParagraphNear(),()=>i.liftEmptyBlock(),()=>i.splitBlock()]),"Mod-Enter":()=>this.editor.commands.exitCode(),Backspace:t,"Mod-Backspace":t,"Shift-Backspace":t,Delete:e,"Mod-Delete":e,"Mod-a":()=>this.editor.commands.selectAll()},s={...n},o={...n,"Ctrl-h":t,"Alt-Backspace":t,"Ctrl-d":e,"Ctrl-Alt-Backspace":e,"Alt-Delete":e,"Alt-d":e,"Ctrl-a":()=>this.editor.commands.selectTextblockStart(),"Ctrl-e":()=>this.editor.commands.selectTextblockEnd()};return Nm()||lM()?o:s},addProseMirrorPlugins(){return[new jr({key:new Zn("clearDocument"),appendTransaction:(t,e,r)=>{if(t.some(v=>v.getMeta("composition")))return;const n=t.some(v=>v.docChanged)&&!e.doc.eq(r.doc),s=t.some(v=>v.getMeta("preventClearDocument"));if(!n||s)return;const{empty:o,from:i,to:a}=e.selection,c=_e.atStart(e.doc).from,d=_e.atEnd(e.doc).to;if(o||!(i===c&&a===d)||!_m(r.doc))return;const f=r.tr,p=mm({state:r,transaction:f}),{commands:g}=new gm({editor:this.editor,state:p});if(g.clearNodes(),!!f.steps.length)return f}})]}}),yG=gr.create({name:"paste",addProseMirrorPlugins(){return[new jr({key:new Zn("tiptapPaste"),props:{handlePaste:(t,e,r)=>{this.editor.emit("paste",{editor:this.editor,event:e,slice:r})}}})]}}),xG=gr.create({name:"tabindex",addProseMirrorPlugins(){return[new jr({key:new Zn("tabindex"),props:{attributes:()=>this.editor.isEditable?{tabindex:"0"}:{}}})]}});class ja{get name(){return this.node.type.name}constructor(e,r,n=!1,s=null){this.currentNode=null,this.actualDepth=null,this.isBlock=n,this.resolvedPos=e,this.editor=r,this.currentNode=s}get node(){return this.currentNode||this.resolvedPos.node()}get element(){return this.editor.view.domAtPos(this.pos).node}get depth(){var e;return(e=this.actualDepth)!==null&&e!==void 0?e:this.resolvedPos.depth}get pos(){return this.resolvedPos.pos}get content(){return this.node.content}set content(e){let r=this.from,n=this.to;if(this.isBlock){if(this.content.size===0){console.error(`You can’t set content on a block node. Tried to set content on ${this.name} at ${this.pos}`);return}r=this.from+1,n=this.to-1}this.editor.commands.insertContentAt({from:r,to:n},e)}get attributes(){return this.node.attrs}get textContent(){return this.node.textContent}get size(){return this.node.nodeSize}get from(){return this.isBlock?this.pos:this.resolvedPos.start(this.resolvedPos.depth)}get range(){return{from:this.from,to:this.to}}get to(){return this.isBlock?this.pos+this.size:this.resolvedPos.end(this.resolvedPos.depth)+(this.node.isText?0:1)}get parent(){if(this.depth===0)return null;const e=this.resolvedPos.start(this.resolvedPos.depth-1),r=this.resolvedPos.doc.resolve(e);return new ja(r,this.editor)}get before(){let e=this.resolvedPos.doc.resolve(this.from-(this.isBlock?1:2));return e.depth!==this.depth&&(e=this.resolvedPos.doc.resolve(this.from-3)),new ja(e,this.editor)}get after(){let e=this.resolvedPos.doc.resolve(this.to+(this.isBlock?2:1));return e.depth!==this.depth&&(e=this.resolvedPos.doc.resolve(this.to+3)),new ja(e,this.editor)}get children(){const e=[];return this.node.content.forEach((r,n)=>{const s=r.isBlock&&!r.isTextblock,o=r.isAtom&&!r.isText,i=this.pos+n+(o?0:1);if(i<0||i>this.resolvedPos.doc.nodeSize-2)return;const a=this.resolvedPos.doc.resolve(i);if(!s&&a.depth<=this.depth)return;const c=new ja(a,this.editor,s,s?r:null);s&&(c.actualDepth=this.depth+1),e.push(new ja(a,this.editor,s,s?r:null))}),e}get firstChild(){return this.children[0]||null}get lastChild(){const e=this.children;return e[e.length-1]||null}closest(e,r={}){let n=null,s=this.parent;for(;s&&!n;){if(s.node.type.name===e)if(Object.keys(r).length>0){const o=s.node.attrs,i=Object.keys(r);for(let a=0;a{n&&s.length>0||(i.node.type.name===e&&o.every(c=>r[c]===i.node.attrs[c])&&s.push(i),!(n&&s.length>0)&&(s=s.concat(i.querySelectorAll(e,r,n))))}),s}setAttribute(e){const{tr:r}=this.editor.state;r.setNodeMarkup(this.from,void 0,{...this.node.attrs,...e}),this.editor.view.dispatch(r)}}const wG=`.ProseMirror { position: relative; } .ProseMirror { word-wrap: break-word; white-space: pre-wrap; white-space: break-spaces; -webkit-font-variant-ligatures: none; font-variant-ligatures: none; font-feature-settings: "liga" 0; /* the above doesn't seem to work in Edge */ } .ProseMirror [contenteditable="false"] { white-space: normal; } .ProseMirror [contenteditable="false"] [contenteditable="true"] { white-space: pre-wrap; } .ProseMirror pre { white-space: pre-wrap; } img.ProseMirror-separator { display: inline !important; border: none !important; margin: 0 !important; width: 0 !important; height: 0 !important; } .ProseMirror-gapcursor { display: none; pointer-events: none; position: absolute; margin: 0; } .ProseMirror-gapcursor:after { content: ""; display: block; position: absolute; top: -2px; width: 20px; border-top: 1px solid black; animation: ProseMirror-cursor-blink 1.1s steps(2, start) infinite; } @keyframes ProseMirror-cursor-blink { to { visibility: hidden; } } .ProseMirror-hideselection *::selection { background: transparent; } .ProseMirror-hideselection *::-moz-selection { background: transparent; } .ProseMirror-hideselection * { caret-color: transparent; } .ProseMirror-focused .ProseMirror-gapcursor { display: block; } .tippy-box[data-animation=fade][data-state=hidden] { opacity: 0 }`;function bG(t,e,r){const n=document.querySelector("style[data-tiptap-style]");if(n!==null)return n;const s=document.createElement("style");return e&&s.setAttribute("nonce",e),s.setAttribute("data-tiptap-style",""),s.innerHTML=t,document.getElementsByTagName("head")[0].appendChild(s),s}class kG extends Vq{constructor(e={}){super(),this.isFocused=!1,this.isInitialized=!1,this.extensionStorage={},this.options={element:document.createElement("div"),content:"",injectCSS:!0,injectNonce:void 0,extensions:[],autofocus:!1,editable:!0,editorProps:{},parseOptions:{},coreExtensionOptions:{},enableInputRules:!0,enablePasteRules:!0,enableCoreExtensions:!0,enableContentCheck:!1,emitContentError:!1,onBeforeCreate:()=>null,onCreate:()=>null,onUpdate:()=>null,onSelectionUpdate:()=>null,onTransaction:()=>null,onFocus:()=>null,onBlur:()=>null,onDestroy:()=>null,onContentError:({error:r})=>{throw r},onPaste:()=>null,onDrop:()=>null},this.isCapturingTransaction=!1,this.capturedTransaction=null,this.setOptions(e),this.createExtensionManager(),this.createCommandManager(),this.createSchema(),this.on("beforeCreate",this.options.onBeforeCreate),this.emit("beforeCreate",{editor:this}),this.on("contentError",this.options.onContentError),this.createView(),this.injectCSS(),this.on("create",this.options.onCreate),this.on("update",this.options.onUpdate),this.on("selectionUpdate",this.options.onSelectionUpdate),this.on("transaction",this.options.onTransaction),this.on("focus",this.options.onFocus),this.on("blur",this.options.onBlur),this.on("destroy",this.options.onDestroy),this.on("drop",({event:r,slice:n,moved:s})=>this.options.onDrop(r,n,s)),this.on("paste",({event:r,slice:n})=>this.options.onPaste(r,n)),window.setTimeout(()=>{this.isDestroyed||(this.commands.focus(this.options.autofocus),this.emit("create",{editor:this}),this.isInitialized=!0)},0)}get storage(){return this.extensionStorage}get commands(){return this.commandManager.commands}chain(){return this.commandManager.chain()}can(){return this.commandManager.can()}injectCSS(){this.options.injectCSS&&document&&(this.css=bG(wG,this.options.injectNonce))}setOptions(e={}){this.options={...this.options,...e},!(!this.view||!this.state||this.isDestroyed)&&(this.options.editorProps&&this.view.setProps(this.options.editorProps),this.view.updateState(this.state))}setEditable(e,r=!0){this.setOptions({editable:e}),r&&this.emit("update",{editor:this,transaction:this.state.tr})}get isEditable(){return this.options.editable&&this.view&&this.view.editable}get state(){return this.view.state}registerPlugin(e,r){const n=JR(r)?r(e,[...this.state.plugins]):[...this.state.plugins,e],s=this.state.reconfigure({plugins:n});return this.view.updateState(s),s}unregisterPlugin(e){if(this.isDestroyed)return;const r=this.state.plugins;let n=r;if([].concat(e).forEach(o=>{const i=typeof o=="string"?`${o} Focus - Student Notes & Calendar App :o.key;n=n.filter(a=>!a.key.startsWith(i))}),r.length===n.length)return;const s=this.state.reconfigure({plugins:n});return this.view.updateState(s),s}createExtensionManager(){var e,r;const s=[...this.options.enableCoreExtensions?[pG,sK.configure({blockSeparator:(r=(e=this.options.coreExtensionOptions)===null||e===void 0?void 0:e.clipboardTextSerializer)===null||r===void 0?void 0:r.blockSeparator}),hG,gG,vG,xG,fG,yG].filter(o=>typeof this.options.enableCoreExtensions=="object"?this.options.enableCoreExtensions[o.name]!==!1:!0):[],...this.options.extensions].filter(o=>["extension","node","mark"].includes(o==null?void 0:o.type));this.extensionManager=new vc(s,this)}createCommandManager(){this.commandManager=new gm({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createView(){var e;let r;try{r=j0(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:this.options.enableContentCheck})}catch(i){if(!(i instanceof Error)||!["[tiptap error]: Invalid JSON content","[tiptap error]: Invalid HTML content"].includes(i.message))throw i;this.emit("contentError",{editor:this,error:i,disableCollaboration:()=>{this.storage.collaboration&&(this.storage.collaboration.isDisabled=!0),this.options.extensions=this.options.extensions.filter(a=>a.name!=="collaboration"),this.createExtensionManager()}}),r=j0(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:!1})}const n=oM(r,this.options.autofocus);this.view=new IR(this.options.element,{...this.options.editorProps,attributes:{role:"textbox",...(e=this.options.editorProps)===null||e===void 0?void 0:e.attributes},dispatchTransaction:this.dispatchTransaction.bind(this),state:cc.create({doc:r,selection:n||void 0})});const s=this.state.reconfigure({plugins:this.extensionManager.plugins});this.view.updateState(s),this.createNodeViews(),this.prependClass();const o=this.view.dom;o.editor=this}createNodeViews(){this.view.isDestroyed||this.view.setProps({nodeViews:this.extensionManager.nodeViews})}prependClass(){this.view.dom.className=`tiptap ${this.view.dom.className}`}captureTransaction(e){this.isCapturingTransaction=!0,e(),this.isCapturingTransaction=!1;const r=this.capturedTransaction;return this.capturedTransaction=null,r}dispatchTransaction(e){if(this.view.isDestroyed)return;if(this.isCapturingTransaction){if(!this.capturedTransaction){this.capturedTransaction=e;return}e.steps.forEach(i=>{var a;return(a=this.capturedTransaction)===null||a===void 0?void 0:a.step(i)});return}const r=this.state.apply(e),n=!this.state.selection.eq(r.selection);this.emit("beforeTransaction",{editor:this,transaction:e,nextState:r}),this.view.updateState(r),this.emit("transaction",{editor:this,transaction:e}),n&&this.emit("selectionUpdate",{editor:this,transaction:e});const s=e.getMeta("focus"),o=e.getMeta("blur");s&&this.emit("focus",{editor:this,event:s.event,transaction:e}),o&&this.emit("blur",{editor:this,event:o.event,transaction:e}),!(!e.docChanged||e.getMeta("preventUpdate"))&&this.emit("update",{editor:this,transaction:e})}getAttributes(e){return ZK(this.state,e)}isActive(e,r){const n=typeof e=="string"?e:null,s=typeof e=="string"?r:e;return eG(this.state,n,s)}getJSON(){return this.state.doc.toJSON()}getHTML(){return S0(this.state.doc.content,this.schema)}getText(e){const{blockSeparator:r=` `,textSerializers:n={}}=e||{};return QK(this.state.doc,{blockSeparator:r,textSerializers:{...tM(this.schema),...n}})}get isEmpty(){return _m(this.state.doc)}getCharacterCount(){return console.warn('[tiptap warn]: "editor.getCharacterCount()" is deprecated. Please use "editor.storage.characterCount.characters()" instead.'),this.state.doc.content.size-2}destroy(){if(this.emit("destroy"),this.view){const e=this.view.dom;e&&e.editor&&delete e.editor,this.view.destroy()}this.removeAllListeners()}get isDestroyed(){var e;return!(!((e=this.view)===null||e===void 0)&&e.docView)}$node(e,r){var n;return((n=this.$doc)===null||n===void 0?void 0:n.querySelector(e,r))||null}$nodes(e,r){var n;return((n=this.$doc)===null||n===void 0?void 0:n.querySelectorAll(e,r))||null}$pos(e){const r=this.state.doc.resolve(e);return new ja(r,this)}get $doc(){return this.$pos(0)}}function yc(t){return new ym({find:t.find,handler:({state:e,range:r,match:n})=>{const s=Re(t.getAttributes,void 0,n);if(s===!1||s===null)return null;const{tr:o}=e,i=n[n.length-1],a=n[0];if(i){const c=a.search(/\S/),d=r.from+a.indexOf(i),u=d+i.length;if(uM(r.from,r.to,e.doc).filter(p=>p.mark.type.excluded.find(v=>v===t.type&&v!==p.mark.type)).filter(p=>p.to>d).length)return null;ur.from&&o.delete(r.from+c,d);const f=r.from+c+i.length;o.addMark(r.from+c,f,t.type.create(s||{})),o.removeStoredMark(t.type)}}})}function SG(t){return new ym({find:t.find,handler:({state:e,range:r,match:n})=>{const s=Re(t.getAttributes,void 0,n)||{},{tr:o}=e,i=r.from;let a=r.to;const c=t.type.create(s);if(n[1]){const d=n[0].lastIndexOf(n[1]);let u=i+d;u>a?u=a:a=u+n[1].length;const h=n[0][n[0].length-1];o.insertText(h,i+n[0].length-1),o.replaceWith(u,a,c)}else if(n[0]){const d=t.type.isInline?i:i-1;o.insert(d,t.type.create(s)).delete(o.mapping.map(i),o.mapping.map(a))}o.scrollIntoView()}})}function M0(t){return new ym({find:t.find,handler:({state:e,range:r,match:n})=>{const s=e.doc.resolve(r.from),o=Re(t.getAttributes,void 0,n)||{};if(!s.node(-1).canReplaceWith(s.index(-1),s.indexAfter(-1),t.type))return null;e.tr.delete(r.from,r.to).setBlockType(r.from,r.from,t.type,o)}})}function Wu(t){return new ym({find:t.find,handler:({state:e,range:r,match:n,chain:s})=>{const o=Re(t.getAttributes,void 0,n)||{},i=e.tr.delete(r.from,r.to),c=i.doc.resolve(r.from).blockRange(),d=c&&zw(c,t.type,o);if(!d)return null;if(i.wrap(c,d),t.keepMarks&&t.editor){const{selection:h,storedMarks:f}=e,{splittableMarks:p}=t.editor.extensionManager,g=f||h.$to.parentOffset&&h.$from.marks();if(g){const v=g.filter(y=>p.includes(y.type.name));i.ensureMarks(v)}}if(t.keepAttributes){const h=t.type.name==="bulletList"||t.type.name==="orderedList"?"listItem":"taskList";s().updateAttributes(h,o).run()}const u=i.doc.resolve(r.from-1).nodeBefore;u&&u.type===t.type&&ri(i.doc,r.from-1)&&(!t.joinPredicate||t.joinPredicate(n,u))&&i.join(r.from-1)}})}let es=class d1{constructor(e={}){this.type="node",this.name="node",this.parent=null,this.child=null,this.config={name:this.name,defaultOptions:{}},this.config={...this.config,...e},this.name=this.config.name,e.defaultOptions&&Object.keys(e.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${this.name}".`),this.options=this.config.defaultOptions,this.config.addOptions&&(this.options=Re(le(this,"addOptions",{name:this.name}))),this.storage=Re(le(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(e={}){return new d1(e)}configure(e={}){const r=this.extend({...this.config,addOptions:()=>bm(this.options,e)});return r.name=this.name,r.parent=this.parent,r}extend(e={}){const r=new d1(e);return r.parent=this,this.child=r,r.name=e.name?e.name:r.parent.name,e.defaultOptions&&Object.keys(e.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${r.name}".`),r.options=Re(le(r,"addOptions",{name:r.name})),r.storage=Re(le(r,"addStorage",{name:r.name,options:r.options})),r}};function xc(t){return new Xq({find:t.find,handler:({state:e,range:r,match:n,pasteEvent:s})=>{const o=Re(t.getAttributes,void 0,n,s);if(o===!1||o===null)return null;const{tr:i}=e,a=n[n.length-1],c=n[0];let d=r.to;if(a){const u=c.search(/\S/),h=r.from+c.indexOf(a),f=h+a.length;if(uM(r.from,r.to,e.doc).filter(g=>g.mark.type.excluded.find(y=>y===t.type&&y!==g.mark.type)).filter(g=>g.to>h).length)return null;fr.from&&i.delete(r.from+u,h),d=r.from+u+a.length,i.addMark(r.from+u,d,t.type.create(o||{})),i.removeStoredMark(t.type)}}})}function NG(t,e){const{selection:r}=t,{$from:n}=r;if(r instanceof me){const o=n.index();return n.parent.canReplaceWith(o,o+1,e)}let s=n.depth;for(;s>=0;){const o=n.index(s);if(n.node(s).contentMatchAt(o).matchType(e))return!0;s-=1}return!1}function CG(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var pM={exports:{}},O0={};/** * @license React * use-sync-external-store-shim.production.min.js * * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */var mM;function jG(){if(mM)return O0;mM=1;var t=W;function e(h,f){return h===f&&(h!==0||1/h===1/f)||h!==h&&f!==f}var r=typeof Object.is=="function"?Object.is:e,n=t.useState,s=t.useEffect,o=t.useLayoutEffect,i=t.useDebugValue;function a(h,f){var p=f(),g=n({inst:{value:p,getSnapshot:f}}),v=g[0].inst,y=g[1];return o(function(){v.value=p,v.getSnapshot=f,c(v)&&y({inst:v})},[h,p,f]),s(function(){return c(v)&&y({inst:v}),h(function(){c(v)&&y({inst:v})})},[h]),i(p),p}function c(h){var f=h.getSnapshot;h=h.value;try{var p=f();return!r(h,p)}catch{return!0}}function d(h,f){return f()}var u=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?d:a;return O0.useSyncExternalStore=t.useSyncExternalStore!==void 0?t.useSyncExternalStore:u,O0}pM.exports=jG();var P0=pM.exports;const EG=(...t)=>e=>{t.forEach(r=>{typeof r=="function"?r(e):r&&(r.current=e)})},_G=({contentComponent:t})=>{const e=P0.useSyncExternalStore(t.subscribe,t.getSnapshot,t.getServerSnapshot);return W.createElement(W.Fragment,null,Object.values(e))};function TG(){const t=new Set;let e={};return{subscribe(r){return t.add(r),()=>{t.delete(r)}},getSnapshot(){return e},getServerSnapshot(){return e},setRenderer(r,n){e={...e,[r]:My.createPortal(n.reactElement,n.element,r)},t.forEach(s=>s())},removeRenderer(r){const n={...e};delete n[r],e=n,t.forEach(s=>s())}}}class RG extends W.Component{constructor(e){var r;super(e),this.editorContentRef=W.createRef(),this.initialized=!1,this.state={hasContentComponentInitialized:!!(!((r=e.editor)===null||r===void 0)&&r.contentComponent)}}componentDidMount(){this.init()}componentDidUpdate(){this.init()}init(){const e=this.props.editor;if(e&&!e.isDestroyed&&e.options.element){if(e.contentComponent)return;const r=this.editorContentRef.current;r.append(...e.options.element.childNodes),e.setOptions({element:r}),e.contentComponent=TG(),this.state.hasContentComponentInitialized||(this.unsubscribeToContentComponent=e.contentComponent.subscribe(()=>{this.setState(n=>n.hasContentComponentInitialized?n:{hasContentComponentInitialized:!0}),this.unsubscribeToContentComponent&&this.unsubscribeToContentComponent()})),e.createNodeViews(),this.initialized=!0}}componentWillUnmount(){const e=this.props.editor;if(!e||(this.initialized=!1,e.isDestroyed||e.view.setProps({nodeViews:{}}),this.unsubscribeToContentComponent&&this.unsubscribeToContentComponent(),e.contentComponent=null,!e.options.element.firstChild))return;const r=document.createElement("div");r.append(...e.options.element.childNodes),e.setOptions({element:r})}render(){const{editor:e,innerRef:r,...n}=this.props;return W.createElement(W.Fragment,null,W.createElement("div",{ref:EG(r,this.editorContentRef),...n}),(e==null?void 0:e.contentComponent)&&W.createElement(_G,{contentComponent:e.contentComponent}))}}const MG=m.forwardRef((t,e)=>{const r=W.useMemo(()=>Math.floor(Math.random()*4294967295).toString(),[t.editor]);return W.createElement(RG,{key:r,innerRef:e,...t})}),OG=W.memo(MG);var PG=function t(e,r){if(e===r)return!0;if(e&&r&&typeof e=="object"&&typeof r=="object"){if(e.constructor!==r.constructor)return!1;var n,s,o;if(Array.isArray(e)){if(n=e.length,n!=r.length)return!1;for(s=n;s--!==0;)if(!t(e[s],r[s]))return!1;return!0}if(e instanceof Map&&r instanceof Map){if(e.size!==r.size)return!1;for(s of e.entries())if(!r.has(s[0]))return!1;for(s of e.entries())if(!t(s[1],r.get(s[0])))return!1;return!0}if(e instanceof Set&&r instanceof Set){if(e.size!==r.size)return!1;for(s of e.entries())if(!r.has(s[0]))return!1;return!0}if(ArrayBuffer.isView(e)&&ArrayBuffer.isView(r)){if(n=e.length,n!=r.length)return!1;for(s=n;s--!==0;)if(e[s]!==r[s])return!1;return!0}if(e.constructor===RegExp)return e.source===r.source&&e.flags===r.flags;if(e.valueOf!==Object.prototype.valueOf)return e.valueOf()===r.valueOf();if(e.toString!==Object.prototype.toString)return e.toString()===r.toString();if(o=Object.keys(e),n=o.length,n!==Object.keys(r).length)return!1;for(s=n;s--!==0;)if(!Object.prototype.hasOwnProperty.call(r,o[s]))return!1;for(s=n;s--!==0;){var i=o[s];if(!(i==="_owner"&&e.$typeof)&&!t(e[i],r[i]))return!1}return!0}return e!==e&&r!==r},AG=CG(PG),gM={exports:{}},A0={};/** * @license React * use-sync-external-store-shim/with-selector.production.min.js * * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */var vM;function IG(){if(vM)return A0;vM=1;var t=W,e=P0;function r(d,u){return d===u&&(d!==0||1/d===1/u)||d!==d&&u!==u}var n=typeof Object.is=="function"?Object.is:r,s=e.useSyncExternalStore,o=t.useRef,i=t.useEffect,a=t.useMemo,c=t.useDebugValue;return A0.useSyncExternalStoreWithSelector=function(d,u,h,f,p){var g=o(null);if(g.current===null){var v={hasValue:!1,value:null};g.current=v}else v=g.current;g=a(function(){function x(C){if(!w){if(w=!0,b=C,C=f(C),p!==void 0&&v.hasValue){var N=v.value;if(p(N,C))return k=N}return k=C}if(N=k,n(b,C))return N;var E=f(C);return p!==void 0&&p(N,E)?N:(b=C,k=E)}var w=!1,b,k,S=h===void 0?null:h;return[function(){return x(u())},S===null?void 0:function(){return x(S())}]},[u,h,f,p]);var y=s(d,g[0],g[1]);return i(function(){v.hasValue=!0,v.value=y},[y]),c(y),y},A0}gM.exports=IG();var DG=gM.exports;const LG=typeof window<"u"?m.useLayoutEffect:m.useEffect;class $G{constructor(e){this.transactionNumber=0,this.lastTransactionNumber=0,this.subscribers=new Set,this.editor=e,this.lastSnapshot={editor:e,transactionNumber:0},this.getSnapshot=this.getSnapshot.bind(this),this.getServerSnapshot=this.getServerSnapshot.bind(this),this.watch=this.watch.bind(this),this.subscribe=this.subscribe.bind(this)}getSnapshot(){return this.transactionNumber===this.lastTransactionNumber?this.lastSnapshot:(this.lastTransactionNumber=this.transactionNumber,this.lastSnapshot={editor:this.editor,transactionNumber:this.transactionNumber},this.lastSnapshot)}getServerSnapshot(){return{editor:null,transactionNumber:0}}subscribe(e){return this.subscribers.add(e),()=>{this.subscribers.delete(e)}}watch(e){if(this.editor=e,this.editor){const r=()=>{this.transactionNumber+=1,this.subscribers.forEach(s=>s())},n=this.editor;return n.on("transaction",r),()=>{n.off("transaction",r)}}}}function FG(t){var e;const[r]=m.useState(()=>new $G(t.editor)),n=DG.useSyncExternalStoreWithSelector(r.subscribe,r.getSnapshot,r.getServerSnapshot,t.selector,(e=t.equalityFn)!==null&&e!==void 0?e:AG);return LG(()=>r.watch(t.editor),[t.editor,r]),m.useDebugValue(n),n}const zG=!1,I0=typeof window>"u",BG=I0||!!(typeof window<"u"&&window.next);class D0{constructor(e){this.editor=null,this.subscriptions=new Set,this.isComponentMounted=!1,this.previousDeps=null,this.instanceId="",this.options=e,this.subscriptions=new Set,this.setEditor(this.getInitialEditor()),this.scheduleDestroy(),this.getEditor=this.getEditor.bind(this),this.getServerSnapshot=this.getServerSnapshot.bind(this),this.subscribe=this.subscribe.bind(this),this.refreshEditorInstance=this.refreshEditorInstance.bind(this),this.scheduleDestroy=this.scheduleDestroy.bind(this),this.onRender=this.onRender.bind(this),this.createEditor=this.createEditor.bind(this)}setEditor(e){this.editor=e,this.instanceId=Math.random().toString(36).slice(2,9),this.subscriptions.forEach(r=>r())}getInitialEditor(){if(this.options.current.immediatelyRender===void 0)return I0||BG?null:this.createEditor();if(this.options.current.immediatelyRender&&I0&&zG)throw new Error("Tiptap Error: SSR has been detected, and `immediatelyRender` has been set to `true` this is an unsupported configuration that may result in errors, explicitly set `immediatelyRender` to `false` to avoid hydration mismatches.");return this.options.current.immediatelyRender?this.createEditor():null}createEditor(){const e={...this.options.current,onBeforeCreate:(...n)=>{var s,o;return(o=(s=this.options.current).onBeforeCreate)===null||o===void 0?void 0:o.call(s,...n)},onBlur:(...n)=>{var s,o;return(o=(s=this.options.current).onBlur)===null||o===void 0?void 0:o.call(s,...n)},onCreate:(...n)=>{var s,o;return(o=(s=this.options.current).onCreate)===null||o===void 0?void 0:o.call(s,...n)},onDestroy:(...n)=>{var s,o;return(o=(s=this.options.current).onDestroy)===null||o===void 0?void 0:o.call(s,...n)},onFocus:(...n)=>{var s,o;return(o=(s=this.options.current).onFocus)===null||o===void 0?void 0:o.call(s,...n)},onSelectionUpdate:(...n)=>{var s,o;return(o=(s=this.options.current).onSelectionUpdate)===null||o===void 0?void 0:o.call(s,...n)},onTransaction:(...n)=>{var s,o;return(o=(s=this.options.current).onTransaction)===null||o===void 0?void 0:o.call(s,...n)},onUpdate:(...n)=>{var s,o;return(o=(s=this.options.current).onUpdate)===null||o===void 0?void 0:o.call(s,...n)},onContentError:(...n)=>{var s,o;return(o=(s=this.options.current).onContentError)===null||o===void 0?void 0:o.call(s,...n)},onDrop:(...n)=>{var s,o;return(o=(s=this.options.current).onDrop)===null||o===void 0?void 0:o.call(s,...n)},onPaste:(...n)=>{var s,o;return(o=(s=this.options.current).onPaste)===null||o===void 0?void 0:o.call(s,...n)}};return new kG(e)}getEditor(){return this.editor}getServerSnapshot(){return null}subscribe(e){return this.subscriptions.add(e),()=>{this.subscriptions.delete(e)}}static compareOptions(e,r){return Object.keys(e).every(n=>["onCreate","onBeforeCreate","onDestroy","onUpdate","onTransaction","onFocus","onBlur","onSelectionUpdate","onContentError","onDrop","onPaste"].includes(n)?!0:n==="extensions"&&e.extensions&&r.extensions?e.extensions.length!==r.extensions.length?!1:e.extensions.every((s,o)=>{var i;return s===((i=r.extensions)===null||i===void 0?void 0:i[o])}):e[n]===r[n])}onRender(e){return()=>(this.isComponentMounted=!0,clearTimeout(this.scheduledDestructionTimeout),this.editor&&!this.editor.isDestroyed&&e.length===0?D0.compareOptions(this.options.current,this.editor.options)||this.editor.setOptions({...this.options.current,editable:this.editor.isEditable}):this.refreshEditorInstance(e),()=>{this.isComponentMounted=!1,this.scheduleDestroy()})}refreshEditorInstance(e){if(this.editor&&!this.editor.isDestroyed){if(this.previousDeps===null){this.previousDeps=e;return}if(this.previousDeps.length===e.length&&this.previousDeps.every((n,s)=>n===e[s]))return}this.editor&&!this.editor.isDestroyed&&this.editor.destroy(),this.setEditor(this.createEditor()),this.previousDeps=e}scheduleDestroy(){const e=this.instanceId,r=this.editor;this.scheduledDestructionTimeout=setTimeout(()=>{if(this.isComponentMounted&&this.instanceId===e){r&&r.setOptions(this.options.current);return}r&&!r.isDestroyed&&(r.destroy(),this.instanceId===e&&this.setEditor(null))},1)}}function UG(t={},e=[]){const r=m.useRef(t);r.current=t;const[n]=m.useState(()=>new D0(r)),s=P0.useSyncExternalStore(n.subscribe,n.getEditor,n.getServerSnapshot);return m.useDebugValue(s),m.useEffect(n.onRender(e)),FG({editor:s,selector:({transactionNumber:o})=>t.shouldRerenderOnTransaction===!1?null:t.immediatelyRender&&o===0?0:o+1}),s}m.createContext({editor:null}).Consumer;const VG=m.createContext({onDragStart:void 0}),WG=()=>m.useContext(VG);W.forwardRef((t,e)=>{const{onDragStart:r}=WG(),n=t.as||"div";return W.createElement(n,{...t,ref:e,"data-node-view-wrapper":"",onDragStart:r,style:{whiteSpace:"normal",...t.style}})});const HG=/^\s*>\s$/,qG=es.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:t}){return["blockquote",mr(this.options.HTMLAttributes,t),0]},addCommands(){return{setBlockquote:()=>({commands:t})=>t.wrapIn(this.name),toggleBlockquote:()=>({commands:t})=>t.toggleWrap(this.name),unsetBlockquote:()=>({commands:t})=>t.lift(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-b":()=>this.editor.commands.toggleBlockquote()}},addInputRules(){return[Wu({find:HG,type:this.type})]}}),KG=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,GG=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,YG=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,JG=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,QG=lo.create({name:"bold",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"strong"},{tag:"b",getAttrs:t=>t.style.fontWeight!=="normal"&&null},{style:"font-weight=400",clearMark:t=>t.type.name===this.name},{style:"font-weight",getAttrs:t=>/^(bold(er)?|[5-9]\d{2,})$/.test(t)&&null}]},renderHTML({HTMLAttributes:t}){return["strong",mr(this.options.HTMLAttributes,t),0]},addCommands(){return{setBold:()=>({commands:t})=>t.setMark(this.name),toggleBold:()=>({commands:t})=>t.toggleMark(this.name),unsetBold:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-b":()=>this.editor.commands.toggleBold(),"Mod-B":()=>this.editor.commands.toggleBold()}},addInputRules(){return[yc({find:KG,type:this.type}),yc({find:YG,type:this.type})]},addPasteRules(){return[xc({find:GG,type:this.type}),xc({find:JG,type:this.type})]}}),XG="listItem",yM="textStyle",xM=/^\s*([-+*])\s$/,ZG=es.create({name:"bulletList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:"ul"}]},renderHTML({HTMLAttributes:t}){return["ul",mr(this.options.HTMLAttributes,t),0]},addCommands(){return{toggleBulletList:()=>({commands:t,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(XG,this.editor.getAttributes(yM)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let t=Wu({find:xM,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(t=Wu({find:xM,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(yM),editor:this.editor})),[t]}}),eY=/(^|[^`])`([^`]+)`(?!`)/,tY=/(^|[^`])`([^`]+)`(?!`)/g,rY=lo.create({name:"code",addOptions(){return{HTMLAttributes:{}}},excludes:"_",code:!0,exitable:!0,parseHTML(){return[{tag:"code"}]},renderHTML({HTMLAttributes:t}){return["code",mr(this.options.HTMLAttributes,t),0]},addCommands(){return{setCode:()=>({commands:t})=>t.setMark(this.name),toggleCode:()=>({commands:t})=>t.toggleMark(this.name),unsetCode:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-e":()=>this.editor.commands.toggleCode()}},addInputRules(){return[yc({find:eY,type:this.type})]},addPasteRules(){return[xc({find:tY,type:this.type})]}}),nY=/^```([a-z]+)?[\s\n]$/,sY=/^~~~([a-z]+)?[\s\n]$/,oY=es.create({name:"codeBlock",addOptions(){return{languageClassPrefix:"language-",exitOnTripleEnter:!0,exitOnArrowDown:!0,defaultLanguage:null,HTMLAttributes:{}}},content:"text*",marks:"",group:"block",code:!0,defining:!0,addAttributes(){return{language:{default:this.options.defaultLanguage,parseHTML:t=>{var e;const{languageClassPrefix:r}=this.options,o=[...((e=t.firstElementChild)===null||e===void 0?void 0:e.classList)||[]].filter(i=>i.startsWith(r)).map(i=>i.replace(r,""))[0];return o||null},rendered:!1}}},parseHTML(){return[{tag:"pre",preserveWhitespace:"full"}]},renderHTML({node:t,HTMLAttributes:e}){return["pre",mr(this.options.HTMLAttributes,e),["code",{class:t.attrs.language?this.options.languageClassPrefix+t.attrs.language:null},0]]},addCommands(){return{setCodeBlock:t=>({commands:e})=>e.setNode(this.name,t),toggleCodeBlock:t=>({commands:e})=>e.toggleNode(this.name,"paragraph",t)}},addKeyboardShortcuts(){return{"Mod-Alt-c":()=>this.editor.commands.toggleCodeBlock(),Backspace:()=>{const{empty:t,$anchor:e}=this.editor.state.selection,r=e.pos===1;return!t||e.parent.type.name!==this.name?!1:r||!e.parent.textContent.length?this.editor.commands.clearNodes():!1},Enter:({editor:t})=>{if(!this.options.exitOnTripleEnter)return!1;const{state:e}=t,{selection:r}=e,{$from:n,empty:s}=r;if(!s||n.parent.type!==this.type)return!1;const o=n.parentOffset===n.parent.nodeSize-2,i=n.parent.textContent.endsWith(` `);return!o||!i?!1:t.chain().command(({tr:a})=>(a.delete(n.pos-2,n.pos),!0)).exitCode().run()},ArrowDown:({editor:t})=>{if(!this.options.exitOnArrowDown)return!1;const{state:e}=t,{selection:r,doc:n}=e,{$from:s,empty:o}=r;if(!o||s.parent.type!==this.type||!(s.parentOffset===s.parent.nodeSize-2))return!1;const a=s.after();return a===void 0?!1:n.nodeAt(a)?t.commands.command(({tr:d})=>(d.setSelection(_e.near(n.resolve(a))),!0)):t.commands.exitCode()}}},addInputRules(){return[M0({find:nY,type:this.type,getAttributes:t=>({language:t[1]})}),M0({find:sY,type:this.type,getAttributes:t=>({language:t[1]})})]},addProseMirrorPlugins(){return[new jr({key:new Zn("codeBlockVSCodeHandler"),props:{handlePaste:(t,e)=>{if(!e.clipboardData||this.editor.isActive(this.type.name))return!1;const r=e.clipboardData.getData("text/plain"),n=e.clipboardData.getData("vscode-editor-data"),s=n?JSON.parse(n):void 0,o=s==null?void 0:s.mode;if(!r||!o)return!1;const{tr:i,schema:a}=t.state,c=a.text(r.replace(/\r\n?/g,` `));return i.replaceSelectionWith(this.type.create({language:o},c)),i.selection.$from.parent.type!==this.type&&i.setSelection(Ce.near(i.doc.resolve(Math.max(0,i.selection.from-2)))),i.setMeta("paste",!0),t.dispatch(i),!0}}})]}}),iY=es.create({name:"doc",topNode:!0,content:"block+"});function aY(t={}){return new jr({view(e){return new lY(e,t)}})}class lY{constructor(e,r){var n;this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.width=(n=r.width)!==null&&n!==void 0?n:1,this.color=r.color===!1?void 0:r.color||"black",this.class=r.class,this.handlers=["dragover","dragend","drop","dragleave"].map(s=>{let o=i=>{this[s](i)};return e.dom.addEventListener(s,o),{name:s,handler:o}})}destroy(){this.handlers.forEach(({name:e,handler:r})=>this.editorView.dom.removeEventListener(e,r))}update(e,r){this.cursorPos!=null&&r.doc!=e.state.doc&&(this.cursorPos>e.state.doc.content.size?this.setCursor(null):this.updateOverlay())}setCursor(e){e!=this.cursorPos&&(this.cursorPos=e,e==null?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let e=this.editorView.state.doc.resolve(this.cursorPos),r=!e.parent.inlineContent,n,s=this.editorView.dom,o=s.getBoundingClientRect(),i=o.width/s.offsetWidth,a=o.height/s.offsetHeight;if(r){let h=e.nodeBefore,f=e.nodeAfter;if(h||f){let p=this.editorView.nodeDOM(this.cursorPos-(h?h.nodeSize:0));if(p){let g=p.getBoundingClientRect(),v=h?g.bottom:g.top;h&&f&&(v=(v+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let y=this.width/2*a;n={left:g.left,right:g.right,top:v-y,bottom:v+y}}}}if(!n){let h=this.editorView.coordsAtPos(this.cursorPos),f=this.width/2*i;n={left:h.left-f,right:h.left+f,top:h.top,bottom:h.bottom}}let c=this.editorView.dom.offsetParent;this.element||(this.element=c.appendChild(document.createElement("div")),this.class&&(this.element.className=this.class),this.element.style.cssText="position: absolute; z-index: 50; pointer-events: none;",this.color&&(this.element.style.backgroundColor=this.color)),this.element.classList.toggle("prosemirror-dropcursor-block",r),this.element.classList.toggle("prosemirror-dropcursor-inline",!r);let d,u;if(!c||c==document.body&&getComputedStyle(c).position=="static")d=-pageXOffset,u=-pageYOffset;else{let h=c.getBoundingClientRect(),f=h.width/c.offsetWidth,p=h.height/c.offsetHeight;d=h.left-c.scrollLeft*f,u=h.top-c.scrollTop*p}this.element.style.left=(n.left-d)/i+"px",this.element.style.top=(n.top-u)/a+"px",this.element.style.width=(n.right-n.left)/i+"px",this.element.style.height=(n.bottom-n.top)/a+"px"}scheduleRemoval(e){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),e)}dragover(e){if(!this.editorView.editable)return;let r=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),n=r&&r.inside>=0&&this.editorView.state.doc.nodeAt(r.inside),s=n&&n.type.spec.disableDropCursor,o=typeof s=="function"?s(this.editorView,r,e):s;if(r&&!o){let i=r.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let a=pT(this.editorView.state.doc,i,this.editorView.dragging.slice);a!=null&&(i=a)}this.setCursor(i),this.scheduleRemoval(5e3)}}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(e){this.editorView.dom.contains(e.relatedTarget)||this.setCursor(null)}}const cY=gr.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[aY(this.options)]}});class dt extends _e{constructor(e){super(e,e)}map(e,r){let n=e.resolve(r.map(this.head));return dt.valid(n)?new dt(n):_e.near(n)}content(){return oe.empty}eq(e){return e instanceof dt&&e.head==this.head}toJSON(){return{type:"gapcursor",pos:this.head}}static fromJSON(e,r){if(typeof r.pos!="number")throw new RangeError("Invalid input for GapCursor.fromJSON");return new dt(e.resolve(r.pos))}getBookmark(){return new L0(this.anchor)}static valid(e){let r=e.parent;if(r.isTextblock||!dY(e)||!uY(e))return!1;let n=r.type.spec.allowGapCursor;if(n!=null)return n;let s=r.contentMatchAt(e.index()).defaultType;return s&&s.isTextblock}static findGapCursorFrom(e,r,n=!1){e:for(;;){if(!n&&dt.valid(e))return e;let s=e.pos,o=null;for(let i=e.depth;;i--){let a=e.node(i);if(r>0?e.indexAfter(i)0){o=a.child(r>0?e.indexAfter(i):e.index(i)-1);break}else if(i==0)return null;s+=r;let c=e.doc.resolve(s);if(dt.valid(c))return c}for(;;){let i=r>0?o.firstChild:o.lastChild;if(!i){if(o.isAtom&&!o.isText&&!me.isSelectable(o)){e=e.doc.resolve(s+o.nodeSize*r),n=!1;continue e}break}o=i,s+=r;let a=e.doc.resolve(s);if(dt.valid(a))return a}return null}}}dt.prototype.visible=!1,dt.findFrom=dt.findGapCursorFrom,_e.jsonID("gapcursor",dt);class L0{constructor(e){this.pos=e}map(e){return new L0(e.map(this.pos))}resolve(e){let r=e.resolve(this.pos);return dt.valid(r)?new dt(r):_e.near(r)}}function wM(t){return t.isAtom||t.spec.isolating||t.spec.createGapCursor}function dY(t){for(let e=t.depth;e>=0;e--){let r=t.index(e),n=t.node(e);if(r==0){if(n.type.spec.isolating)return!0;continue}for(let s=n.child(r-1);;s=s.lastChild){if(s.childCount==0&&!s.inlineContent||wM(s.type))return!0;if(s.inlineContent)return!1}}return!0}function uY(t){for(let e=t.depth;e>=0;e--){let r=t.indexAfter(e),n=t.node(e);if(r==n.childCount){if(n.type.spec.isolating)return!0;continue}for(let s=n.child(r);;s=s.firstChild){if(s.childCount==0&&!s.inlineContent||wM(s.type))return!0;if(s.inlineContent)return!1}}return!0}function hY(){return new jr({props:{decorations:gY,createSelectionBetween(t,e,r){return e.pos==r.pos&&dt.valid(r)?new dt(r):null},handleClick:pY,handleKeyDown:fY,handleDOMEvents:{beforeinput:mY}}})}const fY=BR({ArrowLeft:Tm("horiz",-1),ArrowRight:Tm("horiz",1),ArrowUp:Tm("vert",-1),ArrowDown:Tm("vert",1)});function Tm(t,e){const r=t=="vert"?e>0?"down":"up":e>0?"right":"left";return function(n,s,o){let i=n.selection,a=e>0?i.$to:i.$from,c=i.empty;if(i instanceof Ce){if(!o.endOfTextblock(r)||a.depth==0)return!1;c=!1,a=n.doc.resolve(e>0?a.after():a.before())}let d=dt.findGapCursorFrom(a,e,c);return d?(s&&s(n.tr.setSelection(new dt(d))),!0):!1}}function pY(t,e,r){if(!t||!t.editable)return!1;let n=t.state.doc.resolve(e);if(!dt.valid(n))return!1;let s=t.posAtCoords({left:r.clientX,top:r.clientY});return s&&s.inside>-1&&me.isSelectable(t.state.doc.nodeAt(s.inside))?!1:(t.dispatch(t.state.tr.setSelection(new dt(n))),!0)}function mY(t,e){if(e.inputType!="insertCompositionText"||!(t.state.selection instanceof dt))return!1;let{$from:r}=t.state.selection,n=r.parent.contentMatchAt(r.index()).findWrapping(t.state.schema.nodes.text);if(!n)return!1;let s=Y.empty;for(let i=n.length-1;i>=0;i--)s=Y.from(n[i].createAndFill(null,s));let o=t.state.tr.replace(r.pos,r.pos,new oe(s,0,0));return o.setSelection(Ce.near(o.doc.resolve(r.pos+1))),t.dispatch(o),!1}function gY(t){if(!(t.selection instanceof dt))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",St.create(t.doc,[cn.widget(t.selection.head,e,{key:"gapcursor"})])}const vY=gr.create({name:"gapCursor",addProseMirrorPlugins(){return[hY()]},extendNodeSchema(t){var e;const r={name:t.name,options:t.options,storage:t.storage};return{allowGapCursor:(e=Re(le(t,"allowGapCursor",r)))!==null&&e!==void 0?e:null}}}),yY=es.create({name:"hardBreak",addOptions(){return{keepMarks:!0,HTMLAttributes:{}}},inline:!0,group:"inline",selectable:!1,linebreakReplacement:!0,parseHTML(){return[{tag:"br"}]},renderHTML({HTMLAttributes:t}){return["br",mr(this.options.HTMLAttributes,t)]},renderText(){return` `},addCommands(){return{setHardBreak:()=>({commands:t,chain:e,state:r,editor:n})=>t.first([()=>t.exitCode(),()=>t.command(()=>{const{selection:s,storedMarks:o}=r;if(s.$from.parent.type.spec.isolating)return!1;const{keepMarks:i}=this.options,{splittableMarks:a}=n.extensionManager,c=o||s.$to.parentOffset&&s.$from.marks();return e().insertContent({type:this.name}).command(({tr:d,dispatch:u})=>{if(u&&c&&i){const h=c.filter(f=>a.includes(f.type.name));d.ensureMarks(h)}return!0}).run()})])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}}),xY=es.create({name:"heading",addOptions(){return{levels:[1,2,3,4,5,6],HTMLAttributes:{}}},content:"inline*",group:"block",defining:!0,addAttributes(){return{level:{default:1,rendered:!1}}},parseHTML(){return this.options.levels.map(t=>({tag:`h${t}`,attrs:{level:t}}))},renderHTML({node:t,HTMLAttributes:e}){return[`h${this.options.levels.includes(t.attrs.level)?t.attrs.level:this.options.levels[0]}`,mr(this.options.HTMLAttributes,e),0]},addCommands(){return{setHeading:t=>({commands:e})=>this.options.levels.includes(t.level)?e.setNode(this.name,t):!1,toggleHeading:t=>({commands:e})=>this.options.levels.includes(t.level)?e.toggleNode(this.name,"paragraph",t):!1}},addKeyboardShortcuts(){return this.options.levels.reduce((t,e)=>({...t,[`Mod-Alt-${e}`]:()=>this.editor.commands.toggleHeading({level:e})}),{})},addInputRules(){return this.options.levels.map(t=>M0({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${t}})\\s Focus - Student Notes & Calendar App ),type:this.type,getAttributes:{level:t}}))}});var Rm=200,qt=function(){};qt.prototype.append=function(e){return e.length?(e=qt.from(e),!this.length&&e||e.length=r?qt.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,r))},qt.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)},qt.prototype.forEach=function(e,r,n){r===void 0&&(r=0),n===void 0&&(n=this.length),r<=n?this.forEachInner(e,r,n,0):this.forEachInvertedInner(e,r,n,0)},qt.prototype.map=function(e,r,n){r===void 0&&(r=0),n===void 0&&(n=this.length);var s=[];return this.forEach(function(o,i){return s.push(e(o,i))},r,n),s},qt.from=function(e){return e instanceof qt?e:e&&e.length?new bM(e):qt.empty};var bM=function(t){function e(n){t.call(this),this.values=n}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={length:{configurable:!0},depth:{configurable:!0}};return e.prototype.flatten=function(){return this.values},e.prototype.sliceInner=function(s,o){return s==0&&o==this.length?this:new e(this.values.slice(s,o))},e.prototype.getInner=function(s){return this.values[s]},e.prototype.forEachInner=function(s,o,i,a){for(var c=o;c=i;c--)if(s(this.values[c],a+c)===!1)return!1},e.prototype.leafAppend=function(s){if(this.length+s.length<=Rm)return new e(this.values.concat(s.flatten()))},e.prototype.leafPrepend=function(s){if(this.length+s.length<=Rm)return new e(s.flatten().concat(this.values))},r.length.get=function(){return this.values.length},r.depth.get=function(){return 0},Object.defineProperties(e.prototype,r),e}(qt);qt.empty=new bM([]);var wY=function(t){function e(r,n){t.call(this),this.left=r,this.right=n,this.length=r.length+n.length,this.depth=Math.max(r.depth,n.depth)+1}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},e.prototype.getInner=function(n){return na&&this.right.forEachInner(n,Math.max(s-a,0),Math.min(this.length,o)-a,i+a)===!1)return!1},e.prototype.forEachInvertedInner=function(n,s,o,i){var a=this.left.length;if(s>a&&this.right.forEachInvertedInner(n,s-a,Math.max(o,a)-a,i+a)===!1||o=o?this.right.slice(n-o,s-o):this.left.slice(n,o).append(this.right.slice(0,s-o))},e.prototype.leafAppend=function(n){var s=this.right.leafAppend(n);if(s)return new e(this.left,s)},e.prototype.leafPrepend=function(n){var s=this.left.leafPrepend(n);if(s)return new e(s,this.right)},e.prototype.appendInner=function(n){return this.left.depth>=Math.max(this.right.depth,n.depth)+1?new e(this.left,new e(this.right,n)):new e(this,n)},e}(qt);const bY=500;class ts{constructor(e,r){this.items=e,this.eventCount=r}popEvent(e,r){if(this.eventCount==0)return null;let n=this.items.length;for(;;n--)if(this.items.get(n-1).selection){--n;break}let s,o;r&&(s=this.remapping(n,this.items.length),o=s.maps.length);let i=e.tr,a,c,d=[],u=[];return this.items.forEach((h,f)=>{if(!h.step){s||(s=this.remapping(n,f+1),o=s.maps.length),o--,u.push(h);return}if(s){u.push(new fi(h.map));let p=h.step.map(s.slice(o)),g;p&&i.maybeStep(p).doc&&(g=i.mapping.maps[i.mapping.maps.length-1],d.push(new fi(g,void 0,void 0,d.length+u.length))),o--,g&&s.appendMap(g,o)}else i.maybeStep(h.step);if(h.selection)return a=s?h.selection.map(s.slice(o)):h.selection,c=new ts(this.items.slice(0,n).append(u.reverse().concat(d)),this.eventCount-1),!1},this.items.length,0),{remaining:c,transform:i,selection:a}}addTransform(e,r,n,s){let o=[],i=this.eventCount,a=this.items,c=!s&&a.length?a.get(a.length-1):null;for(let u=0;uSY&&(a=kY(a,d),i-=d),new ts(a.append(o),i)}remapping(e,r){let n=new _u;return this.items.forEach((s,o)=>{let i=s.mirrorOffset!=null&&o-s.mirrorOffset>=e?n.maps.length-s.mirrorOffset:void 0;n.appendMap(s.map,i)},e,r),n}addMaps(e){return this.eventCount==0?this:new ts(this.items.append(e.map(r=>new fi(r))),this.eventCount)}rebased(e,r){if(!this.eventCount)return this;let n=[],s=Math.max(0,this.items.length-r),o=e.mapping,i=e.steps.length,a=this.eventCount;this.items.forEach(f=>{f.selection&&a--},s);let c=r;this.items.forEach(f=>{let p=o.getMirror(--c);if(p==null)return;i=Math.min(i,p);let g=o.maps[p];if(f.step){let v=e.steps[p].invert(e.docs[p]),y=f.selection&&f.selection.map(o.slice(c+1,p));y&&a++,n.push(new fi(g,v,y))}else n.push(new fi(g))},s);let d=[];for(let f=r;fbY&&(h=h.compress(this.items.length-n.length)),h}emptyItemCount(){let e=0;return this.items.forEach(r=>{r.step||e++}),e}compress(e=this.items.length){let r=this.remapping(0,e),n=r.maps.length,s=[],o=0;return this.items.forEach((i,a)=>{if(a>=e)s.push(i),i.selection&&o++;else if(i.step){let c=i.step.map(r.slice(n)),d=c&&c.getMap();if(n--,d&&r.appendMap(d,n),c){let u=i.selection&&i.selection.map(r.slice(n));u&&o++;let h=new fi(d.invert(),c,u),f,p=s.length-1;(f=s.length&&s[p].merge(h))?s[p]=f:s.push(h)}}else i.map&&n--},this.items.length,0),new ts(qt.from(s.reverse()),o)}}ts.empty=new ts(qt.empty,0);function kY(t,e){let r;return t.forEach((n,s)=>{if(n.selection&&e--==0)return r=s,!1}),t.slice(r)}let fi=class aD{constructor(e,r,n,s){this.map=e,this.step=r,this.selection=n,this.mirrorOffset=s}merge(e){if(this.step&&e.step&&!e.selection){let r=e.step.merge(this.step);if(r)return new aD(r.getMap().invert(),r,this.selection)}}};class pi{constructor(e,r,n,s,o){this.done=e,this.undone=r,this.prevRanges=n,this.prevTime=s,this.prevComposition=o}}const SY=20;function NY(t,e,r,n){let s=r.getMeta(Ea),o;if(s)return s.historyState;r.getMeta(EY)&&(t=new pi(t.done,t.undone,null,0,-1));let i=r.getMeta("appendedTransaction");if(r.steps.length==0)return t;if(i&&i.getMeta(Ea))return i.getMeta(Ea).redo?new pi(t.done.addTransform(r,void 0,n,Mm(e)),t.undone,kM(r.mapping.maps),t.prevTime,t.prevComposition):new pi(t.done,t.undone.addTransform(r,void 0,n,Mm(e)),null,t.prevTime,t.prevComposition);if(r.getMeta("addToHistory")!==!1&&!(i&&i.getMeta("addToHistory")===!1)){let a=r.getMeta("composition"),c=t.prevTime==0||!i&&t.prevComposition!=a&&(t.prevTime<(r.time||0)-n.newGroupDelay||!CY(r,t.prevRanges)),d=i?$0(t.prevRanges,r.mapping):kM(r.mapping.maps);return new pi(t.done.addTransform(r,c?e.selection.getBookmark():void 0,n,Mm(e)),ts.empty,d,r.time,a??t.prevComposition)}else return(o=r.getMeta("rebased"))?new pi(t.done.rebased(r,o),t.undone.rebased(r,o),$0(t.prevRanges,r.mapping),t.prevTime,t.prevComposition):new pi(t.done.addMaps(r.mapping.maps),t.undone.addMaps(r.mapping.maps),$0(t.prevRanges,r.mapping),t.prevTime,t.prevComposition)}function CY(t,e){if(!e)return!1;if(!t.docChanged)return!0;let r=!1;return t.mapping.maps[0].forEach((n,s)=>{for(let o=0;o=e[o]&&(r=!0)}),r}function kM(t){let e=[];for(let r=t.length-1;r>=0&&e.length==0;r--)t[r].forEach((n,s,o,i)=>e.push(o,i));return e}function $0(t,e){if(!t)return null;let r=[];for(let n=0;n{let s=Ea.getState(r);if(!s||(t?s.undone:s.done).eventCount==0)return!1;if(n){let o=jY(s,r,t);o&&n(e?o.scrollIntoView():o)}return!0}}const CM=NM(!1,!0),jM=NM(!0,!0),TY=gr.create({name:"history",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:t,dispatch:e})=>CM(t,e),redo:()=>({state:t,dispatch:e})=>jM(t,e)}},addProseMirrorPlugins(){return[_Y(this.options)]},addKeyboardShortcuts(){return{"Mod-z":()=>this.editor.commands.undo(),"Shift-Mod-z":()=>this.editor.commands.redo(),"Mod-y":()=>this.editor.commands.redo(),"Mod-я":()=>this.editor.commands.undo(),"Shift-Mod-я":()=>this.editor.commands.redo()}}}),RY=es.create({name:"horizontalRule",addOptions(){return{HTMLAttributes:{}}},group:"block",parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:t}){return["hr",mr(this.options.HTMLAttributes,t)]},addCommands(){return{setHorizontalRule:()=>({chain:t,state:e})=>{if(!NG(e,e.schema.nodes[this.name]))return!1;const{selection:r}=e,{$from:n,$to:s}=r,o=t();return n.parentOffset===0?o.insertContentAt({from:Math.max(n.pos-1,0),to:s.pos},{type:this.name}):tG(r)?o.insertContentAt(s.pos,{type:this.name}):o.insertContent({type:this.name}),o.command(({tr:i,dispatch:a})=>{var c;if(a){const{$to:d}=i.selection,u=d.end();if(d.nodeAfter)d.nodeAfter.isTextblock?i.setSelection(Ce.create(i.doc,d.pos+1)):d.nodeAfter.isBlock?i.setSelection(me.create(i.doc,d.pos)):i.setSelection(Ce.create(i.doc,d.pos));else{const h=(c=d.parent.type.contentMatch.defaultType)===null||c===void 0?void 0:c.create();h&&(i.insert(u,h),i.setSelection(Ce.create(i.doc,u+1)))}i.scrollIntoView()}return!0}).run()}}},addInputRules(){return[SG({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}}),MY=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,OY=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,PY=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,AY=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,IY=lo.create({name:"italic",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"em"},{tag:"i",getAttrs:t=>t.style.fontStyle!=="normal"&&null},{style:"font-style=normal",clearMark:t=>t.type.name===this.name},{style:"font-style=italic"}]},renderHTML({HTMLAttributes:t}){return["em",mr(this.options.HTMLAttributes,t),0]},addCommands(){return{setItalic:()=>({commands:t})=>t.setMark(this.name),toggleItalic:()=>({commands:t})=>t.toggleMark(this.name),unsetItalic:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-i":()=>this.editor.commands.toggleItalic(),"Mod-I":()=>this.editor.commands.toggleItalic()}},addInputRules(){return[yc({find:MY,type:this.type}),yc({find:PY,type:this.type})]},addPasteRules(){return[xc({find:OY,type:this.type}),xc({find:AY,type:this.type})]}}),DY=es.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:t}){return["li",mr(this.options.HTMLAttributes,t),0]},addKeyboardShortcuts(){return{Enter:()=>this.editor.commands.splitListItem(this.name),Tab:()=>this.editor.commands.sinkListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)}}}),LY="listItem",EM="textStyle",_M=/^(\d+)\.\s$/,$Y=es.create({name:"orderedList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:"block list",content(){return`${this.options.itemTypeName}+`},addAttributes(){return{start:{default:1,parseHTML:t=>t.hasAttribute("start")?parseInt(t.getAttribute("start")||"",10):1},type:{default:null,parseHTML:t=>t.getAttribute("type")}}},parseHTML(){return[{tag:"ol"}]},renderHTML({HTMLAttributes:t}){const{start:e,...r}=t;return e===1?["ol",mr(this.options.HTMLAttributes,r),0]:["ol",mr(this.options.HTMLAttributes,t),0]},addCommands(){return{toggleOrderedList:()=>({commands:t,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(LY,this.editor.getAttributes(EM)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let t=Wu({find:_M,type:this.type,getAttributes:e=>({start:+e[1]}),joinPredicate:(e,r)=>r.childCount+r.attrs.start===+e[1]});return(this.options.keepMarks||this.options.keepAttributes)&&(t=Wu({find:_M,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:e=>({start:+e[1],...this.editor.getAttributes(EM)}),joinPredicate:(e,r)=>r.childCount+r.attrs.start===+e[1],editor:this.editor})),[t]}}),FY=es.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:t}){return["p",mr(this.options.HTMLAttributes,t),0]},addCommands(){return{setParagraph:()=>({commands:t})=>t.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),zY=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,BY=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,UY=lo.create({name:"strike",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"s"},{tag:"del"},{tag:"strike"},{style:"text-decoration",consuming:!1,getAttrs:t=>t.includes("line-through")?{}:!1}]},renderHTML({HTMLAttributes:t}){return["s",mr(this.options.HTMLAttributes,t),0]},addCommands(){return{setStrike:()=>({commands:t})=>t.setMark(this.name),toggleStrike:()=>({commands:t})=>t.toggleMark(this.name),unsetStrike:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-s":()=>this.editor.commands.toggleStrike()}},addInputRules(){return[yc({find:zY,type:this.type})]},addPasteRules(){return[xc({find:BY,type:this.type})]}}),VY=es.create({name:"text",group:"inline"}),WY=gr.create({name:"starterKit",addExtensions(){const t=[];return this.options.bold!==!1&&t.push(QG.configure(this.options.bold)),this.options.blockquote!==!1&&t.push(qG.configure(this.options.blockquote)),this.options.bulletList!==!1&&t.push(ZG.configure(this.options.bulletList)),this.options.code!==!1&&t.push(rY.configure(this.options.code)),this.options.codeBlock!==!1&&t.push(oY.configure(this.options.codeBlock)),this.options.document!==!1&&t.push(iY.configure(this.options.document)),this.options.dropcursor!==!1&&t.push(cY.configure(this.options.dropcursor)),this.options.gapcursor!==!1&&t.push(vY.configure(this.options.gapcursor)),this.options.hardBreak!==!1&&t.push(yY.configure(this.options.hardBreak)),this.options.heading!==!1&&t.push(xY.configure(this.options.heading)),this.options.history!==!1&&t.push(TY.configure(this.options.history)),this.options.horizontalRule!==!1&&t.push(RY.configure(this.options.horizontalRule)),this.options.italic!==!1&&t.push(IY.configure(this.options.italic)),this.options.listItem!==!1&&t.push(DY.configure(this.options.listItem)),this.options.orderedList!==!1&&t.push($Y.configure(this.options.orderedList)),this.options.paragraph!==!1&&t.push(FY.configure(this.options.paragraph)),this.options.strike!==!1&&t.push(UY.configure(this.options.strike)),this.options.text!==!1&&t.push(VY.configure(this.options.text)),t}}),HY=gr.create({name:"placeholder",addOptions(){return{emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",placeholder:"Write something …",showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){return[new jr({key:new Zn("placeholder"),props:{decorations:({doc:t,selection:e})=>{const r=this.editor.isEditable||!this.options.showOnlyWhenEditable,{anchor:n}=e,s=[];if(!r)return null;const o=this.editor.isEmpty;return t.descendants((i,a)=>{const c=n>=a&&n<=a+i.nodeSize,d=!i.isLeaf&&_m(i);if((c||!this.options.showOnlyCurrent)&&d){const u=[this.options.emptyNodeClass];o&&u.push(this.options.emptyEditorClass);const h=cn.node(a,a+i.nodeSize,{class:u.join(" "),"data-placeholder":typeof this.options.placeholder=="function"?this.options.placeholder({editor:this.editor,node:i,pos:a,hasAnchor:c}):this.options.placeholder});s.push(h)}return this.options.includeChildren}),St.create(t,s)}}})]}}),qY=lo.create({name:"underline",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"u"},{style:"text-decoration",consuming:!1,getAttrs:t=>t.includes("underline")?{}:!1}]},renderHTML({HTMLAttributes:t}){return["u",mr(this.options.HTMLAttributes,t),0]},addCommands(){return{setUnderline:()=>({commands:t})=>t.setMark(this.name),toggleUnderline:()=>({commands:t})=>t.toggleMark(this.name),unsetUnderline:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-u":()=>this.editor.commands.toggleUnderline(),"Mod-U":()=>this.editor.commands.toggleUnderline()}}});var KY="Separator",TM="horizontal",GY=["horizontal","vertical"],RM=m.forwardRef((t,e)=>{const{decorative:r,orientation:n=TM,...s}=t,o=YY(n)?n:TM,a=r?{role:"none"}:{"aria-orientation":o==="vertical"?o:void 0,role:"separator"};return l.jsx(se.div,{"data-orientation":o,...a,...s,ref:e})});RM.displayName=KY;function YY(t){return GY.includes(t)}var MM=RM;const wc=m.forwardRef(({className:t,orientation:e="horizontal",decorative:r=!0,...n},s)=>l.jsx(MM,{ref:s,decorative:r,orientation:e,className:B("shrink-0 bg-border",e==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",t),...n}));wc.displayName=MM.displayName;function JY({content:t="",onChange:e,placeholder:r="Start typing your notes...",className:n}){const s=UG({extensions:[WY.configure({heading:{levels:[1,2,3]}}),qY,HY.configure({placeholder:r})],content:t,onUpdate:({editor:i})=>{e==null||e(i.getHTML())},editorProps:{attributes:{class:"prose prose-sm dark:prose-invert max-w-none focus:outline-none min-h-[200px] p-4"}}});if(!s)return null;const o=({onClick:i,isActive:a,children:c,title:d})=>l.jsx(K,{variant:a?"secondary":"ghost",size:"icon-sm",onClick:i,title:d,type:"button",children:c});return l.jsxs("div",{className:B("border rounded-lg overflow-hidden bg-background",n),children:[l.jsxs("div",{className:"flex items-center gap-1 p-2 border-b bg-secondary/30 flex-wrap",children:[l.jsx(o,{onClick:()=>s.chain().focus().toggleHeading({level:1}).run(),isActive:s.isActive("heading",{level:1}),title:"Heading 1",children:l.jsx(W3,{className:"h-4 w-4"})}),l.jsx(o,{onClick:()=>s.chain().focus().toggleHeading({level:2}).run(),isActive:s.isActive("heading",{level:2}),title:"Heading 2",children:l.jsx(H3,{className:"h-4 w-4"})}),l.jsx(o,{onClick:()=>s.chain().focus().toggleHeading({level:3}).run(),isActive:s.isActive("heading",{level:3}),title:"Heading 3",children:l.jsx(q3,{className:"h-4 w-4"})}),l.jsx(wc,{orientation:"vertical",className:"h-6 mx-1"}),l.jsx(o,{onClick:()=>s.chain().focus().toggleBold().run(),isActive:s.isActive("bold"),title:"Bold",children:l.jsx(P3,{className:"h-4 w-4"})}),l.jsx(o,{onClick:()=>s.chain().focus().toggleItalic().run(),isActive:s.isActive("italic"),title:"Italic",children:l.jsx(G3,{className:"h-4 w-4"})}),l.jsx(o,{onClick:()=>s.chain().focus().toggleUnderline().run(),isActive:s.isActive("underline"),title:"Underline",children:l.jsx(fL,{className:"h-4 w-4"})}),l.jsx(o,{onClick:()=>s.chain().focus().toggleStrike().run(),isActive:s.isActive("strike"),title:"Strikethrough",children:l.jsx(cL,{className:"h-4 w-4"})}),l.jsx(wc,{orientation:"vertical",className:"h-6 mx-1"}),l.jsx(o,{onClick:()=>s.chain().focus().toggleBulletList().run(),isActive:s.isActive("bulletList"),title:"Bullet List",children:l.jsx(yC,{className:"h-4 w-4"})}),l.jsx(o,{onClick:()=>s.chain().focus().toggleOrderedList().run(),isActive:s.isActive("orderedList"),title:"Numbered List",children:l.jsx(J3,{className:"h-4 w-4"})}),l.jsx(o,{onClick:()=>s.chain().focus().toggleBlockquote().run(),isActive:s.isActive("blockquote"),title:"Quote",children:l.jsx(nL,{className:"h-4 w-4"})}),l.jsx(wc,{orientation:"vertical",className:"h-6 mx-1"}),l.jsx(o,{onClick:()=>s.chain().focus().undo().run(),title:"Undo",children:l.jsx(NC,{className:"h-4 w-4"})}),l.jsx(o,{onClick:()=>s.chain().focus().redo().run(),title:"Redo",children:l.jsx(wC,{className:"h-4 w-4"})})]}),l.jsx(OG,{editor:s})]})}function Hu(t,[e,r]){return Math.min(r,Math.max(e,t))}var OM=["PageUp","PageDown"],PM=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],AM={"from-left":["Home","PageDown","ArrowDown","ArrowLeft"],"from-right":["Home","PageDown","ArrowDown","ArrowRight"],"from-bottom":["Home","PageDown","ArrowDown","ArrowLeft"],"from-top":["Home","PageDown","ArrowUp","ArrowLeft"]},bc="Slider",[z0,QY,XY]=Ld(bc),[IM,Ure]=Ft(bc,[XY]),[ZY,Om]=IM(bc),DM=m.forwardRef((t,e)=>{const{name:r,min:n=0,max:s=100,step:o=1,orientation:i="horizontal",disabled:a=!1,minStepsBetweenThumbs:c=0,defaultValue:d=[n],value:u,onValueChange:h=()=>{},onValueCommit:f=()=>{},inverted:p=!1,form:g,...v}=t,y=m.useRef(new Set),x=m.useRef(0),b=i==="horizontal"?eJ:tJ,[k=[],S]=Wn({prop:u,defaultProp:d,onChange:P=>{var A;(A=[...y.current][x.current])==null||A.focus(),h(P)}}),C=m.useRef(k);function N(P){const T=iJ(k,P);_(P,T)}function E(P){_(P,x.current)}function j(){const P=C.current[x.current];k[x.current]!==P&&f(k)}function _(P,T,{commit:A}={commit:!1}){const I=dJ(o),V=uJ(Math.round((P-n)/o)*o+n,I),L=Hu(V,[n,s]);S((U=[])=>{const M=sJ(U,L,T);if(cJ(M,c*o)){x.current=M.indexOf(L);const D=String(M)!==String(U);return D&&A&&f(M),D?M:U}else return U})}return l.jsx(ZY,{scope:t.__scopeSlider,name:r,disabled:a,min:n,max:s,valueIndexToChangeRef:x,thumbs:y.current,values:k,orientation:i,form:g,children:l.jsx(z0.Provider,{scope:t.__scopeSlider,children:l.jsx(z0.Slot,{scope:t.__scopeSlider,children:l.jsx(b,{"aria-disabled":a,"data-disabled":a?"":void 0,...v,ref:e,onPointerDown:Q(v.onPointerDown,()=>{a||(C.current=k)}),min:n,max:s,inverted:p,onSlideStart:a?void 0:N,onSlideMove:a?void 0:E,onSlideEnd:a?void 0:j,onHomeKeyDown:()=>!a&&_(n,0,{commit:!0}),onEndKeyDown:()=>!a&&_(s,k.length-1,{commit:!0}),onStepKeyDown:({event:P,direction:T})=>{if(!a){const V=OM.includes(P.key)||P.shiftKey&&PM.includes(P.key)?10:1,L=x.current,U=k[L],M=o*V*T;_(U+M,L,{commit:!0})}}})})})})});DM.displayName=bc;var[LM,$M]=IM(bc,{startEdge:"left",endEdge:"right",size:"width",direction:1}),eJ=m.forwardRef((t,e)=>{const{min:r,max:n,dir:s,inverted:o,onSlideStart:i,onSlideMove:a,onSlideEnd:c,onStepKeyDown:d,...u}=t,[h,f]=m.useState(null),p=we(e,b=>f(b)),g=m.useRef(void 0),v=ha(s),y=v==="ltr",x=y&&!o||!y&&o;function w(b){const k=g.current||h.getBoundingClientRect(),S=[0,k.width],N=V0(S,x?[r,n]:[n,r]);return g.current=k,N(b-k.left)}return l.jsx(LM,{scope:t.__scopeSlider,startEdge:x?"left":"right",endEdge:x?"right":"left",direction:x?1:-1,size:"width",children:l.jsx(FM,{dir:v,"data-orientation":"horizontal",...u,ref:p,style:{...u.style,"--radix-slider-thumb-transform":"translateX(-50%)"},onSlideStart:b=>{const k=w(b.clientX);i==null||i(k)},onSlideMove:b=>{const k=w(b.clientX);a==null||a(k)},onSlideEnd:()=>{g.current=void 0,c==null||c()},onStepKeyDown:b=>{const S=AM[x?"from-left":"from-right"].includes(b.key);d==null||d({event:b,direction:S?-1:1})}})})}),tJ=m.forwardRef((t,e)=>{const{min:r,max:n,inverted:s,onSlideStart:o,onSlideMove:i,onSlideEnd:a,onStepKeyDown:c,...d}=t,u=m.useRef(null),h=we(e,u),f=m.useRef(void 0),p=!s;function g(v){const y=f.current||u.current.getBoundingClientRect(),x=[0,y.height],b=V0(x,p?[n,r]:[r,n]);return f.current=y,b(v-y.top)}return l.jsx(LM,{scope:t.__scopeSlider,startEdge:p?"bottom":"top",endEdge:p?"top":"bottom",size:"height",direction:p?1:-1,children:l.jsx(FM,{"data-orientation":"vertical",...d,ref:h,style:{...d.style,"--radix-slider-thumb-transform":"translateY(50%)"},onSlideStart:v=>{const y=g(v.clientY);o==null||o(y)},onSlideMove:v=>{const y=g(v.clientY);i==null||i(y)},onSlideEnd:()=>{f.current=void 0,a==null||a()},onStepKeyDown:v=>{const x=AM[p?"from-bottom":"from-top"].includes(v.key);c==null||c({event:v,direction:x?-1:1})}})})}),FM=m.forwardRef((t,e)=>{const{__scopeSlider:r,onSlideStart:n,onSlideMove:s,onSlideEnd:o,onHomeKeyDown:i,onEndKeyDown:a,onStepKeyDown:c,...d}=t,u=Om(bc,r);return l.jsx(se.span,{...d,ref:e,onKeyDown:Q(t.onKeyDown,h=>{h.key==="Home"?(i(h),h.preventDefault()):h.key==="End"?(a(h),h.preventDefault()):OM.concat(PM).includes(h.key)&&(c(h),h.preventDefault())}),onPointerDown:Q(t.onPointerDown,h=>{const f=h.target;f.setPointerCapture(h.pointerId),h.preventDefault(),u.thumbs.has(f)?f.focus():n(h)}),onPointerMove:Q(t.onPointerMove,h=>{h.target.hasPointerCapture(h.pointerId)&&s(h)}),onPointerUp:Q(t.onPointerUp,h=>{const f=h.target;f.hasPointerCapture(h.pointerId)&&(f.releasePointerCapture(h.pointerId),o(h))})})}),zM="SliderTrack",BM=m.forwardRef((t,e)=>{const{__scopeSlider:r,...n}=t,s=Om(zM,r);return l.jsx(se.span,{"data-disabled":s.disabled?"":void 0,"data-orientation":s.orientation,...n,ref:e})});BM.displayName=zM;var B0="SliderRange",UM=m.forwardRef((t,e)=>{const{__scopeSlider:r,...n}=t,s=Om(B0,r),o=$M(B0,r),i=m.useRef(null),a=we(e,i),c=s.values.length,d=s.values.map(f=>HM(f,s.min,s.max)),u=c>1?Math.min(...d):0,h=100-Math.max(...d);return l.jsx(se.span,{"data-orientation":s.orientation,"data-disabled":s.disabled?"":void 0,...n,ref:a,style:{...t.style,[o.startEdge]:u+"%",[o.endEdge]:h+"%"}})});UM.displayName=B0;var U0="SliderThumb",VM=m.forwardRef((t,e)=>{const r=QY(t.__scopeSlider),[n,s]=m.useState(null),o=we(e,a=>s(a)),i=m.useMemo(()=>n?r().findIndex(a=>a.ref.current===n):-1,[r,n]);return l.jsx(rJ,{...t,ref:o,index:i})}),rJ=m.forwardRef((t,e)=>{const{__scopeSlider:r,index:n,name:s,...o}=t,i=Om(U0,r),a=$M(U0,r),[c,d]=m.useState(null),u=we(e,w=>d(w)),h=c?i.form||!!c.closest("form"):!0,f=Jd(c),p=i.values[n],g=p===void 0?0:HM(p,i.min,i.max),v=oJ(n,i.values.length),y=f==null?void 0:f[a.size],x=y?aJ(y,g,a.direction):0;return m.useEffect(()=>{if(c)return i.thumbs.add(c),()=>{i.thumbs.delete(c)}},[c,i.thumbs]),l.jsxs("span",{style:{transform:"var(--radix-slider-thumb-transform)",position:"absolute",[a.startEdge]:`calc(${g}% + ${x}px)`},children:[l.jsx(z0.ItemSlot,{scope:t.__scopeSlider,children:l.jsx(se.span,{role:"slider","aria-label":t["aria-label"]||v,"aria-valuemin":i.min,"aria-valuenow":p,"aria-valuemax":i.max,"aria-orientation":i.orientation,"data-orientation":i.orientation,"data-disabled":i.disabled?"":void 0,tabIndex:i.disabled?void 0:0,...o,ref:u,style:p===void 0?{display:"none"}:t.style,onFocus:Q(t.onFocus,()=>{i.valueIndexToChangeRef.current=n})})}),h&&l.jsx(WM,{name:s??(i.name?i.name+(i.values.length>1?"[]":""):void 0),form:i.form,value:p},n)]})});VM.displayName=U0;var nJ="RadioBubbleInput",WM=m.forwardRef(({__scopeSlider:t,value:e,...r},n)=>{const s=m.useRef(null),o=we(s,n),i=tu(e);return m.useEffect(()=>{const a=s.current;if(!a)return;const c=window.HTMLInputElement.prototype,u=Object.getOwnPropertyDescriptor(c,"value").set;if(i!==e&&u){const h=new Event("input",{bubbles:!0});u.call(a,e),a.dispatchEvent(h)}},[i,e]),l.jsx(se.input,{style:{display:"none"},...r,ref:o,defaultValue:e})});WM.displayName=nJ;function sJ(t=[],e,r){const n=[...t];return n[r]=e,n.sort((s,o)=>s-o)}function HM(t,e,r){const o=100/(r-e)*(t-e);return Hu(o,[0,100])}function oJ(t,e){return e>2?`Value ${t+1} of ${e}`:e===2?["Minimum","Maximum"][t]:void 0}function iJ(t,e){if(t.length===1)return 0;const r=t.map(s=>Math.abs(s-e)),n=Math.min(...r);return r.indexOf(n)}function aJ(t,e,r){const n=t/2,o=V0([0,50],[0,n]);return(n-o(e)*r)*r}function lJ(t){return t.slice(0,-1).map((e,r)=>t[r+1]-e)}function cJ(t,e){if(e>0){const r=lJ(t);return Math.min(...r)>=e}return!0}function V0(t,e){return r=>{if(t[0]===t[1]||e[0]===e[1])return e[0];const n=(e[1]-e[0])/(t[1]-t[0]);return e[0]+n*(r-t[0])}}function dJ(t){return(String(t).split(".")[1]||"").length}function uJ(t,e){const r=Math.pow(10,e);return Math.round(t*r)/r}var qM=DM,hJ=BM,fJ=UM,pJ=VM;const KM=m.forwardRef(({className:t,...e},r)=>l.jsxs(qM,{ref:r,className:B("relative flex w-full touch-none select-none items-center",t),...e,children:[l.jsx(hJ,{className:"relative h-2 w-full grow overflow-hidden rounded-full bg-secondary",children:l.jsx(fJ,{className:"absolute h-full bg-primary"})}),l.jsx(pJ,{className:"block h-5 w-5 rounded-full border-2 border-primary bg-background ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50"})]}));KM.displayName=qM.displayName;const mJ=["#000000","#ef4444","#3b82f6","#22c55e","#f59e0b","#8b5cf6","#ec4899"];function gJ({width:t=800,height:e=400,onDrawingChange:r,initialDrawing:n,className:s}){const o=m.useRef(null),[i,a]=m.useState(!1),[c,d]=m.useState("pen"),[u,h]=m.useState("#000000"),[f,p]=m.useState(3),[g,v]=m.useState([]),[y,x]=m.useState(null),[w,b]=m.useState([]),[k,S]=m.useState([]);m.useEffect(()=>{const A=o.current;if(!A)return;const I=A.getContext("2d");I&&(I.fillStyle="#ffffff",I.fillRect(0,0,A.width,A.height),[...g,y].filter(Boolean).forEach(V=>{if(!(!V||V.points.length<2)){I.beginPath(),I.lineCap="round",I.lineJoin="round",V.tool==="eraser"?(I.globalCompositeOperation="destination-out",I.strokeStyle="rgba(255,255,255,1)"):(I.globalCompositeOperation="source-over",I.strokeStyle=V.color),I.lineWidth=V.width,I.moveTo(V.points[0].x,V.points[0].y);for(let L=1;L{if(r){const A=o.current;A&&g.length>0?r(A.toDataURL("image/png")):g.length===0&&r(null)}},[g,r]),m.useEffect(()=>{if(n&&o.current){const A=o.current.getContext("2d");if(!A)return;const I=new Image;I.onload=()=>{A.drawImage(I,0,0)},I.src=n}},[n]);const C=m.useCallback(A=>{const I=o.current;if(!I)return{x:0,y:0};const V=I.getBoundingClientRect(),L=I.width/V.width,U=I.height/V.height;if("touches"in A){const M=A.touches[0];return{x:(M.clientX-V.left)*L,y:(M.clientY-V.top)*U}}return{x:(A.clientX-V.left)*L,y:(A.clientY-V.top)*U}},[]),N=m.useCallback(A=>{A.preventDefault();const I=C(A);a(!0),x({points:[I],color:u,width:c==="eraser"?f*3:f,tool:c})},[u,f,c,C]),E=m.useCallback(A=>{if(!i||!y)return;A.preventDefault();const I=C(A);x(V=>V?{...V,points:[...V.points,I]}:null)},[i,y,C]),j=m.useCallback(()=>{y&&y.points.length>1&&(b(A=>[...A,g]),S([]),v(A=>[...A,y])),a(!1),x(null)},[y,g]),_=m.useCallback(()=>{if(w.length===0)return;const A=w[w.length-1];S(I=>[...I,g]),v(A),b(I=>I.slice(0,-1))},[g,w]),P=m.useCallback(()=>{if(k.length===0)return;const A=k[k.length-1];b(I=>[...I,g]),v(A),S(I=>I.slice(0,-1))},[g,k]),T=m.useCallback(()=>{g.length>0&&(b(A=>[...A,g]),S([])),v([])},[g]);return l.jsxs("div",{className:B("space-y-3",s),children:[l.jsxs("div",{className:"flex items-center gap-4 flex-wrap",children:[l.jsxs("div",{className:"flex items-center gap-1 bg-secondary rounded-lg p-1",children:[l.jsx(K,{variant:c==="pen"?"default":"ghost",size:"icon-sm",onClick:()=>d("pen"),children:l.jsx(tL,{className:"h-4 w-4"})}),l.jsx(K,{variant:c==="eraser"?"default":"ghost",size:"icon-sm",onClick:()=>d("eraser"),children:l.jsx($3,{className:"h-4 w-4"})})]}),l.jsx("div",{className:"flex items-center gap-1",children:mJ.map(A=>l.jsx("button",{className:B("w-6 h-6 rounded-full border-2 transition-transform hover:scale-110",u===A?"border-foreground scale-110":"border-transparent"),style:{backgroundColor:A},onClick:()=>h(A)},A))}),l.jsxs("div",{className:"flex items-center gap-2 min-w-[120px]",children:[l.jsx(eL,{className:"h-3 w-3 text-muted-foreground"}),l.jsx(KM,{value:[f],onValueChange:([A])=>p(A),min:1,max:20,step:1,className:"flex-1"}),l.jsx(Rt,{className:"h-3 w-3 text-muted-foreground"})]}),l.jsxs("div",{className:"flex items-center gap-1 ml-auto",children:[l.jsx(K,{variant:"ghost",size:"icon-sm",onClick:_,disabled:w.length===0,children:l.jsx(NC,{className:"h-4 w-4"})}),l.jsx(K,{variant:"ghost",size:"icon-sm",onClick:P,disabled:k.length===0,children:l.jsx(wC,{className:"h-4 w-4"})}),l.jsx(K,{variant:"ghost",size:"icon-sm",onClick:T,className:"text-destructive hover:text-destructive",children:l.jsx(Ky,{className:"h-4 w-4"})})]})]}),l.jsx("div",{className:"border rounded-lg overflow-hidden bg-white",children:l.jsx("canvas",{ref:o,width:t,height:e,className:"w-full cursor-crosshair touch-none",style:{aspectRatio:`${t}/${e}`},onMouseDown:N,onMouseMove:E,onMouseUp:j,onMouseLeave:j,onTouchStart:N,onTouchMove:E,onTouchEnd:j})})]})}function W0({open:t,onOpenChange:e,eventId:r,classId:n,onNoteSaved:s}){const[o,i]=m.useState(""),[a,c]=m.useState(""),[d,u]=m.useState(null),[h,f]=m.useState(!1),[p,g]=m.useState("text"),{toast:v}=gs(),y=async()=>{if(!a&&!d){v({title:"Nothing to save",description:"Add some text or drawing before saving",variant:"destructive"});return}f(!0);try{const{data:{user:w}}=await q.auth.getUser();if(!w)throw new Error("Not authenticated");let b=a,k=null;if(d){const E=await(await fetch(d)).blob(),j=`${w.id}/${Date.now()}-drawing.png`,{data:_,error:P}=await q.storage.from("audio-notes").upload(j,E,{contentType:"image/png"});if(P)console.error("Failed to upload drawing:",P);else{const{data:{publicUrl:T}}=q.storage.from("audio-notes").getPublicUrl(j);k=T}}const{data:S,error:C}=await q.from("notes").insert({user_id:w.id,event_id:r||null,class_id:n||null,type:"text",title:o||"Untitled Note",content:b,transcription:k?`[Drawing attached: ${k}]`:null}).select().single();if(C)throw new Error(`Failed to save note: ${C.message}`);if(a){const{data:{session:N}}=await q.auth.getSession();if(N){const E=a.replace(/<[^>]*>/g,""),{data:j,error:_}=await q.functions.invoke("process-audio-note",{body:{noteId:S.id,transcription:E,classId:n||null,eventId:r||null}});_?console.error("Failed to process note:",_):(j==null?void 0:j.todosExtracted)>0&&v({title:`${j.todosExtracted} to-do${j.todosExtracted>1?"s":""} extracted!`,description:"AI found action items in your note"})}}v({title:"Note saved",description:"Your note has been saved successfully"}),s==null||s(S.id),i(""),c(""),u(null),e(!1)}catch(w){console.error("Failed to save note:",w),v({title:"Save failed",description:w instanceof Error?w.message:"Failed to save note",variant:"destructive"})}finally{f(!1)}},x=()=>{i(""),c(""),u(null),e(!1)};return l.jsx(Vp,{open:t,onOpenChange:x,children:l.jsxs(bu,{side:"bottom",className:"h-[90vh] flex flex-col",children:[l.jsxs(ku,{className:"flex-row items-center justify-between space-y-0 pb-4",children:[l.jsxs("div",{className:"flex items-center gap-3 flex-1",children:[l.jsx("div",{className:"p-2 rounded-lg bg-primary/10",children:l.jsx(zt,{className:"h-5 w-5 text-primary"})}),l.jsx(Ne,{value:o,onChange:w=>i(w.target.value),placeholder:"Note title...",className:"text-lg font-semibold border-none shadow-none focus-visible:ring-0 p-0 h-auto"})]}),l.jsx("div",{className:"flex items-center gap-2",children:l.jsxs(K,{variant:"glow",onClick:y,disabled:h,children:[h?l.jsx(Bt,{className:"h-4 w-4 animate-spin"}):l.jsx(sL,{className:"h-4 w-4"}),"Save Note"]})})]}),l.jsxs(no,{value:p,onValueChange:g,className:"flex-1 flex flex-col min-h-0",children:[l.jsxs(ks,{className:"w-fit",children:[l.jsxs(Ze,{value:"text",className:"gap-2",children:[l.jsx(zt,{className:"h-4 w-4"}),"Text"]}),l.jsxs(Ze,{value:"draw",className:"gap-2",children:[l.jsx(rL,{className:"h-4 w-4"}),"Draw"]})]}),l.jsxs(et,{value:"text",className:"flex-1 mt-4 min-h-0 overflow-auto",children:[l.jsx(JY,{content:a,onChange:c,placeholder:"Start typing your notes... Use headings, lists, and formatting to organize your thoughts.",className:"h-full"}),l.jsxs("div",{className:"mt-3 flex items-center gap-2 text-xs text-muted-foreground",children:[l.jsx(Nr,{className:"h-3 w-3"}),l.jsx("span",{children:"AI will automatically extract to-dos from your notes"})]})]}),l.jsxs(et,{value:"draw",className:"flex-1 mt-4 min-h-0 overflow-auto",children:[l.jsx(gJ,{width:1200,height:600,onDrawingChange:u,initialDrawing:d}),l.jsx("p",{className:"mt-3 text-xs text-muted-foreground",children:"Use the pen tool to draw, scribble notes, or create diagrams. Your drawing will be saved with your note."})]})]})]})})}const vJ=[{name:"Calendar",href:"/calendar",icon:Sr},{name:"Dashboard",href:"/dashboard",icon:Hy},{name:"Classes",href:"/classes",icon:vt},{name:"To-Do",href:"/todo",icon:jl},{name:"Study Hub",href:"/study-groups",icon:$r},{name:"Study Mode",href:"/study",icon:Wy},{name:"Weekly Recap",href:"/recap",icon:Nr}];function yJ({onNavigate:t}){const{sidebarOpen:e,toggleSidebar:r,toggleSearch:n,classes:s,assignments:o}=Ot(),i=du(),{focusModeEnabled:a,toggleFocusMode:c}=C_(),{classes:d}=ua(),u=d.length>0?d.map(S=>({id:S.id,name:S.name,code:S.code||S.name,color:S.color,instructor:S.professor_name})):s,h=ra(),[f,p]=m.useState(!1),[g,v]=m.useState(null),[y,x]=m.useState(!1),w=o.filter(S=>S.status!=="completed").length,b=()=>{p(!0)},k=S=>{v(S),p(!1),x(!0)};return l.jsxs("aside",{className:B("h-screen border-r border-border bg-sidebar transition-all duration-300 shadow-sm","max-h-[100dvh]",i?"w-[min(280px,85vw)]":e?"w-64":"w-16"),children:[l.jsxs("div",{className:"flex h-full flex-col",children:[l.jsxs("div",{className:B("flex h-16 border-b border-border px-4 gap-2",e?"items-center justify-between":"flex-col items-center justify-center py-2"),children:[l.jsxs(rn,{to:"/landing",onClick:()=>t==null?void 0:t(),className:B("flex items-center rounded-lg hover:opacity-90 transition-opacity shrink-0",e?"gap-3":"justify-center"),children:[l.jsx("div",{className:B("rounded-xl gradient-primary flex items-center justify-center shadow-md",e?"h-9 w-9":"h-8 w-8 rounded-lg"),children:l.jsx("span",{className:B("font-bold text-primary-foreground",e?"text-lg":"text-sm"),children:"F"})}),e&&l.jsx("span",{className:"text-xl font-semibold text-foreground tracking-tight",children:"Focus"})]}),l.jsx(K,{variant:"ghost",size:"icon-sm",onClick:r,className:"shrink-0",children:e?l.jsx(Nl,{className:"h-4 w-4"}):l.jsx(wt,{className:"h-4 w-4"})})]}),l.jsx("div",{className:"p-3 border-b border-border",children:l.jsxs(K,{variant:"glow",className:B("w-full",!e&&"px-0"),onClick:b,children:[l.jsx(Rt,{className:"h-4 w-4"}),e&&l.jsx("span",{children:"New Note"})]})}),l.jsxs("nav",{className:"space-y-1 px-3 py-4 shrink-0",children:[vJ.map(S=>{const C=h.pathname===S.href;return l.jsxs(Ox,{to:S.href,onClick:()=>t==null?void 0:t(),className:B("flex items-center gap-3 rounded-lg px-3 py-2 text-sm font-medium transition-all duration-200",C?"bg-primary/10 text-primary":"text-muted-foreground hover:bg-secondary hover:text-foreground"),children:[l.jsx(S.icon,{className:"h-5 w-5 shrink-0"}),e&&l.jsx("span",{className:"flex-1",children:S.name}),e&&S.name==="To-Do"&&w>0&&l.jsx(ue,{variant:"default",className:"h-5 min-w-5 justify-center px-1.5",children:w})]},S.name)}),l.jsxs("button",{onClick:n,className:B("flex w-full items-center gap-3 rounded-lg px-3 py-2 text-sm font-medium transition-all duration-200","text-muted-foreground hover:bg-secondary hover:text-foreground"),children:[l.jsx(Ud,{className:"h-5 w-5 shrink-0"}),e&&l.jsx("span",{children:"Search"}),e&&l.jsx("kbd",{className:"ml-auto hidden rounded bg-muted px-1.5 py-0.5 text-xs text-muted-foreground md:block",children:"⌘K"})]})]}),e&&l.jsxs("div",{className:"flex-1 min-h-0 border-t border-border px-3 py-4 overflow-y-auto",children:[l.jsxs("div",{className:"mb-2 flex items-center justify-between px-3",children:[l.jsx("span",{className:"text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:"Classes"}),l.jsx(K,{variant:"ghost",size:"icon-sm",className:"h-6 w-6",children:l.jsx(Rt,{className:"h-3 w-3"})})]}),l.jsx("div",{className:"space-y-1",children:u.map(S=>l.jsxs(Ox,{to:`/classes/${S.id}`,className:"flex items-center gap-3 rounded-lg px-3 py-2 text-sm text-muted-foreground hover:bg-secondary hover:text-foreground transition-colors",children:[l.jsx("div",{className:"h-2 w-2 rounded-full shrink-0",style:{backgroundColor:S.color}}),l.jsx("span",{className:"truncate",children:S.code})]},S.id))})]}),l.jsxs("div",{className:"border-t border-border p-3 space-y-2 shrink-0",children:[l.jsxs("div",{className:B("flex items-center gap-3 rounded-lg px-3 py-2 text-sm font-medium transition-all duration-200",a?"bg-primary/10 text-primary":"text-muted-foreground"),children:[l.jsx(xC,{className:B("h-5 w-5 shrink-0",a&&"text-primary")}),e&&l.jsxs(l.Fragment,{children:[l.jsx("span",{className:"flex-1",children:"Focus Mode"}),l.jsx(Ko,{checked:a,onCheckedChange:c,"aria-label":"Toggle Focus Mode"})]}),!e&&l.jsx(Ko,{checked:a,onCheckedChange:c,"aria-label":"Toggle Focus Mode",className:"absolute opacity-0"})]}),l.jsxs(Ox,{to:"/settings",className:B("flex items-center gap-3 rounded-lg px-3 py-2 text-sm font-medium transition-all duration-200","text-muted-foreground hover:bg-secondary hover:text-foreground"),children:[l.jsx(aL,{className:"h-5 w-5 shrink-0"}),e&&l.jsx("span",{children:"Settings"})]})]})]}),l.jsx(wn,{open:f,onOpenChange:p,children:l.jsxs(nn,{className:"sm:max-w-md",children:[l.jsx(bn,{children:l.jsx(kn,{children:"Select a Class for Your Note"})}),l.jsx("div",{className:"space-y-2 pt-4",children:u.length>0?u.map(S=>l.jsxs("button",{onClick:()=>k(S.id),className:"w-full flex items-center gap-3 p-3 rounded-lg hover:bg-secondary transition-colors text-left",children:[l.jsx("div",{className:"h-3 w-3 rounded-full shrink-0",style:{backgroundColor:S.color}}),l.jsxs("div",{className:"flex-1 min-w-0",children:[l.jsxs("p",{className:"font-medium truncate",children:[S.code&&l.jsx("span",{className:"mr-1",children:S.code}),S.name]}),l.jsx("p",{className:"text-xs text-muted-foreground truncate",children:S.instructor})]})]},S.id)):l.jsx("p",{className:"text-center text-muted-foreground py-4",children:"No classes found. Add a class first!"})})]})}),l.jsx(W0,{open:y,onOpenChange:x,classId:g||void 0})]})}var GM=1,xJ=.9,wJ=.8,bJ=.17,H0=.1,q0=.999,kJ=.9999,SJ=.99,NJ=/[\\\/_+.#"@\[\(\{&]/,CJ=/[\\\/_+.#"@\[\(\{&]/g,jJ=/[\s-]/,YM=/[\s-]/g;function K0(t,e,r,n,s,o,i){if(o===e.length)return s===t.length?GM:SJ;var a=`${s},${o}`;if(i[a]!==void 0)return i[a];for(var c=n.charAt(o),d=r.indexOf(c,s),u=0,h,f,p,g;d>=0;)h=K0(t,e,r,n,d+1,o+1,i),h>u&&(d===s?h*=GM:NJ.test(t.charAt(d-1))?(h*=wJ,p=t.slice(s,d-1).match(CJ),p&&s>0&&(h*=Math.pow(q0,p.length))):jJ.test(t.charAt(d-1))?(h*=xJ,g=t.slice(s,d-1).match(YM),g&&s>0&&(h*=Math.pow(q0,g.length))):(h*=bJ,s>0&&(h*=Math.pow(q0,d-s))),t.charAt(d)!==e.charAt(o)&&(h*=kJ)),(hh&&(h=f*H0)),h>u&&(u=h),d=r.indexOf(c,d+1);return i[a]=u,u}function JM(t){return t.toLowerCase().replace(YM," ")}function EJ(t,e,r){return t=r&&r.length>0?`${t+" "+r.join(" ")}`:t,K0(t,e,JM(t),JM(e),0,0,{})}var qu='[cmdk-group=""]',G0='[cmdk-group-items=""]',_J='[cmdk-group-heading=""]',QM='[cmdk-item=""]',XM=`${QM}:not([aria-disabled="true"])`,Y0="cmdk-item-select",kc="data-value",TJ=(t,e,r)=>EJ(t,e,r),ZM=m.createContext(void 0),Ku=()=>m.useContext(ZM),eO=m.createContext(void 0),J0=()=>m.useContext(eO),tO=m.createContext(void 0),rO=m.forwardRef((t,e)=>{let r=Sc(()=>{var $,G;return{search:"",value:(G=($=t.value)!=null?$:t.defaultValue)!=null?G:"",selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}}}),n=Sc(()=>new Set),s=Sc(()=>new Map),o=Sc(()=>new Map),i=Sc(()=>new Set),a=nO(t),{label:c,children:d,value:u,onValueChange:h,filter:f,shouldFilter:p,loop:g,disablePointerSelection:v=!1,vimBindings:y=!0,...x}=t,w=hr(),b=hr(),k=hr(),S=m.useRef(null),C=zJ();_a(()=>{if(u!==void 0){let $=u.trim();r.current.value=$,N.emit()}},[u]),_a(()=>{C(6,A)},[]);let N=m.useMemo(()=>({subscribe:$=>(i.current.add($),()=>i.current.delete($)),snapshot:()=>r.current,setState:($,G,J)=>{var O,z,F,te;if(!Object.is(r.current[$],G)){if(r.current[$]=G,$==="search")T(),_(),C(1,P);else if($==="value"){if(document.activeElement.hasAttribute("cmdk-input")||document.activeElement.hasAttribute("cmdk-root")){let ee=document.getElementById(k);ee?ee.focus():(O=document.getElementById(w))==null||O.focus()}if(C(7,()=>{var ee;r.current.selectedItemId=(ee=I())==null?void 0:ee.id,N.emit()}),J||C(5,A),((z=a.current)==null?void 0:z.value)!==void 0){let ee=G??"";(te=(F=a.current).onValueChange)==null||te.call(F,ee);return}}N.emit()}},emit:()=>{i.current.forEach($=>$())}}),[]),E=m.useMemo(()=>({value:($,G,J)=>{var O;G!==((O=o.current.get($))==null?void 0:O.value)&&(o.current.set($,{value:G,keywords:J}),r.current.filtered.items.set($,j(G,J)),C(2,()=>{_(),N.emit()}))},item:($,G)=>(n.current.add($),G&&(s.current.has(G)?s.current.get(G).add($):s.current.set(G,new Set([$]))),C(3,()=>{T(),_(),r.current.value||P(),N.emit()}),()=>{o.current.delete($),n.current.delete($),r.current.filtered.items.delete($);let J=I();C(4,()=>{T(),(J==null?void 0:J.getAttribute("id"))===&P(),N.emit()})}),group:$=>(s.current.has($)||s.current.set($,new Set),()=>{o.current.delete($),s.current.delete($)}),filter:()=>a.current.shouldFilter,label:c||t["aria-label"],getDisablePointerSelection:()=>a.current.disablePointerSelection,listId:w,inputId:k,labelId:b,listInnerRef:S}),[]);function j($,G){var J,O;let z=(O=(J=a.current)==null?void 0:J.filter)!=null?O:TJ;return $?z($,r.current.search,G):0}function _(){if(!r.current.search||a.current.shouldFilter===!1)return;let $=r.current.filtered.items,G=[];r.current.filtered.groups.forEach(O=>{let z=s.current.get(O),F=0;z.forEach(te=>{let ee=$.get(te);F=Math.max(ee,F)}),G.push([O,F])});let J=S.current;V().sort((O,z)=>{var F,te;let ee=O.getAttribute("id"),Z=z.getAttribute("id");return((F=$.get(Z))!=null?F:0)-((te=$.get(ee))!=null?te:0)}).forEach(O=>{let z=O.closest(G0);z?z.appendChild(O.parentElement===z?O:O.closest(`${G0} > *`)):J.appendChild(O.parentElement===J?O:O.closest(`${G0} > *`))}),G.sort((O,z)=>z[1]-O[1]).forEach(O=>{var z;let F=(z=S.current)==null?void 0:z.querySelector(`${qu}[${kc}="${encodeURIComponent(O[0])}"]`);F==null||F.parentElement.appendChild(F)})}function P(){let $=V().find(J=>J.getAttribute("aria-disabled")!=="true"),G=$==null?void 0:$.getAttribute(kc);N.setState("value",G||void 0)}function T(){var $,G,J,O;if(!r.current.search||a.current.shouldFilter===!1){r.current.filtered.count=n.current.size;return}r.current.filtered.groups=new Set;let z=0;for(let F of n.current){let te=(G=($=o.current.get(F))==null?void 0:$.value)!=null?G:"",ee=(O=(J=o.current.get(F))==null?void 0:J.keywords)!=null?O:[],Z=j(te,ee);r.current.filtered.items.set(F,Z),Z>0&&z++}for(let[F,te]of s.current)for(let ee of te)if(r.current.filtered.items.get(ee)>0){r.current.filtered.groups.add(F);break}r.current.filtered.count=z}function A(){var $,G,J;let O=I();O&&((($=O.parentElement)==null?void 0:$.firstChild)===O&&((J=(G=O.closest(qu))==null?void 0:G.querySelector(_J))==null||J.scrollIntoView({block:"nearest"})),O.scrollIntoView({block:"nearest"}))}function I(){var $;return($=S.current)==null?void 0:$.querySelector(`${QM}[aria-selected="true"]`)}function V(){var $;return Array.from((($=S.current)==null?void 0:$.querySelectorAll(XM))||[])}function L($){let G=V()[$];G&&N.setState("value",G.getAttribute(kc))}function U($){var G;let J=I(),O=V(),z=O.findIndex(te=>te===J),F=O[z+$];(G=a.current)!=null&&G.loop&&(F=z+$<0?O[O.length-1]:z+$===O.length?O[0]:O[z+$]),F&&N.setState("value",F.getAttribute(kc))}function M($){let G=I(),J=G==null?void 0:G.closest(qu),O;for(;J&&!O;)J=$>0?$J(J,qu):FJ(J,qu),O=J==null?void 0:J.querySelector(XM);O?N.setState("value",O.getAttribute(kc)):U($)}let D=()=>L(V().length-1),H=$=>{$.preventDefault(),$.metaKey?D():$.altKey?M(1):U(1)},ne=$=>{$.preventDefault(),$.metaKey?L(0):$.altKey?M(-1):U(-1)};return m.createElement(se.div,{ref:e,tabIndex:-1,...x,"cmdk-root":"",onKeyDown:$=>{var G;(G=x.onKeyDown)==null||G.call(x,$);let J=$.nativeEvent.isComposing||$.keyCode===229;if(!($.defaultPrevented||J))switch($.key){case"n":case"j":{y&&$.ctrlKey&&H($);break}case"ArrowDown":{H($);break}case"p":case"k":{y&&$.ctrlKey&&ne($);break}case"ArrowUp":{ne($);break}case"Home":{$.preventDefault(),L(0);break}case"End":{$.preventDefault(),D();break}case"Enter":{$.preventDefault();let O=I();if(O){let z=new Event(Y0);O.dispatchEvent(z)}}}}},m.createElement("label",{"cmdk-label":"",htmlFor:E.inputId,id:E.labelId,style:UJ},c),Pm(t,$=>m.createElement(eO.Provider,{value:N},m.createElement(ZM.Provider,{value:E},$))))}),RJ=m.forwardRef((t,e)=>{var r,n;let s=hr(),o=m.useRef(null),i=m.useContext(tO),a=Ku(),c=nO(t),d=(n=(r=c.current)==null?void 0:r.forceMount)!=null?n:i==null?void 0:i.forceMount;_a(()=>{if(!d)return a.item(s,i==null?void 0:i.id)},[d]);let u=sO(s,o,[t.value,t.children,o],t.keywords),h=J0(),f=mi(C=>C.value&&C.value===u.current),p=mi(C=>d||a.filter()===!1?!0:C.search?C.filtered.items.get(s)>0:!0);m.useEffect(()=>{let C=o.current;if(!(!C||t.disabled))return C.addEventListener(Y0,g),()=>C.removeEventListener(Y0,g)},[p,t.onSelect,t.disabled]);function g(){var C,N;v(),(N=(C=c.current).onSelect)==null||N.call(C,u.current)}function v(){h.setState("value",u.current,!0)}if(!p)return null;let{disabled:y,value:x,onSelect:w,forceMount:b,keywords:k,...S}=t;return m.createElement(se.div,{ref:Ks(o,e),...S,id:s,"cmdk-item":"",role:"option","aria-disabled":!!y,"aria-selected":!!f,"data-disabled":!!y,"data-selected":!!f,onPointerMove:y||a.getDisablePointerSelection()?void 0:v,onClick:y?void 0:g},t.children)}),MJ=m.forwardRef((t,e)=>{let{heading:r,children:n,forceMount:s,...o}=t,i=hr(),a=m.useRef(null),c=m.useRef(null),d=hr(),u=Ku(),h=mi(p=>s||u.filter()===!1?!0:p.search?p.filtered.groups.has(i):!0);_a(()=>u.group(i),[]),sO(i,a,[t.value,t.heading,c]);let f=m.useMemo(()=>({id:i,forceMount:s}),[s]);return m.createElement(se.div,{ref:Ks(a,e),...o,"cmdk-group":"",role:"presentation",hidden:h?void 0:!0},r&&m.createElement("div",{ref:c,"cmdk-group-heading":"","aria-hidden":!0,id:d},r),Pm(t,p=>m.createElement("div",{"cmdk-group-items":"",role:"group","aria-labelledby":r?d:void 0},m.createElement(tO.Provider,{value:f},p))))}),OJ=m.forwardRef((t,e)=>{let{alwaysRender:r,...n}=t,s=m.useRef(null),o=mi(i=>!i.search);return!r&&!o?null:m.createElement(se.div,{ref:Ks(s,e),...n,"cmdk-separator":"",role:"separator"})}),PJ=m.forwardRef((t,e)=>{let{onValueChange:r,...n}=t,s=t.value!=null,o=J0(),i=mi(d=>d.search),a=mi(d=>d.selectedItemId),c=Ku();return m.useEffect(()=>{t.value!=null&&o.setState("search",t.value)},[t.value]),m.createElement(se.input,{ref:e,...n,"cmdk-input":"",autoComplete:"off",autoCorrect:"off",spellCheck:!1,"aria-autocomplete":"list",role:"combobox","aria-expanded":!0,"aria-controls":c.listId,"aria-labelledby":c.labelId,"aria-activedescendant":a,id:c.inputId,type:"text",value:s?t.value:i,onChange:d=>{s||o.setState("search",d.target.value),r==null||r(d.target.value)}})}),AJ=m.forwardRef((t,e)=>{let{children:r,label:n="Suggestions",...s}=t,o=m.useRef(null),i=m.useRef(null),a=mi(d=>d.selectedItemId),c=Ku();return m.useEffect(()=>{if(i.current&&o.current){let d=i.current,u=o.current,h,f=new ResizeObserver(()=>{h=requestAnimationFrame(()=>{let p=d.offsetHeight;u.style.setProperty("--cmdk-list-height",p.toFixed(1)+"px")})});return f.observe(d),()=>{cancelAnimationFrame(h),f.unobserve(d)}}},[]),m.createElement(se.div,{ref:Ks(o,e),...s,"cmdk-list":"",role:"listbox",tabIndex:-1,"aria-activedescendant":a,"aria-label":n,id:c.listId},Pm(t,d=>m.createElement("div",{ref:Ks(i,c.listInnerRef),"cmdk-list-sizer":""},d)))}),IJ=m.forwardRef((t,e)=>{let{open:r,onOpenChange:n,overlayClassName:s,contentClassName:o,container:i,...a}=t;return m.createElement(Kx,{open:r,onOpenChange:n},m.createElement(Gx,{container:i},m.createElement(ru,{"cmdk-overlay":"",className:s}),m.createElement(nu,{"aria-label":t.label,"cmdk-dialog":"",className:o},m.createElement(rO,{ref:e,...a}))))}),DJ=m.forwardRef((t,e)=>mi(r=>r.filtered.count===0)?m.createElement(se.div,{ref:e,...t,"cmdk-empty":"",role:"presentation"}):null),LJ=m.forwardRef((t,e)=>{let{progress:r,children:n,label:s="Loading...",...o}=t;return m.createElement(se.div,{ref:e,...o,"cmdk-loading":"",role:"progressbar","aria-valuenow":r,"aria-valuemin":0,"aria-valuemax":100,"aria-label":s},Pm(t,i=>m.createElement("div",{"aria-hidden":!0},i)))}),Vr=Object.assign(rO,{List:AJ,Item:RJ,Input:PJ,Group:MJ,Separator:OJ,Dialog:IJ,Empty:DJ,Loading:LJ});function $J(t,e){let r=t.nextElementSibling;for(;r;){if(r.matches(e))return r;r=r.nextElementSibling}}function FJ(t,e){let r=t.previousElementSibling;for(;r;){if(r.matches(e))return r;r=r.previousElementSibling}}function nO(t){let e=m.useRef(t);return _a(()=>{e.current=t}),e}var _a=typeof window>"u"?m.useEffect:m.useLayoutEffect;function Sc(t){let e=m.useRef();return e.current===void 0&&(e.current=t()),e}function mi(t){let e=J0(),r=()=>t(e.snapshot());return m.useSyncExternalStore(e.subscribe,r,r)}function sO(t,e,r,n=[]){let s=m.useRef(),o=Ku();return _a(()=>{var i;let a=(()=>{var d;for(let u of r){if(typeof u=="string")return u.trim();if(typeof u=="object"&&"current"in u)return u.current?(d=u.current.textContent)==null?void 0:d.trim():s.current}})(),c=n.map(d=>d.trim());o.value(t,a,c),(i=e.current)==null||i.setAttribute(kc,a),s.current=a}),s}var zJ=()=>{let[t,e]=m.useState(),r=Sc(()=>new Map);return _a(()=>{r.current.forEach(n=>n()),r.current=new Map},[t]),(n,s)=>{r.current.set(n,s),e({})}};function BJ(t){let e=t.type;return typeof e=="function"?e(t.props):"render"in e?e.render(t.props):t}function Pm({asChild:t,children:e},r){return t&&m.isValidElement(e)?m.cloneElement(BJ(e),{ref:e.ref},r(e.props.children)):r(e)}var UJ={position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0"};const oO=m.forwardRef(({className:t,...e},r)=>l.jsx(Vr,{ref:r,className:B("flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",t),...e}));oO.displayName=Vr.displayName;const VJ=({children:t,...e})=>l.jsx(wn,{...e,children:l.jsx(nn,{className:"overflow-hidden p-0 shadow-lg",children:l.jsx(oO,{className:"[&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground [&_[cmdk-group]:not([hidden])_~[cmdk-group]]:pt-0 [&_[cmdk-group]]:px-2 [&_[cmdk-input-wrapper]_svg]:h-5 [&_[cmdk-input-wrapper]_svg]:w-5 [&_[cmdk-input]]:h-12 [&_[cmdk-item]]:px-2 [&_[cmdk-item]]:py-3 [&_[cmdk-item]_svg]:h-5 [&_[cmdk-item]_svg]:w-5",children:t})})}),iO=m.forwardRef(({className:t,...e},r)=>l.jsxs("div",{className:"flex items-center border-b px-3","cmdk-input-wrapper":"",children:[l.jsx(Ud,{className:"mr-2 h-4 w-4 shrink-0 opacity-50"}),l.jsx(Vr.Input,{ref:r,className:B("flex h-11 w-full rounded-md bg-transparent py-3 text-sm outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",t),...e})]}));iO.displayName=Vr.Input.displayName;const aO=m.forwardRef(({className:t,...e},r)=>l.jsx(Vr.List,{ref:r,className:B("max-h-[300px] overflow-y-auto overflow-x-hidden",t),...e}));aO.displayName=Vr.List.displayName;const lO=m.forwardRef((t,e)=>l.jsx(Vr.Empty,{ref:e,className:"py-6 text-center text-sm",...t}));lO.displayName=Vr.Empty.displayName;const Nc=m.forwardRef(({className:t,...e},r)=>l.jsx(Vr.Group,{ref:r,className:B("overflow-hidden p-1 text-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground",t),...e}));Nc.displayName=Vr.Group.displayName;const Gu=m.forwardRef(({className:t,...e},r)=>l.jsx(Vr.Separator,{ref:r,className:B("-mx-1 h-px bg-border",t),...e}));Gu.displayName=Vr.Separator.displayName;const Cc=m.forwardRef(({className:t,...e},r)=>l.jsx(Vr.Item,{ref:r,className:B("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none data-[disabled=true]:pointer-events-none data-[selected='true']:bg-accent data-[selected=true]:text-accent-foreground data-[disabled=true]:opacity-50",t),...e}));Cc.displayName=Vr.Item.displayName;function WJ(){const{searchOpen:t,toggleSearch:e}=Ot(),[r,n]=m.useState(""),[s,o]=m.useState([]),[i,a]=m.useState(!1),c=Zs();m.useEffect(()=>{const y=x=>{x.key==="k"&&(x.metaKey||x.ctrlKey)&&(x.preventDefault(),e())};return document.addEventListener("keydown",y),()=>document.removeEventListener("keydown",y)},[e]);const d=m.useCallback(async y=>{if(!y.trim()){o([]);return}a(!0);const x=`%${y.toLowerCase()}%`,w=[];try{const{data:b}=await q.from("notes").select("id, title, content, transcription, type, class_id, session_id, created_at").or(`title.ilike.${x},content.ilike.${x},transcription.ilike.${x}`).limit(5);b&&b.forEach(E=>{w.push({id:E.id,type:"note",title:E.title||"Untitled Note",subtitle:E.type==="audio"?"Audio recording":pe(new Date(E.created_at),"MMM d, yyyy"),classId:E.class_id||void 0,sessionId:E.session_id||void 0,icon:E.type==="audio"?l.jsx(Gf,{className:"h-4 w-4"}):l.jsx(zt,{className:"h-4 w-4"})})});const{data:k}=await q.from("classes").select("id, name, code, professor_name, color").or(`name.ilike.${x},code.ilike.${x},professor_name.ilike.${x}`).limit(5);k&&k.forEach(E=>{w.push({id:E.id,type:"class",title:E.name,subtitle:`${E.code} • ${E.professor_name}`,icon:l.jsx(vt,{className:"h-4 w-4"}),color:E.color})});const{data:S}=await q.from("sessions").select("id, class_id, session_date, topics, location, notes").or(`location.ilike.${x},notes.ilike.${x}`).limit(5);if(S){const E=[...new Set(S.map(P=>P.class_id))],{data:j}=await q.from("classes").select("id, name, code, color").in("id",E),_=new Map((j==null?void 0:j.map(P=>[P.id,P]))||[]);S.forEach(P=>{const T=_.get(P.class_id);w.push({id:P.id,type:"session",title:`${(T==null?void 0:T.code)||"Class"} - ${pe(new Date(P.session_date),"MMM d, yyyy")}`,subtitle:P.location||"No location",classId:P.class_id,sessionId:P.id,icon:l.jsx(Sr,{className:"h-4 w-4"}),color:T==null?void 0:T.color})})}const{data:C}=await q.from("deadlines").select("id, title, description, due_date, class_id, deadline_type").or(`title.ilike.${x},description.ilike.${x}`).limit(5);if(C){const E=[...new Set(C.map(P=>P.class_id))],{data:j}=await q.from("classes").select("id, code, color").in("id",E),_=new Map((j==null?void 0:j.map(P=>[P.id,P]))||[]);C.forEach(P=>{const T=_.get(P.class_id);w.push({id:P.id,type:"deadline",title:P.title,subtitle:`${(T==null?void 0:T.code)||"Class"} • Due ${pe(new Date(P.due_date),"MMM d")}`,classId:P.class_id,icon:l.jsx(tr,{className:"h-4 w-4"}),color:T==null?void 0:T.color})})}const{data:N}=await q.from("class_todos").select("id, title, description, class_id, due_date, status").or(`title.ilike.${x},description.ilike.${x}`).limit(5);if(N){const E=[...new Set(N.map(P=>P.class_id))],{data:j}=await q.from("classes").select("id, code, color").in("id",E),_=new Map((j==null?void 0:j.map(P=>[P.id,P]))||[]);N.forEach(P=>{const T=_.get(P.class_id);w.push({id:P.id,type:"task",title:P.title,subtitle:`${(T==null?void 0:T.code)||"Class"} • ${P.status}`,classId:P.class_id,icon:l.jsx(jl,{className:"h-4 w-4"}),color:T==null?void 0:T.color})})}o(w)}catch(b){console.error("Search error:",b)}finally{a(!1)}},[]);m.useEffect(()=>{const y=setTimeout(()=>{d(r)},300);return()=>clearTimeout(y)},[r,d]);const u=y=>{switch(e(),n(""),y.type){case"class":c(`/classes/${y.id}`);break;case"session":c(`/classes/${y.classId}`);break;case"note":y.classId?c(`/classes/${y.classId}`):c("/");break;case"deadline":c(`/classes/${y.classId}`);break;case"task":c("/todo");break;default:c("/")}},h=s.filter(y=>y.type==="note"),f=s.filter(y=>y.type==="class"),p=s.filter(y=>y.type==="session"),g=s.filter(y=>y.type==="deadline"),v=s.filter(y=>y.type==="task");return l.jsxs(VJ,{open:t,onOpenChange:e,children:[l.jsx(iO,{placeholder:"Search notes, classes, tasks...",value:r,onValueChange:n}),l.jsxs(aO,{children:[i&&l.jsx("div",{className:"py-6 text-center text-sm text-muted-foreground",children:"Searching..."}),!i&&r&&s.length===0&&l.jsxs(lO,{children:['No results found for "',r,'"']}),!r&&!i&&l.jsx("div",{className:"py-6 text-center text-sm text-muted-foreground",children:"Start typing to search across notes, classes, tasks, and more..."}),h.length>0&&l.jsx(Nc,{heading:"Notes",children:h.map(y=>l.jsxs(Cc,{value:`note-${y.id}-${y.title}`,onSelect:()=>u(y),className:"flex items-center gap-3 cursor-pointer",children:[l.jsx("div",{className:"p-1.5 rounded-md",style:{backgroundColor:y.color?`${y.color}20`:"hsl(var(--secondary))"},children:y.icon}),l.jsxs("div",{className:"flex-1 min-w-0",children:[l.jsx("p",{className:"text-sm font-medium truncate",children:y.title}),y.subtitle&&l.jsx("p",{className:"text-xs text-muted-foreground truncate",children:y.subtitle})]})]},`note-${y.id}`))}),f.length>0&&l.jsxs(l.Fragment,{children:[h.length>0&&l.jsx(Gu,{}),l.jsx(Nc,{heading:"Classes",children:f.map(y=>l.jsxs(Cc,{value:`class-${y.id}-${y.title}`,onSelect:()=>u(y),className:"flex items-center gap-3 cursor-pointer",children:[l.jsx("div",{className:"p-1.5 rounded-md",style:{backgroundColor:y.color?`${y.color}20`:"hsl(var(--secondary))"},children:l.jsx(vt,{className:"h-4 w-4",style:{color:y.color}})}),l.jsxs("div",{className:"flex-1 min-w-0",children:[l.jsx("p",{className:"text-sm font-medium truncate",children:y.title}),y.subtitle&&l.jsx("p",{className:"text-xs text-muted-foreground truncate",children:y.subtitle})]})]},`class-${y.id}`))})]}),p.length>0&&l.jsxs(l.Fragment,{children:[(h.length>0||f.length>0)&&l.jsx(Gu,{}),l.jsx(Nc,{heading:"Sessions",children:p.map(y=>l.jsxs(Cc,{value:`session-${y.id}-${y.title}`,onSelect:()=>u(y),className:"flex items-center gap-3 cursor-pointer",children:[l.jsx("div",{className:"p-1.5 rounded-md",style:{backgroundColor:y.color?`${y.color}20`:"hsl(var(--secondary))"},children:y.icon}),l.jsxs("div",{className:"flex-1 min-w-0",children:[l.jsx("p",{className:"text-sm font-medium truncate",children:y.title}),y.subtitle&&l.jsx("p",{className:"text-xs text-muted-foreground truncate",children:y.subtitle})]})]},`session-${y.id}`))})]}),g.length>0&&l.jsxs(l.Fragment,{children:[(h.length>0||f.length>0||p.length>0)&&l.jsx(Gu,{}),l.jsx(Nc,{heading:"Deadlines",children:g.map(y=>l.jsxs(Cc,{value:`deadline-${y.id}-${y.title}`,onSelect:()=>u(y),className:"flex items-center gap-3 cursor-pointer",children:[l.jsx("div",{className:"p-1.5 rounded-md",style:{backgroundColor:y.color?`${y.color}20`:"hsl(var(--secondary))"},children:y.icon}),l.jsxs("div",{className:"flex-1 min-w-0",children:[l.jsx("p",{className:"text-sm font-medium truncate",children:y.title}),y.subtitle&&l.jsx("p",{className:"text-xs text-muted-foreground truncate",children:y.subtitle})]})]},`deadline-${y.id}`))})]}),v.length>0&&l.jsxs(l.Fragment,{children:[(h.length>0||f.length>0||p.length>0||g.length>0)&&l.jsx(Gu,{}),l.jsx(Nc,{heading:"Tasks",children:v.map(y=>l.jsxs(Cc,{value:`task-${y.id}-${y.title}`,onSelect:()=>u(y),className:"flex items-center gap-3 cursor-pointer",children:[l.jsx("div",{className:"p-1.5 rounded-md",style:{backgroundColor:y.color?`${y.color}20`:"hsl(var(--secondary))"},children:y.icon}),l.jsxs("div",{className:"flex-1 min-w-0",children:[l.jsx("p",{className:"text-sm font-medium truncate",children:y.title}),y.subtitle&&l.jsx("p",{className:"text-xs text-muted-foreground truncate",children:y.subtitle})]})]},`task-${y.id}`))})]})]})]})}function HJ(){const{sidebarOpen:t,mobileSidebarOpen:e,setMobileSidebarOpen:r}=Ot(),n=du();return l.jsxs("div",{className:"min-h-screen bg-background",children:[n&&e&&l.jsx("div",{className:"fixed inset-0 bg-background/80 backdrop-blur-sm z-30",onClick:()=>r(!1)}),l.jsx("div",{className:B("fixed left-0 top-0 z-40 h-screen transition-transform duration-300",n?e?"translate-x-0":"-translate-x-full":"translate-x-0"),children:l.jsx(yJ,{onNavigate:()=>n&&r(!1)})}),l.jsx(WJ,{}),l.jsx("main",{className:B("min-h-screen transition-all duration-300",n?"ml-0":t?"ml-64":"ml-16"),children:l.jsx(AB,{})})]})}function co(){const t=du(),e=Ot(r=>r.setMobileSidebarOpen);return t?l.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8 shrink-0 md:hidden",onClick:()=>e(!0),children:l.jsx(Z3,{className:"h-5 w-5"})}):null}function qJ(){for(var t=arguments.length,e=new Array(t),r=0;rn=>{e.forEach(s=>s(n))},e)}const Am=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function jc(t){const e=Object.prototype.toString.call(t);return e==="[object Window]"||e==="[object global]"}function Q0(t){return"nodeType"in t}function Wr(t){var e,r;return t?jc(t)?t:Q0(t)&&(e=(r=t.ownerDocument)==null?void 0:r.defaultView)!=null?e:window:window}function X0(t){const{Document:e}=Wr(t);return t instanceof e}function Yu(t){return jc(t)?!1:t instanceof Wr(t).HTMLElement}function cO(t){return t instanceof Wr(t).SVGElement}function Ec(t){return t?jc(t)?t.document:Q0(t)?X0(t)?t:Yu(t)||cO(t)?t.ownerDocument:document:document:document}const js=Am?m.useLayoutEffect:m.useEffect;function Z0(t){const e=m.useRef(t);return js(()=>{e.current=t}),m.useCallback(function(){for(var r=arguments.length,n=new Array(r),s=0;s{t.current=setInterval(n,s)},[]),r=m.useCallback(()=>{t.current!==null&&(clearInterval(t.current),t.current=null)},[]);return[e,r]}function Ju(t,e){e===void 0&&(e=[t]);const r=m.useRef(t);return js(()=>{r.current!==t&&(r.current=t)},e),r}function Qu(t,e){const r=m.useRef();return m.useMemo(()=>{const n=t(r.current);return r.current=n,n},[...e])}function Im(t){const e=Z0(t),r=m.useRef(null),n=m.useCallback(s=>{s!==r.current&&(e==null||e(s,r.current)),r.current=s},[]);return[r,n]}function eb(t){const e=m.useRef();return m.useEffect(()=>{e.current=t},[t]),e.current}let tb={};function Xu(t,e){return m.useMemo(()=>{if(e)return e;const r=tb[t]==null?0:tb[t]+1;return tb[t]=r,t+"-"+r},[t,e])}function dO(t){return function(e){for(var r=arguments.length,n=new Array(r>1?r-1:0),s=1;s{const a=Object.entries(i);for(const[c,d]of a){const u=o[c];u!=null&&(o[c]=u+t*d)}return o},{...e})}}const _c=dO(1),Zu=dO(-1);function GJ(t){return"clientX"in t&&"clientY"in t}function rb(t){if(!t)return!1;const{KeyboardEvent:e}=Wr(t.target);return e&&t instanceof e}function YJ(t){if(!t)return!1;const{TouchEvent:e}=Wr(t.target);return e&&t instanceof e}function nb(t){if(YJ(t)){if(t.touches&&t.touches.length){const{clientX:e,clientY:r}=t.touches[0];return{x:e,y:r}}else if(t.changedTouches&&t.changedTouches.length){const{clientX:e,clientY:r}=t.changedTouches[0];return{x:e,y:r}}}return GJ(t)?{x:t.clientX,y:t.clientY}:null}const eh=Object.freeze({Translate:{toString(t){if(!t)return;const{x:e,y:r}=t;return"translate3d("+(e?Math.round(e):0)+"px, "+(r?Math.round(r):0)+"px, 0)"}},Scale:{toString(t){if(!t)return;const{scaleX:e,scaleY:r}=t;return"scaleX("+e+") scaleY("+r+")"}},Transform:{toString(t){if(t)return[eh.Translate.toString(t),eh.Scale.toString(t)].join(" ")}},Transition:{toString(t){let{property:e,duration:r,easing:n}=t;return e+" "+r+"ms "+n}}}),uO="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function JJ(t){return t.matches(uO)?t:t.querySelector(uO)}const QJ={display:"none"};function XJ(t){let{id:e,value:r}=t;return W.createElement("div",{id:e,style:QJ},r)}function ZJ(t){let{id:e,announcement:r,ariaLiveType:n="assertive"}=t;const s={position:"fixed",top:0,left:0,width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0 0 0 0)",clipPath:"inset(100%)",whiteSpace:"nowrap"};return W.createElement("div",{id:e,style:s,role:"status","aria-live":n,"aria-atomic":!0},r)}function eQ(){const[t,e]=m.useState("");return{announce:m.useCallback(n=>{n!=null&&e(n)},[]),announcement:t}}const hO=m.createContext(null);function tQ(t){const e=m.useContext(hO);m.useEffect(()=>{if(!e)throw new Error("useDndMonitor must be used within a children of ");return e(t)},[t,e])}function rQ(){const[t]=m.useState(()=>new Set),e=m.useCallback(n=>(t.add(n),()=>t.delete(n)),[t]);return[m.useCallback(n=>{let{type:s,event:o}=n;t.forEach(i=>{var a;return(a=i[s])==null?void 0:a.call(i,o)})},[t]),e]}const nQ={draggable:` To pick up a draggable item, press the space bar. While dragging, use the arrow keys to move the item. Press space again to drop the item in its new position, or press escape to cancel. `},sQ={onDragStart(t){let{active:e}=t;return"Picked up draggable item "+e.id+"."},onDragOver(t){let{active:e,over:r}=t;return r?"Draggable item "+e.id+" was moved over droppable area "+r.id+".":"Draggable item "+e.id+" is no longer over a droppable area."},onDragEnd(t){let{active:e,over:r}=t;return r?"Draggable item "+e.id+" was dropped over droppable area "+r.id:"Draggable item "+e.id+" was dropped."},onDragCancel(t){let{active:e}=t;return"Dragging was cancelled. Draggable item "+e.id+" was dropped."}};function oQ(t){let{announcements:e=sQ,container:r,hiddenTextDescribedById:n,screenReaderInstructions:s=nQ}=t;const{announce:o,announcement:i}=eQ(),a=Xu("DndLiveRegion"),[c,d]=m.useState(!1);if(m.useEffect(()=>{d(!0)},[]),tQ(m.useMemo(()=>({onDragStart(h){let{active:f}=h;o(e.onDragStart({active:f}))},onDragMove(h){let{active:f,over:p}=h;e.onDragMove&&o(e.onDragMove({active:f,over:p}))},onDragOver(h){let{active:f,over:p}=h;o(e.onDragOver({active:f,over:p}))},onDragEnd(h){let{active:f,over:p}=h;o(e.onDragEnd({active:f,over:p}))},onDragCancel(h){let{active:f,over:p}=h;o(e.onDragCancel({active:f,over:p}))}}),[o,e])),!c)return null;const u=W.createElement(W.Fragment,null,W.createElement(XJ,{id:n,value:s.draggable}),W.createElement(ZJ,{id:a,announcement:i}));return r?vn.createPortal(u,r):u}var At;(function(t){t.DragStart="dragStart",t.DragMove="dragMove",t.DragEnd="dragEnd",t.DragCancel="dragCancel",t.DragOver="dragOver",t.RegisterDroppable="registerDroppable",t.SetDroppableDisabled="setDroppableDisabled",t.UnregisterDroppable="unregisterDroppable"})(At||(At={}));function Dm(){}function sb(t,e){return m.useMemo(()=>({sensor:t,options:e??{}}),[t,e])}function fO(){for(var t=arguments.length,e=new Array(t),r=0;r[...e].filter(n=>n!=null),[...e])}const rs=Object.freeze({x:0,y:0});function pO(t,e){return Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2))}function mO(t,e){let{data:{value:r}}=t,{data:{value:n}}=e;return r-n}function iQ(t,e){let{data:{value:r}}=t,{data:{value:n}}=e;return n-r}function gO(t){let{left:e,top:r,height:n,width:s}=t;return[{x:e,y:r},{x:e+s,y:r},{x:e,y:r+n},{x:e+s,y:r+n}]}function vO(t,e){if(!t||t.length===0)return null;const[r]=t;return r[e]}function yO(t,e,r){return e===void 0&&(e=t.left),r===void 0&&(r=t.top),{x:e+t.width*.5,y:r+t.height*.5}}const aQ=t=>{let{collisionRect:e,droppableRects:r,droppableContainers:n}=t;const s=yO(e,e.left,e.top),o=[];for(const i of n){const{id:a}=i,c=r.get(a);if(c){const d=pO(yO(c),s);o.push({id:a,data:{droppableContainer:i,value:d}})}}return o.sort(mO)},lQ=t=>{let{collisionRect:e,droppableRects:r,droppableContainers:n}=t;const s=gO(e),o=[];for(const i of n){const{id:a}=i,c=r.get(a);if(c){const d=gO(c),u=s.reduce((f,p,g)=>f+pO(d[g],p),0),h=Number((u/4).toFixed(4));o.push({id:a,data:{droppableContainer:i,value:h}})}}return o.sort(mO)};function cQ(t,e){const r=Math.max(e.top,t.top),n=Math.max(e.left,t.left),s=Math.min(e.left+e.width,t.left+t.width),o=Math.min(e.top+e.height,t.top+t.height),i=s-n,a=o-r;if(n{let{collisionRect:e,droppableRects:r,droppableContainers:n}=t;const s=[];for(const o of n){const{id:i}=o,a=r.get(i);if(a){const c=cQ(a,e);c>0&&s.push({id:i,data:{droppableContainer:o,value:c}})}}return s.sort(iQ)};function uQ(t,e,r){return{...t,scaleX:e&&r?e.width/r.width:1,scaleY:e&&r?e.height/r.height:1}}function xO(t,e){return t&&e?{x:t.left-e.left,y:t.top-e.top}:rs}function hQ(t){return function(r){for(var n=arguments.length,s=new Array(n>1?n-1:0),o=1;o({...i,top:i.top+t*a.y,bottom:i.bottom+t*a.y,left:i.left+t*a.x,right:i.right+t*a.x}),{...r})}}const fQ=hQ(1);function pQ(t){if(t.startsWith("matrix3d(")){const e=t.slice(9,-1).split(/, /);return{x:+e[12],y:+e[13],scaleX:+e[0],scaleY:+e[5]}}else if(t.startsWith("matrix(")){const e=t.slice(7,-1).split(/, /);return{x:+e[4],y:+e[5],scaleX:+e[0],scaleY:+e[3]}}return null}function mQ(t,e,r){const n=pQ(e);if(!n)return t;const{scaleX:s,scaleY:o,x:i,y:a}=n,c=t.left-i-(1-s)*parseFloat(r),d=t.top-a-(1-o)*parseFloat(r.slice(r.indexOf(" ")+1)),u=s?t.width/s:t.width,h=o?t.height/o:t.height;return{width:u,height:h,top:d,right:c+u,bottom:d+h,left:c}}const gQ={ignoreTransform:!1};function Tc(t,e){e===void 0&&(e=gQ);let r=t.getBoundingClientRect();if(e.ignoreTransform){const{transform:d,transformOrigin:u}=Wr(t).getComputedStyle(t);d&&(r=mQ(r,d,u))}const{top:n,left:s,width:o,height:i,bottom:a,right:c}=r;return{top:n,left:s,width:o,height:i,bottom:a,right:c}}function wO(t){return Tc(t,{ignoreTransform:!0})}function vQ(t){const e=t.innerWidth,r=t.innerHeight;return{top:0,left:0,right:e,bottom:r,width:e,height:r}}function yQ(t,e){return e===void 0&&(e=Wr(t).getComputedStyle(t)),e.position==="fixed"}function xQ(t,e){e===void 0&&(e=Wr(t).getComputedStyle(t));const r=/(auto|scroll|overlay)/;return["overflow","overflowX","overflowY"].some(s=>{const o=e[s];return typeof o=="string"?r.test(o):!1})}function Lm(t,e){const r=[];function n(s){if(e!=null&&r.length>=e||!s)return r;if(X0(s)&&s.scrollingElement!=null&&!r.includes(s.scrollingElement))return r.push(s.scrollingElement),r;if(!Yu(s)||cO(s)||r.includes(s))return r;const o=Wr(t).getComputedStyle(s);return s!==t&&xQ(s,o)&&r.push(s),yQ(s,o)?r:n(s.parentNode)}return t?n(t):r}function bO(t){const[e]=Lm(t,1);return e??null}function ob(t){return!Am||!t?null:jc(t)?t:Q0(t)?X0(t)||t===Ec(t).scrollingElement?window:Yu(t)?t:null:null}function kO(t){return jc(t)?t.scrollX:t.scrollLeft}function SO(t){return jc(t)?t.scrollY:t.scrollTop}function ib(t){return{x:kO(t),y:SO(t)}}var Kt;(function(t){t[t.Forward=1]="Forward",t[t.Backward=-1]="Backward"})(Kt||(Kt={}));function NO(t){return!Am||!t?!1:t===document.scrollingElement}function CO(t){const e={x:0,y:0},r=NO(t)?{height:window.innerHeight,width:window.innerWidth}:{height:t.clientHeight,width:t.clientWidth},n={x:t.scrollWidth-r.width,y:t.scrollHeight-r.height},s=t.scrollTop<=e.y,o=t.scrollLeft<=e.x,i=t.scrollTop>=n.y,a=t.scrollLeft>=n.x;return{isTop:s,isLeft:o,isBottom:i,isRight:a,maxScroll:n,minScroll:e}}const wQ={x:.2,y:.2};function bQ(t,e,r,n,s){let{top:o,left:i,right:a,bottom:c}=r;n===void 0&&(n=10),s===void 0&&(s=wQ);const{isTop:d,isBottom:u,isLeft:h,isRight:f}=CO(t),p={x:0,y:0},g={x:0,y:0},v={height:e.height*s.y,width:e.width*s.x};return!d&&o<=e.top+v.height?(p.y=Kt.Backward,g.y=n*Math.abs((e.top+v.height-o)/v.height)):!u&&c>=e.bottom-v.height&&(p.y=Kt.Forward,g.y=n*Math.abs((e.bottom-v.height-c)/v.height)),!f&&a>=e.right-v.width?(p.x=Kt.Forward,g.x=n*Math.abs((e.right-v.width-a)/v.width)):!h&&i<=e.left+v.width&&(p.x=Kt.Backward,g.x=n*Math.abs((e.left+v.width-i)/v.width)),{direction:p,speed:g}}function kQ(t){if(t===document.scrollingElement){const{innerWidth:o,innerHeight:i}=window;return{top:0,left:0,right:o,bottom:i,width:o,height:i}}const{top:e,left:r,right:n,bottom:s}=t.getBoundingClientRect();return{top:e,left:r,right:n,bottom:s,width:t.clientWidth,height:t.clientHeight}}function jO(t){return t.reduce((e,r)=>_c(e,ib(r)),rs)}function SQ(t){return t.reduce((e,r)=>e+kO(r),0)}function NQ(t){return t.reduce((e,r)=>e+SO(r),0)}function CQ(t,e){if(e===void 0&&(e=Tc),!t)return;const{top:r,left:n,bottom:s,right:o}=e(t);bO(t)&&(s<=0||o<=0||r>=window.innerHeight||n>=window.innerWidth)&&t.scrollIntoView({block:"center",inline:"center"})}const jQ=[["x",["left","right"],SQ],["y",["top","bottom"],NQ]];class ab{constructor(e,r){this.rect=void 0,this.width=void 0,this.height=void 0,this.top=void 0,this.bottom=void 0,this.right=void 0,this.left=void 0;const n=Lm(r),s=jO(n);this.rect={...e},this.width=e.width,this.height=e.height;for(const[o,i,a]of jQ)for(const c of i)Object.defineProperty(this,c,{get:()=>{const d=a(n),u=s[o]-d;return this.rect[c]+u},enumerable:!0});Object.defineProperty(this,"rect",{enumerable:!1})}}class th{constructor(e){this.target=void 0,this.listeners=[],this.removeAll=()=>{this.listeners.forEach(r=>{var n;return(n=this.target)==null?void 0:n.removeEventListener(...r)})},this.target=e}add(e,r,n){var s;(s=this.target)==null||s.addEventListener(e,r,n),this.listeners.push([e,r,n])}}function EQ(t){const{EventTarget:e}=Wr(t);return t instanceof e?t:Ec(t)}function lb(t,e){const r=Math.abs(t.x),n=Math.abs(t.y);return typeof e=="number"?Math.sqrt(r**2+n**2)>e:"x"in e&&"y"in e?r>e.x&&n>e.y:"x"in e?r>e.x:"y"in e?n>e.y:!1}var Mn;(function(t){t.Click="click",t.DragStart="dragstart",t.Keydown="keydown",t.ContextMenu="contextmenu",t.Resize="resize",t.SelectionChange="selectionchange",t.VisibilityChange="visibilitychange"})(Mn||(Mn={}));function EO(t){t.preventDefault()}function _Q(t){t.stopPropagation()}var Ie;(function(t){t.Space="Space",t.Down="ArrowDown",t.Right="ArrowRight",t.Left="ArrowLeft",t.Up="ArrowUp",t.Esc="Escape",t.Enter="Enter",t.Tab="Tab"})(Ie||(Ie={}));const _O={start:[Ie.Space,Ie.Enter],cancel:[Ie.Esc],end:[Ie.Space,Ie.Enter,Ie.Tab]},TQ=(t,e)=>{let{currentCoordinates:r}=e;switch(t.code){case Ie.Right:return{...r,x:r.x+25};case Ie.Left:return{...r,x:r.x-25};case Ie.Down:return{...r,y:r.y+25};case Ie.Up:return{...r,y:r.y-25}}};class cb{constructor(e){this.props=void 0,this.autoScrollEnabled=!1,this.referenceCoordinates=void 0,this.listeners=void 0,this.windowListeners=void 0,this.props=e;const{event:{target:r}}=e;this.props=e,this.listeners=new th(Ec(r)),this.windowListeners=new th(Wr(r)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(Mn.Resize,this.handleCancel),this.windowListeners.add(Mn.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(Mn.Keydown,this.handleKeyDown))}handleStart(){const{activeNode:e,onStart:r}=this.props,n=e.node.current;n&&CQ(n),r(rs)}handleKeyDown(e){if(rb(e)){const{active:r,context:n,options:s}=this.props,{keyboardCodes:o=_O,coordinateGetter:i=TQ,scrollBehavior:a="smooth"}=s,{code:c}=e;if(o.end.includes(c)){this.handleEnd(e);return}if(o.cancel.includes(c)){this.handleCancel(e);return}const{collisionRect:d}=n.current,u=d?{x:d.left,y:d.top}:rs;this.referenceCoordinates||(this.referenceCoordinates=u);const h=i(e,{active:r,context:n.current,currentCoordinates:u});if(h){const f=Zu(h,u),p={x:0,y:0},{scrollableAncestors:g}=n.current;for(const v of g){const y=e.code,{isTop:x,isRight:w,isLeft:b,isBottom:k,maxScroll:S,minScroll:C}=CO(v),N=kQ(v),E={x:Math.min(y===Ie.Right?N.right-N.width/2:N.right,Math.max(y===Ie.Right?N.left:N.left+N.width/2,h.x)),y:Math.min(y===Ie.Down?N.bottom-N.height/2:N.bottom,Math.max(y===Ie.Down?N.top:N.top+N.height/2,h.y))},j=y===Ie.Right&&!w||y===Ie.Left&&!b,_=y===Ie.Down&&!k||y===Ie.Up&&!x;if(j&&E.x!==h.x){const P=v.scrollLeft+f.x,T=y===Ie.Right&&P<=S.x||y===Ie.Left&&P>=C.x;if(T&&!f.y){v.scrollTo({left:P,behavior:a});return}T?p.x=v.scrollLeft-P:p.x=y===Ie.Right?v.scrollLeft-S.x:v.scrollLeft-C.x,p.x&&v.scrollBy({left:-p.x,behavior:a});break}else if(_&&E.y!==h.y){const P=v.scrollTop+f.y,T=y===Ie.Down&&P<=S.y||y===Ie.Up&&P>=C.y;if(T&&!f.x){v.scrollTo({top:P,behavior:a});return}T?p.y=v.scrollTop-P:p.y=y===Ie.Down?v.scrollTop-S.y:v.scrollTop-C.y,p.y&&v.scrollBy({top:-p.y,behavior:a});break}}this.handleMove(e,_c(Zu(h,this.referenceCoordinates),p))}}}handleMove(e,r){const{onMove:n}=this.props;e.preventDefault(),n(r)}handleEnd(e){const{onEnd:r}=this.props;e.preventDefault(),this.detach(),r()}handleCancel(e){const{onCancel:r}=this.props;e.preventDefault(),this.detach(),r()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll()}}cb.activators=[{eventName:"onKeyDown",handler:(t,e,r)=>{let{keyboardCodes:n=_O,onActivation:s}=e,{active:o}=r;const{code:i}=t.nativeEvent;if(n.start.includes(i)){const a=o.activatorNode.current;return a&&t.target!==a?!1:(t.preventDefault(),s==null||s({event:t.nativeEvent}),!0)}return!1}}];function TO(t){return!!(t&&"distance"in t)}function RO(t){return!!(t&&"delay"in t)}class db{constructor(e,r,n){var s;n===void 0&&(n=EQ(e.event.target)),this.props=void 0,this.events=void 0,this.autoScrollEnabled=!0,this.document=void 0,this.activated=!1,this.initialCoordinates=void 0,this.timeoutId=null,this.listeners=void 0,this.documentListeners=void 0,this.windowListeners=void 0,this.props=e,this.events=r;const{event:o}=e,{target:i}=o;this.props=e,this.events=r,this.document=Ec(i),this.documentListeners=new th(this.document),this.listeners=new th(n),this.windowListeners=new th(Wr(i)),this.initialCoordinates=(s=nb(o))!=null?s:rs,this.handleStart=this.handleStart.bind(this),this.handleMove=this.handleMove.bind(this),this.handleEnd=this.handleEnd.bind(this),this.handleCancel=this.handleCancel.bind(this),this.handleKeydown=this.handleKeydown.bind(this),this.removeTextSelection=this.removeTextSelection.bind(this),this.attach()}attach(){const{events:e,props:{options:{activationConstraint:r,bypassActivationConstraint:n}}}=this;if(this.listeners.add(e.move.name,this.handleMove,{passive:!1}),this.listeners.add(e.end.name,this.handleEnd),e.cancel&&this.listeners.add(e.cancel.name,this.handleCancel),this.windowListeners.add(Mn.Resize,this.handleCancel),this.windowListeners.add(Mn.DragStart,EO),this.windowListeners.add(Mn.VisibilityChange,this.handleCancel),this.windowListeners.add(Mn.ContextMenu,EO),this.documentListeners.add(Mn.Keydown,this.handleKeydown),r){if(n!=null&&n({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(RO(r)){this.timeoutId=setTimeout(this.handleStart,r.delay),this.handlePending(r);return}if(TO(r)){this.handlePending(r);return}}this.handleStart()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll(),setTimeout(this.documentListeners.removeAll,50),this.timeoutId!==null&&(clearTimeout(this.timeoutId),this.timeoutId=null)}handlePending(e,r){const{active:n,onPending:s}=this.props;s(n,e,this.initialCoordinates,r)}handleStart(){const{initialCoordinates:e}=this,{onStart:r}=this.props;e&&(this.activated=!0,this.documentListeners.add(Mn.Click,_Q,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(Mn.SelectionChange,this.removeTextSelection),r(e))}handleMove(e){var r;const{activated:n,initialCoordinates:s,props:o}=this,{onMove:i,options:{activationConstraint:a}}=o;if(!s)return;const c=(r=nb(e))!=null?r:rs,d=Zu(s,c);if(!n&&a){if(TO(a)){if(a.tolerance!=null&&lb(d,a.tolerance))return this.handleCancel();if(lb(d,a.distance))return this.handleStart()}if(RO(a)&&lb(d,a.tolerance))return this.handleCancel();this.handlePending(a,d);return}e.cancelable&&e.preventDefault(),i(c)}handleEnd(){const{onAbort:e,onEnd:r}=this.props;this.detach(),this.activated||e(this.props.active),r()}handleCancel(){const{onAbort:e,onCancel:r}=this.props;this.detach(),this.activated||e(this.props.active),r()}handleKeydown(e){e.code===Ie.Esc&&this.handleCancel()}removeTextSelection(){var e;(e=this.document.getSelection())==null||e.removeAllRanges()}}const RQ={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class $m extends db{constructor(e){const{event:r}=e,n=Ec(r.target);super(e,RQ,n)}}$m.activators=[{eventName:"onPointerDown",handler:(t,e)=>{let{nativeEvent:r}=t,{onActivation:n}=e;return!r.isPrimary||r.button!==0?!1:(n==null||n({event:r}),!0)}}];const MQ={move:{name:"mousemove"},end:{name:"mouseup"}};var ub;(function(t){t[t.RightClick=2]="RightClick"})(ub||(ub={}));class OQ extends db{constructor(e){super(e,MQ,Ec(e.event.target))}}OQ.activators=[{eventName:"onMouseDown",handler:(t,e)=>{let{nativeEvent:r}=t,{onActivation:n}=e;return r.button===ub.RightClick?!1:(n==null||n({event:r}),!0)}}];const hb={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};class PQ extends db{constructor(e){super(e,hb)}static setup(){return window.addEventListener(hb.move.name,e,{capture:!1,passive:!1}),function(){window.removeEventListener(hb.move.name,e)};function e(){}}}PQ.activators=[{eventName:"onTouchStart",handler:(t,e)=>{let{nativeEvent:r}=t,{onActivation:n}=e;const{touches:s}=r;return s.length>1?!1:(n==null||n({event:r}),!0)}}];var rh;(function(t){t[t.Pointer=0]="Pointer",t[t.DraggableRect=1]="DraggableRect"})(rh||(rh={}));var Fm;(function(t){t[t.TreeOrder=0]="TreeOrder",t[t.ReversedTreeOrder=1]="ReversedTreeOrder"})(Fm||(Fm={}));function AQ(t){let{acceleration:e,activator:r=rh.Pointer,canScroll:n,draggingRect:s,enabled:o,interval:i=5,order:a=Fm.TreeOrder,pointerCoordinates:c,scrollableAncestors:d,scrollableAncestorRects:u,delta:h,threshold:f}=t;const p=DQ({delta:h,disabled:!o}),[g,v]=KJ(),y=m.useRef({x:0,y:0}),x=m.useRef({x:0,y:0}),w=m.useMemo(()=>{switch(r){case rh.Pointer:return c?{top:c.y,bottom:c.y,left:c.x,right:c.x}:null;case rh.DraggableRect:return s}},[r,s,c]),b=m.useRef(null),k=m.useCallback(()=>{const C=b.current;if(!C)return;const N=y.current.x*x.current.x,E=y.current.y*x.current.y;C.scrollBy(N,E)},[]),S=m.useMemo(()=>a===Fm.TreeOrder?[...d].reverse():d,[a,d]);m.useEffect(()=>{if(!o||!d.length||!w){v();return}for(const C of S){if((n==null?void 0:n(C))===!1)continue;const N=d.indexOf(C),E=u[N];if(!E)continue;const{direction:j,speed:_}=bQ(C,E,w,e,f);for(const P of["x","y"])p[P][j[P]]||(_[P]=0,j[P]=0);if(_.x>0||_.y>0){v(),b.current=C,g(k,i),y.current=_,x.current=j;return}}y.current={x:0,y:0},x.current={x:0,y:0},v()},[e,k,n,v,o,i,JSON.stringify(w),JSON.stringify(p),g,d,S,u,JSON.stringify(f)])}const IQ={x:{[Kt.Backward]:!1,[Kt.Forward]:!1},y:{[Kt.Backward]:!1,[Kt.Forward]:!1}};function DQ(t){let{delta:e,disabled:r}=t;const n=eb(e);return Qu(s=>{if(r||!n||!s)return IQ;const o={x:Math.sign(e.x-n.x),y:Math.sign(e.y-n.y)};return{x:{[Kt.Backward]:s.x[Kt.Backward]||o.x===-1,[Kt.Forward]:s.x[Kt.Forward]||o.x===1},y:{[Kt.Backward]:s.y[Kt.Backward]||o.y===-1,[Kt.Forward]:s.y[Kt.Forward]||o.y===1}}},[r,e,n])}function LQ(t,e){const r=e!=null?t.get(e):void 0,n=r?r.node.current:null;return Qu(s=>{var o;return e==null?null:(o=n??s)!=null?o:null},[n,e])}function $Q(t,e){return m.useMemo(()=>t.reduce((r,n)=>{const{sensor:s}=n,o=s.activators.map(i=>({eventName:i.eventName,handler:e(i.handler,n)}));return[...r,...o]},[]),[t,e])}var nh;(function(t){t[t.Always=0]="Always",t[t.BeforeDragging=1]="BeforeDragging",t[t.WhileDragging=2]="WhileDragging"})(nh||(nh={}));var fb;(function(t){t.Optimized="optimized"})(fb||(fb={}));const MO=new Map;function FQ(t,e){let{dragging:r,dependencies:n,config:s}=e;const[o,i]=m.useState(null),{frequency:a,measure:c,strategy:d}=s,u=m.useRef(t),h=y(),f=Ju(h),p=m.useCallback(function(x){x===void 0&&(x=[]),!f.current&&i(w=>w===null?x:w.concat(x.filter(b=>!w.includes(b))))},[f]),g=m.useRef(null),v=Qu(x=>{if(h&&!r)return MO;if(!x||x===MO||u.current!==t||o!=null){const w=new Map;for(let b of t){if(!b)continue;if(o&&o.length>0&&!o.includes(b.id)&&b.rect.current){w.set(b.id,b.rect.current);continue}const k=b.node.current,S=k?new ab(c(k),k):null;b.rect.current=S,S&&w.set(b.id,S)}return w}return x},[t,o,r,h,c]);return m.useEffect(()=>{u.current=t},[t]),m.useEffect(()=>{h||p()},[r,h]),m.useEffect(()=>{o&&o.length>0&&i(null)},[JSON.stringify(o)]),m.useEffect(()=>{h||typeof a!="number"||g.current!==null||(g.current=setTimeout(()=>{p(),g.current=null},a))},[a,h,p,...n]),{droppableRects:v,measureDroppableContainers:p,measuringScheduled:o!=null};function y(){switch(d){case nh.Always:return!1;case nh.BeforeDragging:return r;default:return!r}}}function OO(t,e){return Qu(r=>t?r||(typeof e=="function"?e(t):t):null,[e,t])}function zQ(t,e){return OO(t,e)}function BQ(t){let{callback:e,disabled:r}=t;const n=Z0(e),s=m.useMemo(()=>{if(r||typeof window>"u"||typeof window.MutationObserver>"u")return;const{MutationObserver:o}=window;return new o(n)},[n,r]);return m.useEffect(()=>()=>s==null?void 0:s.disconnect(),[s]),s}function zm(t){let{callback:e,disabled:r}=t;const n=Z0(e),s=m.useMemo(()=>{if(r||typeof window>"u"||typeof window.ResizeObserver>"u")return;const{ResizeObserver:o}=window;return new o(n)},[r]);return m.useEffect(()=>()=>s==null?void 0:s.disconnect(),[s]),s}function UQ(t){return new ab(Tc(t),t)}function PO(t,e,r){e===void 0&&(e=UQ);const[n,s]=m.useState(null);function o(){s(c=>{if(!t)return null;if(t.isConnected===!1){var d;return(d=c??r)!=null?d:null}const u=e(t);return JSON.stringify(c)===JSON.stringify(u)?c:u})}const i=BQ({callback(c){if(t)for(const d of c){const{type:u,target:h}=d;if(u==="childList"&&h instanceof HTMLElement&&h.contains(t)){o();break}}}}),a=zm({callback:o});return js(()=>{o(),t?(a==null||a.observe(t),i==null||i.observe(document.body,{childList:!0,subtree:!0})):(a==null||a.disconnect(),i==null||i.disconnect())},[t]),n}function VQ(t){const e=OO(t);return xO(t,e)}const AO=[];function WQ(t){const e=m.useRef(t),r=Qu(n=>t?n&&n!==AO&&t&&e.current&&t.parentNode===e.current.parentNode?n:Lm(t):AO,[t]);return m.useEffect(()=>{e.current=t},[t]),r}function HQ(t){const[e,r]=m.useState(null),n=m.useRef(t),s=m.useCallback(o=>{const i=ob(o.target);i&&r(a=>a?(a.set(i,ib(i)),new Map(a)):null)},[]);return m.useEffect(()=>{const o=n.current;if(t!==o){i(o);const a=t.map(c=>{const d=ob(c);return d?(d.addEventListener("scroll",s,{passive:!0}),[d,ib(d)]):null}).filter(c=>c!=null);r(a.length?new Map(a):null),n.current=t}return()=>{i(t),i(o)};function i(a){a.forEach(c=>{const d=ob(c);d==null||d.removeEventListener("scroll",s)})}},[s,t]),m.useMemo(()=>t.length?e?Array.from(e.values()).reduce((o,i)=>_c(o,i),rs):jO(t):rs,[t,e])}function IO(t,e){e===void 0&&(e=[]);const r=m.useRef(null);return m.useEffect(()=>{r.current=null},e),m.useEffect(()=>{const n=t!==rs;n&&!r.current&&(r.current=t),!n&&r.current&&(r.current=null)},[t]),r.current?Zu(t,r.current):rs}function qQ(t){m.useEffect(()=>{if(!Am)return;const e=t.map(r=>{let{sensor:n}=r;return n.setup==null?void 0:n.setup()});return()=>{for(const r of e)r==null||r()}},t.map(e=>{let{sensor:r}=e;return r}))}function KQ(t,e){return m.useMemo(()=>t.reduce((r,n)=>{let{eventName:s,handler:o}=n;return r[s]=i=>{o(i,e)},r},{}),[t,e])}function DO(t){return m.useMemo(()=>t?vQ(t):null,[t])}const LO=[];function GQ(t,e){e===void 0&&(e=Tc);const[r]=t,n=DO(r?Wr(r):null),[s,o]=m.useState(LO);function i(){o(()=>t.length?t.map(c=>NO(c)?n:new ab(e(c),c)):LO)}const a=zm({callback:i});return js(()=>{a==null||a.disconnect(),i(),t.forEach(c=>a==null?void 0:a.observe(c))},[t]),s}function YQ(t){if(!t)return null;if(t.children.length>1)return t;const e=t.children[0];return Yu(e)?e:t}function JQ(t){let{measure:e}=t;const[r,n]=m.useState(null),s=m.useCallback(d=>{for(const{target:u}of d)if(Yu(u)){n(h=>{const f=e(u);return h?{...h,width:f.width,height:f.height}:f});break}},[e]),o=zm({callback:s}),i=m.useCallback(d=>{const u=YQ(d);o==null||o.disconnect(),u&&(o==null||o.observe(u)),n(u?e(u):null)},[e,o]),[a,c]=Im(i);return m.useMemo(()=>({nodeRef:a,rect:r,setRef:c}),[r,a,c])}const QQ=[{sensor:$m,options:{}},{sensor:cb,options:{}}],XQ={current:{}},Bm={draggable:{measure:wO},droppable:{measure:wO,strategy:nh.WhileDragging,frequency:fb.Optimized},dragOverlay:{measure:Tc}};class sh extends Map{get(e){var r;return e!=null&&(r=super.get(e))!=null?r:void 0}toArray(){return Array.from(this.values())}getEnabled(){return this.toArray().filter(e=>{let{disabled:r}=e;return!r})}getNodeFor(e){var r,n;return(r=(n=this.get(e))==null?void 0:n.node.current)!=null?r:void 0}}const ZQ={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new sh,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:Dm},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:Bm,measureDroppableContainers:Dm,windowRect:null,measuringScheduled:!1},eX={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:Dm,draggableNodes:new Map,over:null,measureDroppableContainers:Dm},Um=m.createContext(eX),$O=m.createContext(ZQ);function tX(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new sh}}}function rX(t,e){switch(e.type){case At.DragStart:return{...t,draggable:{...t.draggable,initialCoordinates:e.initialCoordinates,active:e.active}};case At.DragMove:return t.draggable.active==null?t:{...t,draggable:{...t.draggable,translate:{x:e.coordinates.x-t.draggable.initialCoordinates.x,y:e.coordinates.y-t.draggable.initialCoordinates.y}}};case At.DragEnd:case At.DragCancel:return{...t,draggable:{...t.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case At.RegisterDroppable:{const{element:r}=e,{id:n}=r,s=new sh(t.droppable.containers);return s.set(n,r),{...t,droppable:{...t.droppable,containers:s}}}case At.SetDroppableDisabled:{const{id:r,key:n,disabled:s}=e,o=t.droppable.containers.get(r);if(!o||n!==o.key)return t;const i=new sh(t.droppable.containers);return i.set(r,{...o,disabled:s}),{...t,droppable:{...t.droppable,containers:i}}}case At.UnregisterDroppable:{const{id:r,key:n}=e,s=t.droppable.containers.get(r);if(!s||n!==s.key)return t;const o=new sh(t.droppable.containers);return o.delete(r),{...t,droppable:{...t.droppable,containers:o}}}default:return t}}function nX(t){let{disabled:e}=t;const{active:r,activatorEvent:n,draggableNodes:s}=m.useContext(Um),o=eb(n),i=eb(r==null?void 0:r.id);return m.useEffect(()=>{if(!e&&!n&&o&&i!=null){if(!rb(o)||document.activeElement===o.target)return;const a=s.get(i);if(!a)return;const{activatorNode:c,node:d}=a;if(!c.current&&!d.current)return;requestAnimationFrame(()=>{for(const u of[c.current,d.current]){if(!u)continue;const h=JJ(u);if(h){h.focus();break}}})}},[n,e,s,i,o]),null}function sX(t,e){let{transform:r,...n}=e;return t!=null&&t.length?t.reduce((s,o)=>o({transform:s,...n}),r):r}function oX(t){return m.useMemo(()=>({draggable:{...Bm.draggable,...t==null?void 0:t.draggable},droppable:{...Bm.droppable,...t==null?void 0:t.droppable},dragOverlay:{...Bm.dragOverlay,...t==null?void 0:t.dragOverlay}}),[t==null?void 0:t.draggable,t==null?void 0:t.droppable,t==null?void 0:t.dragOverlay])}function iX(t){let{activeNode:e,measure:r,initialRect:n,config:s=!0}=t;const o=m.useRef(!1),{x:i,y:a}=typeof s=="boolean"?{x:s,y:s}:s;js(()=>{if(!i&&!a||!e){o.current=!1;return}if(o.current||!n)return;const d=e==null?void 0:e.node.current;if(!d||d.isConnected===!1)return;const u=r(d),h=xO(u,n);if(i||(h.x=0),a||(h.y=0),o.current=!0,Math.abs(h.x)>0||Math.abs(h.y)>0){const f=bO(d);f&&f.scrollBy({top:h.y,left:h.x})}},[e,i,a,n,r])}const FO=m.createContext({...rs,scaleX:1,scaleY:1});var gi;(function(t){t[t.Uninitialized=0]="Uninitialized",t[t.Initializing=1]="Initializing",t[t.Initialized=2]="Initialized"})(gi||(gi={}));const zO=m.memo(function(e){var r,n,s,o;let{id:i,accessibility:a,autoScroll:c=!0,children:d,sensors:u=QQ,collisionDetection:h=dQ,measuring:f,modifiers:p,...g}=e;const v=m.useReducer(rX,void 0,tX),[y,x]=v,[w,b]=rQ(),[k,S]=m.useState(gi.Uninitialized),C=k===gi.Initialized,{draggable:{active:N,nodes:E,translate:j},droppable:{containers:_}}=y,P=N!=null?E.get(N):null,T=m.useRef({initial:null,translated:null}),A=m.useMemo(()=>{var jt;return N!=null?{id:N,data:(jt=P==null?void 0:P.data)!=null?jt:XQ,rect:T}:null},[N,P]),I=m.useRef(null),[V,L]=m.useState(null),[U,M]=m.useState(null),D=Ju(g,Object.values(g)),H=Xu("DndDescribedBy",i),ne=m.useMemo(()=>_.getEnabled(),[_]),$=oX(f),{droppableRects:G,measureDroppableContainers:J,measuringScheduled:O}=FQ(ne,{dragging:C,dependencies:[j.x,j.y],config:$.droppable}),z=LQ(E,N),F=m.useMemo(()=>U?nb(U):null,[U]),te=Qb(),ee=zQ(z,$.draggable.measure);iX({activeNode:N!=null?E.get(N):null,config:te.layoutShiftCompensation,initialRect:ee,measure:$.draggable.measure});const Z=PO(z,$.draggable.measure,ee),ve=PO(z?z.parentElement:null),ce=m.useRef({activatorEvent:null,active:null,activeNode:z,collisionRect:null,collisions:null,droppableRects:G,draggableNodes:E,draggingNode:null,draggingNodeRect:null,droppableContainers:_,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),Le=_.getNodeFor((r=ce.current.over)==null?void 0:r.id),We=JQ({measure:$.dragOverlay.measure}),It=(n=We.nodeRef.current)!=null?n:z,Dt=C?(s=We.rect)!=null?s:Z:null,Dn=!!(We.nodeRef.current&&We.rect),cs=VQ(Dn?null:Z),Ps=DO(It?Wr(It):null),ds=WQ(C?Le??z:null),As=GQ(ds),Va=sX(p,{transform:{x:j.x-cs.x,y:j.y-cs.y,scaleX:1,scaleY:1},activatorEvent:U,active:A,activeNodeRect:Z,containerNodeRect:ve,draggingNodeRect:Dt,over:ce.current.over,overlayNodeRect:We.rect,scrollableAncestors:ds,scrollableAncestorRects:As,windowRect:Ps}),Is=F?_c(F,j):null,hg=HQ(ds),Yb=IO(hg),Kr=IO(hg,[Z]),dn=_c(Va,Yb),Mi=Dt?fQ(Dt,Va):null,Wa=A&&Mi?h({active:A,collisionRect:Mi,droppableRects:G,droppableContainers:ne,pointerCoordinates:Is}):null,Ha=vO(Wa,"id"),[Ds,bh]=m.useState(null),kh=Dn?Va:_c(Va,Kr),Oi=uQ(kh,(o=Ds==null?void 0:Ds.rect)!=null?o:null,Z),qc=m.useRef(null),mo=m.useCallback((jt,ht)=>{let{sensor:Or,options:ye}=ht;if(I.current==null)return;const Ee=E.get(I.current);if(!Ee)return;const Me=jt.nativeEvent,ft=new Or({active:I.current,activeNode:Ee,event:Me,options:ye,context:ce,onAbort(Ge){if(!E.get(Ge))return;const{onDragAbort:pt}=D.current,Yt={id:Ge};pt==null||pt(Yt),w({type:"onDragAbort",event:Yt})},onPending(Ge,yr,pt,Yt){if(!E.get(Ge))return;const{onDragPending:Nh}=D.current,Pi={id:Ge,constraint:yr,initialCoordinates:pt,offset:Yt};Nh==null||Nh(Pi),w({type:"onDragPending",event:Pi})},onStart(Ge){const yr=I.current;if(yr==null)return;const pt=E.get(yr);if(!pt)return;const{onDragStart:Yt}=D.current,Sh={activatorEvent:Me,active:{id:yr,data:pt.data,rect:T}};vn.unstable_batchedUpdates(()=>{Yt==null||Yt(Sh),S(gi.Initializing),x({type:At.DragStart,initialCoordinates:Ge,active:yr}),w({type:"onDragStart",event:Sh}),L(qc.current),M(Me)})},onMove(Ge){x({type:At.DragMove,coordinates:Ge})},onEnd:Gt(At.DragEnd),onCancel:Gt(At.DragCancel)});qc.current=ft;function Gt(Ge){return async function(){const{active:pt,collisions:Yt,over:Sh,scrollAdjustedTranslate:Nh}=ce.current;let Pi=null;if(pt&&Nh){const{cancelDrop:Ch}=D.current;Pi={activatorEvent:Me,active:pt,collisions:Yt,delta:Nh,over:Sh},Ge===At.DragEnd&&typeof Ch=="function"&&await Promise.resolve(Ch(Pi))&&(Ge=At.DragCancel)}I.current=null,vn.unstable_batchedUpdates(()=>{x({type:Ge}),S(gi.Uninitialized),bh(null),L(null),M(null),qc.current=null;const Ch=Ge===At.DragEnd?"onDragEnd":"onDragCancel";if(Pi){const Xb=D.current[Ch];Xb==null||Xb(Pi),w({type:Ch,event:Pi})}})}}},[E]),Jb=m.useCallback((jt,ht)=>(Or,ye)=>{const Ee=Or.nativeEvent,Me=E.get(ye);if(I.current!==null||!Me||Ee.dndKit||Ee.defaultPrevented)return;const ft={active:Me};jt(Or,ht.options,ft)===!0&&(Ee.dndKit={capturedBy:ht.sensor},I.current=ye,mo(Or,ht))},[E,mo]),fg=$Q(u,Jb);qQ(u),js(()=>{Z&&k===gi.Initializing&&S(gi.Initialized)},[Z,k]),m.useEffect(()=>{const{onDragMove:jt}=D.current,{active:ht,activatorEvent:Or,collisions:ye,over:Ee}=ce.current;if(!ht||!Or)return;const Me={active:ht,activatorEvent:Or,collisions:ye,delta:{x:dn.x,y:dn.y},over:Ee};vn.unstable_batchedUpdates(()=>{jt==null||jt(Me),w({type:"onDragMove",event:Me})})},[dn.x,dn.y]),m.useEffect(()=>{const{active:jt,activatorEvent:ht,collisions:Or,droppableContainers:ye,scrollAdjustedTranslate:Ee}=ce.current;if(!jt||I.current==null||!ht||!Ee)return;const{onDragOver:Me}=D.current,ft=ye.get(Ha),Gt=ft&&ft.rect.current?{id:ft.id,rect:ft.rect.current,data:ft.data,disabled:ft.disabled}:null,Ge={active:jt,activatorEvent:ht,collisions:Or,delta:{x:Ee.x,y:Ee.y},over:Gt};vn.unstable_batchedUpdates(()=>{bh(Gt),Me==null||Me(Ge),w({type:"onDragOver",event:Ge})})},[Ha]),js(()=>{ce.current={activatorEvent:U,active:A,activeNode:z,collisionRect:Mi,collisions:Wa,droppableRects:G,draggableNodes:E,draggingNode:It,draggingNodeRect:Dt,droppableContainers:_,over:Ds,scrollableAncestors:ds,scrollAdjustedTranslate:dn},T.current={initial:Dt,translated:Mi}},[A,z,Wa,Mi,E,It,Dt,G,_,Ds,ds,dn]),AQ({...te,delta:j,draggingRect:Mi,pointerCoordinates:Is,scrollableAncestors:ds,scrollableAncestorRects:As});const pg=m.useMemo(()=>({active:A,activeNode:z,activeNodeRect:Z,activatorEvent:U,collisions:Wa,containerNodeRect:ve,dragOverlay:We,draggableNodes:E,droppableContainers:_,droppableRects:G,over:Ds,measureDroppableContainers:J,scrollableAncestors:ds,scrollableAncestorRects:As,measuringConfiguration:$,measuringScheduled:O,windowRect:Ps}),[A,z,Z,U,Wa,ve,We,E,_,G,Ds,J,ds,As,$,O,Ps]),mg=m.useMemo(()=>({activatorEvent:U,activators:fg,active:A,activeNodeRect:Z,ariaDescribedById:{draggable:H},dispatch:x,draggableNodes:E,over:Ds,measureDroppableContainers:J}),[U,fg,A,Z,x,H,E,Ds,J]);return W.createElement(hO.Provider,{value:b},W.createElement(Um.Provider,{value:mg},W.createElement($O.Provider,{value:pg},W.createElement(FO.Provider,{value:Oi},d)),W.createElement(nX,{disabled:(a==null?void 0:a.restoreFocus)===!1})),W.createElement(oQ,{...a,hiddenTextDescribedById:H}));function Qb(){const jt=(V==null?void 0:V.autoScrollEnabled)===!1,ht=typeof c=="object"?c.enabled===!1:c===!1,Or=C&&!jt&&!ht;return typeof c=="object"?{...c,enabled:Or}:{enabled:Or}}}),aX=m.createContext(null),BO="button",lX="Draggable";function UO(t){let{id:e,data:r,disabled:n=!1,attributes:s}=t;const o=Xu(lX),{activators:i,activatorEvent:a,active:c,activeNodeRect:d,ariaDescribedById:u,draggableNodes:h,over:f}=m.useContext(Um),{role:p=BO,roleDescription:g="draggable",tabIndex:v=0}=s??{},y=(c==null?void 0:c.id)===e,x=m.useContext(y?FO:aX),[w,b]=Im(),[k,S]=Im(),C=KQ(i,e),N=Ju(r);js(()=>(h.set(e,{id:e,key:o,node:w,activatorNode:k,data:N}),()=>{const j=h.get(e);j&&j.key===o&&h.delete(e)}),[h,e]);const E=m.useMemo(()=>({role:p,tabIndex:v,"aria-disabled":n,"aria-pressed":y&&p===BO?!0:void 0,"aria-roledescription":g,"aria-describedby":u.draggable}),[n,p,v,y,g,u.draggable]);return{active:c,activatorEvent:a,activeNodeRect:d,attributes:E,isDragging:y,listeners:n?void 0:C,node:w,over:f,setNodeRef:b,setActivatorNodeRef:S,transform:x}}function cX(){return m.useContext($O)}const dX="Droppable",uX={timeout:25};function VO(t){let{data:e,disabled:r=!1,id:n,resizeObserverConfig:s}=t;const o=Xu(dX),{active:i,dispatch:a,over:c,measureDroppableContainers:d}=m.useContext(Um),u=m.useRef({disabled:r}),h=m.useRef(!1),f=m.useRef(null),p=m.useRef(null),{disabled:g,updateMeasurementsFor:v,timeout:y}={...uX,...s},x=Ju(v??n),w=m.useCallback(()=>{if(!h.current){h.current=!0;return}p.current!=null&&clearTimeout(p.current),p.current=setTimeout(()=>{d(Array.isArray(x.current)?x.current:[x.current]),p.current=null},y)},[y]),b=zm({callback:w,disabled:g||!i}),k=m.useCallback((E,j)=>{b&&(j&&(b.unobserve(j),h.current=!1),E&&b.observe(E))},[b]),[S,C]=Im(k),N=Ju(e);return m.useEffect(()=>{!b||!S.current||(b.disconnect(),h.current=!1,b.observe(S.current))},[S,b]),m.useEffect(()=>(a({type:At.RegisterDroppable,element:{id:n,key:o,disabled:r,node:S,rect:f,data:N}}),()=>a({type:At.UnregisterDroppable,key:o,id:n})),[n]),m.useEffect(()=>{r!==u.current.disabled&&(a({type:At.SetDroppableDisabled,id:n,key:o,disabled:r}),u.current.disabled=r)},[n,o,r,a]),{active:i,rect:f,isOver:(c==null?void 0:c.id)===n,node:S,over:c,setNodeRef:C}}function WO(t,e,r){const n=t.slice();return n.splice(r<0?n.length+r:r,0,n.splice(e,1)[0]),n}function hX(t,e){return t.reduce((r,n,s)=>{const o=e.get(n);return o&&(r[s]=o),r},Array(t.length))}function Vm(t){return t!==null&&t>=0}function fX(t,e){if(t===e)return!0;if(t.length!==e.length)return!1;for(let r=0;r{let{rects:e,activeIndex:r,overIndex:n,index:s}=t;const o=WO(e,n,r),i=e[s],a=o[s];return!a||!i?null:{x:a.left-i.left,y:a.top-i.top,scaleX:a.width/i.width,scaleY:a.height/i.height}},HO="Sortable",qO=W.createContext({activeIndex:-1,containerId:HO,disableTransforms:!1,items:[],overIndex:-1,useDragOverlay:!1,sortedRects:[],strategy:oh,disabled:{draggable:!1,droppable:!1}});function pb(t){let{children:e,id:r,items:n,strategy:s=oh,disabled:o=!1}=t;const{active:i,dragOverlay:a,droppableRects:c,over:d,measureDroppableContainers:u}=cX(),h=Xu(HO,r),f=a.rect!==null,p=m.useMemo(()=>n.map(C=>typeof C=="object"&&"id"in C?C.id:C),[n]),g=i!=null,v=i?p.indexOf(i.id):-1,y=d?p.indexOf(d.id):-1,x=m.useRef(p),w=!fX(p,x.current),b=y!==-1&&v===-1||w,k=pX(o);js(()=>{w&&g&&u(p)},[w,p,g,u]),m.useEffect(()=>{x.current=p},[p]);const S=m.useMemo(()=>({activeIndex:v,containerId:h,disabled:k,disableTransforms:b,items:p,overIndex:y,useDragOverlay:f,sortedRects:hX(p,c),strategy:s}),[v,h,k.draggable,k.droppable,b,p,y,c,f,s]);return W.createElement(qO.Provider,{value:S},e)}const mX=t=>{let{id:e,items:r,activeIndex:n,overIndex:s}=t;return WO(r,n,s).indexOf(e)},gX=t=>{let{containerId:e,isSorting:r,wasDragging:n,index:s,items:o,newIndex:i,previousItems:a,previousContainerId:c,transition:d}=t;return!d||!n||a!==o&&s===i?!1:r?!0:i!==s&&e===c},vX={duration:200,easing:"ease"},KO="transform",yX=eh.Transition.toString({property:KO,duration:0,easing:"linear"}),xX={roleDescription:"sortable"};function wX(t){let{disabled:e,index:r,node:n,rect:s}=t;const[o,i]=m.useState(null),a=m.useRef(r);return js(()=>{if(!e&&r!==a.current&&n.current){const c=s.current;if(c){const d=Tc(n.current,{ignoreTransform:!0}),u={x:c.left-d.left,y:c.top-d.top,scaleX:c.width/d.width,scaleY:c.height/d.height};(u.x||u.y)&&i(u)}}r!==a.current&&(a.current=r)},[e,r,n,s]),m.useEffect(()=>{o&&i(null)},[o]),o}function bX(t){let{animateLayoutChanges:e=gX,attributes:r,disabled:n,data:s,getNewIndex:o=mX,id:i,strategy:a,resizeObserverConfig:c,transition:d=vX}=t;const{items:u,containerId:h,activeIndex:f,disabled:p,disableTransforms:g,sortedRects:v,overIndex:y,useDragOverlay:x,strategy:w}=m.useContext(qO),b=kX(n,p),k=u.indexOf(i),S=m.useMemo(()=>({sortable:{containerId:h,index:k,items:u},...s}),[h,s,k,u]),C=m.useMemo(()=>u.slice(u.indexOf(i)),[u,i]),{rect:N,node:E,isOver:j,setNodeRef:_}=VO({id:i,data:S,disabled:b.droppable,resizeObserverConfig:{updateMeasurementsFor:C,...c}}),{active:P,activatorEvent:T,activeNodeRect:A,attributes:I,setNodeRef:V,listeners:L,isDragging:U,over:M,setActivatorNodeRef:D,transform:H}=UO({id:i,data:S,attributes:{...xX,...r},disabled:b.draggable}),ne=qJ(_,V),$=!!P,G=&!g&&Vm(f)&&Vm(y),J=!x&&U,O=J&&G?H:null,F=G?O??(a??w)({rects:v,activeNodeRect:A,activeIndex:f,overIndex:y,index:k}):null,te=Vm(f)&&Vm(y)?o({id:i,items:u,activeIndex:f,overIndex:y}):k,ee=P==null?void 0:P.id,Z=m.useRef({activeId:ee,items:u,newIndex:te,containerId:h}),ve=u!==Z.current.items,ce=e({active:P,containerId:h,isDragging:U,isSorting:$,id:i,index:k,items:u,newIndex:Z.current.newIndex,previousItems:Z.current.items,previousContainerId:Z.current.containerId,transition:d,wasDragging:Z.current.activeId!=null}),Le=wX({disabled:!ce,index:k,node:E,rect:N});return m.useEffect(()=>{&Z.current.newIndex!==te&&(Z.current.newIndex=te),h!==Z.current.containerId&&(Z.current.containerId=h),u!==Z.current.items&&(Z.current.items=u)},[$,te,h,u]),m.useEffect(()=>{if(ee===Z.current.activeId)return;if(ee!=null&&Z.current.activeId==null){Z.current.activeId=ee;return}const It=setTimeout(()=>{Z.current.activeId=ee},50);return()=>clearTimeout(It)},[ee]),{active:P,activeIndex:f,attributes:I,data:S,rect:N,index:k,newIndex:te,items:u,isOver:j,isSorting:$,isDragging:U,listeners:L,node:E,overIndex:y,over:M,setNodeRef:ne,setActivatorNodeRef:D,setDroppableNodeRef:_,setDraggableNodeRef:V,transform:Le??F,transition:We()};function We(){if(Le||ve&&Z.current.newIndex===k)return yX;if(!(J&&!rb(T)||!d)&&($||ce))return eh.Transition.toString({...d,property:KO})}}function kX(t,e){var r,n;return typeof t=="boolean"?{draggable:t,droppable:!1}:{draggable:(r=t==null?void 0:t.draggable)!=null?r:e.draggable,droppable:(n=t==null?void 0:t.droppable)!=null?n:e.droppable}}function Wm(t){if(!t)return!1;const e=t.data.current;return!!(e&&"sortable"in e&&typeof e.sortable=="object"&&"containerId"in e.sortable&&"items"in e.sortable&&"index"in e.sortable)}const SX=[Ie.Down,Ie.Right,Ie.Up,Ie.Left],NX=(t,e)=>{let{context:{active:r,collisionRect:n,droppableRects:s,droppableContainers:o,over:i,scrollableAncestors:a}}=e;if(SX.includes(t.code)){if(t.preventDefault(),!r||!n)return;const c=[];o.getEnabled().forEach(h=>{if(!h||h!=null&&h.disabled)return;const f=s.get(h.id);if(f)switch(t.code){case Ie.Down:n.topf.top&&c.push(h);break;case Ie.Left:n.left>f.left&&c.push(h);break;case Ie.Right:n.left1&&(u=d[1].id),u!=null){const h=o.get(r.id),f=o.get(u),p=f?s.get(f.id):null,g=f==null?void 0:f.node.current;if(g&&p&&h&&f){const y=Lm(g).some((C,N)=>a[N]!==C),x=GO(h,f),w=CX(h,f),b=y||!x?{x:0,y:0}:{x:w?n.width-p.width:0,y:w?n.height-p.height:0},k={x:p.left,y:p.top};return b.x&&b.y?k:Zu(k,b)}}}};function GO(t,e){return!Wm(t)||!Wm(e)?!1:t.data.current.sortable.containerId===e.data.current.sortable.containerId}function CX(t,e){return!Wm(t)||!Wm(e)||!GO(t,e)?!1:t.data.current.sortable.index{const i=localStorage.getItem(Hm);if(i)try{const a=JSON.parse(i),c=ih.map((d,u)=>{const h=a.find(f=>f.id===d.id);return h?{...d,enabled:h.enabled,order:h.order??u}:{...d,order:u}});c.sort((d,u)=>d.order-u.order),e(c)}catch{e(ih)}},[]);const r=i=>{e(a=>{const c=a.map(d=>d.id===i?{...d,enabled:!d.enabled}:d);return localStorage.setItem(Hm,JSON.stringify(c)),c})},n=m.useCallback((i,a)=>{e(c=>{const d=c.findIndex(g=>g.id===i),u=c.findIndex(g=>g.id===a);if(d===-1||u===-1)return c;const h=[...c],[f]=h.splice(d,1);h.splice(u,0,f);const p=h.map((g,v)=>({...g,order:v}));return localStorage.setItem(Hm,JSON.stringify(p)),p})},[]),s=()=>{e(ih),localStorage.setItem(Hm,JSON.stringify(ih))},o=t.filter(i=>i.enabled);return{widgets:t,enabledWidgets:o,toggleWidget:r,reorderWidgets:n,resetToDefaults:s}}var EX="Label",YO=m.forwardRef((t,e)=>l.jsx(se.label,{...t,ref:e,onMouseDown:r=>{var s;r.target.closest("button, input, select, textarea")||((s=t.onMouseDown)==null||s.call(t,r),!r.defaultPrevented&&r.detail>1&&r.preventDefault())}}));YO.displayName=EX;var JO=YO;const _X=Sl("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),de=m.forwardRef(({className:t,...e},r)=>l.jsx(JO,{ref:r,className:B(_X(),t),...e}));de.displayName=JO.displayName;function TX({widgets:t,onToggle:e,onReset:r}){return l.jsxs(wn,{children:[l.jsx(t_,{asChild:!0,children:l.jsxs(K,{variant:"outline",size:"sm",children:[l.jsx(iL,{className:"h-4 w-4 mr-2"}),"Customize"]})}),l.jsxs(nn,{className:"sm:max-w-md",children:[l.jsxs(bn,{children:[l.jsx(kn,{children:"Customize Dashboard"}),l.jsx(Wl,{children:"Choose which widgets to show on your dashboard"})]}),l.jsx("div",{className:"space-y-4 py-4",children:t.map(n=>l.jsxs("div",{className:"flex items-center justify-between gap-4 p-3 rounded-lg border border-border hover:bg-secondary/50 transition-colors",children:[l.jsxs("div",{className:"flex-1",children:[l.jsx(de,{htmlFor:`widget-${n.id}`,className:"font-medium cursor-pointer",children:n.name}),l.jsx("p",{className:"text-xs text-muted-foreground mt-0.5",children:n.description})]}),l.jsx(Ko,{id:`widget-${n.id}`,checked:n.enabled,onCheckedChange:()=>e(n.id)})]},n.id))}),l.jsx("div",{className:"flex justify-end",children:l.jsxs(K,{variant:"ghost",size:"sm",onClick:r,children:[l.jsx(kC,{className:"h-4 w-4 mr-2"}),"Reset to Defaults"]})})]})]})}function mb({id:t,children:e,className:r}){const{attributes:n,listeners:s,setNodeRef:o,transform:i,transition:a,isDragging:c}=bX({id:t}),d={transform:eh.Transform.toString(i),transition:a};return l.jsxs("div",{ref:o,style:d,className:B("relative group",c&&"z-50 opacity-90",r),children:[l.jsx("div",{...n,...s,className:"absolute top-3 right-12 z-10 p-1.5 rounded-md bg-secondary/80 opacity-0 group-hover:opacity-100 transition-opacity cursor-grab active:cursor-grabbing",children:l.jsx(V3,{className:"h-4 w-4 text-muted-foreground"})}),e]})}const RX=Sl("rounded-2xl border bg-card text-card-foreground",{variants:{variant:{default:"shadow-sm",glass:"bg-card/80 backdrop-blur-xl border-border/50",interactive:"shadow-sm hover:shadow-lg hover:border-primary/20 transition-all duration-200 cursor-pointer",bordered:"border-2 border-primary/20"}},defaultVariants:{variant:"default"}}),fe=m.forwardRef(({className:t,variant:e,...r},n)=>l.jsx("div",{ref:n,className:B(RX({variant:e}),t),...r}));fe.displayName="Card";const Nt=m.forwardRef(({className:t,...e},r)=>l.jsx("div",{ref:r,className:B("flex flex-col space-y-1.5 p-6",t),...e}));Nt.displayName="CardHeader";const Ct=m.forwardRef(({className:t,...e},r)=>l.jsx("h3",{ref:r,className:B("text-lg font-semibold leading-none tracking-tight",t),...e}));Ct.displayName="CardTitle";const uo=m.forwardRef(({className:t,...e},r)=>l.jsx("p",{ref:r,className:B("text-sm text-muted-foreground",t),...e}));uo.displayName="CardDescription";const xe=m.forwardRef(({className:t,...e},r)=>l.jsx("div",{ref:r,className:B("p-6 pt-0",t),...e}));xe.displayName="CardContent";const MX=m.forwardRef(({className:t,...e},r)=>l.jsx("div",{ref:r,className:B("flex items-center p-6 pt-0",t),...e}));MX.displayName="CardFooter";function OX(){const{events:t,classes:e}=Ot(),r=new Date,n=yt(r,7),s=t.filter(c=>{const d=new Date(c.date);return d>=ou(r)&&d<=n}).sort((c,d)=>new Date(c.date).getTime()-new Date(d.date).getTime()).slice(0,5),o=c=>e.find(d=>d.id===c),i=c=>Nn(c)?"Today":g8(c)?"Tomorrow":pe(c,"EEE, MMM d"),a=c=>{const[d,u]=c.split(":"),h=parseInt(d,10),f=h>=12?"PM":"AM";return`${h%12||12}:${u} ${f}`};return l.jsxs(fe,{className:"h-full flex flex-col",children:[l.jsx(Nt,{className:"pb-3",children:l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs(Ct,{className:"flex items-center gap-2 text-base",children:[l.jsx("div",{className:"p-1.5 rounded-lg bg-primary/10",children:l.jsx(Sr,{className:"h-4 w-4 text-primary"})}),"Upcoming Events"]}),l.jsx(K,{variant:"ghost",size:"sm",asChild:!0,children:l.jsxs(rn,{to:"/calendar",children:["View All",l.jsx(wt,{className:"h-4 w-4 ml-1"})]})})]})}),l.jsx(xe,{className:"flex-1 pt-0",children:s.length===0?l.jsxs("div",{className:"flex flex-col items-center justify-center h-full py-8 text-center",children:[l.jsx(Sr,{className:"h-10 w-10 text-muted-foreground mb-3"}),l.jsx("p",{className:"text-sm text-muted-foreground",children:"No upcoming events"})]}):l.jsx("div",{className:"space-y-3",children:s.map(c=>{const d=o(c.classId),u=new Date(c.date);return l.jsxs("div",{className:"flex items-start gap-3 p-3 rounded-lg bg-secondary/50 hover:bg-secondary transition-colors",children:[l.jsx("div",{className:"h-10 w-1 rounded-full shrink-0 bg-primary",style:{backgroundColor:d==null?void 0:d.color}}),l.jsxs("div",{className:"flex-1 min-w-0",children:[l.jsxs("div",{className:"flex items-start justify-between gap-2",children:[l.jsx("h4",{className:"font-medium text-sm text-foreground truncate",children:c.title}),d&&l.jsx(ue,{variant:"class",className:"shrink-0 text-xs",style:{backgroundColor:`${d.color}20`,borderColor:`${d.color}50`,color:d.color},children:d.code})]}),l.jsxs("div",{className:"flex items-center gap-3 mt-1.5 text-xs text-muted-foreground",children:[l.jsxs("span",{className:B("flex items-center gap-1",Nn(u)&&"text-primary font-medium"),children:[l.jsx(tr,{className:"h-3 w-3"}),i(u),", ",a(c.startTime)]}),c.location&&l.jsxs("span",{className:"flex items-center gap-1",children:[l.jsx($o,{className:"h-3 w-3"}),c.location]})]})]})]},c.id)})})})]})}function PX(){const{assignments:t,classes:e,updateAssignment:r}=Ot(),n=t.filter(d=>d.status!=="completed").sort((d,u)=>new Date(d.dueDate).getTime()-new Date(u.dueDate).getTime()).slice(0,4),s=d=>e.find(u=>u.id===d),o=d=>{const u=new Date,f=new Date(d).getTime()-u.getTime();return Math.ceil(f/(1e3*60*60*24))},i=(d,u)=>{r(d,{status:u==="completed"?"todo":"completed"})},a=t.filter(d=>d.status==="completed").length,c=t.length;return l.jsxs(fe,{className:"h-full flex flex-col",children:[l.jsxs(Nt,{className:"pb-3",children:[l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs(Ct,{className:"flex items-center gap-2 text-base",children:[l.jsx("div",{className:"p-1.5 rounded-lg bg-success/10",children:l.jsx(jl,{className:"h-4 w-4 text-success"})}),"To-Do List"]}),l.jsx(K,{variant:"ghost",size:"sm",asChild:!0,children:l.jsxs(rn,{to:"/todo",children:["View All",l.jsx(wt,{className:"h-4 w-4 ml-1"})]})})]}),c>0&&l.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:[a," of ",c," completed"]})]}),l.jsx(xe,{className:"flex-1 pt-0",children:n.length===0?l.jsxs("div",{className:"flex flex-col items-center justify-center h-full py-8 text-center",children:[l.jsx(Lo,{className:"h-10 w-10 text-success mb-3"}),l.jsx("p",{className:"text-sm text-muted-foreground",children:"All caught up!"})]}):l.jsx("div",{className:"space-y-2",children:n.map(d=>{const u=s(d.classId),h=o(d.dueDate),f=h<0,p=h>=0&&h<=2;return l.jsxs("div",{className:"flex items-start gap-2 p-2 rounded-lg hover:bg-secondary/50 transition-colors group",children:[l.jsx("button",{onClick:()=>i(d.id,d.status),className:"mt-0.5 shrink-0",children:l.jsx(Gs,{className:"h-4 w-4 text-muted-foreground group-hover:text-primary transition-colors"})}),l.jsxs("div",{className:"flex-1 min-w-0",children:[l.jsx("p",{className:"text-sm font-medium text-foreground truncate",children:d.title}),l.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[u&&l.jsx(ue,{variant:"class",className:"text-xs px-1.5 py-0",style:{backgroundColor:`${u.color}20`,borderColor:`${u.color}50`,color:u.color},children:u.code}),l.jsxs("span",{className:B("flex items-center gap-1 text-xs",f?"text-destructive":p?"text-warning":"text-muted-foreground"),children:[f?l.jsx(Vd,{className:"h-3 w-3"}):l.jsx(tr,{className:"h-3 w-3"}),f?`${Math.abs(h)}d overdue`:h===0?"Today":`${h}d`]})]})]})]},d.id)})})})]})}function AX(){const{classes:t}=Ot(),e=t.slice(0,4),r=s=>{const o=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"];return s.map(i=>o[i.dayOfWeek]).join(", ")},n=s=>{const[o,i]=s.split(":"),a=parseInt(o,10),c=a>=12?"PM":"AM";return`${a%12||12}:${i} ${c}`};return l.jsxs(fe,{className:"h-full flex flex-col",children:[l.jsx(Nt,{className:"pb-3",children:l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs(Ct,{className:"flex items-center gap-2 text-base",children:[l.jsx("div",{className:"p-1.5 rounded-lg bg-accent",children:l.jsx(vt,{className:"h-4 w-4 text-accent-foreground"})}),"My Classes"]}),l.jsx(K,{variant:"ghost",size:"sm",asChild:!0,children:l.jsxs(rn,{to:"/classes",children:["View All",l.jsx(wt,{className:"h-4 w-4 ml-1"})]})})]})}),l.jsx(xe,{className:"flex-1 pt-0",children:e.length===0?l.jsxs("div",{className:"flex flex-col items-center justify-center h-full py-8 text-center",children:[l.jsx(vt,{className:"h-10 w-10 text-muted-foreground mb-3"}),l.jsx("p",{className:"text-sm text-muted-foreground",children:"No classes yet"}),l.jsx(K,{variant:"outline",size:"sm",className:"mt-3",asChild:!0,children:l.jsx(rn,{to:"/classes",children:"Add a class"})})]}):l.jsx("div",{className:"space-y-3",children:e.map(s=>{var i,a;const o=(i=s.schedule)==null?void 0:i[0];return l.jsxs(rn,{to:`/classes/${s.id}`,className:"flex items-start gap-3 p-3 rounded-lg hover:bg-secondary/50 transition-colors group",children:[l.jsx("div",{className:"h-10 w-10 rounded-lg flex items-center justify-center shrink-0",style:{backgroundColor:`${s.color}20`},children:l.jsx("span",{className:"text-sm font-bold",style:{color:s.color},children:((a=s.code)==null?void 0:a.substring(0,2))||s.name.substring(0,2)})}),l.jsxs("div",{className:"flex-1 min-w-0",children:[l.jsxs("p",{className:"font-medium text-sm text-foreground truncate group-hover:text-primary transition-colors",children:[s.code&&l.jsx("span",{className:"mr-1",children:s.code}),s.name]}),o&&l.jsx("div",{className:"flex items-center gap-3 mt-1 text-xs text-muted-foreground",children:l.jsxs("span",{className:"flex items-center gap-1",children:[l.jsx(tr,{className:"h-3 w-3"}),n(o.startTime)," - ",n(o.endTime)]})}),s.schedule&&s.schedule.length>0&&l.jsx("p",{className:"text-xs text-muted-foreground mt-0.5",children:r(s.schedule)})]})]},s.id)})})})]})}var QO={exports:{}},XO={};/** * @license React * use-sync-external-store-shim.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 Rc=m;function IX(t,e){return t===e&&(t!==0||1/t===1/e)||t!==t&&e!==e}var DX=typeof Object.is=="function"?Object.is:IX,LX=Rc.useState,$X=Rc.useEffect,FX=Rc.useLayoutEffect,zX=Rc.useDebugValue;function BX(t,e){var r=e(),n=LX({inst:{value:r,getSnapshot:e}}),s=n[0].inst,o=n[1];return FX(function(){s.value=r,s.getSnapshot=e,gb(s)&&o({inst:s})},[t,r,e]),$X(function(){return gb(s)&&o({inst:s}),t(function(){gb(s)&&o({inst:s})})},[t]),zX(r),r}function gb(t){var e=t.getSnapshot;t=t.value;try{var r=e();return!DX(t,r)}catch{return!0}}function UX(t,e){return e()}var VX=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?UX:BX;XO.useSyncExternalStore=Rc.useSyncExternalStore!==void 0?Rc.useSyncExternalStore:VX,QO.exports=XO;var WX=QO.exports;function HX(){return WX.useSyncExternalStore(qX,()=>!0,()=>!1)}function qX(){return()=>{}}var vb="Avatar",[KX,Vre]=Ft(vb),[GX,ZO]=KX(vb),eP=m.forwardRef((t,e)=>{const{__scopeAvatar:r,...n}=t,[s,o]=m.useState("idle");return l.jsx(GX,{scope:r,imageLoadingStatus:s,onImageLoadingStatusChange:o,children:l.jsx(se.span,{...n,ref:e})})});eP.displayName=vb;var tP="AvatarImage",rP=m.forwardRef((t,e)=>{const{__scopeAvatar:r,src:n,onLoadingStatusChange:s=()=>{},...o}=t,i=ZO(tP,r),a=YX(n,o),c=at(d=>{s(d),i.onImageLoadingStatusChange(d)});return gt(()=>{a!=="idle"&&c(a)},[a,c]),a==="loaded"?l.jsx(se.img,{...o,ref:e,src:n}):null});rP.displayName=tP;var nP="AvatarFallback",sP=m.forwardRef((t,e)=>{const{__scopeAvatar:r,delayMs:n,...s}=t,o=ZO(nP,r),[i,a]=m.useState(n===void 0);return m.useEffect(()=>{if(n!==void 0){const c=window.setTimeout(()=>a(!0),n);return()=>window.clearTimeout(c)}},[n]),i&&o.imageLoadingStatus!=="loaded"?l.jsx(se.span,{...s,ref:e}):null});sP.displayName=nP;function oP(t,e){return t?e?(t.src!==e&&(t.src=e),t.complete&&t.naturalWidth>0?"loaded":"loading"):"error":"idle"}function YX(t,{referrerPolicy:e,crossOrigin:r}){const n=HX(),s=m.useRef(null),o=n?(s.current||(s.current=new window.Image),s.current):null,[i,a]=m.useState(()=>oP(o,t));return gt(()=>{a(oP(o,t))},[o,t]),gt(()=>{const c=h=>()=>{a(h)};if(!o)return;const d=c("loaded"),u=c("error");return o.addEventListener("load",d),o.addEventListener("error",u),e&&(o.referrerPolicy=e),typeof r=="string"&&(o.crossOrigin=r),()=>{o.removeEventListener("load",d),o.removeEventListener("error",u)}},[o,r,e]),i}var iP=eP,aP=rP,lP=sP;const ah=m.forwardRef(({className:t,...e},r)=>l.jsx(iP,{ref:r,className:B("relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full",t),...e}));ah.displayName=iP.displayName;const yb=m.forwardRef(({className:t,...e},r)=>l.jsx(aP,{ref:r,className:B("aspect-square h-full w-full",t),...e}));yb.displayName=aP.displayName;const lh=m.forwardRef(({className:t,...e},r)=>l.jsx(lP,{ref:r,className:B("flex h-full w-full items-center justify-center rounded-full bg-muted",t),...e}));lh.displayName=lP.displayName;const JX=[{id:"1",name:"You",initials:"ME",attendance:12,rank:1},{id:"2",name:"Alex M.",initials:"AM",attendance:10,rank:2},{id:"3",name:"Jordan K.",initials:"JK",attendance:8,rank:3},{id:"4",name:"Sam R.",initials:"SR",attendance:7,rank:4}],QX=t=>{switch(t){case 1:return l.jsx("span",{className:"text-lg",children:"🥇"});case 2:return l.jsx("span",{className:"text-lg",children:"🥈"});case 3:return l.jsx("span",{className:"text-lg",children:"🥉"});default:return l.jsxs("span",{className:"text-xs text-muted-foreground font-medium",children:["#",t]})}};function XX(){return l.jsxs(fe,{className:"h-full flex flex-col",children:[l.jsx(Nt,{className:"pb-3",children:l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs(Ct,{className:"flex items-center gap-2 text-base",children:[l.jsx("div",{className:"p-1.5 rounded-lg bg-primary/10",children:l.jsx($r,{className:"h-4 w-4 text-primary"})}),"Study Hub"]}),l.jsx(K,{variant:"ghost",size:"sm",asChild:!0,children:l.jsxs(rn,{to:"/study-groups",children:["Open",l.jsx(wt,{className:"h-4 w-4 ml-1"})]})})]})}),l.jsxs(xe,{className:"flex-1 pt-0 space-y-4",children:[l.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[l.jsxs(rn,{to:"/study-groups",className:"flex flex-col items-center gap-1.5 p-3 rounded-lg bg-gradient-to-r from-primary/10 to-accent/10 hover:from-primary/20 hover:to-accent/20 transition-colors",children:[l.jsx($r,{className:"h-5 w-5 text-primary"}),l.jsx("span",{className:"text-xs font-medium text-foreground",children:"Groups"})]}),l.jsxs(rn,{to:"/study",className:"flex flex-col items-center gap-1.5 p-3 rounded-lg bg-secondary/50 hover:bg-secondary transition-colors",children:[l.jsx(Yy,{className:"h-5 w-5 text-primary"}),l.jsx("span",{className:"text-xs font-medium text-foreground",children:"Study Mode"})]})]}),l.jsxs("div",{className:"space-y-2",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx(X3,{className:"h-4 w-4 text-primary"}),l.jsx("h4",{className:"text-sm font-medium text-foreground",children:"Attendance Leaderboard"})]}),l.jsx("div",{className:"space-y-1.5",children:JX.map(t=>l.jsxs("div",{className:`flex items-center gap-2 p-2 rounded-lg transition-colors ${t.name==="You"?"bg-primary/10 border border-primary/20":"bg-secondary/30 hover:bg-secondary/50"}`,children:[l.jsx("div",{className:"w-6 flex justify-center",children:QX(t.rank)}),l.jsx(ah,{className:"h-6 w-6",children:l.jsx(lh,{className:"text-[10px] bg-muted",children:t.initials})}),l.jsx("span",{className:`flex-1 text-xs ${t.name==="You"?"font-semibold text-foreground":"text-muted-foreground"}`,children:t.name}),l.jsxs(ue,{variant:"secondary",className:"text-[10px] px-1.5",children:[t.attendance," classes"]})]},t.id))})]})]})]})}var xb="Progress",wb=100,[ZX,Wre]=Ft(xb),[eZ,tZ]=ZX(xb),cP=m.forwardRef((t,e)=>{const{__scopeProgress:r,value:n=null,max:s,getValueLabel:o=rZ,...i}=t;(s||s===0)&&!fP(s)&&console.error(nZ(`${s}`,"Progress"));const a=fP(s)?s:wb;n!==null&&!pP(n,a)&&console.error(sZ(`${n}`,"Progress"));const c=pP(n,a)?n:null,d=qm(c)?o(c,a):void 0;return l.jsx(eZ,{scope:r,value:c,max:a,children:l.jsx(se.div,{"aria-valuemax":a,"aria-valuemin":0,"aria-valuenow":qm(c)?c:void 0,"aria-valuetext":d,role:"progressbar","data-state":hP(c,a),"data-value":c??void 0,"data-max":a,...i,ref:e})})});cP.displayName=xb;var dP="ProgressIndicator",uP=m.forwardRef((t,e)=>{const{__scopeProgress:r,...n}=t,s=tZ(dP,r);return l.jsx(se.div,{"data-state":hP(s.value,s.max),"data-value":s.value??void 0,"data-max":s.max,...n,ref:e})});uP.displayName=dP;function rZ(t,e){return`${Math.round(t/e*100)}%`}function hP(t,e){return t==null?"indeterminate":t===e?"complete":"loading"}function qm(t){return typeof t=="number"}function fP(t){return qm(t)&&!isNaN(t)&&t>0}function pP(t,e){return qm(t)&&!isNaN(t)&&t<=e&&t>=0}function nZ(t,e){return`Invalid prop \`max\` of value \`${t}\` supplied to \`${e}\`. Only numbers greater than 0 are valid max values. Defaulting to \`${wb}\`.`}function sZ(t,e){return`Invalid prop \`value\` of value \`${t}\` supplied to \`${e}\`. The \`value\` prop must be: - a positive number - less than the value passed to \`max\` (or ${wb} if no \`max\` prop is set) - \`null\` or \`undefined\` if the progress is indeterminate. Defaulting to \`null\`.`}var mP=cP,oZ=uP;const ch=m.forwardRef(({className:t,value:e,...r},n)=>l.jsx(mP,{ref:n,className:B("relative h-4 w-full overflow-hidden rounded-full bg-secondary",t),...r,children:l.jsx(oZ,{className:"h-full w-full flex-1 bg-primary transition-all",style:{transform:`translateX(-${100-(e||0)}%)`}})}));ch.displayName=mP.displayName;function iZ(){const{classes:t}=Ot(),r=N_[0],n=r?t.find(a=>a.id===r.classId):null,s=Sn(new Date,{weekStartsOn:1}),o=Pe(s,7),i={notes:12,lectures:8,topics:24,completionRate:75};return l.jsxs(fe,{className:"h-full flex flex-col",children:[l.jsxs(Nt,{className:"pb-3",children:[l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs(Ct,{className:"flex items-center gap-2 text-base",children:[l.jsx("div",{className:"p-1.5 rounded-lg gradient-primary",children:l.jsx(Nr,{className:"h-4 w-4 text-primary-foreground"})}),"Weekly Recap"]}),l.jsx(K,{variant:"ghost",size:"sm",asChild:!0,children:l.jsxs(rn,{to:"/recap",children:["View All",l.jsx(wt,{className:"h-4 w-4 ml-1"})]})})]}),l.jsxs(ue,{variant:"secondary",className:"w-fit text-xs",children:[pe(o,"MMM d")," - ",pe(Pe(s,1),"MMM d")]})]}),l.jsxs(xe,{className:"flex-1 pt-0 space-y-4",children:[l.jsxs("div",{className:"space-y-2",children:[l.jsxs("div",{className:"flex items-center justify-between text-xs",children:[l.jsx("span",{className:"text-muted-foreground",children:"Weekly Progress"}),l.jsxs("span",{className:"font-medium text-foreground",children:[i.completionRate,"%"]})]}),l.jsx(ch,{value:i.completionRate,className:"h-2"})]}),l.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[l.jsxs("div",{className:"p-2 rounded-lg bg-secondary/50 text-center",children:[l.jsx(zt,{className:"h-4 w-4 mx-auto text-primary mb-1"}),l.jsx("p",{className:"text-base font-bold text-foreground",children:i.notes}),l.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Notes"})]}),l.jsxs("div",{className:"p-2 rounded-lg bg-secondary/50 text-center",children:[l.jsx(Gy,{className:"h-4 w-4 mx-auto text-primary mb-1"}),l.jsx("p",{className:"text-base font-bold text-foreground",children:i.lectures}),l.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Lectures"})]}),l.jsxs("div",{className:"p-2 rounded-lg bg-secondary/50 text-center",children:[l.jsx(vt,{className:"h-4 w-4 mx-auto text-primary mb-1"}),l.jsx("p",{className:"text-base font-bold text-foreground",children:i.topics}),l.jsx("p",{className:"text-[10px] text-muted-foreground",children:"Topics"})]})]}),r&&n&&l.jsxs("div",{className:"p-3 rounded-lg bg-secondary/50",children:[l.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[l.jsx("div",{className:"h-2 w-2 rounded-full shrink-0",style:{backgroundColor:n==null?void 0:n.color}}),l.jsx("span",{className:"text-xs font-medium text-foreground truncate",children:(n==null?void 0:n.code)||(n==null?void 0:n.name)})]}),l.jsx("p",{className:"text-xs text-muted-foreground line-clamp-2",children:r.summary}),l.jsxs("div",{className:"flex flex-wrap gap-1 mt-2",children:[r.keyTopics.slice(0,2).map(a=>l.jsx(ue,{variant:"secondary",className:"text-[10px]",children:a},a)),r.keyTopics.length>2&&l.jsxs(ue,{variant:"secondary",className:"text-[10px]",children:["+",r.keyTopics.length-2]})]})]})]})]})}const aZ={"upcoming-events":OX,todo:PX,classes:AX,"study-hub":XX,"weekly-recap":iZ};function lZ(){const{widgets:t,enabledWidgets:e,toggleWidget:r,reorderWidgets:n,resetToDefaults:s}=jX(),o=fO(sb($m,{activationConstraint:{distance:8}}),sb(cb,{coordinateGetter:NX})),i=h=>{const{active:f,over:p}=h;p&&f.id!==p.id&&n(f.id,p.id)},a=h=>{const f=aZ[h];return f?l.jsx(f,{}):null},c=e.filter(h=>h.size==="large"),d=e.filter(h=>h.size==="medium"),u=e.filter(h=>h.size==="small");return l.jsxs("div",{className:"min-h-screen p-4 sm:p-6 max-w-7xl mx-auto",children:[l.jsxs("div",{className:"flex flex-col sm:flex-row items-start sm:items-center justify-between gap-3 mb-8 sm:mb-10",children:[l.jsxs("div",{children:[l.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[l.jsx(co,{}),l.jsx("div",{className:"p-2.5 rounded-xl gradient-primary shadow-md",children:l.jsx(Hy,{className:"h-6 w-6 text-primary-foreground"})}),l.jsx("h1",{className:"text-2xl sm:text-3xl font-bold text-foreground tracking-tight",children:"Dashboard"})]}),l.jsx("p",{className:"text-muted-foreground mt-0.5",children:"Your personalized overview of everything that matters"})]}),l.jsx(TX,{widgets:t,onToggle:r,onReset:s})]}),e.length===0?l.jsxs("div",{className:"flex flex-col items-center justify-center py-20 text-center",children:[l.jsx(Hy,{className:"h-16 w-16 text-muted-foreground mb-4"}),l.jsx("h2",{className:"text-lg font-semibold text-foreground mb-2",children:"No widgets enabled"}),l.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:'Click "Customize" to add widgets to your dashboard'})]}):l.jsx(zO,{sensors:o,collisionDetection:aQ,onDragEnd:i,children:l.jsxs("div",{className:"space-y-6",children:[c.length>0&&l.jsx(pb,{items:c.map(h=>h.id),strategy:oh,children:l.jsx("div",{className:"grid grid-cols-1 gap-6",children:c.map(h=>l.jsx(mb,{id:h.id,className:"min-h-[320px]",children:a(h.id)},h.id))})}),d.length>0&&l.jsx(pb,{items:d.map(h=>h.id),strategy:oh,children:l.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:d.map(h=>l.jsx(mb,{id:h.id,className:"min-h-[360px]",children:a(h.id)},h.id))})}),u.length>0&&l.jsx(pb,{items:u.map(h=>h.id),strategy:oh,children:l.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6",children:u.map(h=>l.jsx(mb,{id:h.id,className:"min-h-[280px]",children:a(h.id)},h.id))})})]})})]})}function Km(){const[t,e]=m.useState([]),[r,n]=m.useState([]),[s,o]=m.useState(!1),[i,a]=m.useState(!1),c=m.useCallback(async()=>{const{data:g,error:v}=await q.from("external_calendars").select("*").order("created_at",{ascending:!0});if(v){console.error("Error fetching calendars:",v);return}e(g||[])},[]),d=m.useCallback(async()=>{const{data:g,error:v}=await q.from("external_calendar_events").select("*, external_calendars(name, color, enabled)").order("start_time",{ascending:!0});if(v){console.error("Error fetching external events:",v);return}const y=(g||[]).filter(x=>{var w;return((w=x.external_calendars)==null?void 0:w.enabled)!==!1}).map(x=>{var w,b;return{...x,calendarName:(w=x.external_calendars)==null?void 0:w.name,calendarColor:(b=x.external_calendars)==null?void 0:b.color}});n(y)},[]),u=async(g,v,y,x)=>{const{data:{user:w}}=await q.auth.getUser();if(!w)return Se.error("Please sign in first"),null;const{data:b,error:k}=await q.from("external_calendars").insert({user_id:w.id,name:g,ics_url:v,provider:y,color:x}).select().single();return k?(console.error("Error adding calendar:",k),Se.error("Failed to add calendar"),null):(await c(),await p(b.id),b)},h=async g=>{const{error:v}=await q.from("external_calendars").delete().eq("id",g);if(v){Se.error("Failed to remove calendar");return}Se.success("Calendar removed"),await c(),await d()},f=async(g,v)=>{const{error:y}=await q.from("external_calendars").update({enabled:v}).eq("id",g);if(y){Se.error("Failed to update calendar");return}await c(),await d()},p=async g=>{var v,y;a(!0);try{const{data:{session:x}}=await q.auth.getSession();if(!x){Se.error("Please sign in first");return}const b=await fetch("https://jqoaxvwjqgjxmenvuwql.supabase.co/functions/v1/sync-external-calendar",{method:"POST",headers:{Authorization:`Bearer ${x.access_token}`,"Content-Type":"application/json",apikey:"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6Impxb2F4dndqcWdqeG1lbnZ1d3FsIiwicm9sZSI6ImFub24iLCJpYXQiOjE3NzEwOTUxMTYsImV4cCI6MjA4NjY3MTExNn0.0em4louFIEQkjQwCvudwxWQILppMpGcPtWTIwd1yvQw"},body:JSON.stringify({action:"sync",calendarId:g})});if(!b.ok)throw new Error("Sync failed");const k=await b.json(),S=((v=k.results)==null?void 0:v.reduce((N,E)=>N+(E.eventsCount||0),0))||0,C=((y=k.results)==null?void 0:y.filter(N=>N.error))||[];C.length>0?Se.error(`Some calendars failed to sync: ${C.map(N=>N.name).join(", ")}`):Se.success(`Synced ${S} events from your calendars`),await c(),await d()}catch(x){console.error("Sync error:",x),Se.error("Failed to sync calendars")}finally{a(!1)}};return m.useEffect(()=>{o(!0),Promise.all([c(),d()]).finally(()=>o(!1))},[c,d]),{calendars:t,events:r,loading:s,syncing:i,addCalendar:u,removeCalendar:h,toggleCalendar:f,syncCalendar:p,refetch:()=>Promise.all([c(),d()])}}const cZ=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"];function dZ({onEventClick:t,onDateClick:e}){const{currentDate:r,setCurrentDate:n,events:s,classes:o}=Ot(),{events:i}=Km(),a=m.useMemo(()=>{const g=p_(r),v=f_(r),y=Sn(g,{weekStartsOn:0}),x=Op(v,{weekStartsOn:0});return Jx({start:y,end:x})},[r]),c=g=>s.filter(v=>eo(new Date(v.date),g)),d=g=>i.filter(v=>eo(new Date(v.start_time),g)),u=g=>o.find(v=>v.id===g),h=()=>n(S_(r,1)),f=()=>n(Yx(r,1)),p=()=>n(new Date);return l.jsxs("div",{className:"flex flex-col h-full",children:[l.jsxs("div",{className:"flex items-center justify-between px-6 py-5 border-b border-border",children:[l.jsxs("div",{className:"flex items-center gap-4",children:[l.jsx("h2",{className:"text-2xl font-semibold text-foreground tracking-tight",children:pe(r,"MMMM yyyy")}),l.jsx(K,{variant:"outline",size:"sm",onClick:p,children:"Today"})]}),l.jsxs("div",{className:"flex items-center gap-1",children:[l.jsx(K,{variant:"ghost",size:"icon",onClick:h,children:l.jsx(Nl,{className:"h-5 w-5"})}),l.jsx(K,{variant:"ghost",size:"icon",onClick:f,children:l.jsx(wt,{className:"h-5 w-5"})})]})]}),l.jsxs("div",{className:"flex-1 p-4",children:[l.jsx("div",{className:"grid grid-cols-7 mb-2",children:cZ.map(g=>l.jsx("div",{className:"py-2 text-center text-xs font-medium uppercase tracking-wider text-muted-foreground",children:g},g))}),l.jsx("div",{className:"grid grid-cols-7 flex-1 border border-border rounded-xl overflow-hidden",children:a.map((g,v)=>{const y=c(g),x=d(g),w=y.length+x.length,b=b_(g,r),k=Nn(g);return l.jsxs("div",{onClick:()=>e(g),className:B("min-h-[100px] p-2 border-r border-b border-border cursor-pointer transition-colors","hover:bg-secondary/30",!b&&"bg-muted/30",k&&"bg-primary/5 border-l-2 border-l-primary",v%7===6&&"border-r-0",v>=a.length-7&&"border-b-0"),children:[l.jsx("div",{className:B("flex h-7 w-7 items-center justify-center rounded-full text-sm mb-1",k?"bg-primary text-primary-foreground font-semibold":b?"text-foreground":"text-muted-foreground"),children:pe(g,"d")}),l.jsxs("div",{className:"space-y-1",children:[y.slice(0,2).map(S=>{const C=u(S.classId);return l.jsx("div",{onClick:N=>{N.stopPropagation(),t(S)},className:"px-2 py-0.5 text-xs rounded truncate cursor-pointer transition-colors",style:{backgroundColor:`${C==null?void 0:C.color}30`,color:C==null?void 0:C.color},children:S.title},S.id)}),x.slice(0,Math.max(0,3-y.length)).map(S=>l.jsx("div",{className:"px-2 py-0.5 text-xs rounded truncate",style:{backgroundColor:`${S.calendarColor||"#6366f1"}25`,color:S.calendarColor||"#6366f1"},children:S.title},S.id)),w>3&&l.jsxs("div",{className:"px-2 text-xs text-muted-foreground",children:["+",w-3," more"]})]})]},g.toISOString())})})]})]})}const gP=Array.from({length:13},(t,e)=>e+7),Gm=60,vP=15;function uZ({onEventClick:t,onDateClick:e}){const{currentDate:r,setCurrentDate:n,events:s,classes:o,notes:i,updateEvent:a}=Ot(),{events:c}=Km(),d=m.useMemo(()=>{const j=Sn(r,{weekStartsOn:1}),_=Op(r,{weekStartsOn:1});return Jx({start:j,end:_})},[r]),u=j=>s.filter(_=>eo(new Date(_.date),j)),h=j=>c.filter(_=>eo(new Date(_.start_time),j)),f=j=>o.find(_=>_.id===j),p=j=>i.some(_=>_.eventId===j),g=j=>{const[_,P]=j.startTime.split(":").map(Number),[T,A]=j.endTime.split(":").map(Number),I=((_-7)*60+P)*(Gm/60),V=((T-_)*60+(A-P))*(Gm/60);return{top:I,height:Math.max(V,30)}},[v,y]=m.useState(null),x=m.useRef(null),w=j=>{const _=j/Gm*60+420,P=Math.round(_/vP)*vP;return{hours:Math.floor(P/60),minutes:P%60}},b=m.useCallback((j,_)=>{j.preventDefault(),j.stopPropagation();const{top:P,height:T}=g(_),A={eventId:_.id,initialY:j.clientY,initialTop:P,currentTop:P,eventHeight:T};x.current=A,y(A);const I=L=>{if(!x.current)return;const U=L.clientY-x.current.initialY,M=Math.max(0,x.current.initialTop+U);x.current={...x.current,currentTop:M},y({...x.current})},V=()=>{if(document.removeEventListener("mousemove",I),document.removeEventListener("mouseup",V),!x.current)return;const{eventId:L,currentTop:U,eventHeight:M}=x.current,D=w(U),H=M/Gm*60,ne=D.hours*60+D.minutes+H,$=Math.floor(ne/60),G=Math.round(ne%60),J=`${String(D.hours).padStart(2,"0")}:${String(D.minutes).padStart(2,"0")}`,O=`${String($).padStart(2,"0")}:${String(G).padStart(2,"0")}`;a(L,{startTime:J,endTime:O}),x.current=null,y(null)};document.addEventListener("mousemove",I),document.addEventListener("mouseup",V)},[a]),k=()=>n(O8(r,1)),S=()=>n(u_(r,1)),C=()=>n(new Date),N=Sn(r,{weekStartsOn:0}),E=Op(r,{weekStartsOn:0});return l.jsxs("div",{className:"flex flex-col h-full",children:[l.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-border",children:[l.jsxs("div",{className:"flex items-center gap-4",children:[l.jsxs("h2",{className:"text-2xl font-semibold text-foreground",children:[pe(N,"MMM d")," - ",pe(E,"MMM d, yyyy")]}),l.jsx(K,{variant:"outline",size:"sm",onClick:C,children:"Today"})]}),l.jsxs("div",{className:"flex items-center gap-1",children:[l.jsx(K,{variant:"ghost",size:"icon",onClick:k,children:l.jsx(Nl,{className:"h-5 w-5"})}),l.jsx(K,{variant:"ghost",size:"icon",onClick:S,children:l.jsx(wt,{className:"h-5 w-5"})})]})]}),l.jsx("div",{className:"flex-1 overflow-auto",children:l.jsxs("div",{className:"min-w-[800px]",children:[l.jsxs("div",{className:"grid grid-cols-8 border-b border-border sticky top-0 bg-background z-10",children:[l.jsx("div",{className:"w-16"})," ",d.map(j=>{const _=Nn(j);return l.jsxs("div",{onClick:()=>e(j),className:B("py-3 text-center cursor-pointer hover:bg-secondary/30 transition-colors border-l border-border",_&&"bg-primary/5"),children:[l.jsx("div",{className:"text-xs font-medium uppercase tracking-wider text-muted-foreground",children:pe(j,"EEE")}),l.jsx("div",{className:B("mt-1 mx-auto flex h-10 w-10 items-center justify-center rounded-full text-lg font-semibold",_?"bg-primary text-primary-foreground":"text-foreground"),children:pe(j,"d")})]},j.toISOString())})]}),l.jsxs("div",{className:"relative",children:[l.jsxs("div",{className:"grid grid-cols-8",children:[l.jsx("div",{className:"w-16",children:gP.map(j=>l.jsx("div",{className:"h-[60px] border-b border-border pr-2 text-right",children:l.jsx("span",{className:"text-xs text-muted-foreground relative -top-2",children:j===12?"12 PM":j>12?`${j-12} PM`:`${j} AM`})},j))}),d.map(j=>{const _=u(j),P=h(j),T=Nn(j);return l.jsxs("div",{className:B("relative border-l border-border",T&&"bg-primary/5"),children:[gP.map(A=>l.jsx("div",{className:"h-[60px] border-b border-border/50"},A)),_.map(A=>{const I=f(A.classId),{top:V,height:L}=g(A),U=p(A.id),M=(v==null?void 0:v.eventId)===A.id,D=M?v.currentTop:V;return l.jsx("div",{onMouseDown:H=>b(H,A),onClick:H=>{v||t(A)},className:B("absolute left-1 right-1 rounded-lg p-2 cursor-grab active:cursor-grabbing transition-shadow","hover:shadow-lg hover:z-10","border border-transparent hover:border-primary/30",M&&"shadow-xl z-50 opacity-80"),style:{top:`${D}px`,height:`${L}px`,backgroundColor:`${I==null?void 0:I.color}25`,borderLeftWidth:"3px",borderLeftColor:I==null?void 0:I.color},children:l.jsxs("div",{className:"flex flex-col h-full overflow-hidden",children:[l.jsxs("div",{className:"flex items-start justify-between gap-1",children:[l.jsx("span",{className:"text-xs font-medium truncate",style:{color:I==null?void 0:I.color},children:A.title}),U&&l.jsx(Gf,{className:"h-3 w-3 shrink-0 text-muted-foreground"})]}),l.jsxs("span",{className:"text-xs text-muted-foreground mt-0.5",children:[A.startTime," - ",A.endTime]}),A.location&&L>50&&l.jsxs("div",{className:"flex items-center gap-1 mt-1 text-xs text-muted-foreground",children:[l.jsx($o,{className:"h-3 w-3"}),l.jsx("span",{className:"truncate",children:A.location})]}),A.type==="exam"&&l.jsx(ue,{variant:"destructive",className:"mt-1 w-fit text-[10px] px-1.5 py-0",children:"Exam"})]})},A.id)}),P.filter(A=>!A.all_day).map(A=>{const I=new Date(A.start_time),V=A.end_time?new Date(A.end_time):new Date(I.getTime()+60*60*1e3),L=I.getHours(),U=I.getMinutes(),M=V.getHours(),D=V.getMinutes(),H=((L-7)*60+U)*(60/60),ne=Math.max(((M-L)*60+(D-U))*(60/60),30),$=A.calendarColor||"#6366f1";return H<0?null:l.jsx("div",{className:B("absolute left-1 right-1 rounded-lg p-2 cursor-default transition-all","hover:shadow-lg hover:z-10","border border-transparent"),style:{top:`${H}px`,height:`${ne}px`,backgroundColor:`${$}20`,borderLeftWidth:"3px",borderLeftColor:$},children:l.jsxs("div",{className:"flex flex-col h-full overflow-hidden",children:[l.jsx("span",{className:"text-xs font-medium truncate",style:{color:$},children:A.title}),l.jsxs("span",{className:"text-xs text-muted-foreground mt-0.5",children:[pe(I,"h:mm a")," - ",pe(V,"h:mm a")]}),A.location&&ne>50&&l.jsxs("div",{className:"flex items-center gap-1 mt-1 text-xs text-muted-foreground",children:[l.jsx($o,{className:"h-3 w-3"}),l.jsx("span",{className:"truncate",children:A.location})]}),A.calendarName&&l.jsx("span",{className:"text-[10px] text-muted-foreground mt-auto truncate",children:A.calendarName})]})},`ext-${A.id}`)})]},j.toISOString())})]}),d.some(j=>Nn(j))&&l.jsx(hZ,{days:d})]})]})})]})}function hZ({days:t}){const e=new Date;if(t.findIndex(i=>Nn(i))===-1)return null;const n=e.getHours(),s=e.getMinutes();if(n<7||n>=20)return null;const o=((n-7)*60+s)*(60/60);return l.jsx("div",{className:"absolute h-0.5 bg-destructive z-20 pointer-events-none",style:{top:`${o}px`,left:"64px",right:0},children:l.jsx("div",{className:"absolute -left-1 -top-1.5 h-3 w-3 rounded-full bg-destructive"})})}const fZ=["S","M","T","W","T","F","S"];function pZ({onEventClick:t,onDateClick:e}){const{currentDate:r,setCurrentDate:n,events:s,classes:o}=Ot(),{events:i}=Km(),[a,c]=m.useState(new Date),d=m.useMemo(()=>{const w=p_(r),b=f_(r),k=Sn(w,{weekStartsOn:0}),S=Op(b,{weekStartsOn:0});return Jx({start:k,end:S})},[r]),u=w=>s.filter(b=>eo(new Date(b.date),w)),h=w=>i.filter(b=>eo(new Date(b.start_time),w)),f=w=>o.find(b=>b.id===w),p=()=>n(S_(r,1)),g=()=>n(Yx(r,1)),v=w=>{c(w),e(w)},y=u(a),x=h(a);return l.jsxs("div",{className:"flex flex-col h-full",children:[l.jsxs("div",{className:"flex items-center justify-between px-4 py-3",children:[l.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:p,children:l.jsx(Nl,{className:"h-5 w-5"})}),l.jsx("h2",{className:"text-base font-semibold text-foreground",children:pe(r,"MMMM yyyy")}),l.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:g,children:l.jsx(wt,{className:"h-5 w-5"})})]}),l.jsxs("div",{className:"px-2",children:[l.jsx("div",{className:"grid grid-cols-7 mb-1",children:fZ.map((w,b)=>l.jsx("div",{className:"py-1 text-center text-[11px] font-medium text-muted-foreground",children:w},b))}),l.jsx("div",{className:"grid grid-cols-7",children:d.map(w=>{const b=u(w),k=h(w);b.length+k.length>0;const S=b_(w,r),C=Nn(w),N=eo(w,a),E=[];return b.forEach(j=>{const _=f(j.classId);_!=null&&_.color&&E.length<3&&!E.includes(_.color)&&E.push(_.color)}),k.forEach(j=>{const _=j.calendarColor||"#6366f1";E.length<3&&!E.includes(_)&&E.push(_)}),l.jsxs("div",{onClick:()=>v(w),className:"flex flex-col items-center py-1 cursor-pointer",children:[l.jsx("div",{className:B("flex h-9 w-9 items-center justify-center rounded-full text-sm transition-colors",N&&C&&"bg-primary text-primary-foreground font-semibold",N&&!C&&"bg-primary/15 text-primary font-semibold",!N&&C&&"text-primary font-semibold",!N&&!C&&S&&"text-foreground",!S&&"text-muted-foreground/40"),children:pe(w,"d")}),l.jsx("div",{className:"flex gap-0.5 h-2 items-center mt-0.5",children:E.map((j,_)=>l.jsx("div",{className:"h-1 w-1 rounded-full",style:{backgroundColor:j}},_))})]},w.toISOString())})})]}),l.jsx("div",{className:"flex-1 overflow-auto border-t border-border mt-2",children:l.jsxs("div",{className:"px-4 py-3",children:[l.jsx("h3",{className:"text-sm font-medium text-muted-foreground mb-3",children:Nn(a)?"Today":pe(a,"EEEE, MMM d")}),y.length===0&&x.length===0?l.jsx("p",{className:"text-sm text-muted-foreground/60 py-8 text-center",children:"No events"}):l.jsxs("div",{className:"space-y-2",children:[y.map(w=>{const b=f(w.classId);return l.jsxs("div",{onClick:()=>t(w),className:"flex items-start gap-3 p-3 rounded-xl bg-card border border-border active:scale-[0.98] transition-transform cursor-pointer",children:[l.jsx("div",{className:"w-1 self-stretch rounded-full shrink-0 mt-0.5",style:{backgroundColor:b==null?void 0:b.color}}),l.jsxs("div",{className:"flex-1 min-w-0",children:[l.jsx("p",{className:"text-sm font-medium text-foreground truncate",children:w.title}),l.jsxs("div",{className:"flex items-center gap-1.5 mt-1",children:[l.jsx(tr,{className:"h-3 w-3 text-muted-foreground"}),l.jsxs("span",{className:"text-xs text-muted-foreground",children:[w.startTime," – ",w.endTime]})]}),w.location&&l.jsxs("div",{className:"flex items-center gap-1.5 mt-0.5",children:[l.jsx($o,{className:"h-3 w-3 text-muted-foreground"}),l.jsx("span",{className:"text-xs text-muted-foreground truncate",children:w.location})]})]}),w.type==="exam"&&l.jsx("span",{className:"text-[10px] font-medium px-1.5 py-0.5 rounded bg-destructive/10 text-destructive shrink-0",children:"Exam"})]},w.id)}),x.map(w=>{const b=w.calendarColor||"#6366f1",k=new Date(w.start_time),S=w.end_time?new Date(w.end_time):null;return l.jsxs("div",{className:"flex items-start gap-3 p-3 rounded-xl bg-card border border-border",children:[l.jsx("div",{className:"w-1 self-stretch rounded-full shrink-0 mt-0.5",style:{backgroundColor:b}}),l.jsxs("div",{className:"flex-1 min-w-0",children:[l.jsx("p",{className:"text-sm font-medium text-foreground truncate",children:w.title}),!w.all_day&&l.jsxs("div",{className:"flex items-center gap-1.5 mt-1",children:[l.jsx(tr,{className:"h-3 w-3 text-muted-foreground"}),l.jsxs("span",{className:"text-xs text-muted-foreground",children:[pe(k,"h:mm a"),S&&` – ${pe(S,"h:mm a")}`]})]}),w.all_day&&l.jsx("span",{className:"text-xs text-muted-foreground",children:"All day"}),w.location&&l.jsxs("div",{className:"flex items-center gap-1.5 mt-0.5",children:[l.jsx($o,{className:"h-3 w-3 text-muted-foreground"}),l.jsx("span",{className:"text-xs text-muted-foreground truncate",children:w.location})]}),w.calendarName&&l.jsx("span",{className:"text-[10px] text-muted-foreground mt-1 block",children:w.calendarName})]})]},`ext-${w.id}`)})]})]})})]})}function mZ(t,e){return m.useReducer((r,n)=>e[r][n]??r,t)}var bb="ScrollArea",[yP,Hre]=Ft(bb),[gZ,On]=yP(bb),xP=m.forwardRef((t,e)=>{const{__scopeScrollArea:r,type:n="hover",dir:s,scrollHideDelay:o=600,...i}=t,[a,c]=m.useState(null),[d,u]=m.useState(null),[h,f]=m.useState(null),[p,g]=m.useState(null),[v,y]=m.useState(null),[x,w]=m.useState(0),[b,k]=m.useState(0),[S,C]=m.useState(!1),[N,E]=m.useState(!1),j=we(e,P=>c(P)),_=ha(s);return l.jsx(gZ,{scope:r,type:n,dir:_,scrollHideDelay:o,scrollArea:a,viewport:d,onViewportChange:u,content:h,onContentChange:f,scrollbarX:p,onScrollbarXChange:g,scrollbarXEnabled:S,onScrollbarXEnabledChange:C,scrollbarY:v,onScrollbarYChange:y,scrollbarYEnabled:N,onScrollbarYEnabledChange:E,onCornerWidthChange:w,onCornerHeightChange:k,children:l.jsx(se.div,{dir:_,...i,ref:j,style:{position:"relative","--radix-scroll-area-corner-width":x+"px","--radix-scroll-area-corner-height":b+"px",...t.style}})})});xP.displayName=bb;var wP="ScrollAreaViewport",bP=m.forwardRef((t,e)=>{const{__scopeScrollArea:r,children:n,nonce:s,...o}=t,i=On(wP,r),a=m.useRef(null),c=we(e,a,i.onViewportChange);return l.jsxs(l.Fragment,{children:[l.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-scroll-area-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-scroll-area-viewport]::-webkit-scrollbar{display:none}"},nonce:s}),l.jsx(se.div,{"data-radix-scroll-area-viewport":"",...o,ref:c,style:{overflowX:i.scrollbarXEnabled?"scroll":"hidden",overflowY:i.scrollbarYEnabled?"scroll":"hidden",...t.style},children:l.jsx("div",{ref:i.onContentChange,style:{minWidth:"100%",display:"table"},children:n})})]})});bP.displayName=wP;var Es="ScrollAreaScrollbar",kb=m.forwardRef((t,e)=>{const{forceMount:r,...n}=t,s=On(Es,t.__scopeScrollArea),{onScrollbarXEnabledChange:o,onScrollbarYEnabledChange:i}=s,a=t.orientation==="horizontal";return m.useEffect(()=>(a?o(!0):i(!0),()=>{a?o(!1):i(!1)}),[a,o,i]),s.type==="hover"?l.jsx(vZ,{...n,ref:e,forceMount:r}):s.type==="scroll"?l.jsx(yZ,{...n,ref:e,forceMount:r}):s.type==="auto"?l.jsx(kP,{...n,ref:e,forceMount:r}):s.type==="always"?l.jsx(Sb,{...n,ref:e}):null});kb.displayName=Es;var vZ=m.forwardRef((t,e)=>{const{forceMount:r,...n}=t,s=On(Es,t.__scopeScrollArea),[o,i]=m.useState(!1);return m.useEffect(()=>{const a=s.scrollArea;let c=0;if(a){const d=()=>{window.clearTimeout(c),i(!0)},u=()=>{c=window.setTimeout(()=>i(!1),s.scrollHideDelay)};return a.addEventListener("pointerenter",d),a.addEventListener("pointerleave",u),()=>{window.clearTimeout(c),a.removeEventListener("pointerenter",d),a.removeEventListener("pointerleave",u)}}},[s.scrollArea,s.scrollHideDelay]),l.jsx(er,{present:r||o,children:l.jsx(kP,{"data-state":o?"visible":"hidden",...n,ref:e})})}),yZ=m.forwardRef((t,e)=>{const{forceMount:r,...n}=t,s=On(Es,t.__scopeScrollArea),o=t.orientation==="horizontal",i=Xm(()=>c("SCROLL_END"),100),[a,c]=mZ("hidden",{hidden:{SCROLL:"scrolling"},scrolling:{SCROLL_END:"idle",POINTER_ENTER:"interacting"},interacting:{SCROLL:"interacting",POINTER_LEAVE:"idle"},idle:{HIDE:"hidden",SCROLL:"scrolling",POINTER_ENTER:"interacting"}});return m.useEffect(()=>{if(a==="idle"){const d=window.setTimeout(()=>c("HIDE"),s.scrollHideDelay);return()=>window.clearTimeout(d)}},[a,s.scrollHideDelay,c]),m.useEffect(()=>{const d=s.viewport,u=o?"scrollLeft":"scrollTop";if(d){let h=d[u];const f=()=>{const p=d[u];h!==p&&(c("SCROLL"),i()),h=p};return d.addEventListener("scroll",f),()=>d.removeEventListener("scroll",f)}},[s.viewport,o,c,i]),l.jsx(er,{present:r||a!=="hidden",children:l.jsx(Sb,{"data-state":a==="hidden"?"hidden":"visible",...n,ref:e,onPointerEnter:Q(t.onPointerEnter,()=>c("POINTER_ENTER")),onPointerLeave:Q(t.onPointerLeave,()=>c("POINTER_LEAVE"))})})}),kP=m.forwardRef((t,e)=>{const r=On(Es,t.__scopeScrollArea),{forceMount:n,...s}=t,[o,i]=m.useState(!1),a=t.orientation==="horizontal",c=Xm(()=>{if(r.viewport){const d=r.viewport.offsetWidth{const{orientation:r="vertical",...n}=t,s=On(Es,t.__scopeScrollArea),o=m.useRef(null),i=m.useRef(0),[a,c]=m.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),d=EP(a.viewport,a.content),u={...n,sizes:a,onSizesChange:c,hasThumb:d>0&&d<1,onThumbChange:f=>o.current=f,onThumbPointerUp:()=>i.current=0,onThumbPointerDown:f=>i.current=f};function h(f,p){return NZ(f,i.current,a,p)}return r==="horizontal"?l.jsx(xZ,{...u,ref:e,onThumbPositionChange:()=>{if(s.viewport&&o.current){const f=s.viewport.scrollLeft,p=_P(f,a,s.dir);o.current.style.transform=`translate3d(${p}px, 0, 0)`}},onWheelScroll:f=>{s.viewport&&(s.viewport.scrollLeft=f)},onDragScroll:f=>{s.viewport&&(s.viewport.scrollLeft=h(f,s.dir))}}):r==="vertical"?l.jsx(wZ,{...u,ref:e,onThumbPositionChange:()=>{if(s.viewport&&o.current){const f=s.viewport.scrollTop,p=_P(f,a);o.current.style.transform=`translate3d(0, ${p}px, 0)`}},onWheelScroll:f=>{s.viewport&&(s.viewport.scrollTop=f)},onDragScroll:f=>{s.viewport&&(s.viewport.scrollTop=h(f))}}):null}),xZ=m.forwardRef((t,e)=>{const{sizes:r,onSizesChange:n,...s}=t,o=On(Es,t.__scopeScrollArea),[i,a]=m.useState(),c=m.useRef(null),d=we(e,c,o.onScrollbarXChange);return m.useEffect(()=>{c.current&&a(getComputedStyle(c.current))},[c]),l.jsx(NP,{"data-orientation":"horizontal",...s,ref:d,sizes:r,style:{bottom:0,left:o.dir==="rtl"?"var(--radix-scroll-area-corner-width)":0,right:o.dir==="ltr"?"var(--radix-scroll-area-corner-width)":0,"--radix-scroll-area-thumb-width":Qm(r)+"px",...t.style},onThumbPointerDown:u=>t.onThumbPointerDown(u.x),onDragScroll:u=>t.onDragScroll(u.x),onWheelScroll:(u,h)=>{if(o.viewport){const f=o.viewport.scrollLeft+u.deltaX;t.onWheelScroll(f),RP(f,h)&&u.preventDefault()}},onResize:()=>{c.current&&o.viewport&&i&&n({content:o.viewport.scrollWidth,viewport:o.viewport.offsetWidth,scrollbar:{size:c.current.clientWidth,paddingStart:Jm(i.paddingLeft),paddingEnd:Jm(i.paddingRight)}})}})}),wZ=m.forwardRef((t,e)=>{const{sizes:r,onSizesChange:n,...s}=t,o=On(Es,t.__scopeScrollArea),[i,a]=m.useState(),c=m.useRef(null),d=we(e,c,o.onScrollbarYChange);return m.useEffect(()=>{c.current&&a(getComputedStyle(c.current))},[c]),l.jsx(NP,{"data-orientation":"vertical",...s,ref:d,sizes:r,style:{top:0,right:o.dir==="ltr"?0:void 0,left:o.dir==="rtl"?0:void 0,bottom:"var(--radix-scroll-area-corner-height)","--radix-scroll-area-thumb-height":Qm(r)+"px",...t.style},onThumbPointerDown:u=>t.onThumbPointerDown(u.y),onDragScroll:u=>t.onDragScroll(u.y),onWheelScroll:(u,h)=>{if(o.viewport){const f=o.viewport.scrollTop+u.deltaY;t.onWheelScroll(f),RP(f,h)&&u.preventDefault()}},onResize:()=>{c.current&&o.viewport&&i&&n({content:o.viewport.scrollHeight,viewport:o.viewport.offsetHeight,scrollbar:{size:c.current.clientHeight,paddingStart:Jm(i.paddingTop),paddingEnd:Jm(i.paddingBottom)}})}})}),[bZ,SP]=yP(Es),NP=m.forwardRef((t,e)=>{const{__scopeScrollArea:r,sizes:n,hasThumb:s,onThumbChange:o,onThumbPointerUp:i,onThumbPointerDown:a,onThumbPositionChange:c,onDragScroll:d,onWheelScroll:u,onResize:h,...f}=t,p=On(Es,r),[g,v]=m.useState(null),y=we(e,j=>v(j)),x=m.useRef(null),w=m.useRef(""),b=p.viewport,k=n.content-n.viewport,S=at(u),C=at(c),N=Xm(h,10);function E(j){if(x.current){const _=j.clientX-x.current.left,P=j.clientY-x.current.top;d({x:_,y:P})}}return m.useEffect(()=>{const j=_=>{const P=_.target;(g==null?void 0:g.contains(P))&&S(_,k)};return document.addEventListener("wheel",j,{passive:!1}),()=>document.removeEventListener("wheel",j,{passive:!1})},[b,g,k,S]),m.useEffect(C,[n,C]),Mc(g,N),Mc(p.content,N),l.jsx(bZ,{scope:r,scrollbar:g,hasThumb:s,onThumbChange:at(o),onThumbPointerUp:at(i),onThumbPositionChange:C,onThumbPointerDown:at(a),children:l.jsx(se.div,{...f,ref:y,style:{position:"absolute",...f.style},onPointerDown:Q(t.onPointerDown,j=>{j.button===0&&(j.target.setPointerCapture(j.pointerId),x.current=g.getBoundingClientRect(),w.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",p.viewport&&(p.viewport.style.scrollBehavior="auto"),E(j))}),onPointerMove:Q(t.onPointerMove,E),onPointerUp:Q(t.onPointerUp,j=>{const _=j.target;_.hasPointerCapture(j.pointerId)&&_.releasePointerCapture(j.pointerId),document.body.style.webkitUserSelect=w.current,p.viewport&&(p.viewport.style.scrollBehavior=""),x.current=null})})})}),Ym="ScrollAreaThumb",CP=m.forwardRef((t,e)=>{const{forceMount:r,...n}=t,s=SP(Ym,t.__scopeScrollArea);return l.jsx(er,{present:r||s.hasThumb,children:l.jsx(kZ,{ref:e,...n})})}),kZ=m.forwardRef((t,e)=>{const{__scopeScrollArea:r,style:n,...s}=t,o=On(Ym,r),i=SP(Ym,r),{onThumbPositionChange:a}=i,c=we(e,h=>i.onThumbChange(h)),d=m.useRef(void 0),u=Xm(()=>{d.current&&(d.current(),d.current=void 0)},100);return m.useEffect(()=>{const h=o.viewport;if(h){const f=()=>{if(u(),!d.current){const p=CZ(h,a);d.current=p,a()}};return a(),h.addEventListener("scroll",f),()=>h.removeEventListener("scroll",f)}},[o.viewport,u,a]),l.jsx(se.div,{"data-state":i.hasThumb?"visible":"hidden",...s,ref:c,style:{width:"var(--radix-scroll-area-thumb-width)",height:"var(--radix-scroll-area-thumb-height)",...n},onPointerDownCapture:Q(t.onPointerDownCapture,h=>{const p=h.target.getBoundingClientRect(),g=h.clientX-p.left,v=h.clientY-p.top;i.onThumbPointerDown({x:g,y:v})}),onPointerUp:Q(t.onPointerUp,i.onThumbPointerUp)})});CP.displayName=Ym;var Nb="ScrollAreaCorner",jP=m.forwardRef((t,e)=>{const r=On(Nb,t.__scopeScrollArea),n=!!(r.scrollbarX&&r.scrollbarY);return r.type!=="scroll"&&n?l.jsx(SZ,{...t,ref:e}):null});jP.displayName=Nb;var SZ=m.forwardRef((t,e)=>{const{__scopeScrollArea:r,...n}=t,s=On(Nb,r),[o,i]=m.useState(0),[a,c]=m.useState(0),d=!!(o&&a);return Mc(s.scrollbarX,()=>{var h;const u=((h=s.scrollbarX)==null?void 0:h.offsetHeight)||0;s.onCornerHeightChange(u),c(u)}),Mc(s.scrollbarY,()=>{var h;const u=((h=s.scrollbarY)==null?void 0:h.offsetWidth)||0;s.onCornerWidthChange(u),i(u)}),d?l.jsx(se.div,{...n,ref:e,style:{width:o,height:a,position:"absolute",right:s.dir==="ltr"?0:void 0,left:s.dir==="rtl"?0:void 0,bottom:0,...t.style}}):null});function Jm(t){return t?parseInt(t,10):0}function EP(t,e){const r=t/e;return isNaN(r)?0:r}function Qm(t){const e=EP(t.viewport,t.content),r=t.scrollbar.paddingStart+t.scrollbar.paddingEnd,n=(t.scrollbar.size-r)*e;return Math.max(n,18)}function NZ(t,e,r,n="ltr"){const s=Qm(r),o=s/2,i=e||o,a=s-i,c=r.scrollbar.paddingStart+i,d=r.scrollbar.size-r.scrollbar.paddingEnd-a,u=r.content-r.viewport,h=n==="ltr"?[0,u]:[u*-1,0];return TP([c,d],h)(t)}function _P(t,e,r="ltr"){const n=Qm(e),s=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,o=e.scrollbar.size-s,i=e.content-e.viewport,a=o-n,c=r==="ltr"?[0,i]:[i*-1,0],d=Hu(t,c);return TP([0,i],[0,a])(d)}function TP(t,e){return r=>{if(t[0]===t[1]||e[0]===e[1])return e[0];const n=(e[1]-e[0])/(t[1]-t[0]);return e[0]+n*(r-t[0])}}function RP(t,e){return t>0&&t{})=>{let r={left:t.scrollLeft,top:t.scrollTop},n=0;return function s(){const o={left:t.scrollLeft,top:t.scrollTop},i=r.left!==o.left,a=r.top!==o.top;(i||a)&&e(),r=o,n=window.requestAnimationFrame(s)}(),()=>window.cancelAnimationFrame(n)};function Xm(t,e){const r=at(t),n=m.useRef(0);return m.useEffect(()=>()=>window.clearTimeout(n.current),[]),m.useCallback(()=>{window.clearTimeout(n.current),n.current=window.setTimeout(r,e)},[r,e])}function Mc(t,e){const r=at(e);gt(()=>{let n=0;if(t){const s=new ResizeObserver(()=>{cancelAnimationFrame(n),n=window.requestAnimationFrame(r)});return s.observe(t),()=>{window.cancelAnimationFrame(n),s.unobserve(t)}}},[t,r])}var MP=xP,jZ=bP,EZ=jP;const Pn=m.forwardRef(({className:t,children:e,...r},n)=>l.jsxs(MP,{ref:n,className:B("relative overflow-hidden",t),...r,children:[l.jsx(jZ,{className:"h-full w-full rounded-[inherit]",children:e}),l.jsx(OP,{}),l.jsx(EZ,{})]}));Pn.displayName=MP.displayName;const OP=m.forwardRef(({className:t,orientation:e="vertical",...r},n)=>l.jsx(kb,{ref:n,orientation:e,className:B("flex touch-none select-none transition-colors",e==="vertical"&&"h-full w-2.5 border-l border-l-transparent p-[1px]",e==="horizontal"&&"h-2.5 flex-col border-t border-t-transparent p-[1px]",t),...r,children:l.jsx(CP,{className:"relative flex-1 rounded-full bg-border"})}));OP.displayName=kb.displayName;function _Z(t={}){const[e,r]=m.useState(!1),[n,s]=m.useState(!1),[o,i]=m.useState(0),[a,c]=m.useState(null),d=m.useRef(null),u=m.useRef([]),h=m.useRef(null),f=m.useRef(0),{toast:p}=gs(),g=m.useCallback(async()=>{try{const x=await navigator.mediaDevices.getUserMedia({audio:{echoCancellation:!0,noiseSuppression:!0}}),w=new MediaRecorder(x,{mimeType:MediaRecorder.isTypeSupported("audio/webm")?"audio/webm":"audio/mp4"});d.current=w,u.current=[],w.ondataavailable=b=>{b.data.size>0&&u.current.push(b.data)},w.start(1e3),r(!0),f.current=Date.now(),h.current=window.setInterval(()=>{i(Math.floor((Date.now()-f.current)/1e3))},1e3),p({title:"Recording started",description:"Speak clearly into your microphone"})}catch(x){console.error("Failed to start recording:",x),p({title:"Recording failed",description:"Could not access microphone. Please check permissions.",variant:"destructive"})}},[p]),v=m.useCallback(async(x,w)=>new Promise(b=>{if(!d.current){b(null);return}const k=d.current;k.onstop=async()=>{h.current&&(clearInterval(h.current),h.current=null),k.stream.getTracks().forEach(S=>S.stop()),r(!1),s(!0);try{const S=new Blob(u.current,{type:k.mimeType}),C=o,{data:{user:N}}=await q.auth.getUser();if(!N)throw new Error("Not authenticated");const E=`${N.id}/${Date.now()}.webm`,{data:j,error:_}=await q.storage.from("audio-notes").upload(E,S,{contentType:k.mimeType});if(_)throw new Error(`Upload failed: ${_.message}`);const{data:{publicUrl:P}}=q.storage.from("audio-notes").getPublicUrl(E),T=`[Audio recording - ${C} seconds] Note: Speech-to-text transcription will be added. For now, please describe the key points from your recording.`,{data:A,error:I}=await q.from("notes").insert({user_id:N.id,event_id:x||null,class_id:w||null,type:"audio",content:T,audio_url:P,transcription:T,duration_seconds:C}).select().single();if(I)throw new Error(`Failed to save note: ${I.message}`);c(T);const{data:{session:V}}=await q.auth.getSession();if(V){const{data:L,error:U}=await q.functions.invoke("process-audio-note",{body:{noteId:A.id,transcription:T,classId:w||null,eventId:x||null}});U?console.error("Failed to process note:",U):L!=null&&L.todos&&t.onTodosExtracted&&t.onTodosExtracted(L.todos)}p({title:"Note saved",description:`Recording saved (${C}s). AI is analyzing for to-dos.`}),t.onTranscriptionComplete&&t.onTranscriptionComplete(T,A.id),b({noteId:A.id,transcription:T})}catch(S){console.error("Failed to process recording:",S),p({title:"Processing failed",description:S instanceof Error?S.message:"Failed to process recording",variant:"destructive"}),b(null)}finally{s(!1),i(0)}},k.stop()}),[o,p,t]),y=m.useCallback(()=>{d.current&&(d.current.stream.getTracks().forEach(x=>x.stop()),d.current=null),h.current&&(clearInterval(h.current),h.current=null),u.current=[],r(!1),i(0)},[]);return{isRecording:e,isProcessing:n,recordingDuration:o,transcription:a,startRecording:g,stopRecording:v,cancelRecording:y}}function TZ({eventId:t,classId:e,onRecordingComplete:r,onTodosExtracted:n,variant:s="button",className:o}){const{isRecording:i,isProcessing:a,recordingDuration:c,startRecording:d,stopRecording:u,cancelRecording:h}=_Z({onTranscriptionComplete:(g,v)=>{r==null||r(v,g)},onTodosExtracted:n}),f=g=>{const v=Math.floor(g/60),y=g%60;return`${v}:${y.toString().padStart(2,"0")}`},p=async()=>{await u(t,e)};return a?l.jsxs(K,{disabled:!0,className:B("flex-1",o),children:[l.jsx(Bt,{className:"h-4 w-4 animate-spin"}),"Processing..."]}):i?l.jsxs("div",{className:B("flex items-center gap-2",o),children:[l.jsxs(K,{variant:"recording",onClick:p,className:"flex-1",children:[l.jsx("div",{className:"recording-indicator mr-2"}),l.jsx("span",{className:"font-mono",children:f(c)}),l.jsx(lL,{className:"h-4 w-4 ml-2 fill-current"})]}),l.jsx(K,{variant:"ghost",size:"icon",onClick:h,className:"shrink-0",children:l.jsx(Wd,{className:"h-4 w-4"})})]}):l.jsxs(K,{variant:"glow",onClick:d,className:B("flex-1",o),children:[l.jsx(Gf,{className:"h-4 w-4"}),"Record Note"]})}function PP({event:t,open:e,onOpenChange:r}){const{classes:n,notes:s}=Ot(),o=Zs(),{toast:i}=gs(),[a,c]=m.useState(!1);if(!t)return null;const d=n.find(p=>p.id===t.classId),u=s.filter(p=>p.eventId===t.id),h=p=>{p.length>0&&i({title:`${p.length} to-do${p.length>1?"s":""} extracted!`,description:"View them in your To-Do list",action:l.jsx(K,{variant:"outline",size:"sm",onClick:()=>o("/todo"),children:"View To-Dos"})})},f={lecture:"Lecture",lab:"Lab Session",exam:"Exam","office-hours":"Office Hours","study-session":"Study Session"};return l.jsx(Vp,{open:e,onOpenChange:r,children:l.jsxs(bu,{className:"w-full sm:max-w-lg border-l border-border bg-background",children:[l.jsxs(ku,{className:"space-y-4",children:[l.jsx("div",{className:"flex items-start justify-between",children:l.jsxs("div",{className:"space-y-1",children:[l.jsx(ue,{variant:"class",style:{backgroundColor:`${d==null?void 0:d.color}20`,borderColor:`${d==null?void 0:d.color}50`,color:d==null?void 0:d.color},children:d==null?void 0:d.code}),l.jsx(Wp,{className:"text-xl font-semibold text-foreground",children:t.title})]})}),l.jsxs("div",{className:"space-y-2 text-sm",children:[l.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[l.jsx(tr,{className:"h-4 w-4"}),l.jsxs("span",{children:[pe(new Date(t.date),"EEEE, MMMM d, yyyy")," · ",t.startTime," - ",t.endTime]})]}),t.location&&l.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[l.jsx($o,{className:"h-4 w-4"}),l.jsx("span",{children:t.location})]}),l.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[l.jsx(vt,{className:"h-4 w-4"}),l.jsx("span",{children:f[t.type]})]})]})]}),l.jsxs("div",{className:"mt-6 space-y-6",children:[l.jsxs("div",{className:"flex gap-2",children:[l.jsx(TZ,{eventId:t.id,classId:t.classId,onTodosExtracted:h}),l.jsxs(K,{className:"flex-1",variant:"outline",onClick:()=>c(!0),children:[l.jsx(zt,{className:"h-4 w-4"}),"Add Text Note"]})]}),l.jsx(W0,{open:a,onOpenChange:c,eventId:t.id,classId:t.classId}),l.jsxs("div",{className:"space-y-3",children:[l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx("h3",{className:"text-sm font-semibold text-foreground",children:"Notes"}),u.length>0&&l.jsxs(K,{variant:"ghost",size:"sm",className:"h-7 text-xs",children:[l.jsx(Nr,{className:"h-3 w-3 mr-1"}),"Generate Summary"]})]}),u.length===0?l.jsxs(fe,{className:"p-6 text-center border-dashed",children:[l.jsx("div",{className:"mx-auto w-12 h-12 rounded-full bg-secondary flex items-center justify-center mb-3",children:l.jsx(zt,{className:"h-6 w-6 text-muted-foreground"})}),l.jsx("p",{className:"text-sm text-muted-foreground mb-3",children:"No notes for this lecture yet"}),l.jsxs(K,{variant:"outline",size:"sm",children:[l.jsx(Rt,{className:"h-4 w-4 mr-1"}),"Add your first note"]})]}):l.jsx(Pn,{className:"h-[400px] pr-4",children:l.jsx("div",{className:"space-y-3",children:u.map(p=>l.jsx(fe,{variant:"interactive",className:"p-4",children:l.jsxs("div",{className:"flex items-start gap-3",children:[l.jsx("div",{className:B("h-8 w-8 rounded-lg flex items-center justify-center shrink-0",p.type==="audio"?"bg-primary/10 text-primary":"bg-secondary text-secondary-foreground"),children:p.type==="audio"?l.jsx(Gf,{className:"h-4 w-4"}):l.jsx(zt,{className:"h-4 w-4"})}),l.jsxs("div",{className:"flex-1 min-w-0",children:[l.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[l.jsx("span",{className:"text-xs text-muted-foreground",children:pe(new Date(p.createdAt),"MMM d, h:mm a")}),p.type==="audio"&&l.jsx(ue,{variant:"outline",className:"text-[10px] px-1.5 py-0",children:"Transcribed"})]}),l.jsx("p",{className:"text-sm text-foreground line-clamp-3",children:p.transcription||p.content}),p.topics.length>0&&l.jsxs("div",{className:"flex flex-wrap gap-1 mt-2",children:[p.topics.slice(0,3).map(g=>l.jsx(ue,{variant:"secondary",className:"text-[10px]",children:g},g)),p.topics.length>3&&l.jsxs(ue,{variant:"secondary",className:"text-[10px]",children:["+",p.topics.length-3]})]})]}),l.jsx(wt,{className:"h-4 w-4 text-muted-foreground shrink-0"})]})},p.id))})})]})]})]})})}var RZ=[" ","Enter","ArrowUp","ArrowDown"],MZ=[" ","Enter"],Ta="Select",[Zm,eg,OZ]=Ld(Ta),[Oc,qre]=Ft(Ta,[OZ,Pl]),tg=Pl(),[PZ,vi]=Oc(Ta),[AZ,IZ]=Oc(Ta),AP=t=>{const{__scopeSelect:e,children:r,open:n,defaultOpen:s,onOpenChange:o,value:i,defaultValue:a,onValueChange:c,dir:d,name:u,autoComplete:h,disabled:f,required:p,form:g}=t,v=tg(e),[y,x]=m.useState(null),[w,b]=m.useState(null),[k,S]=m.useState(!1),C=ha(d),[N,E]=Wn({prop:n,defaultProp:s??!1,onChange:o,caller:Ta}),[j,_]=Wn({prop:i,defaultProp:a,onChange:c,caller:Ta}),P=m.useRef(null),T=y?g||!!y.closest("form"):!0,[A,I]=m.useState(new Set),V=Array.from(A).map(L=>L.props.value).join(";");return l.jsx(yj,{...v,children:l.jsxs(PZ,{required:p,scope:e,trigger:y,onTriggerChange:x,valueNode:w,onValueNodeChange:b,valueNodeHasChildren:k,onValueNodeHasChildrenChange:S,contentId:hr(),value:j,onValueChange:_,open:N,onOpenChange:E,dir:C,triggerPointerDownPosRef:P,disabled:f,children:[l.jsx(Zm.Provider,{scope:e,children:l.jsx(AZ,{scope:t.__scopeSelect,onNativeOptionAdd:m.useCallback(L=>{I(U=>new Set(U).add(L))},[]),onNativeOptionRemove:m.useCallback(L=>{I(U=>{const M=new Set(U);return M.delete(L),M})},[]),children:r})}),T?l.jsxs(sA,{"aria-hidden":!0,required:p,tabIndex:-1,name:u,autoComplete:h,value:j,onChange:L=>_(L.target.value),disabled:f,form:g,children:[j===void 0?l.jsx("option",{value:""}):null,Array.from(A)]},V):null]})})};AP.displayName=Ta;var IP="SelectTrigger",DP=m.forwardRef((t,e)=>{const{__scopeSelect:r,disabled:n=!1,...s}=t,o=tg(r),i=vi(IP,r),a=i.disabled||n,c=we(e,i.onTriggerChange),d=eg(r),u=m.useRef("touch"),[h,f,p]=iA(v=>{const y=d().filter(b=>!b.disabled),x=y.find(b=>b.value===i.value),w=aA(y,v,x);w!==void 0&&i.onValueChange(w.value)}),g=v=>{a||(i.onOpenChange(!0),p()),v&&(i.triggerPointerDownPosRef.current={x:Math.round(v.pageX),y:Math.round(v.pageY)})};return l.jsx(px,{asChild:!0,...o,children:l.jsx(se.button,{type:"button",role:"combobox","aria-controls":i.contentId,"aria-expanded":i.open,"aria-required":i.required,"aria-autocomplete":"none",dir:i.dir,"data-state":i.open?"open":"closed",disabled:a,"data-disabled":a?"":void 0,"data-placeholder":oA(i.value)?"":void 0,...s,ref:c,onClick:Q(s.onClick,v=>{v.currentTarget.focus(),u.current!=="mouse"&&g(v)}),onPointerDown:Q(s.onPointerDown,v=>{u.current=v.pointerType;const y=v.target;y.hasPointerCapture(v.pointerId)&&y.releasePointerCapture(v.pointerId),v.button===0&&v.ctrlKey===!1&&v.pointerType==="mouse"&&(g(v),v.preventDefault())}),onKeyDown:Q(s.onKeyDown,v=>{const y=h.current!=="";!(v.ctrlKey||v.altKey||v.metaKey)&&v.key.length===1&&f(v.key),!(y&&v.key===" ")&&RZ.includes(v.key)&&(g(),v.preventDefault())})})})});DP.displayName=IP;var LP="SelectValue",$P=m.forwardRef((t,e)=>{const{__scopeSelect:r,className:n,style:s,children:o,placeholder:i="",...a}=t,c=vi(LP,r),{onValueNodeHasChildrenChange:d}=c,u=o!==void 0,h=we(e,c.onValueNodeChange);return gt(()=>{d(u)},[d,u]),l.jsx(se.span,{...a,ref:h,style:{pointerEvents:"none"},children:oA(c.value)?l.jsx(l.Fragment,{children:i}):o})});$P.displayName=LP;var DZ="SelectIcon",FP=m.forwardRef((t,e)=>{const{__scopeSelect:r,children:n,...s}=t;return l.jsx(se.span,{"aria-hidden":!0,...s,ref:e,children:n||"▼"})});FP.displayName=DZ;var LZ="SelectPortal",zP=t=>l.jsx($d,{asChild:!0,...t});zP.displayName=LZ;var Ra="SelectContent",BP=m.forwardRef((t,e)=>{const r=vi(Ra,t.__scopeSelect),[n,s]=m.useState();if(gt(()=>{s(new DocumentFragment)},[]),!r.open){const o=n;return o?vn.createPortal(l.jsx(UP,{scope:t.__scopeSelect,children:l.jsx(Zm.Slot,{scope:t.__scopeSelect,children:l.jsx("div",{children:t.children})})}),o):null}return l.jsx(VP,{...t,ref:e})});BP.displayName=Ra;var ns=10,[UP,yi]=Oc(Ra),$Z="SelectContentImpl",FZ=Ji("SelectContent.RemoveScroll"),VP=m.forwardRef((t,e)=>{const{__scopeSelect:r,position:n="item-aligned",onCloseAutoFocus:s,onEscapeKeyDown:o,onPointerDownOutside:i,side:a,sideOffset:c,align:d,alignOffset:u,arrowPadding:h,collisionBoundary:f,collisionPadding:p,sticky:g,hideWhenDetached:v,avoidCollisions:y,...x}=t,w=vi(Ra,r),[b,k]=m.useState(null),[S,C]=m.useState(null),N=we(e,F=>k(F)),[E,j]=m.useState(null),[_,P]=m.useState(null),T=eg(r),[A,I]=m.useState(!1),V=m.useRef(!1);m.useEffect(()=>{if(b)return Vx(b)},[b]),Lx();const L=m.useCallback(F=>{const[te,...ee]=T().map(ce=>ce.ref.current),[Z]=ee.slice(-1),ve=document.activeElement;for(const ce of F)if(ce===ve||(ce==null||ce.scrollIntoView({block:"nearest"}),ce===te&&S&&(S.scrollTop=0),ce===Z&&S&&(S.scrollTop=S.scrollHeight),ce==null||ce.focus(),document.activeElement!==ve))return},[T,S]),U=m.useCallback(()=>L([E,b]),[L,E,b]);m.useEffect(()=>{A&&U()},[A,U]);const{onOpenChange:M,triggerPointerDownPosRef:D}=w;m.useEffect(()=>{if(b){let F={x:0,y:0};const te=Z=>{var ve,ce;F={x:Math.abs(Math.round(Z.pageX)-(((ve=D.current)==null?void 0:ve.x)??0)),y:Math.abs(Math.round(Z.pageY)-(((ce=D.current)==null?void 0:ce.y)??0))}},ee=Z=>{F.x<=10&&F.y<=10?Z.preventDefault():b.contains(Z.target)||M(!1),document.removeEventListener("pointermove",te),D.current=null};return D.current!==null&&(document.addEventListener("pointermove",te),document.addEventListener("pointerup",ee,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",te),document.removeEventListener("pointerup",ee,{capture:!0})}}},[b,M,D]),m.useEffect(()=>{const F=()=>M(!1);return window.addEventListener("blur",F),window.addEventListener("resize",F),()=>{window.removeEventListener("blur",F),window.removeEventListener("resize",F)}},[M]);const[H,ne]=iA(F=>{const te=T().filter(ve=>!ve.disabled),ee=te.find(ve=>ve.ref.current===document.activeElement),Z=aA(te,F,ee);Z&&setTimeout(()=>Z.ref.current.focus())}),$=m.useCallback((F,te,ee)=>{const Z=!V.current&&!ee;(w.value!==void 0&&w.value===te||Z)&&(j(F),Z&&(V.current=!0))},[w.value]),G=m.useCallback(()=>b==null?void 0:b.focus(),[b]),J=m.useCallback((F,te,ee)=>{const Z=!V.current&&!ee;(w.value!==void 0&&w.value===te||Z)&&P(F)},[w.value]),O=n==="popper"?Cb:WP,z=O===Cb?{side:a,sideOffset:c,align:d,alignOffset:u,arrowPadding:h,collisionBoundary:f,collisionPadding:p,sticky:g,hideWhenDetached:v,avoidCollisions:y}:{};return l.jsx(UP,{scope:r,content:b,viewport:S,onViewportChange:C,itemRefCallback:$,selectedItem:E,onItemLeave:G,itemTextRefCallback:J,focusSelectedItem:U,selectedItemText:_,position:n,isPositioned:A,searchRef:H,children:l.jsx(Np,{as:FZ,allowPinchZoom:!0,children:l.jsx(yp,{asChild:!0,trapped:w.open,onMountAutoFocus:F=>{F.preventDefault()},onUnmountAutoFocus:Q(s,F=>{var te;(te=w.trigger)==null||te.focus({preventScroll:!0}),F.preventDefault()}),children:l.jsx(kl,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:o,onPointerDownOutside:i,onFocusOutside:F=>F.preventDefault(),onDismiss:()=>w.onOpenChange(!1),children:l.jsx(O,{role:"listbox",id:w.contentId,"data-state":w.open?"open":"closed",dir:w.dir,onContextMenu:F=>F.preventDefault(),...x,...z,onPlaced:()=>I(!0),ref:N,style:{display:"flex",flexDirection:"column",outline:"none",...x.style},onKeyDown:Q(x.onKeyDown,F=>{const te=F.ctrlKey||F.altKey||F.metaKey;if(F.key==="Tab"&&F.preventDefault(),!te&&F.key.length===1&&ne(F.key),["ArrowUp","ArrowDown","Home","End"].includes(F.key)){let Z=T().filter(ve=>!ve.disabled).map(ve=>ve.ref.current);if(["ArrowUp","End"].includes(F.key)&&(Z=Z.slice().reverse()),["ArrowUp","ArrowDown"].includes(F.key)){const ve=F.target,ce=Z.indexOf(ve);Z=Z.slice(ce+1)}setTimeout(()=>L(Z)),F.preventDefault()}})})})})})})});VP.displayName=$Z;var zZ="SelectItemAlignedPosition",WP=m.forwardRef((t,e)=>{const{__scopeSelect:r,onPlaced:n,...s}=t,o=vi(Ra,r),i=yi(Ra,r),[a,c]=m.useState(null),[d,u]=m.useState(null),h=we(e,N=>u(N)),f=eg(r),p=m.useRef(!1),g=m.useRef(!0),{viewport:v,selectedItem:y,selectedItemText:x,focusSelectedItem:w}=i,b=m.useCallback(()=>{if(o.trigger&&o.valueNode&&a&&d&&v&&y&&x){const N=o.trigger.getBoundingClientRect(),E=d.getBoundingClientRect(),j=o.valueNode.getBoundingClientRect(),_=x.getBoundingClientRect();if(o.dir!=="rtl"){const ve=_.left-E.left,ce=j.left-ve,Le=N.left-ce,We=N.width+Le,It=Math.max(We,E.width),Dt=window.innerWidth-ns,Dn=Hu(ce,[ns,Math.max(ns,Dt-It)]);a.style.minWidth=We+"px",a.style.left=Dn+"px"}else{const ve=E.right-_.right,ce=window.innerWidth-j.right-ve,Le=window.innerWidth-N.right-ce,We=N.width+Le,It=Math.max(We,E.width),Dt=window.innerWidth-ns,Dn=Hu(ce,[ns,Math.max(ns,Dt-It)]);a.style.minWidth=We+"px",a.style.right=Dn+"px"}const P=f(),T=window.innerHeight-ns*2,A=v.scrollHeight,I=window.getComputedStyle(d),V=parseInt(I.borderTopWidth,10),L=parseInt(I.paddingTop,10),U=parseInt(I.borderBottomWidth,10),M=parseInt(I.paddingBottom,10),D=V+L+A+M+U,H=Math.min(y.offsetHeight*5,D),ne=window.getComputedStyle(v),$=parseInt(ne.paddingTop,10),G=parseInt(ne.paddingBottom,10),J=N.top+N.height/2-ns,O=T-J,z=y.offsetHeight/2,F=y.offsetTop+z,te=V+L+F,ee=D-te;if(te<=J){const ve=P.length>0&&y===P[P.length-1].ref.current;a.style.bottom="0px";const ce=d.clientHeight-v.offsetTop-v.offsetHeight,Le=Math.max(O,z+(ve?G:0)+ce+U),We=te+Le;a.style.height=We+"px"}else{const ve=P.length>0&&y===P[0].ref.current;a.style.top="0px";const Le=Math.max(J,V+v.offsetTop+(ve?$:0)+z)+ee;a.style.height=Le+"px",v.scrollTop=te-J+v.offsetTop}a.style.margin=`${ns}px 0`,a.style.minHeight=H+"px",a.style.maxHeight=T+"px",n==null||n(),requestAnimationFrame(()=>p.current=!0)}},[f,o.trigger,o.valueNode,a,d,v,y,x,o.dir,n]);gt(()=>b(),[b]);const[k,S]=m.useState();gt(()=>{d&&S(window.getComputedStyle(d).zIndex)},[d]);const C=m.useCallback(N=>{N&&g.current===!0&&(b(),w==null||w(),g.current=!1)},[b,w]);return l.jsx(UZ,{scope:r,contentWrapper:a,shouldExpandOnScrollRef:p,onScrollButtonChange:C,children:l.jsx("div",{ref:c,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:k},children:l.jsx(se.div,{...s,ref:h,style:{boxSizing:"border-box",maxHeight:"100%",...s.style}})})})});WP.displayName=zZ;var BZ="SelectPopperPosition",Cb=m.forwardRef((t,e)=>{const{__scopeSelect:r,align:n="start",collisionPadding:s=ns,...o}=t,i=tg(r);return l.jsx(mx,{...i,...o,ref:e,align:n,collisionPadding:s,style:{boxSizing:"border-box",...o.style,"--radix-select-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-select-content-available-width":"var(--radix-popper-available-width)","--radix-select-content-available-height":"var(--radix-popper-available-height)","--radix-select-trigger-width":"var(--radix-popper-anchor-width)","--radix-select-trigger-height":"var(--radix-popper-anchor-height)"}})});Cb.displayName=BZ;var[UZ,jb]=Oc(Ra,{}),Eb="SelectViewport",HP=m.forwardRef((t,e)=>{const{__scopeSelect:r,nonce:n,...s}=t,o=yi(Eb,r),i=jb(Eb,r),a=we(e,o.onViewportChange),c=m.useRef(0);return l.jsxs(l.Fragment,{children:[l.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"},nonce:n}),l.jsx(Zm.Slot,{scope:r,children:l.jsx(se.div,{"data-radix-select-viewport":"",role:"presentation",...s,ref:a,style:{position:"relative",flex:1,overflow:"hidden auto",...s.style},onScroll:Q(s.onScroll,d=>{const u=d.currentTarget,{contentWrapper:h,shouldExpandOnScrollRef:f}=i;if(f!=null&&f.current&&h){const p=Math.abs(c.current-u.scrollTop);if(p>0){const g=window.innerHeight-ns*2,v=parseFloat(h.style.minHeight),y=parseFloat(h.style.height),x=Math.max(v,y);if(x0?k:0,h.style.justifyContent="flex-end")}}}c.current=u.scrollTop})})})]})});HP.displayName=Eb;var qP="SelectGroup",[VZ,WZ]=Oc(qP),HZ=m.forwardRef((t,e)=>{const{__scopeSelect:r,...n}=t,s=hr();return l.jsx(VZ,{scope:r,id:s,children:l.jsx(se.div,{role:"group","aria-labelledby":s,...n,ref:e})})});HZ.displayName=qP;var KP="SelectLabel",GP=m.forwardRef((t,e)=>{const{__scopeSelect:r,...n}=t,s=WZ(KP,r);return l.jsx(se.div,{id:s.id,...n,ref:e})});GP.displayName=KP;var rg="SelectItem",[qZ,YP]=Oc(rg),JP=m.forwardRef((t,e)=>{const{__scopeSelect:r,value:n,disabled:s=!1,textValue:o,...i}=t,a=vi(rg,r),c=yi(rg,r),d=a.value===n,[u,h]=m.useState(o??""),[f,p]=m.useState(!1),g=we(e,w=>{var b;return(b=c.itemRefCallback)==null?void 0:b.call(c,w,n,s)}),v=hr(),y=m.useRef("touch"),x=()=>{s||(a.onValueChange(n),a.onOpenChange(!1))};if(n==="")throw new Error("A must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder.");return l.jsx(qZ,{scope:r,value:n,disabled:s,textId:v,isSelected:d,onItemTextChange:m.useCallback(w=>{h(b=>b||((w==null?void 0:w.textContent)??"").trim())},[]),children:l.jsx(Zm.ItemSlot,{scope:r,value:n,disabled:s,textValue:u,children:l.jsx(se.div,{role:"option","aria-labelledby":v,"data-highlighted":f?"":void 0,"aria-selected":d&&f,"data-state":d?"checked":"unchecked","aria-disabled":s||void 0,"data-disabled":s?"":void 0,tabIndex:s?void 0:-1,...i,ref:g,onFocus:Q(i.onFocus,()=>p(!0)),onBlur:Q(i.onBlur,()=>p(!1)),onClick:Q(i.onClick,()=>{y.current!=="mouse"&&x()}),onPointerUp:Q(i.onPointerUp,()=>{y.current==="mouse"&&x()}),onPointerDown:Q(i.onPointerDown,w=>{y.current=w.pointerType}),onPointerMove:Q(i.onPointerMove,w=>{var b;y.current=w.pointerType,s?(b=c.onItemLeave)==null||b.call(c):y.current==="mouse"&&w.currentTarget.focus({preventScroll:!0})}),onPointerLeave:Q(i.onPointerLeave,w=>{var b;w.currentTarget===document.activeElement&&((b=c.onItemLeave)==null||b.call(c))}),onKeyDown:Q(i.onKeyDown,w=>{var k;((k=c.searchRef)==null?void 0:k.current)!==""&&w.key===" "||(MZ.includes(w.key)&&x(),w.key===" "&&w.preventDefault())})})})})});JP.displayName=rg;var dh="SelectItemText",QP=m.forwardRef((t,e)=>{const{__scopeSelect:r,className:n,style:s,...o}=t,i=vi(dh,r),a=yi(dh,r),c=YP(dh,r),d=IZ(dh,r),[u,h]=m.useState(null),f=we(e,x=>h(x),c.onItemTextChange,x=>{var w;return(w=a.itemTextRefCallback)==null?void 0:w.call(a,x,c.value,c.disabled)}),p=u==null?void 0:u.textContent,g=m.useMemo(()=>l.jsx("option",{value:c.value,disabled:c.disabled,children:p},c.value),[c.disabled,c.value,p]),{onNativeOptionAdd:v,onNativeOptionRemove:y}=d;return gt(()=>(v(g),()=>y(g)),[v,y,g]),l.jsxs(l.Fragment,{children:[l.jsx(se.span,{id:c.textId,...o,ref:f}),c.isSelected&&i.valueNode&&!i.valueNodeHasChildren?vn.createPortal(o.children,i.valueNode):null]})});QP.displayName=dh;var XP="SelectItemIndicator",ZP=m.forwardRef((t,e)=>{const{__scopeSelect:r,...n}=t;return YP(XP,r).isSelected?l.jsx(se.span,{"aria-hidden":!0,...n,ref:e}):null});ZP.displayName=XP;var _b="SelectScrollUpButton",eA=m.forwardRef((t,e)=>{const r=yi(_b,t.__scopeSelect),n=jb(_b,t.__scopeSelect),[s,o]=m.useState(!1),i=we(e,n.onScrollButtonChange);return gt(()=>{if(r.viewport&&r.isPositioned){let a=function(){const d=c.scrollTop>0;o(d)};const c=r.viewport;return a(),c.addEventListener("scroll",a),()=>c.removeEventListener("scroll",a)}},[r.viewport,r.isPositioned]),s?l.jsx(rA,{...t,ref:i,onAutoScroll:()=>{const{viewport:a,selectedItem:c}=r;a&&c&&(a.scrollTop=a.scrollTop-c.offsetHeight)}}):null});eA.displayName=_b;var Tb="SelectScrollDownButton",tA=m.forwardRef((t,e)=>{const r=yi(Tb,t.__scopeSelect),n=jb(Tb,t.__scopeSelect),[s,o]=m.useState(!1),i=we(e,n.onScrollButtonChange);return gt(()=>{if(r.viewport&&r.isPositioned){let a=function(){const d=c.scrollHeight-c.clientHeight,u=Math.ceil(c.scrollTop)c.removeEventListener("scroll",a)}},[r.viewport,r.isPositioned]),s?l.jsx(rA,{...t,ref:i,onAutoScroll:()=>{const{viewport:a,selectedItem:c}=r;a&&c&&(a.scrollTop=a.scrollTop+c.offsetHeight)}}):null});tA.displayName=Tb;var rA=m.forwardRef((t,e)=>{const{__scopeSelect:r,onAutoScroll:n,...s}=t,o=yi("SelectScrollButton",r),i=m.useRef(null),a=eg(r),c=m.useCallback(()=>{i.current!==null&&(window.clearInterval(i.current),i.current=null)},[]);return m.useEffect(()=>()=>c(),[c]),gt(()=>{var u;const d=a().find(h=>h.ref.current===document.activeElement);(u=d==null?void 0:d.ref.current)==null||u.scrollIntoView({block:"nearest"})},[a]),l.jsx(se.div,{"aria-hidden":!0,...s,ref:e,style:{flexShrink:0,...s.style},onPointerDown:Q(s.onPointerDown,()=>{i.current===null&&(i.current=window.setInterval(n,50))}),onPointerMove:Q(s.onPointerMove,()=>{var d;(d=o.onItemLeave)==null||d.call(o),i.current===null&&(i.current=window.setInterval(n,50))}),onPointerLeave:Q(s.onPointerLeave,()=>{c()})})}),KZ="SelectSeparator",nA=m.forwardRef((t,e)=>{const{__scopeSelect:r,...n}=t;return l.jsx(se.div,{"aria-hidden":!0,...n,ref:e})});nA.displayName=KZ;var Rb="SelectArrow",GZ=m.forwardRef((t,e)=>{const{__scopeSelect:r,...n}=t,s=tg(r),o=vi(Rb,r),i=yi(Rb,r);return o.open&&i.position==="popper"?l.jsx(gx,{...s,...n,ref:e}):null});GZ.displayName=Rb;var YZ="SelectBubbleInput",sA=m.forwardRef(({__scopeSelect:t,value:e,...r},n)=>{const s=m.useRef(null),o=we(n,s),i=tu(e);return m.useEffect(()=>{const a=s.current;if(!a)return;const c=window.HTMLSelectElement.prototype,u=Object.getOwnPropertyDescriptor(c,"value").set;if(i!==e&&u){const h=new Event("change",{bubbles:!0});u.call(a,e),a.dispatchEvent(h)}},[i,e]),l.jsx(se.select,{...r,style:{...zN,...r.style},ref:o,defaultValue:e})});sA.displayName=YZ;function oA(t){return t===""||t===void 0}function iA(t){const e=at(t),r=m.useRef(""),n=m.useRef(0),s=m.useCallback(i=>{const a=r.current+i;e(a),function c(d){r.current=d,window.clearTimeout(n.current),d!==""&&(n.current=window.setTimeout(()=>c(""),1e3))}(a)},[e]),o=m.useCallback(()=>{r.current="",window.clearTimeout(n.current)},[]);return m.useEffect(()=>()=>window.clearTimeout(n.current),[]),[r,s,o]}function aA(t,e,r){const s=e.length>1&&Array.from(e).every(d=>d===e[0])?e[0]:e,o=r?t.indexOf(r):-1;let i=JZ(t,Math.max(o,0));s.length===1&&(i=i.filter(d=>d!==r));const c=i.find(d=>d.textValue.toLowerCase().startsWith(s.toLowerCase()));return c!==r?c:void 0}function JZ(t,e){return t.map((r,n)=>t[(e+n)%t.length])}var QZ=AP,lA=DP,XZ=$P,ZZ=FP,eee=zP,cA=BP,tee=HP,dA=GP,uA=JP,ree=QP,nee=ZP,hA=eA,fA=tA,pA=nA;const _s=QZ,Ts=XZ,ss=m.forwardRef(({className:t,children:e,...r},n)=>l.jsxs(lA,{ref:n,className:B("flex h-10 w-full items-center justify-between rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",t),...r,children:[e,l.jsx(ZZ,{asChild:!0,children:l.jsx(pC,{className:"h-4 w-4 opacity-50"})})]}));ss.displayName=lA.displayName;const mA=m.forwardRef(({className:t,...e},r)=>l.jsx(hA,{ref:r,className:B("flex cursor-default items-center justify-center py-1",t),...e,children:l.jsx(A3,{className:"h-4 w-4"})}));mA.displayName=hA.displayName;const gA=m.forwardRef(({className:t,...e},r)=>l.jsx(fA,{ref:r,className:B("flex cursor-default items-center justify-center py-1",t),...e,children:l.jsx(pC,{className:"h-4 w-4"})}));gA.displayName=fA.displayName;const is=m.forwardRef(({className:t,children:e,position:r="popper",...n},s)=>l.jsx(eee,{children:l.jsxs(cA,{ref:s,className:B("relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",r==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",t),position:r,...n,children:[l.jsx(mA,{}),l.jsx(tee,{className:B("p-1",r==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:e}),l.jsx(gA,{})]})}));is.displayName=cA.displayName;const see=m.forwardRef(({className:t,...e},r)=>l.jsx(dA,{ref:r,className:B("py-1.5 pl-8 pr-2 text-sm font-semibold",t),...e}));see.displayName=dA.displayName;const Fe=m.forwardRef(({className:t,children:e,...r},n)=>l.jsxs(uA,{ref:n,className:B("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 focus:bg-accent focus:text-accent-foreground",t),...r,children:[l.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:l.jsx(nee,{children:l.jsx(Qi,{className:"h-4 w-4"})})}),l.jsx(ree,{children:e})]}));Fe.displayName=uA.displayName;const oee=m.forwardRef(({className:t,...e},r)=>l.jsx(pA,{ref:r,className:B("-mx-1 my-1 h-px bg-muted",t),...e}));oee.displayName=pA.displayName;const Mb=["#4285F4","#0078D4","#FF6B6B","#51CF66","#FF922B","#845EF7","#339AF0","#20C997"],vA=[{value:"google",label:"Google Calendar"},{value:"outlook",label:"Outlook / Office 365"},{value:"apple",label:"Apple Calendar"},{value:"other",label:"Other (ICS URL)"}];function yA({open:t,onOpenChange:e}){const{calendars:r,syncing:n,addCalendar:s,removeCalendar:o,toggleCalendar:i,syncCalendar:a}=Km(),[c,d]=m.useState(!1),[u,h]=m.useState(!1),[f,p]=m.useState(!1),[g,v]=m.useState(!1),[y,x]=m.useState(""),[w,b]=m.useState(""),[k,S]=m.useState("google"),[C,N]=m.useState(Mb[0]),E=async()=>{const{data:{session:T}}=await q.auth.getSession();return T?`https://jqoaxvwjqgjxmenvuwql.supabase.co/functions/v1/generate-ics-feed?token=${T.access_token}`:(Se.error("Please sign in to sync your calendar"),null)},j=async()=>{h(!0);try{const T=await E();if(!T)return;const A=await fetch(T);if(!A.ok)throw new Error("Failed to download");const I=await A.blob(),V=URL.createObjectURL(I),L=document.createElement("a");L.href=V,L.download="forward-calendar.ics",document.body.appendChild(L),L.click(),document.body.removeChild(L),URL.revokeObjectURL(V),Se.success("Calendar file downloaded!")}catch{Se.error("Failed to download calendar file")}finally{h(!1)}},_=async()=>{const T=await E();if(T)try{await navigator.clipboard.writeText(T),d(!0),Se.success("Calendar link copied!"),setTimeout(()=>d(!1),2e3)}catch{Se.error("Failed to copy link")}},P=async()=>{if(!y.trim()||!w.trim()){Se.error("Please fill in all fields");return}p(!0);const T=await s(y.trim(),w.trim(),k,C);p(!1),T&&(v(!1),x(""),b(""),S("google"),N(Mb[0]))};return l.jsx(wn,{open:t,onOpenChange:e,children:l.jsxs(nn,{className:"sm:max-w-lg max-h-[85vh] overflow-y-auto",children:[l.jsxs(bn,{children:[l.jsxs(kn,{className:"flex items-center gap-2",children:[l.jsx(Sr,{className:"h-5 w-5 text-primary"}),"Calendar Hub"]}),l.jsx(Wl,{children:"Import external calendars and export your Focus calendar."})]}),l.jsxs(no,{defaultValue:"import",className:"mt-2",children:[l.jsxs(ks,{className:"grid w-full grid-cols-2",children:[l.jsx(Ze,{value:"import",children:"Import Calendars"}),l.jsx(Ze,{value:"export",children:"Export"})]}),l.jsxs(et,{value:"import",className:"space-y-4 mt-4",children:[r.length>0&&l.jsxs("div",{className:"space-y-2",children:[l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx("h4",{className:"text-sm font-medium",children:"Connected Calendars"}),l.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>a(),disabled:n,children:[l.jsx(bC,{className:B("h-3 w-3 mr-1",n&&"animate-spin")}),n?"Syncing...":"Sync All"]})]}),r.map(T=>{var A;return l.jsxs("div",{className:"flex items-center gap-3 rounded-lg border border-border p-3",children:[l.jsx("div",{className:"h-3 w-3 rounded-full shrink-0",style:{backgroundColor:T.color}}),l.jsxs("div",{className:"flex-1 min-w-0",children:[l.jsx("div",{className:"text-sm font-medium truncate",children:T.name}),l.jsxs("div",{className:"text-xs text-muted-foreground",children:[((A=vA.find(I=>I.value===T.provider))==null?void 0:A.label)||T.provider,T.last_synced_at&&` · Last synced ${new Date(T.last_synced_at).toLocaleDateString()}`]})]}),l.jsx(Ko,{checked:T.enabled,onCheckedChange:I=>i(T.id,I)}),l.jsx(K,{variant:"ghost",size:"icon-sm",className:"h-7 w-7 text-muted-foreground hover:text-destructive",onClick:()=>o(T.id),children:l.jsx(Ky,{className:"h-3.5 w-3.5"})})]},T.id)})]}),g?l.jsxs("div",{className:"space-y-3 rounded-lg border border-border p-4",children:[l.jsx("h4",{className:"text-sm font-medium",children:"Add Calendar"}),l.jsxs("div",{className:"space-y-2",children:[l.jsx(de,{htmlFor:"cal-name",className:"text-xs",children:"Calendar Name"}),l.jsx(Ne,{id:"cal-name",placeholder:"My Google Calendar",value:y,onChange:T=>x(T.target.value)})]}),l.jsxs("div",{className:"space-y-2",children:[l.jsx(de,{htmlFor:"cal-provider",className:"text-xs",children:"Provider"}),l.jsxs(_s,{value:k,onValueChange:T=>{S(T),T==="google"?N("#4285F4"):T==="outlook"?N("#0078D4"):T==="apple"&&N("#FF6B6B")},children:[l.jsx(ss,{children:l.jsx(Ts,{})}),l.jsx(is,{children:vA.map(T=>l.jsx(Fe,{value:T.value,children:T.label},T.value))})]})]}),l.jsxs("div",{className:"space-y-2",children:[l.jsx(de,{htmlFor:"cal-url",className:"text-xs",children:"ICS Feed URL"}),l.jsx(Ne,{id:"cal-url",placeholder:"https://calendar.google.com/calendar/ical/...",value:w,onChange:T=>b(T.target.value)}),l.jsxs("p",{className:"text-xs text-muted-foreground",children:[k==="google"&&"Google Calendar → Settings → Calendar settings → Secret address in iCal format",k==="outlook"&&"Outlook → Calendar → Settings → Shared calendars → Publish a calendar → ICS link",k==="apple"&&"iCloud → Calendar → Share Calendar → Public Calendar → Copy Link",k==="other"&&"Paste any valid ICS/iCal feed URL"]})]}),l.jsxs("div",{className:"space-y-2",children:[l.jsx(de,{className:"text-xs",children:"Color"}),l.jsx("div",{className:"flex gap-2",children:Mb.map(T=>l.jsx("button",{className:B("h-6 w-6 rounded-full border-2 transition-transform",C===T?"border-foreground scale-110":"border-transparent"),style:{backgroundColor:T},onClick:()=>N(T)},T))})]}),l.jsxs("div",{className:"flex gap-2 pt-1",children:[l.jsx(K,{onClick:P,disabled:f,size:"sm",children:f?"Adding...":"Add & Sync"}),l.jsx(K,{variant:"ghost",size:"sm",onClick:()=>v(!1),children:"Cancel"})]})]}):l.jsxs(K,{variant:"outline",className:"w-full",onClick:()=>v(!0),children:[l.jsx(Rt,{className:"h-4 w-4 mr-2"}),"Add External Calendar"]}),r.length===0&&!g&&l.jsxs("div",{className:"text-center py-6 text-muted-foreground",children:[l.jsx(Sr,{className:"h-10 w-10 mx-auto mb-2 opacity-30"}),l.jsx("p",{className:"text-sm",children:"No external calendars connected yet."}),l.jsx("p",{className:"text-xs mt-1",children:"Add your Google Calendar or Outlook to see all events in one place."})]})]}),l.jsxs(et,{value:"export",className:"space-y-4 mt-4",children:[l.jsxs("div",{className:"rounded-lg border border-border bg-muted/30 p-4 space-y-3",children:[l.jsx("h4",{className:"text-sm font-medium",children:"Subscribe via URL"}),l.jsx("p",{className:"text-xs text-muted-foreground",children:"Copy this link and add it as a subscription in Google Calendar or Outlook."}),l.jsx(K,{onClick:_,className:"w-full",variant:"outline",children:c?l.jsxs(l.Fragment,{children:[l.jsx(Qi,{className:"h-4 w-4 mr-2"}),"Copied!"]}):l.jsxs(l.Fragment,{children:[l.jsx(Vy,{className:"h-4 w-4 mr-2"}),"Copy Calendar URL"]})})]}),l.jsxs("div",{className:"rounded-lg border border-border bg-muted/30 p-4 space-y-3",children:[l.jsx("h4",{className:"text-sm font-medium",children:"Download .ics File"}),l.jsx("p",{className:"text-xs text-muted-foreground",children:"Download a snapshot to import into any calendar app."}),l.jsxs(K,{onClick:j,className:"w-full",disabled:u,children:[l.jsx(D3,{className:"h-4 w-4 mr-2"}),u?"Downloading...":"Download Calendar File"]})]}),l.jsxs("div",{className:"space-y-2",children:[l.jsx("h4",{className:"text-sm font-medium text-muted-foreground",children:"How to subscribe:"}),l.jsxs("div",{className:"space-y-1.5 text-xs text-muted-foreground",children:[l.jsxs("div",{children:[l.jsx("span",{className:"font-semibold text-foreground",children:"Google:"})," Settings → Add calendar → From URL"]}),l.jsxs("div",{children:[l.jsx("span",{className:"font-semibold text-foreground",children:"Outlook:"})," Add calendar → Subscribe from web"]}),l.jsxs("div",{children:[l.jsx("span",{className:"font-semibold text-foreground",children:"Apple:"})," File → New Calendar Subscription"]})]})]})]})]})]})})}function xA({open:t,onOpenChange:e}){const{classes:r,addEvent:n}=Ot(),[s,o]=m.useState(""),[i,a]=m.useState(""),[c,d]=m.useState(""),[u,h]=m.useState("09:00"),[f,p]=m.useState("10:00"),[g,v]=m.useState(""),[y,x]=m.useState("lecture"),w=()=>{if(!s||!i||!c)return;const b={id:`event-${Date.now()}`,classId:i,userId:"user-1",title:s,date:new Date(c),startTime:u,endTime:f,type:y,location:g||void 0,notes:[],createdAt:new Date};n(b),e(!1),o(""),a(""),d(""),h("09:00"),p("10:00"),v(""),x("lecture")};return l.jsx(wn,{open:t,onOpenChange:e,children:l.jsxs(nn,{className:"sm:max-w-[425px]",children:[l.jsxs(bn,{children:[l.jsx(kn,{children:"Add Event"}),l.jsx(Wl,{children:"Create a new event on your calendar."})]}),l.jsxs("div",{className:"space-y-4 pt-2",children:[l.jsxs("div",{className:"space-y-2",children:[l.jsx(de,{htmlFor:"event-title",children:"Title *"}),l.jsx(Ne,{id:"event-title",placeholder:"e.g., Midterm Review Session",value:s,onChange:b=>o(b.target.value)})]}),l.jsxs("div",{className:"space-y-2",children:[l.jsx(de,{children:"Class *"}),l.jsxs(_s,{value:i,onValueChange:a,children:[l.jsx(ss,{children:l.jsx(Ts,{placeholder:"Select a class"})}),l.jsx(is,{children:r.map(b=>l.jsx(Fe,{value:b.id,children:l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("div",{className:"h-2 w-2 rounded-full",style:{backgroundColor:b.color}}),b.code," - ",b.name]})},b.id))})]})]}),l.jsxs("div",{className:"space-y-2",children:[l.jsx(de,{children:"Type"}),l.jsxs(_s,{value:y,onValueChange:b=>x(b),children:[l.jsx(ss,{children:l.jsx(Ts,{})}),l.jsxs(is,{children:[l.jsx(Fe,{value:"lecture",children:"Lecture"}),l.jsx(Fe,{value:"lab",children:"Lab"}),l.jsx(Fe,{value:"exam",children:"Exam"}),l.jsx(Fe,{value:"office-hours",children:"Office Hours"}),l.jsx(Fe,{value:"study-session",children:"Study Session"})]})]})]}),l.jsxs("div",{className:"space-y-2",children:[l.jsx(de,{htmlFor:"event-date",children:"Date *"}),l.jsx(Ne,{id:"event-date",type:"date",value:c,onChange:b=>d(b.target.value)})]}),l.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[l.jsxs("div",{className:"space-y-2",children:[l.jsx(de,{htmlFor:"event-start",children:"Start Time"}),l.jsx(Ne,{id:"event-start",type:"time",value:u,onChange:b=>h(b.target.value)})]}),l.jsxs("div",{className:"space-y-2",children:[l.jsx(de,{htmlFor:"event-end",children:"End Time"}),l.jsx(Ne,{id:"event-end",type:"time",value:f,onChange:b=>p(b.target.value)})]})]}),l.jsxs("div",{className:"space-y-2",children:[l.jsx(de,{htmlFor:"event-location",children:"Location"}),l.jsx(Ne,{id:"event-location",placeholder:"e.g., Room 201",value:g,onChange:b=>v(b.target.value)})]}),l.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[l.jsx(K,{variant:"outline",onClick:()=>e(!1),children:"Cancel"}),l.jsx(K,{onClick:w,disabled:!s||!i||!c,children:"Add Event"})]})]})]})})}function iee(){const{calendarView:t,setCalendarView:e,setSelectedEvent:r,selectedEvent:n}=Ot(),[s,o]=m.useState(!1),[i,a]=m.useState(!1),[c,d]=m.useState(!1);Zs();const u=du(),h=g=>{r(g),o(!0)},f=g=>{console.log("Date clicked:",g)},p=[{value:"month",icon:U3},{value:"week",icon:yC}];return u?l.jsxs("div",{className:"h-screen flex flex-col",children:[l.jsxs("header",{className:"flex items-center justify-between px-4 py-2 border-b border-border bg-background/80 backdrop-blur-sm",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx(co,{}),l.jsx("h1",{className:"text-lg font-bold text-foreground",children:"Calendar"})]}),l.jsxs("div",{className:"flex items-center gap-1",children:[l.jsx(K,{variant:"ghost",size:"sm",className:"h-8 px-2 text-xs",onClick:()=>d(!0),children:l.jsx(Rt,{className:"h-3.5 w-3.5"})}),l.jsx(K,{variant:"ghost",size:"sm",className:"h-8 px-2 text-xs",onClick:()=>a(!0),children:l.jsx(SC,{className:"h-3.5 w-3.5"})})]})]}),l.jsx("div",{className:"flex-1 overflow-hidden",children:l.jsx(pZ,{onEventClick:h,onDateClick:f})}),l.jsx(PP,{event:n,open:s,onOpenChange:o}),l.jsx(yA,{open:i,onOpenChange:a}),l.jsx(xA,{open:c,onOpenChange:d})]}):l.jsxs("div",{className:"h-screen flex flex-col",children:[l.jsxs("header",{className:"flex flex-col sm:flex-row items-start sm:items-center justify-between gap-3 px-4 sm:px-6 py-5 border-b border-border bg-background/95 backdrop-blur-sm",children:[l.jsxs("div",{children:[l.jsx("h1",{className:"text-2xl sm:text-3xl font-bold text-foreground tracking-tight",children:"Calendar"}),l.jsx("p",{className:"text-sm text-muted-foreground mt-0.5",children:"Your class schedule and lecture notes"})]}),l.jsxs("div",{className:"flex items-center gap-2 w-full sm:w-auto",children:[l.jsxs(K,{variant:"glow",size:"sm",onClick:()=>d(!0),children:[l.jsx(Rt,{className:"h-4 w-4 mr-1"}),"Add Event"]}),l.jsxs(K,{variant:"outline",size:"sm",onClick:()=>a(!0),children:[l.jsx(SC,{className:"h-4 w-4 mr-1"}),"Sync"]}),l.jsx("div",{className:"flex rounded-lg border border-border p-1 ml-auto sm:ml-0",children:p.map(({value:g,icon:v})=>l.jsxs(K,{variant:t===g?"secondary":"ghost",size:"sm",onClick:()=>e(g),className:B("capitalize",t===g&&"shadow-sm"),children:[l.jsx(v,{className:"h-4 w-4 mr-1"}),l.jsx("span",{className:"hidden sm:inline",children:g})]},g))})]})]}),l.jsx("div",{className:"flex-1 overflow-hidden",children:t==="month"?l.jsx(dZ,{onEventClick:h,onDateClick:f}):l.jsx(uZ,{onEventClick:h,onDateClick:f})}),l.jsx(PP,{event:n,open:s,onOpenChange:o}),l.jsx(yA,{open:i,onOpenChange:a}),l.jsx(xA,{open:c,onOpenChange:d})]})}const uh=m.forwardRef(({className:t,...e},r)=>l.jsx("textarea",{className:B("flex min-h-[80px] w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",t),ref:r,...e}));uh.displayName="Textarea";const Pc=["#14b8a6","#f59e0b","#8b5cf6","#ec4899","#6366f1","#22c55e","#ef4444","#3b82f6","#f97316","#a855f7"],ng=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"];function aee({open:t,onOpenChange:e,initialData:r}){const{createClass:n,isCreating:s}=ua(),[o,i]=m.useState(1),[a,c]=m.useState({name:(r==null?void 0:r.name)||"",code:(r==null?void 0:r.code)||"",professor_name:(r==null?void 0:r.professor_name)||"",professor_email:(r==null?void 0:r.professor_email)||"",color:(r==null?void 0:r.color)||Pc[0],meeting_days:(r==null?void 0:r.meeting_days)||[],start_time:(r==null?void 0:r.start_time)||"09:00",end_time:(r==null?void 0:r.end_time)||"10:30",location:(r==null?void 0:r.location)||"",timezone:(r==null?void 0:r.timezone)||Intl.DateTimeFormat().resolvedOptions().timeZone,semester_start:(r==null?void 0:r.semester_start)||pe(new Date,"yyyy-MM-dd"),semester_end:(r==null?void 0:r.semester_end)||pe(new Date(new Date().setMonth(new Date().getMonth()+4)),"yyyy-MM-dd"),section_number:(r==null?void 0:r.section_number)||"",office_hours_day:(r==null?void 0:r.office_hours_day)||"",office_hours_time:(r==null?void 0:r.office_hours_time)||"",office_hours_location:(r==null?void 0:r.office_hours_location)||"",class_website:(r==null?void 0:r.class_website)||"",notes:(r==null?void 0:r.notes)||""}),[d,u]=m.useState({}),h=(w,b)=>{c(k=>({...k,[w]:b})),d[w]&&u(k=>({...k,[w]:""}))},f=w=>{c(b=>({...b,meeting_days:b.meeting_days.includes(w)?b.meeting_days.filter(k=>k!==w):[...b.meeting_days,w].sort()}))},p=()=>{const w={};return a.name.trim()||(w.name="Course name is required"),a.professor_name.trim()||(w.professor_name="Professor name is required"),u(w),Object.keys(w).length===0},g=()=>{const w={};return a.meeting_days.length===0&&(w.meeting_days="Select at least one meeting day"),a.start_time||(w.start_time="Start time is required"),a.end_time||(w.end_time="End time is required"),a.location.trim()||(w.location="Location is required"),u(w),Object.keys(w).length===0},v=()=>{o===1&&p()?i(2):o===2&&g()&&i(3)},y=()=>{o>1&&i(o-1)},x=()=>{n(a,{onSuccess:()=>{e(!1),i(1),c({name:"",code:"",professor_name:"",professor_email:"",color:Pc[0],meeting_days:[],start_time:"09:00",end_time:"10:30",location:"",timezone:Intl.DateTimeFormat().resolvedOptions().timeZone,semester_start:pe(new Date,"yyyy-MM-dd"),semester_end:pe(new Date(new Date().setMonth(new Date().getMonth()+4)),"yyyy-MM-dd"),section_number:"",office_hours_day:"",office_hours_time:"",office_hours_location:"",class_website:"",notes:""})}})};return l.jsx(wn,{open:t,onOpenChange:e,children:l.jsxs(nn,{className:"sm:max-w-[500px]",children:[l.jsx(bn,{children:l.jsx(kn,{children:"Add New Class"})}),l.jsx("div",{className:"flex items-center gap-2 mb-6",children:[1,2,3].map(w=>l.jsxs("div",{className:"flex-1",children:[l.jsx("div",{className:B("h-2 rounded-full transition-colors",w<=o?"bg-primary":"bg-secondary")}),l.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:[w===1&&"Basic Info",w===2&&"Schedule",w===3&&"Optional"]})]},w))}),o===1&&l.jsxs("div",{className:"space-y-4",children:[l.jsxs("div",{className:"space-y-2",children:[l.jsx(de,{htmlFor:"name",children:"Course Name *"}),l.jsx(Ne,{id:"name",placeholder:"e.g., Introduction to Biology",value:a.name,onChange:w=>h("name",w.target.value)}),d.name&&l.jsx("p",{className:"text-sm text-destructive",children:d.name})]}),l.jsxs("div",{className:"space-y-2",children:[l.jsx(de,{htmlFor:"code",children:"Course Code"}),l.jsx(Ne,{id:"code",placeholder:"e.g., BIO 101",value:a.code,onChange:w=>h("code",w.target.value)})]}),l.jsxs("div",{className:"space-y-2",children:[l.jsx(de,{htmlFor:"professor",children:"Professor Name *"}),l.jsx(Ne,{id:"professor",placeholder:"e.g., Dr. Sarah Chen",value:a.professor_name,onChange:w=>h("professor_name",w.target.value)}),d.professor_name&&l.jsx("p",{className:"text-sm text-destructive",children:d.professor_name})]}),l.jsxs("div",{className:"space-y-2",children:[l.jsx(de,{htmlFor:"email",children:"Professor Email"}),l.jsx(Ne,{id:"email",type:"email",placeholder:"professor@university.edu",value:a.professor_email,onChange:w=>h("professor_email",w.target.value)})]}),l.jsxs("div",{className:"space-y-2",children:[l.jsx(de,{children:"Class Color"}),l.jsx("div",{className:"flex gap-2 flex-wrap",children:Pc.map(w=>l.jsx("button",{type:"button",className:B("h-8 w-8 rounded-full transition-all",a.color===w&&"ring-2 ring-offset-2 ring-primary"),style:{backgroundColor:w},onClick:()=>h("color",w)},w))})]})]}),o===2&&l.jsxs("div",{className:"space-y-4",children:[l.jsxs("div",{className:"space-y-2",children:[l.jsx(de,{children:"Meeting Days *"}),l.jsx("div",{className:"flex gap-2 flex-wrap",children:ng.map((w,b)=>l.jsx(ue,{variant:a.meeting_days.includes(b)?"default":"outline",className:"cursor-pointer px-3 py-1.5",onClick:()=>f(b),children:w},w))}),d.meeting_days&&l.jsx("p",{className:"text-sm text-destructive",children:d.meeting_days})]}),l.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[l.jsxs("div",{className:"space-y-2",children:[l.jsx(de,{htmlFor:"start_time",children:"Start Time *"}),l.jsx(Ne,{id:"start_time",type:"time",value:a.start_time,onChange:w=>h("start_time",w.target.value)}),d.start_time&&l.jsx("p",{className:"text-sm text-destructive",children:d.start_time})]}),l.jsxs("div",{className:"space-y-2",children:[l.jsx(de,{htmlFor:"end_time",children:"End Time *"}),l.jsx(Ne,{id:"end_time",type:"time",value:a.end_time,onChange:w=>h("end_time",w.target.value)}),d.end_time&&l.jsx("p",{className:"text-sm text-destructive",children:d.end_time})]})]}),l.jsxs("div",{className:"space-y-2",children:[l.jsx(de,{htmlFor:"location",children:"Location *"}),l.jsx(Ne,{id:"location",placeholder:"e.g., Engineering Hall 201 or 'Online'",value:a.location,onChange:w=>h("location",w.target.value)}),d.location&&l.jsx("p",{className:"text-sm text-destructive",children:d.location})]}),l.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[l.jsxs("div",{className:"space-y-2",children:[l.jsx(de,{htmlFor:"semester_start",children:"Semester Start"}),l.jsx(Ne,{id:"semester_start",type:"date",value:a.semester_start,onChange:w=>h("semester_start",w.target.value)})]}),l.jsxs("div",{className:"space-y-2",children:[l.jsx(de,{htmlFor:"semester_end",children:"Semester End"}),l.jsx(Ne,{id:"semester_end",type:"date",value:a.semester_end,onChange:w=>h("semester_end",w.target.value)})]})]})]}),o===3&&l.jsxs("div",{className:"space-y-4",children:[l.jsxs("div",{className:"space-y-2",children:[l.jsx(de,{htmlFor:"section",children:"Section Number"}),l.jsx(Ne,{id:"section",placeholder:"e.g., 001",value:a.section_number,onChange:w=>h("section_number",w.target.value)})]}),l.jsxs("div",{className:"space-y-2",children:[l.jsx(de,{children:"Office Hours"}),l.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[l.jsx(Ne,{placeholder:"Day",value:a.office_hours_day,onChange:w=>h("office_hours_day",w.target.value)}),l.jsx(Ne,{placeholder:"Time",value:a.office_hours_time,onChange:w=>h("office_hours_time",w.target.value)}),l.jsx(Ne,{placeholder:"Location",value:a.office_hours_location,onChange:w=>h("office_hours_location",w.target.value)})]})]}),l.jsxs("div",{className:"space-y-2",children:[l.jsx(de,{htmlFor:"website",children:"Class Website / LMS Link"}),l.jsx(Ne,{id:"website",type:"url",placeholder:"https://canvas.university.edu/course/...",value:a.class_website,onChange:w=>h("class_website",w.target.value)})]}),l.jsxs("div",{className:"space-y-2",children:[l.jsx(de,{htmlFor:"notes",children:"Notes"}),l.jsx(uh,{id:"notes",placeholder:"Any additional notes about this class...",value:a.notes,onChange:w=>h("notes",w.target.value),rows:3})]})]}),l.jsxs("div",{className:"flex justify-between mt-6",children:[o>1?l.jsx(K,{variant:"outline",onClick:y,children:"Back"}):l.jsx("div",{}),o<3?l.jsx(K,{onClick:v,children:"Next"}):l.jsx(K,{onClick:x,disabled:s,children:s?"Creating...":"Create Class"})]})]})})}var sg="Checkbox",[lee,Kre]=Ft(sg),[cee,Ob]=lee(sg);function dee(t){const{__scopeCheckbox:e,checked:r,children:n,defaultChecked:s,disabled:o,form:i,name:a,onCheckedChange:c,required:d,value:u="on",internal_do_not_use_render:h}=t,[f,p]=Wn({prop:r,defaultProp:s??!1,onChange:c,caller:sg}),[g,v]=m.useState(null),[y,x]=m.useState(null),w=m.useRef(!1),b=g?!!i||!!g.closest("form"):!0,k={checked:f,disabled:o,setChecked:p,control:g,setControl:v,name:a,form:i,value:u,hasConsumerStoppedPropagationRef:w,required:d,defaultChecked:xi(s)?!1:s,isFormControl:b,bubbleInput:y,setBubbleInput:x};return l.jsx(cee,{scope:e,...k,children:uee(h)?h(k):n})}var wA="CheckboxTrigger",bA=m.forwardRef(({__scopeCheckbox:t,onKeyDown:e,onClick:r,...n},s)=>{const{control:o,value:i,disabled:a,checked:c,required:d,setControl:u,setChecked:h,hasConsumerStoppedPropagationRef:f,isFormControl:p,bubbleInput:g}=Ob(wA,t),v=we(s,u),y=m.useRef(c);return m.useEffect(()=>{const x=o==null?void 0:o.form;if(x){const w=()=>h(y.current);return x.addEventListener("reset",w),()=>x.removeEventListener("reset",w)}},[o,h]),l.jsx(se.button,{type:"button",role:"checkbox","aria-checked":xi(c)?"mixed":c,"aria-required":d,"data-state":jA(c),"data-disabled":a?"":void 0,disabled:a,value:i,...n,ref:v,onKeyDown:Q(e,x=>{x.key==="Enter"&&x.preventDefault()}),onClick:Q(r,x=>{h(w=>xi(w)?!0:!w),g&&p&&(f.current=x.isPropagationStopped(),f.current||x.stopPropagation())})})});bA.displayName=wA;var Pb=m.forwardRef((t,e)=>{const{__scopeCheckbox:r,name:n,checked:s,defaultChecked:o,required:i,disabled:a,value:c,onCheckedChange:d,form:u,...h}=t;return l.jsx(dee,{__scopeCheckbox:r,checked:s,defaultChecked:o,disabled:a,required:i,onCheckedChange:d,name:n,form:u,value:c,internal_do_not_use_render:({isFormControl:f})=>l.jsxs(l.Fragment,{children:[l.jsx(bA,{...h,ref:e,__scopeCheckbox:r}),f&&l.jsx(CA,{__scopeCheckbox:r})]})})});Pb.displayName=sg;var kA="CheckboxIndicator",SA=m.forwardRef((t,e)=>{const{__scopeCheckbox:r,forceMount:n,...s}=t,o=Ob(kA,r);return l.jsx(er,{present:n||xi(o.checked)||o.checked===!0,children:l.jsx(se.span,{"data-state":jA(o.checked),"data-disabled":o.disabled?"":void 0,...s,ref:e,style:{pointerEvents:"none",...t.style}})})});SA.displayName=kA;var NA="CheckboxBubbleInput",CA=m.forwardRef(({__scopeCheckbox:t,...e},r)=>{const{control:n,hasConsumerStoppedPropagationRef:s,checked:o,defaultChecked:i,required:a,disabled:c,name:d,value:u,form:h,bubbleInput:f,setBubbleInput:p}=Ob(NA,t),g=we(r,p),v=tu(o),y=Jd(n);m.useEffect(()=>{const w=f;if(!w)return;const b=window.HTMLInputElement.prototype,S=Object.getOwnPropertyDescriptor(b,"checked").set,C=!s.current;if(v!==o&&S){const N=new Event("click",{bubbles:C});w.indeterminate=xi(o),S.call(w,xi(o)?!1:o),w.dispatchEvent(N)}},[f,v,o,s]);const x=m.useRef(xi(o)?!1:o);return l.jsx(se.input,{type:"checkbox","aria-hidden":!0,defaultChecked:i??x.current,required:a,disabled:c,name:d,value:u,form:h,...e,tabIndex:-1,ref:g,style:{...e.style,...y,position:"absolute",pointerEvents:"none",opacity:0,margin:0,transform:"translateX(-100%)"}})});CA.displayName=NA;function uee(t){return typeof t=="function"}function xi(t){return t==="indeterminate"}function jA(t){return xi(t)?"indeterminate":t?"checked":"unchecked"}const og=m.forwardRef(({className:t,...e},r)=>l.jsx(Pb,{ref:r,className:B("peer h-4 w-4 shrink-0 rounded-sm border border-primary ring-offset-background data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",t),...e,children:l.jsx(SA,{className:B("flex items-center justify-center text-current"),children:l.jsx(Qi,{className:"h-4 w-4"})})}));og.displayName=Pb.displayName;function hee(){const[t,e]=m.useState(!1),[r,n]=m.useState(null),{toast:s}=gs(),o=async d=>{const u=await d.text();if(u.includes("%PDF-")){const h=u.match(/stream[\r\n]+([\s\S]*?)[\r\n]+endstream/g);if(h){const f=[];for(const p of h){const g=p.replace(/[^\x20-\x7E\r\n]/g," ").trim();g.length>50&&f.push(g)}if(f.length>0)return f.join(` `)}return u.replace(/[^\x20-\x7E\r\n]/g," ").replace(/\s+/g," ").slice(0,5e4)}return u};return{isParsing:t,extractedData:r,parseSyllabus:async d=>{e(!0),n(null);try{const u=await o(d);if(!u||u.length<100)return s({title:"Could not read PDF",description:"The PDF appears to be scanned or empty. Please try a text-based PDF or enter information manually.",variant:"destructive"}),null;const{data:h,error:f}=await q.functions.invoke("parse-syllabus",{body:{syllabusText:u.slice(0,3e4),fileName:d.name}});if(f)throw f;if(!(h!=null&&h.success)||!(h!=null&&h.data))throw new Error((h==null?void 0:h.error)||"Failed to extract syllabus information");const p=h.data;return n(p),s({title:"Syllabus parsed",description:"Review the extracted information below."}),p}catch(u){return console.error("Error parsing syllabus:",u),s({title:"Failed to parse syllabus",description:u instanceof Error?u.message:"An error occurred",variant:"destructive"}),null}finally{e(!1)}},uploadSyllabus:async(d,u)=>{try{const{data:{user:h}}=await q.auth.getUser();if(!h)throw new Error("Not authenticated");const f=`${h.id}/${u}/${d.name}`,{error:p}=await q.storage.from("syllabi").upload(f,d,{upsert:!0});if(p)throw p;const{data:{publicUrl:g}}=q.storage.from("syllabi").getPublicUrl(f);return g}catch(h){return console.error("Error uploading syllabus:",h),null}},clearExtraction:()=>{n(null)}}}function fee({open:t,onOpenChange:e}){var A,I,V;const r=m.useRef(null),{isParsing:n,extractedData:s,parseSyllabus:o,clearExtraction:i}=hee(),{createClass:a,isCreating:c}=ua(),{toast:d}=gs(),[u,h]=m.useState("upload"),[f,p]=m.useState(null),[g,v]=m.useState(null),[y,x]=m.useState(new Set),[w,b]=m.useState(Pc[0]),k=m.useCallback(async L=>{var M;if(!L.type.includes("pdf")){d({title:"Invalid file type",description:"Please upload a PDF file.",variant:"destructive"});return}p(L);const U=await o(L);U&&(v(U),x(new Set(((M=U.deadlines)==null?void 0:M.map((D,H)=>H))||[])),h("review"))},[o,d]),S=m.useCallback(L=>{L.preventDefault();const U=L.dataTransfer.files[0];U&&k(U)},[k]),C=L=>{L.preventDefault()},N=(L,U)=>{v(M=>M?{...M,[L]:U}:null)},E=L=>{if(!g)return;const U=g.meetingDays.includes(L)?g.meetingDays.filter(M=>M!==L):[...g.meetingDays,L].sort();N("meetingDays",U)},j=L=>{x(U=>{const M=new Set(U);return M.has(L)?M.delete(L):M.add(L),M})},_=async()=>{var U,M,D,H,ne,$;if(!g)return;if(!((U=g.courseName)!=null&&U.trim())){d({title:"Course name is required",variant:"destructive"});return}if(!((M=g.professorName)!=null&&M.trim())){d({title:"Professor name is required",variant:"destructive"});return}if(!((D=g.location)!=null&&D.trim())){d({title:"Location is required",variant:"destructive"});return}if(g.meetingDays.length===0){d({title:"At least one meeting day is required",variant:"destructive"});return}if(!g.startTime||!g.endTime){d({title:"Meeting times are required",variant:"destructive"});return}const L={name:g.courseName,code:g.courseCode||"",professor_name:g.professorName,professor_email:g.professorEmail||"",color:w,meeting_days:g.meetingDays,start_time:g.startTime,end_time:g.endTime,location:g.location,timezone:Intl.DateTimeFormat().resolvedOptions().timeZone,semester_start:g.semesterStart||pe(new Date,"yyyy-MM-dd"),semester_end:g.semesterEnd||pe(new Date(new Date().setMonth(new Date().getMonth()+4)),"yyyy-MM-dd"),section_number:"",office_hours_day:((H=g.officeHours)==null?void 0:H.day)||"",office_hours_time:((ne=g.officeHours)==null?void 0:ne.time)||"",office_hours_location:(($=g.officeHours)==null?void 0:$.location)||"",class_website:"",notes:""};a(L,{onSuccess:async G=>{var O;const{data:{user:J}}=await q.auth.getUser();if(J&&((O=g.deadlines)==null?void 0:O.length)>0){const z=g.deadlines.filter((F,te)=>y.has(te)).map(F=>({class_id:G.id,user_id:J.id,title:F.title,description:F.description,deadline_type:F.type,due_date:F.dueDate,weight:F.weight,status:"upcoming",source:"syllabus"}));z.length>0&&await q.from("deadlines").insert(z)}d({title:"Class created from syllabus",description:`${L.name} has been added with ${y.size} deadlines.`}),P()}})},P=()=>{h("upload"),p(null),v(null),x(new Set),b(Pc[0]),i(),e(!1)},T=({level:L})=>{const U={high:"bg-green-500/10 text-green-500",medium:"bg-yellow-500/10 text-yellow-500",low:"bg-red-500/10 text-red-500"};return l.jsxs(ue,{variant:"outline",className:B("text-xs",U[L]),children:[L==="low"&&l.jsx(zd,{className:"h-3 w-3 mr-1"}),L," confidence"]})};return l.jsx(wn,{open:t,onOpenChange:P,children:l.jsxs(nn,{className:"sm:max-w-[600px] max-h-[85vh]",children:[l.jsx(bn,{children:l.jsxs(kn,{children:[u==="upload"&&"Import Syllabus",u==="review"&&"Review Extracted Information"]})}),u==="upload"&&l.jsxs("div",{className:"space-y-4",children:[l.jsx("div",{className:B("border-2 border-dashed rounded-lg p-8 text-center transition-colors",n?"border-primary bg-primary/5":"border-border hover:border-primary/50"),onDrop:S,onDragOver:C,children:n?l.jsxs("div",{className:"flex flex-col items-center gap-3",children:[l.jsx(Bt,{className:"h-10 w-10 text-primary animate-spin"}),l.jsx("p",{className:"text-sm text-muted-foreground",children:"Analyzing syllabus with AI..."})]}):l.jsxs(l.Fragment,{children:[l.jsx(CC,{className:"h-10 w-10 text-muted-foreground mx-auto mb-3"}),l.jsx("p",{className:"font-medium mb-1",children:"Drop your syllabus PDF here"}),l.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:"or click to browse"}),l.jsx(K,{variant:"outline",onClick:()=>{var L;return(L=r.current)==null?void 0:L.click()},children:"Choose File"}),l.jsx("input",{ref:r,type:"file",accept:".pdf",className:"hidden",onChange:L=>{var M;const U=(M=L.target.files)==null?void 0:M[0];U&&k(U)}})]})}),f&&!n&&l.jsxs("div",{className:"flex items-center gap-2 p-3 bg-secondary rounded-lg",children:[l.jsx(zt,{className:"h-5 w-5 text-muted-foreground"}),l.jsx("span",{className:"flex-1 text-sm truncate",children:f.name})]})]}),u==="review"&&g&&l.jsx(Pn,{className:"max-h-[60vh] pr-4",children:l.jsxs("div",{className:"space-y-6",children:[l.jsxs("div",{className:"space-y-4",children:[l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx("h3",{className:"font-semibold",children:"Course Information"}),l.jsx(T,{level:((A=g.confidence)==null?void 0:A.courseName)||"medium"})]}),l.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[l.jsxs("div",{className:"space-y-2",children:[l.jsx(de,{children:"Course Name *"}),l.jsx(Ne,{value:g.courseName||"",onChange:L=>N("courseName",L.target.value),className:g.courseName?"":"border-destructive"})]}),l.jsxs("div",{className:"space-y-2",children:[l.jsx(de,{children:"Course Code"}),l.jsx(Ne,{value:g.courseCode||"",onChange:L=>N("courseCode",L.target.value)})]})]}),l.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[l.jsxs("div",{className:"space-y-2",children:[l.jsx(de,{children:"Professor *"}),l.jsx(Ne,{value:g.professorName||"",onChange:L=>N("professorName",L.target.value),className:g.professorName?"":"border-destructive"})]}),l.jsxs("div",{className:"space-y-2",children:[l.jsx(de,{children:"Email"}),l.jsx(Ne,{value:g.professorEmail||"",onChange:L=>N("professorEmail",L.target.value)})]})]}),l.jsxs("div",{className:"space-y-2",children:[l.jsx(de,{children:"Class Color"}),l.jsx("div",{className:"flex gap-2 flex-wrap",children:Pc.map(L=>l.jsx("button",{type:"button",className:B("h-7 w-7 rounded-full transition-all",w===L&&"ring-2 ring-offset-2 ring-primary"),style:{backgroundColor:L},onClick:()=>b(L)},L))})]})]}),l.jsxs("div",{className:"space-y-4",children:[l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx("h3",{className:"font-semibold",children:"Schedule"}),l.jsx(T,{level:((I=g.confidence)==null?void 0:I.schedule)||"medium"})]}),l.jsxs("div",{className:"space-y-2",children:[l.jsx(de,{children:"Meeting Days *"}),l.jsx("div",{className:"flex gap-2 flex-wrap",children:ng.map((L,U)=>l.jsx(ue,{variant:g.meetingDays.includes(U)?"default":"outline",className:"cursor-pointer px-3 py-1.5",onClick:()=>E(U),children:L},L))})]}),l.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[l.jsxs("div",{className:"space-y-2",children:[l.jsx(de,{children:"Start Time *"}),l.jsx(Ne,{type:"time",value:g.startTime||"",onChange:L=>N("startTime",L.target.value),className:g.startTime?"":"border-destructive"})]}),l.jsxs("div",{className:"space-y-2",children:[l.jsx(de,{children:"End Time *"}),l.jsx(Ne,{type:"time",value:g.endTime||"",onChange:L=>N("endTime",L.target.value),className:g.endTime?"":"border-destructive"})]}),l.jsxs("div",{className:"space-y-2",children:[l.jsx(de,{children:"Location *"}),l.jsx(Ne,{value:g.location||"",onChange:L=>N("location",L.target.value),className:g.location?"":"border-destructive"})]})]}),l.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[l.jsxs("div",{className:"space-y-2",children:[l.jsx(de,{children:"Semester Start"}),l.jsx(Ne,{type:"date",value:g.semesterStart||"",onChange:L=>N("semesterStart",L.target.value)})]}),l.jsxs("div",{className:"space-y-2",children:[l.jsx(de,{children:"Semester End"}),l.jsx(Ne,{type:"date",value:g.semesterEnd||"",onChange:L=>N("semesterEnd",L.target.value)})]})]})]}),g.deadlines&&g.deadlines.length>0&&l.jsxs("div",{className:"space-y-4",children:[l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("h3",{className:"font-semibold",children:["Extracted Deadlines (",y.size," selected)"]}),l.jsx(T,{level:((V=g.confidence)==null?void 0:V.deadlines)||"medium"})]}),l.jsx("div",{className:"space-y-2",children:g.deadlines.map((L,U)=>l.jsx(fe,{className:B("cursor-pointer transition-colors",y.has(U)?"border-primary":"opacity-60"),onClick:()=>j(U),children:l.jsxs(xe,{className:"p-3 flex items-start gap-3",children:[l.jsx(og,{checked:y.has(U),className:"mt-0.5"}),l.jsxs("div",{className:"flex-1 min-w-0",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("span",{className:"font-medium text-sm",children:L.title}),l.jsx(ue,{variant:"outline",className:"text-xs",children:L.type})]}),l.jsxs("p",{className:"text-xs text-muted-foreground mt-0.5",children:["Due: ",pe(new Date(L.dueDate),"MMM d, yyyy"),L.weight&&` • ${L.weight}%`]})]})]})},U))})]})]})}),l.jsx("div",{className:"flex justify-between mt-6 pt-4 border-t",children:u==="review"?l.jsxs(l.Fragment,{children:[l.jsx(K,{variant:"outline",onClick:()=>h("upload"),children:"Back"}),l.jsx(K,{onClick:_,disabled:c,children:c?l.jsxs(l.Fragment,{children:[l.jsx(Bt,{className:"h-4 w-4 mr-2 animate-spin"}),"Creating..."]}):"Create Class"})]}):l.jsx(K,{variant:"outline",onClick:P,className:"ml-auto",children:"Cancel"})})]})})}var Ab=["Enter"," "],pee=["ArrowDown","PageUp","Home"],EA=["ArrowUp","PageDown","End"],mee=[...pee,...EA],gee={ltr:[...Ab,"ArrowRight"],rtl:[...Ab,"ArrowLeft"]},vee={ltr:["ArrowLeft"],rtl:["ArrowRight"]},hh="Menu",[fh,yee,xee]=Ld(hh),[Ma,_A]=Ft(hh,[xee,Pl,nc]),ig=Pl(),TA=nc(),[wee,Oa]=Ma(hh),[bee,ph]=Ma(hh),RA=t=>{const{__scopeMenu:e,open:r=!1,children:n,dir:s,onOpenChange:o,modal:i=!0}=t,a=ig(e),[c,d]=m.useState(null),u=m.useRef(!1),h=at(o),f=ha(s);return m.useEffect(()=>{const p=()=>{u.current=!0,document.addEventListener("pointerdown",g,{capture:!0,once:!0}),document.addEventListener("pointermove",g,{capture:!0,once:!0})},g=()=>u.current=!1;return document.addEventListener("keydown",p,{capture:!0}),()=>{document.removeEventListener("keydown",p,{capture:!0}),document.removeEventListener("pointerdown",g,{capture:!0}),document.removeEventListener("pointermove",g,{capture:!0})}},[]),l.jsx(yj,{...a,children:l.jsx(wee,{scope:e,open:r,onOpenChange:h,content:c,onContentChange:d,children:l.jsx(bee,{scope:e,onClose:m.useCallback(()=>h(!1),[h]),isUsingKeyboardRef:u,dir:f,modal:i,children:n})})})};RA.displayName=hh;var kee="MenuAnchor",Ib=m.forwardRef((t,e)=>{const{__scopeMenu:r,...n}=t,s=ig(r);return l.jsx(px,{...s,...n,ref:e})});Ib.displayName=kee;var Db="MenuPortal",[See,MA]=Ma(Db,{forceMount:void 0}),OA=t=>{const{__scopeMenu:e,forceMount:r,children:n,container:s}=t,o=Oa(Db,e);return l.jsx(See,{scope:e,forceMount:r,children:l.jsx(er,{present:r||o.open,children:l.jsx($d,{asChild:!0,container:s,children:n})})})};OA.displayName=Db;var An="MenuContent",[Nee,Lb]=Ma(An),PA=m.forwardRef((t,e)=>{const r=MA(An,t.__scopeMenu),{forceMount:n=r.forceMount,...s}=t,o=Oa(An,t.__scopeMenu),i=ph(An,t.__scopeMenu);return l.jsx(fh.Provider,{scope:t.__scopeMenu,children:l.jsx(er,{present:n||o.open,children:l.jsx(fh.Slot,{scope:t.__scopeMenu,children:i.modal?l.jsx(Cee,{...s,ref:e}):l.jsx(jee,{...s,ref:e})})})})}),Cee=m.forwardRef((t,e)=>{const r=Oa(An,t.__scopeMenu),n=m.useRef(null),s=we(e,n);return m.useEffect(()=>{const o=n.current;if(o)return Vx(o)},[]),l.jsx($b,{...t,ref:s,trapFocus:r.open,disableOutsidePointerEvents:r.open,disableOutsideScroll:!0,onFocusOutside:Q(t.onFocusOutside,o=>o.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>r.onOpenChange(!1)})}),jee=m.forwardRef((t,e)=>{const r=Oa(An,t.__scopeMenu);return l.jsx($b,{...t,ref:e,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>r.onOpenChange(!1)})}),Eee=Ji("MenuContent.ScrollLock"),$b=m.forwardRef((t,e)=>{const{__scopeMenu:r,loop:n=!1,trapFocus:s,onOpenAutoFocus:o,onCloseAutoFocus:i,disableOutsidePointerEvents:a,onEntryFocus:c,onEscapeKeyDown:d,onPointerDownOutside:u,onFocusOutside:h,onInteractOutside:f,onDismiss:p,disableOutsideScroll:g,...v}=t,y=Oa(An,r),x=ph(An,r),w=ig(r),b=TA(r),k=yee(r),[S,C]=m.useState(null),N=m.useRef(null),E=we(e,N,y.onContentChange),j=m.useRef(0),_=m.useRef(""),P=m.useRef(0),T=m.useRef(null),A=m.useRef("right"),I=m.useRef(0),V=g?Np:m.Fragment,L=g?{as:Eee,allowPinchZoom:!0}:void 0,U=D=>{var F,te;const H=_.current+D,ne=k().filter(ee=>!ee.disabled),$=document.activeElement,G=(F=ne.find(ee=>ee.ref.current===$))==null?void 0:F.textValue,J=ne.map(ee=>ee.textValue),O=Fee(J,H,G),z=(te=ne.find(ee=>ee.textValue===O))==null?void 0:te.ref.current;(function ee(Z){_.current=Z,window.clearTimeout(j.current),Z!==""&&(j.current=window.setTimeout(()=>ee(""),1e3))})(H),z&&setTimeout(()=>z.focus())};m.useEffect(()=>()=>window.clearTimeout(j.current),[]),Lx();const M=m.useCallback(D=>{var ne,$;return A.current===((ne=T.current)==null?void 0:ne.side)&&Bee(D,($=T.current)==null?void 0:$.area)},[]);return l.jsx(Nee,{scope:r,searchRef:_,onItemEnter:m.useCallback(D=>{M(D)&&D.preventDefault()},[M]),onItemLeave:m.useCallback(D=>{var H;M(D)||((H=N.current)==null||H.focus(),C(null))},[M]),onTriggerLeave:m.useCallback(D=>{M(D)&&D.preventDefault()},[M]),pointerGraceTimerRef:P,onPointerGraceIntentChange:m.useCallback(D=>{T.current=D},[]),children:l.jsx(V,{...L,children:l.jsx(yp,{asChild:!0,trapped:s,onMountAutoFocus:Q(o,D=>{var H;D.preventDefault(),(H=N.current)==null||H.focus({preventScroll:!0})}),onUnmountAutoFocus:i,children:l.jsx(kl,{asChild:!0,disableOutsidePointerEvents:a,onEscapeKeyDown:d,onPointerDownOutside:u,onFocusOutside:h,onInteractOutside:f,onDismiss:p,children:l.jsx(_w,{asChild:!0,...b,dir:x.dir,orientation:"vertical",loop:n,currentTabStopId:S,onCurrentTabStopIdChange:C,onEntryFocus:Q(c,D=>{x.isUsingKeyboardRef.current||D.preventDefault()}),preventScrollOnEntryFocus:!0,children:l.jsx(mx,{role:"menu","aria-orientation":"vertical","data-state":JA(y.open),"data-radix-menu-content":"",dir:x.dir,...w,...v,ref:E,style:{outline:"none",...v.style},onKeyDown:Q(v.onKeyDown,D=>{const ne=D.target.closest("[data-radix-menu-content]")===D.currentTarget,$=D.ctrlKey||D.altKey||D.metaKey,G=D.key.length===1;ne&&(D.key==="Tab"&&D.preventDefault(),!&G&&U(D.key));const J=N.current;if(D.target!==J||!mee.includes(D.key))return;D.preventDefault();const z=k().filter(F=>!F.disabled).map(F=>F.ref.current);EA.includes(D.key)&&z.reverse(),Lee(z)}),onBlur:Q(t.onBlur,D=>{D.currentTarget.contains(D.target)||(window.clearTimeout(j.current),_.current="")}),onPointerMove:Q(t.onPointerMove,gh(D=>{const H=D.target,ne=I.current!==D.clientX;if(D.currentTarget.contains(H)&&ne){const $=D.clientX>I.current?"right":"left";A.current=$,I.current=D.clientX}}))})})})})})})});PA.displayName=An;var _ee="MenuGroup",Fb=m.forwardRef((t,e)=>{const{__scopeMenu:r,...n}=t;return l.jsx(se.div,{role:"group",...n,ref:e})});Fb.displayName=_ee;var Tee="MenuLabel",AA=m.forwardRef((t,e)=>{const{__scopeMenu:r,...n}=t;return l.jsx(se.div,{...n,ref:e})});AA.displayName=Tee;var ag="MenuItem",IA="menu.itemSelect",lg=m.forwardRef((t,e)=>{const{disabled:r=!1,onSelect:n,...s}=t,o=m.useRef(null),i=ph(ag,t.__scopeMenu),a=Lb(ag,t.__scopeMenu),c=we(e,o),d=m.useRef(!1),u=()=>{const h=o.current;if(!r&&h){const f=new CustomEvent(IA,{bubbles:!0,cancelable:!0});h.addEventListener(IA,p=>n==null?void 0:n(p),{once:!0}),Ay(h,f),f.defaultPrevented?d.current=!1:i.onClose()}};return l.jsx(DA,{...s,ref:c,disabled:r,onClick:Q(t.onClick,u),onPointerDown:h=>{var f;(f=t.onPointerDown)==null||f.call(t,h),d.current=!0},onPointerUp:Q(t.onPointerUp,h=>{var f;d.current||(f=h.currentTarget)==null||f.click()}),onKeyDown:Q(t.onKeyDown,h=>{const f=a.searchRef.current!=="";r||f&&h.key===" "||Ab.includes(h.key)&&(h.currentTarget.click(),h.preventDefault())})})});lg.displayName=ag;var DA=m.forwardRef((t,e)=>{const{__scopeMenu:r,disabled:n=!1,textValue:s,...o}=t,i=Lb(ag,r),a=TA(r),c=m.useRef(null),d=we(e,c),[u,h]=m.useState(!1),[f,p]=m.useState("");return m.useEffect(()=>{const g=c.current;g&&p((g.textContent??"").trim())},[o.children]),l.jsx(fh.ItemSlot,{scope:r,disabled:n,textValue:s??f,children:l.jsx(Tw,{asChild:!0,...a,focusable:!n,children:l.jsx(se.div,{role:"menuitem","data-highlighted":u?"":void 0,"aria-disabled":n||void 0,"data-disabled":n?"":void 0,...o,ref:d,onPointerMove:Q(t.onPointerMove,gh(g=>{n?i.onItemLeave(g):(i.onItemEnter(g),g.defaultPrevented||g.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:Q(t.onPointerLeave,gh(g=>i.onItemLeave(g))),onFocus:Q(t.onFocus,()=>h(!0)),onBlur:Q(t.onBlur,()=>h(!1))})})})}),Ree="MenuCheckboxItem",LA=m.forwardRef((t,e)=>{const{checked:r=!1,onCheckedChange:n,...s}=t;return l.jsx(UA,{scope:t.__scopeMenu,checked:r,children:l.jsx(lg,{role:"menuitemcheckbox","aria-checked":cg(r)?"mixed":r,...s,ref:e,"data-state":Bb(r),onSelect:Q(s.onSelect,()=>n==null?void 0:n(cg(r)?!0:!r),{checkForDefaultPrevented:!1})})})});LA.displayName=Ree;var $A="MenuRadioGroup",[Mee,Oee]=Ma($A,{value:void 0,onValueChange:()=>{}}),FA=m.forwardRef((t,e)=>{const{value:r,onValueChange:n,...s}=t,o=at(n);return l.jsx(Mee,{scope:t.__scopeMenu,value:r,onValueChange:o,children:l.jsx(Fb,{...s,ref:e})})});FA.displayName=$A;var zA="MenuRadioItem",BA=m.forwardRef((t,e)=>{const{value:r,...n}=t,s=Oee(zA,t.__scopeMenu),o=r===s.value;return l.jsx(UA,{scope:t.__scopeMenu,checked:o,children:l.jsx(lg,{role:"menuitemradio","aria-checked":o,...n,ref:e,"data-state":Bb(o),onSelect:Q(n.onSelect,()=>{var i;return(i=s.onValueChange)==null?void 0:i.call(s,r)},{checkForDefaultPrevented:!1})})})});BA.displayName=zA;var zb="MenuItemIndicator",[UA,Pee]=Ma(zb,{checked:!1}),VA=m.forwardRef((t,e)=>{const{__scopeMenu:r,forceMount:n,...s}=t,o=Pee(zb,r);return l.jsx(er,{present:n||cg(o.checked)||o.checked===!0,children:l.jsx(se.span,{...s,ref:e,"data-state":Bb(o.checked)})})});VA.displayName=zb;var Aee="MenuSeparator",WA=m.forwardRef((t,e)=>{const{__scopeMenu:r,...n}=t;return l.jsx(se.div,{role:"separator","aria-orientation":"horizontal",...n,ref:e})});WA.displayName=Aee;var Iee="MenuArrow",HA=m.forwardRef((t,e)=>{const{__scopeMenu:r,...n}=t,s=ig(r);return l.jsx(gx,{...s,...n,ref:e})});HA.displayName=Iee;var Dee="MenuSub",[Gre,qA]=Ma(Dee),mh="MenuSubTrigger",KA=m.forwardRef((t,e)=>{const r=Oa(mh,t.__scopeMenu),n=ph(mh,t.__scopeMenu),s=qA(mh,t.__scopeMenu),o=Lb(mh,t.__scopeMenu),i=m.useRef(null),{pointerGraceTimerRef:a,onPointerGraceIntentChange:c}=o,d={__scopeMenu:t.__scopeMenu},u=m.useCallback(()=>{i.current&&window.clearTimeout(i.current),i.current=null},[]);return m.useEffect(()=>u,[u]),m.useEffect(()=>{const h=a.current;return()=>{window.clearTimeout(h),c(null)}},[a,c]),l.jsx(Ib,{asChild:!0,...d,children:l.jsx(DA,{id:s.triggerId,"aria-haspopup":"menu","aria-expanded":r.open,"aria-controls":s.contentId,"data-state":JA(r.open),...t,ref:Ks(e,s.onTriggerChange),onClick:h=>{var f;(f=t.onClick)==null||f.call(t,h),!(t.disabled||h.defaultPrevented)&&(h.currentTarget.focus(),r.open||r.onOpenChange(!0))},onPointerMove:Q(t.onPointerMove,gh(h=>{o.onItemEnter(h),!h.defaultPrevented&&!t.disabled&&!r.open&&!i.current&&(o.onPointerGraceIntentChange(null),i.current=window.setTimeout(()=>{r.onOpenChange(!0),u()},100))})),onPointerLeave:Q(t.onPointerLeave,gh(h=>{var p,g;u();const f=(p=r.content)==null?void 0:p.getBoundingClientRect();if(f){const v=(g=r.content)==null?void 0:g.dataset.side,y=v==="right",x=y?-5:5,w=f[y?"left":"right"],b=f[y?"right":"left"];o.onPointerGraceIntentChange({area:[{x:h.clientX+x,y:h.clientY},{x:w,y:f.top},{x:b,y:f.top},{x:b,y:f.bottom},{x:w,y:f.bottom}],side:v}),window.clearTimeout(a.current),a.current=window.setTimeout(()=>o.onPointerGraceIntentChange(null),300)}else{if(o.onTriggerLeave(h),h.defaultPrevented)return;o.onPointerGraceIntentChange(null)}})),onKeyDown:Q(t.onKeyDown,h=>{var p;const f=o.searchRef.current!=="";t.disabled||f&&h.key===" "||gee[n.dir].includes(h.key)&&(r.onOpenChange(!0),(p=r.content)==null||p.focus(),h.preventDefault())})})})});KA.displayName=mh;var GA="MenuSubContent",YA=m.forwardRef((t,e)=>{const r=MA(An,t.__scopeMenu),{forceMount:n=r.forceMount,...s}=t,o=Oa(An,t.__scopeMenu),i=ph(An,t.__scopeMenu),a=qA(GA,t.__scopeMenu),c=m.useRef(null),d=we(e,c);return l.jsx(fh.Provider,{scope:t.__scopeMenu,children:l.jsx(er,{present:n||o.open,children:l.jsx(fh.Slot,{scope:t.__scopeMenu,children:l.jsx($b,{id:a.contentId,"aria-labelledby":a.triggerId,...s,ref:d,align:"start",side:i.dir==="rtl"?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:u=>{var h;i.isUsingKeyboardRef.current&&((h=c.current)==null||h.focus()),u.preventDefault()},onCloseAutoFocus:u=>u.preventDefault(),onFocusOutside:Q(t.onFocusOutside,u=>{u.target!==a.trigger&&o.onOpenChange(!1)}),onEscapeKeyDown:Q(t.onEscapeKeyDown,u=>{i.onClose(),u.preventDefault()}),onKeyDown:Q(t.onKeyDown,u=>{var p;const h=u.currentTarget.contains(u.target),f=vee[i.dir].includes(u.key);h&&f&&(o.onOpenChange(!1),(p=a.trigger)==null||p.focus(),u.preventDefault())})})})})})});YA.displayName=GA;function JA(t){return t?"open":"closed"}function cg(t){return t==="indeterminate"}function Bb(t){return cg(t)?"indeterminate":t?"checked":"unchecked"}function Lee(t){const e=document.activeElement;for(const r of t)if(r===e||(r.focus(),document.activeElement!==e))return}function $ee(t,e){return t.map((r,n)=>t[(e+n)%t.length])}function Fee(t,e,r){const s=e.length>1&&Array.from(e).every(d=>d===e[0])?e[0]:e,o=r?t.indexOf(r):-1;let i=$ee(t,Math.max(o,0));s.length===1&&(i=i.filter(d=>d!==r));const c=i.find(d=>d.toLowerCase().startsWith(s.toLowerCase()));return c!==r?c:void 0}function zee(t,e){const{x:r,y:n}=t;let s=!1;for(let o=0,i=e.length-1;on!=f>n&&r<(h-d)*(n-u)/(f-u)+d&&(s=!s)}return s}function Bee(t,e){if(!e)return!1;const r={x:t.clientX,y:t.clientY};return zee(r,e)}function gh(t){return e=>e.pointerType==="mouse"?t(e):void 0}var Uee=RA,Vee=Ib,Wee=OA,Hee=PA,qee=Fb,Kee=AA,Gee=lg,Yee=LA,Jee=FA,Qee=BA,Xee=VA,Zee=WA,ete=HA,tte=KA,rte=YA,dg="DropdownMenu",[nte,Yre]=Ft(dg,[_A]),Tr=_A(),[ste,QA]=nte(dg),XA=t=>{const{__scopeDropdownMenu:e,children:r,dir:n,open:s,defaultOpen:o,onOpenChange:i,modal:a=!0}=t,c=Tr(e),d=m.useRef(null),[u,h]=Wn({prop:s,defaultProp:o??!1,onChange:i,caller:dg});return l.jsx(ste,{scope:e,triggerId:hr(),triggerRef:d,contentId:hr(),open:u,onOpenChange:h,onOpenToggle:m.useCallback(()=>h(f=>!f),[h]),modal:a,children:l.jsx(Uee,{...c,open:u,onOpenChange:h,dir:n,modal:a,children:r})})};XA.displayName=dg;var ZA="DropdownMenuTrigger",eI=m.forwardRef((t,e)=>{const{__scopeDropdownMenu:r,disabled:n=!1,...s}=t,o=QA(ZA,r),i=Tr(r);return l.jsx(Vee,{asChild:!0,...i,children:l.jsx(se.button,{type:"button",id:o.triggerId,"aria-haspopup":"menu","aria-expanded":o.open,"aria-controls":o.open?o.contentId:void 0,"data-state":o.open?"open":"closed","data-disabled":n?"":void 0,disabled:n,...s,ref:Ks(e,o.triggerRef),onPointerDown:Q(t.onPointerDown,a=>{!n&&a.button===0&&a.ctrlKey===!1&&(o.onOpenToggle(),o.open||a.preventDefault())}),onKeyDown:Q(t.onKeyDown,a=>{n||(["Enter"," "].includes(a.key)&&o.onOpenToggle(),a.key==="ArrowDown"&&o.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(a.key)&&a.preventDefault())})})})});eI.displayName=ZA;var ote="DropdownMenuPortal",tI=t=>{const{__scopeDropdownMenu:e,...r}=t,n=Tr(e);return l.jsx(Wee,{...n,...r})};tI.displayName=ote;var rI="DropdownMenuContent",nI=m.forwardRef((t,e)=>{const{__scopeDropdownMenu:r,...n}=t,s=QA(rI,r),o=Tr(r),i=m.useRef(!1);return l.jsx(Hee,{id:s.contentId,"aria-labelledby":s.triggerId,...o,...n,ref:e,onCloseAutoFocus:Q(t.onCloseAutoFocus,a=>{var c;i.current||(c=s.triggerRef.current)==null||c.focus(),i.current=!1,a.preventDefault()}),onInteractOutside:Q(t.onInteractOutside,a=>{const c=a.detail.originalEvent,d=c.button===0&&c.ctrlKey===!0,u=c.button===2||d;(!s.modal||u)&&(i.current=!0)}),style:{...t.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});nI.displayName=rI;var ite="DropdownMenuGroup",ate=m.forwardRef((t,e)=>{const{__scopeDropdownMenu:r,...n}=t,s=Tr(r);return l.jsx(qee,{...s,...n,ref:e})});ate.displayName=ite;var lte="DropdownMenuLabel",sI=m.forwardRef((t,e)=>{const{__scopeDropdownMenu:r,...n}=t,s=Tr(r);return l.jsx(Kee,{...s,...n,ref:e})});sI.displayName=lte;var cte="DropdownMenuItem",oI=m.forwardRef((t,e)=>{const{__scopeDropdownMenu:r,...n}=t,s=Tr(r);return l.jsx(Gee,{...s,...n,ref:e})});oI.displayName=cte;var dte="DropdownMenuCheckboxItem",iI=m.forwardRef((t,e)=>{const{__scopeDropdownMenu:r,...n}=t,s=Tr(r);return l.jsx(Yee,{...s,...n,ref:e})});iI.displayName=dte;var ute="DropdownMenuRadioGroup",hte=m.forwardRef((t,e)=>{const{__scopeDropdownMenu:r,...n}=t,s=Tr(r);return l.jsx(Jee,{...s,...n,ref:e})});hte.displayName=ute;var fte="DropdownMenuRadioItem",aI=m.forwardRef((t,e)=>{const{__scopeDropdownMenu:r,...n}=t,s=Tr(r);return l.jsx(Qee,{...s,...n,ref:e})});aI.displayName=fte;var pte="DropdownMenuItemIndicator",lI=m.forwardRef((t,e)=>{const{__scopeDropdownMenu:r,...n}=t,s=Tr(r);return l.jsx(Xee,{...s,...n,ref:e})});lI.displayName=pte;var mte="DropdownMenuSeparator",cI=m.forwardRef((t,e)=>{const{__scopeDropdownMenu:r,...n}=t,s=Tr(r);return l.jsx(Zee,{...s,...n,ref:e})});cI.displayName=mte;var gte="DropdownMenuArrow",vte=m.forwardRef((t,e)=>{const{__scopeDropdownMenu:r,...n}=t,s=Tr(r);return l.jsx(ete,{...s,...n,ref:e})});vte.displayName=gte;var yte="DropdownMenuSubTrigger",dI=m.forwardRef((t,e)=>{const{__scopeDropdownMenu:r,...n}=t,s=Tr(r);return l.jsx(tte,{...s,...n,ref:e})});dI.displayName=yte;var xte="DropdownMenuSubContent",uI=m.forwardRef((t,e)=>{const{__scopeDropdownMenu:r,...n}=t,s=Tr(r);return l.jsx(rte,{...s,...n,ref:e,style:{...t.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});uI.displayName=xte;var wte=XA,bte=eI,kte=tI,hI=nI,fI=sI,pI=oI,mI=iI,gI=aI,vI=lI,yI=cI,xI=dI,wI=uI;const Ste=wte,Nte=bte,Cte=m.forwardRef(({className:t,inset:e,children:r,...n},s)=>l.jsxs(xI,{ref:s,className:B("flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none data-[state=open]:bg-accent focus:bg-accent",e&&"pl-8",t),...n,children:[r,l.jsx(wt,{className:"ml-auto h-4 w-4"})]}));Cte.displayName=xI.displayName;const jte=m.forwardRef(({className:t,...e},r)=>l.jsx(wI,{ref:r,className:B("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",t),...e}));jte.displayName=wI.displayName;const bI=m.forwardRef(({className:t,sideOffset:e=4,...r},n)=>l.jsx(kte,{children:l.jsx(hI,{ref:n,sideOffset:e,className:B("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",t),...r})}));bI.displayName=hI.displayName;const Ub=m.forwardRef(({className:t,inset:e,...r},n)=>l.jsx(pI,{ref:n,className:B("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors data-[disabled]:pointer-events-none data-[disabled]:opacity-50 focus:bg-accent focus:text-accent-foreground",e&&"pl-8",t),...r}));Ub.displayName=pI.displayName;const Ete=m.forwardRef(({className:t,children:e,checked:r,...n},s)=>l.jsxs(mI,{ref:s,className:B("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors data-[disabled]:pointer-events-none data-[disabled]:opacity-50 focus:bg-accent focus:text-accent-foreground",t),checked:r,...n,children:[l.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:l.jsx(vI,{children:l.jsx(Qi,{className:"h-4 w-4"})})}),e]}));Ete.displayName=mI.displayName;const _te=m.forwardRef(({className:t,children:e,...r},n)=>l.jsxs(gI,{ref:n,className:B("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors data-[disabled]:pointer-events-none data-[disabled]:opacity-50 focus:bg-accent focus:text-accent-foreground",t),...r,children:[l.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:l.jsx(vI,{children:l.jsx(Gs,{className:"h-2 w-2 fill-current"})})}),e]}));_te.displayName=gI.displayName;const Tte=m.forwardRef(({className:t,inset:e,...r},n)=>l.jsx(fI,{ref:n,className:B("px-2 py-1.5 text-sm font-semibold",e&&"pl-8",t),...r}));Tte.displayName=fI.displayName;const kI=m.forwardRef(({className:t,...e},r)=>l.jsx(yI,{ref:r,className:B("-mx-1 my-1 h-px bg-muted",t),...e}));kI.displayName=yI.displayName;function Rte({classData:t,sessions:e,deadlines:r,notesCount:n,onEdit:s,onDelete:o}){const i=Zs(),a=new Date,c=e.filter(y=>new Date(`${y.session_date}T${y.start_time}`)>a).sort((y,x)=>new Date(y.session_date).getTime()-new Date(x.session_date).getTime()),d=r.filter(y=>y.status!=="completed"&&new Date(y.due_date)>a).sort((y,x)=>new Date(y.due_date).getTime()-new Date(x.due_date).getTime()),u=r.filter(y=>y.status!=="completed"),h=r.filter(y=>y.status==="overdue").length;let f=null;const p=c[0],g=d[0];if(p&&g){const y=new Date(`${p.session_date}T${p.start_time}`),x=new Date(g.due_date);y!t.meeting_days||t.meeting_days.length===0?"":`${t.meeting_days.map(x=>ng[x]).join("/")} ${t.start_time}`;return l.jsxs(fe,{className:"group overflow-hidden cursor-pointer transition-all hover:shadow-lg hover:border-primary/30",onClick:()=>i(`/classes/${t.id}`),children:[l.jsx("div",{className:"h-2",style:{backgroundColor:t.color}}),l.jsx(Nt,{className:"pb-3",children:l.jsxs("div",{className:"flex items-start justify-between",children:[l.jsxs("div",{className:"flex items-center gap-3",children:[l.jsx("div",{className:"h-12 w-12 rounded-xl flex items-center justify-center",style:{backgroundColor:`${t.color}20`},children:l.jsx(vt,{className:"h-6 w-6",style:{color:t.color}})}),l.jsxs("div",{children:[l.jsx(Ct,{className:"text-lg",children:t.code||t.name}),l.jsx("p",{className:"text-sm text-muted-foreground truncate max-w-[180px]",children:t.code?t.name:""})]})]}),l.jsxs(Ste,{children:[l.jsx(Nte,{asChild:!0,children:l.jsx(K,{variant:"ghost",size:"icon",onClick:y=>y.stopPropagation(),className:"opacity-0 group-hover:opacity-100 transition-opacity",children:l.jsx(L3,{className:"h-4 w-4"})})}),l.jsxs(bI,{align:"end",children:[l.jsx(Ub,{onClick:y=>{y.stopPropagation(),s==null||s()},children:"Edit Class"}),l.jsx(kI,{}),l.jsx(Ub,{onClick:y=>{y.stopPropagation(),o==null||o()},className:"text-destructive",children:"Delete Class"})]})]})]})}),l.jsxs(xe,{className:"space-y-4",children:[l.jsxs("div",{className:"space-y-2 text-sm",children:[l.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[l.jsx($r,{className:"h-4 w-4"}),l.jsx("span",{children:t.professor_name})]}),l.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[l.jsx($o,{className:"h-4 w-4"}),l.jsx("span",{children:t.location})]}),l.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[l.jsx(tr,{className:"h-4 w-4"}),l.jsx("span",{className:"truncate",children:v()})]})]}),f&&l.jsx("div",{className:"p-3 rounded-lg bg-secondary/50",children:l.jsxs("div",{className:"flex items-center gap-2",children:[f.type==="session"?l.jsx(Sr,{className:"h-4 w-4 text-primary"}):l.jsx(zd,{className:"h-4 w-4 text-warning"}),l.jsxs("div",{className:"flex-1 min-w-0",children:[l.jsx("p",{className:"text-xs text-muted-foreground",children:f.label}),l.jsx("p",{className:"text-sm font-medium truncate",children:Nn(f.date)?`Today at ${pe(f.date,"h:mm a")}`:pe(f.date,"MMM d, h:mm a")})]}),l.jsx(wt,{className:"h-4 w-4 text-muted-foreground"})]})}),l.jsxs("div",{className:"flex items-center gap-3 pt-3 border-t border-border",children:[l.jsxs("div",{className:"flex items-center gap-1.5",children:[l.jsx(zt,{className:"h-4 w-4 text-muted-foreground"}),l.jsx("span",{className:"text-sm text-foreground font-medium",children:n}),l.jsx("span",{className:"text-xs text-muted-foreground",children:"notes"})]}),l.jsxs("div",{className:"flex items-center gap-1.5",children:[l.jsx(Sr,{className:"h-4 w-4 text-muted-foreground"}),l.jsx("span",{className:"text-sm text-foreground font-medium",children:e.length}),l.jsx("span",{className:"text-xs text-muted-foreground",children:"sessions"})]}),h>0?l.jsxs(ue,{variant:"destructive",className:"ml-auto",children:[h," overdue"]}):u.length>0?l.jsxs(ue,{variant:"warning",className:"ml-auto",children:[u.length," due"]}):null]})]})]})}function Mte(){const t=Ot(o=>o.addEvent);return{createCalendarEvent:async o=>{try{const{data:{user:i}}=await q.auth.getUser();if(!i)throw new Error("Not authenticated");const a=crypto.randomUUID();t({id:a,classId:o.classId,userId:i.id,title:o.title,date:o.date,startTime:o.startTime,endTime:o.endTime,type:"study-session",notes:[],createdAt:new Date});const{error:c}=await q.from("calendar_event_mappings").insert({user_id:i.id,entity_type:o.entityType,entity_id:o.entityId,calendar_provider:"internal",calendar_event_id:a});return c&&console.error("Failed to store calendar mapping:",c),a}catch(i){return console.error("Failed to create calendar event:",i),null}},updateCalendarEvent:async(o,i,a)=>{try{const{data:{user:c}}=await q.auth.getUser();if(!c)return!1;const{data:d}=await q.from("calendar_event_mappings").select("calendar_event_id").eq("entity_id",o).eq("entity_type",i).eq("user_id",c.id).single();return d?!0:(console.log("No calendar mapping found for entity:",o),!1)}catch(c){return console.error("Failed to update calendar event:",c),!1}},deleteCalendarEvent:async(o,i)=>{try{const{data:{user:a}}=await q.auth.getUser();if(!a)return!1;const{error:c}=await q.from("calendar_event_mappings").delete().eq("entity_id",o).eq("entity_type",i).eq("user_id",a.id);return c?(console.error("Failed to delete calendar mapping:",c),!1):!0}catch(a){return console.error("Failed to delete calendar event:",a),!1}},hasCalendarEvent:async(o,i)=>{try{const{data:{user:a}}=await q.auth.getUser();if(!a)return!1;const{data:c}=await q.from("calendar_event_mappings").select("id").eq("entity_id",o).eq("entity_type",i).eq("user_id",a.id).single();return!!c}catch{return!1}}}}const Ote=[{value:"low",label:"Low",color:"bg-secondary text-secondary-foreground"},{value:"medium",label:"Medium",color:"bg-warning/20 text-warning"},{value:"high",label:"High",color:"bg-destructive/20 text-destructive"}];function Vb({open:t,onOpenChange:e,defaultClassId:r,defaultSessionId:n}){const s=Zs(),{toast:o}=gs(),i=Dl(),{classes:a,isLoading:c}=ua(),{createCalendarEvent:d}=Mte(),[u,h]=m.useState({title:"",classId:r||"",sessionId:n||null,dueDate:pe(new Date,"yyyy-MM-dd"),dueTime:"23:59",priority:"medium",description:"",estimatedMinutes:"",addToCalendar:!1,linkedDeadlineId:null}),[f,p]=m.useState(!1);m.useEffect(()=>{r&&h(b=>({...b,classId:r})),n&&h(b=>({...b,sessionId:n}))},[r,n]);const{data:g=[]}=xn({queryKey:["sessions",u.classId],queryFn:async()=>{if(!u.classId)return[];const{data:b}=await q.from("sessions").select("*").eq("class_id",u.classId).order("session_date",{ascending:!0});return b||[]},enabled:!!u.classId}),{data:v=[]}=xn({queryKey:["deadlines",u.classId],queryFn:async()=>{if(!u.classId)return[];const{data:b}=await q.from("deadlines").select("*").eq("class_id",u.classId).order("due_date",{ascending:!0});return b||[]},enabled:!!u.classId}),y=a.find(b=>b.id===u.classId),x=u.title.trim().length>0&&u.classId.length>0&&u.dueDate.length>0&&u.priority.length>0,w=async()=>{if(x){p(!0);try{const{data:{user:b}}=await q.auth.getUser();if(!b)throw new Error("Not authenticated");const k=new Date(`${u.dueDate}T${u.dueTime}`),{data:S,error:C}=await q.from("class_todos").insert({user_id:b.id,class_id:u.classId,title:u.title.trim(),description:u.description.trim()||null,due_date:k.toISOString(),priority:u.priority,status:"todo",linked_session_id:u.sessionId||null,linked_deadline_id:u.linkedDeadlineId||null}).select().single();if(C)throw C;if(u.addToCalendar&&S){const N=await d({title:`Task: ${u.title.trim()} — ${(y==null?void 0:y.code)||(y==null?void 0:y.name)||"Class"}`,date:k,startTime:u.dueTime,endTime:u.dueTime,classId:u.classId,entityType:"task",entityId:S.id,className:y==null?void 0:y.name,classColor:y==null?void 0:y.color});N&&console.log("Calendar event created:",N)}i.invalidateQueries({queryKey:["class-todos"]}),i.invalidateQueries({queryKey:["all-class-todos"]}),o({title:"Task created",description:u.addToCalendar?`"${u.title}" has been added to ${(y==null?void 0:y.name)||"your class"} and your calendar`:`"${u.title}" has been added to ${(y==null?void 0:y.name)||"your class"}`}),h({title:"",classId:r||"",sessionId:n||null,dueDate:pe(new Date,"yyyy-MM-dd"),dueTime:"23:59",priority:"medium",description:"",estimatedMinutes:"",addToCalendar:!1,linkedDeadlineId:null}),e(!1)}catch(b){console.error("Failed to create task:",b),o({title:"Failed to create task",description:b.message,variant:"destructive"})}finally{p(!1)}}};return!c&&a.length===0?l.jsx(wn,{open:t,onOpenChange:e,children:l.jsxs(nn,{className:"sm:max-w-md",children:[l.jsx(bn,{children:l.jsx(kn,{children:"Create a class first"})}),l.jsxs("div",{className:"flex flex-col items-center py-8 text-center",children:[l.jsx("div",{className:"h-16 w-16 rounded-full bg-primary/10 flex items-center justify-center mb-4",children:l.jsx(vt,{className:"h-8 w-8 text-primary"})}),l.jsx("p",{className:"text-muted-foreground mb-6",children:"You need to create at least one class before you can add tasks. Tasks are always affiliated with a class."}),l.jsxs(K,{onClick:()=>{e(!1),s("/classes")},children:[l.jsx(Rt,{className:"h-4 w-4 mr-2"}),"Create a Class",l.jsx(hC,{className:"h-4 w-4 ml-2"})]})]})]})}):l.jsx(wn,{open:t,onOpenChange:e,children:l.jsxs(nn,{className:"sm:max-w-lg max-h-[90vh] overflow-y-auto",children:[l.jsx(bn,{children:l.jsx(kn,{children:"Create Task"})}),l.jsxs("div",{className:"space-y-5 pt-2",children:[l.jsxs("div",{className:"space-y-2",children:[l.jsxs(de,{className:"flex items-center gap-1",children:["Title ",l.jsx("span",{className:"text-destructive",children:"*"})]}),l.jsx(Ne,{value:u.title,onChange:b=>h({...u,title:b.target.value}),placeholder:"e.g., Complete reading for Chapter 5",autoFocus:!0})]}),l.jsxs("div",{className:"space-y-2",children:[l.jsxs(de,{className:"flex items-center gap-1",children:[l.jsx(vt,{className:"h-4 w-4 text-muted-foreground"}),"Class ",l.jsx("span",{className:"text-destructive",children:"*"})]}),l.jsxs(_s,{value:u.classId,onValueChange:b=>h({...u,classId:b,sessionId:null,linkedDeadlineId:null}),children:[l.jsx(ss,{children:l.jsx(Ts,{placeholder:"Select a class"})}),l.jsx(is,{children:a.map(b=>l.jsx(Fe,{value:b.id,children:l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("div",{className:"h-3 w-3 rounded-full",style:{backgroundColor:b.color}}),b.code?`${b.code} - `:"",b.name]})},b.id))})]})]}),u.classId&&g.length>0&&l.jsxs("div",{className:"space-y-2",children:[l.jsxs(de,{className:"flex items-center gap-1",children:[l.jsx(Sr,{className:"h-4 w-4 text-muted-foreground"}),"Link to Session (optional)"]}),l.jsxs(_s,{value:u.sessionId||"none",onValueChange:b=>h({...u,sessionId:b==="none"?null:b}),children:[l.jsx(ss,{children:l.jsx(Ts,{placeholder:"No specific session"})}),l.jsxs(is,{children:[l.jsx(Fe,{value:"none",children:"No specific session"}),g.slice(0,20).map(b=>l.jsxs(Fe,{value:b.id,children:[pe(new Date(b.session_date),"MMM d, yyyy")," - ",b.start_time]},b.id))]})]})]}),l.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[l.jsxs("div",{className:"space-y-2",children:[l.jsxs(de,{className:"flex items-center gap-1",children:[l.jsx(tr,{className:"h-4 w-4 text-muted-foreground"}),"Due Date ",l.jsx("span",{className:"text-destructive",children:"*"})]}),l.jsx(Ne,{type:"date",value:u.dueDate,onChange:b=>h({...u,dueDate:b.target.value})})]}),l.jsxs("div",{className:"space-y-2",children:[l.jsxs(de,{children:["Due Time ",l.jsx("span",{className:"text-destructive",children:"*"})]}),l.jsx(Ne,{type:"time",value:u.dueTime,onChange:b=>h({...u,dueTime:b.target.value})})]})]}),l.jsxs("div",{className:"space-y-2",children:[l.jsxs(de,{className:"flex items-center gap-1",children:[l.jsx(zd,{className:"h-4 w-4 text-muted-foreground"}),"Priority ",l.jsx("span",{className:"text-destructive",children:"*"})]}),l.jsx("div",{className:"flex gap-2",children:Ote.map(b=>l.jsx("button",{type:"button",onClick:()=>h({...u,priority:b.value}),className:B("flex-1 py-2 px-3 rounded-lg border text-sm font-medium transition-all",u.priority===b.value?b.color+" border-current":"bg-background border-border text-muted-foreground hover:bg-secondary"),children:b.label},b.value))})]}),l.jsxs("div",{className:"space-y-2",children:[l.jsx(de,{children:"Description (optional)"}),l.jsx(uh,{value:u.description,onChange:b=>h({...u,description:b.target.value}),placeholder:"Additional notes or details...",rows:3})]}),u.classId&&v.length>0&&l.jsxs("div",{className:"space-y-2",children:[l.jsxs(de,{className:"flex items-center gap-1",children:[l.jsx(Bd,{className:"h-4 w-4 text-muted-foreground"}),"Link to Deadline (optional)"]}),l.jsxs(_s,{value:u.linkedDeadlineId||"none",onValueChange:b=>h({...u,linkedDeadlineId:b==="none"?null:b}),children:[l.jsx(ss,{children:l.jsx(Ts,{placeholder:"No linked deadline"})}),l.jsxs(is,{children:[l.jsx(Fe,{value:"none",children:"No linked deadline"}),v.map(b=>l.jsxs(Fe,{value:b.id,children:[b.title," - ",pe(new Date(b.due_date),"MMM d")]},b.id))]})]})]}),l.jsxs("div",{className:"space-y-2",children:[l.jsxs(de,{className:"flex items-center gap-1",children:[l.jsx(hL,{className:"h-4 w-4 text-muted-foreground"}),"Estimated Time (optional)"]}),l.jsxs(_s,{value:u.estimatedMinutes||"none",onValueChange:b=>h({...u,estimatedMinutes:b==="none"?"":b}),children:[l.jsx(ss,{children:l.jsx(Ts,{placeholder:"No estimate"})}),l.jsxs(is,{children:[l.jsx(Fe,{value:"none",children:"No estimate"}),l.jsx(Fe,{value:"15",children:"15 minutes"}),l.jsx(Fe,{value:"30",children:"30 minutes"}),l.jsx(Fe,{value:"60",children:"1 hour"}),l.jsx(Fe,{value:"120",children:"2 hours"}),l.jsx(Fe,{value:"180",children:"3 hours"}),l.jsx(Fe,{value:"240",children:"4+ hours"})]})]})]}),l.jsxs("div",{className:"flex items-center justify-between p-3 rounded-lg bg-secondary/50",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx(Sr,{className:"h-4 w-4 text-muted-foreground"}),l.jsx("span",{className:"text-sm",children:"Add to calendar"})]}),l.jsx(Ko,{checked:u.addToCalendar,onCheckedChange:b=>h({...u,addToCalendar:b})})]}),l.jsx(K,{onClick:w,disabled:!x||f,className:"w-full",variant:"glow",children:f?"Creating...":"Create Task"}),!x&&l.jsx("p",{className:"text-xs text-muted-foreground text-center",children:"Please fill in all required fields (title, class, due date, priority)"})]})]})})}function Pte(){const{classId:t}=lE(),e=Zs(),{classData:r,sessions:n,deadlines:s,todos:o,notes:i,isLoading:a,addDeadline:c,updateDeadline:d,updateTodo:u}=fH(t),[h,f]=m.useState(!1),[p,g]=m.useState(!1),[v,y]=m.useState(!1),[x,w]=m.useState({title:"",deadline_type:"assignment",due_date:pe(new Date,"yyyy-MM-dd'T'HH:mm"),description:"",weight:""});if(a)return l.jsx("div",{className:"flex items-center justify-center h-full",children:l.jsx("div",{className:"animate-pulse text-muted-foreground",children:"Loading class..."})});if(!r)return l.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-4",children:[l.jsx("p",{className:"text-muted-foreground",children:"Class not found"}),l.jsx(K,{onClick:()=>e("/classes"),children:"Back to Classes"})]});const b=new Date,S=n.filter(j=>new Date(`${j.session_date}T${j.start_time}`)>b).sort((j,_)=>new Date(j.session_date).getTime()-new Date(_.session_date).getTime())[0],C=s.filter(j=>j.status!=="completed"&&m8(new Date(j.due_date))),N=s.filter(j=>j.status!=="completed"&&Xx(new Date(j.due_date))),E=async()=>{const{data:{user:j}}=await q.auth.getUser();!j||!t||(c({class_id:t,user_id:j.id,title:x.title,deadline_type:x.deadline_type,due_date:new Date(x.due_date).toISOString(),description:x.description||null,weight:x.weight?parseFloat(x.weight):null,status:"upcoming",source:"manual",calendar_event_id:null}),f(!1),w({title:"",deadline_type:"assignment",due_date:pe(new Date,"yyyy-MM-dd'T'HH:mm"),description:"",weight:""}))};return l.jsxs("div",{className:"min-h-screen",children:[l.jsxs("div",{className:"p-6 border-b",style:{backgroundColor:`${r.color}08`},children:[l.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>e("/classes"),className:"mb-4",children:[l.jsx(O3,{className:"h-4 w-4 mr-2"}),"Back to Classes"]}),l.jsxs("div",{className:"flex items-start justify-between",children:[l.jsxs("div",{className:"flex items-center gap-4",children:[l.jsx("div",{className:"h-16 w-16 rounded-xl flex items-center justify-center",style:{backgroundColor:`${r.color}20`},children:l.jsx(vt,{className:"h-8 w-8",style:{color:r.color}})}),l.jsxs("div",{children:[l.jsxs("h1",{className:"text-2xl font-bold",children:[r.code&&l.jsx("span",{className:"mr-2",children:r.code}),r.name]}),l.jsxs("div",{className:"flex items-center gap-4 mt-2 text-sm text-muted-foreground",children:[l.jsxs("span",{className:"flex items-center gap-1",children:[l.jsx($r,{className:"h-4 w-4"}),r.professor_name]}),l.jsxs("span",{className:"flex items-center gap-1",children:[l.jsx($o,{className:"h-4 w-4"}),r.location]}),l.jsxs("span",{className:"flex items-center gap-1",children:[l.jsx(tr,{className:"h-4 w-4"}),r.meeting_days.map(j=>ng[j]).join("/")," ",r.start_time]})]})]})]}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsxs(K,{variant:"outline",size:"sm",onClick:()=>y(!0),children:[l.jsx(zt,{className:"h-4 w-4 mr-2"}),"Add Note"]}),l.jsxs(K,{variant:"outline",size:"sm",onClick:()=>g(!0),children:[l.jsx(jl,{className:"h-4 w-4 mr-2"}),"Add To-Do"]}),r.class_website&&l.jsx(K,{variant:"outline",size:"sm",asChild:!0,children:l.jsxs("a",{href:r.class_website,target:"_blank",rel:"noopener noreferrer",children:[l.jsx(F3,{className:"h-4 w-4 mr-2"}),"Course Page"]})})]})]})]}),l.jsxs("div",{className:"p-6 grid grid-cols-1 md:grid-cols-3 gap-4",children:[l.jsx(fe,{className:"bg-primary/5 border-primary/20",children:l.jsxs(xe,{className:"p-4",children:[l.jsxs("div",{className:"flex items-center gap-2 text-primary mb-2",children:[l.jsx(Sr,{className:"h-4 w-4"}),l.jsx("span",{className:"text-sm font-medium",children:"Next Class"})]}),S?l.jsxs("p",{className:"font-semibold",children:[Nn(lu(S.session_date))?`Today at ${S.start_time}`:pe(lu(S.session_date),"MMM d")," at ",S.start_time]}):l.jsx("p",{className:"text-muted-foreground text-sm",children:"No upcoming sessions"})]})}),l.jsx(fe,{className:B("border-warning/20",C.length>0&&"bg-warning/5"),children:l.jsxs(xe,{className:"p-4",children:[l.jsxs("div",{className:"flex items-center gap-2 text-warning mb-2",children:[l.jsx(zd,{className:"h-4 w-4"}),l.jsx("span",{className:"text-sm font-medium",children:"Next Due"})]}),C[0]?l.jsxs(l.Fragment,{children:[l.jsx("p",{className:"font-semibold",children:C[0].title}),l.jsx("p",{className:"text-sm text-muted-foreground",children:pe(new Date(C[0].due_date),"MMM d, h:mm a")})]}):l.jsx("p",{className:"text-muted-foreground text-sm",children:"No upcoming deadlines"})]})}),l.jsx(fe,{className:B("border-destructive/20",N.length>0&&"bg-destructive/5"),children:l.jsxs(xe,{className:"p-4",children:[l.jsxs("div",{className:"flex items-center gap-2 text-destructive mb-2",children:[l.jsx(zd,{className:"h-4 w-4"}),l.jsx("span",{className:"text-sm font-medium",children:"Overdue"})]}),N.length>0?l.jsxs("p",{className:"font-semibold",children:[N.length," item(s)"]}):l.jsxs("p",{className:"text-green-600 text-sm flex items-center gap-1",children:[l.jsx(Qi,{className:"h-4 w-4"}),"All caught up!"]})]})})]}),l.jsx("div",{className:"px-6 pb-6",children:l.jsxs(no,{defaultValue:"sessions",className:"space-y-4",children:[l.jsxs(ks,{children:[l.jsxs(Ze,{value:"sessions",children:["Sessions (",n.length,")"]}),l.jsxs(Ze,{value:"notes",children:["Notes (",i.length,")"]}),l.jsxs(Ze,{value:"deadlines",children:["Deadlines (",s.length,")"]}),l.jsxs(Ze,{value:"todos",children:["To-Dos (",o.length,")"]})]}),l.jsx(et,{value:"sessions",className:"space-y-4",children:l.jsx(Pn,{className:"h-[calc(100vh-400px)]",children:l.jsx("div",{className:"space-y-2",children:n.map(j=>{const _=lu(j.session_date),P=new Date(`${j.session_date}T${j.start_time}`),T=Xx(P),A=Nn(_);return l.jsx(fe,{className:B("transition-colors",A&&"border-primary bg-primary/5",T&&!A&&"opacity-60"),children:l.jsxs(xe,{className:"p-4 flex items-center justify-between",children:[l.jsxs("div",{className:"flex items-center gap-4",children:[l.jsxs("div",{className:"text-center min-w-[50px]",children:[l.jsx("p",{className:"text-2xl font-bold",children:pe(_,"d")}),l.jsx("p",{className:"text-xs text-muted-foreground",children:pe(_,"MMM")})]}),l.jsxs("div",{children:[l.jsxs("p",{className:"font-medium",children:[pe(_,"EEEE"),A&&l.jsx(ue,{variant:"default",className:"ml-2",children:"Today"})]}),l.jsxs("p",{className:"text-sm text-muted-foreground",children:[j.start_time," - ",j.end_time," • ",j.location||r.location]}),j.topics&&j.topics.length>0&&l.jsx("div",{className:"flex gap-1 mt-1",children:j.topics.map((I,V)=>l.jsx(ue,{variant:"outline",className:"text-xs",children:I},V))})]})]}),l.jsx(ue,{variant:j.attendance==="attended"?"default":j.attendance==="missed"?"destructive":"outline",children:j.attendance})]})},j.id)})})})}),l.jsx(et,{value:"notes",className:"space-y-4",children:l.jsx(Pn,{className:"h-[calc(100vh-400px)]",children:i.length>0?l.jsx("div",{className:"space-y-2",children:i.map(j=>l.jsx(fe,{children:l.jsx(xe,{className:"p-4",children:l.jsxs("div",{className:"flex items-start justify-between",children:[l.jsxs("div",{children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx(zt,{className:"h-4 w-4 text-muted-foreground"}),l.jsx("span",{className:"font-medium",children:j.title||`Note from ${pe(new Date(j.created_at),"MMM d")}`}),l.jsx(ue,{variant:"outline",children:j.type})]}),l.jsx("p",{className:"text-sm text-muted-foreground mt-1 line-clamp-2",children:j.content||j.transcription||"No content"})]}),l.jsx("span",{className:"text-xs text-muted-foreground",children:pe(new Date(j.created_at),"MMM d, h:mm a")})]})})},j.id))}):l.jsxs("div",{className:"text-center py-12 text-muted-foreground",children:[l.jsx(zt,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),l.jsx("p",{children:"No notes yet for this class"}),l.jsxs(K,{variant:"outline",size:"sm",className:"mt-4",onClick:()=>y(!0),children:[l.jsx(Rt,{className:"h-4 w-4 mr-2"}),"Add Note"]})]})})}),l.jsxs(et,{value:"deadlines",className:"space-y-4",children:[l.jsx("div",{className:"flex justify-end",children:l.jsxs(wn,{open:h,onOpenChange:f,children:[l.jsx(t_,{asChild:!0,children:l.jsxs(K,{size:"sm",children:[l.jsx(Rt,{className:"h-4 w-4 mr-2"}),"Add Deadline"]})}),l.jsxs(nn,{children:[l.jsx(bn,{children:l.jsx(kn,{children:"Add Deadline"})}),l.jsxs("div",{className:"space-y-4 pt-4",children:[l.jsxs("div",{className:"space-y-2",children:[l.jsx(de,{children:"Title *"}),l.jsx(Ne,{value:x.title,onChange:j=>w({...x,title:j.target.value}),placeholder:"e.g., Midterm Exam"})]}),l.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[l.jsxs("div",{className:"space-y-2",children:[l.jsx(de,{children:"Type"}),l.jsxs(_s,{value:x.deadline_type,onValueChange:j=>w({...x,deadline_type:j}),children:[l.jsx(ss,{children:l.jsx(Ts,{})}),l.jsxs(is,{children:[l.jsx(Fe,{value:"assignment",children:"Assignment"}),l.jsx(Fe,{value:"exam",children:"Exam"}),l.jsx(Fe,{value:"quiz",children:"Quiz"}),l.jsx(Fe,{value:"midterm",children:"Midterm"}),l.jsx(Fe,{value:"final",children:"Final"}),l.jsx(Fe,{value:"reading",children:"Reading"}),l.jsx(Fe,{value:"other",children:"Other"})]})]})]}),l.jsxs("div",{className:"space-y-2",children:[l.jsx(de,{children:"Weight (%)"}),l.jsx(Ne,{type:"number",value:x.weight,onChange:j=>w({...x,weight:j.target.value}),placeholder:"e.g., 20"})]})]}),l.jsxs("div",{className:"space-y-2",children:[l.jsx(de,{children:"Due Date *"}),l.jsx(Ne,{type:"datetime-local",value:x.due_date,onChange:j=>w({...x,due_date:j.target.value})})]}),l.jsxs("div",{className:"space-y-2",children:[l.jsx(de,{children:"Description"}),l.jsx(uh,{value:x.description,onChange:j=>w({...x,description:j.target.value}),placeholder:"Additional details..."})]}),l.jsx(K,{onClick:E,className:"w-full",disabled:!x.title.trim()||!x.due_date,children:"Add Deadline"})]})]})]})}),l.jsx(Pn,{className:"h-[calc(100vh-450px)]",children:s.length>0?l.jsx("div",{className:"space-y-2",children:s.map(j=>{const _=new Date(j.due_date),P=Xx(_)&&j.status!=="completed";return l.jsx(fe,{className:B("transition-colors",P&&"border-destructive bg-destructive/5",j.status==="completed"&&"opacity-60"),children:l.jsxs(xe,{className:"p-4 flex items-center gap-4",children:[l.jsx(og,{checked:j.status==="completed",onCheckedChange:T=>{d({id:j.id,status:T?"completed":"upcoming"})}}),l.jsxs("div",{className:"flex-1",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("span",{className:B("font-medium",j.status==="completed"&&"line-through"),children:j.title}),l.jsx(ue,{variant:"outline",children:j.deadline_type}),j.weight&&l.jsxs(ue,{variant:"secondary",children:[j.weight,"%"]}),P&&l.jsx(ue,{variant:"destructive",children:"Overdue"})]}),l.jsxs("p",{className:"text-sm text-muted-foreground",children:["Due: ",pe(_,"MMM d, yyyy h:mm a")]}),j.description&&l.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:j.description})]}),l.jsx(ue,{variant:"outline",className:"text-xs",children:j.source})]})},j.id)})}):l.jsxs("div",{className:"text-center py-12 text-muted-foreground",children:[l.jsx(Sr,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),l.jsx("p",{children:"No deadlines yet"})]})})]}),l.jsxs(et,{value:"todos",className:"space-y-4",children:[l.jsx("div",{className:"flex justify-end",children:l.jsxs(K,{size:"sm",onClick:()=>g(!0),children:[l.jsx(Rt,{className:"h-4 w-4 mr-2"}),"Add To-Do"]})}),l.jsx(Pn,{className:"h-[calc(100vh-450px)]",children:o.length>0?l.jsx("div",{className:"space-y-2",children:o.map(j=>l.jsx(fe,{className:B(j.status==="completed"&&"opacity-60"),children:l.jsxs(xe,{className:"p-4 flex items-center gap-4",children:[l.jsx(og,{checked:j.status==="completed",onCheckedChange:_=>{u({id:j.id,status:_?"completed":"todo"})}}),l.jsxs("div",{className:"flex-1",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("span",{className:B("font-medium",j.status==="completed"&&"line-through"),children:j.title}),l.jsx(ue,{variant:j.priority==="high"?"destructive":j.priority==="medium"?"warning":"outline",children:j.priority})]}),j.due_date&&l.jsxs("p",{className:"text-sm text-muted-foreground",children:["Due: ",pe(new Date(j.due_date),"MMM d, h:mm a")]}),j.description&&l.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:j.description})]})]})},j.id))}):l.jsxs("div",{className:"text-center py-12 text-muted-foreground",children:[l.jsx(jl,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),l.jsx("p",{children:"No to-dos yet"}),l.jsxs(K,{variant:"outline",size:"sm",className:"mt-4",onClick:()=>g(!0),children:[l.jsx(Rt,{className:"h-4 w-4 mr-2"}),"Add To-Do"]})]})})]})]})}),l.jsx(Vb,{open:p,onOpenChange:g,defaultClassId:t}),l.jsx(W0,{open:v,onOpenChange:y,classId:t})]})}function SI(){const{classId:t}=lE(),{classes:e,isLoading:r,deleteClass:n}=ua(),[s,o]=m.useState(!1),[i,a]=m.useState(!1),{data:c=[]}=xn({queryKey:["all-sessions"],queryFn:async()=>{const{data:{user:h}}=await q.auth.getUser();if(!h)return[];const{data:f}=await q.from("sessions").select("*").eq("user_id",h.id);return f||[]}}),{data:d=[]}=xn({queryKey:["all-deadlines"],queryFn:async()=>{const{data:{user:h}}=await q.auth.getUser();if(!h)return[];const{data:f}=await q.from("deadlines").select("*").eq("user_id",h.id);return f||[]}}),{data:u=[]}=xn({queryKey:["all-notes"],queryFn:async()=>{const{data:{user:h}}=await q.auth.getUser();if(!h)return[];const{data:f}=await q.from("notes").select("*").eq("user_id",h.id);return f||[]}});return t?l.jsx(Pte,{}):l.jsxs("div",{className:"min-h-screen p-4 sm:p-6",children:[l.jsxs("div",{className:"flex flex-col sm:flex-row items-start sm:items-center justify-between gap-3 mb-6 sm:mb-8",children:[l.jsxs("div",{className:"flex items-center gap-3",children:[l.jsx(co,{}),l.jsxs("div",{children:[l.jsx("h1",{className:"text-xl sm:text-2xl font-bold text-foreground",children:"Classes"}),l.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"Manage your classes and access all related materials"})]})]}),l.jsxs("div",{className:"flex items-center gap-2 w-full sm:w-auto",children:[l.jsxs(K,{variant:"outline",size:"sm",onClick:()=>a(!0),className:"flex-1 sm:flex-none",children:[l.jsx(CC,{className:"h-4 w-4 mr-2"}),"Import Syllabus"]}),l.jsxs(K,{variant:"glow",size:"sm",onClick:()=>o(!0),className:"flex-1 sm:flex-none",children:[l.jsx(Rt,{className:"h-4 w-4 mr-2"}),"Add Class"]})]})]}),r?l.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6",children:[1,2,3].map(h=>l.jsx(fe,{className:"h-[280px] animate-pulse bg-secondary/50"},h))}):l.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6",children:[e.map(h=>l.jsx(Rte,{classData:h,sessions:c.filter(f=>f.class_id===h.id),deadlines:d.filter(f=>f.class_id===h.id),notesCount:u.filter(f=>f.class_id===h.id).length,onDelete:()=>{confirm("Are you sure you want to delete this class?")&&n(h.id)}},h.id)),l.jsx(fe,{className:"border-dashed cursor-pointer hover:border-primary/50 hover:bg-secondary/30 transition-all duration-200",onClick:()=>o(!0),children:l.jsxs(xe,{className:"flex flex-col items-center justify-center h-full min-h-[280px] text-center",children:[l.jsx("div",{className:"w-12 h-12 rounded-full bg-secondary flex items-center justify-center mb-3",children:l.jsx(Rt,{className:"h-6 w-6 text-muted-foreground"})}),l.jsx("h3",{className:"font-medium text-foreground mb-1",children:"Add a new class"}),l.jsx("p",{className:"text-sm text-muted-foreground",children:"Set up your schedule and start taking notes"})]})})]}),l.jsx(aee,{open:s,onOpenChange:o}),l.jsx(fee,{open:i,onOpenChange:a})]})}function Ate(){const[t,e]=m.useState([]),[r,n]=m.useState(!0),{toast:s}=gs(),o=m.useCallback(async()=>{try{const{data:{user:c}}=await q.auth.getUser();if(!c){e([]),n(!1);return}const{data:d,error:u}=await q.from("extracted_todos").select("*").eq("user_id",c.id).order("created_at",{ascending:!1});if(u)throw u;e(d||[])}catch(c){console.error("Failed to fetch extracted todos:",c),s({title:"Failed to load AI to-dos",description:"Could not fetch extracted to-dos",variant:"destructive"})}finally{n(!1)}},[s]),i=m.useCallback(async(c,d)=>{try{const{error:u}=await q.from("extracted_todos").update({status:d}).eq("id",c);if(u)throw u;e(h=>h.map(f=>f.id===c?{...f,status:d}:f))}catch(u){console.error("Failed to update todo status:",u),s({title:"Update failed",description:"Could not update to-do status",variant:"destructive"})}},[s]),a=m.useCallback(async c=>{try{const{error:d}=await q.from("extracted_todos").delete().eq("id",c);if(d)throw d;e(u=>u.filter(h=>h.id!==c))}catch(d){console.error("Failed to delete todo:",d),s({title:"Delete failed",description:"Could not delete to-do",variant:"destructive"})}},[s]);return m.useEffect(()=>{o();const c=q.channel("extracted_todos_changes").on("postgres_changes",{event:"*",schema:"public",table:"extracted_todos"},()=>{o()}).subscribe();return()=>{q.removeChannel(c)}},[o]),{todos:t,isLoading:r,updateTodoStatus:i,deleteTodo:a,refetch:o}}function Wb({todo:t,onStatusChange:e,onDelete:r}){const s=(c=>{if(!c)return null;const d=new Date,h=new Date(c).getTime()-d.getTime();return Math.ceil(h/864e5)})(t.due_date),o=s!==null&&s<0,i=s!==null&&s>=0&&s<=2,a=c=>{switch(c){case"high":return"destructive";case"medium":return"warning";case"low":return"secondary"}};return l.jsx(fe,{variant:"interactive",className:"group",children:l.jsx(xe,{className:"p-4",children:l.jsxs("div",{className:"flex items-start gap-3",children:[l.jsx("button",{onClick:()=>e(t.id,t.status==="completed"?"todo":"completed"),className:"mt-0.5 shrink-0",children:t.status==="completed"?l.jsx(Lo,{className:"h-5 w-5 text-success"}):l.jsx(Gs,{className:"h-5 w-5 text-muted-foreground hover:text-primary transition-colors"})}),l.jsxs("div",{className:"flex-1 min-w-0",children:[l.jsxs("div",{className:"flex items-start justify-between gap-2",children:[l.jsx("h4",{className:B("font-medium text-foreground",t.status==="completed"&&"line-through text-muted-foreground"),children:t.title}),l.jsx(K,{variant:"ghost",size:"icon-sm",className:"opacity-0 group-hover:opacity-100 transition-opacity text-muted-foreground hover:text-destructive",onClick:()=>r(t.id),children:l.jsx(Ky,{className:"h-4 w-4"})})]}),t.description&&l.jsx("p",{className:"text-sm text-muted-foreground mt-1 line-clamp-2",children:t.description}),l.jsxs("div",{className:"flex items-center gap-2 mt-3 flex-wrap",children:[l.jsxs(ue,{variant:"outline",className:"bg-primary/10 text-primary border-primary/20",children:[l.jsx(Nr,{className:"h-3 w-3 mr-1"}),"AI Extracted"]}),l.jsx(ue,{variant:a(t.priority),children:t.priority}),t.due_date&&l.jsxs("div",{className:B("flex items-center gap-1 text-xs",o?"text-destructive":i?"text-warning":"text-muted-foreground"),children:[o?l.jsx(Vd,{className:"h-3 w-3"}):l.jsx(tr,{className:"h-3 w-3"}),l.jsx("span",{children:o?`${Math.abs(s)} days overdue`:s===0?"Due today":s===1?"Due tomorrow":`Due in ${s} days`})]})]})]})]})})})}const wi={high:0,medium:1,low:2};function NI({id:t,type:e,status:r,children:n}){const{attributes:s,listeners:o,setNodeRef:i,transform:a,isDragging:c}=UO({id:`${e}-${t}`,data:{type:e,id:t,currentStatus:r}}),d=a?{transform:`translate(${a.x}px, ${a.y}px)`,opacity:c?.5:1,zIndex:c?50:void 0}:void 0;return l.jsx("div",{ref:i,style:d,...s,...o,className:"relative cursor-grab active:cursor-grabbing",children:n})}function Hb({columnId:t,title:e,items:r,classTodoItems:n,icon:s,iconColor:o,renderAssignment:i,renderClassTodo:a}){const{isOver:c,setNodeRef:d}=VO({id:t});return l.jsxs("div",{ref:d,className:B("flex-1 min-w-0 sm:min-w-[300px] rounded-xl p-3 transition-colors",c&&"bg-primary/5 ring-2 ring-primary/20"),children:[l.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[l.jsx("div",{className:B("p-1.5 rounded-lg",o),children:l.jsx(s,{className:"h-4 w-4"})}),l.jsx("h3",{className:"font-semibold text-foreground",children:e}),l.jsx(ue,{variant:"secondary",className:"ml-auto",children:r.length+n.length})]}),l.jsxs("div",{className:"space-y-3",children:[n.map(u=>a(u)),r.map(u=>i(u)),r.length===0&&n.length===0&&l.jsx(fe,{className:B("border-dashed",c&&"border-primary/40"),children:l.jsx(xe,{className:"p-6 text-center",children:l.jsx("p",{className:"text-sm text-muted-foreground",children:c?"Drop here":"No items"})})})]})]})}function Ite(){const t=Zs(),e=Dl(),{assignments:r,classes:n,updateAssignment:s}=Ot(),o=fO(sb($m,{activationConstraint:{distance:8}})),[i,a]=m.useState(null);ua();const[c,d]=m.useState(!1),u=du(),{todos:h,isLoading:f,updateTodoStatus:p,deleteTodo:g}=Ate(),{data:v=[],isLoading:y}=xn({queryKey:["all-class-todos"],queryFn:async()=>{const{data:{user:O}}=await q.auth.getUser();if(!O)return[];const{data:z}=await q.from("class_todos").select("*, classes(name, code, color)").eq("user_id",O.id).order("due_date",{ascending:!0});return z||[]}}),x=[...r.filter(O=>O.status==="todo")].sort((O,z)=>{const F=Date.now(),te=new Date(O.dueDate).getTime(),ee=new Date(z.dueDate).getTime(),Z=teO.status==="in-progress")].sort((O,z)=>{const F=Date.now(),te=new Date(O.dueDate).getTime(),ee=new Date(z.dueDate).getTime(),Z=teO.status==="completed"),k=(O,z)=>[...O].sort((F,te)=>{const ee=Date.now(),Z=F[z]?new Date(F[z]).getTime():1/0,ve=te[z]?new Date(te[z]).getTime():1/0,ce=ZO.status==="todo"),"due_date"),C=k(v.filter(O=>O.status==="in-progress"),"due_date"),N=v.filter(O=>O.status==="completed"),E=h.filter(O=>O.status==="todo"),j=h.filter(O=>O.status==="in-progress"),_=h.filter(O=>O.status==="completed"),P=O=>n.find(z=>z.id===O),T=(O,z)=>{s(O,{status:z})},A=async(O,z)=>{await q.from("class_todos").update({status:z}).eq("id",O),e.invalidateQueries({queryKey:["all-class-todos"]})},I=O=>{a(O.active.id)},V=O=>{a(null);const{active:z,over:F}=O;if(!F)return;const te=F.id,ee=z.data.current;!ee||ee.currentStatus===te||(ee.type==="assignment"?T(ee.id,te):A(ee.id,te))},L=O=>{switch(O){case"high":return"destructive";case"medium":return"warning";case"low":return"secondary";default:return"secondary"}},U=O=>{const z=new Date,te=(typeof O=="string"?new Date(O):O).getTime()-z.getTime();return Math.ceil(te/(1e3*60*60*24))},M=m.useMemo(()=>{const O=[];return[...x,...w].forEach(z=>{O.push({type:"assignment",data:z})}),[...S,...C].forEach(z=>{O.push({type:"classTodo",data:z})}),O.sort((z,F)=>{const te=wi[z.data.priority]??2,ee=wi[F.data.priority]??2;if(te!==ee)return te-ee;const Z=z.type==="assignment"?new Date(z.data.dueDate):z.data.due_date?new Date(z.data.due_date):new Date("2099-01-01"),ve=F.type==="assignment"?new Date(F.data.dueDate):F.data.due_date?new Date(F.data.due_date):new Date("2099-01-01");return Z.getTime()-ve.getTime()})},[x,w,S,C]),D=m.useMemo(()=>{const O=[];return b.forEach(z=>O.push({type:"assignment",data:z})),N.forEach(z=>O.push({type:"classTodo",data:z})),O},[b,N]),H=({item:O})=>{const z=O.type==="assignment",F=O.data.title,te=O.data.priority,ee=O.data.status==="completed",Z=z?P(O.data.classId):O.data.classes,ve=z?O.data.dueDate:O.data.due_date,ce=ve?U(ve):null,Le=ce!==null&&ce<0,We=ce!==null&&ce>=0&&ce<=2,It=()=>{z?T(O.data.id,ee?"todo":"completed"):A(O.data.id,ee?"todo":"completed")},Dt=z?O.data.classId:O.data.class_id,Dn=cs=>{Dt&&t(`/classes/${Dt}`)};return l.jsxs("div",{className:"flex items-start gap-3 p-3 rounded-xl bg-card border border-border transition-transform",children:[l.jsx("button",{onClick:cs=>{cs.stopPropagation(),It()},className:"mt-0.5 shrink-0",children:ee?l.jsx(Lo,{className:"h-5 w-5 text-success"}):l.jsx(Gs,{className:"h-5 w-5 text-muted-foreground"})}),l.jsxs("div",{className:"flex-1 min-w-0 cursor-pointer",onClick:Dn,children:[l.jsx("p",{className:B("text-sm font-medium text-foreground",ee&&"line-through text-muted-foreground"),children:F}),l.jsxs("div",{className:"flex items-center gap-2 mt-1.5 flex-wrap",children:[Z&&l.jsx("span",{className:"text-[11px] font-medium px-1.5 py-0.5 rounded",style:{backgroundColor:`${Z.color}20`,color:Z.color},children:Z.code||Z.name}),!ee&&ce!==null&&l.jsxs("span",{className:B("text-[11px] flex items-center gap-1",Le?"text-destructive":We?"text-warning":"text-muted-foreground"),children:[Le?l.jsx(Vd,{className:"h-3 w-3"}):l.jsx(tr,{className:"h-3 w-3"}),Le?`${Math.abs(ce)}d overdue`:ce===0?"Today":ce===1?"Tomorrow":`${ce}d`]})]})]}),l.jsxs("div",{className:"flex items-center gap-1 shrink-0 mt-0.5",children:[!ee&&l.jsx(ue,{variant:L(te),className:"text-[10px] px-1.5 py-0 h-5",children:te}),Dt&&l.jsx(wt,{className:"h-4 w-4 text-muted-foreground"})]})]})};if(u)return l.jsxs("div",{className:"min-h-screen flex flex-col",children:[l.jsxs("header",{className:"flex items-center justify-between px-4 py-3 border-b border-border bg-background/80 backdrop-blur-sm",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx(co,{}),l.jsx("h1",{className:"text-lg font-bold text-foreground",children:"To-Do"})]}),l.jsxs(K,{variant:"glow",size:"sm",className:"h-8",onClick:()=>d(!0),children:[l.jsx(Rt,{className:"h-4 w-4"}),"Add"]})]}),l.jsxs(no,{defaultValue:"active",className:"flex-1 flex flex-col",children:[l.jsx("div",{className:"px-4 pt-3",children:l.jsxs(ks,{className:"w-full",children:[l.jsxs(Ze,{value:"active",className:"flex-1",children:["To Do",M.length>0&&l.jsx(ue,{variant:"secondary",className:"ml-1.5 text-[10px] h-4 min-w-4 px-1",children:M.length})]}),l.jsxs(Ze,{value:"history",className:"flex-1",children:[l.jsx(vC,{className:"h-3.5 w-3.5 mr-1"}),"History",D.length>0&&l.jsx(ue,{variant:"secondary",className:"ml-1.5 text-[10px] h-4 min-w-4 px-1",children:D.length})]})]})}),l.jsx(et,{value:"active",className:"flex-1 overflow-auto px-4 py-3 mt-0",children:y?l.jsx("div",{className:"flex items-center justify-center py-12",children:l.jsx(Bt,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):M.length===0?l.jsxs("div",{className:"flex flex-col items-center justify-center py-16 text-center",children:[l.jsx(Lo,{className:"h-12 w-12 text-success/40 mb-3"}),l.jsx("p",{className:"text-sm font-medium text-foreground",children:"All caught up!"}),l.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"No pending tasks"})]}):l.jsx("div",{className:"space-y-2",children:M.map((O,z)=>l.jsx(H,{item:O},`${O.type}-${O.data.id}`))})}),l.jsx(et,{value:"history",className:"flex-1 overflow-auto px-4 py-3 mt-0",children:D.length===0?l.jsxs("div",{className:"flex flex-col items-center justify-center py-16 text-center",children:[l.jsx(vC,{className:"h-12 w-12 text-muted-foreground/30 mb-3"}),l.jsx("p",{className:"text-sm font-medium text-foreground",children:"No completed tasks yet"}),l.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Tasks you complete will show up here"})]}):l.jsx("div",{className:"space-y-2",children:D.map(O=>l.jsx(H,{item:O},`${O.type}-${O.data.id}`))})})]}),l.jsx(Vb,{open:c,onOpenChange:d})]});const ne=({assignment:O})=>{const z=P(O.classId),F=U(O.dueDate),te=F<0,ee=F>=0&&F<=2;return l.jsx(NI,{id:O.id,type:"assignment",status:O.status,children:l.jsx(fe,{variant:"interactive",className:"group cursor-pointer",onClick:()=>O.classId&&t(`/classes/${O.classId}`),children:l.jsx(xe,{className:"p-4 pl-8",children:l.jsxs("div",{className:"flex items-start gap-3",children:[l.jsx("button",{onClick:Z=>{Z.stopPropagation(),T(O.id,O.status==="completed"?"todo":"completed")},className:"mt-0.5 shrink-0",children:O.status==="completed"?l.jsx(Lo,{className:"h-5 w-5 text-success"}):l.jsx(Gs,{className:"h-5 w-5 text-muted-foreground hover:text-primary transition-colors"})}),l.jsxs("div",{className:"flex-1 min-w-0",children:[l.jsxs("div",{className:"flex items-start justify-between gap-2",children:[l.jsx("h4",{className:B("font-medium text-foreground",O.status==="completed"&&"line-through text-muted-foreground"),children:O.title}),l.jsx(wt,{className:"h-4 w-4 text-muted-foreground shrink-0 mt-0.5"})]}),O.description&&l.jsx("p",{className:"text-sm text-muted-foreground mt-1 line-clamp-2",children:O.description}),l.jsxs("div",{className:"flex items-center gap-2 mt-3 flex-wrap",children:[l.jsx(ue,{variant:"class",style:{backgroundColor:`${z==null?void 0:z.color}20`,borderColor:`${z==null?void 0:z.color}50`,color:z==null?void 0:z.color},children:z==null?void 0:z.code}),l.jsx(ue,{variant:L(O.priority),children:O.priority}),l.jsxs("div",{className:B("flex items-center gap-1 text-xs",te?"text-destructive":ee?"text-warning":"text-muted-foreground"),children:[te?l.jsx(Vd,{className:"h-3 w-3"}):l.jsx(tr,{className:"h-3 w-3"}),l.jsx("span",{children:te?`${Math.abs(F)} days overdue`:F===0?"Due today":F===1?"Due tomorrow":`Due in ${F} days`})]})]})]})]})})})})},$=({todo:O})=>{const z=O.classes,F=O.due_date?U(O.due_date):null,te=F!==null&&F<0,ee=F!==null&&F>=0&&F<=2;return l.jsx(NI,{id:O.id,type:"classTodo",status:O.status,children:l.jsx(fe,{variant:"interactive",className:"group cursor-pointer",onClick:()=>O.class_id&&t(`/classes/${O.class_id}`),children:l.jsx(xe,{className:"p-4 pl-8",children:l.jsxs("div",{className:"flex items-start gap-3",children:[l.jsx("button",{onClick:Z=>{Z.stopPropagation(),A(O.id,O.status==="completed"?"todo":"completed")},className:"mt-0.5 shrink-0",children:O.status==="completed"?l.jsx(Lo,{className:"h-5 w-5 text-success"}):l.jsx(Gs,{className:"h-5 w-5 text-muted-foreground hover:text-primary transition-colors"})}),l.jsxs("div",{className:"flex-1 min-w-0",children:[l.jsxs("div",{className:"flex items-start justify-between gap-2",children:[l.jsx("h4",{className:B("font-medium text-foreground",O.status==="completed"&&"line-through text-muted-foreground"),children:O.title}),l.jsx(wt,{className:"h-4 w-4 text-muted-foreground shrink-0 mt-0.5"})]}),O.description&&l.jsx("p",{className:"text-sm text-muted-foreground mt-1 line-clamp-2",children:O.description}),l.jsxs("div",{className:"flex items-center gap-2 mt-3 flex-wrap",children:[z&&l.jsxs(ue,{variant:"class",style:{backgroundColor:`${z.color}20`,borderColor:`${z.color}50`,color:z.color},children:[l.jsx(vt,{className:"h-3 w-3 mr-1"}),z.code||z.name]}),l.jsx(ue,{variant:L(O.priority),children:O.priority}),F!==null&&l.jsxs("div",{className:B("flex items-center gap-1 text-xs",te?"text-destructive":ee?"text-warning":"text-muted-foreground"),children:[te?l.jsx(Vd,{className:"h-3 w-3"}):l.jsx(tr,{className:"h-3 w-3"}),l.jsx("span",{children:te?`${Math.abs(F)} days overdue`:F===0?"Due today":F===1?"Due tomorrow":`Due in ${F} days`})]})]})]})]})})})})},G=O=>l.jsx(ne,{assignment:O},O.id),J=O=>l.jsx($,{todo:O},O.id);return l.jsxs("div",{className:"min-h-screen p-4 sm:p-6",children:[l.jsxs("div",{className:"flex flex-col sm:flex-row items-start sm:items-center justify-between gap-3 mb-6 sm:mb-8",children:[l.jsxs("div",{className:"flex items-center gap-3",children:[l.jsx(co,{}),l.jsxs("div",{children:[l.jsx("h1",{className:"text-xl sm:text-2xl font-bold text-foreground",children:"To-Do & Assignments"}),l.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"Track your assignments and tasks across all classes"})]})]}),l.jsxs("div",{className:"flex items-center gap-2 w-full sm:w-auto",children:[l.jsxs(K,{variant:"outline",size:"sm",className:"flex-1 sm:flex-none",children:[l.jsx(mC,{className:"h-4 w-4 mr-2"}),"Filter"]}),l.jsxs(K,{variant:"glow",size:"sm",onClick:()=>d(!0),className:"flex-1 sm:flex-none",children:[l.jsx(Rt,{className:"h-4 w-4"}),"Add Task"]})]})]}),l.jsxs(no,{defaultValue:"all",className:"w-full",children:[l.jsxs(ks,{className:"mb-6",children:[l.jsxs(Ze,{value:"all",children:["All Tasks",(v.length>0||r.length>0)&&l.jsx(ue,{variant:"secondary",className:"ml-1 text-xs",children:v.length+r.length})]}),l.jsxs(Ze,{value:"ai-extracted",className:"gap-2",children:[l.jsx(Nr,{className:"h-3.5 w-3.5"}),"AI Extracted",h.length>0&&l.jsx(ue,{variant:"secondary",className:"ml-1 text-xs",children:h.length})]})]}),l.jsx(et,{value:"all",children:y?l.jsx("div",{className:"flex items-center justify-center py-12",children:l.jsx(Bt,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):l.jsx(zO,{sensors:o,onDragStart:I,onDragEnd:V,children:l.jsxs("div",{className:"flex gap-6 overflow-x-auto pb-4",children:[l.jsx(Hb,{columnId:"todo",title:"To Do",items:x,classTodoItems:S,icon:Gs,iconColor:"bg-secondary text-secondary-foreground",renderAssignment:G,renderClassTodo:J}),l.jsx(Hb,{columnId:"in-progress",title:"In Progress",items:w,classTodoItems:C,icon:tr,iconColor:"bg-warning/20 text-warning",renderAssignment:G,renderClassTodo:J}),l.jsx(Hb,{columnId:"completed",title:"Completed",items:b,classTodoItems:N,icon:Lo,iconColor:"bg-success/20 text-success",renderAssignment:G,renderClassTodo:J})]})})}),l.jsx(et,{value:"ai-extracted",children:f?l.jsx("div",{className:"flex items-center justify-center py-12",children:l.jsx(Bt,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):h.length===0?l.jsx(fe,{className:"border-dashed",children:l.jsxs(xe,{className:"p-12 text-center",children:[l.jsx("div",{className:"mx-auto w-16 h-16 rounded-full bg-primary/10 flex items-center justify-center mb-4",children:l.jsx(Nr,{className:"h-8 w-8 text-primary"})}),l.jsx("h3",{className:"text-lg font-semibold text-foreground mb-2",children:"No AI-extracted to-dos yet"}),l.jsx("p",{className:"text-sm text-muted-foreground max-w-md mx-auto",children:"Record notes during your lectures and our AI will automatically extract to-dos, assignments, and action items for you."})]})}):l.jsxs("div",{className:"flex gap-6 overflow-x-auto pb-4",children:[l.jsxs("div",{className:"flex-1 min-w-[300px]",children:[l.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[l.jsx("div",{className:"p-1.5 rounded-lg bg-secondary text-secondary-foreground",children:l.jsx(Gs,{className:"h-4 w-4"})}),l.jsx("h3",{className:"font-semibold text-foreground",children:"To Do"}),l.jsx(ue,{variant:"secondary",className:"ml-auto",children:E.length})]}),l.jsxs("div",{className:"space-y-3",children:[E.map(O=>l.jsx(Wb,{todo:O,onStatusChange:p,onDelete:g},O.id)),E.length===0&&l.jsx(fe,{className:"border-dashed",children:l.jsx(xe,{className:"p-6 text-center",children:l.jsx("p",{className:"text-sm text-muted-foreground",children:"No items"})})})]})]}),l.jsxs("div",{className:"flex-1 min-w-[300px]",children:[l.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[l.jsx("div",{className:"p-1.5 rounded-lg bg-warning/20 text-warning",children:l.jsx(tr,{className:"h-4 w-4"})}),l.jsx("h3",{className:"font-semibold text-foreground",children:"In Progress"}),l.jsx(ue,{variant:"secondary",className:"ml-auto",children:j.length})]}),l.jsxs("div",{className:"space-y-3",children:[j.map(O=>l.jsx(Wb,{todo:O,onStatusChange:p,onDelete:g},O.id)),j.length===0&&l.jsx(fe,{className:"border-dashed",children:l.jsx(xe,{className:"p-6 text-center",children:l.jsx("p",{className:"text-sm text-muted-foreground",children:"No items"})})})]})]}),l.jsxs("div",{className:"flex-1 min-w-[300px]",children:[l.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[l.jsx("div",{className:"p-1.5 rounded-lg bg-success/20 text-success",children:l.jsx(Lo,{className:"h-4 w-4"})}),l.jsx("h3",{className:"font-semibold text-foreground",children:"Completed"}),l.jsx(ue,{variant:"secondary",className:"ml-auto",children:_.length})]}),l.jsxs("div",{className:"space-y-3",children:[_.map(O=>l.jsx(Wb,{todo:O,onStatusChange:p,onDelete:g},O.id)),_.length===0&&l.jsx(fe,{className:"border-dashed",children:l.jsx(xe,{className:"p-6 text-center",children:l.jsx("p",{className:"text-sm text-muted-foreground",children:"No items"})})})]})]})]})})]}),l.jsx(Vb,{open:c,onOpenChange:d})]})}function Dte(){const{classes:t,events:e,notes:r,assignments:n}=Ot(),[s,o]=m.useState(null),i=s?t.find(h=>h.id===s):null,a=s?r.filter(h=>h.classId===s):[],c=s?e.filter(h=>h.classId===s):[],d=s?e.find(h=>h.classId===s&&h.type==="exam"):null,u=h=>r.filter(f=>f.classId===h).length;return l.jsxs("div",{className:"min-h-screen",children:[l.jsx("header",{className:"border-b border-border bg-background/80 backdrop-blur-sm px-4 sm:px-6 py-4",children:l.jsxs("div",{className:"flex flex-col sm:flex-row items-start sm:items-center justify-between gap-3",children:[l.jsxs("div",{className:"flex items-center gap-3",children:[l.jsx(co,{}),l.jsx("div",{className:"p-2 rounded-xl gradient-primary",children:l.jsx(Wy,{className:"h-6 w-6 text-primary-foreground"})}),l.jsxs("div",{children:[l.jsx("h1",{className:"text-xl sm:text-2xl font-bold text-foreground",children:"Study Mode"}),l.jsx("p",{className:"text-sm text-muted-foreground",children:"Aggregate notes by class for focused exam prep"})]})]}),l.jsx("div",{className:"flex items-center gap-2 w-full sm:w-auto",children:l.jsxs("div",{className:"relative flex-1 sm:flex-none",children:[l.jsx(Ud,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),l.jsx(Ne,{placeholder:"Search notes...",className:"pl-9 w-full sm:w-64"})]})})]})}),l.jsxs("div",{className:"flex flex-col md:flex-row",children:[l.jsxs("aside",{className:"w-full md:w-72 border-b md:border-b-0 md:border-r border-border p-4 md:min-h-[calc(100vh-73px)]",children:[l.jsx("h2",{className:"text-sm font-semibold text-muted-foreground uppercase tracking-wider mb-4",children:"Select a Class"}),l.jsx("div",{className:"flex md:flex-col gap-2 overflow-x-auto md:overflow-x-visible pb-2 md:pb-0",children:t.map(h=>{const f=u(h.id),p=s===h.id;return l.jsx("button",{onClick:()=>o(h.id),className:B("w-full text-left p-3 rounded-lg transition-all duration-200 shrink-0","border","md:w-full w-auto",p?"border-primary/50 bg-primary/5 shadow-sm":"border-transparent hover:bg-secondary hover:border-border"),children:l.jsxs("div",{className:"flex items-center gap-3",children:[l.jsx("div",{className:"h-10 w-10 rounded-lg flex items-center justify-center",style:{backgroundColor:`${h.color}20`},children:l.jsx(vt,{className:"h-5 w-5",style:{color:h.color}})}),l.jsxs("div",{className:"flex-1 min-w-0",children:[l.jsx("p",{className:"font-medium text-foreground truncate",children:h.code}),l.jsx("p",{className:"text-xs text-muted-foreground truncate",children:h.name})]}),l.jsx(ue,{variant:"secondary",className:"shrink-0",children:f})]})},h.id)})})]}),l.jsx("main",{className:"flex-1 p-6",children:i?l.jsxs("div",{className:"space-y-6",children:[l.jsxs("div",{className:"flex items-start justify-between",children:[l.jsxs("div",{children:[l.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[l.jsx(ue,{variant:"class",className:"text-sm px-3 py-1",style:{backgroundColor:`${i.color}20`,borderColor:`${i.color}50`,color:i.color},children:i.code}),i.instructor&&l.jsx("span",{className:"text-sm text-muted-foreground",children:i.instructor})]}),l.jsx("h2",{className:"text-2xl font-bold text-foreground",children:i.name})]}),l.jsxs("div",{className:"flex gap-2 flex-wrap",children:[l.jsxs(K,{variant:"outline",size:"sm",children:[l.jsx(mC,{className:"h-4 w-4 mr-2"}),"Filter Notes"]}),l.jsxs(K,{variant:"glow",size:"sm",children:[l.jsx(Nr,{className:"h-4 w-4"}),"Generate Study Guide"]})]})]}),d&&l.jsx(fe,{className:"border-warning/50 bg-warning/5",children:l.jsx(xe,{className:"p-4",children:l.jsxs("div",{className:"flex items-center gap-4",children:[l.jsx("div",{className:"p-3 rounded-lg bg-warning/20",children:l.jsx(uL,{className:"h-6 w-6 text-warning"})}),l.jsxs("div",{className:"flex-1",children:[l.jsx("h3",{className:"font-semibold text-foreground",children:"Upcoming Exam"}),l.jsxs("p",{className:"text-sm text-muted-foreground",children:[d.title," · ",pe(new Date(d.date),"EEEE, MMMM d")]})]}),l.jsxs(K,{children:[l.jsx(qy,{className:"h-4 w-4 mr-2"}),"Start Review"]})]})})}),l.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-4",children:[l.jsx(fe,{children:l.jsxs(xe,{className:"p-4 flex items-center gap-3",children:[l.jsx("div",{className:"p-2 rounded-lg bg-primary/10",children:l.jsx(zt,{className:"h-5 w-5 text-primary"})}),l.jsxs("div",{children:[l.jsx("p",{className:"text-2xl font-bold text-foreground",children:a.length}),l.jsx("p",{className:"text-xs text-muted-foreground",children:"Total Notes"})]})]})}),l.jsx(fe,{children:l.jsxs(xe,{className:"p-4 flex items-center gap-3",children:[l.jsx("div",{className:"p-2 rounded-lg bg-success/10",children:l.jsx(Sr,{className:"h-5 w-5 text-success"})}),l.jsxs("div",{children:[l.jsx("p",{className:"text-2xl font-bold text-foreground",children:c.length}),l.jsx("p",{className:"text-xs text-muted-foreground",children:"Lectures"})]})]})}),l.jsx(fe,{children:l.jsxs(xe,{className:"p-4 flex items-center gap-3",children:[l.jsx("div",{className:"p-2 rounded-lg bg-warning/10",children:l.jsx(tr,{className:"h-5 w-5 text-warning"})}),l.jsxs("div",{children:[l.jsxs("p",{className:"text-2xl font-bold text-foreground",children:[Math.round(a.reduce((h,f)=>{var p;return h+(((p=f.transcription)==null?void 0:p.length)||f.content.length)},0)/1e3),"k"]}),l.jsx("p",{className:"text-xs text-muted-foreground",children:"Words"})]})]})})]}),l.jsxs("div",{children:[l.jsx("h3",{className:"text-lg font-semibold text-foreground mb-4",children:"All Notes"}),a.length===0?l.jsx(fe,{className:"border-dashed",children:l.jsx(xe,{className:"p-8 text-center",children:l.jsx("p",{className:"text-muted-foreground",children:"No notes for this class yet"})})}):l.jsx("div",{className:"space-y-3",children:a.map(h=>{const f=e.find(p=>p.id===h.eventId);return l.jsx(fe,{variant:"interactive",children:l.jsx(xe,{className:"p-4",children:l.jsxs("div",{className:"flex items-start gap-4",children:[l.jsx("div",{className:"p-2 rounded-lg bg-secondary shrink-0",children:l.jsx(zt,{className:"h-5 w-5 text-muted-foreground"})}),l.jsxs("div",{className:"flex-1 min-w-0",children:[l.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[l.jsx("span",{className:"font-medium text-foreground",children:(f==null?void 0:f.title)||"Untitled Note"}),l.jsx("span",{className:"text-xs text-muted-foreground",children:pe(new Date(h.createdAt),"MMM d, yyyy")})]}),l.jsx("p",{className:"text-sm text-muted-foreground line-clamp-2",children:h.transcription||h.content}),h.topics.length>0&&l.jsx("div",{className:"flex flex-wrap gap-1 mt-2",children:h.topics.map(p=>l.jsx(ue,{variant:"secondary",className:"text-xs",children:p},p))})]}),l.jsx(wt,{className:"h-5 w-5 text-muted-foreground shrink-0"})]})})},h.id)})})]})]}):l.jsxs("div",{className:"flex flex-col items-center justify-center h-[calc(100vh-200px)]",children:[l.jsx("div",{className:"w-20 h-20 rounded-full bg-secondary flex items-center justify-center mb-4",children:l.jsx(vt,{className:"h-10 w-10 text-muted-foreground"})}),l.jsx("h2",{className:"text-xl font-semibold text-foreground mb-2",children:"Select a class to study"}),l.jsx("p",{className:"text-muted-foreground text-center max-w-md",children:"Choose a class from the sidebar to see all your notes, generate summaries, and prepare for exams"})]})})]})]})}function Lte(){const[t,e]=m.useState([]),[r,n]=m.useState(!0),s=m.useCallback(async()=>{try{const{data:{user:g}}=await q.auth.getUser();if(!g){e([]),n(!1);return}const{data:v,error:y}=await q.from("study_groups").select("*").eq("owner_id",g.id);if(y)throw y;const{data:x,error:w}=await q.from("study_group_members").select("group_id").eq("user_id",g.id);if(w)throw w;const b=(x==null?void 0:x.map(E=>E.group_id))||[];let k=[];if(b.length>0){const{data:E,error:j}=await q.from("study_groups").select("*").in("id",b);if(j)throw j;k=E||[]}const S=[...v||[],...k],C=Array.from(new Map(S.map(E=>[E.id,E])).values()),N=await Promise.all(C.map(async E=>{const{count:j}=await q.from("study_group_members").select("*",{count:"exact",head:!0}).eq("group_id",E.id);return{...E,member_count:(j||0)+1}}));e(N)}catch(g){console.error("Error fetching study groups:",g),Se.error("Failed to load study groups")}finally{n(!1)}},[]);return m.useEffect(()=>{s()},[s]),{groups:t,loading:r,refetch:s,createGroup:async g=>{try{const{data:{user:v}}=await q.auth.getUser();if(!v)throw new Error("Not authenticated");const{data:y,error:x}=await q.from("study_groups").insert({name:g.name,description:g.description||null,class_id:g.class_id||null,school_name:g.school_name||null,owner_id:v.id}).select().single();if(x)throw x;return Se.success("Study group created!"),await s(),y}catch(v){return console.error("Error creating group:",v),Se.error("Failed to create study group"),null}},joinGroupByCode:async g=>{try{const{data:{user:v}}=await q.auth.getUser();if(!v)throw new Error("Not authenticated");const{data:y,error:x}=await q.from("study_groups").select("id, name, owner_id").eq("invite_code",g.toLowerCase().trim()).single();if(x||!y)return Se.error("Invalid invite code"),null;if(y.owner_id===v.id)return Se.error("You are the owner of this group"),null;const{data:w}=await q.from("study_group_members").select("id").eq("group_id",y.id).eq("user_id",v.id).single();if(w)return Se.error("You are already a member of this group"),null;const{error:b}=await q.from("study_group_members").insert({group_id:y.id,user_id:v.id});if(b)throw b;return Se.success(`Joined "${y.name}"!`),await s(),y}catch(v){return console.error("Error joining group:",v),Se.error("Failed to join group"),null}},inviteByEmail:async(g,v)=>{try{const{data:{user:y}}=await q.auth.getUser();if(!y)throw new Error("Not authenticated");const{error:x}=await q.from("study_group_invites").insert({group_id:g,email:v.toLowerCase().trim(),invited_by:y.id});if(x){if(x.code==="23505")return Se.error("This email has already been invited"),!1;throw x}return Se.success("Invitation sent!"),!0}catch(y){return console.error("Error inviting:",y),Se.error("Failed to send invitation"),!1}},getGroupMembers:async g=>{try{const{data:v,error:y}=await q.from("study_group_members").select("*").eq("group_id",g);if(y)throw y;const x=(v==null?void 0:v.map(k=>k.user_id))||[];if(x.length===0)return[];const{data:w}=await q.from("profiles").select("user_id, display_name, email, avatar_url").in("user_id",x),b=new Map(w==null?void 0:w.map(k=>[k.user_id,k]));return(v||[]).map(k=>({...k,profile:b.get(k.user_id)||void 0}))}catch(v){return console.error("Error fetching members:",v),[]}},getSharedNotes:async g=>{try{const{data:v,error:y}=await q.from("shared_notes").select(` *, notes:note_id (id, title, content, created_at) `).eq("group_id",g).order("shared_at",{ascending:!1});if(y)throw y;const x=[...new Set((v==null?void 0:v.map(k=>k.shared_by))||[])],{data:w}=await q.from("profiles").select("user_id, display_name, email").in("user_id",x),b=new Map(w==null?void 0:w.map(k=>[k.user_id,k]));return(v||[]).map(k=>({...k,note:k.notes,sharer:b.get(k.shared_by)||void 0}))}catch(v){return console.error("Error fetching shared notes:",v),[]}},shareNote:async(g,v)=>{try{const{data:{user:y}}=await q.auth.getUser();if(!y)throw new Error("Not authenticated");const{error:x}=await q.from("shared_notes").insert({note_id:g,group_id:v,shared_by:y.id});if(x){if(x.code==="23505")return Se.error("This note is already shared with the group"),!1;throw x}return Se.success("Note shared with group!"),!0}catch(y){return console.error("Error sharing note:",y),Se.error("Failed to share note"),!1}},getAttendanceLeaderboard:async g=>{try{const{data:v}=await q.from("study_groups").select("class_id, owner_id").eq("id",g).single();if(!v)return[];const{data:y}=await q.from("study_group_members").select("user_id").eq("group_id",g),x=[v.owner_id,...(y==null?void 0:y.map(b=>b.user_id))||[]],w=[];for(const b of x){let k=0;if(v.class_id){const{count:C}=await q.from("sessions").select("*",{count:"exact",head:!0}).eq("user_id",b).eq("class_id",v.class_id).eq("attendance","present");k=C||0}const{data:S}=await q.from("profiles").select("display_name, email, avatar_url").eq("user_id",b).single();w.push({user_id:b,display_name:(S==null?void 0:S.display_name)||null,email:(S==null?void 0:S.email)||"Unknown",avatar_url:(S==null?void 0:S.avatar_url)||null,attendance_count:k})}return w.sort((b,k)=>k.attendance_count-b.attendance_count)}catch(v){return console.error("Error fetching leaderboard:",v),[]}},findGroupsBySchool:async g=>{try{const{data:v,error:y}=await q.from("study_groups").select("*").ilike("school_name",`%${g}%`);if(y)throw y;return v||[]}catch(v){return console.error("Error finding groups:",v),[]}},leaveGroup:async g=>{try{const{data:{user:v}}=await q.auth.getUser();if(!v)throw new Error("Not authenticated");const{error:y}=await q.from("study_group_members").delete().eq("group_id",g).eq("user_id",v.id);if(y)throw y;return Se.success("Left the group"),await s(),!0}catch(v){return console.error("Error leaving group:",v),Se.error("Failed to leave group"),!1}}}}function $te(){const[t,e]=m.useState(!1),[r,n]=m.useState([]),[s,o]=m.useState(!1);return{generating:t,studyGuides:r,loading:s,generateStudyGuide:async d=>{e(!0);try{const{data:{session:u}}=await q.auth.getSession();if(!u)return Se.error("Please sign in to generate a study guide"),null;const h=await fetch("https://jqoaxvwjqgjxmenvuwql.supabase.co/functions/v1/generate-study-guide",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${u.access_token}`},body:JSON.stringify(d)});if(!h.ok){const p=await h.json();if(h.status===429)return Se.error("Rate limit exceeded. Please try again in a moment."),null;if(h.status===402)return Se.error("AI credits exhausted. Please add credits to continue."),null;throw new Error(p.error||"Failed to generate study guide")}const f=await h.json();if(f.error)throw new Error(f.error);return Se.success("Study guide generated!"),f}catch(u){return console.error("Error generating study guide:",u),Se.error(u instanceof Error?u.message:"Failed to generate study guide"),null}finally{e(!1)}},fetchStudyGuides:async d=>{o(!0);try{const{data:{user:u}}=await q.auth.getUser();if(!u){n([]);return}let h=q.from("study_guides").select("*").eq("user_id",u.id).order("generated_at",{ascending:!1});d&&(h=h.eq("class_id",d));const{data:f,error:p}=await h;if(p)throw p;const g=(f||[]).map(v=>({...v,key_concepts:v.key_concepts||[],practice_questions:v.practice_questions||[],flashcards:v.flashcards||[]}));n(g)}catch(u){console.error("Error fetching study guides:",u),Se.error("Failed to load study guides")}finally{o(!1)}},deleteStudyGuide:async d=>{try{const{error:u}=await q.from("study_guides").delete().eq("id",d);if(u)throw u;return n(h=>h.filter(f=>f.id!==d)),Se.success("Study guide deleted"),!0}catch(u){return console.error("Error deleting study guide:",u),Se.error("Failed to delete study guide"),!1}}}}function Fte({open:t,onOpenChange:e,onCreateGroup:r}){const[n,s]=m.useState(""),[o,i]=m.useState(""),[a,c]=m.useState(""),[d,u]=m.useState(""),[h,f]=m.useState([]),[p,g]=m.useState(!1),[v,y]=m.useState(!1);W.useEffect(()=>{t&&x()},[t]);const x=async()=>{g(!0);try{const{data:{user:b}}=await q.auth.getUser();if(!b)return;const{data:k}=await q.from("classes").select("id, name").eq("user_id",b.id).order("name");f(k||[])}catch(b){console.error("Error fetching classes:",b)}finally{g(!1)}},w=async b=>{if(b.preventDefault(),!!n.trim()){y(!0);try{await r({name:n.trim(),description:o.trim()||void 0,class_id:a||void 0,school_name:d.trim()||void 0}),s(""),i(""),c(""),u(""),e(!1)}finally{y(!1)}}};return l.jsx(wn,{open:t,onOpenChange:e,children:l.jsx(nn,{className:"sm:max-w-md",children:l.jsxs("form",{onSubmit:w,children:[l.jsxs(bn,{children:[l.jsxs(kn,{className:"flex items-center gap-2",children:[l.jsx($r,{className:"h-5 w-5 text-primary"}),"Create Study Group"]}),l.jsx(Wl,{children:"Create a group to share notes and compete with classmates"})]}),l.jsxs("div",{className:"space-y-4 py-4",children:[l.jsxs("div",{className:"space-y-2",children:[l.jsx(de,{htmlFor:"name",children:"Group Name *"}),l.jsx(Ne,{id:"name",value:n,onChange:b=>s(b.target.value),placeholder:"e.g., Bio 101 Study Squad",required:!0})]}),l.jsxs("div",{className:"space-y-2",children:[l.jsx(de,{htmlFor:"description",children:"Description"}),l.jsx(uh,{id:"description",value:o,onChange:b=>i(b.target.value),placeholder:"What's this group about?",rows:2})]}),l.jsxs("div",{className:"space-y-2",children:[l.jsx(de,{htmlFor:"class",children:"Link to Class"}),l.jsxs(_s,{value:a,onValueChange:c,children:[l.jsx(ss,{children:l.jsx(Ts,{placeholder:"Select a class (optional)"})}),l.jsxs(is,{children:[l.jsx(Fe,{value:"none",children:"No class"}),h.map(b=>l.jsx(Fe,{value:b.id,children:b.name},b.id))]})]})]}),l.jsxs("div",{className:"space-y-2",children:[l.jsx(de,{htmlFor:"school",children:"School Name"}),l.jsx(Ne,{id:"school",value:d,onChange:b=>u(b.target.value),placeholder:"e.g., State University"}),l.jsx("p",{className:"text-xs text-muted-foreground",children:"Helps classmates find your group"})]})]}),l.jsxs(n_,{children:[l.jsx(K,{type:"button",variant:"outline",onClick:()=>e(!1),children:"Cancel"}),l.jsxs(K,{type:"submit",disabled:v||!n.trim(),children:[v?l.jsx(Bt,{className:"h-4 w-4 animate-spin mr-2"}):l.jsx(Rt,{className:"h-4 w-4 mr-2"}),"Create Group"]})]})]})})})}function zte({open:t,onOpenChange:e,onJoinByCode:r,onFindBySchool:n}){const[s,o]=m.useState(""),[i,a]=m.useState(""),[c,d]=m.useState(!1),[u,h]=m.useState(!1),[f,p]=m.useState([]),g=async y=>{if(y.preventDefault(),!!s.trim()){d(!0);try{await r(s.trim())&&(o(""),e(!1))}finally{d(!1)}}},v=async()=>{if(i.trim()){h(!0);try{const y=await n(i.trim());p(y)}finally{h(!1)}}};return l.jsx(wn,{open:t,onOpenChange:e,children:l.jsxs(nn,{className:"sm:max-w-lg",children:[l.jsxs(bn,{children:[l.jsxs(kn,{className:"flex items-center gap-2",children:[l.jsx($r,{className:"h-5 w-5 text-primary"}),"Join Study Group"]}),l.jsx(Wl,{children:"Join with an invite code or find groups at your school"})]}),l.jsxs(no,{defaultValue:"code",className:"mt-2",children:[l.jsxs(ks,{className:"grid w-full grid-cols-2",children:[l.jsxs(Ze,{value:"code",className:"gap-2",children:[l.jsx(Bd,{className:"h-4 w-4"}),"Invite Code"]}),l.jsxs(Ze,{value:"school",className:"gap-2",children:[l.jsx(Ud,{className:"h-4 w-4"}),"Find by School"]})]}),l.jsx(et,{value:"code",className:"mt-4",children:l.jsxs("form",{onSubmit:g,className:"space-y-4",children:[l.jsxs("div",{className:"space-y-2",children:[l.jsx(de,{htmlFor:"invite-code",children:"Invite Code"}),l.jsx(Ne,{id:"invite-code",value:s,onChange:y=>o(y.target.value),placeholder:"Enter 8-character code",className:"font-mono text-lg tracking-wider",maxLength:8}),l.jsx("p",{className:"text-xs text-muted-foreground",children:"Ask your group member for the invite code"})]}),l.jsxs(K,{type:"submit",className:"w-full",disabled:c||s.length<1,children:[c?l.jsx(Bt,{className:"h-4 w-4 animate-spin mr-2"}):l.jsx(Bd,{className:"h-4 w-4 mr-2"}),"Join Group"]})]})}),l.jsxs(et,{value:"school",className:"mt-4 space-y-4",children:[l.jsxs("div",{className:"flex gap-2",children:[l.jsx(Ne,{value:i,onChange:y=>a(y.target.value),placeholder:"Search by school name...",onKeyDown:y=>y.key==="Enter"&&v()}),l.jsx(K,{onClick:v,disabled:u,children:u?l.jsx(Bt,{className:"h-4 w-4 animate-spin"}):l.jsx(Ud,{className:"h-4 w-4"})})]}),l.jsx("div",{className:"space-y-2 max-h-[300px] overflow-y-auto",children:f.length===0?l.jsx("p",{className:"text-center text-muted-foreground py-8",children:"Search for groups at your school"}):f.map(y=>l.jsxs(fe,{variant:"interactive",children:[l.jsxs(Nt,{className:"p-4 pb-2",children:[l.jsx(Ct,{className:"text-base",children:y.name}),l.jsxs(uo,{className:"text-xs",children:[y.school_name," • ",y.member_count||1," member(s)"]})]}),y.description&&l.jsx(xe,{className:"p-4 pt-0",children:l.jsx("p",{className:"text-sm text-muted-foreground line-clamp-2",children:y.description})})]},y.id))})]})]})]})})}function Bte({group:t,isOwner:e,onClick:r}){const n=s=>{s.stopPropagation(),navigator.clipboard.writeText(t.invite_code),Se.success("Invite code copied!")};return l.jsxs(fe,{variant:"interactive",onClick:r,children:[l.jsx(Nt,{className:"pb-2",children:l.jsxs("div",{className:"flex items-start justify-between",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("div",{className:"p-2 rounded-lg bg-primary/10",children:l.jsx($r,{className:"h-4 w-4 text-primary"})}),l.jsxs("div",{children:[l.jsxs(Ct,{className:"text-base flex items-center gap-2",children:[t.name,e&&l.jsx(Cl,{className:"h-3.5 w-3.5 text-warning"})]}),t.school_name&&l.jsx(uo,{className:"text-xs",children:t.school_name})]})]}),l.jsx(wt,{className:"h-4 w-4 text-muted-foreground"})]})}),l.jsxs(xe,{className:"pt-2",children:[t.description&&l.jsx("p",{className:"text-sm text-muted-foreground line-clamp-2 mb-3",children:t.description}),l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx("div",{className:"flex items-center gap-2",children:l.jsxs(ue,{variant:"secondary",className:"text-xs",children:[t.member_count||1," member",(t.member_count||1)>1?"s":""]})}),l.jsxs(K,{size:"sm",variant:"ghost",className:"h-7 text-xs gap-1",onClick:n,children:[l.jsx(Vy,{className:"h-3 w-3"}),t.invite_code]})]})]})]})}function Ute({open:t,onOpenChange:e,group:r,currentUserId:n,onGetMembers:s,onGetSharedNotes:o,onGetLeaderboard:i,onInviteByEmail:a,onLeaveGroup:c}){const[d,u]=m.useState([]),[h,f]=m.useState([]),[p,g]=m.useState([]),[v,y]=m.useState(!0),[x,w]=m.useState(""),[b,k]=m.useState(!1),[S,C]=m.useState(!1),N=(r==null?void 0:r.owner_id)===n;m.useEffect(()=>{t&&r&&E()},[t,r]);const E=async()=>{if(r){y(!0);try{const[T,A,I]=await Promise.all([s(r.id),o(r.id),i(r.id)]);u(T),f(A),g(I)}finally{y(!1)}}},j=()=>{r&&(navigator.clipboard.writeText(r.invite_code),Se.success("Invite code copied!"))},_=async()=>{if(!(!r||!x.trim())){k(!0);try{await a(r.id,x)&&w("")}finally{k(!1)}}},P=async()=>{if(!(!r||N)){C(!0);try{await c(r.id)&&e(!1)}finally{C(!1)}}};return r?l.jsx(Vp,{open:t,onOpenChange:e,children:l.jsxs(bu,{className:"w-full sm:max-w-lg",children:[l.jsx(ku,{children:l.jsxs("div",{className:"flex items-center gap-3",children:[l.jsx("div",{className:"p-2 rounded-lg bg-primary/10",children:l.jsx($r,{className:"h-5 w-5 text-primary"})}),l.jsxs("div",{children:[l.jsx(Wp,{children:r.name}),r.school_name&&l.jsx("p",{className:"text-sm text-muted-foreground",children:r.school_name})]})]})}),l.jsxs("div",{className:"mt-4 space-y-4",children:[l.jsxs(fe,{children:[l.jsx(Nt,{className:"p-4 pb-2",children:l.jsx(Ct,{className:"text-sm",children:"Invite Friends"})}),l.jsxs(xe,{className:"p-4 pt-2 space-y-3",children:[l.jsx("div",{className:"flex items-center gap-2",children:l.jsxs(K,{variant:"outline",size:"sm",className:"flex-1 justify-between",onClick:j,children:[l.jsx("span",{className:"font-mono tracking-wider",children:r.invite_code}),l.jsx(Vy,{className:"h-4 w-4"})]})}),l.jsxs("div",{className:"flex gap-2",children:[l.jsx(Ne,{type:"email",placeholder:"friend@email.com",value:x,onChange:T=>w(T.target.value),onKeyDown:T=>T.key==="Enter"&&_()}),l.jsx(K,{size:"icon",onClick:_,disabled:b,children:b?l.jsx(Bt,{className:"h-4 w-4 animate-spin"}):l.jsx(oL,{className:"h-4 w-4"})})]})]})]}),l.jsxs(no,{defaultValue:"members",className:"flex-1",children:[l.jsxs(ks,{className:"w-full grid grid-cols-3",children:[l.jsxs(Ze,{value:"members",className:"gap-1.5",children:[l.jsx($r,{className:"h-4 w-4"}),l.jsx("span",{className:"hidden sm:inline",children:"Members"})]}),l.jsxs(Ze,{value:"notes",className:"gap-1.5",children:[l.jsx(zt,{className:"h-4 w-4"}),l.jsx("span",{className:"hidden sm:inline",children:"Notes"})]}),l.jsxs(Ze,{value:"leaderboard",className:"gap-1.5",children:[l.jsx(Yy,{className:"h-4 w-4"}),l.jsx("span",{className:"hidden sm:inline",children:"Leaderboard"})]})]}),l.jsx(et,{value:"members",className:"mt-4",children:l.jsx(Pn,{className:"h-[350px]",children:v?l.jsx("div",{className:"flex items-center justify-center py-8",children:l.jsx(Bt,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):l.jsxs("div",{className:"space-y-2",children:[l.jsxs("div",{className:"flex items-center gap-3 p-3 rounded-lg bg-muted/50",children:[l.jsx(ah,{className:"h-10 w-10",children:l.jsx(lh,{children:l.jsx(Cl,{className:"h-4 w-4 text-amber-500"})})}),l.jsxs("div",{className:"flex-1 min-w-0",children:[l.jsx("p",{className:"font-medium text-sm",children:"Owner"}),l.jsxs(ue,{variant:"secondary",className:"text-xs",children:[l.jsx(Cl,{className:"h-3 w-3 mr-1"}),"Group Creator"]})]})]}),d.map(T=>{var A,I,V,L,U;return l.jsxs("div",{className:"flex items-center gap-3 p-3 rounded-lg hover:bg-muted/50",children:[l.jsxs(ah,{className:"h-10 w-10",children:[l.jsx(yb,{src:((A=T.profile)==null?void 0:A.avatar_url)||void 0}),l.jsx(lh,{children:(((I=T.profile)==null?void 0:I.display_name)||((V=T.profile)==null?void 0:V.email)||"U")[0].toUpperCase()})]}),l.jsxs("div",{className:"flex-1 min-w-0",children:[l.jsx("p",{className:"font-medium text-sm truncate",children:((L=T.profile)==null?void 0:L.display_name)||((U=T.profile)==null?void 0:U.email)||"Unknown"}),l.jsxs("p",{className:"text-xs text-muted-foreground truncate",children:["Joined ",new Date(T.joined_at).toLocaleDateString()]})]})]},T.id)})]})})}),l.jsx(et,{value:"notes",className:"mt-4",children:l.jsx(Pn,{className:"h-[350px]",children:v?l.jsx("div",{className:"flex items-center justify-center py-8",children:l.jsx(Bt,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):h.length===0?l.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[l.jsx(zt,{className:"h-8 w-8 mx-auto mb-2 opacity-50"}),l.jsx("p",{children:"No shared notes yet"}),l.jsx("p",{className:"text-xs mt-1",children:"Share notes from your classes"})]}):l.jsx("div",{className:"space-y-2",children:h.map(T=>{var A,I,V;return l.jsx(fe,{children:l.jsxs(xe,{className:"p-3",children:[l.jsx("p",{className:"font-medium text-sm",children:((A=T.note)==null?void 0:A.title)||"Untitled Note"}),l.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:["Shared by ",((I=T.sharer)==null?void 0:I.display_name)||((V=T.sharer)==null?void 0:V.email)||"Unknown"," •"," ",new Date(T.shared_at).toLocaleDateString()]})]})},T.id)})})})}),l.jsx(et,{value:"leaderboard",className:"mt-4",children:l.jsx(Pn,{className:"h-[350px]",children:v?l.jsx("div",{className:"flex items-center justify-center py-8",children:l.jsx(Bt,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):p.length===0?l.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[l.jsx(Yy,{className:"h-8 w-8 mx-auto mb-2 opacity-50"}),l.jsx("p",{children:"No attendance data yet"}),l.jsx("p",{className:"text-xs mt-1",children:"Mark your class attendance to compete!"})]}):l.jsx("div",{className:"space-y-2",children:p.map((T,A)=>l.jsxs("div",{className:`flex items-center gap-3 p-3 rounded-lg ${A===0?"bg-primary/10 border border-primary/20":A===1?"bg-muted border border-muted-foreground/20":A===2?"bg-secondary border border-secondary-foreground/20":"hover:bg-muted/50"}`,children:[l.jsx("div",{className:"w-6 text-center font-bold text-lg",children:A===0?"🥇":A===1?"🥈":A===2?"🥉":A+1}),l.jsxs(ah,{className:"h-10 w-10",children:[l.jsx(yb,{src:T.avatar_url||void 0}),l.jsx(lh,{children:(T.display_name||T.email)[0].toUpperCase()})]}),l.jsx("div",{className:"flex-1 min-w-0",children:l.jsx("p",{className:"font-medium text-sm truncate",children:T.display_name||T.email})}),l.jsxs(ue,{variant:"outline",className:"font-mono",children:[T.attendance_count," classes"]})]},T.user_id))})})})]}),!N&&l.jsxs(K,{variant:"outline",className:"w-full text-destructive hover:text-destructive",onClick:P,disabled:S,children:[S?l.jsx(Bt,{className:"h-4 w-4 animate-spin mr-2"}):l.jsx(Q3,{className:"h-4 w-4 mr-2"}),"Leave Group"]})]})]})}):null}function Vte({open:t,onOpenChange:e,guide:r}){const[n,s]=m.useState(0),[o,i]=m.useState(!1),[a,c]=m.useState(new Set),[d,u]=m.useState(0),[h,f]=m.useState(!1),[p,g]=m.useState(new Map);if(!r)return null;const v=r.flashcards||[],y=r.practice_questions||[],x=r.key_concepts||[],w=()=>{s(0),i(!1),c(new Set)},b=j=>{j&&c(_=>new Set([..._,n])),i(!1),n{i(!1),n>0&&s(n-1)},S=v[n],C=y[d],N=v.length>0?(n+1)/v.length*100:0,E=y.length>0?(d+1)/y.length*100:0;return l.jsx(Vp,{open:t,onOpenChange:e,children:l.jsxs(bu,{className:"w-full sm:max-w-2xl",children:[l.jsx(ku,{children:l.jsxs("div",{className:"flex items-center gap-3",children:[l.jsx("div",{className:"p-2 rounded-lg bg-primary/10",children:l.jsx(vt,{className:"h-5 w-5 text-primary"})}),l.jsx(Wp,{children:r.title})]})}),l.jsxs(no,{defaultValue:"summary",className:"mt-4",children:[l.jsxs(ks,{className:"w-full grid grid-cols-4",children:[l.jsxs(Ze,{value:"summary",className:"gap-1.5",children:[l.jsx(vt,{className:"h-4 w-4"}),l.jsx("span",{className:"hidden sm:inline",children:"Summary"})]}),l.jsxs(Ze,{value:"concepts",className:"gap-1.5",children:[l.jsx(fC,{className:"h-4 w-4"}),l.jsx("span",{className:"hidden sm:inline",children:"Concepts"})]}),l.jsxs(Ze,{value:"questions",className:"gap-1.5",children:[l.jsx(I3,{className:"h-4 w-4"}),l.jsx("span",{className:"hidden sm:inline",children:"Quiz"})]}),l.jsxs(Ze,{value:"flashcards",className:"gap-1.5",children:[l.jsx(Y3,{className:"h-4 w-4"}),l.jsx("span",{className:"hidden sm:inline",children:"Cards"})]})]}),l.jsx(et,{value:"summary",className:"mt-4",children:l.jsx(Pn,{className:"h-[500px]",children:l.jsxs(fe,{children:[l.jsx(Nt,{children:l.jsx(Ct,{className:"text-lg",children:"Key Summary"})}),l.jsx(xe,{children:l.jsx("div",{className:"prose prose-sm dark:prose-invert max-w-none",children:(r.summary||"").split(` `).map((j,_)=>l.jsx("p",{className:"mb-3 text-muted-foreground",children:j},_))})})]})})}),l.jsx(et,{value:"concepts",className:"mt-4",children:l.jsx(Pn,{className:"h-[500px]",children:l.jsx("div",{className:"space-y-3",children:x.map((j,_)=>l.jsxs(fe,{children:[l.jsx(Nt,{className:"pb-2",children:l.jsxs(Ct,{className:"text-base flex items-center gap-2",children:[l.jsx(ue,{variant:"outline",className:"text-xs",children:_+1}),j.term]})}),l.jsx(xe,{children:l.jsx("p",{className:"text-sm text-muted-foreground",children:j.definition})})]},_))})})}),l.jsx(et,{value:"questions",className:"mt-4",children:l.jsxs("div",{className:"space-y-4",children:[l.jsxs("div",{className:"flex items-center justify-between text-sm text-muted-foreground",children:[l.jsxs("span",{children:["Question ",d+1," of ",y.length]}),l.jsxs("span",{children:[p.size," answered"]})]}),l.jsx(ch,{value:E,className:"h-2"}),C&&l.jsxs(fe,{className:"min-h-[300px]",children:[l.jsxs(Nt,{children:[l.jsx(ue,{variant:"secondary",className:"w-fit text-xs mb-2",children:C.type==="multiple_choice"?"Multiple Choice":"Short Answer"}),l.jsx(Ct,{className:"text-base font-normal leading-relaxed",children:C.question})]}),l.jsxs(xe,{className:"space-y-3",children:[C.type==="multiple_choice"&&C.options&&l.jsx("div",{className:"space-y-2",children:C.options.map((j,_)=>l.jsxs("div",{className:`p-3 rounded-lg border transition-colors ${h&&j===C.answer?"bg-green-500/10 border-green-500/50":"hover:bg-muted/50"}`,children:[l.jsxs("span",{className:"font-medium mr-2",children:[String.fromCharCode(65+_),"."]}),j]},_))}),h&&l.jsxs("div",{className:"p-4 rounded-lg bg-primary/5 border border-primary/20 mt-4",children:[l.jsx("p",{className:"text-sm font-medium mb-1",children:"Answer:"}),l.jsx("p",{className:"text-sm",children:C.answer})]})]})]}),l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs(K,{variant:"outline",size:"sm",onClick:()=>{u(Math.max(0,d-1)),f(!1)},disabled:d===0,children:[l.jsx(Nl,{className:"h-4 w-4 mr-1"}),"Previous"]}),l.jsxs(K,{variant:"secondary",size:"sm",onClick:()=>f(!h),children:[h?l.jsx(z3,{className:"h-4 w-4 mr-1"}):l.jsx(B3,{className:"h-4 w-4 mr-1"}),h?"Hide":"Show"," Answer"]}),l.jsxs(K,{variant:"outline",size:"sm",onClick:()=>{u(Math.min(y.length-1,d+1)),f(!1)},disabled:d===y.length-1,children:["Next",l.jsx(wt,{className:"h-4 w-4 ml-1"})]})]})]})}),l.jsx(et,{value:"flashcards",className:"mt-4",children:l.jsxs("div",{className:"space-y-4",children:[l.jsxs("div",{className:"flex items-center justify-between text-sm text-muted-foreground",children:[l.jsxs("span",{children:["Card ",n+1," of ",v.length]}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsxs("span",{className:"text-green-600",children:[a.size," known"]}),l.jsxs(K,{variant:"ghost",size:"sm",className:"h-7 text-xs",onClick:w,children:[l.jsx(kC,{className:"h-3 w-3 mr-1"}),"Reset"]})]})]}),l.jsx(ch,{value:N,className:"h-2"}),S&&l.jsx(fe,{className:"min-h-[250px] flex items-center justify-center cursor-pointer transition-all hover:shadow-md",onClick:()=>i(!o),children:l.jsxs(xe,{className:"p-8 text-center",children:[l.jsx(ue,{variant:"outline",className:"mb-4",children:o?"Answer":"Question"}),l.jsx("p",{className:"text-lg",children:o?S.back:S.front}),!o&&l.jsx("p",{className:"text-xs text-muted-foreground mt-4",children:"Click to reveal answer"})]})}),l.jsxs("div",{className:"flex items-center justify-center gap-3",children:[l.jsx(K,{variant:"outline",size:"icon",onClick:k,disabled:n===0,children:l.jsx(Nl,{className:"h-4 w-4"})}),l.jsxs(K,{variant:"outline",className:"text-destructive hover:text-destructive hover:bg-destructive/10",onClick:()=>b(!1),disabled:n===v.length-1,children:[l.jsx(Wd,{className:"h-4 w-4 mr-1"}),"Still Learning"]}),l.jsxs(K,{variant:"outline",className:"text-primary hover:text-primary hover:bg-primary/10",onClick:()=>b(!0),disabled:n===v.length-1,children:[l.jsx(Qi,{className:"h-4 w-4 mr-1"}),"Got It"]}),l.jsx(K,{variant:"outline",size:"icon",onClick:()=>{i(!1),s(Math.min(v.length-1,n+1))},disabled:n===v.length-1,children:l.jsx(wt,{className:"h-4 w-4"})})]})]})})]})]})})}function Wte(){const{groups:t,loading:e,createGroup:r,joinGroupByCode:n,inviteByEmail:s,getGroupMembers:o,getSharedNotes:i,getAttendanceLeaderboard:a,findGroupsBySchool:c,leaveGroup:d}=Lte(),{studyGuides:u,loading:h,generating:f,generateStudyGuide:p,fetchStudyGuides:g}=$te(),{classes:v}=ua(),[y,x]=m.useState(!1),[w,b]=m.useState(!1),[k,S]=m.useState(null),[C,N]=m.useState(!1),[E,j]=m.useState(null),[_,P]=m.useState(!1),[T,A]=m.useState(""),I=v.map(M=>({id:M.id,name:M.name}));m.useEffect(()=>{g()},[]);const V=async()=>{if(!T){Se.error("Please select a class");return}const M=await p({classId:T});M&&(j(M),P(!0),g())},L=M=>{S(M),N(!0)},U=M=>{j(M),P(!0)};return l.jsxs("div",{className:"container mx-auto py-4 sm:py-6 md:py-8 px-4 max-w-6xl",children:[l.jsxs("div",{className:"flex flex-col sm:flex-row items-start sm:items-center justify-between gap-4 mb-6 sm:mb-8",children:[l.jsxs("div",{children:[l.jsxs("h1",{className:"text-xl sm:text-2xl md:text-3xl font-bold flex items-center gap-2 sm:gap-3",children:[l.jsx(co,{}),l.jsx($r,{className:"h-6 w-6 sm:h-8 sm:w-8 text-primary shrink-0"}),"Study Hub"]}),l.jsx("p",{className:"text-muted-foreground mt-1 text-sm sm:text-base",children:"Collaborate with classmates and generate AI study guides"})]}),l.jsxs("div",{className:"flex gap-2 w-full sm:w-auto flex-wrap sm:flex-nowrap",children:[l.jsxs(K,{variant:"outline",onClick:()=>b(!0),className:"flex-1 sm:flex-none min-h-[44px] touch-manipulation",children:[l.jsx(Bd,{className:"h-4 w-4 mr-2 shrink-0"}),"Join Group"]}),l.jsxs(K,{onClick:()=>x(!0),className:"flex-1 sm:flex-none min-h-[44px] touch-manipulation",children:[l.jsx(Rt,{className:"h-4 w-4 mr-2 shrink-0"}),"New Group"]})]})]}),l.jsxs(no,{defaultValue:"groups",className:"space-y-6",children:[l.jsxs(ks,{children:[l.jsxs(Ze,{value:"groups",className:"gap-2",children:[l.jsx($r,{className:"h-4 w-4"}),"Study Groups"]}),l.jsxs(Ze,{value:"guides",className:"gap-2",children:[l.jsx(vt,{className:"h-4 w-4"}),"Study Guides"]})]}),l.jsx(et,{value:"groups",children:e?l.jsx("div",{className:"flex items-center justify-center py-12",children:l.jsx(Bt,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):t.length===0?l.jsx(fe,{className:"border-dashed",children:l.jsxs(xe,{className:"flex flex-col items-center justify-center py-12",children:[l.jsx($r,{className:"h-12 w-12 text-muted-foreground mb-4"}),l.jsx("h3",{className:"text-lg font-medium mb-1",children:"No study groups yet"}),l.jsx("p",{className:"text-muted-foreground text-center mb-4",children:"Create a group to share notes and compete with classmates"}),l.jsxs("div",{className:"flex gap-2",children:[l.jsxs(K,{variant:"outline",onClick:()=>b(!0),children:[l.jsx(Bd,{className:"h-4 w-4 mr-2"}),"Join Group"]}),l.jsxs(K,{onClick:()=>x(!0),children:[l.jsx(Rt,{className:"h-4 w-4 mr-2"}),"Create Group"]})]})]})}):l.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:t.map(M=>l.jsx(Bte,{group:M,isOwner:!1,onClick:()=>L(M)},M.id))})}),l.jsxs(et,{value:"guides",className:"space-y-6",children:[l.jsxs(fe,{children:[l.jsxs(Nt,{children:[l.jsxs(Ct,{className:"flex items-center gap-2",children:[l.jsx(Nr,{className:"h-5 w-5 text-primary"}),"Generate Study Guide"]}),l.jsx(uo,{children:"AI will condense your notes into summaries, flashcards, and practice questions"})]}),l.jsxs(xe,{className:"flex flex-col sm:flex-row gap-3",children:[l.jsxs(_s,{value:T||"__placeholder__",onValueChange:M=>A(M==="__placeholder__"?"":M),children:[l.jsx(ss,{className:"flex-1",children:l.jsx(Ts,{placeholder:"Select a class"})}),l.jsxs(is,{children:[l.jsx(Fe,{value:"__placeholder__",children:I.length===0?"No classes available":"Select a class"}),I.map(M=>l.jsx(Fe,{value:M.id,children:M.name},M.id))]})]}),l.jsxs(K,{onClick:V,disabled:f||!T||T==="__placeholder__",children:[f?l.jsx(Bt,{className:"h-4 w-4 animate-spin mr-2"}):l.jsx(Nr,{className:"h-4 w-4 mr-2"}),"Generate"]})]})]}),h?l.jsx("div",{className:"flex items-center justify-center py-12",children:l.jsx(Bt,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):u.length===0?l.jsx(fe,{className:"border-dashed",children:l.jsxs(xe,{className:"flex flex-col items-center justify-center py-12",children:[l.jsx(vt,{className:"h-12 w-12 text-muted-foreground mb-4"}),l.jsx("h3",{className:"text-lg font-medium mb-1",children:"No study guides yet"}),l.jsx("p",{className:"text-muted-foreground text-center",children:"Generate your first study guide from your class notes"})]})}):l.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:u.map(M=>{var D,H,ne;return l.jsxs(fe,{variant:"interactive",onClick:()=>U(M),children:[l.jsxs(Nt,{className:"pb-2",children:[l.jsx("div",{className:"flex items-start justify-between",children:l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("div",{className:"p-2 rounded-lg bg-primary/10",children:l.jsx(vt,{className:"h-4 w-4 text-primary"})}),l.jsx(Ct,{className:"text-base",children:M.title})]})}),l.jsxs(uo,{className:"text-xs",children:["Generated ",new Date(M.generated_at).toLocaleDateString()]})]}),l.jsx(xe,{className:"pt-2",children:l.jsxs("div",{className:"flex flex-wrap gap-2",children:[l.jsxs(ue,{variant:"secondary",className:"text-xs",children:[((D=M.key_concepts)==null?void 0:D.length)||0," concepts"]}),l.jsxs(ue,{variant:"secondary",className:"text-xs",children:[((H=M.practice_questions)==null?void 0:H.length)||0," questions"]}),l.jsxs(ue,{variant:"secondary",className:"text-xs",children:[((ne=M.flashcards)==null?void 0:ne.length)||0," flashcards"]})]})})]},M.id)})})]})]}),l.jsx(Fte,{open:y,onOpenChange:x,onCreateGroup:r}),l.jsx(zte,{open:w,onOpenChange:b,onJoinByCode:n,onFindBySchool:c}),l.jsx(Ute,{open:C,onOpenChange:N,group:k,currentUserId:null,onGetMembers:o,onGetSharedNotes:i,onGetLeaderboard:a,onInviteByEmail:s,onLeaveGroup:d}),l.jsx(Vte,{open:_,onOpenChange:P,guide:E})]})}function Hte(){const{classes:t}=Ot(),e=N_,r=o=>t.find(i=>i.id===o),n=Sn(new Date,{weekStartsOn:1}),s=Pe(n,7);return l.jsxs("div",{className:"min-h-screen p-4 sm:p-6 max-w-5xl mx-auto",children:[l.jsxs("div",{className:"flex flex-col sm:flex-row items-start sm:items-center justify-between gap-3 mb-6 sm:mb-8",children:[l.jsxs("div",{children:[l.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[l.jsx(co,{}),l.jsx("div",{className:"p-2 rounded-xl gradient-primary",children:l.jsx(Nr,{className:"h-6 w-6 text-primary-foreground"})}),l.jsx("h1",{className:"text-2xl font-bold text-foreground",children:"Weekly Recap"})]}),l.jsx("p",{className:"text-muted-foreground",children:"AI-powered summaries of what you learned each week"})]}),l.jsxs(K,{variant:"outline",children:[l.jsx(bC,{className:"h-4 w-4 mr-2"}),"Generate New"]})]}),l.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4 mb-8",children:[l.jsx(fe,{children:l.jsx(xe,{className:"p-4",children:l.jsxs("div",{className:"flex items-center gap-3",children:[l.jsx("div",{className:"p-2 rounded-lg bg-primary/10",children:l.jsx(zt,{className:"h-5 w-5 text-primary"})}),l.jsxs("div",{children:[l.jsx("p",{className:"text-2xl font-bold text-foreground",children:"12"}),l.jsx("p",{className:"text-xs text-muted-foreground",children:"Notes this week"})]})]})})}),l.jsx(fe,{children:l.jsx(xe,{className:"p-4",children:l.jsxs("div",{className:"flex items-center gap-3",children:[l.jsx("div",{className:"p-2 rounded-lg bg-success/10",children:l.jsx(Gy,{className:"h-5 w-5 text-success"})}),l.jsxs("div",{children:[l.jsx("p",{className:"text-2xl font-bold text-foreground",children:"8"}),l.jsx("p",{className:"text-xs text-muted-foreground",children:"Lectures attended"})]})]})})}),l.jsx(fe,{children:l.jsx(xe,{className:"p-4",children:l.jsxs("div",{className:"flex items-center gap-3",children:[l.jsx("div",{className:"p-2 rounded-lg bg-warning/10",children:l.jsx(fC,{className:"h-5 w-5 text-warning"})}),l.jsxs("div",{children:[l.jsx("p",{className:"text-2xl font-bold text-foreground",children:"24"}),l.jsx("p",{className:"text-xs text-muted-foreground",children:"Topics covered"})]})]})})})]}),l.jsxs("div",{className:"flex items-center gap-2 mb-6",children:[l.jsxs(ue,{variant:"default",className:"px-3 py-1",children:[pe(s,"MMM d")," - ",pe(Pe(n,1),"MMM d, yyyy")]}),l.jsx("span",{className:"text-sm text-muted-foreground",children:"Last week"})]}),l.jsx("div",{className:"space-y-6",children:e.map(o=>{const i=r(o.classId);return l.jsxs(fe,{className:"overflow-hidden",children:[l.jsx(Nt,{className:"pb-3",children:l.jsxs("div",{className:"flex items-start justify-between",children:[l.jsxs("div",{className:"flex items-center gap-3",children:[l.jsx("div",{className:"h-10 w-10 rounded-lg flex items-center justify-center",style:{backgroundColor:`${i==null?void 0:i.color}20`},children:l.jsx(vt,{className:"h-5 w-5",style:{color:i==null?void 0:i.color}})}),l.jsxs("div",{children:[l.jsxs(Ct,{className:"flex items-center gap-2",children:[i==null?void 0:i.name,l.jsx(ue,{variant:"class",style:{backgroundColor:`${i==null?void 0:i.color}20`,borderColor:`${i==null?void 0:i.color}50`,color:i==null?void 0:i.color},children:i==null?void 0:i.code})]}),l.jsxs(uo,{className:"flex items-center gap-1 mt-1",children:[l.jsx(Sr,{className:"h-3 w-3"}),"Generated ",pe(o.generatedAt,"MMM d, h:mm a")]})]})]}),l.jsx(K,{variant:"ghost",size:"sm",asChild:!0,children:l.jsx(rn,{to:`/classes/${o.classId}`,children:l.jsx(wt,{className:"h-4 w-4"})})})]})}),l.jsxs(xe,{children:[l.jsx("div",{className:"flex flex-wrap gap-2 mb-4",children:o.keyTopics.map(a=>l.jsx(ue,{variant:"secondary",children:a},a))}),l.jsx("div",{className:"prose prose-sm prose-invert max-w-none",children:l.jsx("div",{className:"whitespace-pre-wrap text-sm text-foreground/90 leading-relaxed",children:o.summary})}),l.jsx("div",{className:"mt-4 pt-4 border-t border-border",children:l.jsxs("p",{className:"text-xs text-muted-foreground flex items-center gap-2",children:[l.jsx(zt,{className:"h-3 w-3"}),"Generated from ",o.sourceNoteIds.length," note",o.sourceNoteIds.length!==1&&"s"]})})]})]},o.id)})}),e.length===0&&l.jsx(fe,{className:"border-dashed",children:l.jsxs(xe,{className:"p-12 text-center",children:[l.jsx("div",{className:"mx-auto w-16 h-16 rounded-full bg-secondary flex items-center justify-center mb-4",children:l.jsx(Nr,{className:"h-8 w-8 text-muted-foreground"})}),l.jsx("h3",{className:"text-lg font-semibold text-foreground mb-2",children:"No recaps yet"}),l.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:"Take some notes during your lectures and we'll generate your first weekly recap"}),l.jsx(K,{variant:"outline",children:"Go to Calendar"})]})})]})}var qb="Radio",[qte,CI]=Ft(qb),[Kte,Gte]=qte(qb),jI=m.forwardRef((t,e)=>{const{__scopeRadio:r,name:n,checked:s=!1,required:o,disabled:i,value:a="on",onCheck:c,form:d,...u}=t,[h,f]=m.useState(null),p=we(e,y=>f(y)),g=m.useRef(!1),v=h?d||!!h.closest("form"):!0;return l.jsxs(Kte,{scope:r,checked:s,disabled:i,children:[l.jsx(se.button,{type:"button",role:"radio","aria-checked":s,"data-state":RI(s),"data-disabled":i?"":void 0,disabled:i,value:a,...u,ref:p,onClick:Q(t.onClick,y=>{s||c==null||c(),v&&(g.current=y.isPropagationStopped(),g.current||y.stopPropagation())})}),v&&l.jsx(TI,{control:h,bubbles:!g.current,name:n,value:a,checked:s,required:o,disabled:i,form:d,style:{transform:"translateX(-100%)"}})]})});jI.displayName=qb;var EI="RadioIndicator",_I=m.forwardRef((t,e)=>{const{__scopeRadio:r,forceMount:n,...s}=t,o=Gte(EI,r);return l.jsx(er,{present:n||o.checked,children:l.jsx(se.span,{"data-state":RI(o.checked),"data-disabled":o.disabled?"":void 0,...s,ref:e})})});_I.displayName=EI;var Yte="RadioBubbleInput",TI=m.forwardRef(({__scopeRadio:t,control:e,checked:r,bubbles:n=!0,...s},o)=>{const i=m.useRef(null),a=we(i,o),c=tu(r),d=Jd(e);return m.useEffect(()=>{const u=i.current;if(!u)return;const h=window.HTMLInputElement.prototype,p=Object.getOwnPropertyDescriptor(h,"checked").set;if(c!==r&&p){const g=new Event("click",{bubbles:n});p.call(u,r),u.dispatchEvent(g)}},[c,r,n]),l.jsx(se.input,{type:"radio","aria-hidden":!0,defaultChecked:r,...s,tabIndex:-1,ref:a,style:{...s.style,...d,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});TI.displayName=Yte;function RI(t){return t?"checked":"unchecked"}var Jte=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],ug="RadioGroup",[Qte,Jre]=Ft(ug,[nc,CI]),MI=nc(),OI=CI(),[Xte,Zte]=Qte(ug),PI=m.forwardRef((t,e)=>{const{__scopeRadioGroup:r,name:n,defaultValue:s,value:o,required:i=!1,disabled:a=!1,orientation:c,dir:d,loop:u=!0,onValueChange:h,...f}=t,p=MI(r),g=ha(d),[v,y]=Wn({prop:o,defaultProp:s??null,onChange:h,caller:ug});return l.jsx(Xte,{scope:r,name:n,required:i,disabled:a,value:v,onValueChange:y,children:l.jsx(_w,{asChild:!0,...p,orientation:c,dir:g,loop:u,children:l.jsx(se.div,{role:"radiogroup","aria-required":i,"aria-orientation":c,"data-disabled":a?"":void 0,dir:g,...f,ref:e})})})});PI.displayName=ug;var AI="RadioGroupItem",II=m.forwardRef((t,e)=>{const{__scopeRadioGroup:r,disabled:n,...s}=t,o=Zte(AI,r),i=o.disabled||n,a=MI(r),c=OI(r),d=m.useRef(null),u=we(e,d),h=o.value===s.value,f=m.useRef(!1);return m.useEffect(()=>{const p=v=>{Jte.includes(v.key)&&(f.current=!0)},g=()=>f.current=!1;return document.addEventListener("keydown",p),document.addEventListener("keyup",g),()=>{document.removeEventListener("keydown",p),document.removeEventListener("keyup",g)}},[]),l.jsx(Tw,{asChild:!0,...a,focusable:!i,active:h,children:l.jsx(jI,{disabled:i,required:o.required,checked:h,...c,...s,name:o.name,ref:u,onCheck:()=>o.onValueChange(s.value),onKeyDown:Q(p=>{p.key==="Enter"&&p.preventDefault()}),onFocus:Q(s.onFocus,()=>{var p;f.current&&((p=d.current)==null||p.click())})})})});II.displayName=AI;var ere="RadioGroupIndicator",DI=m.forwardRef((t,e)=>{const{__scopeRadioGroup:r,...n}=t,s=OI(r);return l.jsx(_I,{...s,...n,ref:e})});DI.displayName=ere;var LI=PI,$I=II,tre=DI;const FI=m.forwardRef(({className:t,...e},r)=>l.jsx(LI,{className:B("grid gap-2",t),...e,ref:r}));FI.displayName=LI.displayName;const zI=m.forwardRef(({className:t,...e},r)=>l.jsx($I,{ref:r,className:B("aspect-square h-4 w-4 rounded-full border border-primary text-primary ring-offset-background focus:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",t),...e,children:l.jsx(tre,{className:"flex items-center justify-center",children:l.jsx(Gs,{className:"h-2.5 w-2.5 fill-current text-current"})})}));zI.displayName=$I.displayName;function rre(){const[t,e]=m.useState(()=>{if(typeof window<"u"){const n=localStorage.getItem("forward-theme");return n||"light"}return"light"});return m.useEffect(()=>{const n=document.documentElement;t==="dark"?(n.classList.add("dark"),n.classList.remove("light")):(n.classList.add("light"),n.classList.remove("dark")),localStorage.setItem("forward-theme",t)},[t]),{theme:t,setTheme:e,toggleTheme:()=>{e(n=>n==="dark"?"light":"dark")}}}const BI=[{value:"/",label:"Calendar"},{value:"/dashboard",label:"Dashboard"},{value:"/classes",label:"Classes"},{value:"/todo",label:"To-Do"},{value:"/study-groups",label:"Study Hub"},{value:"/settings",label:"Settings"}],UI="forward-home-page";function nre(){const[t,e]=m.useState("/");return m.useEffect(()=>{const n=localStorage.getItem(UI);n&&BI.some(s=>s.value===n)&&e(n)},[]),{homePage:t,setHomePage:n=>{e(n),localStorage.setItem(UI,n)},homePageOptions:BI}}const Pa={free:100*1024*1024,plus:5*1024*1024*1024,premium:50*1024*1024*1024},VI={plus:{monthly:4.99,yearly:49.99},premium:{monthly:9.99,yearly:99.99}};function Kb(t){if(t===0)return"0 B";const e=1024,r=["B","KB","MB","GB","TB"],n=Math.floor(Math.log(t)/Math.log(e));return parseFloat((t/Math.pow(e,n)).toFixed(2))+" "+r[n]}function Gb(){const[t,e]=m.useState({usedBytes:0,limitBytes:Pa.free,tier:"free",usedPercentage:0,usedFormatted:"0 B",limitFormatted:Kb(Pa.free)}),[r,n]=m.useState(!1),s=m.useCallback(async()=>{e({usedBytes:0,limitBytes:Pa.free,tier:"free",usedPercentage:0,usedFormatted:"0 B",limitFormatted:Kb(Pa.free)}),n(!1)},[]);return m.useEffect(()=>{s()},[s]),{storageInfo:t,loading:r,refetch:s,getTierInfo:i=>({name:i.charAt(0).toUpperCase()+i.slice(1),limit:Pa[i],limitFormatted:Kb(Pa[i]),price:i==="free"?null:VI[i]}),tierLimits:Pa,tierPrices:VI}}function sre({onUpgrade:t}){const{storageInfo:e,loading:r}=Gb();if(r)return l.jsxs(fe,{children:[l.jsx(Nt,{children:l.jsxs(Ct,{className:"flex items-center gap-2",children:[l.jsx(gC,{className:"h-5 w-5 text-primary"}),"Storage"]})}),l.jsx(xe,{children:l.jsxs("div",{className:"animate-pulse space-y-3",children:[l.jsx("div",{className:"h-4 bg-muted rounded w-1/2"}),l.jsx("div",{className:"h-3 bg-muted rounded-full"}),l.jsx("div",{className:"h-4 bg-muted rounded w-1/3"})]})})]});if(!e)return null;const n=e.usedPercentage>=80,s=e.usedPercentage>=95;return l.jsxs(fe,{children:[l.jsxs(Nt,{children:[l.jsxs(Ct,{className:"flex items-center gap-2",children:[l.jsx(gC,{className:"h-5 w-5 text-primary"}),"Storage"]}),l.jsx(uo,{children:"Manage your file storage across notes, recordings, and syllabi"})]}),l.jsxs(xe,{className:"space-y-4",children:[l.jsxs("div",{className:"space-y-2",children:[l.jsxs("div",{className:"flex items-center justify-between text-sm",children:[l.jsxs("span",{className:"text-muted-foreground",children:[e.usedFormatted," of ",e.limitFormatted," used"]}),l.jsxs("span",{className:B("font-medium",s&&"text-destructive",n&&!s&&"text-warning"),children:[e.usedPercentage.toFixed(1),"%"]})]}),l.jsx(ch,{value:e.usedPercentage,className:B("h-3",s&&"[&>div]:bg-destructive",n&&!s&&"[&>div]:bg-warning")})]}),n&&l.jsx("div",{className:B("text-sm p-3 rounded-lg",s?"bg-destructive/10 text-destructive":"bg-warning/10 text-warning"),children:s?"You've almost reached your storage limit. Upgrade to continue uploading.":"You're running low on storage. Consider upgrading for more space."}),e.tier==="free"&&l.jsxs(K,{onClick:t,variant:"outline",className:"w-full border-primary/30 hover:bg-primary/5",children:[l.jsx(Gy,{className:"h-4 w-4 mr-2"}),"Need more storage? Upgrade your plan"]})]})]})}const ore={free:["100 MB storage","Unlimited notes","Basic study guides","Join study groups"],plus:["5 GB storage","Priority AI processing","Advanced study guides","Create study groups","Audio transcription"],premium:["50 GB storage","Unlimited AI features","Export all data","Priority support","Early access to features","Custom themes"]};function ire({isOpen:t,onClose:e}){const{storageInfo:r,getTierInfo:n}=Gb();if(!t)return null;const s=(r==null?void 0:r.tier)||"free",o=a=>{Se.info("Payment integration coming soon! You'll be able to upgrade here.",{description:`Selected: ${a.charAt(0).toUpperCase()+a.slice(1)} plan`,duration:4e3})},i=[{tier:"free",icon:l.jsx(mL,{className:"h-5 w-5"}),color:"text-muted-foreground"},{tier:"plus",icon:l.jsx(Nr,{className:"h-5 w-5"}),color:"text-blue-500"},{tier:"premium",icon:l.jsx(Cl,{className:"h-5 w-5"}),color:"text-amber-500"}];return l.jsxs(fe,{className:"border-primary/20",children:[l.jsx(Nt,{children:l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{children:[l.jsxs(Ct,{className:"flex items-center gap-2",children:[l.jsx(Cl,{className:"h-5 w-5 text-primary"}),"Upgrade Your Plan"]}),l.jsx(uo,{children:"Get more storage and premium features"})]}),l.jsx(K,{variant:"ghost",size:"sm",onClick:e,children:"Close"})]})}),l.jsxs(xe,{children:[l.jsx("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:i.map(({tier:a,icon:c,color:d})=>{const u=n(a),h=a===s,f=a!=="free"&&!h;return l.jsxs("div",{className:B("relative p-4 rounded-xl border transition-all",h?"border-primary bg-primary/5":"border-border hover:border-primary/30 hover:bg-secondary/50"),children:[h&&l.jsx(ue,{className:"absolute -top-2 left-1/2 -translate-x-1/2 bg-primary",children:"Current"}),l.jsxs("div",{className:"text-center mb-4",children:[l.jsx("div",{className:B("inline-flex p-2 rounded-full bg-secondary mb-2",d),children:c}),l.jsx("h3",{className:"font-semibold text-lg",children:u.name}),u.price?l.jsxs("div",{className:"mt-1",children:[l.jsxs("span",{className:"text-2xl font-bold",children:["$",u.price.monthly]}),l.jsx("span",{className:"text-muted-foreground text-sm",children:"/mo"})]}):l.jsx("div",{className:"text-2xl font-bold text-muted-foreground mt-1",children:"Free"})]}),l.jsx("div",{className:"space-y-2 mb-4",children:ore[a].map((p,g)=>l.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[l.jsx(Qi,{className:"h-4 w-4 text-primary shrink-0"}),l.jsx("span",{children:p})]},g))}),f&&l.jsxs(K,{className:"w-full",variant:a==="premium"?"glow":"default",onClick:()=>o(a),children:["Upgrade to ",u.name]}),h&&a!=="premium"&&l.jsx("div",{className:"text-center text-sm text-muted-foreground",children:"Your current plan"})]},a)})}),l.jsx("p",{className:"text-center text-xs text-muted-foreground mt-4",children:"Payment processing will be available soon. Prices may vary based on region."})]})]})}function are(){const{theme:t,toggleTheme:e}=rre(),{focusModeEnabled:r,toggleFocusMode:n}=C_(),{homePage:s,setHomePage:o,homePageOptions:i}=nre(),{storageInfo:a}=Gb(),[c,d]=m.useState(!1);return l.jsxs("div",{className:"max-w-2xl mx-auto space-y-6 p-4 sm:p-6",children:[l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{className:"flex items-center gap-3",children:[l.jsx(co,{}),l.jsxs("div",{children:[l.jsx("h1",{className:"text-2xl font-bold text-foreground",children:"Settings"}),l.jsx("p",{className:"text-muted-foreground mt-1",children:"Manage your account and preferences"})]})]}),a&&l.jsxs(ue,{variant:"outline",className:"gap-1",children:[l.jsx(Cl,{className:"h-3 w-3"}),a.tier.charAt(0).toUpperCase()+a.tier.slice(1)]})]}),l.jsx(sre,{onUpgrade:()=>d(!0)}),l.jsx(ire,{isOpen:c,onClose:()=>d(!1)}),l.jsxs(fe,{children:[l.jsxs(Nt,{children:[l.jsxs(Ct,{className:"flex items-center gap-2",children:[t==="dark"?l.jsx(xC,{className:"h-5 w-5 text-primary"}):l.jsx(dL,{className:"h-5 w-5 text-primary"}),"Appearance"]}),l.jsx(uo,{children:"Customize how Focus looks"})]}),l.jsxs(xe,{className:"space-y-4",children:[l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{className:"space-y-0.5",children:[l.jsx(de,{children:"Dark Mode"}),l.jsx("p",{className:"text-sm text-muted-foreground",children:t==="dark"?"Currently using dark theme":"Currently using light theme"})]}),l.jsx(Ko,{checked:t==="dark",onCheckedChange:e,"aria-label":"Toggle dark mode"})]}),l.jsx(wc,{}),l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{className:"space-y-0.5",children:[l.jsx(de,{children:"Focus Mode"}),l.jsx("p",{className:"text-sm text-muted-foreground",children:"Suppress in-app notifications while studying"})]}),l.jsx(Ko,{checked:r,onCheckedChange:n,"aria-label":"Toggle focus mode"})]}),l.jsx(wc,{}),l.jsxs("div",{className:"space-y-3",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx(K3,{className:"h-4 w-4 text-primary"}),l.jsx(de,{children:"Default Home Page"})]}),l.jsx("p",{className:"text-sm text-muted-foreground",children:"Choose what you see first when you open the app"}),l.jsx(FI,{value:s,onValueChange:u=>o(u),className:"grid grid-cols-2 gap-2",children:i.map(u=>l.jsxs("div",{className:"flex items-center space-x-2",children:[l.jsx(zI,{value:u.value,id:`home-${u.value}`}),l.jsx(de,{htmlFor:`home-${u.value}`,className:"cursor-pointer",children:u.label})]},u.value))})]})]})]})]})}function lre({name:t,image:e,bullets:r,bio:n,role:s}){const[o,i]=m.useState(!1),[a,c]=m.useState(!1);return l.jsx("div",{className:"h-[280px] sm:h-[320px] cursor-pointer [perspective:1000px] touch-manipulation min-h-[280px]",onClick:()=>i(!o),role:"button",tabIndex:0,onKeyDown:d=>(d.key==="Enter"||d.key===" ")&&i(u=>!u),"aria-label":`${t} - ${o?"Tap to flip back":"Tap to learn more"}`,children:l.jsxs("div",{className:"relative h-full w-full transition-transform duration-500",style:{transformStyle:"preserve-3d",transform:o?"rotateY(180deg)":"rotateY(0deg)"},children:[l.jsxs("div",{className:"absolute inset-0 rounded-2xl border border-border overflow-hidden shadow-lg",style:{backfaceVisibility:"hidden"},children:[l.jsx("div",{className:"w-full h-full bg-muted/50 flex items-center justify-center",children:a?l.jsx(pL,{className:"h-24 w-24 text-primary/50"}):l.jsx("img",{src:e,alt:t,className:"w-full h-full object-cover",onError:()=>c(!0)})}),l.jsxs("div",{className:"absolute bottom-0 left-0 right-0 p-4 bg-gradient-to-t from-black/70 to-transparent",children:[l.jsx("p",{className:"text-white font-semibold text-lg",children:t}),s&&l.jsx("p",{className:"text-white/80 text-sm",children:s}),l.jsx("p",{className:"text-white/60 text-xs mt-1",children:"Tap to learn more"})]})]}),l.jsxs("div",{className:"absolute inset-0 rounded-2xl border border-border bg-card p-4 sm:p-6 overflow-y-auto shadow-lg overscroll-contain",style:{backfaceVisibility:"hidden",transform:"rotateY(180deg)"},children:[l.jsx("h3",{className:"font-semibold text-lg text-foreground mb-2",children:t}),s&&l.jsx("p",{className:"text-primary text-sm mb-4",children:s}),l.jsx("ul",{className:"text-muted-foreground text-sm leading-relaxed list-disc list-inside space-y-1 mb-4",children:r.split(` `).map((d,u)=>l.jsx("li",{children:d.replace(/^[•\-]\s*/,"")},u))}),l.jsx("p",{className:"text-muted-foreground text-sm leading-relaxed",children:n}),l.jsx("p",{className:"text-xs text-muted-foreground mt-4",children:"Tap to flip back"})]})]})})}const cre=[{name:"Fredre'Oni (Oni) Terrado",image:"/oni.jpeg",role:"CEO",bullets:`• UNC Chapel Hill • Psychology, Info Science & Entrepreneurship • Morehead-Cain Scholar • Carolina Union Activities Board President • Frohlich Lab research • Shuford Ambassador`,bio:"Growing up as a military child, Oni learned that home is built through connections and community. She's led revitalization projects, supported refugees in Thailand, and contributes to Alzheimer's research. Her work sits at the intersection of entrepreneurship and psychology—helping people find belonging and mental well-being."},{name:"Etornam Agbemabiese",image:"/etornam.jpeg",role:"COO",bullets:`• UNC Chapel Hill • Business Admin & Computer Science • MLT Scholar, VCIC Fellow • Incoming DaVita Redwoods Analyst • STAR Consultant`,bio:"Etornam loves dissecting complex problems and turning data into action. A founding team member of Zellit and VCIC Fellow, he's focused on consulting and venture capital—especially in emerging markets where investing demands strong judgment and contextual intelligence."},{name:"Grace Odondi",image:"/grace.jpeg",role:"CTO",bullets:`• UNC Chapel Hill • CS & Math • Full Stack SWE @ Fidelity • VP Black in Technology • UNC CS Teaching Assistant • ColorStack`,bio:"Grace is committed to making technical education more accessible. As VP of Black in Technology and a CS Teaching Assistant, she helps students build skills and confidence. She brings diverse perspectives to everything she does—from the classroom to the choir."}],dre=[{icon:Sr,title:"Smart Calendar Hub",description:"Sync Google, Outlook & Apple calendars in one unified view."},{icon:vt,title:"Class-Linked Notes",description:"Every note auto-links to its class session. Never lose context."},{icon:Nr,title:"AI Weekly Recaps",description:"Get intelligent summaries of your week to prep for exams."},{icon:jl,title:"Smart To-Dos",description:"Tasks extracted from notes and syllabi, organized by priority."},{icon:$r,title:"Study Groups",description:"Collaborate with classmates and share notes effortlessly."},{icon:Wy,title:"Study Mode",description:"AI-generated flashcards and study guides from your notes."}];function WI(){const t=Zs(),e=()=>{t("/calendar")};return l.jsxs("div",{className:"min-h-screen bg-background overflow-x-hidden",children:[l.jsx("div",{className:"fixed inset-0 bg-[linear-gradient(to_right,hsl(var(--border)/0.03)_1px,transparent_1px),linear-gradient(to_bottom,hsl(var(--border)/0.03)_1px,transparent_1px)] bg-[size:4rem_4rem] pointer-events-none"}),l.jsx("header",{className:"fixed top-0 inset-x-0 z-50 glass safe-top",children:l.jsx("div",{className:"max-w-6xl mx-auto flex items-center justify-between px-4 sm:px-6 h-14 sm:h-16 md:h-[4.5rem]",children:l.jsxs(rn,{to:"/landing",className:"flex items-center gap-2 sm:gap-3 hover:opacity-90 transition-opacity min-h-[44px] py-2",children:[l.jsx("div",{className:"h-8 w-8 sm:h-9 sm:w-9 rounded-xl gradient-primary flex items-center justify-center shadow-lg shadow-primary/20 shrink-0",children:l.jsx("span",{className:"text-base sm:text-lg font-bold text-primary-foreground",children:"F"})}),l.jsx("span",{className:"text-lg sm:text-xl font-semibold text-foreground tracking-tight",children:"Focus"})]})})}),l.jsxs("section",{className:"relative pt-24 sm:pt-28 md:pt-36 pb-16 sm:pb-20 md:pb-28 px-4 sm:px-6",children:[l.jsx("div",{className:"absolute top-24 left-1/2 -translate-x-1/2 w-[300px] sm:w-[500px] md:w-[700px] h-[250px] sm:h-[400px] md:h-[500px] rounded-full bg-primary/15 blur-[80px] sm:blur-[100px] pointer-events-none"}),l.jsx("div",{className:"absolute -top-20 -right-20 w-80 h-80 rounded-full bg-primary/5 blur-[80px] pointer-events-none"}),l.jsx("div",{className:"absolute top-1/2 -left-20 w-60 h-60 rounded-full bg-primary/5 blur-[60px] pointer-events-none"}),l.jsxs("div",{className:"relative max-w-4xl mx-auto text-center space-y-6 sm:space-y-8 md:space-y-10",children:[l.jsxs("div",{className:"inline-flex items-center gap-2 px-3 py-1.5 sm:px-4 sm:py-2 rounded-full bg-primary/10 border border-primary/20 text-primary text-xs sm:text-sm font-medium animate-fade-in shadow-sm",children:[l.jsx(Nr,{className:"h-3.5 w-3.5 sm:h-4 sm:w-4"}),"Built for students who move fast"]}),l.jsxs("h1",{className:"text-3xl sm:text-4xl md:text-5xl lg:text-7xl font-bold tracking-tight text-foreground animate-slide-up leading-[1.15] px-1",children:["Your academic life,"," ",l.jsx("span",{className:"text-gradient",children:"organized."})]}),l.jsx("p",{className:"text-base sm:text-lg md:text-xl text-muted-foreground max-w-2xl mx-auto animate-slide-up leading-relaxed px-4",style:{animationDelay:"0.1s"},children:"Calendar, notes, tasks, and study tools — all linked together. Stop juggling apps and start focusing on what matters."}),l.jsx("div",{className:"flex flex-col sm:flex-row items-center justify-center gap-3 sm:gap-4 animate-slide-up pt-2",style:{animationDelay:"0.2s"},children:l.jsxs(K,{variant:"glow",size:"xl",onClick:e,className:"group btn-glow rounded-xl px-6 sm:px-8 h-12 sm:h-14 text-sm sm:text-base font-semibold w-full sm:w-auto min-h-[48px] touch-manipulation",children:[l.jsx(qy,{className:"h-4 w-4 sm:h-5 sm:w-5"}),"Try the Demo",l.jsx(hC,{className:"h-4 w-4 transition-transform group-hover:translate-x-1"})]})}),l.jsx("p",{className:"text-xs sm:text-sm text-muted-foreground animate-fade-in px-4",style:{animationDelay:"0.3s"},children:"No credit card required · Explore everything before signing up"})]})]}),l.jsx("section",{className:"relative py-16 sm:py-24 md:py-32 px-4 sm:px-6",children:l.jsxs("div",{className:"max-w-6xl mx-auto",children:[l.jsxs("div",{className:"text-center mb-12 sm:mb-16 md:mb-20",children:[l.jsxs("h2",{className:"text-2xl sm:text-3xl md:text-4xl lg:text-5xl font-bold text-foreground mb-3 sm:mb-5 tracking-tight px-2",children:["Everything you need to ",l.jsx("span",{className:"text-gradient",children:"ace your semester"})]}),l.jsx("p",{className:"text-muted-foreground text-base sm:text-lg max-w-xl mx-auto leading-relaxed px-4",children:"One app that connects your calendar, notes, and study tools — so nothing falls through the cracks."})]}),l.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-4 sm:gap-6 lg:gap-8",children:dre.map((r,n)=>l.jsxs("div",{className:"group relative p-5 sm:p-6 md:p-8 rounded-xl sm:rounded-2xl border border-border bg-card/80 backdrop-blur-sm hover:border-primary/25 hover:bg-card transition-all duration-300 hover:shadow-xl hover:shadow-primary/5 hover:-translate-y-0.5 animate-slide-up active:scale-[0.99]",style:{animationDelay:`${n*.06}s`},children:[l.jsx("div",{className:"h-10 w-10 sm:h-12 sm:w-12 rounded-xl bg-primary/10 flex items-center justify-center mb-4 sm:mb-5 group-hover:bg-primary/15 transition-colors group-hover:scale-105",children:l.jsx(r.icon,{className:"h-5 w-5 sm:h-6 sm:w-6 text-primary"})}),l.jsx("h3",{className:"text-lg sm:text-xl font-semibold text-foreground mb-2 sm:mb-3",children:r.title}),l.jsx("p",{className:"text-muted-foreground text-sm sm:text-[15px] leading-relaxed",children:r.description})]},r.title))})]})}),l.jsx("section",{className:"relative py-16 sm:py-24 md:py-32 px-4 sm:px-6",children:l.jsxs("div",{className:"max-w-6xl mx-auto",children:[l.jsxs("div",{className:"text-center mb-10 sm:mb-16",children:[l.jsxs("h2",{className:"text-2xl sm:text-3xl md:text-4xl lg:text-5xl font-bold text-foreground mb-3 sm:mb-5 tracking-tight px-2",children:["Meet the ",l.jsx("span",{className:"text-gradient",children:"founders"})]}),l.jsx("p",{className:"text-muted-foreground text-sm sm:text-base md:text-lg max-w-xl mx-auto leading-relaxed px-4",children:"Tap a card to flip and learn more about each team member."})]}),l.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-6 sm:gap-8 max-w-2xl sm:max-w-none mx-auto sm:mx-0",children:cre.map(r=>l.jsx(lre,{name:r.name,image:r.image,role:r.role,bullets:r.bullets,bio:r.bio},r.name))})]})}),l.jsx("section",{className:"py-16 sm:py-24 md:py-32 px-4 sm:px-6",children:l.jsxs("div",{className:"max-w-3xl mx-auto text-center space-y-6 sm:space-y-8",children:[l.jsxs("h2",{className:"text-2xl sm:text-3xl md:text-4xl lg:text-5xl font-bold text-foreground tracking-tight px-2",children:["Ready to get ",l.jsx("span",{className:"text-gradient",children:"ahead"}),"?"]}),l.jsx("p",{className:"text-base sm:text-lg text-muted-foreground max-w-md mx-auto px-4",children:"Join students who are organizing smarter, not harder."}),l.jsx("div",{className:"flex flex-col sm:flex-row items-center justify-center gap-3 sm:gap-4",children:l.jsxs(K,{variant:"outline",size:"lg",onClick:e,className:"rounded-xl border-2 px-6 sm:px-8 h-12 font-medium hover:bg-primary/5 hover:border-primary/30 w-full sm:w-auto min-h-[48px] touch-manipulation",children:[l.jsx(qy,{className:"h-4 w-4"}),"Explore Demo"]})})]})}),l.jsx("footer",{className:"border-t border-border py-8 sm:py-10 px-4 sm:px-6 bg-card/30 safe-bottom",children:l.jsxs("div",{className:"max-w-6xl mx-auto flex flex-col sm:flex-row items-center justify-between gap-4 text-sm text-muted-foreground text-center sm:text-left",children:[l.jsxs("div",{className:"flex items-center gap-3 justify-center sm:justify-start",children:[l.jsx("div",{className:"h-6 w-6 sm:h-7 sm:w-7 rounded-lg gradient-primary flex items-center justify-center",children:l.jsx("span",{className:"text-xs font-bold text-primary-foreground",children:"F"})}),l.jsx("span",{className:"font-medium text-foreground/80",children:"Focus"})]}),l.jsxs("span",{children:["© ",new Date().getFullYear()," Focus. All rights reserved."]})]})})]})}const ure=()=>{const t=ra();return m.useEffect(()=>{console.error("404 Error: User attempted to access non-existent route:",t.pathname)},[t.pathname]),l.jsx("div",{className:"flex min-h-screen items-center justify-center bg-muted",children:l.jsxs("div",{className:"text-center",children:[l.jsx("h1",{className:"mb-4 text-4xl font-bold",children:"404"}),l.jsx("p",{className:"mb-4 text-xl text-muted-foreground",children:"Oops! Page not found"}),l.jsx("a",{href:"/",className:"text-primary underline hover:text-primary/90",children:"Return to Home"})]})})};class HI extends m.Component{constructor(e){super(e),this.state={hasError:!1,error:null}}static getDerivedStateFromError(e){return{hasError:!0,error:e}}componentDidCatch(e,r){console.error("ErrorBoundary caught:",e,r)}render(){return this.state.hasError&&this.state.error?this.props.fallback?this.props.fallback:l.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",minHeight:"100vh",padding:"2rem",textAlign:"center",fontFamily:"system-ui, sans-serif",backgroundColor:"#f8fafc",color:"#1e293b"},children:[l.jsx("div",{style:{fontSize:"3rem",marginBottom:"1rem"},children:"⚠️"}),l.jsx("h2",{style:{fontSize:"1.25rem",fontWeight:600,marginBottom:"0.5rem"},children:"Something went wrong"}),l.jsx("p",{style:{color:"#64748b",marginBottom:"1.5rem",maxWidth:"28rem"},children:this.state.error.message}),l.jsx("button",{onClick:()=>this.setState({hasError:!1,error:null}),style:{padding:"0.5rem 1rem",borderRadius:"0.5rem",border:"1px solid #cbd5e1",backgroundColor:"white",cursor:"pointer",fontSize:"0.875rem"},children:"Try again"})]}):this.props.children}}const hre=new Tz;function fre(){return m.useEffect(()=>{const e=localStorage.getItem("forward-theme")||"light";document.documentElement.classList.add(e),e==="dark"?document.documentElement.classList.remove("light"):document.documentElement.classList.remove("dark")},[]),null}const pre=()=>l.jsx(HI,{children:l.jsx(Az,{client:hre,children:l.jsxs(hz,{children:[l.jsx(fre,{}),l.jsx(JL,{}),l.jsx(_$,{}),l.jsx(VB,{children:l.jsxs(DB,{children:[l.jsx(zr,{path:"/",element:l.jsx(WI,{})}),l.jsx(zr,{path:"/landing",element:l.jsx(WI,{})}),l.jsxs(zr,{element:l.jsx(HJ,{}),children:[l.jsx(zr,{path:"/calendar",element:l.jsx(iee,{})}),l.jsx(zr,{path:"/dashboard",element:l.jsx(lZ,{})}),l.jsx(zr,{path:"/classes",element:l.jsx(SI,{})}),l.jsx(zr,{path:"/classes/:classId",element:l.jsx(SI,{})}),l.jsx(zr,{path:"/todo",element:l.jsx(Ite,{})}),l.jsx(zr,{path:"/study",element:l.jsx(Dte,{})}),l.jsx(zr,{path:"/study-groups",element:l.jsx(HI,{children:l.jsx(Wte,{})})}),l.jsx(zr,{path:"/recap",element:l.jsx(Hte,{})}),l.jsx(zr,{path:"/settings",element:l.jsx(are,{})})]}),l.jsx(zr,{path:"*",element:l.jsx(ure,{})})]})})]})})}),qI=document.getElementById("root");try{RN(qI).render(l.jsx(pre,{}))}catch(t){const e=t instanceof Error?t.message:String(t);qI.innerHTML=`

Failed to load

${e}

`,console.error("App failed to mount:",t)}})();

Loading Focus...